@agi-fans/dsh-tui 0.21.0 → 0.22.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 (243) hide show
  1. package/lib/CHANGELOG.md +158 -1
  2. package/lib/chrome/box.d.ts +47 -16
  3. package/lib/chrome/box.js +172 -130
  4. package/lib/chrome/box.js.map +1 -1
  5. package/lib/chrome/code-highlight.d.ts +15 -0
  6. package/lib/chrome/code-highlight.js +60 -4
  7. package/lib/chrome/code-highlight.js.map +1 -1
  8. package/lib/chrome/command-output.d.ts +29 -2
  9. package/lib/chrome/command-output.js +100 -4
  10. package/lib/chrome/command-output.js.map +1 -1
  11. package/lib/chrome/main-screen-renderer.d.ts +16 -0
  12. package/lib/chrome/main-screen-renderer.js +53 -5
  13. package/lib/chrome/main-screen-renderer.js.map +1 -1
  14. package/lib/chrome/markdown.js +30 -10
  15. package/lib/chrome/markdown.js.map +1 -1
  16. package/lib/chrome/relative-time.d.ts +17 -0
  17. package/lib/chrome/relative-time.js +36 -0
  18. package/lib/chrome/relative-time.js.map +1 -1
  19. package/lib/chrome/secret-mask.d.ts +35 -0
  20. package/lib/chrome/secret-mask.js +180 -0
  21. package/lib/chrome/secret-mask.js.map +1 -0
  22. package/lib/chrome/status-config.d.ts +161 -51
  23. package/lib/chrome/status-config.js +237 -126
  24. package/lib/chrome/status-config.js.map +1 -1
  25. package/lib/chrome/status-line.d.ts +3 -2
  26. package/lib/chrome/status-line.js +105 -63
  27. package/lib/chrome/status-line.js.map +1 -1
  28. package/lib/chrome/terminal-colors.d.ts +85 -0
  29. package/lib/chrome/terminal-colors.js +230 -0
  30. package/lib/chrome/terminal-colors.js.map +1 -0
  31. package/lib/chrome/terminal-images.d.ts +9 -1
  32. package/lib/chrome/terminal-images.js +27 -4
  33. package/lib/chrome/terminal-images.js.map +1 -1
  34. package/lib/chrome/theme.d.ts +32 -9
  35. package/lib/chrome/theme.js +595 -498
  36. package/lib/chrome/theme.js.map +1 -1
  37. package/lib/chrome/tool-renderers.js +69 -13
  38. package/lib/chrome/tool-renderers.js.map +1 -1
  39. package/lib/chrome/tools-list.d.ts +1 -4
  40. package/lib/chrome/tools-list.js +1 -41
  41. package/lib/chrome/tools-list.js.map +1 -1
  42. package/lib/chrome/welcome-tips.d.ts +20 -8
  43. package/lib/chrome/welcome-tips.js +22 -42
  44. package/lib/chrome/welcome-tips.js.map +1 -1
  45. package/lib/commands/auth-ids.d.ts +25 -0
  46. package/lib/commands/auth-ids.js +27 -0
  47. package/lib/commands/auth-ids.js.map +1 -0
  48. package/lib/commands/auth-input.d.ts +34 -0
  49. package/lib/commands/auth-input.js +96 -0
  50. package/lib/commands/auth-input.js.map +1 -0
  51. package/lib/commands/auth-providers.d.ts +39 -0
  52. package/lib/commands/auth-providers.js +125 -0
  53. package/lib/commands/auth-providers.js.map +1 -0
  54. package/lib/commands/auth.d.ts +12 -20
  55. package/lib/commands/auth.js +42 -229
  56. package/lib/commands/auth.js.map +1 -1
  57. package/lib/commands/btw.d.ts +13 -1
  58. package/lib/commands/btw.js +37 -104
  59. package/lib/commands/btw.js.map +1 -1
  60. package/lib/commands/diff.js +1 -96
  61. package/lib/commands/diff.js.map +1 -1
  62. package/lib/commands/export.d.ts +1 -1
  63. package/lib/commands/export.js +3 -27
  64. package/lib/commands/export.js.map +1 -1
  65. package/lib/commands/files.d.ts +17 -1
  66. package/lib/commands/files.js +67 -107
  67. package/lib/commands/files.js.map +1 -1
  68. package/lib/commands/jobs.d.ts +19 -4
  69. package/lib/commands/jobs.js +50 -7
  70. package/lib/commands/jobs.js.map +1 -1
  71. package/lib/commands/model.js +108 -76
  72. package/lib/commands/model.js.map +1 -1
  73. package/lib/commands/permission.js +15 -16
  74. package/lib/commands/permission.js.map +1 -1
  75. package/lib/commands/plugins.js +133 -16
  76. package/lib/commands/plugins.js.map +1 -1
  77. package/lib/commands/schedule.d.ts +10 -0
  78. package/lib/commands/schedule.js +45 -14
  79. package/lib/commands/schedule.js.map +1 -1
  80. package/lib/commands/session-configuration.js +2 -10
  81. package/lib/commands/session-configuration.js.map +1 -1
  82. package/lib/commands/session.js +14 -38
  83. package/lib/commands/session.js.map +1 -1
  84. package/lib/commands/terminal.d.ts +14 -8
  85. package/lib/commands/terminal.js +19 -178
  86. package/lib/commands/terminal.js.map +1 -1
  87. package/lib/commands/trajectory.js +4 -1
  88. package/lib/commands/trajectory.js.map +1 -1
  89. package/lib/definition.d.ts +122 -22
  90. package/lib/definition.js.map +1 -1
  91. package/lib/index.d.ts +1 -0
  92. package/lib/index.js +1 -0
  93. package/lib/index.js.map +1 -1
  94. package/lib/input/actions.d.ts +51 -0
  95. package/lib/input/actions.js +120 -0
  96. package/lib/input/actions.js.map +1 -0
  97. package/lib/input/editor.d.ts +0 -10
  98. package/lib/input/editor.js +11 -9
  99. package/lib/input/editor.js.map +1 -1
  100. package/lib/input/image-paste.d.ts +19 -1
  101. package/lib/input/image-paste.js +82 -1
  102. package/lib/input/image-paste.js.map +1 -1
  103. package/lib/input/keybindings-config.d.ts +12 -5
  104. package/lib/input/keybindings-config.js +30 -57
  105. package/lib/input/keybindings-config.js.map +1 -1
  106. package/lib/input/keys.d.ts +16 -0
  107. package/lib/input/keys.js +38 -3
  108. package/lib/input/keys.js.map +1 -1
  109. package/lib/input/wheel-scroll.d.ts +46 -0
  110. package/lib/input/wheel-scroll.js +69 -0
  111. package/lib/input/wheel-scroll.js.map +1 -0
  112. package/lib/prompt-intents.d.ts +182 -0
  113. package/lib/prompt-intents.js +127 -0
  114. package/lib/prompt-intents.js.map +1 -0
  115. package/lib/runtime/cancellable.d.ts +75 -0
  116. package/lib/runtime/cancellable.js +76 -0
  117. package/lib/runtime/cancellable.js.map +1 -0
  118. package/lib/runtime/composer-images.js +5 -4
  119. package/lib/runtime/composer-images.js.map +1 -1
  120. package/lib/runtime/composer-shell.d.ts +17 -2
  121. package/lib/runtime/composer-shell.js +109 -43
  122. package/lib/runtime/composer-shell.js.map +1 -1
  123. package/lib/runtime/file-recovery-review.d.ts +0 -1
  124. package/lib/runtime/file-recovery-review.js +29 -30
  125. package/lib/runtime/file-recovery-review.js.map +1 -1
  126. package/lib/runtime/file-recovery-store.js +5 -1
  127. package/lib/runtime/file-recovery-store.js.map +1 -1
  128. package/lib/runtime/file-review.js +1 -1
  129. package/lib/runtime/file-review.js.map +1 -1
  130. package/lib/runtime/hook-settings.d.ts +2 -2
  131. package/lib/runtime/plain-tui.d.ts +2 -0
  132. package/lib/runtime/plain-tui.js +7 -1
  133. package/lib/runtime/plain-tui.js.map +1 -1
  134. package/lib/runtime/plugin-settings.d.ts +1 -1
  135. package/lib/runtime/plugin-settings.js +10 -8
  136. package/lib/runtime/plugin-settings.js.map +1 -1
  137. package/lib/runtime/provider-local.d.ts +57 -15
  138. package/lib/runtime/provider-local.js +1112 -471
  139. package/lib/runtime/provider-local.js.map +1 -1
  140. package/lib/runtime/runner.js +5 -11
  141. package/lib/runtime/runner.js.map +1 -1
  142. package/lib/runtime/settings-preferences.js +1 -1
  143. package/lib/runtime/settings-preferences.js.map +1 -1
  144. package/lib/runtime/startup-notices.js +2 -0
  145. package/lib/runtime/startup-notices.js.map +1 -1
  146. package/lib/runtime/terminal-modes.d.ts +47 -0
  147. package/lib/runtime/terminal-modes.js +86 -0
  148. package/lib/runtime/terminal-modes.js.map +1 -0
  149. package/lib/runtime/terminal-notifications.d.ts +3 -5
  150. package/lib/runtime/terminal-notifications.js +4 -8
  151. package/lib/runtime/terminal-notifications.js.map +1 -1
  152. package/lib/runtime/terminal-probe.d.ts +36 -0
  153. package/lib/runtime/terminal-probe.js +37 -0
  154. package/lib/runtime/terminal-probe.js.map +1 -0
  155. package/lib/runtime/terminal-session.d.ts +57 -0
  156. package/lib/runtime/terminal-session.js +164 -0
  157. package/lib/runtime/terminal-session.js.map +1 -0
  158. package/lib/session/interaction-adapter.js +7 -8
  159. package/lib/session/interaction-adapter.js.map +1 -1
  160. package/lib/session/message-queue.js +1 -1
  161. package/lib/session/message-queue.js.map +1 -1
  162. package/lib/session/package-metadata.d.ts +8 -0
  163. package/lib/session/package-metadata.js +8 -0
  164. package/lib/session/package-metadata.js.map +1 -1
  165. package/lib/session/session-controller.d.ts +10 -11
  166. package/lib/session/session-controller.js +95 -13
  167. package/lib/session/session-controller.js.map +1 -1
  168. package/lib/session/session-tree.d.ts +2 -0
  169. package/lib/session/session-tree.js +2 -0
  170. package/lib/session/session-tree.js.map +1 -1
  171. package/lib/session/tui-settings.d.ts +40 -11
  172. package/lib/session/tui-settings.js +73 -34
  173. package/lib/session/tui-settings.js.map +1 -1
  174. package/lib/views/autocomplete.d.ts +18 -2
  175. package/lib/views/autocomplete.js +51 -38
  176. package/lib/views/autocomplete.js.map +1 -1
  177. package/lib/views/copy-targets.d.ts +12 -13
  178. package/lib/views/copy-targets.js +16 -46
  179. package/lib/views/copy-targets.js.map +1 -1
  180. package/lib/views/document-reader.js +18 -5
  181. package/lib/views/document-reader.js.map +1 -1
  182. package/lib/views/event-views.js +42 -6
  183. package/lib/views/event-views.js.map +1 -1
  184. package/lib/views/history-search.js +15 -21
  185. package/lib/views/history-search.js.map +1 -1
  186. package/lib/views/hotkeys.d.ts +7 -1
  187. package/lib/views/hotkeys.js +49 -25
  188. package/lib/views/hotkeys.js.map +1 -1
  189. package/lib/views/list-navigation.d.ts +62 -0
  190. package/lib/views/list-navigation.js +73 -0
  191. package/lib/views/list-navigation.js.map +1 -0
  192. package/lib/views/list-view.d.ts +99 -0
  193. package/lib/views/list-view.js +165 -0
  194. package/lib/views/list-view.js.map +1 -0
  195. package/lib/views/prompt-selector.d.ts +31 -3
  196. package/lib/views/prompt-selector.js +249 -125
  197. package/lib/views/prompt-selector.js.map +1 -1
  198. package/lib/views/session-files.d.ts +1 -2
  199. package/lib/views/session-files.js +1 -11
  200. package/lib/views/session-files.js.map +1 -1
  201. package/lib/views/settings-list.d.ts +10 -8
  202. package/lib/views/settings-list.js +116 -283
  203. package/lib/views/settings-list.js.map +1 -1
  204. package/lib/views/trajectory-timeline.d.ts +72 -0
  205. package/lib/views/trajectory-timeline.js +133 -0
  206. package/lib/views/trajectory-timeline.js.map +1 -0
  207. package/lib/views/trajectory.d.ts +15 -4
  208. package/lib/views/trajectory.js +557 -123
  209. package/lib/views/trajectory.js.map +1 -1
  210. package/lib/views/transcript-render.d.ts +95 -25
  211. package/lib/views/transcript-render.js +501 -167
  212. package/lib/views/transcript-render.js.map +1 -1
  213. package/lib/views/transcript-search.d.ts +39 -6
  214. package/lib/views/transcript-search.js +46 -11
  215. package/lib/views/transcript-search.js.map +1 -1
  216. package/lib/views/transcript-types.d.ts +63 -5
  217. package/lib/views/transcript-types.js +23 -11
  218. package/lib/views/transcript-types.js.map +1 -1
  219. package/package.json +67 -86
  220. package/lib/commands/advisor.d.ts +0 -15
  221. package/lib/commands/advisor.js +0 -200
  222. package/lib/commands/advisor.js.map +0 -1
  223. package/lib/commands/loop.d.ts +0 -52
  224. package/lib/commands/loop.js +0 -307
  225. package/lib/commands/loop.js.map +0 -1
  226. package/lib/commands/rate.d.ts +0 -33
  227. package/lib/commands/rate.js +0 -212
  228. package/lib/commands/rate.js.map +0 -1
  229. package/lib/commands/steer.d.ts +0 -5
  230. package/lib/commands/steer.js +0 -24
  231. package/lib/commands/steer.js.map +0 -1
  232. package/lib/commands/worktree.d.ts +0 -5
  233. package/lib/commands/worktree.js +0 -103
  234. package/lib/commands/worktree.js.map +0 -1
  235. package/lib/runtime/terminal-reader.d.ts +0 -11
  236. package/lib/runtime/terminal-reader.js +0 -87
  237. package/lib/runtime/terminal-reader.js.map +0 -1
  238. package/lib/views/agent-hub.d.ts +0 -32
  239. package/lib/views/agent-hub.js +0 -209
  240. package/lib/views/agent-hub.js.map +0 -1
  241. package/lib/views/copy-selector.d.ts +0 -54
  242. package/lib/views/copy-selector.js +0 -170
  243. package/lib/views/copy-selector.js.map +0 -1
