@unbrained/pm-cli 2026.10.22 → 2026.10.24

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.
Files changed (190) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +38 -0
  3. package/dist/cli/error-guidance.d.ts +12 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/register-setup.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-2B5HAZFK.js → chunk-3S5FLCG7.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-PCPOTFJP.js → chunk-3VI4XDP2.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-UYYTV2TX.js → chunk-4PNAUT2E.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-E3JC3WQL.js → chunk-CDR5ES7Q.js} +54 -54
  11. package/dist/cli-bundle/chunks/chunk-CNEUJHA4.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-AOAQDCXX.js → chunk-CSE47ZAN.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-MV3KYY2A.js → chunk-FASDGYQC.js} +3 -3
  14. package/dist/cli-bundle/chunks/chunk-HZNFNETE.js +127 -0
  15. package/dist/cli-bundle/chunks/{chunk-7OTYULIJ.js → chunk-KGZGXC7T.js} +29 -29
  16. package/dist/cli-bundle/chunks/{chunk-HC2DCGFA.js → chunk-MA7SNKYK.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-GWIGZDRS.js → chunk-R7KWBFM2.js} +2 -2
  18. package/dist/cli-bundle/chunks/chunk-TZYQ4JDZ.js +6 -0
  19. package/dist/cli-bundle/chunks/chunk-URZB3USE.js +113 -0
  20. package/dist/cli-bundle/chunks/chunk-UY5UHI4I.js +2 -0
  21. package/dist/cli-bundle/chunks/{chunk-TNU3XVPC.js → chunk-VPMQEVU6.js} +14 -14
  22. package/dist/cli-bundle/chunks/{chunk-URV4VHQ4.js → chunk-VSSHB6XI.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-LIC5EUQS.js → chunk-YEI4N4A6.js} +48 -48
  24. package/dist/cli-bundle/chunks/chunk-Z62RXNHW.js +3 -0
  25. package/dist/cli-bundle/chunks/chunk-ZDVTXLA6.js +9 -0
  26. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-L3BOTMZN.js → indexed-receipt-blobs-XANVELIV.js} +2 -2
  27. package/dist/cli-bundle/chunks/{mutation-admission-TATOFEXF.js → mutation-admission-NVTBZ7DH.js} +2 -2
  28. package/dist/cli-bundle/chunks/{register-list-query-GULR2IYO.js → register-list-query-2FE6K7FQ.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-mutation-HLSQ4WVW.js → register-mutation-KZXQUZUH.js} +2 -2
  30. package/dist/cli-bundle/chunks/{register-operations-FE3GGA7O.js → register-operations-BOCBWNKJ.js} +2 -2
  31. package/dist/cli-bundle/chunks/register-setup-P3VLCTDY.js +2 -0
  32. package/dist/cli-bundle/chunks/{settlement-hook-UVFYSBMU.js → settlement-hook-YUVCO65H.js} +2 -2
  33. package/dist/cli-bundle/chunks/{stage-QCPZBZRC.js → stage-WRDTMCCF.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-UQ5JPBY2.js → chunk-3QYTS4OY.js} +4 -4
  35. package/dist/cli-bundle/focused-chunks/{chunk-46HBJC6J.js → chunk-5MKNVJCM.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-QGDKWULS.js → chunk-6HJCSHBG.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-7RQOFHMH.js +26 -0
  38. package/dist/cli-bundle/focused-chunks/chunk-AGCEWJ27.js +21 -0
  39. package/dist/cli-bundle/focused-chunks/{chunk-3LWH2RJC.js → chunk-BUZ2Z4P3.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-2GFTVXKZ.js → chunk-CEEOWDB7.js} +3 -3
  41. package/dist/cli-bundle/focused-chunks/{chunk-25NQRZ7J.js → chunk-ES2NGVHZ.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-GXAXDPD4.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-VYAZND5Q.js → chunk-IUAYTD2S.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-TMN3RAXZ.js → chunk-JYXA4JIP.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-A52W6GLA.js → chunk-NFFPNMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-KM77WU5U.js → chunk-NX7TVNUM.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-CX5FNEFC.js → chunk-POLMFGPQ.js} +3 -3
  48. package/dist/cli-bundle/focused-chunks/chunk-R536272H.js +9 -0
  49. package/dist/cli-bundle/focused-chunks/{chunk-W2CND3BD.js → chunk-RSEGFZTY.js} +54 -54
  50. package/dist/cli-bundle/focused-chunks/{chunk-EHPRSWJE.js → chunk-RVUGTIIU.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-CB7TSZ7P.js → chunk-SBJ2IKTH.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-SXVJRLLP.js → chunk-SHUPX6G2.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-GVKYTDOH.js → chunk-TAHSXKAT.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-X5YRJMAY.js +2 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-XTYEASIY.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-ZMWLV2CE.js +91 -0
  57. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-AAQOKO5B.js → indexed-receipt-blobs-FVOA3XMI.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{mutation-admission-TBKR4KRM.js → mutation-admission-PB6YFY7S.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{settlement-hook-MNCHFCAX.js → settlement-hook-2VXEB6PP.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{stage-RM6MJIMT.js → stage-MQE4PFWT.js} +2 -2
  61. package/dist/cli-bundle/main.js +21 -21
  62. package/dist/cli-bundle/sdk-authoring.js +1 -1
  63. package/dist/cli-bundle/sdk-contracts.js +5 -2
  64. package/dist/cli-bundle/sdk-core.js +33 -33
  65. package/dist/cli-bundle/sdk-governance.js +1 -1
  66. package/dist/cli-bundle/sdk-graph.js +1 -1
  67. package/dist/cli-bundle/sdk-merge.js +58 -58
  68. package/dist/cli-bundle/sdk-query.js +1 -1
  69. package/dist/cli-bundle/sdk-runtime.js +1 -1
  70. package/dist/cli-bundle/sdk-testing.js +1 -1
  71. package/dist/cli-bundle/sdk.js +12 -9
  72. package/dist/core/checkpoint/mutation-checkpoint.d.ts +6 -3
  73. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  74. package/dist/core/checkpoint/mutation-context.d.ts +10 -0
  75. package/dist/core/checkpoint/mutation-context.js +2 -0
  76. package/dist/core/config/nested-settings.js +1 -1
  77. package/dist/core/extensions/loader.js +1 -1
  78. package/dist/core/extensions/version-diagnostics.d.ts +2 -0
  79. package/dist/core/extensions/version-diagnostics.js +2 -0
  80. package/dist/core/lock/lock.d.ts +40 -6
  81. package/dist/core/lock/lock.js +3 -3
  82. package/dist/core/shared/errors.d.ts +28 -0
  83. package/dist/core/shared/errors.js +1 -1
  84. package/dist/core/store/item-store.js +1 -1
  85. package/dist/mcp/http-server.js +2 -2
  86. package/dist/mcp/server.js +2 -2
  87. package/dist/sdk/agent/command-recovery.d.ts +1 -0
  88. package/dist/sdk/agent/command-recovery.js +1 -1
  89. package/dist/sdk/agent/linked-resource-recovery.d.ts +13 -0
  90. package/dist/sdk/agent/linked-resource-recovery.js +2 -0
  91. package/dist/sdk/cli-contracts/agent-output-contracts.js +1 -1
  92. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  93. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +3 -2
  94. package/dist/sdk/contracts.d.ts +1 -0
  95. package/dist/sdk/contracts.js +1 -1
  96. package/dist/sdk/core.d.ts +1 -1
  97. package/dist/sdk/core.js +1 -1
  98. package/dist/sdk/extension/doctor.js +1 -1
  99. package/dist/sdk/extension/install-receipts.js +1 -1
  100. package/dist/sdk/extension/install-snapshot.d.ts +11 -0
  101. package/dist/sdk/extension/install-snapshot.js +1 -1
  102. package/dist/sdk/extension.d.ts +12 -0
  103. package/dist/sdk/extension.js +1 -1
  104. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  105. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  106. package/dist/sdk/governance/health.d.ts +1 -0
  107. package/dist/sdk/governance/health.js +2 -2
  108. package/dist/sdk/index.d.ts +4 -2
  109. package/dist/sdk/index.js +1 -1
  110. package/dist/sdk/lifecycle/checkpoint-rollback.d.ts +7 -0
  111. package/dist/sdk/lifecycle/checkpoint-rollback.js +2 -0
  112. package/dist/sdk/lifecycle/close-many.d.ts +1 -1
  113. package/dist/sdk/lifecycle/close-many.js +1 -1
  114. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  115. package/dist/sdk/lifecycle/restore.js +1 -1
  116. package/dist/sdk/lifecycle/update-many.d.ts +1 -1
  117. package/dist/sdk/lifecycle/update-many.js +1 -1
  118. package/dist/sdk/mcp/executable.d.ts +13 -0
  119. package/dist/sdk/mcp/executable.js +5 -0
  120. package/dist/sdk/public-surface.json +1 -1
  121. package/dist/sdk/query/context.d.ts +2 -1
  122. package/dist/sdk/query/context.js +1 -1
  123. package/dist/sdk/query/get.d.ts +2 -1
  124. package/dist/sdk/query/get.js +1 -1
  125. package/dist/sdk/query/list.d.ts +2 -1
  126. package/dist/sdk/query/list.js +1 -1
  127. package/dist/sdk/query/search/types.d.ts +2 -1
  128. package/dist/sdk/query.d.ts +1 -0
  129. package/dist/sdk/query.js +1 -1
  130. package/dist/sdk/read-output-contracts.d.ts +10 -2
  131. package/dist/sdk/read-output-contracts.js +1 -1
  132. package/dist/sdk/runtime-input.js +1 -1
  133. package/dist/sdk/runtime-primitives.d.ts +2 -1
  134. package/dist/sdk/runtime-primitives.js +1 -1
  135. package/dist/sdk/runtime.d.ts +11 -11
  136. package/dist/sdk/runtime.js +1 -1
  137. package/dist/sdk/test/batch.js +2 -2
  138. package/dist/sdk/test/entry.d.ts +5 -1
  139. package/dist/sdk/test/entry.js +2 -1
  140. package/dist/sdk/test/execution.js +2 -2
  141. package/dist/sdk/workspace-snapshot.d.ts +5 -1
  142. package/dist/sdk/workspace-snapshot.js +3 -3
  143. package/dist/sdk/workspace.js +2 -2
  144. package/docs/COMMANDS.md +21 -2
  145. package/docs/CONFIGURATION.md +19 -3
  146. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +2 -1
  147. package/docs/EXTENSION_LIFECYCLE.md +47 -0
  148. package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +16 -1
  149. package/docs/READ_OUTPUT_CONTRACTS.md +15 -0
  150. package/docs/RELEASING.md +9 -0
  151. package/docs/SDK.md +84 -5
  152. package/docs/SDK_STORAGE_LIFECYCLE.md +2 -1
  153. package/docs/TESTING.md +39 -7
  154. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +8 -3
  155. package/marketplace.json +1 -1
  156. package/package.json +1 -1
  157. package/packages/pm-beads/package.json +1 -1
  158. package/packages/pm-calendar/package.json +1 -1
  159. package/packages/pm-command-kit/package.json +1 -1
  160. package/packages/pm-digital-twin/package.json +1 -1
  161. package/packages/pm-governance-audit/package.json +1 -1
  162. package/packages/pm-guide-shell/package.json +1 -1
  163. package/packages/pm-kanban/package.json +1 -1
  164. package/packages/pm-lifecycle-hooks/package.json +1 -1
  165. package/packages/pm-linked-test-adapters/package.json +1 -1
  166. package/packages/pm-search-advanced/package.json +1 -1
  167. package/packages/pm-templates/package.json +1 -1
  168. package/packages/pm-todos/package.json +1 -1
  169. package/packages/pm-vcs/package.json +1 -1
  170. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  171. package/plugins/pm-claude/package.json +1 -1
  172. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  173. package/plugins/pm-codex/package.json +1 -1
  174. package/plugins/pm-codex/plugin.json +1 -1
  175. package/runtime-dependencies.json +1 -1
  176. package/dist/cli-bundle/chunks/chunk-35ISFIPC.js +0 -113
  177. package/dist/cli-bundle/chunks/chunk-5LSN7K4N.js +0 -2
  178. package/dist/cli-bundle/chunks/chunk-BAIVTLJM.js +0 -6
  179. package/dist/cli-bundle/chunks/chunk-C37RDYZI.js +0 -3
  180. package/dist/cli-bundle/chunks/chunk-J444ZX23.js +0 -126
  181. package/dist/cli-bundle/chunks/chunk-O67N62DT.js +0 -2
  182. package/dist/cli-bundle/chunks/chunk-VO3KDIU7.js +0 -9
  183. package/dist/cli-bundle/chunks/register-setup-XUIKAIZA.js +0 -2
  184. package/dist/cli-bundle/focused-chunks/chunk-25L3L2PF.js +0 -2
  185. package/dist/cli-bundle/focused-chunks/chunk-DVNUHTVK.js +0 -9
  186. package/dist/cli-bundle/focused-chunks/chunk-GC4VMLXL.js +0 -20
  187. package/dist/cli-bundle/focused-chunks/chunk-QWKCQ5PW.js +0 -91
  188. package/dist/cli-bundle/focused-chunks/chunk-SOVXHW6Z.js +0 -2
  189. package/dist/cli-bundle/focused-chunks/chunk-UUPJ6OZL.js +0 -26
  190. package/dist/cli-bundle/focused-chunks/chunk-XX5JQCLF.js +0 -2
@@ -1,7 +1,7 @@
1
- import{a as d}from"./chunk-RUKSEZE7.js";import{b as l}from"./chunk-VS565KBX.js";import{A as s,C as m,G as c,K as p}from"./chunk-GWIGZDRS.js";import"./chunk-XAWE4EAK.js";import{execFile as f}from"node:child_process";import{chmod as h,lstat as u}from"node:fs/promises";import{promisify as w}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5b6eab08-f707-586f-bb05-484bd9160551")}catch{}})();var y=w(f),g=`#!/bin/sh
1
+ import{a as d}from"./chunk-RUKSEZE7.js";import{b as l}from"./chunk-VS565KBX.js";import{A as s,C as m,G as c,K as p}from"./chunk-R7KWBFM2.js";import"./chunk-XAWE4EAK.js";import{execFile as f}from"node:child_process";import{chmod as h,lstat as u}from"node:fs/promises";import{promisify as w}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5b6eab08-f707-586f-bb05-484bd9160551")}catch{}})();var y=w(f),g=`#!/bin/sh
2
2
  # pm-cli:lossless-merge-settlement:v1
3
3
  `;async function I(e,t){let r=(await y("git",["rev-parse","--path-format=absolute","--git-path","hooks/pre-commit"],{cwd:e,env:l(),timeout:1e4})).stdout.trim(),o,i=!1;try{o=await d(r,65536)??"",i=process.platform==="win32"||((await u(r)).mode&73)!==0}catch(a){if(!c(a))throw a}if(o!==void 0&&!o.startsWith(g))throw new m("The pre-commit hook already exists and is not owned by pm; it was preserved.",s.CONFLICT,{code:"merge_settlement_hook_conflict",recovery:{suggested_retry:"pm merge install --dry-run"},nextSteps:["Integrate pm merge reconcile --stage into your existing hook after reviewing its policy, or keep manual settlement. pm never replaces an existing unowned hook."]});let n=`${g}merge_head=$(git rev-parse --git-path MERGE_HEAD) || exit 1
4
4
  [ -f "$merge_head" ] || exit 0
5
5
  exec ${t} merge reconcile --stage
6
6
  `;return{path:r,changed:o!==n||!i,content:n}}async function H(e){e.changed&&(await p(e.path,e.content),await h(e.path,493))}export{I as prepareMergeSettlementHook,H as writeMergeSettlementHook};
7
- //# sourceMappingURL=settlement-hook-UVFYSBMU.js.map
7
+ //# sourceMappingURL=settlement-hook-YUVCO65H.js.map
@@ -1,2 +1,2 @@
1
- import{i as w}from"./chunk-MV3KYY2A.js";import"./chunk-IB7UB5TE.js";import{xa as h}from"./chunk-35ISFIPC.js";import{d as u}from"./chunk-VO3KDIU7.js";import{b as g}from"./chunk-VS565KBX.js";import{A as m,C as f}from"./chunk-GWIGZDRS.js";import"./chunk-XAWE4EAK.js";import{execFile as y}from"node:child_process";import{realpath as v}from"node:fs/promises";import l from"node:path";import{promisify as _}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fe5937fc-def3-5ed4-9663-70a6e9d258a1")}catch{}})();var b=_(y);function c(e){return new f(`Automatic merge settlement refused: ${e}`,m.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function x(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let s=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function R(e,t){if(t.length===0)return[];let s=t.map(a=>`:(literal)${a}`),o=new Set((await e(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),r=t.filter(a=>!o.has(a)).map(a=>`:(literal)${a}`);if(r.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...r])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return r}async function k(e){let{git:t,preview:s,paths:o,newReceiptPathspecs:r}=e,a=!1;try{r.length>0&&(await t(["add","--",...r]),a=!0);let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||n.repair.streams.some(p=>!s.repair.streams.some(d=>d.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw a&&await t(["reset","--quiet","--",...r]),n}}function G(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function I(e){try{return{...e,path:await v(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function N(e){let{preview:t}=e;G(t);let{path:s}=await I(e.global),o=await w(s);if(o===null)throw c("a Git workspace is required");let r=i=>b("git",i,{cwd:o,env:g(),timeout:1e4});if(await x(r),(await r(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let a=[...new Set([...[...new Set([...t.repair.streams.map(i=>i.id),...t.receipts.summaries.map(i=>i.item_id)])].map(i=>l.join(s,"history",`${i}.jsonl`)),...t.receipts.summaries.map(i=>l.join(s,"merge-receipts",`${i.receipt_id}.json`))])].map(i=>l.relative(o,i).replaceAll("\\","/"));if(a.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let n=a.map(i=>`:(literal)${i}`),p=t.receipts.summaries.map(i=>l.relative(o,l.join(s,"merge-receipts",`${i.receipt_id}.json`)).replaceAll("\\","/"));if(n.length>0)try{await r(["diff","--quiet","--",...n])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let d=await R(r,p);return e.dryRun?{...t,staged_paths:[]}:k({...e,git:r,paths:a,newReceiptPathspecs:d})}export{I as resolveMergeSettlementGlobal,N as stageLosslessMergeReconciliation};
2
- //# sourceMappingURL=stage-QCPZBZRC.js.map
1
+ import{i as w}from"./chunk-FASDGYQC.js";import"./chunk-IB7UB5TE.js";import{xa as h}from"./chunk-URZB3USE.js";import{d as u}from"./chunk-ZDVTXLA6.js";import{b as g}from"./chunk-VS565KBX.js";import{A as m,C as f}from"./chunk-R7KWBFM2.js";import"./chunk-XAWE4EAK.js";import{execFile as y}from"node:child_process";import{realpath as v}from"node:fs/promises";import l from"node:path";import{promisify as _}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fe5937fc-def3-5ed4-9663-70a6e9d258a1")}catch{}})();var b=_(y);function c(e){return new f(`Automatic merge settlement refused: ${e}`,m.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function x(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let s=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function R(e,t){if(t.length===0)return[];let s=t.map(a=>`:(literal)${a}`),o=new Set((await e(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),r=t.filter(a=>!o.has(a)).map(a=>`:(literal)${a}`);if(r.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...r])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return r}async function k(e){let{git:t,preview:s,paths:o,newReceiptPathspecs:r}=e,a=!1;try{r.length>0&&(await t(["add","--",...r]),a=!0);let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||n.repair.streams.some(p=>!s.repair.streams.some(d=>d.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw a&&await t(["reset","--quiet","--",...r]),n}}function G(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function I(e){try{return{...e,path:await v(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function N(e){let{preview:t}=e;G(t);let{path:s}=await I(e.global),o=await w(s);if(o===null)throw c("a Git workspace is required");let r=i=>b("git",i,{cwd:o,env:g(),timeout:1e4});if(await x(r),(await r(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let a=[...new Set([...[...new Set([...t.repair.streams.map(i=>i.id),...t.receipts.summaries.map(i=>i.item_id)])].map(i=>l.join(s,"history",`${i}.jsonl`)),...t.receipts.summaries.map(i=>l.join(s,"merge-receipts",`${i.receipt_id}.json`))])].map(i=>l.relative(o,i).replaceAll("\\","/"));if(a.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let n=a.map(i=>`:(literal)${i}`),p=t.receipts.summaries.map(i=>l.relative(o,l.join(s,"merge-receipts",`${i.receipt_id}.json`)).replaceAll("\\","/"));if(n.length>0)try{await r(["diff","--quiet","--",...n])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let d=await R(r,p);return e.dryRun?{...t,staged_paths:[]}:k({...e,git:r,paths:a,newReceiptPathspecs:d})}export{I as resolveMergeSettlementGlobal,N as stageLosslessMergeReconciliation};
2
+ //# sourceMappingURL=stage-WRDTMCCF.js.map