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/src/tools/exec.ts
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import * as vm from 'node:vm'
|
|
2
|
-
import { fmtErr } from './errors.js'
|
|
3
|
-
import type { Tool, ToolDefinition, ToolResult } from './types.js'
|
|
4
|
-
|
|
5
|
-
// ── Types ────────────────────────────────────────────────────────────────────
|
|
6
|
-
|
|
7
|
-
interface ExecPragma {
|
|
8
|
-
timeout_ms?: number
|
|
9
|
-
yield_time_ms?: number
|
|
10
|
-
max_output_tokens?: number
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface ExecContext {
|
|
14
|
-
tools: Record<string, (input: unknown) => Promise<string>>
|
|
15
|
-
store: Map<string, unknown>
|
|
16
|
-
output: string[]
|
|
17
|
-
notified: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const PRAGMA_PREFIX = '// @exec:'
|
|
21
|
-
const DEFAULT_TIMEOUT_MS = 30_000
|
|
22
|
-
|
|
23
|
-
// ── Pragma parsing ──────────────────────────────────────────────────────────
|
|
24
|
-
|
|
25
|
-
function parsePragma(input: string): { code: string; pragma: ExecPragma } {
|
|
26
|
-
const lines = input.split('\n')
|
|
27
|
-
const firstLine = lines[0]?.trim() ?? ''
|
|
28
|
-
const pragma: ExecPragma = {}
|
|
29
|
-
|
|
30
|
-
if (firstLine.startsWith(PRAGMA_PREFIX)) {
|
|
31
|
-
const jsonStr = firstLine.slice(PRAGMA_PREFIX.length).trim()
|
|
32
|
-
if (jsonStr) {
|
|
33
|
-
try {
|
|
34
|
-
const parsed = JSON.parse(jsonStr) as ExecPragma
|
|
35
|
-
// Validate fields
|
|
36
|
-
for (const key of Object.keys(parsed)) {
|
|
37
|
-
if (!['timeout_ms', 'yield_time_ms', 'max_output_tokens'].includes(key)) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`exec pragma only supports \`timeout_ms\`, \`yield_time_ms\`, and \`max_output_tokens\`; got \`${key}\``,
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (parsed.timeout_ms !== undefined) {
|
|
44
|
-
if (!Number.isSafeInteger(parsed.timeout_ms) || parsed.timeout_ms < 0) {
|
|
45
|
-
throw new Error('exec pragma field `timeout_ms` must be a non-negative safe integer')
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (parsed.yield_time_ms !== undefined) {
|
|
49
|
-
if (!Number.isSafeInteger(parsed.yield_time_ms) || parsed.yield_time_ms < 0) {
|
|
50
|
-
throw new Error('exec pragma field `yield_time_ms` must be a non-negative safe integer')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (parsed.max_output_tokens !== undefined) {
|
|
54
|
-
if (!Number.isSafeInteger(parsed.max_output_tokens) || parsed.max_output_tokens < 0) {
|
|
55
|
-
throw new Error(
|
|
56
|
-
'exec pragma field `max_output_tokens` must be a non-negative safe integer',
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
Object.assign(pragma, parsed)
|
|
61
|
-
} catch (err) {
|
|
62
|
-
throw new Error(`exec pragma parse error: ${fmtErr(err)}`)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return { code: lines.slice(1).join('\n').trim(), pragma }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return { code: input, pragma }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// ── TypeScript type rendering ────────────────────────────────────────────────
|
|
72
|
-
|
|
73
|
-
function renderTsType(param: Record<string, unknown>, depth = 0): string {
|
|
74
|
-
const indent = ' '.repeat(depth + 1)
|
|
75
|
-
const closeIndent = ' '.repeat(depth)
|
|
76
|
-
|
|
77
|
-
if (param.type === 'string') return 'string'
|
|
78
|
-
if (param.type === 'number' || param.type === 'integer') return 'number'
|
|
79
|
-
if (param.type === 'boolean') return 'boolean'
|
|
80
|
-
if (param.type === 'array') {
|
|
81
|
-
if (param.items) return `Array<${renderTsType(param.items as Record<string, unknown>, depth)}>`
|
|
82
|
-
return 'unknown[]'
|
|
83
|
-
}
|
|
84
|
-
if (param.type === 'object' || (param.properties as Record<string, unknown> | undefined)) {
|
|
85
|
-
const props = param.properties as Record<string, Record<string, unknown>> | undefined
|
|
86
|
-
const additionalProps = param.additionalProperties
|
|
87
|
-
if (!props && !additionalProps) return 'Record<string, unknown>'
|
|
88
|
-
|
|
89
|
-
const lines: string[] = ['{']
|
|
90
|
-
if (props) {
|
|
91
|
-
for (const [key, value] of Object.entries(props)) {
|
|
92
|
-
const isRequired =
|
|
93
|
-
Array.isArray(param.required) && (param.required as string[]).includes(key)
|
|
94
|
-
const opt = isRequired ? '' : '?'
|
|
95
|
-
const desc = value.description ? ` // ${value.description}` : ''
|
|
96
|
-
const valType = renderTsType(value, depth + 1)
|
|
97
|
-
lines.push(`${indent}${JSON.stringify(key)}${opt}: ${valType};${desc}`)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (additionalProps && additionalProps !== false) {
|
|
101
|
-
const valType =
|
|
102
|
-
typeof additionalProps === 'object'
|
|
103
|
-
? renderTsType(additionalProps as Record<string, unknown>, depth + 1)
|
|
104
|
-
: 'unknown'
|
|
105
|
-
lines.push(`${indent}[key: string]: ${valType};`)
|
|
106
|
-
}
|
|
107
|
-
lines.push(`${closeIndent}}`)
|
|
108
|
-
return lines.join('\n')
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return 'unknown'
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function renderToolDeclaration(tool: ToolDefinition): string {
|
|
115
|
-
const params = tool.parameters
|
|
116
|
-
const hasParams = params && Object.keys(params).length > 0
|
|
117
|
-
const paramType = hasParams
|
|
118
|
-
? renderTsType({
|
|
119
|
-
type: 'object',
|
|
120
|
-
properties: params,
|
|
121
|
-
required: Object.entries(params)
|
|
122
|
-
.filter(([_, v]) => v.required)
|
|
123
|
-
.map(([k]) => k),
|
|
124
|
-
} as unknown as Record<string, unknown>)
|
|
125
|
-
: '{}'
|
|
126
|
-
|
|
127
|
-
return `${tool.name}(args: ${paramType}): Promise<string>;`
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// ── Build the exec tool description with TypeScript declarations ────────────
|
|
131
|
-
|
|
132
|
-
function buildExecDescription(toolDefs: ToolDefinition[]): string {
|
|
133
|
-
const toolDeclarations = toolDefs
|
|
134
|
-
.filter(t => t.name !== 'exec')
|
|
135
|
-
.map(t => ` ${renderToolDeclaration(t)}`)
|
|
136
|
-
.join('\n')
|
|
137
|
-
|
|
138
|
-
return `Run JavaScript code to orchestrate/compose tool calls.
|
|
139
|
-
- Evaluates the provided JavaScript code in a fresh V8 sandbox as an async function.
|
|
140
|
-
- All tools are available on the global \`tools\` object, for example \`await tools.read({paths: ["file.ts"]})\`.
|
|
141
|
-
- Tool methods take an object as their input argument and return a string.
|
|
142
|
-
- Runs raw JavaScript — no \`require\`, no file system, no network access, no \`console\` (use \`text()\` instead).
|
|
143
|
-
- Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences.
|
|
144
|
-
- You may optionally start the tool input with a first-line pragma like \`// @exec: {"timeout_ms": 30000, "max_output_tokens": 1000}\`.
|
|
145
|
-
- \`timeout_ms\` sets the maximum execution time (default: 30000).
|
|
146
|
-
- \`max_output_tokens\` sets the token budget for results (approximate character limit).
|
|
147
|
-
|
|
148
|
-
Global helpers:
|
|
149
|
-
- \`text(value)\`: Appends a string to the output. Non-string values are stringified.
|
|
150
|
-
- \`exit()\`: Immediately ends the current script successfully.
|
|
151
|
-
- \`store(key, value)\`: Stores a value under a string key for later \`exec\` calls in the same session.
|
|
152
|
-
- \`load(key)\`: Returns the stored value, or \`undefined\` if missing.
|
|
153
|
-
|
|
154
|
-
Available tool declarations:
|
|
155
|
-
\`\`\`ts
|
|
156
|
-
declare const tools: {
|
|
157
|
-
${toolDeclarations}
|
|
158
|
-
};
|
|
159
|
-
\`\`\``
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// ── Exec tool factory ───────────────────────────────────────────────────────
|
|
163
|
-
|
|
164
|
-
export function createExecTool(getTools: () => Tool[]): Tool {
|
|
165
|
-
// Shared store across exec calls in the same session
|
|
166
|
-
const sharedStore = new Map<string, unknown>()
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
definition: {
|
|
170
|
-
name: 'exec',
|
|
171
|
-
description: 'Run JavaScript code to orchestrate tool calls in a sandboxed V8 isolate.',
|
|
172
|
-
parameters: {
|
|
173
|
-
code: {
|
|
174
|
-
type: 'string',
|
|
175
|
-
description:
|
|
176
|
-
'JavaScript source code to execute. Optionally starts with // @exec: {"timeout_ms": 30000} pragma.',
|
|
177
|
-
required: true,
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
async execute(input: Record<string, unknown>): Promise<ToolResult> {
|
|
182
|
-
const rawCode = input.code as string
|
|
183
|
-
if (!rawCode || typeof rawCode !== 'string') {
|
|
184
|
-
return {
|
|
185
|
-
success: false,
|
|
186
|
-
output: '',
|
|
187
|
-
error: 'exec expects a `code` string parameter with JavaScript source text.',
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Parse pragma
|
|
192
|
-
let code: string
|
|
193
|
-
let pragma: ExecPragma
|
|
194
|
-
try {
|
|
195
|
-
const parsed = parsePragma(rawCode)
|
|
196
|
-
code = parsed.code
|
|
197
|
-
pragma = parsed.pragma
|
|
198
|
-
} catch (err) {
|
|
199
|
-
return { success: false, output: '', error: fmtErr(err) }
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (!code.trim()) {
|
|
203
|
-
return {
|
|
204
|
-
success: false,
|
|
205
|
-
output: '',
|
|
206
|
-
error: 'exec expects non-empty JavaScript source text.',
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Build context
|
|
211
|
-
const ctx: ExecContext = {
|
|
212
|
-
tools: {},
|
|
213
|
-
store: sharedStore,
|
|
214
|
-
output: [],
|
|
215
|
-
notified: false,
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Wrap each registered tool as an async function available in the sandbox
|
|
219
|
-
const allTools = getTools()
|
|
220
|
-
for (const tool of allTools) {
|
|
221
|
-
if (tool.definition.name === 'exec') continue // don't expose exec itself
|
|
222
|
-
ctx.tools[tool.definition.name] = async (toolInput: unknown): Promise<string> => {
|
|
223
|
-
const result = await tool.execute((toolInput ?? {}) as Record<string, unknown>)
|
|
224
|
-
if (!result.success) {
|
|
225
|
-
throw new Error(`Tool "${tool.definition.name}" failed: ${result.error}`)
|
|
226
|
-
}
|
|
227
|
-
return result.output
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Wrap the code in an async function that receives the context
|
|
232
|
-
const wrappedCode = `
|
|
233
|
-
(async () => {
|
|
234
|
-
const tools = context.tools;
|
|
235
|
-
const store = context.store;
|
|
236
|
-
const output = context.output;
|
|
237
|
-
|
|
238
|
-
function text(value) {
|
|
239
|
-
if (value === null || value === undefined) output.push(String(value));
|
|
240
|
-
else if (typeof value === 'object') output.push(JSON.stringify(value));
|
|
241
|
-
else output.push(String(value));
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function exit() {
|
|
245
|
-
context.done = true;
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function store(key, value) {
|
|
250
|
-
context.store.set(key, value);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function load(key) {
|
|
254
|
-
return context.store.get(key);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
${code}
|
|
258
|
-
})()
|
|
259
|
-
`
|
|
260
|
-
|
|
261
|
-
// Create sandbox context
|
|
262
|
-
const sandbox = {
|
|
263
|
-
context: ctx,
|
|
264
|
-
setTimeout: setTimeout.bind(globalThis),
|
|
265
|
-
clearTimeout: clearTimeout.bind(globalThis),
|
|
266
|
-
console: {
|
|
267
|
-
log: (...args: unknown[]) => ctx.output.push(args.map(a => String(a)).join(' ')),
|
|
268
|
-
error: (...args: unknown[]) =>
|
|
269
|
-
ctx.output.push(`ERROR: ${args.map(a => String(a)).join(' ')}`),
|
|
270
|
-
warn: (...args: unknown[]) =>
|
|
271
|
-
ctx.output.push(`WARN: ${args.map(a => String(a)).join(' ')}`),
|
|
272
|
-
info: (...args: unknown[]) => ctx.output.push(args.map(a => String(a)).join(' ')),
|
|
273
|
-
},
|
|
274
|
-
// Safe globals
|
|
275
|
-
Array,
|
|
276
|
-
Object,
|
|
277
|
-
String,
|
|
278
|
-
Number,
|
|
279
|
-
Boolean,
|
|
280
|
-
Date,
|
|
281
|
-
Math,
|
|
282
|
-
JSON,
|
|
283
|
-
RegExp,
|
|
284
|
-
Map,
|
|
285
|
-
Set,
|
|
286
|
-
Promise,
|
|
287
|
-
Error,
|
|
288
|
-
TypeError,
|
|
289
|
-
RangeError,
|
|
290
|
-
SyntaxError,
|
|
291
|
-
ReferenceError,
|
|
292
|
-
parseInt,
|
|
293
|
-
parseFloat,
|
|
294
|
-
isNaN,
|
|
295
|
-
isFinite,
|
|
296
|
-
encodeURI,
|
|
297
|
-
decodeURI,
|
|
298
|
-
encodeURIComponent,
|
|
299
|
-
decodeURIComponent,
|
|
300
|
-
// TextEncoder/Decoder for buffer handling
|
|
301
|
-
TextEncoder,
|
|
302
|
-
TextDecoder,
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const timeout = pragma.timeout_ms ?? DEFAULT_TIMEOUT_MS
|
|
306
|
-
const maxOutputTokens = pragma.max_output_tokens ?? 10_000
|
|
307
|
-
const maxChars = maxOutputTokens * 4 // rough estimate
|
|
308
|
-
|
|
309
|
-
try {
|
|
310
|
-
const script = new vm.Script(wrappedCode, {
|
|
311
|
-
filename: 'exec-sandbox.js',
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
const vmContext = vm.createContext(sandbox)
|
|
315
|
-
await script.runInContext(vmContext, {
|
|
316
|
-
timeout: timeout,
|
|
317
|
-
breakOnSigint: true,
|
|
318
|
-
})
|
|
319
|
-
|
|
320
|
-
let output = ctx.output.join('')
|
|
321
|
-
if (output.length > maxChars) {
|
|
322
|
-
output = `${output.slice(0, maxChars)}\n\n... (output truncated)`
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return { success: true, output: output || '(exec completed with no output)' }
|
|
326
|
-
} catch (err) {
|
|
327
|
-
const msg = fmtErr(err)
|
|
328
|
-
if (msg.includes('timed out') || msg.includes('timeout')) {
|
|
329
|
-
return {
|
|
330
|
-
success: false,
|
|
331
|
-
output: ctx.output.join(''),
|
|
332
|
-
error: `exec timed out after ${timeout}ms`,
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return {
|
|
336
|
-
success: false,
|
|
337
|
-
output: ctx.output.join(''),
|
|
338
|
-
error: `exec error: ${msg}`,
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/** Rebuild the exec tool definition (called when tools change) */
|
|
346
|
-
export function updateExecToolDefinition(execTool: Tool, toolDefs: ToolDefinition[]): void {
|
|
347
|
-
execTool.definition.description = buildExecDescription(toolDefs)
|
|
348
|
-
}
|
package/src/tools/git.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process'
|
|
2
|
-
import type { Tool, ToolDefinition } from './types.js'
|
|
3
|
-
|
|
4
|
-
export const createGitTool = (cwd: string): Tool => {
|
|
5
|
-
const definition: ToolDefinition = {
|
|
6
|
-
name: 'git',
|
|
7
|
-
description:
|
|
8
|
-
'Run git commands for repository operations. Supports status, diff, log, show, branch, and other read-only git operations.',
|
|
9
|
-
parameters: {
|
|
10
|
-
command: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: 'Git subcommand and arguments (e.g. "status", "diff", "log --oneline -5")',
|
|
13
|
-
required: true,
|
|
14
|
-
},
|
|
15
|
-
path: { type: 'string', description: 'Repository path (default: cwd)', required: false },
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const execute = async (
|
|
20
|
-
input: Record<string, unknown>,
|
|
21
|
-
): Promise<{ success: boolean; output: string; error?: string }> => {
|
|
22
|
-
const gitCmd = String(input.command || '').trim()
|
|
23
|
-
const repoPath = String(input.path || cwd)
|
|
24
|
-
|
|
25
|
-
if (!gitCmd) {
|
|
26
|
-
return { success: false, output: '', error: 'command is required' }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Safety: block destructive commands
|
|
30
|
-
const destructivePatterns = [
|
|
31
|
-
/^reset\s+(--hard|--soft|--mixed|--merge|--keep)/i,
|
|
32
|
-
/^push\s+.*(--force|-f)/i,
|
|
33
|
-
/^(rebase|merge|cherry-pick|revert)\b/i,
|
|
34
|
-
/^branch\s+-[dD]/i,
|
|
35
|
-
/^tag\s+-[dD]/i,
|
|
36
|
-
/^(clean|gc|prune)\b/i,
|
|
37
|
-
/^update-ref\b/i,
|
|
38
|
-
/^rm\b/i,
|
|
39
|
-
/^commit\s+--amend/i,
|
|
40
|
-
/^checkout\s+.*-B/i,
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
for (const pattern of destructivePatterns) {
|
|
44
|
-
if (pattern.test(gitCmd)) {
|
|
45
|
-
return {
|
|
46
|
-
success: false,
|
|
47
|
-
output: '',
|
|
48
|
-
error: `Destructive git command not allowed: "${gitCmd}". Only read-only operations are permitted.`,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
const result = execSync(`git ${gitCmd}`, {
|
|
55
|
-
cwd: repoPath,
|
|
56
|
-
encoding: 'utf-8',
|
|
57
|
-
timeout: 30000,
|
|
58
|
-
maxBuffer: 10 * 1024 * 1024, // 10MB
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
return { success: true, output: result.trim() || '(empty output)' }
|
|
62
|
-
} catch (err) {
|
|
63
|
-
const error = err as { stderr?: string; stdout?: string; message?: string }
|
|
64
|
-
const stderr = error.stderr || ''
|
|
65
|
-
const stdout = error.stdout || ''
|
|
66
|
-
const msg = error.message || String(err)
|
|
67
|
-
return {
|
|
68
|
-
success: false,
|
|
69
|
-
output: stdout.trim(),
|
|
70
|
-
error: stderr.trim() || msg,
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return { definition, execute }
|
|
76
|
-
}
|