@bastani/atomic 0.9.2 → 0.9.3-alpha.1
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 +57 -0
- package/README.md +2 -2
- package/dist/builtin/cursor/package.json +2 -2
- 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 +11 -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/schemas.ts +2 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +4 -3
- 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/shared/types-depth.ts +5 -5
- package/dist/builtin/subagents/src/shared/types-runtime.ts +2 -1
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +13 -0
- package/dist/builtin/workflows/README.md +2 -2
- 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/extension/config-loader.ts +35 -15
- package/dist/builtin/workflows/src/extension/discovery.ts +20 -8
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +1 -2
- package/dist/builtin/workflows/src/extension/wiring.ts +1 -1
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +11 -10
- 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 +11 -3
- 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/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/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/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/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 +16 -1
- package/docs/containerization.md +1 -1
- package/docs/docs.json +1 -0
- package/docs/extensions.md +25 -36
- package/docs/quickstart.md +11 -6
- package/docs/sdk.md +5 -5
- 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 +7 -5
- 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 +3 -2
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
* Hashline format primitives: sigils, separators, regex fragments, and
|
|
5
|
+
* display helpers. These are the single source of truth for the parser, the
|
|
6
|
+
* tokenizer, the prompt, and the formal grammar.
|
|
7
|
+
*/
|
|
8
|
+
/** File-section header delimiters: `[path#hash]`. */
|
|
9
|
+
export const HL_FILE_PREFIX = "[";
|
|
10
|
+
export const HL_FILE_SUFFIX = "]";
|
|
11
|
+
/** Payload sigil for literal body rows. */
|
|
12
|
+
export const HL_PAYLOAD_REPLACE = "+";
|
|
13
|
+
/** Hunk-header keyword for concrete line replacement. */
|
|
14
|
+
export const HL_REPLACE_KEYWORD = "replace";
|
|
15
|
+
/** Hunk-header sub-keyword: `replace block N:` resolves N to a tree-sitter block range. */
|
|
16
|
+
export const HL_BLOCK_KEYWORD = "block";
|
|
17
|
+
/** Hunk-header keyword for concrete line deletion. */
|
|
18
|
+
export const HL_DELETE_KEYWORD = "delete";
|
|
19
|
+
/** Hunk-header keyword for insertion operations. */
|
|
20
|
+
export const HL_INSERT_KEYWORD = "insert";
|
|
21
|
+
/** Insert position keyword for inserting before a concrete line. */
|
|
22
|
+
export const HL_INSERT_BEFORE = "before";
|
|
23
|
+
/** Insert position keyword for inserting after a concrete line. */
|
|
24
|
+
export const HL_INSERT_AFTER = "after";
|
|
25
|
+
/** Insert position keyword for inserting at the start of the file. */
|
|
26
|
+
export const HL_INSERT_HEAD = "head";
|
|
27
|
+
/** Insert position keyword for inserting at the end of the file. */
|
|
28
|
+
export const HL_INSERT_TAIL = "tail";
|
|
29
|
+
/** Hunk-header terminator for body-bearing operations. */
|
|
30
|
+
export const HL_HEADER_COLON = ":";
|
|
31
|
+
/** Separator between a hashline file path and its opaque snapshot tag. */
|
|
32
|
+
export const HL_FILE_HASH_SEP = "#";
|
|
33
|
+
/** Separator between two line numbers in a range, e.g. `5..10`. */
|
|
34
|
+
export const HL_RANGE_SEP = "..";
|
|
35
|
+
/** Separator between a line number and displayed line content in hashline mode. */
|
|
36
|
+
export const HL_LINE_BODY_SEP = ":";
|
|
37
|
+
function regexEscape(str) {
|
|
38
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
39
|
+
}
|
|
40
|
+
/** Bare positive line-number Lid (no decorations, no captures, no anchors). */
|
|
41
|
+
export const HL_LINE_RE_RAW = `[1-9]\\d*`;
|
|
42
|
+
/** Capture-group form of {@link HL_LINE_RE_RAW}. */
|
|
43
|
+
export const HL_LINE_CAPTURE_RE_RAW = `(${HL_LINE_RE_RAW})`;
|
|
44
|
+
/** Format a concrete replacement hunk header. */
|
|
45
|
+
export function formatReplaceHeader(start, end) {
|
|
46
|
+
return `${HL_REPLACE_KEYWORD} ${start}${HL_RANGE_SEP}${end}${HL_HEADER_COLON}`;
|
|
47
|
+
}
|
|
48
|
+
/** Format a concrete deletion hunk header. */
|
|
49
|
+
export function formatDeleteHeader(start, end = start) {
|
|
50
|
+
return start === end ? `${HL_DELETE_KEYWORD} ${start}` : `${HL_DELETE_KEYWORD} ${start}${HL_RANGE_SEP}${end}`;
|
|
51
|
+
}
|
|
52
|
+
/** Format an insertion hunk header for a cursor position. */
|
|
53
|
+
export function formatInsertHeader(cursor) {
|
|
54
|
+
switch (cursor.kind) {
|
|
55
|
+
case "before_anchor":
|
|
56
|
+
return `${HL_INSERT_KEYWORD} ${HL_INSERT_BEFORE} ${cursor.anchor.line}${HL_HEADER_COLON}`;
|
|
57
|
+
case "after_anchor":
|
|
58
|
+
return `${HL_INSERT_KEYWORD} ${HL_INSERT_AFTER} ${cursor.anchor.line}${HL_HEADER_COLON}`;
|
|
59
|
+
case "bof":
|
|
60
|
+
return `${HL_INSERT_KEYWORD} ${HL_INSERT_HEAD}${HL_HEADER_COLON}`;
|
|
61
|
+
case "eof":
|
|
62
|
+
return `${HL_INSERT_KEYWORD} ${HL_INSERT_TAIL}${HL_HEADER_COLON}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Number of hex characters in a content-derived file-hash tag. */
|
|
66
|
+
export const HL_FILE_HASH_LENGTH = 4;
|
|
67
|
+
/** Canonical uppercase hexadecimal content-hash tag carried by a hashline section header. */
|
|
68
|
+
export const HL_FILE_HASH_RE_RAW = `[0-9A-F]{${HL_FILE_HASH_LENGTH}}`;
|
|
69
|
+
/** Capture-group form of {@link HL_FILE_HASH_RE_RAW}. */
|
|
70
|
+
export const HL_FILE_HASH_CAPTURE_RE_RAW = `(${HL_FILE_HASH_RE_RAW})`;
|
|
71
|
+
/** Regex-escaped form of {@link HL_LINE_BODY_SEP}, safe for embedding inside a regex. */
|
|
72
|
+
export const HL_LINE_BODY_SEP_RE_RAW = regexEscape(HL_LINE_BODY_SEP);
|
|
73
|
+
/**
|
|
74
|
+
* Representative file-hash tags for use in user-facing error messages and
|
|
75
|
+
* prompt examples.
|
|
76
|
+
*/
|
|
77
|
+
export const HL_FILE_HASH_EXAMPLES = ["1A2B", "3C4D", "9F3E"];
|
|
78
|
+
/**
|
|
79
|
+
* Normalize text before hashing: trim trailing `[ \t\r]` from every line (and
|
|
80
|
+
* the final line) in a single pass so CRLF endings and display-trimmed lines
|
|
81
|
+
* do not invalidate a tag.
|
|
82
|
+
*/
|
|
83
|
+
function normalizeFileHashText(text) {
|
|
84
|
+
return text.replace(/[ \t\r]+(?=\n|$)/g, "");
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Compute the content-derived hash tag carried by a hashline section header.
|
|
88
|
+
* The tag is a 4-hex fingerprint of the whole file's normalized text: any read
|
|
89
|
+
* of byte-identical content mints the same tag, and a follow-up edit anchored
|
|
90
|
+
* at any line validates whenever the live file still hashes to it.
|
|
91
|
+
*/
|
|
92
|
+
// xxHash32 (canonical, seed 0) to match upstream Bun.hash.xxHash32 so section tags
|
|
93
|
+
// are byte-identical to oh-my-pi for identical content. Pure-JS for Node runtime.
|
|
94
|
+
const XXH_PRIME32_1 = 0x9e3779b1;
|
|
95
|
+
const XXH_PRIME32_2 = 0x85ebca77;
|
|
96
|
+
const XXH_PRIME32_3 = 0xc2b2ae3d;
|
|
97
|
+
const XXH_PRIME32_4 = 0x27d4eb2f;
|
|
98
|
+
const XXH_PRIME32_5 = 0x165667b1;
|
|
99
|
+
function xxhRotl(value, bits) {
|
|
100
|
+
return (value << bits) | (value >>> (32 - bits));
|
|
101
|
+
}
|
|
102
|
+
function xxhRound(acc, input) {
|
|
103
|
+
acc = (acc + Math.imul(input, XXH_PRIME32_2)) | 0;
|
|
104
|
+
acc = xxhRotl(acc, 13);
|
|
105
|
+
return Math.imul(acc, XXH_PRIME32_1) | 0;
|
|
106
|
+
}
|
|
107
|
+
function xxHash32(bytes) {
|
|
108
|
+
const len = bytes.length;
|
|
109
|
+
let index = 0;
|
|
110
|
+
let h32;
|
|
111
|
+
const readU32 = (offset) => (bytes[offset] | (bytes[offset + 1] << 8) | (bytes[offset + 2] << 16) | (bytes[offset + 3] << 24)) >>> 0;
|
|
112
|
+
if (len >= 16) {
|
|
113
|
+
let v1 = (XXH_PRIME32_1 + XXH_PRIME32_2) | 0;
|
|
114
|
+
let v2 = XXH_PRIME32_2 | 0;
|
|
115
|
+
let v3 = 0;
|
|
116
|
+
let v4 = -XXH_PRIME32_1 | 0;
|
|
117
|
+
const limit = len - 16;
|
|
118
|
+
while (index <= limit) {
|
|
119
|
+
v1 = xxhRound(v1, readU32(index));
|
|
120
|
+
index += 4;
|
|
121
|
+
v2 = xxhRound(v2, readU32(index));
|
|
122
|
+
index += 4;
|
|
123
|
+
v3 = xxhRound(v3, readU32(index));
|
|
124
|
+
index += 4;
|
|
125
|
+
v4 = xxhRound(v4, readU32(index));
|
|
126
|
+
index += 4;
|
|
127
|
+
}
|
|
128
|
+
h32 = (xxhRotl(v1, 1) + xxhRotl(v2, 7) + xxhRotl(v3, 12) + xxhRotl(v4, 18)) | 0;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
h32 = XXH_PRIME32_5 | 0;
|
|
132
|
+
}
|
|
133
|
+
h32 = (h32 + len) | 0;
|
|
134
|
+
while (index + 4 <= len) {
|
|
135
|
+
h32 = (h32 + Math.imul(readU32(index), XXH_PRIME32_3)) | 0;
|
|
136
|
+
h32 = Math.imul(xxhRotl(h32, 17), XXH_PRIME32_4) | 0;
|
|
137
|
+
index += 4;
|
|
138
|
+
}
|
|
139
|
+
while (index < len) {
|
|
140
|
+
h32 = (h32 + Math.imul(bytes[index], XXH_PRIME32_5)) | 0;
|
|
141
|
+
h32 = Math.imul(xxhRotl(h32, 11), XXH_PRIME32_1) | 0;
|
|
142
|
+
index += 1;
|
|
143
|
+
}
|
|
144
|
+
h32 ^= h32 >>> 15;
|
|
145
|
+
h32 = Math.imul(h32, XXH_PRIME32_2);
|
|
146
|
+
h32 ^= h32 >>> 13;
|
|
147
|
+
h32 = Math.imul(h32, XXH_PRIME32_3);
|
|
148
|
+
h32 ^= h32 >>> 16;
|
|
149
|
+
return h32 >>> 0;
|
|
150
|
+
}
|
|
151
|
+
const xxhEncoder = new TextEncoder();
|
|
152
|
+
export function computeFileHash(text) {
|
|
153
|
+
const normalized = normalizeFileHashText(text);
|
|
154
|
+
const low16 = xxHash32(xxhEncoder.encode(normalized)) & 0xffff;
|
|
155
|
+
return low16.toString(16).padStart(HL_FILE_HASH_LENGTH, "0").toUpperCase();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Format a comma-separated list of example anchors with an optional line-number
|
|
159
|
+
* prefix, quoted for inclusion in error messages: `"160", "42", "7"`.
|
|
160
|
+
*/
|
|
161
|
+
export function describeAnchorExamples(linePrefix = "") {
|
|
162
|
+
const examples = linePrefix ? [linePrefix, `${linePrefix.slice(0, -1) || "4"}2`, "7"] : ["160", "42", "7"];
|
|
163
|
+
return examples.map(e => `"${e}"`).join(", ");
|
|
164
|
+
}
|
|
165
|
+
/** Format a hashline section header for a file path and snapshot tag. */
|
|
166
|
+
export function formatHashlineHeader(filePath, fileHash) {
|
|
167
|
+
return `${HL_FILE_PREFIX}${filePath}${HL_FILE_HASH_SEP}${fileHash}${HL_FILE_SUFFIX}`;
|
|
168
|
+
}
|
|
169
|
+
/** Formats a single numbered line as `LINE:TEXT`. */
|
|
170
|
+
export function formatNumberedLine(lineNumber, line) {
|
|
171
|
+
return `${lineNumber}${HL_LINE_BODY_SEP}${line}`;
|
|
172
|
+
}
|
|
173
|
+
/** Format file text with hashline-mode line-number prefixes for display. */
|
|
174
|
+
export function formatNumberedLines(text, startLine = 1) {
|
|
175
|
+
const lines = text.split("\n");
|
|
176
|
+
return lines.map((line, i) => formatNumberedLine(startLine + i, line)).join("\n");
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/format.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL;;;;GAIG;AAIH,qDAAqD;AACrD,MAAM,C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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"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result returned by {@link Filesystem.writeText}. The patcher echoes back
|
|
3
|
+
* `text` so adapters that transform on serialization (e.g. notebooks) can
|
|
4
|
+
* report what actually landed on disk.
|
|
5
|
+
*/
|
|
6
|
+
export interface WriteResult {
|
|
7
|
+
/** Final text that was persisted. May differ from the input if the FS transformed it. */
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* ENOENT-like error thrown by {@link Filesystem.readText} when a path is
|
|
12
|
+
* missing. Carrying a `code` property keeps the contract compatible with
|
|
13
|
+
* `node:fs` callers that already check `err.code === "ENOENT"`.
|
|
14
|
+
*/
|
|
15
|
+
export declare class NotFoundError extends Error {
|
|
16
|
+
readonly code = "ENOENT";
|
|
17
|
+
constructor(path: string, cause?: unknown);
|
|
18
|
+
}
|
|
19
|
+
/** Type guard for {@link NotFoundError} and structurally-compatible errors. */
|
|
20
|
+
export declare function isNotFound(error: unknown): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Abstract storage backend the {@link Patcher} reads from and writes to.
|
|
23
|
+
* Subclass for new backends; the package ships {@link InMemoryFilesystem} and
|
|
24
|
+
* {@link NodeFilesystem} for the most common cases.
|
|
25
|
+
*
|
|
26
|
+
* Implementations work with raw text — the patcher handles BOM stripping and
|
|
27
|
+
* line-ending normalization itself. `readText` MUST throw {@link
|
|
28
|
+
* NotFoundError} (or any error for which {@link isNotFound} returns true)
|
|
29
|
+
* when the path doesn't exist; that's how the patcher detects a create-vs-
|
|
30
|
+
* update.
|
|
31
|
+
*/
|
|
32
|
+
export declare abstract class Filesystem {
|
|
33
|
+
/** Read the file's full text content. Throw on missing file. */
|
|
34
|
+
abstract readText(path: string): Promise<string>;
|
|
35
|
+
/** Validate that `path` is writable before a prepared batch starts committing. */
|
|
36
|
+
preflightWrite(_path: string): Promise<void>;
|
|
37
|
+
/** Persist `content` at `path`. Returns the actual final text that was written. */
|
|
38
|
+
abstract writeText(path: string, content: string): Promise<WriteResult>;
|
|
39
|
+
/** Return true when the path exists and can be read. Default: probe via {@link readText}. */
|
|
40
|
+
exists(path: string): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Canonical path used as a key by external caches (e.g. snapshot
|
|
43
|
+
* stores). The default is identity; override to return an absolute or
|
|
44
|
+
* otherwise canonicalised path so producers and consumers of cached
|
|
45
|
+
* snapshots agree on the key without each having to redo the resolution.
|
|
46
|
+
*/
|
|
47
|
+
canonicalPath(path: string): string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as
|
|
51
|
+
* a building block for stacked adapters (e.g. an LRU layer on top).
|
|
52
|
+
*/
|
|
53
|
+
export declare class InMemoryFilesystem extends Filesystem {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(initial?: Iterable<readonly [string, string]>);
|
|
56
|
+
readText(path: string): Promise<string>;
|
|
57
|
+
writeText(path: string, content: string): Promise<WriteResult>;
|
|
58
|
+
exists(path: string): Promise<boolean>;
|
|
59
|
+
/** Synchronous helper for setting up fixtures without awaiting. */
|
|
60
|
+
set(path: string, content: string): void;
|
|
61
|
+
/** Synchronous helper for inspecting state without awaiting. */
|
|
62
|
+
get(path: string): string | undefined;
|
|
63
|
+
/** Remove a single entry. Returns true when something was removed. */
|
|
64
|
+
delete(path: string): boolean;
|
|
65
|
+
/** Wipe all entries. */
|
|
66
|
+
clear(): void;
|
|
67
|
+
/** Iterate `[path, content]` pairs. */
|
|
68
|
+
entries(): IterableIterator<[string, string]>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI
|
|
72
|
+
* use. Paths are accepted as-is; callers responsible for any cwd or
|
|
73
|
+
* jail/sandbox resolution should wrap this with their own subclass.
|
|
74
|
+
*/
|
|
75
|
+
export declare class NodeFilesystem extends Filesystem {
|
|
76
|
+
readText(path: string): Promise<string>;
|
|
77
|
+
writeText(path: string, content: string): Promise<WriteResult>;
|
|
78
|
+
canonicalPath(path: string): string;
|
|
79
|
+
exists(path: string): Promise<boolean>;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/fs.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC3B,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,YAAY;IAEzB,YAAY,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAIxC;CACD;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIlD;AAED;;;;;;;;;;GAUG;AACH,8BAAsB,UAAU;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD,kFAAkF;IAC5E,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC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AE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGnE;IAED,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElC;IAEK,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3C;CACD","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).\nimport { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\n/**\n * Storage seam for the hashline patcher. {@link Filesystem} is intentionally\n * minimal — `readText`, `writeText`, `exists` — so any backing store can be\n * adapted: disk, memory, S3, an LSP text-document protocol, a Git tree, a\n * VFS, etc.\n *\n * The patcher does its own BOM stripping and LF normalization between\n * {@link Filesystem.readText} and {@link Filesystem.writeText}; the FS deals\n * only in raw text strings.\n */\nimport * as pathModule from \"node:path\";\n\n/**\n * Result returned by {@link Filesystem.writeText}. The patcher echoes back\n * `text` so adapters that transform on serialization (e.g. notebooks) can\n * report what actually landed on disk.\n */\nexport interface WriteResult {\n\t/** Final text that was persisted. May differ from the input if the FS transformed it. */\n\ttext: string;\n}\n\n/**\n * ENOENT-like error thrown by {@link Filesystem.readText} when a path is\n * missing. Carrying a `code` property keeps the contract compatible with\n * `node:fs` callers that already check `err.code === \"ENOENT\"`.\n */\nexport class NotFoundError extends Error {\n\treadonly code = \"ENOENT\";\n\n\tconstructor(path: string, cause?: unknown) {\n\t\tsuper(`File not found: ${path}`);\n\t\tthis.name = \"NotFoundError\";\n\t\tif (cause !== undefined) (this as Error & { cause?: unknown }).cause = cause;\n\t}\n}\n\n/** Type guard for {@link NotFoundError} and structurally-compatible errors. */\nexport function isNotFound(error: unknown): boolean {\n\tif (error instanceof NotFoundError) return true;\n\tif (error instanceof Error && (error as Error & { code?: string }).code === \"ENOENT\") return true;\n\treturn false;\n}\n\n/**\n * Abstract storage backend the {@link Patcher} reads from and writes to.\n * Subclass for new backends; the package ships {@link InMemoryFilesystem} and\n * {@link NodeFilesystem} for the most common cases.\n *\n * Implementations work with raw text — the patcher handles BOM stripping and\n * line-ending normalization itself. `readText` MUST throw {@link\n * NotFoundError} (or any error for which {@link isNotFound} returns true)\n * when the path doesn't exist; that's how the patcher detects a create-vs-\n * update.\n */\nexport abstract class Filesystem {\n\t/** Read the file's full text content. Throw on missing file. */\n\tabstract readText(path: string): Promise<string>;\n\n\t/** Validate that `path` is writable before a prepared batch starts committing. */\n\tasync preflightWrite(_path: string): Promise<void> {}\n\n\t/** Persist `content` at `path`. Returns the actual final text that was written. */\n\tabstract writeText(path: string, content: string): Promise<WriteResult>;\n\n\t/** Return true when the path exists and can be read. Default: probe via {@link readText}. */\n\tasync exists(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.readText(path);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (isNotFound(error)) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Canonical path used as a key by external caches (e.g. snapshot\n\t * stores). The default is identity; override to return an absolute or\n\t * otherwise canonicalised path so producers and consumers of cached\n\t * snapshots agree on the key without each having to redo the resolution.\n\t */\n\tcanonicalPath(path: string): string {\n\t\treturn path;\n\t}\n}\n\n/**\n * In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as\n * a building block for stacked adapters (e.g. an LRU layer on top).\n */\nexport class InMemoryFilesystem extends Filesystem {\n\t#files = new Map<string, string>();\n\n\tconstructor(initial?: Iterable<readonly [string, string]>) {\n\t\tsuper();\n\t\tif (initial) {\n\t\t\tfor (const [path, content] of initial) this.#files.set(path, content);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst text = this.#files.get(path);\n\t\tif (text === undefined) throw new NotFoundError(path);\n\t\treturn text;\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tthis.#files.set(path, content);\n\t\treturn { text: content };\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn this.#files.has(path);\n\t}\n\n\t/** Synchronous helper for setting up fixtures without awaiting. */\n\tset(path: string, content: string): void {\n\t\tthis.#files.set(path, content);\n\t}\n\n\t/** Synchronous helper for inspecting state without awaiting. */\n\tget(path: string): string | undefined {\n\t\treturn this.#files.get(path);\n\t}\n\n\t/** Remove a single entry. Returns true when something was removed. */\n\tdelete(path: string): boolean {\n\t\treturn this.#files.delete(path);\n\t}\n\n\t/** Wipe all entries. */\n\tclear(): void {\n\t\tthis.#files.clear();\n\t}\n\n\t/** Iterate `[path, content]` pairs. */\n\tentries(): IterableIterator<[string, string]> {\n\t\treturn this.#files.entries();\n\t}\n}\n\n/**\n * Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI\n * use. Paths are accepted as-is; callers responsible for any cwd or\n * jail/sandbox resolution should wrap this with their own subclass.\n */\nexport class NodeFilesystem extends Filesystem {\n\tasync readText(path: string): Promise<string> {\n\t\tif (!existsSync(path)) throw new NotFoundError(path);\n\t\treturn readFile(path, \"utf8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tawait writeFile(path, content, \"utf8\");\n\t\treturn { text: content };\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn pathModule.resolve(path);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn existsSync(path);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
5
|
+
/**
|
|
6
|
+
* Storage seam for the hashline patcher. {@link Filesystem} is intentionally
|
|
7
|
+
* minimal — `readText`, `writeText`, `exists` — so any backing store can be
|
|
8
|
+
* adapted: disk, memory, S3, an LSP text-document protocol, a Git tree, a
|
|
9
|
+
* VFS, etc.
|
|
10
|
+
*
|
|
11
|
+
* The patcher does its own BOM stripping and LF normalization between
|
|
12
|
+
* {@link Filesystem.readText} and {@link Filesystem.writeText}; the FS deals
|
|
13
|
+
* only in raw text strings.
|
|
14
|
+
*/
|
|
15
|
+
import * as pathModule from "node:path";
|
|
16
|
+
/**
|
|
17
|
+
* ENOENT-like error thrown by {@link Filesystem.readText} when a path is
|
|
18
|
+
* missing. Carrying a `code` property keeps the contract compatible with
|
|
19
|
+
* `node:fs` callers that already check `err.code === "ENOENT"`.
|
|
20
|
+
*/
|
|
21
|
+
export class NotFoundError extends Error {
|
|
22
|
+
constructor(path, cause) {
|
|
23
|
+
super(`File not found: ${path}`);
|
|
24
|
+
this.code = "ENOENT";
|
|
25
|
+
this.name = "NotFoundError";
|
|
26
|
+
if (cause !== undefined)
|
|
27
|
+
this.cause = cause;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Type guard for {@link NotFoundError} and structurally-compatible errors. */
|
|
31
|
+
export function isNotFound(error) {
|
|
32
|
+
if (error instanceof NotFoundError)
|
|
33
|
+
return true;
|
|
34
|
+
if (error instanceof Error && error.code === "ENOENT")
|
|
35
|
+
return true;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Abstract storage backend the {@link Patcher} reads from and writes to.
|
|
40
|
+
* Subclass for new backends; the package ships {@link InMemoryFilesystem} and
|
|
41
|
+
* {@link NodeFilesystem} for the most common cases.
|
|
42
|
+
*
|
|
43
|
+
* Implementations work with raw text — the patcher handles BOM stripping and
|
|
44
|
+
* line-ending normalization itself. `readText` MUST throw {@link
|
|
45
|
+
* NotFoundError} (or any error for which {@link isNotFound} returns true)
|
|
46
|
+
* when the path doesn't exist; that's how the patcher detects a create-vs-
|
|
47
|
+
* update.
|
|
48
|
+
*/
|
|
49
|
+
export class Filesystem {
|
|
50
|
+
/** Validate that `path` is writable before a prepared batch starts committing. */
|
|
51
|
+
async preflightWrite(_path) { }
|
|
52
|
+
/** Return true when the path exists and can be read. Default: probe via {@link readText}. */
|
|
53
|
+
async exists(path) {
|
|
54
|
+
try {
|
|
55
|
+
await this.readText(path);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (isNotFound(error))
|
|
60
|
+
return false;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Canonical path used as a key by external caches (e.g. snapshot
|
|
66
|
+
* stores). The default is identity; override to return an absolute or
|
|
67
|
+
* otherwise canonicalised path so producers and consumers of cached
|
|
68
|
+
* snapshots agree on the key without each having to redo the resolution.
|
|
69
|
+
*/
|
|
70
|
+
canonicalPath(path) {
|
|
71
|
+
return path;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as
|
|
76
|
+
* a building block for stacked adapters (e.g. an LRU layer on top).
|
|
77
|
+
*/
|
|
78
|
+
export class InMemoryFilesystem extends Filesystem {
|
|
79
|
+
#files = new Map();
|
|
80
|
+
constructor(initial) {
|
|
81
|
+
super();
|
|
82
|
+
if (initial) {
|
|
83
|
+
for (const [path, content] of initial)
|
|
84
|
+
this.#files.set(path, content);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async readText(path) {
|
|
88
|
+
const text = this.#files.get(path);
|
|
89
|
+
if (text === undefined)
|
|
90
|
+
throw new NotFoundError(path);
|
|
91
|
+
return text;
|
|
92
|
+
}
|
|
93
|
+
async writeText(path, content) {
|
|
94
|
+
this.#files.set(path, content);
|
|
95
|
+
return { text: content };
|
|
96
|
+
}
|
|
97
|
+
async exists(path) {
|
|
98
|
+
return this.#files.has(path);
|
|
99
|
+
}
|
|
100
|
+
/** Synchronous helper for setting up fixtures without awaiting. */
|
|
101
|
+
set(path, content) {
|
|
102
|
+
this.#files.set(path, content);
|
|
103
|
+
}
|
|
104
|
+
/** Synchronous helper for inspecting state without awaiting. */
|
|
105
|
+
get(path) {
|
|
106
|
+
return this.#files.get(path);
|
|
107
|
+
}
|
|
108
|
+
/** Remove a single entry. Returns true when something was removed. */
|
|
109
|
+
delete(path) {
|
|
110
|
+
return this.#files.delete(path);
|
|
111
|
+
}
|
|
112
|
+
/** Wipe all entries. */
|
|
113
|
+
clear() {
|
|
114
|
+
this.#files.clear();
|
|
115
|
+
}
|
|
116
|
+
/** Iterate `[path, content]` pairs. */
|
|
117
|
+
entries() {
|
|
118
|
+
return this.#files.entries();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI
|
|
123
|
+
* use. Paths are accepted as-is; callers responsible for any cwd or
|
|
124
|
+
* jail/sandbox resolution should wrap this with their own subclass.
|
|
125
|
+
*/
|
|
126
|
+
export class NodeFilesystem extends Filesystem {
|
|
127
|
+
async readText(path) {
|
|
128
|
+
if (!existsSync(path))
|
|
129
|
+
throw new NotFoundError(path);
|
|
130
|
+
return readFile(path, "utf8");
|
|
131
|
+
}
|
|
132
|
+
async writeText(path, content) {
|
|
133
|
+
await writeFile(path, content, "utf8");
|
|
134
|
+
return { text: content };
|
|
135
|
+
}
|
|
136
|
+
canonicalPath(path) {
|
|
137
|
+
return pathModule.resolve(path);
|
|
138
|
+
}
|
|
139
|
+
async exists(path) {
|
|
140
|
+
return existsSync(path);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/fs.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL,OAAO,EAAE,UAAU,EAAE,M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;IAED,uCAAuC;IACvC,OAAO;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC7C,KAAK,CAAC,QAAQ,CAAC,IAAY;QAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY,EAAE,OAAe;QAC5C,MAAM,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,IAAY;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;QACxB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACD","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).\nimport { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\n/**\n * Storage seam for the hashline patcher. {@link Filesystem} is intentionally\n * minimal — `readText`, `writeText`, `exists` — so any backing store can be\n * adapted: disk, memory, S3, an LSP text-document protocol, a Git tree, a\n * VFS, etc.\n *\n * The patcher does its own BOM stripping and LF normalization between\n * {@link Filesystem.readText} and {@link Filesystem.writeText}; the FS deals\n * only in raw text strings.\n */\nimport * as pathModule from \"node:path\";\n\n/**\n * Result returned by {@link Filesystem.writeText}. The patcher echoes back\n * `text` so adapters that transform on serialization (e.g. notebooks) can\n * report what actually landed on disk.\n */\nexport interface WriteResult {\n\t/** Final text that was persisted. May differ from the input if the FS transformed it. */\n\ttext: string;\n}\n\n/**\n * ENOENT-like error thrown by {@link Filesystem.readText} when a path is\n * missing. Carrying a `code` property keeps the contract compatible with\n * `node:fs` callers that already check `err.code === \"ENOENT\"`.\n */\nexport class NotFoundError extends Error {\n\treadonly code = \"ENOENT\";\n\n\tconstructor(path: string, cause?: unknown) {\n\t\tsuper(`File not found: ${path}`);\n\t\tthis.name = \"NotFoundError\";\n\t\tif (cause !== undefined) (this as Error & { cause?: unknown }).cause = cause;\n\t}\n}\n\n/** Type guard for {@link NotFoundError} and structurally-compatible errors. */\nexport function isNotFound(error: unknown): boolean {\n\tif (error instanceof NotFoundError) return true;\n\tif (error instanceof Error && (error as Error & { code?: string }).code === \"ENOENT\") return true;\n\treturn false;\n}\n\n/**\n * Abstract storage backend the {@link Patcher} reads from and writes to.\n * Subclass for new backends; the package ships {@link InMemoryFilesystem} and\n * {@link NodeFilesystem} for the most common cases.\n *\n * Implementations work with raw text — the patcher handles BOM stripping and\n * line-ending normalization itself. `readText` MUST throw {@link\n * NotFoundError} (or any error for which {@link isNotFound} returns true)\n * when the path doesn't exist; that's how the patcher detects a create-vs-\n * update.\n */\nexport abstract class Filesystem {\n\t/** Read the file's full text content. Throw on missing file. */\n\tabstract readText(path: string): Promise<string>;\n\n\t/** Validate that `path` is writable before a prepared batch starts committing. */\n\tasync preflightWrite(_path: string): Promise<void> {}\n\n\t/** Persist `content` at `path`. Returns the actual final text that was written. */\n\tabstract writeText(path: string, content: string): Promise<WriteResult>;\n\n\t/** Return true when the path exists and can be read. Default: probe via {@link readText}. */\n\tasync exists(path: string): Promise<boolean> {\n\t\ttry {\n\t\t\tawait this.readText(path);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif (isNotFound(error)) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Canonical path used as a key by external caches (e.g. snapshot\n\t * stores). The default is identity; override to return an absolute or\n\t * otherwise canonicalised path so producers and consumers of cached\n\t * snapshots agree on the key without each having to redo the resolution.\n\t */\n\tcanonicalPath(path: string): string {\n\t\treturn path;\n\t}\n}\n\n/**\n * In-memory {@link Filesystem}. Useful for tests, sandboxes, dry-runs, and as\n * a building block for stacked adapters (e.g. an LRU layer on top).\n */\nexport class InMemoryFilesystem extends Filesystem {\n\t#files = new Map<string, string>();\n\n\tconstructor(initial?: Iterable<readonly [string, string]>) {\n\t\tsuper();\n\t\tif (initial) {\n\t\t\tfor (const [path, content] of initial) this.#files.set(path, content);\n\t\t}\n\t}\n\n\tasync readText(path: string): Promise<string> {\n\t\tconst text = this.#files.get(path);\n\t\tif (text === undefined) throw new NotFoundError(path);\n\t\treturn text;\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tthis.#files.set(path, content);\n\t\treturn { text: content };\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn this.#files.has(path);\n\t}\n\n\t/** Synchronous helper for setting up fixtures without awaiting. */\n\tset(path: string, content: string): void {\n\t\tthis.#files.set(path, content);\n\t}\n\n\t/** Synchronous helper for inspecting state without awaiting. */\n\tget(path: string): string | undefined {\n\t\treturn this.#files.get(path);\n\t}\n\n\t/** Remove a single entry. Returns true when something was removed. */\n\tdelete(path: string): boolean {\n\t\treturn this.#files.delete(path);\n\t}\n\n\t/** Wipe all entries. */\n\tclear(): void {\n\t\tthis.#files.clear();\n\t}\n\n\t/** Iterate `[path, content]` pairs. */\n\tentries(): IterableIterator<[string, string]> {\n\t\treturn this.#files.entries();\n\t}\n}\n\n/**\n * Disk-backed {@link Filesystem} using Bun's file APIs. The default for CLI\n * use. Paths are accepted as-is; callers responsible for any cwd or\n * jail/sandbox resolution should wrap this with their own subclass.\n */\nexport class NodeFilesystem extends Filesystem {\n\tasync readText(path: string): Promise<string> {\n\t\tif (!existsSync(path)) throw new NotFoundError(path);\n\t\treturn readFile(path, \"utf8\");\n\t}\n\n\tasync writeText(path: string, content: string): Promise<WriteResult> {\n\t\tawait writeFile(path, content, \"utf8\");\n\t\treturn { text: content };\n\t}\n\n\tcanonicalPath(path: string): string {\n\t\treturn pathModule.resolve(path);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\treturn existsSync(path);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from "./apply.js";
|
|
2
|
+
export * from "./block.js";
|
|
3
|
+
export * from "./diff-preview.js";
|
|
4
|
+
export * from "./format.js";
|
|
5
|
+
export * from "./fs.js";
|
|
6
|
+
export * from "./input.js";
|
|
7
|
+
export * from "./messages.js";
|
|
8
|
+
export * from "./mismatch.js";
|
|
9
|
+
export * from "./normalize.js";
|
|
10
|
+
export * from "./parser.js";
|
|
11
|
+
export * from "./patcher.js";
|
|
12
|
+
export * from "./prefixes.js";
|
|
13
|
+
export * from "./recovery.js";
|
|
14
|
+
export * from "./snapshots.js";
|
|
15
|
+
export * from "./stream.js";
|
|
16
|
+
export * from "./tokenizer.js";
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,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).\nexport * from \"./apply.js\";\nexport * from \"./block.js\";\nexport * from \"./diff-preview.js\";\nexport * from \"./format.js\";\nexport * from \"./fs.js\";\nexport * from \"./input.js\";\nexport * from \"./messages.js\";\nexport * from \"./mismatch.js\";\nexport * from \"./normalize.js\";\nexport * from \"./parser.js\";\nexport * from \"./patcher.js\";\nexport * from \"./prefixes.js\";\nexport * from \"./recovery.js\";\nexport * from \"./snapshots.js\";\nexport * from \"./stream.js\";\nexport * from \"./tokenizer.js\";\nexport * from \"./types.js\";\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export * from "./apply.js";
|
|
4
|
+
export * from "./block.js";
|
|
5
|
+
export * from "./diff-preview.js";
|
|
6
|
+
export * from "./format.js";
|
|
7
|
+
export * from "./fs.js";
|
|
8
|
+
export * from "./input.js";
|
|
9
|
+
export * from "./messages.js";
|
|
10
|
+
export * from "./mismatch.js";
|
|
11
|
+
export * from "./normalize.js";
|
|
12
|
+
export * from "./parser.js";
|
|
13
|
+
export * from "./patcher.js";
|
|
14
|
+
export * from "./prefixes.js";
|
|
15
|
+
export * from "./recovery.js";
|
|
16
|
+
export * from "./snapshots.js";
|
|
17
|
+
export * from "./stream.js";
|
|
18
|
+
export * from "./tokenizer.js";
|
|
19
|
+
export * from "./types.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/tools/hashline-engine/index.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,iLAAiL;AACjL,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,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).\nexport * from \"./apply.js\";\nexport * from \"./block.js\";\nexport * from \"./diff-preview.js\";\nexport * from \"./format.js\";\nexport * from \"./fs.js\";\nexport * from \"./input.js\";\nexport * from \"./messages.js\";\nexport * from \"./mismatch.js\";\nexport * from \"./normalize.js\";\nexport * from \"./parser.js\";\nexport * from \"./patcher.js\";\nexport * from \"./prefixes.js\";\nexport * from \"./recovery.js\";\nexport * from \"./snapshots.js\";\nexport * from \"./stream.js\";\nexport * from \"./tokenizer.js\";\nexport * from \"./types.js\";\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ApplyResult, BlockResolver, Edit, SplitOptions } from "./types.js";
|
|
2
|
+
interface RawSection {
|
|
3
|
+
path: string;
|
|
4
|
+
fileHash?: string;
|
|
5
|
+
diff: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns true when the input contains at least one line that the tokenizer
|
|
9
|
+
* recognizes as a hashline op. Used by streaming previews to decide whether
|
|
10
|
+
* the partial input is worth treating as a hashline patch yet.
|
|
11
|
+
*/
|
|
12
|
+
export declare function containsRecognizableHashlineOperations(input: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Snapshot of one section in a parsed {@link Patch}: a target file plus the
|
|
15
|
+
* lazily-parsed list of edits that should land on it. Constructed by
|
|
16
|
+
* {@link Patch.parse}; consumers usually iterate `patch.sections` rather
|
|
17
|
+
* than build these directly.
|
|
18
|
+
*/
|
|
19
|
+
export declare class PatchSection {
|
|
20
|
+
#private;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly fileHash: string | undefined;
|
|
23
|
+
readonly diff: string;
|
|
24
|
+
constructor(raw: RawSection);
|
|
25
|
+
/**
|
|
26
|
+
* Parse this section's diff body. Cached: subsequent calls return the
|
|
27
|
+
* same `{ edits, warnings }` object so callers can safely call this from
|
|
28
|
+
* multiple paths (preflight, apply, diff-preview).
|
|
29
|
+
*/
|
|
30
|
+
parse(): {
|
|
31
|
+
edits: Edit[];
|
|
32
|
+
warnings: readonly string[];
|
|
33
|
+
};
|
|
34
|
+
/** Parsed edits for this section. */
|
|
35
|
+
get edits(): readonly Edit[];
|
|
36
|
+
/** Warnings emitted during parsing of this section. */
|
|
37
|
+
get warnings(): readonly string[];
|
|
38
|
+
/**
|
|
39
|
+
* True when at least one edit anchors to concrete file content. Pure
|
|
40
|
+
* `insert head:` / `insert tail:` literal inserts do not count: those are
|
|
41
|
+
* safe to apply to files that don't yet exist.
|
|
42
|
+
*/
|
|
43
|
+
get hasAnchorScopedEdit(): boolean;
|
|
44
|
+
/** Anchor lines touched by this section, sorted ascending and deduplicated. */
|
|
45
|
+
collectAnchorLines(): readonly number[];
|
|
46
|
+
/**
|
|
47
|
+
* Apply this section's edits to `text` and return the post-edit result.
|
|
48
|
+
* Pure: does no I/O, does not validate the section snapshot tag. The
|
|
49
|
+
* {@link Patcher} owns tag validation and recovery; reach for this
|
|
50
|
+
* method directly when you've already validated the file content and
|
|
51
|
+
* just want the result.
|
|
52
|
+
*
|
|
53
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
54
|
+
* unresolvable block throws (this is the final, authoritative preview path).
|
|
55
|
+
*/
|
|
56
|
+
applyTo(text: string, blockResolver?: BlockResolver): ApplyResult;
|
|
57
|
+
/**
|
|
58
|
+
* Streaming-tolerant counterpart to {@link applyTo}. Uses
|
|
59
|
+
* {@link parsePatchStreaming} so a trailing in-flight op (no payload yet,
|
|
60
|
+
* or a per-token parse error mid-stream) does not throw or emit a phantom
|
|
61
|
+
* empty-payload edit. Intended for incremental diff previews; the writer
|
|
62
|
+
* path should always use {@link applyTo}.
|
|
63
|
+
*
|
|
64
|
+
* `blockResolver` resolves any `replace block N:` edits against `text`; an
|
|
65
|
+
* unresolvable block is silently dropped so a half-written file does not
|
|
66
|
+
* throw mid-stream.
|
|
67
|
+
*/
|
|
68
|
+
applyPartialTo(text: string, blockResolver?: BlockResolver): ApplyResult;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A parsed hashline patch — zero or more {@link PatchSection}s, each rooted
|
|
72
|
+
* at a `[PATH#HASH]` header. Construct via {@link Patch.parse}.
|
|
73
|
+
*
|
|
74
|
+
* `Patch` is pure data: parsing is line-anchored and does not look at the
|
|
75
|
+
* filesystem. To apply a patch, hand it to {@link Patcher.apply}.
|
|
76
|
+
*/
|
|
77
|
+
export declare class Patch {
|
|
78
|
+
readonly sections: readonly PatchSection[];
|
|
79
|
+
private constructor();
|
|
80
|
+
/**
|
|
81
|
+
* Parse `input` into a {@link Patch}. `options.cwd` resolves absolute
|
|
82
|
+
* paths inside headers to cwd-relative form; `options.path` provides a
|
|
83
|
+
* fallback when the input lacks a header but contains hashline ops
|
|
84
|
+
* (useful for streaming previews).
|
|
85
|
+
*
|
|
86
|
+
* Consecutive sections targeting the same path are merged into a single
|
|
87
|
+
* section with concatenated diff bodies. Anchors authored against the
|
|
88
|
+
* same file snapshot must be applied as one batch; otherwise the first
|
|
89
|
+
* sub-edit shifts line numbers out from under the second's anchors and
|
|
90
|
+
* validation fails.
|
|
91
|
+
*/
|
|
92
|
+
static parse(input: string, options?: SplitOptions): Patch;
|
|
93
|
+
/**
|
|
94
|
+
* Parse `input` and return only the first section. Throws if the input
|
|
95
|
+
* has zero sections. Convenience for the single-section case where the
|
|
96
|
+
* caller already knows the patch is one hunk.
|
|
97
|
+
*/
|
|
98
|
+
static parseSingle(input: string, options?: SplitOptions): PatchSection;
|
|
99
|
+
}
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=input.d.ts.map
|