@@ -1,13 +1,23 @@
1
- /** Workspace browsing, deliverables, and durable file attachments. */
1
+ /**
2
+ * File attachments: one surface for adding a file to the composer and for
3
+ * reading back everything this session has already attached.
4
+ *
5
+ * There used to be a `/files` browser as well — a full-screen directory walker
6
+ * with its own workspace search and a deliverables view. It was a file manager
7
+ * inside a chat, which is not what a chat needs: `@` already completes any path
8
+ * in the workspace, a tool card's paths already open a preview, and the Agent
9
+ * already reports the files it wrote. Nothing it offered was unreachable without
10
+ * it, and it cost the reader a mode to learn.
11
+ */
2
12
  import { createReadStream } from 'node:fs';
3
- import { readdir, stat } from 'node:fs/promises';
4
- import { basename, dirname, resolve } from 'node:path';
13
+ import { stat } from 'node:fs/promises';
14
+ import { basename, resolve } from 'node:path';
5
15
  import { homedir } from 'node:os';
6
- import { deliverableFiles, logAttachments } from "../views/session-files.js";
16
+ import { logAttachments } from "../views/session-files.js";
7
17
  import { filePreview, openSystemFile, reviewFiles } from "../runtime/file-review.js";
8
18
  import { previewImages } from "../runtime/image-preview.js";
