@bastani/atomic 0.9.18-alpha.5 → 0.9.18-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +39 -0
- package/dist/builtin/intercom/README.md +22 -2
- package/dist/builtin/intercom/broker/broker.ts +676 -128
- package/dist/builtin/intercom/broker/client.ts +151 -35
- package/dist/builtin/intercom/broker/delivered-message-cache.ts +497 -37
- package/dist/builtin/intercom/broker/framing.ts +4 -2
- package/dist/builtin/intercom/broker/paths.ts +10 -0
- package/dist/builtin/intercom/broker/pending-send-registry.ts +1 -2
- package/dist/builtin/intercom/broker/send-handler.ts +311 -52
- package/dist/builtin/intercom/broker/send-signature.ts +4 -2
- package/dist/builtin/intercom/broker/socket-writes.ts +103 -0
- package/dist/builtin/intercom/broker/spawn.ts +9 -4
- package/dist/builtin/intercom/index.bundle.mjs +1410 -212
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recoverable-disconnect.ts +52 -0
- package/dist/builtin/intercom/retry-policy.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +17 -9
- package/dist/builtin/intercom/types.ts +27 -8
- package/dist/builtin/intercom/workflow-stage-path-matching.ts +90 -0
- package/dist/builtin/intercom/workflow-stage-target.ts +57 -0
- package/dist/builtin/mcp/index.bundle.mjs +427 -126
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +19 -0
- package/dist/builtin/subagents/README.md +3 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
- package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +11 -11
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +3 -3
- package/dist/builtin/subagents/agents/worker.md +2 -2
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/skills/qlty/SKILL.md +29 -101
- package/dist/builtin/subagents/skills/qlty/references/manual-configuration.md +52 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +49 -132
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +46 -0
- package/dist/builtin/workflows/README.md +7 -7
- package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
- package/dist/builtin/workflows/builtin/{chunk-szz1ajz9.js → chunk-42s7sw0b.js} +9 -2
- package/dist/builtin/workflows/builtin/{chunk-2dqb5s2q.js → chunk-79fjkcvh.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-n58a7v26.js → chunk-b0v2xab1.js} +181 -10
- package/dist/builtin/workflows/builtin/{chunk-fghhy2a5.js → chunk-ed4jfn5t.js} +23 -5
- package/dist/builtin/workflows/builtin/{chunk-h3r2vkzc.js → chunk-hqpe2cyx.js} +60 -21
- package/dist/builtin/workflows/builtin/{chunk-hzzn6adg.js → chunk-k3w87x8y.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-82ha8p41.js → chunk-n8h4yyew.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-qwzvgxnq.js → chunk-reqr3sr3.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-c53y8bdh.js → chunk-wgccch41.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-0x6e303p.js → chunk-zbekjqew.js} +20 -7
- package/dist/builtin/workflows/builtin/{chunk-29wrp38a.js → chunk-ze5x3d1r.js} +1 -1
- package/dist/builtin/workflows/builtin/classify-and-act.js +2 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +2 -2
- package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
- package/dist/builtin/workflows/builtin/goal.js +3 -3
- package/dist/builtin/workflows/builtin/index.js +11 -11
- package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
- package/dist/builtin/workflows/builtin/open-claude-design.js +2 -2
- package/dist/builtin/workflows/builtin/ralph.js +3 -3
- package/dist/builtin/workflows/builtin/steering-context.js +1 -1
- package/dist/builtin/workflows/builtin/tournament.js +2 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/prompt-engineer/SKILL.md +39 -52
- package/dist/builtin/workflows/skills/prompt-engineer/references/advanced_patterns.md +9 -37
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5.md +49 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_fable_5_1.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_4_8.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_opus_5.md +47 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/claude_sonnet_5.md +57 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_5.md +60 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_5_6.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/gpt_6_astra.md +58 -0
- package/dist/builtin/workflows/skills/prompt-engineer/references/quality_improvement.md +18 -4
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +3194 -737
- package/dist/builtin/workflows/src/index.js +899 -436
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -10
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +4 -0
- package/dist/cli/list-models.js.map +1 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -2
- package/dist/client/index.js.map +1 -1
- package/dist/config.d.ts +0 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -45
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +8 -6
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +1 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +3 -4
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +6 -0
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +13 -5
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +1 -1
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +8 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session.d.ts +2 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +8 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +12 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.js +0 -1
- package/dist/core/extensions/runner-shortcuts.js.map +1 -1
- package/dist/core/fast-model-routing-transport.d.ts +12 -0
- package/dist/core/fast-model-routing-transport.d.ts.map +1 -0
- package/dist/core/{codex-fast-mode-transport.js → fast-model-routing-transport.js} +29 -29
- package/dist/core/fast-model-routing-transport.js.map +1 -0
- package/dist/core/fast-model-routing.d.ts +57 -0
- package/dist/core/fast-model-routing.d.ts.map +1 -0
- package/dist/core/fast-model-routing.js +201 -0
- package/dist/core/fast-model-routing.js.map +1 -0
- package/dist/core/fast-model-variants.d.ts +98 -0
- package/dist/core/fast-model-variants.d.ts.map +1 -0
- package/dist/core/fast-model-variants.js +148 -0
- package/dist/core/fast-model-variants.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +4 -2
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/keybindings.d.ts +0 -10
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -8
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +15 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver-initial.js +1 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +14 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +25 -3
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime.d.ts +39 -2
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +91 -7
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +8 -2
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +18 -18
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts.map +1 -1
- package/dist/core/session-manager-archive.js +25 -2
- package/dist/core/session-manager-archive.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts +0 -2
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +2 -9
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager-internals.d.ts +0 -1
- package/dist/core/settings-manager-internals.d.ts.map +1 -1
- package/dist/core/settings-manager-internals.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +0 -8
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +0 -53
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-types.d.ts +0 -5
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +4 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.js +7 -7
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/edit.d.ts +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +128 -3
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +2 -2
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +40 -10
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -8
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +14 -0
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.d.ts +4 -0
- package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js +26 -1
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +7 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +43 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +0 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -2
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +0 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +6 -11
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -5
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +3 -19
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +1 -2
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +4 -11
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js +3 -3
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +8 -8
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +5 -16
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -9
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +20 -10
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +1 -5
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +3 -0
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +0 -8
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +15 -9
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -3
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +1 -3
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -12
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +10 -13
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +29 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +2 -32
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +1 -5
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -5
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +6 -13
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +19 -13
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +27 -3
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +4 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +13 -6
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +2 -3
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/tools-manager.d.ts +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +33 -18
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/custom-provider.md +2 -0
- package/docs/development.md +17 -0
- package/docs/docs.json +14 -2
- package/docs/extensions.md +9 -4
- package/docs/intercom.md +41 -7
- package/docs/keybindings.md +8 -6
- package/docs/models/evals.md +394 -0
- package/docs/models/model-selection.md +54 -27
- package/docs/models/pareto-efficiency.md +33 -16
- package/docs/models.md +37 -1
- package/docs/packages.md +2 -2
- package/docs/providers.md +44 -20
- package/docs/quickstart.md +8 -6
- package/docs/rpc.md +3 -3
- package/docs/sdk.md +2 -16
- package/docs/settings.md +19 -22
- package/docs/skills.md +4 -2
- package/docs/subagents.md +9 -3
- package/docs/tools/edit.md +373 -0
- package/docs/tools.md +3 -7
- package/docs/tui.md +2 -1
- package/docs/usage.md +3 -5
- package/docs/workflows/api-reference.md +1395 -0
- package/docs/workflows/authoring.md +678 -0
- package/docs/workflows/builtins.md +245 -0
- package/docs/workflows/operations.md +811 -0
- package/docs/workflows/reliable-design.md +2099 -0
- package/docs/workflows/verification.md +62 -0
- package/docs/workflows.md +15 -5183
- package/npm-shrinkwrap.json +584 -69
- package/package.json +7 -7
- package/dist/client/remote-session.d.ts +0 -64
- package/dist/client/remote-session.d.ts.map +0 -1
- package/dist/client/remote-session.js +0 -351
- package/dist/client/remote-session.js.map +0 -1
- package/dist/client/transcript.d.ts +0 -12
- package/dist/client/transcript.d.ts.map +0 -1
- package/dist/client/transcript.js +0 -98
- package/dist/client/transcript.js.map +0 -1
- package/dist/core/codex-fast-mode-transport.d.ts +0 -12
- package/dist/core/codex-fast-mode-transport.d.ts.map +0 -1
- package/dist/core/codex-fast-mode-transport.js.map +0 -1
- package/dist/core/codex-fast-mode.d.ts +0 -53
- package/dist/core/codex-fast-mode.d.ts.map +0 -1
- package/dist/core/codex-fast-mode.js +0 -249
- package/dist/core/codex-fast-mode.js.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts +0 -27
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +0 -107
- package/dist/modes/interactive/components/fast-mode-selector.js.map +0 -1
- package/dist/server/create-harness.d.ts +0 -53
- package/dist/server/create-harness.d.ts.map +0 -1
- package/dist/server/create-harness.js +0 -360
- package/dist/server/create-harness.js.map +0 -1
- package/docs/models/artificial-analysis-index.md +0 -83
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,+BAA+B,EAE/B,sBAAsB,GACtB,MAAM,eAAe,CAAC;AACvB,O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AClC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { nativeBlockResolver } from \"./block-resolver.ts\";\nimport { EditBatchCoordinator, parallelEditBatchWarning } from \"./edit-batch.ts\";\nimport { generateDiffString, generateUnifiedPatch, normalizeToLF, stripBom } from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatCompactHashlineEditResult,\n\ttype HashlineSnapshotStore,\n\trecordHashlineSnapshot,\n} from \"./hashline.ts\";\nimport {\n\tFilesystem,\n\tmissingSnapshotTagMessage,\n\tPatch,\n\tPatcher,\n\ttype PatchSectionResult,\n\ttype PreparedSection,\n\ttype WriteResult,\n} from \"./hashline-engine/index.ts\";\nimport { isNotebookPath, readEditableNotebookText, serializeEditedNotebookText } from \"./notebook.ts\";\nimport { resolveReadPath } from \"./path-utils.ts\";\nimport { renderToolPath } from \"./render-utils.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst editSchema = Type.Object(\n\t{\n\t\tinput: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"One or more hashline file sections. Must start with [PATH#TAG]; tag comes from the latest read, search, write, or successful edit output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\nexport const editToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Apply source edits with hashline patch input\",\n\tguidelines: Object.freeze([\n\t\t\"hashline edit format: a header ending in ':' is followed by '+'TEXT body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.\",\n\t\t\"Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'replace block N:' replaces the whole syntactic block that BEGINS on line N (Atomic resolves the closing line with a brace/indent heuristic; point N at the opener); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert after block N:' inserts after the END of the block beginning on N; 'insert head:' / 'insert tail:' insert at file start/end. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.\",\n\t\t\"Body rows appear only under a ':' header. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.\",\n\t\t\"Numbers refer to the ORIGINAL file and do not shift as hunks apply; they die with the call — every applied edit mints a fresh #TAG and renumbers, so anchor the next edit on the edit response or a fresh read. Parallel edit calls that share a [path#TAG] are applied as one snapshot batch. Ranges are TIGHT: cover ONLY lines whose content changes; a stale wide range shreds everything it spans. Pure additions use 'insert', never a widened 'replace'. Whole construct → 'replace block N'; lines inside it → 'replace N..M'.\",\n\t\t\"On a stale-tag rejection or any surprising result: STOP and re-read before further edits. Never start or end a range mid-expression/mid-block, and never span a hunk across an elided ('…') region — read it first. Never use edit to reformat/restyle code; run the project formatter instead.\",\n\t] as const),\n} as const);\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\tdiff: string;\n\tpatch: string;\n\tfirstChangedLine?: number;\n}\n\nexport interface EditOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\toperations?: EditOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: EditToolDetails | undefined;\n};\n\nclass EditFilesystem extends Filesystem {\n\tprivate readonly cwd: string;\n\tprivate readonly operations: EditOperations;\n\tconstructor(cwd: string, operations: EditOperations) {\n\t\tsuper();\n\t\tthis.cwd = cwd;\n\t\tthis.operations = operations;\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn resolveReadPath(path, this.cwd);\n\t}\n\n\tasync preflightWrite(path: string): Promise<void> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\ttry {\n\t\t\tawait this.operations.access(absolutePath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error && \"code\" in error ? `Error code: ${error.code}` : String(error);\n\t\t\tthrow new Error(`Could not edit file: ${path}. ${message}.`);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\treturn isNotebookPath(absolutePath)\n\t\t\t? readEditableNotebookText(absolutePath, path)\n\t\t\t: (await this.operations.readFile(absolutePath)).toString(\"utf-8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\tconst persisted = isNotebookPath(absolutePath)\n\t\t\t? serializeEditedNotebookText(absolutePath, path, normalizeToLF(stripBom(content).text))\n\t\t\t: content;\n\t\tawait this.operations.writeFile(absolutePath, persisted);\n\t\treturn { text: persisted };\n\t}\n}\n\nfunction isFourDigitHexTag(value: string): boolean {\n\treturn (\n\t\tvalue.length === 4 &&\n\t\t[...value].every(\n\t\t\t(char) => (char >= \"0\" && char <= \"9\") || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\"),\n\t\t)\n\t);\n}\n\nfunction extractFirstHeaderPath(input: string | undefined): string | undefined {\n\tif (!input) return undefined;\n\tfor (const line of input.split(\"\\n\")) {\n\t\tconst trimmed = line.trimStart();\n\t\tif (!trimmed.startsWith(\"[\")) continue;\n\t\tconst hashIndex = trimmed.indexOf(\"#\", 1);\n\t\tconst closeIndex = hashIndex >= 0 ? trimmed.indexOf(\"]\", hashIndex + 1) : -1;\n\t\tif (hashIndex <= 1 || closeIndex !== hashIndex + 5) continue;\n\t\tconst tag = trimmed.slice(hashIndex + 1, closeIndex);\n\t\tif (isFourDigitHexTag(tag)) return trimmed.slice(1, hashIndex);\n\t}\n\treturn undefined;\n}\n\nfunction formatEditCall(args: unknown, theme: Theme, cwd: string): string {\n\tconst input = args && typeof args === \"object\" && \"input\" in args ? (args as { input?: unknown }).input : undefined;\n\tconst pathDisplay = renderToolPath(\n\t\textractFirstHeaderPath(typeof input === \"string\" ? input : undefined) ?? null,\n\t\ttheme,\n\t\tcwd,\n\t);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))} ${pathDisplay}`;\n}\n\nfunction formatEditResult(result: EditToolResultLike, theme: Theme, isError: boolean): string | undefined {\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\treturn errorText ? theme.fg(\"error\", errorText) : undefined;\n\t}\n\treturn result.details?.diff ? renderDiff(result.details.diff) : undefined;\n}\n\nasync function withFileMutationQueues<T>(filePaths: readonly string[], fn: () => Promise<T>): Promise<T> {\n\tconst sorted = [...new Set(filePaths)].sort();\n\tconst run = (index: number): Promise<T> => {\n\t\tconst filePath = sorted[index];\n\t\treturn filePath ? withFileMutationQueue(filePath, () => run(index + 1)) : fn();\n\t};\n\treturn run(0);\n}\n\nfunction throwIfAborted(signal?: AbortSignal): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nfunction formatNoopMessage(path: string, count: number): string {\n\treturn `Edits to ${path} parsed and applied cleanly, but produced no change: your body row(s) are byte-identical to the file at the targeted lines. The bug is somewhere else — re-read the file before issuing another edit. Do NOT widen the payload or add lines; verify the anchor first.${count > 1 ? `\\nNo-op count for this identical payload: ${count}.` : \"\"}`;\n}\n\nfunction blockMessages(item: PreparedSection | PatchSectionResult): string[] {\n\tconst warnings =\n\t\t\"parseWarnings\" in item ? [...item.parseWarnings, ...(item.applyResult.warnings ?? [])] : item.warnings;\n\tconst resolutions =\n\t\t(\"applyResult\" in item ? item.applyResult.blockResolutions : item.blockResolutions)?.map((resolution) => {\n\t\t\tconst verb = resolution.op === \"insert_after\" ? \"insert after block\" : `${resolution.op} block`;\n\t\t\tconst lands = resolution.op === \"insert_after\" ? `; body lands after line ${resolution.end}` : \"\";\n\t\t\treturn `${verb} ${resolution.anchorLine} → resolved lines ${resolution.start}-${resolution.end} (${resolution.end - resolution.start + 1} lines)${lands}`;\n\t\t}) ?? [];\n\treturn [...warnings, ...resolutions];\n}\n\nfunction assertUniquePreparedPaths(prepared: readonly PreparedSection[]): void {\n\tconst seen = new Map<string, string>();\n\tfor (const entry of prepared) {\n\t\tconst previous = seen.get(entry.canonicalPath);\n\t\tif (previous)\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple hashline sections resolve to the same file (${previous} and ${entry.section.path}). Merge their ops under one header before applying.`,\n\t\t\t);\n\t\tseen.set(entry.canonicalPath, entry.section.path);\n\t}\n}\n\ninterface EditCwdScope {\n\treadonly fs: EditFilesystem;\n\treadonly batcher: EditBatchCoordinator<EditToolResultLike>;\n\tapplySiblingEdits(siblings: readonly { input: string }[], applySignal?: AbortSignal): Promise<EditToolResultLike>;\n}\n\nfunction createEditCwdScope(cwd: string, ops: EditOperations, hashlineStore: HashlineSnapshotStore): EditCwdScope {\n\tconst fs = new EditFilesystem(cwd, ops);\n\tconst patcher = new Patcher({ fs, snapshots: hashlineStore.snapshots, blockResolver: nativeBlockResolver });\n\tconst noopCounts = new Map<string, number>();\n\tconst batcher = new EditBatchCoordinator<EditToolResultLike>();\n\tasync function applySiblingEdits(\n\t\tsiblings: readonly { input: string }[],\n\t\tapplySignal?: AbortSignal,\n\t): Promise<EditToolResultLike> {\n\t\tconst merged =\n\t\t\tsiblings.length === 1\n\t\t\t\t? Patch.parse(siblings[0]!.input, { cwd })\n\t\t\t\t: Patch.parse(siblings.map((sibling) => sibling.input).join(\"\\n\"), { cwd });\n\t\tconst prepared: PreparedSection[] = [];\n\t\tfor (const section of merged.sections) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tprepared.push(await patcher.prepare(section));\n\t\t}\n\t\tassertUniquePreparedPaths(prepared);\n\t\tconst noops = prepared.filter((item) => item.isNoop);\n\t\tif (noops.length > 0) {\n\t\t\tif (noops.length !== prepared.length)\n\t\t\t\tthrow new Error(`Hashline edit for ${noops[0]!.section.path} did not change the file.`);\n\t\t\tconst key = prepared.map((item) => `${item.canonicalPath}\\0${item.applyResult.text}`).join(\"\\0\\0\");\n\t\t\tconst count = (noopCounts.get(key) ?? 0) + 1;\n\t\t\tnoopCounts.set(key, count);\n\t\t\tif (count >= 3) throw new Error(`STOP. ${formatNoopMessage(prepared[0]!.section.path, count)}`);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatNoopMessage(prepared[0]!.section.path, count) }],\n\t\t\t\tdetails: { diff: \"\", patch: \"\" },\n\t\t\t};\n\t\t}\n\t\tfor (const item of prepared) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tif (normalizeToLF(stripBom(await fs.readText(item.section.path)).text) !== item.normalized)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Stale hashline tag for ${item.section.path}: file content changed before write. Re-read before editing.`,\n\t\t\t\t);\n\t\t}\n\t\tconst outputs: string[] = [];\n\t\tlet combinedDiff = \"\",\n\t\t\tcombinedPatch = \"\";\n\t\tlet firstChangedLine: number | undefined;\n\t\tconst batchNote = siblings.length > 1 ? [parallelEditBatchWarning(siblings.length)] : [];\n\t\tfor (let index = 0; index < prepared.length; index++) {\n\t\t\tconst item = prepared[index]!;\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tlet result: PatchSectionResult;\n\t\t\ttry {\n\t\t\t\tresult = await patcher.commit(item);\n\t\t\t} catch (error) {\n\t\t\t\tconst written = prepared.slice(0, index).map((entry) => entry.section.path);\n\t\t\t\tconst notWritten = prepared.slice(index + 1).map((entry) => entry.section.path);\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to write ${item.section.path}: ${message}` +\n\t\t\t\t\t\t(written.length > 0 ? ` Sections already written: ${written.join(\", \")}.` : \"\") +\n\t\t\t\t\t\t(notWritten.length > 0 ? ` Sections not written: ${notWritten.join(\", \")}.` : \"\"),\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tinvalidateNativeSearchCache(result.canonicalPath);\n\t\t\tconst snapshot = recordHashlineSnapshot(result.canonicalPath, cwd, result.after, hashlineStore);\n\t\t\tconst diffResult = generateDiffString(result.before, result.after);\n\t\t\tcombinedDiff += `${combinedDiff ? \"\\n\" : \"\"}${diffResult.diff}`;\n\t\t\tcombinedPatch += `${combinedPatch ? \"\\n\" : \"\"}${generateUnifiedPatch(result.path, result.before, result.after)}`;\n\t\t\tfirstChangedLine ??= diffResult.firstChangedLine;\n\t\t\toutputs.push(formatCompactHashlineEditResult(snapshot, diffResult, [...batchNote, ...blockMessages(result)]));\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: outputs.join(\"\\n\\n\") }],\n\t\t\tdetails: { diff: combinedDiff, patch: combinedPatch, firstChangedLine },\n\t\t};\n\t}\n\treturn { fs, batcher, applySiblingEdits };\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\t// Atomic adaptation of upstream #8627 (\"use ctx.cwd for cwd-sensitive tools\"). Upstream's edit\n\t// tool is a stateless text replacer, so it could resolve `ctx?.cwd || cwd` inline. Atomic's\n\t// hashline patcher instead carries per-tool state — the `EditFilesystem`, the `Patcher`, the\n\t// repeated-no-op counters, and the parallel-edit batcher — that is all keyed to one cwd.\n\t// Mutating a shared cwd field would corrupt concurrent tool calls, so each distinct execution\n\t// cwd gets its own scope. Callers that pass no ctx keep the factory cwd's scope unchanged.\n\tconst scopes = new Map<string, EditCwdScope>();\n\tconst scopeFor = (executionCwd: string): EditCwdScope => {\n\t\tconst existing = scopes.get(executionCwd);\n\t\tif (existing) return existing;\n\t\tconst scope = createEditCwdScope(executionCwd, ops, hashlineStore);\n\t\tscopes.set(executionCwd, scope);\n\t\treturn scope;\n\t};\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing files with the hashline patch language: each section starts with [PATH#TAG] (TAG is the 4-hex snapshot tag from your latest read/search), then hunk headers (replace N..M:, replace block N:, delete N..M, delete block N, insert before|after N:, insert after block N:, insert head:, insert tail:) followed by +TEXT body rows. Numbers refer to the original file. Use the write tool to create new files.\",\n\t\tpromptSnippet: editToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...editToolSystemPromptContribution.guidelines],\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: editSchema,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tif (typeof input.input !== \"string\" || input.input.trim() === \"\")\n\t\t\t\tthrow new Error(\"edit input must be a non-empty hashline script with [PATH#TAG] sections.\");\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst { fs, batcher, applySiblingEdits } = scopeFor(executionCwd);\n\t\t\tconst patch = Patch.parse(input.input, { cwd: executionCwd });\n\t\t\tconst paths = new Map<string, string>();\n\t\t\tfor (const section of patch.sections) {\n\t\t\t\tif (section.fileHash === undefined) throw new Error(missingSnapshotTagMessage(section.path));\n\t\t\t\tpaths.set(section.path, section.fileHash);\n\t\t\t}\n\t\t\tconst entry = batcher.announce(input.input, paths, signal);\n\t\t\ttry {\n\t\t\t\treturn await withFileMutationQueues(\n\t\t\t\t\t[...paths.keys()].map((sectionPath) => fs.canonicalPath(sectionPath)),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\t\t\tthrowIfAborted(signal);\n\t\t\t\t\t\tconst siblings = batcher.takeCompatible(entry);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await applySiblingEdits(siblings, signal);\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.resolve(result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.reject(error);\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\tentry.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tbatcher.drop(entry);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatEditCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatEditResult(result as EditToolResultLike, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) return component;\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/core/tools/edit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,QAAQ,IAAI,UAAU,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAExE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,+BAA+B,EAE/B,sBAAsB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,UAAU,EACV,y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AO,IAAI,CAAC;QACb,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;YAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAA4B,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACtF,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;YACtF,SAAS,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,CAAC,MAAM;gBAAE,OAAO,SAAS,CAAC;YAC9B,SAAS,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3C,OAAO,SAAS,CAAC;QAClB,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAyB;IACpE,OAAO,kBAAkB,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { constants } from \"fs\";\nimport { access as fsAccess, readFile as fsReadFile, writeFile as fsWriteFile } from \"fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { renderDiff } from \"../../modes/interactive/components/diff.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport { nativeBlockResolver } from \"./block-resolver.ts\";\nimport { EditBatchCoordinator, parallelEditBatchWarning } from \"./edit-batch.ts\";\nimport { generateDiffString, generateUnifiedPatch, normalizeToLF, stripBom } from \"./edit-diff.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatCompactHashlineEditResult,\n\ttype HashlineSnapshotStore,\n\trecordHashlineSnapshot,\n} from \"./hashline.ts\";\nimport {\n\tFilesystem,\n\tmissingSnapshotTagMessage,\n\tPatch,\n\tPatcher,\n\ttype PatchSectionResult,\n\ttype PreparedSection,\n\ttype WriteResult,\n} from \"./hashline-engine/index.ts\";\nimport { isNotebookPath, readEditableNotebookText, serializeEditedNotebookText } from \"./notebook.ts\";\nimport { resolveReadPath } from \"./path-utils.ts\";\nimport { renderToolPath } from \"./render-utils.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst editSchema = Type.Object(\n\t{\n\t\tinput: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"One or more hashline file sections. Must start with [PATH#TAG]; tag comes from the latest read, search, write, or successful edit output.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n// Hashline prompt origin: can1357/oh-my-pi packages/hashline/src/prompt.md @ 15b5c1397fc (MIT).\n// This file carries Atomic-maintained local modifications; see ./hashline-engine/PROVENANCE.md and ./hashline-engine/LICENSE.upstream.\nexport const editToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Apply source edits with hashline patch input\",\n\tguidelines: Object.freeze([\n\t\t\"hashline edit format: a header ending in ':' is followed by '+TEXT' body rows; 'delete' has no body. Every section starts with [PATH#TAG]; TAG is REQUIRED (the 4-hex snapshot tag from your latest read/search) — there is no hashless form. Use the write tool to create new files.\",\n\t\t\"Ops: 'replace N..M:' replaces original lines N..M (INCLUSIVE — line M is consumed); 'delete N..M' / 'delete block N' delete (no body); 'insert before N:' / 'insert after N:' insert relative to a line; 'insert head:' / 'insert tail:' insert at file start/end. Block ops ('replace block N:', 'delete block N', 'insert after block N:') resolve the exact syntactic node BEGINNING on N through the native Rust tree-sitter `blockRangeAt` primitive in `@bastani/atomic-natives`; the brace/indent heuristic is the fallback only when the native binding is unavailable. Single line: 'replace N..N:' / 'delete N'. The range is the ORIGINAL lines you touch; body length is irrelevant.\",\n\t\t\"Body rows appear only under a ':' header and start on the NEXT line. Every row is '+TEXT' (adds a literal line, leading whitespace kept; '+' alone adds a blank line). There is NO other body row kind — never write '-old' or a bare/context line. To keep a line, leave it out of every range. For a literal line starting with '-' or '+', prefix it: '+-x', '++x'.\",\n\t\t\"Block anchors: 'replace block N' resolves the outermost node BEGINNING on N. Where a language folds a decorator/annotation into its construct (Python folds `@dec` and `def` into one node; TypeScript/Java annotations also fold), anchoring at the first decorator sweeps both. Rust `#[attr]` and doc- or line-comments resolve alone; replacing there with a construct body duplicates the construct, so use explicit 'replace N..M:' to take both. Confirm the result echo: 'replace block N → resolved lines A-B (K lines)'. 'insert after block N:' takes the opener, never the closer; insert-after echoes '; body lands after line B'. Resolution fails for an unsupported language, blank/closer line, no node beginning on N, or an unparsable block; use 'replace N..M:' or 'insert after M:' instead.\",\n\t\t\"Numbers refer to the ORIGINAL file and do not shift as hunks apply; they die with the call — every applied edit mints a fresh #TAG and renumbers, so anchor the next edit on the edit response or a fresh read. Parallel edit calls that share a [path#TAG] are applied as one snapshot batch. Ranges are TIGHT: cover ONLY lines whose content changes; a stale wide range shreds everything it spans. Pure additions use 'insert', never a widened 'replace'. Whole construct → 'replace block N'; lines inside it → 'replace N..M'.\",\n\t\t\"On a stale-tag rejection or any surprising result: STOP and re-read before further edits. Never start or end a range mid-expression/mid-block, and never span a hunk across an elided ('…') region — read it first. Never use edit to reformat/restyle code; run the project formatter instead.\",\n\t\t[\n\t\t\t\"Worked examples. Original (the exact shape `read` returns):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"1:@cache\",\n\t\t\t\"2:def greet(name):\",\n\t\t\t'3: msg = \"Hello, \" + name',\n\t\t\t\"4: print(msg)\",\n\t\t\t'5:greet(\"world\")',\n\t\t\t\"```\",\n\t\t\t\"Replace one original line with one line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"replace 3..3:\",\n\t\t\t'+ msg = f\"Hi, {name}\"',\n\t\t\t\"```\",\n\t\t\t\"Replace the decorated Python block (Python folds `@cache` and `def` into one node; anchoring at line 2 would keep/orphan line 1). For a Rust attribute or doc- or line-comment, use explicit `replace N..M:` to take both it and the construct:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"replace block 1:\",\n\t\t\t\"+@cache\",\n\t\t\t\"+def greet(name):\",\n\t\t\t'+ print(f\"Hello, {name}\")',\n\t\t\t\"```\",\n\t\t\t\"Delete one line (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete 4\",\n\t\t\t\"```\",\n\t\t\t\"Delete a range (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete 3..4\",\n\t\t\t\"```\",\n\t\t\t\"Delete a whole block (no colon/body):\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"delete block 2\",\n\t\t\t\"```\",\n\t\t\t\"Insert before a line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert before 5:\",\n\t\t\t\"+log()\",\n\t\t\t\"```\",\n\t\t\t\"Insert after a line:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert after 3:\",\n\t\t\t\"+ print(msg)\",\n\t\t\t\"```\",\n\t\t\t\"Insert after the block whose opener is line 2:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert after block 2:\",\n\t\t\t\"+audit()\",\n\t\t\t\"```\",\n\t\t\t\"Insert at both file ends:\",\n\t\t\t\"```text\",\n\t\t\t\"[greet.py#A1B2]\",\n\t\t\t\"insert head:\",\n\t\t\t\"+# generated\",\n\t\t\t\"insert tail:\",\n\t\t\t'+greet(\"everyone\")',\n\t\t\t\"```\",\n\t\t\t\"Multi-file input:\",\n\t\t\t\"```text\",\n\t\t\t\"[src/a.ts#0A3B]\",\n\t\t\t\"replace 1..1:\",\n\t\t\t\"+export const enabled = true;\",\n\t\t\t\"[src/b.ts#1F7C]\",\n\t\t\t\"delete 20\",\n\t\t\t\"```\",\n\t\t].join(\"\\n\"),\n\t\t[\n\t\t\t\"Anti-patterns:\",\n\t\t\t\"```text\",\n\t\t\t\"# WRONG — `-` rows are rejected; bare context rows are auto-prefixed and inserted as literal content: `-` rows are not valid; the range already names the lines being changed. For a literal `-` line, write `+-…`.\",\n\t\t\t\"replace 3..3:\",\n\t\t\t' msg = \"Hello\"',\n\t\t\t\"- print(msg)\",\n\t\t\t\"+ return msg\",\n\t\t\t\"# RIGHT\",\n\t\t\t\"replace 3..3:\",\n\t\t\t\"+ return msg\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — body glued to its header: payload line has no preceding hunk header; body starts on the NEXT line.\",\n\t\t\t\"replace block 238:+export const value = 1;\",\n\t\t\t\"# RIGHT\",\n\t\t\t\"replace block 238:\",\n\t\t\t\"+export const value = 1;\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — `delete N..M` has no colon and no body.\",\n\t\t\t\"delete 2..3:\",\n\t\t\t\"+replacement\",\n\t\t\t\"# RIGHT: delete 2..3\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — empty `insert` / `replace`: `insert` needs at least one `+TEXT` body row. A bodyless concrete `replace` silently deletes the range.\",\n\t\t\t\"insert after 2:\",\n\t\t\t\"replace 4..4:\",\n\t\t\t\"# RIGHT — give `replace` a body; if deletion is intended, write `delete 4`.\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — widened replace for a pure insertion can drop retyped keepers.\",\n\t\t\t\"replace 2..4:\",\n\t\t\t\"+kept()\",\n\t\t\t\"+added()\",\n\t\t\t\"# RIGHT: insert after 2:\",\n\t\t\t\"+added()\",\n\t\t\t\"\",\n\t\t\t\"# WRONG — block anchor is a closer/last visible line.\",\n\t\t\t\"insert after block 3:\",\n\t\t\t\"+after()\",\n\t\t\t\"# RIGHT: insert after 3:\",\n\t\t\t\"+after()\",\n\t\t\t\"```\",\n\t\t].join(\"\\n\"),\n\t\t[\n\t\t\t\"If you remember nothing else:\",\n\t\t\t\"1. RE-GROUND AFTER EVERY EDIT. Every apply mints a fresh #TAG and renumbers; use the edit response or a fresh read. Stale tag or surprise? STOP and re-read.\",\n\t\t\t\"2. RANGES ARE TIGHT. Cover only lines that change; a stale wide range shreds everything it spans. Whole construct → replace block N.\",\n\t\t\t\"3. THE BODY IS THE FINAL CONTENT. Only +TEXT rows; never -old/context lines. The range does the deleting.\",\n\t\t].join(\"\\n\"),\n\t] as const),\n} as const);\n\nexport type EditToolInput = Static<typeof editSchema>;\n\nexport interface EditToolDetails {\n\tdiff: string;\n\tpatch: string;\n\tfirstChangedLine?: number;\n}\n\nexport interface EditOperations {\n\treadFile: (absolutePath: string) => Promise<Buffer>;\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\taccess: (absolutePath: string) => Promise<void>;\n}\n\nconst defaultEditOperations: EditOperations = {\n\treadFile: (path) => fsReadFile(path),\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\taccess: (path) => fsAccess(path, constants.R_OK | constants.W_OK),\n};\n\nexport interface EditToolOptions {\n\toperations?: EditOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\ntype EditToolResultLike = {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: EditToolDetails | undefined;\n};\n\nclass EditFilesystem extends Filesystem {\n\tprivate readonly cwd: string;\n\tprivate readonly operations: EditOperations;\n\tconstructor(cwd: string, operations: EditOperations) {\n\t\tsuper();\n\t\tthis.cwd = cwd;\n\t\tthis.operations = operations;\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn resolveReadPath(path, this.cwd);\n\t}\n\n\tasync preflightWrite(path: string): Promise<void> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\ttry {\n\t\t\tawait this.operations.access(absolutePath);\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error && \"code\" in error ? `Error code: ${error.code}` : String(error);\n\t\t\tthrow new Error(`Could not edit file: ${path}. ${message}.`);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\treturn isNotebookPath(absolutePath)\n\t\t\t? readEditableNotebookText(absolutePath, path)\n\t\t\t: (await this.operations.readFile(absolutePath)).toString(\"utf-8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tconst absolutePath = this.canonicalPath(path);\n\t\tconst persisted = isNotebookPath(absolutePath)\n\t\t\t? serializeEditedNotebookText(absolutePath, path, normalizeToLF(stripBom(content).text))\n\t\t\t: content;\n\t\tawait this.operations.writeFile(absolutePath, persisted);\n\t\treturn { text: persisted };\n\t}\n}\n\nfunction isFourDigitHexTag(value: string): boolean {\n\treturn (\n\t\tvalue.length === 4 &&\n\t\t[...value].every(\n\t\t\t(char) => (char >= \"0\" && char <= \"9\") || (char >= \"a\" && char <= \"f\") || (char >= \"A\" && char <= \"F\"),\n\t\t)\n\t);\n}\n\nfunction extractFirstHeaderPath(input: string | undefined): string | undefined {\n\tif (!input) return undefined;\n\tfor (const line of input.split(\"\\n\")) {\n\t\tconst trimmed = line.trimStart();\n\t\tif (!trimmed.startsWith(\"[\")) continue;\n\t\tconst hashIndex = trimmed.indexOf(\"#\", 1);\n\t\tconst closeIndex = hashIndex >= 0 ? trimmed.indexOf(\"]\", hashIndex + 1) : -1;\n\t\tif (hashIndex <= 1 || closeIndex !== hashIndex + 5) continue;\n\t\tconst tag = trimmed.slice(hashIndex + 1, closeIndex);\n\t\tif (isFourDigitHexTag(tag)) return trimmed.slice(1, hashIndex);\n\t}\n\treturn undefined;\n}\n\nfunction formatEditCall(args: unknown, theme: Theme, cwd: string): string {\n\tconst input = args && typeof args === \"object\" && \"input\" in args ? (args as { input?: unknown }).input : undefined;\n\tconst pathDisplay = renderToolPath(\n\t\textractFirstHeaderPath(typeof input === \"string\" ? input : undefined) ?? null,\n\t\ttheme,\n\t\tcwd,\n\t);\n\treturn `${theme.fg(\"toolTitle\", theme.bold(\"edit\"))} ${pathDisplay}`;\n}\n\nfunction formatEditResult(result: EditToolResultLike, theme: Theme, isError: boolean): string | undefined {\n\tif (isError) {\n\t\tconst errorText = result.content\n\t\t\t.filter((c) => c.type === \"text\")\n\t\t\t.map((c) => c.text || \"\")\n\t\t\t.join(\"\\n\");\n\t\treturn errorText ? theme.fg(\"error\", errorText) : undefined;\n\t}\n\treturn result.details?.diff ? renderDiff(result.details.diff) : undefined;\n}\n\nasync function withFileMutationQueues<T>(filePaths: readonly string[], fn: () => Promise<T>): Promise<T> {\n\tconst sorted = [...new Set(filePaths)].sort();\n\tconst run = (index: number): Promise<T> => {\n\t\tconst filePath = sorted[index];\n\t\treturn filePath ? withFileMutationQueue(filePath, () => run(index + 1)) : fn();\n\t};\n\treturn run(0);\n}\n\nfunction throwIfAborted(signal?: AbortSignal): void {\n\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n}\n\nfunction formatNoopMessage(path: string, count: number): string {\n\treturn `Edits to ${path} parsed and applied cleanly, but produced no change: your body row(s) are byte-identical to the file at the targeted lines. The bug is somewhere else — re-read the file before issuing another edit. Do NOT widen the payload or add lines; verify the anchor first.${count > 1 ? `\\nNo-op count for this identical payload: ${count}.` : \"\"}`;\n}\n\nfunction blockMessages(item: PreparedSection | PatchSectionResult): string[] {\n\tconst warnings =\n\t\t\"parseWarnings\" in item ? [...item.parseWarnings, ...(item.applyResult.warnings ?? [])] : item.warnings;\n\tconst resolutions =\n\t\t(\"applyResult\" in item ? item.applyResult.blockResolutions : item.blockResolutions)?.map((resolution) => {\n\t\t\tconst verb = resolution.op === \"insert_after\" ? \"insert after block\" : `${resolution.op} block`;\n\t\t\tconst lands = resolution.op === \"insert_after\" ? `; body lands after line ${resolution.end}` : \"\";\n\t\t\treturn `${verb} ${resolution.anchorLine} → resolved lines ${resolution.start}-${resolution.end} (${resolution.end - resolution.start + 1} lines)${lands}`;\n\t\t}) ?? [];\n\treturn [...warnings, ...resolutions];\n}\n\nfunction assertUniquePreparedPaths(prepared: readonly PreparedSection[]): void {\n\tconst seen = new Map<string, string>();\n\tfor (const entry of prepared) {\n\t\tconst previous = seen.get(entry.canonicalPath);\n\t\tif (previous)\n\t\t\tthrow new Error(\n\t\t\t\t`Multiple hashline sections resolve to the same file (${previous} and ${entry.section.path}). Merge their ops under one header before applying.`,\n\t\t\t);\n\t\tseen.set(entry.canonicalPath, entry.section.path);\n\t}\n}\n\ninterface EditCwdScope {\n\treadonly fs: EditFilesystem;\n\treadonly batcher: EditBatchCoordinator<EditToolResultLike>;\n\tapplySiblingEdits(siblings: readonly { input: string }[], applySignal?: AbortSignal): Promise<EditToolResultLike>;\n}\n\nfunction createEditCwdScope(cwd: string, ops: EditOperations, hashlineStore: HashlineSnapshotStore): EditCwdScope {\n\tconst fs = new EditFilesystem(cwd, ops);\n\tconst patcher = new Patcher({ fs, snapshots: hashlineStore.snapshots, blockResolver: nativeBlockResolver });\n\tconst noopCounts = new Map<string, number>();\n\tconst batcher = new EditBatchCoordinator<EditToolResultLike>();\n\tasync function applySiblingEdits(\n\t\tsiblings: readonly { input: string }[],\n\t\tapplySignal?: AbortSignal,\n\t): Promise<EditToolResultLike> {\n\t\tconst merged =\n\t\t\tsiblings.length === 1\n\t\t\t\t? Patch.parse(siblings[0]!.input, { cwd })\n\t\t\t\t: Patch.parse(siblings.map((sibling) => sibling.input).join(\"\\n\"), { cwd });\n\t\tconst prepared: PreparedSection[] = [];\n\t\tfor (const section of merged.sections) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tprepared.push(await patcher.prepare(section));\n\t\t}\n\t\tassertUniquePreparedPaths(prepared);\n\t\tconst noops = prepared.filter((item) => item.isNoop);\n\t\tif (noops.length > 0) {\n\t\t\tif (noops.length !== prepared.length)\n\t\t\t\tthrow new Error(`Hashline edit for ${noops[0]!.section.path} did not change the file.`);\n\t\t\tconst key = prepared.map((item) => `${item.canonicalPath}\\0${item.applyResult.text}`).join(\"\\0\\0\");\n\t\t\tconst count = (noopCounts.get(key) ?? 0) + 1;\n\t\t\tnoopCounts.set(key, count);\n\t\t\tif (count >= 3) throw new Error(`STOP. ${formatNoopMessage(prepared[0]!.section.path, count)}`);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text: formatNoopMessage(prepared[0]!.section.path, count) }],\n\t\t\t\tdetails: { diff: \"\", patch: \"\" },\n\t\t\t};\n\t\t}\n\t\tfor (const item of prepared) {\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tif (normalizeToLF(stripBom(await fs.readText(item.section.path)).text) !== item.normalized)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Stale hashline tag for ${item.section.path}: file content changed before write. Re-read before editing.`,\n\t\t\t\t);\n\t\t}\n\t\tconst outputs: string[] = [];\n\t\tlet combinedDiff = \"\",\n\t\t\tcombinedPatch = \"\";\n\t\tlet firstChangedLine: number | undefined;\n\t\tconst batchNote = siblings.length > 1 ? [parallelEditBatchWarning(siblings.length)] : [];\n\t\tfor (let index = 0; index < prepared.length; index++) {\n\t\t\tconst item = prepared[index]!;\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tlet result: PatchSectionResult;\n\t\t\ttry {\n\t\t\t\tresult = await patcher.commit(item);\n\t\t\t} catch (error) {\n\t\t\t\tconst written = prepared.slice(0, index).map((entry) => entry.section.path);\n\t\t\t\tconst notWritten = prepared.slice(index + 1).map((entry) => entry.section.path);\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Failed to write ${item.section.path}: ${message}` +\n\t\t\t\t\t\t(written.length > 0 ? ` Sections already written: ${written.join(\", \")}.` : \"\") +\n\t\t\t\t\t\t(notWritten.length > 0 ? ` Sections not written: ${notWritten.join(\", \")}.` : \"\"),\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrowIfAborted(applySignal);\n\t\t\tinvalidateNativeSearchCache(result.canonicalPath);\n\t\t\tconst snapshot = recordHashlineSnapshot(result.canonicalPath, cwd, result.after, hashlineStore);\n\t\t\tconst diffResult = generateDiffString(result.before, result.after);\n\t\t\tcombinedDiff += `${combinedDiff ? \"\\n\" : \"\"}${diffResult.diff}`;\n\t\t\tcombinedPatch += `${combinedPatch ? \"\\n\" : \"\"}${generateUnifiedPatch(result.path, result.before, result.after)}`;\n\t\t\tfirstChangedLine ??= diffResult.firstChangedLine;\n\t\t\toutputs.push(formatCompactHashlineEditResult(snapshot, diffResult, [...batchNote, ...blockMessages(result)]));\n\t\t}\n\t\treturn {\n\t\t\tcontent: [{ type: \"text\", text: outputs.join(\"\\n\\n\") }],\n\t\t\tdetails: { diff: combinedDiff, patch: combinedPatch, firstChangedLine },\n\t\t};\n\t}\n\treturn { fs, batcher, applySiblingEdits };\n}\n\nexport function createEditToolDefinition(\n\tcwd: string,\n\toptions?: EditToolOptions,\n): ToolDefinition<typeof editSchema, EditToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultEditOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\t// Atomic adaptation of upstream #8627 (\"use ctx.cwd for cwd-sensitive tools\"). Upstream's edit\n\t// tool is a stateless text replacer, so it could resolve `ctx?.cwd || cwd` inline. Atomic's\n\t// hashline patcher instead carries per-tool state — the `EditFilesystem`, the `Patcher`, the\n\t// repeated-no-op counters, and the parallel-edit batcher — that is all keyed to one cwd.\n\t// Mutating a shared cwd field would corrupt concurrent tool calls, so each distinct execution\n\t// cwd gets its own scope. Callers that pass no ctx keep the factory cwd's scope unchanged.\n\tconst scopes = new Map<string, EditCwdScope>();\n\tconst scopeFor = (executionCwd: string): EditCwdScope => {\n\t\tconst existing = scopes.get(executionCwd);\n\t\tif (existing) return existing;\n\t\tconst scope = createEditCwdScope(executionCwd, ops, hashlineStore);\n\t\tscopes.set(executionCwd, scope);\n\t\treturn scope;\n\t};\n\treturn {\n\t\tname: \"edit\",\n\t\tlabel: \"edit\",\n\t\tdescription:\n\t\t\t\"Edit existing files with the hashline patch language: each section starts with [PATH#TAG] (TAG is the 4-hex snapshot tag from your latest read/search), then hunk headers (replace N..M:, replace block N:, delete N..M, delete block N, insert before|after N:, insert after block N:, insert head:, insert tail:) followed by +TEXT body rows. Numbers refer to the original file. Use the write tool to create new files.\",\n\t\tpromptSnippet: editToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...editToolSystemPromptContribution.guidelines],\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: editSchema,\n\t\tasync execute(_toolCallId, input: EditToolInput, signal?: AbortSignal, _onUpdate?, ctx?: ExtensionContext) {\n\t\t\tif (typeof input.input !== \"string\" || input.input.trim() === \"\")\n\t\t\t\tthrow new Error(\"edit input must be a non-empty hashline script with [PATH#TAG] sections.\");\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst { fs, batcher, applySiblingEdits } = scopeFor(executionCwd);\n\t\t\tconst patch = Patch.parse(input.input, { cwd: executionCwd });\n\t\t\tconst paths = new Map<string, string>();\n\t\t\tfor (const section of patch.sections) {\n\t\t\t\tif (section.fileHash === undefined) throw new Error(missingSnapshotTagMessage(section.path));\n\t\t\t\tpaths.set(section.path, section.fileHash);\n\t\t\t}\n\t\t\tconst entry = batcher.announce(input.input, paths, signal);\n\t\t\ttry {\n\t\t\t\treturn await withFileMutationQueues(\n\t\t\t\t\t[...paths.keys()].map((sectionPath) => fs.canonicalPath(sectionPath)),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\t\t\tthrowIfAborted(signal);\n\t\t\t\t\t\tconst siblings = batcher.takeCompatible(entry);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await applySiblingEdits(siblings, signal);\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.resolve(result);\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tfor (const sibling of siblings) sibling.reject(error);\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} catch (error) {\n\t\t\t\tif (entry.settled) return await entry.promise;\n\t\t\t\tentry.reject(error);\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tbatcher.drop(entry);\n\t\t\t}\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(formatEditCall(args, theme, context.cwd));\n\t\t\treturn text;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatEditResult(result as EditToolResultLike, theme, context.isError);\n\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\tcomponent.clear();\n\t\t\tif (!output) return component;\n\t\t\tcomponent.addChild(new Spacer(1));\n\t\t\tcomponent.addChild(new Text(output, 1, 0));\n\t\t\treturn component;\n\t\t},\n\t};\n}\n\nexport function createEditTool(cwd: string, options?: EditToolOptions): AgentTool<typeof editSchema> {\n\treturn wrapToolDefinition(createEditToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -20,8 +20,8 @@ export interface StrippedHashlineContent {
|
|
|
20
20
|
content: string;
|
|
21
21
|
stripped: boolean;
|
|
22
22
|
}
|
|
23
|
-
export declare function stripKnownHashlineCopiedContentWithMeta(content: string,
|
|
24
|
-
export declare function stripKnownHashlineCopiedContent(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore): string;
|
|
23
|
+
export declare function stripKnownHashlineCopiedContentWithMeta(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore, emittedPath: string): StrippedHashlineContent;
|
|
24
|
+
export declare function stripKnownHashlineCopiedContent(content: string, absolutePath: string, cwd: string, store: HashlineSnapshotStore, emittedPath: string): string;
|
|
25
25
|
export declare function formatCompactHashlineEditResult(snapshot: HashlineSnapshot, diff: {
|
|
26
26
|
diff?: string;
|
|
27
27
|
firstChangedLine?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashline.d.ts","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AACA,OAAO,EAKN,KAAK,aAAa,EAClB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,WAAW,gBAAgB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAC7E,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC7E;AAMD,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7E;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAkBnE;AAED,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,qBAAqB,GAC1B,gBAAgB,CAElB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,SAAmB,EAAE,SAAS,SAAI,GAAG,MAAM,CAKnH;AAED,MAAM,W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AuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,uCAAuC,CACtD,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,qBAAqB,EAC5B,WAAW,EAAE,MAAM,GACjB,uBAAuB,CA2FzB;AAED,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,qBAAqB,EAC5B,WAAW,EAAE,MAAM,GACjB,MAAM,CAER;AAED,wBAAgB,+BAA+B,CAC9C,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,EAClD,QAAQ,GAAE,SAAS,MAAM,EAAO,GAC9B,MAAM,CAMR"}
|
|
@@ -46,7 +46,7 @@ export function formatHashlineContent(snapshot, content = snapshot.content, star
|
|
|
46
46
|
formatNumberedLines(normalizeHashlineContent(content), startLine),
|
|
47
47
|
].join("\n");
|
|
48
48
|
}
|
|
49
|
-
export function stripKnownHashlineCopiedContentWithMeta(content,
|
|
49
|
+
export function stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store, emittedPath) {
|
|
50
50
|
const normalized = normalizeHashlineContent(content);
|
|
51
51
|
const lines = normalized.split("\n");
|
|
52
52
|
const headerIndex = lines.findIndex((line, index) => /^\[[^\]\n]+#[0-9A-Fa-f]{4}\]$/.test(line) &&
|
|
@@ -62,20 +62,50 @@ export function stripKnownHashlineCopiedContentWithMeta(content, _absolutePath,
|
|
|
62
62
|
const body = lines.slice(headerIndex + 1);
|
|
63
63
|
if (body.length === 0)
|
|
64
64
|
return { content: snapshot.content, stripped: true };
|
|
65
|
+
// The write tool emits its confirmation from the raw `path` argument it was
|
|
66
|
+
// called with (`Successfully wrote to ${path}`), not from the resolved path,
|
|
67
|
+
// so `emittedPath` is the authoritative anchor: it is the only form that is
|
|
68
|
+
// guaranteed to round-trip. The resolved and cwd-relative forms are accepted
|
|
69
|
+
// because a caller may have named the file either way, and the snapshot's own
|
|
70
|
+
// paths are accepted because a copied confirmation may belong to the write
|
|
71
|
+
// that produced the snapshot being copied. Every candidate is a complete
|
|
72
|
+
// path — a bare basename is deliberately NOT accepted, since `Successfully
|
|
73
|
+
// wrote to notes.md` is ordinary prose when the target is `deep/dir/notes.md`,
|
|
74
|
+
// and treating it as chrome destroys that line and everything after it.
|
|
75
|
+
const knownConfirmationPaths = new Set();
|
|
76
|
+
const addKnownPath = (filePath) => {
|
|
77
|
+
if (!filePath)
|
|
78
|
+
return;
|
|
79
|
+
knownConfirmationPaths.add(filePath);
|
|
80
|
+
knownConfirmationPaths.add(filePath.replaceAll("\\", "/"));
|
|
81
|
+
knownConfirmationPaths.add(filePath.replaceAll("/", "\\"));
|
|
82
|
+
};
|
|
83
|
+
addKnownPath(emittedPath);
|
|
84
|
+
addKnownPath(absolutePath);
|
|
85
|
+
if (absolutePath)
|
|
86
|
+
addKnownPath(relative(cwd, absolutePath));
|
|
87
|
+
addKnownPath(snapshot.absolutePath);
|
|
88
|
+
addKnownPath(snapshot.displayPath);
|
|
89
|
+
const isKnownWriteConfirmation = (line) => {
|
|
90
|
+
const match = line.match(/^Successfully wrote (?:\d+ bytes )?to (.+)$/);
|
|
91
|
+
return match !== null && knownConfirmationPaths.has(match[1] ?? "");
|
|
92
|
+
};
|
|
65
93
|
const stripped = [];
|
|
66
94
|
const snapshotLines = snapshot.content.split("\n");
|
|
67
95
|
let sawRow = false;
|
|
68
96
|
let lastCopiedLineNumber;
|
|
69
97
|
// Trailing tool chrome a model is likely to copy along with the hashline
|
|
70
98
|
// body: the read/search continuation footers, the write tool's own
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
99
|
+
// confirmation (and its stripped-note), and `Resolved …` conflict footers.
|
|
100
|
+
// A write confirmation is chrome only when it names the exact path the write
|
|
101
|
+
// was asked for; a matching prefix or basename alone may be user content.
|
|
102
|
+
// The optional byte count keeps pre-e583b290 confirmations matchable.
|
|
103
|
+
// These footers never carry a line number, so they mark the end of the
|
|
104
|
+
// numbered body instead of aborting stripping like an arbitrary line.
|
|
75
105
|
const isToolFooter = (line) => line.trim() === "" ||
|
|
76
106
|
/^\[\d+ more lines in file\./.test(line) ||
|
|
77
107
|
/^\[Showing lines /.test(line) ||
|
|
78
|
-
|
|
108
|
+
isKnownWriteConfirmation(line) ||
|
|
79
109
|
/^Resolved \d+ conflicts?/.test(line) ||
|
|
80
110
|
/^Resolved conflict \d+/.test(line) ||
|
|
81
111
|
/^Note: stripped copied hashline/.test(line) ||
|
|
@@ -108,14 +138,14 @@ export function stripKnownHashlineCopiedContentWithMeta(content, _absolutePath,
|
|
|
108
138
|
return { content: strippedContent, stripped: true };
|
|
109
139
|
}
|
|
110
140
|
// Header + only tool chrome (e.g. a copied write confirmation
|
|
111
|
-
// `Successfully wrote
|
|
112
|
-
//
|
|
141
|
+
// `Successfully wrote to <path>`) names a known snapshot with no numbered
|
|
142
|
+
// body to recover — resolve to the snapshot's stored content.
|
|
113
143
|
if (onlyFooter)
|
|
114
144
|
return { content: snapshot.content, stripped: true };
|
|
115
145
|
return { content, stripped: false };
|
|
116
146
|
}
|
|
117
|
-
export function stripKnownHashlineCopiedContent(content, absolutePath, cwd, store) {
|
|
118
|
-
return stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store).content;
|
|
147
|
+
export function stripKnownHashlineCopiedContent(content, absolutePath, cwd, store, emittedPath) {
|
|
148
|
+
return stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store, emittedPath).content;
|
|
119
149
|
}
|
|
120
150
|
export function formatCompactHashlineEditResult(snapshot, diff, messages = []) {
|
|
121
151
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashline.js","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alizePath, relative, sep } from \"node:path\";\nimport {\n\tcomputeFileHash,\n\tformatHashlineHeader,\n\tformatNumberedLines,\n\tInMemorySnapshotStore,\n\ttype SnapshotStore,\n} from \"./hashline-engine/index.ts\";\n\nexport interface HashlineSnapshot {\n\tabsolutePath: string;\n\tdisplayPath: string;\n\ttag: string;\n\tcontent: string;\n}\n\nexport interface HashlineSnapshotStore {\n\treadonly snapshots: SnapshotStore;\n\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot;\n\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nexport function hashlineDisplayPath(absolutePath: string, cwd: string): string {\n\tconst relativePath = relative(cwd, absolutePath);\n\tif (relativePath && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath)) return toPosixPath(relativePath);\n\treturn toPosixPath(absolutePath);\n}\n\nexport function normalizeHashlineContent(content: string): string {\n\treturn content\n\t\t.replace(/^\\uFEFF/, \"\")\n\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t.replace(/\\r/g, \"\\n\");\n}\n\nexport function computeHashlineTag(content: string): string {\n\treturn computeFileHash(normalizeHashlineContent(content));\n}\n\nexport function createHashlineSnapshotStore(): HashlineSnapshotStore {\n\tconst snapshots = new InMemorySnapshotStore();\n\tconst headers = new Map<string, HashlineSnapshot>();\n\treturn {\n\t\tsnapshots,\n\t\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot {\n\t\t\tconst normalizedPath = normalizePath(absolutePath);\n\t\t\tconst normalized = normalizeHashlineContent(content);\n\t\t\tconst displayPath = hashlineDisplayPath(normalizedPath, cwd);\n\t\t\tconst tag = snapshots.record(normalizedPath, normalized);\n\t\t\tconst snapshot = { absolutePath: normalizedPath, displayPath, tag, content: normalized };\n\t\t\theaders.set(`${displayPath}\\0${tag}`, snapshot);\n\t\t\treturn snapshot;\n\t\t},\n\t\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined {\n\t\t\treturn headers.get(`${displayPath}\\0${tag.toUpperCase()}`);\n\t\t},\n\t};\n}\n\nexport function recordHashlineSnapshot(\n\tabsolutePath: string,\n\tcwd: string,\n\tcontent: string,\n\tstore: HashlineSnapshotStore,\n): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\tformatNumberedLines(normalizeHashlineContent(content), startLine),\n\t].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent {\n\tcontent: string;\n\tstripped: boolean;\n}\n\nexport function stripKnownHashlineCopiedContentWithMeta(\n\tcontent: string,\n\t_absolutePath: string,\n\t_cwd: string,\n\tstore: HashlineSnapshotStore,\n): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex(\n\t\t(line, index) =>\n\t\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) &&\n\t\t\tlines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)),\n\t);\n\tif (headerIndex < 0) return { content, stripped: false };\n\tconst header = (lines[headerIndex] ?? \"\").match(/^\\[([^\\]\\n]+)#([0-9A-Fa-f]{4})\\]$/);\n\tif (!header) return { content, stripped: false };\n\tconst snapshot = store.findByHeader(header[1] ?? \"\", header[2] ?? \"\");\n\tif (!snapshot) return { content, stripped: false };\n\tconst body = lines.slice(headerIndex + 1);\n\tif (body.length === 0) return { content: snapshot.content, stripped: true };\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\tlet lastCopiedLineNumber: number | undefined;\n\t// Trailing tool chrome a model is likely to copy along with the hashline\n\t// body: the read/search continuation footers, the write tool's own\n\t// `Successfully wrote N bytes to <path>` confirmation (and its stripped-\n\t// note), and `Resolved …` conflict footers. These never carry a line\n\t// number, so they mark the end of the numbered body — they must not abort\n\t// stripping the way an arbitrary non-row line would.\n\tconst isToolFooter = (line: string): boolean =>\n\t\tline.trim() === \"\" ||\n\t\t/^\\[\\d+ more lines in file\\./.test(line) ||\n\t\t/^\\[Showing lines /.test(line) ||\n\t\t/^Successfully wrote \\d+ bytes to /.test(line) ||\n\t\t/^Resolved \\d+ conflicts?/.test(line) ||\n\t\t/^Resolved conflict \\d+/.test(line) ||\n\t\t/^Note: stripped copied hashline/.test(line) ||\n\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line);\n\tlet onlyFooter = true;\n\tfor (const line of body) {\n\t\tif (isToolFooter(line)) {\n\t\t\t// A footer after the numbered body ends the body; a footer before any\n\t\t\t// row (leading blanks / a copied snapshot header) is just skipped.\n\t\t\tif (sawRow) break;\n\t\t\tcontinue;\n\t\t}\n\t\tonlyFooter = false;\n\t\tconst match = line.match(/^[* ]?(\\d+):(.*)$/s);\n\t\tif (!match) return { content, stripped: false };\n\t\tsawRow = true;\n\t\tconst lineNumber = Number.parseInt(match[1] ?? \"0\", 10);\n\t\tconst strippedLine = match[2] ?? \"\";\n\t\tif (snapshotLines[lineNumber - 1] !== strippedLine) return { content, stripped: false };\n\t\tlastCopiedLineNumber = lineNumber;\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) {\n\t\tlet strippedContent = stripped.join(\"\\n\");\n\t\tif (snapshot.content.endsWith(\"\\n\") && lastCopiedLineNumber === snapshotLines.length - 1) strippedContent += \"\\n\";\n\t\treturn { content: strippedContent, stripped: true };\n\t}\n\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote N bytes to <path>`) names a known snapshot with no\n\t// numbered body to recover — resolve to the snapshot's stored content.\n\tif (onlyFooter) return { content: snapshot.content, stripped: true };\n\treturn { content, stripped: false };\n}\n\nexport function stripKnownHashlineCopiedContent(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store).content;\n}\n\nexport function formatCompactHashlineEditResult(\n\tsnapshot: HashlineSnapshot,\n\tdiff: { diff?: string; firstChangedLine?: number },\n\tmessages: readonly string[] = [],\n): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\t...messages,\n\t\tdiff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`,\n\t].join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hashline.js","sourceRoot":"","sources":["../../../src/core/tools/hashline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,aAAa,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClF,OAAO,EACN,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AAepC,SAAS,WAAW,CAAC,QAAgB;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,YAAoB,EAAE,GAAW;IACpE,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACjD,IAAI,YAAY,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;IAClH,OAAO,WAAW,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,OAAe;IACvD,OAAO,OAAO;SACZ,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;SACtB,O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GAAsB,EAAE;IAEhC,OAAO;QACN,oBAAoB,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC;QACxD,GAAG,QAAQ;QACX,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,uBAAuB,IAAI,CAAC,gBAAgB,IAAI,CAAC,EAAE;KACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["import { isAbsolute, normalize as normalizePath, relative, sep } from \"node:path\";\nimport {\n\tcomputeFileHash,\n\tformatHashlineHeader,\n\tformatNumberedLines,\n\tInMemorySnapshotStore,\n\ttype SnapshotStore,\n} from \"./hashline-engine/index.ts\";\n\nexport interface HashlineSnapshot {\n\tabsolutePath: string;\n\tdisplayPath: string;\n\ttag: string;\n\tcontent: string;\n}\n\nexport interface HashlineSnapshotStore {\n\treadonly snapshots: SnapshotStore;\n\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot;\n\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined;\n}\n\nfunction toPosixPath(filePath: string): string {\n\treturn filePath.split(sep).join(\"/\");\n}\n\nexport function hashlineDisplayPath(absolutePath: string, cwd: string): string {\n\tconst relativePath = relative(cwd, absolutePath);\n\tif (relativePath && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath)) return toPosixPath(relativePath);\n\treturn toPosixPath(absolutePath);\n}\n\nexport function normalizeHashlineContent(content: string): string {\n\treturn content\n\t\t.replace(/^\\uFEFF/, \"\")\n\t\t.replace(/\\r\\n/g, \"\\n\")\n\t\t.replace(/\\r/g, \"\\n\");\n}\n\nexport function computeHashlineTag(content: string): string {\n\treturn computeFileHash(normalizeHashlineContent(content));\n}\n\nexport function createHashlineSnapshotStore(): HashlineSnapshotStore {\n\tconst snapshots = new InMemorySnapshotStore();\n\tconst headers = new Map<string, HashlineSnapshot>();\n\treturn {\n\t\tsnapshots,\n\t\trecord(absolutePath: string, cwd: string, content: string): HashlineSnapshot {\n\t\t\tconst normalizedPath = normalizePath(absolutePath);\n\t\t\tconst normalized = normalizeHashlineContent(content);\n\t\t\tconst displayPath = hashlineDisplayPath(normalizedPath, cwd);\n\t\t\tconst tag = snapshots.record(normalizedPath, normalized);\n\t\t\tconst snapshot = { absolutePath: normalizedPath, displayPath, tag, content: normalized };\n\t\t\theaders.set(`${displayPath}\\0${tag}`, snapshot);\n\t\t\treturn snapshot;\n\t\t},\n\t\tfindByHeader(displayPath: string, tag: string): HashlineSnapshot | undefined {\n\t\t\treturn headers.get(`${displayPath}\\0${tag.toUpperCase()}`);\n\t\t},\n\t};\n}\n\nexport function recordHashlineSnapshot(\n\tabsolutePath: string,\n\tcwd: string,\n\tcontent: string,\n\tstore: HashlineSnapshotStore,\n): HashlineSnapshot {\n\treturn store.record(absolutePath, cwd, content);\n}\n\nexport function formatHashlineContent(snapshot: HashlineSnapshot, content = snapshot.content, startLine = 1): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\tformatNumberedLines(normalizeHashlineContent(content), startLine),\n\t].join(\"\\n\");\n}\n\nexport interface StrippedHashlineContent {\n\tcontent: string;\n\tstripped: boolean;\n}\n\nexport function stripKnownHashlineCopiedContentWithMeta(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): StrippedHashlineContent {\n\tconst normalized = normalizeHashlineContent(content);\n\tconst lines = normalized.split(\"\\n\");\n\tconst headerIndex = lines.findIndex(\n\t\t(line, index) =>\n\t\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line) &&\n\t\t\tlines.slice(0, index).every((prefix) => prefix.trim() === \"\" || /^#\\s+.+\\/?$/.test(prefix)),\n\t);\n\tif (headerIndex < 0) return { content, stripped: false };\n\tconst header = (lines[headerIndex] ?? \"\").match(/^\\[([^\\]\\n]+)#([0-9A-Fa-f]{4})\\]$/);\n\tif (!header) return { content, stripped: false };\n\tconst snapshot = store.findByHeader(header[1] ?? \"\", header[2] ?? \"\");\n\tif (!snapshot) return { content, stripped: false };\n\tconst body = lines.slice(headerIndex + 1);\n\tif (body.length === 0) return { content: snapshot.content, stripped: true };\n\t// The write tool emits its confirmation from the raw `path` argument it was\n\t// called with (`Successfully wrote to ${path}`), not from the resolved path,\n\t// so `emittedPath` is the authoritative anchor: it is the only form that is\n\t// guaranteed to round-trip. The resolved and cwd-relative forms are accepted\n\t// because a caller may have named the file either way, and the snapshot's own\n\t// paths are accepted because a copied confirmation may belong to the write\n\t// that produced the snapshot being copied. Every candidate is a complete\n\t// path — a bare basename is deliberately NOT accepted, since `Successfully\n\t// wrote to notes.md` is ordinary prose when the target is `deep/dir/notes.md`,\n\t// and treating it as chrome destroys that line and everything after it.\n\tconst knownConfirmationPaths = new Set<string>();\n\tconst addKnownPath = (filePath: string): void => {\n\t\tif (!filePath) return;\n\t\tknownConfirmationPaths.add(filePath);\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"\\\\\", \"/\"));\n\t\tknownConfirmationPaths.add(filePath.replaceAll(\"/\", \"\\\\\"));\n\t};\n\taddKnownPath(emittedPath);\n\taddKnownPath(absolutePath);\n\tif (absolutePath) addKnownPath(relative(cwd, absolutePath));\n\taddKnownPath(snapshot.absolutePath);\n\taddKnownPath(snapshot.displayPath);\n\tconst isKnownWriteConfirmation = (line: string): boolean => {\n\t\tconst match = line.match(/^Successfully wrote (?:\\d+ bytes )?to (.+)$/);\n\t\treturn match !== null && knownConfirmationPaths.has(match[1] ?? \"\");\n\t};\n\tconst stripped: string[] = [];\n\tconst snapshotLines = snapshot.content.split(\"\\n\");\n\tlet sawRow = false;\n\tlet lastCopiedLineNumber: number | undefined;\n\t// Trailing tool chrome a model is likely to copy along with the hashline\n\t// body: the read/search continuation footers, the write tool's own\n\t// confirmation (and its stripped-note), and `Resolved …` conflict footers.\n\t// A write confirmation is chrome only when it names the exact path the write\n\t// was asked for; a matching prefix or basename alone may be user content.\n\t// The optional byte count keeps pre-e583b290 confirmations matchable.\n\t// These footers never carry a line number, so they mark the end of the\n\t// numbered body instead of aborting stripping like an arbitrary line.\n\tconst isToolFooter = (line: string): boolean =>\n\t\tline.trim() === \"\" ||\n\t\t/^\\[\\d+ more lines in file\\./.test(line) ||\n\t\t/^\\[Showing lines /.test(line) ||\n\t\tisKnownWriteConfirmation(line) ||\n\t\t/^Resolved \\d+ conflicts?/.test(line) ||\n\t\t/^Resolved conflict \\d+/.test(line) ||\n\t\t/^Note: stripped copied hashline/.test(line) ||\n\t\t/^\\[[^\\]\\n]+#[0-9A-Fa-f]{4}\\]$/.test(line);\n\tlet onlyFooter = true;\n\tfor (const line of body) {\n\t\tif (isToolFooter(line)) {\n\t\t\t// A footer after the numbered body ends the body; a footer before any\n\t\t\t// row (leading blanks / a copied snapshot header) is just skipped.\n\t\t\tif (sawRow) break;\n\t\t\tcontinue;\n\t\t}\n\t\tonlyFooter = false;\n\t\tconst match = line.match(/^[* ]?(\\d+):(.*)$/s);\n\t\tif (!match) return { content, stripped: false };\n\t\tsawRow = true;\n\t\tconst lineNumber = Number.parseInt(match[1] ?? \"0\", 10);\n\t\tconst strippedLine = match[2] ?? \"\";\n\t\tif (snapshotLines[lineNumber - 1] !== strippedLine) return { content, stripped: false };\n\t\tlastCopiedLineNumber = lineNumber;\n\t\tstripped.push(strippedLine);\n\t}\n\tif (sawRow) {\n\t\tlet strippedContent = stripped.join(\"\\n\");\n\t\tif (snapshot.content.endsWith(\"\\n\") && lastCopiedLineNumber === snapshotLines.length - 1) strippedContent += \"\\n\";\n\t\treturn { content: strippedContent, stripped: true };\n\t}\n\n\t// Header + only tool chrome (e.g. a copied write confirmation\n\t// `Successfully wrote to <path>`) names a known snapshot with no numbered\n\t// body to recover — resolve to the snapshot's stored content.\n\tif (onlyFooter) return { content: snapshot.content, stripped: true };\n\treturn { content, stripped: false };\n}\n\nexport function stripKnownHashlineCopiedContent(\n\tcontent: string,\n\tabsolutePath: string,\n\tcwd: string,\n\tstore: HashlineSnapshotStore,\n\temittedPath: string,\n): string {\n\treturn stripKnownHashlineCopiedContentWithMeta(content, absolutePath, cwd, store, emittedPath).content;\n}\n\nexport function formatCompactHashlineEditResult(\n\tsnapshot: HashlineSnapshot,\n\tdiff: { diff?: string; firstChangedLine?: number },\n\tmessages: readonly string[] = [],\n): string {\n\treturn [\n\t\tformatHashlineHeader(snapshot.displayPath, snapshot.tag),\n\t\t...messages,\n\t\tdiff.diff?.trim() || `First changed line: ${diff.firstChangedLine ?? 1}`,\n\t].join(\"\\n\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAW/D,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EAAoB,cAAc,EAA2B,MAAM,wBAAwB,CAAC;AAGxG,OAAO,EAGN,KAAK,qBAAqB,EAI1B,MAAM,eAAe,CAAC;AAiBvB,QAAA,MAAM,WAAW;;;EAYhB,CAAC;AAEF,eAAO,MAAM,iCAAiC;sBACpC,+CAA+C;;EAI9C,CAAC;AACZ,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AACxD,MAAM,WAAW,gBAAgB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,8BAA8B;IAC9B,SAAS,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CA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AK,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AAwFD,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,qBAAqB,CAAC;CACtC;AA+ID,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAiNlE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG"}
|
package/dist/core/tools/write.js
CHANGED
|
@@ -263,7 +263,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
263
263
|
if (!sqlite && parsedSqlite?.table)
|
|
264
264
|
throw new Error(`SQLite database not found or is not SQLite: ${path}`);
|
|
265
265
|
if (sqlite) {
|
|
266
|
-
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore);
|
|
266
|
+
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore, path);
|
|
267
267
|
const message = writeSqliteSelector(sqlite, stripped.content);
|
|
268
268
|
return {
|
|
269
269
|
content: [{ type: "text", text: `${message}${strippedHashlineNote(stripped.stripped)}` }],
|
|
@@ -271,21 +271,21 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
if (archive) {
|
|
274
|
-
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore);
|
|
274
|
+
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore, path);
|
|
275
275
|
const resolvedArchive = resolveArchiveSelector(archive, executionCwd);
|
|
276
276
|
writeArchiveSelector(resolvedArchive, stripped.content);
|
|
277
277
|
return {
|
|
278
278
|
content: [
|
|
279
279
|
{
|
|
280
280
|
type: "text",
|
|
281
|
-
text: `Successfully wrote
|
|
281
|
+
text: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,
|
|
282
282
|
},
|
|
283
283
|
],
|
|
284
284
|
details: { resolvedPath: resolvedArchive.archivePath },
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
if (path.startsWith("conflict://")) {
|
|
288
|
-
const writeContent = stripKnownHashlineCopiedContent(content, "", executionCwd, hashlineStore);
|
|
288
|
+
const writeContent = stripKnownHashlineCopiedContent(content, "", executionCwd, hashlineStore, path);
|
|
289
289
|
const target = decodeURIComponent(path.slice("conflict://".length));
|
|
290
290
|
if (!target)
|
|
291
291
|
throw new Error("conflict:// target is required.");
|
|
@@ -323,13 +323,13 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
323
323
|
const sourcePath = path.startsWith("local://") ? resolveInternalSelector(path, executionCwd) : undefined;
|
|
324
324
|
if (sourcePath)
|
|
325
325
|
return createWriteToolDefinition(executionCwd, options).execute(_toolCallId, { path: sourcePath, content }, signal, _onUpdate, ctx);
|
|
326
|
-
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore);
|
|
326
|
+
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore, path);
|
|
327
327
|
await writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);
|
|
328
328
|
return {
|
|
329
329
|
content: [
|
|
330
330
|
{
|
|
331
331
|
type: "text",
|
|
332
|
-
text: `Successfully wrote
|
|
332
|
+
text: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,
|
|
333
333
|
},
|
|
334
334
|
],
|
|
335
335
|
details: {},
|
|
@@ -353,7 +353,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
353
353
|
const existing = await fsReadFile(absolutePath, "utf8").catch(() => undefined);
|
|
354
354
|
if (existing !== undefined && hasGeneratedMarker(existing))
|
|
355
355
|
throw new Error(`Refusing to overwrite generated file: ${path}`);
|
|
356
|
-
const stripped = stripKnownHashlineCopiedContentWithMeta(content, absolutePath, executionCwd, hashlineStore);
|
|
356
|
+
const stripped = stripKnownHashlineCopiedContentWithMeta(content, absolutePath, executionCwd, hashlineStore, path);
|
|
357
357
|
const writeContent = stripped.content;
|
|
358
358
|
await ops.writeFile(absolutePath, writeContent);
|
|
359
359
|
invalidateNativeSearchCache(absolutePath);
|
|
@@ -373,7 +373,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
373
373
|
content: [
|
|
374
374
|
{
|
|
375
375
|
type: "text",
|
|
376
|
-
text: `${header}\nSuccessfully wrote
|
|
376
|
+
text: `${header}\nSuccessfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,
|
|
377
377
|
},
|
|
378
378
|
],
|
|
379
379
|
details: { resolvedPath: absolutePath, ...(madeExecutable ? { madeExecutable } : {}) },
|