lonny-agent 0.2.4 → 0.2.7
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/.github/workflows/ci.yml +21 -0
- package/AGENTS.md +106 -0
- package/CHANGELOG.md +24 -0
- package/README.md +326 -326
- package/dist/agent/__tests__/session-restore.test.d.ts +2 -0
- package/dist/agent/__tests__/session-restore.test.d.ts.map +1 -0
- package/dist/agent/__tests__/session-restore.test.js +260 -0
- package/dist/agent/__tests__/session-restore.test.js.map +1 -0
- package/dist/agent/commands.d.ts +26 -0
- package/dist/agent/commands.d.ts.map +1 -0
- package/dist/agent/commands.js +253 -0
- package/dist/agent/commands.js.map +1 -0
- package/dist/agent/compaction.js +8 -1
- package/dist/agent/compaction.js.map +1 -1
- package/dist/agent/index.d.ts +2 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llm.d.ts +4 -0
- package/dist/agent/llm.d.ts.map +1 -1
- package/dist/agent/memory.d.ts +12 -0
- package/dist/agent/memory.d.ts.map +1 -0
- package/dist/agent/memory.js +51 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/prompt-builder.d.ts +6 -1
- package/dist/agent/prompt-builder.d.ts.map +1 -1
- package/dist/agent/prompt-builder.js +100 -33
- package/dist/agent/prompt-builder.js.map +1 -1
- package/dist/agent/providers/google.d.ts.map +1 -1
- package/dist/agent/providers/google.js.map +1 -1
- package/dist/agent/providers/openai.d.ts +1 -0
- package/dist/agent/providers/openai.d.ts.map +1 -1
- package/dist/agent/providers/openai.js +59 -6
- package/dist/agent/providers/openai.js.map +1 -1
- package/dist/agent/session-chat.d.ts +3 -0
- package/dist/agent/session-chat.d.ts.map +1 -0
- package/dist/agent/session-chat.js +384 -0
- package/dist/agent/session-chat.js.map +1 -0
- package/dist/agent/session-display.d.ts +29 -0
- package/dist/agent/session-display.d.ts.map +1 -0
- package/dist/agent/session-display.js +179 -0
- package/dist/agent/session-display.js.map +1 -0
- package/dist/agent/session-persistence.d.ts +55 -0
- package/dist/agent/session-persistence.d.ts.map +1 -0
- package/dist/agent/session-persistence.js +101 -0
- package/dist/agent/session-persistence.js.map +1 -0
- package/dist/agent/session-utils.d.ts +5 -0
- package/dist/agent/session-utils.d.ts.map +1 -0
- package/dist/agent/session-utils.js +51 -0
- package/dist/agent/session-utils.js.map +1 -0
- package/dist/agent/session.d.ts +19 -17
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +234 -578
- package/dist/agent/session.js.map +1 -1
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +67 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +7 -1
- package/dist/config/index.js.map +1 -1
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/__tests__/bash.test.js +169 -2
- package/dist/tools/__tests__/bash.test.js.map +1 -1
- package/dist/tools/__tests__/edit.test.js +1091 -340
- package/dist/tools/__tests__/edit.test.js.map +1 -1
- package/dist/tools/__tests__/fetch.test.js +1 -1
- package/dist/tools/__tests__/fetch.test.js.map +1 -1
- package/dist/tools/__tests__/glob.test.js +1 -1
- package/dist/tools/__tests__/glob.test.js.map +1 -1
- package/dist/tools/__tests__/grep.test.js +33 -1
- package/dist/tools/__tests__/grep.test.js.map +1 -1
- package/dist/tools/__tests__/ls.test.js +1 -1
- package/dist/tools/__tests__/ls.test.js.map +1 -1
- package/dist/tools/__tests__/read.test.js +1 -1
- package/dist/tools/__tests__/read.test.js.map +1 -1
- package/dist/tools/__tests__/registry.test.js +313 -0
- package/dist/tools/__tests__/registry.test.js.map +1 -1
- package/dist/tools/__tests__/sed.test.d.ts +2 -0
- package/dist/tools/__tests__/sed.test.d.ts.map +1 -0
- package/dist/tools/__tests__/sed.test.js +228 -0
- package/dist/tools/__tests__/sed.test.js.map +1 -0
- package/dist/tools/__tests__/write_plan.test.js +1 -1
- package/dist/tools/__tests__/write_plan.test.js.map +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +711 -18
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/codebase/ast/__tests__/ast-edit-demo.d.ts +2 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-demo.d.ts.map +1 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-demo.js +7 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-demo.js.map +1 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-final.d.ts +6 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-final.d.ts.map +1 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-final.js +11 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-final.js.map +1 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-test.d.ts +2 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-test.d.ts.map +1 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-test.js +9 -0
- package/dist/tools/codebase/ast/__tests__/ast-edit-test.js.map +1 -0
- package/dist/tools/codebase/ast/__tests__/integration.test.d.ts +2 -0
- package/dist/tools/codebase/ast/__tests__/integration.test.d.ts.map +1 -0
- package/dist/tools/codebase/ast/__tests__/integration.test.js +415 -0
- package/dist/tools/codebase/ast/__tests__/integration.test.js.map +1 -0
- package/dist/tools/codebase/ast/__tests__/tree-sitter.test.d.ts +2 -0
- package/dist/tools/codebase/ast/__tests__/tree-sitter.test.d.ts.map +1 -0
- package/dist/tools/codebase/ast/__tests__/tree-sitter.test.js +414 -0
- package/dist/tools/codebase/ast/__tests__/tree-sitter.test.js.map +1 -0
- package/dist/tools/codebase/ast/adapter.d.ts +23 -0
- package/dist/tools/codebase/ast/adapter.d.ts.map +1 -0
- package/dist/tools/codebase/ast/adapter.js +11 -0
- package/dist/tools/codebase/ast/adapter.js.map +1 -0
- package/dist/tools/codebase/ast/tools.d.ts +3 -0
- package/dist/tools/codebase/ast/tools.d.ts.map +1 -0
- package/dist/tools/codebase/ast/tools.js +286 -0
- package/dist/tools/codebase/ast/tools.js.map +1 -0
- package/dist/tools/codebase/ast/tree-sitter-adapter.d.ts +3 -0
- package/dist/tools/codebase/ast/tree-sitter-adapter.d.ts.map +1 -0
- package/dist/tools/codebase/ast/tree-sitter-adapter.js +412 -0
- package/dist/tools/codebase/ast/tree-sitter-adapter.js.map +1 -0
- package/dist/tools/codebase/ast/tree-sitter-converters.d.ts +4 -0
- package/dist/tools/codebase/ast/tree-sitter-converters.d.ts.map +1 -0
- package/dist/tools/codebase/ast/tree-sitter-converters.js +447 -0
- package/dist/tools/codebase/ast/tree-sitter-converters.js.map +1 -0
- package/dist/tools/codebase/ast/types.d.ts +103 -0
- package/dist/tools/codebase/ast/types.d.ts.map +1 -0
- package/dist/tools/codebase/ast/types.js +2 -0
- package/dist/tools/codebase/ast/types.js.map +1 -0
- package/dist/tools/codebase/ast/wasm/tree-sitter-python.wasm +0 -0
- package/dist/tools/codebase/ast/wasm/tree-sitter-tsx.wasm +0 -0
- package/dist/tools/codebase/ast/wasm/tree-sitter-typescript.wasm +0 -0
- package/dist/tools/codebase/ast/wasm/tree-sitter.wasm +0 -0
- package/dist/tools/codebase/ast/wasm/web-tree-sitter.wasm +0 -0
- package/dist/tools/codebase/find.d.ts +3 -0
- package/dist/tools/codebase/find.d.ts.map +1 -0
- package/dist/tools/codebase/find.js +61 -0
- package/dist/tools/codebase/find.js.map +1 -0
- package/dist/tools/codebase/glob.d.ts +3 -0
- package/dist/tools/codebase/glob.d.ts.map +1 -0
- package/dist/tools/codebase/glob.js +37 -0
- package/dist/tools/codebase/glob.js.map +1 -0
- package/dist/tools/codebase/grep.d.ts +3 -0
- package/dist/tools/codebase/grep.d.ts.map +1 -0
- package/dist/tools/codebase/grep.js +169 -0
- package/dist/tools/codebase/grep.js.map +1 -0
- package/dist/tools/codebase/ls.d.ts +3 -0
- package/dist/tools/codebase/ls.d.ts.map +1 -0
- package/dist/tools/codebase/ls.js +39 -0
- package/dist/tools/codebase/ls.js.map +1 -0
- package/dist/tools/codebase/read.d.ts +10 -0
- package/dist/tools/codebase/read.d.ts.map +1 -0
- package/dist/tools/codebase/read.js +81 -0
- package/dist/tools/codebase/read.js.map +1 -0
- package/dist/tools/delete_memory.d.ts +3 -0
- package/dist/tools/delete_memory.d.ts.map +1 -0
- package/dist/tools/delete_memory.js +46 -0
- package/dist/tools/delete_memory.js.map +1 -0
- package/dist/tools/edit/diff-compute.d.ts +4 -0
- package/dist/tools/edit/diff-compute.d.ts.map +1 -0
- package/dist/tools/edit/diff-compute.js +18 -0
- package/dist/tools/edit/diff-compute.js.map +1 -0
- package/dist/tools/edit/diff-render.d.ts +18 -0
- package/dist/tools/edit/diff-render.d.ts.map +1 -0
- package/dist/tools/edit/diff-render.js +128 -0
- package/dist/tools/edit/diff-render.js.map +1 -0
- package/dist/tools/edit/edit.d.ts +4 -0
- package/dist/tools/edit/edit.d.ts.map +1 -0
- package/dist/tools/edit/edit.js +440 -0
- package/dist/tools/edit/edit.js.map +1 -0
- package/dist/tools/edit/matcher.d.ts +24 -0
- package/dist/tools/edit/matcher.d.ts.map +1 -0
- package/dist/tools/edit/matcher.js +66 -0
- package/dist/tools/edit/matcher.js.map +1 -0
- package/dist/tools/edit/parser.d.ts +10 -0
- package/dist/tools/edit/parser.d.ts.map +1 -0
- package/dist/tools/edit/parser.js +120 -0
- package/dist/tools/edit/parser.js.map +1 -0
- package/dist/tools/edit/types.d.ts +16 -0
- package/dist/tools/edit/types.d.ts.map +1 -0
- package/dist/tools/edit/types.js +2 -0
- package/dist/tools/edit/types.js.map +1 -0
- package/dist/tools/edit/write_plan.d.ts +5 -0
- package/dist/tools/edit/write_plan.d.ts.map +1 -0
- package/dist/tools/edit/write_plan.js +98 -0
- package/dist/tools/edit/write_plan.js.map +1 -0
- package/dist/tools/edit.d.ts +50 -9
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +394 -159
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/execute/bash/constants.d.ts +24 -0
- package/dist/tools/execute/bash/constants.d.ts.map +1 -0
- package/dist/tools/execute/bash/constants.js +88 -0
- package/dist/tools/execute/bash/constants.js.map +1 -0
- package/dist/tools/execute/bash/errors.d.ts +39 -0
- package/dist/tools/execute/bash/errors.d.ts.map +1 -0
- package/dist/tools/execute/bash/errors.js +249 -0
- package/dist/tools/execute/bash/errors.js.map +1 -0
- package/dist/tools/execute/bash/execution.d.ts +18 -0
- package/dist/tools/execute/bash/execution.d.ts.map +1 -0
- package/dist/tools/execute/bash/execution.js +207 -0
- package/dist/tools/execute/bash/execution.js.map +1 -0
- package/dist/tools/execute/bash/index.d.ts +3 -0
- package/dist/tools/execute/bash/index.d.ts.map +1 -0
- package/dist/tools/execute/bash/index.js +117 -0
- package/dist/tools/execute/bash/index.js.map +1 -0
- package/dist/tools/execute/bash/platform.d.ts +6 -0
- package/dist/tools/execute/bash/platform.d.ts.map +1 -0
- package/dist/tools/execute/bash/platform.js +64 -0
- package/dist/tools/execute/bash/platform.js.map +1 -0
- package/dist/tools/execute/bash/security.d.ts +12 -0
- package/dist/tools/execute/bash/security.d.ts.map +1 -0
- package/dist/tools/execute/bash/security.js +26 -0
- package/dist/tools/execute/bash/security.js.map +1 -0
- package/dist/tools/execute/bash/validation.d.ts +16 -0
- package/dist/tools/execute/bash/validation.d.ts.map +1 -0
- package/dist/tools/execute/bash/validation.js +57 -0
- package/dist/tools/execute/bash/validation.js.map +1 -0
- package/dist/tools/execute/bash.d.ts +3 -0
- package/dist/tools/execute/bash.d.ts.map +1 -0
- package/dist/tools/execute/bash.js +728 -0
- package/dist/tools/execute/bash.js.map +1 -0
- package/dist/tools/execute/git.d.ts +3 -0
- package/dist/tools/execute/git.d.ts.map +1 -0
- package/dist/tools/execute/git.js +183 -0
- package/dist/tools/execute/git.js.map +1 -0
- package/dist/tools/execute/task_complete.d.ts +7 -0
- package/dist/tools/execute/task_complete.d.ts.map +1 -0
- package/dist/tools/execute/task_complete.js +38 -0
- package/dist/tools/execute/task_complete.js.map +1 -0
- package/dist/tools/fetch.d.ts.map +1 -1
- package/dist/tools/fetch.js +2 -0
- package/dist/tools/fetch.js.map +1 -1
- package/dist/tools/find.d.ts.map +1 -1
- package/dist/tools/find.js +2 -0
- package/dist/tools/find.js.map +1 -1
- package/dist/tools/git.d.ts.map +1 -1
- package/dist/tools/git.js +2 -0
- package/dist/tools/git.js.map +1 -1
- package/dist/tools/glob.d.ts.map +1 -1
- package/dist/tools/glob.js +2 -0
- package/dist/tools/glob.js.map +1 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +56 -30
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/install/clawhub.d.ts +26 -0
- package/dist/tools/install/clawhub.d.ts.map +1 -0
- package/dist/tools/install/clawhub.js +182 -0
- package/dist/tools/install/clawhub.js.map +1 -0
- package/dist/tools/install/constants.d.ts +5 -0
- package/dist/tools/install/constants.d.ts.map +1 -0
- package/dist/tools/install/constants.js +5 -0
- package/dist/tools/install/constants.js.map +1 -0
- package/dist/tools/install/install_skill.d.ts +3 -0
- package/dist/tools/install/install_skill.d.ts.map +1 -0
- package/dist/tools/install/install_skill.js +132 -0
- package/dist/tools/install/install_skill.js.map +1 -0
- package/dist/tools/install/npm.d.ts +8 -0
- package/dist/tools/install/npm.d.ts.map +1 -0
- package/dist/tools/install/npm.js +52 -0
- package/dist/tools/install/npm.js.map +1 -0
- package/dist/tools/install/skill-content.d.ts +9 -0
- package/dist/tools/install/skill-content.d.ts.map +1 -0
- package/dist/tools/install/skill-content.js +89 -0
- package/dist/tools/install/skill-content.js.map +1 -0
- package/dist/tools/install_skill.d.ts.map +1 -1
- package/dist/tools/install_skill.js +2 -0
- package/dist/tools/install_skill.js.map +1 -1
- package/dist/tools/list_memory.d.ts +3 -0
- package/dist/tools/list_memory.d.ts.map +1 -0
- package/dist/tools/list_memory.js +55 -0
- package/dist/tools/list_memory.js.map +1 -0
- package/dist/tools/ls.d.ts.map +1 -1
- package/dist/tools/ls.js +2 -0
- package/dist/tools/ls.js.map +1 -1
- package/dist/tools/memory/delete_memory.d.ts +3 -0
- package/dist/tools/memory/delete_memory.d.ts.map +1 -0
- package/dist/tools/memory/delete_memory.js +46 -0
- package/dist/tools/memory/delete_memory.js.map +1 -0
- package/dist/tools/memory/list_memory.d.ts +3 -0
- package/dist/tools/memory/list_memory.d.ts.map +1 -0
- package/dist/tools/memory/list_memory.js +55 -0
- package/dist/tools/memory/list_memory.js.map +1 -0
- package/dist/tools/memory/save_memory.d.ts +3 -0
- package/dist/tools/memory/save_memory.d.ts.map +1 -0
- package/dist/tools/memory/save_memory.js +45 -0
- package/dist/tools/memory/save_memory.js.map +1 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +2 -0
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/registry.d.ts +7 -8
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +114 -46
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/save_memory.d.ts +3 -0
- package/dist/tools/save_memory.d.ts.map +1 -0
- package/dist/tools/save_memory.js +45 -0
- package/dist/tools/save_memory.js.map +1 -0
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +2 -0
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/sed.d.ts +4 -0
- package/dist/tools/sed.d.ts.map +1 -0
- package/dist/tools/sed.js +121 -0
- package/dist/tools/sed.js.map +1 -0
- package/dist/tools/tree.d.ts +12 -0
- package/dist/tools/tree.d.ts.map +1 -0
- package/dist/tools/tree.js +87 -0
- package/dist/tools/tree.js.map +1 -0
- package/dist/tools/types.d.ts +12 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/web/fetch.d.ts +3 -0
- package/dist/tools/web/fetch.d.ts.map +1 -0
- package/dist/tools/web/fetch.js +49 -0
- package/dist/tools/web/fetch.js.map +1 -0
- package/dist/tools/web/search.d.ts +3 -0
- package/dist/tools/web/search.d.ts.map +1 -0
- package/dist/tools/web/search.js +134 -0
- package/dist/tools/web/search.js.map +1 -0
- package/dist/tools/write_plan.d.ts.map +1 -1
- package/dist/tools/write_plan.js +2 -0
- package/dist/tools/write_plan.js.map +1 -1
- package/dist/tui/commands.d.ts +4 -0
- package/dist/tui/commands.d.ts.map +1 -0
- package/dist/tui/commands.js +118 -0
- package/dist/tui/commands.js.map +1 -0
- package/dist/tui/components/colors.d.ts +36 -0
- package/dist/tui/components/colors.d.ts.map +1 -0
- package/dist/tui/components/colors.js +48 -0
- package/dist/tui/components/colors.js.map +1 -0
- package/dist/tui/components/header-bar.d.ts +26 -0
- package/dist/tui/components/header-bar.d.ts.map +1 -0
- package/dist/tui/components/header-bar.js +78 -0
- package/dist/tui/components/header-bar.js.map +1 -0
- package/dist/tui/components/index.d.ts +9 -0
- package/dist/tui/components/index.d.ts.map +1 -0
- package/dist/tui/components/index.js +9 -0
- package/dist/tui/components/index.js.map +1 -0
- package/dist/tui/components/landing-screen.d.ts +12 -0
- package/dist/tui/components/landing-screen.d.ts.map +1 -0
- package/dist/tui/components/landing-screen.js +53 -0
- package/dist/tui/components/landing-screen.js.map +1 -0
- package/dist/tui/components/pixel-logo.d.ts +5 -0
- package/dist/tui/components/pixel-logo.d.ts.map +1 -0
- package/dist/tui/components/pixel-logo.js +27 -0
- package/dist/tui/components/pixel-logo.js.map +1 -0
- package/dist/tui/components/plan-utils.d.ts +11 -0
- package/dist/tui/components/plan-utils.d.ts.map +1 -0
- package/dist/tui/components/plan-utils.js +62 -0
- package/dist/tui/components/plan-utils.js.map +1 -0
- package/dist/tui/components/plans-list.d.ts +18 -0
- package/dist/tui/components/plans-list.d.ts.map +1 -0
- package/dist/tui/components/plans-list.js +46 -0
- package/dist/tui/components/plans-list.js.map +1 -0
- package/dist/tui/components/rich-footer.d.ts +29 -0
- package/dist/tui/components/rich-footer.d.ts.map +1 -0
- package/dist/tui/components/rich-footer.js +124 -0
- package/dist/tui/components/rich-footer.js.map +1 -0
- package/dist/tui/components/todo-panel.d.ts +14 -0
- package/dist/tui/components/todo-panel.d.ts.map +1 -0
- package/dist/tui/components/todo-panel.js +83 -0
- package/dist/tui/components/todo-panel.js.map +1 -0
- package/dist/tui/components.d.ts.map +1 -1
- package/dist/tui/components.js +14 -7
- package/dist/tui/components.js.map +1 -1
- package/dist/tui/index.d.ts +2 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +99 -505
- package/dist/tui/index.js.map +1 -1
- package/dist/tui/overlays.d.ts +28 -0
- package/dist/tui/overlays.d.ts.map +1 -0
- package/dist/tui/overlays.js +154 -0
- package/dist/tui/overlays.js.map +1 -0
- package/dist/tui/themes.d.ts +5 -0
- package/dist/tui/themes.d.ts.map +1 -0
- package/dist/tui/themes.js +38 -0
- package/dist/tui/themes.js.map +1 -0
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +62 -101
- package/dist/web/index.js.map +1 -1
- package/dist/web/public/app.js +5 -855
- package/dist/web/public/confirm.js +70 -0
- package/dist/web/public/index.html +121 -120
- package/dist/web/public/input.js +107 -0
- package/dist/web/public/messages.js +411 -0
- package/dist/web/public/sidebar.js +82 -0
- package/dist/web/public/state.js +72 -0
- package/dist/web/public/style.css +247 -70
- package/dist/web/public/utils.js +37 -0
- package/dist/web/public/websocket.js +267 -0
- package/dist/web/public/ws.js +19 -0
- package/dist/web/session-bridge.d.ts.map +1 -1
- package/dist/web/session-bridge.js +85 -10
- package/dist/web/session-bridge.js.map +1 -1
- package/docs/ast-tools.md +117 -0
- package/package.json +11 -5
- package/scripts/check-line-count.mjs +53 -0
- package/scripts/copy-ast-wasm.mjs +32 -0
- package/scripts/copy-native.mjs +24 -0
- package/scripts/copy-web.mjs +15 -0
- package/src/agent/__tests__/session-restore.test.ts +284 -0
- package/src/agent/commands.ts +274 -0
- package/src/agent/compaction.ts +9 -2
- package/src/agent/index.ts +7 -2
- package/src/agent/llm.ts +4 -0
- package/src/agent/memory.ts +60 -0
- package/src/agent/prompt-builder.ts +111 -33
- package/src/agent/providers/google.ts +0 -1
- package/src/agent/providers/openai.ts +79 -8
- package/src/agent/session-chat.ts +480 -0
- package/src/agent/session-display.ts +195 -0
- package/src/agent/session-persistence.ts +146 -0
- package/src/agent/session-utils.ts +54 -0
- package/src/agent/session.ts +269 -670
- package/src/cli/index.ts +73 -4
- package/src/config/index.ts +14 -7
- package/src/index.ts +30 -3
- package/src/tools/__tests__/bash.test.ts +188 -2
- package/src/tools/__tests__/edit.test.ts +1216 -356
- package/src/tools/__tests__/fetch.test.ts +1 -1
- package/src/tools/__tests__/glob.test.ts +1 -1
- package/src/tools/__tests__/grep.test.ts +36 -1
- package/src/tools/__tests__/ls.test.ts +1 -1
- package/src/tools/__tests__/read.test.ts +1 -1
- package/src/tools/__tests__/registry.test.ts +332 -0
- package/src/tools/__tests__/write_plan.test.ts +1 -1
- package/src/tools/codebase/ast/__tests__/integration.test.ts +452 -0
- package/src/tools/codebase/ast/__tests__/tree-sitter.test.ts +466 -0
- package/src/tools/codebase/ast/adapter.ts +44 -0
- package/src/tools/codebase/ast/tools.ts +322 -0
- package/src/tools/codebase/ast/tree-sitter-adapter.ts +468 -0
- package/src/tools/codebase/ast/tree-sitter-converters.ts +480 -0
- package/src/tools/codebase/ast/types.ts +102 -0
- package/src/tools/codebase/ast/wasm/tree-sitter-python.wasm +0 -0
- package/src/tools/codebase/ast/wasm/tree-sitter-tsx.wasm +0 -0
- package/src/tools/codebase/ast/wasm/tree-sitter-typescript.wasm +0 -0
- package/src/tools/codebase/ast/wasm/tree-sitter.wasm +0 -0
- package/src/tools/codebase/ast/wasm/web-tree-sitter.wasm +0 -0
- package/src/tools/{find.ts → codebase/find.ts} +4 -2
- package/src/tools/{glob.ts → codebase/glob.ts} +4 -2
- package/src/tools/{grep.ts → codebase/grep.ts} +61 -32
- package/src/tools/{ls.ts → codebase/ls.ts} +4 -2
- package/src/tools/{read.ts → codebase/read.ts} +5 -3
- package/src/tools/edit/diff-compute.ts +21 -0
- package/src/tools/edit/diff-render.ts +145 -0
- package/src/tools/edit/edit.ts +468 -0
- package/src/tools/edit/matcher.ts +70 -0
- package/src/tools/edit/parser.ts +131 -0
- package/src/tools/edit/types.ts +19 -0
- package/src/tools/{write_plan.ts → edit/write_plan.ts} +4 -2
- package/src/tools/execute/bash/constants.ts +93 -0
- package/src/tools/execute/bash/errors.ts +304 -0
- package/src/tools/execute/bash/execution.ts +211 -0
- package/src/tools/execute/bash/index.ts +131 -0
- package/src/tools/execute/bash/platform.ts +65 -0
- package/src/tools/execute/bash/security.ts +28 -0
- package/src/tools/execute/bash/validation.ts +78 -0
- package/src/tools/execute/git.ts +209 -0
- package/src/tools/execute/task_complete.ts +40 -0
- package/src/tools/install/clawhub.ts +222 -0
- package/src/tools/install/constants.ts +4 -0
- package/src/tools/install/install_skill.ts +150 -0
- package/src/tools/install/npm.ts +60 -0
- package/src/tools/install/skill-content.ts +108 -0
- package/src/tools/memory/delete_memory.ts +46 -0
- package/src/tools/memory/list_memory.ts +53 -0
- package/src/tools/memory/save_memory.ts +45 -0
- package/src/tools/registry.ts +121 -50
- package/src/tools/tree.ts +103 -0
- package/src/tools/types.ts +13 -0
- package/src/tools/{fetch.ts → web/fetch.ts} +4 -2
- package/src/tools/{search.ts → web/search.ts} +4 -2
- package/src/tui/commands.ts +135 -0
- package/src/tui/components/colors.ts +52 -0
- package/src/tui/components/header-bar.ts +88 -0
- package/src/tui/components/index.ts +8 -0
- package/src/tui/components/landing-screen.ts +67 -0
- package/src/tui/components/pixel-logo.ts +33 -0
- package/src/tui/components/plan-utils.ts +69 -0
- package/src/tui/components/plans-list.ts +55 -0
- package/src/tui/components/rich-footer.ts +146 -0
- package/src/tui/components/todo-panel.ts +95 -0
- package/src/tui/index.ts +110 -561
- package/src/tui/overlays.ts +203 -0
- package/src/tui/themes.ts +41 -0
- package/src/web/index.ts +66 -107
- package/src/web/public/app.js +5 -855
- package/src/web/public/confirm.js +70 -0
- package/src/web/public/index.html +121 -120
- package/src/web/public/input.js +107 -0
- package/src/web/public/messages.js +411 -0
- package/src/web/public/sidebar.js +82 -0
- package/src/web/public/state.js +72 -0
- package/src/web/public/style.css +247 -70
- package/src/web/public/utils.js +37 -0
- package/src/web/public/websocket.js +267 -0
- package/src/web/public/ws.js +19 -0
- package/src/web/session-bridge.ts +90 -12
- package/.claude/settings.local.json +0 -14
- package/.kilo/plans/1780064105789-mighty-pixel.md +0 -171
- package/.kilo/plans/1780293725888-quick-wizard.md +0 -62
- package/.lonny/plan-web-cwd-status.md +0 -38
- package/AGENT.md +0 -99
- package/src/tools/bash.ts +0 -39
- package/src/tools/edit.ts +0 -554
- package/src/tools/exec.ts +0 -348
- package/src/tools/git.ts +0 -76
- package/src/tools/install_skill.ts +0 -539
- package/src/tui/components.ts +0 -635
package/dist/agent/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as readline from 'node:readline';
|
|
2
2
|
import { Session } from './session.js';
|
|
3
|
-
export async function runAgent(prompt, config) {
|
|
3
|
+
export async function runAgent(prompt, config, preloadedSession) {
|
|
4
4
|
const output = {
|
|
5
5
|
write: text => process.stdout.write(text),
|
|
6
6
|
confirmTool: async (toolCalls) => {
|
|
@@ -18,7 +18,7 @@ export async function runAgent(prompt, config) {
|
|
|
18
18
|
});
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
-
const session = (await Session.load(config, output))
|
|
21
|
+
const session = preloadedSession ?? (await Session.load(config, output)) ?? new Session(config, output);
|
|
22
22
|
await session.chat(prompt);
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=index.js.map
|
package/dist/agent/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC,OA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A;QACJ,CAAC;KACF,CAAA;IACD,MAAM,OAAO,GACX,gBAAgB,IAAI,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzF,MAAM,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC"}
|
package/dist/agent/llm.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface LLMProvider {
|
|
|
13
13
|
export interface TokenUsage {
|
|
14
14
|
input_tokens: number;
|
|
15
15
|
output_tokens: number;
|
|
16
|
+
/** DeepSeek-specific: tokens read from cache */
|
|
17
|
+
prompt_cache_hit_tokens?: number;
|
|
18
|
+
/** DeepSeek-specific: tokens not in cache */
|
|
19
|
+
prompt_cache_miss_tokens?: number;
|
|
16
20
|
}
|
|
17
21
|
export interface LLMChunk {
|
|
18
22
|
type: 'text' | 'tool_use' | 'complete';
|
package/dist/agent/llm.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEjE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;IAC9C,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CACF,QAAQ,EAAE,UAAU,EAAE,EACtB,KAAK,EAAE,cAAc,EAAE,EACvB,MAAM,CAAC,EAAE,WAAW,GAC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
|
|
|
1
|
+
export interface MemoryEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
createdAt: string;
|
|
4
|
+
content: string;
|
|
5
|
+
tags?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function getMemoryDir(cwd: string): string;
|
|
8
|
+
export declare function ensureMemoryDir(cwd: string): void;
|
|
9
|
+
export declare function loadMemory(cwd: string): MemoryEntry[];
|
|
10
|
+
export declare function saveMemory(cwd: string, entry: MemoryEntry): void;
|
|
11
|
+
export declare function formatMemoryForPrompt(memories: MemoryEntry[]): string;
|
|
12
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agent/memory.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAID,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGjD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAoBrD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAKhE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CASrE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
const MEM_DIR = '.lonny/memory';
|
|
4
|
+
export function getMemoryDir(cwd) {
|
|
5
|
+
return path.resolve(cwd, MEM_DIR);
|
|
6
|
+
}
|
|
7
|
+
export function ensureMemoryDir(cwd) {
|
|
8
|
+
const d = getMemoryDir(cwd);
|
|
9
|
+
if (!fs.existsSync(d))
|
|
10
|
+
fs.mkdirSync(d, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
export function loadMemory(cwd) {
|
|
13
|
+
const d = getMemoryDir(cwd);
|
|
14
|
+
try {
|
|
15
|
+
if (!fs.existsSync(d))
|
|
16
|
+
return [];
|
|
17
|
+
const files = fs.readdirSync(d).filter(f => f.endsWith('.json'));
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const f of files) {
|
|
20
|
+
try {
|
|
21
|
+
const data = JSON.parse(fs.readFileSync(path.join(d, f), 'utf-8'));
|
|
22
|
+
out.push(data);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
// ignore corrupted file
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// sort by createdAt
|
|
29
|
+
out.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function saveMemory(cwd, entry) {
|
|
37
|
+
ensureMemoryDir(cwd);
|
|
38
|
+
const id = entry.id || String(Date.now());
|
|
39
|
+
const file = path.join(getMemoryDir(cwd), `${id}.json`);
|
|
40
|
+
fs.writeFileSync(file, JSON.stringify(entry, null, 2), 'utf-8');
|
|
41
|
+
}
|
|
42
|
+
export function formatMemoryForPrompt(memories) {
|
|
43
|
+
if (!memories || memories.length === 0)
|
|
44
|
+
return '';
|
|
45
|
+
const parts = [];
|
|
46
|
+
for (const m of memories) {
|
|
47
|
+
parts.push(`- [${m.createdAt}] ${m.content.slice(0, 400).replace(/\n/g, ' ')}${m.content.length > 400 ? '…' : ''}`);
|
|
48
|
+
}
|
|
49
|
+
return parts.join('\n');
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { ToolDefinition } from '../tools/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Build the system prompt for the current configuration.
|
|
4
5
|
* Extracted from session.ts to keep module size manageable (<500 LoC target).
|
|
6
|
+
*
|
|
7
|
+
* @param config - Current configuration
|
|
8
|
+
* @param definitions - Optional tool definitions for dynamic tree generation.
|
|
9
|
+
* When provided, replaces the hardcoded tool lists with a hierarchical tree.
|
|
5
10
|
*/
|
|
6
|
-
export declare function buildSystemPrompt(config: Config): Promise<string>;
|
|
11
|
+
export declare function buildSystemPrompt(config: Config, definitions?: ToolDefinition[]): Promise<string>;
|
|
7
12
|
//# sourceMappingURL=prompt-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/agent/prompt-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/agent/prompt-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAQvD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,cAAc,EAAE,GAC7B,OAAO,CAAC,MAAM,CAAC,CA4OjB"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import * as os from 'node:os';
|
|
2
|
+
import { formatToolTreeForPrompt } from '../tools/tree.js';
|
|
3
|
+
const CORE_TOOL_NAMES = new Set(['read', 'edit', 'bash', 'glob', 'grep']);
|
|
4
|
+
import { formatMemoryForPrompt, loadMemory } from './memory.js';
|
|
2
5
|
import { discoverProject, formatProjectContext } from './project.js';
|
|
3
6
|
import { formatSkillsForPrompt, loadSkills } from './skills.js';
|
|
4
7
|
/**
|
|
5
8
|
* Build the system prompt for the current configuration.
|
|
6
9
|
* Extracted from session.ts to keep module size manageable (<500 LoC target).
|
|
10
|
+
*
|
|
11
|
+
* @param config - Current configuration
|
|
12
|
+
* @param definitions - Optional tool definitions for dynamic tree generation.
|
|
13
|
+
* When provided, replaces the hardcoded tool lists with a hierarchical tree.
|
|
7
14
|
*/
|
|
8
|
-
export async function buildSystemPrompt(config) {
|
|
15
|
+
export async function buildSystemPrompt(config, definitions) {
|
|
9
16
|
const platform = os.platform();
|
|
10
17
|
const release = os.release();
|
|
11
18
|
const shell = process.env.SHELL || process.env.ComSpec || 'unknown';
|
|
@@ -15,11 +22,28 @@ export async function buildSystemPrompt(config) {
|
|
|
15
22
|
// ── Load skills ────────────────────────────────────────────────────────
|
|
16
23
|
const skills = loadSkills(cwd);
|
|
17
24
|
const skillsSection = formatSkillsForPrompt(skills);
|
|
25
|
+
// ── Load long-term memory (persistent) ─────────────────────────────────
|
|
26
|
+
const memories = loadMemory(cwd);
|
|
27
|
+
const memorySection = formatMemoryForPrompt(memories);
|
|
18
28
|
// ── Load project context ─────────────────────────────────────────────────
|
|
19
29
|
const projectInfo = await discoverProject(cwd);
|
|
20
30
|
const projectSection = formatProjectContext(projectInfo);
|
|
21
31
|
// ── Mode-specific tool list ───────────────────────────────────────────
|
|
22
32
|
function getToolListForMode(mode) {
|
|
33
|
+
// When tool definitions are available, use the dynamic tree
|
|
34
|
+
if (definitions && definitions.length > 0) {
|
|
35
|
+
const header = mode === 'plan'
|
|
36
|
+
? 'Available tools (read-only investigation + write_plan):'
|
|
37
|
+
: mode === 'ask'
|
|
38
|
+
? 'Available tools:'
|
|
39
|
+
: 'Available tools:';
|
|
40
|
+
const tree = formatToolTreeForPrompt(definitions, CORE_TOOL_NAMES);
|
|
41
|
+
const note = mode !== 'ask'
|
|
42
|
+
? '\n Direct access: read, edit, bash, glob, grep\n Extended tools: use `tool()` gateway (see tree above)\n'
|
|
43
|
+
: '';
|
|
44
|
+
return `${header}\n${tree}${note}\n`;
|
|
45
|
+
}
|
|
46
|
+
// Fallback hardcoded lists (when definitions not available)
|
|
23
47
|
if (mode === 'ask') {
|
|
24
48
|
return `Available tools:
|
|
25
49
|
- \`fetch\`: Fetch content from a URL
|
|
@@ -44,13 +68,13 @@ export async function buildSystemPrompt(config) {
|
|
|
44
68
|
- \`glob\`: Find files by glob pattern (pattern: string)
|
|
45
69
|
- \`grep\`: Search file content by regex (pattern: string, include?: string, path?: string)
|
|
46
70
|
- \`ls\`: List directory (path?: string)
|
|
47
|
-
- \`bash\`: Execute a shell command
|
|
48
|
-
- \`edit\`: Replace text in files
|
|
49
|
-
- \`install_skill\`: Install an npm package as a skill — fetches package info from npm, runs npm install, and creates a .lonny/skills/ file with usage instructions for the AI
|
|
50
|
-
- \`
|
|
51
|
-
- \`
|
|
52
|
-
- \`
|
|
53
|
-
- \`
|
|
71
|
+
- \`bash\`: Execute a shell command — for running commands (NOT for creating or modifying files — use \`edit\` for that)
|
|
72
|
+
- \`edit\`: Replace text in files using markdown code block format. Use: \`edit({ content: "\`\`\`edit\\nfile: path\\nold: |\\ntext\\nnew: |\\ntext\\n\`\`\`" })\`. NOTE: There is no "write" tool — always use \`edit\` to modify files.
|
|
73
|
+
- \`install_skill\`: Install an npm package as a skill — fetches package info from npm, runs npm install, and creates a .lonny/skills/ file with usage instructions for the AI
|
|
74
|
+
- \`save_memory\`: Save a memory entry to long-term memory (content: string, tags?: string[])
|
|
75
|
+
- \`find\`: Find files by name pattern (pattern: string, path?: string, maxResults?: number)
|
|
76
|
+
- \`git\`: Run read-only git commands (command: string)
|
|
77
|
+
- \`search\`: Search the web using Tavily (query: string, search_depth?: string, include_answer?: boolean, max_results?: number, topic?: string, days?: number)
|
|
54
78
|
`;
|
|
55
79
|
}
|
|
56
80
|
// ── Shared rules (identical across modes; stable prefix for caching) ─────
|
|
@@ -58,15 +82,48 @@ export async function buildSystemPrompt(config) {
|
|
|
58
82
|
RULES:
|
|
59
83
|
1. Read first: Use read/grep/glob tools to gather all context you need before making any edits.
|
|
60
84
|
2. Be thorough: Explore the relevant parts of the codebase.
|
|
61
|
-
3.
|
|
62
|
-
4.
|
|
85
|
+
3. AST tools (\`ast_query\`, \`ast_edit\`) are available via the \`tool()\` gateway. Use \`ast_query\` to inspect code structure (functions, classes, imports) before editing. Use \`ast_edit\` for structure-aware edits that preserve formatting.
|
|
86
|
+
4. **For JavaScript/TypeScript files, prefer AST tools over raw text tools**: Use \`ast_query\` (not \`read\`) to understand file structure — it returns structured function/class/import/export data with exact line numbers. Use \`ast_edit\` (not \`edit\`) to replace entire functions, classes, or variables — it avoids string-matching issues and preserves formatting. Reserve \`edit\` for small surgical changes to function bodies or single-line fixes.
|
|
87
|
+
5. COST OPTIMIZATION (CRITICAL): Each API call costs money. You MUST maximize work per call. Use \`read(paths: [...])\` to read multiple files at once. Use \`edit({ content: "..." })\` with multiple \`\`\`edit blocks to edit multiple files at once.
|
|
88
|
+
6. There is NO "write" tool. To modify files, use the \`edit\` tool (listed above). Calling \`write\` will fail with "Unknown tool".
|
|
63
89
|
|
|
64
|
-
${getToolListForMode(config.mode)}
|
|
90
|
+
${getToolListForMode(config.mode)}
|
|
91
|
+
`;
|
|
92
|
+
// ── Memory section (appended to system prompt to provide long-term context) ──
|
|
93
|
+
const memoryPromptSection = memorySection ? `\n## Long-term Memory\n\n${memorySection}` : '';
|
|
94
|
+
// NOTE: Mention save_memory in loop/code mode tool lists only if the tool exists at runtime.
|
|
95
|
+
// The tool may be provided via plugin or future implementation.
|
|
65
96
|
// ── Mode-specific instructions ───────────────────────────────────────────
|
|
66
|
-
const modeInstructions = config.mode === '
|
|
67
|
-
? `You are
|
|
97
|
+
const modeInstructions = config.mode === 'loop'
|
|
98
|
+
? `You are an autonomous coding agent operating in LOOP mode. You will CONTINUE working on the task automatically after each turn — you do NOT need to ask for confirmation between steps.
|
|
99
|
+
|
|
100
|
+
${getToolListForMode('loop')}
|
|
101
|
+
RULES (loop-specific):
|
|
102
|
+
1. Read first: Use read/grep/glob tools to gather all context you need BEFORE making any edits. **For JS/TS files, prefer \`ast_query\` over \`read\`** — it returns structured function/class/import/export data with exact line numbers. Use \`tool({ name: "ast_query", params: { path: "file.ts", query: "structure" }})\` to inspect code structure via AST before editing. **For edits to whole functions/classes/variables in JS/TS, prefer \`ast_edit\` over \`edit\`** — use \`tool({ name: "ast_edit", params: { path: "file.ts", editType: "replace-node", targetLine: 5, newCode: "..." }})\` to avoid string-matching issues. Reserve \`edit\` for small surgical changes inside function bodies or single-line fixes. The \`read\` output prefixes each line with "<lineNumber>: " for easy reference. Do NOT include the "N: " prefix when copying text into \`edit\`.
|
|
103
|
+
2. edit CALL FORMAT — use markdown code block format:
|
|
104
|
+
\`\`\`edit
|
|
105
|
+
file: src/file.ts
|
|
106
|
+
old: |
|
|
107
|
+
text to replace
|
|
108
|
+
new: |
|
|
109
|
+
replacement text
|
|
110
|
+
\`\`\`
|
|
111
|
+
Use separate \`\`\`edit blocks for multiple files.
|
|
112
|
+
3. After making edits to a file, if you need to make ANOTHER edit to the SAME file, you MUST re-read it first to get the updated content.
|
|
113
|
+
4. If \`edit\` reports \`old_string not found\`, do NOT retry with the same old_string — re-read the file immediately to see its actual current content, then retry with correctly-copied text.
|
|
114
|
+
5. When copying old_string from \`read\` output, include 2-3 lines of context BEFORE and AFTER the target change to make the string unique in the file.
|
|
115
|
+
6. On Windows, files may use CRLF (\\r\\n) line endings, but the \`edit\` tool normalizes them to LF (\\n). Always use \`\\n\` (not \`\\r\\n\`) in old_string/new_string.
|
|
116
|
+
7. CRITICAL: old_string must be CONTIGUOUS — do NOT skip any lines between the old_string start and end. If you need to modify non-adjacent sections, use separate \`\`\`edit blocks.
|
|
117
|
+
8. The \`|\` (pipe) after \`old:\` / \`new:\` supports chomping: \`|\` keeps trailing newline, \`|-\` strips it. Use \`|\` (not \`|-\`) when copying old_string — wrong chomping causes "old_string not found".
|
|
118
|
+
9. COST OPTIMIZATION (CRITICAL): Each API call costs money. You MUST maximize work per call. Use \`read(paths: [...])\` to read multiple files at once. Use \`edit({ content: "..." })\` with multiple \`\`\`edit blocks to edit multiple files at once.
|
|
119
|
+
10. TODO LIST MAINTENANCE: After completing a task item, update the corresponding plan file in \`.lonny/\` by checking off the TODO item (change \`- [ ]\` to \`- [x]\`). Use \`read\` to find the plan file, then \`edit\` to update the checkbox.
|
|
120
|
+
11. LOOP BEHAVIOR: After this turn ends, you will AUTOMATICALLY receive a continuation prompt to continue working on the same task. You do NOT need to stop and wait for the user — keep going until the task is complete.
|
|
121
|
+
12. If you believe the task is COMPLETE, end your response with a clear summary of what was accomplished. The system will detect this and stop the loop.
|
|
122
|
+
13. You can use /stop at any time to halt execution.`
|
|
123
|
+
: config.mode === 'plan'
|
|
124
|
+
? `You are a planning agent. Your ONLY job is to investigate the codebase and produce an actionable implementation plan with a todo list.
|
|
68
125
|
|
|
69
|
-
You CANNOT edit files. You do NOT have access to edit, bash (write mode),
|
|
126
|
+
You CANNOT edit files. You do NOT have access to edit, bash (write mode), or install_skill.
|
|
70
127
|
Any attempt to call these tools will FAIL — they are simply unavailable in this mode.
|
|
71
128
|
|
|
72
129
|
RULES (plan-specific):
|
|
@@ -78,6 +135,7 @@ RULES (plan-specific):
|
|
|
78
135
|
6. If the plan is very long (or the todo list has many items), split into multiple files with descriptive names like \`backend-api.md\`, \`frontend-ui.md\`, \`database.md\`, etc.
|
|
79
136
|
7. You MUST also include the todo list in your text response to the user (not just in the file).
|
|
80
137
|
7. If the user asks you to modify files, run write commands, or install packages — refuse and explain they need to switch to code mode (\`/mode code\`).
|
|
138
|
+
8. When the task involves writing code, your plan MUST follow Test-Driven Development: write tests first, then implement. Include a \`- [ ] Write tests for ...\` step BEFORE the implementation steps in the todo list.
|
|
81
139
|
|
|
82
140
|
OUTPUT FORMAT (you MUST include both in write_plan AND in your response text):
|
|
83
141
|
|
|
@@ -93,33 +151,39 @@ A short, ordered description of the approach. Reference concrete files using \`p
|
|
|
93
151
|
End your response by telling the user where the plan was saved and asking whether they want to switch to \`code\` mode to execute it. Use exactly: "Switch to code mode to implement this plan? (run \`/mode code\`)"
|
|
94
152
|
|
|
95
153
|
If the user's request is a question rather than a change request, answer it directly and skip the plan/todo sections.`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
- \`search\`: Search the web using Tavily
|
|
100
|
-
|
|
154
|
+
: config.mode === 'ask'
|
|
155
|
+
? `You are a Q&A assistant. You can ONLY use the following tools to search for information:
|
|
156
|
+
${getToolListForMode('ask')}
|
|
101
157
|
You CANNOT execute any shell commands (\`bash\`), read local files, or make any changes to the codebase.
|
|
102
158
|
|
|
103
159
|
RULES (ask-specific):
|
|
104
160
|
1. Use \`fetch\` and \`search\` to find information and answer user questions.
|
|
105
161
|
2. You CANNOT use \`bash\`, \`read\`, \`edit\`, \`write_plan\`, \`glob\`, \`grep\`, \`ls\`, \`find\`, or \`git\`.
|
|
106
162
|
3. If the user wants you to modify code or run commands, explain you are in ask mode and suggest switching to code mode.`
|
|
107
|
-
|
|
163
|
+
: `You are a coding agent optimized for per-call pricing.
|
|
108
164
|
|
|
109
165
|
RULES (code-specific):
|
|
110
166
|
1. Read first: Use read/grep/glob tools to gather all context you need BEFORE making any edits. The \`read\` output prefixes each line with "<lineNumber>: " for easy reference. Do NOT include the "N: " prefix when copying text into \`edit\`.
|
|
111
|
-
2. edit CALL FORMAT —
|
|
112
|
-
|
|
113
|
-
|
|
167
|
+
2. edit CALL FORMAT — use markdown code block format:
|
|
168
|
+
\`\`\`edit
|
|
169
|
+
file: src/file.ts
|
|
170
|
+
old: |
|
|
171
|
+
text to replace
|
|
172
|
+
new: |
|
|
173
|
+
replacement text
|
|
174
|
+
\`\`\`
|
|
175
|
+
Use separate \`\`\`edit blocks for multiple files.
|
|
114
176
|
3. After making edits to a file, if you need to make ANOTHER edit to the SAME file, you MUST re-read it first to get the updated content.
|
|
115
177
|
4. If \`edit\` reports \`old_string not found\`, do NOT retry with the same old_string — re-read the file immediately to see its actual current content, then retry with correctly-copied text.
|
|
116
|
-
5. When copying old_string from \`read\` output, include 2-3 lines of context BEFORE and AFTER the target change to make the string unique in the file.
|
|
117
|
-
6.
|
|
118
|
-
7.
|
|
119
|
-
8.
|
|
178
|
+
5. When copying old_string from \`read\` output, include 2-3 lines of context BEFORE and AFTER the target change to make the string unique in the file.
|
|
179
|
+
6. CRITICAL: old_string must be CONTIGUOUS — do NOT skip any lines between the old_string start and end. If you need to modify non-adjacent sections, use separate \`\`\`edit blocks.
|
|
180
|
+
7. The \`|\` (pipe) after \`old:\` / \`new:\` supports chomping: \`|\` keeps trailing newline, \`|-\` strips it. Use \`|\` (not \`|-\`) when copying old_string — wrong chomping causes "old_string not found".
|
|
181
|
+
8. On Windows, files may use CRLF (\\r\\n) line endings, but the \`edit\` tool normalizes them to LF (\\n). Always use \`\\n\` (not \`\\r\\n\`) in old_string/new_string.
|
|
182
|
+
9. COST OPTIMIZATION (CRITICAL): Each API call costs money. You have a hard limit of ~5 API calls per task.
|
|
183
|
+
10. TODO LIST MAINTENANCE: After completing a task item, update the corresponding plan file in \`.lonny/\` by checking off the TODO item (change \`- [ ]\` to \`- [x]\`). Use \`read\` to find the plan file, then \`edit\` to update the checkbox.`;
|
|
120
184
|
// ── Built-in development methodologies ─────────────────────────────────
|
|
121
185
|
// Embedded directly from Superpowers — no skill files needed.
|
|
122
|
-
const methodologySection = config.mode === 'code'
|
|
186
|
+
const methodologySection = config.mode === 'code' || config.mode === 'loop'
|
|
123
187
|
? `
|
|
124
188
|
|
|
125
189
|
## Development Methodology
|
|
@@ -155,16 +219,19 @@ Before writing a plan, explore the user's request thoroughly:
|
|
|
155
219
|
- Shell: ${shell}
|
|
156
220
|
- Working directory: ${cwd}
|
|
157
221
|
- OS: ${isWindows ? 'Windows' : 'Linux/macOS'}
|
|
158
|
-
- Available shell commands: ${isWindows ? 'PowerShell (cmd is also available but PowerShell is preferred)' : 'bash'}
|
|
159
|
-
${isWindows ? '
|
|
160
|
-
${isWindows ? '
|
|
222
|
+
- Available shell commands: ${isWindows ? 'PowerShell (cmd is also available but PowerShell is preferred)' : 'bash'}
|
|
223
|
+
${isWindows ? ' ⚠️ THIS IS WINDOWS. Do NOT use Unix/Linux paths like `/workspace/...` or `/home/...`. The working directory is a Windows path (e.g. `C:\\Users\\...`).' : ''}
|
|
224
|
+
${isWindows ? ' ⚠️ Do NOT use Unix commands: `find`, `cat`, `ls -la`, `which`, `cp`, `mv`, `rm`, `touch`, `chmod`, `mkdir`, `grep`, `head`, `tail`. They will ALL fail.' : ''}
|
|
225
|
+
${isWindows ? ' - Use `type` instead of `cat`, `dir` instead of `ls`, `where` instead of `which`, `Select-Object -First N` instead of `head -N`' : ''}
|
|
226
|
+
${isWindows ? ' - Use `;` (semicolon) instead of `&&` to chain commands' : ''}
|
|
227
|
+
${isWindows ? ' - ⚠️ `Select-String` exits with code 1 when no match is found (e.g. `Select-String -Pattern "FAIL"` returns code 1 if no line contains FAIL). This is NORMAL — it does NOT mean the command failed. Append `; $LASTEXITCODE = 0` to suppress this.' : ''}`;
|
|
161
228
|
// Plan mode uses its own standalone tool list inside modeInstructions — skip sharedRules
|
|
162
|
-
const rulesSection = config.mode === 'plan'
|
|
229
|
+
const rulesSection = config.mode === 'plan' || config.mode === 'loop'
|
|
163
230
|
? ''
|
|
164
231
|
: `
|
|
165
232
|
${sharedRules}`;
|
|
166
233
|
return `${modeInstructions}
|
|
167
234
|
|
|
168
|
-
${envSection}${rulesSection}${methodologySection}${projectSection}${skillsSection}`;
|
|
235
|
+
${envSection}${rulesSection}${methodologySection}${projectSection}${memoryPromptSection}${skillsSection}`;
|
|
169
236
|
}
|
|
170
237
|
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/agent/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE/D
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sourceRoot":"","sources":["../../src/agent/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG1D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAEzE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,WAA8B;IAE9B,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;IAC9B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;IAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,CAAA;IACnE,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAA;IACtB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;IACtB,MAAM,SAAS,GAAG,QAAQ,KAAK,OAAO,CAAA;IAEtC,0EAA0E;IAC1E,MAAM,MAAM,GAAG,UAAU,CAAC,GAA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CAAC,CAAC,EAAE;EACpJ,SAAS,CAAC,CAAC,CAAC,2DAA2D,CAAC,CAAC,CAAC,EAAE;EAC5E,SAAS,CAAC,CAAC,CAAC,uPAAuP,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAE1Q,yFAAyF;IACzF,MAAM,YAAY,GAChB,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;QAC9C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;EACN,WAAW,EAAE,CAAA;IACb,OAAO,GAAG,gBAAgB;;EAE1B,UAAU,GAAG,YAAY,GAAG,kBAAkB,GAAG,cAAc,GAAG,mBAAmB,GAAG,aAAa,EAAE,CAAA;AACzG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAsClE,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,OAAO,CAAQ;gBAEX,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAMrD,IAAI,CACT,QAAQ,EAAE,UAAU,EAAE,EACtB,KAAK,EAAE,cAAc,EAAE,EACvB,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,E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sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/openai.ts"],"names":[],"mappings":"AAQA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AA+ClE,qBAAa,cAAe,YAAW,WAAW;IAChD,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,eAAe,CAAC,CAAQ;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,6DAA6D;IAC7D,OAAO,CAAC,WAAW,CAAS;gBAG1B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,OAAO,EAClB,eAAe,CAAC,EAAE,MAAM,EACxB,WAAW,CAAC,EAAE,OAAO,EACrB,WAAW,CAAC,EAAE,OAAO;IAYhB,IAAI,CACT,QAAQ,EAAE,UAAU,EAAE,EACtB,KAAK,EAAE,cAAc,EAAE,EACvB,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,QAAQ,CAAC;CA4T5B"}
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
+
/** Try to parse JSON, and attempt to repair common issues like unescaped quotes */
|
|
3
|
+
function tryParseJSON(input) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(input);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
// Try to repair common JSON issues from LLM output
|
|
9
|
+
let repaired = input;
|
|
10
|
+
// Fix unescaped quotes in string values:
|
|
11
|
+
// Pattern: key="unquoted text" -> key="escaped text"
|
|
12
|
+
// This regex finds ="<not properly escaped>" and adds escaping
|
|
13
|
+
// It handles: ="<content with spaces and 中文">
|
|
14
|
+
repaired = repaired.replace(/= "([^"\\]*(?:\\.[^"\\]*)*)"/g, (match, content) => {
|
|
15
|
+
// Escape any unescaped quotes within the content
|
|
16
|
+
const escaped = content.replace(/(?<!\\)"/g, '\\"');
|
|
17
|
+
return `= "${escaped}"`;
|
|
18
|
+
});
|
|
19
|
+
// Also try escaping quotes after @ (for @click="...")
|
|
20
|
+
repaired = repaired.replace(/@(\w+)="([^"\\]*(?:\\.[^"\\]*)*)"/g, (match, attr, content) => {
|
|
21
|
+
const escaped = content.replace(/(?<!\\)"/g, '\\"');
|
|
22
|
+
return `@${attr}="${escaped}"`;
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
return JSON.parse(repaired);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
2
32
|
export class OpenAIProvider {
|
|
3
33
|
client;
|
|
4
34
|
model;
|
|
35
|
+
baseURL;
|
|
5
36
|
thinking;
|
|
6
37
|
reasoningEffort;
|
|
7
38
|
enableCache;
|
|
@@ -10,6 +41,7 @@ export class OpenAIProvider {
|
|
|
10
41
|
constructor(apiKey, baseURL, model, thinking, reasoningEffort, enableCache, strictTools) {
|
|
11
42
|
this.client = new OpenAI({ apiKey, baseURL });
|
|
12
43
|
this.model = model || 'gpt-4o';
|
|
44
|
+
this.baseURL = baseURL;
|
|
13
45
|
this.thinking = thinking;
|
|
14
46
|
this.reasoningEffort = reasoningEffort;
|
|
15
47
|
this.enableCache = enableCache ?? false;
|
|
@@ -78,15 +110,26 @@ export class OpenAIProvider {
|
|
|
78
110
|
content: m.content || '',
|
|
79
111
|
};
|
|
80
112
|
});
|
|
113
|
+
// 检测当前对接的是否为官方 OpenAI 应用程序接口
|
|
114
|
+
const isOfficialOpenAI = this.baseURL ? /api\.openai\.com/i.test(this.baseURL) : true;
|
|
115
|
+
// Build reasoning params compatible with the target API
|
|
116
|
+
const reasoningParams = {};
|
|
117
|
+
if (this.thinking) {
|
|
118
|
+
if (isOfficialOpenAI) {
|
|
119
|
+
reasoningParams.thinking = { type: 'enabled' };
|
|
120
|
+
reasoningParams.reasoning_effort = this.reasoningEffort || 'high';
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
reasoningParams.reasoning = { effort: this.reasoningEffort || 'high' };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
81
126
|
const stream = await this.client.chat.completions.create({
|
|
82
127
|
model: this.model,
|
|
83
128
|
messages: openAIMessages,
|
|
84
129
|
tools: openAIFormattedTools.length > 0 ? openAIFormattedTools : undefined,
|
|
85
130
|
stream: true,
|
|
86
131
|
stream_options: { include_usage: true },
|
|
87
|
-
...
|
|
88
|
-
? { thinking: { type: 'enabled' }, reasoning_effort: this.reasoningEffort || 'high' }
|
|
89
|
-
: {}),
|
|
132
|
+
...reasoningParams,
|
|
90
133
|
...(this.enableCache ? { enable_cache: true } : {}),
|
|
91
134
|
}, signal ? { signal } : undefined);
|
|
92
135
|
let currentToolCall = null;
|
|
@@ -100,6 +143,7 @@ export class OpenAIProvider {
|
|
|
100
143
|
for await (const chunk of stream) {
|
|
101
144
|
// Capture usage info if present (may come in a chunk without choices)
|
|
102
145
|
// OpenAI uses prompt_tokens/completion_tokens; map to our input_tokens/output_tokens
|
|
146
|
+
// DeepSeek also returns prompt_cache_hit_tokens & prompt_cache_miss_tokens
|
|
103
147
|
const rawChunk = chunk;
|
|
104
148
|
if (rawChunk.usage) {
|
|
105
149
|
lastUsage = rawChunk.usage;
|
|
@@ -112,6 +156,8 @@ export class OpenAIProvider {
|
|
|
112
156
|
usage: {
|
|
113
157
|
input_tokens: rawChunk.usage.prompt_tokens ?? 0,
|
|
114
158
|
output_tokens: rawChunk.usage.completion_tokens ?? 0,
|
|
159
|
+
prompt_cache_hit_tokens: rawChunk.usage.prompt_cache_hit_tokens,
|
|
160
|
+
prompt_cache_miss_tokens: rawChunk.usage.prompt_cache_miss_tokens,
|
|
115
161
|
},
|
|
116
162
|
};
|
|
117
163
|
pendingComplete = null;
|
|
@@ -140,7 +186,7 @@ export class OpenAIProvider {
|
|
|
140
186
|
let input;
|
|
141
187
|
const rawArgs = currentToolCall.arguments || '';
|
|
142
188
|
try {
|
|
143
|
-
input =
|
|
189
|
+
input = tryParseJSON(rawArgs || '{}') || {};
|
|
144
190
|
}
|
|
145
191
|
catch {
|
|
146
192
|
console.error('[openai] Failed to parse tool_call arguments (flush on new tool):', rawArgs);
|
|
@@ -172,12 +218,13 @@ export class OpenAIProvider {
|
|
|
172
218
|
if (currentToolCall) {
|
|
173
219
|
const finalArgs = currentToolCall.arguments || '';
|
|
174
220
|
try {
|
|
221
|
+
const parsed = tryParseJSON(finalArgs || '{}');
|
|
175
222
|
yield {
|
|
176
223
|
type: 'tool_use',
|
|
177
224
|
tool_call: {
|
|
178
225
|
id: currentToolCall.id,
|
|
179
226
|
name: currentToolCall.name,
|
|
180
|
-
input:
|
|
227
|
+
input: parsed || {},
|
|
181
228
|
},
|
|
182
229
|
reasoning_content: reasoningContent,
|
|
183
230
|
};
|
|
@@ -206,6 +253,8 @@ export class OpenAIProvider {
|
|
|
206
253
|
usage: {
|
|
207
254
|
input_tokens: lastUsage.prompt_tokens ?? 0,
|
|
208
255
|
output_tokens: lastUsage.completion_tokens ?? 0,
|
|
256
|
+
prompt_cache_hit_tokens: lastUsage.prompt_cache_hit_tokens,
|
|
257
|
+
prompt_cache_miss_tokens: lastUsage.prompt_cache_miss_tokens,
|
|
209
258
|
},
|
|
210
259
|
};
|
|
211
260
|
reasoningContent = undefined;
|
|
@@ -226,6 +275,8 @@ export class OpenAIProvider {
|
|
|
226
275
|
? {
|
|
227
276
|
input_tokens: lastUsage.prompt_tokens ?? 0,
|
|
228
277
|
output_tokens: lastUsage.completion_tokens ?? 0,
|
|
278
|
+
prompt_cache_hit_tokens: lastUsage.prompt_cache_hit_tokens,
|
|
279
|
+
prompt_cache_miss_tokens: lastUsage.prompt_cache_miss_tokens,
|
|
229
280
|
}
|
|
230
281
|
: undefined;
|
|
231
282
|
yield {
|
|
@@ -241,12 +292,14 @@ export class OpenAIProvider {
|
|
|
241
292
|
? {
|
|
242
293
|
input_tokens: lastUsage.prompt_tokens ?? 0,
|
|
243
294
|
output_tokens: lastUsage.completion_tokens ?? 0,
|
|
295
|
+
prompt_cache_hit_tokens: lastUsage.prompt_cache_hit_tokens,
|
|
296
|
+
prompt_cache_miss_tokens: lastUsage.prompt_cache_miss_tokens,
|
|
244
297
|
}
|
|
245
298
|
: undefined;
|
|
246
299
|
let input;
|
|
247
300
|
const rawFinalArgs = currentToolCall.arguments || '';
|
|
248
301
|
try {
|
|
249
|
-
input =
|
|
302
|
+
input = tryParseJSON(rawFinalArgs || '{}') || {};
|
|
250
303
|
}
|
|
251
304
|
catch {
|
|
252
305
|
console.error('[openai] Failed to parse tool_call arguments (final flush):', rawFinalArgs);
|