9
19
  import { registerCommands } from "./registration.js";
10
- import { loadProjectPaths, rankProjectPaths } from "../session/project-file-search.js";
20
+ import { askPrompt } from "../prompt-intents.js";
11
21
  import { currentWorkingDirectory } from "../session/working-directory.js";
12
22
  export const name = 'omdsh-command-files';
13
23
  export const inject = ['commands', 'tui', 'attachments'];
@@ -15,103 +25,34 @@ export function userPath(input, cwd) {
15
25
  const unquoted = input.replace(/^(?:"(.*)"|'(.*)')$/u, '$1$2');
16
26
  return resolve(cwd, unquoted.startsWith('~/') ? homedir() + unquoted.slice(1) : unquoted);
17
27
  }
18
- async function searchWorkspaceFile(ctx, root, initialQuery, signal) {
19
- const entries = (await loadProjectPaths(root, signal)).filter(entry => !entry.directory);
20
- const ranked = initialQuery.trim() === '' ? entries.slice(0, 1000) : rankProjectPaths(entries, initialQuery, 500);
21
- if (ranked.length === 0)
22
- return null;
23
- if (ranked.length === 1 && initialQuery.trim() !== '')
24
- return resolve(root, ranked[0].path);
25
- const answer = await ctx.tui.prompt({
26
- title: `Workspace files · ${root}`,
27
- question: initialQuery.trim() === '' ? 'Search workspace files' : `Matches for "${initialQuery.trim()}"`,
28
- presentation: 'fullscreen-list',
29
- optionLayout: 'compact',
30
- allowCustom: false,
31
- filterable: true,
32
- signal,
33
- notify: false,
34
- options: ranked.map(entry => ({ label: entry.path, value: resolve(root, entry.path) })),
35
- });
36
- return answer;
37
- }
38
- async function browse(ctx, invocation) {
39
- const cwd = currentWorkingDirectory(ctx, invocation.agent.session);
40
- const rawQuery = invocation.rawInput.trim();
41
- let path = userPath(rawQuery, cwd);
42
- while (!invocation.signal.aborted) {
43
- let info;
44
- try {
45
- info = await stat(path);
46
- }
47
- catch (error) {
48
- if (error.code === 'ENOENT' && rawQuery !== '' && ctx.tui.interactive === true) {
49
- const matched = await searchWorkspaceFile(ctx, cwd, rawQuery, invocation.signal);
50
- if (matched !== null) {
51
- path = matched;
52
- info = await stat(path);
53
- }
54
- else {
55
- throw error;
56
- }
57
- }
58
- else {
59
- throw error;
60
- }
61
- }
62
- if (info.isFile()) {
63
- if (ctx.tui.interactive !== true)
64
- return { kind: 'success', text: await filePreview(path, invocation.signal) };
65
- const directory = dirname(path);
66
- const files = (await readdir(directory, { withFileTypes: true })).filter(entry => entry.isFile())
67
- .sort((a, b) => a.name.localeCompare(b.name)).slice(0, 500)
68
- .map(entry => ({ path: resolve(directory, entry.name), label: entry.name }));
69
- if (!files.some(file => file.path === path))
70
- files.push({ path, label: basename(path) });
71
- await reviewFiles(ctx.tui, `Files · ${directory}`, directory, files, index => filePreview(files[index].path, invocation.signal), invocation.signal, files.findIndex(file => file.path === path), false);
72
- path = directory;
73
- continue;
74
- }
75
- const entries = (await readdir(path, { withFileTypes: true })).filter(entry => entry.name !== '.git' && entry.name !== 'node_modules')
76
- .sort((a, b) => Number(b.isDirectory()) - Number(a.isDirectory()) || a.name.localeCompare(b.name));
77
- const page = entries.slice(0, 500);
78
- if (ctx.tui.interactive !== true)
79
- return { kind: 'success', text: page.map(entry => entry.name + (entry.isDirectory() ? '/' : '')).join('\n') };
80
- const answer = await ctx.tui.prompt({ title: `Files · ${path}`, question: path, presentation: 'fullscreen-list', optionLayout: 'compact',
81
- allowCustom: false, filterable: true, signal: invocation.signal, notify: false,
82
- detail: entries.length > page.length ? `Showing ${page.length} of ${entries.length} entries; Shift+F searches all workspace files.` : 'Shift+F searches workspace files · Shift+P shows this session’s deliverables.',
83
- options: [{ label: '../', value: dirname(path) }, ...page.map(entry => ({ label: entry.name + (entry.isDirectory() ? '/' : ''), value: resolve(path, entry.name) }))],
84
- actions: [{ key: 'F', label: 'search workspace', valuePrefix: 'search:' }, { key: 'P', label: 'deliverables', valuePrefix: 'present:' }] });
85
- if (answer === null)
86
- break;
87
- if (answer.startsWith('search:')) {
88
- const picked = await searchWorkspaceFile(ctx, path, '', invocation.signal);
89
- if (picked === null)
90
- continue;
91
- path = picked;
92
- continue;
93
- }
94
- if (answer.startsWith('present:')) {
95
- const files = deliverableFiles(invocation.agent.session.snapshotEvents()).map(path => ({ path, label: path }));
96
- if (files.length === 0) {
97
- ctx.tui.notice('No deliverables in this session.');
98
- continue;
99
- }
100
- await reviewFiles(ctx.tui, 'Deliverables', cwd, files, index => filePreview(resolve(cwd, files[index]?.path ?? ''), invocation.signal), invocation.signal, undefined, false);
101
- }
102
- else
103
- path = answer;
104
- }
105
- return { kind: 'success' };
106
- }
28
+ /** Staged leaf names the picker offers, mapped back to the durable reference. */
29
+ const ADD_CANDIDATE_PREFIX = 'add:';
30
+ /**
31
+ * One attachment surface, not three. A path argument attaches immediately; no
32
+ * argument opens the session's stored attachments with an Add entry at the top,
33
+ * so reading what is there and adding something new are the same gesture
34
+ * instead of two commands the reader has to keep apart.
35
+ */
107
36
  export async function attachFile(ctx, invocation) {
37
+ const input = invocation.rawInput.trim();
38
+ // A bare `/attach` reads this session's log, which needs no composer; asking
39
+ // for a path, or offering to add one, is the part that does.
40
+ if (input === '' && ctx.tui.interactive !== true)
41
+ return listAttachments(ctx, invocation);
42
+ if (input === '')
43
+ return attachments(ctx, invocation);
108
44
  if (ctx.tui.interactive !== true || ctx.tui.stageFileAttachment === undefined)
109
45
  return { kind: 'error', text: 'File drafts require an interactive composer.' };
110
- let input = invocation.rawInput.trim();
111
- if (input === '')
112
- input = await ctx.tui.prompt({ title: 'Attach file', question: 'Path to the file', allowCustom: true, notify: false, signal: invocation.signal }) ?? '';
113
- if (input === '' || invocation.signal.aborted)
114
- return { kind: 'success' };
46
+ return stageAttachment(ctx, invocation, input);
47
+ }
48
+ /** Plain-mode list: the same rows the picker offers, as transcript text. */
49
+ function listAttachments(_ctx, invocation) {
50
+ const refs = logAttachments(invocation.agent.session.snapshotEvents());
51
+ return { kind: 'success', text: refs.map(ref => `${ref.name ?? ref.attachmentId} · ${ref.bytes} bytes`).join('\n') || 'No attachments in this session.' };
52
+ }
53
+ async function stageAttachment(ctx, invocation, input) {
54
+ if (ctx.tui.stageFileAttachment === undefined)
55
+ return { kind: 'error', text: 'File drafts require an interactive composer.' };
115
56
  const path = userPath(input, currentWorkingDirectory(ctx, invocation.agent.session));
116
57
  const info = await stat(path);
117
58
  if (!info.isFile())
@@ -128,16 +69,32 @@ export async function attachFile(ctx, invocation) {
128
69
  }
129
70
  }
