@xrkseek/harness 0.4.0-rc.4 → 0.4.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/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/checkpoint/README.md +88 -0
- package/node_modules/@xrkseek/checkpoint/dist/index.d.ts +5 -0
- package/node_modules/@xrkseek/checkpoint/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/index.js +5 -0
- package/node_modules/@xrkseek/checkpoint/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/json-file.d.ts +5 -0
- package/node_modules/@xrkseek/checkpoint/dist/json-file.d.ts.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/json-file.js +29 -0
- package/node_modules/@xrkseek/checkpoint/dist/json-file.js.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/process-git.d.ts +8 -0
- package/node_modules/@xrkseek/checkpoint/dist/process-git.d.ts.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/process-git.js +40 -0
- package/node_modules/@xrkseek/checkpoint/dist/process-git.js.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/store.d.ts +101 -0
- package/node_modules/@xrkseek/checkpoint/dist/store.d.ts.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/store.js +312 -0
- package/node_modules/@xrkseek/checkpoint/dist/store.js.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/types.d.ts +65 -0
- package/node_modules/@xrkseek/checkpoint/dist/types.d.ts.map +1 -0
- package/node_modules/@xrkseek/checkpoint/dist/types.js +18 -0
- package/node_modules/@xrkseek/checkpoint/dist/types.js.map +1 -0
- package/node_modules/@xrkseek/checkpoint/package.json +23 -0
- package/node_modules/@xrkseek/code-runtime/README.md +11 -4
- package/node_modules/@xrkseek/code-runtime/dist/index.d.ts +43 -3
- package/node_modules/@xrkseek/code-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/code-runtime/dist/index.js +209 -7
- package/node_modules/@xrkseek/code-runtime/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/context-fragments/README.md +28 -0
- package/node_modules/@xrkseek/context-fragments/dist/index.d.ts +104 -0
- package/node_modules/@xrkseek/context-fragments/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/context-fragments/dist/index.js +192 -0
- package/node_modules/@xrkseek/context-fragments/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/context-fragments/package.json +27 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js +7 -4
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/invariant.d.ts +11 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/invariant.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/invariant.js +21 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/invariant.js.map +1 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.d.ts +7 -5
- package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.js +24 -109
- package/node_modules/@xrkseek/core-agent-loop/dist/tool-result-bound.js.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/package.json +7 -0
- package/node_modules/@xrkseek/core-session/README.md +3 -1
- package/node_modules/@xrkseek/core-session/dist/invariant.d.ts +18 -0
- package/node_modules/@xrkseek/core-session/dist/invariant.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-session/dist/invariant.js +114 -0
- package/node_modules/@xrkseek/core-session/dist/invariant.js.map +1 -0
- package/node_modules/@xrkseek/core-session/dist/session-interchange.d.ts +2 -1
- package/node_modules/@xrkseek/core-session/dist/session-interchange.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/session-interchange.js +6 -1
- package/node_modules/@xrkseek/core-session/dist/session-interchange.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js +37 -23
- package/node_modules/@xrkseek/core-session/dist/sqlite-store.js.map +1 -1
- package/node_modules/@xrkseek/core-session/package.json +33 -26
- package/node_modules/@xrkseek/core-system-prompt/README.md +7 -7
- package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.js +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts +55 -3
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js +107 -11
- package/node_modules/@xrkseek/core-system-prompt/dist/three-layer.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/guards.d.ts +9 -1
- package/node_modules/@xrkseek/core-tools/dist/guards.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/guards.js +53 -9
- package/node_modules/@xrkseek/core-tools/dist/guards.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts +2 -1
- package/node_modules/@xrkseek/core-tools/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/index.js +2 -1
- package/node_modules/@xrkseek/core-tools/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.d.ts +5 -0
- package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.d.ts.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.js +12 -0
- package/node_modules/@xrkseek/core-tools/dist/session-query-prompt.js.map +1 -0
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +6 -2
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/README.md +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/format.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/format.js +7 -5
- package/node_modules/@xrkseek/exec-computer-use/dist/format.js.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/index.d.ts +14 -3
- package/node_modules/@xrkseek/exec-computer-use/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/index.js +22 -8
- package/node_modules/@xrkseek/exec-computer-use/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/keys.d.ts +10 -0
- package/node_modules/@xrkseek/exec-computer-use/dist/keys.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-computer-use/dist/keys.js +89 -0
- package/node_modules/@xrkseek/exec-computer-use/dist/keys.js.map +1 -0
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.d.ts +3 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.js +12 -8
- package/node_modules/@xrkseek/exec-computer-use/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.js +138 -2
- package/node_modules/@xrkseek/exec-computer-use/dist/windows-uia.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/README.md +12 -9
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.d.ts +32 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.js +203 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-apply.js.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.d.ts +52 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.js +260 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch-parser.js.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch.d.ts +27 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch.js +69 -0
- package/node_modules/@xrkseek/exec-fs/dist/apply-patch.js.map +1 -0
- package/node_modules/@xrkseek/exec-fs/dist/index.d.ts +6 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/index.js +72 -3
- package/node_modules/@xrkseek/exec-fs/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/present.d.ts +4 -0
- package/node_modules/@xrkseek/exec-fs/dist/present.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/present.js +25 -0
- package/node_modules/@xrkseek/exec-fs/dist/present.js.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.d.ts +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.js +10 -6
- package/node_modules/@xrkseek/exec-fs/dist/routing-prompt.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts +15 -2
- package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/index.js +14 -7
- package/node_modules/@xrkseek/exec-image-gen/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.d.ts +6 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.js +14 -8
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/README.md +5 -3
- package/node_modules/@xrkseek/exec-memory/dist/http.d.ts +42 -0
- package/node_modules/@xrkseek/exec-memory/dist/http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/http.js +232 -0
- package/node_modules/@xrkseek/exec-memory/dist/http.js.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/index.d.ts +5 -2
- package/node_modules/@xrkseek/exec-memory/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/index.js +3 -1
- package/node_modules/@xrkseek/exec-memory/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/provider.d.ts +19 -0
- package/node_modules/@xrkseek/exec-memory/dist/provider.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/provider.js +8 -0
- package/node_modules/@xrkseek/exec-memory/dist/provider.js.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/resolve.d.ts +25 -0
- package/node_modules/@xrkseek/exec-memory/dist/resolve.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/resolve.js +46 -0
- package/node_modules/@xrkseek/exec-memory/dist/resolve.js.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/store.d.ts +8 -4
- package/node_modules/@xrkseek/exec-memory/dist/store.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/store.js +6 -0
- package/node_modules/@xrkseek/exec-memory/dist/store.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.js +12 -9
- package/node_modules/@xrkseek/exec-memory/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/write-path.d.ts +17 -6
- package/node_modules/@xrkseek/exec-memory/dist/write-path.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/write-path.js +81 -20
- package/node_modules/@xrkseek/exec-memory/dist/write-path.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/package.json +1 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/doctor.d.ts +24 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/doctor.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/doctor.js +118 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/doctor.js.map +1 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/hardline.d.ts +24 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/hardline.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/hardline.js +93 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/hardline.js.map +1 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/index.d.ts +3 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/index.js +3 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/resolve.d.ts +17 -0
- package/node_modules/@xrkseek/exec-sandbox/dist/resolve.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/resolve.js +47 -5
- package/node_modules/@xrkseek/exec-sandbox/dist/resolve.js.map +1 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/service.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-sandbox/dist/service.js +2 -5
- package/node_modules/@xrkseek/exec-sandbox/dist/service.js.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/README.md +16 -16
- package/node_modules/@xrkseek/exec-ssh/dist/config.d.ts +10 -0
- package/node_modules/@xrkseek/exec-ssh/dist/config.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/config.js +50 -0
- package/node_modules/@xrkseek/exec-ssh/dist/config.js.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/fs.d.ts +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/fs.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/fs.js +18 -1
- package/node_modules/@xrkseek/exec-ssh/dist/fs.js.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/index.js +1 -1
- package/node_modules/@xrkseek/exec-ssh/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts +15 -2
- package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/index.js +14 -9
- package/node_modules/@xrkseek/exec-video-gen/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.d.ts +6 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.js +14 -10
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-voice/README.md +25 -25
- package/node_modules/@xrkseek/exec-voice/dist/index.d.ts +16 -3
- package/node_modules/@xrkseek/exec-voice/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/index.js +14 -8
- package/node_modules/@xrkseek/exec-voice/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts +26 -0
- package/node_modules/@xrkseek/exec-voice/dist/readiness.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-voice/dist/readiness.js +69 -0
- package/node_modules/@xrkseek/exec-voice/dist/readiness.js.map +1 -0
- package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts +4 -1
- package/node_modules/@xrkseek/exec-voice/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-voice/dist/tools.js +3 -14
- package/node_modules/@xrkseek/exec-voice/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/README.md +11 -11
- package/node_modules/@xrkseek/exec-web/dist/browser-cdp.d.ts +22 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-cdp.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-cdp.js +32 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-cdp.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.d.ts +21 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.js +52 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-runtime-registry.js.map +1 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-session.d.ts +2 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-session.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-session.js +3 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-session.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.d.ts +9 -0
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.js +34 -15
- package/node_modules/@xrkseek/exec-web/dist/browser-tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/fetch-http.d.ts +7 -0
- package/node_modules/@xrkseek/exec-web/dist/fetch-http.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/fetch-http.js +8 -2
- package/node_modules/@xrkseek/exec-web/dist/fetch-http.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/format.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/format.js +4 -3
- package/node_modules/@xrkseek/exec-web/dist/format.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/index.d.ts +4 -2
- package/node_modules/@xrkseek/exec-web/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/index.js +8 -3
- package/node_modules/@xrkseek/exec-web/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.d.ts +46 -0
- package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.js +144 -0
- package/node_modules/@xrkseek/exec-web/dist/outbound-allowlist.js.map +1 -0
- package/node_modules/@xrkseek/exec-web/dist/url-policy.d.ts +6 -1
- package/node_modules/@xrkseek/exec-web/dist/url-policy.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-web/dist/url-policy.js +5 -2
- package/node_modules/@xrkseek/exec-web/dist/url-policy.js.map +1 -1
- package/node_modules/@xrkseek/im-gateway-contract/README.md +50 -0
- package/node_modules/@xrkseek/im-gateway-contract/dist/index.d.ts +77 -0
- package/node_modules/@xrkseek/im-gateway-contract/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/im-gateway-contract/dist/index.js +120 -0
- package/node_modules/@xrkseek/im-gateway-contract/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/im-gateway-contract/examples/mock-sidecar.mjs +124 -0
- package/node_modules/@xrkseek/im-gateway-contract/package.json +25 -0
- package/node_modules/@xrkseek/mcp/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/mcp/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/index.js +1 -0
- package/node_modules/@xrkseek/mcp/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/mcp/dist/oauth-product.d.ts +31 -0
- package/node_modules/@xrkseek/mcp/dist/oauth-product.d.ts.map +1 -0
- package/node_modules/@xrkseek/mcp/dist/oauth-product.js +72 -0
- package/node_modules/@xrkseek/mcp/dist/oauth-product.js.map +1 -0
- package/node_modules/@xrkseek/policy/README.md +18 -15
- package/node_modules/@xrkseek/policy/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/policy/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/policy/dist/index.js +1 -0
- package/node_modules/@xrkseek/policy/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/policy/dist/permission-pre.d.ts.map +1 -1
- package/node_modules/@xrkseek/policy/dist/permission-pre.js +1 -0
- package/node_modules/@xrkseek/policy/dist/permission-pre.js.map +1 -1
- package/node_modules/@xrkseek/policy/dist/security-guidance.d.ts +50 -0
- package/node_modules/@xrkseek/policy/dist/security-guidance.d.ts.map +1 -0
- package/node_modules/@xrkseek/policy/dist/security-guidance.js +262 -0
- package/node_modules/@xrkseek/policy/dist/security-guidance.js.map +1 -0
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts +81 -7
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +307 -63
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-harness/package.json +53 -52
- package/node_modules/@xrkseek/preset-minimal/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/preset.js +7 -2
- package/node_modules/@xrkseek/preset-minimal/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js +19 -1
- package/node_modules/@xrkseek/preset-server/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/protocol/dist/json-schema.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/json-schema.js +3 -0
- package/node_modules/@xrkseek/protocol/dist/json-schema.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/session-events.d.ts +18 -0
- package/node_modules/@xrkseek/protocol/dist/session-events.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/session-events.js.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/validate.d.ts.map +1 -1
- package/node_modules/@xrkseek/protocol/dist/validate.js +30 -0
- package/node_modules/@xrkseek/protocol/dist/validate.js.map +1 -1
- package/node_modules/@xrkseek/runtime-invariants/README.md +28 -0
- package/node_modules/@xrkseek/runtime-invariants/dist/index.d.ts +94 -0
- package/node_modules/@xrkseek/runtime-invariants/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/runtime-invariants/dist/index.js +163 -0
- package/node_modules/@xrkseek/runtime-invariants/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/runtime-invariants/package.json +27 -0
- package/node_modules/@xrkseek/secrets/README.md +28 -0
- package/node_modules/@xrkseek/secrets/dist/index.d.ts +11 -0
- package/node_modules/@xrkseek/secrets/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/index.js +23 -0
- package/node_modules/@xrkseek/secrets/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/keyring.d.ts +10 -0
- package/node_modules/@xrkseek/secrets/dist/keyring.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/keyring.js +77 -0
- package/node_modules/@xrkseek/secrets/dist/keyring.js.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/memory.d.ts +4 -0
- package/node_modules/@xrkseek/secrets/dist/memory.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/memory.js +21 -0
- package/node_modules/@xrkseek/secrets/dist/memory.js.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/redact.d.ts +23 -0
- package/node_modules/@xrkseek/secrets/dist/redact.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/redact.js +38 -0
- package/node_modules/@xrkseek/secrets/dist/redact.js.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/resolve.d.ts +10 -0
- package/node_modules/@xrkseek/secrets/dist/resolve.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/resolve.js +24 -0
- package/node_modules/@xrkseek/secrets/dist/resolve.js.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/types.d.ts +27 -0
- package/node_modules/@xrkseek/secrets/dist/types.d.ts.map +1 -0
- package/node_modules/@xrkseek/secrets/dist/types.js +15 -0
- package/node_modules/@xrkseek/secrets/dist/types.js.map +1 -0
- package/node_modules/@xrkseek/secrets/package.json +29 -0
- package/node_modules/@xrkseek/server-config/dist/index.d.ts +6 -0
- package/node_modules/@xrkseek/server-config/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-config/dist/index.js +12 -0
- package/node_modules/@xrkseek/server-config/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-cron/README.md +1 -1
- package/node_modules/@xrkseek/server-cron/dist/index.d.ts +10 -1
- package/node_modules/@xrkseek/server-cron/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-cron/dist/index.js +9 -2
- package/node_modules/@xrkseek/server-cron/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js +6 -2
- package/node_modules/@xrkseek/server-face/dist/adapt/wire-event.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/agent-team-output.d.ts +34 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-output.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-output.js +140 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-output.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts +13 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-roles.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js +67 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-roles.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.d.ts +79 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.js +230 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-tasks.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/approval-category.d.ts +25 -0
- package/node_modules/@xrkseek/server-face/dist/approval-category.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/approval-category.js +108 -0
- package/node_modules/@xrkseek/server-face/dist/approval-category.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/approvals.d.ts +17 -0
- package/node_modules/@xrkseek/server-face/dist/approvals.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/approvals.js +50 -0
- package/node_modules/@xrkseek/server-face/dist/approvals.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/context.d.ts +22 -0
- package/node_modules/@xrkseek/server-face/dist/context.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/cost-meter-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/cost-meter-store.js +22 -0
- package/node_modules/@xrkseek/server-face/dist/cost-meter-store.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/dispatch.js +14 -2
- package/node_modules/@xrkseek/server-face/dist/dispatch.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.d.ts +87 -2
- package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.js +456 -32
- package/node_modules/@xrkseek/server-face/dist/external-agent-runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-round-driver.d.ts +48 -0
- package/node_modules/@xrkseek/server-face/dist/goal-round-driver.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/goal-round-driver.js +69 -0
- package/node_modules/@xrkseek/server-face/dist/goal-round-driver.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts +6 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-store.js +45 -9
- package/node_modules/@xrkseek/server-face/dist/goal-store.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/goal-tools.d.ts +13 -0
- package/node_modules/@xrkseek/server-face/dist/goal-tools.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/goal-tools.js +131 -0
- package/node_modules/@xrkseek/server-face/dist/goal-tools.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.d.ts +10 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.js +156 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/checkpoint.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts +7 -0
- package/node_modules/@xrkseek/server-face/dist/handlers/session.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js +88 -2
- package/node_modules/@xrkseek/server-face/dist/handlers/session.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/subagent.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/handlers/subagent.js +62 -3
- package/node_modules/@xrkseek/server-face/dist/handlers/subagent.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +19 -5
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js +18 -4
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/managed-worktree.d.ts +115 -0
- package/node_modules/@xrkseek/server-face/dist/managed-worktree.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/managed-worktree.js +330 -0
- package/node_modules/@xrkseek/server-face/dist/managed-worktree.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.d.ts +33 -0
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js +352 -0
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.d.ts +15 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.js +26 -2
- package/node_modules/@xrkseek/server-face/dist/projections/units/context-timeline.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/propose-skill.d.ts +20 -0
- package/node_modules/@xrkseek/server-face/dist/propose-skill.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/propose-skill.js +65 -0
- package/node_modules/@xrkseek/server-face/dist/propose-skill.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts +33 -0
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.js +366 -0
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/reference-discovery.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/reference-discovery.js +1 -0
- package/node_modules/@xrkseek/server-face/dist/reference-discovery.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/rollout-trace.d.ts +58 -0
- package/node_modules/@xrkseek/server-face/dist/rollout-trace.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/rollout-trace.js +194 -0
- package/node_modules/@xrkseek/server-face/dist/rollout-trace.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts +7 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.js +93 -4
- package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-export.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-export.js +74 -0
- package/node_modules/@xrkseek/server-face/dist/session-export.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-query-tools.d.ts +23 -0
- package/node_modules/@xrkseek/server-face/dist/session-query-tools.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/session-query-tools.js +275 -0
- package/node_modules/@xrkseek/server-face/dist/session-query-tools.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts +209 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.js +559 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts +2 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js +67 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts +5 -0
- package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-document.js +69 -0
- package/node_modules/@xrkseek/server-face/dist/settings-document.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +220 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/slash.js +70 -16
- package/node_modules/@xrkseek/server-face/dist/slash.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-registry.d.ts +4 -0
- package/node_modules/@xrkseek/server-face/dist/subagent-registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-registry.js +4 -0
- package/node_modules/@xrkseek/server-face/dist/subagent-registry.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts +14 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +614 -62
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-worktree.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-worktree.js +7 -2
- package/node_modules/@xrkseek/server-face/dist/subagent-worktree.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/types.d.ts +4 -0
- package/node_modules/@xrkseek/server-face/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js +11 -0
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.d.ts +40 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.js +154 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-checkpoint.js.map +1 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts +1 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-face.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-face.js +25 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-face.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts +11 -0
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.js +14 -4
- package/node_modules/@xrkseek/server-face/dist/workspace-registry.js.map +1 -1
- package/node_modules/@xrkseek/server-face/package.json +3 -0
- package/node_modules/@xrkseek/server-host/dist/index.d.ts +61 -0
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +376 -10
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.d.ts +16 -0
- package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.js +24 -0
- package/node_modules/@xrkseek/server-host/dist/invariants-fail-fast.js.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/standing-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js +4 -1
- package/node_modules/@xrkseek/server-host/dist/standing-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-host/package.json +10 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js +10 -4
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-providers.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts +17 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/adapter-types.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts +8 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js +20 -5
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-classifier.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/auto-review-http.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js +2 -2
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/dsh-compat-matrix.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.d.ts +5 -17
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.js +50 -49
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/im-gateway-sidecar.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.d.ts +14 -4
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.js +30 -14
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/memory-embeddings.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.d.ts +3 -0
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js +5 -5
- package/node_modules/@xrkseek/server-http/dist/dsh-compat/noema.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts +5 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js +1 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js.map +1 -1
- package/node_modules/@xrkseek/server-http/package.json +1 -0
- package/node_modules/@xrkseek/server-loader/dist/index.d.ts +1 -1
- package/node_modules/@xrkseek/server-loader/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-loader/dist/index.js +1 -1
- package/node_modules/@xrkseek/server-loader/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-loader/dist/shell-hooks.d.ts +75 -3
- package/node_modules/@xrkseek/server-loader/dist/shell-hooks.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-loader/dist/shell-hooks.js +415 -46
- package/node_modules/@xrkseek/server-loader/dist/shell-hooks.js.map +1 -1
- package/node_modules/@xrkseek/session-format/README.md +20 -0
- package/node_modules/@xrkseek/session-format/dist/catalog.d.ts +27 -0
- package/node_modules/@xrkseek/session-format/dist/catalog.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/catalog.js +36 -0
- package/node_modules/@xrkseek/session-format/dist/catalog.js.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/chain.d.ts +38 -0
- package/node_modules/@xrkseek/session-format/dist/chain.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/chain.js +86 -0
- package/node_modules/@xrkseek/session-format/dist/chain.js.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/detect.d.ts +29 -0
- package/node_modules/@xrkseek/session-format/dist/detect.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/detect.js +68 -0
- package/node_modules/@xrkseek/session-format/dist/detect.js.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/index.d.ts +12 -0
- package/node_modules/@xrkseek/session-format/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/index.js +12 -0
- package/node_modules/@xrkseek/session-format/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/interchange-version.d.ts +6 -0
- package/node_modules/@xrkseek/session-format/dist/interchange-version.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/interchange-version.js +6 -0
- package/node_modules/@xrkseek/session-format/dist/interchange-version.js.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/sqlite-schema.d.ts +31 -0
- package/node_modules/@xrkseek/session-format/dist/sqlite-schema.d.ts.map +1 -0
- package/node_modules/@xrkseek/session-format/dist/sqlite-schema.js +52 -0
- package/node_modules/@xrkseek/session-format/dist/sqlite-schema.js.map +1 -0
- package/node_modules/@xrkseek/session-format/package.json +24 -0
- package/node_modules/@xrkseek/session-telemetry/dist/index.d.ts +18 -4
- package/node_modules/@xrkseek/session-telemetry/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/session-telemetry/dist/index.js +97 -36
- package/node_modules/@xrkseek/session-telemetry/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/spill/README.md +27 -0
- package/node_modules/@xrkseek/spill/dist/index.d.ts +11 -0
- package/node_modules/@xrkseek/spill/dist/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/spill/dist/index.js +11 -0
- package/node_modules/@xrkseek/spill/dist/index.js.map +1 -0
- package/node_modules/@xrkseek/spill/dist/local-store.d.ts +30 -0
- package/node_modules/@xrkseek/spill/dist/local-store.d.ts.map +1 -0
- package/node_modules/@xrkseek/spill/dist/local-store.js +73 -0
- package/node_modules/@xrkseek/spill/dist/local-store.js.map +1 -0
- package/node_modules/@xrkseek/spill/dist/policy.d.ts +59 -0
- package/node_modules/@xrkseek/spill/dist/policy.d.ts.map +1 -0
- package/node_modules/@xrkseek/spill/dist/policy.js +143 -0
- package/node_modules/@xrkseek/spill/dist/policy.js.map +1 -0
- package/node_modules/@xrkseek/spill/dist/types.d.ts +46 -0
- package/node_modules/@xrkseek/spill/dist/types.d.ts.map +1 -0
- package/node_modules/@xrkseek/spill/dist/types.js +8 -0
- package/node_modules/@xrkseek/spill/dist/types.js.map +1 -0
- package/node_modules/@xrkseek/spill/package.json +27 -0
- package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.js +2 -0
- package/node_modules/@xrkseek/workspace/dist/ecosystem-instructions.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/workspace/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/index.js +1 -0
- package/node_modules/@xrkseek/workspace/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/workspace/dist/skill-propose.d.ts +71 -0
- package/node_modules/@xrkseek/workspace/dist/skill-propose.d.ts.map +1 -0
- package/node_modules/@xrkseek/workspace/dist/skill-propose.js +259 -0
- package/node_modules/@xrkseek/workspace/dist/skill-propose.js.map +1 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/README.md +46 -45
- package/node_modules/@xrkseek/xrk-file-reference-local/README.zh.md +46 -45
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.d.ts +37 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.d.ts.map +1 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.js +91 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/gitignore.js.map +1 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts +7 -0
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.d.ts.map +1 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js +46 -4
- package/node_modules/@xrkseek/xrk-file-reference-local/dist/search.js.map +1 -1
- package/node_modules/@xrkseek/xrk-file-reference-local/package.json +30 -29
- package/node_modules/ignore/LICENSE-MIT +21 -0
- package/node_modules/ignore/README.md +452 -0
- package/node_modules/ignore/index.d.ts +81 -0
- package/node_modules/ignore/index.js +793 -0
- package/node_modules/ignore/legacy.js +690 -0
- package/node_modules/ignore/package.json +87 -0
- package/package.json +17 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply parsed Codex-style hunks onto LF-normalized file text (seek_sequence).
|
|
3
|
+
*/
|
|
4
|
+
import { detectLineEndings, normalizeLineEndings, restoreLineEndings, } from "./edit-text.js";
|
|
5
|
+
export class ApplyPatchError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "ApplyPatchError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function normaliseUnicode(s) {
|
|
12
|
+
return s
|
|
13
|
+
.trim()
|
|
14
|
+
.split("")
|
|
15
|
+
.map((c) => {
|
|
16
|
+
const code = c.codePointAt(0) ?? 0;
|
|
17
|
+
if (code === 0x2010 ||
|
|
18
|
+
code === 0x2011 ||
|
|
19
|
+
code === 0x2012 ||
|
|
20
|
+
code === 0x2013 ||
|
|
21
|
+
code === 0x2014 ||
|
|
22
|
+
code === 0x2015 ||
|
|
23
|
+
code === 0x2212) {
|
|
24
|
+
return "-";
|
|
25
|
+
}
|
|
26
|
+
if (code === 0x2018 || code === 0x2019 || code === 0x201a || code === 0x201b) {
|
|
27
|
+
return "'";
|
|
28
|
+
}
|
|
29
|
+
if (code === 0x201c || code === 0x201d || code === 0x201e || code === 0x201f) {
|
|
30
|
+
return '"';
|
|
31
|
+
}
|
|
32
|
+
if (code === 0x00a0 ||
|
|
33
|
+
(code >= 0x2002 && code <= 0x200a) ||
|
|
34
|
+
code === 0x202f ||
|
|
35
|
+
code === 0x205f ||
|
|
36
|
+
code === 0x3000) {
|
|
37
|
+
return " ";
|
|
38
|
+
}
|
|
39
|
+
return c;
|
|
40
|
+
})
|
|
41
|
+
.join("");
|
|
42
|
+
}
|
|
43
|
+
/** Locate `pattern` in `lines` at/after `start` (Codex seek_sequence). */
|
|
44
|
+
export function seekSequence(lines, pattern, start, eof) {
|
|
45
|
+
if (pattern.length === 0)
|
|
46
|
+
return start;
|
|
47
|
+
if (pattern.length > lines.length)
|
|
48
|
+
return undefined;
|
|
49
|
+
const searchStart = eof && lines.length >= pattern.length
|
|
50
|
+
? Math.max(start, lines.length - pattern.length)
|
|
51
|
+
: start;
|
|
52
|
+
const passes = [
|
|
53
|
+
(a, b) => a === b,
|
|
54
|
+
(a, b) => a.trimEnd() === b.trimEnd(),
|
|
55
|
+
(a, b) => a.trim() === b.trim(),
|
|
56
|
+
(a, b) => normaliseUnicode(a) === normaliseUnicode(b),
|
|
57
|
+
];
|
|
58
|
+
for (const eq of passes) {
|
|
59
|
+
for (let i = searchStart; i <= lines.length - pattern.length; i += 1) {
|
|
60
|
+
let ok = true;
|
|
61
|
+
for (let p = 0; p < pattern.length; p += 1) {
|
|
62
|
+
if (!eq(lines[i + p], pattern[p])) {
|
|
63
|
+
ok = false;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (ok)
|
|
68
|
+
return i;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
function splitLfLines(content) {
|
|
74
|
+
const lines = content.split("\n");
|
|
75
|
+
if (lines.length > 0 && lines[lines.length - 1] === "") {
|
|
76
|
+
lines.pop();
|
|
77
|
+
}
|
|
78
|
+
return lines;
|
|
79
|
+
}
|
|
80
|
+
function computeReplacements(originalLines, path, chunks) {
|
|
81
|
+
const replacements = [];
|
|
82
|
+
let lineIndex = 0;
|
|
83
|
+
for (const chunk of chunks) {
|
|
84
|
+
if (chunk.changeContext !== undefined) {
|
|
85
|
+
const idx = seekSequence(originalLines, [chunk.changeContext], lineIndex, false);
|
|
86
|
+
if (idx === undefined) {
|
|
87
|
+
throw new ApplyPatchError(`Failed to find context '${chunk.changeContext}' in ${path}`);
|
|
88
|
+
}
|
|
89
|
+
lineIndex = idx + 1;
|
|
90
|
+
}
|
|
91
|
+
if (chunk.oldLines.length === 0) {
|
|
92
|
+
const insertionIdx = originalLines.length;
|
|
93
|
+
replacements.push([insertionIdx, 0, [...chunk.newLines]]);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
let pattern = chunk.oldLines;
|
|
97
|
+
let newSlice = chunk.newLines;
|
|
98
|
+
let found = seekSequence(originalLines, pattern, lineIndex, chunk.isEndOfFile);
|
|
99
|
+
if (found === undefined &&
|
|
100
|
+
pattern.length > 0 &&
|
|
101
|
+
pattern[pattern.length - 1] === "") {
|
|
102
|
+
pattern = pattern.slice(0, -1);
|
|
103
|
+
if (newSlice.length > 0 && newSlice[newSlice.length - 1] === "") {
|
|
104
|
+
newSlice = newSlice.slice(0, -1);
|
|
105
|
+
}
|
|
106
|
+
found = seekSequence(originalLines, pattern, lineIndex, chunk.isEndOfFile);
|
|
107
|
+
}
|
|
108
|
+
if (found === undefined) {
|
|
109
|
+
throw new ApplyPatchError(`Failed to find expected lines in ${path}:\n${chunk.oldLines.join("\n")}`);
|
|
110
|
+
}
|
|
111
|
+
replacements.push([found, pattern.length, [...newSlice]]);
|
|
112
|
+
lineIndex = found + pattern.length;
|
|
113
|
+
}
|
|
114
|
+
replacements.sort((a, b) => a[0] - b[0]);
|
|
115
|
+
return replacements;
|
|
116
|
+
}
|
|
117
|
+
function applyReplacements(lines, replacements) {
|
|
118
|
+
const next = [...lines];
|
|
119
|
+
for (const [startIdx, oldLen, newSegment] of [...replacements].reverse()) {
|
|
120
|
+
for (let i = 0; i < oldLen; i += 1) {
|
|
121
|
+
if (startIdx < next.length)
|
|
122
|
+
next.splice(startIdx, 1);
|
|
123
|
+
}
|
|
124
|
+
for (let offset = 0; offset < newSegment.length; offset += 1) {
|
|
125
|
+
next.splice(startIdx + offset, 0, newSegment[offset]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return next;
|
|
129
|
+
}
|
|
130
|
+
/** Derive new file body (LF + trailing newline) from update chunks. */
|
|
131
|
+
export function deriveUpdatedContents(originalRaw, path, chunks) {
|
|
132
|
+
const endings = detectLineEndings(originalRaw);
|
|
133
|
+
const originalLf = normalizeLineEndings(originalRaw);
|
|
134
|
+
const originalLines = splitLfLines(originalLf);
|
|
135
|
+
const replacements = computeReplacements(originalLines, path, chunks);
|
|
136
|
+
const newLines = applyReplacements(originalLines, replacements);
|
|
137
|
+
if (newLines.length === 0 || newLines[newLines.length - 1] !== "") {
|
|
138
|
+
newLines.push("");
|
|
139
|
+
}
|
|
140
|
+
const nextLf = newLines.join("\n");
|
|
141
|
+
return {
|
|
142
|
+
original: originalRaw,
|
|
143
|
+
next: restoreLineEndings(nextLf, endings),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Pure planning step: compute all writes/deletes from hunks + current file map.
|
|
148
|
+
* `readFile` returns raw UTF-8 or `undefined` when missing.
|
|
149
|
+
*/
|
|
150
|
+
export function planPatchApplication(hunks, readFile) {
|
|
151
|
+
const writes = new Map();
|
|
152
|
+
const deletes = [];
|
|
153
|
+
const ops = [];
|
|
154
|
+
for (const hunk of hunks) {
|
|
155
|
+
if (hunk.kind === "add") {
|
|
156
|
+
if (readFile(hunk.path) !== undefined || writes.has(hunk.path)) {
|
|
157
|
+
throw new ApplyPatchError(`Add File failed: ${hunk.path} already exists`);
|
|
158
|
+
}
|
|
159
|
+
writes.set(hunk.path, hunk.contents);
|
|
160
|
+
ops.push({ action: "add", path: hunk.path });
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (hunk.kind === "delete") {
|
|
164
|
+
if (readFile(hunk.path) === undefined && !writes.has(hunk.path)) {
|
|
165
|
+
throw new ApplyPatchError(`Delete File failed: ${hunk.path} not found`);
|
|
166
|
+
}
|
|
167
|
+
writes.delete(hunk.path);
|
|
168
|
+
deletes.push(hunk.path);
|
|
169
|
+
ops.push({ action: "delete", path: hunk.path });
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const raw = writes.get(hunk.path) ?? readFile(hunk.path);
|
|
173
|
+
if (raw === undefined) {
|
|
174
|
+
throw new ApplyPatchError(`Update File failed: ${hunk.path} not found`);
|
|
175
|
+
}
|
|
176
|
+
if (hunk.chunks.length === 0 && !hunk.movePath) {
|
|
177
|
+
throw new ApplyPatchError(`Update file hunk for path '${hunk.path}' is empty`);
|
|
178
|
+
}
|
|
179
|
+
const updated = hunk.chunks.length === 0
|
|
180
|
+
? raw
|
|
181
|
+
: deriveUpdatedContents(raw, hunk.path, hunk.chunks).next;
|
|
182
|
+
const dest = hunk.movePath ?? hunk.path;
|
|
183
|
+
if (hunk.movePath) {
|
|
184
|
+
if (readFile(hunk.movePath) !== undefined || writes.has(hunk.movePath)) {
|
|
185
|
+
throw new ApplyPatchError(`Move failed: destination ${hunk.movePath} already exists`);
|
|
186
|
+
}
|
|
187
|
+
writes.delete(hunk.path);
|
|
188
|
+
deletes.push(hunk.path);
|
|
189
|
+
writes.set(hunk.movePath, updated);
|
|
190
|
+
ops.push({
|
|
191
|
+
action: "move",
|
|
192
|
+
path: hunk.movePath,
|
|
193
|
+
fromPath: hunk.path,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
writes.set(dest, updated);
|
|
198
|
+
ops.push({ action: "update", path: dest });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { ops, writes, deletes };
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=apply-patch-apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch-apply.js","sourceRoot":"","sources":["../src/apply-patch-apply.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAID,SAAS,gBAAgB,CAAC,CAAS;IACjC,OAAO,CAAC;SACL,IAAI,EAAE;SACN,KAAK,CAAC,EAAE,CAAC;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACnC,IACE,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM;YACf,IAAI,KAAK,MAAM,EACf,CAAC;YACD,OAAO,GA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AAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex apply_patch grammar (portable subset).
|
|
3
|
+
* Markers: Begin/End Patch · Add/Delete/Update File · Move to · @@ · End of File.
|
|
4
|
+
*/
|
|
5
|
+
export declare const BEGIN_PATCH_MARKER = "*** Begin Patch";
|
|
6
|
+
export declare const END_PATCH_MARKER = "*** End Patch";
|
|
7
|
+
export declare const ADD_FILE_MARKER = "*** Add File: ";
|
|
8
|
+
export declare const DELETE_FILE_MARKER = "*** Delete File: ";
|
|
9
|
+
export declare const UPDATE_FILE_MARKER = "*** Update File: ";
|
|
10
|
+
export declare const MOVE_TO_MARKER = "*** Move to: ";
|
|
11
|
+
export declare const EOF_MARKER = "*** End of File";
|
|
12
|
+
export declare const CHANGE_CONTEXT_MARKER = "@@ ";
|
|
13
|
+
export declare const EMPTY_CHANGE_CONTEXT_MARKER = "@@";
|
|
14
|
+
export declare class PatchParseError extends Error {
|
|
15
|
+
readonly lineNumber?: number;
|
|
16
|
+
constructor(message: string, lineNumber?: number);
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateFileChunk {
|
|
19
|
+
readonly changeContext?: string;
|
|
20
|
+
readonly oldLines: string[];
|
|
21
|
+
readonly newLines: string[];
|
|
22
|
+
/** Pairs of indices into old/new that were explicit context (` ` lines). */
|
|
23
|
+
readonly contextLineIndices: ReadonlyArray<readonly [number, number]>;
|
|
24
|
+
readonly isEndOfFile: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type PatchHunk = {
|
|
27
|
+
readonly kind: "add";
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly contents: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "delete";
|
|
32
|
+
readonly path: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "update";
|
|
35
|
+
readonly path: string;
|
|
36
|
+
readonly movePath?: string;
|
|
37
|
+
readonly chunks: readonly UpdateFileChunk[];
|
|
38
|
+
};
|
|
39
|
+
export interface ParsedPatch {
|
|
40
|
+
readonly hunks: readonly PatchHunk[];
|
|
41
|
+
readonly patch: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse a full `*** Begin Patch` … `*** End Patch` document into hunks.
|
|
45
|
+
* Lenient: trims marker lines; strips a trivial `<<EOF` heredoc wrapper.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parsePatch(raw: string): ParsedPatch;
|
|
48
|
+
/** Paths that already exist on disk and must be observed (write-intent). */
|
|
49
|
+
export declare function patchPathsRequiringRead(hunks: readonly PatchHunk[]): readonly string[];
|
|
50
|
+
/** All paths touched by the patch (for presentation / intent emit). */
|
|
51
|
+
export declare function patchTouchedPaths(hunks: readonly PatchHunk[]): readonly string[];
|
|
52
|
+
//# sourceMappingURL=apply-patch-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch-parser.d.ts","sourceRoot":"","sources":["../src/apply-patch-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAChD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AACtD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAC9C,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE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SAAS,SAAS,EAAE,GAC1B,SAAS,MAAM,EAAE,CAWnB"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex apply_patch grammar (portable subset).
|
|
3
|
+
* Markers: Begin/End Patch · Add/Delete/Update File · Move to · @@ · End of File.
|
|
4
|
+
*/
|
|
5
|
+
export const BEGIN_PATCH_MARKER = "*** Begin Patch";
|
|
6
|
+
export const END_PATCH_MARKER = "*** End Patch";
|
|
7
|
+
export const ADD_FILE_MARKER = "*** Add File: ";
|
|
8
|
+
export const DELETE_FILE_MARKER = "*** Delete File: ";
|
|
9
|
+
export const UPDATE_FILE_MARKER = "*** Update File: ";
|
|
10
|
+
export const MOVE_TO_MARKER = "*** Move to: ";
|
|
11
|
+
export const EOF_MARKER = "*** End of File";
|
|
12
|
+
export const CHANGE_CONTEXT_MARKER = "@@ ";
|
|
13
|
+
export const EMPTY_CHANGE_CONTEXT_MARKER = "@@";
|
|
14
|
+
export class PatchParseError extends Error {
|
|
15
|
+
lineNumber;
|
|
16
|
+
constructor(message, lineNumber) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "PatchParseError";
|
|
19
|
+
if (lineNumber !== undefined)
|
|
20
|
+
this.lineNumber = lineNumber;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function pushContext(chunk, line) {
|
|
24
|
+
chunk.contextLineIndices.push([chunk.oldLines.length, chunk.newLines.length]);
|
|
25
|
+
chunk.oldLines.push(line);
|
|
26
|
+
chunk.newLines.push(line);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse a full `*** Begin Patch` … `*** End Patch` document into hunks.
|
|
30
|
+
* Lenient: trims marker lines; strips a trivial `<<EOF` heredoc wrapper.
|
|
31
|
+
*/
|
|
32
|
+
export function parsePatch(raw) {
|
|
33
|
+
let text = raw.trim();
|
|
34
|
+
const heredoc = text.match(/^<<['"]?EOF['"]?\r?\n([\s\S]*?)\r?\nEOF\s*$/);
|
|
35
|
+
if (heredoc?.[1] !== undefined)
|
|
36
|
+
text = heredoc[1].trim();
|
|
37
|
+
const lines = text.split(/\r?\n/);
|
|
38
|
+
if (lines.length === 0) {
|
|
39
|
+
throw new PatchParseError("The first line of the patch must be '*** Begin Patch'");
|
|
40
|
+
}
|
|
41
|
+
const hunks = [];
|
|
42
|
+
/** not-started | started | add | delete | update | ended */
|
|
43
|
+
let mode = "not-started";
|
|
44
|
+
let updateHunkLine = 0;
|
|
45
|
+
let lineNumber = 0;
|
|
46
|
+
const ensureUpdateNotEmpty = (forLine) => {
|
|
47
|
+
const last = hunks[hunks.length - 1];
|
|
48
|
+
if (!last || last.kind !== "update")
|
|
49
|
+
return;
|
|
50
|
+
if (last.chunks.length === 0 && mode === "update") {
|
|
51
|
+
throw new PatchParseError(`Update file hunk for path '${last.path}' is empty`, updateHunkLine);
|
|
52
|
+
}
|
|
53
|
+
const chunk = last.chunks[last.chunks.length - 1];
|
|
54
|
+
if (chunk && chunk.oldLines.length === 0 && chunk.newLines.length === 0) {
|
|
55
|
+
if (forLine.trim() === END_PATCH_MARKER) {
|
|
56
|
+
throw new PatchParseError("Update hunk does not contain any lines", lineNumber);
|
|
57
|
+
}
|
|
58
|
+
throw new PatchParseError(`Unexpected line found in update hunk: '${forLine}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const startHunkHeader = (trimmed) => {
|
|
62
|
+
if (trimmed === END_PATCH_MARKER) {
|
|
63
|
+
ensureUpdateNotEmpty(trimmed);
|
|
64
|
+
mode = "ended";
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
if (trimmed.startsWith(ADD_FILE_MARKER)) {
|
|
68
|
+
ensureUpdateNotEmpty(trimmed);
|
|
69
|
+
hunks.push({
|
|
70
|
+
kind: "add",
|
|
71
|
+
path: trimmed.slice(ADD_FILE_MARKER.length),
|
|
72
|
+
contents: "",
|
|
73
|
+
});
|
|
74
|
+
mode = "add";
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
if (trimmed.startsWith(DELETE_FILE_MARKER)) {
|
|
78
|
+
ensureUpdateNotEmpty(trimmed);
|
|
79
|
+
hunks.push({
|
|
80
|
+
kind: "delete",
|
|
81
|
+
path: trimmed.slice(DELETE_FILE_MARKER.length),
|
|
82
|
+
});
|
|
83
|
+
mode = "delete";
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (trimmed.startsWith(UPDATE_FILE_MARKER)) {
|
|
87
|
+
ensureUpdateNotEmpty(trimmed);
|
|
88
|
+
hunks.push({
|
|
89
|
+
kind: "update",
|
|
90
|
+
path: trimmed.slice(UPDATE_FILE_MARKER.length),
|
|
91
|
+
chunks: [],
|
|
92
|
+
});
|
|
93
|
+
mode = "update";
|
|
94
|
+
updateHunkLine = lineNumber;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
};
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
lineNumber += 1;
|
|
101
|
+
const trimmed = line.trim();
|
|
102
|
+
if (mode === "not-started") {
|
|
103
|
+
if (trimmed === BEGIN_PATCH_MARKER) {
|
|
104
|
+
mode = "started";
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
throw new PatchParseError("The first line of the patch must be '*** Begin Patch'", lineNumber);
|
|
108
|
+
}
|
|
109
|
+
if (mode === "ended") {
|
|
110
|
+
if (trimmed === "")
|
|
111
|
+
continue;
|
|
112
|
+
throw new PatchParseError(`Unexpected content after '*** End Patch': '${trimmed}'`, lineNumber);
|
|
113
|
+
}
|
|
114
|
+
if (mode === "started") {
|
|
115
|
+
if (startHunkHeader(trimmed))
|
|
116
|
+
continue;
|
|
117
|
+
throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
|
|
118
|
+
}
|
|
119
|
+
if (mode === "add") {
|
|
120
|
+
if (startHunkHeader(trimmed))
|
|
121
|
+
continue;
|
|
122
|
+
if (line.startsWith("+")) {
|
|
123
|
+
const last = hunks[hunks.length - 1];
|
|
124
|
+
if (last?.kind === "add") {
|
|
125
|
+
last.contents += `${line.slice(1)}\n`;
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
|
|
130
|
+
}
|
|
131
|
+
if (mode === "delete") {
|
|
132
|
+
if (startHunkHeader(trimmed))
|
|
133
|
+
continue;
|
|
134
|
+
throw new PatchParseError(`'${trimmed}' is not a valid hunk header. Valid hunk headers: '*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`, lineNumber);
|
|
135
|
+
}
|
|
136
|
+
// update
|
|
137
|
+
const updateLine = line.trimEnd();
|
|
138
|
+
if (startHunkHeader(updateLine.trim()))
|
|
139
|
+
continue;
|
|
140
|
+
const last = hunks[hunks.length - 1];
|
|
141
|
+
if (!last || last.kind !== "update") {
|
|
142
|
+
throw new PatchParseError("internal: expected update hunk", lineNumber);
|
|
143
|
+
}
|
|
144
|
+
const update = last;
|
|
145
|
+
if (update.chunks.at(-1)?.isEndOfFile) {
|
|
146
|
+
if (updateLine === "")
|
|
147
|
+
continue;
|
|
148
|
+
if (updateLine !== EMPTY_CHANGE_CONTEXT_MARKER &&
|
|
149
|
+
!updateLine.startsWith(CHANGE_CONTEXT_MARKER)) {
|
|
150
|
+
throw new PatchParseError(`Expected update hunk to start with a @@ context marker, got: '${line}'`, lineNumber);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (update.chunks.length === 0 &&
|
|
154
|
+
update.movePath === undefined &&
|
|
155
|
+
updateLine.startsWith(MOVE_TO_MARKER)) {
|
|
156
|
+
update.movePath = updateLine.slice(MOVE_TO_MARKER.length);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if ((updateLine === EMPTY_CHANGE_CONTEXT_MARKER ||
|
|
160
|
+
updateLine.startsWith(CHANGE_CONTEXT_MARKER)) &&
|
|
161
|
+
update.chunks.at(-1) &&
|
|
162
|
+
update.chunks.at(-1).oldLines.length === 0 &&
|
|
163
|
+
update.chunks.at(-1).newLines.length === 0) {
|
|
164
|
+
throw new PatchParseError(`Unexpected line found in update hunk: '${line}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
|
|
165
|
+
}
|
|
166
|
+
if (updateLine === EMPTY_CHANGE_CONTEXT_MARKER) {
|
|
167
|
+
update.chunks.push({
|
|
168
|
+
oldLines: [],
|
|
169
|
+
newLines: [],
|
|
170
|
+
contextLineIndices: [],
|
|
171
|
+
isEndOfFile: false,
|
|
172
|
+
});
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (updateLine.startsWith(CHANGE_CONTEXT_MARKER)) {
|
|
176
|
+
update.chunks.push({
|
|
177
|
+
changeContext: updateLine.slice(CHANGE_CONTEXT_MARKER.length),
|
|
178
|
+
oldLines: [],
|
|
179
|
+
newLines: [],
|
|
180
|
+
contextLineIndices: [],
|
|
181
|
+
isEndOfFile: false,
|
|
182
|
+
});
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (updateLine === EOF_MARKER) {
|
|
186
|
+
const chunk = update.chunks.at(-1);
|
|
187
|
+
if (!chunk || (chunk.oldLines.length === 0 && chunk.newLines.length === 0)) {
|
|
188
|
+
throw new PatchParseError("Update hunk does not contain any lines", lineNumber);
|
|
189
|
+
}
|
|
190
|
+
chunk.isEndOfFile = true;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const ensureChunk = () => {
|
|
194
|
+
if (update.chunks.length === 0) {
|
|
195
|
+
update.chunks.push({
|
|
196
|
+
oldLines: [],
|
|
197
|
+
newLines: [],
|
|
198
|
+
contextLineIndices: [],
|
|
199
|
+
isEndOfFile: false,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return update.chunks[update.chunks.length - 1];
|
|
203
|
+
};
|
|
204
|
+
if (line === "") {
|
|
205
|
+
pushContext(ensureChunk(), "");
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (line.startsWith(" ")) {
|
|
209
|
+
pushContext(ensureChunk(), line.slice(1));
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
if (line.startsWith("+")) {
|
|
213
|
+
ensureChunk().newLines.push(line.slice(1));
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (line.startsWith("-")) {
|
|
217
|
+
ensureChunk().oldLines.push(line.slice(1));
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
const lastChunk = update.chunks.at(-1);
|
|
221
|
+
if (lastChunk &&
|
|
222
|
+
(lastChunk.oldLines.length > 0 || lastChunk.newLines.length > 0)) {
|
|
223
|
+
throw new PatchParseError(`Expected update hunk to start with a @@ context marker, got: '${line}'`, lineNumber);
|
|
224
|
+
}
|
|
225
|
+
throw new PatchParseError(`Unexpected line found in update hunk: '${line}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`, lineNumber);
|
|
226
|
+
}
|
|
227
|
+
if (mode !== "ended") {
|
|
228
|
+
throw new PatchParseError("The last line of the patch must be '*** End Patch'");
|
|
229
|
+
}
|
|
230
|
+
if (hunks.length === 0) {
|
|
231
|
+
throw new PatchParseError("Patch contains no hunks");
|
|
232
|
+
}
|
|
233
|
+
return { hunks: hunks, patch: text };
|
|
234
|
+
}
|
|
235
|
+
/** Paths that already exist on disk and must be observed (write-intent). */
|
|
236
|
+
export function patchPathsRequiringRead(hunks) {
|
|
237
|
+
const out = [];
|
|
238
|
+
for (const hunk of hunks) {
|
|
239
|
+
if (hunk.kind === "add")
|
|
240
|
+
continue;
|
|
241
|
+
out.push(hunk.path);
|
|
242
|
+
}
|
|
243
|
+
return out;
|
|
244
|
+
}
|
|
245
|
+
/** All paths touched by the patch (for presentation / intent emit). */
|
|
246
|
+
export function patchTouchedPaths(hunks) {
|
|
247
|
+
const out = [];
|
|
248
|
+
for (const hunk of hunks) {
|
|
249
|
+
if (hunk.kind === "add" || hunk.kind === "delete") {
|
|
250
|
+
out.push(hunk.path);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
out.push(hunk.path);
|
|
254
|
+
if (hunk.movePath)
|
|
255
|
+
out.push(hunk.movePath);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=apply-patch-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch-parser.js","sourceRoot":"","sources":["../src/apply-patch-parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,UAAU,CAAU;IAE7B,YAAY,OAAe,EAAE,UAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,UAAU,KAAK,SAAS;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC7D,CAAC;CAC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EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,SAAS;QAClC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,iBAAiB,CAC/B,KAA2B;IAE3B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,IAAI,CAAC,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a Codex-format patch through FsService (path-jail + intents).
|
|
3
|
+
*/
|
|
4
|
+
export interface ApplyPatchResult {
|
|
5
|
+
readonly ops: readonly {
|
|
6
|
+
readonly action: "add" | "update" | "delete" | "move";
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly fromPath?: string;
|
|
9
|
+
}[];
|
|
10
|
+
readonly hunkCount: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ApplyPatchFs {
|
|
13
|
+
read(userPath: string, maxBytes?: number): Promise<{
|
|
14
|
+
readonly content: string;
|
|
15
|
+
readonly truncated?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
write(userPath: string, content: string): Promise<void>;
|
|
18
|
+
remove(userPath: string): Promise<void>;
|
|
19
|
+
stat(userPath: string): Promise<{
|
|
20
|
+
readonly size: number;
|
|
21
|
+
readonly isFile: boolean;
|
|
22
|
+
readonly isDirectory: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
/** Parse + apply; emits write intents via FsService. */
|
|
26
|
+
export declare function applyPatchToFs(fs: ApplyPatchFs, patchText: string): Promise<ApplyPatchResult>;
|
|
27
|
+
//# sourceMappingURL=apply-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch.d.ts","sourceRoot":"","sources":["../src/apply-patch.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,SAAS;QACrB,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;QACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KAC5B,EAAE,CAAC;IACJ,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CACF,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;QACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;KAC/B,CAAC,CAAC;CACJ;AA4BD,wDAAwD;AACxD,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAyC3B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a Codex-format patch through FsService (path-jail + intents).
|
|
3
|
+
*/
|
|
4
|
+
import { ApplyPatchError, planPatchApplication } from "./apply-patch-apply.js";
|
|
5
|
+
import { parsePatch, PatchParseError, } from "./apply-patch-parser.js";
|
|
6
|
+
async function tryRead(fs, userPath) {
|
|
7
|
+
try {
|
|
8
|
+
const st = await fs.stat(userPath);
|
|
9
|
+
if (st.isDirectory) {
|
|
10
|
+
throw new ApplyPatchError(`cannot apply patch to directory: ${userPath}`);
|
|
11
|
+
}
|
|
12
|
+
const out = await fs.read(userPath);
|
|
13
|
+
return out.content;
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (err instanceof ApplyPatchError)
|
|
17
|
+
throw err;
|
|
18
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
19
|
+
if (/ENOENT|no such file|not found|PathEscape/i.test(message) ||
|
|
20
|
+
err?.code === "ENOENT") {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Parse + apply; emits write intents via FsService. */
|
|
27
|
+
export async function applyPatchToFs(fs, patchText) {
|
|
28
|
+
let hunks;
|
|
29
|
+
try {
|
|
30
|
+
hunks = parsePatch(patchText).hunks;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err instanceof PatchParseError)
|
|
34
|
+
throw err;
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
const cache = new Map();
|
|
38
|
+
const readFile = (p) => {
|
|
39
|
+
if (!cache.has(p)) {
|
|
40
|
+
throw new ApplyPatchError(`internal: missing cached read for ${p}`);
|
|
41
|
+
}
|
|
42
|
+
return cache.get(p);
|
|
43
|
+
};
|
|
44
|
+
for (const hunk of hunks) {
|
|
45
|
+
if (hunk.kind === "add") {
|
|
46
|
+
cache.set(hunk.path, await tryRead(fs, hunk.path));
|
|
47
|
+
}
|
|
48
|
+
else if (hunk.kind === "delete") {
|
|
49
|
+
cache.set(hunk.path, await tryRead(fs, hunk.path));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
cache.set(hunk.path, await tryRead(fs, hunk.path));
|
|
53
|
+
if (hunk.movePath) {
|
|
54
|
+
cache.set(hunk.movePath, await tryRead(fs, hunk.movePath));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const plan = planPatchApplication(hunks, readFile);
|
|
59
|
+
for (const [userPath, content] of plan.writes) {
|
|
60
|
+
await fs.write(userPath, content);
|
|
61
|
+
}
|
|
62
|
+
for (const userPath of plan.deletes) {
|
|
63
|
+
if (plan.writes.has(userPath))
|
|
64
|
+
continue;
|
|
65
|
+
await fs.remove(userPath);
|
|
66
|
+
}
|
|
67
|
+
return { ops: plan.ops, hunkCount: hunks.length };
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=apply-patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-patch.js","sourceRoot":"","sources":["../src/apply-patch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EACL,UAAU,EACV,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AAyBjC,KAAK,UAAU,OAAO,CACpB,EAAgB,EAChB,QAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CA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