@travisennis/acai 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/agent/index.d.ts +119 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +406 -0
- package/dist/agent/manual-loop.d.ts +41 -0
- package/dist/agent/manual-loop.d.ts.map +1 -0
- package/dist/agent/manual-loop.js +278 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -33
- package/dist/commands/add-directory-command.d.ts +3 -0
- package/dist/commands/add-directory-command.d.ts.map +1 -0
- package/dist/commands/add-directory-command.js +85 -0
- package/dist/commands/application-log-command.d.ts.map +1 -1
- package/dist/commands/application-log-command.js +34 -0
- package/dist/commands/clear-command.d.ts.map +1 -1
- package/dist/commands/clear-command.js +8 -0
- package/dist/commands/compact-command.d.ts.map +1 -1
- package/dist/commands/compact-command.js +15 -2
- package/dist/commands/context-command.d.ts +3 -0
- package/dist/commands/context-command.d.ts.map +1 -0
- package/dist/commands/context-command.js +183 -0
- package/dist/commands/copy-command.d.ts.map +1 -1
- package/dist/commands/copy-command.js +28 -0
- package/dist/commands/edit-command.d.ts.map +1 -1
- package/dist/commands/edit-command.js +33 -0
- package/dist/commands/edit-prompt-command.d.ts.map +1 -1
- package/dist/commands/edit-prompt-command.js +28 -0
- package/dist/commands/exit-command.d.ts.map +1 -1
- package/dist/commands/exit-command.js +20 -0
- package/dist/commands/files-command.d.ts.map +1 -1
- package/dist/commands/files-command.js +57 -0
- package/dist/commands/generate-rules-command.d.ts.map +1 -1
- package/dist/commands/generate-rules-command.js +311 -1
- package/dist/commands/handoff-command.d.ts +3 -0
- package/dist/commands/handoff-command.d.ts.map +1 -0
- package/dist/commands/handoff-command.js +202 -0
- package/dist/commands/health-command.d.ts.map +1 -1
- package/dist/commands/health-command.js +119 -2
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +28 -0
- package/dist/commands/history-command.d.ts +3 -0
- package/dist/commands/history-command.d.ts.map +1 -0
- package/dist/commands/history-command.js +534 -0
- package/dist/commands/init-command.d.ts +1 -1
- package/dist/commands/init-command.d.ts.map +1 -1
- package/dist/commands/init-command.js +55 -18
- package/dist/commands/last-log-command.d.ts.map +1 -1
- package/dist/commands/last-log-command.js +27 -0
- package/dist/commands/list-directories-command.d.ts +3 -0
- package/dist/commands/list-directories-command.d.ts.map +1 -0
- package/dist/commands/list-directories-command.js +48 -0
- package/dist/commands/list-tools-command.d.ts.map +1 -1
- package/dist/commands/list-tools-command.js +66 -3
- package/dist/commands/manager.d.ts +15 -3
- package/dist/commands/manager.d.ts.map +1 -1
- package/dist/commands/manager.js +86 -26
- package/dist/commands/model-command.d.ts +22 -0
- package/dist/commands/model-command.d.ts.map +1 -1
- package/dist/commands/model-command.js +256 -0
- package/dist/commands/paste-command.d.ts.map +1 -1
- package/dist/commands/paste-command.js +92 -0
- package/dist/commands/pickup-command.d.ts +3 -0
- package/dist/commands/pickup-command.d.ts.map +1 -0
- package/dist/commands/pickup-command.js +161 -0
- package/dist/commands/prompt-command.d.ts +1 -1
- package/dist/commands/prompt-command.d.ts.map +1 -1
- package/dist/commands/prompt-command.js +117 -2
- package/dist/commands/remove-directory-command.d.ts +3 -0
- package/dist/commands/remove-directory-command.d.ts.map +1 -0
- package/dist/commands/remove-directory-command.js +87 -0
- package/dist/commands/reset-command.d.ts +1 -1
- package/dist/commands/reset-command.d.ts.map +1 -1
- package/dist/commands/reset-command.js +13 -2
- package/dist/commands/rules-command.d.ts.map +1 -1
- package/dist/commands/rules-command.js +65 -0
- package/dist/commands/save-command.d.ts.map +1 -1
- package/dist/commands/save-command.js +12 -0
- package/dist/commands/shell-command.d.ts.map +1 -1
- package/dist/commands/shell-command.js +68 -0
- package/dist/commands/types.d.ts +9 -4
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/usage-command.d.ts.map +1 -1
- package/dist/commands/usage-command.js +22 -0
- package/dist/config.d.ts +6 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -29
- package/dist/formatting.d.ts +108 -0
- package/dist/formatting.d.ts.map +1 -1
- package/dist/formatting.js +147 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +140 -38
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +47 -18
- package/dist/mentions.d.ts +2 -1
- package/dist/mentions.d.ts.map +1 -1
- package/dist/mentions.js +16 -1
- package/dist/messages.d.ts +8 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +56 -19
- package/dist/middleware/cache.d.ts +3 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +53 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/middleware/index.js +1 -0
- package/dist/models/ai-config.d.ts +4 -2
- package/dist/models/ai-config.d.ts.map +1 -1
- package/dist/models/ai-config.js +12 -2
- package/dist/models/anthropic-provider.d.ts.map +1 -1
- package/dist/models/anthropic-provider.js +3 -60
- package/dist/models/manager.d.ts +2 -1
- package/dist/models/manager.d.ts.map +1 -1
- package/dist/models/manager.js +26 -2
- package/dist/models/openrouter-provider.d.ts +7 -14
- package/dist/models/openrouter-provider.d.ts.map +1 -1
- package/dist/models/openrouter-provider.js +114 -169
- package/dist/models/providers.d.ts +1 -1
- package/dist/models/providers.d.ts.map +1 -1
- package/dist/prompts.d.ts +1 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +53 -4
- package/dist/repl/display-tool-messages.d.ts +1 -1
- package/dist/repl/display-tool-messages.d.ts.map +1 -1
- package/dist/repl/display-tool-messages.js +47 -44
- package/dist/repl/get-prompt-header.d.ts.map +1 -1
- package/dist/repl/get-prompt-header.js +1 -30
- package/dist/repl/project-status-line.d.ts +2 -0
- package/dist/repl/project-status-line.d.ts.map +1 -0
- package/dist/repl/project-status-line.js +31 -0
- package/dist/repl/prompt.d.ts +21 -0
- package/dist/repl/prompt.d.ts.map +1 -0
- package/dist/{repl-prompt.js → repl/prompt.js} +119 -22
- package/dist/repl/tool-call-repair.d.ts.map +1 -1
- package/dist/repl/tool-call-repair.js +8 -4
- package/dist/repl-new.d.ts +53 -0
- package/dist/repl-new.d.ts.map +1 -0
- package/dist/repl-new.js +374 -0
- package/dist/repl.d.ts +3 -5
- package/dist/repl.d.ts.map +1 -1
- package/dist/repl.js +74 -166
- package/dist/terminal/checkbox-prompt.d.ts.map +1 -1
- package/dist/terminal/checkbox-prompt.js +10 -4
- package/dist/terminal/index.d.ts +7 -0
- package/dist/terminal/index.d.ts.map +1 -1
- package/dist/terminal/index.js +94 -0
- package/dist/terminal/input-prompt.d.ts +2 -1
- package/dist/terminal/input-prompt.d.ts.map +1 -1
- package/dist/terminal/markdown.js +3 -0
- package/dist/terminal/search-prompt.d.ts.map +1 -1
- package/dist/terminal/search-prompt.js +11 -10
- package/dist/terminal/select-prompt.d.ts +2 -2
- package/dist/terminal/select-prompt.d.ts.map +1 -1
- package/dist/terminal/select-prompt.js +47 -39
- package/dist/tokens/threshold.d.ts +35 -0
- package/dist/tokens/threshold.d.ts.map +1 -0
- package/dist/tokens/threshold.js +85 -0
- package/dist/tools/advanced-edit-file.d.ts +69 -0
- package/dist/tools/advanced-edit-file.d.ts.map +1 -0
- package/dist/tools/advanced-edit-file.js +281 -0
- package/dist/tools/agent.d.ts +16 -5
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/agent.js +71 -58
- package/dist/tools/bash-utils.d.ts +1 -1
- package/dist/tools/bash-utils.d.ts.map +1 -1
- package/dist/tools/bash-utils.js +14 -6
- package/dist/tools/bash.d.ts +21 -12
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +88 -135
- package/dist/tools/code-interpreter.d.ts +21 -9
- package/dist/tools/code-interpreter.d.ts.map +1 -1
- package/dist/tools/code-interpreter.js +138 -137
- package/dist/tools/delete-file.d.ts +17 -10
- package/dist/tools/delete-file.d.ts.map +1 -1
- package/dist/tools/delete-file.js +51 -95
- package/dist/tools/directory-tree.d.ts +17 -6
- package/dist/tools/directory-tree.d.ts.map +1 -1
- package/dist/tools/directory-tree.js +47 -49
- package/dist/tools/dynamic-tool-loader.d.ts +18 -8
- package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-loader.js +121 -129
- package/dist/tools/dynamic-tool-parser.d.ts +1 -0
- package/dist/tools/dynamic-tool-parser.d.ts.map +1 -1
- package/dist/tools/dynamic-tool-parser.js +1 -0
- package/dist/tools/edit-file.d.ts +35 -15
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +112 -112
- package/dist/tools/filesystem-utils.d.ts +2 -1
- package/dist/tools/filesystem-utils.d.ts.map +1 -1
- package/dist/tools/filesystem-utils.js +31 -17
- package/dist/tools/glob.d.ts +36 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +143 -0
- package/dist/tools/grep.d.ts +73 -12
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +413 -168
- package/dist/tools/index.d.ts +204 -124
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +242 -135
- package/dist/tools/llm-edit-fixer.d.ts +25 -0
- package/dist/tools/llm-edit-fixer.d.ts.map +1 -0
- package/dist/tools/llm-edit-fixer.js +150 -0
- package/dist/tools/move-file.d.ts +19 -7
- package/dist/tools/move-file.d.ts.map +1 -1
- package/dist/tools/move-file.js +40 -33
- package/dist/tools/read-file.d.ts +47 -9
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +74 -69
- package/dist/tools/read-multiple-files.d.ts +17 -6
- package/dist/tools/read-multiple-files.d.ts.map +1 -1
- package/dist/tools/read-multiple-files.js +76 -73
- package/dist/tools/save-file.d.ts +45 -12
- package/dist/tools/save-file.d.ts.map +1 -1
- package/dist/tools/save-file.js +58 -101
- package/dist/tools/think.d.ts +15 -7
- package/dist/tools/think.d.ts.map +1 -1
- package/dist/tools/think.js +30 -22
- package/dist/tools/types.d.ts +4 -10
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +9 -0
- package/dist/tools/utils.d.ts +14 -0
- package/dist/tools/utils.d.ts.map +1 -0
- package/dist/tools/utils.js +16 -0
- package/dist/tools/web-fetch.d.ts +11 -4
- package/dist/tools/web-fetch.d.ts.map +1 -1
- package/dist/tools/web-fetch.js +39 -38
- package/dist/tools/web-search.d.ts +15 -6
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +50 -32
- package/dist/tui/autocomplete.d.ts +44 -0
- package/dist/tui/autocomplete.d.ts.map +1 -0
- package/dist/tui/autocomplete.js +466 -0
- package/dist/tui/components/assistant-message.d.ts +18 -0
- package/dist/tui/components/assistant-message.d.ts.map +1 -0
- package/dist/tui/components/assistant-message.js +29 -0
- package/dist/tui/components/editor.d.ts +51 -0
- package/dist/tui/components/editor.d.ts.map +1 -0
- package/dist/tui/components/editor.js +758 -0
- package/dist/tui/components/footer.d.ts +24 -0
- package/dist/tui/components/footer.d.ts.map +1 -0
- package/dist/tui/components/footer.js +197 -0
- package/dist/tui/components/input.d.ts +14 -0
- package/dist/tui/components/input.d.ts.map +1 -0
- package/dist/tui/components/input.js +122 -0
- package/dist/tui/components/loader.d.ts +19 -0
- package/dist/tui/components/loader.d.ts.map +1 -0
- package/dist/tui/components/loader.js +45 -0
- package/dist/tui/components/markdown.d.ts +103 -0
- package/dist/tui/components/markdown.d.ts.map +1 -0
- package/dist/tui/components/markdown.js +533 -0
- package/dist/tui/components/modal.d.ts +40 -0
- package/dist/tui/components/modal.d.ts.map +1 -0
- package/dist/tui/components/modal.js +292 -0
- package/dist/tui/components/prompt-status.d.ts +16 -0
- package/dist/tui/components/prompt-status.d.ts.map +1 -0
- package/dist/tui/components/prompt-status.js +21 -0
- package/dist/tui/components/select-list.d.ts +22 -0
- package/dist/tui/components/select-list.d.ts.map +1 -0
- package/dist/tui/components/select-list.js +143 -0
- package/dist/tui/components/spacer.d.ts +16 -0
- package/dist/tui/components/spacer.d.ts.map +1 -0
- package/dist/tui/components/spacer.js +27 -0
- package/dist/tui/components/text.d.ts +26 -0
- package/dist/tui/components/text.d.ts.map +1 -0
- package/dist/tui/components/text.js +143 -0
- package/dist/tui/components/thinking-block.d.ts +14 -0
- package/dist/tui/components/thinking-block.d.ts.map +1 -0
- package/dist/tui/components/thinking-block.js +30 -0
- package/dist/tui/components/tool-execution.d.ts +17 -0
- package/dist/tui/components/tool-execution.d.ts.map +1 -0
- package/dist/tui/components/tool-execution.js +153 -0
- package/dist/tui/components/user-message.d.ts +9 -0
- package/dist/tui/components/user-message.d.ts.map +1 -0
- package/dist/tui/components/user-message.js +21 -0
- package/dist/tui/components/welcome.d.ts +6 -0
- package/dist/tui/components/welcome.d.ts.map +1 -0
- package/dist/tui/components/welcome.js +30 -0
- package/dist/tui/index.d.ts +14 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +18 -0
- package/dist/tui/terminal.d.ts +37 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +104 -0
- package/dist/tui/tui.d.ts +67 -0
- package/dist/tui/tui.d.ts.map +1 -0
- package/dist/tui/tui.js +184 -0
- package/dist/tui/utils.d.ts +19 -0
- package/dist/tui/utils.d.ts.map +1 -0
- package/dist/tui/utils.js +31 -0
- package/dist/utils/generators.d.ts +3 -0
- package/dist/utils/generators.d.ts.map +1 -0
- package/dist/utils/generators.js +25 -0
- package/dist/utils/iterables.d.ts +2 -0
- package/dist/utils/iterables.d.ts.map +1 -0
- package/dist/utils/iterables.js +6 -0
- package/package.json +16 -16
- package/dist/conversation-analyzer.d.ts +0 -11
- package/dist/conversation-analyzer.d.ts.map +0 -1
- package/dist/conversation-analyzer.js +0 -88
- package/dist/repl-prompt.d.ts +0 -15
- package/dist/repl-prompt.d.ts.map +0 -1
- package/dist/tokens/manage-output.d.ts +0 -34
- package/dist/tokens/manage-output.d.ts.map +0 -1
- package/dist/tokens/manage-output.js +0 -44
- package/dist/tool-executor.d.ts +0 -28
- package/dist/tool-executor.d.ts.map +0 -1
- package/dist/tool-executor.js +0 -74
- package/dist/tools/file-editing-utils.d.ts +0 -2
- package/dist/tools/file-editing-utils.d.ts.map +0 -1
- package/dist/tools/file-editing-utils.js +0 -135
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TUI implementation with differential rendering
|
|
3
|
+
*/
|
|
4
|
+
import type { Modal } from "./components/modal.ts";
|
|
5
|
+
import type { Terminal } from "./terminal.ts";
|
|
6
|
+
import { visibleWidth } from "./utils.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Component interface - all components must implement this
|
|
9
|
+
*/
|
|
10
|
+
export interface Component {
|
|
11
|
+
/**
|
|
12
|
+
* Render the component to lines for the given viewport width
|
|
13
|
+
* @param width - Current viewport width
|
|
14
|
+
* @returns Array of strings, each representing a line
|
|
15
|
+
*/
|
|
16
|
+
render(width: number): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional handler for keyboard input when component has focus
|
|
19
|
+
*/
|
|
20
|
+
handleInput?(data: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Optional method to get cursor position relative to component
|
|
23
|
+
* Returns [row, col] where row is 0-indexed within component
|
|
24
|
+
* and col is 0-indexed column position
|
|
25
|
+
*/
|
|
26
|
+
getCursorPosition?(): [number, number] | null;
|
|
27
|
+
}
|
|
28
|
+
export { visibleWidth };
|
|
29
|
+
/**
|
|
30
|
+
* Container - a component that contains other components
|
|
31
|
+
*/
|
|
32
|
+
export declare class Container implements Component {
|
|
33
|
+
children: Component[];
|
|
34
|
+
addChild(component: Component): void;
|
|
35
|
+
removeChild(component: Component): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
render(width: number): string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
41
|
+
*/
|
|
42
|
+
export declare class TUI extends Container {
|
|
43
|
+
private terminal;
|
|
44
|
+
private focusedComponent;
|
|
45
|
+
private renderRequested;
|
|
46
|
+
private activeModal;
|
|
47
|
+
constructor(terminal: Terminal);
|
|
48
|
+
setFocus(component: Component | null): void;
|
|
49
|
+
start(): void;
|
|
50
|
+
stop(): void;
|
|
51
|
+
requestRender(): void;
|
|
52
|
+
private handleInput;
|
|
53
|
+
private doRender;
|
|
54
|
+
/**
|
|
55
|
+
* Show a modal dialog
|
|
56
|
+
*/
|
|
57
|
+
showModal(modal: Modal): void;
|
|
58
|
+
/**
|
|
59
|
+
* Hide the active modal
|
|
60
|
+
*/
|
|
61
|
+
hideModal(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Check if a modal is currently active
|
|
64
|
+
*/
|
|
65
|
+
isModalActive(): boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=tui.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../../source/tui/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;OAIG;IACH,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC/C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,qBAAa,SAAU,YAAW,SAAS;IACzC,QAAQ,EAAE,SAAS,EAAE,CAAM;IAE3B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAIpC,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAOvC,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAOhC;AAED;;GAEG;AAGH,qBAAa,GAAI,SAAQ,SAAS;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,gBAAgB,CAA0B;IAClD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAsB;gBAE7B,QAAQ,EAAE,QAAQ;IAK9B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAI3C,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAKZ,aAAa,IAAI,IAAI;IASrB,OAAO,CAAC,WAAW;IAwBnB,OAAO,CAAC,QAAQ;IAmFhB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B;;OAEG;IACH,SAAS,IAAI,IAAI;IAKjB;;OAEG;IACH,aAAa,IAAI,OAAO;CAGzB"}
|
package/dist/tui/tui.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TUI implementation with differential rendering
|
|
3
|
+
*/
|
|
4
|
+
import { getTerminalSize } from "../terminal/formatting.js";
|
|
5
|
+
import style from "../terminal/style.js";
|
|
6
|
+
import { visibleWidth } from "./utils.js";
|
|
7
|
+
export { visibleWidth };
|
|
8
|
+
/**
|
|
9
|
+
* Container - a component that contains other components
|
|
10
|
+
*/
|
|
11
|
+
export class Container {
|
|
12
|
+
children = [];
|
|
13
|
+
addChild(component) {
|
|
14
|
+
this.children.push(component);
|
|
15
|
+
}
|
|
16
|
+
removeChild(component) {
|
|
17
|
+
const index = this.children.indexOf(component);
|
|
18
|
+
if (index !== -1) {
|
|
19
|
+
this.children.splice(index, 1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
clear() {
|
|
23
|
+
this.children = [];
|
|
24
|
+
}
|
|
25
|
+
render(width) {
|
|
26
|
+
const lines = [];
|
|
27
|
+
for (const child of this.children) {
|
|
28
|
+
lines.push(...child.render(width));
|
|
29
|
+
}
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
35
|
+
*/
|
|
36
|
+
// biome-ignore lint/style/useNamingConvention: override
|
|
37
|
+
export class TUI extends Container {
|
|
38
|
+
terminal;
|
|
39
|
+
focusedComponent = null;
|
|
40
|
+
renderRequested = false;
|
|
41
|
+
activeModal = null;
|
|
42
|
+
constructor(terminal) {
|
|
43
|
+
super();
|
|
44
|
+
this.terminal = terminal;
|
|
45
|
+
}
|
|
46
|
+
setFocus(component) {
|
|
47
|
+
this.focusedComponent = component;
|
|
48
|
+
}
|
|
49
|
+
start() {
|
|
50
|
+
this.terminal.start((data) => this.handleInput(data), () => this.requestRender());
|
|
51
|
+
this.terminal.hideCursor();
|
|
52
|
+
this.requestRender();
|
|
53
|
+
}
|
|
54
|
+
stop() {
|
|
55
|
+
this.terminal.showCursor();
|
|
56
|
+
this.terminal.stop();
|
|
57
|
+
}
|
|
58
|
+
requestRender() {
|
|
59
|
+
if (this.renderRequested)
|
|
60
|
+
return;
|
|
61
|
+
this.renderRequested = true;
|
|
62
|
+
process.nextTick(() => {
|
|
63
|
+
this.renderRequested = false;
|
|
64
|
+
this.doRender();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
handleInput(data) {
|
|
68
|
+
// Handle Ctrl+C globally - exit the application
|
|
69
|
+
if (data.charCodeAt(0) === 3) {
|
|
70
|
+
console.log("\nCtrl+C pressed - exiting...");
|
|
71
|
+
this.stop();
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
// Handle Escape key to close modal if one is active
|
|
75
|
+
if (data === "\x1b" && this.activeModal) {
|
|
76
|
+
this.hideModal();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Pass input to active modal first, then focused component
|
|
80
|
+
if (this.activeModal?.handleInput) {
|
|
81
|
+
this.activeModal.handleInput(data);
|
|
82
|
+
this.requestRender();
|
|
83
|
+
}
|
|
84
|
+
else if (this.focusedComponent?.handleInput) {
|
|
85
|
+
this.focusedComponent.handleInput(data);
|
|
86
|
+
this.requestRender();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
doRender() {
|
|
90
|
+
const width = this.terminal.columns;
|
|
91
|
+
// Render all components to get new lines
|
|
92
|
+
const newLines = this.render(width);
|
|
93
|
+
// Always do full re-render for simplicity and reliability
|
|
94
|
+
// This ensures that previous content is properly cleared
|
|
95
|
+
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
|
96
|
+
buffer += "\x1b[3J\x1b[2J\x1b[H"; // Clear scrollback, screen, and home
|
|
97
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
98
|
+
if (i > 0)
|
|
99
|
+
buffer += "\r\n";
|
|
100
|
+
buffer += newLines[i];
|
|
101
|
+
}
|
|
102
|
+
// Render modal on top if active
|
|
103
|
+
if (this.activeModal) {
|
|
104
|
+
const modalLines = this.activeModal.render(width);
|
|
105
|
+
// Render backdrop first if modal has backdrop
|
|
106
|
+
if (this.activeModal.backdrop) {
|
|
107
|
+
const backdropLine = style.bgRgb(0, 0, 0)(" ".repeat(width));
|
|
108
|
+
const { columns } = getTerminalSize(); // 24
|
|
109
|
+
for (let i = 0; i < columns; i++) {
|
|
110
|
+
// Cover entire terminal
|
|
111
|
+
buffer += `\x1b[${i + 1};1H`;
|
|
112
|
+
buffer += backdropLine;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Render modal content
|
|
116
|
+
for (let i = 0; i < modalLines.length; i++) {
|
|
117
|
+
if (modalLines[i]) {
|
|
118
|
+
// Position cursor and overwrite existing content
|
|
119
|
+
buffer += `\x1b[${i + 1};1H`;
|
|
120
|
+
buffer += modalLines[i];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
buffer += "\x1b[?2026l"; // End synchronized output
|
|
125
|
+
this.terminal.write(buffer);
|
|
126
|
+
}
|
|
127
|
+
// private positionCursor(
|
|
128
|
+
// componentCursorPos: [number, number] | null,
|
|
129
|
+
// ): void {
|
|
130
|
+
// if (!componentCursorPos) {
|
|
131
|
+
// // No cursor position from component, hide cursor
|
|
132
|
+
// this.terminal.hideCursor();
|
|
133
|
+
// return;
|
|
134
|
+
// }
|
|
135
|
+
// const [cursorRow, cursorCol] = componentCursorPos;
|
|
136
|
+
//
|
|
137
|
+
// // Calculate absolute cursor position in the terminal
|
|
138
|
+
// // We need to find which line in newLines corresponds to the component's cursor row
|
|
139
|
+
// // and then position the cursor at that line and column
|
|
140
|
+
//
|
|
141
|
+
// // Find the line offset for the focused component
|
|
142
|
+
// let componentStartLine = 0;
|
|
143
|
+
// if (this.focusedComponent) {
|
|
144
|
+
// // Find the line where this component starts by summing heights of previous components
|
|
145
|
+
// for (const child of this.children) {
|
|
146
|
+
// if (child === this.focusedComponent) {
|
|
147
|
+
// break;
|
|
148
|
+
// }
|
|
149
|
+
// // Use the already-rendered lines to calculate height, not re-render
|
|
150
|
+
// const childLines = child.render(this.terminal.columns);
|
|
151
|
+
// componentStartLine += childLines.length;
|
|
152
|
+
// }
|
|
153
|
+
// }
|
|
154
|
+
//
|
|
155
|
+
// const absoluteRow = componentStartLine + cursorRow;
|
|
156
|
+
// const absoluteCol = cursorCol;
|
|
157
|
+
//
|
|
158
|
+
// // Position cursor using absolute positioning
|
|
159
|
+
// // Move to home position first, then move down to row, then right to column
|
|
160
|
+
// // Note: terminal rows/columns are 1-indexed, so we add 1
|
|
161
|
+
// this.terminal.write(`\x1b[H\x1b[${absoluteRow + 1}B\x1b[${absoluteCol + 1}G`);
|
|
162
|
+
// this.terminal.showCursor();
|
|
163
|
+
// }
|
|
164
|
+
/**
|
|
165
|
+
* Show a modal dialog
|
|
166
|
+
*/
|
|
167
|
+
showModal(modal) {
|
|
168
|
+
this.activeModal = modal;
|
|
169
|
+
this.requestRender();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Hide the active modal
|
|
173
|
+
*/
|
|
174
|
+
hideModal() {
|
|
175
|
+
this.activeModal = null;
|
|
176
|
+
this.requestRender();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Check if a modal is currently active
|
|
180
|
+
*/
|
|
181
|
+
isModalActive() {
|
|
182
|
+
return this.activeModal !== null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the visible width of a string in terminal columns.
|
|
3
|
+
* This correctly handles:
|
|
4
|
+
* - ANSI escape codes (ignored)
|
|
5
|
+
* - Emojis and wide characters (counted as 2 columns)
|
|
6
|
+
* - Combining characters (counted correctly)
|
|
7
|
+
* - Tabs (replaced with 3 spaces for consistent width)
|
|
8
|
+
*/
|
|
9
|
+
export declare function visibleWidth(str: string): number;
|
|
10
|
+
/**
|
|
11
|
+
* Apply background color to a line, padding to full width.
|
|
12
|
+
*
|
|
13
|
+
* @param line - Line of text (may contain ANSI codes)
|
|
14
|
+
* @param width - Total width to pad to
|
|
15
|
+
* @param bgFn - Background color function
|
|
16
|
+
* @returns Line with background applied and padded to width
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
|
|
19
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../source/tui/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIhD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC7B,MAAM,CASR"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import stringWidth from "string-width";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate the visible width of a string in terminal columns.
|
|
4
|
+
* This correctly handles:
|
|
5
|
+
* - ANSI escape codes (ignored)
|
|
6
|
+
* - Emojis and wide characters (counted as 2 columns)
|
|
7
|
+
* - Combining characters (counted correctly)
|
|
8
|
+
* - Tabs (replaced with 3 spaces for consistent width)
|
|
9
|
+
*/
|
|
10
|
+
export function visibleWidth(str) {
|
|
11
|
+
// Replace tabs with 3 spaces before measuring
|
|
12
|
+
const normalized = str.replace(/\t/g, " ");
|
|
13
|
+
return stringWidth(normalized);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Apply background color to a line, padding to full width.
|
|
17
|
+
*
|
|
18
|
+
* @param line - Line of text (may contain ANSI codes)
|
|
19
|
+
* @param width - Total width to pad to
|
|
20
|
+
* @param bgFn - Background color function
|
|
21
|
+
* @returns Line with background applied and padded to width
|
|
22
|
+
*/
|
|
23
|
+
export function applyBackgroundToLine(line, width, bgFn) {
|
|
24
|
+
// Calculate padding needed
|
|
25
|
+
const visibleLen = visibleWidth(line);
|
|
26
|
+
const paddingNeeded = Math.max(0, width - visibleLen);
|
|
27
|
+
const padding = " ".repeat(paddingNeeded);
|
|
28
|
+
// Apply background to content + padding
|
|
29
|
+
const withPadding = line + padding;
|
|
30
|
+
return bgFn(withPadding);
|
|
31
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function exhaustGenerator<T, TReturn, TNext>(generator: Generator<T, TReturn, TNext>): TReturn;
|
|
2
|
+
export declare function exhaustGenerator<T, TReturn, TNext>(generator: AsyncGenerator<T, TReturn, TNext>): Promise<TReturn>;
|
|
3
|
+
//# sourceMappingURL=generators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../source/utils/generators.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAChD,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GACtC,OAAO,CAAC;AAGX,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAChD,SAAS,EAAE,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAC3C,OAAO,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function isPromiseLike(value) {
|
|
2
|
+
return (typeof value === "object" &&
|
|
3
|
+
value !== null &&
|
|
4
|
+
typeof value.then === "function");
|
|
5
|
+
}
|
|
6
|
+
// biome-ignore lint/style/useNamingConvention: temp
|
|
7
|
+
export function exhaustGenerator(generator) {
|
|
8
|
+
const firstResult = generator.next();
|
|
9
|
+
if (isPromiseLike(firstResult)) {
|
|
10
|
+
const asyncGenerator = generator;
|
|
11
|
+
return (async () => {
|
|
12
|
+
let result = await firstResult;
|
|
13
|
+
while (!result.done) {
|
|
14
|
+
result = await asyncGenerator.next();
|
|
15
|
+
}
|
|
16
|
+
return result.value;
|
|
17
|
+
})();
|
|
18
|
+
}
|
|
19
|
+
const syncGenerator = generator;
|
|
20
|
+
let result = firstResult;
|
|
21
|
+
while (!result.done) {
|
|
22
|
+
result = syncGenerator.next();
|
|
23
|
+
}
|
|
24
|
+
return result.value;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterables.d.ts","sourceRoot":"","sources":["../../source/utils/iterables.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAQ5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travisennis/acai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "An AI assistant for developing software.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,16 +48,16 @@
|
|
|
48
48
|
"typecheck:staged": "npm run typecheck"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ai-sdk/anthropic": "^2.0.
|
|
52
|
-
"@ai-sdk/deepseek": "^1.0.
|
|
53
|
-
"@ai-sdk/google": "^2.0.
|
|
54
|
-
"@ai-sdk/groq": "^2.0.
|
|
55
|
-
"@ai-sdk/openai": "^2.0.
|
|
56
|
-
"@ai-sdk/openai-compatible": "^1.0.
|
|
51
|
+
"@ai-sdk/anthropic": "^2.0.47",
|
|
52
|
+
"@ai-sdk/deepseek": "^1.0.29",
|
|
53
|
+
"@ai-sdk/google": "^2.0.43",
|
|
54
|
+
"@ai-sdk/groq": "^2.0.31",
|
|
55
|
+
"@ai-sdk/openai": "^2.0.72",
|
|
56
|
+
"@ai-sdk/openai-compatible": "^1.0.27",
|
|
57
57
|
"@crosscopy/clipboard": "^0.2.8",
|
|
58
|
-
"@openrouter/ai-sdk-provider": "^1.2.
|
|
58
|
+
"@openrouter/ai-sdk-provider": "^1.2.5",
|
|
59
59
|
"@travisennis/stdlib": "^0.0.14",
|
|
60
|
-
"ai": "^5.0.
|
|
60
|
+
"ai": "^5.0.101",
|
|
61
61
|
"cheerio": "^1.1.2",
|
|
62
62
|
"cli-table3": "^0.6.5",
|
|
63
63
|
"diff": "^8.0.2",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"fast-glob": "^3.3.3",
|
|
66
66
|
"highlight.js": "^11.11.1",
|
|
67
67
|
"jsonrepair": "^3.13.1",
|
|
68
|
-
"marked": "
|
|
69
|
-
"p-throttle": "^8.
|
|
68
|
+
"marked": "17.0.1",
|
|
69
|
+
"p-throttle": "^8.1.0",
|
|
70
70
|
"parse5": "^8.0.0",
|
|
71
71
|
"parse5-htmlparser2-tree-adapter": "^8.0.0",
|
|
72
|
-
"pino": "^10.
|
|
73
|
-
"pino-pretty": "^13.1.
|
|
72
|
+
"pino": "^10.1.0",
|
|
73
|
+
"pino-pretty": "^13.1.2",
|
|
74
74
|
"pino-roll": "^4.0.0",
|
|
75
75
|
"tiktoken": "^1.0.22",
|
|
76
|
-
"zod": "^4.1.
|
|
76
|
+
"zod": "^4.1.13"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@ai-sdk/provider": "^2.0.0",
|
|
80
|
-
"@biomejs/biome": "2.
|
|
80
|
+
"@biomejs/biome": "2.3.7",
|
|
81
81
|
"@commitlint/config-conventional": "^20.0.0",
|
|
82
|
-
"@types/node": "^24.
|
|
82
|
+
"@types/node": "^24.10.1",
|
|
83
83
|
"c8": "^10.1.3",
|
|
84
84
|
"commitlint": "^20.1.0",
|
|
85
85
|
"domhandler": "^5.0.3",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type ModelMessage } from "ai";
|
|
2
|
-
import type { ModelManager } from "./models/manager.ts";
|
|
3
|
-
import type { Terminal } from "./terminal/index.ts";
|
|
4
|
-
import type { TokenTracker } from "./tokens/tracker.ts";
|
|
5
|
-
export declare function analyzeConversation({ modelManager, messages, tokenTracker, }: {
|
|
6
|
-
modelManager: ModelManager;
|
|
7
|
-
messages: ModelMessage[];
|
|
8
|
-
terminal?: Terminal | undefined;
|
|
9
|
-
tokenTracker: TokenTracker;
|
|
10
|
-
}): Promise<string[]>;
|
|
11
|
-
//# sourceMappingURL=conversation-analyzer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-analyzer.d.ts","sourceRoot":"","sources":["../source/conversation-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,IAAI,CAAC;AAGrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAyCxD,wBAAsB,mBAAmB,CAAC,EACxC,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,EAAE;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA0DpB"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { generateText } from "ai";
|
|
2
|
-
import { config } from "./config.js";
|
|
3
|
-
import { createUserMessage } from "./messages.js";
|
|
4
|
-
import { systemPrompt } from "./prompts.js";
|
|
5
|
-
// Modified System Prompt
|
|
6
|
-
const system = async () => `You are an expert analyst reviewing conversations between a coding agent and a software engineer. Your goal is to identify instances where the engineer corrected the agent's approach or understanding in a way that reveals a *generalizable principle* for improving the agent's future behavior across *different* tasks.
|
|
7
|
-
|
|
8
|
-
**Your Task:**
|
|
9
|
-
1. Analyze the conversation provided.
|
|
10
|
-
2. Identify significant corrections or redirections from the engineer. Ignore minor clarifications or task-specific adjustments.
|
|
11
|
-
3. For each significant correction, infer a *single, concise, broadly applicable, actionable rule* (starting with 'Always' or 'Never') that captures the underlying principle the agent should follow in the future.
|
|
12
|
-
4. Ensure the rule is general enough to be useful in various scenarios, not just the specific context of this conversation.
|
|
13
|
-
5. Provide a brief, illustrative quote or example from the conversation in parentheses after the rule.
|
|
14
|
-
6. List only the inferred rules in Markdown bullet points. Do not include explanations, summaries, or conversational filler.
|
|
15
|
-
|
|
16
|
-
**Crucially, AVOID generating rules that are:**
|
|
17
|
-
- Overly specific to the files, functions, or variables discussed (e.g., "Always check for null in the 'processUserData' function"). Instead, generalize (e.g., "Always validate data from external sources before processing").
|
|
18
|
-
- Merely restatements of the task requirements.
|
|
19
|
-
- Too narrow to be useful outside the immediate context.
|
|
20
|
-
- Related to minor typos or formatting preferences unless they represent a consistent pattern requested by the user.
|
|
21
|
-
|
|
22
|
-
**Good General Rule Examples:**
|
|
23
|
-
<examples>
|
|
24
|
-
- Always ask for clarification if the user's request is ambiguous.
|
|
25
|
-
- Never make assumptions about file paths without confirmation.
|
|
26
|
-
- Always follow the user's explicitly stated formatting preferences.
|
|
27
|
-
- Never provide incomplete code snippets without indicating they are partial.
|
|
28
|
-
- Always check for potential null or undefined values before accessing properties.
|
|
29
|
-
</examples>
|
|
30
|
-
|
|
31
|
-
**Bad Specific Rule Examples (Avoid These):**
|
|
32
|
-
<bad-examples>
|
|
33
|
-
- Always use 'const' instead of 'let' for the 'userId' variable in 'auth.ts'.
|
|
34
|
-
- Never forget to pass the 'config' object to the 'initializeDb' function.
|
|
35
|
-
- Always add a try-catch block around the 'api.fetchData()' call in 'dataService.ts'.
|
|
36
|
-
</bad-examples>
|
|
37
|
-
|
|
38
|
-
This is the original system prompt the agent operated under:
|
|
39
|
-
<systemPrompt>
|
|
40
|
-
${await systemPrompt()}
|
|
41
|
-
</systemPrompt>`;
|
|
42
|
-
export async function analyzeConversation({ modelManager, messages, tokenTracker, }) {
|
|
43
|
-
const learnedRules = await config.readCachedLearnedRulesFile();
|
|
44
|
-
// Modified User Message within analyzeConversation
|
|
45
|
-
messages.push(createUserMessage([
|
|
46
|
-
`Analyze this conversation based on the system instructions. Identify points where the user made significant corrections revealing general principles for agent improvement. Infer concise, broadly applicable rules (Always/Never) based *only* on these corrections.
|
|
47
|
-
|
|
48
|
-
**Key Requirements:**
|
|
49
|
-
- Focus on *generalizable* rules applicable to future, different tasks.
|
|
50
|
-
- Avoid rules tied to the specifics of *this* conversation.
|
|
51
|
-
- Ensure rules don't already exist in <existing-rules>.
|
|
52
|
-
- If no *new, general* rules can be inferred, return an empty list or response.
|
|
53
|
-
- Return *only* the Markdown list of rules, with no preamble or explanation.
|
|
54
|
-
|
|
55
|
-
<existing-rules>
|
|
56
|
-
${learnedRules}
|
|
57
|
-
</existing-rules>`,
|
|
58
|
-
]));
|
|
59
|
-
const { text, usage } = await generateText({
|
|
60
|
-
model: modelManager.getModel("conversation-analyzer"),
|
|
61
|
-
maxOutputTokens: 8192,
|
|
62
|
-
system: await system(),
|
|
63
|
-
messages: messages,
|
|
64
|
-
});
|
|
65
|
-
tokenTracker.trackUsage("conversation-analyzer", usage);
|
|
66
|
-
// Trim whitespace and check if the response is effectively empty or just whitespace
|
|
67
|
-
const potentialRulesText = text.trim();
|
|
68
|
-
// Basic check to prevent adding empty lines or just formatting
|
|
69
|
-
if (!potentialRulesText || potentialRulesText.length === 0) {
|
|
70
|
-
return []; // Return empty array if no valid rules generated
|
|
71
|
-
}
|
|
72
|
-
// Split into individual rules, filter out empty lines
|
|
73
|
-
const potentialRulesList = potentialRulesText
|
|
74
|
-
.split("\n")
|
|
75
|
-
.map((rule) => rule.trim())
|
|
76
|
-
.filter((rule) => rule.length > 0);
|
|
77
|
-
if (potentialRulesList.length === 0) {
|
|
78
|
-
return []; // Return empty array if splitting results in no rules
|
|
79
|
-
}
|
|
80
|
-
// Further validation could be added here (e.g., check if it starts with '- ', etc.)
|
|
81
|
-
// before writing to the file.
|
|
82
|
-
// Append only if there are non-empty potential rules
|
|
83
|
-
const updatedRules = learnedRules.endsWith("\n") || learnedRules.length === 0
|
|
84
|
-
? `${learnedRules}${potentialRulesList.join("\n")}`
|
|
85
|
-
: `${learnedRules}\n${potentialRulesList.join("\n")}`;
|
|
86
|
-
await config.writeCachedLearnedRulesFile(updatedRules);
|
|
87
|
-
return potentialRulesList; // Return the list of rules that were added
|
|
88
|
-
}
|
package/dist/repl-prompt.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CommandManager } from "./commands/manager.ts";
|
|
2
|
-
export declare class ReplPrompt {
|
|
3
|
-
private keypressListener?;
|
|
4
|
-
private rl;
|
|
5
|
-
private history;
|
|
6
|
-
private maxHistory;
|
|
7
|
-
constructor({ commands, history, }: {
|
|
8
|
-
commands: CommandManager;
|
|
9
|
-
history: string[];
|
|
10
|
-
});
|
|
11
|
-
input(): Promise<string>;
|
|
12
|
-
close(): void;
|
|
13
|
-
[Symbol.dispose](): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=repl-prompt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"repl-prompt.d.ts","sourceRoot":"","sources":["../source/repl-prompt.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAyD5D,qBAAa,UAAU;IAErB,OAAO,CAAC,gBAAgB,CAAC,CAAkC;IAC3D,OAAO,CAAC,EAAE,CAAY;IACtB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,UAAU,CAAM;gBAEZ,EACV,QAAQ,EACR,OAAO,GACR,EAAE;QAAE,QAAQ,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IA4F5C,KAAK;IAoBX,KAAK;IAQL,CAAC,MAAM,CAAC,OAAO,CAAC;CAGjB"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { TokenCounter } from "./counter.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Interface for options when managing output
|
|
4
|
-
*/
|
|
5
|
-
interface ManageOutputOptions {
|
|
6
|
-
tokenCounter: TokenCounter;
|
|
7
|
-
threshold?: number;
|
|
8
|
-
truncate?: boolean;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Interface for the result of managing output
|
|
12
|
-
*/
|
|
13
|
-
interface TruncatedOutput {
|
|
14
|
-
content: string;
|
|
15
|
-
tokenCount: number;
|
|
16
|
-
truncated: true;
|
|
17
|
-
warning: string;
|
|
18
|
-
}
|
|
19
|
-
interface Output {
|
|
20
|
-
content: string;
|
|
21
|
-
tokenCount: number;
|
|
22
|
-
truncated: false;
|
|
23
|
-
warning?: string;
|
|
24
|
-
}
|
|
25
|
-
type ManagedOutput = Output | TruncatedOutput;
|
|
26
|
-
/**
|
|
27
|
-
* Manages output by counting tokens and optionally truncating if over threshold.
|
|
28
|
-
* @param input - The input string to manage
|
|
29
|
-
* @param options - Configuration for management
|
|
30
|
-
* @returns Managed output details
|
|
31
|
-
*/
|
|
32
|
-
export declare function manageOutput(input: string, options: ManageOutputOptions): ManagedOutput;
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=manage-output.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manage-output.d.ts","sourceRoot":"","sources":["../../source/tokens/manage-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,MAAM;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,aAAa,GAAG,MAAM,GAAG,eAAe,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,GAC3B,aAAa,CA2Cf"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages output by counting tokens and optionally truncating if over threshold.
|
|
3
|
-
* @param input - The input string to manage
|
|
4
|
-
* @param options - Configuration for management
|
|
5
|
-
* @returns Managed output details
|
|
6
|
-
*/
|
|
7
|
-
export function manageOutput(input, options) {
|
|
8
|
-
const { threshold = 8000, truncate = true } = options;
|
|
9
|
-
if (!input) {
|
|
10
|
-
return { content: input, tokenCount: 0, truncated: false };
|
|
11
|
-
}
|
|
12
|
-
let tokenCount;
|
|
13
|
-
try {
|
|
14
|
-
tokenCount = options.tokenCounter.count(input);
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
console.warn(`Token counting failed: ${error}. Using fallback.`);
|
|
18
|
-
// Fallback: Rough estimate (4 chars ~1 token)
|
|
19
|
-
tokenCount = Math.ceil(input.length / 4);
|
|
20
|
-
}
|
|
21
|
-
if (tokenCount <= threshold) {
|
|
22
|
-
return { content: input, tokenCount, truncated: false };
|
|
23
|
-
}
|
|
24
|
-
const _exceededBy = tokenCount - threshold;
|
|
25
|
-
let truncatedContent = input;
|
|
26
|
-
let truncated = false;
|
|
27
|
-
if (truncate) {
|
|
28
|
-
// Simple truncation: Cut to approx threshold tokens, add ellipsis
|
|
29
|
-
// For better UX, could be smarter (e.g., by lines for grep, preserve JSON)
|
|
30
|
-
// But keep general for now
|
|
31
|
-
const targetLength = threshold * 4; // Rough char estimate
|
|
32
|
-
truncatedContent = `${input.slice(0, targetLength)}\n\n[Output truncated at ~${threshold} tokens (${_exceededBy} tokens omitted)]`;
|
|
33
|
-
truncated = true;
|
|
34
|
-
}
|
|
35
|
-
const warning = truncated
|
|
36
|
-
? `Warning: Output exceeds token threshold (${threshold}). Tokens: ${tokenCount}. ${truncate ? "Truncated." : "Full output returned—consider summarizing."}`
|
|
37
|
-
: undefined;
|
|
38
|
-
return {
|
|
39
|
-
content: truncatedContent,
|
|
40
|
-
tokenCount,
|
|
41
|
-
truncated,
|
|
42
|
-
warning,
|
|
43
|
-
};
|
|
44
|
-
}
|
package/dist/tool-executor.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
interface AskContext {
|
|
2
|
-
toolName: string;
|
|
3
|
-
toolCallId: string;
|
|
4
|
-
message: string;
|
|
5
|
-
choices: {
|
|
6
|
-
accept: string;
|
|
7
|
-
acceptAll: string;
|
|
8
|
-
reject: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export type AskResponse = {
|
|
12
|
-
result: "accept" | "accept-all";
|
|
13
|
-
reason?: string;
|
|
14
|
-
} | {
|
|
15
|
-
result: "reject";
|
|
16
|
-
reason: string;
|
|
17
|
-
};
|
|
18
|
-
export declare class ToolExecutor {
|
|
19
|
-
private autoAcceptAll;
|
|
20
|
-
private autoAcceptMap;
|
|
21
|
-
constructor(autoAcceptAll: boolean);
|
|
22
|
-
autoAccept(toolName: string): boolean;
|
|
23
|
-
ask(ctx: AskContext, { abortSignal }: {
|
|
24
|
-
abortSignal?: AbortSignal;
|
|
25
|
-
}): Promise<AskResponse>;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=tool-executor.d.ts.map
|