130
71
  async function attachments(ctx, invocation) {
131
- const refs = logAttachments(invocation.agent.session.snapshotEvents());
132
72
  if (ctx.tui.interactive !== true)
133
- return { kind: 'success', text: refs.map(ref => `${ref.name ?? ref.attachmentId} · ${ref.bytes} bytes`).join('\n') || 'No attachments in this session.' };
73
+ return listAttachments(ctx, invocation);
134
74
  while (!invocation.signal.aborted) {
135
- const answer = await ctx.tui.prompt({ title: 'Attachments', question: 'Choose a stored attachment', emptyText: 'No attachments in this session.',
136
- presentation: 'fullscreen-list', optionLayout: 'compact', filterable: true, allowCustom: false, signal: invocation.signal,
75
+ // Re-read every pass: adding a file during this loop has to show up in it.
76
+ const refs = logAttachments(invocation.agent.session.snapshotEvents());
77
+ const answer = await ctx.tui.prompt({
78
+ title: 'Attachments',
79
+ question: ctx.tui.stageFileAttachment === undefined ? 'Choose a stored attachment' : 'Choose a stored attachment, or add a file',
80
+ presentation: 'card', filterable: true, allowCustom: false, signal: invocation.signal,
137
81
  notify: false,
138
- options: refs.map((ref, index) => ({ label: ref.name ?? String(ref.attachmentId), value: String(index), description: `${ref.bytes.toLocaleString()} bytes · ${'mediaType' in ref ? ref.mediaType : 'file'}` })) });
82
+ options: [
83
+ ...(ctx.tui.stageFileAttachment === undefined
84
+ ? []
85
+ : [{ label: 'Add a file', value: ADD_CANDIDATE_PREFIX, description: 'Attach a new file from disk without sending it' }]),
86
+ ...refs.map((ref, index) => ({ label: ref.name ?? String(ref.attachmentId), value: String(index), description: `${ref.bytes.toLocaleString()} bytes · ${'mediaType' in ref ? ref.mediaType : 'file'}` })),
87
+ ],
88
+ });
139
89
  if (answer === null)
140
90
  break;
91
+ if (answer === ADD_CANDIDATE_PREFIX && ctx.tui.stageFileAttachment !== undefined) {
92
+ const staged = await stageAttachment(ctx, invocation, await ctx.tui.prompt(askPrompt({ title: 'Attach file', question: 'Path to the file', signal: invocation.signal })) ?? '');
93
+ if (staged.kind === 'error')
94
+ return staged;
95
+ // The list the reader just left is now stale; reopen it with the new row.
96
+ continue;
97
+ }
141
98
  const ref = refs[Number(answer)];
142
99
  if (ref === undefined)
143
100
  continue;
@@ -177,9 +134,12 @@ export function apply(ctx) {
177
134
  }
178
135
  };
179
136
  registerCommands(ctx, [
180
- { name: 'files', description: 'Browse workspace files and session deliverables', input: { hint: '[path]' }, handler: safe(browse) },
181
- { name: 'attach', description: 'Add a file to the composer without sending it', input: { hint: '[path]' }, handler: safe(attachFile) },
182
- { name: 'attachments', description: 'View this session’s stored attachments', handler: safe(attachments) },
137
+ {
138
+ name: 'attach',
139
+ description: 'Attach a file to the composer, or review what this session already attached',
140
+ input: { hint: '[path]' },
141
+ handler: safe(attachFile),
142
+ },
183
143
  ], 'omdsh file interaction');
184
144
  }
