@kabmo-labs/kabmo 0.28.0 → 0.30.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 (232) hide show
  1. package/bunfig.toml +6 -0
  2. package/dist/client/index.html +2 -2
  3. package/dist/client/index.js +481 -472
  4. package/dist/client/static/js/{index-xzvyrxya.js → index-5vjbp04s.js} +1193 -1049
  5. package/dist/client/static/js/index-naa91727.css +1 -0
  6. package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
  7. package/package.json +3 -2
  8. package/public/manifest.webmanifest +1 -0
  9. package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
  10. package/src/client/components/common/ComposerTextarea.tsx +6 -0
  11. package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
  12. package/src/client/components/common/ReloadPageButton.tsx +11 -2
  13. package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
  14. package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
  15. package/src/client/components/common/file-icon/index.tsx +7 -1
  16. package/src/client/components/common/harness-glyph/brands.ts +7 -1
  17. package/src/client/components/common/image-viewer/index.tsx +37 -165
  18. package/src/client/components/common/picker-search/index.tsx +70 -0
  19. package/src/client/components/common/search-select/index.tsx +2 -7
  20. package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
  21. package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
  22. package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
  23. package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
  24. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
  25. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
  26. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
  27. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
  28. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
  29. package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
  30. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +6 -4
  31. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
  32. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +25 -0
  33. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
  34. package/src/client/components/settings/Sidebar.tsx +6 -8
  35. package/src/client/components/settings/categories/HarnessSettings.tsx +4 -2
  36. package/src/client/components/settings/categories/PanelPluginSettings.tsx +2 -2
  37. package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
  38. package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
  39. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
  40. package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
  41. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
  42. package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
  43. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
  44. package/src/client/components/settings/groups.test.tsx +2 -2
  45. package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
  46. package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
  47. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +4 -1
  48. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
  49. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +8 -3
  50. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
  51. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +42 -15
  52. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +28 -0
  53. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +28 -10
  54. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
  55. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
  56. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
  57. package/src/client/components/workspace/editor/FilePane.tsx +32 -0
  58. package/src/client/components/workspace/editor/Toolbar.tsx +4 -0
  59. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +1 -0
  60. package/src/client/components/workspace/editor/toolbar-clusters.tsx +5 -2
  61. package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
  62. package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
  63. package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
  64. package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
  65. package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
  66. package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
  67. package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
  68. package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
  69. package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
  70. package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
  71. package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
  72. package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
  73. package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
  74. package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
  75. package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
  76. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
  77. package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
  78. package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
  79. package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
  80. package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
  81. package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
  82. package/src/client/components/workspace/file-explorer/index.tsx +53 -29
  83. package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
  84. package/src/client/data/settings/omp-schema.json +169 -22
  85. package/src/client/glass-palette.test.ts +72 -0
  86. package/src/client/glass.css +39 -14
  87. package/src/client/glass.test.ts +28 -67
  88. package/src/client/hooks/chat/composer/history.test.ts +267 -0
  89. package/src/client/hooks/chat/composer/history.ts +146 -0
  90. package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
  91. package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
  92. package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
  93. package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
  94. package/src/client/hooks/editor/file-editor-types.ts +15 -0
  95. package/src/client/hooks/editor/save-bytes.ts +79 -0
  96. package/src/client/hooks/editor/use-dirty-tracking.test.ts +73 -0
  97. package/src/client/hooks/editor/use-dirty-tracking.ts +96 -0
  98. package/src/client/hooks/editor/use-file-cache.ts +1 -0
  99. package/src/client/hooks/editor/use-file-editor.test.ts +30 -0
  100. package/src/client/hooks/editor/use-file-editor.ts +20 -17
  101. package/src/client/hooks/editor/use-file-read.ts +21 -2
  102. package/src/client/hooks/editor/use-grid-selection.ts +160 -0
  103. package/src/client/hooks/models/use-harness-update.test.ts +35 -2
  104. package/src/client/hooks/models/use-harness-update.ts +49 -10
  105. package/src/client/hooks/workspace/diff-file.test.ts +72 -0
  106. package/src/client/hooks/workspace/diff-file.ts +12 -6
  107. package/src/client/hooks/workspace/file-archive.ts +220 -0
  108. package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
  109. package/src/client/hooks/workspace/file-clipboard.ts +37 -26
  110. package/src/client/hooks/workspace/file-selection.test.ts +67 -0
  111. package/src/client/hooks/workspace/file-selection.ts +156 -0
  112. package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
  113. package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
  114. package/src/client/lib/editor/workbook-drafts.ts +42 -0
  115. package/src/client/lib/launch/file-handlers.ts +2 -2
  116. package/src/client/lib/scrollbar-activity.test.ts +21 -88
  117. package/src/client/lib/scrollbar-activity.ts +71 -73
  118. package/src/client/lib/scrollbar-events.ts +143 -0
  119. package/src/client/lib/scrollbar-input.test.ts +126 -0
  120. package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
  121. package/src/client/tailwind.css +32 -1
  122. package/src/server/db.server.test.ts +50 -1
  123. package/src/server/db.server.ts +36 -3
  124. package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
  125. package/src/server/lib/chat/prompt-history.server.ts +65 -0
  126. package/src/server/lib/chat/schema.server.ts +35 -0
  127. package/src/server/lib/db/schema.ts +3 -0
  128. package/src/server/lib/fs/archive.test.ts +198 -0
  129. package/src/server/lib/fs/archive.ts +278 -0
  130. package/src/server/lib/fs/git-diff.test.ts +26 -1
  131. package/src/server/lib/fs/git-diff.ts +43 -15
  132. package/src/server/lib/harness/launch-table.ts +19 -0
  133. package/src/server/lib/harness/provider-entry.ts +1 -1
  134. package/src/server/lib/harness/provider-file.server.ts +1 -1
  135. package/src/server/lib/harness/provider-sources.server.ts +2 -1
  136. package/src/server/lib/harness/provider-write.server.ts +2 -1
  137. package/src/server/lib/harness/update-job-store.ts +12 -0
  138. package/src/server/lib/harness/update-queue.server.ts +15 -10
  139. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
  140. package/src/server/lib/omp/rpc/frame-fold.test.ts +5 -1
  141. package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
  142. package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
  143. package/src/server/lib/omp/session/delete.server.ts +1 -0
  144. package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
  145. package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
  146. package/src/server/lib/panels/auto-update.server.test.ts +5 -2
  147. package/src/server/lib/panels/git-update.server.test.ts +5 -2
  148. package/src/server/lib/panels/install.server.test.ts +5 -2
  149. package/src/server/lib/panels/remove.server.test.ts +5 -2
  150. package/src/server/routes/agent/command.ts +11 -0
  151. package/src/server/routes/agent/new.ts +5 -0
  152. package/src/server/routes/chat/index.ts +5 -0
  153. package/src/server/routes/chat/prompt-history.test.ts +67 -0
  154. package/src/server/routes/chat/prompt-history.ts +31 -0
  155. package/src/server/routes/chat/stream.test.ts +21 -0
  156. package/src/server/routes/chat/stream.ts +5 -0
  157. package/src/server/routes/fs/action-archive.test.ts +128 -0
  158. package/src/server/routes/fs/action-bulk.ts +106 -0
  159. package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
  160. package/src/server/routes/fs/action-transfer.test.ts +26 -0
  161. package/src/server/routes/fs/action.ts +91 -11
  162. package/src/server/routes/fs/archive.ts +20 -0
  163. package/src/server/routes/fs/grant.test.ts +5 -2
  164. package/src/server/routes/fs/index.ts +2 -0
  165. package/src/server/routes/fs/scope.test.ts +6 -2
  166. package/src/server/routes/harness/import-action.ts +1 -1
  167. package/src/server/routes/harness/root.ts +6 -1
  168. package/src/server/routes/harness/summary.test.ts +50 -0
  169. package/src/server/routes/harness/update-status.ts +41 -2
  170. package/src/server/routes/harness/update.test.ts +56 -2
  171. package/src/server/routes/sessions/delete.test.ts +4 -0
  172. package/src/shared/lib/chat/ask-form/index.ts +39 -31
  173. package/src/shared/lib/chat/ask-form/labels.ts +46 -0
  174. package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
  175. package/src/shared/lib/chat/ask-form.test.ts +57 -0
  176. package/src/shared/lib/chat/ask-questions.ts +31 -0
  177. package/src/shared/lib/chat/composer/history.test.ts +67 -0
  178. package/src/shared/lib/chat/composer/history.ts +61 -0
  179. package/src/shared/lib/chat/irc-notice.ts +42 -0
  180. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +2 -0
  181. package/src/shared/lib/chat/todo/parser.ts +6 -4
  182. package/src/shared/lib/fs/archive.test.ts +101 -0
  183. package/src/shared/lib/fs/archive.ts +191 -0
  184. package/src/shared/lib/fs/clipboard.test.ts +32 -7
  185. package/src/shared/lib/fs/clipboard.ts +59 -14
  186. package/src/shared/lib/fs/csv.test.ts +50 -0
  187. package/src/shared/lib/fs/csv.ts +40 -0
  188. package/src/shared/lib/fs/document-kind.test.ts +13 -6
  189. package/src/shared/lib/fs/document-kind.ts +18 -6
  190. package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
  191. package/src/shared/lib/fs/file-kind.test.ts +2 -7
  192. package/src/shared/lib/fs/file-kind.ts +4 -2
  193. package/src/shared/lib/fs/grid-edit.test.ts +24 -0
  194. package/src/shared/lib/fs/grid-edit.ts +29 -0
  195. package/src/shared/lib/fs/grid-selection.test.ts +137 -0
  196. package/src/shared/lib/fs/grid-selection.ts +138 -0
  197. package/src/shared/lib/harness/brand-color.ts +5 -0
  198. package/src/shared/lib/harness/catalog.test.ts +22 -0
  199. package/src/shared/lib/harness/catalog.ts +12 -1
  200. package/src/shared/lib/harness/config-fields.test.ts +25 -0
  201. package/src/shared/lib/harness/config-fields.ts +33 -3
  202. package/src/shared/lib/harness/dialects.ts +1 -1
  203. package/src/shared/lib/harness/mcp-facts.ts +4 -0
  204. package/src/shared/lib/harness/provider-contracts.ts +109 -0
  205. package/src/shared/lib/harness/provider-facts.test.ts +2 -1
  206. package/src/shared/lib/harness/provider-facts.ts +24 -115
  207. package/src/shared/lib/harness/provider-lookup.ts +37 -0
  208. package/src/shared/lib/harness/providers.ts +2 -1
  209. package/src/shared/lib/harness/updates.ts +10 -0
  210. package/src/shared/lib/icons/tint-hues.generated.ts +14 -13
  211. package/src/shared/lib/omp/session/mapper.test.ts +31 -0
  212. package/src/shared/lib/omp/session/mapper.ts +17 -0
  213. package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
  214. package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
  215. package/src/shared/lib/omp/session/messages-map.ts +17 -0
  216. package/src/shared/lib/omp/session/wait.ts +10 -1
  217. package/src/shared/lib/settings/sections.ts +8 -4
  218. package/src/shared/lib/ui/picker-filter.test.ts +23 -0
  219. package/src/shared/lib/ui/picker-filter.ts +20 -0
  220. package/src/shared/types/chat.ts +4 -0
  221. package/src/shared/types/harness.ts +5 -1
  222. package/src/shared/types/omp/session.ts +18 -0
  223. package/src/shared/types/settings/state.ts +6 -6
  224. package/src/shared/types/todo.ts +3 -1
  225. package/src/test-support/file-actions.test-util.ts +4 -0
  226. package/src/test-support/file-archive.test-util.ts +41 -0
  227. package/src/test-support/file-clipboard.test-util.ts +9 -6
  228. package/src/test-support/file-editor.test-util.ts +3 -2
  229. package/src/test-support/glass-css.ts +30 -0
  230. package/src/test-support/harness-table.test-util.ts +2 -0
  231. package/src/test-support/preload.ts +46 -0
  232. package/dist/client/static/js/index-81f7berm.css +0 -1
