@odysx/codemind 0.1.0 → 0.1.1

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 (226) hide show
  1. package/dist/core/provider/index.d.ts +52 -10
  2. package/dist/core/provider/index.js +99 -12
  3. package/package.json +6 -1
  4. package/dist/commands/agents.d.ts.map +0 -1
  5. package/dist/commands/agents.js.map +0 -1
  6. package/dist/commands/auth.d.ts.map +0 -1
  7. package/dist/commands/auth.js.map +0 -1
  8. package/dist/commands/chat.d.ts.map +0 -1
  9. package/dist/commands/chat.js.map +0 -1
  10. package/dist/commands/keys.d.ts.map +0 -1
  11. package/dist/commands/keys.js.map +0 -1
  12. package/dist/commands/local.d.ts.map +0 -1
  13. package/dist/commands/local.js.map +0 -1
  14. package/dist/commands/mcp.d.ts.map +0 -1
  15. package/dist/commands/mcp.js.map +0 -1
  16. package/dist/commands/prompts.d.ts.map +0 -1
  17. package/dist/commands/prompts.js.map +0 -1
  18. package/dist/commands/skills.d.ts.map +0 -1
  19. package/dist/commands/skills.js.map +0 -1
  20. package/dist/core/auth/index.d.ts.map +0 -1
  21. package/dist/core/auth/index.js.map +0 -1
  22. package/dist/core/config/index.d.ts.map +0 -1
  23. package/dist/core/config/index.js.map +0 -1
  24. package/dist/core/history.d.ts.map +0 -1
  25. package/dist/core/history.js.map +0 -1
  26. package/dist/core/markdown-renderer.d.ts.map +0 -1
  27. package/dist/core/markdown-renderer.js.map +0 -1
  28. package/dist/core/permissions/index.d.ts.map +0 -1
  29. package/dist/core/permissions/index.js.map +0 -1
  30. package/dist/core/provider/external.d.ts.map +0 -1
  31. package/dist/core/provider/external.js.map +0 -1
  32. package/dist/core/provider/index.d.ts.map +0 -1
  33. package/dist/core/provider/index.js.map +0 -1
  34. package/dist/core/registry/index.d.ts.map +0 -1
  35. package/dist/core/registry/index.js.map +0 -1
  36. package/dist/core/schema/types.d.ts.map +0 -1
  37. package/dist/core/schema/types.js.map +0 -1
  38. package/dist/core/terminal.d.ts.map +0 -1
  39. package/dist/core/terminal.js.map +0 -1
  40. package/dist/core/workspace/index.d.ts.map +0 -1
  41. package/dist/core/workspace/index.js.map +0 -1
  42. package/dist/index.d.ts.map +0 -1
  43. package/dist/index.js.map +0 -1
  44. package/dist/ui/app.d.ts.map +0 -1
  45. package/dist/ui/app.js.map +0 -1
  46. package/dist/ui/commands/cases/catalog.d.ts.map +0 -1
  47. package/dist/ui/commands/cases/catalog.js.map +0 -1
  48. package/dist/ui/commands/cases/misc.d.ts.map +0 -1
  49. package/dist/ui/commands/cases/misc.js.map +0 -1
  50. package/dist/ui/commands/cases/tasks.d.ts.map +0 -1
  51. package/dist/ui/commands/cases/tasks.js.map +0 -1
  52. package/dist/ui/commands/runCommand.d.ts.map +0 -1
  53. package/dist/ui/commands/runCommand.js.map +0 -1
  54. package/dist/ui/components/AgentPicker.d.ts.map +0 -1
  55. package/dist/ui/components/AgentPicker.js.map +0 -1
  56. package/dist/ui/components/AuthPicker.d.ts.map +0 -1
  57. package/dist/ui/components/AuthPicker.js.map +0 -1
  58. package/dist/ui/components/Banner.d.ts.map +0 -1
  59. package/dist/ui/components/Banner.js.map +0 -1
  60. package/dist/ui/components/CommandMenu.d.ts.map +0 -1
  61. package/dist/ui/components/CommandMenu.js.map +0 -1
  62. package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
  63. package/dist/ui/components/ErrorBoundary.js.map +0 -1
  64. package/dist/ui/components/InputBar.d.ts.map +0 -1
  65. package/dist/ui/components/InputBar.js.map +0 -1
  66. package/dist/ui/components/KeysPanel.d.ts.map +0 -1
  67. package/dist/ui/components/KeysPanel.js.map +0 -1
  68. package/dist/ui/components/MessageView.d.ts.map +0 -1
  69. package/dist/ui/components/MessageView.js.map +0 -1
  70. package/dist/ui/components/PermissionPrompt.d.ts.map +0 -1
  71. package/dist/ui/components/PermissionPrompt.js.map +0 -1
  72. package/dist/ui/components/Pickers.d.ts.map +0 -1
  73. package/dist/ui/components/Pickers.js.map +0 -1
  74. package/dist/ui/components/SearchOverlay.d.ts.map +0 -1
  75. package/dist/ui/components/SearchOverlay.js.map +0 -1
  76. package/dist/ui/components/SessionPicker.d.ts.map +0 -1
  77. package/dist/ui/components/SessionPicker.js.map +0 -1
  78. package/dist/ui/components/WorkingIndicator.d.ts.map +0 -1
  79. package/dist/ui/components/WorkingIndicator.js.map +0 -1
  80. package/dist/ui/controls/ApiKeyEntry.d.ts.map +0 -1
  81. package/dist/ui/controls/ApiKeyEntry.js.map +0 -1
  82. package/dist/ui/controls/MultiSelect.d.ts.map +0 -1
  83. package/dist/ui/controls/MultiSelect.js.map +0 -1
  84. package/dist/ui/hooks/useAgentPicker.d.ts.map +0 -1
  85. package/dist/ui/hooks/useAgentPicker.js.map +0 -1
  86. package/dist/ui/hooks/useAuthFlow.d.ts.map +0 -1
  87. package/dist/ui/hooks/useAuthFlow.js.map +0 -1
  88. package/dist/ui/hooks/useKeysFlow.d.ts.map +0 -1
  89. package/dist/ui/hooks/useKeysFlow.js.map +0 -1
  90. package/dist/ui/hooks/useSessionPicker.d.ts.map +0 -1
  91. package/dist/ui/hooks/useSessionPicker.js.map +0 -1
  92. package/dist/ui/hooks/useTerminalSize.d.ts.map +0 -1
  93. package/dist/ui/hooks/useTerminalSize.js.map +0 -1
  94. package/dist/ui/input/keyRouter.d.ts.map +0 -1
  95. package/dist/ui/input/keyRouter.js.map +0 -1
  96. package/dist/ui/layouts/ScreenLayout.d.ts.map +0 -1
  97. package/dist/ui/layouts/ScreenLayout.js.map +0 -1
  98. package/dist/ui/shared/types.d.ts.map +0 -1
  99. package/dist/ui/shared/types.js.map +0 -1
  100. package/dist/ui/theme.d.ts.map +0 -1
  101. package/dist/ui/theme.js.map +0 -1
  102. package/dist/ui/utils/markdown.d.ts.map +0 -1
  103. package/dist/ui/utils/markdown.js.map +0 -1
  104. package/dist/ui/utils/mentions.d.ts.map +0 -1
  105. package/dist/ui/utils/mentions.js.map +0 -1
  106. package/dist/ui/utils/terminal-text.d.ts.map +0 -1
  107. package/dist/ui/utils/terminal-text.js.map +0 -1
  108. package/dist/ui/utils/text.d.ts.map +0 -1
  109. package/dist/ui/utils/text.js.map +0 -1
  110. package/eslint.config.js +0 -40
  111. package/graphify-out/GRAPH_REPORT.md +0 -140
  112. package/graphify-out/cache/1236b1806943f8eb5c64fece9fb448149370f4a1b52b32f0977ad528d7911291.json +0 -1
  113. package/graphify-out/cache/15cbf641dcc0fd641c18da872214918203a1f64baa7ac8430e4702ef32d18b02.json +0 -1
  114. package/graphify-out/cache/1abc52745bb46f6cc5a528530e2bc1f368c26e348dff85cdde5cad6f275d7177.json +0 -1
  115. package/graphify-out/cache/1c7815c37c13177e98895e272285f6151a8d0807478fc843ec452634b3e9912d.json +0 -1
  116. package/graphify-out/cache/1ec38c39f044f329c78642b61d6394fb8e15d0014335f32947d1f5c7b88c02bc.json +0 -1
  117. package/graphify-out/cache/20c9b57ff76dbb9d57cbd00659b0a42d2b28dd2abacf1ef4143cc67a5b6fe7f4.json +0 -1
  118. package/graphify-out/cache/285e11876884eb619e779d540cd957b33e70f14c67ecc26c9b9755aa9cedd717.json +0 -1
  119. package/graphify-out/cache/2c0a9c49ab51f4e0f07543b4e941bf802b7db31fa607c4cee8e595575be68fe7.json +0 -1
  120. package/graphify-out/cache/3025e6c2756c79ccaadd51d611f25a8b6630a6a11ce1b4e6e261b3e033dc194f.json +0 -1
  121. package/graphify-out/cache/4801a686ddfa0a52824a4fc3d65443cbb0ab9f0b030af67d02fccb520c584a08.json +0 -1
  122. package/graphify-out/cache/4f8fd96f38aa7d0293b4fab60c4581c4f3e68f4533c664c9cd78d1c53bea1cba.json +0 -1
  123. package/graphify-out/cache/5928e562b0f5700184b810e2403f4aa685e2b93c3c584c10460562b514c40fdd.json +0 -1
  124. package/graphify-out/cache/66132486efb0a4cfaeea766448f1f15bb33635808714052e7e24e5b00fbc984f.json +0 -1
  125. package/graphify-out/cache/66ab27669e7ec685130063662af9f30018c267f7639b4af4b0504a98282c383a.json +0 -1
  126. package/graphify-out/cache/6ff6b3dd433b5ffe96e166263a203dd622397e419dc00bb676824988b7defeab.json +0 -1
  127. package/graphify-out/cache/7a00a49932177a6215e2590b1ddfd6f1d8494792f693068e9d427d16b165d370.json +0 -1
  128. package/graphify-out/cache/7b681bc5182f40f707f1c0b16b78af38efffa62a1df315d10878f4de888408ef.json +0 -1
  129. package/graphify-out/cache/81196d44e50ac0b276d826a531ed10c425a528b298e3fe18e8d5a3eec996e9d5.json +0 -1
  130. package/graphify-out/cache/8934e9b32dea6e66fdc34fa1681b287ff1335c389917e0fc6ee2fc573e23e87b.json +0 -1
  131. package/graphify-out/cache/975f6c99807f86b79c80ca40c783618e2080a927eaebe6ea3db37b869f048851.json +0 -1
  132. package/graphify-out/cache/9ab98f08626fd8190462595e38de828293ad184db8df5e1177b05a8fe290faa1.json +0 -1
  133. package/graphify-out/cache/9c434a6796d7932b6e87a908c155c09cb2b8d097fc55f141f0302b6600f94749.json +0 -1
  134. package/graphify-out/cache/ac5cf4c489dc417c1f6ea728d0b6ba12ac7087bc6c2e736697ff3024b4d4e534.json +0 -1
  135. package/graphify-out/cache/ae5083b5c1dca3e5c6af485e7f6eb8a08ff8b382cdecf92ab5e0902053442afe.json +0 -1
  136. package/graphify-out/cache/b274057fc2e0118cf2746d1d8060841122bb2a2b0305566fc3f32d3a51e08bcc.json +0 -1
  137. package/graphify-out/cache/b39beef31da682387f030c0d149f6cd5b3e66effbf936cc8430db15360759dda.json +0 -1
  138. package/graphify-out/cache/bf3c6a36bb72820bc11cbf4a5c49067d1f62013d4686c019a4dbd9951b1e980e.json +0 -1
  139. package/graphify-out/cache/c034e156028d1a58b89bce659726e9a4065ddc4d2b560d6bce7a206fdff8dad3.json +0 -1
  140. package/graphify-out/cache/c619b5bbe8d1f427fbd7816d1e9fcfaf90d7201b020ae6b578166aeb9cb20683.json +0 -1
  141. package/graphify-out/cache/c8db77a9da0b0f601acfa50a620f31155cdda0d0cc0f2285adcea19e77194ee6.json +0 -1
  142. package/graphify-out/cache/ca664791ec7741a2077d9e7c10384142d30e7a3b77b388df719c315da608d57d.json +0 -1
  143. package/graphify-out/cache/cba43a116186bd55c8a63368dea4eee4a8123b2bec0a42df6efb3254f89f9a7a.json +0 -1
  144. package/graphify-out/cache/cd51cbb3dad1cf34417b9761fe2eb184a9f57d23dc86e45630e63bfa2ecafddc.json +0 -1
  145. package/graphify-out/cache/d06738cde193b34a136b94104220c17e0212b814b3e4d7ff399105635cae1a03.json +0 -1
  146. package/graphify-out/cache/d093c19f0169c0398eeb1360895b1c16ecc50abc59f4be8eec3f6fd27c89a6e5.json +0 -1
  147. package/graphify-out/cache/da8f75c438531d232fe114d5cbf2374576ce842a5fb87c7e5a88b78fdb334e5e.json +0 -1
  148. package/graphify-out/cache/e35798fa04ddede548a6953bdea506bd7d0788dfed4e8a8ea6ae77b1b60ef5e0.json +0 -1
  149. package/graphify-out/cache/e5a38c254719000487098782125e15e2e982c07d66b99d359ed1781f30f9fc8c.json +0 -1
  150. package/graphify-out/cache/e6e4c4a5a7200ee0154585b5d6538f699b0a746dbded3164f8391f06ce7cb212.json +0 -1
  151. package/graphify-out/cache/ea8d0838df6309b673b031f616b253af957898ee7289d25a541fa6183b732e4e.json +0 -1
  152. package/graphify-out/cache/ebaee92b0e881efd7a08f3143e2c1803310396b4651d4f77532003c699cc6836.json +0 -1
  153. package/graphify-out/cache/edf8543318a9e60d56d04704078da6c37202ddd6fdfc83144fe2b94fe19b80ef.json +0 -1
  154. package/graphify-out/cache/efca19d3668035f11126fc9eccbeab290abfa94babf3f9a8706de81d17aba263.json +0 -1
  155. package/graphify-out/cache/f1480bb642025ebd6d99986cdd8a7d5726897ec038300e4b095c9c938435dfad.json +0 -1
  156. package/graphify-out/cache/f459f21277f03865f732affb175b1b092954dae5967f27b3cd1864466e3e24f4.json +0 -1
  157. package/graphify-out/cache/f899e37e864010b30f4c196e86082d7bd022a0df032005e0407883ebcec36514.json +0 -1
  158. package/graphify-out/cache/fb3cbe07fbcd97c536cff9c6bc343c35f22d49613f05c53ad30ef67a75c5d93e.json +0 -1
  159. package/graphify-out/cache/fd3dc682b1ca2f5ae03b50d6b0e045ae50f5701c0a21c5a388d77ef482939d3a.json +0 -1
  160. package/graphify-out/graph.html +0 -257
  161. package/graphify-out/graph.json +0 -4396
  162. package/scripts/e2e-external.mjs +0 -65
  163. package/scripts/live-agents.mjs +0 -6
  164. package/scripts/live-stream.mjs +0 -51
  165. package/src/commands/agents.ts +0 -91
  166. package/src/commands/auth.ts +0 -39
  167. package/src/commands/chat.ts +0 -198
  168. package/src/commands/keys.ts +0 -83
  169. package/src/commands/local.ts +0 -302
  170. package/src/commands/mcp.ts +0 -74
  171. package/src/commands/prompts.ts +0 -58
  172. package/src/commands/skills.ts +0 -43
  173. package/src/core/auth/index.ts +0 -101
  174. package/src/core/config/index.ts +0 -152
  175. package/src/core/history.ts +0 -79
  176. package/src/core/markdown-renderer.ts +0 -420
  177. package/src/core/permissions/index.ts +0 -99
  178. package/src/core/provider/external.ts +0 -312
  179. package/src/core/provider/index.ts +0 -517
  180. package/src/core/registry/index.ts +0 -250
  181. package/src/core/schema/types.ts +0 -106
  182. package/src/core/terminal.ts +0 -124
  183. package/src/core/workspace/index.ts +0 -216
  184. package/src/index.ts +0 -401
  185. package/src/ui/app.tsx +0 -644
  186. package/src/ui/commands/cases/catalog.ts +0 -76
  187. package/src/ui/commands/cases/misc.ts +0 -293
  188. package/src/ui/commands/cases/tasks.ts +0 -115
  189. package/src/ui/commands/runCommand.ts +0 -178
  190. package/src/ui/components/Banner.tsx +0 -63
  191. package/src/ui/components/CommandMenu.tsx +0 -63
  192. package/src/ui/components/ErrorBoundary.tsx +0 -75
  193. package/src/ui/components/InputBar.tsx +0 -227
  194. package/src/ui/components/KeysPanel.tsx +0 -115
  195. package/src/ui/components/MessageView.tsx +0 -226
  196. package/src/ui/components/Pickers.tsx +0 -234
  197. package/src/ui/components/SearchOverlay.tsx +0 -65
  198. package/src/ui/components/WorkingIndicator.tsx +0 -35
  199. package/src/ui/controls/ApiKeyEntry.tsx +0 -29
  200. package/src/ui/controls/MultiSelect.tsx +0 -55
  201. package/src/ui/hooks/useAgentPicker.ts +0 -64
  202. package/src/ui/hooks/useAuthFlow.ts +0 -47
  203. package/src/ui/hooks/useKeysFlow.ts +0 -157
  204. package/src/ui/hooks/useSessionPicker.ts +0 -84
  205. package/src/ui/hooks/useTerminalSize.ts +0 -36
  206. package/src/ui/input/keyRouter.ts +0 -627
  207. package/src/ui/layouts/ScreenLayout.tsx +0 -202
  208. package/src/ui/shared/types.ts +0 -160
  209. package/src/ui/theme.ts +0 -53
  210. package/src/ui/utils/markdown.ts +0 -255
  211. package/src/ui/utils/mentions.ts +0 -40
  212. package/src/ui/utils/terminal-text.ts +0 -130
  213. package/src/ui/utils/text.ts +0 -174
  214. package/test/commands.test.mjs +0 -127
  215. package/test/config.test.mjs +0 -123
  216. package/test/history.test.mjs +0 -42
  217. package/test/keyrouter.test.mjs +0 -324
  218. package/test/layout.test.mjs +0 -271
  219. package/test/markdown.test.mjs +0 -92
  220. package/test/mentions.test.mjs +0 -51
  221. package/test/permissions.test.mjs +0 -130
  222. package/test/provider.test.mjs +0 -287
  223. package/test/terminal-text.test.mjs +0 -116
  224. package/test/text.test.mjs +0 -134
  225. package/test/workspace.test.mjs +0 -101
  226. package/tsconfig.json +0 -32
