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,199 @@
|
|
|
1
|
+
import { HASHLINE_DICT } from "./constants";
|
|
2
|
+
import { createHashlineChunkFormatter } from "./hashline-chunk-formatter";
|
|
3
|
+
|
|
4
|
+
const RE_SIGNIFICANT = /[\p{L}\p{N}]/u;
|
|
5
|
+
|
|
6
|
+
export function computeLineHash(lineNumber: number, content: string): string {
|
|
7
|
+
const stripped = content.endsWith("\r")
|
|
8
|
+
? content.slice(0, -1).replace(/\s+/g, "")
|
|
9
|
+
: content.replace(/\s+/g, "");
|
|
10
|
+
const seed = RE_SIGNIFICANT.test(stripped) ? 0 : lineNumber;
|
|
11
|
+
const hash = Bun.hash.xxHash32(stripped, seed);
|
|
12
|
+
const index = hash % 256;
|
|
13
|
+
return HASHLINE_DICT[index];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function computeFileHash(content: string): string {
|
|
17
|
+
const rawHash = Bun.hash.xxHash32(content, 0);
|
|
18
|
+
const normalized =
|
|
19
|
+
((rawHash % 0x1_00_00_00_00) + 0x1_00_00_00_00) % 0x1_00_00_00_00;
|
|
20
|
+
return normalized.toString(16).padStart(8, "0");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function formatHashLine(lineNumber: number, content: string): string {
|
|
24
|
+
const hash = computeLineHash(lineNumber, content);
|
|
25
|
+
return `${lineNumber}#${hash}|${content}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatLineTag(lineNumber: number, lineText: string): string {
|
|
29
|
+
return `${lineNumber}#${computeLineHash(lineNumber, lineText)}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function formatHashLines(content: string): string {
|
|
33
|
+
if (!content) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
const lines = content.split("\n");
|
|
37
|
+
return lines.map((line, index) => formatHashLine(index + 1, line)).join("\n");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function formatHashlineNumberedLines(
|
|
41
|
+
lines: string[],
|
|
42
|
+
startLine: number
|
|
43
|
+
): string {
|
|
44
|
+
return lines
|
|
45
|
+
.map((line, index) => {
|
|
46
|
+
const lineNumber = startLine + index;
|
|
47
|
+
return formatHashLine(lineNumber, line);
|
|
48
|
+
})
|
|
49
|
+
.join("\n");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface HashlineStreamOptions {
|
|
53
|
+
maxChunkBytes?: number;
|
|
54
|
+
maxChunkLines?: number;
|
|
55
|
+
startLine?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function isReadableStream(value: unknown): value is ReadableStream<Uint8Array> {
|
|
59
|
+
return (
|
|
60
|
+
typeof value === "object" &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
"getReader" in value &&
|
|
63
|
+
typeof (value as { getReader?: unknown }).getReader === "function"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function* bytesFromReadableStream(
|
|
68
|
+
stream: ReadableStream<Uint8Array>
|
|
69
|
+
): AsyncGenerator<Uint8Array> {
|
|
70
|
+
const reader = stream.getReader();
|
|
71
|
+
try {
|
|
72
|
+
while (true) {
|
|
73
|
+
const { done, value } = await reader.read();
|
|
74
|
+
if (done) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (value) {
|
|
78
|
+
yield value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
reader.releaseLock();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function* streamHashLinesFromUtf8(
|
|
87
|
+
source: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>,
|
|
88
|
+
options: HashlineStreamOptions = {}
|
|
89
|
+
): AsyncGenerator<string> {
|
|
90
|
+
const startLine = options.startLine ?? 1;
|
|
91
|
+
const maxChunkLines = options.maxChunkLines ?? 200;
|
|
92
|
+
const maxChunkBytes = options.maxChunkBytes ?? 64 * 1024;
|
|
93
|
+
const decoder = new TextDecoder("utf-8");
|
|
94
|
+
const chunks = isReadableStream(source)
|
|
95
|
+
? bytesFromReadableStream(source)
|
|
96
|
+
: source;
|
|
97
|
+
|
|
98
|
+
let lineNumber = startLine;
|
|
99
|
+
let pending = "";
|
|
100
|
+
let sawAnyText = false;
|
|
101
|
+
let endedWithNewline = false;
|
|
102
|
+
const chunkFormatter = createHashlineChunkFormatter({
|
|
103
|
+
maxChunkLines,
|
|
104
|
+
maxChunkBytes,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const pushLine = (line: string): string[] => {
|
|
108
|
+
const formatted = formatHashLine(lineNumber, line);
|
|
109
|
+
lineNumber += 1;
|
|
110
|
+
return chunkFormatter.push(formatted);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const consumeText = (text: string): string[] => {
|
|
114
|
+
if (text.length === 0) {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
sawAnyText = true;
|
|
118
|
+
pending += text;
|
|
119
|
+
const chunksToYield: string[] = [];
|
|
120
|
+
|
|
121
|
+
while (true) {
|
|
122
|
+
const idx = pending.indexOf("\n");
|
|
123
|
+
if (idx === -1) {
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
const line = pending.slice(0, idx);
|
|
127
|
+
pending = pending.slice(idx + 1);
|
|
128
|
+
endedWithNewline = true;
|
|
129
|
+
chunksToYield.push(...pushLine(line));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (pending.length > 0) {
|
|
133
|
+
endedWithNewline = false;
|
|
134
|
+
}
|
|
135
|
+
return chunksToYield;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
for await (const chunk of chunks) {
|
|
139
|
+
for (const out of consumeText(decoder.decode(chunk, { stream: true }))) {
|
|
140
|
+
yield out;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (const out of consumeText(decoder.decode())) {
|
|
145
|
+
yield out;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (sawAnyText && (pending.length > 0 || endedWithNewline)) {
|
|
149
|
+
for (const out of pushLine(pending)) {
|
|
150
|
+
yield out;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const finalChunk = chunkFormatter.flush();
|
|
155
|
+
if (finalChunk) {
|
|
156
|
+
yield finalChunk;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function* streamHashLinesFromLines(
|
|
161
|
+
lines: Iterable<string> | AsyncIterable<string>,
|
|
162
|
+
options: HashlineStreamOptions = {}
|
|
163
|
+
): AsyncGenerator<string> {
|
|
164
|
+
const startLine = options.startLine ?? 1;
|
|
165
|
+
const maxChunkLines = options.maxChunkLines ?? 200;
|
|
166
|
+
const maxChunkBytes = options.maxChunkBytes ?? 64 * 1024;
|
|
167
|
+
|
|
168
|
+
let lineNumber = startLine;
|
|
169
|
+
const chunkFormatter = createHashlineChunkFormatter({
|
|
170
|
+
maxChunkLines,
|
|
171
|
+
maxChunkBytes,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
const pushLine = (line: string): string[] => {
|
|
175
|
+
const formatted = formatHashLine(lineNumber, line);
|
|
176
|
+
lineNumber += 1;
|
|
177
|
+
return chunkFormatter.push(formatted);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const asyncIterator = (lines as AsyncIterable<string>)[Symbol.asyncIterator];
|
|
181
|
+
if (typeof asyncIterator === "function") {
|
|
182
|
+
for await (const line of lines as AsyncIterable<string>) {
|
|
183
|
+
for (const out of pushLine(line)) {
|
|
184
|
+
yield out;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
for (const line of lines as Iterable<string>) {
|
|
189
|
+
for (const out of pushLine(line)) {
|
|
190
|
+
yield out;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const finalChunk = chunkFormatter.flush();
|
|
196
|
+
if (finalChunk) {
|
|
197
|
+
yield finalChunk;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface HashlineChunkFormatter {
|
|
2
|
+
flush(): string | undefined;
|
|
3
|
+
push(formattedLine: string): string[];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface HashlineChunkFormatterOptions {
|
|
7
|
+
maxChunkBytes: number;
|
|
8
|
+
maxChunkLines: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createHashlineChunkFormatter(
|
|
12
|
+
options: HashlineChunkFormatterOptions
|
|
13
|
+
): HashlineChunkFormatter {
|
|
14
|
+
const { maxChunkLines, maxChunkBytes } = options;
|
|
15
|
+
let outputLines: string[] = [];
|
|
16
|
+
let outputBytes = 0;
|
|
17
|
+
|
|
18
|
+
const flush = (): string | undefined => {
|
|
19
|
+
if (outputLines.length === 0) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const chunk = outputLines.join("\n");
|
|
23
|
+
outputLines = [];
|
|
24
|
+
outputBytes = 0;
|
|
25
|
+
return chunk;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const push = (formattedLine: string): string[] => {
|
|
29
|
+
const chunksToYield: string[] = [];
|
|
30
|
+
const separatorBytes = outputLines.length === 0 ? 0 : 1;
|
|
31
|
+
const lineBytes = Buffer.byteLength(formattedLine, "utf-8");
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
outputLines.length > 0 &&
|
|
35
|
+
(outputLines.length >= maxChunkLines ||
|
|
36
|
+
outputBytes + separatorBytes + lineBytes > maxChunkBytes)
|
|
37
|
+
) {
|
|
38
|
+
const flushed = flush();
|
|
39
|
+
if (flushed) {
|
|
40
|
+
chunksToYield.push(flushed);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
outputLines.push(formattedLine);
|
|
45
|
+
outputBytes += (outputLines.length === 1 ? 0 : 1) + lineBytes;
|
|
46
|
+
|
|
47
|
+
if (outputLines.length >= maxChunkLines || outputBytes >= maxChunkBytes) {
|
|
48
|
+
const flushed = flush();
|
|
49
|
+
if (flushed) {
|
|
50
|
+
chunksToYield.push(flushed);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return chunksToYield;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
push,
|
|
59
|
+
flush,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { computeLineHash } from "./hash-computation";
|
|
2
|
+
|
|
3
|
+
export function generateHashlineDiff(
|
|
4
|
+
oldContent: string,
|
|
5
|
+
newContent: string,
|
|
6
|
+
filePath: string
|
|
7
|
+
): string {
|
|
8
|
+
const oldLines = oldContent.split("\n");
|
|
9
|
+
const newLines = newContent.split("\n");
|
|
10
|
+
|
|
11
|
+
let diff = `--- ${filePath}\n+++ ${filePath}\n`;
|
|
12
|
+
const maxLines = Math.max(oldLines.length, newLines.length);
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < maxLines; i += 1) {
|
|
15
|
+
const oldLine = oldLines[i] ?? "";
|
|
16
|
+
const newLine = newLines[i] ?? "";
|
|
17
|
+
const lineNum = i + 1;
|
|
18
|
+
const hash = computeLineHash(lineNum, newLine);
|
|
19
|
+
|
|
20
|
+
if (i >= oldLines.length) {
|
|
21
|
+
diff += `+ ${lineNum}#${hash}|${newLine}\n`;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (i >= newLines.length) {
|
|
25
|
+
diff += `- ${lineNum}# |${oldLine}\n`;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (oldLine !== newLine) {
|
|
29
|
+
diff += `- ${lineNum}# |${oldLine}\n`;
|
|
30
|
+
diff += `+ ${lineNum}#${hash}|${newLine}\n`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return diff;
|
|
35
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// === Source-matching re-exports (1:1 from oh-my-opencode) ===
|
|
2
|
+
|
|
3
|
+
// biome-ignore lint/performance/noBarrelFile: intentional barrel file for hashline module public API
|
|
4
|
+
export {
|
|
5
|
+
HASHLINE_DICT,
|
|
6
|
+
HASHLINE_OUTPUT_PATTERN,
|
|
7
|
+
HASHLINE_REF_PATTERN,
|
|
8
|
+
NIBBLE_STR,
|
|
9
|
+
} from "./constants";
|
|
10
|
+
export type { HashlineApplyReport } from "./edit-operations";
|
|
11
|
+
export {
|
|
12
|
+
applyHashlineEdits,
|
|
13
|
+
applyHashlineEditsWithReport,
|
|
14
|
+
} from "./edit-operations";
|
|
15
|
+
export {
|
|
16
|
+
parseHashlineText,
|
|
17
|
+
stripLinePrefixes,
|
|
18
|
+
toNewLines,
|
|
19
|
+
} from "./edit-text-normalization";
|
|
20
|
+
export type { FileTextEnvelope } from "./file-text-canonicalization";
|
|
21
|
+
export {
|
|
22
|
+
canonicalizeFileText,
|
|
23
|
+
restoreFileText,
|
|
24
|
+
} from "./file-text-canonicalization";
|
|
25
|
+
export type { HashlineStreamOptions } from "./hash-computation";
|
|
26
|
+
export {
|
|
27
|
+
computeFileHash,
|
|
28
|
+
computeLineHash,
|
|
29
|
+
formatHashLine,
|
|
30
|
+
formatHashLines,
|
|
31
|
+
formatHashlineNumberedLines,
|
|
32
|
+
formatLineTag,
|
|
33
|
+
streamHashLinesFromLines,
|
|
34
|
+
streamHashLinesFromLines as streamHashlineNumberedLinesFromLines,
|
|
35
|
+
streamHashLinesFromUtf8,
|
|
36
|
+
streamHashLinesFromUtf8 as streamHashlineNumberedLinesFromUtf8,
|
|
37
|
+
} from "./hash-computation";
|
|
38
|
+
export type { RawHashlineEdit } from "./normalize-edits";
|
|
39
|
+
export { normalizeHashlineEdits } from "./normalize-edits";
|
|
40
|
+
export type {
|
|
41
|
+
AppendEdit,
|
|
42
|
+
HashlineEdit,
|
|
43
|
+
PrependEdit,
|
|
44
|
+
ReplaceEdit,
|
|
45
|
+
} from "./types";
|
|
46
|
+
export type { LineRef, LineRef as LineTag } from "./validation";
|
|
47
|
+
// parseLineRef wrappers with old names
|
|
48
|
+
export {
|
|
49
|
+
HashlineMismatchError,
|
|
50
|
+
parseLineRef,
|
|
51
|
+
parseLineRef as parseLineTag,
|
|
52
|
+
tryParseLineTag,
|
|
53
|
+
validateLineRef,
|
|
54
|
+
validateLineRefs,
|
|
55
|
+
} from "./validation";
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const CONTINUATION_TOKEN_REGEX =
|
|
2
|
+
/(?:&&|\|\||\?\?|\?|:|=|,|\+|-|\*|\/|\.|\()\s*$/u;
|
|
3
|
+
const MERGE_OPERATOR_REGEX = /[|&?]/;
|
|
4
|
+
const MERGE_OPERATOR_REGEX_GLOBAL = /[|&?]/g;
|
|
5
|
+
const SEMICOLON_SPLIT_REGEX = /;\s+/;
|
|
6
|
+
|
|
7
|
+
export function stripTrailingContinuationTokens(text: string): string {
|
|
8
|
+
return text.replace(CONTINUATION_TOKEN_REGEX, "");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function stripMergeOperatorChars(text: string): string {
|
|
12
|
+
return text.replace(MERGE_OPERATOR_REGEX_GLOBAL, "");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: merge expansion algorithm
|
|
16
|
+
export function maybeExpandSingleLineMerge(
|
|
17
|
+
originalLines: string[],
|
|
18
|
+
replacementLines: string[]
|
|
19
|
+
): string[] {
|
|
20
|
+
if (replacementLines.length !== 1 || originalLines.length <= 1) {
|
|
21
|
+
return replacementLines;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const merged = replacementLines[0];
|
|
25
|
+
const parts = originalLines
|
|
26
|
+
.map((line) => line.trim())
|
|
27
|
+
.filter((line) => line.length > 0);
|
|
28
|
+
if (parts.length !== originalLines.length) {
|
|
29
|
+
return replacementLines;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const indices: number[] = [];
|
|
33
|
+
let offset = 0;
|
|
34
|
+
let orderedMatch = true;
|
|
35
|
+
for (const part of parts) {
|
|
36
|
+
let idx = merged.indexOf(part, offset);
|
|
37
|
+
let matchedLen = part.length;
|
|
38
|
+
if (idx === -1) {
|
|
39
|
+
const stripped = stripTrailingContinuationTokens(part);
|
|
40
|
+
if (stripped !== part) {
|
|
41
|
+
idx = merged.indexOf(stripped, offset);
|
|
42
|
+
if (idx !== -1) {
|
|
43
|
+
matchedLen = stripped.length;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (idx === -1) {
|
|
48
|
+
const segment = merged.slice(offset);
|
|
49
|
+
const segmentStripped = stripMergeOperatorChars(segment);
|
|
50
|
+
const partStripped = stripMergeOperatorChars(part);
|
|
51
|
+
const fuzzyIdx = segmentStripped.indexOf(partStripped);
|
|
52
|
+
if (fuzzyIdx !== -1) {
|
|
53
|
+
let strippedPos = 0;
|
|
54
|
+
let originalPos = 0;
|
|
55
|
+
while (strippedPos < fuzzyIdx && originalPos < segment.length) {
|
|
56
|
+
if (!MERGE_OPERATOR_REGEX.test(segment[originalPos])) {
|
|
57
|
+
strippedPos += 1;
|
|
58
|
+
}
|
|
59
|
+
originalPos += 1;
|
|
60
|
+
}
|
|
61
|
+
idx = offset + originalPos;
|
|
62
|
+
// Compute actual consumed length in original string by walking through
|
|
63
|
+
// until partStripped.length non-operator characters are consumed
|
|
64
|
+
let consumed = 0;
|
|
65
|
+
let realLen = 0;
|
|
66
|
+
while (
|
|
67
|
+
consumed < partStripped.length &&
|
|
68
|
+
originalPos + realLen < segment.length
|
|
69
|
+
) {
|
|
70
|
+
if (!MERGE_OPERATOR_REGEX.test(segment[originalPos + realLen])) {
|
|
71
|
+
consumed += 1;
|
|
72
|
+
}
|
|
73
|
+
realLen += 1;
|
|
74
|
+
}
|
|
75
|
+
matchedLen = realLen;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (idx === -1) {
|
|
79
|
+
orderedMatch = false;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
indices.push(idx);
|
|
83
|
+
offset = idx + matchedLen;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const expanded: string[] = [];
|
|
87
|
+
if (orderedMatch) {
|
|
88
|
+
for (let i = 0; i < indices.length; i += 1) {
|
|
89
|
+
const start = indices[i];
|
|
90
|
+
const end = i + 1 < indices.length ? indices[i + 1] : merged.length;
|
|
91
|
+
const candidate = merged.slice(start, end).trim();
|
|
92
|
+
if (candidate.length === 0) {
|
|
93
|
+
orderedMatch = false;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
expanded.push(candidate);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (orderedMatch && expanded.length === originalLines.length) {
|
|
101
|
+
return expanded;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const semicolonSplit = merged
|
|
105
|
+
.split(SEMICOLON_SPLIT_REGEX)
|
|
106
|
+
.map((line, idx, arr) => {
|
|
107
|
+
if (idx < arr.length - 1 && !line.endsWith(";")) {
|
|
108
|
+
return `${line};`;
|
|
109
|
+
}
|
|
110
|
+
return line;
|
|
111
|
+
})
|
|
112
|
+
.map((line) => line.trim())
|
|
113
|
+
.filter((line) => line.length > 0);
|
|
114
|
+
|
|
115
|
+
if (semicolonSplit.length === originalLines.length) {
|
|
116
|
+
return semicolonSplit;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return replacementLines;
|
|
120
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppendEdit,
|
|
3
|
+
HashlineEdit,
|
|
4
|
+
PrependEdit,
|
|
5
|
+
ReplaceEdit,
|
|
6
|
+
} from "./types";
|
|
7
|
+
|
|
8
|
+
type HashlineToolOp = "replace" | "append" | "prepend";
|
|
9
|
+
|
|
10
|
+
export interface RawHashlineEdit {
|
|
11
|
+
end?: string;
|
|
12
|
+
lines?: string | string[] | null;
|
|
13
|
+
op?: HashlineToolOp;
|
|
14
|
+
pos?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function normalizeAnchor(value: string | undefined): string | undefined {
|
|
18
|
+
if (typeof value !== "string") {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
return trimmed === "" ? undefined : trimmed;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function requireLines(edit: RawHashlineEdit, index: number): string | string[] {
|
|
26
|
+
if (edit.lines === undefined) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Edit ${index}: lines is required for ${edit.op ?? "unknown"}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (edit.lines === null) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
return edit.lines;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function requireLine(
|
|
38
|
+
anchor: string | undefined,
|
|
39
|
+
index: number,
|
|
40
|
+
op: HashlineToolOp
|
|
41
|
+
): string {
|
|
42
|
+
if (!anchor) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Edit ${index}: ${op} requires at least one anchor line reference (pos or end)`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return anchor;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function normalizeReplaceEdit(
|
|
51
|
+
edit: RawHashlineEdit,
|
|
52
|
+
index: number
|
|
53
|
+
): HashlineEdit {
|
|
54
|
+
const pos = normalizeAnchor(edit.pos);
|
|
55
|
+
const end = normalizeAnchor(edit.end);
|
|
56
|
+
const anchor = requireLine(pos ?? end, index, "replace");
|
|
57
|
+
const lines = requireLines(edit, index);
|
|
58
|
+
|
|
59
|
+
const normalized: ReplaceEdit = {
|
|
60
|
+
op: "replace",
|
|
61
|
+
pos: anchor,
|
|
62
|
+
lines,
|
|
63
|
+
};
|
|
64
|
+
if (end) {
|
|
65
|
+
normalized.end = end;
|
|
66
|
+
}
|
|
67
|
+
return normalized;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizeAppendEdit(
|
|
71
|
+
edit: RawHashlineEdit,
|
|
72
|
+
index: number
|
|
73
|
+
): HashlineEdit {
|
|
74
|
+
const pos = normalizeAnchor(edit.pos);
|
|
75
|
+
const end = normalizeAnchor(edit.end);
|
|
76
|
+
const anchor = pos ?? end;
|
|
77
|
+
const lines = requireLines(edit, index);
|
|
78
|
+
|
|
79
|
+
const normalized: AppendEdit = {
|
|
80
|
+
op: "append",
|
|
81
|
+
lines,
|
|
82
|
+
};
|
|
83
|
+
if (anchor) {
|
|
84
|
+
normalized.pos = anchor;
|
|
85
|
+
}
|
|
86
|
+
return normalized;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function normalizePrependEdit(
|
|
90
|
+
edit: RawHashlineEdit,
|
|
91
|
+
index: number
|
|
92
|
+
): HashlineEdit {
|
|
93
|
+
const pos = normalizeAnchor(edit.pos);
|
|
94
|
+
const end = normalizeAnchor(edit.end);
|
|
95
|
+
const anchor = pos ?? end;
|
|
96
|
+
const lines = requireLines(edit, index);
|
|
97
|
+
|
|
98
|
+
const normalized: PrependEdit = {
|
|
99
|
+
op: "prepend",
|
|
100
|
+
lines,
|
|
101
|
+
};
|
|
102
|
+
if (anchor) {
|
|
103
|
+
normalized.pos = anchor;
|
|
104
|
+
}
|
|
105
|
+
return normalized;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function normalizeHashlineEdits(
|
|
109
|
+
rawEdits: RawHashlineEdit[]
|
|
110
|
+
): HashlineEdit[] {
|
|
111
|
+
return rawEdits.map((rawEdit, index) => {
|
|
112
|
+
const edit = rawEdit ?? {};
|
|
113
|
+
|
|
114
|
+
switch (edit.op) {
|
|
115
|
+
case "replace":
|
|
116
|
+
return normalizeReplaceEdit(edit, index);
|
|
117
|
+
case "append":
|
|
118
|
+
return normalizeAppendEdit(edit, index);
|
|
119
|
+
case "prepend":
|
|
120
|
+
return normalizePrependEdit(edit, index);
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(
|
|
123
|
+
`Edit ${index}: unsupported op "${String(edit.op)}". Legacy format was removed; use op/pos/end/lines.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ReplaceEdit {
|
|
2
|
+
end?: string;
|
|
3
|
+
lines: string | string[];
|
|
4
|
+
op: "replace";
|
|
5
|
+
pos: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AppendEdit {
|
|
9
|
+
lines: string | string[];
|
|
10
|
+
op: "append";
|
|
11
|
+
pos?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface PrependEdit {
|
|
15
|
+
lines: string | string[];
|
|
16
|
+
op: "prepend";
|
|
17
|
+
pos?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type HashlineEdit = ReplaceEdit | AppendEdit | PrependEdit;
|