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,172 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
|
2
|
+
import { agentManager } from "../agent";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_TOOL_FALLBACK_MODE,
|
|
5
|
+
LEGACY_ENABLED_TOOL_FALLBACK_MODE,
|
|
6
|
+
TOOL_FALLBACK_MODES,
|
|
7
|
+
type ToolFallbackMode,
|
|
8
|
+
} from "../tool-fallback-mode";
|
|
9
|
+
import { createHelpCommand } from "./help";
|
|
10
|
+
import { executeCommand, getCommands, registerCommand } from "./index";
|
|
11
|
+
import { createReasoningModeCommand } from "./reasoning-mode";
|
|
12
|
+
import { createToolFallbackCommand } from "./tool-fallback";
|
|
13
|
+
import type { Command } from "./types";
|
|
14
|
+
|
|
15
|
+
let commandCounter = 0;
|
|
16
|
+
|
|
17
|
+
const nextCommandName = (prefix: string): string => {
|
|
18
|
+
commandCounter += 1;
|
|
19
|
+
return `${prefix}-${commandCounter}`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe("Command aliases", () => {
|
|
23
|
+
it("executes canonical command via alias", async () => {
|
|
24
|
+
const canonicalName = nextCommandName("clear");
|
|
25
|
+
const aliasName = nextCommandName("new");
|
|
26
|
+
|
|
27
|
+
registerCommand({
|
|
28
|
+
name: canonicalName,
|
|
29
|
+
aliases: [aliasName],
|
|
30
|
+
description: "Alias command test",
|
|
31
|
+
execute: () => ({
|
|
32
|
+
success: true,
|
|
33
|
+
message: `resolved:${canonicalName}`,
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const result = await executeCommand(`/${aliasName}`);
|
|
38
|
+
|
|
39
|
+
expect(result).not.toBeNull();
|
|
40
|
+
expect(result?.success).toBe(true);
|
|
41
|
+
expect(result?.message).toBe(`resolved:${canonicalName}`);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("renders merged display name in help output", async () => {
|
|
45
|
+
const commandMap = new Map<string, Command>();
|
|
46
|
+
commandMap.set("clear", {
|
|
47
|
+
name: "clear",
|
|
48
|
+
displayName: "clear (new)",
|
|
49
|
+
aliases: ["new"],
|
|
50
|
+
description: "Start a new session",
|
|
51
|
+
execute: () => ({ success: true, action: "new-session" }),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const help = createHelpCommand(() => commandMap);
|
|
55
|
+
const result = await help.execute({ args: [] });
|
|
56
|
+
|
|
57
|
+
expect(result.success).toBe(true);
|
|
58
|
+
expect(result.message).toContain("/clear (new) - Start a new session");
|
|
59
|
+
expect(result.message).not.toContain("/new - Start a new session");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("Skill command prefixes", () => {
|
|
64
|
+
it("keeps non-command skills addressable without prompts prefix", async () => {
|
|
65
|
+
const result = await executeCommand("/example");
|
|
66
|
+
|
|
67
|
+
expect(result).not.toBeNull();
|
|
68
|
+
expect(result?.success).toBe(true);
|
|
69
|
+
expect(result && "isSkill" in result && result.isSkill).toBe(true);
|
|
70
|
+
|
|
71
|
+
if (result && "isSkill" in result && result.isSkill) {
|
|
72
|
+
expect(result.skillId).toBe("prompts:example");
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("resolves prompts prefix for non-command skills", async () => {
|
|
77
|
+
const result = await executeCommand("/prompts:example");
|
|
78
|
+
|
|
79
|
+
expect(result).not.toBeNull();
|
|
80
|
+
expect(result?.success).toBe(true);
|
|
81
|
+
expect(result && "isSkill" in result && result.isSkill).toBe(true);
|
|
82
|
+
|
|
83
|
+
if (result && "isSkill" in result && result.isSkill) {
|
|
84
|
+
expect(result.skillId).toBe("prompts:example");
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe("Reasoning mode command", () => {
|
|
90
|
+
let originalMode: ReturnType<typeof agentManager.getReasoningMode>;
|
|
91
|
+
let originalProvider: ReturnType<typeof agentManager.getProvider>;
|
|
92
|
+
let originalModelId: ReturnType<typeof agentManager.getModelId>;
|
|
93
|
+
|
|
94
|
+
beforeEach(() => {
|
|
95
|
+
originalMode = agentManager.getReasoningMode();
|
|
96
|
+
originalProvider = agentManager.getProvider();
|
|
97
|
+
originalModelId = agentManager.getModelId();
|
|
98
|
+
agentManager.setProvider("friendli");
|
|
99
|
+
agentManager.setModelId("MiniMaxAI/MiniMax-M2.5");
|
|
100
|
+
agentManager.setReasoningMode("on");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
afterEach(() => {
|
|
104
|
+
agentManager.setProvider(originalProvider);
|
|
105
|
+
agentManager.setModelId(originalModelId);
|
|
106
|
+
agentManager.setReasoningMode(originalMode);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("supports /think alias for /reasoning-mode", async () => {
|
|
110
|
+
if (!getCommands().has("reasoning-mode")) {
|
|
111
|
+
registerCommand(createReasoningModeCommand());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const result = await executeCommand("/think interleaved");
|
|
115
|
+
expect(result).not.toBeNull();
|
|
116
|
+
expect(result?.success).toBe(true);
|
|
117
|
+
expect(agentManager.getReasoningMode()).toBe("interleaved");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("rejects unsupported mode for current model", async () => {
|
|
121
|
+
if (!getCommands().has("reasoning-mode")) {
|
|
122
|
+
registerCommand(createReasoningModeCommand());
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const result = await executeCommand("/reasoning-mode preserved");
|
|
126
|
+
expect(result).not.toBeNull();
|
|
127
|
+
expect(result?.success).toBe(false);
|
|
128
|
+
expect(result?.message).toContain("not supported");
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("Tool fallback command", () => {
|
|
133
|
+
let originalMode: ToolFallbackMode;
|
|
134
|
+
|
|
135
|
+
beforeEach(() => {
|
|
136
|
+
originalMode = agentManager.getToolFallbackMode();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
afterEach(() => {
|
|
140
|
+
agentManager.setToolFallbackMode(originalMode);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("shows mode usage when called without arguments", async () => {
|
|
144
|
+
const command = createToolFallbackCommand();
|
|
145
|
+
const result = await command.execute({ args: [] });
|
|
146
|
+
|
|
147
|
+
expect(result.success).toBe(true);
|
|
148
|
+
expect(result.message).toContain("Tool fallback mode:");
|
|
149
|
+
expect(result.message).toContain(TOOL_FALLBACK_MODES.join("|"));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("sets explicit mode values", async () => {
|
|
153
|
+
const command = createToolFallbackCommand();
|
|
154
|
+
|
|
155
|
+
const result = await command.execute({ args: ["hermes"] });
|
|
156
|
+
|
|
157
|
+
expect(result.success).toBe(true);
|
|
158
|
+
expect(agentManager.getToolFallbackMode()).toBe("hermes");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("accepts legacy on/off values", async () => {
|
|
162
|
+
const command = createToolFallbackCommand();
|
|
163
|
+
|
|
164
|
+
await command.execute({ args: ["on"] });
|
|
165
|
+
expect(agentManager.getToolFallbackMode()).toBe(
|
|
166
|
+
LEGACY_ENABLED_TOOL_FALLBACK_MODE
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await command.execute({ args: ["off"] });
|
|
170
|
+
expect(agentManager.getToolFallbackMode()).toBe(DEFAULT_TOOL_FALLBACK_MODE);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command, CommandResult } from "./types";
|
|
2
|
+
|
|
3
|
+
const newSessionAction = (): CommandResult => ({
|
|
4
|
+
success: true,
|
|
5
|
+
action: "new-session",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const createClearCommand = (): Command => ({
|
|
9
|
+
name: "clear",
|
|
10
|
+
displayName: "clear (new)",
|
|
11
|
+
aliases: ["new"],
|
|
12
|
+
description: "Start a new session",
|
|
13
|
+
execute: () => newSessionAction(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { colorize } from "../../interaction/colors";
|
|
2
|
+
import type { Command, CommandResult } from "../types";
|
|
3
|
+
|
|
4
|
+
interface ToggleCommandConfig {
|
|
5
|
+
description: string;
|
|
6
|
+
disabledMessage?: string;
|
|
7
|
+
enabledMessage?: string;
|
|
8
|
+
featureName: string;
|
|
9
|
+
getter: () => boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
setter: (value: boolean) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createToggleCommand(config: ToggleCommandConfig): Command {
|
|
15
|
+
const {
|
|
16
|
+
name,
|
|
17
|
+
description,
|
|
18
|
+
getter,
|
|
19
|
+
setter,
|
|
20
|
+
featureName,
|
|
21
|
+
enabledMessage,
|
|
22
|
+
disabledMessage,
|
|
23
|
+
} = config;
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
name,
|
|
27
|
+
description,
|
|
28
|
+
argumentSuggestions: ["on", "off"],
|
|
29
|
+
execute: ({ args }): CommandResult => {
|
|
30
|
+
if (args.length === 0) {
|
|
31
|
+
const currentStatus = getter();
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
message: `${featureName} is currently ${colorize(currentStatus ? "green" : "red", currentStatus ? "enabled" : "disabled")}.\nUsage: /${name} <on|off>`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const action = args[0]?.toLowerCase();
|
|
39
|
+
|
|
40
|
+
if (action === "on" || action === "enable" || action === "true") {
|
|
41
|
+
setter(true);
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
message: colorize(
|
|
45
|
+
"green",
|
|
46
|
+
enabledMessage || `${featureName} enabled`
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (action === "off" || action === "disable" || action === "false") {
|
|
52
|
+
setter(false);
|
|
53
|
+
return {
|
|
54
|
+
success: true,
|
|
55
|
+
message: colorize(
|
|
56
|
+
"yellow",
|
|
57
|
+
disabledMessage || `${featureName} disabled`
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
message: `Invalid argument: ${action}. Use 'on' or 'off'.`,
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Command, CommandResult } from "./types";
|
|
2
|
+
|
|
3
|
+
export const createHelpCommand = (
|
|
4
|
+
getCommands: () => Map<string, Command>
|
|
5
|
+
): Command => ({
|
|
6
|
+
name: "help",
|
|
7
|
+
description: "Show available commands",
|
|
8
|
+
execute: (): CommandResult => {
|
|
9
|
+
const getCommandName = (command: Command): string => {
|
|
10
|
+
if (command.displayName) {
|
|
11
|
+
return command.displayName;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (command.aliases && command.aliases.length > 0) {
|
|
15
|
+
return `${command.name} (${command.aliases.join(", ")})`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return command.name;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const commandList = Array.from(getCommands().values())
|
|
22
|
+
.map((cmd) => ` /${getCommandName(cmd)} - ${cmd.description}`)
|
|
23
|
+
.join("\n");
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
success: true,
|
|
27
|
+
message: `Available commands:\n${commandList}`,
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { toPromptsCommandName } from "../context/skill-command-prefix";
|
|
2
|
+
import { loadSkillById } from "../context/skills";
|
|
3
|
+
import { createHelpCommand } from "./help";
|
|
4
|
+
import type { Command, CommandContext, CommandResult } from "./types";
|
|
5
|
+
|
|
6
|
+
export interface SkillCommandResult extends CommandResult {
|
|
7
|
+
isSkill: true;
|
|
8
|
+
skillContent: string;
|
|
9
|
+
skillId: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const commands = new Map<string, Command>();
|
|
13
|
+
const commandAliases = new Map<string, string>();
|
|
14
|
+
|
|
15
|
+
const getCommands = (): Map<string, Command> => commands;
|
|
16
|
+
|
|
17
|
+
export { getCommands };
|
|
18
|
+
|
|
19
|
+
export const registerCommand = (command: Command): void => {
|
|
20
|
+
const normalizedName = command.name.toLowerCase();
|
|
21
|
+
|
|
22
|
+
if (commands.has(normalizedName)) {
|
|
23
|
+
throw new Error(`Duplicate command name: ${normalizedName}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const aliases = command.aliases?.map((alias) => alias.toLowerCase()) ?? [];
|
|
27
|
+
const normalizedCommand: Command = {
|
|
28
|
+
...command,
|
|
29
|
+
name: normalizedName,
|
|
30
|
+
aliases,
|
|
31
|
+
};
|
|
32
|
+
commands.set(normalizedName, normalizedCommand);
|
|
33
|
+
|
|
34
|
+
for (const alias of aliases) {
|
|
35
|
+
if (alias === normalizedName) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (commands.has(alias)) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
`Alias '${alias}' for /${normalizedName} conflicts with command /${alias}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const existingTarget = commandAliases.get(alias);
|
|
46
|
+
if (existingTarget && existingTarget !== normalizedName) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`Alias '${alias}' for /${normalizedName} already maps to /${existingTarget}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
commandAliases.set(alias, normalizedName);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const resolveRegisteredCommandName = (name: string): string => {
|
|
57
|
+
const normalizedName = name.toLowerCase();
|
|
58
|
+
return commandAliases.get(normalizedName) ?? normalizedName;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
registerCommand(createHelpCommand(getCommands));
|
|
62
|
+
|
|
63
|
+
const COMMAND_PREFIX = "/";
|
|
64
|
+
const WHITESPACE_REGEX = /\s+/;
|
|
65
|
+
|
|
66
|
+
export const isCommand = (input: string): boolean =>
|
|
67
|
+
input.startsWith(COMMAND_PREFIX);
|
|
68
|
+
|
|
69
|
+
export const parseCommand = (
|
|
70
|
+
input: string
|
|
71
|
+
): { name: string; args: string[] } | null => {
|
|
72
|
+
if (!isCommand(input)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const parts = input.slice(COMMAND_PREFIX.length).split(WHITESPACE_REGEX);
|
|
77
|
+
const name = parts[0]?.toLowerCase();
|
|
78
|
+
|
|
79
|
+
if (!name) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return { name, args: parts.slice(1) };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const executeCommand = async (
|
|
87
|
+
input: string
|
|
88
|
+
): Promise<CommandResult | SkillCommandResult | null> => {
|
|
89
|
+
const parsed = parseCommand(input);
|
|
90
|
+
|
|
91
|
+
if (!parsed) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const resolvedName = resolveRegisteredCommandName(parsed.name);
|
|
96
|
+
const command = commands.get(resolvedName);
|
|
97
|
+
|
|
98
|
+
if (!command) {
|
|
99
|
+
// Check if it's a skill
|
|
100
|
+
const skill = await loadSkillById(parsed.name);
|
|
101
|
+
if (skill) {
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
isSkill: true,
|
|
105
|
+
skillId: toPromptsCommandName(skill.info.id),
|
|
106
|
+
skillContent: skill.content,
|
|
107
|
+
} as SkillCommandResult;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
message: `Unknown command: /${parsed.name}. Type /help for available commands.`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const context: CommandContext = { args: parsed.args };
|
|
117
|
+
|
|
118
|
+
return await command.execute(context);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const isSkillCommandResult = (
|
|
122
|
+
result: CommandResult | SkillCommandResult | null
|
|
123
|
+
): result is SkillCommandResult => {
|
|
124
|
+
return result !== null && "isSkill" in result && result.isSkill === true;
|
|
125
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { ProviderType } from "../agent";
|
|
2
|
+
import { ANTHROPIC_MODELS, agentManager } from "../agent";
|
|
3
|
+
import type { FriendliReasoningModelConfig } from "../friendli-models";
|
|
4
|
+
import { FRIENDLI_MODELS } from "../friendli-models";
|
|
5
|
+
import { colorize } from "../interaction/colors";
|
|
6
|
+
import type { Command, CommandResult } from "./types";
|
|
7
|
+
|
|
8
|
+
export interface ModelInfo {
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
provider: ProviderType;
|
|
12
|
+
reasoning?: FriendliReasoningModelConfig | null;
|
|
13
|
+
type?: "serverless" | "dedicated";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getAnthropicModels(): ModelInfo[] {
|
|
17
|
+
return ANTHROPIC_MODELS.map((m) => ({
|
|
18
|
+
id: m.id,
|
|
19
|
+
name: m.name,
|
|
20
|
+
provider: "anthropic" as const,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getAvailableModels(): ModelInfo[] {
|
|
25
|
+
const anthropicModels = getAnthropicModels();
|
|
26
|
+
|
|
27
|
+
return [...anthropicModels, ...FRIENDLI_MODELS.filter((m) => !m.masked)];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function findModelBySelection(
|
|
31
|
+
selection: string,
|
|
32
|
+
models: ModelInfo[] = getAvailableModels()
|
|
33
|
+
): ModelInfo | undefined {
|
|
34
|
+
const selectedIndex = Number.parseInt(selection, 10) - 1;
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
!Number.isNaN(selectedIndex) &&
|
|
38
|
+
selectedIndex >= 0 &&
|
|
39
|
+
selectedIndex < models.length
|
|
40
|
+
) {
|
|
41
|
+
return models[selectedIndex];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return models.find((m) => m.id === selection);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const getProviderLabel = (provider: ProviderType): string => {
|
|
48
|
+
const providerLabels: Record<ProviderType, string> = {
|
|
49
|
+
anthropic: "Anthropic",
|
|
50
|
+
friendli: "FriendliAI",
|
|
51
|
+
};
|
|
52
|
+
return providerLabels[provider];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const applyModelSelection = (
|
|
56
|
+
selectedModel: ModelInfo
|
|
57
|
+
): CommandResult => {
|
|
58
|
+
const currentModelId = agentManager.getModelId();
|
|
59
|
+
const currentProvider = agentManager.getProvider();
|
|
60
|
+
|
|
61
|
+
if (
|
|
62
|
+
selectedModel.id === currentModelId &&
|
|
63
|
+
selectedModel.provider === currentProvider
|
|
64
|
+
) {
|
|
65
|
+
return {
|
|
66
|
+
success: true,
|
|
67
|
+
message: `Already using model: ${selectedModel.id}`,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (selectedModel.provider !== currentProvider) {
|
|
72
|
+
agentManager.setProvider(selectedModel.provider);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
agentManager.setModelId(selectedModel.id);
|
|
76
|
+
if (selectedModel.type) {
|
|
77
|
+
agentManager.setModelType(selectedModel.type);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const providerLabel = getProviderLabel(selectedModel.provider);
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
message: colorize(
|
|
84
|
+
"green",
|
|
85
|
+
`Model changed to: ${selectedModel.id} (${providerLabel})`
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
function formatModelList(
|
|
91
|
+
models: ModelInfo[],
|
|
92
|
+
currentModelId: string,
|
|
93
|
+
currentProvider: ProviderType
|
|
94
|
+
): string {
|
|
95
|
+
const lines = models.map((model, index) => {
|
|
96
|
+
const isCurrent =
|
|
97
|
+
model.id === currentModelId && model.provider === currentProvider;
|
|
98
|
+
const marker = isCurrent ? colorize("green", " (current)") : "";
|
|
99
|
+
let providerLabel: string;
|
|
100
|
+
if (model.provider === "anthropic") {
|
|
101
|
+
providerLabel = colorize("magenta", " [Anthropic]");
|
|
102
|
+
} else if (model.type === "dedicated") {
|
|
103
|
+
providerLabel = colorize("cyan", " [FDE]");
|
|
104
|
+
} else {
|
|
105
|
+
providerLabel = colorize("blue", " [FriendliAI]");
|
|
106
|
+
}
|
|
107
|
+
const nameLabel = model.name ? ` - ${model.name}` : "";
|
|
108
|
+
return ` ${index + 1}. ${model.id}${nameLabel}${providerLabel}${marker}`;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return `Available models:\n${lines.join("\n")}\n\nUsage: /model <number> to select`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const createModelCommand = (): Command => ({
|
|
115
|
+
name: "model",
|
|
116
|
+
description: "List or change the AI model",
|
|
117
|
+
execute: ({ args }): CommandResult => {
|
|
118
|
+
const models = getAvailableModels();
|
|
119
|
+
|
|
120
|
+
if (models.length === 0) {
|
|
121
|
+
return { success: false, message: "No models available." };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const currentModelId = agentManager.getModelId();
|
|
125
|
+
const currentProvider = agentManager.getProvider();
|
|
126
|
+
|
|
127
|
+
if (args.length === 0) {
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
message: formatModelList(models, currentModelId, currentProvider),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const selection = args[0];
|
|
135
|
+
const selectedModel = findModelBySelection(selection, models);
|
|
136
|
+
|
|
137
|
+
if (!selectedModel) {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
message: `Invalid selection: ${selection}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return applyModelSelection(selectedModel);
|
|
145
|
+
},
|
|
146
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { agentManager } from "../agent";
|
|
2
|
+
import { parseReasoningMode, REASONING_MODES } from "../reasoning-mode";
|
|
3
|
+
import type { Command } from "./types";
|
|
4
|
+
|
|
5
|
+
const REASONING_MODE_USAGE = REASONING_MODES.join("|");
|
|
6
|
+
|
|
7
|
+
export const createReasoningModeCommand = (): Command => ({
|
|
8
|
+
name: "reasoning-mode",
|
|
9
|
+
aliases: ["think"],
|
|
10
|
+
description: "Set reasoning mode (off/on/interleaved/preserved)",
|
|
11
|
+
argumentSuggestions: [...REASONING_MODES],
|
|
12
|
+
execute: ({ args }) => {
|
|
13
|
+
const selectableModes = agentManager.getSelectableReasoningModes();
|
|
14
|
+
const selectableLabel = selectableModes.join("|");
|
|
15
|
+
|
|
16
|
+
if (args.length === 0) {
|
|
17
|
+
const currentMode = agentManager.getReasoningMode();
|
|
18
|
+
return {
|
|
19
|
+
success: true,
|
|
20
|
+
message: `Reasoning mode: ${currentMode}\nSelectable: ${selectableLabel}\nUsage: /reasoning-mode <${REASONING_MODE_USAGE}>`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const rawMode = args[0] ?? "";
|
|
25
|
+
const mode = parseReasoningMode(rawMode);
|
|
26
|
+
if (!mode) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
message: `Invalid mode: ${rawMode}. Use one of: ${REASONING_MODE_USAGE}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!selectableModes.includes(mode)) {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
message: `Mode ${mode} is not supported for current model. Selectable: ${selectableLabel}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const currentMode = agentManager.getReasoningMode();
|
|
41
|
+
if (mode === currentMode) {
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
message: `Already using reasoning mode: ${mode}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
agentManager.setReasoningMode(mode);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
message: `Reasoning mode set to: ${mode}`,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
import type { ModelMessage } from "ai";
|
|
3
|
+
import {
|
|
4
|
+
appendNextUserPromptSentinel,
|
|
5
|
+
NEXT_USER_PROMPT_SENTINEL,
|
|
6
|
+
} from "./render";
|
|
7
|
+
|
|
8
|
+
describe("render prompt shaping", () => {
|
|
9
|
+
it("appends the sentinel as the last user message", () => {
|
|
10
|
+
const messages: ModelMessage[] = [
|
|
11
|
+
{
|
|
12
|
+
role: "user",
|
|
13
|
+
content: "existing prompt",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
role: "assistant",
|
|
17
|
+
content: "existing response",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const withSentinel = appendNextUserPromptSentinel(messages);
|
|
22
|
+
|
|
23
|
+
expect(withSentinel).toHaveLength(3);
|
|
24
|
+
expect(withSentinel.at(-1)).toEqual({
|
|
25
|
+
role: "user",
|
|
26
|
+
content: NEXT_USER_PROMPT_SENTINEL,
|
|
27
|
+
});
|
|
28
|
+
expect(NEXT_USER_PROMPT_SENTINEL).toBe(
|
|
29
|
+
NEXT_USER_PROMPT_SENTINEL.toUpperCase()
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("does not mutate the original message array", () => {
|
|
34
|
+
const messages: ModelMessage[] = [
|
|
35
|
+
{
|
|
36
|
+
role: "assistant",
|
|
37
|
+
content: "final answer",
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const withSentinel = appendNextUserPromptSentinel(messages);
|
|
42
|
+
|
|
43
|
+
expect(messages).toHaveLength(1);
|
|
44
|
+
expect(withSentinel).not.toBe(messages);
|
|
45
|
+
expect(withSentinel).toHaveLength(2);
|
|
46
|
+
});
|
|
47
|
+
});
|