@cmodjs/core 7.0.0 → 8.0.0

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.
Files changed (138) hide show
  1. package/docs/commands.md +104 -70
  2. package/docs/dependencies.md +153 -23
  3. package/docs/index.md +54 -10
  4. package/docs/install-steps.md +20 -17
  5. package/docs/jobs.md +42 -17
  6. package/docs/mod.md +37 -30
  7. package/docs/options.md +2 -2
  8. package/docs/session.md +39 -29
  9. package/docs/testing.md +84 -23
  10. package/docs/ui.md +128 -58
  11. package/installer.d.ts +2 -2
  12. package/jobs/context.js +1 -1
  13. package/jobs/program.d.ts +2 -3
  14. package/jobs/program.d.ts.map +1 -1
  15. package/jobs/program.js +72 -23
  16. package/mod.d.ts +23 -8
  17. package/mod.d.ts.map +1 -1
  18. package/mod.js +3 -3
  19. package/package.json +1 -1
  20. package/records.d.ts +5 -3
  21. package/records.d.ts.map +1 -1
  22. package/records.js +18 -9
  23. package/register.d.ts.map +1 -1
  24. package/register.js +7 -15
  25. package/rpc.d.ts +7 -0
  26. package/rpc.d.ts.map +1 -0
  27. package/rpc.js +59 -0
  28. package/runtime/bound.d.ts +1 -0
  29. package/runtime/bound.d.ts.map +1 -1
  30. package/runtime/bound.js +10 -0
  31. package/runtime/bun.d.ts +20 -0
  32. package/runtime/bun.d.ts.map +1 -0
  33. package/runtime/bun.js +20 -0
  34. package/runtime/claude.d.ts +1 -0
  35. package/runtime/claude.d.ts.map +1 -1
  36. package/runtime/conversations.d.ts +9 -2
  37. package/runtime/conversations.d.ts.map +1 -1
  38. package/runtime/conversations.js +244 -185
  39. package/runtime/deadline.d.ts +4 -3
  40. package/runtime/deadline.d.ts.map +1 -1
  41. package/runtime/deadline.js +10 -4
  42. package/runtime/engine.d.ts +4 -4
  43. package/runtime/engine.d.ts.map +1 -1
  44. package/runtime/installer.d.ts +3 -3
  45. package/runtime/installer.d.ts.map +1 -1
  46. package/runtime/installer.js +10 -9
  47. package/runtime/interfaces.d.ts +108 -42
  48. package/runtime/interfaces.d.ts.map +1 -1
  49. package/runtime/interfaces.js +639 -143
  50. package/runtime/lifecycle.d.ts +3 -5
  51. package/runtime/lifecycle.d.ts.map +1 -1
  52. package/runtime/lifecycle.js +74 -63
  53. package/runtime/options.d.ts.map +1 -1
  54. package/runtime/options.js +2 -6
  55. package/runtime/parts.d.ts +64 -1
  56. package/runtime/parts.d.ts.map +1 -1
  57. package/runtime/parts.js +311 -4
  58. package/runtime/programs.d.ts +1 -0
  59. package/runtime/programs.d.ts.map +1 -1
  60. package/runtime/programs.js +5 -3
  61. package/runtime/rpc.d.ts +2 -0
  62. package/runtime/rpc.d.ts.map +1 -1
  63. package/runtime/rpc.js +30 -5
  64. package/runtime/sessions.d.ts +3 -3
  65. package/runtime/sessions.d.ts.map +1 -1
  66. package/runtime/sessions.js +38 -73
  67. package/runtime/toaster.js +1 -1
  68. package/runtime/ui.d.ts +19 -8
  69. package/runtime/ui.d.ts.map +1 -1
  70. package/runtime/ui.js +51 -47
  71. package/runtime/web.d.ts +0 -73
  72. package/runtime/web.d.ts.map +1 -1
  73. package/runtime/web.js +9 -5
  74. package/runtime/widgets.d.ts +4 -2
  75. package/runtime/widgets.d.ts.map +1 -1
  76. package/runtime/widgets.js +17 -16
  77. package/session/conversation.d.ts +6 -2
  78. package/session/conversation.d.ts.map +1 -1
  79. package/session/session.d.ts +22 -6
  80. package/session/session.d.ts.map +1 -1
  81. package/session/session.js +1 -0
  82. package/src/installer.ts +2 -2
  83. package/src/jobs/context.ts +1 -1
  84. package/src/jobs/program.ts +63 -23
  85. package/src/mod.ts +22 -11
  86. package/src/records.ts +21 -9
  87. package/src/register.ts +7 -15
  88. package/src/rpc.ts +67 -0
  89. package/src/runtime/bound.ts +10 -0
  90. package/src/runtime/bun.ts +40 -0
  91. package/src/runtime/claude.ts +1 -0
  92. package/src/runtime/conversations.ts +247 -182
  93. package/src/runtime/deadline.ts +13 -6
  94. package/src/runtime/engine.ts +4 -4
  95. package/src/runtime/installer.ts +13 -12
  96. package/src/runtime/interfaces.ts +753 -172
  97. package/src/runtime/lifecycle.ts +93 -67
  98. package/src/runtime/options.ts +2 -5
  99. package/src/runtime/parts.ts +364 -5
  100. package/src/runtime/programs.ts +6 -3
  101. package/src/runtime/rpc.ts +32 -5
  102. package/src/runtime/sessions.ts +39 -73
  103. package/src/runtime/toaster.ts +1 -1
  104. package/src/runtime/ui.ts +67 -55
  105. package/src/runtime/web.ts +10 -39
  106. package/src/runtime/widgets.ts +20 -18
  107. package/src/session/conversation.ts +7 -2
  108. package/src/session/session.ts +14 -6
  109. package/src/testing/fake-claude.ts +10 -4
  110. package/src/testing/fake-serve.ts +106 -6
  111. package/src/testing/fake-sessions.ts +6 -5
  112. package/src/testing.ts +149 -67
  113. package/src/ui/areas.ts +2 -2
  114. package/src/ui/elements.ts +21 -16
  115. package/src/ui/panes.ts +14 -7
  116. package/testing/fake-claude.d.ts +2 -0
  117. package/testing/fake-claude.d.ts.map +1 -1
  118. package/testing/fake-claude.js +10 -4
  119. package/testing/fake-serve.d.ts +32 -2
  120. package/testing/fake-serve.d.ts.map +1 -1
  121. package/testing/fake-serve.js +81 -6
  122. package/testing/fake-sessions.d.ts.map +1 -1
  123. package/testing/fake-sessions.js +6 -5
  124. package/testing.d.ts +21 -4
  125. package/testing.d.ts.map +1 -1
  126. package/testing.js +131 -55
  127. package/ui/areas.d.ts +3 -1
  128. package/ui/areas.d.ts.map +1 -1
  129. package/ui/elements.d.ts +18 -9
  130. package/ui/elements.d.ts.map +1 -1
  131. package/ui/elements.js +9 -8
  132. package/ui/panes.d.ts +10 -6
  133. package/ui/panes.d.ts.map +1 -1
  134. package/ui/panes.js +5 -3
  135. package/runtime/pages.d.ts +0 -34
  136. package/runtime/pages.d.ts.map +0 -1
  137. package/runtime/pages.js +0 -157
  138. package/src/runtime/pages.ts +0 -198
