@bastani/atomic 0.9.2 → 0.9.3-alpha.2
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 +66 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/CHANGELOG.md +15 -0
- package/dist/builtin/cursor/README.md +2 -1
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/cursor/src/cursor-models-raw.json +2 -9
- package/dist/builtin/cursor/src/model-mapper.ts +14 -3
- package/dist/builtin/cursor/src/proto/protobuf-codec-base64.ts +22 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +53 -13
- package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +24 -7
- package/dist/builtin/cursor/src/proto/protobuf-codec.ts +3 -2
- package/dist/builtin/cursor/src/stream.ts +5 -11
- package/dist/builtin/cursor/src/transport-types.ts +3 -0
- package/dist/builtin/cursor/src/transport.ts +1 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/direct-tools.ts +4 -2
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/proxy-call.ts +3 -1
- package/dist/builtin/mcp/utils.ts +18 -7
- package/dist/builtin/subagents/CHANGELOG.md +20 -0
- package/dist/builtin/subagents/README.md +6 -6
- package/dist/builtin/subagents/agents/code-simplifier.md +7 -6
- package/dist/builtin/subagents/agents/codebase-analyzer.md +5 -4
- package/dist/builtin/subagents/agents/codebase-locator.md +3 -3
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +10 -10
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +4 -4
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +3 -3
- package/dist/builtin/subagents/agents/codebase-research-locator.md +4 -4
- package/dist/builtin/subagents/agents/debugger.md +5 -5
- package/dist/builtin/subagents/agents/worker.md +56 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +11 -11
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +3 -5
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +3 -3
- package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -0
- package/dist/builtin/subagents/src/extension/index.ts +6 -3
- package/dist/builtin/subagents/src/extension/schemas.ts +2 -7
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -4
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +15 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +35 -1
- package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/nested-render.ts +2 -2
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +2 -1
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +4 -2
- package/dist/builtin/subagents/src/shared/types-async.ts +1 -0
- package/dist/builtin/subagents/src/shared/types-depth.ts +5 -5
- package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +27 -5
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
- package/dist/builtin/subagents/src/tui/render-layout.ts +27 -4
- package/dist/builtin/subagents/src/tui/render-result-animation.ts +22 -31
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +6 -6
- package/dist/builtin/subagents/src/tui/render-result.ts +20 -19
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +3 -3
- package/dist/builtin/subagents/src/tui/render-widget.ts +46 -7
- package/dist/builtin/subagents/src/tui/render.ts +2 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +56 -0
- package/dist/builtin/workflows/README.md +3 -3
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +11 -6
- package/dist/builtin/workflows/builtin/goal-ledger.ts +33 -1
- package/dist/builtin/workflows/builtin/goal-prompts.ts +23 -28
- package/dist/builtin/workflows/builtin/goal-reducer.ts +2 -2
- package/dist/builtin/workflows/builtin/goal-reports.ts +2 -5
- package/dist/builtin/workflows/builtin/goal-review.ts +1 -1
- package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
- package/dist/builtin/workflows/builtin/open-claude-design-feedback.ts +3 -3
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +1 -3
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph-core.ts +7 -17
- package/dist/builtin/workflows/builtin/ralph-runner.ts +11 -18
- package/dist/builtin/workflows/builtin/shared-prompts.ts +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/authoring.d.ts +1 -1
- package/dist/builtin/workflows/src/durable/backend.ts +343 -0
- package/dist/builtin/workflows/src/durable/child-primitive.ts +79 -0
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +421 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +171 -0
- package/dist/builtin/workflows/src/durable/factory.ts +96 -0
- package/dist/builtin/workflows/src/durable/file-backend.ts +433 -0
- package/dist/builtin/workflows/src/durable/index.ts +73 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +217 -0
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +299 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +171 -0
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +284 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +180 -0
- package/dist/builtin/workflows/src/durable/types.ts +168 -0
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +96 -0
- package/dist/builtin/workflows/src/engine/options.ts +3 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +2 -2
- package/dist/builtin/workflows/src/engine/primitives/task.ts +4 -4
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +22 -8
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +8 -0
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +69 -0
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +31 -0
- package/dist/builtin/workflows/src/engine/run.ts +148 -6
- package/dist/builtin/workflows/src/engine/runtime.ts +8 -2
- package/dist/builtin/workflows/src/extension/config-loader.ts +35 -15
- package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
- package/dist/builtin/workflows/src/extension/extension-factory.ts +6 -12
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +5 -1
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +4 -2
- package/dist/builtin/workflows/src/extension/runtime.ts +48 -9
- package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +143 -4
- package/dist/builtin/workflows/src/runs/background/quit.ts +61 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +5 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +74 -33
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +20 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +8 -7
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +19 -2
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +10 -10
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +5 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +25 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +16 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +20 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +23 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +30 -1
- package/dist/builtin/workflows/src/shared/store-public-types.ts +6 -2
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +12 -6
- package/dist/builtin/workflows/src/shared/types.ts +55 -0
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +1 -1
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +41 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +82 -24
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +7 -0
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +22 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +4 -5
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +9 -11
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +9 -3
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +11 -2
- package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +35 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +51 -17
- package/dist/builtin/workflows/src/tui/stage-chat-view-status.ts +36 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +5 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/status-list.ts +14 -2
- package/dist/builtin/workflows/src/tui/widget.ts +23 -8
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +5 -4
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +8 -8
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +151 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/config-self-update.d.ts.map +1 -1
- package/dist/config-self-update.js +3 -4
- package/dist/config-self-update.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -5
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -0
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +1 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +23 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/bash-executor.d.ts +2 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +29 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +36 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +14 -2
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.js +50 -1
- package/dist/core/compaction/context-compaction-metrics.js.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-prompt.js +2 -0
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -1
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction-runner.js +1 -1
- package/dist/core/compaction/context-compaction-runner.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-application.js +5 -5
- package/dist/core/compaction/context-deletion-application.js.map +1 -1
- package/dist/core/compaction/context-deletion-targets.d.ts +2 -0
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-targets.js +23 -3
- package/dist/core/compaction/context-deletion-targets.js.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +6 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
- package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -1
- package/dist/core/compaction/context-deletion-tools.js +18 -10
- package/dist/core/compaction/context-deletion-tools.js.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
- package/dist/core/compaction/context-transcript-analysis.js +2 -4
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
- package/dist/core/copilot-gemini-tool-arguments.js +2 -60
- package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +2 -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/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +57 -32
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +11 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/tool-events.d.ts +13 -13
- package/dist/core/extensions/tool-events.d.ts.map +1 -1
- package/dist/core/extensions/tool-events.js +3 -3
- package/dist/core/extensions/tool-events.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/flattened-tool-arguments.d.ts +18 -0
- package/dist/core/flattened-tool-arguments.d.ts.map +1 -1
- package/dist/core/flattened-tool-arguments.js +104 -0
- package/dist/core/flattened-tool-arguments.js.map +1 -1
- package/dist/core/messages.d.ts +1 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +46 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +12 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +15 -7
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +20 -9
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +2 -2
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js +9 -3
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +2 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts +3 -3
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +27 -8
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +3 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +55 -12
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-manager-tool-dependencies.d.ts +10 -0
- package/dist/core/session-manager-tool-dependencies.d.ts.map +1 -0
- package/dist/core/session-manager-tool-dependencies.js +133 -0
- package/dist/core/session-manager-tool-dependencies.js.map +1 -0
- package/dist/core/session-manager-types.d.ts +22 -0
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/session-manager.d.ts +2 -2
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +1 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +4 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +18 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts +4 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.js +15 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -1
- package/dist/core/settings-types.d.ts +11 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/system-prompt.d.ts +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/artifact-protocol.d.ts +11 -0
- package/dist/core/tools/artifact-protocol.d.ts.map +1 -0
- package/dist/core/tools/artifact-protocol.js +76 -0
- package/dist/core/tools/artifact-protocol.js.map +1 -0
- package/dist/core/tools/artifacts.d.ts +18 -0
- package/dist/core/tools/artifacts.d.ts.map +1 -0
- package/dist/core/tools/artifacts.js +90 -0
- package/dist/core/tools/artifacts.js.map +1 -0
- package/dist/core/tools/bash-async-jobs.d.ts +20 -0
- package/dist/core/tools/bash-async-jobs.d.ts.map +1 -0
- package/dist/core/tools/bash-async-jobs.js +59 -0
- package/dist/core/tools/bash-async-jobs.js.map +1 -0
- package/dist/core/tools/bash-async-output.d.ts +10 -0
- package/dist/core/tools/bash-async-output.d.ts.map +1 -0
- package/dist/core/tools/bash-async-output.js +80 -0
- package/dist/core/tools/bash-async-output.js.map +1 -0
- package/dist/core/tools/bash-interceptor.d.ts +10 -0
- package/dist/core/tools/bash-interceptor.d.ts.map +1 -0
- package/dist/core/tools/bash-interceptor.js +39 -0
- package/dist/core/tools/bash-interceptor.js.map +1 -0
- package/dist/core/tools/bash-leading-cd.d.ts +7 -0
- package/dist/core/tools/bash-leading-cd.d.ts.map +1 -0
- package/dist/core/tools/bash-leading-cd.js +59 -0
- package/dist/core/tools/bash-leading-cd.js.map +1 -0
- package/dist/core/tools/bash-pty-native.d.ts +14 -0
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -0
- package/dist/core/tools/bash-pty-native.js +71 -0
- package/dist/core/tools/bash-pty-native.js.map +1 -0
- package/dist/core/tools/bash.d.ts +28 -17
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +152 -35
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/block-resolver.d.ts +16 -0
- package/dist/core/tools/block-resolver.d.ts.map +1 -0
- package/dist/core/tools/block-resolver.js +74 -0
- package/dist/core/tools/block-resolver.js.map +1 -0
- package/dist/core/tools/conflict-registry.d.ts +16 -0
- package/dist/core/tools/conflict-registry.d.ts.map +1 -0
- package/dist/core/tools/conflict-registry.js +44 -0
- package/dist/core/tools/conflict-registry.js.map +1 -0
- package/dist/core/tools/directory-tree.d.ts +13 -0
- package/dist/core/tools/directory-tree.d.ts.map +1 -0
- package/dist/core/tools/directory-tree.js +81 -0
- package/dist/core/tools/directory-tree.js.map +1 -0
- package/dist/core/tools/edit.d.ts +4 -29
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +136 -228
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/fetch-url.d.ts +74 -0
- package/dist/core/tools/fetch-url.d.ts.map +1 -0
- package/dist/core/tools/fetch-url.js +518 -0
- package/dist/core/tools/fetch-url.js.map +1 -0
- package/dist/core/tools/find.d.ts +27 -9
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +400 -176
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/glob-path-utils.d.ts +8 -0
- package/dist/core/tools/glob-path-utils.d.ts.map +1 -0
- package/dist/core/tools/glob-path-utils.js +26 -0
- package/dist/core/tools/glob-path-utils.js.map +1 -0
- package/dist/core/tools/grep.d.ts +12 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +141 -17
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hashline-engine/apply.d.ts +11 -0
- package/dist/core/tools/hashline-engine/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/apply.js +752 -0
- package/dist/core/tools/hashline-engine/apply.js.map +1 -0
- package/dist/core/tools/hashline-engine/block.d.ts +40 -0
- package/dist/core/tools/hashline-engine/block.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/block.js +117 -0
- package/dist/core/tools/hashline-engine/block.js.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts +15 -0
- package/dist/core/tools/hashline-engine/diff-preview.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/diff-preview.js +98 -0
- package/dist/core/tools/hashline-engine/diff-preview.js.map +1 -0
- package/dist/core/tools/hashline-engine/format.d.ts +71 -0
- package/dist/core/tools/hashline-engine/format.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/format.js +178 -0
- package/dist/core/tools/hashline-engine/format.js.map +1 -0
- package/dist/core/tools/hashline-engine/fs.d.ts +81 -0
- package/dist/core/tools/hashline-engine/fs.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/fs.js +143 -0
- package/dist/core/tools/hashline-engine/fs.js.map +1 -0
- package/dist/core/tools/hashline-engine/index.d.ts +18 -0
- package/dist/core/tools/hashline-engine/index.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/index.js +20 -0
- package/dist/core/tools/hashline-engine/index.js.map +1 -0
- package/dist/core/tools/hashline-engine/input.d.ts +101 -0
- package/dist/core/tools/hashline-engine/input.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/input.js +398 -0
- package/dist/core/tools/hashline-engine/input.js.map +1 -0
- package/dist/core/tools/hashline-engine/messages.d.ts +99 -0
- package/dist/core/tools/hashline-engine/messages.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/messages.js +144 -0
- package/dist/core/tools/hashline-engine/messages.js.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts +45 -0
- package/dist/core/tools/hashline-engine/mismatch.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/mismatch.js +90 -0
- package/dist/core/tools/hashline-engine/mismatch.js.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts +21 -0
- package/dist/core/tools/hashline-engine/normalize.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/normalize.js +33 -0
- package/dist/core/tools/hashline-engine/normalize.js.map +1 -0
- package/dist/core/tools/hashline-engine/parser.d.ts +24 -0
- package/dist/core/tools/hashline-engine/parser.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/parser.js +381 -0
- package/dist/core/tools/hashline-engine/parser.js.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts +118 -0
- package/dist/core/tools/hashline-engine/patcher.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/patcher.js +341 -0
- package/dist/core/tools/hashline-engine/patcher.js.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts +43 -0
- package/dist/core/tools/hashline-engine/prefixes.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/prefixes.js +135 -0
- package/dist/core/tools/hashline-engine/prefixes.js.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts +41 -0
- package/dist/core/tools/hashline-engine/recovery.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/recovery.js +168 -0
- package/dist/core/tools/hashline-engine/recovery.js.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts +65 -0
- package/dist/core/tools/hashline-engine/snapshots.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/snapshots.js +108 -0
- package/dist/core/tools/hashline-engine/snapshots.js.map +1 -0
- package/dist/core/tools/hashline-engine/stream.d.ts +3 -0
- package/dist/core/tools/hashline-engine/stream.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/stream.js +111 -0
- package/dist/core/tools/hashline-engine/stream.js.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts +69 -0
- package/dist/core/tools/hashline-engine/tokenizer.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/tokenizer.js +430 -0
- package/dist/core/tools/hashline-engine/tokenizer.js.map +1 -0
- package/dist/core/tools/hashline-engine/types.d.ts +166 -0
- package/dist/core/tools/hashline-engine/types.d.ts.map +1 -0
- package/dist/core/tools/hashline-engine/types.js +9 -0
- package/dist/core/tools/hashline-engine/types.js.map +1 -0
- package/dist/core/tools/hashline.d.ts +29 -0
- package/dist/core/tools/hashline.d.ts.map +1 -0
- package/dist/core/tools/hashline.js +110 -0
- package/dist/core/tools/hashline.js.map +1 -0
- package/dist/core/tools/index.d.ts +6 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +52 -35
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/notebook.d.ts +38 -0
- package/dist/core/tools/notebook.d.ts.map +1 -0
- package/dist/core/tools/notebook.js +125 -0
- package/dist/core/tools/notebook.js.map +1 -0
- package/dist/core/tools/read-document-extract.d.ts +9 -0
- package/dist/core/tools/read-document-extract.d.ts.map +1 -0
- package/dist/core/tools/read-document-extract.js +212 -0
- package/dist/core/tools/read-document-extract.js.map +1 -0
- package/dist/core/tools/read-selectors.d.ts +24 -0
- package/dist/core/tools/read-selectors.d.ts.map +1 -0
- package/dist/core/tools/read-selectors.js +277 -0
- package/dist/core/tools/read-selectors.js.map +1 -0
- package/dist/core/tools/read-url.d.ts +37 -0
- package/dist/core/tools/read-url.d.ts.map +1 -0
- package/dist/core/tools/read-url.js +39 -0
- package/dist/core/tools/read-url.js.map +1 -0
- package/dist/core/tools/read.d.ts +11 -11
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +224 -94
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +44 -0
- package/dist/core/tools/resource-selectors.d.ts.map +1 -0
- package/dist/core/tools/resource-selectors.js +808 -0
- package/dist/core/tools/resource-selectors.js.map +1 -0
- package/dist/core/tools/search-details.d.ts +26 -0
- package/dist/core/tools/search-details.d.ts.map +1 -0
- package/dist/core/tools/search-details.js +24 -0
- package/dist/core/tools/search-details.js.map +1 -0
- package/dist/core/tools/search-line-ranges.d.ts +11 -0
- package/dist/core/tools/search-line-ranges.d.ts.map +1 -0
- package/dist/core/tools/search-line-ranges.js +65 -0
- package/dist/core/tools/search-line-ranges.js.map +1 -0
- package/dist/core/tools/search-native.d.ts +97 -0
- package/dist/core/tools/search-native.d.ts.map +1 -0
- package/dist/core/tools/search-native.js +27 -0
- package/dist/core/tools/search-native.js.map +1 -0
- package/dist/core/tools/search.d.ts +24 -0
- package/dist/core/tools/search.d.ts.map +1 -0
- package/dist/core/tools/search.js +573 -0
- package/dist/core/tools/search.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +4 -4
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +3 -3
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/url-ip-guards.d.ts +4 -0
- package/dist/core/tools/url-ip-guards.d.ts.map +1 -0
- package/dist/core/tools/url-ip-guards.js +126 -0
- package/dist/core/tools/url-ip-guards.js.map +1 -0
- package/dist/core/tools/write.d.ts +12 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +166 -14
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -3
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +12 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +4 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js +131 -0
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +7 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +15 -4
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +9 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +7 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +3 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +26 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +0 -5
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +1 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +80 -2
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-hotkeys-debug.js +3 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +51 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +5 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +12 -0
- 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-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +4 -1
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-onboarding.d.ts +11 -0
- package/dist/modes/interactive/interactive-onboarding.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-onboarding.js +220 -0
- package/dist/modes/interactive/interactive-onboarding.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +4 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +6 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +9 -4
- 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 +28 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +21 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/markit.d.ts +8 -0
- package/dist/utils/markit.d.ts.map +1 -0
- package/dist/utils/markit.js +53 -0
- package/dist/utils/markit.js.map +1 -0
- package/dist/utils/paths.d.ts +2 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +14 -1
- package/dist/utils/paths.js.map +1 -1
- package/docs/compaction.md +18 -1
- package/docs/containerization.md +1 -1
- package/docs/docs.json +1 -0
- package/docs/extensions.md +25 -36
- package/docs/models.md +1 -1
- package/docs/providers.md +2 -1
- package/docs/quickstart.md +11 -6
- package/docs/sdk.md +5 -5
- package/docs/session-format.md +6 -0
- package/docs/sessions.md +6 -0
- package/docs/settings.md +7 -0
- package/docs/subagents.md +3 -2
- package/docs/tools.md +49 -0
- package/docs/usage.md +3 -3
- package/docs/workflows.md +112 -8
- package/examples/extensions/subagent/README.md +5 -5
- package/examples/extensions/subagent/agents/planner.md +1 -1
- package/examples/extensions/subagent/agents/reviewer.md +1 -1
- package/examples/extensions/subagent/agents/scout.md +2 -2
- package/examples/extensions/subagent/display.ts +3 -3
- package/examples/sdk/05-tools.ts +3 -3
- package/examples/sdk/README.md +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/apply.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL;;;;;;;;GAQG;AACH,OAAO,EAAE,8BAA8B,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1H,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAc7C,SAAS,mBAAmB,CAAC,IAAU;IACtC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC;AAC9D,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACvC,OAAO,MAAM,CAAC,IAAI,KAAK,eAAe,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC;AAED,SAAS,cAAc,CAAC,IAAiB;IACxC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,mBAAmB,CAAC,SAA4B;IACxD,4EAA4E;IAC5E,sEAAsE;IACtE,8EAA8E;IAC9E,6EAA6E;IAC7E,mDAAmD;IACnD,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,C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M,EAAE,CAAC,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACtG,IAAI,CAAC,UAAU;YAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,CAAC;QAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzE,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,CAAC;QACzC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;QACvC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QAChD,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IACrE,IAAI,cAAc,KAAK,SAAS;QAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAEpE,OAAO;QACN,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1B,gBAAgB;QAChB,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5C,CAAC;AACH,CAAC","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Apply a parsed list of {@link Edit}s to a text body and return the\n * post-edit lines plus any diagnostic warnings. Pure function: no FS, no\n * mutation of the input.\n *\n * Replacement groups are first normalized by {@link repairReplacementBoundaries},\n * which absorbs common model mistakes where a payload restates unchanged range\n * boundaries or duplicates/drops structural closers.\n */\nimport { afterInsertLandingShiftWarning, blockInsertLandingShiftWarning, UNRESOLVED_BLOCK_INTERNAL } from \"./messages.js\";\nimport { cloneCursor } from \"./tokenizer.js\";\nimport type { Anchor, ApplyResult, Cursor, Edit } from \"./types.js\";\n\ntype LineOrigin = \"original\" | \"insert\" | \"replacement\";\n\ntype InsertEdit = Extract<Edit, { kind: \"insert\" }>;\ntype DeleteEdit = Extract<Edit, { kind: \"delete\" }>;\ntype AppliedEdit = InsertEdit | DeleteEdit;\n\ninterface IndexedEdit {\n\tedit: AppliedEdit;\n\tidx: number;\n}\n\nfunction isReplacementInsert(edit: Edit): edit is InsertEdit & { mode: \"replacement\" } {\n\treturn edit.kind === \"insert\" && edit.mode === \"replacement\";\n}\n\nfunction getCursorAnchors(cursor: Cursor): Anchor[] {\n\treturn cursor.kind === \"before_anchor\" || cursor.kind === \"after_anchor\" ? [cursor.anchor] : [];\n}\n\nfunction getEditAnchors(edit: AppliedEdit): Anchor[] {\n\tif (edit.kind === \"delete\") return [edit.anchor];\n\treturn getCursorAnchors(edit.cursor);\n}\n\nfunction trailingPhantomLine(fileLines: readonly string[]): number {\n\t// `split(\"\\n\")` on a newline-terminated file yields a trailing \"\" sentinel.\n\t// It is addressable for inserts (append-past-end), but it is not real\n\t// content. Deleting it only strips the file's final newline, so ignore delete\n\t// edits that land there; inclusive ranges ending at EOF then do the intended\n\t// thing and delete through the last concrete line.\n\treturn fileLines.length > 1 && fileLines[fileLines.length - 1] === \"\" ? fileLines.length : 0;\n}\n\nfunction dropTrailingPhantomDeletes(edits: AppliedEdit[], fileLines: readonly string[]): AppliedEdit[] {\n\tconst phantomLine = trailingPhantomLine(fileLines);\n\tif (phantomLine === 0) return edits;\n\treturn edits.filter(edit => edit.kind !== \"delete\" || edit.anchor.line !== phantomLine);\n}\n\n/**\n * Verify every anchored edit points at an existing line. File-version binding is\n * checked once per section via the header hash before this function runs.\n */\nfunction validateLineBounds(edits: readonly AppliedEdit[], fileLines: readonly string[]): void {\n\tfor (const edit of edits) {\n\t\tfor (const anchor of getEditAnchors(edit)) {\n\t\t\tif (anchor.line < 1 || anchor.line > fileLines.length) {\n\t\t\t\tthrow new Error(`Line ${anchor.line} does not exist (file has ${fileLines.length} lines)`);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction cloneAppliedEdit(edit: AppliedEdit, index: number): AppliedEdit {\n\tif (edit.kind === \"delete\") return { ...edit, anchor: { ...edit.anchor }, index };\n\treturn { ...edit, cursor: cloneCursor(edit.cursor), index };\n}\n\nfunction insertAtStart(fileLines: string[], lineOrigins: LineOrigin[], lines: string[]): void {\n\tif (lines.length === 0) return;\n\tconst origins = lines.map((): LineOrigin => \"insert\");\n\tif (fileLines.length === 1 && fileLines[0] === \"\") {\n\t\tfileLines.splice(0, 1, ...lines);\n\t\tlineOrigins.splice(0, 1, ...origins);\n\t\treturn;\n\t}\n\tfileLines.splice(0, 0, ...lines);\n\tlineOrigins.splice(0, 0, ...origins);\n}\n\nfunction insertAtEnd(fileLines: string[], lineOrigins: LineOrigin[], lines: string[]): number | undefined {\n\tif (lines.length === 0) return undefined;\n\tconst origins = lines.map((): LineOrigin => \"insert\");\n\tif (fileLines.length === 1 && fileLines[0] === \"\") {\n\t\tfileLines.splice(0, 1, ...lines);\n\t\tlineOrigins.splice(0, 1, ...origins);\n\t\treturn 1;\n\t}\n\tconst hasTrailingNewline = fileLines.length > 0 && fileLines[fileLines.length - 1] === \"\";\n\tconst insertIndex = hasTrailingNewline ? fileLines.length - 1 : fileLines.length;\n\tfileLines.splice(insertIndex, 0, ...lines);\n\tlineOrigins.splice(insertIndex, 0, ...origins);\n\treturn insertIndex + 1;\n}\n\nfunction bucketAnchorEditsByLine(edits: IndexedEdit[]): Map<number, IndexedEdit[]> {\n\tconst byLine = new Map<number, IndexedEdit[]>();\n\tfor (const entry of edits) {\n\t\tconst line =\n\t\t\tentry.edit.kind === \"delete\"\n\t\t\t\t? entry.edit.anchor.line\n\t\t\t\t: entry.edit.cursor.kind === \"before_anchor\" || entry.edit.cursor.kind === \"after_anchor\"\n\t\t\t\t\t? entry.edit.cursor.anchor.line\n\t\t\t\t\t: 0;\n\t\tconst bucket = byLine.get(line);\n\t\tif (bucket) bucket.push(entry);\n\t\telse byLine.set(line, [entry]);\n\t}\n\treturn byLine;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Replacement-boundary repair\n//\n// Models routinely miscount a replacement range's edges. Sometimes the payload\n// re-states unchanged lines that still live on both sides of the range\n// (duplicating a function header and final statement); sometimes it only\n// re-states or omits a structural closer, which leaves delimiter balance broken.\n//\n// A balance-neutral boundary-echo repair fires only when both the leading and\n// trailing payload edges are exact copies of the surviving lines outside the\n// range. One-sided content echoes are left alone unless delimiter-balance repair\n// proves they are duplicated structural boundaries. This preserves intended\n// duplicate statements while absorbing the common \"body includes the unchanged\n// wrapper\" mistake.\n\n/** A line that is nothing but closing delimiters: `}`, `)`, `];`, `})`, `},`. */\nexport const STRUCTURAL_CLOSER_RE = /^\\s*[)\\]}]+[;,]?\\s*$/;\n\ninterface DelimiterBalance {\n\tparen: number;\n\tbracket: number;\n\tbrace: number;\n}\n\n/**\n * Net `()` / `[]` / `{}` delta across `lines`, skipping delimiters inside line\n * comments (`//`), block comments, and string/template literals. Block-comment\n * and backtick-template state carry across lines; `\"` / `'` reset at EOL since\n * they cannot span lines. Deliberately language-light: constructs it cannot\n * classify (e.g. regex literals) are counted naively, which can only suppress a\n * repair (the safe direction), never force one.\n */\nfunction computeDelimiterBalance(lines: readonly string[]): DelimiterBalance {\n\tconst balance: DelimiterBalance = { paren: 0, bracket: 0, brace: 0 };\n\tlet inBlockComment = false;\n\tlet quote = \"\";\n\tfor (const line of lines) {\n\t\tfor (let i = 0; i < line.length; i++) {\n\t\t\tconst ch = line[i];\n\t\t\tif (inBlockComment) {\n\t\t\t\tif (ch === \"*\" && line[i + 1] === \"/\") {\n\t\t\t\t\tinBlockComment = false;\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (quote) {\n\t\t\t\tif (ch === \"\\\\\") i++;\n\t\t\t\telse if (ch === quote) quote = \"\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === '\"' || ch === \"'\" || ch === \"`\") {\n\t\t\t\tquote = ch;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === \"/\" && line[i + 1] === \"/\") break;\n\t\t\tif (ch === \"/\" && line[i + 1] === \"*\") {\n\t\t\t\tinBlockComment = true;\n\t\t\t\ti++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tswitch (ch) {\n\t\t\t\tcase \"(\":\n\t\t\t\t\tbalance.paren++;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \")\":\n\t\t\t\t\tbalance.paren--;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"[\":\n\t\t\t\t\tbalance.bracket++;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"]\":\n\t\t\t\t\tbalance.bracket--;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"{\":\n\t\t\t\t\tbalance.brace++;\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"}\":\n\t\t\t\t\tbalance.brace--;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// `\"` / `'` cannot span lines; only backtick templates and block comments do.\n\t\tif (quote === '\"' || quote === \"'\") quote = \"\";\n\t}\n\treturn balance;\n}\n\nfunction balanceDelta(a: DelimiterBalance, b: DelimiterBalance): DelimiterBalance {\n\treturn { paren: a.paren - b.paren, bracket: a.bracket - b.bracket, brace: a.brace - b.brace };\n}\n\nfunction balanceNegate(a: DelimiterBalance): DelimiterBalance {\n\treturn { paren: -a.paren, bracket: -a.bracket, brace: -a.brace };\n}\n\nfunction balanceEqual(a: DelimiterBalance, b: DelimiterBalance): boolean {\n\treturn a.paren === b.paren && a.bracket === b.bracket && a.brace === b.brace;\n}\n\nfunction balanceIsZero(a: DelimiterBalance): boolean {\n\treturn a.paren === 0 && a.bracket === 0 && a.brace === 0;\n}\n\ninterface ReplacementGroup {\n\t/** Positions in the edit array of the payload inserts, in payload order. */\n\tinsertIndices: number[];\n\t/** Positions in the edit array of the range deletes, ascending by line. */\n\tdeleteIndices: number[];\n\tpayload: string[];\n\t/** First deleted line (1-indexed). */\n\tstartLine: number;\n\t/** Last deleted line (1-indexed). */\n\tendLine: number;\n}\n\n/**\n * Detect a replacement group starting at `start`: a run of `before_anchor`\n * replacement inserts sharing one source op line, immediately followed by the\n * contiguous range deletes for that same op. Mirrors how the parser lowers an\n * `replace N..M:` hunk with a body.\n */\nfunction findReplacementGroup(edits: readonly AppliedEdit[], start: number): ReplacementGroup | undefined {\n\tconst first = edits[start];\n\tif (first?.kind !== \"insert\" || first.mode !== \"replacement\" || first.cursor.kind !== \"before_anchor\") {\n\t\treturn undefined;\n\t}\n\tconst { lineNum } = first;\n\tconst anchorLine = first.cursor.anchor.line;\n\tconst insertIndices: number[] = [];\n\tconst payload: string[] = [];\n\tlet i = start;\n\tfor (; i < edits.length; i++) {\n\t\tconst edit = edits[i];\n\t\tif (edit.kind !== \"insert\" || edit.mode !== \"replacement\" || edit.lineNum !== lineNum) break;\n\t\tif (edit.cursor.kind !== \"before_anchor\" || edit.cursor.anchor.line !== anchorLine) break;\n\t\tinsertIndices.push(i);\n\t\tpayload.push(edit.text);\n\t}\n\tconst deleteIndices: number[] = [];\n\tlet expectedLine = anchorLine;\n\tfor (; i < edits.length; i++) {\n\t\tconst edit = edits[i];\n\t\tif (edit.kind !== \"delete\" || edit.lineNum !== lineNum || edit.anchor.line !== expectedLine) break;\n\t\tdeleteIndices.push(i);\n\t\texpectedLine++;\n\t}\n\tif (deleteIndices.length === 0) return undefined;\n\treturn {\n\t\tinsertIndices,\n\t\tdeleteIndices,\n\t\tpayload,\n\t\tstartLine: anchorLine,\n\t\tendLine: anchorLine + deleteIndices.length - 1,\n\t};\n}\n\n/**\n * Largest `k` such that the payload's last `k` lines exactly equal the `k`\n * surviving file lines just below the range AND dropping them zeroes `delta`.\n * Requires a non-zero `delta`: a zero-balance candidate can never account for\n * the imbalance, so intentional duplicates of ordinary statements stay intact,\n * while duplicated structural lines (closers like `});`, openers like `foo(`)\n * are dropped when they exactly explain the imbalance.\n */\nfunction findDuplicateSuffix(group: ReplacementGroup, fileLines: readonly string[], delta: DelimiterBalance): number {\n\tif (balanceIsZero(delta)) return 0;\n\tconst { payload, endLine } = group;\n\tconst maxK = Math.min(payload.length, fileLines.length - endLine);\n\tfor (let k = maxK; k >= 1; k--) {\n\t\tlet matches = true;\n\t\tfor (let t = 0; t < k; t++) {\n\t\t\tif (payload[payload.length - k + t] !== fileLines[endLine + t]) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!matches) continue;\n\t\tif (balanceEqual(computeDelimiterBalance(payload.slice(payload.length - k)), delta)) return k;\n\t}\n\treturn 0;\n}\n\n/**\n * Largest `j` such that the payload's first `j` lines exactly equal the `j`\n * surviving file lines just above the range AND dropping them zeroes `delta`.\n * Requires a non-zero `delta`; see {@link findDuplicateSuffix}.\n */\nfunction findDuplicatePrefix(group: ReplacementGroup, fileLines: readonly string[], delta: DelimiterBalance): number {\n\tif (balanceIsZero(delta)) return 0;\n\tconst { payload, startLine } = group;\n\tconst maxJ = Math.min(payload.length, startLine - 1);\n\tfor (let j = maxJ; j >= 1; j--) {\n\t\tlet matches = true;\n\t\tfor (let t = 0; t < j; t++) {\n\t\t\tif (payload[t] !== fileLines[startLine - 1 - j + t]) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!matches) continue;\n\t\tif (balanceEqual(computeDelimiterBalance(payload.slice(0, j)), delta)) return j;\n\t}\n\treturn 0;\n}\n\n/**\n * Smallest `m` such that the range's last `m` deleted lines are all pure\n * structural closers and sparing them (keeping instead of deleting) zeroes\n * `delta`. The mirror mistake: a range that swallows a closing delimiter the\n * payload never restates.\n */\nfunction findDroppedSuffixClosers(\n\tgroup: ReplacementGroup,\n\tfileLines: readonly string[],\n\tdelta: DelimiterBalance,\n): number {\n\tconst wanted = balanceNegate(delta);\n\tconst maxM = group.deleteIndices.length;\n\tfor (let m = 1; m <= maxM; m++) {\n\t\tif (!STRUCTURAL_CLOSER_RE.test(fileLines[group.endLine - m] ?? \"\")) break;\n\t\tif (balanceEqual(computeDelimiterBalance(fileLines.slice(group.endLine - m, group.endLine)), wanted)) return m;\n\t}\n\treturn 0;\n}\n\ninterface BoundaryEcho {\n\tleading: number;\n\ttrailing: number;\n}\n\nfunction hasNonWhitespace(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst code = text.charCodeAt(i);\n\t\tif (code !== 9 && code !== 10 && code !== 11 && code !== 12 && code !== 13 && code !== 32) return true;\n\t}\n\treturn false;\n}\n\nfunction countDuplicateLeadingBoundaryLines(group: ReplacementGroup, fileLines: readonly string[]): number {\n\tconst { payload, startLine } = group;\n\tconst max = Math.min(payload.length, startLine - 1);\n\tfor (let count = max; count >= 1; count--) {\n\t\tlet matches = true;\n\t\tlet hasContent = false;\n\t\tfor (let offset = 0; offset < count; offset++) {\n\t\t\tconst line = payload[offset];\n\t\t\tif (line !== fileLines[startLine - 1 - count + offset]) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\thasContent ||= hasNonWhitespace(line);\n\t\t}\n\t\tif (matches && hasContent) return count;\n\t}\n\treturn 0;\n}\n\nfunction countDuplicateTrailingBoundaryLines(group: ReplacementGroup, fileLines: readonly string[]): number {\n\tconst { payload, endLine } = group;\n\tconst max = Math.min(payload.length, fileLines.length - endLine);\n\tfor (let count = max; count >= 1; count--) {\n\t\tlet matches = true;\n\t\tlet hasContent = false;\n\t\tfor (let offset = 0; offset < count; offset++) {\n\t\t\tconst line = payload[payload.length - count + offset];\n\t\t\tif (line !== fileLines[endLine + offset]) {\n\t\t\t\tmatches = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\thasContent ||= hasNonWhitespace(line);\n\t\t}\n\t\tif (matches && hasContent) return count;\n\t}\n\treturn 0;\n}\n\nfunction findBoundaryEcho(group: ReplacementGroup, fileLines: readonly string[]): BoundaryEcho | undefined {\n\tconst leadingMax = countDuplicateLeadingBoundaryLines(group, fileLines);\n\tif (leadingMax === 0) return undefined;\n\tconst trailingMax = countDuplicateTrailingBoundaryLines(group, fileLines);\n\tif (trailingMax === 0) return undefined;\n\t// Bail when every payload line could be claimed by a boundary echo: any\n\t// repair would strip explicit replacement content with no signal that the\n\t// payload was a mistake rather than an intentional duplication.\n\tif (leadingMax + trailingMax >= group.payload.length) return undefined;\n\t// Balance-neutrality guard (see header comment): the dropped echo lines must\n\t// either be delimiter-neutral on their own or exactly cancel the payload/range\n\t// balance delta. In brace-heavy code where bare closer lines repeat, an\n\t// \"echo\" that shifts delimiter balance is structural content the payload\n\t// placed intentionally — stripping it would corrupt the result.\n\tconst leadingBalance = computeDelimiterBalance(group.payload.slice(0, leadingMax));\n\tconst trailingBalance = computeDelimiterBalance(group.payload.slice(group.payload.length - trailingMax));\n\tconst droppedBalance = balanceDelta(leadingBalance, balanceNegate(trailingBalance));\n\tif (!balanceIsZero(droppedBalance)) {\n\t\tconst delta = balanceDelta(\n\t\t\tcomputeDelimiterBalance(group.payload),\n\t\t\tcomputeDelimiterBalance(fileLines.slice(group.startLine - 1, group.endLine)),\n\t\t);\n\t\tif (!balanceEqual(droppedBalance, delta)) return undefined;\n\t}\n\treturn { leading: leadingMax, trailing: trailingMax };\n}\n\nfunction describeBoundaryEchoRepair(group: ReplacementGroup, echo: BoundaryEcho): string {\n\treturn (\n\t\t`Auto-repaired a replacement boundary echo at line ${group.startLine}: ` +\n\t\t`dropped ${echo.leading} leading and ${echo.trailing} trailing payload line(s) already present outside the range. ` +\n\t\t`Issue the payload as the final desired content for the selected range only — never restate unchanged lines bordering the range.`\n\t);\n}\n\nfunction describeBoundaryRepair(group: ReplacementGroup, action: string): string {\n\treturn (\n\t\t`Auto-repaired a delimiter-balance mismatch in the replacement at line ${group.startLine}: ${action}. ` +\n\t\t`Issue the payload as the final desired content only — never restate or omit a closing bracket bordering the range.`\n\t);\n}\n\n/**\n * Normalize replacement groups so common off-by-one boundaries do not duplicate\n * unchanged surrounding lines or structural closers. Returns the repaired edit\n * list plus one warning per repaired group.\n */\nfunction repairReplacementBoundaries(\n\tedits: readonly AppliedEdit[],\n\tfileLines: readonly string[],\n): {\n\tedits: AppliedEdit[];\n\twarnings: string[];\n} {\n\tconst out: AppliedEdit[] = [];\n\tconst warnings: string[] = [];\n\tlet i = 0;\n\twhile (i < edits.length) {\n\t\tconst group = findReplacementGroup(edits, i);\n\t\tif (!group) {\n\t\t\tout.push(edits[i]);\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst inserts = group.insertIndices.map(idx => edits[idx]);\n\t\tconst deletes = group.deleteIndices.map(idx => edits[idx]);\n\t\ti = group.deleteIndices[group.deleteIndices.length - 1] + 1;\n\n\t\tconst boundaryEcho = findBoundaryEcho(group, fileLines);\n\t\tif (boundaryEcho) {\n\t\t\twarnings.push(describeBoundaryEchoRepair(group, boundaryEcho));\n\t\t\tout.push(...inserts.slice(boundaryEcho.leading, inserts.length - boundaryEcho.trailing), ...deletes);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst delta = balanceDelta(\n\t\t\tcomputeDelimiterBalance(group.payload),\n\t\t\tcomputeDelimiterBalance(fileLines.slice(group.startLine - 1, group.endLine)),\n\t\t);\n\t\tif (balanceIsZero(delta)) {\n\t\t\tout.push(...inserts, ...deletes);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst dupSuffix = findDuplicateSuffix(group, fileLines, delta);\n\t\tif (dupSuffix > 0) {\n\t\t\twarnings.push(\n\t\t\t\tdescribeBoundaryRepair(\n\t\t\t\t\tgroup,\n\t\t\t\t\t`dropped ${dupSuffix} duplicated trailing payload line(s) already present below the range`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tout.push(...inserts.slice(0, inserts.length - dupSuffix), ...deletes);\n\t\t\tcontinue;\n\t\t}\n\t\tconst dupPrefix = findDuplicatePrefix(group, fileLines, delta);\n\t\tif (dupPrefix > 0) {\n\t\t\twarnings.push(\n\t\t\t\tdescribeBoundaryRepair(\n\t\t\t\t\tgroup,\n\t\t\t\t\t`dropped ${dupPrefix} duplicated leading payload line(s) already present above the range`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tout.push(...inserts.slice(dupPrefix), ...deletes);\n\t\t\tcontinue;\n\t\t}\n\t\tconst droppedClosers = findDroppedSuffixClosers(group, fileLines, delta);\n\t\tif (droppedClosers > 0) {\n\t\t\twarnings.push(\n\t\t\t\tdescribeBoundaryRepair(\n\t\t\t\t\tgroup,\n\t\t\t\t\t`kept ${droppedClosers} structural closing line(s) the range deleted without restating`,\n\t\t\t\t),\n\t\t\t);\n\t\t\tout.push(...inserts, ...deletes.slice(0, deletes.length - droppedClosers));\n\t\t\tcontinue;\n\t\t}\n\t\tout.push(...inserts, ...deletes);\n\t}\n\treturn { edits: out, warnings };\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// After-insert landing correction\n//\n// The body rows of an `insert after N:` hunk carry an implicit depth claim:\n// their leading indentation says how deep the author expects the new lines\n// to sit. Two corrections share that claim, in opposite directions:\n//\n// Outward (any after-insert): when the depth is shallower than line N itself,\n// the hunk is inserting a sibling of some enclosing construct while anchored\n// inside it — the common shape is anchoring on the last statement of a block\n// and writing the body at the parent's depth. Sliding the landing point\n// forward across the structural closer lines that follow (and nothing else —\n// content lines are never crossed) places the body at the depth its\n// indentation names.\n//\n// Inward (block-lowered inserts only): `insert after block N:` anchors on the\n// resolved block's closing line, but a body indented deeper than that closer\n// claims a depth inside the block — the common misreading of the op as\n// \"append at the end of block N's body\". Sliding the landing point backward\n// across the block's trailing closer lines places the body inside, at its\n// claimed depth. Scoped to block-lowered inserts because there the author\n// named the opener and never saw the closer; a plain `insert after M:` on a\n// closer line stays literal (the escape hatch for genuinely-after content\n// such as method-chain continuations).\n//\n// Both shifts are deliberately conservative: they fire only when the body\n// and anchor indentation are comparable (one is a prefix of the other),\n// cross only pure closing-delimiter lines, stop as soon as depth matches the\n// body's claim, and are abandoned when any other edit in the patch targets a\n// crossed line. Every shift is reported as a warning so the author can\n// re-issue when the original landing was intended.\n\n/** Leading run of tabs and spaces. */\nfunction leadingIndent(line: string): string {\n\tlet end = 0;\n\twhile (end < line.length) {\n\t\tconst code = line.charCodeAt(end);\n\t\tif (code !== 9 && code !== 32) break;\n\t\tend++;\n\t}\n\treturn line.slice(0, end);\n}\n\n/** `deeper` strictly extends `shallower` (same indent style, more depth). */\nfunction isIndentDeeper(deeper: string, shallower: string): boolean {\n\treturn deeper.length > shallower.length && deeper.startsWith(shallower);\n}\n\ninterface AfterInsertGroup {\n\t/** Anchor line shared by every insert row of the hunk. */\n\tanchor: number;\n\t/** Indices into the edit list, in patch order. */\n\tmembers: number[];\n\t/** First line of the resolved block when lowered from `insert after block N:`. */\n\tblockStart?: number;\n}\n\n/**\n * Depth of an after-insert hunk's body: the shallowest indentation across its\n * non-blank rows. Returns `undefined` when no depth claim can be made — an\n * all-blank or all-closer body, or rows whose indentation styles are not\n * mutually comparable (tabs vs spaces).\n */\nfunction bodyTargetIndent(rows: readonly string[]): string | undefined {\n\tconst nonBlank = rows.filter(hasNonWhitespace);\n\tif (nonBlank.length === 0) return undefined;\n\t// A body of pure closers re-balances delimiters; it claims no depth.\n\tif (nonBlank.every(row => STRUCTURAL_CLOSER_RE.test(row))) return undefined;\n\tlet target = leadingIndent(nonBlank[0] ?? \"\");\n\tfor (const row of nonBlank) {\n\t\tconst indent = leadingIndent(row);\n\t\tif (indent.startsWith(target)) continue;\n\t\tif (target.startsWith(indent)) target = indent;\n\t\telse return undefined;\n\t}\n\treturn target;\n}\n\n/**\n * Resolve where an after-insert hunk anchored on `group.anchor` should land\n * given its body depth `target`: the last structural closer line in the run\n * directly below the anchor whose indentation still covers `target`. Returns\n * `undefined` when the landing stays put.\n */\nfunction resolveShiftedLanding(\n\tgroup: AfterInsertGroup,\n\ttarget: string,\n\tfileLines: readonly string[],\n\ttargetedLines: ReadonlySet<number>,\n): { line: number; crossed: number } | undefined {\n\tconst anchorText = fileLines[group.anchor - 1];\n\tif (anchorText === undefined || !hasNonWhitespace(anchorText)) return undefined;\n\tif (!isIndentDeeper(leadingIndent(anchorText), target)) return undefined;\n\n\tlet landing = group.anchor;\n\tlet crossed = 0;\n\tfor (let line = group.anchor + 1; line <= fileLines.length; line++) {\n\t\tconst text = fileLines[line - 1] ?? \"\";\n\t\tif (!hasNonWhitespace(text)) continue; // look past blanks, never land on them\n\t\tif (!STRUCTURAL_CLOSER_RE.test(text)) break; // content is never crossed\n\t\tconst indent = leadingIndent(text);\n\t\tif (!indent.startsWith(target)) break; // shallower than the body — crossing would over-escape\n\t\tif (targetedLines.has(line)) return undefined; // another hunk owns this closer\n\t\tlanding = line;\n\t\tcrossed++;\n\t\tif (indent.length === target.length) break; // depth returned to the body's level\n\t}\n\treturn landing === group.anchor ? undefined : { line: landing, crossed };\n}\n\n/**\n * Resolve where a block-lowered after-insert anchored on the block's closing\n * line should land given a body depth `target` deeper than that closer: just\n * above the block's trailing run of closer lines, bounded below by\n * `blockStart` (an empty block lands the body right after its opener).\n * Returns `undefined` when the landing stays put.\n */\nfunction resolveInwardLanding(\n\tgroup: AfterInsertGroup,\n\ttarget: string,\n\tblockStart: number,\n\tfileLines: readonly string[],\n\ttargetedLines: ReadonlySet<number>,\n): number | undefined {\n\tconst anchorText = fileLines[group.anchor - 1];\n\tif (anchorText === undefined || !hasNonWhitespace(anchorText)) return undefined;\n\t// Fires only when the block ends in a pure closer the body out-indents.\n\t// Blocks ending in content (indentation-only languages) already land the\n\t// body inside the block — nothing to correct.\n\tif (!STRUCTURAL_CLOSER_RE.test(anchorText)) return undefined;\n\tif (!isIndentDeeper(target, leadingIndent(anchorText))) return undefined;\n\n\tlet landing = group.anchor;\n\tfor (let line = group.anchor; line > blockStart; line--) {\n\t\tconst text = fileLines[line - 1] ?? \"\";\n\t\tif (!hasNonWhitespace(text)) {\n\t\t\tlanding = line - 1; // look past trailing blanks, never land after one\n\t\t\tcontinue;\n\t\t}\n\t\tif (!STRUCTURAL_CLOSER_RE.test(text)) break; // content reached — land right after it\n\t\tconst indent = leadingIndent(text);\n\t\tif (!isIndentDeeper(target, indent)) break; // closer at the body's depth — land after it\n\t\t// Another hunk owns this closer (the group's own rows put the anchor\n\t\t// itself in `targetedLines`; that one is ours to cross).\n\t\tif (line !== group.anchor && targetedLines.has(line)) return undefined;\n\t\tlanding = line - 1;\n\t}\n\treturn landing === group.anchor ? undefined : landing;\n}\n\n/**\n * Slide mis-anchored after-insert hunks to the depth their body indentation\n * claims: outward past the structural closer lines that follow the anchor\n * when the body is shallower, or — for `insert after block N:` lowerings —\n * inward across the block's trailing closers when the body is deeper than\n * the block's closing line. Returns the corrected edit list plus one warning\n * per shifted hunk.\n */\nfunction repairAfterInsertLandings(\n\tedits: readonly AppliedEdit[],\n\tfileLines: readonly string[],\n): { edits: readonly AppliedEdit[]; warnings: string[] } {\n\t// Group plain (non-replacement) after-anchor inserts per authored hunk:\n\t// rows of one hunk share the anchor line and the patch header line.\n\tconst groups = new Map<string, AfterInsertGroup>();\n\tedits.forEach((edit, idx) => {\n\t\tif (edit.kind !== \"insert\" || edit.mode === \"replacement\") return;\n\t\tif (edit.cursor.kind !== \"after_anchor\") return;\n\t\tconst key = `${edit.cursor.anchor.line}:${edit.lineNum}`;\n\t\tconst group = groups.get(key);\n\t\tif (group === undefined)\n\t\t\tgroups.set(key, { anchor: edit.cursor.anchor.line, members: [idx], blockStart: edit.blockStart });\n\t\telse group.members.push(idx);\n\t});\n\tif (groups.size === 0) return { edits, warnings: [] };\n\n\t// Lines explicitly targeted by any edit; a shift never crosses them.\n\tconst targetedLines = new Set<number>();\n\tfor (const edit of edits) {\n\t\tif (edit.kind === \"delete\") targetedLines.add(edit.anchor.line);\n\t\telse if (edit.cursor.kind === \"before_anchor\" || edit.cursor.kind === \"after_anchor\")\n\t\t\ttargetedLines.add(edit.cursor.anchor.line);\n\t}\n\n\tlet out: AppliedEdit[] | undefined;\n\tconst warnings: string[] = [];\n\tconst retarget = (group: AfterInsertGroup, line: number): void => {\n\t\tout ??= [...edits];\n\t\tfor (const idx of group.members) {\n\t\t\tconst edit = out[idx] as InsertEdit;\n\t\t\tout[idx] = { ...edit, cursor: { kind: \"after_anchor\", anchor: { line } } };\n\t\t}\n\t};\n\tfor (const group of groups.values()) {\n\t\tconst target = bodyTargetIndent(group.members.map(idx => (edits[idx] as InsertEdit).text));\n\t\tif (target === undefined) continue;\n\t\tconst outward = resolveShiftedLanding(group, target, fileLines, targetedLines);\n\t\tif (outward !== undefined) {\n\t\t\tretarget(group, outward.line);\n\t\t\twarnings.push(afterInsertLandingShiftWarning(group.anchor, outward.line, outward.crossed));\n\t\t\tcontinue;\n\t\t}\n\t\tif (group.blockStart === undefined) continue;\n\t\tconst inward = resolveInwardLanding(group, target, group.blockStart, fileLines, targetedLines);\n\t\tif (inward === undefined) continue;\n\t\tretarget(group, inward);\n\t\twarnings.push(blockInsertLandingShiftWarning(group.blockStart, group.anchor, inward));\n\t}\n\treturn { edits: out ?? edits, warnings };\n}\n\n/**\n * Apply a parsed list of edits to a text body. Pure function — no I/O.\n *\n * Returns the post-edit text and the first changed line number (1-indexed).\n * Throws if an anchor is out of bounds.\n */\nexport function applyEdits(text: string, edits: readonly Edit[]): ApplyResult {\n\tif (edits.length === 0) return { text, firstChangedLine: undefined };\n\n\t// Block edits are deferred until `resolveBlockEdits` expands them into\n\t// concrete inserts + deletes. Reaching the applier with one still present\n\t// is an internal wiring bug, not authored-input error.\n\tfor (const edit of edits) {\n\t\tif (edit.kind === \"block\") throw new Error(UNRESOLVED_BLOCK_INTERNAL);\n\t}\n\tconst appliedEdits = edits as readonly AppliedEdit[];\n\n\tconst fileLines = text.split(\"\\n\");\n\tconst lineOrigins: LineOrigin[] = fileLines.map(() => \"original\");\n\n\tlet firstChangedLine: number | undefined;\n\tconst trackFirstChanged = (line: number) => {\n\t\tif (firstChangedLine === undefined || line < firstChangedLine) firstChangedLine = line;\n\t};\n\n\tconst targetEdits = dropTrailingPhantomDeletes(\n\t\tappliedEdits.map((edit, index) => cloneAppliedEdit(edit, index)),\n\t\tfileLines,\n\t);\n\tvalidateLineBounds(targetEdits, fileLines);\n\tconst { edits: repaired, warnings: boundaryWarnings } = repairReplacementBoundaries(targetEdits, fileLines);\n\tconst { edits: landed, warnings: landingWarnings } = repairAfterInsertLandings(repaired, fileLines);\n\tconst warnings = [...boundaryWarnings, ...landingWarnings];\n\n\t// Partition edits into bof, eof, and anchor-targeted buckets.\n\tconst bofLines: string[] = [];\n\tconst eofLines: string[] = [];\n\tconst anchorEdits: IndexedEdit[] = [];\n\tlanded.forEach((edit, idx) => {\n\t\tif (edit.kind === \"insert\" && edit.cursor.kind === \"bof\") {\n\t\t\tbofLines.push(edit.text);\n\t\t} else if (edit.kind === \"insert\" && edit.cursor.kind === \"eof\") {\n\t\t\teofLines.push(edit.text);\n\t\t} else {\n\t\t\tanchorEdits.push({ edit, idx });\n\t\t}\n\t});\n\n\t// Apply per-line buckets bottom-up so earlier indices stay valid.\n\tconst byLine = bucketAnchorEditsByLine(anchorEdits);\n\tfor (const line of [...byLine.keys()].sort((a, b) => b - a)) {\n\t\tconst bucket = byLine.get(line);\n\t\tif (!bucket) continue;\n\t\tbucket.sort((a, b) => a.idx - b.idx);\n\n\t\tconst idx = line - 1;\n\t\tconst currentLine = fileLines[idx] ?? \"\";\n\t\tconst beforeInsertLines: string[] = [];\n\t\tconst afterInsertLines: string[] = [];\n\t\tconst replacementLines: string[] = [];\n\t\tlet deleteLine = false;\n\n\t\tfor (const { edit } of bucket) {\n\t\t\tif (isReplacementInsert(edit)) {\n\t\t\t\treplacementLines.push(edit.text);\n\t\t\t} else if (edit.kind === \"insert\" && edit.cursor.kind === \"after_anchor\") {\n\t\t\t\tafterInsertLines.push(edit.text);\n\t\t\t} else if (edit.kind === \"insert\") {\n\t\t\t\tbeforeInsertLines.push(edit.text);\n\t\t\t} else if (edit.kind === \"delete\") {\n\t\t\t\tdeleteLine = true;\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tbeforeInsertLines.length === 0 &&\n\t\t\treplacementLines.length === 0 &&\n\t\t\tafterInsertLines.length === 0 &&\n\t\t\t!deleteLine\n\t\t)\n\t\t\tcontinue;\n\n\t\tconst replacement = deleteLine\n\t\t\t? [...beforeInsertLines, ...replacementLines, ...afterInsertLines]\n\t\t\t: [...beforeInsertLines, ...replacementLines, currentLine, ...afterInsertLines];\n\t\tconst origins: LineOrigin[] = [];\n\t\tfor (let i = 0; i < beforeInsertLines.length; i++) origins.push(\"insert\");\n\t\tfor (let i = 0; i < replacementLines.length; i++) origins.push(deleteLine ? \"replacement\" : \"insert\");\n\t\tif (!deleteLine) origins.push(lineOrigins[idx] ?? \"original\");\n\t\tfor (let i = 0; i < afterInsertLines.length; i++) origins.push(\"insert\");\n\n\t\tfileLines.splice(idx, 1, ...replacement);\n\t\tlineOrigins.splice(idx, 1, ...origins);\n\t\ttrackFirstChanged(line);\n\t}\n\n\tif (bofLines.length > 0) {\n\t\tinsertAtStart(fileLines, lineOrigins, bofLines);\n\t\ttrackFirstChanged(1);\n\t}\n\tconst eofChangedLine = insertAtEnd(fileLines, lineOrigins, eofLines);\n\tif (eofChangedLine !== undefined) trackFirstChanged(eofChangedLine);\n\n\treturn {\n\t\ttext: fileLines.join(\"\\n\"),\n\t\tfirstChangedLine,\n\t\t...(warnings.length > 0 ? { warnings } : {}),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BlockResolution, BlockResolver, Edit } from "./types.js";
|
|
2
|
+
export interface ResolveBlockEditsOptions {
|
|
3
|
+
/**
|
|
4
|
+
* How to handle a replace/delete block edit that cannot be resolved
|
|
5
|
+
* (missing resolver or a `null` span). `"throw"` (default) raises a
|
|
6
|
+
* `blockUnresolvedMessage` error — used by the authoritative apply + final
|
|
7
|
+
* preview paths. `"drop"` silently skips the edit — used by the streaming
|
|
8
|
+
* preview, where a half-written file or transient parse error must not
|
|
9
|
+
* throw. Unresolvable `insert after block N:` edits never reach this: they
|
|
10
|
+
* are lowered to plain `insert after N:` with a warning.
|
|
11
|
+
*/
|
|
12
|
+
onUnresolved?: "throw" | "drop";
|
|
13
|
+
/**
|
|
14
|
+
* Invoked once per successfully resolved block edit, in patch order, with
|
|
15
|
+
* the anchor line and the concrete span it resolved to. Lets the host echo
|
|
16
|
+
* the resolution back to the caller. Never fired for dropped/unresolvable
|
|
17
|
+
* edits.
|
|
18
|
+
*/
|
|
19
|
+
onResolved?: (resolution: BlockResolution) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Invoked once per diagnostic produced while resolving — currently the
|
|
22
|
+
* `insert after block N:` lowerings (closer anchor or unresolvable block).
|
|
23
|
+
* Hosts should surface these on the apply result's `warnings`.
|
|
24
|
+
*/
|
|
25
|
+
onWarning?: (message: string) => void;
|
|
26
|
+
}
|
|
27
|
+
/** True when at least one edit is an unresolved deferred block edit. */
|
|
28
|
+
export declare function hasBlockEdit(edits: readonly Edit[]): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve every deferred block edit in `edits` against `text` (parsed as the
|
|
31
|
+
* language inferred from `path`). Non-block edits pass through untouched.
|
|
32
|
+
* Returns a fresh edit list with no `block` variants. The fast path returns the
|
|
33
|
+
* input unchanged when there is nothing to resolve.
|
|
34
|
+
*
|
|
35
|
+
* Synthesized inserts/deletes carry sequential `index` values for readability
|
|
36
|
+
* only — {@link applyEdits} re-derives every edit's index from array order, so
|
|
37
|
+
* the passthrough edits keeping their original indices is harmless.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveBlockEdits(edits: readonly Edit[], text: string, path: string, resolver: BlockResolver | undefined, options?: ResolveBlockEditsOptions): readonly Edit[];
|
|
40
|
+
//# sourceMappingURL=block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/block.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAU,IAAI,EAAE,MAAM,YAAY,CAAC;AAE/E,MAAM,WAAW,wBAAwB;IACxC;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,OAAO,CAE5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,GAAG,SAAS,EACnC,OAAO,GAAE,wBAA6B,GACpC,SAAS,IAAI,EAAE,CAuFjB","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Expand deferred block edits (`replace block N:` / `delete block N` /\n * `insert after block N:`) into concrete inserts + deletes.\n *\n * The hashline parser cannot expand a block edit on its own — the line span is\n * unknown until file text + path (→ language) are available. This transform\n * runs at every apply/preview boundary that has text: it calls the injected\n * {@link BlockResolver} to resolve each block's `[start, end]` span, then emits\n * the exact same edits the concrete form produces in the parser: `replace\n * start..end:` inserts + deletes for a replace, a pure range delete for a\n * delete, and plain `after_anchor` inserts at `end` for an insert-after. After\n * it runs, no `block` edits remain, so {@link applyEdits} (and recovery) only\n * ever see resolved edits.\n */\nimport { STRUCTURAL_CLOSER_RE } from \"./apply.js\";\nimport {\n\tBLOCK_RESOLVER_UNAVAILABLE,\n\tblockUnresolvedMessage,\n\tinsertAfterBlockCloserLoweredWarning,\n\tinsertAfterBlockUnresolvedLoweredWarning,\n} from \"./messages.js\";\nimport type { BlockResolution, BlockResolver, Cursor, Edit } from \"./types.js\";\n\nexport interface ResolveBlockEditsOptions {\n\t/**\n\t * How to handle a replace/delete block edit that cannot be resolved\n\t * (missing resolver or a `null` span). `\"throw\"` (default) raises a\n\t * `blockUnresolvedMessage` error — used by the authoritative apply + final\n\t * preview paths. `\"drop\"` silently skips the edit — used by the streaming\n\t * preview, where a half-written file or transient parse error must not\n\t * throw. Unresolvable `insert after block N:` edits never reach this: they\n\t * are lowered to plain `insert after N:` with a warning.\n\t */\n\tonUnresolved?: \"throw\" | \"drop\";\n\t/**\n\t * Invoked once per successfully resolved block edit, in patch order, with\n\t * the anchor line and the concrete span it resolved to. Lets the host echo\n\t * the resolution back to the caller. Never fired for dropped/unresolvable\n\t * edits.\n\t */\n\tonResolved?: (resolution: BlockResolution) => void;\n\t/**\n\t * Invoked once per diagnostic produced while resolving — currently the\n\t * `insert after block N:` lowerings (closer anchor or unresolvable block).\n\t * Hosts should surface these on the apply result's `warnings`.\n\t */\n\tonWarning?: (message: string) => void;\n}\n\n/** True when at least one edit is an unresolved deferred block edit. */\nexport function hasBlockEdit(edits: readonly Edit[]): boolean {\n\treturn edits.some(edit => edit.kind === \"block\");\n}\n\n/**\n * Resolve every deferred block edit in `edits` against `text` (parsed as the\n * language inferred from `path`). Non-block edits pass through untouched.\n * Returns a fresh edit list with no `block` variants. The fast path returns the\n * input unchanged when there is nothing to resolve.\n *\n * Synthesized inserts/deletes carry sequential `index` values for readability\n * only — {@link applyEdits} re-derives every edit's index from array order, so\n * the passthrough edits keeping their original indices is harmless.\n */\nexport function resolveBlockEdits(\n\tedits: readonly Edit[],\n\ttext: string,\n\tpath: string,\n\tresolver: BlockResolver | undefined,\n\toptions: ResolveBlockEditsOptions = {},\n): readonly Edit[] {\n\tif (!hasBlockEdit(edits)) return edits;\n\tconst onUnresolved = options.onUnresolved ?? \"throw\";\n\tconst resolved: Edit[] = [];\n\tlet synthIndex = 0;\n\tfor (const edit of edits) {\n\t\tif (edit.kind !== \"block\") {\n\t\t\tresolved.push(edit);\n\t\t\tcontinue;\n\t\t}\n\t\tconst op = edit.mode === \"insert_after\" ? \"insert_after\" : edit.payloads.length === 0 ? \"delete\" : \"replace\";\n\t\tconst span = resolver ? resolver({ path, text, line: edit.anchor.line }) : null;\n\t\tif (span === null) {\n\t\t\t// `insert after block N:` never fails the patch — lower it to plain\n\t\t\t// `insert after N:` with a warning instead. Two flavors:\n\t\t\t// - anchored on a pure closing-delimiter line: no block begins\n\t\t\t// there, but line N IS the end of one, and \"after the end of the\n\t\t\t// block\" is exactly the plain form — warn with the opener rule.\n\t\t\t// - otherwise (unsupported language, blank line, unparsable block,\n\t\t\t// or no resolver wired): \"after the block at N\" degrades to\n\t\t\t// \"after line N\" — warn to verify the landing line.\n\t\t\tif (op === \"insert_after\") {\n\t\t\t\tconst anchorText = text.split(\"\\n\")[edit.anchor.line - 1];\n\t\t\t\tconst isCloser = anchorText !== undefined && STRUCTURAL_CLOSER_RE.test(anchorText);\n\t\t\t\toptions.onWarning?.(\n\t\t\t\t\tisCloser\n\t\t\t\t\t\t? insertAfterBlockCloserLoweredWarning(edit.anchor.line)\n\t\t\t\t\t\t: insertAfterBlockUnresolvedLoweredWarning(edit.anchor.line),\n\t\t\t\t);\n\t\t\t\tfor (const payload of edit.payloads) {\n\t\t\t\t\tconst cursor: Cursor = { kind: \"after_anchor\", anchor: { line: edit.anchor.line } };\n\t\t\t\t\tresolved.push({ kind: \"insert\", cursor, text: payload, lineNum: edit.lineNum, index: synthIndex++ });\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (onUnresolved === \"drop\") continue;\n\t\t\tthrow new Error(\n\t\t\t\t`line ${edit.lineNum}: ${\n\t\t\t\t\tresolver ? blockUnresolvedMessage(edit.anchor.line, op, text.split(\"\\n\")) : BLOCK_RESOLVER_UNAVAILABLE\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t\toptions.onResolved?.({\n\t\t\tanchorLine: edit.anchor.line,\n\t\t\tstart: span.start,\n\t\t\tend: span.end,\n\t\t\top,\n\t\t});\n\t\tif (op === \"insert_after\") {\n\t\t\t// Mirror the parser's `insert after N:` lowering: one `after_anchor`\n\t\t\t// insert per payload row, anchored on the block's last line. The\n\t\t\t// `blockStart` tag lets the applier's landing correction slide a\n\t\t\t// body that claims a depth inside the block back across the block's\n\t\t\t// trailing closer lines.\n\t\t\tfor (const payload of edit.payloads) {\n\t\t\t\tconst cursor: Cursor = { kind: \"after_anchor\", anchor: { line: span.end } };\n\t\t\t\tresolved.push({\n\t\t\t\t\tkind: \"insert\",\n\t\t\t\t\tcursor,\n\t\t\t\t\ttext: payload,\n\t\t\t\t\tlineNum: edit.lineNum,\n\t\t\t\t\tindex: synthIndex++,\n\t\t\t\t\tblockStart: span.start,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Mirror the parser's `replace start..end:` expansion exactly: one\n\t\t// `before_anchor` replacement insert per payload row at `span.start`,\n\t\t// then one delete per line across `[span.start, span.end]`. An empty\n\t\t// `payloads` (from `delete block N`) emits no inserts — a pure deletion.\n\t\tfor (const payload of edit.payloads) {\n\t\t\tconst cursor: Cursor = { kind: \"before_anchor\", anchor: { line: span.start } };\n\t\t\tresolved.push({\n\t\t\t\tkind: \"insert\",\n\t\t\t\tcursor,\n\t\t\t\ttext: payload,\n\t\t\t\tlineNum: edit.lineNum,\n\t\t\t\tindex: synthIndex++,\n\t\t\t\tmode: \"replacement\",\n\t\t\t});\n\t\t}\n\t\tfor (let line = span.start; line <= span.end; line++) {\n\t\t\tresolved.push({ kind: \"delete\", anchor: { line }, lineNum: edit.lineNum, index: synthIndex++ });\n\t\t}\n\t}\n\treturn resolved;\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.
|
|
2
|
+
// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).
|
|
3
|
+
/**
|
|
4
|
+
* Expand deferred block edits (`replace block N:` / `delete block N` /
|
|
5
|
+
* `insert after block N:`) into concrete inserts + deletes.
|
|
6
|
+
*
|
|
7
|
+
* The hashline parser cannot expand a block edit on its own — the line span is
|
|
8
|
+
* unknown until file text + path (→ language) are available. This transform
|
|
9
|
+
* runs at every apply/preview boundary that has text: it calls the injected
|
|
10
|
+
* {@link BlockResolver} to resolve each block's `[start, end]` span, then emits
|
|
11
|
+
* the exact same edits the concrete form produces in the parser: `replace
|
|
12
|
+
* start..end:` inserts + deletes for a replace, a pure range delete for a
|
|
13
|
+
* delete, and plain `after_anchor` inserts at `end` for an insert-after. After
|
|
14
|
+
* it runs, no `block` edits remain, so {@link applyEdits} (and recovery) only
|
|
15
|
+
* ever see resolved edits.
|
|
16
|
+
*/
|
|
17
|
+
import { STRUCTURAL_CLOSER_RE } from "./apply.js";
|
|
18
|
+
import { BLOCK_RESOLVER_UNAVAILABLE, blockUnresolvedMessage, insertAfterBlockCloserLoweredWarning, insertAfterBlockUnresolvedLoweredWarning, } from "./messages.js";
|
|
19
|
+
/** True when at least one edit is an unresolved deferred block edit. */
|
|
20
|
+
export function hasBlockEdit(edits) {
|
|
21
|
+
return edits.some(edit => edit.kind === "block");
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolve every deferred block edit in `edits` against `text` (parsed as the
|
|
25
|
+
* language inferred from `path`). Non-block edits pass through untouched.
|
|
26
|
+
* Returns a fresh edit list with no `block` variants. The fast path returns the
|
|
27
|
+
* input unchanged when there is nothing to resolve.
|
|
28
|
+
*
|
|
29
|
+
* Synthesized inserts/deletes carry sequential `index` values for readability
|
|
30
|
+
* only — {@link applyEdits} re-derives every edit's index from array order, so
|
|
31
|
+
* the passthrough edits keeping their original indices is harmless.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveBlockEdits(edits, text, path, resolver, options = {}) {
|
|
34
|
+
if (!hasBlockEdit(edits))
|
|
35
|
+
return edits;
|
|
36
|
+
const onUnresolved = options.onUnresolved ?? "throw";
|
|
37
|
+
const resolved = [];
|
|
38
|
+
let synthIndex = 0;
|
|
39
|
+
for (const edit of edits) {
|
|
40
|
+
if (edit.kind !== "block") {
|
|
41
|
+
resolved.push(edit);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const op = edit.mode === "insert_after" ? "insert_after" : edit.payloads.length === 0 ? "delete" : "replace";
|
|
45
|
+
const span = resolver ? resolver({ path, text, line: edit.anchor.line }) : null;
|
|
46
|
+
if (span === null) {
|
|
47
|
+
// `insert after block N:` never fails the patch — lower it to plain
|
|
48
|
+
// `insert after N:` with a warning instead. Two flavors:
|
|
49
|
+
// - anchored on a pure closing-delimiter line: no block begins
|
|
50
|
+
// there, but line N IS the end of one, and "after the end of the
|
|
51
|
+
// block" is exactly the plain form — warn with the opener rule.
|
|
52
|
+
// - otherwise (unsupported language, blank line, unparsable block,
|
|
53
|
+
// or no resolver wired): "after the block at N" degrades to
|
|
54
|
+
// "after line N" — warn to verify the landing line.
|
|
55
|
+
if (op === "insert_after") {
|
|
56
|
+
const anchorText = text.split("\n")[edit.anchor.line - 1];
|
|
57
|
+
const isCloser = anchorText !== undefined && STRUCTURAL_CLOSER_RE.test(anchorText);
|
|
58
|
+
options.onWarning?.(isCloser
|
|
59
|
+
? insertAfterBlockCloserLoweredWarning(edit.anchor.line)
|
|
60
|
+
: insertAfterBlockUnresolvedLoweredWarning(edit.anchor.line));
|
|
61
|
+
for (const payload of edit.payloads) {
|
|
62
|
+
const cursor = { kind: "after_anchor", anchor: { line: edit.anchor.line } };
|
|
63
|
+
resolved.push({ kind: "insert", cursor, text: payload, lineNum: edit.lineNum, index: synthIndex++ });
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (onUnresolved === "drop")
|
|
68
|
+
continue;
|
|
69
|
+
throw new Error(`line ${edit.lineNum}: ${resolver ? blockUnresolvedMessage(edit.anchor.line, op, text.split("\n")) : BLOCK_RESOLVER_UNAVAILABLE}`);
|
|
70
|
+
}
|
|
71
|
+
options.onResolved?.({
|
|
72
|
+
anchorLine: edit.anchor.line,
|
|
73
|
+
start: span.start,
|
|
74
|
+
end: span.end,
|
|
75
|
+
op,
|
|
76
|
+
});
|
|
77
|
+
if (op === "insert_after") {
|
|
78
|
+
// Mirror the parser's `insert after N:` lowering: one `after_anchor`
|
|
79
|
+
// insert per payload row, anchored on the block's last line. The
|
|
80
|
+
// `blockStart` tag lets the applier's landing correction slide a
|
|
81
|
+
// body that claims a depth inside the block back across the block's
|
|
82
|
+
// trailing closer lines.
|
|
83
|
+
for (const payload of edit.payloads) {
|
|
84
|
+
const cursor = { kind: "after_anchor", anchor: { line: span.end } };
|
|
85
|
+
resolved.push({
|
|
86
|
+
kind: "insert",
|
|
87
|
+
cursor,
|
|
88
|
+
text: payload,
|
|
89
|
+
lineNum: edit.lineNum,
|
|
90
|
+
index: synthIndex++,
|
|
91
|
+
blockStart: span.start,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Mirror the parser's `replace start..end:` expansion exactly: one
|
|
97
|
+
// `before_anchor` replacement insert per payload row at `span.start`,
|
|
98
|
+
// then one delete per line across `[span.start, span.end]`. An empty
|
|
99
|
+
// `payloads` (from `delete block N`) emits no inserts — a pure deletion.
|
|
100
|
+
for (const payload of edit.payloads) {
|
|
101
|
+
const cursor = { kind: "before_anchor", anchor: { line: span.start } };
|
|
102
|
+
resolved.push({
|
|
103
|
+
kind: "insert",
|
|
104
|
+
cursor,
|
|
105
|
+
text: payload,
|
|
106
|
+
lineNum: edit.lineNum,
|
|
107
|
+
index: synthIndex++,
|
|
108
|
+
mode: "replacement",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
for (let line = span.start; line <= span.end; line++) {
|
|
112
|
+
resolved.push({ kind: "delete", anchor: { line }, lineNum: edit.lineNum, index: synthIndex++ });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return resolved;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/block.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EACN,0BAA0B,EAC1B,sBAAsB,EACtB,oCAAoC,EACpC,wCAAwC,GACxC,MAAM,eAAe,CAAC;AA6BvB,wEAAwE;AACxE,MAAM,UAAU,YAAY,CAAC,KAAsB;IAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAChC,KAAsB,EACtB,IAAY,EACZ,IAAY,EACZ,QAAmC,EACnC,OAAO,GAA6B,EAAE;IAEtC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,O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ACb,IAAI,EAAE,QAAQ;oBACd,MAAM;oBACN,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,KAAK,EAAE,UAAU,EAAE;oBACnB,UAAU,EAAE,IAAI,CAAC,KAAK;iBACtB,CAAC,CAAC;YACJ,CAAC;YACD,SAAS;QACV,CAAC;QACD,mEAAmE;QACnE,sEAAsE;QACtE,qEAAqE;QACrE,yEAAyE;QACzE,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,MAAM,GAAW,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAC/E,QAAQ,CAAC,IAAI,CAAC;gBACb,IAAI,EAAE,QAAQ;gBACd,MAAM;gBACN,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK,EAAE,UAAU,EAAE;gBACnB,IAAI,EAAE,aAAa;aACnB,CAAC,CAAC;QACJ,CAAC;QACD,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC;YACtD,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QACjG,CAAC;IACF,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Expand deferred block edits (`replace block N:` / `delete block N` /\n * `insert after block N:`) into concrete inserts + deletes.\n *\n * The hashline parser cannot expand a block edit on its own — the line span is\n * unknown until file text + path (→ language) are available. This transform\n * runs at every apply/preview boundary that has text: it calls the injected\n * {@link BlockResolver} to resolve each block's `[start, end]` span, then emits\n * the exact same edits the concrete form produces in the parser: `replace\n * start..end:` inserts + deletes for a replace, a pure range delete for a\n * delete, and plain `after_anchor` inserts at `end` for an insert-after. After\n * it runs, no `block` edits remain, so {@link applyEdits} (and recovery) only\n * ever see resolved edits.\n */\nimport { STRUCTURAL_CLOSER_RE } from \"./apply.js\";\nimport {\n\tBLOCK_RESOLVER_UNAVAILABLE,\n\tblockUnresolvedMessage,\n\tinsertAfterBlockCloserLoweredWarning,\n\tinsertAfterBlockUnresolvedLoweredWarning,\n} from \"./messages.js\";\nimport type { BlockResolution, BlockResolver, Cursor, Edit } from \"./types.js\";\n\nexport interface ResolveBlockEditsOptions {\n\t/**\n\t * How to handle a replace/delete block edit that cannot be resolved\n\t * (missing resolver or a `null` span). `\"throw\"` (default) raises a\n\t * `blockUnresolvedMessage` error — used by the authoritative apply + final\n\t * preview paths. `\"drop\"` silently skips the edit — used by the streaming\n\t * preview, where a half-written file or transient parse error must not\n\t * throw. Unresolvable `insert after block N:` edits never reach this: they\n\t * are lowered to plain `insert after N:` with a warning.\n\t */\n\tonUnresolved?: \"throw\" | \"drop\";\n\t/**\n\t * Invoked once per successfully resolved block edit, in patch order, with\n\t * the anchor line and the concrete span it resolved to. Lets the host echo\n\t * the resolution back to the caller. Never fired for dropped/unresolvable\n\t * edits.\n\t */\n\tonResolved?: (resolution: BlockResolution) => void;\n\t/**\n\t * Invoked once per diagnostic produced while resolving — currently the\n\t * `insert after block N:` lowerings (closer anchor or unresolvable block).\n\t * Hosts should surface these on the apply result's `warnings`.\n\t */\n\tonWarning?: (message: string) => void;\n}\n\n/** True when at least one edit is an unresolved deferred block edit. */\nexport function hasBlockEdit(edits: readonly Edit[]): boolean {\n\treturn edits.some(edit => edit.kind === \"block\");\n}\n\n/**\n * Resolve every deferred block edit in `edits` against `text` (parsed as the\n * language inferred from `path`). Non-block edits pass through untouched.\n * Returns a fresh edit list with no `block` variants. The fast path returns the\n * input unchanged when there is nothing to resolve.\n *\n * Synthesized inserts/deletes carry sequential `index` values for readability\n * only — {@link applyEdits} re-derives every edit's index from array order, so\n * the passthrough edits keeping their original indices is harmless.\n */\nexport function resolveBlockEdits(\n\tedits: readonly Edit[],\n\ttext: string,\n\tpath: string,\n\tresolver: BlockResolver | undefined,\n\toptions: ResolveBlockEditsOptions = {},\n): readonly Edit[] {\n\tif (!hasBlockEdit(edits)) return edits;\n\tconst onUnresolved = options.onUnresolved ?? \"throw\";\n\tconst resolved: Edit[] = [];\n\tlet synthIndex = 0;\n\tfor (const edit of edits) {\n\t\tif (edit.kind !== \"block\") {\n\t\t\tresolved.push(edit);\n\t\t\tcontinue;\n\t\t}\n\t\tconst op = edit.mode === \"insert_after\" ? \"insert_after\" : edit.payloads.length === 0 ? \"delete\" : \"replace\";\n\t\tconst span = resolver ? resolver({ path, text, line: edit.anchor.line }) : null;\n\t\tif (span === null) {\n\t\t\t// `insert after block N:` never fails the patch — lower it to plain\n\t\t\t// `insert after N:` with a warning instead. Two flavors:\n\t\t\t// - anchored on a pure closing-delimiter line: no block begins\n\t\t\t// there, but line N IS the end of one, and \"after the end of the\n\t\t\t// block\" is exactly the plain form — warn with the opener rule.\n\t\t\t// - otherwise (unsupported language, blank line, unparsable block,\n\t\t\t// or no resolver wired): \"after the block at N\" degrades to\n\t\t\t// \"after line N\" — warn to verify the landing line.\n\t\t\tif (op === \"insert_after\") {\n\t\t\t\tconst anchorText = text.split(\"\\n\")[edit.anchor.line - 1];\n\t\t\t\tconst isCloser = anchorText !== undefined && STRUCTURAL_CLOSER_RE.test(anchorText);\n\t\t\t\toptions.onWarning?.(\n\t\t\t\t\tisCloser\n\t\t\t\t\t\t? insertAfterBlockCloserLoweredWarning(edit.anchor.line)\n\t\t\t\t\t\t: insertAfterBlockUnresolvedLoweredWarning(edit.anchor.line),\n\t\t\t\t);\n\t\t\t\tfor (const payload of edit.payloads) {\n\t\t\t\t\tconst cursor: Cursor = { kind: \"after_anchor\", anchor: { line: edit.anchor.line } };\n\t\t\t\t\tresolved.push({ kind: \"insert\", cursor, text: payload, lineNum: edit.lineNum, index: synthIndex++ });\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (onUnresolved === \"drop\") continue;\n\t\t\tthrow new Error(\n\t\t\t\t`line ${edit.lineNum}: ${\n\t\t\t\t\tresolver ? blockUnresolvedMessage(edit.anchor.line, op, text.split(\"\\n\")) : BLOCK_RESOLVER_UNAVAILABLE\n\t\t\t\t}`,\n\t\t\t);\n\t\t}\n\t\toptions.onResolved?.({\n\t\t\tanchorLine: edit.anchor.line,\n\t\t\tstart: span.start,\n\t\t\tend: span.end,\n\t\t\top,\n\t\t});\n\t\tif (op === \"insert_after\") {\n\t\t\t// Mirror the parser's `insert after N:` lowering: one `after_anchor`\n\t\t\t// insert per payload row, anchored on the block's last line. The\n\t\t\t// `blockStart` tag lets the applier's landing correction slide a\n\t\t\t// body that claims a depth inside the block back across the block's\n\t\t\t// trailing closer lines.\n\t\t\tfor (const payload of edit.payloads) {\n\t\t\t\tconst cursor: Cursor = { kind: \"after_anchor\", anchor: { line: span.end } };\n\t\t\t\tresolved.push({\n\t\t\t\t\tkind: \"insert\",\n\t\t\t\t\tcursor,\n\t\t\t\t\ttext: payload,\n\t\t\t\t\tlineNum: edit.lineNum,\n\t\t\t\t\tindex: synthIndex++,\n\t\t\t\t\tblockStart: span.start,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Mirror the parser's `replace start..end:` expansion exactly: one\n\t\t// `before_anchor` replacement insert per payload row at `span.start`,\n\t\t// then one delete per line across `[span.start, span.end]`. An empty\n\t\t// `payloads` (from `delete block N`) emits no inserts — a pure deletion.\n\t\tfor (const payload of edit.payloads) {\n\t\t\tconst cursor: Cursor = { kind: \"before_anchor\", anchor: { line: span.start } };\n\t\t\tresolved.push({\n\t\t\t\tkind: \"insert\",\n\t\t\t\tcursor,\n\t\t\t\ttext: payload,\n\t\t\t\tlineNum: edit.lineNum,\n\t\t\t\tindex: synthIndex++,\n\t\t\t\tmode: \"replacement\",\n\t\t\t});\n\t\t}\n\t\tfor (let line = span.start; line <= span.end; line++) {\n\t\t\tresolved.push({ kind: \"delete\", anchor: { line }, lineNum: edit.lineNum, index: synthIndex++ });\n\t\t}\n\t}\n\treturn resolved;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-number a unified diff that uses the `+<lineNum>|content` /
|
|
3
|
+
* `-<lineNum>|content` / ` <lineNum>|content` line format into a compact
|
|
4
|
+
* current-file preview. Removed lines are counted for stats and post-edit
|
|
5
|
+
* offset tracking, but omitted from the preview. Added and context lines are
|
|
6
|
+
* anchored to their post-edit positions so a follow-up edit can reuse visible
|
|
7
|
+
* concrete lines directly. Long contiguous added runs are summarized with a
|
|
8
|
+
* `…` marker instead of echoing every inserted line.
|
|
9
|
+
*
|
|
10
|
+
* This is intentionally decoupled from the diff producer: anything that
|
|
11
|
+
* emits the `<sign><lineNum>|<content>` shape works.
|
|
12
|
+
*/
|
|
13
|
+
import type { CompactDiffOptions, CompactDiffPreview } from "./types.js";
|
|
14
|
+
export declare function buildCompactDiffPreview(diff: string, options?: CompactDiffOptions): CompactDiffPreview;
|
|
15
|
+
//# sourceMappingURL=diff-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-preview.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/diff-preview.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA+DzE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,kBAAkB,CAgD1G","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Re-number a unified diff that uses the `+<lineNum>|content` /\n * `-<lineNum>|content` / ` <lineNum>|content` line format into a compact\n * current-file preview. Removed lines are counted for stats and post-edit\n * offset tracking, but omitted from the preview. Added and context lines are\n * anchored to their post-edit positions so a follow-up edit can reuse visible\n * concrete lines directly. Long contiguous added runs are summarized with a\n * `…` marker instead of echoing every inserted line.\n *\n * This is intentionally decoupled from the diff producer: anything that\n * emits the `<sign><lineNum>|<content>` shape works.\n */\nimport type { CompactDiffOptions, CompactDiffPreview } from \"./types.js\";\n\nconst DEFAULT_ADDED_RUN_CONTEXT_LINES = 2;\n\nconst PREVIEW_ELISION_MARKER = \"…\";\n/** Blank row separating non-contiguous regions of a numbered diff. */\nconst PREVIEW_GAP_ROW = \"\";\nconst RAW_ELISION_MARKERS = new Set([\"...\", PREVIEW_ELISION_MARKER, `+${PREVIEW_ELISION_MARKER}`]);\n\nfunction isPreviewSeparator(line: string | undefined): boolean {\n\treturn line === PREVIEW_ELISION_MARKER || line === PREVIEW_GAP_ROW;\n}\n\nfunction appendPreviewLine(output: string[], line: string): void {\n\tconst normalized = RAW_ELISION_MARKERS.has(line) ? PREVIEW_ELISION_MARKER : line;\n\t// Separators (elision markers, blank gap rows) never stack: omitted\n\t// removed lines between two separators would otherwise leave them\n\t// adjacent. A leading separator is dropped outright.\n\tif (isPreviewSeparator(normalized) && (output.length === 0 || isPreviewSeparator(output[output.length - 1]))) {\n\t\treturn;\n\t}\n\toutput.push(normalized);\n}\n\ninterface ParsedDiffLine {\n\tkind: \"+\" | \"-\" | \" \";\n\tlineNumber: number;\n\tcontent: string;\n}\n\nfunction normalizeAddedRunContext(value: number | undefined): number {\n\tif (value === undefined || !Number.isFinite(value)) return DEFAULT_ADDED_RUN_CONTEXT_LINES;\n\treturn Math.max(1, Math.trunc(value));\n}\n\nfunction parseNumberedDiffLine(line: string): ParsedDiffLine | undefined {\n\tconst kind = line[0];\n\tif (kind !== \"+\" && kind !== \"-\" && kind !== \" \") return undefined;\n\n\tconst body = line.slice(1);\n\tconst sep = body.indexOf(\"|\");\n\tif (sep === -1) return undefined;\n\n\tconst lineNumber = Number.parseInt(body.slice(0, sep), 10);\n\tif (!Number.isFinite(lineNumber)) return undefined;\n\n\treturn { kind, lineNumber, content: body.slice(sep + 1) };\n}\n\nfunction appendAddedRun(output: string[], run: string[], edgeLines: number): void {\n\tif (run.length === 0) return;\n\n\tconst collapseThreshold = edgeLines * 2 + 1;\n\tif (run.length <= collapseThreshold) {\n\t\tfor (const text of run) appendPreviewLine(output, text);\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < edgeLines; i++) appendPreviewLine(output, run[i]);\n\tappendPreviewLine(output, PREVIEW_ELISION_MARKER);\n\tfor (let i = run.length - edgeLines; i < run.length; i++) appendPreviewLine(output, run[i]);\n}\n\nexport function buildCompactDiffPreview(diff: string, options: CompactDiffOptions = {}): CompactDiffPreview {\n\tconst lines = diff.length === 0 ? [] : diff.split(\"\\n\");\n\tconst addedRunContext = normalizeAddedRunContext(options.maxAddedRunContext ?? options.maxUnchangedRun);\n\tlet addedLines = 0;\n\tlet removedLines = 0;\n\tconst formatted: string[] = [];\n\tconst addedRun: string[] = [];\n\n\tconst flushAddedRun = (): void => {\n\t\tappendAddedRun(formatted, addedRun, addedRunContext);\n\t\taddedRun.length = 0;\n\t};\n\n\t// External diff producers number `+` lines with the post-edit line number,\n\t// `-` lines with the pre-edit line number, and context lines with the\n\t// pre-edit line number. To emit fresh line numbers usable for follow-up\n\t// edits, convert context-line numbers to post-edit positions by tracking\n\t// the running offset (added so far - removed so far) as we walk the diff.\n\tfor (const line of lines) {\n\t\tconst parsed = parseNumberedDiffLine(line);\n\t\tif (!parsed) {\n\t\t\tflushAddedRun();\n\t\t\tappendPreviewLine(formatted, line);\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (parsed.kind) {\n\t\t\tcase \"+\": {\n\t\t\t\taddedLines++;\n\t\t\t\taddedRun.push(`${parsed.lineNumber}:${parsed.content}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"-\":\n\t\t\t\tflushAddedRun();\n\t\t\t\tremovedLines++;\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tflushAddedRun();\n\t\t\t\tconst newLineNumber = parsed.lineNumber + addedLines - removedLines;\n\t\t\t\tappendPreviewLine(formatted, `${newLineNumber}:${parsed.content}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tflushAddedRun();\n\twhile (formatted.length > 0 && isPreviewSeparator(formatted[formatted.length - 1])) formatted.pop();\n\n\treturn { preview: formatted.join(\"\\n\"), addedLines, removedLines };\n}\n"]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const DEFAULT_ADDED_RUN_CONTEXT_LINES = 2;
|
|
2
|
+
const PREVIEW_ELISION_MARKER = "…";
|
|
3
|
+
/** Blank row separating non-contiguous regions of a numbered diff. */
|
|
4
|
+
const PREVIEW_GAP_ROW = "";
|
|
5
|
+
const RAW_ELISION_MARKERS = new Set(["...", PREVIEW_ELISION_MARKER, `+${PREVIEW_ELISION_MARKER}`]);
|
|
6
|
+
function isPreviewSeparator(line) {
|
|
7
|
+
return line === PREVIEW_ELISION_MARKER || line === PREVIEW_GAP_ROW;
|
|
8
|
+
}
|
|
9
|
+
function appendPreviewLine(output, line) {
|
|
10
|
+
const normalized = RAW_ELISION_MARKERS.has(line) ? PREVIEW_ELISION_MARKER : line;
|
|
11
|
+
// Separators (elision markers, blank gap rows) never stack: omitted
|
|
12
|
+
// removed lines between two separators would otherwise leave them
|
|
13
|
+
// adjacent. A leading separator is dropped outright.
|
|
14
|
+
if (isPreviewSeparator(normalized) && (output.length === 0 || isPreviewSeparator(output[output.length - 1]))) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
output.push(normalized);
|
|
18
|
+
}
|
|
19
|
+
function normalizeAddedRunContext(value) {
|
|
20
|
+
if (value === undefined || !Number.isFinite(value))
|
|
21
|
+
return DEFAULT_ADDED_RUN_CONTEXT_LINES;
|
|
22
|
+
return Math.max(1, Math.trunc(value));
|
|
23
|
+
}
|
|
24
|
+
function parseNumberedDiffLine(line) {
|
|
25
|
+
const kind = line[0];
|
|
26
|
+
if (kind !== "+" && kind !== "-" && kind !== " ")
|
|
27
|
+
return undefined;
|
|
28
|
+
const body = line.slice(1);
|
|
29
|
+
const sep = body.indexOf("|");
|
|
30
|
+
if (sep === -1)
|
|
31
|
+
return undefined;
|
|
32
|
+
const lineNumber = Number.parseInt(body.slice(0, sep), 10);
|
|
33
|
+
if (!Number.isFinite(lineNumber))
|
|
34
|
+
return undefined;
|
|
35
|
+
return { kind, lineNumber, content: body.slice(sep + 1) };
|
|
36
|
+
}
|
|
37
|
+
function appendAddedRun(output, run, edgeLines) {
|
|
38
|
+
if (run.length === 0)
|
|
39
|
+
return;
|
|
40
|
+
const collapseThreshold = edgeLines * 2 + 1;
|
|
41
|
+
if (run.length <= collapseThreshold) {
|
|
42
|
+
for (const text of run)
|
|
43
|
+
appendPreviewLine(output, text);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
for (let i = 0; i < edgeLines; i++)
|
|
47
|
+
appendPreviewLine(output, run[i]);
|
|
48
|
+
appendPreviewLine(output, PREVIEW_ELISION_MARKER);
|
|
49
|
+
for (let i = run.length - edgeLines; i < run.length; i++)
|
|
50
|
+
appendPreviewLine(output, run[i]);
|
|
51
|
+
}
|
|
52
|
+
export function buildCompactDiffPreview(diff, options = {}) {
|
|
53
|
+
const lines = diff.length === 0 ? [] : diff.split("\n");
|
|
54
|
+
const addedRunContext = normalizeAddedRunContext(options.maxAddedRunContext ?? options.maxUnchangedRun);
|
|
55
|
+
let addedLines = 0;
|
|
56
|
+
let removedLines = 0;
|
|
57
|
+
const formatted = [];
|
|
58
|
+
const addedRun = [];
|
|
59
|
+
const flushAddedRun = () => {
|
|
60
|
+
appendAddedRun(formatted, addedRun, addedRunContext);
|
|
61
|
+
addedRun.length = 0;
|
|
62
|
+
};
|
|
63
|
+
// External diff producers number `+` lines with the post-edit line number,
|
|
64
|
+
// `-` lines with the pre-edit line number, and context lines with the
|
|
65
|
+
// pre-edit line number. To emit fresh line numbers usable for follow-up
|
|
66
|
+
// edits, convert context-line numbers to post-edit positions by tracking
|
|
67
|
+
// the running offset (added so far - removed so far) as we walk the diff.
|
|
68
|
+
for (const line of lines) {
|
|
69
|
+
const parsed = parseNumberedDiffLine(line);
|
|
70
|
+
if (!parsed) {
|
|
71
|
+
flushAddedRun();
|
|
72
|
+
appendPreviewLine(formatted, line);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
switch (parsed.kind) {
|
|
76
|
+
case "+": {
|
|
77
|
+
addedLines++;
|
|
78
|
+
addedRun.push(`${parsed.lineNumber}:${parsed.content}`);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case "-":
|
|
82
|
+
flushAddedRun();
|
|
83
|
+
removedLines++;
|
|
84
|
+
break;
|
|
85
|
+
default: {
|
|
86
|
+
flushAddedRun();
|
|
87
|
+
const newLineNumber = parsed.lineNumber + addedLines - removedLines;
|
|
88
|
+
appendPreviewLine(formatted, `${newLineNumber}:${parsed.content}`);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
flushAddedRun();
|
|
94
|
+
while (formatted.length > 0 && isPreviewSeparator(formatted[formatted.length - 1]))
|
|
95
|
+
formatted.pop();
|
|
96
|
+
return { preview: formatted.join("\n"), addedLines, removedLines };
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=diff-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-preview.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-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GAAG;gBACP,aAAa,EAAE,CAAC;gBAChB,YAAY,EAAE,CAAC;gBACf,MAAM;YACP,SAAS,CAAC;gBACT,aAAa,EAAE,CAAC;gBAChB,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;gBACpE,iBAAiB,CAAC,SAAS,EAAE,GAAG,aAAa,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;gBACnE,MAAM;YACP,CAAC;QACF,CAAC;IACF,CAAC;IACD,aAAa,EAAE,CAAC;IAChB,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,kBAAkB,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAAE,SAAS,CAAC,GAAG,EAAE,CAAC;IAEpG,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AACpE,CAAC","sourcesContent":["// @generated vendored verbatim from oh-my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Re-number a unified diff that uses the `+<lineNum>|content` /\n * `-<lineNum>|content` / ` <lineNum>|content` line format into a compact\n * current-file preview. Removed lines are counted for stats and post-edit\n * offset tracking, but omitted from the preview. Added and context lines are\n * anchored to their post-edit positions so a follow-up edit can reuse visible\n * concrete lines directly. Long contiguous added runs are summarized with a\n * `…` marker instead of echoing every inserted line.\n *\n * This is intentionally decoupled from the diff producer: anything that\n * emits the `<sign><lineNum>|<content>` shape works.\n */\nimport type { CompactDiffOptions, CompactDiffPreview } from \"./types.js\";\n\nconst DEFAULT_ADDED_RUN_CONTEXT_LINES = 2;\n\nconst PREVIEW_ELISION_MARKER = \"…\";\n/** Blank row separating non-contiguous regions of a numbered diff. */\nconst PREVIEW_GAP_ROW = \"\";\nconst RAW_ELISION_MARKERS = new Set([\"...\", PREVIEW_ELISION_MARKER, `+${PREVIEW_ELISION_MARKER}`]);\n\nfunction isPreviewSeparator(line: string | undefined): boolean {\n\treturn line === PREVIEW_ELISION_MARKER || line === PREVIEW_GAP_ROW;\n}\n\nfunction appendPreviewLine(output: string[], line: string): void {\n\tconst normalized = RAW_ELISION_MARKERS.has(line) ? PREVIEW_ELISION_MARKER : line;\n\t// Separators (elision markers, blank gap rows) never stack: omitted\n\t// removed lines between two separators would otherwise leave them\n\t// adjacent. A leading separator is dropped outright.\n\tif (isPreviewSeparator(normalized) && (output.length === 0 || isPreviewSeparator(output[output.length - 1]))) {\n\t\treturn;\n\t}\n\toutput.push(normalized);\n}\n\ninterface ParsedDiffLine {\n\tkind: \"+\" | \"-\" | \" \";\n\tlineNumber: number;\n\tcontent: string;\n}\n\nfunction normalizeAddedRunContext(value: number | undefined): number {\n\tif (value === undefined || !Number.isFinite(value)) return DEFAULT_ADDED_RUN_CONTEXT_LINES;\n\treturn Math.max(1, Math.trunc(value));\n}\n\nfunction parseNumberedDiffLine(line: string): ParsedDiffLine | undefined {\n\tconst kind = line[0];\n\tif (kind !== \"+\" && kind !== \"-\" && kind !== \" \") return undefined;\n\n\tconst body = line.slice(1);\n\tconst sep = body.indexOf(\"|\");\n\tif (sep === -1) return undefined;\n\n\tconst lineNumber = Number.parseInt(body.slice(0, sep), 10);\n\tif (!Number.isFinite(lineNumber)) return undefined;\n\n\treturn { kind, lineNumber, content: body.slice(sep + 1) };\n}\n\nfunction appendAddedRun(output: string[], run: string[], edgeLines: number): void {\n\tif (run.length === 0) return;\n\n\tconst collapseThreshold = edgeLines * 2 + 1;\n\tif (run.length <= collapseThreshold) {\n\t\tfor (const text of run) appendPreviewLine(output, text);\n\t\treturn;\n\t}\n\n\tfor (let i = 0; i < edgeLines; i++) appendPreviewLine(output, run[i]);\n\tappendPreviewLine(output, PREVIEW_ELISION_MARKER);\n\tfor (let i = run.length - edgeLines; i < run.length; i++) appendPreviewLine(output, run[i]);\n}\n\nexport function buildCompactDiffPreview(diff: string, options: CompactDiffOptions = {}): CompactDiffPreview {\n\tconst lines = diff.length === 0 ? [] : diff.split(\"\\n\");\n\tconst addedRunContext = normalizeAddedRunContext(options.maxAddedRunContext ?? options.maxUnchangedRun);\n\tlet addedLines = 0;\n\tlet removedLines = 0;\n\tconst formatted: string[] = [];\n\tconst addedRun: string[] = [];\n\n\tconst flushAddedRun = (): void => {\n\t\tappendAddedRun(formatted, addedRun, addedRunContext);\n\t\taddedRun.length = 0;\n\t};\n\n\t// External diff producers number `+` lines with the post-edit line number,\n\t// `-` lines with the pre-edit line number, and context lines with the\n\t// pre-edit line number. To emit fresh line numbers usable for follow-up\n\t// edits, convert context-line numbers to post-edit positions by tracking\n\t// the running offset (added so far - removed so far) as we walk the diff.\n\tfor (const line of lines) {\n\t\tconst parsed = parseNumberedDiffLine(line);\n\t\tif (!parsed) {\n\t\t\tflushAddedRun();\n\t\t\tappendPreviewLine(formatted, line);\n\t\t\tcontinue;\n\t\t}\n\n\t\tswitch (parsed.kind) {\n\t\t\tcase \"+\": {\n\t\t\t\taddedLines++;\n\t\t\t\taddedRun.push(`${parsed.lineNumber}:${parsed.content}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"-\":\n\t\t\t\tflushAddedRun();\n\t\t\t\tremovedLines++;\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tflushAddedRun();\n\t\t\t\tconst newLineNumber = parsed.lineNumber + addedLines - removedLines;\n\t\t\t\tappendPreviewLine(formatted, `${newLineNumber}:${parsed.content}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tflushAddedRun();\n\twhile (formatted.length > 0 && isPreviewSeparator(formatted[formatted.length - 1])) formatted.pop();\n\n\treturn { preview: formatted.join(\"\\n\"), addedLines, removedLines };\n}\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashline format primitives: sigils, separators, regex fragments, and
|
|
3
|
+
* display helpers. These are the single source of truth for the parser, the
|
|
4
|
+
* tokenizer, the prompt, and the formal grammar.
|
|
5
|
+
*/
|
|
6
|
+
import type { Cursor } from "./types.js";
|
|
7
|
+
/** File-section header delimiters: `[path#hash]`. */
|
|
8
|
+
export declare const HL_FILE_PREFIX = "[";
|
|
9
|
+
export declare const HL_FILE_SUFFIX = "]";
|
|
10
|
+
/** Payload sigil for literal body rows. */
|
|
11
|
+
export declare const HL_PAYLOAD_REPLACE = "+";
|
|
12
|
+
/** Hunk-header keyword for concrete line replacement. */
|
|
13
|
+
export declare const HL_REPLACE_KEYWORD = "replace";
|
|
14
|
+
/** Hunk-header sub-keyword: `replace block N:` resolves N to a tree-sitter block range. */
|
|
15
|
+
export declare const HL_BLOCK_KEYWORD = "block";
|
|
16
|
+
/** Hunk-header keyword for concrete line deletion. */
|
|
17
|
+
export declare const HL_DELETE_KEYWORD = "delete";
|
|
18
|
+
/** Hunk-header keyword for insertion operations. */
|
|
19
|
+
export declare const HL_INSERT_KEYWORD = "insert";
|
|
20
|
+
/** Insert position keyword for inserting before a concrete line. */
|
|
21
|
+
export declare const HL_INSERT_BEFORE = "before";
|
|
22
|
+
/** Insert position keyword for inserting after a concrete line. */
|
|
23
|
+
export declare const HL_INSERT_AFTER = "after";
|
|
24
|
+
/** Insert position keyword for inserting at the start of the file. */
|
|
25
|
+
export declare const HL_INSERT_HEAD = "head";
|
|
26
|
+
/** Insert position keyword for inserting at the end of the file. */
|
|
27
|
+
export declare const HL_INSERT_TAIL = "tail";
|
|
28
|
+
/** Hunk-header terminator for body-bearing operations. */
|
|
29
|
+
export declare const HL_HEADER_COLON = ":";
|
|
30
|
+
/** Separator between a hashline file path and its opaque snapshot tag. */
|
|
31
|
+
export declare const HL_FILE_HASH_SEP = "#";
|
|
32
|
+
/** Separator between two line numbers in a range, e.g. `5..10`. */
|
|
33
|
+
export declare const HL_RANGE_SEP = "..";
|
|
34
|
+
/** Separator between a line number and displayed line content in hashline mode. */
|
|
35
|
+
export declare const HL_LINE_BODY_SEP = ":";
|
|
36
|
+
/** Bare positive line-number Lid (no decorations, no captures, no anchors). */
|
|
37
|
+
export declare const HL_LINE_RE_RAW = "[1-9]\\d*";
|
|
38
|
+
/** Capture-group form of {@link HL_LINE_RE_RAW}. */
|
|
39
|
+
export declare const HL_LINE_CAPTURE_RE_RAW = "([1-9]\\d*)";
|
|
40
|
+
/** Format a concrete replacement hunk header. */
|
|
41
|
+
export declare function formatReplaceHeader(start: number, end: number): string;
|
|
42
|
+
/** Format a concrete deletion hunk header. */
|
|
43
|
+
export declare function formatDeleteHeader(start: number, end?: number): string;
|
|
44
|
+
/** Format an insertion hunk header for a cursor position. */
|
|
45
|
+
export declare function formatInsertHeader(cursor: Cursor): string;
|
|
46
|
+
/** Number of hex characters in a content-derived file-hash tag. */
|
|
47
|
+
export declare const HL_FILE_HASH_LENGTH = 4;
|
|
48
|
+
/** Canonical uppercase hexadecimal content-hash tag carried by a hashline section header. */
|
|
49
|
+
export declare const HL_FILE_HASH_RE_RAW = "[0-9A-F]{4}";
|
|
50
|
+
/** Capture-group form of {@link HL_FILE_HASH_RE_RAW}. */
|
|
51
|
+
export declare const HL_FILE_HASH_CAPTURE_RE_RAW = "([0-9A-F]{4})";
|
|
52
|
+
/** Regex-escaped form of {@link HL_LINE_BODY_SEP}, safe for embedding inside a regex. */
|
|
53
|
+
export declare const HL_LINE_BODY_SEP_RE_RAW: string;
|
|
54
|
+
/**
|
|
55
|
+
* Representative file-hash tags for use in user-facing error messages and
|
|
56
|
+
* prompt examples.
|
|
57
|
+
*/
|
|
58
|
+
export declare const HL_FILE_HASH_EXAMPLES: readonly ["1A2B", "3C4D", "9F3E"];
|
|
59
|
+
export declare function computeFileHash(text: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Format a comma-separated list of example anchors with an optional line-number
|
|
62
|
+
* prefix, quoted for inclusion in error messages: `"160", "42", "7"`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function describeAnchorExamples(linePrefix?: string): string;
|
|
65
|
+
/** Format a hashline section header for a file path and snapshot tag. */
|
|
66
|
+
export declare function formatHashlineHeader(filePath: string, fileHash: string): string;
|
|
67
|
+
/** Formats a single numbered line as `LINE:TEXT`. */
|
|
68
|
+
export declare function formatNumberedLine(lineNumber: number, line: string): string;
|
|
69
|
+
/** Format file text with hashline-mode line-number prefixes for display. */
|
|
70
|
+
export declare function formatNumberedLines(text: string, startLine?: number): string;
|
|
71
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/format.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,qDAAqD;AACrD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAC5C,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAC1C,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAC1C,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,mEAAmE;AACnE,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,sEAAsE;AACtE,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,oEAAoE;AACpE,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,0DAA0D;AAC1D,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,mEAAmE;AACnE,eAAO,MAAM,YAAY,OAAO,CA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my-pi packages/hashline @ 15b5c1397fc -- DO NOT EDIT.\n// Parity source for the Atomic hashline edit engine (issue #1483); adapted only for Atomic's Node runtime (relative imports, Bun->Node host calls, erasable constructor syntax).\n/**\n * Hashline format primitives: sigils, separators, regex fragments, and\n * display helpers. These are the single source of truth for the parser, the\n * tokenizer, the prompt, and the formal grammar.\n */\n\nimport type { Cursor } from \"./types.js\";\n\n/** File-section header delimiters: `[path#hash]`. */\nexport const HL_FILE_PREFIX = \"[\";\nexport const HL_FILE_SUFFIX = \"]\";\n\n/** Payload sigil for literal body rows. */\nexport const HL_PAYLOAD_REPLACE = \"+\";\n\n/** Hunk-header keyword for concrete line replacement. */\nexport const HL_REPLACE_KEYWORD = \"replace\";\n/** Hunk-header sub-keyword: `replace block N:` resolves N to a tree-sitter block range. */\nexport const HL_BLOCK_KEYWORD = \"block\";\n/** Hunk-header keyword for concrete line deletion. */\nexport const HL_DELETE_KEYWORD = \"delete\";\n/** Hunk-header keyword for insertion operations. */\nexport const HL_INSERT_KEYWORD = \"insert\";\n/** Insert position keyword for inserting before a concrete line. */\nexport const HL_INSERT_BEFORE = \"before\";\n/** Insert position keyword for inserting after a concrete line. */\nexport const HL_INSERT_AFTER = \"after\";\n/** Insert position keyword for inserting at the start of the file. */\nexport const HL_INSERT_HEAD = \"head\";\n/** Insert position keyword for inserting at the end of the file. */\nexport const HL_INSERT_TAIL = \"tail\";\n/** Hunk-header terminator for body-bearing operations. */\nexport const HL_HEADER_COLON = \":\";\n\n/** Separator between a hashline file path and its opaque snapshot tag. */\nexport const HL_FILE_HASH_SEP = \"#\";\n\n/** Separator between two line numbers in a range, e.g. `5..10`. */\nexport const HL_RANGE_SEP = \"..\";\n\n/** Separator between a line number and displayed line content in hashline mode. */\nexport const HL_LINE_BODY_SEP = \":\";\n\nfunction regexEscape(str: string): string {\n\treturn str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Bare positive line-number Lid (no decorations, no captures, no anchors). */\nexport const HL_LINE_RE_RAW = `[1-9]\\\\d*`;\n\n/** Capture-group form of {@link HL_LINE_RE_RAW}. */\nexport const HL_LINE_CAPTURE_RE_RAW = `(${HL_LINE_RE_RAW})`;\n\n/** Format a concrete replacement hunk header. */\nexport function formatReplaceHeader(start: number, end: number): string {\n\treturn `${HL_REPLACE_KEYWORD} ${start}${HL_RANGE_SEP}${end}${HL_HEADER_COLON}`;\n}\n\n/** Format a concrete deletion hunk header. */\nexport function formatDeleteHeader(start: number, end = start): string {\n\treturn start === end ? `${HL_DELETE_KEYWORD} ${start}` : `${HL_DELETE_KEYWORD} ${start}${HL_RANGE_SEP}${end}`;\n}\n\n/** Format an insertion hunk header for a cursor position. */\nexport function formatInsertHeader(cursor: Cursor): string {\n\tswitch (cursor.kind) {\n\t\tcase \"before_anchor\":\n\t\t\treturn `${HL_INSERT_KEYWORD} ${HL_INSERT_BEFORE} ${cursor.anchor.line}${HL_HEADER_COLON}`;\n\t\tcase \"after_anchor\":\n\t\t\treturn `${HL_INSERT_KEYWORD} ${HL_INSERT_AFTER} ${cursor.anchor.line}${HL_HEADER_COLON}`;\n\t\tcase \"bof\":\n\t\t\treturn `${HL_INSERT_KEYWORD} ${HL_INSERT_HEAD}${HL_HEADER_COLON}`;\n\t\tcase \"eof\":\n\t\t\treturn `${HL_INSERT_KEYWORD} ${HL_INSERT_TAIL}${HL_HEADER_COLON}`;\n\t}\n}\n\n/** Number of hex characters in a content-derived file-hash tag. */\nexport const HL_FILE_HASH_LENGTH = 4;\n/** Canonical uppercase hexadecimal content-hash tag carried by a hashline section header. */\nexport const HL_FILE_HASH_RE_RAW = `[0-9A-F]{${HL_FILE_HASH_LENGTH}}`;\n/** Capture-group form of {@link HL_FILE_HASH_RE_RAW}. */\nexport const HL_FILE_HASH_CAPTURE_RE_RAW = `(${HL_FILE_HASH_RE_RAW})`;\n/** Regex-escaped form of {@link HL_LINE_BODY_SEP}, safe for embedding inside a regex. */\nexport const HL_LINE_BODY_SEP_RE_RAW = regexEscape(HL_LINE_BODY_SEP);\n/**\n * Representative file-hash tags for use in user-facing error messages and\n * prompt examples.\n */\nexport const HL_FILE_HASH_EXAMPLES = [\"1A2B\", \"3C4D\", \"9F3E\"] as const;\n/**\n * Normalize text before hashing: trim trailing `[ \\t\\r]` from every line (and\n * the final line) in a single pass so CRLF endings and display-trimmed lines\n * do not invalidate a tag.\n */\nfunction normalizeFileHashText(text: string): string {\n\treturn text.replace(/[ \\t\\r]+(?=\\n|$)/g, \"\");\n}\n/**\n * Compute the content-derived hash tag carried by a hashline section header.\n * The tag is a 4-hex fingerprint of the whole file's normalized text: any read\n * of byte-identical content mints the same tag, and a follow-up edit anchored\n * at any line validates whenever the live file still hashes to it.\n */\n// xxHash32 (canonical, seed 0) to match upstream Bun.hash.xxHash32 so section tags\n// are byte-identical to oh-my-pi for identical content. Pure-JS for Node runtime.\nconst XXH_PRIME32_1 = 0x9e3779b1;\nconst XXH_PRIME32_2 = 0x85ebca77;\nconst XXH_PRIME32_3 = 0xc2b2ae3d;\nconst XXH_PRIME32_4 = 0x27d4eb2f;\nconst XXH_PRIME32_5 = 0x165667b1;\nfunction xxhRotl(value: number, bits: number): number {\n\treturn (value << bits) | (value >>> (32 - bits));\n}\nfunction xxhRound(acc: number, input: number): number {\n\tacc = (acc + Math.imul(input, XXH_PRIME32_2)) | 0;\n\tacc = xxhRotl(acc, 13);\n\treturn Math.imul(acc, XXH_PRIME32_1) | 0;\n}\nfunction xxHash32(bytes: Uint8Array): number {\n\tconst len = bytes.length;\n\tlet index = 0;\n\tlet h32: number;\n\tconst readU32 = (offset: number): number =>\n\t\t(bytes[offset]! | (bytes[offset + 1]! << 8) | (bytes[offset + 2]! << 16) | (bytes[offset + 3]! << 24)) >>> 0;\n\tif (len >= 16) {\n\t\tlet v1 = (XXH_PRIME32_1 + XXH_PRIME32_2) | 0;\n\t\tlet v2 = XXH_PRIME32_2 | 0;\n\t\tlet v3 = 0;\n\t\tlet v4 = -XXH_PRIME32_1 | 0;\n\t\tconst limit = len - 16;\n\t\twhile (index <= limit) {\n\t\t\tv1 = xxhRound(v1, readU32(index)); index += 4;\n\t\t\tv2 = xxhRound(v2, readU32(index)); index += 4;\n\t\t\tv3 = xxhRound(v3, readU32(index)); index += 4;\n\t\t\tv4 = xxhRound(v4, readU32(index)); index += 4;\n\t\t}\n\t\th32 = (xxhRotl(v1, 1) + xxhRotl(v2, 7) + xxhRotl(v3, 12) + xxhRotl(v4, 18)) | 0;\n\t} else {\n\t\th32 = XXH_PRIME32_5 | 0;\n\t}\n\th32 = (h32 + len) | 0;\n\twhile (index + 4 <= len) {\n\t\th32 = (h32 + Math.imul(readU32(index), XXH_PRIME32_3)) | 0;\n\t\th32 = Math.imul(xxhRotl(h32, 17), XXH_PRIME32_4) | 0;\n\t\tindex += 4;\n\t}\n\twhile (index < len) {\n\t\th32 = (h32 + Math.imul(bytes[index]!, XXH_PRIME32_5)) | 0;\n\t\th32 = Math.imul(xxhRotl(h32, 11), XXH_PRIME32_1) | 0;\n\t\tindex += 1;\n\t}\n\th32 ^= h32 >>> 15;\n\th32 = Math.imul(h32, XXH_PRIME32_2);\n\th32 ^= h32 >>> 13;\n\th32 = Math.imul(h32, XXH_PRIME32_3);\n\th32 ^= h32 >>> 16;\n\treturn h32 >>> 0;\n}\nconst xxhEncoder = new TextEncoder();\nexport function computeFileHash(text: string): string {\n\tconst normalized = normalizeFileHashText(text);\n\tconst low16 = xxHash32(xxhEncoder.encode(normalized)) & 0xffff;\n\treturn low16.toString(16).padStart(HL_FILE_HASH_LENGTH, \"0\").toUpperCase();\n}\n\n/**\n * Format a comma-separated list of example anchors with an optional line-number\n * prefix, quoted for inclusion in error messages: `\"160\", \"42\", \"7\"`.\n */\nexport function describeAnchorExamples(linePrefix = \"\"): string {\n\tconst examples = linePrefix ? [linePrefix, `${linePrefix.slice(0, -1) || \"4\"}2`, \"7\"] : [\"160\", \"42\", \"7\"];\n\treturn examples.map(e => `\"${e}\"`).join(\", \");\n}\n\n/** Format a hashline section header for a file path and snapshot tag. */\nexport function formatHashlineHeader(filePath: string, fileHash: string): string {\n\treturn `${HL_FILE_PREFIX}${filePath}${HL_FILE_HASH_SEP}${fileHash}${HL_FILE_SUFFIX}`;\n}\n\n/** Formats a single numbered line as `LINE:TEXT`. */\nexport function formatNumberedLine(lineNumber: number, line: string): string {\n\treturn `${lineNumber}${HL_LINE_BODY_SEP}${line}`;\n}\n\n/** Format file text with hashline-mode line-number prefixes for display. */\nexport function formatNumberedLines(text: string, startLine = 1): string {\n\tconst lines = text.split(\"\\n\");\n\treturn lines.map((line, i) => formatNumberedLine(startLine + i, line)).join(\"\\n\");\n}\n"]}
|