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,566 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { readdir, readFile, realpath } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { basename, dirname, join } from "node:path";
|
|
5
|
+
import { cwd } from "node:process";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { glob } from "glob";
|
|
8
|
+
import { parse as parseYAML } from "yaml";
|
|
9
|
+
import { parsePromptsCommandName } from "./skill-command-prefix";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const BUNDLED_SKILLS_DIR = join(__dirname, "../skills");
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export interface SkillInfo {
|
|
19
|
+
argumentHint?: string; // For slash commands
|
|
20
|
+
description: string;
|
|
21
|
+
dirPath?: string; // Only for v2 skills
|
|
22
|
+
format: "legacy" | "v2" | "command";
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
path: string;
|
|
26
|
+
source:
|
|
27
|
+
| "bundled"
|
|
28
|
+
| "global"
|
|
29
|
+
| "project"
|
|
30
|
+
| "global-command"
|
|
31
|
+
| "project-command";
|
|
32
|
+
version?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface SkillFrontmatter {
|
|
36
|
+
"allowed-tools"?: string;
|
|
37
|
+
"argument-hint"?: string;
|
|
38
|
+
compatibility?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
"disable-model-invocation"?: boolean;
|
|
41
|
+
license?: string;
|
|
42
|
+
metadata?: {
|
|
43
|
+
author?: string;
|
|
44
|
+
version?: string;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
model?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
triggers?: string[];
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Legacy Format (*.md with regex parsing)
|
|
55
|
+
// ============================================================================
|
|
56
|
+
|
|
57
|
+
const FRONTMATTER_REGEX = /^---\n([\s\S]*?)\n---/;
|
|
58
|
+
const NAME_REGEX = /^name:\s*(.+)$/m;
|
|
59
|
+
const DESC_REGEX = /^description:\s*(.+)$/m;
|
|
60
|
+
const VERSION_REGEX = /^version:\s*(.+)$/m;
|
|
61
|
+
const TRIGGERS_REGEX = /^triggers:\s*\n((?:\s{2}- .+\n?)+)/m;
|
|
62
|
+
const LIST_ITEM_REGEX = /^\s*-\s*/;
|
|
63
|
+
const SKILL_NAME_REGEX = /^[a-z0-9-]+$/;
|
|
64
|
+
const EXPECTED_SKILL_IO_ERROR_CODES = new Set([
|
|
65
|
+
"EACCES",
|
|
66
|
+
"EISDIR",
|
|
67
|
+
"ENOENT",
|
|
68
|
+
"ENOTDIR",
|
|
69
|
+
"EPERM",
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
function getErrnoCode(error: unknown): string | null {
|
|
73
|
+
if (
|
|
74
|
+
typeof error === "object" &&
|
|
75
|
+
error !== null &&
|
|
76
|
+
"code" in error &&
|
|
77
|
+
typeof (error as NodeJS.ErrnoException).code === "string"
|
|
78
|
+
) {
|
|
79
|
+
return (error as NodeJS.ErrnoException).code ?? null;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function isExpectedSkillIoError(error: unknown): boolean {
|
|
85
|
+
const code = getErrnoCode(error);
|
|
86
|
+
return code !== null && EXPECTED_SKILL_IO_ERROR_CODES.has(code);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getErrorMessage(error: unknown): string {
|
|
90
|
+
if (error instanceof Error) {
|
|
91
|
+
return error.message;
|
|
92
|
+
}
|
|
93
|
+
return String(error);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function warnUnexpectedSkillError(scope: string, error: unknown): void {
|
|
97
|
+
console.warn(`[skills] ${scope}: ${getErrorMessage(error)}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function parseFrontmatterRegex(content: string): SkillFrontmatter | null {
|
|
101
|
+
const match = content.match(FRONTMATTER_REGEX);
|
|
102
|
+
if (!match) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const frontmatter = match[1];
|
|
107
|
+
const metadata: Partial<SkillFrontmatter> = {};
|
|
108
|
+
|
|
109
|
+
const nameMatch = frontmatter.match(NAME_REGEX);
|
|
110
|
+
if (nameMatch) {
|
|
111
|
+
metadata.name = nameMatch[1].trim();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const descMatch = frontmatter.match(DESC_REGEX);
|
|
115
|
+
if (descMatch) {
|
|
116
|
+
metadata.description = descMatch[1].trim();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const versionMatch = frontmatter.match(VERSION_REGEX);
|
|
120
|
+
if (versionMatch) {
|
|
121
|
+
metadata.version = versionMatch[1].trim();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const triggersMatch = frontmatter.match(TRIGGERS_REGEX);
|
|
125
|
+
if (triggersMatch) {
|
|
126
|
+
metadata.triggers = triggersMatch[1]
|
|
127
|
+
.split("\n")
|
|
128
|
+
.filter((line) => line.trim())
|
|
129
|
+
.map((line) => line.replace(LIST_ITEM_REGEX, "").trim());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (!(metadata.name && metadata.description)) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return metadata as SkillFrontmatter;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function loadLegacySkills(
|
|
139
|
+
dirPath: string,
|
|
140
|
+
source: "bundled" | "global" | "project"
|
|
141
|
+
): Promise<SkillInfo[]> {
|
|
142
|
+
try {
|
|
143
|
+
const skillFiles = await glob("*.md", { cwd: dirPath, absolute: false });
|
|
144
|
+
if (skillFiles.length === 0) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const skills = await Promise.all(
|
|
149
|
+
skillFiles.map(async (file) => {
|
|
150
|
+
const filePath = join(dirPath, file);
|
|
151
|
+
try {
|
|
152
|
+
const content = await readFile(filePath, "utf-8");
|
|
153
|
+
const metadata = parseFrontmatterRegex(content);
|
|
154
|
+
if (!metadata) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const skillId = file.replace(".md", "");
|
|
159
|
+
return {
|
|
160
|
+
id: skillId,
|
|
161
|
+
name: metadata.name,
|
|
162
|
+
description: metadata.description,
|
|
163
|
+
version: metadata.version,
|
|
164
|
+
format: "legacy" as const,
|
|
165
|
+
path: filePath,
|
|
166
|
+
source,
|
|
167
|
+
};
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (!isExpectedSkillIoError(error)) {
|
|
170
|
+
warnUnexpectedSkillError("loadLegacySkills:file", error);
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return skills.filter((skill) => skill !== null) as SkillInfo[];
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (!isExpectedSkillIoError(error)) {
|
|
180
|
+
warnUnexpectedSkillError("loadLegacySkills:glob", error);
|
|
181
|
+
}
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// V2 Format (SKILL.md with YAML parsing)
|
|
188
|
+
// ============================================================================
|
|
189
|
+
|
|
190
|
+
function parseFrontmatterYAML(content: string): SkillFrontmatter | null {
|
|
191
|
+
const match = content.match(FRONTMATTER_REGEX);
|
|
192
|
+
if (!match) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
return parseYAML(match[1]) as SkillFrontmatter;
|
|
198
|
+
} catch {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function validateSkillName(name: string): boolean {
|
|
204
|
+
if (!name || typeof name !== "string") {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (name.length < 1 || name.length > 64) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
if (!SKILL_NAME_REGEX.test(name)) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (name.startsWith("-") || name.endsWith("-")) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function isSkillDirectory(dirPath: string): boolean {
|
|
220
|
+
return existsSync(join(dirPath, "SKILL.md"));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async function discoverSkillDirectories(searchPath: string): Promise<string[]> {
|
|
224
|
+
try {
|
|
225
|
+
const entries = await readdir(searchPath, { withFileTypes: true });
|
|
226
|
+
const skillDirs: string[] = [];
|
|
227
|
+
|
|
228
|
+
for (const entry of entries) {
|
|
229
|
+
if (entry.isDirectory()) {
|
|
230
|
+
const dirPath = join(searchPath, entry.name);
|
|
231
|
+
if (isSkillDirectory(dirPath)) {
|
|
232
|
+
skillDirs.push(dirPath);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return skillDirs;
|
|
238
|
+
} catch (error) {
|
|
239
|
+
if (!isExpectedSkillIoError(error)) {
|
|
240
|
+
warnUnexpectedSkillError("discoverSkillDirectories", error);
|
|
241
|
+
}
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function loadSkillV2(
|
|
247
|
+
dirPath: string,
|
|
248
|
+
source: "bundled" | "global" | "project"
|
|
249
|
+
): Promise<SkillInfo | null> {
|
|
250
|
+
try {
|
|
251
|
+
const skillPath = join(dirPath, "SKILL.md");
|
|
252
|
+
const content = await readFile(skillPath, "utf-8");
|
|
253
|
+
const frontmatter = parseFrontmatterYAML(content);
|
|
254
|
+
|
|
255
|
+
if (!(frontmatter?.name && frontmatter.description)) {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const dirName = basename(dirPath);
|
|
260
|
+
if (!validateSkillName(frontmatter.name)) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
if (frontmatter.name !== dirName) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
if (frontmatter.description.length > 1024) {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
id: frontmatter.name,
|
|
272
|
+
name: frontmatter.name,
|
|
273
|
+
description: frontmatter.description,
|
|
274
|
+
version: frontmatter.metadata?.version || frontmatter.version,
|
|
275
|
+
format: "v2",
|
|
276
|
+
path: skillPath,
|
|
277
|
+
dirPath,
|
|
278
|
+
source,
|
|
279
|
+
};
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (!isExpectedSkillIoError(error)) {
|
|
282
|
+
warnUnexpectedSkillError("loadSkillV2", error);
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function loadV2Skills(
|
|
289
|
+
bundledPath: string,
|
|
290
|
+
projectPath?: string
|
|
291
|
+
): Promise<SkillInfo[]> {
|
|
292
|
+
const globalPath = join(homedir(), ".claude", "skills");
|
|
293
|
+
|
|
294
|
+
const [projectDirs, globalDirs, bundledDirs] = await Promise.all([
|
|
295
|
+
projectPath ? discoverSkillDirectories(projectPath) : Promise.resolve([]),
|
|
296
|
+
discoverSkillDirectories(globalPath),
|
|
297
|
+
discoverSkillDirectories(bundledPath),
|
|
298
|
+
]);
|
|
299
|
+
|
|
300
|
+
const [projectSkills, globalSkills, bundledSkills] = await Promise.all([
|
|
301
|
+
Promise.all(projectDirs.map((dir) => loadSkillV2(dir, "project"))),
|
|
302
|
+
Promise.all(globalDirs.map((dir) => loadSkillV2(dir, "global"))),
|
|
303
|
+
Promise.all(bundledDirs.map((dir) => loadSkillV2(dir, "bundled"))),
|
|
304
|
+
]);
|
|
305
|
+
|
|
306
|
+
const allSkills = [
|
|
307
|
+
...projectSkills.filter((s): s is SkillInfo => s !== null),
|
|
308
|
+
...globalSkills.filter((s): s is SkillInfo => s !== null),
|
|
309
|
+
...bundledSkills.filter((s): s is SkillInfo => s !== null),
|
|
310
|
+
];
|
|
311
|
+
|
|
312
|
+
// Deduplicate by ID and real path (symlink detection)
|
|
313
|
+
const seen = new Map<string, SkillInfo>();
|
|
314
|
+
const seenRealPaths = new Set<string>();
|
|
315
|
+
const realpathCache = new Map<string, string>();
|
|
316
|
+
|
|
317
|
+
for (const skill of allSkills) {
|
|
318
|
+
if (!skill.dirPath) {
|
|
319
|
+
seen.set(skill.id, skill);
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Resolve real path for symlink detection
|
|
324
|
+
let realPath: string;
|
|
325
|
+
try {
|
|
326
|
+
const cached = realpathCache.get(skill.dirPath);
|
|
327
|
+
if (cached) {
|
|
328
|
+
realPath = cached;
|
|
329
|
+
} else {
|
|
330
|
+
realPath = await realpath(skill.dirPath);
|
|
331
|
+
realpathCache.set(skill.dirPath, realPath);
|
|
332
|
+
}
|
|
333
|
+
} catch (error) {
|
|
334
|
+
if (!isExpectedSkillIoError(error)) {
|
|
335
|
+
warnUnexpectedSkillError("loadV2Skills:realpath", error);
|
|
336
|
+
}
|
|
337
|
+
realPath = skill.dirPath;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (seenRealPaths.has(realPath)) {
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
seenRealPaths.add(realPath);
|
|
344
|
+
|
|
345
|
+
const existing = seen.get(skill.id);
|
|
346
|
+
if (!existing) {
|
|
347
|
+
seen.set(skill.id, skill);
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Priority: project > global > bundled (commands have lower priority)
|
|
352
|
+
const priority: Record<SkillInfo["source"], number> = {
|
|
353
|
+
project: 5,
|
|
354
|
+
global: 4,
|
|
355
|
+
bundled: 3,
|
|
356
|
+
"project-command": 2,
|
|
357
|
+
"global-command": 1,
|
|
358
|
+
};
|
|
359
|
+
if (priority[skill.source] > priority[existing.source]) {
|
|
360
|
+
seen.set(skill.id, skill);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return Array.from(seen.values());
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// ============================================================================
|
|
368
|
+
// Slash Commands (*.md files in commands directories)
|
|
369
|
+
// ============================================================================
|
|
370
|
+
|
|
371
|
+
interface SlashCommandInfo {
|
|
372
|
+
argumentHint?: string;
|
|
373
|
+
description: string;
|
|
374
|
+
id: string;
|
|
375
|
+
name: string;
|
|
376
|
+
path: string;
|
|
377
|
+
source: "global-command" | "project-command";
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async function loadSlashCommands(
|
|
381
|
+
dirPath: string,
|
|
382
|
+
source: "global-command" | "project-command"
|
|
383
|
+
): Promise<SlashCommandInfo[]> {
|
|
384
|
+
try {
|
|
385
|
+
// Find all .md files including subdirectories
|
|
386
|
+
const commandFiles = await glob("**/*.md", {
|
|
387
|
+
cwd: dirPath,
|
|
388
|
+
absolute: false,
|
|
389
|
+
nodir: true,
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (commandFiles.length === 0) {
|
|
393
|
+
return [];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
const commands = await Promise.all(
|
|
397
|
+
commandFiles.map(async (file) => {
|
|
398
|
+
const filePath = join(dirPath, file);
|
|
399
|
+
try {
|
|
400
|
+
const content = await readFile(filePath, "utf-8");
|
|
401
|
+
|
|
402
|
+
// Parse frontmatter with YAML
|
|
403
|
+
const frontmatter = parseFrontmatterYAML(content);
|
|
404
|
+
|
|
405
|
+
// Command ID is filename without .md extension
|
|
406
|
+
// Subdirectory is used for namespacing but not part of the ID
|
|
407
|
+
const commandId = basename(file, ".md");
|
|
408
|
+
|
|
409
|
+
// Use description from frontmatter, or generate from filename
|
|
410
|
+
const description =
|
|
411
|
+
frontmatter?.description || `Slash command: ${commandId}`;
|
|
412
|
+
|
|
413
|
+
return {
|
|
414
|
+
id: commandId,
|
|
415
|
+
name: frontmatter?.name || commandId,
|
|
416
|
+
description,
|
|
417
|
+
path: filePath,
|
|
418
|
+
source,
|
|
419
|
+
argumentHint: frontmatter?.["argument-hint"],
|
|
420
|
+
} as SlashCommandInfo;
|
|
421
|
+
} catch (error) {
|
|
422
|
+
if (!isExpectedSkillIoError(error)) {
|
|
423
|
+
warnUnexpectedSkillError("loadSlashCommands:file", error);
|
|
424
|
+
}
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
})
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
return commands.filter((cmd): cmd is SlashCommandInfo => cmd !== null);
|
|
431
|
+
} catch (error) {
|
|
432
|
+
if (!isExpectedSkillIoError(error)) {
|
|
433
|
+
warnUnexpectedSkillError("loadSlashCommands:glob", error);
|
|
434
|
+
}
|
|
435
|
+
return [];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async function loadAllSlashCommands(): Promise<SkillInfo[]> {
|
|
440
|
+
const globalCommandsPath = join(homedir(), ".claude", "commands");
|
|
441
|
+
const projectCommandsPath = join(cwd(), ".claude", "commands");
|
|
442
|
+
|
|
443
|
+
const [globalCommands, projectCommands] = await Promise.all([
|
|
444
|
+
loadSlashCommands(globalCommandsPath, "global-command"),
|
|
445
|
+
loadSlashCommands(projectCommandsPath, "project-command"),
|
|
446
|
+
]);
|
|
447
|
+
|
|
448
|
+
// Convert to SkillInfo format
|
|
449
|
+
const toSkillInfo = (cmd: SlashCommandInfo): SkillInfo => ({
|
|
450
|
+
id: cmd.id,
|
|
451
|
+
name: cmd.name,
|
|
452
|
+
description: cmd.description,
|
|
453
|
+
format: "command",
|
|
454
|
+
path: cmd.path,
|
|
455
|
+
source: cmd.source,
|
|
456
|
+
argumentHint: cmd.argumentHint,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
// Project commands take priority over global commands with same ID
|
|
460
|
+
const commandsMap = new Map<string, SkillInfo>();
|
|
461
|
+
|
|
462
|
+
for (const cmd of globalCommands) {
|
|
463
|
+
commandsMap.set(cmd.id, toSkillInfo(cmd));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
for (const cmd of projectCommands) {
|
|
467
|
+
commandsMap.set(cmd.id, toSkillInfo(cmd));
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return Array.from(commandsMap.values());
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// ============================================================================
|
|
474
|
+
// Public API
|
|
475
|
+
// ============================================================================
|
|
476
|
+
|
|
477
|
+
export async function loadAllSkills(): Promise<SkillInfo[]> {
|
|
478
|
+
const projectSkillsPath = join(cwd(), ".claude", "skills");
|
|
479
|
+
const globalSkillsPath = join(homedir(), ".claude", "skills");
|
|
480
|
+
|
|
481
|
+
const [bundledLegacy, globalLegacy, projectLegacy, v2Skills, slashCommands] =
|
|
482
|
+
await Promise.all([
|
|
483
|
+
loadLegacySkills(BUNDLED_SKILLS_DIR, "bundled"),
|
|
484
|
+
loadLegacySkills(globalSkillsPath, "global"),
|
|
485
|
+
loadLegacySkills(projectSkillsPath, "project"),
|
|
486
|
+
loadV2Skills(BUNDLED_SKILLS_DIR, projectSkillsPath),
|
|
487
|
+
loadAllSlashCommands(),
|
|
488
|
+
]);
|
|
489
|
+
|
|
490
|
+
const allLegacy = [...bundledLegacy, ...globalLegacy, ...projectLegacy];
|
|
491
|
+
const skillsMap = new Map<string, SkillInfo>();
|
|
492
|
+
|
|
493
|
+
// Add slash commands first (lowest priority)
|
|
494
|
+
for (const cmd of slashCommands) {
|
|
495
|
+
skillsMap.set(cmd.id, cmd);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// Add legacy skills (overrides commands with same ID)
|
|
499
|
+
for (const skill of allLegacy) {
|
|
500
|
+
skillsMap.set(skill.id, skill);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Add v2 skills (v2 takes priority over legacy if same ID)
|
|
504
|
+
for (const skill of v2Skills) {
|
|
505
|
+
skillsMap.set(skill.id, skill);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return Array.from(skillsMap.values());
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export async function loadSkillById(
|
|
512
|
+
skillId: string
|
|
513
|
+
): Promise<{ content: string; info: SkillInfo } | null> {
|
|
514
|
+
const allSkills = await loadAllSkills();
|
|
515
|
+
|
|
516
|
+
const promptsSkillId = parsePromptsCommandName(skillId);
|
|
517
|
+
const skill = promptsSkillId
|
|
518
|
+
? allSkills.find((s) => s.id === promptsSkillId)
|
|
519
|
+
: allSkills.find((s) => s.id === skillId);
|
|
520
|
+
|
|
521
|
+
if (!skill) {
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
try {
|
|
526
|
+
const content = await readFile(skill.path, "utf-8");
|
|
527
|
+
return { content, info: skill };
|
|
528
|
+
} catch (error) {
|
|
529
|
+
if (!isExpectedSkillIoError(error)) {
|
|
530
|
+
warnUnexpectedSkillError("loadSkillById", error);
|
|
531
|
+
}
|
|
532
|
+
return null;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export async function loadSkillsMetadata(): Promise<string> {
|
|
537
|
+
try {
|
|
538
|
+
const skills = await loadAllSkills();
|
|
539
|
+
if (skills.length === 0) {
|
|
540
|
+
return "";
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
const skillDescriptions = skills
|
|
544
|
+
.map(
|
|
545
|
+
(skill) => `- **${skill.name}** (\`${skill.id}\`): ${skill.description}`
|
|
546
|
+
)
|
|
547
|
+
.join("\n");
|
|
548
|
+
|
|
549
|
+
return `
|
|
550
|
+
|
|
551
|
+
## Available Skills
|
|
552
|
+
|
|
553
|
+
The following specialized skills are available. When you need detailed instructions for a specific workflow, use the \`load_skill\` tool with the skill ID.
|
|
554
|
+
|
|
555
|
+
${skillDescriptions}
|
|
556
|
+
|
|
557
|
+
**How to use skills:**
|
|
558
|
+
1. Identify which skill matches your current task based on the descriptions above
|
|
559
|
+
2. Use \`load_skill\` tool with the skill ID (e.g., \`load_skill("git-workflow")\`)
|
|
560
|
+
3. Follow the detailed instructions provided by the skill
|
|
561
|
+
`;
|
|
562
|
+
} catch (error) {
|
|
563
|
+
warnUnexpectedSkillError("loadSkillsMetadata", error);
|
|
564
|
+
return "";
|
|
565
|
+
}
|
|
566
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import SHELL_EXECUTE_CONTEXT from "../tools/execute/shell-execute.txt";
|
|
2
|
+
import SHELL_INTERACT_CONTEXT from "../tools/execute/shell-interact.txt";
|
|
3
|
+
import GLOB_FILES_CONTEXT from "../tools/explore/glob-files.txt";
|
|
4
|
+
import GREP_FILES_CONTEXT from "../tools/explore/grep-files.txt";
|
|
5
|
+
import READ_FILE_CONTEXT from "../tools/explore/read-file.txt";
|
|
6
|
+
import DELETE_FILE_CONTEXT from "../tools/modify/delete-file.txt";
|
|
7
|
+
import EDIT_FILE_CONTEXT from "../tools/modify/edit-file.txt";
|
|
8
|
+
import WRITE_FILE_CONTEXT from "../tools/modify/write-file.txt";
|
|
9
|
+
import LOAD_SKILL_CONTEXT from "../tools/planning/load-skill.txt";
|
|
10
|
+
import TODO_WRITE_CONTEXT from "../tools/planning/todo-write.txt";
|
|
11
|
+
|
|
12
|
+
export const SYSTEM_PROMPT = `You are an expert software engineer assistant.
|
|
13
|
+
|
|
14
|
+
Your goal is to help users accomplish coding tasks efficiently and correctly.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
${READ_FILE_CONTEXT}
|
|
19
|
+
|
|
20
|
+
${GLOB_FILES_CONTEXT}
|
|
21
|
+
|
|
22
|
+
${GREP_FILES_CONTEXT}
|
|
23
|
+
|
|
24
|
+
${EDIT_FILE_CONTEXT}
|
|
25
|
+
|
|
26
|
+
${WRITE_FILE_CONTEXT}
|
|
27
|
+
|
|
28
|
+
${DELETE_FILE_CONTEXT}
|
|
29
|
+
|
|
30
|
+
${SHELL_EXECUTE_CONTEXT}
|
|
31
|
+
|
|
32
|
+
${SHELL_INTERACT_CONTEXT}
|
|
33
|
+
|
|
34
|
+
${LOAD_SKILL_CONTEXT}
|
|
35
|
+
|
|
36
|
+
${TODO_WRITE_CONTEXT}
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Core Principles
|
|
41
|
+
|
|
42
|
+
### 1. Understand Before Acting
|
|
43
|
+
- **ALWAYS read files before editing them** - never assume file contents
|
|
44
|
+
- **Inspect data files** (CSV, JSON, etc.) to understand actual structure - never assume column names or formats
|
|
45
|
+
- **Read existing code** to understand expected behavior before writing new implementations
|
|
46
|
+
- **Use explore tools first** (read_file, grep_files, glob_files) to gather context
|
|
47
|
+
|
|
48
|
+
### 2. Choose the Right Tool
|
|
49
|
+
- **File operations**: Use dedicated tools (read_file, edit_file, write_file, delete_file)
|
|
50
|
+
- **Content search**: Use grep_files (not shell grep/rg)
|
|
51
|
+
- **File discovery**: Use glob_files (not shell find/ls)
|
|
52
|
+
- **Shell commands**: ONLY for operations that truly require shell (git, npm, build, tests)
|
|
53
|
+
|
|
54
|
+
### 3. Parallel vs Sequential Tool Execution
|
|
55
|
+
- **You can call multiple tools in a single response** for better performance
|
|
56
|
+
- **Call tools in parallel** when they are independent and have no dependencies:
|
|
57
|
+
- Reading multiple files
|
|
58
|
+
- Running multiple independent grep/glob searches
|
|
59
|
+
- Executing independent shell commands (git status + git diff)
|
|
60
|
+
- Gathering information from different sources
|
|
61
|
+
- **Call tools sequentially** when there are dependencies:
|
|
62
|
+
- Create file → then read it
|
|
63
|
+
- Read file → then edit it based on contents
|
|
64
|
+
- Write file → then run tests on it
|
|
65
|
+
- Operations that modify the same file or resource
|
|
66
|
+
- **Example (parallel)**: Send a single message with multiple tool calls:
|
|
67
|
+
- read_file("src/app.ts") + read_file("src/utils.ts") + grep_files("function.*main")
|
|
68
|
+
- **Example (sequential)**: Chain dependent operations using shell &&:
|
|
69
|
+
- shell_execute("git add . && git commit -m 'message' && git push")
|
|
70
|
+
- **Performance**: Parallel execution can provide 2-5x efficiency gains for independent operations
|
|
71
|
+
|
|
72
|
+
### 4. Path Handling
|
|
73
|
+
- **Preserve path format** given in the task:
|
|
74
|
+
- Task says "/app/out.html" → use "/app/out.html" (keep absolute)
|
|
75
|
+
- Task says "file.txt" → use "file.txt" (keep relative)
|
|
76
|
+
- **Never change** between absolute and relative paths unless explicitly requested
|
|
77
|
+
|
|
78
|
+
### 5. Safety and Correctness
|
|
79
|
+
- **Read before write**: Always verify file contents before modifying
|
|
80
|
+
- **Test your changes**: Run tests or verify functionality after modifications
|
|
81
|
+
- **Handle errors gracefully**: Check command outputs and handle failures appropriately
|
|
82
|
+
- **Be precise**: Use read_file hashline anchors ({line_number}#{hash_id}) with edit_file for deterministic edits
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Workflow Example
|
|
87
|
+
|
|
88
|
+
**Good workflow**:
|
|
89
|
+
1. Use glob_files to find relevant files
|
|
90
|
+
2. Use read_file to understand current implementation
|
|
91
|
+
3. Use grep_files to find related code patterns
|
|
92
|
+
4. Use edit_file to make surgical changes
|
|
93
|
+
5. Use shell_execute to run tests and verify
|
|
94
|
+
|
|
95
|
+
**Bad workflow**:
|
|
96
|
+
❌ Using shell_execute with cat instead of read_file
|
|
97
|
+
❌ Using shell_execute with sed instead of edit_file
|
|
98
|
+
❌ Editing files without reading them first
|
|
99
|
+
❌ Assuming file structure without inspection
|
|
100
|
+
`;
|