micro-models-agent 0.2.35 → 0.2.37
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/agent/context.d.ts.map +1 -1
- package/dist/agent/context.js +3 -5
- package/dist/agent/context.js.map +1 -1
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +84 -5
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +141 -131
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +23 -1
- package/dist/cli/config.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/repl/commands.d.ts.map +1 -1
- package/dist/repl/commands.js +148 -45
- package/dist/repl/commands.js.map +1 -1
- package/dist/skills/builtin/cli-expert/SKILL.md +848 -0
- package/dist/skills/builtin/code-review/SKILL.md +424 -0
- package/dist/skills/builtin/git-expert/SKILL.md +522 -0
- package/dist/skills/builtin/jest-testing-expert/SKILL.md +957 -0
- package/dist/skills/builtin/nodejs-expert/SKILL.md +192 -0
- package/dist/skills/builtin/systematic-debugging/SKILL.md +296 -0
- package/dist/skills/builtin/test-driven-development/SKILL.md +371 -0
- package/dist/skills/builtin/typescript-expert/SKILL.md +429 -0
- package/dist/skills/loader.d.ts +7 -1
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +39 -21
- package/dist/skills/loader.js.map +1 -1
- package/dist/styling/index.d.ts +4 -1
- package/dist/styling/index.d.ts.map +1 -1
- package/dist/styling/index.js +12 -2
- package/dist/styling/index.js.map +1 -1
- package/dist/styling/loader.d.ts +5 -0
- package/dist/styling/loader.d.ts.map +1 -1
- package/dist/styling/loader.js +31 -5
- package/dist/styling/loader.js.map +1 -1
- package/dist/ui/components/status-bar.d.ts.map +1 -1
- package/dist/ui/components/status-bar.js +4 -6
- package/dist/ui/components/status-bar.js.map +1 -1
- package/dist/ui/index.d.ts +4 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +11 -1
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/ink/components/App.d.ts +62 -0
- package/dist/ui/ink/components/App.d.ts.map +1 -0
- package/dist/ui/ink/components/App.js +136 -0
- package/dist/ui/ink/components/App.js.map +1 -0
- package/dist/ui/ink/components/Conversation.d.ts +20 -0
- package/dist/ui/ink/components/Conversation.d.ts.map +1 -0
- package/dist/ui/ink/components/Conversation.js +15 -0
- package/dist/ui/ink/components/Conversation.js.map +1 -0
- package/dist/ui/ink/components/MessageBlock.d.ts +15 -0
- package/dist/ui/ink/components/MessageBlock.d.ts.map +1 -0
- package/dist/ui/ink/components/MessageBlock.js +45 -0
- package/dist/ui/ink/components/MessageBlock.js.map +1 -0
- package/dist/ui/ink/components/PromptInput.d.ts +12 -0
- package/dist/ui/ink/components/PromptInput.d.ts.map +1 -0
- package/dist/ui/ink/components/PromptInput.js +129 -0
- package/dist/ui/ink/components/PromptInput.js.map +1 -0
- package/dist/ui/ink/components/StatusBar.d.ts +14 -0
- package/dist/ui/ink/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/ink/components/StatusBar.js +20 -0
- package/dist/ui/ink/components/StatusBar.js.map +1 -0
- package/dist/ui/ink/components/StreamBlock.d.ts +8 -0
- package/dist/ui/ink/components/StreamBlock.d.ts.map +1 -0
- package/dist/ui/ink/components/StreamBlock.js +15 -0
- package/dist/ui/ink/components/StreamBlock.js.map +1 -0
- package/dist/ui/ink/components/Tags.d.ts +26 -0
- package/dist/ui/ink/components/Tags.d.ts.map +1 -0
- package/dist/ui/ink/components/Tags.js +37 -0
- package/dist/ui/ink/components/Tags.js.map +1 -0
- package/dist/ui/ink/components/ToolCallBlock.d.ts +11 -0
- package/dist/ui/ink/components/ToolCallBlock.d.ts.map +1 -0
- package/dist/ui/ink/components/ToolCallBlock.js +8 -0
- package/dist/ui/ink/components/ToolCallBlock.js.map +1 -0
- package/dist/ui/ink/renderer.d.ts +42 -0
- package/dist/ui/ink/renderer.d.ts.map +1 -0
- package/dist/ui/ink/renderer.js +110 -0
- package/dist/ui/ink/renderer.js.map +1 -0
- package/dist/ui/ink/theme.d.ts +20 -0
- package/dist/ui/ink/theme.d.ts.map +1 -0
- package/dist/ui/ink/theme.js +45 -0
- package/dist/ui/ink/theme.js.map +1 -0
- package/package.json +9 -4
package/dist/styling/loader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, existsSync, mkdirSync } from 'node:fs';
|
|
1
|
+
import { readFileSync, existsSync, mkdirSync, writeFileSync, readdirSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { ThemeEngine } from './engine.js';
|
|
@@ -64,11 +64,37 @@ function mergeTheme(base, overrides) {
|
|
|
64
64
|
format: { ...base.format, ...overrides.format },
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
export function loadThemeConfig(name) {
|
|
68
|
+
const builtIn = BUILT_IN_THEMES[name || 'light'] || BUILT_IN_THEMES.light;
|
|
69
|
+
const custom = loadJsonTheme(name || 'light');
|
|
70
|
+
return custom ? mergeTheme(builtIn, custom) : builtIn;
|
|
71
|
+
}
|
|
67
72
|
export function loadTheme(name = 'light') {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
return new ThemeEngine(loadThemeConfig(name));
|
|
74
|
+
}
|
|
75
|
+
export function listThemes() {
|
|
76
|
+
const builtIn = Object.keys(BUILT_IN_THEMES);
|
|
77
|
+
let custom = [];
|
|
78
|
+
try {
|
|
79
|
+
custom = readdirSync(THEMES_DIR)
|
|
80
|
+
.filter(f => f.endsWith('.json'))
|
|
81
|
+
.map(f => f.replace('.json', ''));
|
|
82
|
+
}
|
|
83
|
+
catch { /* no custom themes dir */ }
|
|
84
|
+
return [...builtIn, ...custom];
|
|
85
|
+
}
|
|
86
|
+
export function installTheme(name, content) {
|
|
87
|
+
ensureThemeDir();
|
|
88
|
+
const filePath = join(THEMES_DIR, `${name}.json`);
|
|
89
|
+
writeFileSync(filePath, content, 'utf-8');
|
|
90
|
+
return filePath;
|
|
91
|
+
}
|
|
92
|
+
export function removeTheme(name) {
|
|
93
|
+
const filePath = join(THEMES_DIR, `${name}.json`);
|
|
94
|
+
if (!existsSync(filePath))
|
|
95
|
+
return false;
|
|
96
|
+
unlinkSync(filePath);
|
|
97
|
+
return true;
|
|
72
98
|
}
|
|
73
99
|
export function ensureThemeDir() {
|
|
74
100
|
if (!existsSync(THEMES_DIR)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/styling/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/styling/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACtG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,OAAO,GAAG,IAAI,C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E,CAAC;IACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;IAClD,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;IAClD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACxC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../../src/ui/components/status-bar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../../../src/ui/components/status-bar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAUzD"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
export function formatStatusLine(info) {
|
|
2
2
|
const parts = [];
|
|
3
|
-
if (info.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (info.tokens !== undefined && info.contextWindow !== undefined) {
|
|
7
|
-
parts.push(`${info.tokens}/${info.contextWindow}`);
|
|
3
|
+
if (info.model) {
|
|
4
|
+
const short = info.model.split('/').pop() || info.model;
|
|
5
|
+
parts.push(short);
|
|
8
6
|
}
|
|
9
7
|
if (info.step !== undefined && info.maxSteps !== undefined) {
|
|
10
8
|
parts.push(`step ${info.step}/${info.maxSteps}`);
|
|
11
9
|
}
|
|
12
|
-
return parts.join(' │ ') || 'MMA
|
|
10
|
+
return parts.join(' │ ') || 'MMA';
|
|
13
11
|
}
|
|
14
12
|
//# sourceMappingURL=status-bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/ui/components/status-bar.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../../../src/ui/components/status-bar.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,IAAgB;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,KAAK,CAAA;QACvD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnB,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAClD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,CAAA;AACnC,CAAC"}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { OutputRenderer } from './renderer.js';
|
|
2
|
-
export type { OutputRenderer, StatusInfo } from './renderer.js';
|
|
3
2
|
export interface SlashCommandInfo {
|
|
4
3
|
name: string;
|
|
5
4
|
description: string;
|
|
6
5
|
}
|
|
7
|
-
export
|
|
6
|
+
export type { OutputRenderer, StatusInfo } from './renderer.js';
|
|
7
|
+
export declare function createRenderer(commands?: SlashCommandInfo[], options?: {
|
|
8
|
+
mode?: 'readline' | 'ink';
|
|
9
|
+
}): Promise<OutputRenderer>;
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ui/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAA;AAE/D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAA;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/D,wBAAsB,cAAc,CAClC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,EAC7B,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,UAAU,GAAG,KAAK,CAAA;CAAE,GACtC,OAAO,CAAC,cAAc,CAAC,CAiBzB"}
|
package/dist/ui/index.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
export async function createRenderer(commands) {
|
|
1
|
+
export async function createRenderer(commands, options) {
|
|
2
|
+
const mode = options?.mode ||
|
|
3
|
+
(process.env.INK_MODE === '1' ? 'ink' : 'readline');
|
|
4
|
+
if (mode === 'ink') {
|
|
5
|
+
const { InkRenderer } = await import('./ink/renderer.js');
|
|
6
|
+
const r = new InkRenderer();
|
|
7
|
+
if (commands)
|
|
8
|
+
r.setCommands(commands);
|
|
9
|
+
await r.start();
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
2
12
|
const { ReadlineRenderer } = await import('./readline-renderer.js');
|
|
3
13
|
const r = new ReadlineRenderer();
|
|
4
14
|
if (commands)
|
package/dist/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAA6B,EAC7B,OAAuC;IAEvC,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI;QACxB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IAEtD,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAC1D,MAAM,CAAC,GAAG,IAAI,WAAW,EAAE,CAAC;QAC5B,IAAI,QAAQ;YAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACjC,IAAI,QAAQ;QAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface StatusInfo {
|
|
3
|
+
provider?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
tokens?: number;
|
|
6
|
+
contextWindow?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
maxSteps?: number;
|
|
9
|
+
}
|
|
10
|
+
export type Action = {
|
|
11
|
+
type: 'ADD_MESSAGE';
|
|
12
|
+
kind: 'message';
|
|
13
|
+
data: any;
|
|
14
|
+
} | {
|
|
15
|
+
type: 'ADD_TOOL_CALL';
|
|
16
|
+
data: any;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'TOOL_PREVIEW';
|
|
19
|
+
data: any;
|
|
20
|
+
} | {
|
|
21
|
+
type: 'TOOL_END';
|
|
22
|
+
data: any;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'STREAM_CHUNK';
|
|
25
|
+
chunk: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: 'STREAM_REASONING';
|
|
28
|
+
text: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'STREAM_END';
|
|
31
|
+
} | {
|
|
32
|
+
type: 'SPINNER';
|
|
33
|
+
show: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
type: 'STATUS';
|
|
36
|
+
info: StatusInfo;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'CONTEXT';
|
|
39
|
+
text: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: 'SHOW_PROMPT';
|
|
42
|
+
message: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'HIDE_PROMPT';
|
|
45
|
+
} | {
|
|
46
|
+
type: 'CLEAR';
|
|
47
|
+
};
|
|
48
|
+
export interface AppHandle {
|
|
49
|
+
dispatch(action: Action): void;
|
|
50
|
+
setPromptResolve(fn: ((value: string) => void) | null): void;
|
|
51
|
+
getPromptResolve(): ((value: string) => void) | null;
|
|
52
|
+
}
|
|
53
|
+
interface AppProps {
|
|
54
|
+
onReady: (handle: AppHandle) => void;
|
|
55
|
+
commands?: {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
}[];
|
|
59
|
+
}
|
|
60
|
+
export declare function App({ onReady, commands }: AppProps): React.JSX.Element;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=App.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../src/ui/ink/components/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgC,MAAM,OAAO,CAAC;AAMrD,UAAU,UAAU;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAgBD,MAAM,MAAM,MAAM,GACd;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAClC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AA4GtB,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAC7D,gBAAgB,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CACtD;AAED,UAAU,QAAQ;IAChB,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD;AAED,wBAAgB,GAAG,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,qBAwClD"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useReducer, useEffect } from 'react';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
import { Conversation } from './Conversation.js';
|
|
5
|
+
import { StatusBar } from './StatusBar.js';
|
|
6
|
+
import { PromptInput } from './PromptInput.js';
|
|
7
|
+
function reducer(state, action) {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case 'ADD_MESSAGE': {
|
|
10
|
+
const data = { ...action.data };
|
|
11
|
+
if (data.tag === 'user')
|
|
12
|
+
data.role = 'user';
|
|
13
|
+
return {
|
|
14
|
+
...state,
|
|
15
|
+
nextId: state.nextId + 1,
|
|
16
|
+
entries: [...state.entries, { id: state.nextId, kind: 'message', data }],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
case 'ADD_TOOL_CALL':
|
|
20
|
+
return {
|
|
21
|
+
...state,
|
|
22
|
+
nextId: state.nextId + 1,
|
|
23
|
+
toolCallIndex: state.entries.length,
|
|
24
|
+
entries: [...state.entries, { id: state.nextId, kind: 'tool_call', data: { name: action.data.name, args: action.data.args || '', result: '', time: '' } }],
|
|
25
|
+
};
|
|
26
|
+
case 'TOOL_PREVIEW': {
|
|
27
|
+
const idx = state.toolCallIndex;
|
|
28
|
+
if (idx < 0 || idx >= state.entries.length)
|
|
29
|
+
return state;
|
|
30
|
+
const entry = state.entries[idx];
|
|
31
|
+
if (entry.kind !== 'tool_call')
|
|
32
|
+
return state;
|
|
33
|
+
const updated = { ...entry, data: { ...entry.data, args: action.data.args || entry.data.args } };
|
|
34
|
+
const entries = [...state.entries];
|
|
35
|
+
entries[idx] = updated;
|
|
36
|
+
return { ...state, entries };
|
|
37
|
+
}
|
|
38
|
+
case 'TOOL_END': {
|
|
39
|
+
const idx = state.toolCallIndex;
|
|
40
|
+
if (idx < 0 || idx >= state.entries.length)
|
|
41
|
+
return state;
|
|
42
|
+
const entry = state.entries[idx];
|
|
43
|
+
if (entry.kind !== 'tool_call')
|
|
44
|
+
return state;
|
|
45
|
+
const updated = {
|
|
46
|
+
...entry,
|
|
47
|
+
data: {
|
|
48
|
+
...entry.data,
|
|
49
|
+
result: action.data.result || '',
|
|
50
|
+
time: action.data.time || '',
|
|
51
|
+
exitCode: action.data.exitCode,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const entries = [...state.entries];
|
|
55
|
+
entries[idx] = updated;
|
|
56
|
+
return { ...state, entries };
|
|
57
|
+
}
|
|
58
|
+
case 'STREAM_CHUNK':
|
|
59
|
+
return { ...state, streaming: true, streamingContent: state.streamingContent + action.chunk };
|
|
60
|
+
case 'STREAM_REASONING':
|
|
61
|
+
return { ...state, streaming: true, streamingContent: action.text, isReasoning: true };
|
|
62
|
+
case 'STREAM_END': {
|
|
63
|
+
const content = state.streamingContent;
|
|
64
|
+
if (!content)
|
|
65
|
+
return { ...state, streaming: false, streamingContent: '', isReasoning: false };
|
|
66
|
+
const newEntry = { id: state.nextId, kind: 'message', data: { type: 'message', content, role: 'assistant' } };
|
|
67
|
+
return {
|
|
68
|
+
...state,
|
|
69
|
+
nextId: state.nextId + 1,
|
|
70
|
+
entries: [...state.entries, newEntry],
|
|
71
|
+
streaming: false,
|
|
72
|
+
streamingContent: '',
|
|
73
|
+
isReasoning: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
case 'SPINNER':
|
|
77
|
+
return { ...state, showSpinner: action.show };
|
|
78
|
+
case 'STATUS':
|
|
79
|
+
return { ...state, status: { ...state.status, ...action.info } };
|
|
80
|
+
case 'CONTEXT':
|
|
81
|
+
return { ...state, contextUsage: action.text };
|
|
82
|
+
case 'SHOW_PROMPT':
|
|
83
|
+
return { ...state, showPrompt: true, promptMessage: action.message };
|
|
84
|
+
case 'HIDE_PROMPT':
|
|
85
|
+
return { ...state, showPrompt: false, promptMessage: '' };
|
|
86
|
+
case 'CLEAR':
|
|
87
|
+
return {
|
|
88
|
+
entries: [],
|
|
89
|
+
nextId: 1,
|
|
90
|
+
streaming: false,
|
|
91
|
+
streamingContent: '',
|
|
92
|
+
isReasoning: false,
|
|
93
|
+
showSpinner: false,
|
|
94
|
+
status: {},
|
|
95
|
+
contextUsage: '',
|
|
96
|
+
showPrompt: false,
|
|
97
|
+
promptMessage: '',
|
|
98
|
+
toolCallIndex: -1,
|
|
99
|
+
};
|
|
100
|
+
default:
|
|
101
|
+
return state;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const initialState = {
|
|
105
|
+
entries: [],
|
|
106
|
+
nextId: 1,
|
|
107
|
+
streaming: false,
|
|
108
|
+
streamingContent: '',
|
|
109
|
+
isReasoning: false,
|
|
110
|
+
showSpinner: false,
|
|
111
|
+
status: {},
|
|
112
|
+
contextUsage: '',
|
|
113
|
+
showPrompt: false,
|
|
114
|
+
promptMessage: '',
|
|
115
|
+
toolCallIndex: -1,
|
|
116
|
+
};
|
|
117
|
+
export function App({ onReady, commands }) {
|
|
118
|
+
const [state, dispatch] = useReducer(reducer, initialState);
|
|
119
|
+
const promptResolveRef = React.useRef(null);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
onReady({
|
|
122
|
+
dispatch,
|
|
123
|
+
setPromptResolve(fn) { promptResolveRef.current = fn; },
|
|
124
|
+
getPromptResolve() { return promptResolveRef.current; },
|
|
125
|
+
});
|
|
126
|
+
}, []);
|
|
127
|
+
return (_jsxs(Box, { flexDirection: "column", height: "100%", children: [_jsx(Conversation, { entries: state.entries, streaming: state.streaming, streamingContent: state.streamingContent, isReasoning: state.isReasoning, showSpinner: state.showSpinner }), _jsx(Box, { flexShrink: 0, marginTop: 1, children: _jsx(PromptInput, { commands: commands, disabled: !state.showPrompt, onSubmit: (value) => {
|
|
128
|
+
const resolve = promptResolveRef.current;
|
|
129
|
+
if (resolve) {
|
|
130
|
+
promptResolveRef.current = null;
|
|
131
|
+
resolve(value);
|
|
132
|
+
}
|
|
133
|
+
dispatch({ type: 'HIDE_PROMPT' });
|
|
134
|
+
} }) }), _jsx(Box, { flexShrink: 0, children: _jsx(StatusBar, { info: state.status, usage: state.contextUsage }) })] }));
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=App.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.js","sourceRoot":"","sources":["../../../../src/ui/ink/components/App.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS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AAU,EAAE,CAAC,YAChB,KAAC,SAAS,IAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,GAAI,GACxD,IACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type MessageItem } from './MessageBlock.js';
|
|
3
|
+
import { type ToolCallData } from './ToolCallBlock.js';
|
|
4
|
+
export type ConversationEntry = {
|
|
5
|
+
id: number;
|
|
6
|
+
kind: 'message';
|
|
7
|
+
data: MessageItem;
|
|
8
|
+
} | {
|
|
9
|
+
id: number;
|
|
10
|
+
kind: 'tool_call';
|
|
11
|
+
data: ToolCallData;
|
|
12
|
+
};
|
|
13
|
+
export declare function Conversation({ entries, streaming, streamingContent, isReasoning, showSpinner, }: {
|
|
14
|
+
entries: ConversationEntry[];
|
|
15
|
+
streaming: boolean;
|
|
16
|
+
streamingContent: string;
|
|
17
|
+
isReasoning: boolean;
|
|
18
|
+
showSpinner: boolean;
|
|
19
|
+
}): React.JSX.Element;
|
|
20
|
+
//# sourceMappingURL=Conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversation.d.ts","sourceRoot":"","sources":["../../../../src/ui/ink/components/Conversation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE,MAAM,MAAM,iBAAiB,GACzB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAClD;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAE1D,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,WAAW,GACZ,EAAE;IACD,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,qBAeA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
import { MessageBlock } from './MessageBlock.js';
|
|
5
|
+
import { ToolCallBlock } from './ToolCallBlock.js';
|
|
6
|
+
import { StreamBlock, SpinnerLine } from './StreamBlock.js';
|
|
7
|
+
export function Conversation({ entries, streaming, streamingContent, isReasoning, showSpinner, }) {
|
|
8
|
+
return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Box, { flexDirection: "column", children: entries.map((entry) => {
|
|
9
|
+
if (entry.kind === 'message') {
|
|
10
|
+
return React.createElement(MessageBlock, { key: entry.id, item: entry.data });
|
|
11
|
+
}
|
|
12
|
+
return React.createElement(ToolCallBlock, { key: entry.id, data: entry.data });
|
|
13
|
+
}) }), showSpinner && !streaming && _jsx(SpinnerLine, {}), streaming && _jsx(StreamBlock, { content: streamingContent, isReasoning: isReasoning })] }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Conversation.js","sourceRoot":"","sources":["../../../../src/ui/ink/components/Conversation.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM5D,MAAM,UAAU,YAAY,CAAC,EAC3B,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,WAAW,GAOZ;IACC,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,aACrC,KAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,YACxB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAwB,EAAE,EAAE;oBACxC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;wBAC7B,OAAO,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAmB,EAAE,CAAC,CAAC;oBAC/F,CAAC;oBACD,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAoB,EAAE,CAAC,CAAC;gBACjG,CAAC,CAAC,GACE,EACL,WAAW,IAAI,CAAC,SAAS,IAAI,KAAC,WAAW,KAAG,EAC5C,SAAS,IAAI,KAAC,WAAW,IAAC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,GAAI,IAC9E,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface MessageItem {
|
|
2
|
+
type: 'message' | 'info' | 'success' | 'warning' | 'error' | 'dim' | 'heading' | 'bracket';
|
|
3
|
+
content?: string;
|
|
4
|
+
tag?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
role?: 'user' | 'assistant';
|
|
7
|
+
}
|
|
8
|
+
export declare function MessageBlock({ item }: {
|
|
9
|
+
item: MessageItem;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export declare function FileOutputBlock({ lines, startIndex }: {
|
|
12
|
+
lines: string[];
|
|
13
|
+
startIndex: number;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=MessageBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBlock.d.ts","sourceRoot":"","sources":["../../../../src/ui/ink/components/MessageBlock.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAC7B;AAWD,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,+BA0D3D;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,+BAa7F"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import Markdown from 'ink-markdown-es';
|
|
4
|
+
import { getInkTheme } from '../theme.js';
|
|
5
|
+
import { LineNumbers, BracketTag } from './Tags.js';
|
|
6
|
+
const TYPE_COLORS = {
|
|
7
|
+
info: 'info',
|
|
8
|
+
success: 'success',
|
|
9
|
+
warning: 'warning',
|
|
10
|
+
error: 'error',
|
|
11
|
+
dim: 'dim',
|
|
12
|
+
heading: 'heading',
|
|
13
|
+
};
|
|
14
|
+
export function MessageBlock({ item }) {
|
|
15
|
+
const t = getInkTheme();
|
|
16
|
+
if (item.role === 'assistant') {
|
|
17
|
+
return (_jsxs(Box, { children: [_jsx(Text, { children: ' ' }), _jsx(Box, { flexGrow: 1, flexDirection: "column", children: _jsxs(Box, { children: [_jsx(Text, { bold: true, color: "cyan", children: '◆ ' }), _jsx(Markdown, { styles: {
|
|
18
|
+
paragraph: { margin: 0 },
|
|
19
|
+
listItem: { paddingLeft: 2, margin: 0 },
|
|
20
|
+
code: { marginTop: 0, marginBottom: 0 },
|
|
21
|
+
h1: { marginBottom: 0 },
|
|
22
|
+
h2: { marginBottom: 0 },
|
|
23
|
+
h3: { marginBottom: 0 },
|
|
24
|
+
}, children: item.content ?? '' })] }) })] }));
|
|
25
|
+
}
|
|
26
|
+
if (item.role === 'user') {
|
|
27
|
+
return (_jsxs(Box, { children: [_jsx(Text, { children: ' ' }), _jsx(Text, { bold: true, color: "yellow", children: '▶' }), _jsx(Text, { children: ' ' }), _jsx(Text, { bold: true, children: item.content })] }));
|
|
28
|
+
}
|
|
29
|
+
if (item.type === 'message') {
|
|
30
|
+
return (_jsx(Box, { children: _jsx(Text, { children: item.content }) }));
|
|
31
|
+
}
|
|
32
|
+
if (item.type === 'bracket') {
|
|
33
|
+
return _jsx(BracketTag, { tag: item.tag || '', message: item.message || '' });
|
|
34
|
+
}
|
|
35
|
+
const colorKey = TYPE_COLORS[item.type];
|
|
36
|
+
const style = colorKey ? t.colors[colorKey] : {};
|
|
37
|
+
return (_jsx(Box, { children: _jsx(Text, { ...style, children: item.content }) }));
|
|
38
|
+
}
|
|
39
|
+
export function FileOutputBlock({ lines, startIndex }) {
|
|
40
|
+
return (_jsx(Box, { flexDirection: "column", children: lines.map((line, i) => {
|
|
41
|
+
const lineNum = (startIndex + i).toString().padStart(4);
|
|
42
|
+
return (_jsxs(Box, { children: [_jsx(LineNumbers, { text: lineNum }), _jsxs(Text, { children: ["| ", line] })] }, i));
|
|
43
|
+
}) }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=MessageBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageBlock.js","sourceRoot":"","sources":["../../../../src/ui/ink/components/MessageBlock.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAW,MAAM,WAAW,CAAC;AAU7D,MAAM,WAAW,GAAmE;IAClF,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,EAAE,IAAI,EAAyB;IAC1D,MAAM,CAAC,GAAG,WAAW,EAAE,CAAC;IAExB,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC9B,OAAO,CACL,MAAC,GAAG,eACF,KAAC,IAAI,cAAE,IAAI,GAAQ,EACnB,KAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,YACtC,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAC,MAAM,YAAE,IAAI,GAAQ,EACrC,KAAC,QAAQ,IACP,MAAM,EAAE;oCACN,SAAS,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;oCACxB,QAAQ,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;oCACvC,IAAI,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE;oCACvC,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE;oCACvB,EAAE,EAAE,EAAE,YAAY,EAAE,C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AAC,QAAQ,YACxB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACrB,MAAM,OAAO,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACxD,OAAO,CACL,MAAC,GAAG,eACF,KAAC,WAAW,IAAC,IAAI,EAAE,OAAO,GAAI,EAAA,MAAC,IAAI,qBAAI,IAAI,IAAQ,KAD3C,CAAC,CAEL,CACP,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface CommandInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function PromptInput({ commands, onSubmit, disabled, }: {
|
|
7
|
+
commands?: CommandInfo[];
|
|
8
|
+
onSubmit: (value: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=PromptInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptInput.d.ts","sourceRoot":"","sources":["../../../../src/ui/ink/components/PromptInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAInD,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,qBAsJA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { Box, Text, useInput } from 'ink';
|
|
4
|
+
import { getInkTheme } from '../theme.js';
|
|
5
|
+
const HINTS = [
|
|
6
|
+
'Ctrl+C to exit',
|
|
7
|
+
'/help for commands',
|
|
8
|
+
'Tab for completion',
|
|
9
|
+
'↑/↓ for history',
|
|
10
|
+
'Shift+Enter for newline',
|
|
11
|
+
'Ask me anything',
|
|
12
|
+
];
|
|
13
|
+
export function PromptInput({ commands, onSubmit, disabled, }) {
|
|
14
|
+
const [value, setValue] = useState('');
|
|
15
|
+
const [cursor, setCursor] = useState(0);
|
|
16
|
+
const [history, setHistory] = useState([]);
|
|
17
|
+
const [historyIdx, setHistoryIdx] = useState(-1);
|
|
18
|
+
const [suggestions, setSuggestions] = useState([]);
|
|
19
|
+
const [suggestIdx, setSuggestIdx] = useState(0);
|
|
20
|
+
const [hintIdx, setHintIdx] = useState(0);
|
|
21
|
+
const t = getInkTheme();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!disabled)
|
|
24
|
+
return;
|
|
25
|
+
const id = setInterval(() => setHintIdx((i) => (i + 1) % HINTS.length), 4000);
|
|
26
|
+
return () => clearInterval(id);
|
|
27
|
+
}, [disabled]);
|
|
28
|
+
useInput((input, key) => {
|
|
29
|
+
if (disabled)
|
|
30
|
+
return;
|
|
31
|
+
if (key.return && !key.shift) {
|
|
32
|
+
const trimmed = value.trim();
|
|
33
|
+
if (trimmed) {
|
|
34
|
+
onSubmit(trimmed);
|
|
35
|
+
setHistory((h) => [trimmed, ...h].slice(0, 50));
|
|
36
|
+
}
|
|
37
|
+
setValue('');
|
|
38
|
+
setCursor(0);
|
|
39
|
+
setHistoryIdx(-1);
|
|
40
|
+
setSuggestions([]);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (key.return && key.shift) {
|
|
44
|
+
setValue((v) => v.slice(0, cursor) + '\n' + v.slice(cursor));
|
|
45
|
+
setCursor((c) => c + 1);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (key.tab) {
|
|
49
|
+
const line = value.slice(0, cursor);
|
|
50
|
+
const match = line.match(/^\/(\w*)$/);
|
|
51
|
+
if (match && commands) {
|
|
52
|
+
const partial = match[1].toLowerCase();
|
|
53
|
+
const matches = commands.filter((c) => c.name.startsWith(partial));
|
|
54
|
+
if (matches.length > 0) {
|
|
55
|
+
if (suggestions.length === 0) {
|
|
56
|
+
setSuggestions(matches);
|
|
57
|
+
setSuggestIdx(0);
|
|
58
|
+
}
|
|
59
|
+
const idx = suggestions.length > 0 ? suggestIdx : 0;
|
|
60
|
+
const selected = matches[idx];
|
|
61
|
+
const nextIdx = (suggestIdx + 1) % matches.length;
|
|
62
|
+
setSuggestIdx(nextIdx);
|
|
63
|
+
setValue('/' + selected.name + value.slice(cursor));
|
|
64
|
+
setCursor('/'.length + selected.name.length);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
setSuggestions([]);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (key.upArrow) {
|
|
72
|
+
const beforeCursor = value.slice(0, cursor);
|
|
73
|
+
if (beforeCursor === '' && history.length > 0) {
|
|
74
|
+
const newIdx = historyIdx < history.length - 1 ? historyIdx + 1 : historyIdx;
|
|
75
|
+
if (newIdx !== historyIdx) {
|
|
76
|
+
setHistoryIdx(newIdx);
|
|
77
|
+
setValue(history[newIdx]);
|
|
78
|
+
setCursor(history[newIdx].length);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (key.downArrow) {
|
|
84
|
+
if (historyIdx >= 0) {
|
|
85
|
+
const newIdx = historyIdx - 1;
|
|
86
|
+
if (newIdx >= 0) {
|
|
87
|
+
setHistoryIdx(newIdx);
|
|
88
|
+
setValue(history[newIdx]);
|
|
89
|
+
setCursor(history[newIdx].length);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
setHistoryIdx(-1);
|
|
93
|
+
setValue('');
|
|
94
|
+
setCursor(0);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (key.leftArrow) {
|
|
100
|
+
if (cursor > 0)
|
|
101
|
+
setCursor((c) => c - 1);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (key.rightArrow) {
|
|
105
|
+
if (cursor < value.length)
|
|
106
|
+
setCursor((c) => c + 1);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (key.backspace || key.delete) {
|
|
110
|
+
if (cursor > 0) {
|
|
111
|
+
setValue((v) => v.slice(0, cursor - 1) + v.slice(cursor));
|
|
112
|
+
setCursor((c) => c - 1);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (key.ctrl && input === 'c') {
|
|
117
|
+
onSubmit('');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (input && !key.ctrl && !key.meta) {
|
|
121
|
+
setValue((v) => v.slice(0, cursor) + input + v.slice(cursor));
|
|
122
|
+
setCursor((c) => c + input.length);
|
|
123
|
+
setSuggestions([]);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const showSuggestions = suggestions.length > 0;
|
|
127
|
+
return (_jsxs(Box, { flexDirection: "column", width: "100%", children: [showSuggestions && (_jsx(Box, { flexDirection: "column", marginLeft: 1, marginBottom: 1, children: suggestions.map((s, i) => (_jsx(Box, { children: _jsxs(Text, { inverse: i === suggestIdx, ...t.colors.dim, children: ["/", s.name, " \u2014 ", s.description] }) }, i))) })), _jsxs(Box, { width: "100%", children: [_jsx(Text, { ...(disabled ? t.colors.dim : t.colors.prompt), children: 'MMA> ' }), disabled ? (_jsx(Text, { ...t.colors.dim, children: HINTS[hintIdx] })) : (_jsxs(Text, { children: [value.slice(0, cursor), _jsx(Text, { inverse: true, children: value[cursor] || ' ' }), value.slice(cursor + 1)] }))] })] }));
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=PromptInput.js.map
|