@unbrained/pm-cli 2026.11.17 → 2026.11.19
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/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2UTJ5QIE.js +71 -0
- package/dist/cli-bundle/chunks/{chunk-VLKCFZY6.js → chunk-4FNMPZ7Y.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-723PMYNX.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-77MGDTK4.js → chunk-AGPFANRX.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-RXNBNF6O.js → chunk-AMHD7WIV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7K2RUKMK.js → chunk-AOV5HG3Y.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-36R3JTAD.js → chunk-CNMGGAZO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XPBADEUK.js → chunk-CTOE26W4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FXSLODOK.js → chunk-GQCMICAL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ABFHWRLE.js → chunk-IQKCRLQP.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QANUQMDL.js → chunk-IUTN67EB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-M76BEWTT.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-ADKDFCVT.js → chunk-N2CPCFSN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KIQNEOKJ.js → chunk-NMVPQTZI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XP35IEHT.js → chunk-O7IFAJ76.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X5TFNFTS.js → chunk-OESI2ETD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ACLBUVQG.js → chunk-P4A5RFLX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QZNL5XDT.js → chunk-PRVT7ITI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O4ZSIMNC.js → chunk-Q32Q3LRH.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DXSZL3T6.js → chunk-XPBPGDFW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4FIN2XWC.js → chunk-Z5LHCEXG.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-7RVMVXTE.js → item-revision-YJKGOYBR.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-K4YZ7GWR.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-3PKQOAYK.js → mutation-admission-JLMQJ2M5.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-TPZLHFHQ.js → register-list-query-4AXLLXK7.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-JG5AEBRJ.js → register-mutation-FJIXGGF4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-3CNXP46P.js → register-operations-W4E2KEMA.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-4N56VL2P.js → register-setup-RYRIBNSN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VBA4BIHN.js → chunk-2XULTI5B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2MQNIDKG.js → chunk-4S7I342K.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GD2YWUAD.js → chunk-77CDWGBW.js} +55 -54
- package/dist/cli-bundle/focused-chunks/{chunk-BNLLST32.js → chunk-7A4VIRIU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SESMRMEE.js → chunk-D72EQN7Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YWPLBFPC.js → chunk-GAOWBALE.js} +23 -23
- package/dist/cli-bundle/focused-chunks/chunk-N64BUB63.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XJS4COL2.js → chunk-OF4UM5B6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6JQXDGHM.js → chunk-P4TG4VMJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-U7GDVAH7.js → item-revision-32HFGFYG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-7C4BH47O.js → item-transaction-C4VW3SHX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-SKXVITP5.js → mutation-admission-PNK6ORZR.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-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +58 -58
- 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 +2 -0
- package/dist/core/shared/process-tree.js +3 -0
- package/dist/core/shared/secret-rules.d.ts +94 -4
- package/dist/core/shared/secret-rules.js +5 -4
- 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/linked-artifacts.js +2 -2
- package/dist/sdk/mutation-guard.d.ts +146 -5
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/test/execution.js +2 -2
- package/docs/COMMANDS.md +33 -0
- package/docs/CONFIGURATION.md +1 -0
- package/docs/DEFECT_RECURRENCE.md +3 -2
- package/docs/MUTATION_INTEGRITY.md +259 -7
- package/docs/PACKAGE_EVIDENCE.md +66 -0
- package/marketplace.json +1 -1
- package/package.json +1 -3
- 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-2WHXFKMY.js +0 -31
- package/dist/cli-bundle/chunks/chunk-3IU2S5UQ.js +0 -70
- package/dist/cli-bundle/chunks/chunk-AM26RAG7.js +0 -124
- package/dist/cli-bundle/chunks/item-transaction-NVX6P3FK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZDY5L2C2.js +0 -26
- package/node_modules/fdir/LICENSE +0 -7
- package/node_modules/fdir/README.md +0 -91
- package/node_modules/fdir/dist/index.cjs +0 -588
- package/node_modules/fdir/dist/index.d.cts +0 -155
- package/node_modules/fdir/dist/index.d.mts +0 -155
- package/node_modules/fdir/dist/index.mjs +0 -570
- package/node_modules/fdir/package.json +0 -106
- package/node_modules/picomatch/LICENSE +0 -21
- package/node_modules/picomatch/README.md +0 -743
- package/node_modules/picomatch/index.js +0 -17
- package/node_modules/picomatch/lib/constants.js +0 -184
- package/node_modules/picomatch/lib/parse.js +0 -1425
- package/node_modules/picomatch/lib/picomatch.js +0 -361
- package/node_modules/picomatch/lib/scan.js +0 -403
- package/node_modules/picomatch/lib/utils.js +0 -72
- package/node_modules/picomatch/package.json +0 -83
- package/node_modules/picomatch/posix.js +0 -3
- package/node_modules/tinyglobby/LICENSE +0 -21
- package/node_modules/tinyglobby/README.md +0 -25
- package/node_modules/tinyglobby/dist/index.cjs +0 -335
- package/node_modules/tinyglobby/dist/index.d.cts +0 -148
- package/node_modules/tinyglobby/dist/index.d.mts +0 -148
- package/node_modules/tinyglobby/dist/index.mjs +0 -307
- package/node_modules/tinyglobby/package.json +0 -70
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as ve}from"./chunk-4FIN2XWC.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-AM26RAG7.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-Z5LHCEXG.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-723PMYNX.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-4FNMPZ7Y.js.map
|