185
145
  //# sourceMappingURL=files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/commands/files.ts"],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OAAO,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAA;QAAC,CAAC;IAClN,CAAC,CAAA;IACD,gBAAgB,CAAC,GAAG,EAAE;QACpB;YACE,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6EAA6E;YAC1F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;SAC1B;KACF,EAAE,wBAAwB,CAAC,CAAA;AAC9B,CAAC"}
@@ -1,14 +1,29 @@
1
1
  /**
2
2
  * Human-facing background-job surface over the Harness job registry.
3
- * `/jobs` lists this session's jobs; `/jobs kill <id>` requests cancellation.
4
- * Output stays with the model: the registry's read cursor is consuming, so a
5
- * human read would steal the model's next `job_output`.
3
+ * `/jobs` lists this session's jobs, `/jobs <id>` replays one run's observer-only
4
+ * narration, and `/jobs kill <id>` requests cancellation.
5
+ *
6
+ * Reading `stdout` and `stderr` stays with the model: those channels feed the
7
+ * registry's consuming cursor, so a human read would steal the model's next
8
+ * `job_output`. The `log` channel is the opposite — the Harness marks it as
9
+ * producer narration that only observers see, which is why a workflow's phase
10
+ * lines can be replayed here without taking anything from the model.
11
+ *
6
12
  * @module @agi-fans/dsh-tui/command-jobs
7
13
  */
8
14
  import type { Context } from '@deepseek-ai/cordis';
9
- import { type JobView } from '@deepseek-ai/dsh-jobs';
15
+ import { type JobOutputRead, type JobView } from '@deepseek-ai/dsh-jobs';
10
16
  export declare const name = "omdsh-command-jobs";
11
17
  export declare const inject: string[];
12
18
  /** Markdown panel for `/jobs`; `now` is injected so the rendering stays pure. */
13
19
  export declare function jobsText(jobs: readonly JobView[], now: number): string;