package/docs/ui.md CHANGED
@@ -1,25 +1,28 @@
1
1
  # UI
2
2
 
3
- A mod draws in five ways: pages in the Sidebar and in Settings, panes of its own, widgets the person places around the prompt and on the Dashboard, styles that change how Claude Code draws a row or a block of a reply, and short messages: toasts and questions. Each part is added with one `add` call in `setup`, and each call returns the part, with `remove()` to take it back.
3
+ A mod draws in six ways: widgets the person places around the prompt and on the Dashboard, views beside the session, pages that fill a window, panes of its own, styles that change how Claude Code draws a row or a block of a reply, and short messages: toasts and questions. Each part is added with one `add` call in `setup`, and each call returns the part, with `remove()` to take it back.
4
+
5
+ Widgets, views, and pages are the three units every app places, as a VS Code extension adds a Status Bar Item, a View, and an editor, and each workbench places them. Each app draws them with its own renderer: Claude Code, the browser app, and any app that reaches the `cmod/UI` interface ([dependencies.md](dependencies.md#interfaces-several-mods-answer-one-name)). So a mod writes each once, and it works in each app. Panes and styles are Claude Code's own places, and only Claude Code draws them.
4
6
 
5
7
  ```ts
6
- mod.sidebar.add<Params>(page: PageInit<State, Params>): Page<Params>
7
- mod.settings.add<Params>(page: PageInit<State, Params>): Page<Params>
8
+ mod.widgets.add(widget: WidgetInit<State>): Widget
9
+ mod.views.add<Params>(view: ViewInit<State, Params>): View<Params>
10
+ mod.pages.add<Params>(page: PageInit<State, Params>): Page<Params>
11
+ mod.settings.add<Params>(view: ViewInit<State, Params>): View<Params>
8
12
  mod.settings.open(): Promise<void>
9
13
  mod.panes.add<Params>(pane: PaneInit<State, Params>): Pane<Params>
10
- mod.widgets.add(widget: WidgetInit<State>): Widget
11
14
  mod.styles.add<K extends Kind>(style: StyleInit<K, State>): Style
12
15
  mod.toast: Toast
13
16
  mod.ask(question: string, options?: readonly string[] | AskOptions): Promise<string>
14
17
  ```
15
18
 
16
- `mod.js` exports the types: `PageInit`, `Page`, `PageProps`, `PaneInit`, `Pane`, `PaneProps`, `OpenOptions`, `ScrollTarget`, `ScrollOptions`, `WidgetInit`, `Widget`, `WidgetContext`, `Area`, `StyleInit`, `Style`, `StyleProps`, `Kind`, and `Row`.
19
+ `mod.js` exports the types: `ViewInit`, `View`, `ViewProps`, `PageInit`, `Page`, `PageProps`, `PaneInit`, `Pane`, `PaneProps`, `OpenOptions`, `ScrollTarget`, `ScrollOptions`, `WidgetInit`, `Widget`, `WidgetContext`, `Area`, `StyleInit`, `Style`, `StyleProps`, `Kind`, and `Row`.
17
20
 
18
21
  Claude Mod Manager (cmod) draws the mod again whenever a value in `mod.state` changes. A render reads `mod.state` and returns what to show. It never draws by hand.
19
22
 
20
23
  ## Every message the person acts on carries a button
21
24
 
22
- A mod never asks the person to type a command. When a toast, a page, or a pane needs the person to do something, it draws a `Button` that does it, or that opens the place where they do it, such as `mod.settings.open()` or a page's `open()`. cmod follows the same rule: a failure caused by a provider that is not installed carries a `Plugins` button, and a secret option carries an `Open /config` button. A failure caused by a permission the person turned off shows no toast, because the person chose it, and goes to the Log in Settings.
25
+ A mod never asks the person to type a command. When a toast, a view, a page, or a pane needs the person to do something, it draws a `Button` that does it, or that opens the place where they do it, such as `mod.settings.open()` or a view's `open()`. cmod follows the same rule: a failure caused by a provider that is not installed carries a `Plugins` button, and a secret option carries an `Open /config` button.
23
26
 
24
27
  ## Elements
25
28
 
@@ -27,15 +30,17 @@ A mod never asks the person to type a command. When a toast, a page, or a pane n
27
30
 
28
31
  - `Box`, with `BoxProps`, draws a flex container: `flexDirection`, `gap`, `padding`, `margin`, `minWidth`, and the rest.
29
32
  - `Text`, with `TextProps`, draws text: `bold`, `dimColor`, `color`, `wrap`, and the rest.
30
- - `Button`, with `ButtonProps`, draws a button: `label` or one string child, `hotkey`, `key`, `variant`, and either `onPress` or `href`. `onPress` gets a `Press`, which names the `surface` the press came from.
33
+ - `Button`, with `ButtonProps`, draws a button: `label` or one string child, `hotkey`, `key`, `variant`, and either `onPress` or `href`. `onPress` gets a `Press`, which names the `surface` the press came from: `'terminal'`, `'desktop'`, `'mobile'`, `'vscode'`, `'browser'`, or `'herdr'`. A `Button` that shows only an icon as its children takes a `label` too, its accessible name, which a screen reader says in place of the icon.
31
34
  - `Code`, with `CodeProps`, draws highlighted code.
32
35
  - `Markdown`, with `MarkdownProps`, draws markdown text, as Claude Code draws a reply.
33
36
  - `Input`, with `InputProps`, draws a text input. It is one line tall unless `rows` says more: `rows: 4` draws four lines that wrap, as a `<textarea>`, for a note or a comment.
34
37
  - `Select`, with `SelectProps`, draws a choice of options.
35
- - `Image`, with `ImageProps`, draws an image, with `alt` text. Only the terminal draws it.
36
- - `Raster`, with `RasterProps`, draws a grid of terminal cells, each a glyph with its colors. Only the terminal draws it.
37
- - `Svg`, with `SvgProps`, draws an SVG drawing, with `alt` text. The desktop and phone apps draw it, and the terminal does not.
38
- - `Client`, with `ClientProps`, draws a region the mod's own surface module draws and handles input for, named by `module`, a string literal path such as `'./board.tsx'`. It draws only in a pane or a style. A page or widget that draws it shows `The <title> page could not draw` with `Client draws only in panes and styles.` under it.
38
+ - `Image`, with `ImageProps`, draws an image, with a `label`, its accessible name. Only the terminal draws it.
39
+ - `Raster`, with `RasterProps`, draws a grid of terminal cells, each a glyph with its colors, with a `label`, its accessible name. Only the terminal draws it.
40
+ - `Svg`, with `SvgProps`, draws an SVG drawing, with a `label`, its accessible name. The desktop and phone apps draw it, and the terminal does not.
41
+ - `Client`, with `ClientProps`, draws a region the mod's own surface module draws and handles input for, named by `module`, a string literal path such as `'./board.tsx'`. It draws only in a pane or a style. A view, page, or widget that draws it shows `The <title> view could not draw`, or page or widget, with `Client draws only in panes and styles.` under it.
42
+
43
+ An element with no text needs a `label`, because each app's renderer owns accessibility and says the label where a sighted person sees the picture. Claude Code takes an `Image`'s or an `Svg`'s `label` as its `alt`, and the browser app writes each `label` as the element's accessible name.
39
44
 
40
45
  Claude Code refuses a whole drawing that holds an element its app does not draw, and draws its own instead. A style reads `surface` to pick what to draw, and a pane reads it from its props.
41
46
 
@@ -98,19 +103,21 @@ Progress(props: { value: number; width?: number })
98
103
  - `Progress` fills `value` percent of `width` columns, 24 unless given. Put the count or a label beside it in a `Text`, or pass it as a loading toast's `description`.
99
104
  - `Tabs`, `Toggle`, `Help`, and `Pagination` hold no state of their own. Keep their value in `mod.state` and set it in the callback, as in React's controlled components.
100
105
 
101
- ## The Sidebar and its pages
106
+ ## Views and pages
107
+
108
+ A view is a part of a mod that shows beside the session, as a VS Code View shows beside the editor. A page fills a window, as a VS Code editor does. Both draw the same way and have the same members, and each app places them: the browser app shows a view in a tab beside the conversation and a page in the whole window.
102
109
 
103
- The Sidebar is one pane the cmod plugin draws beside the conversation for every mod. Its tabs are the Dashboard, the pages mods opened, and Settings. A mod that asks the person to set an option or to finish a step opens its install page there, the `Install <mod>` tab ([install-steps.md](install-steps.md#steps-in-claude-code)). The person shows or hides it with `meta+0`, switches tabs with `0` for the Dashboard, `1` to `8` for the pages, and `9` for Settings, and closes a page with the `×` on its tab. They change both combos in Settings, under cmod, Hotkeys.
110
+ Claude Code has no place that takes the whole window, so it shows both in the Sidebar, one pane the cmod plugin draws beside the conversation for every mod. Its tabs are the Dashboard, the views and pages mods opened, and Settings. A view draws in a panel titled with the mod's name, and a page draws at the Sidebar's full width with no panel. A mod that asks the person to set an option or to finish a step opens its install view there, the `Install <mod>` tab ([install-steps.md](install-steps.md#steps-in-claude-code)). The person shows or hides the Sidebar with `meta+0`, switches tabs with `0` for the Dashboard, `1` to `8` for the views and pages, and `9` for Settings, and closes one with the `×` on its tab. They change both combos in Settings, under cmod, Hotkeys.
104
111
 
105
- A page is a part of a mod that draws in the Sidebar. Put each page in its own file in `src/pages/`:
112
+ Put each view in its own file in `src/views/`, and each page in `src/pages/`:
106
113
 
107
114
  ```tsx
108
- import type { PageInit } from '../../node_modules/@cmodjs/core/mod.js'
115
+ import type { ViewInit } from '../../node_modules/@cmodjs/core/mod.js'
109
116
  import { Box, Button, Text } from '../../node_modules/@cmodjs/core/ui/elements.js'
110
117
 
111
118
  export type NotesState = { global: { notes: readonly string[] } }
112
119
 
113
- export const notesPage: PageInit<NotesState> = {
120
+ export const notesView: ViewInit<NotesState> = {
114
121
  id: 'notes',
115
122
  title: 'Notes',
116
123
  render: (mod) => (
@@ -123,13 +130,15 @@ export const notesPage: PageInit<NotesState> = {
123
130
  ```
124
131
 
125
132
  ```ts
126
- type PageInit<State, Params = undefined> = {
133
+ type ViewInit<State, Params = undefined> = {
127
134
  readonly id: string
128
135
  readonly title: string
129
- render(mod: Mod<State>, props: { readonly params: Params; readonly isFocused: boolean; readonly columns: number }): JSX.Element
136
+ render(mod: Mod<State>, props: ViewProps<Params>): JSX.Element
130
137
  }
131
138
 
132
- type Page<Params = undefined> = {
139
+ type ViewProps<Params> = { readonly params: Params; readonly isFocused: boolean; readonly columns: number; readonly surface: Surface }
140
+
141
+ type View<Params = undefined> = {
133
142
  readonly id: string
134
143
  readonly isOpen: boolean
135
144
  readonly isShown: boolean
@@ -142,28 +151,34 @@ type Page<Params = undefined> = {
142
151
  focus(key: string): Promise<void>
143
152
  remove(): void
144
153
  }
154
+
155
+ type PageInit<State, Params = undefined> = ViewInit<State, Params>
156
+ type PageProps<Params> = ViewProps<Params>
157
+ type Page<Params = undefined> = View<Params>
145
158
  ```
146
159
 
147
- - `id` is 1 to 64 letters, digits, `_`, or `-`, unique among the mod's pages. `title` labels the page's tab. Either one missing throws `<mod>: "<id>" is not a page id.` or `<mod>: the page "<id>" needs a title, the label its tab shows.`
148
- - `mod.sidebar.add(page)` adds the page and returns it. Adding two pages with one id throws `<mod>: the page "<id>" is already added. Give each page its own id.`
149
- - `open` shows the page as a tab of the Sidebar, and shows the Sidebar. `params` is what the page shows, such as a run's number, and the page reads it as `props.params`. A page whose `Params` is not `undefined` must be given `params`. `{ focus: true }` gives it the keyboard.
150
- - `toggle` closes an open page and opens a closed one. `close` takes its tab away, and the Sidebar hides once no page is left.
151
- - `isOpen` is true while the page has a tab, `isShown` while its tab is the one on screen, and `isFocused` while it has the keyboard.
152
- - `scrollTo` brings an element the page drew with that `key` into view, or the page's start or end.
153
- - `focus` moves the keyboard once to the `Button`, `Input`, or `Select` the page drew with that `key`, while the Sidebar holds the keyboard, such as from a `Button` the person pressed. Unlike `autoFocus`, which takes the keyboard each time the Sidebar shows, it moves it only when called. A key the page does not draw rejects with `<mod>: the <title> page draws no Button, Input, or Select with the key "<key>".` The cmod plugin moves the keyboard after the handler returns, so `focus` resolves once the cmod plugin has the request, and a move Claude Code refuses goes to the Log.
154
- - `props.columns` is the width the page draws in. The Sidebar draws the page in a panel titled with the mod's name, under its tab bar and above its key bar, so `columns` is the Sidebar's width less 6: its padding of one column on each side, and the panel's border and padding.
155
- - A page opened from what the person did, such as a slash command they typed, a hotkey, or a `Button` they pressed, shows at any terminal width. A page opened from anything else, such as `setup`, a timer, or a listener, shows only on a terminal 144 columns wide. Below that it waits until the person opens the Sidebar.
156
- - A page draws only the elements of `ui/elements.js` and `ui/components.js`, text, numbers, and plain objects, because the cmod plugin draws it. A `Button`'s `onPress` runs in the mod.
157
- - A `render` that throws draws `The <title> page could not draw: <error>` in the page, and cmod shows the error toast `The <title> page could not draw` once, until the page draws again.
158
- - A press on a `Button` from an older drawing, such as one drawn before the mod reloaded, runs nothing. cmod shows the toast `The <mod> button was from an older drawing, so nothing ran` and draws the page again.
159
-
160
- The person can run their sessions from the browser app too, which `open in browser` on the Sidebar's key bar opens and Settings, under cmod, turns off, and through Tailscale from each of their machines. It lists every running session, and an open session shows its Dashboard, pages, and Settings in tabs beside its conversation, as in the Sidebar. A page needs no change: the browser draws the same `render`, with `props.columns` the browser's width in characters and `props.isFocused` true. A `Button`, `Input`, `Select`, or Markdown link pressed there runs the same handler, with `surface: 'desktop'`, and the page redraws in the browser and in the Sidebar. A page the browser shows counts as `isShown`. The browser draws an `Image` from a file or shared memory as its `alt` text, and `Code` without syntax colors.
160
+ - `id` is 1 to 64 letters, digits, `_`, or `-`, unique among the mod's widgets, views, and pages, because each app names a part by its mod and id. `title` labels the tab. Either one missing throws `<mod>: "<id>" is not a view id.` or `<mod>: the view "<id>" needs a title, the label its tab shows.`, with `page` for a page.
161
+ - `mod.views.add(view)` and `mod.pages.add(page)` add the part and return it. An id the mod already gave a widget, view, or page throws `<mod>: the <widget, view, or page> "<id>" is already added. Give the view another id.`, with `page` for a page.
162
+ - `open` shows the view or page as a tab of the Sidebar, and shows the Sidebar. `params` is what it shows, such as a run's number, and it reads it as `props.params`. One whose `Params` is not `undefined` must be given `params`. `{ focus: true }` gives it the keyboard.
163
+ - `toggle` closes an open view or page and opens a closed one. `close` takes its tab away, and the Sidebar hides once no tab is left.
164
+ - `isOpen` is true while it has a tab, `isShown` while its tab is the one on screen in the Sidebar or in any app, and `isFocused` while it has the keyboard in the Sidebar.
165
+ - `isOpen` turns true the moment `open` is called and false the moment `close` is called, so a slash command or a `Button` handler that awaits `open()` reads `isOpen` true on the next line, though the cmod plugin opens the tab only once the handler returns.
166
+ - `scrollTo` brings an element it drew with that `key` into view, or its start or end.
167
+ - `focus` moves the keyboard once to the `Button`, `Input`, or `Select` it drew with that `key`, while the Sidebar holds the keyboard, such as from a `Button` the person pressed. Unlike `autoFocus`, which takes the keyboard each time the Sidebar shows, it moves it only when called. A key it does not draw rejects with `<mod>: the <title> view draws no Button, Input, or Select with the key "<key>".`, with `page` for a page. The cmod plugin moves the keyboard after the handler returns, so `focus` resolves once the cmod plugin has the request, and a move Claude Code refuses goes to the Log.
168
+ - `props.columns` is the width it draws in. In Claude Code the Sidebar draws a view in its panel, under its tab bar and above its key bar, so a view's `columns` is the Sidebar's width less 6: its padding of one column on each side, and the panel's border and padding. A page's `columns` is the Sidebar's whole width.
169
+ - `props.surface` is the app that draws it: `'terminal'`, `'desktop'`, `'mobile'`, `'vscode'`, `'browser'`, or `'herdr'`.
170
+ - One opened from what the person did, such as a slash command they typed, a hotkey, or a `Button` they pressed, shows at any terminal width. One opened from anything else, such as `setup`, a timer, or a listener, shows only on a terminal 144 columns wide. Below that it waits until the person opens the Sidebar.
171
+ - A view or page draws only the elements of `ui/elements.js` and `ui/components.js`, text, numbers, and plain objects, because the cmod plugin draws it. A `Button`'s `onPress` runs in the mod.
172
+ - A `render` that throws draws `The <title> view could not draw: <error>` in its place, with `page` for a page, and cmod shows the error toast `The <title> view could not draw` once, until it draws again.
173
+ - A press on a `Button` from an older drawing, such as one drawn before the mod reloaded, runs nothing. cmod shows the toast `The <mod> button was from an older drawing, so nothing ran` and draws it again.
174
+
175
+ The person can run their sessions from the browser app too, which `open in browser` on the Sidebar's key bar opens and Settings, under cmod, turns off, and through Tailscale from each of their devices. It lists every running session, and an open session shows its views, the cmod plugin's Dashboard, History, and Settings among them, and the pages open in it, in tabs beside its conversation. It reaches them through `cmod/UI`, as every app does. A view or page needs no change: the browser draws the same `render`, with `props.columns` the browser's width in characters, `props.isFocused` true, and `props.surface` `'browser'`. A `Button`, `Input`, `Select`, or Markdown link pressed there runs the same handler, with `surface: 'browser'`, and the view or page redraws in the browser and in the Sidebar. A page the mod opens itself opens in the browser too. A view or page any app shows counts as `isShown`, the browser's included. The browser draws an `Image` from a file or shared memory as its `label`, and `Code` without syntax colors.
161
176
 
162
177
  A hotkey is the usual way in:
163
178
 
164
179
  ```tsx
165
180
  import { defineMod } from '../node_modules/@cmodjs/core/mod.js'
166
- import { notesPage, type NotesState } from './pages/notes.js'
181
+ import { notesView, type NotesState } from './views/notes.js'
167
182
 
168
183
  const initialState: NotesState = { global: { notes: [] } }
169
184
 
@@ -174,19 +189,76 @@ export const myMod = defineMod({
174
189
  toggle: { title: 'Show or hide the notes', default: 'alt+shift+n' },
175
190
  },
176
191
  setup(mod) {
177
- const page = mod.sidebar.add(notesPage)
178
- mod.hotkeys.toggle.onPress(() => page.toggle({ focus: true }))
192
+ const view = mod.views.add(notesView)
193
+ mod.hotkeys.toggle.onPress(() => view.toggle({ focus: true }))
179
194
  },
180
195
  })
181
196
  ```
182
197
 
183
- ### Settings pages
198
+ ### Views in Settings
199
+
200
+ `mod.settings.add(view)` adds a view to the mod's entry in Settings, beside the Options, Hotkeys, and Changelog cmod draws for every mod. It takes the same `ViewInit` and returns the same `View`. `mod.settings.open()` shows Settings at the mod's entry. `/mods` and `meta+m` open Settings too.
201
+
202
+ ### Every app reaches them through cmod/UI
203
+
204
+ Each session's cmod plugin answers the `cmod/UI` interface for its own session, and `cmod serve` sends each call to the plugin that holds the session the call names, so an app reaches every session's widgets, views, and pages through one `cmod serve` ([dependencies.md](dependencies.md#interfaces-several-mods-answer-one-name)):
205
+
206
+ ```ts
207
+ widgets(session): { mod, id, areas }[]
208
+ views(session): { mod, id, title }[]
209
+ pages(session): { mod, id, title }[]
210
+ draw(session, { mod, id }, { columns, surface, area }): element data
211
+ press(session, handler, input)
212
+ open(session, { mod, id })
213
+ close(session, { mod, id })
214
+ show(session, client, { mod, id }[])
215
+ event Change { session, part: 'widgets' | 'views' | 'pages' }
216
+ event Redraw { session, mod, id }
217
+ event Open { session, mod, id }
218
+ event Close { session, mod, id }
219
+ ```
220
+
221
+ - `views` lists the views that show beside the session, and leaves out the views in Settings. The cmod plugin's own Dashboard, History, and Settings are its views `dashboard`, `history`, and `settings`, so an app lists and draws them as it does every mod's.
222
+ - `draw` returns the part's elements as data, the shape `elementData` writes, with each handler as `{ $cmodHandler: <number> }`. A widget draws for `area`, the area the app shows it in, which its `render` reads as `context.area`, and for `surface`, which it reads as `context.surface`, and an area the widget does not list rejects. For `TurnEnd`, `context.turn` is the session's last finished turn, and the widget draws `null` until the first turn finishes, as Claude Code draws no turn's end before it. Each turn that finishes tells `Redraw` for every widget that lists `TurnEnd`. Without `area`, it draws for the Dashboard when it lists the Dashboard, else for its first area. A view or page draws with the params it was opened with.
223
+ - `press` runs the handler with that number, with a `Press` whose `surface` is the one `input` gives, and `input`'s `key`, `kind`, `value`, and `link`. Its `component` is the one the part draws in within Claude Code: `'Pane'` for a view, a page, or a widget drawn for `Dashboard`, and for a widget drawn for another area, `'AbovePrompt'`, `'PromptHint'`, `'Spinner'`, or `'TurnDuration'`. A number from a drawing two draws back or older runs nothing and rejects.
224
+ - `show` tells which views and pages one place an app draws in shows, as VS Code's workbench sets each view's visibility for the extension host, so each one counts as `isShown` in its mod. `client` names that place, a name the app picks, such as one browser tab. Each `show` replaces that client's last list for the session, and an empty list clears it. A list lapses 16 seconds after its client's last `show`, so an app sends it again before then, every 5 seconds as the browser does, and clears it when the place closes.
225
+ - `Change` tells that a mod added or removed a widget, view, or page, and `Redraw` that a part of a mod may draw new data, after a state change the mod drew differently.
226
+ - `Open` and `Close` tell that a mod opened or closed one of its views or pages itself, with `open()` or `close()` on it, from a press, a slash command, or a timer, as a VS Code extension's `reveal` asks the workbench to show its view. An app shows the part on `Open` and takes it away on `Close`. An app's own `open` and `close` tell neither, and neither does a view in Settings.
227
+
228
+ ### Herdr draws them through cmod/UI
229
+
230
+ The Herdr app shows Claude Code in its terminals, and cmod's Herdr mod draws every mod's widgets, views, and pages beside them, so a mod writes no Herdr code. `cmod serve` places it in `mods/cmod/` of Herdr's home ([cmod serve](commands.md#cmod-serve)), and it reaches each session through [`cmod ui`](commands.md#cmod-ui), with `surface: 'herdr'` and `columns` its width in 8-pixel columns. Toasts and questions stay in Claude Code's own terminal, which Herdr shows.
231
+
232
+ It shows the session of the focused terminal: the terminal's foreground process, whose `sessions/<pid>.json` in Claude Code's config folder names the session. A terminal of a shell, or on another machine, shows no session. A mod pane taking the keyboard keeps the session it showed.
233
+
234
+ It never docks itself, because Herdr writes a dock into whichever layout file shows when it first sees the mod, once per Herdr home, and a layout another mod rewrites loses it for good. Herdr shows it in two ways. `mod.open` with `{ "name": "cmod" }` opens the dock as a window over any layout, Herdr's own included, and closes it when run again: from `herdr-app do mod.open:cmod`, a `keys.json` binding such as `"ctrl-shift-m": "mod.open:cmod"`, or another mod's `run`. The window takes no keyboard, so the dock keeps following the focused terminal, and Herdr remembers where it was dragged. A layout author places it anywhere a mod goes instead, with the `props` that say what it shows:
235
+
236
+ - `{ "mod": "cmod" }`, or `{ "show": "views" }`, shows the focused session's views as tabs, in the order `views` lists them, the cmod plugin's own `dashboard`, `history`, and `settings` among them, and lists the session's pages under them. A page opens as a Herdr tab, `tab.new` with `{ "show": "page", "session", "mod", "id", "title" }`. A page a mod opens itself opens the same way on `Open`, and its tab closes on `Close`. A view a mod opens becomes the shown tab, and a `Close` of the shown view goes back to the first one, as the Sidebar takes a closed view away.
237
+ - `{ "show": "widgets", "area": "belowPrompt" }` draws in a row each widget that lists that area, drawn for that area, for a status bar block. `area` is the value of an area constant: `abovePrompt`, `belowPrompt`, `working`, `turnEnd`, or `dashboard`, the default. In a pane header Herdr gives `props().terminal`, so each pane's header draws its own session's widgets.
238
+ - `{ "show": "page", "session": "<id>", "mod": "<mod>", "id": "<page>" }` draws one page of one session, as the dock's page list opens it.
239
+
240
+ Each dock and page tab tells `show` the view or page it draws, under a client name it makes once, so the mod's view or page counts as `isShown` while Herdr shows it. It tells again when its shown tab or its focused session changes, renews the list every 5 seconds, and clears it when its focused session changes or the placement closes. A `{ "show": "widgets" }` block tells nothing, because `isShown` is about views and pages.
241
+
242
+ ```json
243
+ { "id": "cmod", "type": "block", "size": { "px": 360 }, "content": { "mod": "cmod", "props": { "show": "views" } } }
244
+ { "id": "status", "type": "block", "size": { "px": 28 }, "content": { "mod": "cmod", "props": { "show": "widgets", "area": "belowPrompt" } } }
245
+ ```
246
+
247
+ Each element draws as Herdr's own, and each `label`, or a `Text`'s text, is its accessible name:
184
248
 
185
- `mod.settings.add(page)` adds a page to the mod's entry in Settings, beside the Options, Hotkeys, and Changelog cmod draws for every mod. It takes the same `PageInit` and returns the same `Page`. `mod.settings.open()` shows Settings at the mod's entry. `/mods` and `meta+m` open Settings too.
249
+ - `Box` draws a flex row or column with its gap, padding, margin, sizes, border, and background, a column or row as 8 pixels across, a row as 18 pixels down, and a space step as 6 pixels.
250
+ - `Text` draws its text with its color, weight, and style. A theme color such as `'success'` draws in the Herdr theme's color of the same meaning.
251
+ - `Button` draws Herdr's button. A press runs its handler, and a `Button` with `href` opens an `http:` or `https:` page in the browser, and copies any other link.
252
+ - `Input` draws a field, and `rows` above 1 a text area. Each change runs `onInput`, and Enter runs `onSubmit`.
253
+ - `Select` draws its options as a group of buttons, with the selected one marked.
254
+ - `Markdown` draws Herdr's Markdown text. A link it lists in `pressableLinks`, or any link without them, runs `onLinkPress`, and with no `onLinkPress` it opens as a `Button`'s `href` does.
255
+ - `Code` draws a read-only code view with the language's colors.
256
+ - `Image` and `Svg` draw the picture, which the mod writes under `mods/cmod/.drawn/` first, because Herdr draws only a picture in its home. An image from shared memory draws its `label`.
257
+ - `Raster` draws its cells as rows of colored text.
186
258
 
187
259
  ## Panes
188
260
 
189
- A pane is a framed region of the mod's own, outside the Sidebar. Claude Code docks it beside the transcript in fullscreen, or shows it above the prompt. Use a page unless the part needs its own size, its own Escape, or to hold back toasts, as a dialog does.
261
+ A pane is a framed region of the mod's own, outside the Sidebar. Claude Code docks it beside the transcript in fullscreen, or shows it above the prompt. Only Claude Code draws a pane, so use a view or a page unless the part needs its own size, its own Escape, or to hold back toasts, as a dialog does.
190
262
 
191
263
  ```ts
192
264
  type PaneInit<State, Params = undefined> = {
@@ -202,7 +274,7 @@ type PaneInit<State, Params = undefined> = {
202
274
  }
203
275
  ```
204
276
 
205
- `mod.panes.add(pane)` adds the pane and returns a `Pane`, with the same members as a `Page`.
277
+ `mod.panes.add(pane)` adds the pane and returns a `Pane`, with the same members as a `View`.
206
278
 
207
279
  - `id` is 1 to 64 letters, digits, `_`, or `-`. Another id throws `<mod>: "<id>" is not a pane id.`
208
280
  - `title` labels the pane's tab while more than one pane is open.
@@ -213,7 +285,7 @@ type PaneInit<State, Params = undefined> = {
213
285
  - `onScroll` runs after this pane's window moved, with a `PaneScroll`. `onClose` runs after the pane closed, by the person or by `close()`, with a `PaneClose`, whose `origin.kind` is `'person'` or `'plugin'`. A handler that throws shows the error toast `The <title> pane's <handler> threw`.
214
286
  - `open` asks Claude Code to show the pane, and `isOpen` turns true once Claude Code places it. A pane opened from what the person did shows at any width, and one opened from anything else only at 144 columns, or 110 for a pane the person opened before.
215
287
  - `focus` moves the keyboard once to the `Button`, `Input`, or `Select` the pane drew with that `key`, while the pane holds the keyboard. It resolves once the keyboard moved, and rejects with `<mod>: Claude Code did not focus "<key>" in the <title> pane: <reason>` when it did not.
216
- - Adding two panes with one id throws `<mod>: the pane "<id>" is already added. Give each pane its own id.`
288
+ - Adding two panes with one id throws `<mod>: the pane "<id>" is already added. Give the pane another id.`
217
289
  - A `render` that throws draws `The <title> pane could not draw: <error>` in the pane.
218
290
 
219
291
  A pane with `closeOnEscape` and `holdToasts`, opened with `focus`, is a dialog:
@@ -237,7 +309,7 @@ export const confirmPane: PaneInit<{ session: { deleting: boolean } }> = {
237
309
  <Button label="Delete" onPress={() => void (mod.state.session.deleting = true)} />,
238
310
  ]}
239
311
  >
240
- <Text dimColor wrap="wrap">Its 3 commits are not on main. Deleting it removes them from this machine.</Text>
312
+ <Text dimColor wrap="wrap">Its 3 commits are not on main. Deleting it removes them from this device.</Text>
241
313
  </Dialog>
242
314
  ),
243
315
  }
@@ -250,7 +322,7 @@ Open it with `mod.panes.add(confirmPane).open({ focus: true })`. It draws as:
250
322
  Delete the branch feature/kit?
251
323
 
252
324
  Its 3 commits are not on main. Deleting it removes them from
253
- this machine.
325
+ this device.
254
326
 
255
327
  [ Keep it ] [ Delete ]
256
328
  ```
@@ -269,8 +341,8 @@ type WidgetInit<State> = {
269
341
  }
270
342
 
271
343
  type WidgetContext =
272
- | { readonly area: typeof TurnEnd; readonly columns: number; readonly turn: Turn }
273
- | { readonly area: Exclude<Area, typeof TurnEnd>; readonly columns: number }
344
+ | { readonly area: typeof TurnEnd; readonly columns: number; readonly surface: Surface; readonly turn: Turn }
345
+ | { readonly area: Exclude<Area, typeof TurnEnd>; readonly columns: number; readonly surface: Surface }
274
346
 
275
347
  type Widget = { readonly id: string; readonly area: Area | undefined; remove(): void }
276
348
  ```
@@ -283,16 +355,16 @@ type Widget = { readonly id: string; readonly area: Area | undefined; remove():
283
355
  - `TurnEnd` draws under the line that closes each turn, in the transcript.
284
356
  - `Dashboard` draws on the Sidebar's Dashboard tab.
285
357
 
286
- - `id` is 1 to 64 letters, digits, `_`, or `-`, unique in the mod. `title` names the widget in Settings, under cmod, Widgets.
358
+ - `id` is 1 to 64 letters, digits, `_`, or `-`, unique among the mod's widgets, views, and pages. `title` names the widget in Settings, under cmod, Widgets.
287
359
  - `areas` lists where the person may place the widget. A new widget first draws in the first row of its first area. `area` on the returned `Widget` is where the person placed it.
288
360
  - `place.side` is the side of that row a new widget lands on: `'left'`, the default, or `'right'`.
289
361
  - `place.size` is how wide the widget draws. `'fit'`, the default, keeps the widget's own width and never shrinks. `'fill'` gives up width when its line runs short, so the `fit` widgets beside it stay whole.
290
362
  - A `fill` widget draws its text with `wrap: 'truncate-end'`, so the text ends in `…` where its width runs out. Text that wraps breaks into lines instead.
291
- - `render` returns the widget's elements, or `undefined` to draw nothing now. `columns` is the width of the row it draws in.
292
- - In `TurnEnd`, `context.turn` is the [turn](session.md#turn) that closed, so a widget there reads its answer, failure, or usage.
363
+ - `render` returns the widget's elements, or `undefined` to draw nothing now. `columns` is the width of the row it draws in, and `surface` the app that draws it: `'terminal'`, `'desktop'`, `'mobile'`, `'vscode'`, `'browser'`, or `'herdr'`.
364
+ - In `TurnEnd`, `context.turn` is the [turn](session.md#turn-context-goal-and-task) that closed, so a widget there reads its answer, failure, or usage.
293
365
  - A widget draws only the elements of `ui/elements.js` and `ui/components.js`, text, numbers, and plain objects. A `Button`'s `onPress` runs in the mod.
294
366
  - A `render` that throws draws nothing, and cmod shows the error toast `The <title> widget could not draw` once, until the widget draws again. The widgets beside it still draw.
295
- - Adding two widgets with one id throws `<mod>: the widget "<id>" is already added. Give each widget its own id.`
367
+ - An id the mod already gave a widget, view, or page throws `<mod>: the <widget, view, or page> "<id>" is already added. Give the widget another id.`
296
368
 
297
369
  ```tsx
298
370
  import { BelowPrompt, Dashboard, type WidgetInit } from '../../node_modules/@cmodjs/core/mod.js'
@@ -400,9 +472,9 @@ Each kind of markdown block of a reply is a kind of its own. `ui/markdown.js` ex
400
472
  - `ThematicBreak`: a `---` line.
401
473
  - `HtmlBlock`: an HTML block, with `value`.
402
474
 
403
- Every block's props hold `text`, its plain text, one line per list item, table row, or quoted line, and `source`, its markdown. `Default` draws the block as Claude Code would, and `<Default source="…" />` draws other markdown in its place. A style may call `Default` once per part, such as once per list item, quoted line, or table cell. Each part, and each `Markdown` a style draws itself, keeps the `dimColor`, `onLinkPress`, and `pressableLinks` of the `Markdown` element that holds the block unless it sets them itself, so a dim element stays dim and its links still run its `onLinkPress`, in a pane, a page, or a widget, whichever mod's style draws it. When that element has a `key`, the first of them without a key of its own takes that key and each later one takes it with `:1`, `:2`, and so on, because Claude Code refuses two `Markdown` elements with one key and needs a key on each one with `onLinkPress`. While a reply streams in, Claude Code draws a block that is not finished yet, and the mod draws it once it is.
475
+ Every block's props hold `text`, its plain text, one line per list item, table row, or quoted line, and `source`, its markdown. `Default` draws the block as Claude Code would, and `<Default source="…" />` draws other markdown in its place. A style may call `Default` once per part, such as once per list item, quoted line, or table cell. Each part, and each `Markdown` a style draws itself, keeps the `dimColor`, `onLinkPress`, and `pressableLinks` of the `Markdown` element that holds the block unless it sets them itself, so a dim element stays dim and its links still run its `onLinkPress`, in a pane, a view, a page, or a widget, whichever mod's style draws it. When that element has a `key`, the first of them without a key of its own takes that key and each later one takes it with `:1`, `:2`, and so on, because Claude Code refuses two `Markdown` elements with one key and needs a key on each one with `onLinkPress`. While a reply streams in, Claude Code draws a block that is not finished yet, and the mod draws it once it is.
404
476
 
405
- A markdown style draws wherever markdown shows: in Claude's replies and in every `Markdown` element any mod or cmod draws, in panes, pages, widgets, the Dashboard, Settings, and changelogs. A `Markdown` element goes through the styles of the mod that draws it first, then through each other mod's, in the order the mods added their first markdown style. A mod that removes its last markdown style and adds one again moves to the end. Another mod's style shows as soon as that mod has drawn the block, and Claude Code's drawing shows until then. When that mod does not answer, Claude Code's drawing stays, and cmod reports `The markdown style of <mod> drew nothing` to the Log, with the reason.
477
+ A markdown style draws wherever markdown shows: in Claude's replies and in every `Markdown` element any mod or cmod draws, in panes, views, pages, widgets, the Dashboard, Settings, and changelogs. A `Markdown` element goes through the styles of the mod that draws it first, then through each other mod's, in the order the mods added their first markdown style. A mod that removes its last markdown style and adds one again moves to the end. Another mod's style shows as soon as that mod has drawn the block, and Claude Code's drawing shows until then. When that mod does not answer, Claude Code's drawing stays, and cmod reports `The markdown style of <mod> drew nothing` to the Log, with the reason.
406
478
 
407
479
  Claude Code refuses a whole drawing in which two `Input`, `Select`, `Markdown`, `Client`, `Raster`, or `Image` elements share a key. So cmod puts each block's place in front of every key its style draws, and the keys a style draws need be unique only within the one block it draws, as a component's keys are in React. The place is the block's number in its markdown, from `0`, after the `key` of the `Markdown` element that holds it, or that element's number among the ones drawn without a key. A block that draws again in its place keeps its keys, so Claude Code keeps what the person typed in its `Input`.
408
480
 
@@ -458,21 +530,19 @@ type ToastOptions = {
458
530
  - `✕` closes the toast. The band shows the newest 3, and `+N more` shows every toast.
459
531
  - `promise` shows `loading` while `task` runs, then `success` or `error` in the same row. `unwrap()` resolves or rejects as `task` does.
460
532
 
461
- Every error cmod catches for a mod, such as a listener that throws, goes to the Log, in Settings on cmod's page, and so does every warning cmod has for a mod, such as a session that did not hear of its listener. A warning never shows a toast. The Log keeps the newest 100 failures of every session, each with the mod, the time, the message, the versions of the mod, its `@cmodjs/core`, cmod, and Claude Code, `Copy`, and `Report`, and the same failure again updates its entry and counts the repeat. `cmod log <mod>` prints the same entries in a terminal ([commands.md](commands.md#cmod-log)).
533
+ Every error cmod catches for a mod, such as a listener that throws, goes to the Log, in Settings in cmod's entry, and so does every warning cmod has for a mod, such as a session that did not hear of its listener. A warning never shows a toast. The Log keeps the newest 100 failures of every session, each with the mod, the time, the message, the versions of the mod, its `@cmodjs/core`, cmod, and Claude Code, `Copy`, and `Report`, and the same failure again updates its entry and counts the repeat. `cmod log <mod>` prints the same entries in a terminal ([commands.md](commands.md#cmod-log)).
462
534
 
463
535
  An error also shows as a toast when any of these holds:
464
536
 
465
537
  - it is critical: the mod's install or setup in this session failed, or a button or hotkey the person pressed failed
466
538
  - the mod runs from its checkout, linked with [`cmod link`](commands.md#cmod-link) or loaded with `--plugin-dir`, and the session works in that checkout or a folder inside it, because there the person is its author
467
- - `Show errors from installed mods` is on, in Settings on cmod's page under Preferences
539
+ - `Show errors from installed mods` is on, in Settings in cmod's entry under Preferences
468
540
 
469
541
  A failure every session meets at once, such as a program every session shares that stopped, is not critical, so it toasts only where its author works.
470
542
 
471
543
  A failure whose cause is a call another mod did not answer, because it was installing or Claude Code stopped its hook, goes to the Log as a warning, because the mod that did not answer logs its own failure. A failure whose Log call cmod does not answer, such as while cmod installs, waits and tries the Log again after 10 seconds, 1 minute, and 5 minutes, and shows its toast only when cmod still has not answered.
472
544
 
473
- A cmod older than 4.3.0 keeps no Log, so there every error shows its toast.
474
-
475
- So a listener or handler that fails throws its error and lets cmod report it. A failure the mod works around and goes on past, such as one rule of many that did not load, goes to [`mod.log`](mod.md#modlog) with a `level`. A `mod.toast.error` for either reaches no Log and shows in every session, so a broken config of a mod the person runs in 30 sessions shows in all 30.
545
+ So a listener or handler that fails throws its error and lets cmod report it. A failure the mod works around and goes on past, such as one rule of many that did not load, goes to [`mod.log`](mod.md#mod-log) with a `level`. A `mod.toast.error` for either reaches no Log and shows in every session, so a broken config of a mod the person runs in 30 sessions shows in all 30.
476
546
 
477
547
  The error toast stays, with its buttons and the time on a line under the message. `Report`, which every error toast has, comes first, at the same column in every error toast, and the buttons only some errors have come after it:
478
548
 
@@ -517,8 +587,8 @@ sessions.current.caption(toolCall: ToolCall message, text: string | undefined):
517
587
  ```
518
588
 
519
589
  - `scrollTo` brings a [message](session.md#message)'s row into view, such as the message a person pressed in a history page. It scrolls only while the mod answers the person's own press or key.
520
- - `caption` shows `text` as one line under the permission dialog that is open for that tool call, such as `checked by safe-delete`. `undefined` removes the line, and Claude Code removes it on its own once the call is decided.
590
+ - `caption` shows `text` as one line under the permission dialog that is open for that tool call, such as `checked by my-mod`. `undefined` removes the line, and Claude Code removes it on its own once the call is decided.
521
591
 
522
592
  ## Test the UI
523
593
 
524
- `tested.shown.page` and `tested.shown.pane` read the page or pane the mod shows now, with `lines()`, `press(key)`, `input(key, text)`, `select(key, value)`, and `focusedKey()`. `tested.lines(area)` draws the mod's widgets in an area, and `tested.lines(kind, props)` draws a style. `tested.hotkey(name)` presses a hotkey. `tested.shown.toasts` lists the toasts shown now, each as `{ type, message, description? }`. [testing.md](testing.md) covers each.
594
+ `tested.shown.view`, `tested.shown.page`, and `tested.shown.pane` read the view, page, or pane the mod shows now, with `lines()`, `press(key)`, `input(key, text)`, `select(key, value)`, and `focusedKey()`. `tested.lines(area)` draws the mod's widgets in an area, and `tested.lines(kind, props)` draws a style. `tested.hotkey(name)` presses a hotkey. `tested.shown.toasts` lists the toasts shown now, each as `{ type, message, description? }`. [testing.md](testing.md) covers each.
package/installer.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Mod } from './mod.js';
2
- import type { PageProps } from './ui/panes.js';
2
+ import type { ViewProps } from './ui/panes.js';
3
3
  export type Step<State extends object = Record<never, never>> = {
4
4
  readonly id: string;
5
5
  readonly title: string;
6
- render(mod: Mod<State>, props: PageProps<undefined>): JSX.Element;
6
+ render(mod: Mod<State>, props: ViewProps<undefined>): JSX.Element;
7
7
  isDone(mod: Mod<State>): boolean | Promise<boolean>;
8
8
  };
9
9
  export declare function checkSteps(name: string, steps: readonly Step<never>[]): void;
package/jobs/context.js CHANGED
@@ -42,7 +42,7 @@ export async function inFolder(call, folder, workspace) {
42
42
  return { ...call, folder: (await workspace.scope?.workTreeOf('path' in call ? call.path : folder)) ?? folder };
43
43
  }
44
44
  export function withinDeadline(mod, deadline, subject, run) {
45
- return beforeDeadline(engineOf(mod).claude, deadline, subject, Promise.resolve().then(run));
45
+ return beforeDeadline(engineOf(mod).claude.clock, deadline, subject, () => Promise.resolve().then(run));
46
46
  }
47
47
  export function targetWords(target) {
48
48
  const { key, patterns, exclusions } = targetOf(target);
package/jobs/program.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { Job } from '../mod.js';
1
+ import type { InterfaceName, InterfaceProvider, Job } from '../mod.js';
2
2
  import { type ProcessType } from '../records.js';
3
- import type { InterfaceName } from '../runtime/interfaces.js';
4
3
  export type Program = {
5
4
  readonly state: 'stopped' | 'starting' | 'running' | 'backoff' | 'fatal';
6
5
  ready(): Promise<{
@@ -8,6 +7,7 @@ export type Program = {
8
7
  socketPath?: string;
9
8
  tailnetUrl?: string;
10
9
  }>;
10
+ provider<Name extends InterfaceName>(name: Name): Promise<InterfaceProvider<Name>>;
11
11
  };
12
12
  export declare function program(options: {
13
13
  readonly command: readonly string[];
@@ -15,7 +15,6 @@ export declare function program(options: {
15
15
  readonly singleInstance?: boolean;
16
16
  readonly isService?: boolean;
17
17
  readonly isWebApp?: boolean;
18
- readonly provides?: readonly InterfaceName[];
19
18
  readonly processType?: ProcessType;
20
19
  }): Job<Program>;
21
20
  //# sourceMappingURL=program.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAA0D,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AACxG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAO7D,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC5E,CAAA;AAYD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAA;IAC5C,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CACnC,GAAG,GAAG,CAAC,OAAO,CAAC,CA6Jf"}
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/jobs/program.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAS5E,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,KAAK,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAC3E,QAAQ,CAAC,IAAI,SAAS,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAA;CACnF,CAAA;AAYD,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7C,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAA;CACnC,GAAG,GAAG,CAAC,OAAO,CAAC,CAoMf"}