Файли
openidea/wit/decorations.wit
T
Charlie.Weiтаcharli117 83a3b1208a feat(plugins): hover-card actions and a plugin agent-task API (1.21) (#8221)
Two additive plugin API 1.21 features. decorations.set-actionable puts up to 4 buttons on a plugin decoration's Markdown hover card; each runs one of the plugin's declared commands as if from Find Action (no new capability; undeclared commands fail the call; stale documents don't run). agents.start-task (agents capability, invoking window, trusted project) creates a task that opens in the Agents window with the prompt prefilled and unsent, optionally continuing a recorded session like fork-session. Checked-in components rebuilt; bindings regenerated.

Co-authored-by: charli117 <[email protected]>
2026-12-05 21:17:50 +08:00

84 рядки
4.9 KiB
Plaintext

package openidea:[email protected];
/// Editor and project-tree decorations (API 1.4). Requires project.read. An editor set
/// follows its file: the file's own project, or the nearest one when it is outside them all.
/// Tree sets are rooted in an open project. Sets belong to the plugin and disappear when it stops.
/// Styles: highlight, search, added, modified, removed, warning, error, info,
/// typo, weak, underline, strikethrough, muted. Unknown styles are ignored. Theme tokens only,
/// except for the colors a `set-styled` item gives (API 1.17).
interface decorations {
use types.{error, range, card-action};
/// An editor annotation; after is plain text shown after the range.
record decoration { range: range, style: string, hover: option<string>, after: option<string> }
/// An editor annotation whose hover is rendered as Markdown (API 1.16).
/// `hover` stays the plain-text fallback for hosts that do not render it.
record markdown-decoration {
range: range,
style: string,
hover: option<string>,
after: option<string>,
/// Markdown shown in the editor's hover card while the pointer rests on
/// the range or its after label.
markdown-hover: option<string>,
}
/// Colors of a styled decoration (API 1.17): `#rrggbb`, or `#rrggbbaa` with an alpha
/// (`ff` fully opaque). An absent color keeps the style's own.
record decoration-colors {
foreground: option<string>,
background: option<string>,
}
/// An editor annotation with its own colors (API 1.17). `style` may be empty when
/// `colors` is set: the range then shows only those colors.
record styled-decoration {
range: range,
style: string,
hover: option<string>,
after: option<string>,
markdown-hover: option<string>,
colors: option<decoration-colors>,
}
/// An editor annotation with its own colors and hover-card actions (API 1.21).
/// Like `styled-decoration`, with buttons on the Markdown hover card.
record actionable-decoration {
range: range,
style: string,
hover: option<string>,
after: option<string>,
markdown-hover: option<string>,
colors: option<decoration-colors>,
/// At most 4 actions; each command must be one this plugin declares.
actions: list<card-action>,
}
/// A project-tree annotation; badge is at most two Unicode characters.
record file-decoration { badge: option<string>, style: string, tooltip: option<string> }
/// Replace this set for a file. At most 10,000 items/file and 50 editor sets/plugin.
/// Metadata is bounded to 4 MiB per plugin. Unknown styles are ignored.
set: func(path: string, set-id: string, items: list<decoration>) -> result<_, error>;
/// Like `set`, with each item's Markdown hover rendered as a hover card
/// (API 1.16). Same limits and set-id replacement rules as `set`; `clear`
/// removes a set regardless of which call created it.
set-markdown: func(path: string, set-id: string, items: list<markdown-decoration>) -> result<_, error>;
/// Like `set-markdown`, with each item's own colors (API 1.17): for highlights a plugin
/// assigns, such as one color per marked variable. Colors apply only to the item's range
/// and after label; an invalid color fails the call. Same limits and set-id rules as `set`.
set-styled: func(path: string, set-id: string, items: list<styled-decoration>) -> result<_, error>;
/// Like `set-styled`, with each item's hover-card actions (API 1.21). An action
/// runs this plugin's declared command as if from Find Action and closes the
/// card; an undeclared command fails the call. Same limits and set-id rules as `set`.
set-actionable: func(path: string, set-id: string, items: list<actionable-decoration>) -> result<_, error>;
/// Remove this editor set from every file/project.
clear: func(set-id: string) -> result<_, error>;
/// Replace this set's tree annotation for a file; at most 50 tree sets/plugin.
set-file: func(path: string, set-id: string, item: file-decoration) -> result<_, error>;
/// Remove this tree set from every file/project.
clear-file: func(set-id: string) -> result<_, error>;
/// Replace this set's tree annotation for a file with a note shown after its name (API 1.7):
/// one line of at most 200 characters, with an optional tooltip.
set-file-note: func(path: string, set-id: string, note: string, tooltip: option<string>) -> result<_, error>;
/// Replace this set's tree icon for a file or folder with an id declared under
/// `[[contributes.fileIcons]]` (API 1.8), with an optional tooltip.
set-file-icon: func(path: string, set-id: string, icon: string, tooltip: option<string>) -> result<_, error>;
/// Replace all `(path, icon)` entries of a tree set at once (API 1.8; at most 10,000 entries).
set-file-icons: func(set-id: string, items: list<tuple<string, string>>) -> result<_, error>;
}