20
+ /**
21
+ * The observer-only narration of one run, newest last.
22
+ *
23
+ * `readAt` from zero reads retained bytes at absolute offsets without moving the
24
+ * model's cursor; only `log` chunks are printed, because `stdout` and `stderr`
25
+ * belong to the model's own read. A lossy read says so rather than pretending the
26
+ * run started where retention begins.
27
+ */
28
+ export declare function runText(snapshot: JobView, read: JobOutputRead, now: number): string;
14
29
  export declare function apply(ctx: Context): void;
@@ -1,8 +1,14 @@
1
1
  /**
2
2
  * Human-facing background-job surface over the Harness job registry.
3
- * `/jobs` lists this session's jobs; `/jobs kill <id>` requests cancellation.
4
- * Output stays with the model: the registry's read cursor is consuming, so a
5
- * human read would steal the model's next `job_output`.
3
+ * `/jobs` lists this session's jobs, `/jobs <id>` replays one run's observer-only
4
+ * narration, and `/jobs kill <id>` requests cancellation.
5
+ *
6
+ * Reading `stdout` and `stderr` stays with the model: those channels feed the
7
+ * registry's consuming cursor, so a human read would steal the model's next
8
+ * `job_output`. The `log` channel is the opposite — the Harness marks it as
9
+ * producer narration that only observers see, which is why a workflow's phase
10
+ * lines can be replayed here without taking anything from the model.
11
+ *
6
12
  * @module @agi-fans/dsh-tui/command-jobs
7
13
  */
8
14
  import { JobId } from '@deepseek-ai/dsh-jobs';
@@ -37,7 +43,7 @@ export function jobsText(jobs, now) {
37
43
  '|---|---|---|',
38
44
  ...jobs.map(job => `| \`${job.id}\` | ${statusCell(job, now)} | ${(job.label || '—').replace(/\|/gu, '\\|')} |`),
39
45
  '',
40
- '`/jobs kill <id>` stops a running job.',
46
+ '`/jobs <id>` replays a run\'s narration. `/jobs kill <id>` stops a running job.',
41
47
  ].join('\n');
42
48
  }
43
49
  function killJob(ctx, invocation) {
@@ -55,6 +61,41 @@ function killJob(ctx, invocation) {
55
61
  return { kind: 'error', text: error instanceof Error ? error.message : String(error) };
56
62
  }
57
63
  }
