@unbrained/pm-cli 2026.11.18 → 2026.11.20
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/.claude-plugin/marketplace.json +1 -1
- package/AGENTS.md +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-SSZBVRIN.js → chunk-2IZGNOGT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-T3E3WNHO.js → chunk-3BOR22MC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LGWP5D7V.js → chunk-4QQPM3IY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TA5VN4ME.js → chunk-4TZW4NLM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TS2CZE3O.js → chunk-5LF5QZT3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-WKHS4QC6.js → chunk-6HRPGEBF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FJQCORYR.js → chunk-6X2AGUOT.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-2VH6COJE.js → chunk-7ESF676D.js} +37 -37
- package/dist/cli-bundle/chunks/{chunk-CGTVDSAR.js → chunk-7EZZ4W7O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QK7RAN7R.js → chunk-DG2EOOFX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YJI2Y5N6.js → chunk-FF4TXJDH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7UUPLMCU.js → chunk-FOYRE23V.js} +46 -46
- package/dist/cli-bundle/chunks/{chunk-L2ZLH3LZ.js → chunk-GXGW6KHB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7ETRLLK3.js → chunk-HJQ3XPS3.js} +30 -30
- package/dist/cli-bundle/chunks/{chunk-JBPXNG6P.js → chunk-KDDIHGAO.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KEBLUTC3.js +71 -0
- package/dist/cli-bundle/chunks/{chunk-7LCJA54R.js → chunk-KQSPKWFH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VETSGCF4.js → chunk-M5D3CEMY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-AGU7632B.js → chunk-MGYAJONE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CR5GC3VO.js → chunk-OXG5XPC7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H64BNM4A.js → chunk-W4TLA5H3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-S3RMFLEG.js → chunk-XK25TAJZ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-XDIJK6VW.js → chunk-ZAO7VGX3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MUGGRKK3.js → chunk-ZVEHACE6.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-BV5BUBCR.js → item-revision-GE2CQECR.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-YSAWJRA2.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-DDYJW5B4.js → mutation-actor-5GYX7LP3.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-5AWMXMCB.js → mutation-admission-72TYKPGU.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-RJT7YBRF.js → register-list-query-OQZZEWEB.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-6KTMJGYF.js → register-mutation-YZEUZ6XT.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-W24TA3HZ.js → register-operations-JNVCF7EW.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-QK67WUX6.js → register-setup-LDKULZSD.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-XGWW3T64.js → stage-Q2QZ2IBG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IGMFXB5W.js → chunk-3LRSQXCN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EZXLY6S4.js → chunk-5VSXKA35.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-LZR3JKYT.js → chunk-7SB6VKEI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-MTBC32ZR.js → chunk-BZCLW5V7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ICEHI4SN.js → chunk-FPKVHC3Q.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HO2YUD4P.js → chunk-I7XBR2RM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XS2YZCT5.js → chunk-JUYJ7NXL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZFUZ4YYN.js → chunk-KQJNJZKP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7RF2YPZ5.js → chunk-MJP3TFVW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3H3SVHAT.js → chunk-O25KFLLA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7Z2NYAK4.js → chunk-PKMDWIP3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EO4XM3XJ.js → chunk-PQXTZLK3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-T3NMYMW4.js → chunk-PRFEOCNZ.js} +24 -24
- package/dist/cli-bundle/focused-chunks/{chunk-A2CLYPDA.js → chunk-PZSTRYTA.js} +40 -40
- package/dist/cli-bundle/focused-chunks/{chunk-PNCCTZKI.js → chunk-QNJQPJWO.js} +23 -23
- package/dist/cli-bundle/focused-chunks/{chunk-5JVB42Z7.js → chunk-SIPDQBJI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-FPPYE6CY.js → chunk-SJE3PYPI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6OZ7BKWJ.js → chunk-TNKI6WKG.js} +55 -54
- package/dist/cli-bundle/focused-chunks/{chunk-ONHUG7IL.js → chunk-TRCXANRR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DWCFZVT2.js → chunk-UATP3RK3.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OPY43DNJ.js → chunk-V55XZFOP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OAIAZHRG.js → chunk-ZKGGGU2K.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-NS2V4WON.js → item-revision-OXDZHMJ7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-NENC4HYI.js → item-transaction-54VSTT6L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-2SVBO324.js → mutation-actor-6DYIF6NH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-DZIBDJAE.js → mutation-admission-2BYXANVJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-LVAGKCEE.js → stage-FGHSB3QX.js} +2 -2
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +55 -55
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/fs/file-glob.js +1 -1
- package/dist/core/shared/process-tree.js +3 -0
- package/dist/core/shared/secret-rules.d.ts +12 -1
- package/dist/core/shared/secret-rules.js +2 -2
- package/dist/core/shared/text-normalization.d.ts +9 -0
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/extension/managed-state.d.ts +3 -1
- package/dist/sdk/extension/managed-state.js +1 -1
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/update-check.d.ts +42 -6
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension.d.ts +3 -1
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/mutation-guard.d.ts +121 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/read-output/continuation.d.ts +9 -3
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output-budget.d.ts +44 -3
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/test/execution.js +2 -2
- package/docs/CONFIGURATION.md +1 -0
- package/docs/MUTATION_INTEGRITY.md +72 -0
- package/docs/PACKAGE_EVIDENCE.md +66 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +16 -1
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-OD2I3SFQ.js +0 -70
- package/dist/cli-bundle/chunks/item-transaction-E2ST3A3X.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as ve}from"./chunk-QK7RAN7R.js";import{Ad as g,Bd as b,Kc as Ie,oc as ge,pc as ye,qb as x,rb as k,xb as _e}from"./chunk-2VH6COJE.js";import{v as pe}from"./chunk-CR5GC3VO.js";import{Cc as ne,Ch as ae,Dh as de,Ea as j,Eh as le,Fh as fe,Gh as ue,Hh as me,Ih as N,Ka as X,Ma as J,O as V,Sa as Q,Sh as p,X as Y,Ya as Z,Zc as v,_c as w,ce as ie,cj as he,mb as ee,nb as te,oh as oe,vh as T,wh as re,xh as B,yh as se,zh as ce}from"./chunk-7UUPLMCU.js";import{A as u,C as l,z as W}from"./chunk-5OFMWP3Q.js";import{readdir as Ke}from"node:fs/promises";import H from"node:path";(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]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function D(e,t){return(t===void 0?void 0:J(e,t))?.execution_role??j[e.trim().toLowerCase()]??"agent"}var O="blocked_by",be="blocks",Le=Object.freeze([O,be]),A="no-active-blocker";function d(e){return e.trim().toLowerCase()}function E(e,t){return t?`external:${e}`:`local:${d(e)}`}function _(e){let t=new Map,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(n.length>0&&d(n)!==A){let i=g(n);t.set(E(n,i),i?n:d(n))}for(let i of e.dependencies??[]){let o=typeof i.id=="string"?i.id.trim():"";if(p(i.kind)===O&&o.length>0&&d(o)!==A){let r=g(o)||b(i.source_kind);t.set(E(o,r),r?o:d(o))}}return[...t.values()].sort((i,o)=>i.localeCompare(o))}function C(e){let t=new Map;for(let n of e){let i=d(n.id);i.length!==0&&t.set(i,new Set(_(n)))}for(let n of e){let i=d(n.id);if(i.length!==0)for(let o of n.dependencies??[]){let r=p(o.kind)===be&&typeof o.id=="string"?d(o.id):"";if(r.length===0||r===A)continue;let c=t.get(r)??new Set;c.add(i),t.set(r,c)}}return new Map([...t].map(([n,i])=>[n,[...i].sort((o,r)=>o.localeCompare(r))]))}function we(e,t){let n=d(e.id);return n.length>0?C(t).get(n)??_(e):_(e)}function L(e,t,n,i){let o=e,r=typeof o.id=="string"?i?.get(d(o.id))??we(o,[...t.values()]):_(e),c=new Set((e.dependencies??[]).filter(s=>p(s.kind)===O&&b(s.source_kind)&&typeof s.id=="string"&&s.id.trim().length>0).map(s=>E(s.id.trim(),!0)));return r.map(s=>{if(g(s)||c.has(E(s,!0)))return{id:s,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let a=t.get(d(s));return a?{id:s,title:a.title,status:a.status,resolved:w(a.status,n)}:{id:s,title:null,status:null,resolved:!1}})}function M(e,t,n){return L(e,t,n)}function Me(e,t){let n=new Map(e.map(c=>[d(c.id),c])),i=C(e),o=new Set([...xe(t),...t.blocked_statuses]),r=new Set;for(let c of e){let s=v(c.status,t);o.has(s)&&(t.blocked_statuses.has(s)||L(c,n,t,i).some(a=>!a.resolved))&&r.add(d(c.id))}return r}function He(e,t,n={},i){let o=[...e.ready,...e.decisions,...e.gates];n.includeContainers===!0&&o.push(...e.containers.filter(c=>c.open_blockers.length===0&&!t.blocked_statuses.has(v(c.item.status,t))));let r={ready:[],decisions:[],gates:[]};for(let c of o){let s=D(c.item.type,i);s==="human"&&n.includeDecisions!==!0?r.decisions.push(c):s==="gate"&&n.includeGates!==!0?r.gates.push(c):r.ready.push(c)}return r}function xe(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function Pe(e,t,n){let i=[d(e)],o=new Set;for(;i.length>0;){let r=i.pop();if(!o.has(r)){o.add(r);for(let c of t.get(r)??[]){if(!w(c.status,n))return!0;i.push(d(c.id))}}}return!1}function $e(e){let t=new Map,n=new Map,i=new Map,o=C(e);for(let r of e){t.set(d(r.id),r);let c=typeof r.parent=="string"?r.parent.trim():"";if(c.length>0){let s=d(c),a=n.get(s)??[];a.push(r),n.set(s,a)}for(let s of o.get(d(r.id))){let a=d(s),m=i.get(a)??[];m.push(r.id),i.set(a,m)}}return{itemsById:t,childrenByParent:n,blockedByReverse:i,blockerIdsByItem:o}}function Fe(e,t,n,i){let{itemsById:o,childrenByParent:r,blockedByReverse:c,blockerIdsByItem:s}=$e(t),a=new Set([...xe(n),...n.blocked_statuses]),m=new Set(t.filter(f=>!w(f.status,n)).map(f=>d(f.id))),F=[],K=[],S=[],U=[],G=[],q=0;for(let f of e){if(!a.has(v(f.status,n)))continue;q+=1;let z=L(f,o,n,s).filter(h=>!h.resolved),Ae=(c.get(d(f.id))??[]).filter(h=>m.has(d(h))).sort((h,Oe)=>h.localeCompare(Oe)),I={item:f,open_blockers:z,unblocks:Ae};if(Pe(f.id,r,n)){S.push(I);continue}let De=n.blocked_statuses.has(v(f.status,n));if(z.length===0&&!De){let h=D(f.type,i);h==="human"?U.push(I):h==="gate"?G.push(I):F.push(I)}else K.push(I)}return{ready:F,blocked:K,containers:S,decisions:U,gates:G,active_count:q,container_count:S.length}}(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]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();(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]="e9b7731d-e6f5-51a8-970b-462c0b728a9c")}catch{}})();function Ue(e,t){let n=new Map;for(let i of e){let o=i.external?i.id:t.get(i.id.toLowerCase())?.id??i.id;n.set(i.external?`external:${o}`:`local:${o.toLowerCase()}`,{...i,id:o})}return[...n.values()]}async function P(e,t){let n=H.basename(e),i=(await Ke(H.dirname(e)).catch(o=>{throw ge("Cannot verify the blocker's physical file identity",{exitCode:u.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===n.toLowerCase()).sort((o,r)=>+(r===n)-+(o===n)||o.localeCompare(r)).map(o=>H.parse(o).name)[0];if(i===void 0)throw new l(`Blocker canonical file disappeared during identity verification: ${t}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return i}async function ht(e){let t=_(e.metadata);if(t.length===0)return[];let n=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(o=>p(o.kind)==="blocked_by").map(o=>o.id)].filter(o=>typeof o=="string").map(o=>[o.trim().toLowerCase(),o.trim()])),i=new Map;for(let o of t){if(g(o)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(o)||e.metadata.dependencies?.some(s=>s.id.trim()===o&&p(s.kind)==="blocked_by"&&b(s.source_kind)))continue;let r=await x(e.pmRoot,n.get(o),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(r===null)continue;let c=await k(r,{schema:e.settings.schema});if(r.id=await P(r.itemPath,r.id),c.document.metadata.id!==r.id)throw new l(`Blocker identity differs from its canonical file: ${r.id}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});i.set(o.toLowerCase(),c.document.metadata)}return Ue(M({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},i,ne(e.settings.schema)),i)}(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]="222cbba7-e2df-5afb-8d75-14f9f99b3bd2")}catch{}})();var Ee="item_revision_conflict",Ge=10,Ce=/^[0-9a-f]{64}$/u;function y(e,t){return new l(`Invalid expected revision ${JSON.stringify(e)}: ${t}.`,u.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function Re(e){let t=typeof e=="string"?e.trim().toLowerCase():"";if(!Ce.test(t))throw y(String(e),"the revision is not a 64-character hexadecimal item_hash");return t}function qe(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw y(String(t),"expected a string");let n=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw y(t,"the value is empty");let i=o=>te(t)===t?o:ee;return n.map(o=>{let r=o.lastIndexOf("="),c=r===-1?void 0:o.slice(0,r).trim();if(c!==void 0&&c.length===0)throw y(i(o),"the item id before = is empty");let s=r===-1?o:o.slice(r+1);if(!Ce.test(s.trim().toLowerCase()))throw y(i(s),"the revision is not a 64-character hexadecimal item_hash");let a=Re(s);return c===void 0?{itemHash:a}:{id:c,itemHash:a}})})}async function Se(e,t){let n=await pe(e),i=X(n,he()).type_to_folder,o=await x(e,t,n.id_prefix,n.item_format,i);if(o){let{document:r}=await k(o,{schema:n.schema});if(r.metadata.id!==await P(o.itemPath,o.id))throw new l(`Item file ${o.id} embeds the id ${r.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,u.CONFLICT,{code:"item_identity_conflict",item_id:o.id,required:`Repair ${o.id}'s identity first (pm validate reports it; pm restore ${o.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:r.metadata.id,document:r}}try{return{id:(await ve(e,t,n,i)).id,document:W}}catch{throw await _e(e,t,n.id_prefix,i)}}function $(e){return Q(e.cwd??process.cwd(),e.pmRoot)}async function Dt(e,t={}){let n=await Se($(t),e);return{id:n.id,item_hash:oe(n.document)}}async function Te(e,t,n){let i=[];for(let o of t){let r=o.id??n;if(r===void 0||r.trim().length===0)throw new l("A bare expected revision needs an item to bind to.",u.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});i.push({id:(await Se(e,r)).id,itemHash:o.itemHash})}return i}function ze(e){return[...new Set(e.patch.map(t=>{let n=t.path.split("/");return String(n[1]==="metadata"?n[2]:n[1])}))].sort()}async function We(e,t,n){let i;try{i=await ie(Z(e,t),t)}catch{return}let o=-1;for(let s=i.length-1;s>=0;s-=1){let a=i[s];if(a.after_hash===n){o=s+1;break}if(a.before_hash===n){o=s;break}}if(o===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let r=i.slice(o),c=r.slice(-Ge);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ze(s)})),changes_since_omitted:r.length-c.length}}async function Ot(e,t){if(!R(e))return{};let n=await Be(e,t);return{error_code:Ee,expected_revision:String(n.context.expected_revision),current_revision:String(n.context.current_revision),details:n.context.details}}function R(e){return ye(e)&&e.context.code===Ee}function Lt(e){let t=e.find(n=>R(n));if(t!==void 0)throw t}function Mt(){return new l("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",u.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function Ve(e,t){if(t===void 0||!R(e)||typeof e.context.item_id!="string"||ue(e))return e;let n=e.context.reason===de;if(!n&&e.context.reason!==ae)return e;let i=me(N(e,new l(e.message,e.exitCode,{...e.context,...le(e.context.item_id,n,t)})));return i.stack=e.stack,i}async function Be(e,t,n){if(!fe(e,t))return e;let i=Ve(e,n);if(!R(i)||i.context.details!==void 0)return i;let o=i.context.item_id,r=i.context.expected_revision;if(typeof o!="string"||typeof r!="string")return i;let c;try{c=await We(t,o,r)}catch{return i}if(c===void 0)return i;let s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(m=>({ts:m.ts,op:m.op,author:m.author,fields:[...m.fields]})),changes_since_omitted:c.changes_since_omitted},a=N(i,new l(i.message,i.exitCode,{...i.context,details:s}));return a.stack=i.stack,a}async function Ne(e,t,n){try{return{result:await re(e,t),...se(e)}}catch(i){throw e.pmRoot===void 0?i:await Be(i,e.pmRoot,n)}}function Ye(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",$(e)]}}async function Ht(e,t,n={}){return Ne(await je(e,n),t,Ye(n))}async function je(e,t={}){let n=$(t),i=e.map(({id:r,itemHash:c})=>({id:r,itemHash:Re(c)})),o=T();return B(o,n,await Te(n,i)),o}function Pt(e){let t=ce(e);return t===void 0||t.length>0}function Xe(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var ke=new Set(V);function Je(e,t={}){let n=e.trim().replace(/\s+/gu,"-"),i=ke.has(n)?n:e;if(ke.has(i)&&(!Ie(i)||i==="deps")&&!Y.has(i))throw Qe(i);if((i==="test"||i==="test-all")&&t.background===!0)throw new l(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,u.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${i} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function Qe(e){return new l(`--expect-hash guards item writes, and ${e} is not a mutation.`,u.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function Ze(e,t){if(t.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let n=e,i=Array.isArray(n.warnings)?n.warnings:[];return{...n,warnings:[...i,...t.map(Xe)]}}async function $t(e){let t=e.expectHash;if(t!==void 0&&typeof t!="string"&&!(Array.isArray(t)&&t.every(r=>typeof r=="string")))throw y(JSON.stringify(t)??String(t),"expected a string or an array of strings");let n=qe(t);if(n.length===0)return e.run();Je(e.action,{background:e.background===!0||e.options?.background===!0});let i=T();B(i,e.pmRoot,await Te(e.pmRoot,n,e.defaultId));let o=await Ne(i,e.run,e.invocation);return Ze(o.result,o.unchecked)}export{D as a,Le as b,_ as c,C as d,we as e,M as f,Me as g,He as h,Fe as i,ht as j,Ee as k,Ge as l,Re as m,qe as n,Dt as o,Te as p,We as q,Ot as r,R as s,Lt as t,Mt as u,Ve as v,Be as w,Ne as x,Ht as y,je as z,Pt as A,Xe as B,Je as C,Qe as D,$t as E};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as ve}from"./chunk-DG2EOOFX.js";import{Dd as g,Ed as b,Nc as Ie,oc as ge,pc as ye,qb as x,rb as k,xb as _e}from"./chunk-7ESF676D.js";import{v as pe}from"./chunk-OXG5XPC7.js";import{Cc as ne,Ch as ae,Dh as de,Ea as j,Eh as le,Fh as fe,Gh as ue,Hh as me,Ih as N,Ka as X,Ma as J,O as V,Sa as Q,Sh as p,X as Y,Ya as Z,Zc as v,_c as w,ce as ie,cj as he,mb as ee,nb as te,oh as oe,vh as T,wh as re,xh as B,yh as se,zh as ce}from"./chunk-FOYRE23V.js";import{A as u,C as l,z as W}from"./chunk-5OFMWP3Q.js";import{readdir as Ke}from"node:fs/promises";import H from"node:path";(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]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function D(e,t){return(t===void 0?void 0:J(e,t))?.execution_role??j[e.trim().toLowerCase()]??"agent"}var O="blocked_by",be="blocks",Le=Object.freeze([O,be]),A="no-active-blocker";function d(e){return e.trim().toLowerCase()}function E(e,t){return t?`external:${e}`:`local:${d(e)}`}function _(e){let t=new Map,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(n.length>0&&d(n)!==A){let i=g(n);t.set(E(n,i),i?n:d(n))}for(let i of e.dependencies??[]){let o=typeof i.id=="string"?i.id.trim():"";if(p(i.kind)===O&&o.length>0&&d(o)!==A){let r=g(o)||b(i.source_kind);t.set(E(o,r),r?o:d(o))}}return[...t.values()].sort((i,o)=>i.localeCompare(o))}function C(e){let t=new Map;for(let n of e){let i=d(n.id);i.length!==0&&t.set(i,new Set(_(n)))}for(let n of e){let i=d(n.id);if(i.length!==0)for(let o of n.dependencies??[]){let r=p(o.kind)===be&&typeof o.id=="string"?d(o.id):"";if(r.length===0||r===A)continue;let c=t.get(r)??new Set;c.add(i),t.set(r,c)}}return new Map([...t].map(([n,i])=>[n,[...i].sort((o,r)=>o.localeCompare(r))]))}function we(e,t){let n=d(e.id);return n.length>0?C(t).get(n)??_(e):_(e)}function L(e,t,n,i){let o=e,r=typeof o.id=="string"?i?.get(d(o.id))??we(o,[...t.values()]):_(e),c=new Set((e.dependencies??[]).filter(s=>p(s.kind)===O&&b(s.source_kind)&&typeof s.id=="string"&&s.id.trim().length>0).map(s=>E(s.id.trim(),!0)));return r.map(s=>{if(g(s)||c.has(E(s,!0)))return{id:s,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let a=t.get(d(s));return a?{id:s,title:a.title,status:a.status,resolved:w(a.status,n)}:{id:s,title:null,status:null,resolved:!1}})}function M(e,t,n){return L(e,t,n)}function Me(e,t){let n=new Map(e.map(c=>[d(c.id),c])),i=C(e),o=new Set([...xe(t),...t.blocked_statuses]),r=new Set;for(let c of e){let s=v(c.status,t);o.has(s)&&(t.blocked_statuses.has(s)||L(c,n,t,i).some(a=>!a.resolved))&&r.add(d(c.id))}return r}function He(e,t,n={},i){let o=[...e.ready,...e.decisions,...e.gates];n.includeContainers===!0&&o.push(...e.containers.filter(c=>c.open_blockers.length===0&&!t.blocked_statuses.has(v(c.item.status,t))));let r={ready:[],decisions:[],gates:[]};for(let c of o){let s=D(c.item.type,i);s==="human"&&n.includeDecisions!==!0?r.decisions.push(c):s==="gate"&&n.includeGates!==!0?r.gates.push(c):r.ready.push(c)}return r}function xe(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function Pe(e,t,n){let i=[d(e)],o=new Set;for(;i.length>0;){let r=i.pop();if(!o.has(r)){o.add(r);for(let c of t.get(r)??[]){if(!w(c.status,n))return!0;i.push(d(c.id))}}}return!1}function $e(e){let t=new Map,n=new Map,i=new Map,o=C(e);for(let r of e){t.set(d(r.id),r);let c=typeof r.parent=="string"?r.parent.trim():"";if(c.length>0){let s=d(c),a=n.get(s)??[];a.push(r),n.set(s,a)}for(let s of o.get(d(r.id))){let a=d(s),m=i.get(a)??[];m.push(r.id),i.set(a,m)}}return{itemsById:t,childrenByParent:n,blockedByReverse:i,blockerIdsByItem:o}}function Fe(e,t,n,i){let{itemsById:o,childrenByParent:r,blockedByReverse:c,blockerIdsByItem:s}=$e(t),a=new Set([...xe(n),...n.blocked_statuses]),m=new Set(t.filter(f=>!w(f.status,n)).map(f=>d(f.id))),F=[],K=[],S=[],U=[],G=[],q=0;for(let f of e){if(!a.has(v(f.status,n)))continue;q+=1;let z=L(f,o,n,s).filter(h=>!h.resolved),Ae=(c.get(d(f.id))??[]).filter(h=>m.has(d(h))).sort((h,Oe)=>h.localeCompare(Oe)),I={item:f,open_blockers:z,unblocks:Ae};if(Pe(f.id,r,n)){S.push(I);continue}let De=n.blocked_statuses.has(v(f.status,n));if(z.length===0&&!De){let h=D(f.type,i);h==="human"?U.push(I):h==="gate"?G.push(I):F.push(I)}else K.push(I)}return{ready:F,blocked:K,containers:S,decisions:U,gates:G,active_count:q,container_count:S.length}}(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]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();(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]="e9b7731d-e6f5-51a8-970b-462c0b728a9c")}catch{}})();function Ue(e,t){let n=new Map;for(let i of e){let o=i.external?i.id:t.get(i.id.toLowerCase())?.id??i.id;n.set(i.external?`external:${o}`:`local:${o.toLowerCase()}`,{...i,id:o})}return[...n.values()]}async function P(e,t){let n=H.basename(e),i=(await Ke(H.dirname(e)).catch(o=>{throw ge("Cannot verify the blocker's physical file identity",{exitCode:u.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===n.toLowerCase()).sort((o,r)=>+(r===n)-+(o===n)||o.localeCompare(r)).map(o=>H.parse(o).name)[0];if(i===void 0)throw new l(`Blocker canonical file disappeared during identity verification: ${t}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return i}async function ht(e){let t=_(e.metadata);if(t.length===0)return[];let n=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(o=>p(o.kind)==="blocked_by").map(o=>o.id)].filter(o=>typeof o=="string").map(o=>[o.trim().toLowerCase(),o.trim()])),i=new Map;for(let o of t){if(g(o)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(o)||e.metadata.dependencies?.some(s=>s.id.trim()===o&&p(s.kind)==="blocked_by"&&b(s.source_kind)))continue;let r=await x(e.pmRoot,n.get(o),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(r===null)continue;let c=await k(r,{schema:e.settings.schema});if(r.id=await P(r.itemPath,r.id),c.document.metadata.id!==r.id)throw new l(`Blocker identity differs from its canonical file: ${r.id}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});i.set(o.toLowerCase(),c.document.metadata)}return Ue(M({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},i,ne(e.settings.schema)),i)}(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]="222cbba7-e2df-5afb-8d75-14f9f99b3bd2")}catch{}})();var Ee="item_revision_conflict",Ge=10,Ce=/^[0-9a-f]{64}$/u;function y(e,t){return new l(`Invalid expected revision ${JSON.stringify(e)}: ${t}.`,u.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function Re(e){let t=typeof e=="string"?e.trim().toLowerCase():"";if(!Ce.test(t))throw y(String(e),"the revision is not a 64-character hexadecimal item_hash");return t}function qe(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw y(String(t),"expected a string");let n=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw y(t,"the value is empty");let i=o=>te(t)===t?o:ee;return n.map(o=>{let r=o.lastIndexOf("="),c=r===-1?void 0:o.slice(0,r).trim();if(c!==void 0&&c.length===0)throw y(i(o),"the item id before = is empty");let s=r===-1?o:o.slice(r+1);if(!Ce.test(s.trim().toLowerCase()))throw y(i(s),"the revision is not a 64-character hexadecimal item_hash");let a=Re(s);return c===void 0?{itemHash:a}:{id:c,itemHash:a}})})}async function Se(e,t){let n=await pe(e),i=X(n,he()).type_to_folder,o=await x(e,t,n.id_prefix,n.item_format,i);if(o){let{document:r}=await k(o,{schema:n.schema});if(r.metadata.id!==await P(o.itemPath,o.id))throw new l(`Item file ${o.id} embeds the id ${r.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,u.CONFLICT,{code:"item_identity_conflict",item_id:o.id,required:`Repair ${o.id}'s identity first (pm validate reports it; pm restore ${o.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:r.metadata.id,document:r}}try{return{id:(await ve(e,t,n,i)).id,document:W}}catch{throw await _e(e,t,n.id_prefix,i)}}function $(e){return Q(e.cwd??process.cwd(),e.pmRoot)}async function Dt(e,t={}){let n=await Se($(t),e);return{id:n.id,item_hash:oe(n.document)}}async function Te(e,t,n){let i=[];for(let o of t){let r=o.id??n;if(r===void 0||r.trim().length===0)throw new l("A bare expected revision needs an item to bind to.",u.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});i.push({id:(await Se(e,r)).id,itemHash:o.itemHash})}return i}function ze(e){return[...new Set(e.patch.map(t=>{let n=t.path.split("/");return String(n[1]==="metadata"?n[2]:n[1])}))].sort()}async function We(e,t,n){let i;try{i=await ie(Z(e,t),t)}catch{return}let o=-1;for(let s=i.length-1;s>=0;s-=1){let a=i[s];if(a.after_hash===n){o=s+1;break}if(a.before_hash===n){o=s;break}}if(o===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let r=i.slice(o),c=r.slice(-Ge);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ze(s)})),changes_since_omitted:r.length-c.length}}async function Ot(e,t){if(!R(e))return{};let n=await Be(e,t);return{error_code:Ee,expected_revision:String(n.context.expected_revision),current_revision:String(n.context.current_revision),details:n.context.details}}function R(e){return ye(e)&&e.context.code===Ee}function Lt(e){let t=e.find(n=>R(n));if(t!==void 0)throw t}function Mt(){return new l("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",u.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function Ve(e,t){if(t===void 0||!R(e)||typeof e.context.item_id!="string"||ue(e))return e;let n=e.context.reason===de;if(!n&&e.context.reason!==ae)return e;let i=me(N(e,new l(e.message,e.exitCode,{...e.context,...le(e.context.item_id,n,t)})));return i.stack=e.stack,i}async function Be(e,t,n){if(!fe(e,t))return e;let i=Ve(e,n);if(!R(i)||i.context.details!==void 0)return i;let o=i.context.item_id,r=i.context.expected_revision;if(typeof o!="string"||typeof r!="string")return i;let c;try{c=await We(t,o,r)}catch{return i}if(c===void 0)return i;let s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(m=>({ts:m.ts,op:m.op,author:m.author,fields:[...m.fields]})),changes_since_omitted:c.changes_since_omitted},a=N(i,new l(i.message,i.exitCode,{...i.context,details:s}));return a.stack=i.stack,a}async function Ne(e,t,n){try{return{result:await re(e,t),...se(e)}}catch(i){throw e.pmRoot===void 0?i:await Be(i,e.pmRoot,n)}}function Ye(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",$(e)]}}async function Ht(e,t,n={}){return Ne(await je(e,n),t,Ye(n))}async function je(e,t={}){let n=$(t),i=e.map(({id:r,itemHash:c})=>({id:r,itemHash:Re(c)})),o=T();return B(o,n,await Te(n,i)),o}function Pt(e){let t=ce(e);return t===void 0||t.length>0}function Xe(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var ke=new Set(V);function Je(e,t={}){let n=e.trim().replace(/\s+/gu,"-"),i=ke.has(n)?n:e;if(ke.has(i)&&(!Ie(i)||i==="deps")&&!Y.has(i))throw Qe(i);if((i==="test"||i==="test-all")&&t.background===!0)throw new l(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,u.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${i} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function Qe(e){return new l(`--expect-hash guards item writes, and ${e} is not a mutation.`,u.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function Ze(e,t){if(t.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let n=e,i=Array.isArray(n.warnings)?n.warnings:[];return{...n,warnings:[...i,...t.map(Xe)]}}async function $t(e){let t=e.expectHash;if(t!==void 0&&typeof t!="string"&&!(Array.isArray(t)&&t.every(r=>typeof r=="string")))throw y(JSON.stringify(t)??String(t),"expected a string or an array of strings");let n=qe(t);if(n.length===0)return e.run();Je(e.action,{background:e.background===!0||e.options?.background===!0});let i=T();B(i,e.pmRoot,await Te(e.pmRoot,n,e.defaultId));let o=await Ne(i,e.run,e.invocation);return Ze(o.result,o.unchecked)}export{D as a,Le as b,_ as c,C as d,we as e,M as f,Me as g,He as h,Fe as i,ht as j,Ee as k,Ge as l,Re as m,qe as n,Dt as o,Te as p,We as q,Ot as r,R as s,Lt as t,Mt as u,Ve as v,Be as w,Ne as x,Ht as y,je as z,Pt as A,Xe as B,Je as C,Qe as D,$t as E};
|
|
2
|
+
//# sourceMappingURL=chunk-3BOR22MC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$a as te,Ub as et,Vb as tt,Xb as ne,_b as nt,a as Je,ac as rt,bc as it,xc as ot}from"./chunk-S3RMFLEG.js";import{u as Qe}from"./chunk-SSZBVRIN.js";import{wc as Ze}from"./chunk-7ETRLLK3.js";import{m as Xe}from"./chunk-WKHS4QC6.js";import{a as ze,c as U,d as Q,e as Be,f as ee,g as Ve}from"./chunk-OD2I3SFQ.js";import{ra as He,wb as j,xa as Ye,zb as D}from"./chunk-VETSGCF4.js";import{Va as Z,d as Ee,ia as Ge,ka as N,t as Oe,u as Ae,ub as Le,uc as We,v as z}from"./chunk-2VH6COJE.js";import{k as xe,o as qe,v as Ke}from"./chunk-CR5GC3VO.js";import{$c as Ce,Bc as Ie,Bd as Ne,Fc as E,Ka as V,Mc as Y,Ta as ke,a as be,be as Ue,bj as De,ce as R,cj as X,gc as $e,jh as I,oh as je,oj as Fe,pj as Pe,uh as C,vc as Me,xc as H,yc as Re}from"./chunk-7UUPLMCU.js";import{A as p,C as u,G as B,I as Te,J as $,l as ve,q as k,t as _e,y as Se}from"./chunk-5OFMWP3Q.js";import ue from"node:crypto";import{constants as se,readFileSync as Tn}from"node:fs";import{cp as kn,lstat as kt,mkdir as $n,mkdtemp as $t,open as Mn,readdir as Rn,realpath as Mt,rm as Rt,stat as pe,writeFile as It}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import m from"node:path";import yt from"node:crypto";(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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var O=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...ve,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function at(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return O.has(t)?t:e}(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function F(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new u(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,p.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var re=["op","id","reason","options","unique","match"],Lt=[...re,"ref"],st=[...Lt,"item"],Wt="mutate-",ct="row-",dt=["schema_version","mutations"],wt="[a-z][a-z0-9._-]{0,63}",ut=new RegExp(`^${wt}$`,"u"),gt=new RegExp(`(^|,)id=@(${wt})(?=,|$)`,"gu"),pt=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),P=["item","item_hash","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],vt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),Jt=new Set([...vt,"completed_at","id"]),_t={create:j.map(e=>e.target),update:D.map(e=>e.target),close:He.map(e=>pt(e.flag)).filter(e=>e!=="reason"),release:Ye.map(e=>pt(e.flag))};function gr(e){let t=yt.createHash("sha256").update(e).digest("hex");return`${Wt}${t.slice(0,24)}`}function vr(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new u("createCompensation must be close or delete.",p.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let i=e[r];if(i===void 0)continue;let o=typeof i=="number"||typeof i=="string"&&i.trim().length>0?Number(i):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new u(`${r} must be a positive safe integer.`,p.USAGE);t[r]=o}return t}function w(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function G(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let i of t){let o=$e(e,i,n);o!==null&&(r===void 0||o<r.distance)&&(r={key:i,distance:o})}return r?.key}function A(e,t,n){let r=G(t,n);return new u(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,p.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function ae(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new u(`${t} must be valid JSON: ${r}`,p.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function zt(e,t){if(!w(e))throw new u(`Mutation ${t+1} must be an object.`,p.USAGE);for(let n of Object.keys(e))if(!re.includes(n))throw A(`mutation ${t+1}`,n,re);return e}function Bt(e,t,n,r){if(e===void 0)return;if(!w(e))throw new u(`Mutation ${n+1} options must be an object.`,p.USAGE);let i=[..._t[t],...Et(t,r)];for(let o of Object.keys(e))if(!i.includes(o))throw A(`mutation ${n+1} ${t} options`,o,i);return F(e,t,n),e}function lt(e,t,n,r){if(e===void 0)return;let i=r==="unique"?"create":"update";if(t!==i)throw new u(`Mutation ${n+1} ${r} is only valid for ${i} operations.`,p.USAGE);let o=w(e)&&typeof e.key=="string"?e.key.trim():"";if(!w(e)||o.length===0||e.value===void 0||e.value===null)throw new u(`Mutation ${n+1} ${r} must be an object with a non-empty key and a value.`,p.USAGE);return{key:o,value:e.value}}function Vt(e,t,n){let r=zt(e,t),{op:i,id:o,reason:a}=r;if(i!=="create"&&i!=="update"&&i!=="close"&&i!=="release")throw new u(`Mutation ${t+1} op must be create, update, close, or release.`,p.USAGE);let s=Bt(r.options,i,t,n),d=lt(r.unique,i,t,"unique"),c=lt(r.match,i,t,"match");if(typeof o!="string"||o.trim().length===0)throw new u(`Mutation ${t+1} requires a non-empty id.`,p.USAGE);let l=o.trim();if(i==="close"){if(typeof a!="string"||a.trim().length===0)throw new u(`Mutation ${t+1} close requires a non-empty reason.`,p.USAGE);return{op:i,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(i==="release")return{op:i,id:l,...s===void 0?{}:{options:s}};if(!w(s))throw new u(`Mutation ${t+1} ${i} requires an options object.`,p.USAGE);return{op:i,id:l,options:s,...d===void 0?{}:{unique:d},...c===void 0?{}:{match:c}}}function St(e,t={}){let n=ae(e,"Mutation batch"),r=Array.isArray(n)?n:w(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(r===void 0||r.length===0)throw new u("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",p.USAGE);let i=t.runtimeFields??[];return r.map((o,a)=>{let s=Vt(o,a,i);return s.options!==void 0&&Oe(s.options),s})}function Ht(e,t,n){let r=yt.createHash("sha256").update(e).update("\0").update(t).digest("hex"),i=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ge(n)}${i}`}function mt(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new u(`Unknown mutation reference "${e}".`,p.USAGE);return r}function ft(e,t){if(typeof e!="string")return e;let n=e.replace(gt,(r,i,o)=>{let a=t[o];if(a===void 0)throw new u(`Unknown mutation reference "@${o}".`,p.USAGE);return`${i}id=${a}`});if(/(^|,)id=@/u.test(n))throw new u(`Malformed mutation reference in dependency "${e}".`,p.USAGE);return n}function Yt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(gt)].map(t=>t[1]).filter(t=>t!==void 0)}function Xt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let c=w(s.options)?s.options:{},l=Array.isArray(c.dep)?c.dep:c.dep===void 0?[]:[c.dep];n.set(d,[c.parent,c.blockedBy,...l].flatMap(Yt))}let r=new Set,i=new Set,o=a=>{if(r.has(a))throw new u(`Mutation reference cycle includes "@${a}".`,p.USAGE);if(!i.has(a)){r.add(a);for(let s of n.get(a))n.has(s)&&o(s);r.delete(a),i.add(a)}};for(let a of n.keys())o(a)}function Zt(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),r=n[0];if(!r.ok&&(r.line.startsWith("[")||r.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&w(o.value)))return null;let i=[];for(let o of n){if(!o.ok)throw new u(`Mutation document line ${o.number} must be one valid JSON object: ${We(o.error)}`,p.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!w(o.value))throw new u(`Mutation document line ${o.number} must be a JSON object.`,p.USAGE);i.push(o.value)}return i}function Qt(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function en(e){let t;try{t=ae(e,"Mutation document")}catch(n){let r=Zt(e);if(r===null)throw n;return{schema_version:1,mutations:r}}return Array.isArray(t)?{schema_version:1,mutations:t}:w(t)&&!Qt(t)?{schema_version:1,mutations:[t]}:t}function tn(e,t){let n=Object.hasOwn(e,"op")?nn(e,t):rn(e,t);if(n.op==="create"&&n.id===void 0&&w(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new u(`Mutation ${t+1} item id must be a string.`,p.USAGE);n.id=n.item.id}return n}function nn(e,t){for(let n of Object.keys(e))if(!st.includes(n))throw A(`mutation ${t+1}`,n,st);if(e.item!==void 0&&e.op!=="create")throw new u(`Mutation ${t+1} item documents are only valid for create operations.`,p.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new u(`Mutation ${t+1} must declare either item or options, not both.`,p.USAGE);return{...e}}function rn(e,t){let{ref:n,id:r,item:i,...o}=e,a=i!==void 0?i:o;if(i!==void 0&&Object.keys(o).length>0)throw new u(`Mutation ${t+1} must not mix item document keys with top-level fields.`,p.USAGE);if(!w(a))throw new u(`Mutation ${t+1} item document must be an object.`,p.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...r===void 0?{}:{id:r},item:a}}function on(e){let t=en(e);if(!w(t))throw new u("Mutation document must be a JSON array or object.",p.USAGE);for(let n of Object.keys(t))if(!dt.includes(n))throw A("mutation document",n,dt);if(t.schema_version!==void 0&&t.schema_version!==1)throw new u("Mutation document schema_version must be 1.",p.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new u("Mutation document requires a non-empty mutations array.",p.USAGE);return t.mutations.map((n,r)=>{if(!w(n))throw new u(`Mutation ${r+1} must be an object.`,p.USAGE);return tn(n,r)})}function an(e,t,n){let r=new Set(Object.values(At(t,n,Object.create(null))));for(let i of t)i.op==="create"&&typeof i.id=="string"&&i.id.trim().length>0&&r.add(N(i.id,n.idPrefix));return{...e,existing:e.existing.filter(i=>!r.has(i.id))}}function sn(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,r]of e.entries()){if(r.op!=="create"||r.ref!==void 0||typeof r.id=="string"&&r.id.trim().length>0)continue;let i=`${ct}${n+1}`;if(t.has(i))throw new u(`Mutation ${n+1} receives the synthesized ref "${i}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${ct}<n> aliases are reserved for rows without one.`,p.USAGE);r.ref=i}}function bt(e,t,n){let r=An(JSON.stringify(e),t,{},n);return delete r.stdinJson,delete r.documentAnnotationSnapshot,r}function Et(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function cn(e,t){for(let n of e)w(n.item)&&(n.options=bt(n.item,"create",t),delete n.item)}function Ot(e,t){return t.some(n=>n.metadata_key===e)?e:at(e)}function ie(e,t,n){let r=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(w(e.item)){if(e.item[t]!==void 0)return e.item[t];if(Ot(r,n)===t&&e.item[r]!==void 0)return e.item[r]}let i=w(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&i[E(o)]!==void 0?i[E(o)]:i[t]!==void 0?i[t]:i[r]!==void 0?i[r]:(Array.isArray(i.field)?i.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function dn(e,t){return e<t?-1:+(e!==t)}function oe(e){return Array.isArray(e)?e.map(oe):w(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>dn(t,n)).map(([t,n])=>[t,oe(n)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(oe(e))}function un(e,t,n,r,i){let o=t.key.trim();if(o.length===0)throw new u("Upsert key must be a non-empty field name.",p.USAGE);let a=pn(t.existing),s=new Map,d=new Set;for(let[c,l]of e.entries()){if(l.op!=="create")continue;let f=ln(l,o,c,s,r),y=mn(a.get(f)??[],o,f);if(y===void 0){l.unique={key:o,value:ie(l,o,r)};continue}let h=N(y,n);typeof l.ref=="string"&&(i[l.ref]=h),fn(l,h,r,{key:o,value:ie(l,o,r)}),d.add(c)}return d}function pn(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let r=_(n.value);t.set(r,[...t.get(r)??[],n.id])}return t}function ln(e,t,n,r,i){let o=ie(e,t,i);if(o==null||o==="")throw new u(`Mutation ${n+1} is missing the upsert key "${t}".`,p.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=_(o),s=r.get(a);if(s!==void 0)throw new u(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return r.set(a,n),a}function mn(e,t,n){if(e.length>1)throw new u(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,p.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function fn(e,t,n,r){let i=new Set([..._t.update,...Et("update",n)]),o=w(e.item)?bt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>i.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=r}function At(e,t,n){for(let[r,i]of e.entries())if(i.ref!==void 0){if(i.op!=="create")throw new u(`Mutation ${r+1} ref is only valid for create operations.`,p.USAGE);if(typeof i.ref!="string"||!ut.test(i.ref))throw new u(`Mutation ${r+1} ref must match ${ut.source}.`,p.USAGE);if(n[i.ref]!==void 0)throw new u(`Duplicate mutation ref "${i.ref}".`,p.USAGE);n[i.ref]=typeof i.id=="string"&&i.id.trim().length>0?N(i.id,t.idPrefix):Ht(t.transactionId,i.ref,t.idPrefix)}return n}function _r(e,t){let n=on(e);sn(n);let r=n.map(l=>typeof l.ref=="string"?l.ref:void 0),i=Object.create(null),o=t.upsert===void 0?new Set:un(n,an(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],i);cn(n,t.runtimeFields??[]),At(n,t,i),Xt(n,r);let a=n.map(l=>{let f={...l},y=typeof f.ref=="string"?f.ref:void 0;if(delete f.ref,y!==void 0?f.id=i[y]:f.id=mt(f.id,i),w(f.options)){let h={...f.options};for(let g of["parent","blockedBy"])h[g]!==void 0&&(h[g]=mt(h[g],i));Array.isArray(h.dep)?h.dep=h.dep.map(g=>ft(g,i)):h.dep!==void 0&&(h.dep=ft(h.dep,i)),f.options=h}return f}),s=St(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new u("Duplicate resolved create id in mutation document.",p.USAGE);let c=s.map((l,f)=>{let y=r[f];return{index:f,...typeof y=="string"?{ref:y}:{},id:l.id,op:l.op,...o.has(f)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:i,rows:c}}function hn(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let r=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function yn(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(w))throw new u(`${n} must be an array of objects.`,p.USAGE);return e.map(r=>hn(r,t))}}function wn(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function ht(e,t,n=!1){for(let[r,i,o]of Ze){let a=t[r],s=yn(n&&["comments","notes","learnings"].includes(r)&&Array.isArray(a)?a.filter(d=>!w(d)||d.created_at===void 0):a,o,r);s!==void 0&&s.length>0&&(e[i]=s)}}function gn(e,t){for(let n of Object.keys(e)){if(t){if(!P.includes(n))throw A("item envelope",n,P);continue}if(!O.has(n)&&G(n,[...O])===void 0&&G(n,P)==="item")throw A("item envelope",n,P)}}function vn(e){let t=Object.hasOwn(e,"item");gn(e,t);let n=t?e.item:e;if(!w(n))throw new u("Item document item must be an object.",p.USAGE);return{item:n,...t&&w(e.linked)?{linked:e.linked}:{}}}function _n(e,t,n,r,i,o){if((r==="update"?Jt:vt).has(t))return;let a=i.find(s=>s.metadata_key===t&&s.commands.includes(r));if(a!==void 0){let s=Y(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!O.has(t)){if(G(t,[...O])!==void 0)throw A("item document",t,[...O]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=wn(t,n))}function Sn(e){return{command_to_fields:new Map([["create",e.filter(t=>t.commands.includes("create"))]])}}function bn(e,t,n,r){let i=r.filter(c=>c.commands.includes("create")),o=new Set([...Ce.filter(c=>t.has(c.option)).map(c=>c.field),...i.filter(c=>t.has(E(c))).map(c=>c.metadata_key),...Xe(Array.isArray(n)?n.map(String):[],Sn(i)).metadataKeys]),a=(Array.isArray(e)?e:[]).filter(w).filter(c=>typeof c.field=="string"&&!o.has(c.field));if(a.length===0)return{};let s=a.map(c=>typeof c.reason=="string"?c.reason.trim():""),d=a.map(c=>c.field);return t.has("deferReason")?{defer:d}:s.every(c=>c.length>0)?{defer:d,deferReason:[...new Set(s)].join("; ")}:{defer:d}}function En(e,t,n){let r=new Set(Object.entries(e).filter(([,o])=>o!==void 0).map(([o])=>o)),i=t==="create"?j:D;for(let{target:o,keys:a}of i)a.some(s=>r.has(s))&&r.add(o);for(let o of n.filter(a=>a.commands.includes(t)))Y(e,o)!==void 0&&r.add(E(o));return r}function On(e,t,n){let r=t==="create"?j:D;for(let{target:i}of r)i!=="field"&&n.has(i)&&delete e[i]}function An(e,t,n={},r=[]){let i=ae(e,"Item document");if(!w(i))throw new u("Item document must be a JSON object.",p.USAGE);let{item:o,linked:a}=vn(i),s={};for(let[f,y]of Object.entries(o)){let h=Ot(f,r);h!==f&&Object.hasOwn(o,h)||_n(s,h,y,t,r,n)}ht(s,o,t==="update"),a!==void 0&&ht(s,a);let d=En(n,t,r);if(On(s,t,d),t==="create"&&!d.has("defer")&&Object.assign(s,bn(o.deferred_fields,d,n.unset,r)),t==="update"){let f=Object.fromEntries(["comments","notes","learnings"].filter(y=>Object.hasOwn(o,y)&&!d.has(y.slice(0,-1))).map(y=>[y,o[y].filter(h=>w(h)&&h.created_at!==void 0)]));Object.keys(f).length>0&&(s.documentAnnotationSnapshot=f)}let c={...s,...Object.fromEntries(Object.entries(n).filter(([,f])=>f!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0},l=Object.keys(s).filter(f=>!d.has(f));return Ae(Ee(c,l),l)}function Sr(e){return St(JSON.stringify(e))}(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]="359a47e6-c7e8-5713-bd07-1e19fb81674a")}catch{}})();async function In(e,t){if(!qe(e))return{schema:H(t.schema),typeDefinitionsFromFile:[]};let n=await Wn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Cn(e,t,n,r){let i=V({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},X());return(await Le(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function le(e){let t=new Map,n=async r=>{let i=await Ke(e),o=await In(e,i),a=new Map;for(let s of await Cn(e,i,o,r)){let d=_(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,o]of t){let a=r[i];if(a==null)continue;let s=await o,d=_(a);s.set(d,[...s.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function Nn(e,t){let n=_(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new u(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,p.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function Un(e,t,n){let r=e.metadata[n.key],i=_(n.value);if(_(r)!==i)throw new u(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,p.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function Tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function L(e,t){let n={...e,...t};return e===void 0?n:z(e,n)}async function b(e,t){try{let n=(await te(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof u&&n.exitCode===p.NOT_FOUND)return;throw n}}function me(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ue.createHash("sha256").update(be(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function jn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function v(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function fe(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function M(e,t,n,r){let i=await R(m.join(e,"history",`${t}.jsonl`),t),o=v(n,r,"apply"),a=v(n,r,"compensate");for(let s=i.length-1;s>=0;s-=1){let d=i[s].message;if(fe(d,o))return!0;if(d===a)return!1}return!1}async function he(e,t){let n=await b(e,t.id);if(n?.updatedAt===void 0)throw new u(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,p.NOT_FOUND);let r=await R(m.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new u(`Bulk ${t.op} target ${t.id} has no restorable history`,p.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(Z(r)+r.length),target_history_hash:I(r),target_history_length:r.length}}function T(e,t,n){return new u(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,p.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Nt(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Dn(e,t,n){let{expectedHistory:r,length:i,version:o}=t;if(I(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||I(e.slice(0,i))!==r||o!==String(Z(e)+i))throw T(n,n.itemId,n.stepId);let a=v(n.transactionId,n.stepId,"apply"),s=e.slice(i),d=y=>fe(y.message,a)||y.context?.item_transaction_step===a,c=v(n.transactionId,n.stepId,"compensate");if(s.filter(y=>d(y)||y.message===c).at(-1)?.message===c)return!1;let l=s.filter(d);if(l.length===0)return!1;let f=e.at(-1).after_hash===l.at(-1).after_hash&&s.every(y=>Nt(y,n.transactionId));if(l.length!==s.length&&!f)throw T(n,n.itemId,n.stepId);return!0}async function Ut(e,t){let n=m.join(e,"history",`${t}.jsonl`),r=await Ue(n,t);return{history:r.entries,assertOwnedUnderLock:(i,o)=>{let a;try{a=Tn(n).equals(r.raw_bytes)&&je(i)===r.entries.at(-1).after_hash}catch(s){throw Object.assign(o(),{cause:s})}if(!a)throw o()}}}async function W(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let o=i.target_updated_at,a=await b(e.pmRoot,t);if(a===void 0)return;let{history:s,assertOwnedUnderLock:d}=await Ut(e.pmRoot,a.id),c=i.target_history_hash,l=typeof c=="string";if(typeof c=="string"){if(!Dn(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:a.id,stepId:n}))return}else{if(a.updatedAt===o)return;if(!await M(e.pmRoot,a.id,e.transactionId,n))throw T(e,a.id,n)}let f=()=>it(t,typeof i.target_version=="string"?i.target_version:o,{force:!0,author:e.author,message:v(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await C({pmRoot:e.pmRoot,id:a.id,validate:y=>{d(y,()=>T(e,a.id,n))},compensation:Dt(e,t,n,"restore",l)},f)}var jt=new WeakMap;function Dt(e,t,n,r,i){let o=i?ze(e.pmRoot,e.transactionId):void 0,a=o===void 0?void 0:jt.get(o);if(!(a?.stepId!==n||a.itemId!==t||a.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function Ft(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await R(m.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new u(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,p.CONFLICT,{code:"transaction_create_compensated",item_id:r.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await Nn(e.uniqueIndex,t.unique);let r=await et(L(t.options,{author:e.author,id:t.id,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await Fn(e,t.id,n)}}}async function Fn(e,t,n){let r=await b(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:o}=await Ut(e.pmRoot,r.id),a=v(e.transactionId,n,"apply"),s=v(e.transactionId,n,"compensate"),d=i.filter(c=>fe(c.message,a)||c.message===s).at(-1);if(d?.message!==s){if(d===void 0||!i.every(c=>Nt(c,e.transactionId)))throw T(e,r.id,n);await C({pmRoot:e.pmRoot,id:r.id,validate:c=>{o(c,()=>T(e,r.id,n))},compensation:Dt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:s};e.createCompensation==="delete"?await rt(t,c,{pmRoot:e.pmRoot}):await ne(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Pn(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=()=>tt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,o=i,a=(await C({pmRoot:e.pmRoot,id:String((await te(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{o!==void 0&&Un(s,t.id,o)},committed:s=>{i!==void 0&&(o={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:v(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await W(e,t.id,n,r)}}}function Gn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=(await ne(t.id,t.reason,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"close"}},async compensate(r){await W(e,t.id,n,r)}}}function xn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=(await nt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"release"}},async compensate(r){await W(e,t.id,n,r)}}}function ye(e,t,n){let r=me(t,n),i=qn(e,t,r);return jt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function qn(e,t,n){switch(t.op){case"create":return Ft(e,t,n);case"update":return Pn(e,t,n);case"close":return Gn(e,t,n);case"release":return xn(e,t,n)}}function Kn(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!Tt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!Tt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);F(e.options,e.op,t)}function Pt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Kn(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:o}=r.unique,a=t.get(i)??new Map,s=_(o),d=a.get(s);if(d!==void 0)throw new u(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(i,a)}}function Gt(e){let t=[...e];return Pt(t),t.map(n=>{let r=structuredClone(n);return n.options!==void 0&&r.options!==void 0&&z(n.options,r.options),r})}function xt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:xt(r,i)})}async function ce(e,t,n){try{return await n()}catch(r){throw r instanceof u?new u(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function qt(e,t,n,r){let i=m.relative(e,t),o=i.split(m.sep);return o[0]==="extensions"&&o[2]==="node_modules"&&!r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))?!1:["locks","runtime","search"].includes(i.split(m.sep)[0])?r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`)):i===""||n===void 0||n.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))}async function q(e,t){let n=await kt(t);if(n.isSymbolicLink())await pe(t);else if(n.isDirectory()||n.isFile())return n;throw $(m.relative(e,t))}async function Ln(e,t){let n=await Mn(t,se.O_RDONLY|se.O_NOFOLLOW|se.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(m.relative(e,t));let i=ue.createHash("sha256");if(r.size>0)for await(let o of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(o);return i.digest()}finally{await n.close()}}async function de(e,t,n){let r=ue.createHash("sha256");async function i(o){for(let a of(await Rn(o)).sort()){let s=m.join(o,a);qt(e,s,t,n)&&((await q(e,s)).isDirectory()?await i(s):(r.update(JSON.stringify(m.relative(e,s))),r.update(await Ln(e,s))))}}return await i(e),r.digest("hex")}function x(){return new u("Tracker changed while preparing the transaction preview; retry against stable state.",p.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function we(e){if(!B(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),r=n;for(;;)try{let i=await kt(r);return r!==n&&i.isDirectory()}catch(i){if(!B(i))return!1;let o=m.dirname(r);if(o===r)return!1;r=o}}async function K(e,t){let n=m.join(e,t);try{let r=e;for(let i of t.split(m.sep).slice(0,-1))r=m.join(r,i),await q(e,r);if(!(await q(e,n)).isFile())throw $(t);return await Te(n,$(t))}catch(r){if(await we(r))return;throw r}}async function Kt(e,t,n,r){let i=H(n);for(let[o,a]of Object.entries(i.files)){let s=m.relative(e,Re(e,a,Me[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new u("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",p.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});i.files[o]=s;let d=await K(e,s);if(r?.set(s,d),d!==void 0){let c=m.join(t,s);await $n(m.dirname(c),{recursive:!0}),await It(c,d)}}return Ie(t,i)}async function Wn(e,t){await pe(e);let n=await $t(m.join(Ct(),"pm-schema-plan-"));try{let r=await Mt(e);return await Kt(r,m.join(n,"configuration"),t)}catch(r){throw await we(r)?x():r}finally{await Rt(n,{recursive:!0,force:!0})}}async function Jn(e,t,n){let r=new Map,i=await K(e,k);r.set(k,i);let o;try{o=JSON.parse(i??"null")}catch{o=null}let a=xe(o),s=a.success?a.data:void 0,d=await Kt(e,t,s?.schema,r),c=d.schema,l=m.relative(e,Ne(e));r.set(l,await K(e,l));let f=V({...Se,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),y=ke(e)===e?[..._e.filter(Boolean),k,Je,"transactions",...f.folders,...r.keys()].map(g=>m.normalize(g)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:c.files}});return{configuration:r,ownedPaths:y,stagedSettings:h,registryFolders:f.folders}}async function zn(e,t,n){await pe(e);try{let r=await Mt(e),i=await Jn(r,m.join(m.dirname(t),"configuration"),n),o=[...i.configuration.keys(),...i.registryFolders].map(c=>m.normalize(c)),a=await de(r,i.ownedPaths,o);await kn(r,t,{recursive:!0,dereference:!1,filter:async c=>qt(r,c,i.ownedPaths,o)?(await q(r,c),!0):!1});let[s,d]=await Promise.all([de(r,i.ownedPaths,o),de(t,i.ownedPaths,o)]);if(a!==s||a!==d)throw x();for(let[c,l]of i.configuration)if(await K(t,c)!==l)throw x();i.stagedSettings!==void 0&&await It(m.join(t,k),i.stagedSettings)}catch(r){throw await we(r)?x():r}}async function Qr(e){let t=U(e),n=Gt(e.mutations),r=X(),i=Pe(),o=await $t(m.join(Ct(),"pm-transaction-preview-")),a=m.join(o,"tracker");try{await zn(t.pmRoot,a,r);let s=!1,d=[],c=[],l=new Set;return await Fe(i,()=>ot({path:a,noExtensions:!0},async()=>{De(r);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:le(a)},y=n.map((h,g)=>{let S=ye({...f,onCreateWarnings:(J,ge)=>{ge.length>0&&d.push({index:g,id:J,op:"create",warnings:ge})}},h,g);return{...S,inspect:()=>ce(h,g,()=>S.inspect()),prepareCompensation:()=>ce(h,g,async()=>S.prepareCompensation?.()),apply:()=>ce(h,g,async()=>{let J=await S.apply();return l.add(g),J})}});if(await Q({...t,pmRoot:a,steps:y,onTransition:({transition:h})=>{h==="committed"&&(s=!0)}}),s)for(let[h,g]of n.entries()){let S=(await Qe(g.id,{path:a},{full:!0})).item;c.push({index:h,id:String(S.id),op:g.op,execution:l.has(h)?"applied":"adopted",item:S,commit_time_fields:xt(S)})}})),{records:c,validated:s,state:s?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Rt(o,{recursive:!0,force:!0})}}async function Bn(e){let t=U(e),n=Gt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:le(t.pmRoot)},o=await Q({...t,steps:n.map((s,d)=>ye(i,s,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),a={};for(let[s,d]of n.entries()){let c=me(d,s),l=o.results[c];a[jn(d,s)]=l}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:a}}function Vn(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function ei(e){return Bn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Vn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var ti={buildCreateStep:Ft,bulkHistoryMarker:v,compensateByRestore:W,deriveStepId:me,isUpdateMarkerApplied:M,readItemSnapshot:b};async function ni(e,t){let n=await Be(e,t);return n===void 0?void 0:{journal:n,planDigest:ee(n)}}function Hn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new u("Transaction has no supported item recovery plan",p.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;Pt(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:le(e.pmRoot)};return r.map((o,a)=>ye(i,o,a))}async function ri(e){let t=U(e),n=await Ve({...e,...t,resolveSteps:r=>Hn({...e,...t},r)});return{journal:n,planDigest:ee(n)}}export{at as a,gr as b,vr as c,St as d,_ as e,_r as f,An as g,Sr as h,In as i,Cn as j,Wn as k,Qr as l,Bn as m,Vn as n,ei as o,ti as p,ni as q,ri as r};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{$a as te,Ub as et,Vb as tt,Xb as ne,_b as nt,a as Je,ac as rt,bc as it,xc as ot}from"./chunk-XK25TAJZ.js";import{u as Qe}from"./chunk-2IZGNOGT.js";import{wc as Ze}from"./chunk-HJQ3XPS3.js";import{m as Xe}from"./chunk-6HRPGEBF.js";import{a as ze,c as U,d as Q,e as Be,f as ee,g as Ve}from"./chunk-KEBLUTC3.js";import{ra as He,wb as j,xa as Ye,zb as D}from"./chunk-M5D3CEMY.js";import{Va as Z,d as Ee,ia as Ge,ka as N,t as Oe,u as Ae,ub as Le,uc as We,v as z}from"./chunk-7ESF676D.js";import{k as xe,o as qe,v as Ke}from"./chunk-OXG5XPC7.js";import{$c as Ce,Bc as Ie,Bd as Ne,Fc as E,Ka as V,Mc as Y,Ta as ke,a as be,be as Ue,bj as De,ce as R,cj as X,gc as $e,jh as I,oh as je,oj as Fe,pj as Pe,uh as C,vc as Me,xc as H,yc as Re}from"./chunk-FOYRE23V.js";import{A as p,C as u,G as B,I as Te,J as $,l as ve,q as k,t as _e,y as Se}from"./chunk-5OFMWP3Q.js";import ue from"node:crypto";import{constants as se,readFileSync as Tn}from"node:fs";import{cp as kn,lstat as kt,mkdir as $n,mkdtemp as $t,open as Mn,readdir as Rn,realpath as Mt,rm as Rt,stat as pe,writeFile as It}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import m from"node:path";import yt from"node:crypto";(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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var O=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...ve,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function at(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return O.has(t)?t:e}(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function F(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new u(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,p.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var re=["op","id","reason","options","unique","match"],Lt=[...re,"ref"],st=[...Lt,"item"],Wt="mutate-",ct="row-",dt=["schema_version","mutations"],wt="[a-z][a-z0-9._-]{0,63}",ut=new RegExp(`^${wt}$`,"u"),gt=new RegExp(`(^|,)id=@(${wt})(?=,|$)`,"gu"),pt=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),P=["item","item_hash","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],vt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),Jt=new Set([...vt,"completed_at","id"]),_t={create:j.map(e=>e.target),update:D.map(e=>e.target),close:He.map(e=>pt(e.flag)).filter(e=>e!=="reason"),release:Ye.map(e=>pt(e.flag))};function gr(e){let t=yt.createHash("sha256").update(e).digest("hex");return`${Wt}${t.slice(0,24)}`}function vr(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new u("createCompensation must be close or delete.",p.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let i=e[r];if(i===void 0)continue;let o=typeof i=="number"||typeof i=="string"&&i.trim().length>0?Number(i):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new u(`${r} must be a positive safe integer.`,p.USAGE);t[r]=o}return t}function w(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function G(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let i of t){let o=$e(e,i,n);o!==null&&(r===void 0||o<r.distance)&&(r={key:i,distance:o})}return r?.key}function A(e,t,n){let r=G(t,n);return new u(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,p.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function ae(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new u(`${t} must be valid JSON: ${r}`,p.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function zt(e,t){if(!w(e))throw new u(`Mutation ${t+1} must be an object.`,p.USAGE);for(let n of Object.keys(e))if(!re.includes(n))throw A(`mutation ${t+1}`,n,re);return e}function Bt(e,t,n,r){if(e===void 0)return;if(!w(e))throw new u(`Mutation ${n+1} options must be an object.`,p.USAGE);let i=[..._t[t],...Et(t,r)];for(let o of Object.keys(e))if(!i.includes(o))throw A(`mutation ${n+1} ${t} options`,o,i);return F(e,t,n),e}function lt(e,t,n,r){if(e===void 0)return;let i=r==="unique"?"create":"update";if(t!==i)throw new u(`Mutation ${n+1} ${r} is only valid for ${i} operations.`,p.USAGE);let o=w(e)&&typeof e.key=="string"?e.key.trim():"";if(!w(e)||o.length===0||e.value===void 0||e.value===null)throw new u(`Mutation ${n+1} ${r} must be an object with a non-empty key and a value.`,p.USAGE);return{key:o,value:e.value}}function Vt(e,t,n){let r=zt(e,t),{op:i,id:o,reason:a}=r;if(i!=="create"&&i!=="update"&&i!=="close"&&i!=="release")throw new u(`Mutation ${t+1} op must be create, update, close, or release.`,p.USAGE);let s=Bt(r.options,i,t,n),d=lt(r.unique,i,t,"unique"),c=lt(r.match,i,t,"match");if(typeof o!="string"||o.trim().length===0)throw new u(`Mutation ${t+1} requires a non-empty id.`,p.USAGE);let l=o.trim();if(i==="close"){if(typeof a!="string"||a.trim().length===0)throw new u(`Mutation ${t+1} close requires a non-empty reason.`,p.USAGE);return{op:i,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(i==="release")return{op:i,id:l,...s===void 0?{}:{options:s}};if(!w(s))throw new u(`Mutation ${t+1} ${i} requires an options object.`,p.USAGE);return{op:i,id:l,options:s,...d===void 0?{}:{unique:d},...c===void 0?{}:{match:c}}}function St(e,t={}){let n=ae(e,"Mutation batch"),r=Array.isArray(n)?n:w(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(r===void 0||r.length===0)throw new u("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",p.USAGE);let i=t.runtimeFields??[];return r.map((o,a)=>{let s=Vt(o,a,i);return s.options!==void 0&&Oe(s.options),s})}function Ht(e,t,n){let r=yt.createHash("sha256").update(e).update("\0").update(t).digest("hex"),i=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ge(n)}${i}`}function mt(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new u(`Unknown mutation reference "${e}".`,p.USAGE);return r}function ft(e,t){if(typeof e!="string")return e;let n=e.replace(gt,(r,i,o)=>{let a=t[o];if(a===void 0)throw new u(`Unknown mutation reference "@${o}".`,p.USAGE);return`${i}id=${a}`});if(/(^|,)id=@/u.test(n))throw new u(`Malformed mutation reference in dependency "${e}".`,p.USAGE);return n}function Yt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(gt)].map(t=>t[1]).filter(t=>t!==void 0)}function Xt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let c=w(s.options)?s.options:{},l=Array.isArray(c.dep)?c.dep:c.dep===void 0?[]:[c.dep];n.set(d,[c.parent,c.blockedBy,...l].flatMap(Yt))}let r=new Set,i=new Set,o=a=>{if(r.has(a))throw new u(`Mutation reference cycle includes "@${a}".`,p.USAGE);if(!i.has(a)){r.add(a);for(let s of n.get(a))n.has(s)&&o(s);r.delete(a),i.add(a)}};for(let a of n.keys())o(a)}function Zt(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),r=n[0];if(!r.ok&&(r.line.startsWith("[")||r.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&w(o.value)))return null;let i=[];for(let o of n){if(!o.ok)throw new u(`Mutation document line ${o.number} must be one valid JSON object: ${We(o.error)}`,p.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!w(o.value))throw new u(`Mutation document line ${o.number} must be a JSON object.`,p.USAGE);i.push(o.value)}return i}function Qt(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function en(e){let t;try{t=ae(e,"Mutation document")}catch(n){let r=Zt(e);if(r===null)throw n;return{schema_version:1,mutations:r}}return Array.isArray(t)?{schema_version:1,mutations:t}:w(t)&&!Qt(t)?{schema_version:1,mutations:[t]}:t}function tn(e,t){let n=Object.hasOwn(e,"op")?nn(e,t):rn(e,t);if(n.op==="create"&&n.id===void 0&&w(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new u(`Mutation ${t+1} item id must be a string.`,p.USAGE);n.id=n.item.id}return n}function nn(e,t){for(let n of Object.keys(e))if(!st.includes(n))throw A(`mutation ${t+1}`,n,st);if(e.item!==void 0&&e.op!=="create")throw new u(`Mutation ${t+1} item documents are only valid for create operations.`,p.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new u(`Mutation ${t+1} must declare either item or options, not both.`,p.USAGE);return{...e}}function rn(e,t){let{ref:n,id:r,item:i,...o}=e,a=i!==void 0?i:o;if(i!==void 0&&Object.keys(o).length>0)throw new u(`Mutation ${t+1} must not mix item document keys with top-level fields.`,p.USAGE);if(!w(a))throw new u(`Mutation ${t+1} item document must be an object.`,p.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...r===void 0?{}:{id:r},item:a}}function on(e){let t=en(e);if(!w(t))throw new u("Mutation document must be a JSON array or object.",p.USAGE);for(let n of Object.keys(t))if(!dt.includes(n))throw A("mutation document",n,dt);if(t.schema_version!==void 0&&t.schema_version!==1)throw new u("Mutation document schema_version must be 1.",p.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new u("Mutation document requires a non-empty mutations array.",p.USAGE);return t.mutations.map((n,r)=>{if(!w(n))throw new u(`Mutation ${r+1} must be an object.`,p.USAGE);return tn(n,r)})}function an(e,t,n){let r=new Set(Object.values(At(t,n,Object.create(null))));for(let i of t)i.op==="create"&&typeof i.id=="string"&&i.id.trim().length>0&&r.add(N(i.id,n.idPrefix));return{...e,existing:e.existing.filter(i=>!r.has(i.id))}}function sn(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,r]of e.entries()){if(r.op!=="create"||r.ref!==void 0||typeof r.id=="string"&&r.id.trim().length>0)continue;let i=`${ct}${n+1}`;if(t.has(i))throw new u(`Mutation ${n+1} receives the synthesized ref "${i}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${ct}<n> aliases are reserved for rows without one.`,p.USAGE);r.ref=i}}function bt(e,t,n){let r=An(JSON.stringify(e),t,{},n);return delete r.stdinJson,delete r.documentAnnotationSnapshot,r}function Et(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function cn(e,t){for(let n of e)w(n.item)&&(n.options=bt(n.item,"create",t),delete n.item)}function Ot(e,t){return t.some(n=>n.metadata_key===e)?e:at(e)}function ie(e,t,n){let r=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(w(e.item)){if(e.item[t]!==void 0)return e.item[t];if(Ot(r,n)===t&&e.item[r]!==void 0)return e.item[r]}let i=w(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&i[E(o)]!==void 0?i[E(o)]:i[t]!==void 0?i[t]:i[r]!==void 0?i[r]:(Array.isArray(i.field)?i.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function dn(e,t){return e<t?-1:+(e!==t)}function oe(e){return Array.isArray(e)?e.map(oe):w(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>dn(t,n)).map(([t,n])=>[t,oe(n)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(oe(e))}function un(e,t,n,r,i){let o=t.key.trim();if(o.length===0)throw new u("Upsert key must be a non-empty field name.",p.USAGE);let a=pn(t.existing),s=new Map,d=new Set;for(let[c,l]of e.entries()){if(l.op!=="create")continue;let f=ln(l,o,c,s,r),y=mn(a.get(f)??[],o,f);if(y===void 0){l.unique={key:o,value:ie(l,o,r)};continue}let h=N(y,n);typeof l.ref=="string"&&(i[l.ref]=h),fn(l,h,r,{key:o,value:ie(l,o,r)}),d.add(c)}return d}function pn(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let r=_(n.value);t.set(r,[...t.get(r)??[],n.id])}return t}function ln(e,t,n,r,i){let o=ie(e,t,i);if(o==null||o==="")throw new u(`Mutation ${n+1} is missing the upsert key "${t}".`,p.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=_(o),s=r.get(a);if(s!==void 0)throw new u(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return r.set(a,n),a}function mn(e,t,n){if(e.length>1)throw new u(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,p.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function fn(e,t,n,r){let i=new Set([..._t.update,...Et("update",n)]),o=w(e.item)?bt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>i.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=r}function At(e,t,n){for(let[r,i]of e.entries())if(i.ref!==void 0){if(i.op!=="create")throw new u(`Mutation ${r+1} ref is only valid for create operations.`,p.USAGE);if(typeof i.ref!="string"||!ut.test(i.ref))throw new u(`Mutation ${r+1} ref must match ${ut.source}.`,p.USAGE);if(n[i.ref]!==void 0)throw new u(`Duplicate mutation ref "${i.ref}".`,p.USAGE);n[i.ref]=typeof i.id=="string"&&i.id.trim().length>0?N(i.id,t.idPrefix):Ht(t.transactionId,i.ref,t.idPrefix)}return n}function _r(e,t){let n=on(e);sn(n);let r=n.map(l=>typeof l.ref=="string"?l.ref:void 0),i=Object.create(null),o=t.upsert===void 0?new Set:un(n,an(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],i);cn(n,t.runtimeFields??[]),At(n,t,i),Xt(n,r);let a=n.map(l=>{let f={...l},y=typeof f.ref=="string"?f.ref:void 0;if(delete f.ref,y!==void 0?f.id=i[y]:f.id=mt(f.id,i),w(f.options)){let h={...f.options};for(let g of["parent","blockedBy"])h[g]!==void 0&&(h[g]=mt(h[g],i));Array.isArray(h.dep)?h.dep=h.dep.map(g=>ft(g,i)):h.dep!==void 0&&(h.dep=ft(h.dep,i)),f.options=h}return f}),s=St(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new u("Duplicate resolved create id in mutation document.",p.USAGE);let c=s.map((l,f)=>{let y=r[f];return{index:f,...typeof y=="string"?{ref:y}:{},id:l.id,op:l.op,...o.has(f)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:i,rows:c}}function hn(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let r=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function yn(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(w))throw new u(`${n} must be an array of objects.`,p.USAGE);return e.map(r=>hn(r,t))}}function wn(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function ht(e,t,n=!1){for(let[r,i,o]of Ze){let a=t[r],s=yn(n&&["comments","notes","learnings"].includes(r)&&Array.isArray(a)?a.filter(d=>!w(d)||d.created_at===void 0):a,o,r);s!==void 0&&s.length>0&&(e[i]=s)}}function gn(e,t){for(let n of Object.keys(e)){if(t){if(!P.includes(n))throw A("item envelope",n,P);continue}if(!O.has(n)&&G(n,[...O])===void 0&&G(n,P)==="item")throw A("item envelope",n,P)}}function vn(e){let t=Object.hasOwn(e,"item");gn(e,t);let n=t?e.item:e;if(!w(n))throw new u("Item document item must be an object.",p.USAGE);return{item:n,...t&&w(e.linked)?{linked:e.linked}:{}}}function _n(e,t,n,r,i,o){if((r==="update"?Jt:vt).has(t))return;let a=i.find(s=>s.metadata_key===t&&s.commands.includes(r));if(a!==void 0){let s=Y(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!O.has(t)){if(G(t,[...O])!==void 0)throw A("item document",t,[...O]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=wn(t,n))}function Sn(e){return{command_to_fields:new Map([["create",e.filter(t=>t.commands.includes("create"))]])}}function bn(e,t,n,r){let i=r.filter(c=>c.commands.includes("create")),o=new Set([...Ce.filter(c=>t.has(c.option)).map(c=>c.field),...i.filter(c=>t.has(E(c))).map(c=>c.metadata_key),...Xe(Array.isArray(n)?n.map(String):[],Sn(i)).metadataKeys]),a=(Array.isArray(e)?e:[]).filter(w).filter(c=>typeof c.field=="string"&&!o.has(c.field));if(a.length===0)return{};let s=a.map(c=>typeof c.reason=="string"?c.reason.trim():""),d=a.map(c=>c.field);return t.has("deferReason")?{defer:d}:s.every(c=>c.length>0)?{defer:d,deferReason:[...new Set(s)].join("; ")}:{defer:d}}function En(e,t,n){let r=new Set(Object.entries(e).filter(([,o])=>o!==void 0).map(([o])=>o)),i=t==="create"?j:D;for(let{target:o,keys:a}of i)a.some(s=>r.has(s))&&r.add(o);for(let o of n.filter(a=>a.commands.includes(t)))Y(e,o)!==void 0&&r.add(E(o));return r}function On(e,t,n){let r=t==="create"?j:D;for(let{target:i}of r)i!=="field"&&n.has(i)&&delete e[i]}function An(e,t,n={},r=[]){let i=ae(e,"Item document");if(!w(i))throw new u("Item document must be a JSON object.",p.USAGE);let{item:o,linked:a}=vn(i),s={};for(let[f,y]of Object.entries(o)){let h=Ot(f,r);h!==f&&Object.hasOwn(o,h)||_n(s,h,y,t,r,n)}ht(s,o,t==="update"),a!==void 0&&ht(s,a);let d=En(n,t,r);if(On(s,t,d),t==="create"&&!d.has("defer")&&Object.assign(s,bn(o.deferred_fields,d,n.unset,r)),t==="update"){let f=Object.fromEntries(["comments","notes","learnings"].filter(y=>Object.hasOwn(o,y)&&!d.has(y.slice(0,-1))).map(y=>[y,o[y].filter(h=>w(h)&&h.created_at!==void 0)]));Object.keys(f).length>0&&(s.documentAnnotationSnapshot=f)}let c={...s,...Object.fromEntries(Object.entries(n).filter(([,f])=>f!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0},l=Object.keys(s).filter(f=>!d.has(f));return Ae(Ee(c,l),l)}function Sr(e){return St(JSON.stringify(e))}(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]="359a47e6-c7e8-5713-bd07-1e19fb81674a")}catch{}})();async function In(e,t){if(!qe(e))return{schema:H(t.schema),typeDefinitionsFromFile:[]};let n=await Wn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Cn(e,t,n,r){let i=V({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},X());return(await Le(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function le(e){let t=new Map,n=async r=>{let i=await Ke(e),o=await In(e,i),a=new Map;for(let s of await Cn(e,i,o,r)){let d=_(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,o]of t){let a=r[i];if(a==null)continue;let s=await o,d=_(a);s.set(d,[...s.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function Nn(e,t){let n=_(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new u(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,p.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function Un(e,t,n){let r=e.metadata[n.key],i=_(n.value);if(_(r)!==i)throw new u(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,p.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function Tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function L(e,t){let n={...e,...t};return e===void 0?n:z(e,n)}async function b(e,t){try{let n=(await te(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof u&&n.exitCode===p.NOT_FOUND)return;throw n}}function me(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ue.createHash("sha256").update(be(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function jn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function v(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function fe(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function M(e,t,n,r){let i=await R(m.join(e,"history",`${t}.jsonl`),t),o=v(n,r,"apply"),a=v(n,r,"compensate");for(let s=i.length-1;s>=0;s-=1){let d=i[s].message;if(fe(d,o))return!0;if(d===a)return!1}return!1}async function he(e,t){let n=await b(e,t.id);if(n?.updatedAt===void 0)throw new u(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,p.NOT_FOUND);let r=await R(m.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new u(`Bulk ${t.op} target ${t.id} has no restorable history`,p.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(Z(r)+r.length),target_history_hash:I(r),target_history_length:r.length}}function T(e,t,n){return new u(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,p.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Nt(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Dn(e,t,n){let{expectedHistory:r,length:i,version:o}=t;if(I(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||I(e.slice(0,i))!==r||o!==String(Z(e)+i))throw T(n,n.itemId,n.stepId);let a=v(n.transactionId,n.stepId,"apply"),s=e.slice(i),d=y=>fe(y.message,a)||y.context?.item_transaction_step===a,c=v(n.transactionId,n.stepId,"compensate");if(s.filter(y=>d(y)||y.message===c).at(-1)?.message===c)return!1;let l=s.filter(d);if(l.length===0)return!1;let f=e.at(-1).after_hash===l.at(-1).after_hash&&s.every(y=>Nt(y,n.transactionId));if(l.length!==s.length&&!f)throw T(n,n.itemId,n.stepId);return!0}async function Ut(e,t){let n=m.join(e,"history",`${t}.jsonl`),r=await Ue(n,t);return{history:r.entries,assertOwnedUnderLock:(i,o)=>{let a;try{a=Tn(n).equals(r.raw_bytes)&&je(i)===r.entries.at(-1).after_hash}catch(s){throw Object.assign(o(),{cause:s})}if(!a)throw o()}}}async function W(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let o=i.target_updated_at,a=await b(e.pmRoot,t);if(a===void 0)return;let{history:s,assertOwnedUnderLock:d}=await Ut(e.pmRoot,a.id),c=i.target_history_hash,l=typeof c=="string";if(typeof c=="string"){if(!Dn(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:a.id,stepId:n}))return}else{if(a.updatedAt===o)return;if(!await M(e.pmRoot,a.id,e.transactionId,n))throw T(e,a.id,n)}let f=()=>it(t,typeof i.target_version=="string"?i.target_version:o,{force:!0,author:e.author,message:v(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await C({pmRoot:e.pmRoot,id:a.id,validate:y=>{d(y,()=>T(e,a.id,n))},compensation:Dt(e,t,n,"restore",l)},f)}var jt=new WeakMap;function Dt(e,t,n,r,i){let o=i?ze(e.pmRoot,e.transactionId):void 0,a=o===void 0?void 0:jt.get(o);if(!(a?.stepId!==n||a.itemId!==t||a.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function Ft(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await R(m.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new u(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,p.CONFLICT,{code:"transaction_create_compensated",item_id:r.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await Nn(e.uniqueIndex,t.unique);let r=await et(L(t.options,{author:e.author,id:t.id,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await Fn(e,t.id,n)}}}async function Fn(e,t,n){let r=await b(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:o}=await Ut(e.pmRoot,r.id),a=v(e.transactionId,n,"apply"),s=v(e.transactionId,n,"compensate"),d=i.filter(c=>fe(c.message,a)||c.message===s).at(-1);if(d?.message!==s){if(d===void 0||!i.every(c=>Nt(c,e.transactionId)))throw T(e,r.id,n);await C({pmRoot:e.pmRoot,id:r.id,validate:c=>{o(c,()=>T(e,r.id,n))},compensation:Dt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:s};e.createCompensation==="delete"?await rt(t,c,{pmRoot:e.pmRoot}):await ne(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Pn(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=()=>tt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,o=i,a=(await C({pmRoot:e.pmRoot,id:String((await te(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{o!==void 0&&Un(s,t.id,o)},committed:s=>{i!==void 0&&(o={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:v(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await W(e,t.id,n,r)}}}function Gn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=(await ne(t.id,t.reason,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"close"}},async compensate(r){await W(e,t.id,n,r)}}}function xn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=(await nt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"release"}},async compensate(r){await W(e,t.id,n,r)}}}function ye(e,t,n){let r=me(t,n),i=qn(e,t,r);return jt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function qn(e,t,n){switch(t.op){case"create":return Ft(e,t,n);case"update":return Pn(e,t,n);case"close":return Gn(e,t,n);case"release":return xn(e,t,n)}}function Kn(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!Tt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!Tt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);F(e.options,e.op,t)}function Pt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Kn(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:o}=r.unique,a=t.get(i)??new Map,s=_(o),d=a.get(s);if(d!==void 0)throw new u(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(i,a)}}function Gt(e){let t=[...e];return Pt(t),t.map(n=>{let r=structuredClone(n);return n.options!==void 0&&r.options!==void 0&&z(n.options,r.options),r})}function xt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:xt(r,i)})}async function ce(e,t,n){try{return await n()}catch(r){throw r instanceof u?new u(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function qt(e,t,n,r){let i=m.relative(e,t),o=i.split(m.sep);return o[0]==="extensions"&&o[2]==="node_modules"&&!r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))?!1:["locks","runtime","search"].includes(i.split(m.sep)[0])?r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`)):i===""||n===void 0||n.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))}async function q(e,t){let n=await kt(t);if(n.isSymbolicLink())await pe(t);else if(n.isDirectory()||n.isFile())return n;throw $(m.relative(e,t))}async function Ln(e,t){let n=await Mn(t,se.O_RDONLY|se.O_NOFOLLOW|se.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(m.relative(e,t));let i=ue.createHash("sha256");if(r.size>0)for await(let o of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(o);return i.digest()}finally{await n.close()}}async function de(e,t,n){let r=ue.createHash("sha256");async function i(o){for(let a of(await Rn(o)).sort()){let s=m.join(o,a);qt(e,s,t,n)&&((await q(e,s)).isDirectory()?await i(s):(r.update(JSON.stringify(m.relative(e,s))),r.update(await Ln(e,s))))}}return await i(e),r.digest("hex")}function x(){return new u("Tracker changed while preparing the transaction preview; retry against stable state.",p.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function we(e){if(!B(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),r=n;for(;;)try{let i=await kt(r);return r!==n&&i.isDirectory()}catch(i){if(!B(i))return!1;let o=m.dirname(r);if(o===r)return!1;r=o}}async function K(e,t){let n=m.join(e,t);try{let r=e;for(let i of t.split(m.sep).slice(0,-1))r=m.join(r,i),await q(e,r);if(!(await q(e,n)).isFile())throw $(t);return await Te(n,$(t))}catch(r){if(await we(r))return;throw r}}async function Kt(e,t,n,r){let i=H(n);for(let[o,a]of Object.entries(i.files)){let s=m.relative(e,Re(e,a,Me[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new u("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",p.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});i.files[o]=s;let d=await K(e,s);if(r?.set(s,d),d!==void 0){let c=m.join(t,s);await $n(m.dirname(c),{recursive:!0}),await It(c,d)}}return Ie(t,i)}async function Wn(e,t){await pe(e);let n=await $t(m.join(Ct(),"pm-schema-plan-"));try{let r=await Mt(e);return await Kt(r,m.join(n,"configuration"),t)}catch(r){throw await we(r)?x():r}finally{await Rt(n,{recursive:!0,force:!0})}}async function Jn(e,t,n){let r=new Map,i=await K(e,k);r.set(k,i);let o;try{o=JSON.parse(i??"null")}catch{o=null}let a=xe(o),s=a.success?a.data:void 0,d=await Kt(e,t,s?.schema,r),c=d.schema,l=m.relative(e,Ne(e));r.set(l,await K(e,l));let f=V({...Se,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),y=ke(e)===e?[..._e.filter(Boolean),k,Je,"transactions",...f.folders,...r.keys()].map(g=>m.normalize(g)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:c.files}});return{configuration:r,ownedPaths:y,stagedSettings:h,registryFolders:f.folders}}async function zn(e,t,n){await pe(e);try{let r=await Mt(e),i=await Jn(r,m.join(m.dirname(t),"configuration"),n),o=[...i.configuration.keys(),...i.registryFolders].map(c=>m.normalize(c)),a=await de(r,i.ownedPaths,o);await kn(r,t,{recursive:!0,dereference:!1,filter:async c=>qt(r,c,i.ownedPaths,o)?(await q(r,c),!0):!1});let[s,d]=await Promise.all([de(r,i.ownedPaths,o),de(t,i.ownedPaths,o)]);if(a!==s||a!==d)throw x();for(let[c,l]of i.configuration)if(await K(t,c)!==l)throw x();i.stagedSettings!==void 0&&await It(m.join(t,k),i.stagedSettings)}catch(r){throw await we(r)?x():r}}async function Qr(e){let t=U(e),n=Gt(e.mutations),r=X(),i=Pe(),o=await $t(m.join(Ct(),"pm-transaction-preview-")),a=m.join(o,"tracker");try{await zn(t.pmRoot,a,r);let s=!1,d=[],c=[],l=new Set;return await Fe(i,()=>ot({path:a,noExtensions:!0},async()=>{De(r);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:le(a)},y=n.map((h,g)=>{let S=ye({...f,onCreateWarnings:(J,ge)=>{ge.length>0&&d.push({index:g,id:J,op:"create",warnings:ge})}},h,g);return{...S,inspect:()=>ce(h,g,()=>S.inspect()),prepareCompensation:()=>ce(h,g,async()=>S.prepareCompensation?.()),apply:()=>ce(h,g,async()=>{let J=await S.apply();return l.add(g),J})}});if(await Q({...t,pmRoot:a,steps:y,onTransition:({transition:h})=>{h==="committed"&&(s=!0)}}),s)for(let[h,g]of n.entries()){let S=(await Qe(g.id,{path:a},{full:!0})).item;c.push({index:h,id:String(S.id),op:g.op,execution:l.has(h)?"applied":"adopted",item:S,commit_time_fields:xt(S)})}})),{records:c,validated:s,state:s?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Rt(o,{recursive:!0,force:!0})}}async function Bn(e){let t=U(e),n=Gt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:le(t.pmRoot)},o=await Q({...t,steps:n.map((s,d)=>ye(i,s,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),a={};for(let[s,d]of n.entries()){let c=me(d,s),l=o.results[c];a[jn(d,s)]=l}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:a}}function Vn(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function ei(e){return Bn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Vn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var ti={buildCreateStep:Ft,bulkHistoryMarker:v,compensateByRestore:W,deriveStepId:me,isUpdateMarkerApplied:M,readItemSnapshot:b};async function ni(e,t){let n=await Be(e,t);return n===void 0?void 0:{journal:n,planDigest:ee(n)}}function Hn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new u("Transaction has no supported item recovery plan",p.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;Pt(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:le(e.pmRoot)};return r.map((o,a)=>ye(i,o,a))}async function ri(e){let t=U(e),n=await Ve({...e,...t,resolveSteps:r=>Hn({...e,...t},r)});return{journal:n,planDigest:ee(n)}}export{at as a,gr as b,vr as c,St as d,_ as e,_r as f,An as g,Sr as h,In as i,Cn as j,Wn as k,Qr as l,Bn as m,Vn as n,ei as o,ti as p,ni as q,ri as r};
|
|
2
|
+
//# sourceMappingURL=chunk-4QQPM3IY.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_c as o}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{_c as o}from"./chunk-HJQ3XPS3.js";import{sa as d}from"./chunk-7ESF676D.js";(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]="41b0b451-a696-5d06-a19d-df1d6b28963c")}catch{}})();function i(e,t,n){return o(e,d(t),n)}export{i as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4TZW4NLM.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as R}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as R}from"./chunk-DG2EOOFX.js";import{Va as E,Xa as D,Za as T,_a as H}from"./chunk-7ESF676D.js";import{I as M,v as x}from"./chunk-OXG5XPC7.js";import{Ka as c,Sa as y,ce as g,cj as w,je as u,ne as _,oh as I,qh as v,rh as b,sc as p}from"./chunk-FOYRE23V.js";import{A as f,C as l}from"./chunk-5OFMWP3Q.js";(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]="eb2e6046-156c-56ee-a03a-ecaa1cccfb45")}catch{}})();function K(e,t){let i=_(e),s=e.length>0?e[e.length-1].after_hash:b(),a=t===void 0||i.item_hash_version===void 0?void 0:v(t,i.item_hash_version,p(e.at(-1)?.hash_algorithm)),n=t===void 0?void 0:a===void 0?I(t):a[Math.max(0,a.indexOf(s))],o=n===void 0?void 0:n===s,r=[...i.errors];return o===!1&&r.push("verify_failed:current_item_hash_mismatch"),{ok:r.length===0,entries:e.length,errors:r,latest_after_hash:e.length>0?e[e.length-1].after_hash:void 0,current_item_hash:n,current_matches_latest:o}}async function Q(e,t,i={}){let s=y(i.cwd??process.cwd(),i.pmRoot);await M(s);let a=await x(s),n=c(a,w()),o=await R(s,e,a,n.type_to_folder),r=await g(o.historyPath,o.id);if(r.length===0)throw new l(`No history exists for ${o.id}; point-in-time reads are unavailable.`,f.NOT_FOUND);let d=D(t,r),C=H(T(r,d.historyIndex),d),m=u(C,{schema:a.schema});if(m.metadata.id!==o.id)throw new l(`History target resolved to item ${m.metadata.id}, expected ${o.id}.`,f.GENERIC_FAILURE);let k=r[d.historyIndex],h=E(r,!0);return{document:m,reconstructed:!0,as_of_version:h===null?null:h+d.historyIndex+1,as_of_timestamp:k.ts,target:d,history_length:r.length}}(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]="e524f0ad-faad-5d89-b8f5-1283979919ad")}catch{}})();export{K as a,Q as b};
|
|
2
|
+
//# sourceMappingURL=chunk-5LF5QZT3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ab as Z,Bb as Q,Hb as A,Jb as w,Kc as ee,Lb as k,Lc as te,Nc as ne,jc as O,oc as S,wb as K,xb as X,yb as J,zb as I}from"./chunk-VETSGCF4.js";import{L as R,b as E,ba as x,c as L,s as H,t as Y,ta as W,v as C,w as q}from"./chunk-2VH6COJE.js";import{Rb as m}from"./chunk-7UUPLMCU.js";import{A as u,C as f}from"./chunk-5OFMWP3Q.js";(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]="202cbe4e-7d36-5b12-be9d-d35608a6b36d")}catch{}})();var Oe=new Set(["none","null"]);function it(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function g(e){return e===void 0?!1:Oe.has(e.trim().toLowerCase())}function st(e,t,n){if(!g(e))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function lt(e,t,n){if(!e||e.length===0||L(e)||!e.some(i=>g(i)))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function ct(e,t){for(let n of t){let a=e[n.optionKey];if(!Array.isArray(a)||a.length===0)continue;if(!a.every(r=>typeof r=="string"))throw new f(`${n.valueFlag} entries must be strings.`,u.USAGE);if(L(a))continue;let i=a;if(i.some(r=>g(r))){if(i.filter(r=>!g(r)).length>0)throw new f(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,u.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}}return e}(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]="5146346c-df7b-5011-9d55-c59a7ff88f29")}catch{}})();var ge=["close_reason","close-reason"],ae=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],oe=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],Te=[...ae,...oe],re=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],B=[...Te,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...re],he=[...ae,{canonical:"close-reason",aliases:ge,optionKey:"closeReason",metadataKey:"close_reason"},...oe,...re],ve=new Set(["none","null","-"]);function ie(e){return e==="create"?B:he}function F(e,t){let n=t.unset;if(n!==void 0&&typeof n!="string"&&!Array.isArray(n))return;let a=[];for(let i of ie(e))i.optionKey==="author"||!Object.hasOwn(t,i.optionKey)||t[i.optionKey]!==null||(Reflect.deleteProperty(t,i.optionKey),a.push(i.canonical));a.length!==0&&(t.unset=[...n===void 0?[]:typeof n=="string"?[n]:n,...a])}function U(e){return typeof e=="string"&&ve.has(e.trim().toLowerCase())}function pt(e,t,n,a){return n?ie(e).flatMap(i=>{let r=t[i.optionKey],o=a[i.metadataKey];return U(r)&&(U(o)||Array.isArray(o)&&o.some(U))?[`literal_sentinel_stored:${i.canonical}:${r.trim()}`]:[]}):[]}function Ee(e,t){return e.flatMap(n=>n.includes(",")&&t(n)?[n]:n.split(","))}function Ce(e){let t=new Set,n=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:n};let a=Ee(e.raw,i=>e.resolveDefinition(i.trim().toLowerCase())!==void 0);for(let i of a){let r=i.trim().toLowerCase();if(!r)throw new f("--unset values must not be empty; name each field once, for example --unset parent,release",u.USAGE);if(g(r))throw new f('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',u.USAGE);let o=e.resolveDefinition(r);if(!o)throw new f(`Unsupported --unset field "${i}". Supported fields: ${e.supportedFields}`,u.USAGE);t.add(o.metadataKey),n.add(o.optionKey)}return{metadataKeys:t,optionKeys:n}}function Se(e,t,n){let a=e.trim().toLowerCase();if(!n)return;let i=n.command_to_fields?.get(t)??[];for(let r of i){if(r.allow_unset===!1)continue;let o=new Set;if(typeof r.key=="string"&&r.key.length>0&&o.add(r.key.toLowerCase()),typeof r.metadata_key=="string"&&r.metadata_key.length>0&&o.add(r.metadata_key.toLowerCase()),typeof r.cli_flag=="string"&&r.cli_flag.length>0&&(o.add(r.cli_flag.replaceAll("-","_").toLowerCase()),o.add(r.cli_flag.toLowerCase())),Array.isArray(r.cli_aliases))for(let s of r.cli_aliases)typeof s!="string"||s.length===0||(o.add(s.replaceAll("-","_").toLowerCase()),o.add(s.toLowerCase()));if(o.has(a))return{optionKey:r.key,metadataKey:r.metadata_key}}}var Ne=(()=>{let e=new Map;for(let t of B)for(let n of t.aliases)e.set(n,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),be=B.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function yt(e,t){return Ce({raw:e,supportedFields:be,resolveDefinition:n=>Ne.get(n)??Se(n,"create",t)})}(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]="837a5c2d-6447-5696-b0de-32641cde14cd")}catch{}})();var Re={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function T(e,t,n){let a=`${e} ${t} must be ${n}.`;throw new f(a,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:a,examples:[Re[e]]})}function N(e,t,n){typeof e!="string"&&T(t,n,"a string")}function $(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&T(t,"options","an object")}function se(e,t){(e==="append"||e==="update")&&t.id!==void 0&&N(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&N(t.id,"reopen","id"),t.reason!==void 0&&N(t.reason,"reopen","reason"),t.options!==void 0&&Ke(t.options))}function Nt(e){$(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&N(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&T("append","force","a boolean")}function Ke(e){$(e,"reopen");for(let t of S["item-reopen"].optional){let n=e[t];n!==void 0&&(m(Reflect.get(O,t)).type==="boolean"?typeof n!="boolean"&&T("reopen",t,"a boolean"):N(n,"reopen",t))}}function Ie(e,t){return e?t?"a string or string array":"a string array":"a string"}function we(e,t,n,a,i,r){n===void 0||typeof n=="string"&&(!i||r)||a==="priority"&&typeof n=="number"&&Number.isFinite(n)||i&&Array.isArray(n)&&Array.from(n).every(o=>typeof o=="string")||T(e,t,Ie(i,r))}function ke(e,t,n){let a=e==="create"?w:k;for(let{param:i}of[...a,...A,{param:"force"}]){if(m(Reflect.get(O,i)).type!=="boolean")continue;let r=n.find(o=>o.keys.includes(i))?.keys??[i];for(let o of r)t[o]!==void 0&&typeof t[o]!="boolean"&&T(e,o,"a boolean")}}function G(e,t,n=!0,a=!1){let i=e==="create"?K:I;for(let{target:r,keys:o,repeatable:s}of i)if(m(Reflect.get(O,r)).type!=="boolean")for(let d of o){let _=a&&d!==r,y=s===!0&&(r!=="acceptanceCriteria"||_);we(e,d,t[d],r,y,n||_)}ke(e,t,i)}function bt(e,t){$(t,e);let n=H(t),a=E(n);return a||F(e,n),G(e,n,!1,a),n}(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]="63a51994-4328-5a65-938c-d0de377ac338")}catch{}})();var Fe=Symbol("pm.mcp-mutation-transport"),Me=new Set(["create","update","append"]),P={create:{parameters:w,aliases:K,strings:X,repeatables:J},update:{parameters:k,aliases:I,strings:Z,repeatables:Q}},De=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function b(e){return Fe in e}function D(e,t){return b(e)?Y(t):C(e,t)}function Vt(e,t,n=[]){let a=C(e,{...e,...t});for(let i of n)Reflect.deleteProperty(a,i);return a}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function c(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function zt(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ht(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new f(`${t} must be a finite integer.`,u.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new f(`${t} must be a finite integer.`,u.USAGE);return n}}function Yt(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:l(e,"limit")??l(t,"limit")}function qt(e){let t=l(e,"outputFormat");return{json:!0,quiet:!0,author:l(e,"author"),path:l(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:l(e,"outputInclude"),outputLimit:c(e,"outputLimit"),outputBudget:c(e,"outputBudget"),outputSession:l(e,"outputSession"),outputCursor:l(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var de=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ue=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),Pe=new Set([...ue].filter(e=>e!=="file")),Le=new Set(["files","files-discover","docs","test","test-all"]),z=new Set(["comments","notes","learnings"]);function xe(e,t){if(!(!z.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new f(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,u.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var Ue=new Set(["claim","release","start-task","pause-task","close-task"]),fe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},Be=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),$e=new Set(["query","keywords","id","text"]);function Ge(e){return Be.has(e)?S[e].optional.filter(t=>!$e.has(t)):[]}var je=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function Ve(e,t){if(!je.has(e??""))return t;let n={...t};for(let a of S[e].optional){let i=a.replace(/[A-Z]/gu,r=>`_${r.toLowerCase()}`);i===a||n[i]===void 0||(n[a]??=n[i],delete n[i])}return n}function ze(e,t,n){if(!z.has(e??""))return n;let a=n,i=a.text??t.text;if(i===void 0)return a;if(a.add!==void 0&&a.add!==i){let o=e.replace(/s$/u,"");throw new f(`Specify ${o} text either as text or with add, not both.`,u.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${o} text once: text and add are the same source.`})}let r={...a,add:i};return delete r.text,r}function He(e,t){let n=t.replace(/[A-Z]/gu,a=>`_${a.toLowerCase()}`);return e[t]!==void 0||e[n]!==void 0}function Ye(e){return[...fe[e]??[],...Ge(e),...pe]}var pe=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function ye(e,t=""){let n={},a=Le.has(t),i=t==="files"||t==="files-discover"||t==="docs",r=z.has(t)?Pe:ue;for(let[o,s]of Object.entries(e)){if(Array.isArray(s)&&de.has(o)){n[o]=s.join(",");continue}if(o==="note"&&i){n[o]=s;continue}if(typeof s=="string"&&r.has(o)){n[o]=[s];continue}if(typeof s=="string"&&a&&(o==="add"||o==="remove")){n[o]=[s];continue}n[o]=s}return Object.assign(n,Object.fromEntries(Object.getOwnPropertySymbols(e).map(o=>[o,Reflect.get(e,o)]))),n}function qe(e,t,n){let a=l(e,"author");return a!==void 0?a:n!==void 0&&Ue.has(n)?l(e,"assignee")??l(t,"assignee"):void 0}function We(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function Xe(e,t,n){let a={},i=P[e],r=new Set([...i.parameters.map(({param:o})=>o),...A.map(({param:o})=>o),...fe[e],...pe,"force"]);for(let o of r){let s=i.aliases.find(d=>d.keys.includes(o))?.keys??[o];t[o]===void 0||s.some(d=>n[d]!==void 0)||(a[o]=t[o])}return a}function h(e,t){throw new f(`Invalid MCP ${e} value for "${t}". No changes were made.`,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function Je(e,t,n){let a=P[e],i=[...a.parameters,...A,{param:"force"}];for(let{param:r}of i){if(m(O[r]).type!=="boolean")continue;let o=(a.aliases.find(s=>s.keys.includes(r))?.keys??[r]).find(s=>n[s]!==void 0&&typeof n[s]!="boolean");o!==void 0&&h(e,o)}for(let r of["idOnly","fullChangedFields"])t[r]!==void 0&&typeof t[r]!="boolean"&&h(e,r)}function Ze(e,t,n){t.options!==void 0&&!p(t.options)&&h(e,"options"),Je(e,t,n);for(let o of de){let s=n[o];Array.isArray(s)&&s.some(d=>typeof d!="string")&&h(e,o)}let a=Ae(n,e),i=P[e];for(let{keys:o,target:s}of i.strings)o.some(d=>n[d]!==void 0)&&a[s]===void 0&&h(e,s);let r=i.repeatables.flatMap(({keys:o})=>o).find(o=>{let s=n[o];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(d=>typeof d!="string"))});return r!==void 0&&h(e,r),a}function Qe(e,t,n,a,i){let r=(t==="create"||t==="update")&&b(e),o={...r?Xe(t,e,a):n,...a};if((t==="create"||t==="update")&&!r){let s=p(e.options)&&E(e.options);s||F(t,o),G(t,o,!0,s)}return r?Ze(t,e,o):i?ye(o,t):o}function et(e,t){return!Me.has(e??"")||E(t)?t:W(t)}function Wt(e,t,{nativeAction:n=!0}={}){se(t,e);let a=p(e.options)?e.options:void 0,i=m(e.options),r={},o=y=>{He(i,y)||e[y]===void 0||(r[y]=e[y])};for(let y of Ye(t??""))o(y);t!==void 0&&b(e)&&xe(t,i);let s=ze(t,e,Ve(t,Qe(e,t,r,i,n)));if(t==="history-attest"&&b(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new f("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",u.USAGE);let d=b(e)?e:a??e,_=D(d,We(s,qe(e,s,t)));return et(t,_)}function Xt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Jt(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function tt(e){let t=[],n=!0;for(let a of e.trim().toLowerCase()){if(a>="a"&&a<="z"||a>="0"&&a<="9"){t.push(a),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Zt(e){return!De.has(tt(e))}function Qt(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function nt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function en(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),a={};for(let[r,o]of Object.entries(e))n.has(r)||(a[r]=o);let i={...a,...t};return delete i.args,delete i.author,i}function tn(e,t){let n=D(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:n}}function V(e){return{type:c(e,"filterType"),tag:c(e,"filterTag"),priority:c(e,"filterPriority"),deadlineBefore:c(e,"filterDeadlineBefore"),deadlineAfter:c(e,"filterDeadlineAfter"),updatedAfter:c(e,"filterUpdatedAfter"),updatedBefore:c(e,"filterUpdatedBefore"),createdAfter:c(e,"filterCreatedAfter"),createdBefore:c(e,"filterCreatedBefore"),ids:x(e.ids),assignee:c(e,"filterAssignee"),assigneeFilter:c(e,"filterAssigneeFilter")??c(e,"filterAssignee_filter"),parent:c(e,"filterParent"),sprint:c(e,"filterSprint"),release:c(e,"filterRelease"),limit:c(e,"limit"),offset:c(e,"offset")}}function j(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return nt(e)}function M(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function nn(e){let t=j(e.kind),n=j(e.exemptIsolate),a=j(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:M(e.maxDepth),limit:M(e.limit),after:l(e,"after"),direction:l(e,"direction"),maxPaths:M(e.maxPaths),sample:M(e.sample),...n===void 0?{}:{exemptIsolate:n},...a===void 0?{}:{exemptIsolateType:a},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function me(e){let t=ne(e);return e.ids!==void 0&&(t.ids=x(e.ids)),t}function an(e){return{status:l(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),reason:l(e,"reason"),completedAt:l(e,"completedAt")??l(e,"completed_at"),resolution:l(e,"resolution"),expectedResult:l(e,"expectedResult")??l(e,"expected_result")??l(e,"expected"),actualResult:l(e,"actualResult")??l(e,"actual_result")??l(e,"actual"),validateClose:l(e,"validateClose")??l(e,"validate_close"),author:l(e,"author"),message:l(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var at=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function le(e){let t={};for(let[n,a]of Object.entries(e))at.has(n)||(t[n]=a);return _e(t)}function _e(e){return Ae(e,"update")}function Ae(e,t){let n=ye(e,t),a=P[t],i=new Set([...a.parameters,...A].filter(({booleanish:r})=>r===!0).map(({param:r})=>r));for(let{keys:r}of a.repeatables)for(let o of r)typeof n[o]=="string"&&(n[o]=[n[o]]);for(let r of a.strings)for(let o of r.keys){let s=n[o];(typeof s=="number"&&Number.isFinite(s)||s===!1&&i.has(o))&&(n[o]=String(s))}return t==="create"?{...ee(n,{requireType:!1})}:te(n)}function on(e){if(p(e.list)||p(e.update)){let t=p(e.update)?e.update:le(e),n=D(e,_e(t));return{status:c(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),update:q(t,n),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:c(e,"filterStatus"),list:V(e),update:D(e,le(e)),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function ce(e){return"expectHash"in e||"expect_hash"in e}function rn(e){if(!ce(e)&&!(p(e.options)&&ce(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:n,...a}=e,i=p(a.options)?a.options:{},{expectHash:r,expect_hash:o,...s}=i,d=[t,n,r,o].filter(v=>v!==void 0),_=d.length>1?d.flatMap(v=>Array.isArray(v)?v:[v]):d[0],y=C(e,"options"in a?{...a,options:p(a.options)?C(a.options,s):a.options}:a);return{expectHash:_,dispatchArgs:y}}export{it as a,g as b,st as c,lt as d,ct as e,ge as f,B as g,he as h,pt as i,Ee as j,Ce as k,Se as l,yt as m,N as n,$ as o,Nt as p,Ke as q,bt as r,b as s,Vt as t,l as u,c as v,zt as w,p as x,Ht as y,Yt as z,qt as A,fe as B,ye as C,Wt as D,Xt as E,Jt as F,tt as G,Zt as H,Qt as I,nt as J,en as K,tn as L,V as M,nn as N,an as O,_e as P,on as Q,rn as R};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Ab as Z,Bb as Q,Hb as A,Jb as w,Kc as ee,Lb as k,Lc as te,Nc as ne,jc as O,oc as S,wb as K,xb as X,yb as J,zb as I}from"./chunk-M5D3CEMY.js";import{L as R,b as E,ba as x,c as L,s as H,t as Y,ta as W,v as C,w as q}from"./chunk-7ESF676D.js";import{Rb as m}from"./chunk-FOYRE23V.js";import{A as u,C as f}from"./chunk-5OFMWP3Q.js";(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]="202cbe4e-7d36-5b12-be9d-d35608a6b36d")}catch{}})();var Oe=new Set(["none","null"]);function it(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function g(e){return e===void 0?!1:Oe.has(e.trim().toLowerCase())}function st(e,t,n){if(!g(e))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function lt(e,t,n){if(!e||e.length===0||L(e)||!e.some(i=>g(i)))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function ct(e,t){for(let n of t){let a=e[n.optionKey];if(!Array.isArray(a)||a.length===0)continue;if(!a.every(r=>typeof r=="string"))throw new f(`${n.valueFlag} entries must be strings.`,u.USAGE);if(L(a))continue;let i=a;if(i.some(r=>g(r))){if(i.filter(r=>!g(r)).length>0)throw new f(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,u.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}}return e}(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]="5146346c-df7b-5011-9d55-c59a7ff88f29")}catch{}})();var ge=["close_reason","close-reason"],ae=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],oe=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],Te=[...ae,...oe],re=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],B=[...Te,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...re],he=[...ae,{canonical:"close-reason",aliases:ge,optionKey:"closeReason",metadataKey:"close_reason"},...oe,...re],ve=new Set(["none","null","-"]);function ie(e){return e==="create"?B:he}function F(e,t){let n=t.unset;if(n!==void 0&&typeof n!="string"&&!Array.isArray(n))return;let a=[];for(let i of ie(e))i.optionKey==="author"||!Object.hasOwn(t,i.optionKey)||t[i.optionKey]!==null||(Reflect.deleteProperty(t,i.optionKey),a.push(i.canonical));a.length!==0&&(t.unset=[...n===void 0?[]:typeof n=="string"?[n]:n,...a])}function U(e){return typeof e=="string"&&ve.has(e.trim().toLowerCase())}function pt(e,t,n,a){return n?ie(e).flatMap(i=>{let r=t[i.optionKey],o=a[i.metadataKey];return U(r)&&(U(o)||Array.isArray(o)&&o.some(U))?[`literal_sentinel_stored:${i.canonical}:${r.trim()}`]:[]}):[]}function Ee(e,t){return e.flatMap(n=>n.includes(",")&&t(n)?[n]:n.split(","))}function Ce(e){let t=new Set,n=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:n};let a=Ee(e.raw,i=>e.resolveDefinition(i.trim().toLowerCase())!==void 0);for(let i of a){let r=i.trim().toLowerCase();if(!r)throw new f("--unset values must not be empty; name each field once, for example --unset parent,release",u.USAGE);if(g(r))throw new f('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',u.USAGE);let o=e.resolveDefinition(r);if(!o)throw new f(`Unsupported --unset field "${i}". Supported fields: ${e.supportedFields}`,u.USAGE);t.add(o.metadataKey),n.add(o.optionKey)}return{metadataKeys:t,optionKeys:n}}function Se(e,t,n){let a=e.trim().toLowerCase();if(!n)return;let i=n.command_to_fields?.get(t)??[];for(let r of i){if(r.allow_unset===!1)continue;let o=new Set;if(typeof r.key=="string"&&r.key.length>0&&o.add(r.key.toLowerCase()),typeof r.metadata_key=="string"&&r.metadata_key.length>0&&o.add(r.metadata_key.toLowerCase()),typeof r.cli_flag=="string"&&r.cli_flag.length>0&&(o.add(r.cli_flag.replaceAll("-","_").toLowerCase()),o.add(r.cli_flag.toLowerCase())),Array.isArray(r.cli_aliases))for(let s of r.cli_aliases)typeof s!="string"||s.length===0||(o.add(s.replaceAll("-","_").toLowerCase()),o.add(s.toLowerCase()));if(o.has(a))return{optionKey:r.key,metadataKey:r.metadata_key}}}var Ne=(()=>{let e=new Map;for(let t of B)for(let n of t.aliases)e.set(n,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),be=B.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function yt(e,t){return Ce({raw:e,supportedFields:be,resolveDefinition:n=>Ne.get(n)??Se(n,"create",t)})}(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]="837a5c2d-6447-5696-b0de-32641cde14cd")}catch{}})();var Re={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function T(e,t,n){let a=`${e} ${t} must be ${n}.`;throw new f(a,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:a,examples:[Re[e]]})}function N(e,t,n){typeof e!="string"&&T(t,n,"a string")}function $(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&T(t,"options","an object")}function se(e,t){(e==="append"||e==="update")&&t.id!==void 0&&N(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&N(t.id,"reopen","id"),t.reason!==void 0&&N(t.reason,"reopen","reason"),t.options!==void 0&&Ke(t.options))}function Nt(e){$(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&N(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&T("append","force","a boolean")}function Ke(e){$(e,"reopen");for(let t of S["item-reopen"].optional){let n=e[t];n!==void 0&&(m(Reflect.get(O,t)).type==="boolean"?typeof n!="boolean"&&T("reopen",t,"a boolean"):N(n,"reopen",t))}}function Ie(e,t){return e?t?"a string or string array":"a string array":"a string"}function we(e,t,n,a,i,r){n===void 0||typeof n=="string"&&(!i||r)||a==="priority"&&typeof n=="number"&&Number.isFinite(n)||i&&Array.isArray(n)&&Array.from(n).every(o=>typeof o=="string")||T(e,t,Ie(i,r))}function ke(e,t,n){let a=e==="create"?w:k;for(let{param:i}of[...a,...A,{param:"force"}]){if(m(Reflect.get(O,i)).type!=="boolean")continue;let r=n.find(o=>o.keys.includes(i))?.keys??[i];for(let o of r)t[o]!==void 0&&typeof t[o]!="boolean"&&T(e,o,"a boolean")}}function G(e,t,n=!0,a=!1){let i=e==="create"?K:I;for(let{target:r,keys:o,repeatable:s}of i)if(m(Reflect.get(O,r)).type!=="boolean")for(let d of o){let _=a&&d!==r,y=s===!0&&(r!=="acceptanceCriteria"||_);we(e,d,t[d],r,y,n||_)}ke(e,t,i)}function bt(e,t){$(t,e);let n=H(t),a=E(n);return a||F(e,n),G(e,n,!1,a),n}(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]="63a51994-4328-5a65-938c-d0de377ac338")}catch{}})();var Fe=Symbol("pm.mcp-mutation-transport"),Me=new Set(["create","update","append"]),P={create:{parameters:w,aliases:K,strings:X,repeatables:J},update:{parameters:k,aliases:I,strings:Z,repeatables:Q}},De=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function b(e){return Fe in e}function D(e,t){return b(e)?Y(t):C(e,t)}function Vt(e,t,n=[]){let a=C(e,{...e,...t});for(let i of n)Reflect.deleteProperty(a,i);return a}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function c(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function zt(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ht(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new f(`${t} must be a finite integer.`,u.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new f(`${t} must be a finite integer.`,u.USAGE);return n}}function Yt(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:l(e,"limit")??l(t,"limit")}function qt(e){let t=l(e,"outputFormat");return{json:!0,quiet:!0,author:l(e,"author"),path:l(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:l(e,"outputInclude"),outputLimit:c(e,"outputLimit"),outputBudget:c(e,"outputBudget"),outputSession:l(e,"outputSession"),outputCursor:l(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var de=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ue=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),Pe=new Set([...ue].filter(e=>e!=="file")),Le=new Set(["files","files-discover","docs","test","test-all"]),z=new Set(["comments","notes","learnings"]);function xe(e,t){if(!(!z.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new f(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,u.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var Ue=new Set(["claim","release","start-task","pause-task","close-task"]),fe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},Be=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),$e=new Set(["query","keywords","id","text"]);function Ge(e){return Be.has(e)?S[e].optional.filter(t=>!$e.has(t)):[]}var je=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function Ve(e,t){if(!je.has(e??""))return t;let n={...t};for(let a of S[e].optional){let i=a.replace(/[A-Z]/gu,r=>`_${r.toLowerCase()}`);i===a||n[i]===void 0||(n[a]??=n[i],delete n[i])}return n}function ze(e,t,n){if(!z.has(e??""))return n;let a=n,i=a.text??t.text;if(i===void 0)return a;if(a.add!==void 0&&a.add!==i){let o=e.replace(/s$/u,"");throw new f(`Specify ${o} text either as text or with add, not both.`,u.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${o} text once: text and add are the same source.`})}let r={...a,add:i};return delete r.text,r}function He(e,t){let n=t.replace(/[A-Z]/gu,a=>`_${a.toLowerCase()}`);return e[t]!==void 0||e[n]!==void 0}function Ye(e){return[...fe[e]??[],...Ge(e),...pe]}var pe=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function ye(e,t=""){let n={},a=Le.has(t),i=t==="files"||t==="files-discover"||t==="docs",r=z.has(t)?Pe:ue;for(let[o,s]of Object.entries(e)){if(Array.isArray(s)&&de.has(o)){n[o]=s.join(",");continue}if(o==="note"&&i){n[o]=s;continue}if(typeof s=="string"&&r.has(o)){n[o]=[s];continue}if(typeof s=="string"&&a&&(o==="add"||o==="remove")){n[o]=[s];continue}n[o]=s}return Object.assign(n,Object.fromEntries(Object.getOwnPropertySymbols(e).map(o=>[o,Reflect.get(e,o)]))),n}function qe(e,t,n){let a=l(e,"author");return a!==void 0?a:n!==void 0&&Ue.has(n)?l(e,"assignee")??l(t,"assignee"):void 0}function We(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function Xe(e,t,n){let a={},i=P[e],r=new Set([...i.parameters.map(({param:o})=>o),...A.map(({param:o})=>o),...fe[e],...pe,"force"]);for(let o of r){let s=i.aliases.find(d=>d.keys.includes(o))?.keys??[o];t[o]===void 0||s.some(d=>n[d]!==void 0)||(a[o]=t[o])}return a}function h(e,t){throw new f(`Invalid MCP ${e} value for "${t}". No changes were made.`,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function Je(e,t,n){let a=P[e],i=[...a.parameters,...A,{param:"force"}];for(let{param:r}of i){if(m(O[r]).type!=="boolean")continue;let o=(a.aliases.find(s=>s.keys.includes(r))?.keys??[r]).find(s=>n[s]!==void 0&&typeof n[s]!="boolean");o!==void 0&&h(e,o)}for(let r of["idOnly","fullChangedFields"])t[r]!==void 0&&typeof t[r]!="boolean"&&h(e,r)}function Ze(e,t,n){t.options!==void 0&&!p(t.options)&&h(e,"options"),Je(e,t,n);for(let o of de){let s=n[o];Array.isArray(s)&&s.some(d=>typeof d!="string")&&h(e,o)}let a=Ae(n,e),i=P[e];for(let{keys:o,target:s}of i.strings)o.some(d=>n[d]!==void 0)&&a[s]===void 0&&h(e,s);let r=i.repeatables.flatMap(({keys:o})=>o).find(o=>{let s=n[o];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(d=>typeof d!="string"))});return r!==void 0&&h(e,r),a}function Qe(e,t,n,a,i){let r=(t==="create"||t==="update")&&b(e),o={...r?Xe(t,e,a):n,...a};if((t==="create"||t==="update")&&!r){let s=p(e.options)&&E(e.options);s||F(t,o),G(t,o,!0,s)}return r?Ze(t,e,o):i?ye(o,t):o}function et(e,t){return!Me.has(e??"")||E(t)?t:W(t)}function Wt(e,t,{nativeAction:n=!0}={}){se(t,e);let a=p(e.options)?e.options:void 0,i=m(e.options),r={},o=y=>{He(i,y)||e[y]===void 0||(r[y]=e[y])};for(let y of Ye(t??""))o(y);t!==void 0&&b(e)&&xe(t,i);let s=ze(t,e,Ve(t,Qe(e,t,r,i,n)));if(t==="history-attest"&&b(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new f("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",u.USAGE);let d=b(e)?e:a??e,_=D(d,We(s,qe(e,s,t)));return et(t,_)}function Xt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Jt(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function tt(e){let t=[],n=!0;for(let a of e.trim().toLowerCase()){if(a>="a"&&a<="z"||a>="0"&&a<="9"){t.push(a),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Zt(e){return!De.has(tt(e))}function Qt(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function nt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function en(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),a={};for(let[r,o]of Object.entries(e))n.has(r)||(a[r]=o);let i={...a,...t};return delete i.args,delete i.author,i}function tn(e,t){let n=D(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:n}}function V(e){return{type:c(e,"filterType"),tag:c(e,"filterTag"),priority:c(e,"filterPriority"),deadlineBefore:c(e,"filterDeadlineBefore"),deadlineAfter:c(e,"filterDeadlineAfter"),updatedAfter:c(e,"filterUpdatedAfter"),updatedBefore:c(e,"filterUpdatedBefore"),createdAfter:c(e,"filterCreatedAfter"),createdBefore:c(e,"filterCreatedBefore"),ids:x(e.ids),assignee:c(e,"filterAssignee"),assigneeFilter:c(e,"filterAssigneeFilter")??c(e,"filterAssignee_filter"),parent:c(e,"filterParent"),sprint:c(e,"filterSprint"),release:c(e,"filterRelease"),limit:c(e,"limit"),offset:c(e,"offset")}}function j(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return nt(e)}function M(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function nn(e){let t=j(e.kind),n=j(e.exemptIsolate),a=j(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:M(e.maxDepth),limit:M(e.limit),after:l(e,"after"),direction:l(e,"direction"),maxPaths:M(e.maxPaths),sample:M(e.sample),...n===void 0?{}:{exemptIsolate:n},...a===void 0?{}:{exemptIsolateType:a},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function me(e){let t=ne(e);return e.ids!==void 0&&(t.ids=x(e.ids)),t}function an(e){return{status:l(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),reason:l(e,"reason"),completedAt:l(e,"completedAt")??l(e,"completed_at"),resolution:l(e,"resolution"),expectedResult:l(e,"expectedResult")??l(e,"expected_result")??l(e,"expected"),actualResult:l(e,"actualResult")??l(e,"actual_result")??l(e,"actual"),validateClose:l(e,"validateClose")??l(e,"validate_close"),author:l(e,"author"),message:l(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var at=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function le(e){let t={};for(let[n,a]of Object.entries(e))at.has(n)||(t[n]=a);return _e(t)}function _e(e){return Ae(e,"update")}function Ae(e,t){let n=ye(e,t),a=P[t],i=new Set([...a.parameters,...A].filter(({booleanish:r})=>r===!0).map(({param:r})=>r));for(let{keys:r}of a.repeatables)for(let o of r)typeof n[o]=="string"&&(n[o]=[n[o]]);for(let r of a.strings)for(let o of r.keys){let s=n[o];(typeof s=="number"&&Number.isFinite(s)||s===!1&&i.has(o))&&(n[o]=String(s))}return t==="create"?{...ee(n,{requireType:!1})}:te(n)}function on(e){if(p(e.list)||p(e.update)){let t=p(e.update)?e.update:le(e),n=D(e,_e(t));return{status:c(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),update:q(t,n),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:c(e,"filterStatus"),list:V(e),update:D(e,le(e)),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function ce(e){return"expectHash"in e||"expect_hash"in e}function rn(e){if(!ce(e)&&!(p(e.options)&&ce(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:n,...a}=e,i=p(a.options)?a.options:{},{expectHash:r,expect_hash:o,...s}=i,d=[t,n,r,o].filter(v=>v!==void 0),_=d.length>1?d.flatMap(v=>Array.isArray(v)?v:[v]):d[0],y=C(e,"options"in a?{...a,options:p(a.options)?C(a.options,s):a.options}:a);return{expectHash:_,dispatchArgs:y}}export{it as a,g as b,st as c,lt as d,ct as e,ge as f,B as g,he as h,pt as i,Ee as j,Ce as k,Se as l,yt as m,N as n,$ as o,Nt as p,Ke as q,bt as r,b as s,Vt as t,l as u,c as v,zt as w,p as x,Ht as y,Yt as z,qt as A,fe as B,ye as C,Wt as D,Xt as E,Jt as F,tt as G,Zt as H,Qt as I,nt as J,en as K,tn as L,V as M,nn as N,an as O,_e as P,on as Q,rn as R};
|
|
2
|
+
//# sourceMappingURL=chunk-6HRPGEBF.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as k,c as I,d as A,e as E,k as T,m as _}from"./chunk-
|
|
1
|
+
import{a as k,c as I,d as A,e as E,k as T,m as _}from"./chunk-2IZGNOGT.js";import{lb as b,mb as v,nb as R}from"./chunk-7EZZ4W7O.js";import{Cc as f,Fc as g,Gc as a,Xc as w}from"./chunk-M5D3CEMY.js";import{ca as x,od as H}from"./chunk-7ESF676D.js";import{$g as m,Wg as C,ah as y,hj as D}from"./chunk-FOYRE23V.js";import{A as c,C as p}from"./chunk-5OFMWP3Q.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="631e56aa-4d7e-58b6-bbea-a0d320716b82")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0bcdd63c-5fd3-585d-a6c5-9393029ef864")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4dce4f19-071c-54a8-be0d-5975d9e3b34b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f330a0c5-a967-5383-9c27-efa4a39e0f0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f910b36e-c3ed-532e-a679-12547d249443")}catch{}})();function O(t,e){if(typeof t!="string")return;let o=Number.parseInt(t,10);if(!/^\d+$/.test(t.trim())||!Number.isSafeInteger(o))throw new p(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function S(t,e,o){let r=f(o),n=Date.now(),i=await x(a(e,"ids")),l=i===void 0?void 0:H(i),d=O(e.allOver,"--all-over"),u=O(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new p("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let s=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||d!==void 0||s!==void 0)&&typeof e.before=="string")throw new p("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(I(t,{ids:l,allOver:d,scope:s}),t!==void 0&&u!==void 0)throw new p("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(t===void 0){let h=await A({ids:l,scope:s,allOver:d,minEntries:u,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await k(t,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r)}r.profile&&y(`profile:command=history-compact took_ms=${Date.now()-n}`)}async function N(t,e,o,r){let n=f(r),i=Date.now(),l=await _(t,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},n);await w(n,l),m(l,n),n.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function B(t,e){let o=f(e),r=await T({verify:a(t,"verify"),output:a(t,"output"),hashAlgorithm:a(t,"hashAlgorithm")},o);"format"in r?(D(r),o.quiet||C(`${JSON.stringify(r,null,2)}
|
|
2
2
|
`)):m(r,o),"ok"in r&&!r.ok&&(process.exitCode=c.GENERIC_FAILURE)}function Z(t,e){t.command(e?"attest":"history-attest",{hidden:!e}).summary("Export or verify history proof.").option("--verify <file>","Compare retained streams with a detached JSON proof").option("--output <file>","Create a proof file and return a compact receipt").option("--hash-algorithm <name>","Bundle digest algorithm: sha256 (default) or sha512").description("Export exact-byte history commitments, or verify an independently retained proof without tracker writes.").action(B),t.command("restore",{hidden:!e}).summary("Restore a version.").argument("<id>","Item id").argument("<target>","Restore target timestamp or version number").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(N),t.command(e?"redact":"history-redact",{hidden:!e}).summary("Redact sensitive values.").argument("<id>","Item id").option("--literal <value>","Literal; repeatable",g).option("--regex <value>","Raw RegExp source (repeatable; e.g. /var/[a-z]+) or /pattern/flags. Leading-slash input is a literal only when the final unescaped slash is followed by supported JavaScript flag letters or nothing.",g).option("--replacement <value>",'Default: "[redacted]"').option("--dry-run","Preview; no item/history edits").option("--author <value>","Author").option("--message <value>","Audit marker message").option("--force","Override owner/lock").description("Redact and reseal item history.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=Array.isArray(r.literal)?r.literal:void 0,u=Array.isArray(r.regex)?r.regex:void 0,s=await E(o,{literal:d,regex:u,replacement:a(r,"replacement"),dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force},i);s.changed&&!s.dry_run&&await w(i,s),m(s,i),i.profile&&y(`profile:command=history-redact took_ms=${Date.now()-l}`)}),t.command(e?"repair":"history-repair",{hidden:!e}).summary("Repair drift.").argument("[id]","Item id (omit with --all)").option("--salvage-tail","Recover invalid tail; requires verified prefix").option("--all","Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run","Preview the re-anchor impact without writing the history file").option("--normalize-provenance","Remove invalid provenance; return aggregate-only evidence").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the repair marker entry").option("--force","Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=r.all===!0;v(o,d);let u={dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force,normalizeProvenance:r.normalizeProvenance===!0,salvageTail:r.salvageTail===!0};if(d){let s=await R(u,i);m(s,i),s.totals.failed>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let s=await b(o,u,i);m(s,i)}i.profile&&y(`profile:command=history-repair took_ms=${Date.now()-l}`)}),t.command(e?"compact":"history-compact",{hidden:!e}).summary("Compact streams.").argument("[id]","Item id (omit when using a bulk selector)").option("--before <value>","Compact entries strictly before this version number or ISO timestamp (single-id mode only)").option("--ids <value>","Bulk IDs: comma/newline text, - stdin, or @path file").option("--all-over <n>","Bulk: compact every stream with more than N entries").option("--closed","Bulk: compact only closed (terminal) items' streams").option("--all-streams","Bulk: compact every history stream regardless of lifecycle state").option("--min-entries <n>","Bulk: skip streams with at most N entries (already compact; default 3)").option("--dry-run","Preview compaction impact without writing the history file").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the compaction marker entry").option("--force","Force ownership/lock override").description("Compact item history streams into a synthetic baseline plus retained tail entries. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to compact many.").action(S)}export{Z as a};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-6X2AGUOT.js.map
|