@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.
- package/dist/core/provider/index.d.ts +52 -10
- package/dist/core/provider/index.js +99 -12
- package/package.json +6 -1
- package/dist/commands/agents.d.ts.map +0 -1
- package/dist/commands/agents.js.map +0 -1
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/chat.d.ts.map +0 -1
- package/dist/commands/chat.js.map +0 -1
- package/dist/commands/keys.d.ts.map +0 -1
- package/dist/commands/keys.js.map +0 -1
- package/dist/commands/local.d.ts.map +0 -1
- package/dist/commands/local.js.map +0 -1
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/prompts.d.ts.map +0 -1
- package/dist/commands/prompts.js.map +0 -1
- package/dist/commands/skills.d.ts.map +0 -1
- package/dist/commands/skills.js.map +0 -1
- package/dist/core/auth/index.d.ts.map +0 -1
- package/dist/core/auth/index.js.map +0 -1
- package/dist/core/config/index.d.ts.map +0 -1
- package/dist/core/config/index.js.map +0 -1
- package/dist/core/history.d.ts.map +0 -1
- package/dist/core/history.js.map +0 -1
- package/dist/core/markdown-renderer.d.ts.map +0 -1
- package/dist/core/markdown-renderer.js.map +0 -1
- package/dist/core/permissions/index.d.ts.map +0 -1
- package/dist/core/permissions/index.js.map +0 -1
- package/dist/core/provider/external.d.ts.map +0 -1
- package/dist/core/provider/external.js.map +0 -1
- package/dist/core/provider/index.d.ts.map +0 -1
- package/dist/core/provider/index.js.map +0 -1
- package/dist/core/registry/index.d.ts.map +0 -1
- package/dist/core/registry/index.js.map +0 -1
- package/dist/core/schema/types.d.ts.map +0 -1
- package/dist/core/schema/types.js.map +0 -1
- package/dist/core/terminal.d.ts.map +0 -1
- package/dist/core/terminal.js.map +0 -1
- package/dist/core/workspace/index.d.ts.map +0 -1
- package/dist/core/workspace/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ui/app.d.ts.map +0 -1
- package/dist/ui/app.js.map +0 -1
- package/dist/ui/commands/cases/catalog.d.ts.map +0 -1
- package/dist/ui/commands/cases/catalog.js.map +0 -1
- package/dist/ui/commands/cases/misc.d.ts.map +0 -1
- package/dist/ui/commands/cases/misc.js.map +0 -1
- package/dist/ui/commands/cases/tasks.d.ts.map +0 -1
- package/dist/ui/commands/cases/tasks.js.map +0 -1
- package/dist/ui/commands/runCommand.d.ts.map +0 -1
- package/dist/ui/commands/runCommand.js.map +0 -1
- package/dist/ui/components/AgentPicker.d.ts.map +0 -1
- package/dist/ui/components/AgentPicker.js.map +0 -1
- package/dist/ui/components/AuthPicker.d.ts.map +0 -1
- package/dist/ui/components/AuthPicker.js.map +0 -1
- package/dist/ui/components/Banner.d.ts.map +0 -1
- package/dist/ui/components/Banner.js.map +0 -1
- package/dist/ui/components/CommandMenu.d.ts.map +0 -1
- package/dist/ui/components/CommandMenu.js.map +0 -1
- package/dist/ui/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/ui/components/ErrorBoundary.js.map +0 -1
- package/dist/ui/components/InputBar.d.ts.map +0 -1
- package/dist/ui/components/InputBar.js.map +0 -1
- package/dist/ui/components/KeysPanel.d.ts.map +0 -1
- package/dist/ui/components/KeysPanel.js.map +0 -1
- package/dist/ui/components/MessageView.d.ts.map +0 -1
- package/dist/ui/components/MessageView.js.map +0 -1
- package/dist/ui/components/PermissionPrompt.d.ts.map +0 -1
- package/dist/ui/components/PermissionPrompt.js.map +0 -1
- package/dist/ui/components/Pickers.d.ts.map +0 -1
- package/dist/ui/components/Pickers.js.map +0 -1
- package/dist/ui/components/SearchOverlay.d.ts.map +0 -1
- package/dist/ui/components/SearchOverlay.js.map +0 -1
- package/dist/ui/components/SessionPicker.d.ts.map +0 -1
- package/dist/ui/components/SessionPicker.js.map +0 -1
- package/dist/ui/components/WorkingIndicator.d.ts.map +0 -1
- package/dist/ui/components/WorkingIndicator.js.map +0 -1
- package/dist/ui/controls/ApiKeyEntry.d.ts.map +0 -1
- package/dist/ui/controls/ApiKeyEntry.js.map +0 -1
- package/dist/ui/controls/MultiSelect.d.ts.map +0 -1
- package/dist/ui/controls/MultiSelect.js.map +0 -1
- package/dist/ui/hooks/useAgentPicker.d.ts.map +0 -1
- package/dist/ui/hooks/useAgentPicker.js.map +0 -1
- package/dist/ui/hooks/useAuthFlow.d.ts.map +0 -1
- package/dist/ui/hooks/useAuthFlow.js.map +0 -1
- package/dist/ui/hooks/useKeysFlow.d.ts.map +0 -1
- package/dist/ui/hooks/useKeysFlow.js.map +0 -1
- package/dist/ui/hooks/useSessionPicker.d.ts.map +0 -1
- package/dist/ui/hooks/useSessionPicker.js.map +0 -1
- package/dist/ui/hooks/useTerminalSize.d.ts.map +0 -1
- package/dist/ui/hooks/useTerminalSize.js.map +0 -1
- package/dist/ui/input/keyRouter.d.ts.map +0 -1
- package/dist/ui/input/keyRouter.js.map +0 -1
- package/dist/ui/layouts/ScreenLayout.d.ts.map +0 -1
- package/dist/ui/layouts/ScreenLayout.js.map +0 -1
- package/dist/ui/shared/types.d.ts.map +0 -1
- package/dist/ui/shared/types.js.map +0 -1
- package/dist/ui/theme.d.ts.map +0 -1
- package/dist/ui/theme.js.map +0 -1
- package/dist/ui/utils/markdown.d.ts.map +0 -1
- package/dist/ui/utils/markdown.js.map +0 -1
- package/dist/ui/utils/mentions.d.ts.map +0 -1
- package/dist/ui/utils/mentions.js.map +0 -1
- package/dist/ui/utils/terminal-text.d.ts.map +0 -1
- package/dist/ui/utils/terminal-text.js.map +0 -1
- package/dist/ui/utils/text.d.ts.map +0 -1
- package/dist/ui/utils/text.js.map +0 -1
- package/eslint.config.js +0 -40
- package/graphify-out/GRAPH_REPORT.md +0 -140
- package/graphify-out/cache/1236b1806943f8eb5c64fece9fb448149370f4a1b52b32f0977ad528d7911291.json +0 -1
- package/graphify-out/cache/15cbf641dcc0fd641c18da872214918203a1f64baa7ac8430e4702ef32d18b02.json +0 -1
- package/graphify-out/cache/1abc52745bb46f6cc5a528530e2bc1f368c26e348dff85cdde5cad6f275d7177.json +0 -1
- package/graphify-out/cache/1c7815c37c13177e98895e272285f6151a8d0807478fc843ec452634b3e9912d.json +0 -1
- package/graphify-out/cache/1ec38c39f044f329c78642b61d6394fb8e15d0014335f32947d1f5c7b88c02bc.json +0 -1
- package/graphify-out/cache/20c9b57ff76dbb9d57cbd00659b0a42d2b28dd2abacf1ef4143cc67a5b6fe7f4.json +0 -1
- package/graphify-out/cache/285e11876884eb619e779d540cd957b33e70f14c67ecc26c9b9755aa9cedd717.json +0 -1
- package/graphify-out/cache/2c0a9c49ab51f4e0f07543b4e941bf802b7db31fa607c4cee8e595575be68fe7.json +0 -1
- package/graphify-out/cache/3025e6c2756c79ccaadd51d611f25a8b6630a6a11ce1b4e6e261b3e033dc194f.json +0 -1
- package/graphify-out/cache/4801a686ddfa0a52824a4fc3d65443cbb0ab9f0b030af67d02fccb520c584a08.json +0 -1
- package/graphify-out/cache/4f8fd96f38aa7d0293b4fab60c4581c4f3e68f4533c664c9cd78d1c53bea1cba.json +0 -1
- package/graphify-out/cache/5928e562b0f5700184b810e2403f4aa685e2b93c3c584c10460562b514c40fdd.json +0 -1
- package/graphify-out/cache/66132486efb0a4cfaeea766448f1f15bb33635808714052e7e24e5b00fbc984f.json +0 -1
- package/graphify-out/cache/66ab27669e7ec685130063662af9f30018c267f7639b4af4b0504a98282c383a.json +0 -1
- package/graphify-out/cache/6ff6b3dd433b5ffe96e166263a203dd622397e419dc00bb676824988b7defeab.json +0 -1
- package/graphify-out/cache/7a00a49932177a6215e2590b1ddfd6f1d8494792f693068e9d427d16b165d370.json +0 -1
- package/graphify-out/cache/7b681bc5182f40f707f1c0b16b78af38efffa62a1df315d10878f4de888408ef.json +0 -1
- package/graphify-out/cache/81196d44e50ac0b276d826a531ed10c425a528b298e3fe18e8d5a3eec996e9d5.json +0 -1
- package/graphify-out/cache/8934e9b32dea6e66fdc34fa1681b287ff1335c389917e0fc6ee2fc573e23e87b.json +0 -1
- package/graphify-out/cache/975f6c99807f86b79c80ca40c783618e2080a927eaebe6ea3db37b869f048851.json +0 -1
- package/graphify-out/cache/9ab98f08626fd8190462595e38de828293ad184db8df5e1177b05a8fe290faa1.json +0 -1
- package/graphify-out/cache/9c434a6796d7932b6e87a908c155c09cb2b8d097fc55f141f0302b6600f94749.json +0 -1
- package/graphify-out/cache/ac5cf4c489dc417c1f6ea728d0b6ba12ac7087bc6c2e736697ff3024b4d4e534.json +0 -1
- package/graphify-out/cache/ae5083b5c1dca3e5c6af485e7f6eb8a08ff8b382cdecf92ab5e0902053442afe.json +0 -1
- package/graphify-out/cache/b274057fc2e0118cf2746d1d8060841122bb2a2b0305566fc3f32d3a51e08bcc.json +0 -1
- package/graphify-out/cache/b39beef31da682387f030c0d149f6cd5b3e66effbf936cc8430db15360759dda.json +0 -1
- package/graphify-out/cache/bf3c6a36bb72820bc11cbf4a5c49067d1f62013d4686c019a4dbd9951b1e980e.json +0 -1
- package/graphify-out/cache/c034e156028d1a58b89bce659726e9a4065ddc4d2b560d6bce7a206fdff8dad3.json +0 -1
- package/graphify-out/cache/c619b5bbe8d1f427fbd7816d1e9fcfaf90d7201b020ae6b578166aeb9cb20683.json +0 -1
- package/graphify-out/cache/c8db77a9da0b0f601acfa50a620f31155cdda0d0cc0f2285adcea19e77194ee6.json +0 -1
- package/graphify-out/cache/ca664791ec7741a2077d9e7c10384142d30e7a3b77b388df719c315da608d57d.json +0 -1
- package/graphify-out/cache/cba43a116186bd55c8a63368dea4eee4a8123b2bec0a42df6efb3254f89f9a7a.json +0 -1
- package/graphify-out/cache/cd51cbb3dad1cf34417b9761fe2eb184a9f57d23dc86e45630e63bfa2ecafddc.json +0 -1
- package/graphify-out/cache/d06738cde193b34a136b94104220c17e0212b814b3e4d7ff399105635cae1a03.json +0 -1
- package/graphify-out/cache/d093c19f0169c0398eeb1360895b1c16ecc50abc59f4be8eec3f6fd27c89a6e5.json +0 -1
- package/graphify-out/cache/da8f75c438531d232fe114d5cbf2374576ce842a5fb87c7e5a88b78fdb334e5e.json +0 -1
- package/graphify-out/cache/e35798fa04ddede548a6953bdea506bd7d0788dfed4e8a8ea6ae77b1b60ef5e0.json +0 -1
- package/graphify-out/cache/e5a38c254719000487098782125e15e2e982c07d66b99d359ed1781f30f9fc8c.json +0 -1
- package/graphify-out/cache/e6e4c4a5a7200ee0154585b5d6538f699b0a746dbded3164f8391f06ce7cb212.json +0 -1
- package/graphify-out/cache/ea8d0838df6309b673b031f616b253af957898ee7289d25a541fa6183b732e4e.json +0 -1
- package/graphify-out/cache/ebaee92b0e881efd7a08f3143e2c1803310396b4651d4f77532003c699cc6836.json +0 -1
- package/graphify-out/cache/edf8543318a9e60d56d04704078da6c37202ddd6fdfc83144fe2b94fe19b80ef.json +0 -1
- package/graphify-out/cache/efca19d3668035f11126fc9eccbeab290abfa94babf3f9a8706de81d17aba263.json +0 -1
- package/graphify-out/cache/f1480bb642025ebd6d99986cdd8a7d5726897ec038300e4b095c9c938435dfad.json +0 -1
- package/graphify-out/cache/f459f21277f03865f732affb175b1b092954dae5967f27b3cd1864466e3e24f4.json +0 -1
- package/graphify-out/cache/f899e37e864010b30f4c196e86082d7bd022a0df032005e0407883ebcec36514.json +0 -1
- package/graphify-out/cache/fb3cbe07fbcd97c536cff9c6bc343c35f22d49613f05c53ad30ef67a75c5d93e.json +0 -1
- package/graphify-out/cache/fd3dc682b1ca2f5ae03b50d6b0e045ae50f5701c0a21c5a388d77ef482939d3a.json +0 -1
- package/graphify-out/graph.html +0 -257
- package/graphify-out/graph.json +0 -4396
- package/scripts/e2e-external.mjs +0 -65
- package/scripts/live-agents.mjs +0 -6
- package/scripts/live-stream.mjs +0 -51
- package/src/commands/agents.ts +0 -91
- package/src/commands/auth.ts +0 -39
- package/src/commands/chat.ts +0 -198
- package/src/commands/keys.ts +0 -83
- package/src/commands/local.ts +0 -302
- package/src/commands/mcp.ts +0 -74
- package/src/commands/prompts.ts +0 -58
- package/src/commands/skills.ts +0 -43
- package/src/core/auth/index.ts +0 -101
- package/src/core/config/index.ts +0 -152
- package/src/core/history.ts +0 -79
- package/src/core/markdown-renderer.ts +0 -420
- package/src/core/permissions/index.ts +0 -99
- package/src/core/provider/external.ts +0 -312
- package/src/core/provider/index.ts +0 -517
- package/src/core/registry/index.ts +0 -250
- package/src/core/schema/types.ts +0 -106
- package/src/core/terminal.ts +0 -124
- package/src/core/workspace/index.ts +0 -216
- package/src/index.ts +0 -401
- package/src/ui/app.tsx +0 -644
- package/src/ui/commands/cases/catalog.ts +0 -76
- package/src/ui/commands/cases/misc.ts +0 -293
- package/src/ui/commands/cases/tasks.ts +0 -115
- package/src/ui/commands/runCommand.ts +0 -178
- package/src/ui/components/Banner.tsx +0 -63
- package/src/ui/components/CommandMenu.tsx +0 -63
- package/src/ui/components/ErrorBoundary.tsx +0 -75
- package/src/ui/components/InputBar.tsx +0 -227
- package/src/ui/components/KeysPanel.tsx +0 -115
- package/src/ui/components/MessageView.tsx +0 -226
- package/src/ui/components/Pickers.tsx +0 -234
- package/src/ui/components/SearchOverlay.tsx +0 -65
- package/src/ui/components/WorkingIndicator.tsx +0 -35
- package/src/ui/controls/ApiKeyEntry.tsx +0 -29
- package/src/ui/controls/MultiSelect.tsx +0 -55
- package/src/ui/hooks/useAgentPicker.ts +0 -64
- package/src/ui/hooks/useAuthFlow.ts +0 -47
- package/src/ui/hooks/useKeysFlow.ts +0 -157
- package/src/ui/hooks/useSessionPicker.ts +0 -84
- package/src/ui/hooks/useTerminalSize.ts +0 -36
- package/src/ui/input/keyRouter.ts +0 -627
- package/src/ui/layouts/ScreenLayout.tsx +0 -202
- package/src/ui/shared/types.ts +0 -160
- package/src/ui/theme.ts +0 -53
- package/src/ui/utils/markdown.ts +0 -255
- package/src/ui/utils/mentions.ts +0 -40
- package/src/ui/utils/terminal-text.ts +0 -130
- package/src/ui/utils/text.ts +0 -174
- package/test/commands.test.mjs +0 -127
- package/test/config.test.mjs +0 -123
- package/test/history.test.mjs +0 -42
- package/test/keyrouter.test.mjs +0 -324
- package/test/layout.test.mjs +0 -271
- package/test/markdown.test.mjs +0 -92
- package/test/mentions.test.mjs +0 -51
- package/test/permissions.test.mjs +0 -130
- package/test/provider.test.mjs +0 -287
- package/test/terminal-text.test.mjs +0 -116
- package/test/text.test.mjs +0 -134
- package/test/workspace.test.mjs +0 -101
- package/tsconfig.json +0 -32
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message rendering — user prompts, system notices, and markdown-aware agent
|
|
3
|
-
* replies.
|
|
4
|
-
*
|
|
5
|
-
* Completed messages render once inside Ink's static region (see
|
|
6
|
-
* ScreenLayout), so this component can afford real structure: headings,
|
|
7
|
-
* lists, fenced code with a language label, quotes, rules, and tables. The
|
|
8
|
-
* cheap line parser lives in utils/markdown.ts.
|
|
9
|
-
*/
|
|
10
|
-
import React, { memo } from "react";
|
|
11
|
-
import { Box, Text, useStdout } from "ink";
|
|
12
|
-
import type { ChatMessage } from "../shared/types.js";
|
|
13
|
-
import { parseMarkdown } from "../utils/markdown.js";
|
|
14
|
-
import type { InlineRun, MdLine } from "../utils/markdown.js";
|
|
15
|
-
import { displayWidth, padToWidth, sanitize, truncateToWidth } from "../utils/terminal-text.js";
|
|
16
|
-
import { theme, systemColor } from "../theme.js";
|
|
17
|
-
|
|
18
|
-
/* ── Inline styling ─────────────────────────────────────────────────────── */
|
|
19
|
-
|
|
20
|
-
const Run = ({ run }: { run: InlineRun }) => (
|
|
21
|
-
<Text
|
|
22
|
-
bold={run.bold}
|
|
23
|
-
italic={run.italic}
|
|
24
|
-
underline={run.underline}
|
|
25
|
-
strikethrough={run.strike}
|
|
26
|
-
color={run.code ? theme.color.code : run.link ? theme.color.link : undefined}
|
|
27
|
-
>
|
|
28
|
-
{run.text}
|
|
29
|
-
</Text>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const Runs = ({ runs }: { runs: InlineRun[] }) =>
|
|
33
|
-
runs.length === 0 ? null : (
|
|
34
|
-
<>
|
|
35
|
-
{runs.map((run, i) => (
|
|
36
|
-
<Run key={i} run={run} />
|
|
37
|
-
))}
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
/* ── Block rendering ────────────────────────────────────────────────────── */
|
|
42
|
-
|
|
43
|
-
const MAX_CODE_LINES = 400;
|
|
44
|
-
|
|
45
|
-
const CodeBlock = ({ lang, lines, open }: { lang: string; lines: string[]; open: boolean }) => {
|
|
46
|
-
const shown = lines.slice(0, MAX_CODE_LINES);
|
|
47
|
-
const hidden = lines.length - shown.length;
|
|
48
|
-
return (
|
|
49
|
-
<Box flexDirection="column" marginY={1}>
|
|
50
|
-
<Text dimColor>
|
|
51
|
-
{theme.glyph.rule.repeat(2)} {lang || "code"}
|
|
52
|
-
{open ? " …" : ""}
|
|
53
|
-
</Text>
|
|
54
|
-
<Box flexDirection="column" paddingLeft={1}>
|
|
55
|
-
{shown.map((line, i) => (
|
|
56
|
-
<Text key={i} color={theme.color.muted}>
|
|
57
|
-
{line || " "}
|
|
58
|
-
</Text>
|
|
59
|
-
))}
|
|
60
|
-
{hidden > 0 && <Text dimColor>… {hidden} more lines</Text>}
|
|
61
|
-
</Box>
|
|
62
|
-
<Text dimColor>{theme.glyph.rule.repeat(2)}</Text>
|
|
63
|
-
</Box>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const TableBlock = ({ line }: { line: Extract<MdLine, { kind: "table" }> }) => {
|
|
68
|
-
const { stdout } = useStdout();
|
|
69
|
-
const available = Math.max(20, (stdout?.columns ?? 80) - 4);
|
|
70
|
-
const columns = line.header.length;
|
|
71
|
-
// Column widths are measured in terminal columns, not code units: a CJK or
|
|
72
|
-
// emoji cell is two columns wide and would misalign every row after it.
|
|
73
|
-
// The per-cell cap keeps a wide table inside the terminal instead of
|
|
74
|
-
// letting Ink wrap it into unreadable fragments.
|
|
75
|
-
const cap = Math.max(6, Math.floor((available - 2 * (columns - 1)) / columns));
|
|
76
|
-
const widths = line.header.map((cell, i) => {
|
|
77
|
-
let width = Math.max(displayWidth(cell), 3);
|
|
78
|
-
// reduce, not spread: Math.max(...rows) overflows the stack on huge tables
|
|
79
|
-
for (const row of line.rows) width = Math.max(width, displayWidth(row[i] ?? ""));
|
|
80
|
-
return Math.min(width, cap);
|
|
81
|
-
});
|
|
82
|
-
const pad = (cell: string, i: number): string =>
|
|
83
|
-
padToWidth(truncateToWidth(cell, widths[i], ""), widths[i], line.align[i] ?? "left");
|
|
84
|
-
return (
|
|
85
|
-
<Box flexDirection="column" marginY={1}>
|
|
86
|
-
<Text bold color={theme.color.brand}>
|
|
87
|
-
{line.header.map((c, i) => pad(c, i)).join(" ")}
|
|
88
|
-
</Text>
|
|
89
|
-
<Text dimColor>{widths.map((w) => theme.glyph.rule.repeat(w)).join(" ")}</Text>
|
|
90
|
-
{line.rows.map((row, r) => (
|
|
91
|
-
<Text key={r}>{row.map((c, i) => pad(c ?? "", i)).join(" ")}</Text>
|
|
92
|
-
))}
|
|
93
|
-
</Box>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const Block = ({ line }: { line: MdLine }) => {
|
|
98
|
-
// Called unconditionally: hooks may not sit inside a switch branch.
|
|
99
|
-
const { stdout } = useStdout();
|
|
100
|
-
switch (line.kind) {
|
|
101
|
-
case "blank":
|
|
102
|
-
return <Text> </Text>;
|
|
103
|
-
case "heading":
|
|
104
|
-
return (
|
|
105
|
-
<Box marginTop={1}>
|
|
106
|
-
<Text bold color={theme.color.brand}>
|
|
107
|
-
<Runs runs={line.runs} />
|
|
108
|
-
</Text>
|
|
109
|
-
</Box>
|
|
110
|
-
);
|
|
111
|
-
case "rule": {
|
|
112
|
-
// A fixed 40 is right for exactly one width: at 40 columns the 41st
|
|
113
|
-
// cell wrapped and left an orphan glyph on the next line.
|
|
114
|
-
const width = Math.max(10, Math.min(40, (stdout?.columns ?? 80) - 4));
|
|
115
|
-
return <Text dimColor>{theme.glyph.rule.repeat(width)}</Text>;
|
|
116
|
-
}
|
|
117
|
-
case "quote":
|
|
118
|
-
return (
|
|
119
|
-
<Text color={theme.color.accent}>
|
|
120
|
-
{theme.glyph.bar} <Runs runs={line.runs} />
|
|
121
|
-
</Text>
|
|
122
|
-
);
|
|
123
|
-
case "bullet":
|
|
124
|
-
return (
|
|
125
|
-
<Text>
|
|
126
|
-
{" ".repeat(line.depth)}
|
|
127
|
-
<Text color={theme.color.success}>{line.marker} </Text>
|
|
128
|
-
<Runs runs={line.runs} />
|
|
129
|
-
</Text>
|
|
130
|
-
);
|
|
131
|
-
case "code":
|
|
132
|
-
return <CodeBlock lang={line.lang} lines={line.lines} open={line.open} />;
|
|
133
|
-
case "table":
|
|
134
|
-
return <TableBlock line={line} />;
|
|
135
|
-
case "text":
|
|
136
|
-
default:
|
|
137
|
-
return (
|
|
138
|
-
<Text wrap="wrap">
|
|
139
|
-
<Runs runs={line.runs} />
|
|
140
|
-
</Text>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
/* ── Messages ───────────────────────────────────────────────────────────── */
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* How many rendered blocks of a live reply are shown at once.
|
|
149
|
-
*
|
|
150
|
-
* A 1200-line reply costs ~266 ms per frame in Ink's layout/output pass; 90%
|
|
151
|
-
* of that is node layout, not parsing. Rendering only the tail bounds the
|
|
152
|
-
* frame to roughly constant time. Nothing is lost: when the turn ends the
|
|
153
|
-
* whole message moves into <Static> and is written once, in full.
|
|
154
|
-
*/
|
|
155
|
-
const LIVE_BLOCK_LIMIT = 60;
|
|
156
|
-
|
|
157
|
-
const MessageViewImpl = ({ msg, live = false }: { msg: ChatMessage; live?: boolean }) => {
|
|
158
|
-
// User text comes from the keyboard (and mid-prompt pastes) and system lines
|
|
159
|
-
// can embed server error strings: both are untrusted for terminal purposes.
|
|
160
|
-
if (msg.role === "user") {
|
|
161
|
-
return (
|
|
162
|
-
<Box
|
|
163
|
-
marginTop={1}
|
|
164
|
-
marginBottom={1}
|
|
165
|
-
paddingLeft={1}
|
|
166
|
-
borderStyle="round"
|
|
167
|
-
borderColor={theme.color.muted}
|
|
168
|
-
borderTop={false}
|
|
169
|
-
borderRight={false}
|
|
170
|
-
borderBottom={false}
|
|
171
|
-
>
|
|
172
|
-
<Text color={theme.color.user} bold>
|
|
173
|
-
{theme.glyph.pointer}{" "}
|
|
174
|
-
</Text>
|
|
175
|
-
<Text color={theme.color.user}>{sanitize(msg.text)}</Text>
|
|
176
|
-
</Box>
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (msg.role === "system") {
|
|
181
|
-
const text = sanitize(msg.text);
|
|
182
|
-
return (
|
|
183
|
-
<Box marginTop={1} paddingLeft={1}>
|
|
184
|
-
<Text color={systemColor(text)} wrap="wrap">
|
|
185
|
-
{text}
|
|
186
|
-
</Text>
|
|
187
|
-
</Box>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const blocks = parseMarkdown(msg.text);
|
|
192
|
-
const hidden = live ? Math.max(0, blocks.length - LIVE_BLOCK_LIMIT) : 0;
|
|
193
|
-
const shown = hidden > 0 ? blocks.slice(-LIVE_BLOCK_LIMIT) : blocks;
|
|
194
|
-
return (
|
|
195
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
196
|
-
<Box>
|
|
197
|
-
<Text color={theme.color.accent} bold>
|
|
198
|
-
{msg.agentName ?? "agent"}
|
|
199
|
-
</Text>
|
|
200
|
-
<Text dimColor> {theme.glyph.info}</Text>
|
|
201
|
-
</Box>
|
|
202
|
-
<Box flexDirection="column" paddingLeft={1}>
|
|
203
|
-
{hidden > 0 && (
|
|
204
|
-
<Text dimColor>… {hidden} earlier line{hidden === 1 ? "" : "s"} (shown in full when the reply finishes)</Text>
|
|
205
|
-
)}
|
|
206
|
-
{shown.map((line, i) => (
|
|
207
|
-
<Block key={hidden + i} line={line} />
|
|
208
|
-
))}
|
|
209
|
-
</Box>
|
|
210
|
-
</Box>
|
|
211
|
-
);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const MessageView = memo(MessageViewImpl);
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* The reply currently being streamed. Rendered outside the static region.
|
|
218
|
-
*
|
|
219
|
-
* Memoized on purpose: a token commit replaces the message object and should
|
|
220
|
-
* re-parse, but keystrokes and the elapsed-seconds tick also re-render App
|
|
221
|
-
* while a turn is live. Without `memo` each of those re-parses the entire
|
|
222
|
-
* reply (several ms on a long answer) for no visible change.
|
|
223
|
-
*/
|
|
224
|
-
export const StreamingMessage = memo(({ msg }: { msg: ChatMessage }) => (
|
|
225
|
-
<MessageViewImpl msg={msg} live />
|
|
226
|
-
));
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Overlay pickers: agent switcher, session resumer, sign-in chooser, and the
|
|
3
|
-
* y/N permission prompt for risky local ops.
|
|
4
|
-
*
|
|
5
|
-
* One frame, one interaction grammar (`↑/↓ move · Enter confirm · esc back`),
|
|
6
|
-
* one palette — the four overlays should feel like the same control.
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { Box, Text } from "ink";
|
|
10
|
-
import type { AgentOption, PendingOp, SessionRow } from "../shared/types.js";
|
|
11
|
-
import { theme } from "../theme.js";
|
|
12
|
-
|
|
13
|
-
/** Shared frame so every overlay has identical chrome. */
|
|
14
|
-
const Panel = ({
|
|
15
|
-
title,
|
|
16
|
-
hint,
|
|
17
|
-
color = theme.color.accent,
|
|
18
|
-
children,
|
|
19
|
-
}: {
|
|
20
|
-
title: string;
|
|
21
|
-
hint?: string;
|
|
22
|
-
/** Optional: undefined means "no colour" when colour is disabled. */
|
|
23
|
-
color?: string;
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
}) => (
|
|
26
|
-
<Box
|
|
27
|
-
flexDirection="column"
|
|
28
|
-
borderStyle="round"
|
|
29
|
-
borderColor={color}
|
|
30
|
-
paddingX={1}
|
|
31
|
-
paddingY={0}
|
|
32
|
-
marginBottom={1}
|
|
33
|
-
>
|
|
34
|
-
<Text bold color={color}>
|
|
35
|
-
{title}
|
|
36
|
-
</Text>
|
|
37
|
-
{hint && <Text dimColor>{hint}</Text>}
|
|
38
|
-
<Box marginTop={1} flexDirection="column">
|
|
39
|
-
{children}
|
|
40
|
-
</Box>
|
|
41
|
-
</Box>
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
/** A selectable row: pointer, label, and a dimmed detail. */
|
|
45
|
-
const Row = ({
|
|
46
|
-
selected,
|
|
47
|
-
color,
|
|
48
|
-
label,
|
|
49
|
-
detail,
|
|
50
|
-
disabled,
|
|
51
|
-
}: {
|
|
52
|
-
selected: boolean;
|
|
53
|
-
color?: string;
|
|
54
|
-
label: string;
|
|
55
|
-
detail?: string;
|
|
56
|
-
disabled?: boolean;
|
|
57
|
-
}) => (
|
|
58
|
-
// One Text node, not a flex row of label + detail. As siblings, a narrow
|
|
59
|
-
// terminal wrapped them independently and the two columns interleaved
|
|
60
|
-
// ("Refactor the — date" / "authentication 3:30 pm").
|
|
61
|
-
<Text
|
|
62
|
-
color={selected ? color : theme.color.muted}
|
|
63
|
-
bold={selected}
|
|
64
|
-
dimColor={disabled}
|
|
65
|
-
wrap="truncate-end"
|
|
66
|
-
>
|
|
67
|
-
{selected ? `${theme.glyph.pointer} ` : " "}
|
|
68
|
-
{label}
|
|
69
|
-
{detail ? ` — ${detail}` : ""}
|
|
70
|
-
</Text>
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
/** Notice rendered in place of rows when a list is empty. */
|
|
74
|
-
const Empty = ({ children }: { children: React.ReactNode }) => (
|
|
75
|
-
<Text dimColor>{children}</Text>
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
/* ── /agent picker ── */
|
|
79
|
-
export const AgentPicker = ({
|
|
80
|
-
options,
|
|
81
|
-
selected,
|
|
82
|
-
busy,
|
|
83
|
-
}: {
|
|
84
|
-
options: AgentOption[];
|
|
85
|
-
selected: number;
|
|
86
|
-
busy?: boolean;
|
|
87
|
-
}) => (
|
|
88
|
-
<Panel title="Select an agent" hint="↑/↓ move · Enter switch · esc cancel">
|
|
89
|
-
{busy && options.length === 0 ? (
|
|
90
|
-
<Empty>Loading your agents…</Empty>
|
|
91
|
-
) : options.length === 0 ? (
|
|
92
|
-
<Empty>No agents available.</Empty>
|
|
93
|
-
) : (
|
|
94
|
-
options.map((opt, idx) => (
|
|
95
|
-
<Row
|
|
96
|
-
key={opt.id}
|
|
97
|
-
selected={idx === selected}
|
|
98
|
-
color={theme.color.accent}
|
|
99
|
-
label={opt.label}
|
|
100
|
-
detail={opt.description}
|
|
101
|
-
/>
|
|
102
|
-
))
|
|
103
|
-
)}
|
|
104
|
-
</Panel>
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
/* ── /sessions picker ── */
|
|
108
|
-
export const SessionPicker = ({
|
|
109
|
-
rows,
|
|
110
|
-
selected,
|
|
111
|
-
busy,
|
|
112
|
-
}: {
|
|
113
|
-
rows: SessionRow[];
|
|
114
|
-
selected: number;
|
|
115
|
-
busy?: boolean;
|
|
116
|
-
}) => (
|
|
117
|
-
<Panel title="Resume a session" hint="↑/↓ move · Enter resume · esc cancel" color={theme.color.info}>
|
|
118
|
-
{busy && rows.length === 0 ? (
|
|
119
|
-
<Empty>Loading your sessions…</Empty>
|
|
120
|
-
) : rows.length === 0 ? (
|
|
121
|
-
<Empty>No sessions yet.</Empty>
|
|
122
|
-
) : (
|
|
123
|
-
rows.map((s, idx) => {
|
|
124
|
-
const when = s.updated_at ? new Date(s.updated_at).toLocaleString() : "unknown time";
|
|
125
|
-
const who = s.agent_name || s.agent_id || "agent";
|
|
126
|
-
return (
|
|
127
|
-
<Box key={s.session_id} flexDirection="column">
|
|
128
|
-
<Row
|
|
129
|
-
selected={idx === selected}
|
|
130
|
-
color={theme.color.info}
|
|
131
|
-
label={s.title?.slice(0, 60) || s.session_id.slice(0, 8)}
|
|
132
|
-
detail={when}
|
|
133
|
-
/>
|
|
134
|
-
{idx === selected && (
|
|
135
|
-
<Text dimColor>
|
|
136
|
-
{" "}
|
|
137
|
-
{who}
|
|
138
|
-
{s.model ? ` · ${s.model}` : ""} · {s.session_id.slice(0, 12)}
|
|
139
|
-
</Text>
|
|
140
|
-
)}
|
|
141
|
-
</Box>
|
|
142
|
-
);
|
|
143
|
-
})
|
|
144
|
-
)}
|
|
145
|
-
</Panel>
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
/* ── Sign-in method picker ── */
|
|
149
|
-
export const AuthPicker = ({
|
|
150
|
-
options,
|
|
151
|
-
selected,
|
|
152
|
-
busy,
|
|
153
|
-
}: {
|
|
154
|
-
options: readonly { id: string; label: string; description: string }[];
|
|
155
|
-
selected: number;
|
|
156
|
-
busy?: boolean;
|
|
157
|
-
}) => (
|
|
158
|
-
<Panel title="Sign in to OdysX" hint="↑/↓ move · Enter select · esc cancel" color={theme.color.info}>
|
|
159
|
-
{options.map((opt, idx) => (
|
|
160
|
-
<Row
|
|
161
|
-
key={opt.id}
|
|
162
|
-
selected={idx === selected && !busy}
|
|
163
|
-
color={theme.color.info}
|
|
164
|
-
label={opt.label}
|
|
165
|
-
detail={opt.description}
|
|
166
|
-
/>
|
|
167
|
-
))}
|
|
168
|
-
</Panel>
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Folder trust prompt — shown once per unfamiliar workspace, before the REPL
|
|
173
|
-
* exposes any read/write/exec capability. Unlike the y/N op prompt, declining
|
|
174
|
-
* here exits: an untrusted folder means no session at all, not a session with
|
|
175
|
-
* capabilities turned off one by one after the fact.
|
|
176
|
-
*/
|
|
177
|
-
export const TrustPrompt = ({
|
|
178
|
-
folder,
|
|
179
|
-
selected,
|
|
180
|
-
mode,
|
|
181
|
-
}: {
|
|
182
|
-
folder: string;
|
|
183
|
-
selected: number;
|
|
184
|
-
mode: string;
|
|
185
|
-
}) => (
|
|
186
|
-
<Panel
|
|
187
|
-
title={`${theme.glyph.warn} Trust this folder?`}
|
|
188
|
-
color={theme.color.warning}
|
|
189
|
-
hint="↑/↓ or 1/2 to choose · Enter confirm · esc exit"
|
|
190
|
-
>
|
|
191
|
-
<Text wrap="truncate-end">{folder}</Text>
|
|
192
|
-
<Text dimColor>
|
|
193
|
-
Codemind can read, edit, and run commands here. Only trust folders you own.
|
|
194
|
-
</Text>
|
|
195
|
-
<Box marginTop={1} flexDirection="column">
|
|
196
|
-
<Row
|
|
197
|
-
selected={selected === 0}
|
|
198
|
-
color={theme.color.success}
|
|
199
|
-
label="1. Yes, I trust this folder"
|
|
200
|
-
/>
|
|
201
|
-
<Row
|
|
202
|
-
selected={selected === 1}
|
|
203
|
-
color={theme.color.error}
|
|
204
|
-
label="2. No, exit"
|
|
205
|
-
/>
|
|
206
|
-
</Box>
|
|
207
|
-
<Text dimColor>Permission mode after trusting: {mode} (/mode to change)</Text>
|
|
208
|
-
</Panel>
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
/* ── PermissionPrompt — y/N for risky local ops, with a diff preview ── */
|
|
212
|
-
export const PermissionPrompt = ({ op }: { op: PendingOp }) => (
|
|
213
|
-
<Panel title={`${theme.glyph.warn} Permission required`} color={theme.color.warning} hint="y = allow · n/esc = deny">
|
|
214
|
-
<Text>
|
|
215
|
-
OdysX wants to <Text bold>{op.kind}</Text>: {op.summary}
|
|
216
|
-
</Text>
|
|
217
|
-
{op.diff && (
|
|
218
|
-
<Box flexDirection="column" marginTop={1} paddingLeft={1}>
|
|
219
|
-
<Text bold>{op.diff.file}</Text>
|
|
220
|
-
{op.diff.before ? (
|
|
221
|
-
<Text color={theme.color.error}>- {preview(op.diff.before)}</Text>
|
|
222
|
-
) : (
|
|
223
|
-
<Text dimColor>(new file)</Text>
|
|
224
|
-
)}
|
|
225
|
-
<Text color={theme.color.success}>+ {preview(op.diff.after)}</Text>
|
|
226
|
-
</Box>
|
|
227
|
-
)}
|
|
228
|
-
</Panel>
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
const preview = (text: string): string => {
|
|
232
|
-
const single = text.replace(/\s*\n\s*/g, " ⏎ ");
|
|
233
|
-
return single.length > 160 ? single.slice(0, 159) + "…" : single;
|
|
234
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Searchable overlay used by Ctrl+/ (command palette) and Ctrl+R (history).
|
|
3
|
-
*
|
|
4
|
-
* Both modes share one interaction grammar and one frame; only the title,
|
|
5
|
-
* rows and empty hint differ. It renders above the input bar and outside
|
|
6
|
-
* <Static>, so results are redrawn on every keystroke.
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { Box, Text, useStdout } from "ink";
|
|
10
|
-
import { theme } from "../theme.js";
|
|
11
|
-
import { displayWidth, truncateToWidth } from "../utils/terminal-text.js";
|
|
12
|
-
|
|
13
|
-
export interface SearchRow {
|
|
14
|
-
key: string;
|
|
15
|
-
label: string;
|
|
16
|
-
detail?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const SearchOverlay = ({
|
|
20
|
-
title,
|
|
21
|
-
query,
|
|
22
|
-
rows,
|
|
23
|
-
selected,
|
|
24
|
-
hint,
|
|
25
|
-
}: {
|
|
26
|
-
title: string;
|
|
27
|
-
query: string;
|
|
28
|
-
rows: SearchRow[];
|
|
29
|
-
selected: number;
|
|
30
|
-
hint: string;
|
|
31
|
-
}) => {
|
|
32
|
-
const { stdout } = useStdout();
|
|
33
|
-
const width = Math.max(20, (stdout?.columns ?? 80) - 6);
|
|
34
|
-
// Bound the visible window so a long history can't push the input offscreen.
|
|
35
|
-
const limit = 10;
|
|
36
|
-
const start = Math.max(0, Math.min(selected - 4, Math.max(0, rows.length - limit)));
|
|
37
|
-
const visible = rows.slice(start, start + limit);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Box flexDirection="column" borderStyle="round" borderColor={theme.color.info} paddingX={1} marginBottom={1}>
|
|
41
|
-
<Text bold color={theme.color.info}>{title}</Text>
|
|
42
|
-
<Text color={theme.color.user}>
|
|
43
|
-
{theme.glyph.pointer} {query || "…"}
|
|
44
|
-
</Text>
|
|
45
|
-
{visible.map((row, i) => (
|
|
46
|
-
<Text
|
|
47
|
-
key={row.key}
|
|
48
|
-
color={start + i === selected ? theme.color.brand : theme.color.muted}
|
|
49
|
-
bold={start + i === selected}
|
|
50
|
-
wrap="truncate-end"
|
|
51
|
-
>
|
|
52
|
-
{start + i === selected ? "› " : " "}
|
|
53
|
-
{truncateToWidth(row.label, Math.max(8, Math.floor(width * 0.55)))}
|
|
54
|
-
{row.detail ? ` ${truncateToWidth(row.detail, Math.max(6, width - displayWidth(row.label) - 8))}` : ""}
|
|
55
|
-
</Text>
|
|
56
|
-
))}
|
|
57
|
-
{rows.length === 0 && <Text dimColor>No matches.</Text>}
|
|
58
|
-
{start > 0 && <Text dimColor> … {start} above</Text>}
|
|
59
|
-
{rows.length - start - visible.length > 0 && (
|
|
60
|
-
<Text dimColor> … {rows.length - start - visible.length} below</Text>
|
|
61
|
-
)}
|
|
62
|
-
<Text dimColor>{hint}</Text>
|
|
63
|
-
</Box>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Live spinner while the agent streams — frame, elapsed time, and what Enter
|
|
3
|
-
* will do (queue) vs Esc (interrupt).
|
|
4
|
-
*/
|
|
5
|
-
import React, { useState, useEffect } from "react";
|
|
6
|
-
import { Box, Text } from "ink";
|
|
7
|
-
import { theme } from "../theme.js";
|
|
8
|
-
|
|
9
|
-
const SPINNER_FRAMES = ["✶", "✻", "✽", "✺", "❋", "✹"];
|
|
10
|
-
|
|
11
|
-
const formatElapsed = (seconds: number): string => {
|
|
12
|
-
if (seconds < 60) return `${seconds}s`;
|
|
13
|
-
return `${Math.floor(seconds / 60)}m ${seconds % 60}s`;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const WorkingIndicator = ({ elapsed, agent }: { elapsed: number; agent?: string }) => {
|
|
17
|
-
const [frame, setFrame] = useState(0);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const iv = setInterval(() => setFrame((f) => (f + 1) % SPINNER_FRAMES.length), 90);
|
|
21
|
-
return () => clearInterval(iv);
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Box marginBottom={1} paddingLeft={1} columnGap={1}>
|
|
26
|
-
<Text color={theme.color.accent}>{SPINNER_FRAMES[frame]}</Text>
|
|
27
|
-
<Text color={theme.color.muted} wrap="truncate-end">
|
|
28
|
-
{agent ? `${agent} is thinking` : "Thinking"} · {formatElapsed(elapsed)}
|
|
29
|
-
</Text>
|
|
30
|
-
{/* Truncated rather than wrapped: this row sits above the input, so a
|
|
31
|
-
wrapped hint would push the prompt down on narrow terminals. */}
|
|
32
|
-
<Text dimColor wrap="truncate-end">esc to interrupt · enter to queue</Text>
|
|
33
|
-
</Box>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Masked "paste your API key" entry box (auth flow, api-key mode).
|
|
3
|
-
*/
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { Box, Text } from "ink";
|
|
6
|
-
import { theme } from "../theme.js";
|
|
7
|
-
|
|
8
|
-
export const ApiKeyEntry = ({ draft }: { draft: string }) => (
|
|
9
|
-
<Box
|
|
10
|
-
flexDirection="column"
|
|
11
|
-
borderStyle="round"
|
|
12
|
-
borderColor={theme.color.info}
|
|
13
|
-
paddingX={1}
|
|
14
|
-
marginBottom={1}
|
|
15
|
-
>
|
|
16
|
-
<Text bold color={theme.color.info}>
|
|
17
|
-
Paste your OdysX API key
|
|
18
|
-
</Text>
|
|
19
|
-
<Text dimColor>Enter to save · esc to cancel · input is masked</Text>
|
|
20
|
-
<Box marginTop={1}>
|
|
21
|
-
<Text color={theme.color.info} bold>
|
|
22
|
-
{theme.glyph.pointer}
|
|
23
|
-
{" "}
|
|
24
|
-
{"•".repeat(draft.length)}
|
|
25
|
-
<Text dimColor>_</Text>
|
|
26
|
-
</Text>
|
|
27
|
-
</Box>
|
|
28
|
-
</Box>
|
|
29
|
-
);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MultiSelect — checkbox list for picking multiple options.
|
|
3
|
-
* space toggles a row · enter confirms · esc cancels (via parent).
|
|
4
|
-
*/
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { Box, Text } from "ink";
|
|
7
|
-
import { theme } from "../theme.js";
|
|
8
|
-
|
|
9
|
-
export interface MultiSelectProps {
|
|
10
|
-
title: string;
|
|
11
|
-
options: Array<{ id: string; label: string; description?: string }>;
|
|
12
|
-
selectedIds: ReadonlySet<string>;
|
|
13
|
-
cursorIndex: number;
|
|
14
|
-
busy?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const MultiSelect = ({
|
|
18
|
-
title,
|
|
19
|
-
options,
|
|
20
|
-
selectedIds,
|
|
21
|
-
cursorIndex,
|
|
22
|
-
busy,
|
|
23
|
-
}: MultiSelectProps) => (
|
|
24
|
-
<Box
|
|
25
|
-
flexDirection="column"
|
|
26
|
-
borderStyle="round"
|
|
27
|
-
borderColor={theme.color.accent}
|
|
28
|
-
paddingX={1}
|
|
29
|
-
marginBottom={1}
|
|
30
|
-
>
|
|
31
|
-
<Text bold color={theme.color.accent}>
|
|
32
|
-
{title}
|
|
33
|
-
</Text>
|
|
34
|
-
<Text dimColor>↑/↓ to move · space to toggle · enter to confirm · esc to cancel</Text>
|
|
35
|
-
|
|
36
|
-
<Box marginTop={1} flexDirection="column">
|
|
37
|
-
{busy ? (
|
|
38
|
-
<Text dimColor>Loading…</Text>
|
|
39
|
-
) : (
|
|
40
|
-
options.map((opt, idx) => {
|
|
41
|
-
const isCursor = idx === cursorIndex;
|
|
42
|
-
const checked = selectedIds.has(opt.id);
|
|
43
|
-
return (
|
|
44
|
-
<Box key={opt.id}>
|
|
45
|
-
<Text color={isCursor ? theme.color.accent : theme.color.muted} bold={isCursor}>
|
|
46
|
-
{isCursor ? `${theme.glyph.pointer} ` : " "}[{checked ? theme.glyph.check : " "}] {opt.label}
|
|
47
|
-
{opt.description && <Text dimColor> — {opt.description}</Text>}
|
|
48
|
-
</Text>
|
|
49
|
-
</Box>
|
|
50
|
-
);
|
|
51
|
-
})
|
|
52
|
-
)}
|
|
53
|
-
</Box>
|
|
54
|
-
</Box>
|
|
55
|
-
);
|