64
+ /**
65
+ * The observer-only narration of one run, newest last.
66
+ *
67
+ * `readAt` from zero reads retained bytes at absolute offsets without moving the
68
+ * model's cursor; only `log` chunks are printed, because `stdout` and `stderr`
69
+ * belong to the model's own read. A lossy read says so rather than pretending the
70
+ * run started where retention begins.
71
+ */
72
+ export function runText(snapshot, read, now) {
73
+ const narration = read.chunks.filter(chunk => chunk.channel === 'log');
74
+ const header = `${snapshot.label || snapshot.kind} · ${statusCell(snapshot, now)}`;
75
+ if (narration.length === 0) {
76
+ return [header, '', read.chunks.length === 0
77
+ ? 'This run has not narrated anything yet.'
78
+ : 'This run only wrote model-facing output, which stays with the model.'].join('\n');
79
+ }
80
+ return [
81
+ header,
82
+ '',
83
+ ...(read.lossy ? ['Earlier narration is no longer retained.', ''] : []),
84
+ ...narration.map(chunk => (chunk.gapBefore === true ? '…\n' : '') + chunk.text.replace(/\n$/u, '')),
85
+ ].join('\n');
86
+ }
87
+ function showRun(ctx, invocation, id) {
88
+ const sessionId = invocation.agent.session.id;
89
+ const snapshot = ctx.jobs.list(sessionId).find(job => String(job.id) === id);
90
+ if (snapshot === undefined)
91
+ return { kind: 'error', text: `No job ${id} in this session.` };
92
+ try {
93
+ return { kind: 'success', text: runText(snapshot, ctx.jobs.readAt(JobId(id), 0, sessionId), Date.now()) };
94
+ }
95
+ catch (error) {
96
+ return { kind: 'error', text: error instanceof Error ? error.message : String(error) };
97
+ }
98
+ }
58
99
  function showJobs(ctx, invocation) {
59
100
  const raw = invocation.rawInput.trim();
60
101
  if (raw === '') {
@@ -67,14 +108,16 @@ function showJobs(ctx, invocation) {
67
108
  return { kind: 'error', text: 'Usage: /jobs kill <id>' };
68
109
  return killJob(ctx, { ...invocation, rawInput: id });
69
110
  }
70
- return { kind: 'error', text: 'Usage: /jobs [kill <id>]' };
111
+ if (rest.length === 0)
112
+ return showRun(ctx, invocation, verb);
113
+ return { kind: 'error', text: 'Usage: /jobs [<id>|kill <id>]' };
71
114
  }
72
115
  export function apply(ctx) {
73
116
  registerCommands(ctx, [
74
117
  {
75
118
  name: 'jobs',
76
- description: 'List background jobs or stop one',
77
- input: { hint: '[kill <id>]' },
119
+ description: 'List background jobs, replay one run, or stop one',
120
+ input: { hint: '[<id>|kill <id>]' },
78
121
  handler: invocation => showJobs(ctx, invocation),
79
122
  },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,EAAE,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,gBAAgB,CAAC,GAAG,EAAE;QACpB;YACE,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,mDAAmD;YAChE,KAAK,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;YACnC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;SACjD;KACF,EAAE,oBAAoB,CAAC,CAAA;AAC1B,CAAC"}
@@ -6,13 +6,12 @@ import { addModelFavorite, readModelFavorites, removeModelFavorite, updateFavori
6
6
  import { registerCommands } from "./registration.js";
7
7
  export const name = 'omdsh-command-model';
8
8
  export const inject = ['commands', 'omdshSession', 'tui', 'llm'];
9
- const FULLSCREEN_CHOICE_THRESHOLD = 8;
10
- function fixedChoice(optionCount) {
11
- const fullscreen = optionCount > FULLSCREEN_CHOICE_THRESHOLD;
9
+ function fixedChoice() {
10
+ // Nothing here decides how tall the list is: a list is a list, and the card
11
+ // windows it. `optionCount` stays a parameter because the label names the size.
12
12
  return {
13
- ...(fullscreen ? { presentation: 'fullscreen-list' } : {}),
14
- optionLayout: 'compact',
15
- filterable: fullscreen,
13
+ presentation: 'card',
14
+ filterable: true,
16
15
  allowCustom: false,
17
16
  notify: false,
18
17
  };
@@ -203,6 +202,29 @@ async function loadCatalog(ctx) {
203
202
  }
204
203
  return catalog;
205
204
  }
205
+ /**
206
+ * Marker the prompt prepends when the reader asks for one session only.
207
+ *
208
+ * NUL cannot occur in a model id, so it separates the scope from the value
209
+ * without needing a second return channel from the picker.
210
+ */
211
+ const SESSION_SCOPE = '\u0000session:';
212
+ /** Every model as one row, with the current and favorite ones marked. */
213
+ function catalogOptions(catalog, current, favorites) {
214
+ return catalog.map(entry => {
215
+ const id = `${entry.provider}/${entry.model}`;
216
+ const isCurrent = entry.provider === current.provider && entry.model === current.model;
217
+ const isFavorite = favorites.some(favorite => favorite.provider === entry.provider && favorite.model === entry.model);
218
+ return {
219
+ label: id,
220
+ value: id,
221
+ ...(entry.description === '' ? {} : { description: entry.description }),
222
+ ...(isCurrent
223
+ ? { badge: { label: 'current', tone: 'success' } }
224
+ : isFavorite ? { badge: { label: 'favorite', tone: 'muted' } } : {}),
225
+ };
226
+ });
227
+ }
206
228
  function pickEffort(current, info) {
207
229
  if (current.reasoningEffort === undefined)
208
230
  return undefined;
@@ -248,7 +270,7 @@ async function resolveQuerySelect(ctx, invocation, query, sessionOnly) {
248
270
  }
249
271
  else {
250
272
  const raw = await ctx.tui.prompt({
251
- ...fixedChoice(matches.length),
273
+ ...fixedChoice(),
252
274
  title: sessionOnly ? 'Model (session)' : 'Model',
253
275
  question: `Matches for "${query.trim()}"; use provider:model to disambiguate`,
254
276
  options: matches.map(match => ({ label: `${match.provider}/${match.model}`, value: `${match.provider}/${match.model}`, description: match.description })),
@@ -268,14 +290,13 @@ async function selectModel(ctx, invocation) {
268
290
  const body = sessionOnly ? raw.slice('--session'.length).trim() : raw;
269
291
  const action = body.toLowerCase();
270
292
  if (sessionOnly) {
271
- // Session scope accepts a query only; subcommand flags cannot combine.
272
- if (body === '')
273
- return { kind: 'error', text: 'Usage: /model --session <query>' };
293
+ // Session scope takes a query, or none at all to open the same list.
274
294
  if (action === 'next' || action === 'previous' || action === 'reasoning'
275
295
  || action === 'favorite' || action === 'unfavorite' || action === 'favorites') {
276
296
  return { kind: 'error', text: 'Invalid arguments: /model --session does not take a subcommand.' };
277
297
  }
278
- return resolveQuerySelect(ctx, invocation, body, true);
298
+ if (body !== '')
299
+ return resolveQuerySelect(ctx, invocation, body, true);
279
300
  }
280
301
  if (action === 'next')
281
302
  return cycleFavorite(ctx, invocation, 1);
@@ -287,83 +308,94 @@ async function selectModel(ctx, invocation) {
287
308
  return manageFavorite(ctx, invocation, action);
288
309
  if (body !== '')
289
310
  return resolveQuerySelect(ctx, invocation, body, false);
290
- const providers = ctx.llm.listProviders();
291
- if (providers.length === 0)
311
+ const catalog = await loadCatalog(ctx);
312
+ if (catalog.length === 0)
292
313
  return { kind: 'error', text: 'No model providers are registered.' };
293
314
  const current = ctx.omdshSession.selection(invocation.agent);
294
- let provider = providers[0]?.id;
295
- if (providers.length > 1) {
296
- const providerRaw = await ctx.tui.prompt({
297
- ...fixedChoice(providers.length),
298
- title: 'Model provider',
299
- question: 'Choose a provider',
300
- options: providers.map(entry => ({
301
- label: entry.id === 'deepseek-official' ? 'deepseek' : entry.id,
302
- value: entry.id,
303
- })),
304
- initialValue: current.provider,
305
- signal: invocation.signal,
306
- });
307
- if (providerRaw === null)
308
- return { kind: 'success' };
309
- provider = selected(providerRaw, providers.map(entry => entry.id));
310
- if (provider === undefined || !providers.some(entry => entry.id === provider)) {
311
- return { kind: 'error', text: `Unknown provider: ${providerRaw}` };
312
- }
313
- }
314
- if (provider === undefined)
315
- return { kind: 'error', text: 'No model provider is available.' };
316
- const models = await ctx.llm.listModels(provider);
317
- if (models.length === 0)
318
- return { kind: 'error', text: `No models are available for ${provider}.` };
319
- const modelRaw = await ctx.tui.prompt({
320
- ...fixedChoice(models.length),
321
- title: 'Model',
322
- question: `Choose a model for ${provider}`,
323
- options: models.map(model => ({ label: model.id, value: model.id, description: model.description ?? model.name })),
324
- ...(provider === current.provider ? { initialValue: current.model } : {}),
315
+ /**
316
+ * One list for every provider.
317
+ *
318
+ * Choosing a model used to take three prompts — provider, then model, then
319
+ * reasoning effort — and the first two were asking the reader to narrow a list
320
+ * the terminal can filter itself. Provider is not a decision a reader needs to
321
+ * make first: it is one column of the model they already have in mind, so it
322
+ * becomes part of the row and part of the search text.
323
+ */
324
+ const favorites = readModelFavorites(favoritesPath());
325
+ const picked = await ctx.tui.prompt({
326
+ presentation: 'card',
327
+ filterable: true,
328
+ allowCustom: false,
329
+ notify: false,
330
+ title: sessionOnly ? 'Model · this session' : 'Model',
331
+ question: 'Type to search every provider, then Enter to switch',
332
+ options: catalogOptions(catalog, current, favorites),
333
+ ...(current.provider === '' || current.model === '' ? {} : { initialValue: `${current.provider}/${current.model}` }),
334
+ // Enter applies the scope the reader already asked for. The action is the
335
+ // other scope, so "just this once" no longer requires knowing the model id
336
+ // before opening the list.
337
+ ...(sessionOnly
338
+ ? {}
339
+ : { actions: [{ key: 'ctrl+d', label: 'This session only', valuePrefix: SESSION_SCOPE }] }),
325
340
  signal: invocation.signal,
326
341
  });
327
- if (modelRaw === null)
342
+ if (picked === null)
343
+ return { kind: 'success' };
344
+ const scoped = picked.startsWith(SESSION_SCOPE);
345
+ const chosen = scoped ? picked.slice(SESSION_SCOPE.length) : picked;
346
+ const entry = catalog.find(candidate => `${candidate.provider}/${candidate.model}` === chosen);
347
+ if (entry === undefined)
348
+ return { kind: 'error', text: `Unknown model: ${chosen}` };
349
+ const useSession = sessionOnly || scoped;
350
+ const info = await ctx.llm.resolveModelInfo(entry.provider, entry.model, invocation.signal);
351
+ const reasoningEffort = await resolveEffort(ctx, invocation, current, info, useSession);
352
+ if (reasoningEffort === null)
328
353
  return { kind: 'success' };
329
- const model = selected(modelRaw, models.map(entry => entry.id));
330
- if (model === undefined || !models.some(entry => entry.id === model)) {
331
- return { kind: 'error', text: `Unknown model: ${modelRaw}` };
332
- }
333
- const info = await ctx.llm.resolveModelInfo(provider, model, invocation.signal);
334
- let reasoningEffort = current.reasoningEffort;
335
- if (info.reasoning === undefined) {
336
- reasoningEffort = undefined;
337
- }
338
- else {
339
- const effortRaw = await ctx.tui.prompt({
340
- ...fixedChoice(info.reasoning.efforts.length),
341
- title: 'Reasoning effort',
342
- question: 'Choose reasoning effort',
343
- options: info.reasoning.efforts.map(effort => ({ label: String(effort.id), description: effort.description ?? effort.name })),
344
- ...(reasoningEffort === undefined ? {} : { initialValue: String(reasoningEffort) }),
345
- signal: invocation.signal,
346
- });
347
- if (effortRaw === null)
348
- return { kind: 'success' };
349
- const effortIds = info.reasoning.efforts.map(entry => String(entry.id));
350
- const resolved = selected(effortRaw, effortIds);
351
- if (resolved === undefined || !effortIds.includes(resolved)) {
352
- return { kind: 'error', text: `Unknown reasoning effort: ${effortRaw}` };
353
- }
354
- reasoningEffort = ReasoningEffortId(resolved);
355
- }
356
354
  const selection = {
357
- provider,
358
- model,
355
+ provider: entry.provider,
356
+ model: entry.model,
359
357
  ...(reasoningEffort === undefined ? {} : { reasoningEffort }),
360
358
  };
361
- await ctx.omdshSession.changeSelection(invocation.agent, selection, info);
359
+ await ctx.omdshSession.changeSelection(invocation.agent, selection, info, { persist: !useSession });
362
360
  return {
363
361
  kind: 'success',
364
- text: `Default model: ${provider}/${model}${reasoningEffort === undefined ? '' : ` (${String(reasoningEffort)})`}`,
362
+ text: `${useSession ? 'Session' : 'Default'} model: ${entry.provider}/${entry.model}`
363
+ + (reasoningEffort === undefined ? '' : ` (${String(reasoningEffort)})`),
365
364
  };
366
365
  }
366
+ /**
367
+ * Ask for a reasoning effort only when the choice is actually open.
368
+ *
369
+ * The prompt used to appear on every switch to a reasoning model, including one
370
+ * that kept an effort the new model also offers — a question whose answer was
371
+ * already decided. It now appears when the new model's vocabulary does not
372
+ * contain the current effort, which is the only case where the reader has
373
+ * something to say. `undefined` means "no reasoning", `null` means "cancelled".
374
+ */
375
+ async function resolveEffort(ctx, invocation, current, info, sessionOnly) {
376
+ const efforts = info.reasoning?.efforts ?? [];
377
+ if (efforts.length === 0)
378
+ return undefined;
379
+ const ids = efforts.map(effort => String(effort.id));
380
+ const inherited = current.reasoningEffort === undefined ? undefined : String(current.reasoningEffort);
381
+ if (inherited !== undefined && ids.includes(inherited))
382
+ return ReasoningEffortId(inherited);
383
+ // A single effort is not a choice; take it rather than asking.
384
+ if (ids.length === 1)
385
+ return ReasoningEffortId(ids[0]);
386
+ const raw = await ctx.tui.prompt({
387
+ ...fixedChoice(),
388
+ title: sessionOnly ? 'Reasoning effort · this session' : 'Reasoning effort',
389
+ question: 'Choose reasoning effort',
390
+ options: efforts.map(effort => ({ label: String(effort.id), description: effort.description ?? effort.name })),
391
+ ...(ids[0] === undefined ? {} : { initialValue: ids[0] }),
392
+ signal: invocation.signal,
393
+ });
394
+ if (raw === null)
395
+ return null;
396
+ const resolved = selected(raw, ids);
397
+ return resolved === undefined || !ids.includes(resolved) ? undefined : ReasoningEffortId(resolved);
398
+ }
367
399
  export function apply(ctx) {
368
400
  registerCommands(ctx, [
369
401
  {