@@ -1,324 +0,0 @@
1
- // Tests: the keyboard router — the surface every keystroke goes through.
2
- //
3
- // Each case builds the same mutable dependency bundle app.tsx builds, calls
4
- // handleKey with the key shape Ink 5 actually produces (verified against
5
- // node_modules/ink/build/parse-keypress.js), and asserts on the resulting
6
- // state. Ink reports a key as a set of booleans plus a chunk; the chunk is
7
- // empty for every "non-alphanumeric" key, which is what made Backspace and
8
- // Delete indistinguishable.
9
- import { describe, it } from "node:test";
10
- import assert from "node:assert/strict";
11
- import { handleKey } from "../dist/ui/input/keyRouter.js";
12
-
13
- /** Build a deps bundle backed by a mutable state object. */
14
- const makeDeps = (overrides = {}) => {
15
- const state = {
16
- input: "",
17
- cursor: 0,
18
- menuIndex: 0,
19
- messages: [],
20
- pendingOp: null,
21
- aborted: 0,
22
- exited: 0,
23
- trusted: false,
24
- ranCommands: [],
25
- createdKeys: [],
26
- resumed: [],
27
- };
28
-
29
- const d = {
30
- trust: { pending: false, index: 0 },
31
- setTrust: (fn) => { d.trust = typeof fn === "function" ? fn(d.trust) : fn; },
32
- search: { mode: null, query: "", index: 0 },
33
- setSearch: (fn) => { d.search = typeof fn === "function" ? fn(d.search) : fn; },
34
- commandRows: [],
35
- historyRows: [],
36
- trustFolder: () => { state.trusted = true; d.trust.pending = false; },
37
- pendingOp: null,
38
- keys: {
39
- mode: "closed", busy: false, rows: [], selectedIndex: 0,
40
- draftName: "", scopeCursor: 0, scopeSelection: new Set(), createdKey: null, activeKeyLabel: null,
41
- },
42
- sessionPick: { open: false, busy: false, rows: [], index: 0 },
43
- agentPick: { open: false, busy: false, options: [], index: 0 },
44
- authMode: "closed",
45
- authIndex: 0,
46
- authBusy: false,
47
- apiKeyDraft: "",
48
- streaming: false,
49
- input: "",
50
- cursor: 0,
51
- history: [],
52
- historyIndex: -1,
53
- menuOpen: false,
54
- filteredCommands: [],
55
- clampedMenuIndex: 0,
56
- menuWordLength: 0,
57
-
58
- setMessages: (fn) => {
59
- state.messages = typeof fn === "function" ? fn(state.messages) : fn;
60
- },
61
- setPendingOp: (op) => { d.pendingOp = op; state.pendingOp = op; },
62
- setKeys: (fn) => { d.keys = typeof fn === "function" ? fn(d.keys) : fn; },
63
- openKeysPanel: async () => {},
64
- createKey: async (name, scopes) => { state.createdKeys.push({ name, scopes }); },
65
- resumeSession: async (sid) => { state.resumed.push(sid); },
66
- setSessionPick: (fn) => { d.sessionPick = typeof fn === "function" ? fn(d.sessionPick) : fn; },
67
- setAgentId: () => {},
68
- setAgentPick: (fn) => { d.agentPick = typeof fn === "function" ? fn(d.agentPick) : fn; },
69
- setAuthMode: (m) => { d.authMode = typeof m === "function" ? m(d.authMode) : m; },
70
- setAuthIndex: (i) => { d.authIndex = typeof i === "function" ? i(d.authIndex) : i; },
71
- setApiKeyDraft: (fn) => { d.apiKeyDraft = typeof fn === "function" ? fn(d.apiKeyDraft) : fn; },
72
- submitApiKey: async () => {},
73
- runLocal: async () => {},
74
- revokeSelected: async () => {},
75
- showUsage: async () => {},
76
- selectKey: (row) => { state.selectedKey = row; },
77
- submit: async () => {},
78
- setMenuIndex: (fn) => { state.menuIndex = typeof fn === "function" ? fn(state.menuIndex) : fn; },
79
- setInput: (fn) => { state.input = typeof fn === "function" ? fn(state.input) : fn; d.input = state.input; },
80
- setCursor: (fn) => { state.cursor = typeof fn === "function" ? fn(state.cursor) : fn; d.cursor = state.cursor; },
81
- setHistory: (fn) => { d.history = typeof fn === "function" ? fn(d.history) : fn; },
82
- setHistoryIndex: (i) => { d.historyIndex = typeof i === "function" ? i(d.historyIndex) : i; },
83
- historyDraftRef: { current: "" },
84
- abortRef: { current: { abort: () => { state.aborted++; } } },
85
- queuedSubmitRef: { current: null },
86
- runCommand: (raw) => { state.ranCommands.push(raw); },
87
- requestExit: () => { state.exited++; },
88
- ...overrides,
89
- };
90
- // Keep the router's view of input/cursor in sync with the setters.
91
- Object.defineProperty(d, "input", { get: () => state.input, set: (v) => { state.input = v; } });
92
- Object.defineProperty(d, "cursor", { get: () => state.cursor, set: (v) => { state.cursor = v; } });
93
-
94
- const type = (text) => {
95
- for (const ch of text) {
96
- handleKey(ch, { upArrow: false, downArrow: false, return: false, escape: false }, d);
97
- }
98
- };
99
- const press = (chunk, key = {}) =>
100
- handleKey(chunk, {
101
- upArrow: false, downArrow: false, return: false, escape: false, ...key,
102
- }, d);
103
-
104
- return { d, state, type, press };
105
- };
106
-
107
- const BACKSPACE = { delete: true }; // what Ink 5 reports for the 0x7f byte
108
-
109
- describe("backspace", () => {
110
- it("deletes the character before the caret", () => {
111
- const { state, type, press } = makeDeps();
112
- type("hello");
113
- press("", BACKSPACE);
114
- assert.equal(state.input, "hell");
115
- assert.equal(state.cursor, 4);
116
- });
117
-
118
- it("deletes backwards when the caret is mid-word", () => {
119
- const { state, type, press } = makeDeps();
120
- type("abc");
121
- press("", { leftArrow: true });
122
- press("", { leftArrow: true });
123
- assert.equal(state.cursor, 1);
124
- press("", BACKSPACE);
125
- // Forward-delete here would have produced "ac"; backspace produces "bc".
126
- assert.equal(state.input, "bc");
127
- assert.equal(state.cursor, 0);
128
- });
129
- });
130
-
131
- describe("ctrl+c", () => {
132
- it("clears a non-empty draft", () => {
133
- const { state, type, press } = makeDeps();
134
- type("half-written");
135
- press("c", { ctrl: true });
136
- assert.equal(state.input, "");
137
- assert.equal(state.exited, 0);
138
- });
139
-
140
- it("exits when the draft is empty", () => {
141
- const { state, press } = makeDeps();
142
- press("c", { ctrl: true });
143
- assert.equal(state.exited, 1);
144
- });
145
-
146
- it("exits while a permission prompt is up instead of being swallowed", () => {
147
- const { d, state, press } = makeDeps();
148
- d.pendingOp = { kind: "exec", cliArgs: [], summary: "rm" };
149
- press("c", { ctrl: true });
150
- assert.equal(state.exited, 1);
151
- });
152
-
153
- it("a callback-based approval runs its callback instead of a CLI command", () => {
154
- const { d, press } = makeDeps();
155
- let approved = false;
156
- d.pendingOp = { kind: "write", cliArgs: [], summary: "export", onApproved: () => { approved = true; } };
157
- press("y", {});
158
- assert.equal(approved, true);
159
- assert.equal(d.pendingOp, null);
160
- });
161
-
162
- it("exits while a picker is open", () => {
163
- const overrides = {};
164
- const { d, state, press } = makeDeps(overrides);
165
- d.sessionPick = { open: true, busy: false, rows: [{ session_id: "s1" }], index: 0 };
166
- press("c", { ctrl: true });
167
- assert.equal(state.exited, 1);
168
- });
169
- });
170
-
171
- describe("slash-menu dispatch", () => {
172
- it("completes a command whose caret sits mid-word", () => {
173
- const { d, state, type, press } = makeDeps();
174
- type("/he");
175
- press("", { leftArrow: true });
176
- d.menuOpen = true;
177
- d.filteredCommands = [{ name: "help", description: "Show help" }];
178
- press("", { tab: true });
179
- // The old code appended the remainder ("e") as if it were an argument.
180
- assert.equal(state.input, "/help");
181
- });
182
-
183
- it("runs the highlighted command and keeps trailing arguments", () => {
184
- const { d, state, type, press } = makeDeps();
185
- type("/co");
186
- d.menuOpen = true;
187
- d.filteredCommands = [{ name: "compact", description: "Clear context" }];
188
- press("", { return: true });
189
- assert.deepEqual(state.ranCommands, ["/compact"]);
190
- assert.equal(state.input, "");
191
- });
192
- });
193
-
194
- describe("alt+enter", () => {
195
- it("inserts a newline rather than a raw carriage return", () => {
196
- const { state, type, press } = makeDeps();
197
- type("one");
198
- // xterm sends ESC CR for Alt+Enter; Ink reports chunk "\r", return false.
199
- press("\r", {});
200
- assert.equal(state.input, "one\n");
201
- assert.ok(!state.input.includes("\r"));
202
- });
203
-
204
- it("normalizes a CRLF paste to newlines", () => {
205
- const { state, press } = makeDeps();
206
- press("a\r\nb", {});
207
- assert.equal(state.input, "a\nb");
208
- });
209
- });
210
-
211
- describe("streaming", () => {
212
- it("queues typed prose instead of submitting it", () => {
213
- const { d, type, press } = makeDeps({ streaming: true });
214
- type("next question");
215
- press("", { return: true });
216
- assert.equal(d.queuedSubmitRef.current, "next question");
217
- });
218
-
219
- it("runs a completed slash command immediately", () => {
220
- const { d, state, type, press } = makeDeps({ streaming: true });
221
- type("/status");
222
- press("", { return: true, });
223
- assert.deepEqual(state.ranCommands, ["/status"]);
224
- assert.equal(d.queuedSubmitRef.current, null);
225
- });
226
-
227
- it("interrupts on escape", () => {
228
- const { state, press } = makeDeps({ streaming: true });
229
- press("", { escape: true });
230
- assert.equal(state.aborted, 1);
231
- });
232
- });
233
-
234
- describe("search overlays", () => {
235
- it("opens the command palette with Ctrl+/ and runs the selected command", () => {
236
- const { d, state, press } = makeDeps({
237
- commandRows: [{ key: "/help", label: "/help", detail: "Show help" }],
238
- });
239
- press("/", { ctrl: true });
240
- assert.equal(d.search.mode, "commands");
241
- assert.equal(state.ranCommands.length, 0);
242
- press("", { return: true });
243
- assert.deepEqual(state.ranCommands, ["/help"]);
244
- assert.equal(d.search.mode, null);
245
- });
246
-
247
- it("opens history search with Ctrl+R and loads the chosen prompt", () => {
248
- const { d, press } = makeDeps({
249
- historyRows: [{ key: "h0", label: "explain this function" }],
250
- });
251
- press("r", { ctrl: true });
252
- assert.equal(d.search.mode, "history");
253
- press("", { return: true });
254
- assert.equal(d.input, "explain this function");
255
- assert.equal(d.search.mode, null);
256
- });
257
-
258
- it("filters as you type and resets the selection, esc closes", () => {
259
- const { d, press } = makeDeps({ search: { mode: "commands", query: "", index: 3 } });
260
- press("h");
261
- assert.equal(d.search.query, "h");
262
- assert.equal(d.search.index, 0);
263
- press("", { escape: true });
264
- assert.equal(d.search.mode, null);
265
- });
266
- });
267
-
268
- describe("folder trust gate", () => {
269
- const pending = () => ({ trust: { pending: true, index: 0 } });
270
-
271
- it("trusts on 1 or Enter with the first option", () => {
272
- const a = makeDeps(pending());
273
- a.press("1");
274
- assert.equal(a.state.trusted, true);
275
- assert.equal(a.state.exited, 0);
276
-
277
- const b = makeDeps(pending());
278
- b.press("", { return: true });
279
- assert.equal(b.state.trusted, true);
280
- });
281
-
282
- it("exits on 2, esc, or Enter with the second option highlighted", () => {
283
- for (const pressFn of [
284
- (h) => h.press("2"),
285
- (h) => h.press("", { escape: true }),
286
- (h) => { h.d.trust.index = 1; h.press("", { return: true }); },
287
- ]) {
288
- const h = makeDeps(pending());
289
- pressFn(h);
290
- assert.equal(h.state.exited, 1);
291
- assert.equal(h.state.trusted, false);
292
- }
293
- });
294
-
295
- it("moves the selection with arrows and ignores all other editing", () => {
296
- const { d, state, press, type } = makeDeps(pending());
297
- press("", { downArrow: true });
298
- assert.equal(d.trust.index, 1);
299
- press("", { upArrow: true });
300
- assert.equal(d.trust.index, 0);
301
- type("hello");
302
- assert.equal(state.input, "");
303
- });
304
- });
305
-
306
- describe("key api flow", () => {
307
- it("does not create a second key while the first request is in flight", () => {
308
- const { d, state, press } = makeDeps();
309
- d.keys = {
310
- ...d.keys, mode: "create-scopes", draftName: "ci",
311
- scopeCursor: 0, scopeSelection: new Set(["chat"]), busy: true,
312
- };
313
- press("", { return: true });
314
- assert.deepEqual(state.createdKeys, []);
315
- });
316
-
317
- it("s marks the selected key active", () => {
318
- const { d, state, press } = makeDeps();
319
- const row = { id: "k1", name: "ci", key_prefix: "odx_abc123", is_active: true };
320
- d.keys = { ...d.keys, mode: "menu", rows: [row], selectedIndex: 0 };
321
- press("s", {});
322
- assert.equal(state.selectedKey, row);
323
- });
324
- });
@@ -1,271 +0,0 @@
1
- // Tests: ScreenLayout actually renders — transcript, markdown, menu, input bar.
2
- //
3
- // Rendered headlessly into a fake TTY so the assertions see the real Ink frame
4
- // output. This is the safety net for layout regressions (everything is laid out
5
- // for a terminal width, which unit tests of the parser can't catch).
6
- import { describe, it } from "node:test";
7
- import assert from "node:assert/strict";
8
- import { EventEmitter } from "node:events";
9
- import React from "react";
10
- import { render } from "ink";
11
- import { ScreenLayout, splitTranscript } from "../dist/ui/layouts/ScreenLayout.js";
12
- import { displayWidth } from "../dist/ui/utils/terminal-text.js";
13
-
14
- class FakeStdout extends EventEmitter {
15
- columns = 100;
16
- rows = 30;
17
- isTTY = true;
18
- frames = [];
19
- write(s) {
20
- this.frames.push(s);
21
- return true;
22
- }
23
- }
24
-
25
- const fakeStdin = () => {
26
- const stdin = new EventEmitter();
27
- stdin.isTTY = true;
28
- stdin.setRawMode = () => {};
29
- stdin.ref = () => {};
30
- stdin.unref = () => {};
31
- stdin.setEncoding = () => {};
32
- stdin.resume = () => {};
33
- stdin.pause = () => {};
34
- return stdin;
35
- };
36
-
37
- const baseProps = (overrides = {}) => ({
38
- messages: [],
39
- streaming: false,
40
- elapsed: 0,
41
- trust: { pending: false, index: 0, folder: "~/projects/x", mode: "manual" },
42
- permissionMode: "manual",
43
- search: { mode: null, query: "", index: 0 },
44
- commandRows: [],
45
- historyRows: [],
46
- agentPick: { open: false, busy: false, options: [], index: 0 },
47
- authMode: "closed",
48
- authIndex: 0,
49
- authBusy: false,
50
- apiKeyDraft: "",
51
- sessionPick: { open: false, busy: false, rows: [], index: 0 },
52
- pendingOp: null,
53
- keys: {
54
- mode: "closed", busy: false, rows: [], selectedIndex: 0,
55
- draftName: "", scopeCursor: 0, scopeSelection: new Set(), createdKey: null, activeKeyLabel: null,
56
- },
57
- menuOpen: false,
58
- filteredCommands: [],
59
- clampedMenuIndex: 0,
60
- input: "",
61
- cursor: 0,
62
- agentName: "master",
63
- model: "gpt",
64
- authed: true,
65
- provider: "odysx",
66
- permissionPending: false,
67
- cwd: "~/projects/x",
68
- rows: 30,
69
- ...overrides,
70
- });
71
-
72
- /** Strip ANSI/control sequences so assertions see what the terminal shows. */
73
- // eslint-disable-next-line no-control-regex
74
- const visible = (s) => s.replace(/\x1B(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1B]*(?:\x07|\x1B\\)|[@-Z\\-_])/g, "");
75
-
76
- /** Render once, read the frame, unmount. */
77
- const renderOnce = (props) => {
78
- const { columns, rows, ...layout } = props;
79
- const stdout = new FakeStdout();
80
- if (columns) stdout.columns = columns;
81
- if (rows) stdout.rows = rows;
82
- const instance = render(React.createElement(ScreenLayout, baseProps(layout)), {
83
- stdout,
84
- stdin: fakeStdin(),
85
- debug: false,
86
- exitOnCtrlC: false,
87
- patchConsole: false,
88
- });
89
- const out = visible(stdout.frames.join(""));
90
- instance.unmount();
91
- return out;
92
- };
93
-
94
- describe("ScreenLayout", () => {
95
- it("renders the banner and the input prompt on an empty transcript", () => {
96
- const out = renderOnce({});
97
- assert.match(out, /Codemind/);
98
- assert.match(out, /❯/);
99
- });
100
-
101
- it("renders a markdown reply's structure", () => {
102
- const out = renderOnce({
103
- messages: [{ role: "assistant", text: "# Heading\n\n**bold** text\n\n```js\nconst x = 1;\n```" }],
104
- });
105
- assert.match(out, /Heading/);
106
- assert.match(out, /bold/);
107
- assert.match(out, /const x = 1/);
108
- });
109
-
110
- it("colors errors from system lines", () => {
111
- const out = renderOnce({ messages: [{ role: "system", text: "✗ boom" }] });
112
- assert.match(out, /boom/);
113
- });
114
-
115
- it("keeps system notices appended after the last reply visible", () => {
116
- const out = renderOnce({
117
- messages: [
118
- { role: "user", text: "hi" },
119
- { role: "assistant", text: "reply" },
120
- { role: "system", text: "✓ approved" },
121
- ],
122
- });
123
- assert.match(out, /approved/);
124
- });
125
-
126
- it("hides the input bar while an overlay is open", () => {
127
- const out = renderOnce({ authMode: "picker" });
128
- // The picker's own ❯ is fine; the footer's "authed · /help · ctrl+c"
129
- // (which only the InputBar renders) must be gone.
130
- assert.doesNotMatch(out, /authed · \/help/);
131
- assert.match(out, /Sign in to OdysX/);
132
- });
133
-
134
- it("renders a multiline draft with the caret on its own row", () => {
135
- const value = "line one\nline two";
136
- const out = renderOnce({ input: value, cursor: value.length });
137
- assert.match(out, /line one/);
138
- assert.match(out, /line two/);
139
- // Each logical line is its own row; two lines means the draft is not run
140
- // together into one paragraph with a stray newline glyph.
141
- const rows = out.split("\n").filter((l) => /line (one|two)/.test(l));
142
- assert.equal(rows.length, 2);
143
- assert.ok(rows[0].includes("line one") && rows[1].includes("line two"), "draft order preserved");
144
- });
145
-
146
- it("keeps the settled transcript a growing prefix (Static invariant)", () => {
147
- // <Static> remembers how many items it has written and renders
148
- // items.slice(index). If settled ever shrinks or re-orders, a finished
149
- // reply is skipped or written twice. Note the old bug: items.slice()
150
- // re-indexed between the first and second frame, so "a1" was dropped and
151
- // "q2" written twice.
152
- const q1 = { role: "user", text: "q1" };
153
- const a1 = { role: "assistant", text: "a1" };
154
- const q2 = { role: "user", text: "q2" };
155
- const a2 = { role: "assistant", text: "a2" };
156
-
157
- const frames = [[q1, a1], [q1, a1, q2], [q1, a1, q2, a2]];
158
- let previous = [];
159
- const written = [];
160
- let index = 0;
161
- for (const frame of frames) {
162
- const { settled } = splitTranscript(frame);
163
- // Prefix property: every settled item keeps its position.
164
- assert.deepEqual(settled.slice(0, previous.length), previous, "settled prefix is stable");
165
- written.push(...settled.slice(index).map((m) => m.text));
166
- index = settled.length;
167
- previous = settled;
168
- }
169
- assert.deepEqual(written, ["q1", "a1", "q2"], "each item written exactly once");
170
- });
171
-
172
- it("keeps the footer on one row at 80 columns with a long path", () => {
173
- const out = renderOnce({
174
- columns: 80,
175
- cwd: "~/projects/" + "x".repeat(40),
176
- messages: [{ role: "system", text: "hi" }],
177
- });
178
- const footer = out.split("\n").find((l) => l.includes("authed"));
179
- assert.ok(footer, "footer rendered");
180
- // The budget used to be a guess; a long cwd wrapped the right-hand hints
181
- // onto a second line, which pushed the input up on every keystroke.
182
- assert.match(footer, /\/help · ctrl\+c/);
183
- });
184
-
185
- it("does not let a horizontal rule overflow a narrow terminal", () => {
186
- const out = renderOnce({
187
- columns: 40,
188
- rows: 30,
189
- messages: [{ role: "assistant", text: "a\n\n---\n\nb" }],
190
- });
191
- const rules = out.split("\n").filter((l) => /^\s*─+\s*$/.test(l));
192
- assert.ok(rules.length > 0, "rule rendered");
193
- for (const rule of rules) {
194
- assert.ok(rule.trim().length <= 40, `rule is ${rule.trim().length} columns`);
195
- }
196
- });
197
-
198
- it("windows a very long single-line paste instead of painting it all", () => {
199
- const value = "x".repeat(5000);
200
- const out = renderOnce({ columns: 80, rows: 24, input: value, cursor: value.length });
201
- const painted = out.split("\n").filter((l) => l.includes("xxxx")).length;
202
- // Previously one logical line became ~69 wrapped rows, pushing the
203
- // transcript off-screen and dropping the box border.
204
- assert.ok(painted <= 12, `painted ${painted} rows for one logical line`);
205
- assert.match(out, /…/, "the window is marked as clipped");
206
- });
207
-
208
- it("aligns a table containing double-width glyphs", () => {
209
- const out = renderOnce({
210
- columns: 80,
211
- messages: [{ role: "assistant", text: "| a | b |\n|---|---|\n| 世界 | x |" }],
212
- });
213
- const header = out.split("\n").find((l) => /^\s*a\s+b\s*$/.test(l));
214
- const row = out.split("\n").find((l) => l.includes("世界"));
215
- assert.ok(header, "header rendered");
216
- assert.ok(row, "table row rendered");
217
- // The second column must start at the same terminal column in both rows.
218
- // A `.length`-based layout counts 世界 as 6 UTF-16 units but only 4
219
- // columns, so "x" would land two columns right of "b".
220
- const columnOf = (line, needle) => displayWidth(line.slice(0, line.indexOf(needle)));
221
- assert.equal(columnOf(row, "x"), columnOf(header, "b"));
222
- });
223
-
224
- it("shows the command menu with the selection marker", () => {
225
- const out = renderOnce({
226
- menuOpen: true,
227
- input: "/",
228
- cursor: 1,
229
- filteredCommands: [
230
- { name: "help", description: "Show help" },
231
- { name: "clear", description: "Clear conversation" },
232
- ],
233
- });
234
- assert.match(out, /\/help/);
235
- assert.match(out, /›/);
236
- });
237
-
238
- it("shows the folder trust gate instead of the REPL input", () => {
239
- const out = renderOnce({
240
- trust: { pending: true, index: 1, folder: "~/new/project", mode: "manual" },
241
- permissionMode: "manual",
242
- messages: [{ role: "assistant", text: "should be hidden" }],
243
- });
244
- assert.match(out, /Trust this folder/);
245
- assert.match(out, /~\/new\/project/);
246
- assert.match(out, /Yes, I trust this folder/);
247
- assert.match(out, /No, exit/);
248
- assert.doesNotMatch(out, /should be hidden/);
249
- assert.doesNotMatch(out, /\/help · ctrl\+c/);
250
- assert.match(out, /❯ 2\. No, exit/, "the second option is highlighted");
251
- });
252
-
253
- it("shows the active permission mode in the footer", () => {
254
- const out = renderOnce({ permissionMode: "plan" });
255
- assert.match(out, /mode:plan/);
256
- });
257
-
258
- it("renders the search overlay instead of the input bar", () => {
259
- const out = renderOnce({
260
- search: { mode: "commands", query: "his", index: 0 },
261
- commandRows: [
262
- { key: "/history", label: "/history", detail: "Prompt history" },
263
- { key: "/help", label: "/help", detail: "Show help" },
264
- ],
265
- });
266
- assert.match(out, /Commands/);
267
- assert.match(out, /his/);
268
- assert.match(out, /\/history/);
269
- assert.doesNotMatch(out, /\/help · ctrl\+c/);
270
- });
271
- });
@@ -1,92 +0,0 @@
1
- // Tests: the line-oriented markdown parser feeding MessageView.
2
- import { describe, it } from "node:test";
3
- import assert from "node:assert/strict";
4
- import { parseMarkdown, parseInline } from "../dist/ui/utils/markdown.js";
5
-
6
- describe("parseInline", () => {
7
- it("splits bold, italic, and code runs", () => {
8
- const runs = parseInline("a **b** *c* `d`");
9
- const text = runs.map((r) => r.text).join("");
10
- assert.equal(text, "a b c d");
11
- assert.ok(runs.some((r) => r.bold && r.text === "b"));
12
- assert.ok(runs.some((r) => r.italic && r.text === "c"));
13
- assert.ok(runs.some((r) => r.code && r.text === "d"));
14
- });
15
-
16
- it("keeps links with their target", () => {
17
- const runs = parseInline("see [docs](https://x.y)");
18
- const link = runs.find((r) => r.link);
19
- assert.ok(link, "link run present");
20
- assert.equal(link.text, "docs");
21
- assert.equal(link.link, "https://x.y");
22
- });
23
-
24
- it("treats unmatched markers as literal text", () => {
25
- const runs = parseInline("2 * 3 ** 4");
26
- assert.equal(runs.map((r) => r.text).join(""), "2 * 3 ** 4");
27
- });
28
- });
29
-
30
- describe("parseMarkdown", () => {
31
- it("classifies headings, bullets, quotes, rules, and tables", () => {
32
- const lines = parseMarkdown(
33
- "# Title\n\n- one\n - nested\n\n> quote\n\n---\n\n| a | b |\n|---|---|\n| 1 | 2 |\n",
34
- );
35
- const kinds = lines.map((l) => l.kind);
36
- assert.ok(kinds.includes("heading"));
37
- assert.ok(kinds.includes("bullet"));
38
- assert.ok(kinds.includes("quote"));
39
- assert.ok(kinds.includes("rule"));
40
- assert.ok(kinds.includes("table"));
41
-
42
- const heading = lines.find((l) => l.kind === "heading");
43
- assert.equal(heading.level, 1);
44
- });
45
-
46
- it("nests bullets by indent", () => {
47
- const lines = parseMarkdown("- a\n - b\n");
48
- const bullets = lines.filter((l) => l.kind === "bullet");
49
- assert.equal(bullets[0].depth, 0);
50
- assert.equal(bullets[1].depth, 1);
51
- });
52
-
53
- it("captures a fenced code block with its language", () => {
54
- const lines = parseMarkdown("```ts\nconst x = 1;\n```\n");
55
- const code = lines.find((l) => l.kind === "code");
56
- assert.equal(code.lang, "ts");
57
- assert.deepEqual(code.lines, ["const x = 1;"]);
58
- assert.equal(code.open, false);
59
- });
60
-
61
- it("keeps an unterminated fence open while streaming", () => {
62
- const lines = parseMarkdown("text\n```py\nprint(1)\n");
63
- const code = lines.find((l) => l.kind === "code");
64
- assert.equal(code.open, true);
65
- assert.deepEqual(code.lines, ["print(1)"]);
66
- });
67
-
68
- it("parses table alignment", () => {
69
- const lines = parseMarkdown("| a | b | c |\n|:--|:-:|--:|\n| 1 | 2 | 3 |\n");
70
- const table = lines.find((l) => l.kind === "table");
71
- assert.deepEqual(table.align, ["left", "center", "right"]);
72
- assert.deepEqual(table.header, ["a", "b", "c"]);
73
- assert.deepEqual(table.rows, [["1", "2", "3"]]);
74
- });
75
-
76
- it("never throws on malformed input", () => {
77
- for (const sample of ["", "|", "```", "#", "- ", "> ", "|||"]) {
78
- assert.doesNotThrow(() => parseMarkdown(sample));
79
- }
80
- });
81
-
82
- it("strips escape sequences from model output", () => {
83
- const lines = parseMarkdown("# hi \x1b[2Jthere\n\ntext \x1b]0;pwned\x07!");
84
- const text = JSON.stringify(lines);
85
- assert.ok(!text.includes("\x1b"), "no escape bytes survive in the model");
86
- // The screen-clear's payload is just the parameters — text around it stays.
87
- assert.ok(text.includes("there"));
88
- // An OSC title sequence is removed whole, including its argument.
89
- assert.ok(!text.includes("pwned"));
90
- assert.ok(text.includes("text !"));
91
- });
92
- });