@odysx/codemind 0.0.0-stage → 0.1.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.
- package/README.md +293 -2
- package/dist/commands/agents.d.ts +2 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +91 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/auth.d.ts +2 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +35 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +180 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/keys.d.ts +2 -0
- package/dist/commands/keys.d.ts.map +1 -0
- package/dist/commands/keys.js +81 -0
- package/dist/commands/keys.js.map +1 -0
- package/dist/commands/local.d.ts +2 -0
- package/dist/commands/local.d.ts.map +1 -0
- package/dist/commands/local.js +325 -0
- package/dist/commands/local.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +73 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/prompts.d.ts +2 -0
- package/dist/commands/prompts.d.ts.map +1 -0
- package/dist/commands/prompts.js +59 -0
- package/dist/commands/prompts.js.map +1 -0
- package/dist/commands/skills.d.ts +2 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +41 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/core/auth/index.d.ts +10 -0
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +82 -0
- package/dist/core/auth/index.js.map +1 -0
- package/dist/core/config/index.d.ts +47 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +118 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/history.d.ts +14 -0
- package/dist/core/history.d.ts.map +1 -0
- package/dist/core/history.js +80 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/markdown-renderer.d.ts +47 -0
- package/dist/core/markdown-renderer.d.ts.map +1 -0
- package/dist/core/markdown-renderer.js +385 -0
- package/dist/core/markdown-renderer.js.map +1 -0
- package/dist/core/permissions/index.d.ts +31 -0
- package/dist/core/permissions/index.d.ts.map +1 -0
- package/dist/core/permissions/index.js +64 -0
- package/dist/core/permissions/index.js.map +1 -0
- package/dist/core/provider/external.d.ts +28 -0
- package/dist/core/provider/external.d.ts.map +1 -0
- package/dist/core/provider/external.js +248 -0
- package/dist/core/provider/external.js.map +1 -0
- package/dist/core/provider/index.d.ts +96 -0
- package/dist/core/provider/index.d.ts.map +1 -0
- package/dist/core/provider/index.js +423 -0
- package/dist/core/provider/index.js.map +1 -0
- package/dist/core/registry/index.d.ts +25 -0
- package/dist/core/registry/index.d.ts.map +1 -0
- package/dist/core/registry/index.js +216 -0
- package/dist/core/registry/index.js.map +1 -0
- package/dist/core/schema/types.d.ts +93 -0
- package/dist/core/schema/types.d.ts.map +1 -0
- package/dist/core/schema/types.js +12 -0
- package/dist/core/schema/types.js.map +1 -0
- package/dist/core/terminal.d.ts +40 -0
- package/dist/core/terminal.d.ts.map +1 -0
- package/dist/core/terminal.js +134 -0
- package/dist/core/terminal.js.map +1 -0
- package/dist/core/workspace/index.d.ts +35 -0
- package/dist/core/workspace/index.d.ts.map +1 -0
- package/dist/core/workspace/index.js +194 -0
- package/dist/core/workspace/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +393 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/app.d.ts +3 -0
- package/dist/ui/app.d.ts.map +1 -0
- package/dist/ui/app.js +554 -0
- package/dist/ui/app.js.map +1 -0
- package/dist/ui/commands/cases/catalog.d.ts +11 -0
- package/dist/ui/commands/cases/catalog.d.ts.map +1 -0
- package/dist/ui/commands/cases/catalog.js +62 -0
- package/dist/ui/commands/cases/catalog.js.map +1 -0
- package/dist/ui/commands/cases/misc.d.ts +35 -0
- package/dist/ui/commands/cases/misc.d.ts.map +1 -0
- package/dist/ui/commands/cases/misc.js +245 -0
- package/dist/ui/commands/cases/misc.js.map +1 -0
- package/dist/ui/commands/cases/tasks.d.ts +13 -0
- package/dist/ui/commands/cases/tasks.d.ts.map +1 -0
- package/dist/ui/commands/cases/tasks.js +91 -0
- package/dist/ui/commands/cases/tasks.js.map +1 -0
- package/dist/ui/commands/runCommand.d.ts +22 -0
- package/dist/ui/commands/runCommand.d.ts.map +1 -0
- package/dist/ui/commands/runCommand.js +136 -0
- package/dist/ui/commands/runCommand.js.map +1 -0
- package/dist/ui/components/AgentPicker.d.ts +11 -0
- package/dist/ui/components/AgentPicker.d.ts.map +1 -0
- package/dist/ui/components/AgentPicker.js +7 -0
- package/dist/ui/components/AgentPicker.js.map +1 -0
- package/dist/ui/components/AuthPicker.d.ts +14 -0
- package/dist/ui/components/AuthPicker.d.ts.map +1 -0
- package/dist/ui/components/AuthPicker.js +7 -0
- package/dist/ui/components/AuthPicker.js.map +1 -0
- package/dist/ui/components/Banner.d.ts +8 -0
- package/dist/ui/components/Banner.d.ts.map +1 -0
- package/dist/ui/components/Banner.js +24 -0
- package/dist/ui/components/Banner.js.map +1 -0
- package/dist/ui/components/CommandMenu.d.ts +17 -0
- package/dist/ui/components/CommandMenu.d.ts.map +1 -0
- package/dist/ui/components/CommandMenu.js +21 -0
- package/dist/ui/components/CommandMenu.js.map +1 -0
- package/dist/ui/components/ErrorBoundary.d.ts +24 -0
- package/dist/ui/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/ui/components/ErrorBoundary.js +51 -0
- package/dist/ui/components/ErrorBoundary.js.map +1 -0
- package/dist/ui/components/InputBar.d.ts +28 -0
- package/dist/ui/components/InputBar.d.ts.map +1 -0
- package/dist/ui/components/InputBar.js +108 -0
- package/dist/ui/components/InputBar.js.map +1 -0
- package/dist/ui/components/KeysPanel.d.ts +12 -0
- package/dist/ui/components/KeysPanel.d.ts.map +1 -0
- package/dist/ui/components/KeysPanel.js +25 -0
- package/dist/ui/components/KeysPanel.js.map +1 -0
- package/dist/ui/components/MessageView.d.ts +29 -0
- package/dist/ui/components/MessageView.d.ts.map +1 -0
- package/dist/ui/components/MessageView.js +107 -0
- package/dist/ui/components/MessageView.js.map +1 -0
- package/dist/ui/components/PermissionPrompt.d.ts +10 -0
- package/dist/ui/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/ui/components/PermissionPrompt.js +4 -0
- package/dist/ui/components/PermissionPrompt.js.map +1 -0
- package/dist/ui/components/Pickers.d.ts +43 -0
- package/dist/ui/components/Pickers.d.ts.map +1 -0
- package/dist/ui/components/Pickers.js +33 -0
- package/dist/ui/components/Pickers.js.map +1 -0
- package/dist/ui/components/SearchOverlay.d.ts +21 -0
- package/dist/ui/components/SearchOverlay.d.ts.map +1 -0
- package/dist/ui/components/SearchOverlay.js +14 -0
- package/dist/ui/components/SearchOverlay.js.map +1 -0
- package/dist/ui/components/SessionPicker.d.ts +12 -0
- package/dist/ui/components/SessionPicker.d.ts.map +1 -0
- package/dist/ui/components/SessionPicker.js +8 -0
- package/dist/ui/components/SessionPicker.js.map +1 -0
- package/dist/ui/components/WorkingIndicator.d.ts +10 -0
- package/dist/ui/components/WorkingIndicator.d.ts.map +1 -0
- package/dist/ui/components/WorkingIndicator.js +23 -0
- package/dist/ui/components/WorkingIndicator.js.map +1 -0
- package/dist/ui/controls/ApiKeyEntry.d.ts +8 -0
- package/dist/ui/controls/ApiKeyEntry.d.ts.map +1 -0
- package/dist/ui/controls/ApiKeyEntry.js +5 -0
- package/dist/ui/controls/ApiKeyEntry.js.map +1 -0
- package/dist/ui/controls/MultiSelect.d.ts +18 -0
- package/dist/ui/controls/MultiSelect.d.ts.map +1 -0
- package/dist/ui/controls/MultiSelect.js +9 -0
- package/dist/ui/controls/MultiSelect.js.map +1 -0
- package/dist/ui/hooks/useAgentPicker.d.ts +14 -0
- package/dist/ui/hooks/useAgentPicker.d.ts.map +1 -0
- package/dist/ui/hooks/useAgentPicker.js +53 -0
- package/dist/ui/hooks/useAgentPicker.js.map +1 -0
- package/dist/ui/hooks/useAuthFlow.d.ts +14 -0
- package/dist/ui/hooks/useAuthFlow.d.ts.map +1 -0
- package/dist/ui/hooks/useAuthFlow.js +31 -0
- package/dist/ui/hooks/useAuthFlow.js.map +1 -0
- package/dist/ui/hooks/useKeysFlow.d.ts +17 -0
- package/dist/ui/hooks/useKeysFlow.d.ts.map +1 -0
- package/dist/ui/hooks/useKeysFlow.js +130 -0
- package/dist/ui/hooks/useKeysFlow.js.map +1 -0
- package/dist/ui/hooks/useSessionPicker.d.ts +29 -0
- package/dist/ui/hooks/useSessionPicker.d.ts.map +1 -0
- package/dist/ui/hooks/useSessionPicker.js +58 -0
- package/dist/ui/hooks/useSessionPicker.js.map +1 -0
- package/dist/ui/hooks/useTerminalSize.d.ts +6 -0
- package/dist/ui/hooks/useTerminalSize.d.ts.map +1 -0
- package/dist/ui/hooks/useTerminalSize.js +29 -0
- package/dist/ui/hooks/useTerminalSize.js.map +1 -0
- package/dist/ui/input/keyRouter.d.ts +125 -0
- package/dist/ui/input/keyRouter.d.ts.map +1 -0
- package/dist/ui/input/keyRouter.js +574 -0
- package/dist/ui/input/keyRouter.js.map +1 -0
- package/dist/ui/layouts/ScreenLayout.d.ts +98 -0
- package/dist/ui/layouts/ScreenLayout.d.ts.map +1 -0
- package/dist/ui/layouts/ScreenLayout.js +56 -0
- package/dist/ui/layouts/ScreenLayout.js.map +1 -0
- package/dist/ui/shared/types.d.ts +143 -0
- package/dist/ui/shared/types.d.ts.map +1 -0
- package/dist/ui/shared/types.js +38 -0
- package/dist/ui/shared/types.js.map +1 -0
- package/dist/ui/theme.d.ts +29 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +54 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/ui/utils/markdown.d.ts +74 -0
- package/dist/ui/utils/markdown.d.ts.map +1 -0
- package/dist/ui/utils/markdown.js +187 -0
- package/dist/ui/utils/markdown.js.map +1 -0
- package/dist/ui/utils/mentions.d.ts +12 -0
- package/dist/ui/utils/mentions.d.ts.map +1 -0
- package/dist/ui/utils/mentions.js +28 -0
- package/dist/ui/utils/mentions.js.map +1 -0
- package/dist/ui/utils/terminal-text.d.ts +33 -0
- package/dist/ui/utils/terminal-text.d.ts.map +1 -0
- package/dist/ui/utils/terminal-text.js +123 -0
- package/dist/ui/utils/terminal-text.js.map +1 -0
- package/dist/ui/utils/text.d.ts +72 -0
- package/dist/ui/utils/text.d.ts.map +1 -0
- package/dist/ui/utils/text.js +171 -0
- package/dist/ui/utils/text.js.map +1 -0
- package/eslint.config.js +40 -0
- package/graphify-out/GRAPH_REPORT.md +140 -0
- package/graphify-out/cache/1236b1806943f8eb5c64fece9fb448149370f4a1b52b32f0977ad528d7911291.json +1 -0
- package/graphify-out/cache/15cbf641dcc0fd641c18da872214918203a1f64baa7ac8430e4702ef32d18b02.json +1 -0
- package/graphify-out/cache/1abc52745bb46f6cc5a528530e2bc1f368c26e348dff85cdde5cad6f275d7177.json +1 -0
- package/graphify-out/cache/1c7815c37c13177e98895e272285f6151a8d0807478fc843ec452634b3e9912d.json +1 -0
- package/graphify-out/cache/1ec38c39f044f329c78642b61d6394fb8e15d0014335f32947d1f5c7b88c02bc.json +1 -0
- package/graphify-out/cache/20c9b57ff76dbb9d57cbd00659b0a42d2b28dd2abacf1ef4143cc67a5b6fe7f4.json +1 -0
- package/graphify-out/cache/285e11876884eb619e779d540cd957b33e70f14c67ecc26c9b9755aa9cedd717.json +1 -0
- package/graphify-out/cache/2c0a9c49ab51f4e0f07543b4e941bf802b7db31fa607c4cee8e595575be68fe7.json +1 -0
- package/graphify-out/cache/3025e6c2756c79ccaadd51d611f25a8b6630a6a11ce1b4e6e261b3e033dc194f.json +1 -0
- package/graphify-out/cache/4801a686ddfa0a52824a4fc3d65443cbb0ab9f0b030af67d02fccb520c584a08.json +1 -0
- package/graphify-out/cache/4f8fd96f38aa7d0293b4fab60c4581c4f3e68f4533c664c9cd78d1c53bea1cba.json +1 -0
- package/graphify-out/cache/5928e562b0f5700184b810e2403f4aa685e2b93c3c584c10460562b514c40fdd.json +1 -0
- package/graphify-out/cache/66132486efb0a4cfaeea766448f1f15bb33635808714052e7e24e5b00fbc984f.json +1 -0
- package/graphify-out/cache/66ab27669e7ec685130063662af9f30018c267f7639b4af4b0504a98282c383a.json +1 -0
- package/graphify-out/cache/6ff6b3dd433b5ffe96e166263a203dd622397e419dc00bb676824988b7defeab.json +1 -0
- package/graphify-out/cache/7a00a49932177a6215e2590b1ddfd6f1d8494792f693068e9d427d16b165d370.json +1 -0
- package/graphify-out/cache/7b681bc5182f40f707f1c0b16b78af38efffa62a1df315d10878f4de888408ef.json +1 -0
- package/graphify-out/cache/81196d44e50ac0b276d826a531ed10c425a528b298e3fe18e8d5a3eec996e9d5.json +1 -0
- package/graphify-out/cache/8934e9b32dea6e66fdc34fa1681b287ff1335c389917e0fc6ee2fc573e23e87b.json +1 -0
- package/graphify-out/cache/975f6c99807f86b79c80ca40c783618e2080a927eaebe6ea3db37b869f048851.json +1 -0
- package/graphify-out/cache/9ab98f08626fd8190462595e38de828293ad184db8df5e1177b05a8fe290faa1.json +1 -0
- package/graphify-out/cache/9c434a6796d7932b6e87a908c155c09cb2b8d097fc55f141f0302b6600f94749.json +1 -0
- package/graphify-out/cache/ac5cf4c489dc417c1f6ea728d0b6ba12ac7087bc6c2e736697ff3024b4d4e534.json +1 -0
- package/graphify-out/cache/ae5083b5c1dca3e5c6af485e7f6eb8a08ff8b382cdecf92ab5e0902053442afe.json +1 -0
- package/graphify-out/cache/b274057fc2e0118cf2746d1d8060841122bb2a2b0305566fc3f32d3a51e08bcc.json +1 -0
- package/graphify-out/cache/b39beef31da682387f030c0d149f6cd5b3e66effbf936cc8430db15360759dda.json +1 -0
- package/graphify-out/cache/bf3c6a36bb72820bc11cbf4a5c49067d1f62013d4686c019a4dbd9951b1e980e.json +1 -0
- package/graphify-out/cache/c034e156028d1a58b89bce659726e9a4065ddc4d2b560d6bce7a206fdff8dad3.json +1 -0
- package/graphify-out/cache/c619b5bbe8d1f427fbd7816d1e9fcfaf90d7201b020ae6b578166aeb9cb20683.json +1 -0
- package/graphify-out/cache/c8db77a9da0b0f601acfa50a620f31155cdda0d0cc0f2285adcea19e77194ee6.json +1 -0
- package/graphify-out/cache/ca664791ec7741a2077d9e7c10384142d30e7a3b77b388df719c315da608d57d.json +1 -0
- package/graphify-out/cache/cba43a116186bd55c8a63368dea4eee4a8123b2bec0a42df6efb3254f89f9a7a.json +1 -0
- package/graphify-out/cache/cd51cbb3dad1cf34417b9761fe2eb184a9f57d23dc86e45630e63bfa2ecafddc.json +1 -0
- package/graphify-out/cache/d06738cde193b34a136b94104220c17e0212b814b3e4d7ff399105635cae1a03.json +1 -0
- package/graphify-out/cache/d093c19f0169c0398eeb1360895b1c16ecc50abc59f4be8eec3f6fd27c89a6e5.json +1 -0
- package/graphify-out/cache/da8f75c438531d232fe114d5cbf2374576ce842a5fb87c7e5a88b78fdb334e5e.json +1 -0
- package/graphify-out/cache/e35798fa04ddede548a6953bdea506bd7d0788dfed4e8a8ea6ae77b1b60ef5e0.json +1 -0
- package/graphify-out/cache/e5a38c254719000487098782125e15e2e982c07d66b99d359ed1781f30f9fc8c.json +1 -0
- package/graphify-out/cache/e6e4c4a5a7200ee0154585b5d6538f699b0a746dbded3164f8391f06ce7cb212.json +1 -0
- package/graphify-out/cache/ea8d0838df6309b673b031f616b253af957898ee7289d25a541fa6183b732e4e.json +1 -0
- package/graphify-out/cache/ebaee92b0e881efd7a08f3143e2c1803310396b4651d4f77532003c699cc6836.json +1 -0
- package/graphify-out/cache/edf8543318a9e60d56d04704078da6c37202ddd6fdfc83144fe2b94fe19b80ef.json +1 -0
- package/graphify-out/cache/efca19d3668035f11126fc9eccbeab290abfa94babf3f9a8706de81d17aba263.json +1 -0
- package/graphify-out/cache/f1480bb642025ebd6d99986cdd8a7d5726897ec038300e4b095c9c938435dfad.json +1 -0
- package/graphify-out/cache/f459f21277f03865f732affb175b1b092954dae5967f27b3cd1864466e3e24f4.json +1 -0
- package/graphify-out/cache/f899e37e864010b30f4c196e86082d7bd022a0df032005e0407883ebcec36514.json +1 -0
- package/graphify-out/cache/fb3cbe07fbcd97c536cff9c6bc343c35f22d49613f05c53ad30ef67a75c5d93e.json +1 -0
- package/graphify-out/cache/fd3dc682b1ca2f5ae03b50d6b0e045ae50f5701c0a21c5a388d77ef482939d3a.json +1 -0
- package/graphify-out/graph.html +257 -0
- package/graphify-out/graph.json +4396 -0
- package/package.json +45 -6
- package/scripts/e2e-external.mjs +65 -0
- package/scripts/live-agents.mjs +6 -0
- package/scripts/live-stream.mjs +51 -0
- package/src/commands/agents.ts +91 -0
- package/src/commands/auth.ts +39 -0
- package/src/commands/chat.ts +198 -0
- package/src/commands/keys.ts +83 -0
- package/src/commands/local.ts +302 -0
- package/src/commands/mcp.ts +74 -0
- package/src/commands/prompts.ts +58 -0
- package/src/commands/skills.ts +43 -0
- package/src/core/auth/index.ts +101 -0
- package/src/core/config/index.ts +152 -0
- package/src/core/history.ts +79 -0
- package/src/core/markdown-renderer.ts +420 -0
- package/src/core/permissions/index.ts +99 -0
- package/src/core/provider/external.ts +312 -0
- package/src/core/provider/index.ts +517 -0
- package/src/core/registry/index.ts +250 -0
- package/src/core/schema/types.ts +106 -0
- package/src/core/terminal.ts +124 -0
- package/src/core/workspace/index.ts +216 -0
- package/src/index.ts +401 -0
- package/src/ui/app.tsx +644 -0
- package/src/ui/commands/cases/catalog.ts +76 -0
- package/src/ui/commands/cases/misc.ts +293 -0
- package/src/ui/commands/cases/tasks.ts +115 -0
- package/src/ui/commands/runCommand.ts +178 -0
- package/src/ui/components/Banner.tsx +63 -0
- package/src/ui/components/CommandMenu.tsx +63 -0
- package/src/ui/components/ErrorBoundary.tsx +75 -0
- package/src/ui/components/InputBar.tsx +227 -0
- package/src/ui/components/KeysPanel.tsx +115 -0
- package/src/ui/components/MessageView.tsx +226 -0
- package/src/ui/components/Pickers.tsx +234 -0
- package/src/ui/components/SearchOverlay.tsx +65 -0
- package/src/ui/components/WorkingIndicator.tsx +35 -0
- package/src/ui/controls/ApiKeyEntry.tsx +29 -0
- package/src/ui/controls/MultiSelect.tsx +55 -0
- package/src/ui/hooks/useAgentPicker.ts +64 -0
- package/src/ui/hooks/useAuthFlow.ts +47 -0
- package/src/ui/hooks/useKeysFlow.ts +157 -0
- package/src/ui/hooks/useSessionPicker.ts +84 -0
- package/src/ui/hooks/useTerminalSize.ts +36 -0
- package/src/ui/input/keyRouter.ts +627 -0
- package/src/ui/layouts/ScreenLayout.tsx +202 -0
- package/src/ui/shared/types.ts +160 -0
- package/src/ui/theme.ts +53 -0
- package/src/ui/utils/markdown.ts +255 -0
- package/src/ui/utils/mentions.ts +40 -0
- package/src/ui/utils/terminal-text.ts +130 -0
- package/src/ui/utils/text.ts +174 -0
- package/test/commands.test.mjs +127 -0
- package/test/config.test.mjs +123 -0
- package/test/history.test.mjs +42 -0
- package/test/keyrouter.test.mjs +324 -0
- package/test/layout.test.mjs +271 -0
- package/test/markdown.test.mjs +92 -0
- package/test/mentions.test.mjs +51 -0
- package/test/permissions.test.mjs +130 -0
- package/test/provider.test.mjs +287 -0
- package/test/terminal-text.test.mjs +116 -0
- package/test/text.test.mjs +134 -0
- package/test/workspace.test.mjs +101 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Tests: character-level prompt editing helpers (pure functions).
|
|
2
|
+
import { describe, it } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import {
|
|
5
|
+
toChars, clampCursor, insertAt, deleteBefore, deleteAt, wordAt, wordBounds,
|
|
6
|
+
lineStart, lineEnd, moveVertical, fuzzyScore, fuzzyRank,
|
|
7
|
+
} from "../dist/ui/utils/text.js";
|
|
8
|
+
|
|
9
|
+
describe("cursor basics", () => {
|
|
10
|
+
it("clamps out-of-range cursors", () => {
|
|
11
|
+
assert.equal(clampCursor(-3, "abc"), 0);
|
|
12
|
+
assert.equal(clampCursor(99, "abc"), 3);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("keeps emoji intact as one unit", () => {
|
|
16
|
+
assert.deepEqual(toChars("a😀b"), ["a", "😀", "b"]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe("insertAt / delete", () => {
|
|
21
|
+
it("inserts at the caret and advances it", () => {
|
|
22
|
+
assert.deepEqual(insertAt("ac", 1, "b"), { text: "abc", cursor: 2 });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("inserts a pasted chunk whole", () => {
|
|
26
|
+
const r = insertAt("ab", 1, "XY");
|
|
27
|
+
assert.equal(r.text, "aXYb");
|
|
28
|
+
assert.equal(r.cursor, 3);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("backspace at position 0 is a no-op", () => {
|
|
32
|
+
assert.deepEqual(deleteBefore("abc", 0), { text: "abc", cursor: 0 });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("delete at end of text is a no-op", () => {
|
|
36
|
+
assert.deepEqual(deleteAt("abc", 3), { text: "abc", cursor: 3 });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("deletes around the caret correctly", () => {
|
|
40
|
+
assert.deepEqual(deleteBefore("abc", 2), { text: "ac", cursor: 1 });
|
|
41
|
+
assert.deepEqual(deleteAt("abc", 1), { text: "ac", cursor: 1 });
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("wordAt", () => {
|
|
46
|
+
it("finds the token under the caret", () => {
|
|
47
|
+
assert.deepEqual(wordAt("/he", 3), { word: "/he", start: 0 });
|
|
48
|
+
assert.deepEqual(wordAt("hi /cl", 6), { word: "/cl", start: 3 });
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe("multiline navigation with wide characters", () => {
|
|
53
|
+
// The caret is a code-point index; the first implementation mixed in
|
|
54
|
+
// UTF-16 offsets from String.indexOf/length, so an emoji earlier in the
|
|
55
|
+
// draft shifted every line boundary.
|
|
56
|
+
const text = "😀😀😀\nabc";
|
|
57
|
+
|
|
58
|
+
it("finds the line start after a surrogate pair", () => {
|
|
59
|
+
assert.equal(lineStart(text, 7), 4);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("finds the line end in code points, not UTF-16 units", () => {
|
|
63
|
+
assert.equal(lineEnd(text, 4), 7);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("does not run off the end of the value", () => {
|
|
67
|
+
assert.ok(lineEnd(text, 7) <= toChars(text).length);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("stays on the first line when the caret is at index 0 of a leading newline", () => {
|
|
71
|
+
assert.equal(lineStart("\nabc", 0), 0);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("moves up to the same column on the previous line", () => {
|
|
75
|
+
assert.equal(moveVertical(text, 5, -1), 1);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe("wordBounds", () => {
|
|
80
|
+
it("spans the whole token around the caret", () => {
|
|
81
|
+
// wordAt stops at the caret; replacing a token needs both ends.
|
|
82
|
+
const bounds = wordBounds("/help", 2);
|
|
83
|
+
assert.equal(bounds.start, 0);
|
|
84
|
+
assert.equal(bounds.end, 5);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("stops at whitespace on both sides", () => {
|
|
88
|
+
assert.deepEqual(wordBounds("say /help now", 6), { start: 4, end: 9 });
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("multiline navigation", () => {
|
|
93
|
+
const text = "ab\ncdef\nghi";
|
|
94
|
+
|
|
95
|
+
it("finds line boundaries", () => {
|
|
96
|
+
assert.equal(lineStart(text, 1), 0);
|
|
97
|
+
assert.equal(lineStart(text, 5), 3);
|
|
98
|
+
assert.equal(lineEnd(text, 4), 7);
|
|
99
|
+
assert.equal(lineEnd(text, 10), text.length);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("moves up preserving the column", () => {
|
|
103
|
+
// Column 2 on line 2 ("gh|i" at 10 → col 1) moves to line 1 col 1.
|
|
104
|
+
assert.equal(moveVertical(text, 4, -1), 1);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("clamps the column to a shorter line", () => {
|
|
108
|
+
// From end of "cdef" (7) up to "ab" clamps to its end (2).
|
|
109
|
+
assert.equal(moveVertical(text, 7, -1), 2);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("stays put on the first/last line", () => {
|
|
113
|
+
assert.equal(moveVertical(text, 1, -1), 1);
|
|
114
|
+
assert.equal(moveVertical(text, 9, 1), 9);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("fuzzy search", () => {
|
|
119
|
+
it("matches subsequences case-insensitively", () => {
|
|
120
|
+
assert.ok(fuzzyScore("/History", "hi") >= 0);
|
|
121
|
+
assert.equal(fuzzyScore("abc", "xz"), -1);
|
|
122
|
+
assert.equal(fuzzyScore("anything", ""), 0);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("ranks matching candidates above non-matches", () => {
|
|
126
|
+
const items = ["/help", "the high story", "show history"];
|
|
127
|
+
assert.deepEqual(fuzzyRank(items, "hi", (s) => s), ["the high story", "show history"]);
|
|
128
|
+
assert.equal(fuzzyScore("/help", "hi"), -1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("works with emoji without splitting a surrogate pair", () => {
|
|
132
|
+
assert.ok(fuzzyScore("😀 deploy service", "ds") >= 0);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Tests: workspace path confinement.
|
|
2
|
+
//
|
|
3
|
+
// Confinement is the only thing standing between a model-authored command and
|
|
4
|
+
// the rest of the filesystem, so these cover the escape routes that a purely
|
|
5
|
+
// lexical check misses: `..` traversal, junctions/symlinks, path case, and
|
|
6
|
+
// Windows device/UNC paths.
|
|
7
|
+
import { describe, it, before, after } from "node:test";
|
|
8
|
+
import assert from "node:assert/strict";
|
|
9
|
+
import { mkdtempSync, mkdirSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join, sep } from "node:path";
|
|
12
|
+
|
|
13
|
+
// The workspace root is read once per process and honours ODYSX_WORKSPACE,
|
|
14
|
+
// so point it at a scratch directory before importing the module.
|
|
15
|
+
const root = mkdtempSync(join(tmpdir(), "odysx-ws-"));
|
|
16
|
+
const outside = mkdtempSync(join(tmpdir(), "odysx-out-"));
|
|
17
|
+
process.env.ODYSX_WORKSPACE = root;
|
|
18
|
+
|
|
19
|
+
const { confinePath, getWorkspaceRoot } = await import("../dist/core/workspace/index.js");
|
|
20
|
+
|
|
21
|
+
before(() => {
|
|
22
|
+
mkdirSync(join(root, "src"), { recursive: true });
|
|
23
|
+
writeFileSync(join(root, "src", "app.ts"), "x");
|
|
24
|
+
writeFileSync(join(outside, "secret.txt"), "s");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
after(() => {
|
|
28
|
+
delete process.env.ODYSX_WORKSPACE;
|
|
29
|
+
for (const dir of [root, outside]) {
|
|
30
|
+
try { rmSync(dir, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe("confinePath", () => {
|
|
35
|
+
it("accepts a relative path inside the root", () => {
|
|
36
|
+
const decision = confinePath("src/app.ts");
|
|
37
|
+
assert.equal(decision.ok, true);
|
|
38
|
+
assert.ok(decision.resolved.startsWith(root));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("accepts an absolute path already inside the root", () => {
|
|
42
|
+
assert.equal(confinePath(join(root, "src", "app.ts")).ok, true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("refuses traversal out of the root", () => {
|
|
46
|
+
const decision = confinePath("../" + "outside.txt");
|
|
47
|
+
assert.equal(decision.ok, false);
|
|
48
|
+
assert.match(decision.error, /escapes workspace/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("refuses an absolute path outside the root", () => {
|
|
52
|
+
assert.equal(confinePath(join(outside, "secret.txt")).ok, false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("refuses a path that climbs out and back in via a sibling prefix", () => {
|
|
56
|
+
// "<root>-evil" shares the root's prefix as a string but is a different
|
|
57
|
+
// directory; a naive startsWith accepts it.
|
|
58
|
+
assert.equal(confinePath(join(root + "-evil", "x")).ok, false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("refuses Windows device and UNC paths", () => {
|
|
62
|
+
if (process.platform !== "win32") return;
|
|
63
|
+
for (const p of ["\\\\?\\C:\\Windows\\System32", "\\\\server\\share\\x"]) {
|
|
64
|
+
const decision = confinePath(p);
|
|
65
|
+
assert.equal(decision.ok, false, p);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("follows a symlink/junction out of the workspace and refuses it", () => {
|
|
70
|
+
// Junction creation needs elevation on Windows; symlinks need Developer
|
|
71
|
+
// Mode. If the platform refuses, the escape route doesn't exist either.
|
|
72
|
+
const link = join(root, "link-out");
|
|
73
|
+
try {
|
|
74
|
+
symlinkSync(outside, link, "junction");
|
|
75
|
+
} catch {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const decision = confinePath("link-out/secret.txt");
|
|
79
|
+
assert.equal(decision.ok, false, "a link out of the root must not resolve inside it");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("resolves the root itself as inside", () => {
|
|
83
|
+
assert.equal(confinePath(".").ok, true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("treats path case consistently on case-insensitive platforms", () => {
|
|
87
|
+
if (process.platform !== "win32" && process.platform !== "darwin") return;
|
|
88
|
+
const decision = confinePath(join(root, "SRC", "APP.TS"));
|
|
89
|
+
assert.equal(decision.ok, true, "the filesystem is case-insensitive, so the guard must be too");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("exposes the resolved root", () => {
|
|
93
|
+
assert.equal(getWorkspaceRoot(), realpathSync.native(root));
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
describe("workspace root", () => {
|
|
98
|
+
it("never reports a path with a trailing separator", () => {
|
|
99
|
+
assert.ok(!getWorkspaceRoot().endsWith(sep) || getWorkspaceRoot() === sep);
|
|
100
|
+
});
|
|
101
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"rootDir": "src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUnusedLocals": false,
|
|
10
|
+
"noUnusedParameters": false,
|
|
11
|
+
"noFallthroughCasesInSwitch": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"types": [
|
|
14
|
+
"node"
|
|
15
|
+
],
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"forceConsistentCasingInFileNames": true,
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"declaration": true,
|
|
20
|
+
"declarationMap": true,
|
|
21
|
+
"sourceMap": true,
|
|
22
|
+
"jsx": "react-jsx",
|
|
23
|
+
"jsxImportSource": "react"
|
|
24
|
+
},
|
|
25
|
+
"include": [
|
|
26
|
+
"src/**/*"
|
|
27
|
+
],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
"dist"
|
|
31
|
+
]
|
|
32
|
+
}
|