plugsuits 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +3 -0
- package/dist/agent-reasoning-default.test.d.ts +2 -0
- package/dist/agent-reasoning-default.test.d.ts.map +1 -0
- package/dist/agent-reasoning-default.test.js +38 -0
- package/dist/agent-reasoning-default.test.js.map +1 -0
- package/dist/agent.d.ts +61 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +308 -0
- package/dist/agent.js.map +1 -0
- package/dist/agent.test.d.ts +2 -0
- package/dist/agent.test.d.ts.map +1 -0
- package/dist/agent.test.js +38 -0
- package/dist/agent.test.js.map +1 -0
- package/dist/cli-args.d.ts +15 -0
- package/dist/cli-args.d.ts.map +1 -0
- package/dist/cli-args.js +63 -0
- package/dist/cli-args.js.map +1 -0
- package/dist/cli-args.test.d.ts +2 -0
- package/dist/cli-args.test.d.ts.map +1 -0
- package/dist/cli-args.test.js +105 -0
- package/dist/cli-args.test.js.map +1 -0
- package/dist/commands/aliases-and-tool-fallback.test.d.ts +2 -0
- package/dist/commands/aliases-and-tool-fallback.test.d.ts.map +1 -0
- package/dist/commands/aliases-and-tool-fallback.test.js +132 -0
- package/dist/commands/aliases-and-tool-fallback.test.js.map +1 -0
- package/dist/commands/clear.d.ts +3 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +12 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/factories/create-toggle-command.d.ts +13 -0
- package/dist/commands/factories/create-toggle-command.d.ts.map +1 -0
- package/dist/commands/factories/create-toggle-command.js +38 -0
- package/dist/commands/factories/create-toggle-command.js.map +1 -0
- package/dist/commands/help.d.ts +3 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +23 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/index.d.ts +18 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +82 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/model.d.ts +15 -0
- package/dist/commands/model.d.ts.map +1 -0
- package/dist/commands/model.js +100 -0
- package/dist/commands/model.js.map +1 -0
- package/dist/commands/reasoning-mode.d.ts +3 -0
- package/dist/commands/reasoning-mode.d.ts.map +1 -0
- package/dist/commands/reasoning-mode.js +47 -0
- package/dist/commands/reasoning-mode.js.map +1 -0
- package/dist/commands/render.d.ts +19 -0
- package/dist/commands/render.d.ts.map +1 -0
- package/dist/commands/render.js +140 -0
- package/dist/commands/render.js.map +1 -0
- package/dist/commands/render.test.d.ts +2 -0
- package/dist/commands/render.test.d.ts.map +1 -0
- package/dist/commands/render.test.js +36 -0
- package/dist/commands/render.test.js.map +1 -0
- package/dist/commands/tool-fallback.d.ts +3 -0
- package/dist/commands/tool-fallback.d.ts.map +1 -0
- package/dist/commands/tool-fallback.js +38 -0
- package/dist/commands/tool-fallback.js.map +1 -0
- package/dist/commands/translate.d.ts +3 -0
- package/dist/commands/translate.d.ts.map +1 -0
- package/dist/commands/translate.js +12 -0
- package/dist/commands/translate.js.map +1 -0
- package/dist/commands/translate.test.d.ts +2 -0
- package/dist/commands/translate.test.d.ts.map +1 -0
- package/dist/commands/translate.test.js +49 -0
- package/dist/commands/translate.test.js.map +1 -0
- package/dist/commands/types.d.ts +17 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/context/environment-context.d.ts +2 -0
- package/dist/context/environment-context.d.ts.map +1 -0
- package/dist/context/environment-context.js +11 -0
- package/dist/context/environment-context.js.map +1 -0
- package/dist/context/paths.d.ts +3 -0
- package/dist/context/paths.d.ts.map +1 -0
- package/dist/context/paths.js +3 -0
- package/dist/context/paths.js.map +1 -0
- package/dist/context/session.d.ts +4 -0
- package/dist/context/session.d.ts.map +1 -0
- package/dist/context/session.js +16 -0
- package/dist/context/session.js.map +1 -0
- package/dist/context/skill-command-prefix.d.ts +4 -0
- package/dist/context/skill-command-prefix.d.ts.map +1 -0
- package/dist/context/skill-command-prefix.js +15 -0
- package/dist/context/skill-command-prefix.js.map +1 -0
- package/dist/context/skills-integration.test.d.ts +2 -0
- package/dist/context/skills-integration.test.d.ts.map +1 -0
- package/dist/context/skills-integration.test.js +87 -0
- package/dist/context/skills-integration.test.js.map +1 -0
- package/dist/context/skills.d.ts +18 -0
- package/dist/context/skills.d.ts.map +1 -0
- package/dist/context/skills.js +431 -0
- package/dist/context/skills.js.map +1 -0
- package/dist/context/skills.test.d.ts +2 -0
- package/dist/context/skills.test.d.ts.map +1 -0
- package/dist/context/skills.test.js +20 -0
- package/dist/context/skills.test.js.map +1 -0
- package/dist/context/system-prompt.d.ts +2 -0
- package/dist/context/system-prompt.d.ts.map +1 -0
- package/dist/context/system-prompt.js +100 -0
- package/dist/context/system-prompt.js.map +1 -0
- package/dist/context/translation-integration.test.d.ts +2 -0
- package/dist/context/translation-integration.test.d.ts.map +1 -0
- package/dist/context/translation-integration.test.js +138 -0
- package/dist/context/translation-integration.test.js.map +1 -0
- package/dist/context/translation.d.ts +21 -0
- package/dist/context/translation.d.ts.map +1 -0
- package/dist/context/translation.js +82 -0
- package/dist/context/translation.js.map +1 -0
- package/dist/context/translation.test.d.ts +2 -0
- package/dist/context/translation.test.d.ts.map +1 -0
- package/dist/context/translation.test.js +129 -0
- package/dist/context/translation.test.js.map +1 -0
- package/dist/entrypoints/cli-input-rendering.test.d.ts +2 -0
- package/dist/entrypoints/cli-input-rendering.test.d.ts.map +1 -0
- package/dist/entrypoints/cli-input-rendering.test.js +192 -0
- package/dist/entrypoints/cli-input-rendering.test.js.map +1 -0
- package/dist/entrypoints/cli.d.ts +3 -0
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli.js +1268 -0
- package/dist/entrypoints/cli.js.map +1 -0
- package/dist/entrypoints/headless-agent-config.d.ts +21 -0
- package/dist/entrypoints/headless-agent-config.d.ts.map +1 -0
- package/dist/entrypoints/headless-agent-config.js +15 -0
- package/dist/entrypoints/headless-agent-config.js.map +1 -0
- package/dist/entrypoints/headless-agent-config.test.d.ts +2 -0
- package/dist/entrypoints/headless-agent-config.test.d.ts.map +1 -0
- package/dist/entrypoints/headless-agent-config.test.js +63 -0
- package/dist/entrypoints/headless-agent-config.test.js.map +1 -0
- package/dist/entrypoints/headless.d.ts +3 -0
- package/dist/entrypoints/headless.d.ts.map +1 -0
- package/dist/entrypoints/headless.js +396 -0
- package/dist/entrypoints/headless.js.map +1 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +14 -0
- package/dist/env.js.map +1 -0
- package/dist/friendli-models.d.ts +21 -0
- package/dist/friendli-models.d.ts.map +1 -0
- package/dist/friendli-models.js +57 -0
- package/dist/friendli-models.js.map +1 -0
- package/dist/friendli-reasoning.d.ts +10 -0
- package/dist/friendli-reasoning.d.ts.map +1 -0
- package/dist/friendli-reasoning.js +181 -0
- package/dist/friendli-reasoning.js.map +1 -0
- package/dist/friendli-reasoning.test.d.ts +2 -0
- package/dist/friendli-reasoning.test.d.ts.map +1 -0
- package/dist/friendli-reasoning.test.js +77 -0
- package/dist/friendli-reasoning.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/colors.d.ts +22 -0
- package/dist/interaction/colors.d.ts.map +1 -0
- package/dist/interaction/colors.js +24 -0
- package/dist/interaction/colors.js.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.d.ts +19 -0
- package/dist/interaction/pi-tui-stream-renderer.d.ts.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.js +1509 -0
- package/dist/interaction/pi-tui-stream-renderer.js.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.test.d.ts +2 -0
- package/dist/interaction/pi-tui-stream-renderer.test.d.ts.map +1 -0
- package/dist/interaction/pi-tui-stream-renderer.test.js +1314 -0
- package/dist/interaction/pi-tui-stream-renderer.test.js.map +1 -0
- package/dist/interaction/spinner.d.ts +13 -0
- package/dist/interaction/spinner.d.ts.map +1 -0
- package/dist/interaction/spinner.js +51 -0
- package/dist/interaction/spinner.js.map +1 -0
- package/dist/middleware/index.d.ts +7 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +15 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/todo-continuation.d.ts +11 -0
- package/dist/middleware/todo-continuation.d.ts.map +1 -0
- package/dist/middleware/todo-continuation.js +103 -0
- package/dist/middleware/todo-continuation.js.map +1 -0
- package/dist/middleware/trim-leading-newlines.d.ts +3 -0
- package/dist/middleware/trim-leading-newlines.d.ts.map +1 -0
- package/dist/middleware/trim-leading-newlines.js +49 -0
- package/dist/middleware/trim-leading-newlines.js.map +1 -0
- package/dist/reasoning-mode.d.ts +5 -0
- package/dist/reasoning-mode.d.ts.map +1 -0
- package/dist/reasoning-mode.js +30 -0
- package/dist/reasoning-mode.js.map +1 -0
- package/dist/reasoning-mode.test.d.ts +2 -0
- package/dist/reasoning-mode.test.d.ts.map +1 -0
- package/dist/reasoning-mode.test.js +22 -0
- package/dist/reasoning-mode.test.js.map +1 -0
- package/dist/tool-fallback-mode.d.ts +6 -0
- package/dist/tool-fallback-mode.d.ts.map +1 -0
- package/dist/tool-fallback-mode.js +25 -0
- package/dist/tool-fallback-mode.js.map +1 -0
- package/dist/tools/execute/shell-execute.d.ts +17 -0
- package/dist/tools/execute/shell-execute.d.ts.map +1 -0
- package/dist/tools/execute/shell-execute.js +55 -0
- package/dist/tools/execute/shell-execute.js.map +1 -0
- package/dist/tools/execute/shell-execute.test.d.ts +2 -0
- package/dist/tools/execute/shell-execute.test.d.ts.map +1 -0
- package/dist/tools/execute/shell-execute.test.js +86 -0
- package/dist/tools/execute/shell-execute.test.js.map +1 -0
- package/dist/tools/execute/shell-interact.d.ts +10 -0
- package/dist/tools/execute/shell-interact.d.ts.map +1 -0
- package/dist/tools/execute/shell-interact.js +122 -0
- package/dist/tools/execute/shell-interact.js.map +1 -0
- package/dist/tools/execute/shell-interact.test.d.ts +2 -0
- package/dist/tools/execute/shell-interact.test.d.ts.map +1 -0
- package/dist/tools/execute/shell-interact.test.js +175 -0
- package/dist/tools/execute/shell-interact.test.js.map +1 -0
- package/dist/tools/explore/glob.d.ts +15 -0
- package/dist/tools/explore/glob.d.ts.map +1 -0
- package/dist/tools/explore/glob.js +107 -0
- package/dist/tools/explore/glob.js.map +1 -0
- package/dist/tools/explore/glob.test.d.ts +2 -0
- package/dist/tools/explore/glob.test.d.ts.map +1 -0
- package/dist/tools/explore/glob.test.js +183 -0
- package/dist/tools/explore/glob.test.js.map +1 -0
- package/dist/tools/explore/grep.d.ts +27 -0
- package/dist/tools/explore/grep.d.ts.map +1 -0
- package/dist/tools/explore/grep.js +203 -0
- package/dist/tools/explore/grep.js.map +1 -0
- package/dist/tools/explore/grep.test.d.ts +2 -0
- package/dist/tools/explore/grep.test.d.ts.map +1 -0
- package/dist/tools/explore/grep.test.js +132 -0
- package/dist/tools/explore/grep.test.js.map +1 -0
- package/dist/tools/explore/read-file.d.ts +23 -0
- package/dist/tools/explore/read-file.d.ts.map +1 -0
- package/dist/tools/explore/read-file.js +84 -0
- package/dist/tools/explore/read-file.js.map +1 -0
- package/dist/tools/explore/read-file.test.d.ts +2 -0
- package/dist/tools/explore/read-file.test.d.ts.map +1 -0
- package/dist/tools/explore/read-file.test.js +278 -0
- package/dist/tools/explore/read-file.test.js.map +1 -0
- package/dist/tools/index.d.ts +71 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +26 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/modify/delete-file.d.ts +19 -0
- package/dist/tools/modify/delete-file.d.ts.map +1 -0
- package/dist/tools/modify/delete-file.js +71 -0
- package/dist/tools/modify/delete-file.js.map +1 -0
- package/dist/tools/modify/delete-file.test.d.ts +2 -0
- package/dist/tools/modify/delete-file.test.d.ts.map +1 -0
- package/dist/tools/modify/delete-file.test.js +136 -0
- package/dist/tools/modify/delete-file.test.js.map +1 -0
- package/dist/tools/modify/edit-file-diagnostics.d.ts +17 -0
- package/dist/tools/modify/edit-file-diagnostics.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-diagnostics.js +157 -0
- package/dist/tools/modify/edit-file-diagnostics.js.map +1 -0
- package/dist/tools/modify/edit-file-repair.d.ts +13 -0
- package/dist/tools/modify/edit-file-repair.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-repair.js +135 -0
- package/dist/tools/modify/edit-file-repair.js.map +1 -0
- package/dist/tools/modify/edit-file-stress.test.d.ts +2 -0
- package/dist/tools/modify/edit-file-stress.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-stress.test.js +163 -0
- package/dist/tools/modify/edit-file-stress.test.js.map +1 -0
- package/dist/tools/modify/edit-file-validation.d.ts +9 -0
- package/dist/tools/modify/edit-file-validation.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-validation.js +86 -0
- package/dist/tools/modify/edit-file-validation.js.map +1 -0
- package/dist/tools/modify/edit-file-whitespace.test.d.ts +2 -0
- package/dist/tools/modify/edit-file-whitespace.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file-whitespace.test.js +90 -0
- package/dist/tools/modify/edit-file-whitespace.test.js.map +1 -0
- package/dist/tools/modify/edit-file.d.ts +33 -0
- package/dist/tools/modify/edit-file.d.ts.map +1 -0
- package/dist/tools/modify/edit-file.js +177 -0
- package/dist/tools/modify/edit-file.js.map +1 -0
- package/dist/tools/modify/edit-file.test.d.ts +2 -0
- package/dist/tools/modify/edit-file.test.d.ts.map +1 -0
- package/dist/tools/modify/edit-file.test.js +948 -0
- package/dist/tools/modify/edit-file.test.js.map +1 -0
- package/dist/tools/modify/write-file.d.ts +17 -0
- package/dist/tools/modify/write-file.d.ts.map +1 -0
- package/dist/tools/modify/write-file.js +39 -0
- package/dist/tools/modify/write-file.js.map +1 -0
- package/dist/tools/modify/write-file.test.d.ts +2 -0
- package/dist/tools/modify/write-file.test.d.ts.map +1 -0
- package/dist/tools/modify/write-file.test.js +168 -0
- package/dist/tools/modify/write-file.test.js.map +1 -0
- package/dist/tools/planning/load-skill.d.ts +13 -0
- package/dist/tools/planning/load-skill.d.ts.map +1 -0
- package/dist/tools/planning/load-skill.js +101 -0
- package/dist/tools/planning/load-skill.js.map +1 -0
- package/dist/tools/planning/load-skill.test.d.ts +2 -0
- package/dist/tools/planning/load-skill.test.d.ts.map +1 -0
- package/dist/tools/planning/load-skill.test.js +37 -0
- package/dist/tools/planning/load-skill.test.js.map +1 -0
- package/dist/tools/planning/todo-write.d.ts +49 -0
- package/dist/tools/planning/todo-write.d.ts.map +1 -0
- package/dist/tools/planning/todo-write.js +118 -0
- package/dist/tools/planning/todo-write.js.map +1 -0
- package/dist/tools/planning/todo-write.test.d.ts +2 -0
- package/dist/tools/planning/todo-write.test.d.ts.map +1 -0
- package/dist/tools/planning/todo-write.test.js +82 -0
- package/dist/tools/planning/todo-write.test.js.map +1 -0
- package/dist/tools/utils/execute/format-utils.d.ts +4 -0
- package/dist/tools/utils/execute/format-utils.d.ts.map +1 -0
- package/dist/tools/utils/execute/format-utils.js +31 -0
- package/dist/tools/utils/execute/format-utils.js.map +1 -0
- package/dist/tools/utils/execute/format-utils.test.d.ts +2 -0
- package/dist/tools/utils/execute/format-utils.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/format-utils.test.js +40 -0
- package/dist/tools/utils/execute/format-utils.test.js.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.d.ts +12 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.d.ts.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.js +269 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.js.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts +2 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.js +233 -0
- package/dist/tools/utils/execute/noninteractive-wrapper.test.js.map +1 -0
- package/dist/tools/utils/execute/output-handler.d.ts +14 -0
- package/dist/tools/utils/execute/output-handler.d.ts.map +1 -0
- package/dist/tools/utils/execute/output-handler.js +71 -0
- package/dist/tools/utils/execute/output-handler.js.map +1 -0
- package/dist/tools/utils/execute/output-handler.test.d.ts +2 -0
- package/dist/tools/utils/execute/output-handler.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/output-handler.test.js +58 -0
- package/dist/tools/utils/execute/output-handler.test.js.map +1 -0
- package/dist/tools/utils/execute/process-manager.d.ts +17 -0
- package/dist/tools/utils/execute/process-manager.d.ts.map +1 -0
- package/dist/tools/utils/execute/process-manager.js +229 -0
- package/dist/tools/utils/execute/process-manager.js.map +1 -0
- package/dist/tools/utils/execute/process-manager.test.d.ts +2 -0
- package/dist/tools/utils/execute/process-manager.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/process-manager.test.js +139 -0
- package/dist/tools/utils/execute/process-manager.test.js.map +1 -0
- package/dist/tools/utils/execute/shell-detection.d.ts +3 -0
- package/dist/tools/utils/execute/shell-detection.d.ts.map +1 -0
- package/dist/tools/utils/execute/shell-detection.js +56 -0
- package/dist/tools/utils/execute/shell-detection.js.map +1 -0
- package/dist/tools/utils/execute/shell-detection.test.d.ts +2 -0
- package/dist/tools/utils/execute/shell-detection.test.d.ts.map +1 -0
- package/dist/tools/utils/execute/shell-detection.test.js +86 -0
- package/dist/tools/utils/execute/shell-detection.test.js.map +1 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts +5 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.d.ts.map +1 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.js +113 -0
- package/dist/tools/utils/hashline/autocorrect-replacement-lines.js.map +1 -0
- package/dist/tools/utils/hashline/constants.d.ts +5 -0
- package/dist/tools/utils/hashline/constants.d.ts.map +1 -0
- package/dist/tools/utils/hashline/constants.js +11 -0
- package/dist/tools/utils/hashline/constants.js.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.d.ts +7 -0
- package/dist/tools/utils/hashline/diff-utils.d.ts.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.js +50 -0
- package/dist/tools/utils/hashline/diff-utils.js.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.test.d.ts +2 -0
- package/dist/tools/utils/hashline/diff-utils.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/diff-utils.test.js +46 -0
- package/dist/tools/utils/hashline/diff-utils.test.js.map +1 -0
- package/dist/tools/utils/hashline/edit-deduplication.d.ts +6 -0
- package/dist/tools/utils/hashline/edit-deduplication.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-deduplication.js +32 -0
- package/dist/tools/utils/hashline/edit-deduplication.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.d.ts +11 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.js +93 -0
- package/dist/tools/utils/hashline/edit-operation-primitives.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.d.ts +9 -0
- package/dist/tools/utils/hashline/edit-operations.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.js +101 -0
- package/dist/tools/utils/hashline/edit-operations.js.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.test.d.ts +2 -0
- package/dist/tools/utils/hashline/edit-operations.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-operations.test.js +135 -0
- package/dist/tools/utils/hashline/edit-operations.test.js.map +1 -0
- package/dist/tools/utils/hashline/edit-ordering.d.ts +5 -0
- package/dist/tools/utils/hashline/edit-ordering.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-ordering.js +54 -0
- package/dist/tools/utils/hashline/edit-ordering.js.map +1 -0
- package/dist/tools/utils/hashline/edit-text-normalization.d.ts +9 -0
- package/dist/tools/utils/hashline/edit-text-normalization.d.ts.map +1 -0
- package/dist/tools/utils/hashline/edit-text-normalization.js +135 -0
- package/dist/tools/utils/hashline/edit-text-normalization.js.map +1 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.d.ts +8 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.d.ts.map +1 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.js +42 -0
- package/dist/tools/utils/hashline/file-text-canonicalization.js.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.d.ts +14 -0
- package/dist/tools/utils/hashline/hash-computation.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.js +158 -0
- package/dist/tools/utils/hashline/hash-computation.js.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.test.d.ts +2 -0
- package/dist/tools/utils/hashline/hash-computation.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hash-computation.test.js +63 -0
- package/dist/tools/utils/hashline/hash-computation.test.js.map +1 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts +11 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.js +41 -0
- package/dist/tools/utils/hashline/hashline-chunk-formatter.js.map +1 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.d.ts +2 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.d.ts.map +1 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.js +27 -0
- package/dist/tools/utils/hashline/hashline-edit-diff.js.map +1 -0
- package/dist/tools/utils/hashline/index.d.ts +14 -0
- package/dist/tools/utils/hashline/index.d.ts.map +1 -0
- package/dist/tools/utils/hashline/index.js +11 -0
- package/dist/tools/utils/hashline/index.js.map +1 -0
- package/dist/tools/utils/hashline/merge-expansion.d.ts +4 -0
- package/dist/tools/utils/hashline/merge-expansion.d.ts.map +1 -0
- package/dist/tools/utils/hashline/merge-expansion.js +105 -0
- package/dist/tools/utils/hashline/merge-expansion.js.map +1 -0
- package/dist/tools/utils/hashline/normalize-edits.d.ts +11 -0
- package/dist/tools/utils/hashline/normalize-edits.d.ts.map +1 -0
- package/dist/tools/utils/hashline/normalize-edits.js +81 -0
- package/dist/tools/utils/hashline/normalize-edits.js.map +1 -0
- package/dist/tools/utils/hashline/types.d.ts +18 -0
- package/dist/tools/utils/hashline/types.d.ts.map +1 -0
- package/dist/tools/utils/hashline/types.js +2 -0
- package/dist/tools/utils/hashline/types.js.map +1 -0
- package/dist/tools/utils/hashline/validation.d.ts +19 -0
- package/dist/tools/utils/hashline/validation.d.ts.map +1 -0
- package/dist/tools/utils/hashline/validation.js +161 -0
- package/dist/tools/utils/hashline/validation.js.map +1 -0
- package/dist/tools/utils/hashline/validation.test.d.ts +2 -0
- package/dist/tools/utils/hashline/validation.test.d.ts.map +1 -0
- package/dist/tools/utils/hashline/validation.test.js +86 -0
- package/dist/tools/utils/hashline/validation.test.js.map +1 -0
- package/dist/tools/utils/safety-utils.d.ts +66 -0
- package/dist/tools/utils/safety-utils.d.ts.map +1 -0
- package/dist/tools/utils/safety-utils.js +681 -0
- package/dist/tools/utils/safety-utils.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +16 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +257 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/package.json +49 -0
- package/src/AGENTS.md +52 -0
- package/src/agent-reasoning-default.test.ts +48 -0
- package/src/agent.test.ts +49 -0
- package/src/agent.ts +455 -0
- package/src/cli-args.test.ts +152 -0
- package/src/cli-args.ts +90 -0
- package/src/commands/aliases-and-tool-fallback.test.ts +172 -0
- package/src/commands/clear.ts +14 -0
- package/src/commands/factories/create-toggle-command.ts +68 -0
- package/src/commands/help.ts +30 -0
- package/src/commands/index.ts +125 -0
- package/src/commands/model.ts +146 -0
- package/src/commands/reasoning-mode.ts +55 -0
- package/src/commands/render.test.ts +47 -0
- package/src/commands/render.ts +205 -0
- package/src/commands/tool-fallback.ts +47 -0
- package/src/commands/translate.test.ts +62 -0
- package/src/commands/translate.ts +14 -0
- package/src/commands/types.ts +18 -0
- package/src/context/environment-context.ts +11 -0
- package/src/context/paths.ts +2 -0
- package/src/context/session.ts +18 -0
- package/src/context/skill-command-prefix.ts +18 -0
- package/src/context/skills-integration.test.ts +113 -0
- package/src/context/skills.test.ts +25 -0
- package/src/context/skills.ts +566 -0
- package/src/context/system-prompt.ts +100 -0
- package/src/context/translation-integration.test.ts +194 -0
- package/src/context/translation.test.ts +186 -0
- package/src/context/translation.ts +122 -0
- package/src/entrypoints/AGENTS.md +33 -0
- package/src/entrypoints/cli-input-rendering.test.ts +236 -0
- package/src/entrypoints/cli.ts +1845 -0
- package/src/entrypoints/headless-agent-config.test.ts +82 -0
- package/src/entrypoints/headless-agent-config.ts +42 -0
- package/src/entrypoints/headless.ts +622 -0
- package/src/env.ts +14 -0
- package/src/friendli-models.ts +81 -0
- package/src/friendli-reasoning.test.ts +147 -0
- package/src/friendli-reasoning.ts +280 -0
- package/src/index.ts +3 -0
- package/src/interaction/colors.ts +24 -0
- package/src/interaction/pi-tui-stream-renderer.test.ts +1471 -0
- package/src/interaction/pi-tui-stream-renderer.ts +2150 -0
- package/src/interaction/spinner.ts +61 -0
- package/src/middleware/index.ts +32 -0
- package/src/middleware/todo-continuation.ts +128 -0
- package/src/middleware/trim-leading-newlines.ts +66 -0
- package/src/reasoning-mode.test.ts +24 -0
- package/src/reasoning-mode.ts +40 -0
- package/src/skills/example/SKILL.md +44 -0
- package/src/skills/example/references/api.md +37 -0
- package/src/skills/example/scripts/setup.sh +13 -0
- package/src/skills/git-workflow.md +405 -0
- package/src/tool-fallback-mode.ts +34 -0
- package/src/tools/AGENTS.md +44 -0
- package/src/tools/execute/shell-execute.test.ts +114 -0
- package/src/tools/execute/shell-execute.ts +74 -0
- package/src/tools/execute/shell-execute.txt +27 -0
- package/src/tools/execute/shell-interact.test.ts +236 -0
- package/src/tools/execute/shell-interact.ts +151 -0
- package/src/tools/execute/shell-interact.txt +15 -0
- package/src/tools/explore/glob-files.txt +8 -0
- package/src/tools/explore/glob.test.ts +217 -0
- package/src/tools/explore/glob.ts +137 -0
- package/src/tools/explore/grep-files.txt +12 -0
- package/src/tools/explore/grep.test.ts +183 -0
- package/src/tools/explore/grep.ts +266 -0
- package/src/tools/explore/read-file.test.ts +355 -0
- package/src/tools/explore/read-file.ts +102 -0
- package/src/tools/explore/read-file.txt +24 -0
- package/src/tools/index.ts +29 -0
- package/src/tools/modify/AGENTS.md +38 -0
- package/src/tools/modify/delete-file.test.ts +200 -0
- package/src/tools/modify/delete-file.ts +95 -0
- package/src/tools/modify/delete-file.txt +9 -0
- package/src/tools/modify/edit-file-diagnostics.ts +210 -0
- package/src/tools/modify/edit-file-repair.ts +183 -0
- package/src/tools/modify/edit-file-stress.test.ts +200 -0
- package/src/tools/modify/edit-file-validation.ts +134 -0
- package/src/tools/modify/edit-file-whitespace.test.ts +117 -0
- package/src/tools/modify/edit-file.test.ts +1231 -0
- package/src/tools/modify/edit-file.ts +252 -0
- package/src/tools/modify/edit-file.txt +73 -0
- package/src/tools/modify/write-file.test.ts +240 -0
- package/src/tools/modify/write-file.ts +56 -0
- package/src/tools/modify/write-file.txt +9 -0
- package/src/tools/planning/load-skill.test.ts +48 -0
- package/src/tools/planning/load-skill.ts +136 -0
- package/src/tools/planning/load-skill.txt +6 -0
- package/src/tools/planning/todo-write.test.ts +91 -0
- package/src/tools/planning/todo-write.ts +141 -0
- package/src/tools/planning/todo-write.txt +7 -0
- package/src/tools/utils/execute/format-utils.test.ts +53 -0
- package/src/tools/utils/execute/format-utils.ts +37 -0
- package/src/tools/utils/execute/noninteractive-wrapper.test.ts +306 -0
- package/src/tools/utils/execute/noninteractive-wrapper.ts +314 -0
- package/src/tools/utils/execute/output-handler.test.ts +72 -0
- package/src/tools/utils/execute/output-handler.ts +101 -0
- package/src/tools/utils/execute/process-manager.test.ts +175 -0
- package/src/tools/utils/execute/process-manager.ts +310 -0
- package/src/tools/utils/execute/shell-detection.test.ts +112 -0
- package/src/tools/utils/execute/shell-detection.ts +72 -0
- package/src/tools/utils/hashline/autocorrect-replacement-lines.ts +159 -0
- package/src/tools/utils/hashline/constants.ts +13 -0
- package/src/tools/utils/hashline/diff-utils.test.ts +61 -0
- package/src/tools/utils/hashline/diff-utils.ts +64 -0
- package/src/tools/utils/hashline/edit-deduplication.ts +40 -0
- package/src/tools/utils/hashline/edit-operation-primitives.ts +149 -0
- package/src/tools/utils/hashline/edit-operations.test.ts +154 -0
- package/src/tools/utils/hashline/edit-operations.ts +132 -0
- package/src/tools/utils/hashline/edit-ordering.ts +60 -0
- package/src/tools/utils/hashline/edit-text-normalization.ts +180 -0
- package/src/tools/utils/hashline/file-text-canonicalization.ts +58 -0
- package/src/tools/utils/hashline/hash-computation.test.ts +82 -0
- package/src/tools/utils/hashline/hash-computation.ts +199 -0
- package/src/tools/utils/hashline/hashline-chunk-formatter.ts +61 -0
- package/src/tools/utils/hashline/hashline-edit-diff.ts +35 -0
- package/src/tools/utils/hashline/index.ts +55 -0
- package/src/tools/utils/hashline/merge-expansion.ts +120 -0
- package/src/tools/utils/hashline/normalize-edits.ts +127 -0
- package/src/tools/utils/hashline/types.ts +20 -0
- package/src/tools/utils/hashline/validation.test.ts +109 -0
- package/src/tools/utils/hashline/validation.ts +212 -0
- package/src/tools/utils/safety-utils.ts +938 -0
- package/src/utils/tools-manager.ts +353 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
2
|
+
import { isAbsolute, join, normalize, relative } from "node:path";
|
|
3
|
+
import { tool } from "ai";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { loadSkillById, type SkillInfo } from "../../context/skills";
|
|
6
|
+
import LOAD_SKILL_DESCRIPTION from "./load-skill.txt";
|
|
7
|
+
|
|
8
|
+
const inputSchema = z.object({
|
|
9
|
+
skillName: z
|
|
10
|
+
.string()
|
|
11
|
+
.describe("Name of the skill to load (e.g., 'git-workflow')"),
|
|
12
|
+
relativePath: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe(
|
|
16
|
+
"Optional: Relative path to file within v2 skill directory (e.g., 'scripts/setup.sh')"
|
|
17
|
+
),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type LoadSkillInput = z.infer<typeof inputSchema>;
|
|
21
|
+
|
|
22
|
+
function validateSkillName(skillName: string): string | null {
|
|
23
|
+
if (!skillName || skillName.trim() === "") {
|
|
24
|
+
throw new Error("skillName must be a non-empty string");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (skillName.includes("..") || skillName.includes("/")) {
|
|
28
|
+
return `Error: Invalid skill name '${skillName}'. Skill names cannot contain '..' or '/'.`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function validateRelativePath(relativePath: string): string | null {
|
|
35
|
+
if (relativePath.includes("..") || isAbsolute(relativePath)) {
|
|
36
|
+
return `Error: Invalid relative path '${relativePath}'. Path must be relative and cannot contain '..'.`;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function loadSubFile(
|
|
42
|
+
skillName: string,
|
|
43
|
+
relativePath: string,
|
|
44
|
+
info: SkillInfo & { dirPath: string }
|
|
45
|
+
): Promise<string> {
|
|
46
|
+
const fullPath = normalize(join(info.dirPath, relativePath));
|
|
47
|
+
const realSkillDir = await realpath(info.dirPath);
|
|
48
|
+
const realFilePath = await realpath(fullPath).catch(() => fullPath);
|
|
49
|
+
|
|
50
|
+
const relativeFromSkillDir = relative(realSkillDir, realFilePath);
|
|
51
|
+
const isWithinSkillDir =
|
|
52
|
+
relativeFromSkillDir === "" ||
|
|
53
|
+
!(
|
|
54
|
+
relativeFromSkillDir.startsWith("..") || isAbsolute(relativeFromSkillDir)
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (!isWithinSkillDir) {
|
|
58
|
+
return `Error: Path '${relativePath}' resolves outside skill directory. This is not allowed.`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const fileContent = await readFile(realFilePath, "utf-8");
|
|
63
|
+
return `# Skill File: ${skillName}/${relativePath}\n\n${fileContent}`;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
66
|
+
return `Error: File '${relativePath}' not found in skill '${skillName}'.`;
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getSourceLabel(source: SkillInfo["source"]): string {
|
|
73
|
+
if (source === "bundled") {
|
|
74
|
+
return "Bundled";
|
|
75
|
+
}
|
|
76
|
+
if (source === "global") {
|
|
77
|
+
return "Global";
|
|
78
|
+
}
|
|
79
|
+
return "Project";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function executeLoadSkill({
|
|
83
|
+
skillName,
|
|
84
|
+
relativePath,
|
|
85
|
+
}: LoadSkillInput): Promise<string> {
|
|
86
|
+
// Validate skill name
|
|
87
|
+
const nameError = validateSkillName(skillName);
|
|
88
|
+
if (nameError) {
|
|
89
|
+
return nameError;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Validate relative path if provided
|
|
93
|
+
if (relativePath) {
|
|
94
|
+
const pathError = validateRelativePath(relativePath);
|
|
95
|
+
if (pathError) {
|
|
96
|
+
return pathError;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const result = await loadSkillById(skillName);
|
|
102
|
+
|
|
103
|
+
if (!result) {
|
|
104
|
+
return `Error: Skill '${skillName}' not found. Available skills can be found in the system prompt.`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const { content, info } = result;
|
|
108
|
+
|
|
109
|
+
// If relativePath is provided, load that file instead
|
|
110
|
+
if (relativePath) {
|
|
111
|
+
if (info.format !== "v2" || !info.dirPath) {
|
|
112
|
+
return `Error: Skill '${skillName}' is a legacy format skill. Only v2 skills support subdirectory files.`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return loadSubFile(
|
|
116
|
+
skillName,
|
|
117
|
+
relativePath,
|
|
118
|
+
info as SkillInfo & { dirPath: string }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Load main skill file
|
|
123
|
+
const sourceLabel = getSourceLabel(info.source);
|
|
124
|
+
const formatLabel = info.format === "v2" ? " (v2)" : "";
|
|
125
|
+
|
|
126
|
+
return `# Skill Loaded: ${skillName} [${sourceLabel}${formatLabel}]\n\n${content}`;
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return `Error loading skill '${skillName}': ${error instanceof Error ? error.message : String(error)}`;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const loadSkillTool = tool({
|
|
133
|
+
description: LOAD_SKILL_DESCRIPTION,
|
|
134
|
+
inputSchema,
|
|
135
|
+
execute: executeLoadSkill,
|
|
136
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { initializeSession } from "../../context/session";
|
|
5
|
+
import { executeTodoWrite } from "./todo-write";
|
|
6
|
+
|
|
7
|
+
const testDir = join(process.cwd(), ".cea");
|
|
8
|
+
|
|
9
|
+
describe("executeTodoWrite", () => {
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
initializeSession();
|
|
12
|
+
try {
|
|
13
|
+
await rm(testDir, { recursive: true, force: true });
|
|
14
|
+
} catch {
|
|
15
|
+
// Ignore if directory doesn't exist
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(async () => {
|
|
20
|
+
try {
|
|
21
|
+
await rm(testDir, { recursive: true, force: true });
|
|
22
|
+
} catch {
|
|
23
|
+
// Cleanup - ignore errors
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("creates todo list with multiple tasks", async () => {
|
|
28
|
+
const result = await executeTodoWrite({
|
|
29
|
+
todos: [
|
|
30
|
+
{
|
|
31
|
+
id: "1",
|
|
32
|
+
content: "First task",
|
|
33
|
+
status: "pending",
|
|
34
|
+
priority: "high",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "2",
|
|
38
|
+
content: "Second task",
|
|
39
|
+
status: "in_progress",
|
|
40
|
+
priority: "medium",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result).toContain("OK - updated todo list");
|
|
46
|
+
expect(result).toContain("total: 2 tasks");
|
|
47
|
+
expect(result).toContain("pending: 1");
|
|
48
|
+
expect(result).toContain("in_progress: 1");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("handles empty todo list", async () => {
|
|
52
|
+
const result = await executeTodoWrite({
|
|
53
|
+
todos: [],
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(result).toContain("OK - updated todo list");
|
|
57
|
+
expect(result).toContain("total: 0 tasks");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("includes task descriptions in output", async () => {
|
|
61
|
+
const result = await executeTodoWrite({
|
|
62
|
+
todos: [
|
|
63
|
+
{
|
|
64
|
+
id: "1",
|
|
65
|
+
content: "Task with description",
|
|
66
|
+
status: "pending",
|
|
67
|
+
priority: "high",
|
|
68
|
+
description: "Detailed description here",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(result).toContain("Task with description");
|
|
74
|
+
expect(result).toContain("Detailed description here");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("rejects empty content", () => {
|
|
78
|
+
expect(
|
|
79
|
+
executeTodoWrite({
|
|
80
|
+
todos: [
|
|
81
|
+
{
|
|
82
|
+
id: "1",
|
|
83
|
+
content: "",
|
|
84
|
+
status: "pending",
|
|
85
|
+
priority: "high",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
})
|
|
89
|
+
).rejects.toThrow('Todo item with id "1" has empty content');
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { tool } from "ai";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { TODO_DIR } from "../../context/paths";
|
|
6
|
+
import { getSessionId } from "../../context/session";
|
|
7
|
+
import TODO_WRITE_DESCRIPTION from "./todo-write.txt";
|
|
8
|
+
|
|
9
|
+
const todoItemSchema = z.object({
|
|
10
|
+
id: z.string().describe("Unique identifier for the todo item"),
|
|
11
|
+
content: z.string().describe("Brief description of the task"),
|
|
12
|
+
status: z
|
|
13
|
+
.enum(["pending", "in_progress", "completed", "cancelled"])
|
|
14
|
+
.describe("Current status of the task"),
|
|
15
|
+
priority: z
|
|
16
|
+
.enum(["high", "medium", "low"])
|
|
17
|
+
.describe("Priority level of the task"),
|
|
18
|
+
description: z.string().optional().describe("Detailed task description"),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const inputSchema = z.object({
|
|
22
|
+
todos: z
|
|
23
|
+
.array(todoItemSchema)
|
|
24
|
+
.describe("Array of todo items for the task list"),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type TodoItem = z.infer<typeof todoItemSchema>;
|
|
28
|
+
export type TodoWriteInput = z.infer<typeof inputSchema>;
|
|
29
|
+
|
|
30
|
+
function generateMarkdown(todos: TodoItem[]): string {
|
|
31
|
+
const lines = ["# Current Task List", ""];
|
|
32
|
+
|
|
33
|
+
const byStatus = {
|
|
34
|
+
in_progress: todos.filter((t) => t.status === "in_progress"),
|
|
35
|
+
pending: todos.filter((t) => t.status === "pending"),
|
|
36
|
+
completed: todos.filter((t) => t.status === "completed"),
|
|
37
|
+
cancelled: todos.filter((t) => t.status === "cancelled"),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (byStatus.in_progress.length > 0) {
|
|
41
|
+
lines.push("## 🔄 In Progress");
|
|
42
|
+
for (const todo of byStatus.in_progress) {
|
|
43
|
+
lines.push(`- [~] **${todo.content}** (${todo.priority})`);
|
|
44
|
+
if (todo.description) {
|
|
45
|
+
lines.push(` ${todo.description}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
lines.push("");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (byStatus.pending.length > 0) {
|
|
52
|
+
lines.push("## 📋 Pending");
|
|
53
|
+
for (const todo of byStatus.pending) {
|
|
54
|
+
lines.push(`- [ ] ${todo.content} (${todo.priority})`);
|
|
55
|
+
if (todo.description) {
|
|
56
|
+
lines.push(` ${todo.description}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
lines.push("");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (byStatus.completed.length > 0) {
|
|
63
|
+
lines.push("## ✅ Completed");
|
|
64
|
+
for (const todo of byStatus.completed) {
|
|
65
|
+
lines.push(`- [x] ${todo.content}`);
|
|
66
|
+
}
|
|
67
|
+
lines.push("");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (byStatus.cancelled.length > 0) {
|
|
71
|
+
lines.push("## ❌ Cancelled");
|
|
72
|
+
for (const todo of byStatus.cancelled) {
|
|
73
|
+
lines.push(`- [-] ${todo.content}`);
|
|
74
|
+
}
|
|
75
|
+
lines.push("");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return lines.join("\n");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function executeTodoWrite({
|
|
82
|
+
todos,
|
|
83
|
+
}: TodoWriteInput): Promise<string> {
|
|
84
|
+
// Validate content is not empty (runtime check to avoid minLength in JSON schema)
|
|
85
|
+
for (const todo of todos) {
|
|
86
|
+
if (!todo.content || todo.content.trim() === "") {
|
|
87
|
+
throw new Error(`Todo item with id "${todo.id}" has empty content`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const sessionId = getSessionId();
|
|
92
|
+
const cwd = process.cwd();
|
|
93
|
+
const todoDir = join(cwd, TODO_DIR);
|
|
94
|
+
|
|
95
|
+
await mkdir(todoDir, { recursive: true });
|
|
96
|
+
|
|
97
|
+
const timestamp = new Date().toISOString();
|
|
98
|
+
const todoData = {
|
|
99
|
+
todos,
|
|
100
|
+
updatedAt: timestamp,
|
|
101
|
+
sessionId,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const jsonPath = join(todoDir, `${sessionId}.json`);
|
|
105
|
+
await writeFile(jsonPath, JSON.stringify(todoData, null, 2), "utf-8");
|
|
106
|
+
|
|
107
|
+
const markdown = generateMarkdown(todos);
|
|
108
|
+
const mdPath = join(todoDir, `${sessionId}.md`);
|
|
109
|
+
await writeFile(mdPath, markdown, "utf-8");
|
|
110
|
+
|
|
111
|
+
const stats = {
|
|
112
|
+
total: todos.length,
|
|
113
|
+
completed: todos.filter((t) => t.status === "completed").length,
|
|
114
|
+
inProgress: todos.filter((t) => t.status === "in_progress").length,
|
|
115
|
+
pending: todos.filter((t) => t.status === "pending").length,
|
|
116
|
+
cancelled: todos.filter((t) => t.status === "cancelled").length,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const output = [
|
|
120
|
+
"OK - updated todo list",
|
|
121
|
+
`session: ${sessionId}`,
|
|
122
|
+
`path: ${TODO_DIR}/${sessionId}.json`,
|
|
123
|
+
`total: ${stats.total} tasks`,
|
|
124
|
+
`completed: ${stats.completed}`,
|
|
125
|
+
`in_progress: ${stats.inProgress}`,
|
|
126
|
+
`pending: ${stats.pending}`,
|
|
127
|
+
`cancelled: ${stats.cancelled}`,
|
|
128
|
+
"",
|
|
129
|
+
"======== Current Task List ========",
|
|
130
|
+
markdown,
|
|
131
|
+
"======== end ========",
|
|
132
|
+
];
|
|
133
|
+
|
|
134
|
+
return output.join("\n");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export const todoWriteTool = tool({
|
|
138
|
+
description: TODO_WRITE_DESCRIPTION,
|
|
139
|
+
inputSchema,
|
|
140
|
+
execute: executeTodoWrite,
|
|
141
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import {
|
|
3
|
+
formatBackgroundMessage,
|
|
4
|
+
formatTerminalScreen,
|
|
5
|
+
formatTimeoutMessage,
|
|
6
|
+
} from "./format-utils";
|
|
7
|
+
|
|
8
|
+
describe("formatTerminalScreen", () => {
|
|
9
|
+
it("wraps content with screen markers", () => {
|
|
10
|
+
const result = formatTerminalScreen("hello world");
|
|
11
|
+
|
|
12
|
+
expect(result).toContain("=== Current Terminal Screen ===");
|
|
13
|
+
expect(result).toContain("hello world");
|
|
14
|
+
expect(result).toContain("=== End of Screen ===");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("returns no visible output message for empty content", () => {
|
|
18
|
+
expect(formatTerminalScreen("")).toBe("(no visible output)");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("returns no visible output for whitespace-only content", () => {
|
|
22
|
+
expect(formatTerminalScreen(" \n\n ")).toBe("(no visible output)");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("trims terminal output before wrapping", () => {
|
|
26
|
+
const result = formatTerminalScreen(" hello\nworld \n");
|
|
27
|
+
|
|
28
|
+
expect(result).toContain("hello\nworld");
|
|
29
|
+
expect(result).not.toContain(" ");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("formatTimeoutMessage", () => {
|
|
34
|
+
it("formats timeout message with terminal screen", () => {
|
|
35
|
+
const result = formatTimeoutMessage(1000, "output");
|
|
36
|
+
|
|
37
|
+
expect(result).toContain("[TIMEOUT] Command timed out after 1000ms.");
|
|
38
|
+
expect(result).toContain("=== Current Terminal Screen ===");
|
|
39
|
+
expect(result).toContain("output");
|
|
40
|
+
expect(result).toContain("[POSSIBLE ACTIONS]");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("formatBackgroundMessage", () => {
|
|
45
|
+
it("formats background message with terminal screen and reminder", () => {
|
|
46
|
+
const result = formatBackgroundMessage("output");
|
|
47
|
+
|
|
48
|
+
expect(result).toContain("[Background process started]");
|
|
49
|
+
expect(result).toContain("=== Current Terminal Screen ===");
|
|
50
|
+
expect(result).toContain("output");
|
|
51
|
+
expect(result).toContain("[IMPORTANT] Process started in background.");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const TERMINAL_SCREEN_PREFIX = "=== Current Terminal Screen ===";
|
|
2
|
+
const TERMINAL_SCREEN_SUFFIX = "=== End of Screen ===";
|
|
3
|
+
|
|
4
|
+
const TIMEOUT_PREFIX = "[TIMEOUT]";
|
|
5
|
+
const BACKGROUND_PREFIX = "[Background process started]";
|
|
6
|
+
|
|
7
|
+
export function formatTerminalScreen(content: string): string {
|
|
8
|
+
if (!content?.trim()) {
|
|
9
|
+
return "(no visible output)";
|
|
10
|
+
}
|
|
11
|
+
return `${TERMINAL_SCREEN_PREFIX}\n${content.trim()}\n${TERMINAL_SCREEN_SUFFIX}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function formatTimeoutMessage(
|
|
15
|
+
timeoutMs: number,
|
|
16
|
+
terminalScreen: string
|
|
17
|
+
): string {
|
|
18
|
+
const formattedScreen = formatTerminalScreen(terminalScreen);
|
|
19
|
+
const timeoutHeader = `${TIMEOUT_PREFIX} Command timed out after ${timeoutMs}ms. The process may still be running.`;
|
|
20
|
+
const reminder = [
|
|
21
|
+
"[POSSIBLE ACTIONS]",
|
|
22
|
+
"• Use shell_interact to send keys to the process",
|
|
23
|
+
"• If the process should continue, increase timeout_ms parameter",
|
|
24
|
+
].join("\n");
|
|
25
|
+
return `${timeoutHeader}\n\n${formattedScreen}\n\n${reminder}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatBackgroundMessage(terminalScreen: string): string {
|
|
29
|
+
const screen = formatTerminalScreen(terminalScreen);
|
|
30
|
+
const reminder = [
|
|
31
|
+
"[IMPORTANT] Process started in background.",
|
|
32
|
+
"• VERIFY the service is running before concluding (e.g., curl endpoint, check logs)",
|
|
33
|
+
"• Do NOT assume success without verification",
|
|
34
|
+
"• Use shell_interact to check status or send signals if needed",
|
|
35
|
+
].join("\n");
|
|
36
|
+
return `${BACKGROUND_PREFIX}\n\n${screen}\n\n${reminder}`;
|
|
37
|
+
}
|