edge-pi-cli 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/auth/anthropic-oauth.d.ts +10 -0
- package/dist/auth/anthropic-oauth.d.ts.map +1 -0
- package/dist/auth/anthropic-oauth.js +97 -0
- package/dist/auth/anthropic-oauth.js.map +1 -0
- package/dist/auth/auth-storage.d.ts +46 -0
- package/dist/auth/auth-storage.d.ts.map +1 -0
- package/dist/auth/auth-storage.js +213 -0
- package/dist/auth/auth-storage.js.map +1 -0
- package/dist/auth/github-copilot-oauth.d.ts +8 -0
- package/dist/auth/github-copilot-oauth.d.ts.map +1 -0
- package/dist/auth/github-copilot-oauth.js +131 -0
- package/dist/auth/github-copilot-oauth.js.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/openai-codex-oauth.d.ts +8 -0
- package/dist/auth/openai-codex-oauth.d.ts.map +1 -0
- package/dist/auth/openai-codex-oauth.js +131 -0
- package/dist/auth/openai-codex-oauth.js.map +1 -0
- package/dist/auth/types.d.ts +41 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +5 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/args.d.ts +35 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +191 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/context.d.ts +16 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +38 -0
- package/dist/context.js.map +1 -0
- package/dist/main.d.ts +8 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +313 -0
- package/dist/main.js.map +1 -0
- package/dist/model-factory.d.ts +45 -0
- package/dist/model-factory.d.ts.map +1 -0
- package/dist/model-factory.js +175 -0
- package/dist/model-factory.js.map +1 -0
- package/dist/modes/interactive/bash-helpers.d.ts +31 -0
- package/dist/modes/interactive/bash-helpers.d.ts.map +1 -0
- package/dist/modes/interactive/bash-helpers.js +68 -0
- package/dist/modes/interactive/bash-helpers.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +54 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +18 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +77 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary.d.ts +18 -0
- package/dist/modes/interactive/components/compaction-summary.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary.js +45 -0
- package/dist/modes/interactive/components/compaction-summary.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +20 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +82 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +30 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +133 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +17 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +49 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +1397 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme.d.ts +26 -0
- package/dist/modes/interactive/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme.js +64 -0
- package/dist/modes/interactive/theme.js.map +1 -0
- package/dist/modes/interactive-mode.d.ts +5 -0
- package/dist/modes/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive-mode.js +5 -0
- package/dist/modes/interactive-mode.js.map +1 -0
- package/dist/modes/print-mode.d.ts +20 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +56 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/prompts.d.ts +53 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +132 -0
- package/dist/prompts.js.map +1 -0
- package/dist/settings.d.ts +34 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +73 -0
- package/dist/settings.js.map +1 -0
- package/dist/skills.d.ts +51 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +304 -0
- package/dist/skills.js.map +1 -0
- package/dist/utils/bash-executor.d.ts +32 -0
- package/dist/utils/bash-executor.d.ts.map +1 -0
- package/dist/utils/bash-executor.js +166 -0
- package/dist/utils/bash-executor.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +24 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +211 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/find-fd.d.ts +12 -0
- package/dist/utils/find-fd.d.ts.map +1 -0
- package/dist/utils/find-fd.js +33 -0
- package/dist/utils/find-fd.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper functions for inline bash features.
|
|
3
|
+
* Extracted for testability — no TUI dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parse a user input string that starts with `!` or `!!` as a bash command.
|
|
7
|
+
* Returns null if the input is not a bash command or the command part is empty.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseBashInput(input: string): {
|
|
10
|
+
command: string;
|
|
11
|
+
excludeFromContext: boolean;
|
|
12
|
+
} | null;
|
|
13
|
+
/**
|
|
14
|
+
* Build the footer string for a completed bash execution.
|
|
15
|
+
* Returns raw text (caller applies chalk styling).
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatBashFooter(exitCode: number | undefined, cancelled: boolean, truncated: boolean, fullOutputPath?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Truncate output lines for collapsed display.
|
|
20
|
+
* Returns the visible portion and info about hidden lines.
|
|
21
|
+
*/
|
|
22
|
+
export declare function truncateDisplayLines(output: string, expanded: boolean, maxCollapsedLines?: number): {
|
|
23
|
+
display: string;
|
|
24
|
+
hiddenCount: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Format pending steering/follow-up messages for display.
|
|
28
|
+
* Returns an array of label strings (unstyled).
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatPendingMessages(steeringMessages: string[], followUpMessages: string[]): string[];
|
|
31
|
+
//# sourceMappingURL=bash-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-helpers.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/bash-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAQrG;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,OAAO,EAClB,cAAc,CAAC,EAAE,MAAM,GACrB,MAAM,CAeR;AAID;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,EACjB,iBAAiB,SAA8B,GAC7C;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAW1C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAStG","sourcesContent":["/**\n * Pure helper functions for inline bash features.\n * Extracted for testability — no TUI dependencies.\n */\n\n/**\n * Parse a user input string that starts with `!` or `!!` as a bash command.\n * Returns null if the input is not a bash command or the command part is empty.\n */\nexport function parseBashInput(input: string): { command: string; excludeFromContext: boolean } | null {\n\tif (!input.startsWith(\"!\")) return null;\n\n\tconst excludeFromContext = input.startsWith(\"!!\");\n\tconst command = excludeFromContext ? input.slice(2).trim() : input.slice(1).trim();\n\tif (!command) return null;\n\n\treturn { command, excludeFromContext };\n}\n\n/**\n * Build the footer string for a completed bash execution.\n * Returns raw text (caller applies chalk styling).\n */\nexport function formatBashFooter(\n\texitCode: number | undefined,\n\tcancelled: boolean,\n\ttruncated: boolean,\n\tfullOutputPath?: string,\n): string {\n\tlet footer = \"\";\n\tif (cancelled) {\n\t\tfooter = \"[cancelled]\";\n\t} else if (exitCode !== undefined && exitCode !== 0) {\n\t\tfooter = `[exit ${exitCode}]`;\n\t} else if (exitCode !== undefined) {\n\t\tfooter = `[exit ${exitCode}]`;\n\t}\n\n\tif (truncated && fullOutputPath) {\n\t\tfooter += `${footer ? \" \" : \"\"}(truncated, full output: ${fullOutputPath})`;\n\t}\n\n\treturn footer;\n}\n\nconst DEFAULT_MAX_COLLAPSED_LINES = 12;\n\n/**\n * Truncate output lines for collapsed display.\n * Returns the visible portion and info about hidden lines.\n */\nexport function truncateDisplayLines(\n\toutput: string,\n\texpanded: boolean,\n\tmaxCollapsedLines = DEFAULT_MAX_COLLAPSED_LINES,\n): { display: string; hiddenCount: number } {\n\tconst trimmed = output.trimEnd();\n\tif (!trimmed) return { display: \"\", hiddenCount: 0 };\n\n\tconst lines = trimmed.split(\"\\n\");\n\tif (expanded || lines.length <= maxCollapsedLines) {\n\t\treturn { display: trimmed, hiddenCount: 0 };\n\t}\n\n\tconst display = lines.slice(0, maxCollapsedLines).join(\"\\n\");\n\treturn { display, hiddenCount: lines.length - maxCollapsedLines };\n}\n\n/**\n * Format pending steering/follow-up messages for display.\n * Returns an array of label strings (unstyled).\n */\nexport function formatPendingMessages(steeringMessages: string[], followUpMessages: string[]): string[] {\n\tconst lines: string[] = [];\n\tfor (const msg of steeringMessages) {\n\t\tlines.push(`Steering: ${msg}`);\n\t}\n\tfor (const msg of followUpMessages) {\n\t\tlines.push(`Follow-up: ${msg}`);\n\t}\n\treturn lines;\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helper functions for inline bash features.
|
|
3
|
+
* Extracted for testability — no TUI dependencies.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Parse a user input string that starts with `!` or `!!` as a bash command.
|
|
7
|
+
* Returns null if the input is not a bash command or the command part is empty.
|
|
8
|
+
*/
|
|
9
|
+
export function parseBashInput(input) {
|
|
10
|
+
if (!input.startsWith("!"))
|
|
11
|
+
return null;
|
|
12
|
+
const excludeFromContext = input.startsWith("!!");
|
|
13
|
+
const command = excludeFromContext ? input.slice(2).trim() : input.slice(1).trim();
|
|
14
|
+
if (!command)
|
|
15
|
+
return null;
|
|
16
|
+
return { command, excludeFromContext };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build the footer string for a completed bash execution.
|
|
20
|
+
* Returns raw text (caller applies chalk styling).
|
|
21
|
+
*/
|
|
22
|
+
export function formatBashFooter(exitCode, cancelled, truncated, fullOutputPath) {
|
|
23
|
+
let footer = "";
|
|
24
|
+
if (cancelled) {
|
|
25
|
+
footer = "[cancelled]";
|
|
26
|
+
}
|
|
27
|
+
else if (exitCode !== undefined && exitCode !== 0) {
|
|
28
|
+
footer = `[exit ${exitCode}]`;
|
|
29
|
+
}
|
|
30
|
+
else if (exitCode !== undefined) {
|
|
31
|
+
footer = `[exit ${exitCode}]`;
|
|
32
|
+
}
|
|
33
|
+
if (truncated && fullOutputPath) {
|
|
34
|
+
footer += `${footer ? " " : ""}(truncated, full output: ${fullOutputPath})`;
|
|
35
|
+
}
|
|
36
|
+
return footer;
|
|
37
|
+
}
|
|
38
|
+
const DEFAULT_MAX_COLLAPSED_LINES = 12;
|
|
39
|
+
/**
|
|
40
|
+
* Truncate output lines for collapsed display.
|
|
41
|
+
* Returns the visible portion and info about hidden lines.
|
|
42
|
+
*/
|
|
43
|
+
export function truncateDisplayLines(output, expanded, maxCollapsedLines = DEFAULT_MAX_COLLAPSED_LINES) {
|
|
44
|
+
const trimmed = output.trimEnd();
|
|
45
|
+
if (!trimmed)
|
|
46
|
+
return { display: "", hiddenCount: 0 };
|
|
47
|
+
const lines = trimmed.split("\n");
|
|
48
|
+
if (expanded || lines.length <= maxCollapsedLines) {
|
|
49
|
+
return { display: trimmed, hiddenCount: 0 };
|
|
50
|
+
}
|
|
51
|
+
const display = lines.slice(0, maxCollapsedLines).join("\n");
|
|
52
|
+
return { display, hiddenCount: lines.length - maxCollapsedLines };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Format pending steering/follow-up messages for display.
|
|
56
|
+
* Returns an array of label strings (unstyled).
|
|
57
|
+
*/
|
|
58
|
+
export function formatPendingMessages(steeringMessages, followUpMessages) {
|
|
59
|
+
const lines = [];
|
|
60
|
+
for (const msg of steeringMessages) {
|
|
61
|
+
lines.push(`Steering: ${msg}`);
|
|
62
|
+
}
|
|
63
|
+
for (const msg of followUpMessages) {
|
|
64
|
+
lines.push(`Follow-up: ${msg}`);
|
|
65
|
+
}
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=bash-helpers.js.map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M,CAAC;AAAA,CACd;AAED,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAc,EACd,QAAiB,EACjB,iBAAiB,GAAG,2BAA2B,EACJ;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAErD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7D,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;AAAA,CAClE;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,gBAA0B,EAAE,gBAA0B,EAAY;IACvG,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["/**\n * Pure helper functions for inline bash features.\n * Extracted for testability — no TUI dependencies.\n */\n\n/**\n * Parse a user input string that starts with `!` or `!!` as a bash command.\n * Returns null if the input is not a bash command or the command part is empty.\n */\nexport function parseBashInput(input: string): { command: string; excludeFromContext: boolean } | null {\n\tif (!input.startsWith(\"!\")) return null;\n\n\tconst excludeFromContext = input.startsWith(\"!!\");\n\tconst command = excludeFromContext ? input.slice(2).trim() : input.slice(1).trim();\n\tif (!command) return null;\n\n\treturn { command, excludeFromContext };\n}\n\n/**\n * Build the footer string for a completed bash execution.\n * Returns raw text (caller applies chalk styling).\n */\nexport function formatBashFooter(\n\texitCode: number | undefined,\n\tcancelled: boolean,\n\ttruncated: boolean,\n\tfullOutputPath?: string,\n): string {\n\tlet footer = \"\";\n\tif (cancelled) {\n\t\tfooter = \"[cancelled]\";\n\t} else if (exitCode !== undefined && exitCode !== 0) {\n\t\tfooter = `[exit ${exitCode}]`;\n\t} else if (exitCode !== undefined) {\n\t\tfooter = `[exit ${exitCode}]`;\n\t}\n\n\tif (truncated && fullOutputPath) {\n\t\tfooter += `${footer ? \" \" : \"\"}(truncated, full output: ${fullOutputPath})`;\n\t}\n\n\treturn footer;\n}\n\nconst DEFAULT_MAX_COLLAPSED_LINES = 12;\n\n/**\n * Truncate output lines for collapsed display.\n * Returns the visible portion and info about hidden lines.\n */\nexport function truncateDisplayLines(\n\toutput: string,\n\texpanded: boolean,\n\tmaxCollapsedLines = DEFAULT_MAX_COLLAPSED_LINES,\n): { display: string; hiddenCount: number } {\n\tconst trimmed = output.trimEnd();\n\tif (!trimmed) return { display: \"\", hiddenCount: 0 };\n\n\tconst lines = trimmed.split(\"\\n\");\n\tif (expanded || lines.length <= maxCollapsedLines) {\n\t\treturn { display: trimmed, hiddenCount: 0 };\n\t}\n\n\tconst display = lines.slice(0, maxCollapsedLines).join(\"\\n\");\n\treturn { display, hiddenCount: lines.length - maxCollapsedLines };\n}\n\n/**\n * Format pending steering/follow-up messages for display.\n * Returns an array of label strings (unstyled).\n */\nexport function formatPendingMessages(steeringMessages: string[], followUpMessages: string[]): string[] {\n\tconst lines: string[] = [];\n\tfor (const msg of steeringMessages) {\n\t\tlines.push(`Steering: ${msg}`);\n\t}\n\tfor (const msg of followUpMessages) {\n\t\tlines.push(`Follow-up: ${msg}`);\n\t}\n\treturn lines;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component that renders a streaming assistant message with markdown.
|
|
3
|
+
* Mirrors the UX from @mariozechner/pi-coding-agent.
|
|
4
|
+
*/
|
|
5
|
+
import { Container, type MarkdownTheme } from "@mariozechner/pi-tui";
|
|
6
|
+
export declare class AssistantMessageComponent extends Container {
|
|
7
|
+
private contentContainer;
|
|
8
|
+
private markdownTheme;
|
|
9
|
+
private lastText;
|
|
10
|
+
private isAborted;
|
|
11
|
+
private errorMessage?;
|
|
12
|
+
constructor(markdownTheme?: MarkdownTheme);
|
|
13
|
+
updateText(text: string): void;
|
|
14
|
+
setAborted(message?: string): void;
|
|
15
|
+
setError(message: string): void;
|
|
16
|
+
invalidate(): void;
|
|
17
|
+
private rebuild;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=assistant-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-message.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAY,KAAK,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AAI7F,qBAAa,yBAA0B,SAAQ,SAAS;IACvD,OAAO,CAAC,gBAAgB,CAAY;IACpC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B,YAAY,aAAa,GAAE,aAAkC,EAK5D;IAED,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAG7B;IAED,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAIjC;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG9B;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,CAAC,OAAO;CAkBf","sourcesContent":["/**\n * Component that renders a streaming assistant message with markdown.\n * Mirrors the UX from @mariozechner/pi-coding-agent.\n */\n\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { getMarkdownTheme } from \"../theme.js\";\n\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate lastText = \"\";\n\tprivate isAborted = false;\n\tprivate errorMessage?: string;\n\n\tconstructor(markdownTheme: MarkdownTheme = getMarkdownTheme()) {\n\t\tsuper();\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\t}\n\n\tupdateText(text: string): void {\n\t\tthis.lastText = text;\n\t\tthis.rebuild();\n\t}\n\n\tsetAborted(message?: string): void {\n\t\tthis.isAborted = true;\n\t\tthis.errorMessage = message;\n\t\tthis.rebuild();\n\t}\n\n\tsetError(message: string): void {\n\t\tthis.errorMessage = message;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.contentContainer.clear();\n\n\t\tif (this.lastText.trim()) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Markdown(this.lastText.trim(), 1, 0, this.markdownTheme));\n\t\t}\n\n\t\tif (this.isAborted) {\n\t\t\tconst msg =\n\t\t\t\tthis.errorMessage && this.errorMessage !== \"Request was aborted\" ? this.errorMessage : \"Operation aborted\";\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Text(chalk.red(msg), 1, 0));\n\t\t} else if (this.errorMessage) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Text(chalk.red(`Error: ${this.errorMessage}`), 1, 0));\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component that renders a streaming assistant message with markdown.
|
|
3
|
+
* Mirrors the UX from @mariozechner/pi-coding-agent.
|
|
4
|
+
*/
|
|
5
|
+
import { Container, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import { getMarkdownTheme } from "../theme.js";
|
|
8
|
+
export class AssistantMessageComponent extends Container {
|
|
9
|
+
contentContainer;
|
|
10
|
+
markdownTheme;
|
|
11
|
+
lastText = "";
|
|
12
|
+
isAborted = false;
|
|
13
|
+
errorMessage;
|
|
14
|
+
constructor(markdownTheme = getMarkdownTheme()) {
|
|
15
|
+
super();
|
|
16
|
+
this.markdownTheme = markdownTheme;
|
|
17
|
+
this.contentContainer = new Container();
|
|
18
|
+
this.addChild(this.contentContainer);
|
|
19
|
+
}
|
|
20
|
+
updateText(text) {
|
|
21
|
+
this.lastText = text;
|
|
22
|
+
this.rebuild();
|
|
23
|
+
}
|
|
24
|
+
setAborted(message) {
|
|
25
|
+
this.isAborted = true;
|
|
26
|
+
this.errorMessage = message;
|
|
27
|
+
this.rebuild();
|
|
28
|
+
}
|
|
29
|
+
setError(message) {
|
|
30
|
+
this.errorMessage = message;
|
|
31
|
+
this.rebuild();
|
|
32
|
+
}
|
|
33
|
+
invalidate() {
|
|
34
|
+
super.invalidate();
|
|
35
|
+
this.rebuild();
|
|
36
|
+
}
|
|
37
|
+
rebuild() {
|
|
38
|
+
this.contentContainer.clear();
|
|
39
|
+
if (this.lastText.trim()) {
|
|
40
|
+
this.contentContainer.addChild(new Spacer(1));
|
|
41
|
+
this.contentContainer.addChild(new Markdown(this.lastText.trim(), 1, 0, this.markdownTheme));
|
|
42
|
+
}
|
|
43
|
+
if (this.isAborted) {
|
|
44
|
+
const msg = this.errorMessage && this.errorMessage !== "Request was aborted" ? this.errorMessage : "Operation aborted";
|
|
45
|
+
this.contentContainer.addChild(new Spacer(1));
|
|
46
|
+
this.contentContainer.addChild(new Text(chalk.red(msg), 1, 0));
|
|
47
|
+
}
|
|
48
|
+
else if (this.errorMessage) {
|
|
49
|
+
this.contentContainer.addChild(new Spacer(1));
|
|
50
|
+
this.contentContainer.addChild(new Text(chalk.red(`Error: ${this.errorMessage}`), 1, 0));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=assistant-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-message.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/assistant-message.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,yBAA0B,SAAQ,SAAS;IAC/C,gBAAgB,CAAY;IAC5B,aAAa,CAAgB;IAC7B,QAAQ,GAAG,EAAE,CAAC;IACd,SAAS,GAAG,KAAK,CAAC;IAClB,YAAY,CAAU;IAE9B,YAAY,aAAa,GAAkB,gBAAgB,EAAE,EAAE;QAC9D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,IAAI,SAAS,EAAE,CAAC;QACxC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAAA,CACrC;IAED,UAAU,CAAC,IAAY,EAAQ;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,OAAO,EAAE,CAAC;IAAA,CACf;IAED,UAAU,CAA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AC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1F,CAAC;IAAA,CACD;CACD","sourcesContent":["/**\n * Component that renders a streaming assistant message with markdown.\n * Mirrors the UX from @mariozechner/pi-coding-agent.\n */\n\nimport { Container, Markdown, type MarkdownTheme, Spacer, Text } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { getMarkdownTheme } from \"../theme.js\";\n\nexport class AssistantMessageComponent extends Container {\n\tprivate contentContainer: Container;\n\tprivate markdownTheme: MarkdownTheme;\n\tprivate lastText = \"\";\n\tprivate isAborted = false;\n\tprivate errorMessage?: string;\n\n\tconstructor(markdownTheme: MarkdownTheme = getMarkdownTheme()) {\n\t\tsuper();\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.contentContainer = new Container();\n\t\tthis.addChild(this.contentContainer);\n\t}\n\n\tupdateText(text: string): void {\n\t\tthis.lastText = text;\n\t\tthis.rebuild();\n\t}\n\n\tsetAborted(message?: string): void {\n\t\tthis.isAborted = true;\n\t\tthis.errorMessage = message;\n\t\tthis.rebuild();\n\t}\n\n\tsetError(message: string): void {\n\t\tthis.errorMessage = message;\n\t\tthis.rebuild();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.contentContainer.clear();\n\n\t\tif (this.lastText.trim()) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Markdown(this.lastText.trim(), 1, 0, this.markdownTheme));\n\t\t}\n\n\t\tif (this.isAborted) {\n\t\t\tconst msg =\n\t\t\t\tthis.errorMessage && this.errorMessage !== \"Request was aborted\" ? this.errorMessage : \"Operation aborted\";\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Text(chalk.red(msg), 1, 0));\n\t\t} else if (this.errorMessage) {\n\t\t\tthis.contentContainer.addChild(new Spacer(1));\n\t\t\tthis.contentContainer.addChild(new Text(chalk.red(`Error: ${this.errorMessage}`), 1, 0));\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Container, type TUI } from "@mariozechner/pi-tui";
|
|
2
|
+
export declare class BashExecutionComponent extends Container {
|
|
3
|
+
private command;
|
|
4
|
+
private ui;
|
|
5
|
+
private excludeFromContext;
|
|
6
|
+
private contentBox;
|
|
7
|
+
private loader;
|
|
8
|
+
private output;
|
|
9
|
+
private expanded;
|
|
10
|
+
private complete;
|
|
11
|
+
constructor(command: string, ui: TUI, excludeFromContext?: boolean);
|
|
12
|
+
appendOutput(chunk: string): void;
|
|
13
|
+
setComplete(exitCode: number | undefined, cancelled: boolean, truncated?: boolean, fullOutputPath?: string): void;
|
|
14
|
+
setExpanded(expanded: boolean): void;
|
|
15
|
+
getOutput(): string;
|
|
16
|
+
private updateDisplay;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=bash-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/bash-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,SAAS,EAAwB,KAAK,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAItF,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,EAAE,CAAM;IAChB,OAAO,CAAC,kBAAkB,CAAU;IACpC,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IAEzB,YAAY,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,kBAAkB,UAAQ,EAmB/D;IAED,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhC;IAED,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,UAAQ,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAqB9G;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAED,SAAS,IAAI,MAAM,CAElB;IAED,OAAO,CAAC,aAAa;CAuBrB","sourcesContent":["import { Box, Container, Loader, Spacer, Text, type TUI } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatBashFooter, truncateDisplayLines } from \"../bash-helpers.js\";\n\nexport class BashExecutionComponent extends Container {\n\tprivate command: string;\n\tprivate ui: TUI;\n\tprivate excludeFromContext: boolean;\n\tprivate contentBox: Box;\n\tprivate loader: Loader;\n\tprivate output = \"\";\n\tprivate expanded = false;\n\tprivate complete = false;\n\n\tconstructor(command: string, ui: TUI, excludeFromContext = false) {\n\t\tsuper();\n\t\tthis.command = command;\n\t\tthis.ui = ui;\n\t\tthis.excludeFromContext = excludeFromContext;\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.contentBox = new Box(1, 1, (s: string) => chalk.bgHex(\"#282832\")(s));\n\t\tthis.addChild(this.contentBox);\n\n\t\tthis.loader = new Loader(\n\t\t\tthis.ui,\n\t\t\t(s) => chalk.cyan(s),\n\t\t\t(s) => chalk.dim(s),\n\t\t\t\"Running...\",\n\t\t);\n\t\tthis.loader.start();\n\n\t\tthis.updateDisplay();\n\t}\n\n\tappendOutput(chunk: string): void {\n\t\tthis.output += chunk;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetComplete(exitCode: number | undefined, cancelled: boolean, truncated = false, fullOutputPath?: string): void {\n\t\tthis.complete = true;\n\t\tthis.loader.stop();\n\n\t\tconst rawFooter = formatBashFooter(exitCode, cancelled, truncated, fullOutputPath);\n\t\tif (rawFooter) {\n\t\t\t// Apply chalk styling based on status\n\t\t\tlet styledFooter: string;\n\t\t\tif (cancelled) {\n\t\t\t\tstyledFooter = chalk.dim(rawFooter);\n\t\t\t} else if (exitCode !== undefined && exitCode !== 0) {\n\t\t\t\tstyledFooter = chalk.red(rawFooter);\n\t\t\t} else {\n\t\t\t\tstyledFooter = chalk.dim(rawFooter);\n\t\t\t}\n\n\t\t\tthis.output = this.output.trimEnd();\n\t\t\tthis.output += `\\n\\n${styledFooter}\\n`;\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tgetOutput(): string {\n\t\treturn this.output;\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.contentBox.clear();\n\n\t\tconst titlePrefix = this.excludeFromContext ? chalk.dim(\"!!\") : chalk.dim(\"!\");\n\t\tconst title = `${titlePrefix} ${chalk.bold(`$ ${this.command}`)}`;\n\n\t\tconst header = this.excludeFromContext ? chalk.dim(title) : title;\n\t\tthis.contentBox.addChild(new Text(header, 0, 0));\n\n\t\tif (!this.complete) {\n\t\t\tthis.contentBox.addChild(new Text(\"\\n\", 0, 0));\n\t\t\tthis.contentBox.addChild(this.loader);\n\t\t\tthis.contentBox.addChild(new Text(\"\\n\", 0, 0));\n\t\t}\n\n\t\tconst { display, hiddenCount } = truncateDisplayLines(this.output, this.expanded);\n\t\tif (display) {\n\t\t\tthis.contentBox.addChild(new Text(`\\n${chalk.white(display)}`, 0, 0));\n\t\t\tif (hiddenCount > 0) {\n\t\t\t\tthis.contentBox.addChild(new Text(chalk.gray(`\\n... (${hiddenCount} more lines)`), 0, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Box, Container, Loader, Spacer, Text } from "@mariozechner/pi-tui";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { formatBashFooter, truncateDisplayLines } from "../bash-helpers.js";
|
|
4
|
+
export class BashExecutionComponent extends Container {
|
|
5
|
+
command;
|
|
6
|
+
ui;
|
|
7
|
+
excludeFromContext;
|
|
8
|
+
contentBox;
|
|
9
|
+
loader;
|
|
10
|
+
output = "";
|
|
11
|
+
expanded = false;
|
|
12
|
+
complete = false;
|
|
13
|
+
constructor(command, ui, excludeFromContext = false) {
|
|
14
|
+
super();
|
|
15
|
+
this.command = command;
|
|
16
|
+
this.ui = ui;
|
|
17
|
+
this.excludeFromContext = excludeFromContext;
|
|
18
|
+
this.addChild(new Spacer(1));
|
|
19
|
+
this.contentBox = new Box(1, 1, (s) => chalk.bgHex("#282832")(s));
|
|
20
|
+
this.addChild(this.contentBox);
|
|
21
|
+
this.loader = new Loader(this.ui, (s) => chalk.cyan(s), (s) => chalk.dim(s), "Running...");
|
|
22
|
+
this.loader.start();
|
|
23
|
+
this.updateDisplay();
|
|
24
|
+
}
|
|
25
|
+
appendOutput(chunk) {
|
|
26
|
+
this.output += chunk;
|
|
27
|
+
this.updateDisplay();
|
|
28
|
+
}
|
|
29
|
+
setComplete(exitCode, cancelled, truncated = false, fullOutputPath) {
|
|
30
|
+
this.complete = true;
|
|
31
|
+
this.loader.stop();
|
|
32
|
+
const rawFooter = formatBashFooter(exitCode, cancelled, truncated, fullOutputPath);
|
|
33
|
+
if (rawFooter) {
|
|
34
|
+
// Apply chalk styling based on status
|
|
35
|
+
let styledFooter;
|
|
36
|
+
if (cancelled) {
|
|
37
|
+
styledFooter = chalk.dim(rawFooter);
|
|
38
|
+
}
|
|
39
|
+
else if (exitCode !== undefined && exitCode !== 0) {
|
|
40
|
+
styledFooter = chalk.red(rawFooter);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
styledFooter = chalk.dim(rawFooter);
|
|
44
|
+
}
|
|
45
|
+
this.output = this.output.trimEnd();
|
|
46
|
+
this.output += `\n\n${styledFooter}\n`;
|
|
47
|
+
}
|
|
48
|
+
this.updateDisplay();
|
|
49
|
+
}
|
|
50
|
+
setExpanded(expanded) {
|
|
51
|
+
this.expanded = expanded;
|
|
52
|
+
this.updateDisplay();
|
|
53
|
+
}
|
|
54
|
+
getOutput() {
|
|
55
|
+
return this.output;
|
|
56
|
+
}
|
|
57
|
+
updateDisplay() {
|
|
58
|
+
this.contentBox.clear();
|
|
59
|
+
const titlePrefix = this.excludeFromContext ? chalk.dim("!!") : chalk.dim("!");
|
|
60
|
+
const title = `${titlePrefix} ${chalk.bold(`$ ${this.command}`)}`;
|
|
61
|
+
const header = this.excludeFromContext ? chalk.dim(title) : title;
|
|
62
|
+
this.contentBox.addChild(new Text(header, 0, 0));
|
|
63
|
+
if (!this.complete) {
|
|
64
|
+
this.contentBox.addChild(new Text("\n", 0, 0));
|
|
65
|
+
this.contentBox.addChild(this.loader);
|
|
66
|
+
this.contentBox.addChild(new Text("\n", 0, 0));
|
|
67
|
+
}
|
|
68
|
+
const { display, hiddenCount } = truncateDisplayLines(this.output, this.expanded);
|
|
69
|
+
if (display) {
|
|
70
|
+
this.contentBox.addChild(new Text(`\n${chalk.white(display)}`, 0, 0));
|
|
71
|
+
if (hiddenCount > 0) {
|
|
72
|
+
this.contentBox.addChild(new Text(chalk.gray(`\n... (${hiddenCount} more lines)`), 0, 0));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=bash-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash-execution.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/bash-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,sBAAsB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K,CAAC,IAAI,CAAC,UAAU,WAAW,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3F,CAAC;QACF,CAAC;IAAA,CACD;CACD","sourcesContent":["import { Box, Container, Loader, Spacer, Text, type TUI } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatBashFooter, truncateDisplayLines } from \"../bash-helpers.js\";\n\nexport class BashExecutionComponent extends Container {\n\tprivate command: string;\n\tprivate ui: TUI;\n\tprivate excludeFromContext: boolean;\n\tprivate contentBox: Box;\n\tprivate loader: Loader;\n\tprivate output = \"\";\n\tprivate expanded = false;\n\tprivate complete = false;\n\n\tconstructor(command: string, ui: TUI, excludeFromContext = false) {\n\t\tsuper();\n\t\tthis.command = command;\n\t\tthis.ui = ui;\n\t\tthis.excludeFromContext = excludeFromContext;\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.contentBox = new Box(1, 1, (s: string) => chalk.bgHex(\"#282832\")(s));\n\t\tthis.addChild(this.contentBox);\n\n\t\tthis.loader = new Loader(\n\t\t\tthis.ui,\n\t\t\t(s) => chalk.cyan(s),\n\t\t\t(s) => chalk.dim(s),\n\t\t\t\"Running...\",\n\t\t);\n\t\tthis.loader.start();\n\n\t\tthis.updateDisplay();\n\t}\n\n\tappendOutput(chunk: string): void {\n\t\tthis.output += chunk;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetComplete(exitCode: number | undefined, cancelled: boolean, truncated = false, fullOutputPath?: string): void {\n\t\tthis.complete = true;\n\t\tthis.loader.stop();\n\n\t\tconst rawFooter = formatBashFooter(exitCode, cancelled, truncated, fullOutputPath);\n\t\tif (rawFooter) {\n\t\t\t// Apply chalk styling based on status\n\t\t\tlet styledFooter: string;\n\t\t\tif (cancelled) {\n\t\t\t\tstyledFooter = chalk.dim(rawFooter);\n\t\t\t} else if (exitCode !== undefined && exitCode !== 0) {\n\t\t\t\tstyledFooter = chalk.red(rawFooter);\n\t\t\t} else {\n\t\t\t\tstyledFooter = chalk.dim(rawFooter);\n\t\t\t}\n\n\t\t\tthis.output = this.output.trimEnd();\n\t\t\tthis.output += `\\n\\n${styledFooter}\\n`;\n\t\t}\n\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\tgetOutput(): string {\n\t\treturn this.output;\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.contentBox.clear();\n\n\t\tconst titlePrefix = this.excludeFromContext ? chalk.dim(\"!!\") : chalk.dim(\"!\");\n\t\tconst title = `${titlePrefix} ${chalk.bold(`$ ${this.command}`)}`;\n\n\t\tconst header = this.excludeFromContext ? chalk.dim(title) : title;\n\t\tthis.contentBox.addChild(new Text(header, 0, 0));\n\n\t\tif (!this.complete) {\n\t\t\tthis.contentBox.addChild(new Text(\"\\n\", 0, 0));\n\t\t\tthis.contentBox.addChild(this.loader);\n\t\t\tthis.contentBox.addChild(new Text(\"\\n\", 0, 0));\n\t\t}\n\n\t\tconst { display, hiddenCount } = truncateDisplayLines(this.output, this.expanded);\n\t\tif (display) {\n\t\t\tthis.contentBox.addChild(new Text(`\\n${chalk.white(display)}`, 0, 0));\n\t\t\tif (hiddenCount > 0) {\n\t\t\t\tthis.contentBox.addChild(new Text(chalk.gray(`\\n... (${hiddenCount} more lines)`), 0, 0));\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compaction summary component.
|
|
3
|
+
*
|
|
4
|
+
* Displays a compact indicator showing that the context was compacted,
|
|
5
|
+
* with expandable summary details.
|
|
6
|
+
*/
|
|
7
|
+
import { Box, type MarkdownTheme } from "@mariozechner/pi-tui";
|
|
8
|
+
export declare class CompactionSummaryComponent extends Box {
|
|
9
|
+
private expanded;
|
|
10
|
+
private tokensBefore;
|
|
11
|
+
private summary;
|
|
12
|
+
private markdownTheme;
|
|
13
|
+
constructor(tokensBefore: number, summary: string, markdownTheme?: MarkdownTheme);
|
|
14
|
+
setExpanded(expanded: boolean): void;
|
|
15
|
+
invalidate(): void;
|
|
16
|
+
private updateDisplay;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=compaction-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-summary.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAY,KAAK,aAAa,EAAgB,MAAM,sBAAsB,CAAC;AAIvF,qBAAa,0BAA2B,SAAQ,GAAG;IAClD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAgB;IAErC,YAAY,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAE,aAAkC,EAMnG;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,CAAC,aAAa;CAqBrB","sourcesContent":["/**\n * Compaction summary component.\n *\n * Displays a compact indicator showing that the context was compacted,\n * with expandable summary details.\n */\n\nimport { Box, Markdown, type MarkdownTheme, Spacer, Text } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { getMarkdownTheme } from \"../theme.js\";\n\nexport class CompactionSummaryComponent extends Box {\n\tprivate expanded = false;\n\tprivate tokensBefore: number;\n\tprivate summary: string;\n\tprivate markdownTheme: MarkdownTheme;\n\n\tconstructor(tokensBefore: number, summary: string, markdownTheme: MarkdownTheme = getMarkdownTheme()) {\n\t\tsuper(1, 1, (t: string) => chalk.bgHex(\"#282840\")(t));\n\t\tthis.tokensBefore = tokensBefore;\n\t\tthis.summary = summary;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.clear();\n\n\t\tconst tokenStr = this.tokensBefore.toLocaleString();\n\t\tconst label = chalk.cyan.bold(\"[compaction]\");\n\t\tthis.addChild(new Text(label, 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tif (this.expanded) {\n\t\t\tconst header = `**Compacted from ${tokenStr} tokens**\\n\\n`;\n\t\t\tthis.addChild(new Markdown(header + this.summary, 0, 0, this.markdownTheme));\n\t\t} else {\n\t\t\tthis.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\tchalk.white(`Compacted from ${tokenStr} tokens (`) + chalk.dim(\"Ctrl+E\") + chalk.white(\" to expand)\"),\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compaction summary component.
|
|
3
|
+
*
|
|
4
|
+
* Displays a compact indicator showing that the context was compacted,
|
|
5
|
+
* with expandable summary details.
|
|
6
|
+
*/
|
|
7
|
+
import { Box, Markdown, Spacer, Text } from "@mariozechner/pi-tui";
|
|
8
|
+
import chalk from "chalk";
|
|
9
|
+
import { getMarkdownTheme } from "../theme.js";
|
|
10
|
+
export class CompactionSummaryComponent extends Box {
|
|
11
|
+
expanded = false;
|
|
12
|
+
tokensBefore;
|
|
13
|
+
summary;
|
|
14
|
+
markdownTheme;
|
|
15
|
+
constructor(tokensBefore, summary, markdownTheme = getMarkdownTheme()) {
|
|
16
|
+
super(1, 1, (t) => chalk.bgHex("#282840")(t));
|
|
17
|
+
this.tokensBefore = tokensBefore;
|
|
18
|
+
this.summary = summary;
|
|
19
|
+
this.markdownTheme = markdownTheme;
|
|
20
|
+
this.updateDisplay();
|
|
21
|
+
}
|
|
22
|
+
setExpanded(expanded) {
|
|
23
|
+
this.expanded = expanded;
|
|
24
|
+
this.updateDisplay();
|
|
25
|
+
}
|
|
26
|
+
invalidate() {
|
|
27
|
+
super.invalidate();
|
|
28
|
+
this.updateDisplay();
|
|
29
|
+
}
|
|
30
|
+
updateDisplay() {
|
|
31
|
+
this.clear();
|
|
32
|
+
const tokenStr = this.tokensBefore.toLocaleString();
|
|
33
|
+
const label = chalk.cyan.bold("[compaction]");
|
|
34
|
+
this.addChild(new Text(label, 0, 0));
|
|
35
|
+
this.addChild(new Spacer(1));
|
|
36
|
+
if (this.expanded) {
|
|
37
|
+
const header = `**Compacted from ${tokenStr} tokens**\n\n`;
|
|
38
|
+
this.addChild(new Markdown(header + this.summary, 0, 0, this.markdownTheme));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.addChild(new Text(chalk.white(`Compacted from ${tokenStr} tokens (`) + chalk.dim("Ctrl+E") + chalk.white(" to expand)"), 0, 0));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=compaction-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-summary.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/compaction-summary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAsB,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,0BAA2B,SAAQ,GAAG;IAC1C,QAAQ,GAAG,KAAK,CAAC;IACjB,YAAY,CAAS;IACrB,OAAO,CAAS;IAChB,aAAa,CAAgB;IAErC,YAAY,YAAoB,EAAE,OAAe,EAAE,aAAa,GAAkB,gBAAgB,EAAE,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CACP,KAAK,CAAC,KAAK,CAAC,kBAAkB,QAAQ,WAAW,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,EACrG,CAAC,EACD,CAAC,CACD,CACD,CAAC;QACH,CAAC;IAAA,CACD;CACD","sourcesContent":["/**\n * Compaction summary component.\n *\n * Displays a compact indicator showing that the context was compacted,\n * with expandable summary details.\n */\n\nimport { Box, Markdown, type MarkdownTheme, Spacer, Text } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { getMarkdownTheme } from \"../theme.js\";\n\nexport class CompactionSummaryComponent extends Box {\n\tprivate expanded = false;\n\tprivate tokensBefore: number;\n\tprivate summary: string;\n\tprivate markdownTheme: MarkdownTheme;\n\n\tconstructor(tokensBefore: number, summary: string, markdownTheme: MarkdownTheme = getMarkdownTheme()) {\n\t\tsuper(1, 1, (t: string) => chalk.bgHex(\"#282840\")(t));\n\t\tthis.tokensBefore = tokensBefore;\n\t\tthis.summary = summary;\n\t\tthis.markdownTheme = markdownTheme;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate updateDisplay(): void {\n\t\tthis.clear();\n\n\t\tconst tokenStr = this.tokensBefore.toLocaleString();\n\t\tconst label = chalk.cyan.bold(\"[compaction]\");\n\t\tthis.addChild(new Text(label, 0, 0));\n\t\tthis.addChild(new Spacer(1));\n\n\t\tif (this.expanded) {\n\t\t\tconst header = `**Compacted from ${tokenStr} tokens**\\n\\n`;\n\t\t\tthis.addChild(new Markdown(header + this.summary, 0, 0, this.markdownTheme));\n\t\t} else {\n\t\t\tthis.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\tchalk.white(`Compacted from ${tokenStr} tokens (`) + chalk.dim(\"Ctrl+E\") + chalk.white(\" to expand)\"),\n\t\t\t\t\t0,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footer component showing provider/model info, cwd, token stats, and status.
|
|
3
|
+
* Mirrors the UX from @mariozechner/pi-coding-agent's FooterComponent.
|
|
4
|
+
*/
|
|
5
|
+
import { type Component } from "@mariozechner/pi-tui";
|
|
6
|
+
export declare class FooterComponent implements Component {
|
|
7
|
+
private provider;
|
|
8
|
+
private modelId;
|
|
9
|
+
private contextTokens;
|
|
10
|
+
private contextWindow;
|
|
11
|
+
private autoCompaction;
|
|
12
|
+
private isSubscription;
|
|
13
|
+
constructor(provider: string, modelId: string);
|
|
14
|
+
setSubscription(isSubscription: boolean): void;
|
|
15
|
+
setTokenInfo(contextTokens: number, contextWindow: number): void;
|
|
16
|
+
setAutoCompaction(enabled: boolean): void;
|
|
17
|
+
invalidate(): void;
|
|
18
|
+
render(width: number): string[];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=footer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAiC,MAAM,sBAAsB,CAAC;AASrF,qBAAa,eAAgB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAAS;IAE/B,YAAY,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAG5C;IAED,eAAe,CAAC,cAAc,EAAE,OAAO,GAAG,IAAI,CAE7C;IAED,YAAY,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAG/D;IAED,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExC;IAED,UAAU,IAAI,IAAI,CAEjB;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CA+C9B;CACD","sourcesContent":["/**\n * Footer component showing provider/model info, cwd, token stats, and status.\n * Mirrors the UX from @mariozechner/pi-coding-agent's FooterComponent.\n */\n\nimport { type Component, truncateToWidth, visibleWidth } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\n\nfunction formatTokens(n: number): string {\n\tif (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n\tif (n >= 1_000) return `${(n / 1_000).toFixed(1)}k`;\n\treturn String(n);\n}\n\nexport class FooterComponent implements Component {\n\tprivate provider: string;\n\tprivate modelId: string;\n\tprivate contextTokens = 0;\n\tprivate contextWindow = 0;\n\tprivate autoCompaction = false;\n\tprivate isSubscription = false;\n\n\tconstructor(provider: string, modelId: string) {\n\t\tthis.provider = provider;\n\t\tthis.modelId = modelId;\n\t}\n\n\tsetSubscription(isSubscription: boolean): void {\n\t\tthis.isSubscription = isSubscription;\n\t}\n\n\tsetTokenInfo(contextTokens: number, contextWindow: number): void {\n\t\tthis.contextTokens = contextTokens;\n\t\tthis.contextWindow = contextWindow;\n\t}\n\n\tsetAutoCompaction(enabled: boolean): void {\n\t\tthis.autoCompaction = enabled;\n\t}\n\n\tinvalidate(): void {\n\t\t// Stateless - re-computes each render\n\t}\n\n\trender(width: number): string[] {\n\t\t// Build path display\n\t\tlet pwd = process.cwd();\n\t\tconst home = process.env.HOME || process.env.USERPROFILE;\n\t\tif (home && pwd.startsWith(home)) {\n\t\t\tpwd = `~${pwd.slice(home.length)}`;\n\t\t}\n\n\t\t// Truncate path if too long\n\t\tif (pwd.length > width) {\n\t\t\tconst half = Math.floor(width / 2) - 2;\n\t\t\tif (half > 0) {\n\t\t\t\tconst start = pwd.slice(0, half);\n\t\t\t\tconst end = pwd.slice(-(half - 1));\n\t\t\t\tpwd = `${start}...${end}`;\n\t\t\t} else {\n\t\t\t\tpwd = pwd.slice(0, Math.max(1, width));\n\t\t\t}\n\t\t}\n\n\t\t// Build right side: token info + model\n\t\tconst subIndicator = this.isSubscription ? \" (sub)\" : \"\";\n\t\tconst modelLabel = `${this.provider}/${this.modelId}${subIndicator}`;\n\t\tconst rightParts: string[] = [];\n\n\t\tif (this.contextWindow > 0) {\n\t\t\tconst pct = Math.round((this.contextTokens / this.contextWindow) * 100);\n\t\t\tconst autoIndicator = this.autoCompaction ? \"*\" : \"\";\n\t\t\trightParts.push(`${pct}%/${formatTokens(this.contextWindow)}${autoIndicator}`);\n\t\t}\n\n\t\trightParts.push(modelLabel);\n\t\tconst rightSide = rightParts.join(\" \");\n\n\t\tconst pwdWidth = visibleWidth(pwd);\n\t\tconst rightWidth = visibleWidth(rightSide);\n\t\tconst minPadding = 2;\n\n\t\tlet statsLine: string;\n\t\tif (pwdWidth + minPadding + rightWidth <= width) {\n\t\t\tconst padding = \" \".repeat(width - pwdWidth - rightWidth);\n\t\t\tstatsLine = pwd + padding + rightSide;\n\t\t} else {\n\t\t\tstatsLine = truncateToWidth(pwd, width);\n\t\t}\n\n\t\treturn [chalk.dim(statsLine)];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footer component showing provider/model info, cwd, token stats, and status.
|
|
3
|
+
* Mirrors the UX from @mariozechner/pi-coding-agent's FooterComponent.
|
|
4
|
+
*/
|
|
5
|
+
import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
function formatTokens(n) {
|
|
8
|
+
if (n >= 1_000_000)
|
|
9
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
10
|
+
if (n >= 1_000)
|
|
11
|
+
return `${(n / 1_000).toFixed(1)}k`;
|
|
12
|
+
return String(n);
|
|
13
|
+
}
|
|
14
|
+
export class FooterComponent {
|
|
15
|
+
provider;
|
|
16
|
+
modelId;
|
|
17
|
+
contextTokens = 0;
|
|
18
|
+
contextWindow = 0;
|
|
19
|
+
autoCompaction = false;
|
|
20
|
+
isSubscription = false;
|
|
21
|
+
constructor(provider, modelId) {
|
|
22
|
+
this.provider = provider;
|
|
23
|
+
this.modelId = modelId;
|
|
24
|
+
}
|
|
25
|
+
setSubscription(isSubscription) {
|
|
26
|
+
this.isSubscription = isSubscription;
|
|
27
|
+
}
|
|
28
|
+
setTokenInfo(contextTokens, contextWindow) {
|
|
29
|
+
this.contextTokens = contextTokens;
|
|
30
|
+
this.contextWindow = contextWindow;
|
|
31
|
+
}
|
|
32
|
+
setAutoCompaction(enabled) {
|
|
33
|
+
this.autoCompaction = enabled;
|
|
34
|
+
}
|
|
35
|
+
invalidate() {
|
|
36
|
+
// Stateless - re-computes each render
|
|
37
|
+
}
|
|
38
|
+
render(width) {
|
|
39
|
+
// Build path display
|
|
40
|
+
let pwd = process.cwd();
|
|
41
|
+
const home = process.env.HOME || process.env.USERPROFILE;
|
|
42
|
+
if (home && pwd.startsWith(home)) {
|
|
43
|
+
pwd = `~${pwd.slice(home.length)}`;
|
|
44
|
+
}
|
|
45
|
+
// Truncate path if too long
|
|
46
|
+
if (pwd.length > width) {
|
|
47
|
+
const half = Math.floor(width / 2) - 2;
|
|
48
|
+
if (half > 0) {
|
|
49
|
+
const start = pwd.slice(0, half);
|
|
50
|
+
const end = pwd.slice(-(half - 1));
|
|
51
|
+
pwd = `${start}...${end}`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
pwd = pwd.slice(0, Math.max(1, width));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Build right side: token info + model
|
|
58
|
+
const subIndicator = this.isSubscription ? " (sub)" : "";
|
|
59
|
+
const modelLabel = `${this.provider}/${this.modelId}${subIndicator}`;
|
|
60
|
+
const rightParts = [];
|
|
61
|
+
if (this.contextWindow > 0) {
|
|
62
|
+
const pct = Math.round((this.contextTokens / this.contextWindow) * 100);
|
|
63
|
+
const autoIndicator = this.autoCompaction ? "*" : "";
|
|
64
|
+
rightParts.push(`${pct}%/${formatTokens(this.contextWindow)}${autoIndicator}`);
|
|
65
|
+
}
|
|
66
|
+
rightParts.push(modelLabel);
|
|
67
|
+
const rightSide = rightParts.join(" ");
|
|
68
|
+
const pwdWidth = visibleWidth(pwd);
|
|
69
|
+
const rightWidth = visibleWidth(rightSide);
|
|
70
|
+
const minPadding = 2;
|
|
71
|
+
let statsLine;
|
|
72
|
+
if (pwdWidth + minPadding + rightWidth <= width) {
|
|
73
|
+
const padding = " ".repeat(width - pwdWidth - rightWidth);
|
|
74
|
+
statsLine = pwd + padding + rightSide;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
statsLine = truncateToWidth(pwd, width);
|
|
78
|
+
}
|
|
79
|
+
return [chalk.dim(statsLine)];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=footer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"footer.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/footer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAkB,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,SAAS,YAAY,CAAC,CAAS,EAAU;IACxC,IAAI,CAAC,IAAI,SAAS;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5D,IAAI,CAAC,IAAI,KAAK;QAAE,OAAO,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACpD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;AAAA,CACjB;A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AAM,UAAU,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,CAAC,CAAC;QAErB,IAAI,SAAiB,CAAC;QACtB,IAAI,QAAQ,GAAG,UAAU,GAAG,UAAU,IAAI,KAAK,EAAE,CAAC;YACjD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC;YAC1D,SAAS,GAAG,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;QACvC,CAAC;aAAM,CAAC;YACP,SAAS,GAAG,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IAAA,CAC9B;CACD","sourcesContent":["/**\n * Footer component showing provider/model info, cwd, token stats, and status.\n * Mirrors the UX from @mariozechner/pi-coding-agent's FooterComponent.\n */\n\nimport { type Component, truncateToWidth, visibleWidth } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\n\nfunction formatTokens(n: number): string {\n\tif (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n\tif (n >= 1_000) return `${(n / 1_000).toFixed(1)}k`;\n\treturn String(n);\n}\n\nexport class FooterComponent implements Component {\n\tprivate provider: string;\n\tprivate modelId: string;\n\tprivate contextTokens = 0;\n\tprivate contextWindow = 0;\n\tprivate autoCompaction = false;\n\tprivate isSubscription = false;\n\n\tconstructor(provider: string, modelId: string) {\n\t\tthis.provider = provider;\n\t\tthis.modelId = modelId;\n\t}\n\n\tsetSubscription(isSubscription: boolean): void {\n\t\tthis.isSubscription = isSubscription;\n\t}\n\n\tsetTokenInfo(contextTokens: number, contextWindow: number): void {\n\t\tthis.contextTokens = contextTokens;\n\t\tthis.contextWindow = contextWindow;\n\t}\n\n\tsetAutoCompaction(enabled: boolean): void {\n\t\tthis.autoCompaction = enabled;\n\t}\n\n\tinvalidate(): void {\n\t\t// Stateless - re-computes each render\n\t}\n\n\trender(width: number): string[] {\n\t\t// Build path display\n\t\tlet pwd = process.cwd();\n\t\tconst home = process.env.HOME || process.env.USERPROFILE;\n\t\tif (home && pwd.startsWith(home)) {\n\t\t\tpwd = `~${pwd.slice(home.length)}`;\n\t\t}\n\n\t\t// Truncate path if too long\n\t\tif (pwd.length > width) {\n\t\t\tconst half = Math.floor(width / 2) - 2;\n\t\t\tif (half > 0) {\n\t\t\t\tconst start = pwd.slice(0, half);\n\t\t\t\tconst end = pwd.slice(-(half - 1));\n\t\t\t\tpwd = `${start}...${end}`;\n\t\t\t} else {\n\t\t\t\tpwd = pwd.slice(0, Math.max(1, width));\n\t\t\t}\n\t\t}\n\n\t\t// Build right side: token info + model\n\t\tconst subIndicator = this.isSubscription ? \" (sub)\" : \"\";\n\t\tconst modelLabel = `${this.provider}/${this.modelId}${subIndicator}`;\n\t\tconst rightParts: string[] = [];\n\n\t\tif (this.contextWindow > 0) {\n\t\t\tconst pct = Math.round((this.contextTokens / this.contextWindow) * 100);\n\t\t\tconst autoIndicator = this.autoCompaction ? \"*\" : \"\";\n\t\t\trightParts.push(`${pct}%/${formatTokens(this.contextWindow)}${autoIndicator}`);\n\t\t}\n\n\t\trightParts.push(modelLabel);\n\t\tconst rightSide = rightParts.join(\" \");\n\n\t\tconst pwdWidth = visibleWidth(pwd);\n\t\tconst rightWidth = visibleWidth(rightSide);\n\t\tconst minPadding = 2;\n\n\t\tlet statsLine: string;\n\t\tif (pwdWidth + minPadding + rightWidth <= width) {\n\t\t\tconst padding = \" \".repeat(width - pwdWidth - rightWidth);\n\t\t\tstatsLine = pwd + padding + rightSide;\n\t\t} else {\n\t\t\tstatsLine = truncateToWidth(pwd, width);\n\t\t}\n\n\t\treturn [chalk.dim(statsLine)];\n\t}\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component that renders a tool call with its result.
|
|
3
|
+
* Mirrors the UX from @mariozechner/pi-coding-agent's ToolExecutionComponent.
|
|
4
|
+
*/
|
|
5
|
+
import { Container } from "@mariozechner/pi-tui";
|
|
6
|
+
/** Structured tool output that supports text and optional image data */
|
|
7
|
+
export interface ToolOutput {
|
|
8
|
+
text: string;
|
|
9
|
+
image?: {
|
|
10
|
+
base64: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare class ToolExecutionComponent extends Container {
|
|
15
|
+
private contentBox;
|
|
16
|
+
private toolName;
|
|
17
|
+
private args;
|
|
18
|
+
private result?;
|
|
19
|
+
private expanded;
|
|
20
|
+
private isPartial;
|
|
21
|
+
constructor(toolName: string, args: Record<string, unknown>);
|
|
22
|
+
updateArgs(args: Record<string, unknown>): void;
|
|
23
|
+
updateResult(output: ToolOutput, isError: boolean, isPartial?: boolean): void;
|
|
24
|
+
setExpanded(expanded: boolean): void;
|
|
25
|
+
invalidate(): void;
|
|
26
|
+
private updateDisplay;
|
|
27
|
+
private getPreviewLineCount;
|
|
28
|
+
private formatHeader;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=tool-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-execution.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/tool-execution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAO,SAAS,EAAgB,MAAM,sBAAsB,CAAC;AAkBpE,wEAAwE;AACxE,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,qBAAa,sBAAuB,SAAQ,SAAS;IACpD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAA0B;IACtC,OAAO,CAAC,MAAM,CAAC,CAGb;IACF,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAQ;IAEzB,YAAY,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAU1D;IAED,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAG9C;IAED,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,UAAQ,GAAG,IAAI,CAI1E;IAED,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAGnC;IAEQ,UAAU,IAAI,IAAI,CAG1B;IAED,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,YAAY;CAgDpB","sourcesContent":["/**\n * Component that renders a tool call with its result.\n * Mirrors the UX from @mariozechner/pi-coding-agent's ToolExecutionComponent.\n */\n\nimport { homedir } from \"node:os\";\nimport { Box, Container, Spacer, Text } from \"@mariozechner/pi-tui\";\nimport chalk from \"chalk\";\nimport { colors } from \"../theme.js\";\n\n/** Preview line limit for bash output when collapsed */\nconst BASH_PREVIEW_LINES = 5;\n\n/** Max lines for read/write/grep/find output when collapsed */\nconst DEFAULT_PREVIEW_LINES = 10;\n\nfunction shortenPath(path: string): string {\n\tconst home = homedir();\n\tif (path.startsWith(home)) {\n\t\treturn `~${path.slice(home.length)}`;\n\t}\n\treturn path;\n}\n\n/** Structured tool output that supports text and optional image data */\nexport interface ToolOutput {\n\ttext: string;\n\timage?: { base64: string; mimeType: string };\n}\n\nexport class ToolExecutionComponent extends Container {\n\tprivate contentBox: Box;\n\tprivate toolName: string;\n\tprivate args: Record<string, unknown>;\n\tprivate result?: {\n\t\toutput: ToolOutput;\n\t\tisError: boolean;\n\t};\n\tprivate expanded = false;\n\tprivate isPartial = true;\n\n\tconstructor(toolName: string, args: Record<string, unknown>) {\n\t\tsuper();\n\t\tthis.toolName = toolName;\n\t\tthis.args = args;\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.contentBox = new Box(1, 1, colors.toolPendingBg);\n\t\tthis.addChild(this.contentBox);\n\n\t\tthis.updateDisplay();\n\t}\n\n\tupdateArgs(args: Record<string, unknown>): void {\n\t\tthis.args = args;\n\t\tthis.updateDisplay();\n\t}\n\n\tupdateResult(output: ToolOutput, isError: boolean, isPartial = false): void {\n\t\tthis.result = { output, isError };\n\t\tthis.isPartial = isPartial;\n\t\tthis.updateDisplay();\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.expanded = expanded;\n\t\tthis.updateDisplay();\n\t}\n\n\toverride invalidate(): void {\n\t\tsuper.invalidate();\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate updateDisplay(): void {\n\t\t// Set background based on state\n\t\tconst bgFn = this.isPartial\n\t\t\t? colors.toolPendingBg\n\t\t\t: this.result?.isError\n\t\t\t\t? colors.toolErrorBg\n\t\t\t\t: colors.toolSuccessBg;\n\n\t\tthis.contentBox.setBgFn(bgFn);\n\t\tthis.contentBox.clear();\n\n\t\tconst headerText = this.formatHeader();\n\t\tthis.contentBox.addChild(new Text(headerText, 0, 0));\n\n\t\tif (this.result) {\n\t\t\tconst output = this.result.output.text.trim();\n\t\t\tif (output) {\n\t\t\t\tconst lines = output.split(\"\\n\");\n\t\t\t\tconst maxLines = this.expanded ? lines.length : this.getPreviewLineCount();\n\t\t\t\tconst displayLines = lines.slice(0, maxLines);\n\t\t\t\tconst remaining = lines.length - maxLines;\n\n\t\t\t\tconst styledOutput = displayLines.map((line) => chalk.gray(line)).join(\"\\n\");\n\n\t\t\t\tthis.contentBox.addChild(new Text(`\\n${styledOutput}`, 0, 0));\n\n\t\t\t\tif (remaining > 0) {\n\t\t\t\t\tthis.contentBox.addChild(new Text(chalk.gray(`\\n... (${remaining} more lines)`), 0, 0));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate getPreviewLineCount(): number {\n\t\tif (this.toolName === \"bash\") return BASH_PREVIEW_LINES;\n\t\treturn DEFAULT_PREVIEW_LINES;\n\t}\n\n\tprivate formatHeader(): string {\n\t\tswitch (this.toolName) {\n\t\t\tcase \"bash\": {\n\t\t\t\tconst command = String(this.args.command || \"\");\n\t\t\t\tconst timeout = this.args.timeout as number | undefined;\n\t\t\t\tconst timeoutSuffix = timeout ? chalk.gray(` (timeout ${timeout}s)`) : \"\";\n\t\t\t\treturn chalk.bold(`$ ${command || chalk.gray(\"...\")}`) + timeoutSuffix;\n\t\t\t}\n\t\t\tcase \"read\": {\n\t\t\t\tconst path = shortenPath(String(this.args.file_path || this.args.path || \"\"));\n\t\t\t\tconst offset = this.args.offset as number | undefined;\n\t\t\t\tconst limit = this.args.limit as number | undefined;\n\t\t\t\tlet pathDisplay = path ? chalk.cyan(path) : chalk.gray(\"...\");\n\t\t\t\tif (offset !== undefined || limit !== undefined) {\n\t\t\t\t\tconst startLine = offset ?? 1;\n\t\t\t\t\tconst endLine = limit !== undefined ? startLine + limit - 1 : \"\";\n\t\t\t\t\tpathDisplay += chalk.yellow(`:${startLine}${endLine ? `-${endLine}` : \"\"}`);\n\t\t\t\t}\n\t\t\t\treturn `${chalk.bold(\"read\")} ${pathDisplay}`;\n\t\t\t}\n\t\t\tcase \"write\": {\n\t\t\t\tconst path = shortenPath(String(this.args.file_path || this.args.path || \"\"));\n\t\t\t\treturn `${chalk.bold(\"write\")} ${path ? chalk.cyan(path) : chalk.gray(\"...\")}`;\n\t\t\t}\n\t\t\tcase \"edit\": {\n\t\t\t\tconst path = shortenPath(String(this.args.file_path || this.args.path || \"\"));\n\t\t\t\treturn `${chalk.bold(\"edit\")} ${path ? chalk.cyan(path) : chalk.gray(\"...\")}`;\n\t\t\t}\n\t\t\tcase \"grep\": {\n\t\t\t\tconst pattern = String(this.args.pattern || \"\");\n\t\t\t\tconst path = shortenPath(String(this.args.path || \".\"));\n\t\t\t\tconst glob = this.args.glob ? ` (${this.args.glob})` : \"\";\n\t\t\t\treturn `${chalk.bold(\"grep\")} ${chalk.cyan(`/${pattern}/`)}${chalk.gray(` in ${path}${glob}`)}`;\n\t\t\t}\n\t\t\tcase \"find\": {\n\t\t\t\tconst pattern = String(this.args.pattern || \"\");\n\t\t\t\tconst path = shortenPath(String(this.args.path || \".\"));\n\t\t\t\treturn `${chalk.bold(\"find\")} ${chalk.cyan(pattern)}${chalk.gray(` in ${path}`)}`;\n\t\t\t}\n\t\t\tcase \"ls\": {\n\t\t\t\tconst path = shortenPath(String(this.args.path || \".\"));\n\t\t\t\treturn `${chalk.bold(\"ls\")} ${chalk.cyan(path)}`;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn chalk.bold(this.toolName);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|