indusagi-coding-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2249 -0
- package/README.md +546 -0
- package/dist/cli/args.js +282 -0
- package/dist/cli/config-selector.js +30 -0
- package/dist/cli/file-processor.js +78 -0
- package/dist/cli/list-models.js +91 -0
- package/dist/cli/session-picker.js +31 -0
- package/dist/cli.js +10 -0
- package/dist/config.js +158 -0
- package/dist/core/agent-session.js +2097 -0
- package/dist/core/auth-storage.js +278 -0
- package/dist/core/bash-executor.js +211 -0
- package/dist/core/compaction/branch-summarization.js +241 -0
- package/dist/core/compaction/compaction.js +606 -0
- package/dist/core/compaction/index.js +6 -0
- package/dist/core/compaction/utils.js +137 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/event-bus.js +24 -0
- package/dist/core/exec.js +70 -0
- package/dist/core/export-html/ansi-to-html.js +248 -0
- package/dist/core/export-html/index.js +221 -0
- package/dist/core/export-html/template.css +905 -0
- package/dist/core/export-html/template.html +54 -0
- package/dist/core/export-html/template.js +1549 -0
- package/dist/core/export-html/tool-renderer.js +56 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +6 -0
- package/dist/core/extensions/index.js +8 -0
- package/dist/core/extensions/loader.js +395 -0
- package/dist/core/extensions/runner.js +499 -0
- package/dist/core/extensions/types.js +31 -0
- package/dist/core/extensions/wrapper.js +101 -0
- package/dist/core/footer-data-provider.js +133 -0
- package/dist/core/index.js +8 -0
- package/dist/core/keybindings.js +140 -0
- package/dist/core/messages.js +122 -0
- package/dist/core/model-registry.js +454 -0
- package/dist/core/model-resolver.js +309 -0
- package/dist/core/package-manager.js +1142 -0
- package/dist/core/prompt-templates.js +250 -0
- package/dist/core/resource-loader.js +569 -0
- package/dist/core/sdk.js +225 -0
- package/dist/core/session-manager.js +1078 -0
- package/dist/core/settings-manager.js +430 -0
- package/dist/core/skills.js +339 -0
- package/dist/core/system-prompt.js +136 -0
- package/dist/core/timings.js +24 -0
- package/dist/core/tools/bash.js +226 -0
- package/dist/core/tools/edit-diff.js +242 -0
- package/dist/core/tools/edit.js +145 -0
- package/dist/core/tools/find.js +205 -0
- package/dist/core/tools/grep.js +238 -0
- package/dist/core/tools/index.js +60 -0
- package/dist/core/tools/ls.js +117 -0
- package/dist/core/tools/path-utils.js +52 -0
- package/dist/core/tools/read.js +165 -0
- package/dist/core/tools/truncate.js +204 -0
- package/dist/core/tools/write.js +77 -0
- package/dist/index.js +41 -0
- package/dist/main.js +565 -0
- package/dist/migrations.js +260 -0
- package/dist/modes/index.js +7 -0
- package/dist/modes/interactive/components/armin.js +328 -0
- package/dist/modes/interactive/components/assistant-message.js +86 -0
- package/dist/modes/interactive/components/bash-execution.js +155 -0
- package/dist/modes/interactive/components/bordered-loader.js +47 -0
- package/dist/modes/interactive/components/branch-summary-message.js +41 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +42 -0
- package/dist/modes/interactive/components/config-selector.js +458 -0
- package/dist/modes/interactive/components/countdown-timer.js +27 -0
- package/dist/modes/interactive/components/custom-editor.js +61 -0
- package/dist/modes/interactive/components/custom-message.js +80 -0
- package/dist/modes/interactive/components/diff.js +132 -0
- package/dist/modes/interactive/components/dynamic-border.js +19 -0
- package/dist/modes/interactive/components/extension-editor.js +96 -0
- package/dist/modes/interactive/components/extension-input.js +54 -0
- package/dist/modes/interactive/components/extension-selector.js +70 -0
- package/dist/modes/interactive/components/footer.js +213 -0
- package/dist/modes/interactive/components/index.js +31 -0
- package/dist/modes/interactive/components/keybinding-hints.js +60 -0
- package/dist/modes/interactive/components/login-dialog.js +138 -0
- package/dist/modes/interactive/components/model-selector.js +253 -0
- package/dist/modes/interactive/components/oauth-selector.js +91 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +262 -0
- package/dist/modes/interactive/components/session-selector-search.js +145 -0
- package/dist/modes/interactive/components/session-selector.js +698 -0
- package/dist/modes/interactive/components/settings-selector.js +250 -0
- package/dist/modes/interactive/components/show-images-selector.js +33 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +44 -0
- package/dist/modes/interactive/components/theme-selector.js +43 -0
- package/dist/modes/interactive/components/thinking-selector.js +45 -0
- package/dist/modes/interactive/components/tool-execution.js +608 -0
- package/dist/modes/interactive/components/tree-selector.js +892 -0
- package/dist/modes/interactive/components/user-message-selector.js +109 -0
- package/dist/modes/interactive/components/user-message.js +15 -0
- package/dist/modes/interactive/components/visual-truncate.js +32 -0
- package/dist/modes/interactive/interactive-mode.js +3576 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +84 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.js +938 -0
- package/dist/modes/print-mode.js +96 -0
- package/dist/modes/rpc/rpc-client.js +390 -0
- package/dist/modes/rpc/rpc-mode.js +448 -0
- package/dist/modes/rpc/rpc-types.js +7 -0
- package/dist/utils/changelog.js +86 -0
- package/dist/utils/clipboard-image.js +116 -0
- package/dist/utils/clipboard.js +58 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/git.js +5 -0
- package/dist/utils/image-convert.js +34 -0
- package/dist/utils/image-resize.js +180 -0
- package/dist/utils/mime.js +25 -0
- package/dist/utils/photon.js +120 -0
- package/dist/utils/shell.js +164 -0
- package/dist/utils/sleep.js +16 -0
- package/dist/utils/tools-manager.js +186 -0
- package/docs/compaction.md +390 -0
- package/docs/custom-provider.md +538 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +1733 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +162 -0
- package/docs/models.md +193 -0
- package/docs/packages.md +163 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +147 -0
- package/docs/rpc.md +1048 -0
- package/docs/sdk.md +957 -0
- package/docs/session.md +412 -0
- package/docs/settings.md +216 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +226 -0
- package/docs/terminal-setup.md +65 -0
- package/docs/themes.md +295 -0
- package/docs/tree.md +219 -0
- package/docs/tui.md +887 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +192 -0
- package/examples/extensions/antigravity-image-gen.ts +414 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +115 -0
- package/examples/extensions/custom-footer.ts +65 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +605 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +350 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +83 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +105 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/handoff.ts +151 -0
- package/examples/extensions/hello.ts +25 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +60 -0
- package/examples/extensions/modal-editor.ts +86 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +25 -0
- package/examples/extensions/overlay-qa-tests.ts +882 -0
- package/examples/extensions/overlay-test.ts +151 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +341 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +399 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/qna.ts +120 -0
- package/examples/extensions/question.ts +265 -0
- package/examples/extensions/questionnaire.ts +428 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/sandbox/index.ts +318 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +344 -0
- package/examples/extensions/space-invaders.ts +561 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +40 -0
- package/examples/extensions/subagent/README.md +172 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +127 -0
- package/examples/extensions/subagent/index.ts +964 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +196 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/todo.ts +300 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +147 -0
- package/examples/extensions/trigger-compact.ts +40 -0
- package/examples/extensions/truncated-tool.ts +193 -0
- package/examples/extensions/widget-placement.ts +17 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/sdk/01-minimal.ts +22 -0
- package/examples/sdk/02-custom-model.ts +50 -0
- package/examples/sdk/03-custom-prompt.ts +55 -0
- package/examples/sdk/04-skills.ts +46 -0
- package/examples/sdk/05-tools.ts +56 -0
- package/examples/sdk/06-extensions.ts +88 -0
- package/examples/sdk/07-context-files.ts +40 -0
- package/examples/sdk/08-prompt-templates.ts +47 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/examples/sdk/10-settings.ts +38 -0
- package/examples/sdk/11-sessions.ts +48 -0
- package/examples/sdk/12-full-control.ts +82 -0
- package/examples/sdk/13-codex-oauth.ts +37 -0
- package/examples/sdk/README.md +144 -0
- package/package.json +85 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component for displaying bash command execution with streaming output.
|
|
3
|
+
*/
|
|
4
|
+
import { Container, Loader, Spacer, Text } from "indusagi/tui";
|
|
5
|
+
import stripAnsi from "strip-ansi";
|
|
6
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, truncateTail, } from "../../../core/tools/truncate.js";
|
|
7
|
+
import { theme } from "../theme/theme.js";
|
|
8
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
9
|
+
import { editorKey, keyHint } from "./keybinding-hints.js";
|
|
10
|
+
import { truncateToVisualLines } from "./visual-truncate.js";
|
|
11
|
+
// Preview line limit when not expanded (matches tool execution behavior)
|
|
12
|
+
const PREVIEW_LINES = 20;
|
|
13
|
+
export class BashExecutionComponent extends Container {
|
|
14
|
+
constructor(command, ui, excludeFromContext = false) {
|
|
15
|
+
super();
|
|
16
|
+
this.outputLines = [];
|
|
17
|
+
this.status = "running";
|
|
18
|
+
this.exitCode = undefined;
|
|
19
|
+
this.expanded = false;
|
|
20
|
+
this.command = command;
|
|
21
|
+
this.ui = ui;
|
|
22
|
+
// Use dim border for excluded-from-context commands (!! prefix)
|
|
23
|
+
const colorKey = excludeFromContext ? "dim" : "bashMode";
|
|
24
|
+
const borderColor = (str) => theme.fg(colorKey, str);
|
|
25
|
+
// Add spacer
|
|
26
|
+
this.addChild(new Spacer(1));
|
|
27
|
+
// Top border
|
|
28
|
+
this.addChild(new DynamicBorder(borderColor));
|
|
29
|
+
// Content container (holds dynamic content between borders)
|
|
30
|
+
this.contentContainer = new Container();
|
|
31
|
+
this.addChild(this.contentContainer);
|
|
32
|
+
// Command header
|
|
33
|
+
const header = new Text(theme.fg(colorKey, theme.bold(`$ ${command}`)), 1, 0);
|
|
34
|
+
this.contentContainer.addChild(header);
|
|
35
|
+
// Loader
|
|
36
|
+
this.loader = new Loader(ui, (spinner) => theme.fg(colorKey, spinner), (text) => theme.fg("muted", text), `Running... (${editorKey("selectCancel")} to cancel)`);
|
|
37
|
+
this.contentContainer.addChild(this.loader);
|
|
38
|
+
// Bottom border
|
|
39
|
+
this.addChild(new DynamicBorder(borderColor));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set whether the output is expanded (shows full output) or collapsed (preview only).
|
|
43
|
+
*/
|
|
44
|
+
setExpanded(expanded) {
|
|
45
|
+
this.expanded = expanded;
|
|
46
|
+
this.updateDisplay();
|
|
47
|
+
}
|
|
48
|
+
invalidate() {
|
|
49
|
+
super.invalidate();
|
|
50
|
+
this.updateDisplay();
|
|
51
|
+
}
|
|
52
|
+
appendOutput(chunk) {
|
|
53
|
+
// Strip ANSI codes and normalize line endings
|
|
54
|
+
// Note: binary data is already sanitized in tui-renderer.ts executeBashCommand
|
|
55
|
+
const clean = stripAnsi(chunk).replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
56
|
+
// Append to output lines
|
|
57
|
+
const newLines = clean.split("\n");
|
|
58
|
+
if (this.outputLines.length > 0 && newLines.length > 0) {
|
|
59
|
+
// Append first chunk to last line (incomplete line continuation)
|
|
60
|
+
this.outputLines[this.outputLines.length - 1] += newLines[0];
|
|
61
|
+
this.outputLines.push(...newLines.slice(1));
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.outputLines.push(...newLines);
|
|
65
|
+
}
|
|
66
|
+
this.updateDisplay();
|
|
67
|
+
}
|
|
68
|
+
setComplete(exitCode, cancelled, truncationResult, fullOutputPath) {
|
|
69
|
+
this.exitCode = exitCode;
|
|
70
|
+
this.status = cancelled
|
|
71
|
+
? "cancelled"
|
|
72
|
+
: exitCode !== 0 && exitCode !== undefined && exitCode !== null
|
|
73
|
+
? "error"
|
|
74
|
+
: "complete";
|
|
75
|
+
this.truncationResult = truncationResult;
|
|
76
|
+
this.fullOutputPath = fullOutputPath;
|
|
77
|
+
// Stop loader
|
|
78
|
+
this.loader.stop();
|
|
79
|
+
this.updateDisplay();
|
|
80
|
+
}
|
|
81
|
+
updateDisplay() {
|
|
82
|
+
// Apply truncation for LLM context limits (same limits as bash tool)
|
|
83
|
+
const fullOutput = this.outputLines.join("\n");
|
|
84
|
+
const contextTruncation = truncateTail(fullOutput, {
|
|
85
|
+
maxLines: DEFAULT_MAX_LINES,
|
|
86
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
87
|
+
});
|
|
88
|
+
// Get the lines to potentially display (after context truncation)
|
|
89
|
+
const availableLines = contextTruncation.content ? contextTruncation.content.split("\n") : [];
|
|
90
|
+
// Apply preview truncation based on expanded state
|
|
91
|
+
const previewLogicalLines = availableLines.slice(-PREVIEW_LINES);
|
|
92
|
+
const hiddenLineCount = availableLines.length - previewLogicalLines.length;
|
|
93
|
+
// Rebuild content container
|
|
94
|
+
this.contentContainer.clear();
|
|
95
|
+
// Command header
|
|
96
|
+
const header = new Text(theme.fg("bashMode", theme.bold(`$ ${this.command}`)), 1, 0);
|
|
97
|
+
this.contentContainer.addChild(header);
|
|
98
|
+
// Output
|
|
99
|
+
if (availableLines.length > 0) {
|
|
100
|
+
if (this.expanded) {
|
|
101
|
+
// Show all lines
|
|
102
|
+
const displayText = availableLines.map((line) => theme.fg("muted", line)).join("\n");
|
|
103
|
+
this.contentContainer.addChild(new Text(`\n${displayText}`, 1, 0));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
// Use shared visual truncation utility
|
|
107
|
+
const styledOutput = previewLogicalLines.map((line) => theme.fg("muted", line)).join("\n");
|
|
108
|
+
const { visualLines } = truncateToVisualLines(`\n${styledOutput}`, PREVIEW_LINES, this.ui.terminal.columns, 1);
|
|
109
|
+
this.contentContainer.addChild({ render: () => visualLines, invalidate: () => { } });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Loader or status
|
|
113
|
+
if (this.status === "running") {
|
|
114
|
+
this.contentContainer.addChild(this.loader);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const statusParts = [];
|
|
118
|
+
// Show how many lines are hidden (collapsed preview)
|
|
119
|
+
if (hiddenLineCount > 0) {
|
|
120
|
+
if (this.expanded) {
|
|
121
|
+
statusParts.push(`(${keyHint("expandTools", "to collapse")})`);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
statusParts.push(`${theme.fg("muted", `... ${hiddenLineCount} more lines`)} (${keyHint("expandTools", "to expand")})`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (this.status === "cancelled") {
|
|
128
|
+
statusParts.push(theme.fg("warning", "(cancelled)"));
|
|
129
|
+
}
|
|
130
|
+
else if (this.status === "error") {
|
|
131
|
+
statusParts.push(theme.fg("error", `(exit ${this.exitCode})`));
|
|
132
|
+
}
|
|
133
|
+
// Add truncation warning (context truncation, not preview truncation)
|
|
134
|
+
const wasTruncated = this.truncationResult?.truncated || contextTruncation.truncated;
|
|
135
|
+
if (wasTruncated && this.fullOutputPath) {
|
|
136
|
+
statusParts.push(theme.fg("warning", `Output truncated. Full output: ${this.fullOutputPath}`));
|
|
137
|
+
}
|
|
138
|
+
if (statusParts.length > 0) {
|
|
139
|
+
this.contentContainer.addChild(new Text(`\n${statusParts.join("\n")}`, 1, 0));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the raw output for creating BashExecutionMessage.
|
|
145
|
+
*/
|
|
146
|
+
getOutput() {
|
|
147
|
+
return this.outputLines.join("\n");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the command that was executed.
|
|
151
|
+
*/
|
|
152
|
+
getCommand() {
|
|
153
|
+
return this.command;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CancellableLoader, Container, Loader, Spacer, Text } from "indusagi/tui";
|
|
2
|
+
import { DynamicBorder } from "./dynamic-border.js";
|
|
3
|
+
import { keyHint } from "./keybinding-hints.js";
|
|
4
|
+
/** Loader wrapped with borders for extension UI */
|
|
5
|
+
export class BorderedLoader extends Container {
|
|
6
|
+
constructor(tui, theme, message, options) {
|
|
7
|
+
super();
|
|
8
|
+
this.cancellable = options?.cancellable ?? true;
|
|
9
|
+
const borderColor = (s) => theme.fg("border", s);
|
|
10
|
+
this.addChild(new DynamicBorder(borderColor));
|
|
11
|
+
if (this.cancellable) {
|
|
12
|
+
this.loader = new CancellableLoader(tui, (s) => theme.fg("accent", s), (s) => theme.fg("muted", s), message);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.signalController = new AbortController();
|
|
16
|
+
this.loader = new Loader(tui, (s) => theme.fg("accent", s), (s) => theme.fg("muted", s), message);
|
|
17
|
+
}
|
|
18
|
+
this.addChild(this.loader);
|
|
19
|
+
if (this.cancellable) {
|
|
20
|
+
this.addChild(new Spacer(1));
|
|
21
|
+
this.addChild(new Text(keyHint("selectCancel", "cancel"), 1, 0));
|
|
22
|
+
}
|
|
23
|
+
this.addChild(new Spacer(1));
|
|
24
|
+
this.addChild(new DynamicBorder(borderColor));
|
|
25
|
+
}
|
|
26
|
+
get signal() {
|
|
27
|
+
if (this.cancellable) {
|
|
28
|
+
return this.loader.signal;
|
|
29
|
+
}
|
|
30
|
+
return this.signalController?.signal ?? new AbortController().signal;
|
|
31
|
+
}
|
|
32
|
+
set onAbort(fn) {
|
|
33
|
+
if (this.cancellable) {
|
|
34
|
+
this.loader.onAbort = fn;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
handleInput(data) {
|
|
38
|
+
if (this.cancellable) {
|
|
39
|
+
this.loader.handleInput(data);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
dispose() {
|
|
43
|
+
if ("dispose" in this.loader && typeof this.loader.dispose === "function") {
|
|
44
|
+
this.loader.dispose();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Box, Markdown, Spacer, Text } from "indusagi/tui";
|
|
2
|
+
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
|
3
|
+
import { editorKey } from "./keybinding-hints.js";
|
|
4
|
+
/**
|
|
5
|
+
* Component that renders a branch summary message with collapsed/expanded state.
|
|
6
|
+
* Uses same background color as custom messages for visual consistency.
|
|
7
|
+
*/
|
|
8
|
+
export class BranchSummaryMessageComponent extends Box {
|
|
9
|
+
constructor(message, markdownTheme = getMarkdownTheme()) {
|
|
10
|
+
super(1, 1, (t) => theme.bg("customMessageBg", t));
|
|
11
|
+
this.expanded = false;
|
|
12
|
+
this.message = message;
|
|
13
|
+
this.markdownTheme = markdownTheme;
|
|
14
|
+
this.updateDisplay();
|
|
15
|
+
}
|
|
16
|
+
setExpanded(expanded) {
|
|
17
|
+
this.expanded = expanded;
|
|
18
|
+
this.updateDisplay();
|
|
19
|
+
}
|
|
20
|
+
invalidate() {
|
|
21
|
+
super.invalidate();
|
|
22
|
+
this.updateDisplay();
|
|
23
|
+
}
|
|
24
|
+
updateDisplay() {
|
|
25
|
+
this.clear();
|
|
26
|
+
const label = theme.fg("customMessageLabel", `\x1b[1m[branch]\x1b[22m`);
|
|
27
|
+
this.addChild(new Text(label, 0, 0));
|
|
28
|
+
this.addChild(new Spacer(1));
|
|
29
|
+
if (this.expanded) {
|
|
30
|
+
const header = "**Branch Summary**\n\n";
|
|
31
|
+
this.addChild(new Markdown(header + this.message.summary, 0, 0, this.markdownTheme, {
|
|
32
|
+
color: (text) => theme.fg("customMessageText", text),
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.addChild(new Text(theme.fg("customMessageText", "Branch summary (") +
|
|
37
|
+
theme.fg("dim", editorKey("expandTools")) +
|
|
38
|
+
theme.fg("customMessageText", " to expand)"), 0, 0));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Box, Markdown, Spacer, Text } from "indusagi/tui";
|
|
2
|
+
import { getMarkdownTheme, theme } from "../theme/theme.js";
|
|
3
|
+
import { editorKey } from "./keybinding-hints.js";
|
|
4
|
+
/**
|
|
5
|
+
* Component that renders a compaction message with collapsed/expanded state.
|
|
6
|
+
* Uses same background color as custom messages for visual consistency.
|
|
7
|
+
*/
|
|
8
|
+
export class CompactionSummaryMessageComponent extends Box {
|
|
9
|
+
constructor(message, markdownTheme = getMarkdownTheme()) {
|
|
10
|
+
super(1, 1, (t) => theme.bg("customMessageBg", t));
|
|
11
|
+
this.expanded = false;
|
|
12
|
+
this.message = message;
|
|
13
|
+
this.markdownTheme = markdownTheme;
|
|
14
|
+
this.updateDisplay();
|
|
15
|
+
}
|
|
16
|
+
setExpanded(expanded) {
|
|
17
|
+
this.expanded = expanded;
|
|
18
|
+
this.updateDisplay();
|
|
19
|
+
}
|
|
20
|
+
invalidate() {
|
|
21
|
+
super.invalidate();
|
|
22
|
+
this.updateDisplay();
|
|
23
|
+
}
|
|
24
|
+
updateDisplay() {
|
|
25
|
+
this.clear();
|
|
26
|
+
const tokenStr = this.message.tokensBefore.toLocaleString();
|
|
27
|
+
const label = theme.fg("customMessageLabel", `\x1b[1m[compaction]\x1b[22m`);
|
|
28
|
+
this.addChild(new Text(label, 0, 0));
|
|
29
|
+
this.addChild(new Spacer(1));
|
|
30
|
+
if (this.expanded) {
|
|
31
|
+
const header = `**Compacted from ${tokenStr} tokens**\n\n`;
|
|
32
|
+
this.addChild(new Markdown(header + this.message.summary, 0, 0, this.markdownTheme, {
|
|
33
|
+
color: (text) => theme.fg("customMessageText", text),
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.addChild(new Text(theme.fg("customMessageText", `Compacted from ${tokenStr} tokens (`) +
|
|
38
|
+
theme.fg("dim", editorKey("expandTools")) +
|
|
39
|
+
theme.fg("customMessageText", " to expand)"), 0, 0));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|