@opencode/plugin 0.0.0-dev-554 → 0.0.0-dev-562
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gui/context.d.ts +2 -2
- package/dist/gui/host-apis.d.ts +246 -4
- package/dist/gui/registries.d.ts +124 -2
- package/dist/gui/registries.js +33 -0
- package/package.json +8 -8
package/dist/gui/context.d.ts
CHANGED
|
@@ -177,8 +177,8 @@ export interface Context extends BaseContext {
|
|
|
177
177
|
*/
|
|
178
178
|
readonly embeds: Embeds;
|
|
179
179
|
/**
|
|
180
|
-
* The app's own components: icons, buttons, tooltips, menus, the loading indicator, the dialog frame,
|
|
181
|
-
* text fields, keybind chips, Markdown and
|
|
180
|
+
* The app's own components: icons, buttons, tooltips, menus and menu rows, the loading indicator, the dialog frame,
|
|
181
|
+
* switches, text fields, selects, keybind chips, Markdown, highlighted code, and settings pages, sections and rows.
|
|
182
182
|
*
|
|
183
183
|
* @example
|
|
184
184
|
* ```tsx
|
package/dist/gui/host-apis.d.ts
CHANGED
|
@@ -839,6 +839,26 @@ export interface Layout {
|
|
|
839
839
|
* ```
|
|
840
840
|
*/
|
|
841
841
|
menu(): readonly SessionPanelMenuItem[];
|
|
842
|
+
/**
|
|
843
|
+
* The side region width the user dragged to, or `resize` stored, while one of your panel's tabs shows; undefined
|
|
844
|
+
* when none is stored, as before the app interface mounts. Reactive.
|
|
845
|
+
*
|
|
846
|
+
* @param panel - Your `Panel`'s id.
|
|
847
|
+
*/
|
|
848
|
+
width(panel: string): number | undefined;
|
|
849
|
+
/**
|
|
850
|
+
* Stores the side region width for your panel, as a drag on one of its tabs does; it applies while the side pane
|
|
851
|
+
* shows one of the panel's tabs, and the user's next drag replaces it. Waits until the app interface mounts.
|
|
852
|
+
*
|
|
853
|
+
* @param panel - Your `Panel`'s id.
|
|
854
|
+
* @param width - CSS pixels. The host keeps the conversation at its minimum width and the region at its own.
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* ```ts
|
|
858
|
+
* ctx.layout.side.resize("quota", 360)
|
|
859
|
+
* ```
|
|
860
|
+
*/
|
|
861
|
+
resize(panel: string, width: number): void;
|
|
842
862
|
};
|
|
843
863
|
/**
|
|
844
864
|
* The inner sidebar preference every side panel shares, which `usePanel().sidebar` also reads inside a panel render.
|
|
@@ -1643,7 +1663,7 @@ export interface UiTooltipProps {
|
|
|
1643
1663
|
/** The element that shows the tooltip while the pointer rests on it or it has keyboard focus. */
|
|
1644
1664
|
readonly children: JSX.Element;
|
|
1645
1665
|
}
|
|
1646
|
-
/** An action in `UiMenuProps.items`. */
|
|
1666
|
+
/** An action in `UiMenuProps.items`, and the props of `Ui.MenuItem`. */
|
|
1647
1667
|
export interface UiMenuItem {
|
|
1648
1668
|
/** Marks the entry as an action. Optional: an entry without `type` is an action. */
|
|
1649
1669
|
readonly type?: "item";
|
|
@@ -1693,6 +1713,26 @@ export interface UiMenuProps {
|
|
|
1693
1713
|
/** The trigger cannot open the menu. Defaults to false. */
|
|
1694
1714
|
readonly disabled?: boolean;
|
|
1695
1715
|
}
|
|
1716
|
+
/** Props of `Ui.MenuGroup`. */
|
|
1717
|
+
export interface UiMenuGroupProps {
|
|
1718
|
+
/** The group's heading. Pass translated copy. */
|
|
1719
|
+
readonly label: string;
|
|
1720
|
+
/** The group's rows, such as `Ui.MenuItem` and `Ui.MenuSub`. */
|
|
1721
|
+
readonly children: JSX.Element;
|
|
1722
|
+
}
|
|
1723
|
+
/** Props of `Ui.MenuSub`. */
|
|
1724
|
+
export interface UiMenuSubProps {
|
|
1725
|
+
/** The text of the row that opens the submenu, which also names the submenu for screen readers. */
|
|
1726
|
+
readonly label: string;
|
|
1727
|
+
/** An icon before the text. Omit it for none. */
|
|
1728
|
+
readonly icon?: IconName;
|
|
1729
|
+
/** The row cannot open the submenu. Defaults to false. */
|
|
1730
|
+
readonly disabled?: boolean;
|
|
1731
|
+
/** Runs with true when the submenu opens and false when it closes, for example to load its rows only while open. */
|
|
1732
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
1733
|
+
/** The submenu's rows, such as `Ui.MenuItem`, `Ui.MenuSeparator` and `Ui.MenuGroup`. */
|
|
1734
|
+
readonly children: JSX.Element;
|
|
1735
|
+
}
|
|
1696
1736
|
/** Props of `Ui.Loader`. */
|
|
1697
1737
|
export interface UiLoaderProps {
|
|
1698
1738
|
/**
|
|
@@ -1806,6 +1846,74 @@ export interface UiCodeProps {
|
|
|
1806
1846
|
/** Classes of the code block, for layout. */
|
|
1807
1847
|
readonly class?: string;
|
|
1808
1848
|
}
|
|
1849
|
+
/** One choice in `UiSelectProps.options`. */
|
|
1850
|
+
export interface UiSelectOption<T extends string = string> {
|
|
1851
|
+
/** The value `onChange` receives. Unique among the options. */
|
|
1852
|
+
readonly value: T;
|
|
1853
|
+
/** The choice's text, in the list and on the closed select. Pass translated copy. */
|
|
1854
|
+
readonly label: string;
|
|
1855
|
+
}
|
|
1856
|
+
/** Props of `Ui.Select`. */
|
|
1857
|
+
export interface UiSelectProps<T extends string = string> {
|
|
1858
|
+
/** The choices, in order. */
|
|
1859
|
+
readonly options: readonly UiSelectOption<T>[];
|
|
1860
|
+
/** The selected choice's value. Undefined, or a value no option has, shows `placeholder`. */
|
|
1861
|
+
readonly value: T | undefined;
|
|
1862
|
+
/**
|
|
1863
|
+
* Runs with the value the user picks. Pass it on to `value` to keep the select in step. Picking the selected choice
|
|
1864
|
+
* again does not call it.
|
|
1865
|
+
*/
|
|
1866
|
+
readonly onChange: (value: T) => void;
|
|
1867
|
+
/** The select's accessible name, which screen readers announce. Pass translated copy; it is not shown. */
|
|
1868
|
+
readonly label: string;
|
|
1869
|
+
/** Text the select shows while no choice is selected. Omit it for none. */
|
|
1870
|
+
readonly placeholder?: string;
|
|
1871
|
+
/** The select cannot be opened. Defaults to false. */
|
|
1872
|
+
readonly disabled?: boolean;
|
|
1873
|
+
/** Shows the select as invalid. Defaults to false. */
|
|
1874
|
+
readonly invalid?: boolean;
|
|
1875
|
+
/**
|
|
1876
|
+
* Where the list opens from the select. Defaults to `bottom-end`, as the app's settings rows open theirs; it flips
|
|
1877
|
+
* when there is no room.
|
|
1878
|
+
*/
|
|
1879
|
+
readonly placement?: "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
1880
|
+
/** Classes of the select, for layout. The app's styles give it its look. */
|
|
1881
|
+
readonly class?: string;
|
|
1882
|
+
}
|
|
1883
|
+
/** Props of `Ui.SettingsLayout`. */
|
|
1884
|
+
export interface UiSettingsLayoutProps {
|
|
1885
|
+
/** The page's title, at the top of the page. Pass translated copy, usually the `SettingsPage.title`. */
|
|
1886
|
+
readonly title: string;
|
|
1887
|
+
/** Text under the title. Omit it for none. */
|
|
1888
|
+
readonly description?: string;
|
|
1889
|
+
/** Controls at the end of the title row, such as a `Ui.Button` that opens a website. Omit it for none. */
|
|
1890
|
+
readonly actions?: JSX.Element;
|
|
1891
|
+
/** The page's sections, usually `Ui.SettingsSection`s. */
|
|
1892
|
+
readonly children: JSX.Element;
|
|
1893
|
+
}
|
|
1894
|
+
/** Props of `Ui.SettingsSection`. */
|
|
1895
|
+
export interface UiSettingsSectionProps {
|
|
1896
|
+
/** The section's heading, which also names it for screen readers. Omit it for a section without a heading. */
|
|
1897
|
+
readonly title?: string;
|
|
1898
|
+
/** The section's rows, usually `Ui.SettingsRow`s, in the app's bordered list. */
|
|
1899
|
+
readonly children: JSX.Element;
|
|
1900
|
+
/** Content under the list, outside its border, such as an error that concerns the rows. Omit it for none. */
|
|
1901
|
+
readonly footer?: JSX.Element;
|
|
1902
|
+
}
|
|
1903
|
+
/** Props of `Ui.SettingsRow`. */
|
|
1904
|
+
export interface UiSettingsRowProps {
|
|
1905
|
+
/** The setting's name. Pass translated copy. */
|
|
1906
|
+
readonly title: JSX.Element;
|
|
1907
|
+
/** Text under the title that says what the setting does. Omit it for none. */
|
|
1908
|
+
readonly description?: JSX.Element;
|
|
1909
|
+
/**
|
|
1910
|
+
* The `SettingEntry.id` that reveals this row: when the user picks the entry in settings search, the host scrolls
|
|
1911
|
+
* to the row and highlights it. Omit it for a row that search does not list.
|
|
1912
|
+
*/
|
|
1913
|
+
readonly id?: string;
|
|
1914
|
+
/** The row's control at its end, such as a `Ui.Switch`, `Ui.Select` or `Ui.Button`. Omit it for none. */
|
|
1915
|
+
readonly children?: JSX.Element;
|
|
1916
|
+
}
|
|
1809
1917
|
/**
|
|
1810
1918
|
* The app's own components, so a plugin's UI looks and behaves like the app's: the same buttons, menus, dialogs and
|
|
1811
1919
|
* fields, in the user's theme, fonts and language. Each takes a small set of props the SDK keeps stable. A component
|
|
@@ -1869,6 +1977,64 @@ export interface Ui {
|
|
|
1869
1977
|
* ```
|
|
1870
1978
|
*/
|
|
1871
1979
|
Menu(props: UiMenuProps): JSX.Element;
|
|
1980
|
+
/**
|
|
1981
|
+
* One action row of a menu the host renders, such as the `session.location.menu` slot, so your rows look and
|
|
1982
|
+
* behave like the host's: keyboard navigation, the muted icon, shortcut chips, and the menu closing on a pick. It
|
|
1983
|
+
* also renders inside `Ui.MenuGroup` and `Ui.MenuSub`. It takes the fields of an entry of `UiMenuProps.items`.
|
|
1984
|
+
* Outside a menu it throws, so the host records the error and the contribution renders nothing.
|
|
1985
|
+
*
|
|
1986
|
+
* @param props - The row's text, icon, keys and action.
|
|
1987
|
+
*
|
|
1988
|
+
* @example
|
|
1989
|
+
* ```tsx
|
|
1990
|
+
* ctx.add(Slot, {
|
|
1991
|
+
* at: "session.location.menu",
|
|
1992
|
+
* render: (input) => <ctx.ui.MenuItem label={ctx.t("usage")} icon="status" onSelect={() => open(input.session)} />,
|
|
1993
|
+
* })
|
|
1994
|
+
* ```
|
|
1995
|
+
*/
|
|
1996
|
+
MenuItem(props: UiMenuItem): JSX.Element;
|
|
1997
|
+
/**
|
|
1998
|
+
* A line between rows of a menu the host renders, or of a `Ui.MenuSub`, with the menu's spacing and color.
|
|
1999
|
+
*
|
|
2000
|
+
* @example
|
|
2001
|
+
* ```tsx
|
|
2002
|
+
* <>
|
|
2003
|
+
* <ctx.ui.MenuSeparator />
|
|
2004
|
+
* <ctx.ui.MenuItem label={ctx.t("usage")} onSelect={open} />
|
|
2005
|
+
* </>
|
|
2006
|
+
* ```
|
|
2007
|
+
*/
|
|
2008
|
+
MenuSeparator(): JSX.Element;
|
|
2009
|
+
/**
|
|
2010
|
+
* Rows of a menu the host renders under a heading, as `UiMenuGroup` groups the entries of `Ui.Menu`. Outside a menu
|
|
2011
|
+
* it throws, as `Ui.MenuItem` does.
|
|
2012
|
+
*
|
|
2013
|
+
* @param props - The heading and its rows.
|
|
2014
|
+
*
|
|
2015
|
+
* @example
|
|
2016
|
+
* ```tsx
|
|
2017
|
+
* <ctx.ui.MenuGroup label={ctx.t("usage")}>
|
|
2018
|
+
* <ctx.ui.MenuItem label={ctx.t("today")} onSelect={() => open("today")} />
|
|
2019
|
+
* <ctx.ui.MenuItem label={ctx.t("month")} onSelect={() => open("month")} />
|
|
2020
|
+
* </ctx.ui.MenuGroup>
|
|
2021
|
+
* ```
|
|
2022
|
+
*/
|
|
2023
|
+
MenuGroup(props: UiMenuGroupProps): JSX.Element;
|
|
2024
|
+
/**
|
|
2025
|
+
* A row of a menu the host renders that opens a submenu beside it, with the host's chevron, as the location menu's
|
|
2026
|
+
* branch and folder rows do. Outside a menu it throws, as `Ui.MenuItem` does.
|
|
2027
|
+
*
|
|
2028
|
+
* @param props - The row's text and icon, and the submenu's rows.
|
|
2029
|
+
*
|
|
2030
|
+
* @example
|
|
2031
|
+
* ```tsx
|
|
2032
|
+
* <ctx.ui.MenuSub label={ctx.t("openIn")} icon="outline-share">
|
|
2033
|
+
* <For each={apps()}>{(app) => <ctx.ui.MenuItem label={app.name} onSelect={() => launch(app)} />}</For>
|
|
2034
|
+
* </ctx.ui.MenuSub>
|
|
2035
|
+
* ```
|
|
2036
|
+
*/
|
|
2037
|
+
MenuSub(props: UiMenuSubProps): JSX.Element;
|
|
1872
2038
|
/**
|
|
1873
2039
|
* The app's loading indicator, for anything that loads, connects or runs that is not the AI working.
|
|
1874
2040
|
*
|
|
@@ -1918,6 +2084,26 @@ export interface Ui {
|
|
|
1918
2084
|
* ```
|
|
1919
2085
|
*/
|
|
1920
2086
|
TextInput(props: UiTextInputProps): JSX.Element;
|
|
2087
|
+
/**
|
|
2088
|
+
* A select that opens a list of choices, as the app's settings rows pick a language or a width. The value is a
|
|
2089
|
+
* string; `T` narrows it to your choices' values.
|
|
2090
|
+
*
|
|
2091
|
+
* @param props - The choices, the selected value and its handler.
|
|
2092
|
+
*
|
|
2093
|
+
* @example
|
|
2094
|
+
* ```tsx
|
|
2095
|
+
* <ctx.ui.Select
|
|
2096
|
+
* label={ctx.t("period")}
|
|
2097
|
+
* options={[
|
|
2098
|
+
* { value: "day", label: ctx.t("period.day") },
|
|
2099
|
+
* { value: "month", label: ctx.t("period.month") },
|
|
2100
|
+
* ]}
|
|
2101
|
+
* value={period()}
|
|
2102
|
+
* onChange={setPeriod}
|
|
2103
|
+
* />
|
|
2104
|
+
* ```
|
|
2105
|
+
*/
|
|
2106
|
+
Select<T extends string>(props: UiSelectProps<T>): JSX.Element;
|
|
1921
2107
|
/**
|
|
1922
2108
|
* Keys shown as chips, as menus and tooltips show shortcuts.
|
|
1923
2109
|
*
|
|
@@ -1932,7 +2118,8 @@ export interface Ui {
|
|
|
1932
2118
|
/**
|
|
1933
2119
|
* Markdown rendered as the timeline renders a message: headings, lists, tables, links, math and highlighted code
|
|
1934
2120
|
* blocks with a copy button. On the session screen, links to local files open through the LinkHandler
|
|
1935
|
-
* contributions,
|
|
2121
|
+
* contributions, and fenced code blocks show `CodeBlock` and `CodeBlockAction` contributions, as the timeline's do;
|
|
2122
|
+
* inside a `CodeBlock` render they do not. Rendering is asynchronous: the block fills in shortly after it mounts.
|
|
1936
2123
|
*
|
|
1937
2124
|
* @param props - The Markdown source.
|
|
1938
2125
|
*
|
|
@@ -1943,8 +2130,9 @@ export interface Ui {
|
|
|
1943
2130
|
*/
|
|
1944
2131
|
Markdown(props: UiMarkdownProps): JSX.Element;
|
|
1945
2132
|
/**
|
|
1946
|
-
* A read-only code block, highlighted as the timeline highlights code, with a copy button.
|
|
1947
|
-
*
|
|
2133
|
+
* A read-only code block, highlighted as the timeline highlights code, with a copy button. It always shows the code:
|
|
2134
|
+
* `CodeBlock` and `CodeBlockAction` contributions do not apply, so a `CodeBlock` render can show its source through
|
|
2135
|
+
* it. Highlighting is asynchronous: the block fills in shortly after it mounts.
|
|
1948
2136
|
*
|
|
1949
2137
|
* @param props - The code and its language.
|
|
1950
2138
|
*
|
|
@@ -1954,4 +2142,58 @@ export interface Ui {
|
|
|
1954
2142
|
* ```
|
|
1955
2143
|
*/
|
|
1956
2144
|
Code(props: UiCodeProps): JSX.Element;
|
|
2145
|
+
/**
|
|
2146
|
+
* The frame of a settings page of your own (a `SettingsPage` without `page`): the app's page header with the title,
|
|
2147
|
+
* then your sections, spaced as the app's pages are. Search that reveals the page itself highlights its header. The
|
|
2148
|
+
* settings components take their look from the Settings screen's styles, so render them from a `SettingsPage`.
|
|
2149
|
+
*
|
|
2150
|
+
* @param props - The page's title, header actions and sections.
|
|
2151
|
+
*
|
|
2152
|
+
* @example
|
|
2153
|
+
* ```tsx
|
|
2154
|
+
* ctx.add(SettingsPage, {
|
|
2155
|
+
* id: "acme",
|
|
2156
|
+
* get title() {
|
|
2157
|
+
* return ctx.t("title")
|
|
2158
|
+
* },
|
|
2159
|
+
* render: () => (
|
|
2160
|
+
* <ctx.ui.SettingsLayout title={ctx.t("title")} description={ctx.t("description")}>
|
|
2161
|
+
* <ctx.ui.SettingsSection title={ctx.t("sync")}>{rows()}</ctx.ui.SettingsSection>
|
|
2162
|
+
* </ctx.ui.SettingsLayout>
|
|
2163
|
+
* ),
|
|
2164
|
+
* })
|
|
2165
|
+
* ```
|
|
2166
|
+
*/
|
|
2167
|
+
SettingsLayout(props: UiSettingsLayoutProps): JSX.Element;
|
|
2168
|
+
/**
|
|
2169
|
+
* A section of settings rows: an optional heading over the app's bordered list. Render it in `SettingsLayout`, or on
|
|
2170
|
+
* its own as a section on a host page (`SettingsPage.page`).
|
|
2171
|
+
*
|
|
2172
|
+
* @param props - The heading and rows.
|
|
2173
|
+
*
|
|
2174
|
+
* @example
|
|
2175
|
+
* ```tsx
|
|
2176
|
+
* <ctx.ui.SettingsSection title={ctx.t("sync")}>
|
|
2177
|
+
* <ctx.ui.SettingsRow id="acme-sync" title={ctx.t("sync")} description={ctx.t("sync.description")}>
|
|
2178
|
+
* <ctx.ui.Switch label={ctx.t("sync")} hideLabel checked={sync()} onChange={setSync} />
|
|
2179
|
+
* </ctx.ui.SettingsRow>
|
|
2180
|
+
* </ctx.ui.SettingsSection>
|
|
2181
|
+
* ```
|
|
2182
|
+
*/
|
|
2183
|
+
SettingsSection(props: UiSettingsSectionProps): JSX.Element;
|
|
2184
|
+
/**
|
|
2185
|
+
* One setting, as the app's own settings rows show it: its title and description, and its control at the end. Render
|
|
2186
|
+
* it in a `SettingsSection`, or on its own as rows in a host section (`SettingsPage.section`), where it lines up
|
|
2187
|
+
* with the host's rows.
|
|
2188
|
+
*
|
|
2189
|
+
* @param props - The setting's text, search id and control.
|
|
2190
|
+
*
|
|
2191
|
+
* @example
|
|
2192
|
+
* ```tsx
|
|
2193
|
+
* <ctx.ui.SettingsRow id="acme-sync" title={ctx.t("sync")} description={ctx.t("sync.description")}>
|
|
2194
|
+
* <ctx.ui.Switch label={ctx.t("sync")} hideLabel checked={sync()} onChange={setSync} />
|
|
2195
|
+
* </ctx.ui.SettingsRow>
|
|
2196
|
+
* ```
|
|
2197
|
+
*/
|
|
2198
|
+
SettingsRow(props: UiSettingsRowProps): JSX.Element;
|
|
1957
2199
|
}
|
package/dist/gui/registries.d.ts
CHANGED
|
@@ -254,6 +254,16 @@ export interface Panel {
|
|
|
254
254
|
readonly region: "side";
|
|
255
255
|
/** Asks for the wider session minimum while the side region is open. Reactive. */
|
|
256
256
|
readonly wide?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Gives the panel a side region width of its own, for content that wants less room or more than other tabs. While the
|
|
259
|
+
* side pane shows one of the panel's tabs, the region takes the width the user last dragged it to on this panel,
|
|
260
|
+
* app-wide, else this one; other tabs keep the conversation's width. The host keeps the conversation at its minimum
|
|
261
|
+
* width and the region at least `narrow`. Omit it to share the conversation's width, unless `Layout.side.resize`
|
|
262
|
+
* stored one for the panel.
|
|
263
|
+
* - A number: CSS pixels.
|
|
264
|
+
* - `narrow`: the narrowest the region goes.
|
|
265
|
+
*/
|
|
266
|
+
readonly width?: number | "narrow";
|
|
257
267
|
/** Tabs are not restored: stored keys this panel stops listing leave the strip. See also `PanelTab.transient`. */
|
|
258
268
|
readonly transient?: boolean;
|
|
259
269
|
/**
|
|
@@ -387,7 +397,8 @@ export interface SettingsPage {
|
|
|
387
397
|
/** Search metadata, indexed without mounting the page. */
|
|
388
398
|
readonly entries?: readonly SettingEntry[];
|
|
389
399
|
/**
|
|
390
|
-
* Renders the page, section or rows.
|
|
400
|
+
* Renders the page, section or rows: `Ui.SettingsLayout` frames a page, `Ui.SettingsSection` a section, and
|
|
401
|
+
* `Ui.SettingsRow` is one row, each as the app's own settings render them.
|
|
391
402
|
*
|
|
392
403
|
* @param input - `target` is the entry search is revealing.
|
|
393
404
|
*/
|
|
@@ -642,6 +653,81 @@ export interface ComposerPill {
|
|
|
642
653
|
*/
|
|
643
654
|
menu?(input: ComposerPillMenuProps): JSX.Element;
|
|
644
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* One complete fenced code block, as a `CodeBlock` render and a `CodeBlockAction` receive it. Do not destructure:
|
|
658
|
+
* `session` is a getter.
|
|
659
|
+
*/
|
|
660
|
+
export interface CodeBlockProps {
|
|
661
|
+
/** The source between the fences, without the final line break. */
|
|
662
|
+
readonly code: string;
|
|
663
|
+
/**
|
|
664
|
+
* The fence's language: the first word of its info string, lowercased, without characters other than letters, digits
|
|
665
|
+
* and `_ # + . -`. For ```` ```Mermaid title="Flow" ```` it is `mermaid`; empty for a fence without one.
|
|
666
|
+
*/
|
|
667
|
+
readonly language: string;
|
|
668
|
+
/**
|
|
669
|
+
* The routed session of the screen that shows the block; a new object when another session is routed. Undefined for
|
|
670
|
+
* Markdown outside a session screen, where the host does not offer code block content today.
|
|
671
|
+
*/
|
|
672
|
+
readonly session?: MountedSession;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Renders the fenced code blocks of some languages as your own UI in place of the highlighted code, for example a
|
|
676
|
+
* diagram for ```` ```mermaid ```` or a table for ```` ```csv ````. Applies to Markdown on the session screen: the
|
|
677
|
+
* timeline (assistant text and tool output), side panels such as the file viewer's Markdown preview, and `ctx.ui.Markdown`
|
|
678
|
+
* rendered there. `ctx.ui.Code`, and Markdown your own render shows, keep the plain code, so a render never meets
|
|
679
|
+
* itself.
|
|
680
|
+
*
|
|
681
|
+
* The host renders a block only once its closing fence arrives: while it streams, and in a message that stopped
|
|
682
|
+
* mid-block, the user sees the highlighted code, then your UI replaces it in place. Blocks of other languages cost
|
|
683
|
+
* nothing. The block keeps its Copy button and `CodeBlockAction` buttons over the top end corner of your UI, and its
|
|
684
|
+
* height follows your UI as it grows; reserve the height you know (for example a minimum) so the timeline shifts less
|
|
685
|
+
* when asynchronous content arrives.
|
|
686
|
+
*/
|
|
687
|
+
export interface CodeBlock {
|
|
688
|
+
/**
|
|
689
|
+
* The languages whose blocks you render, compared with `CodeBlockProps.language`, e.g. `["csv", "tsv"]`. The host
|
|
690
|
+
* resolves no aliases: list each name you accept. When several contributions list a language, the first contributed
|
|
691
|
+
* renders it.
|
|
692
|
+
*/
|
|
693
|
+
readonly languages: readonly string[];
|
|
694
|
+
/**
|
|
695
|
+
* Renders one block once, under your plugin's context; its own reactivity updates it, also when another session is
|
|
696
|
+
* routed. Return `undefined` or `null` to keep the highlighted code, e.g. for a source you cannot parse. A render that
|
|
697
|
+
* throws records the error under your plugin and the block shows its code; the plugin keeps running. The host
|
|
698
|
+
* renders it again only when the block or the set of contributions changes.
|
|
699
|
+
*
|
|
700
|
+
* @param props - The block and its session. Do not destructure.
|
|
701
|
+
* @returns Your UI for the block, or `undefined` or `null` to keep the code.
|
|
702
|
+
*/
|
|
703
|
+
render(props: CodeBlockProps): JSX.Element | undefined;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* A button beside the Copy button of the fenced code blocks of some languages, for example "Run in terminal" for
|
|
707
|
+
* ```` ```sh ````. It shows where `CodeBlock` content shows, once the block's closing fence arrives, so it never acts on
|
|
708
|
+
* half a block. Buttons reveal with Copy on hover or focus.
|
|
709
|
+
*/
|
|
710
|
+
export interface CodeBlockAction {
|
|
711
|
+
/** The action's id, unique within the plugin. */
|
|
712
|
+
readonly id: string;
|
|
713
|
+
/**
|
|
714
|
+
* The languages whose blocks show the button, compared with `CodeBlockProps.language`, e.g. `["sh", "bash", "shell"]`.
|
|
715
|
+
* The host resolves no aliases: list each name you accept.
|
|
716
|
+
*/
|
|
717
|
+
readonly languages: readonly string[];
|
|
718
|
+
/** The button's icon. */
|
|
719
|
+
readonly icon: IconName;
|
|
720
|
+
/** The button's accessible name and tooltip. Read it from a getter so it follows the locale. */
|
|
721
|
+
readonly title: string;
|
|
722
|
+
/** Buttons list in ascending order, before Copy. Defaults to 0; ties keep contribution order. */
|
|
723
|
+
readonly order?: number;
|
|
724
|
+
/**
|
|
725
|
+
* Runs when the user clicks the button. A throw or a rejection is logged under your plugin and changes nothing else.
|
|
726
|
+
*
|
|
727
|
+
* @param input - The clicked block and its session. Do not destructure.
|
|
728
|
+
*/
|
|
729
|
+
run(input: CodeBlockProps): void | Promise<void>;
|
|
730
|
+
}
|
|
645
731
|
/**
|
|
646
732
|
* The seed colors a theme variant generates its scales from. Each is a hex color: `#rgb`, `#rgba`, `#rrggbb` or
|
|
647
733
|
* `#rrggbbaa`.
|
|
@@ -751,7 +837,10 @@ export interface SlotMap {
|
|
|
751
837
|
*/
|
|
752
838
|
readonly compact: boolean;
|
|
753
839
|
};
|
|
754
|
-
/**
|
|
840
|
+
/**
|
|
841
|
+
* Items in the project/location menu, after its location details. Omitted on loading headers without a screen.
|
|
842
|
+
* Render rows with `Ui.MenuItem`, `Ui.MenuSub`, `Ui.MenuGroup` and `Ui.MenuSeparator`, so they match the host's.
|
|
843
|
+
*/
|
|
755
844
|
readonly "session.location.menu": {
|
|
756
845
|
/** The menu's owning session screen; always present. */
|
|
757
846
|
readonly screen: SessionScreen;
|
|
@@ -876,6 +965,39 @@ export declare const TitlebarItem: Registry<TitlebarItem>;
|
|
|
876
965
|
* ```
|
|
877
966
|
*/
|
|
878
967
|
export declare const ComposerPill: Registry<ComposerPill>;
|
|
968
|
+
/**
|
|
969
|
+
* The registry of renderers for fenced code blocks, by language.
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* ```tsx
|
|
973
|
+
* ctx.add(CodeBlock, {
|
|
974
|
+
* languages: ["csv"],
|
|
975
|
+
* render: (props) => {
|
|
976
|
+
* const rows = parseCsv(props.code)
|
|
977
|
+
*
|
|
978
|
+
* return rows ? <CsvTable rows={rows} /> : undefined
|
|
979
|
+
* },
|
|
980
|
+
* })
|
|
981
|
+
* ```
|
|
982
|
+
*/
|
|
983
|
+
export declare const CodeBlock: Registry<CodeBlock>;
|
|
984
|
+
/**
|
|
985
|
+
* The registry of buttons beside a fenced code block's Copy button, by language.
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```ts
|
|
989
|
+
* ctx.add(CodeBlockAction, {
|
|
990
|
+
* id: "run",
|
|
991
|
+
* languages: ["sh", "bash", "shell"],
|
|
992
|
+
* icon: "terminal",
|
|
993
|
+
* get title() {
|
|
994
|
+
* return ctx.t("run")
|
|
995
|
+
* },
|
|
996
|
+
* run: (input) => runInTerminal(input.code, input.session),
|
|
997
|
+
* })
|
|
998
|
+
* ```
|
|
999
|
+
*/
|
|
1000
|
+
export declare const CodeBlockAction: Registry<CodeBlockAction>;
|
|
879
1001
|
/**
|
|
880
1002
|
* The registry of content for the host's slots (`SlotMap`).
|
|
881
1003
|
*
|
package/dist/gui/registries.js
CHANGED
|
@@ -89,6 +89,39 @@ export const TitlebarItem = Registry.define("titlebar-item");
|
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
91
|
export const ComposerPill = Registry.define("composer-pill");
|
|
92
|
+
/**
|
|
93
|
+
* The registry of renderers for fenced code blocks, by language.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* ctx.add(CodeBlock, {
|
|
98
|
+
* languages: ["csv"],
|
|
99
|
+
* render: (props) => {
|
|
100
|
+
* const rows = parseCsv(props.code)
|
|
101
|
+
*
|
|
102
|
+
* return rows ? <CsvTable rows={rows} /> : undefined
|
|
103
|
+
* },
|
|
104
|
+
* })
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export const CodeBlock = Registry.define("code-block");
|
|
108
|
+
/**
|
|
109
|
+
* The registry of buttons beside a fenced code block's Copy button, by language.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* ctx.add(CodeBlockAction, {
|
|
114
|
+
* id: "run",
|
|
115
|
+
* languages: ["sh", "bash", "shell"],
|
|
116
|
+
* icon: "terminal",
|
|
117
|
+
* get title() {
|
|
118
|
+
* return ctx.t("run")
|
|
119
|
+
* },
|
|
120
|
+
* run: (input) => runInTerminal(input.code, input.session),
|
|
121
|
+
* })
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export const CodeBlockAction = Registry.define("code-block-action");
|
|
92
125
|
/**
|
|
93
126
|
* The registry of content for the host's slots (`SlotMap`).
|
|
94
127
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/plugin",
|
|
4
|
-
"version": "0.0.0-dev-
|
|
4
|
+
"version": "0.0.0-dev-562",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -78,15 +78,15 @@
|
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@ai-sdk/provider": "3.0.8",
|
|
81
|
-
"@opencode/ai": "0.0.0-dev-
|
|
82
|
-
"@opencode/client": "0.0.0-dev-
|
|
83
|
-
"@opencode/protocol": "0.0.0-dev-
|
|
84
|
-
"@opencode/schema": "0.0.0-dev-
|
|
85
|
-
"@opencode/util": "0.0.0-dev-
|
|
81
|
+
"@opencode/ai": "0.0.0-dev-562",
|
|
82
|
+
"@opencode/client": "0.0.0-dev-562",
|
|
83
|
+
"@opencode/protocol": "0.0.0-dev-562",
|
|
84
|
+
"@opencode/schema": "0.0.0-dev-562",
|
|
85
|
+
"@opencode/util": "0.0.0-dev-562",
|
|
86
86
|
"effect": "4.1.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
89
|
-
"@opencode/theme": "0.0.0-dev-
|
|
89
|
+
"@opencode/theme": "0.0.0-dev-562",
|
|
90
90
|
"@opentui/core": ">=0.8.1",
|
|
91
91
|
"@opentui/solid": ">=0.8.1",
|
|
92
92
|
"electron": "*",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
|
-
"@opencode/theme": "0.0.0-dev-
|
|
121
|
+
"@opencode/theme": "0.0.0-dev-562",
|
|
122
122
|
"@opentui/core": "0.8.1",
|
|
123
123
|
"@opentui/solid": "0.8.1",
|
|
124
124
|
"@tsconfig/bun": "1.0.9",
|