@@ -0,0 +1,137 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The grid's selection arithmetic and its clipboard payload.
8
+ *
9
+ * Both fail silently when wrong: an off-by-one range copies the wrong block,
10
+ * and a payload that is not quoted correctly pastes as one column (or as extra
11
+ * rows) in Excel — the exact round trip the copy exists for.
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+ import {
16
+ cellAddress,
17
+ cellRange,
18
+ clampCell,
19
+ columnLabel,
20
+ moveCell,
21
+ rangeAddress,
22
+ rangeColumnCount,
23
+ rangeContains,
24
+ rangeRowCount,
25
+ rangeToTsv,
26
+ selectAllRange,
27
+ } from '@/shared/lib/fs/grid-selection';
28
+
29
+ describe('columnLabel', () => {
30
+ test('the first 26 columns are A..Z', () => {
31
+ expect(columnLabel(0)).toBe('A');
32
+ expect(columnLabel(25)).toBe('Z');
33
+ });
34
+
35
+ // Bijective base-26: there is no zero digit, so 26 is AA and not BA.
36
+ test('past Z the label carries', () => {
37
+ expect(columnLabel(26)).toBe('AA');
38
+ expect(columnLabel(27)).toBe('AB');
39
+ expect(columnLabel(51)).toBe('AZ');
40
+ expect(columnLabel(52)).toBe('BA');
41
+ expect(columnLabel(701)).toBe('ZZ');
42
+ expect(columnLabel(702)).toBe('AAA');
43
+ });
44
+ });
45
+
46
+ describe('addresses', () => {
47
+ test('a cell is its letter and its one-based row', () => {
48
+ expect(cellAddress({ row: 0, col: 0 })).toBe('A1');
49
+ expect(cellAddress({ row: 4, col: 2 })).toBe('C5');
50
+ });
51
+
52
+ test('a range names both corners, and a single cell names one', () => {
53
+ expect(rangeAddress({ top: 1, left: 1, bottom: 4, right: 3 })).toBe('B2:D5');
54
+ expect(rangeAddress({ top: 2, left: 2, bottom: 2, right: 2 })).toBe('C3');
55
+ });
56
+ });
57
+
58
+ describe('cellRange', () => {
59
+ test('the rectangle is the same whichever corner came first', () => {
60
+ const forward = cellRange({ row: 1, col: 1 }, { row: 4, col: 3 });
61
+ const backward = cellRange({ row: 4, col: 3 }, { row: 1, col: 1 });
62
+ expect(forward).toEqual({ top: 1, left: 1, bottom: 4, right: 3 });
63
+ expect(backward).toEqual(forward);
64
+ });
65
+
66
+ test('a single cell is a 1x1 range', () => {
67
+ const range = cellRange({ row: 2, col: 2 }, { row: 2, col: 2 });
68
+ expect(rangeRowCount(range)).toBe(1);
69
+ expect(rangeColumnCount(range)).toBe(1);
70
+ });
71
+
72
+ test('containment is inclusive on every edge', () => {
73
+ const range = { top: 1, left: 1, bottom: 3, right: 2 };
74
+ expect(rangeContains(range, 1, 1)).toBe(true);
75
+ expect(rangeContains(range, 3, 2)).toBe(true);
76
+ expect(rangeContains(range, 0, 1)).toBe(false);
77
+ expect(rangeContains(range, 1, 3)).toBe(false);
78
+ });
79
+ });
80
+
81
+ describe('clampCell and moveCell', () => {
82
+ test('a cell outside the grid is pulled to the nearest edge', () => {
83
+ expect(clampCell({ row: -3, col: -1 }, 5, 4)).toEqual({ row: 0, col: 0 });
84
+ expect(clampCell({ row: 99, col: 99 }, 5, 4)).toEqual({ row: 4, col: 3 });
85
+ });
86
+
87
+ test('a move stops at the edge instead of wrapping', () => {
88
+ expect(moveCell({ row: 0, col: 0 }, -1, 0, 5, 4)).toEqual({ row: 0, col: 0 });
89
+ expect(moveCell({ row: 4, col: 3 }, 1, 1, 5, 4)).toEqual({ row: 4, col: 3 });
90
+ expect(moveCell({ row: 2, col: 2 }, 1, -1, 5, 4)).toEqual({ row: 3, col: 1 });
91
+ });
92
+
93
+ test('an empty grid clamps to its only possible cell', () => {
94
+ expect(clampCell({ row: 3, col: 3 }, 0, 0)).toEqual({ row: 0, col: 0 });
95
+ });
96
+ });
97
+
98
+ describe('selectAllRange', () => {
99
+ test('covers every cell', () => {
100
+ expect(selectAllRange(3, 2)).toEqual({ top: 0, left: 0, bottom: 2, right: 1 });
101
+ });
102
+
103
+ test('an empty grid has nothing to select', () => {
104
+ expect(selectAllRange(0, 4)).toBeNull();
105
+ expect(selectAllRange(4, 0)).toBeNull();
106
+ });
107
+ });
108
+
109
+ describe('rangeToTsv', () => {
110
+ const rows = [
111
+ ['Name', 'Qty', 'Note'],
112
+ ['Widget', '3', 'plain'],
113
+ ['Gadget', '1', 'has, comma'],
114
+ ];
115
+
116
+ test('a block is tab-separated with CRLF between rows', () => {
117
+ expect(rangeToTsv(rows, { top: 0, left: 0, bottom: 1, right: 1 })).toBe('Name\tQty\r\nWidget\t3');
118
+ });
119
+
120
+ test('a single cell is one field', () => {
121
+ expect(rangeToTsv(rows, { top: 2, left: 2, bottom: 2, right: 2 })).toBe('has, comma');
122
+ });
123
+
124
+ // The failure this prevents: a cell holding a tab or a newline splits the
125
+ // pasted block into extra columns or rows.
126
+ test('a field with a tab, a newline or a quote is quoted and its quotes doubled', () => {
127
+ const tricky = [['a\tb', 'line\nbreak', 'say "hi"']];
128
+ expect(rangeToTsv(tricky, { top: 0, left: 0, bottom: 0, right: 2 })).toBe(
129
+ '"a\tb"\t"line\nbreak"\t"say ""hi"""',
130
+ );
131
+ });
132
+
133
+ test('a ragged row keeps the block shape with empty fields', () => {
134
+ const ragged = [['a'], ['b', 'c']];
135
+ expect(rangeToTsv(ragged, { top: 0, left: 0, bottom: 1, right: 1 })).toBe('a\t\r\nb\tc');
136
+ });
137
+ });
@@ -0,0 +1,138 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Cell geometry and clipboard text for the spreadsheet grid.
8
+ *
9
+ * The grid is a rectangle of cells, and every interaction on it — a click, a
10
+ * drag, an arrow key, a copy — is the same two facts: which cell is the anchor
11
+ * and which is the focus. Keeping that arithmetic here (pure, unit-tested)
12
+ * means the component only draws, and the two things that fail silently when
13
+ * wrong are pinned: a range that is off by one cell, and a clipboard payload
14
+ * that Excel reads as one column because a cell held a tab.
15
+ *
16
+ * Addresses are A1-style over the DATA rows: the grid's first data row is row
17
+ * 1, so `A1` is the top-left cell the user can select. The header strip is a
18
+ * label, not a row, and is deliberately not addressable.
19
+ */
20
+
21
+ /** A cell in the grid: zero-based row and column. */
22
+ export interface GridCell {
23
+ row: number;
24
+ col: number;
25
+ }
26
+
27
+ /** A rectangle of cells, inclusive on every edge. */
28
+ export interface GridRange {
29
+ top: number;
30
+ left: number;
31
+ bottom: number;
32
+ right: number;
33
+ }
34
+
35
+ /** The rectangle spanned by two cells, in either order. */
36
+ export function cellRange(a: GridCell, b: GridCell): GridRange {
37
+ return {
38
+ top: Math.min(a.row, b.row),
39
+ left: Math.min(a.col, b.col),
40
+ bottom: Math.max(a.row, b.row),
41
+ right: Math.max(a.col, b.col),
42
+ };
43
+ }
44
+
45
+ /** Whether a cell falls inside a range. */
46
+ export function rangeContains(range: GridRange, row: number, col: number): boolean {
47
+ return row >= range.top && row <= range.bottom && col >= range.left && col <= range.right;
48
+ }
49
+
50
+ /** How many rows a range covers. */
51
+ export function rangeRowCount(range: GridRange): number {
52
+ return range.bottom - range.top + 1;
53
+ }
54
+
55
+ /** How many columns a range covers. */
56
+ export function rangeColumnCount(range: GridRange): number {
57
+ return range.right - range.left + 1;
58
+ }
59
+
60
+ /**
61
+ * The spreadsheet letter for a zero-based column: 0 → `A`, 25 → `Z`, 26 → `AA`.
62
+ *
63
+ * Bijective base-26, not plain base-26: there is no zero digit, so the
64
+ * subtraction happens before the modulo and the quotient is floored after it.
65
+ */
66
+ export function columnLabel(index: number): string {
67
+ let remaining = index + 1;
68
+ let label = '';
69
+ while (remaining > 0) {
70
+ const digit = (remaining - 1) % 26;
71
+ label = String.fromCharCode(65 + digit) + label;
72
+ remaining = Math.floor((remaining - 1) / 26);
73
+ }
74
+ return label;
75
+ }
76
+
77
+ /** The A1 address of a cell. */
78
+ export function cellAddress(cell: GridCell): string {
79
+ return `${columnLabel(cell.col)}${cell.row + 1}`;
80
+ }
81
+
82
+ /** The A1 address of a range: `B2` for one cell, `B2:D5` for a block. */
83
+ export function rangeAddress(range: GridRange): string {
84
+ const start = cellAddress({ row: range.top, col: range.left });
85
+ const end = cellAddress({ row: range.bottom, col: range.right });
86
+ return start === end ? start : `${start}:${end}`;
87
+ }
88
+
89
+ /** A cell clamped into a grid of `rowCount` × `columnCount` cells. */
90
+ export function clampCell(cell: GridCell, rowCount: number, columnCount: number): GridCell {
91
+ return {
92
+ row: Math.min(Math.max(cell.row, 0), Math.max(rowCount - 1, 0)),
93
+ col: Math.min(Math.max(cell.col, 0), Math.max(columnCount - 1, 0)),
94
+ };
95
+ }
96
+
97
+ /** A cell moved by a delta and clamped to the grid. */
98
+ export function moveCell(
99
+ cell: GridCell,
100
+ rowDelta: number,
101
+ columnDelta: number,
102
+ rowCount: number,
103
+ columnCount: number,
104
+ ): GridCell {
105
+ return clampCell({ row: cell.row + rowDelta, col: cell.col + columnDelta }, rowCount, columnCount);
106
+ }
107
+
108
+ /** The whole grid as a range, or null when it has no cells. */
109
+ export function selectAllRange(rowCount: number, columnCount: number): GridRange | null {
110
+ if (rowCount <= 0 || columnCount <= 0) return null;
111
+ return { top: 0, left: 0, bottom: rowCount - 1, right: columnCount - 1 };
112
+ }
113
+
114
+ /**
115
+ * The selected block as tab-separated text, ready for Excel, Numbers or Sheets.
116
+ *
117
+ * Excel's own clipboard format is TSV, and a field that contains a tab, a line
118
+ * break or a quote is wrapped in quotes with its quotes doubled — the same
119
+ * convention as CSV. Without that a cell holding a newline splits one row into
120
+ * two when pasted back into a spreadsheet, which is the exact round trip this
121
+ * copy exists for.
122
+ *
123
+ * Rows are joined with CRLF because that is what Excel writes to the clipboard
124
+ * on every platform; a bare LF is accepted by most consumers but not all.
125
+ * Missing cells (a ragged row) are empty fields, so the block keeps its shape.
126
+ */
127
+ export function rangeToTsv(rows: readonly (readonly string[])[], range: GridRange): string {
128
+ const lines: string[] = [];
129
+ for (let row = range.top; row <= range.bottom; row += 1) {
130
+ const cells: string[] = [];
131
+ for (let col = range.left; col <= range.right; col += 1) {
132
+ const value = rows[row]?.[col] ?? '';
133
+ cells.push(/[\t\r\n"]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value);
134
+ }
135
+ lines.push(cells.join('\t'));
136
+ }
137
+ return lines.join('\r\n');
138
+ }
@@ -45,6 +45,11 @@ const HARNESS_BASES: Readonly<Record<string, string>> = {
45
45
  zcode: '#000000',
46
46
  // A multi-stop mark; the blue stop is the one its own dominant uses carry.
47
47
  antigravity: '#3186FF',
48
+ // jcode publishes a near-monochrome ring (`#111`), so it paints in the theme's
49
+ // ink like the other wordmark-style marks.
50
+ jcode: '#111111',
51
+ // xAI publishes a one-colour mark.
52
+ grok: '#000000',
48
53
  };
49
54
 
50
55
  /**
@@ -67,6 +67,28 @@ describe('harness catalog after the Gemini retirement', () => {
67
67
  expect(command).not.toEqual(['zcode', 'acp']);
68
68
  });
69
69
 
70
+ test('jcode is listed and launches its own `acp` subcommand', () => {
71
+ // jcode ships the ACP server itself (`src/cli/acp.rs`), backed by its
72
+ // daemon; the vendor installer is the only install path.
73
+ const descriptor = harnessDescriptor('jcode');
74
+ expect(descriptor?.transport).toBe('acp');
75
+ expect(descriptor?.glyph).toBe('jcode');
76
+ expect(HARNESS_LAUNCH.jcode?.command).toEqual(['jcode', 'acp']);
77
+ expect(HARNESS_LAUNCH.jcode?.install).toContain('https://jcode.sh/install');
78
+ });
79
+
80
+ test('grok is listed and launches its own ACP server, approvals left on', () => {
81
+ // Grok Build ships `grok agent stdio` itself. `--always-approve` must NOT be
82
+ // in the launch line: it would silence `session/request_permission`, making
83
+ // the composer's access tiers inert.
84
+ const descriptor = harnessDescriptor('grok');
85
+ expect(descriptor?.transport).toBe('acp');
86
+ expect(descriptor?.glyph).toBe('grok');
87
+ expect(HARNESS_LAUNCH.grok?.command).toEqual(['grok', 'agent', 'stdio']);
88
+ expect(HARNESS_LAUNCH.grok?.command).not.toContain('--always-approve');
89
+ expect(HARNESS_LAUNCH.grok?.install).toContain('https://x.ai/cli/install.sh');
90
+ });
91
+
70
92
  test('every catalog entry has a launch line or is the built-in transport', () => {
71
93
  // The built-in transport has no agent to launch by definition; everything
72
94
  // else without a line would probe to "no launch command is configured",
@@ -46,7 +46,12 @@ export type BuiltinHarnessId =
46
46
  * `zcode app-server`. The CLI ships no native ACP server (measured against
47
47
  * the 3.17.x source: no `acp` subcommand), so the launch line names that
48
48
  * bridge and the bridge finds the CLI by itself. */
49
- | 'zcode';
49
+ | 'zcode'
50
+ /** The Rust agent from jcode.sh. Its own ACP adapter (`jcode acp`) is backed
51
+ * by the Jcode daemon. */
52
+ | 'jcode'
53
+ /** xAI's Grok Build CLI, over its own ACP server (`grok agent stdio`). */
54
+ | 'grok';
50
55
 
51
56
  /**
52
57
  * A harness id: one this build ships, or one the user added.
@@ -75,6 +80,8 @@ export const HARNESS_IDS: readonly BuiltinHarnessId[] = [
75
80
  'kimi',
76
81
  'cursor',
77
82
  'zcode',
83
+ 'jcode',
84
+ 'grok',
78
85
  ];
79
86
 
80
87
  export interface HarnessDescriptor {
@@ -127,6 +134,8 @@ export type HarnessGlyph =
127
134
  | 'cursor'
128
135
  | 'antigravity'
129
136
  | 'zcode'
137
+ | 'jcode'
138
+ | 'grok'
130
139
  /** A user-added ACP harness: no vendor mark, drawn as its initial. */
131
140
  | 'custom';
132
141
 
@@ -151,6 +160,8 @@ export const HARNESS_CATALOG: Readonly<Record<BuiltinHarnessId, HarnessDescripto
151
160
  kimi: { id: 'kimi', label: 'kimi', initial: 'K', transport: 'acp', glyph: 'kimi' },
152
161
  cursor: { id: 'cursor', label: 'cursor', initial: '⌖', transport: 'acp', glyph: 'cursor' },
153
162
  zcode: { id: 'zcode', label: 'zcode', initial: 'Z', transport: 'acp', glyph: 'zcode' },
163
+ jcode: { id: 'jcode', label: 'jcode', initial: 'J', transport: 'acp', glyph: 'jcode' },
164
+ grok: { id: 'grok', label: 'grok', initial: 'G', transport: 'acp', glyph: 'grok' },
154
165
  };
155
166
 
156
167
  /**
@@ -137,3 +137,28 @@ describe('the env box speaks the agent’s own vocabulary', () => {
137
137
  }
138
138
  });
139
139
  });
140
+
141
+ describe('the launch box names this harness’s own line', () => {
142
+ test('omp’s card does not advertise Antigravity', () => {
143
+ const plan = configFieldPlan('omp-acp', undefined, { launchCommand: 'omp acp' });
144
+ expect(plan.launchPlaceholder).toBe('omp acp');
145
+ expect(plan.launchHint).toContain('omp acp');
146
+ // The quoting example carries the args and this agent's binary.
147
+ expect(plan.launchHint).toContain('/Users/me/bin/omp acp');
148
+ expect(plan.launchHint).not.toContain('agy');
149
+ });
150
+
151
+ test('Claude’s line keeps its package spec in the quoting example', () => {
152
+ const line = 'npx -y @agentclientprotocol/claude-agent-acp@0.100.0';
153
+ const plan = configFieldPlan('claude', undefined, { launchCommand: line });
154
+ expect(plan.launchPlaceholder).toBe(line);
155
+ expect(plan.launchHint).toContain(`/Users/me/bin/${line}`);
156
+ expect(plan.launchHint).not.toContain('agy');
157
+ });
158
+
159
+ test('no known line means the box says so instead of inventing one', () => {
160
+ const plan = configFieldPlan('a-user-harness', undefined);
161
+ expect(plan.launchPlaceholder).toBe('the agent’s own command');
162
+ expect(plan.launchHint).not.toContain('agy');
163
+ });
164
+ });
@@ -30,7 +30,7 @@
30
30
  */
31
31
 
32
32
  import type { HarnessId } from '@/shared/lib/harness/catalog';
33
- import { providerFacts } from '@/shared/lib/harness/provider-facts';
33
+ import { providerFacts } from '@/shared/lib/harness/provider-lookup';
34
34
 
35
35
  /** The probe fields this plan reads. Absent means "never probed". */
36
36
  export interface ConfigProbeFacts {
@@ -55,6 +55,9 @@ export interface ConfigFieldPlan {
55
55
  envPlaceholder: string;
56
56
  /** What to type in the launch box when empty, from the build's own table. */
57
57
  launchPlaceholder: string;
58
+ /** What leaving the box empty falls back to, plus the quoting example, both
59
+ * naming THIS harness's line. */
60
+ launchHint: string;
58
61
  /** Per-harness guidance the generic form cannot know. */
59
62
  notes: string[];
60
63
  }
@@ -128,12 +131,37 @@ function environmentFacts(id: HarnessId): { hint: string; placeholder: string; n
128
131
  };
129
132
  }
130
133
 
134
+ /**
135
+ * The launch box, described by the harness's OWN line.
136
+ *
137
+ * The hint used to quote the INSTALL command as "the built-in line" and pin its
138
+ * quoting example to `/Users/me/bin/agy acp` — Antigravity's line, printed on
139
+ * every card, including omp's and Claude's, whose binaries are `omp` and `npx`.
140
+ * Both facts now come from the line this build would actually spawn.
141
+ */
142
+ function launchFacts(command: string | undefined): { placeholder: string; hint: string } {
143
+ const line = command?.trim() ?? '';
144
+ if (!line) {
145
+ return {
146
+ placeholder: 'the agent’s own command',
147
+ hint: 'Empty runs the launch line this build’s table gives the agent.',
148
+ };
149
+ }
150
+ const [binary, ...args] = line.split(/\s+/);
151
+ const name = binary.split('/').pop() || binary;
152
+ return {
153
+ placeholder: line,
154
+ hint: `Empty runs the built-in line (${line}). Quoted paths survive: ${[`/Users/me/bin/${name}`, ...args].join(' ')}`,
155
+ };
156
+ }
157
+
131
158
  /**
132
159
  * The plan for one harness.
133
160
  *
134
161
  * `provider` is the CURRENT config value: a provider already stored stays
135
162
  * editable even when the probe has not run, because hiding a stored value is how
136
- * a form silently rewrites what it cannot show.
163
+ * a form silently rewrites what it cannot show. `launchCommand` is the line the
164
+ * build would spawn, so the box can name it.
137
165
  */
138
166
  export function configFieldPlan(
139
167
  id: HarnessId,
@@ -148,6 +176,7 @@ export function configFieldPlan(
148
176
  // that does not exist left the field permanently empty.
149
177
  const modelsAreSelectors = providers.length > 0;
150
178
  const storedProvider = Boolean(options.provider?.trim());
179
+ const launch = launchFacts(options.launchCommand);
151
180
 
152
181
  return {
153
182
  showProvider: modelsAreSelectors || storedProvider,
@@ -157,7 +186,8 @@ export function configFieldPlan(
157
186
  modelsAreSelectors,
158
187
  envHint: env.hint,
159
188
  envPlaceholder: env.placeholder,
160
- launchPlaceholder: options.launchCommand ?? 'the agent’s own command',
189
+ launchPlaceholder: launch.placeholder,
190
+ launchHint: launch.hint,
161
191
  notes: env.notes,
162
192
  };
163
193
  }
@@ -30,7 +30,7 @@
30
30
  * pick a target's field value, and both must agree.
31
31
  */
32
32
 
33
- import type { ProviderRegistryKind } from '@/shared/lib/harness/provider-facts';
33
+ import type { ProviderRegistryKind } from '@/shared/lib/harness/provider-contracts';
34
34
 
35
35
  export type CanonicalProtocol =
36
36
  | 'openai-chat'
@@ -51,6 +51,10 @@ export const HARNESS_MCP_FACTS: Record<BuiltinHarnessId, HarnessMcpFacts> = {
51
51
  kimi: { delivery: 'acp', note: 'Injected on session/new, so every new chat sees the current list.' },
52
52
  cursor: { delivery: 'acp', note: 'Injected on session/new, so every new chat sees the current list.' },
53
53
  zcode: { delivery: 'acp', note: 'Injected on session/new, so every new chat sees the current list.' },
54
+ jcode: { delivery: 'acp', note: 'Injected on session/new, so every new chat sees the current list.' },
55
+ // Measured on 1.0.77: `mcpCapabilities` advertises stdio, http AND sse, and
56
+ // the agent also loads config.toml / ~/.claude.json / .mcp.json on its own.
57
+ grok: { delivery: 'acp', note: 'Injected on session/new and advertised for stdio, http and sse (measured 1.0.77); grok also loads MCP servers from config.toml, ~/.claude.json and the project .mcp.json.' },
54
58
  };
55
59
 
56
60
  /**
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The shapes the measured provider table is written in.
8
+ *
9
+ * Split from `provider-facts.ts` so the table module stays inside the file
10
+ * ceiling as harnesses are added; the table is the one owner of the FACTS,
11
+ * these are the one owner of their SHAPE.
12
+ */
13
+
14
+ import type { HarnessId } from '@/shared/lib/harness/catalog';
15
+ import type { CanonicalProtocol } from '@/shared/lib/harness/dialects';
16
+
17
+ /** How a harness stores providers. */
18
+ export type ProviderRegistryKind =
19
+ /** A YAML document with a `providers` map (omp). */
20
+ | 'yaml-providers'
21
+ /** A JSON document with a `provider` map (opencode). */
22
+ | 'json-provider'
23
+ /** A TOML document with a `model_providers` table (codex). */
24
+ | 'toml-model-providers'
25
+ /** A JSON document with a `providers` map (pi). */
26
+ | 'json-providers'
27
+ /** A TOML document with a `providers` table (kimi). */
28
+ | 'toml-providers'
29
+ /** A JSON settings document with `modelProviders` (qwen). */
30
+ | 'json-model-providers'
31
+ /** ZCode's personal-provider rules: arrays under `config.providerConfigRules`
32
+ * and `config.modelConfigRules` (3.12+). */
33
+ | 'zcode-provider-rules'
34
+ /** No provider registry this build writes; an env contract instead. */
35
+ | 'env'
36
+ /** A registry that exists but belongs to the agent's own writer. */
37
+ | 'agent-managed'
38
+ /** Nothing to offer. */
39
+ | 'none';
40
+
41
+ export interface ProviderRegistry {
42
+ kind: ProviderRegistryKind;
43
+ /** Path relative to the user's home, or null when there is no file. */
44
+ file: string | null;
45
+ /** Dot-path the providers live under, for the editors and the reader. */
46
+ pointer: string;
47
+ /** False when Kabmo may read the entries but must not write them. */
48
+ writable: boolean;
49
+ /** The base-URL field's name in THIS format, so a writer does not guess. */
50
+ baseUrlField: string | null;
51
+ /** The API-key field's name in this format. */
52
+ apiKeyField: string | null;
53
+ /** The dialect/SDK field's name, when the format has one. */
54
+ dialectField?: string;
55
+ /** How this format spells a model entry, for the model list. */
56
+ modelsField: string | null;
57
+ /**
58
+ * Provider ids this registry ships itself. An entry under one of these is the
59
+ * VENDOR's provider with an endpoint override — not a custom provider — and an
60
+ * import must never offer or write one: copying `anthropic` out of omp into
61
+ * codex would replace the vendor entry instead of adding a gateway.
62
+ */
63
+ bundledIds?: readonly string[];
64
+ /**
65
+ * False when this registry writes a MODEL TABLE beside the provider (kimi's
66
+ * `[models.<alias>]`, codex's `model`), so a provider alone serves nothing.
67
+ * The writer then emits the model rows too instead of leaving a husk.
68
+ */
69
+ modelsAreRows?: boolean;
70
+ }
71
+
72
+ /**
73
+ * One picker alias a vendor SDK resolves from the environment. Claude Code's
74
+ * `opus`/`sonnet`/`haiku`/`fable` aliases resolve to ids the VENDOR ships
75
+ * unless `ANTHROPIC_DEFAULT_<FAMILY>_MODEL` pins them; a gateway that lists
76
+ * only its own ids answers the vendor ids with `400 model not found`.
77
+ */
78
+ export interface EnvModelAlias {
79
+ family: string;
80
+ env: string;
81
+ }
82
+
83
+ /** The env names an `environment` harness reads, in the order its docs list. */
84
+ export interface EnvProviderContract {
85
+ baseUrl: string;
86
+ apiKey: string;
87
+ model?: string;
88
+ modelAliases?: readonly EnvModelAlias[];
89
+ }
90
+
91
+ export interface HarnessProviderFacts {
92
+ registry: ProviderRegistry;
93
+ /** Present only for an `env` harness. */
94
+ env?: EnvProviderContract;
95
+ /**
96
+ * The single wire protocol an `environment` harness's SDK speaks. Claude Code
97
+ * is Anthropic Messages and Antigravity is Google GenAI — an endpoint that
98
+ * speaks neither cannot be carried there, and an import has to say so instead
99
+ * of writing a URL the agent will fail every request against.
100
+ */
101
+ envProtocol?: CanonicalProtocol;
102
+ /** True when adding a provider ADDS a choice; false when it replaces the
103
+ * agent's own endpoint (Claude Code, Antigravity). */
104
+ createsChoice: boolean;
105
+ /** Harnesses whose entries this one can import, because the fields line up. */
106
+ importFrom: readonly HarnessId[];
107
+ /** One sentence for the settings card, in the vendor's own vocabulary. */
108
+ summary: string;
109
+ }
@@ -35,7 +35,8 @@ import {
35
35
  registryLabel,
36
36
  supportsProviderEditor,
37
37
  } from '@/shared/lib/harness/providers';
38
- import { HARNESS_PROVIDER_FACTS, managesProviders, providerFacts } from '@/shared/lib/harness/provider-facts';
38
+ import { HARNESS_PROVIDER_FACTS } from '@/shared/lib/harness/provider-facts';
39
+ import { managesProviders, providerFacts } from '@/shared/lib/harness/provider-lookup';
39
40
  import { HARNESS_IDS } from '@/shared/lib/harness/catalog';
40
41
 
41
42
  /** Harnesses whose registry Kabmo may WRITE, with the format it writes. */