@unbrained/pm-cli 2026.11.28 → 2026.11.29
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/commander-usage.js +4 -4
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/linked-resource-value-list.js +2 -0
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-YEMFOKFG.js → chunk-3AZOATC2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LMDIKSDZ.js → chunk-3E53F7QY.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-OFIYA3PI.js → chunk-3TK2YOVB.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-C4O5TZY3.js → chunk-3US5T6B2.js} +60 -60
- package/dist/cli-bundle/chunks/chunk-4EBHZBM2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-MGJMQSN4.js → chunk-4QA5O64H.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-5EFS7K7Y.js +1 -0
- package/dist/cli-bundle/chunks/chunk-CNZOC6JD.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-TWRUA2NH.js → chunk-CV2B4JUB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-DBASKWBO.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-Q6BGQRCB.js → chunk-EYEQC3L2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O2SWNEBW.js → chunk-FRYNDVLN.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GSLOAEY2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-T7RZPIOB.js → chunk-JFPCL45G.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CTM26LUE.js → chunk-JQHLOSSS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-JV7LREUF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-K3MVVDLN.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-6OIHST4I.js → chunk-K672XXGQ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-T7UTG56V.js → chunk-KCR4NF2A.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-L7HON3BE.js +23 -0
- package/dist/cli-bundle/chunks/chunk-LQEB6GSY.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZXERHBMA.js → chunk-NLHNB2L3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FG4TNQQM.js → chunk-NRCGGNOE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KHFUHGL3.js → chunk-OGVSGXQX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CATRDGAB.js → chunk-PY6A7ULK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-O2WNNIKK.js → chunk-Q6GIFUCW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CDUV7DFD.js → chunk-R6M5OGJH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-RWHS77ME.js +113 -0
- package/dist/cli-bundle/chunks/chunk-SV27NNXQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-TE6FBDHP.js +4 -0
- package/dist/cli-bundle/chunks/{chunk-LRGYV6QQ.js → chunk-VI3A7UZ2.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-E2LQ6LCJ.js → chunk-WLZ5KVM2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WNB62BGK.js +10 -0
- package/dist/cli-bundle/chunks/chunk-X5D5YUHR.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZK4CY24V.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-JQYPSABI.js → chunk-ZSBPE36C.js} +2 -2
- package/dist/cli-bundle/chunks/field-definition-losses-XKE4DRUA.js +2 -0
- package/dist/cli-bundle/chunks/{field-option-collisions-G4LQ2646.js → field-option-collisions-OZE43TOH.js} +2 -2
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-H3MMNXXG.js → indexed-receipt-blobs-DR3FDHND.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-O7L3AA2W.js → item-revision-3WXNNFLP.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-DJ5GAITL.js +2 -0
- package/dist/cli-bundle/chunks/linked-resource-value-list-2655COY2.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-A45DFDEO.js → mutation-actor-QOKPDYM4.js} +2 -2
- package/dist/cli-bundle/chunks/mutation-admission-JNJHB3E6.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-FCPGG2UT.js → register-list-query-YGVUE4YZ.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-VD3JX23I.js → register-mutation-3JVZQDHH.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-LCHUHKRA.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-EWAZZWPL.js → register-setup-IJ7M3VUK.js} +2 -2
- package/dist/cli-bundle/chunks/runtime-schema-OAIUNQRL.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-KWBOSRDZ.js → settlement-hook-BIVNGBZF.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-UIDZMTE5.js → stage-7BD7U2BX.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-26P6C6OO.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-2CQFGJQ6.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-42SU4LK3.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7P6OGPEG.js → chunk-5NSWNLFE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Y7EC2L2G.js → chunk-ACTBMSCH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-BPBKHY6H.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YC3PFFDE.js → chunk-BPOU2S44.js} +57 -57
- package/dist/cli-bundle/focused-chunks/chunk-BZ3PUUPG.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-AHCOSTL7.js → chunk-CWQLW4ZO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-7EKKUYN5.js → chunk-EUDAUT6T.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-GTUPHXKR.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NGFDPEP7.js → chunk-IRYNVGKH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-JFICNN4T.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-J4V3J5MC.js → chunk-KLOHZNJ4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KPASZGBL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-Q6JCMFGU.js → chunk-KWKPX36T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZYHGQIQ7.js → chunk-LKTRICZR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-OEMI52ZS.js → chunk-LSVRZ4KQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-MYWUMVCZ.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-CQLOYNJY.js → chunk-NNLENKU7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NO5MUY4I.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-XVCMYFQU.js → chunk-NZA2LP4Y.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-HCWDMFWA.js → chunk-PPCBCPIZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-QTV6UE2Q.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-VNU3IFBL.js → chunk-S4AC7OMI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-YX75PQFO.js → chunk-S5VG7RFY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JD45Y2BR.js → chunk-TSZVCALS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-O33WUEAF.js → chunk-TX24L7RQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WJAUHPXD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4SX2BN4V.js → chunk-XR6MLUVW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/field-definition-losses-GGA6FUHD.js +2 -0
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-63YQ2J3N.js → field-option-collisions-HABQYZMQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-PG2VJ3MB.js → indexed-receipt-blobs-EUYZJR5R.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-PV5O6F5Y.js → item-revision-YH5R7YPW.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-YZ2PUPGM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{mutation-actor-2AAUJG2Z.js → mutation-actor-DJ2VRLKG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-3SECKVKY.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-IDRXWCC4.js +2 -0
- package/dist/cli-bundle/focused-chunks/{settlement-hook-4MGRERCT.js → settlement-hook-Q6MJQKIE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-56RYPMBK.js → stage-FEJT2UCG.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- 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 +63 -63
- 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 +1 -1
- package/dist/core/extensions/item-fields.d.ts +18 -1
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/fs/fs-utils.d.ts +8 -0
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/item/item-type-inspection.js +2 -0
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +19 -0
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/store/settings.d.ts +7 -0
- package/dist/core/store/settings.js +5 -5
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/schema/field-definition-losses.js +1 -1
- package/dist/sdk/schema/schema-file-entry-losses.js +2 -0
- package/dist/sdk/test/execution.d.ts +9 -1
- package/dist/sdk/test/execution.js +4 -4
- package/docs/COMMANDS.md +3 -1
- package/docs/CONFIGURATION.md +1 -1
- package/docs/EXTENSIONS.md +1 -1
- package/docs/SDK_AUDITED_MUTATIONS.md +9 -0
- package/marketplace.json +1 -1
- package/node_modules/fast-json-patch/README.md +2 -2
- package/node_modules/fast-json-patch/dist/fast-json-patch.js +604 -818
- package/node_modules/fast-json-patch/dist/fast-json-patch.min.js +4 -8
- package/node_modules/fast-json-patch/package.json +14 -17
- package/package.json +2 -2
- 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-2YD2AERA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-54AQJTUH.js +0 -3
- package/dist/cli-bundle/chunks/chunk-56DKWGHE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-56GUDMXN.js +0 -113
- package/dist/cli-bundle/chunks/chunk-5ECCMDSU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-6RBD2AKU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-D3I5AHNN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-MO6PPUI6.js +0 -2
- package/dist/cli-bundle/chunks/chunk-RGE3XW3A.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SP6CDM6B.js +0 -31
- package/dist/cli-bundle/chunks/chunk-WKDKBS4P.js +0 -4
- package/dist/cli-bundle/chunks/chunk-YLS2N4SN.js +0 -2
- package/dist/cli-bundle/chunks/field-definition-losses-JFMMMVTV.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-4XC74ULD.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-SIUIMAEO.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-KHJD4GFZ.js +0 -2
- package/dist/cli-bundle/chunks/runtime-schema-3RAXYNG5.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5MZXU6HB.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-64DSKZJN.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-A5B43EWU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-E4C6T3NL.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-KMGI5GZP.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-MSLRDKWL.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-RBOWKXFV.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-TF57RHS2.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-X5ZVPFK7.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-Z4FWJGQG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZHHFOQSL.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-ZUAPUBJK.js +0 -2
- package/dist/cli-bundle/focused-chunks/field-definition-losses-NUZO3JCP.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-S5QXBGAT.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-X7HHNERR.js +0 -2
- package/dist/cli-bundle/focused-chunks/runtime-schema-5J2ONRNV.js +0 -2
- package/node_modules/fast-json-patch/webpack.config.js +0 -63
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as se}from"./chunk-SV27NNXQ.js";import"./chunk-SLFRSZK6.js";import{Ac as Q,Cc as Z,Db as V,Dc as ee,Ga as P,Jb as N,Mb as q,Uc as te,Xa as M,Xc as ae,Yc as re,Zc as B,dd as ie,nc as J,oc as U,pc as $,qc as H,rc as W,sc as j,tc as G,ub as F,vc as S,wc as z,xc as Y,yc as K,zc as X}from"./chunk-L7HON3BE.js";import"./chunk-KCR4NF2A.js";import"./chunk-X5D5YUHR.js";import"./chunk-4QA5O64H.js";import"./chunk-VI3A7UZ2.js";import{ca as ne,ja as oe}from"./chunk-WNB62BGK.js";import"./chunk-JFPCL45G.js";import"./chunk-JQHLOSSS.js";import"./chunk-6H36ZHMI.js";import"./chunk-3TK2YOVB.js";import"./chunk-OGVSGXQX.js";import"./chunk-AA52P34H.js";import{Ka as h,ja as D,ka as T,la as L,pa as c,sa as f,ta as i,ua as y}from"./chunk-R6M5OGJH.js";import"./chunk-4EBHZBM2.js";import"./chunk-WLZ5KVM2.js";import"./chunk-PZA7QECY.js";import{R as b}from"./chunk-PY6A7ULK.js";import{u as C}from"./chunk-3E53F7QY.js";import"./chunk-3AZOATC2.js";import{Ib as O,Ue as l,Ve as d,fh as A}from"./chunk-RWHS77ME.js";import{o as x}from"./chunk-GSLOAEY2.js";import"./chunk-CNZOC6JD.js";import"./chunk-NRCGGNOE.js";import{o as I,p as E}from"./chunk-JV7LREUF.js";import"./chunk-TE6FBDHP.js";import{A as u,C as p}from"./chunk-K672XXGQ.js";import"./chunk-XAWE4EAK.js";var le=new Map([["measurements","boolean"],["metric","string"],["measurementLimit","number"],["observe","string_array"],["direction","direction"],["measurementSource","string"],["measurementItem","string"],["measurementRevision","string"],["author","string"],["message","string"],["provenanceCoverage","boolean"],["fleetAttribution","boolean"],["since","string"],["eventLimit","number"],["minimumSample","number"]]),ve=new Set(["higher","lower","target"]),xe=[...le.keys()].sort((e,t)=>e.localeCompare(t)).join(", ");function be(e,t){return e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="number"?typeof t=="number":e==="string_array"?Array.isArray(t)&&t.every(a=>typeof a=="string"):e==="direction"&&ve.has(t)}function ce(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch(a){throw new p(`--analytics must be valid JSON: ${String(a)}`,u.USAGE)}if(t===null||typeof t!="object"||Array.isArray(t))throw new p("--analytics must be a JSON object.",u.USAGE);for(let[a,n]of Object.entries(t)){let o=le.get(a);if(!be(o,n))throw new p(o===void 0?`Unknown --analytics field "${a}". Accepted fields: ${xe}.`:`--analytics field "${a}" must be ${o.replace("_"," ")}.`,u.USAGE)}return t}var de=(e,t)=>V(e,t,{runUpdate:(a,n,o)=>se(a,n,o)});async function Ae(e,t,a,n,o){let r=c(o),s=e==="run",m=e==="verdicts",g=e==="presets"||e==="apply",v=e==="promote",k=await N({action:e,...s||m||g||v?{}:{kind:t},id:s||m||v?a??t:a,preset:g?a??t:void 0,definition:i(n,"definition"),trigger:i(n,"trigger"),tree:i(n,"tree"),gate:i(n,"gate"),limit:i(n,"limit"),dry_run:n.dryRun===!0,fullChangedFields:r.fullChangedFields,idOnly:r.idOnly,author:i(n,"author"),message:i(n,"message"),owner:i(n,"owner"),apply:n.apply===!0,enforcement:i(n,"enforcement")},r);l(k,r),typeof k=="object"&&k!==null&&"exit_code"in k&&k.exit_code===1&&(process.exitCode=1)}function ue(e){e.command("assurance").argument("<action>","Action; inspect `pm contracts --command assurance`").argument("[kind]","Declaration kind or run gate id").argument("[id]","Declaration/gate id").description("Manage SDK-owned assurance contracts.").option("--definition <json>","Put declaration JSON").option("--trigger <value>","Gate trigger").option("--tree <value>","Revision identity").option("--gate <id>","Verdict gate filter").option("--limit <number>","Verdict limit").option("--dry-run","Evaluate without recording").option("--author <value>","Mutation author").option("--message <value>","Mutation rationale").option("--owner <item-id>","Preset/derivation owner").option("--apply","Persist derived proposals").option("--enforcement <level>","Promote to warn or block").action(Ae)}function Ce(e,t){let a=e?.trim().toLowerCase(),n=t?.trim().toLowerCase();if(a===void 0||a.length===0)return n;if(a==="local-analytics")return n&&n.length>0?n:"status";if(n!==void 0&&n.length>0)throw b({command_path:"telemetry",token:`${e} ${t}`,allowed:["status","flush","stats","clear","local-analytics"],token_kind:"path",examples:["pm telemetry stats --limit 10","pm telemetry local-analytics status --json"]});return a}function Se(e){return{addValues:Array.isArray(e.add)?e.add:[],addJsonValues:Array.isArray(e.addJson)?e.addJson:[],removeValues:Array.isArray(e.remove)?e.remove:[],removeIndexValues:Array.isArray(e.removeIndex)?e.removeIndex:[]}}function fe(e,t){if(e.background===!0){if(e.run!==!0)throw new p("--background requires --run",u.USAGE);if(e.acknowledgeLinkedTests===!0)throw new p("--background cannot be combined with --acknowledge-linked-tests; acknowledgement is a non-executing foreground operation",u.USAGE);if(e.update!==void 0||e.updateIndex!==void 0||e.setJson!==void 0||t.addValues.length>0||t.addJsonValues.length>0||t.removeValues.length>0||t.removeIndexValues.length>0)throw new p("--background does not support --add/--add-json/--remove/--remove-index or metadata edits; update linked tests first, then run in background",u.USAGE)}}async function Be(e,t,a,n){let o=await B({kind:"test",commandArgs:D(e,{...t,add:n.addValues,addJson:n.addJsonValues,remove:n.removeValues,removeIndex:n.removeIndexValues}),targetId:e,author:typeof t.author=="string"?t.author:void 0,noExtensions:a.noExtensions===!0},a);l(o,a)}function _e(e){return{update:typeof e.update=="string"?e.update:void 0,updateIndex:typeof e.updateIndex=="string"||typeof e.updateIndex=="number"?e.updateIndex:void 0,setJson:typeof e.setJson=="string"?e.setJson:void 0}}function _(e,t){return{add:t.addValues,addJson:t.addJsonValues,remove:t.removeValues,removeIndex:t.removeIndexValues,..._e(e),list:!!e.list,fullHistory:e.fullHistory===!0,run:!!e.run,match:typeof e.match=="string"?e.match:void 0,onlyIndex:typeof e.onlyIndex=="string"||typeof e.onlyIndex=="number"?e.onlyIndex:void 0,onlyLast:!!e.onlyLast,timeout:typeof e.timeout=="string"?e.timeout:void 0,progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:typeof e.pmContext=="string"?e.pmContext:void 0,overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:typeof e.workspaceContext=="string"?e.workspaceContext:void 0,overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,acknowledgeLinkedTests:!!e.acknowledgeLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,fullOutput:!!e.fullOutput,autoPmContext:!!e.autoPmContext,author:typeof e.author=="string"?e.author:void 0,message:typeof e.message=="string"?e.message:void 0,force:!!e.force,measure:Array.isArray(e.measure)?e.measure:[],metricBelow:typeof e.metricBelow=="string"?e.metricBelow:void 0,metricDiff:typeof e.metricDiff=="string"?e.metricDiff:void 0}}var Nt={buildRunTestOptions:_,buildRunTestAllOptions:pe,runWorkspacePositionAction:he,validateBackgroundTestOptions:fe};async function Re(e,t,a,n){let o=await oe(e,_(t,n),a);(t.update!==void 0||t.updateIndex!==void 0||t.setJson!==void 0||n.addValues.length>0||n.addJsonValues.length>0||n.removeValues.length>0||t.run===!0||n.removeIndexValues.length>0)&&await h(a,o),l(o,a),(o.run_results.some(r=>r.status==="failed"||r.status==="refused")||o.fail_on_skipped_triggered===!0)&&(process.exitCode=u.DEPENDENCY_FAILED)}async function Ie(e,t,a){let n=c(a),o=Date.now(),r=Se(t);t.background===!0&&ne(e,_(t,r),n,x(process.cwd(),n.path),!0),fe(t,r),t.background===!0?await Be(e,t,n,r):await Re(e,t,n,r),n.profile&&d(`profile:command=test took_ms=${Date.now()-o}`)}function w(e){let t=i(e,"author"),a=i(e,"assignee");if(t!==void 0&&a!==void 0&&t!==a)throw new p("Lifecycle ownership received conflicting --author and --assignee values; use one actor value for both aliases.",u.USAGE,{code:"conflicting_lifecycle_owner",examples:["pm claim pm-123","pm claim pm-123 --start","pm release pm-123"]});return{author:t??a,message:i(e,"message")}}async function Ee(e,t){let a=c(t),n=Date.now();if(e.background===!0){let s=await B({kind:"test-all",commandArgs:T(e),statusFilter:i(e,"status"),noExtensions:a.noExtensions===!0},a);l(s,a),a.profile&&d(`profile:command=test-all took_ms=${Date.now()-n}`);return}let r=await re(pe(e),a);await h(a,{ids:r.results.map(s=>s.id)}),l(r,a),(r.failed>0||r.fail_on_skipped_triggered===!0)&&(process.exitCode=u.DEPENDENCY_FAILED),a.profile&&d(`profile:command=test-all took_ms=${Date.now()-n}`)}function pe(e){return{status:i(e,"status"),limit:i(e,"limit"),offset:i(e,"offset"),timeout:i(e,"timeout"),progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:i(e,"pmContext"),overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:i(e,"workspaceContext"),overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,fullOutput:!!e.fullOutput,autoPmContext:!!e.autoPmContext}}async function Oe(e,t,a,n){let o=c(n),r=Date.now(),s=await ae({subcommand:Ce(e,t),limit:i(a,"limit")},o);l(s,o),o.profile&&d(`profile:command=telemetry took_ms=${Date.now()-r}`)}async function De(e,t){let a=c(t),n=Date.now(),o=ce(i(e,"analytics")),r=await te(a,{includeEmpty:e.includeEmpty===!0,storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:i(e,"tagPrefix"),fieldUtilization:e.fieldUtilization===!0,...o});r.recorded_observations?.some(s=>s.changed)===!0&&await h(a,{ids:r.recorded_observations?.flatMap(s=>s.observation.item_id?[s.observation.item_id]:[])}),l(r,a),a.profile&&d(`profile:command=stats took_ms=${Date.now()-n}`)}async function Te(e,t){let a=c(t),n=Date.now(),o=i(e,"threshold"),r=i(e,"limit"),s=await M(a,{...e.exhaustive===!0?{exhaustive:!0}:{},status:Array.isArray(e.status)&&e.status.length>0?e.status:void 0,since:i(e,"since"),...o===void 0?{}:{threshold:Number(o)},...r===void 0?{}:{limit:Number(r)}});l(s,a),a.profile&&d(`profile:command=duplicates took_ms=${Date.now()-n}`)}async function Le(e,t){let a=c(t),n=Date.now(),o=!!e.strictExit||!!e.failOnWarn,r=await F(a,{strictExit:o,strictDirectories:!!e.strictDirectories,requireMergeDrivers:!!e.requireMergeDrivers,checkOnly:!!e.checkOnly,checkTelemetry:!!e.checkTelemetry,noRefresh:!!e.noRefresh,refreshVectors:!!e.refreshVectors,verboseStaleItems:!!e.verboseStaleItems,verboseAuthorEvents:!!e.verboseAuthorEvents,brief:!!e.brief,summary:!!e.summary||o&&e.full!==!0,skipVectors:!!e.skipVectors,skipIntegrity:!!e.skipIntegrity,skipDrift:!!e.skipDrift,full:!!e.full});l(r,a),o&&!r.ok&&(A({...r,exit_code:u.GENERIC_FAILURE,error_code:"health_findings",error_category:"validation",command_resolution:"health_findings",resolution_stage:"execute"}),process.exitCode=u.GENERIC_FAILURE),a.profile&&d(`profile:command=health took_ms=${Date.now()-n}`)}async function Pe(e,t){let a=c(t),n=Date.now(),o=await de({checkMetadata:!!e.checkMetadata,metadataProfile:i(e,"metadataProfile"),checkResolution:!!e.checkResolution,checkCompleteness:!!e.checkCompleteness,checkLifecycle:!!e.checkLifecycle,checkStaleBlockers:!!e.checkStaleBlockers,dependencyCycleSeverity:i(e,"dependencyCycleSeverity"),parentCycleSeverity:i(e,"parentCycleSeverity"),checkFiles:!!e.checkFiles,checkCommandReferences:!!e.checkCommandReferences,scanMode:i(e,"scanMode"),includePmInternals:!!e.includePmInternals,verboseFileLists:!!e.verboseFileLists,verboseDiagnostics:!!e.verboseDiagnostics,allAffectedIds:!!e.allAffectedIds,checkHistoryDrift:!!e.checkHistoryDrift,checkStorageIntegrity:!!e.checkStorageIntegrity,fixHints:!!e.fixHints,autoFix:!!e.autoFix,dryRun:!!e.dryRun,fixScope:Array.isArray(e.fixScope)?e.fixScope:void 0,pruneMissing:!!e.pruneMissing,counts:!!e.counts,full:!!e.full},a);l(o,a),(e.strictExit||e.failOnWarn)&&(o.has_warnings||!o.ok)&&(A({...o,exit_code:u.GENERIC_FAILURE,error_code:"validation_findings",error_category:"validation",command_resolution:"validation_findings",resolution_stage:"execute"}),process.exitCode=u.GENERIC_FAILURE),a.profile&&d(`profile:command=validate took_ms=${Date.now()-n}`)}async function Me(e,t){let a=c(t),n=Date.now(),o=await q(a,{dryRun:e.dryRun===!0,scope:Array.isArray(e.scope)?e.scope:[]});l(o,a),a.profile&&d(`profile:command=gc took_ms=${Date.now()-n}`)}async function Fe(e,t,a,n){let o=c(n),r=x(process.cwd(),o.path),s=e.trim().toLowerCase();if(!S.some(m=>m===s))throw b({command_path:"workspace snapshot",token:e,allowed:S,display_name:"workspace snapshot",token_kind:"action",examples:["pm workspace snapshot create before-migration","pm workspace snapshot restore before-migration"]});if(s==="list"){l(await K(r),o);return}if(s==="create"){l(await z(r,t===void 0?{}:{name:t}),o);return}if(t===void 0)throw new p(`pm workspace snapshot ${s} requires a snapshot name or fingerprint`,u.USAGE);if(s==="inspect"){l(await Y(r,t),o);return}if(s==="restore"){if(a.dryRun===!0){l(await X(r,t),o);return}let m=await C(r);l(await Q(r,t,{force:a.force===!0,author:O(i(a,"author"),m.author_default),message:i(a,"message"),lockTtlSeconds:m.locks.ttl_seconds,lockWaitMs:m.locks.wait_ms}),o);return}l(await Z(r,t),o)}async function he(e,t){let a=c(t);l(await ee(a),a)}async function Ve(e,t){let a=c(t),n=Date.now(),o=await P({action:i(e,"action"),command:i(e,"command"),summary:!!e.summary,schemaOnly:!!e.schemaOnly,flagsOnly:!!e.flagsOnly,availabilityOnly:!!e.availabilityOnly,runtimeOnly:!!e.runtimeOnly||!!e.activeOnly,full:!!e.full},a);l(o,a),a.profile&&d(`profile:command=contracts took_ms=${Date.now()-n}`)}async function Ne(e,t,a){let n=t.next===!0,o=t.start===!0;if(o&&e){await ye(e,t,a);return}U(e,n,o);let r=c(a),s=Date.now(),m={...w(t),ifAvailable:t.ifAvailable===!0,...t.takeoverStale===!0?{takeoverStale:!0}:{},maxAttempts:t.maxAttempts,...o?{start:!0}:{}},g=n?await $(!!t.force,r,m,qe(t)):await J(e,!!t.force,r,m);await h(r,g),l(g,r),r.profile&&d(`profile:command=claim took_ms=${Date.now()-s}`)}function qe(e){return{type:i(e,"type"),tag:i(e,"tag"),priority:e.priority,assigneeFilter:i(e,"assigneeFilter"),parent:i(e,"parent"),sprint:i(e,"sprint"),release:i(e,"release"),includeDecisions:e.includeDecisions===!0,includeGates:e.includeGates===!0,includeContainers:e.includeContainers===!0,tokenBudget:e.tokenBudget??e.token_budget,explainRanking:e.explainRanking===!0||e.explain_ranking===!0}}async function Je(e,t,a){if(t.pause===!0){await ge(e,t,a);return}let n=c(a),o=Date.now(),r=await H(e,!!t.force,n,{...w(t),ownershipReleaseBypass:t.ownershipReleaseBypass===!0,handoff:t.handoff});await h(n,r),l(await L("release",[e],t,n,r),n),n.profile&&d(`profile:command=release took_ms=${Date.now()-o}`)}async function R(e){let t=c(e),a=I(e.name());if(!a||t.json||t.quiet)return;(await C(x(process.cwd(),t.path))).ux?.deprecation_hints&&d(E(a))}async function ye(e,t,a){await R(a);let n=c(a),o=Date.now(),r=await W(e,{...w(t),force:!!t.force,next:t.next===!0,ifAvailable:t.ifAvailable===!0,...t.takeoverStale===!0?{takeoverStale:!0}:{}},n);await h(n,r.update),l(r,n),n.profile&&d(`profile:command=start-task took_ms=${Date.now()-o}`)}async function ge(e,t,a){await R(a);let n=c(a),o=Date.now(),r=await j(e,{...w(t),handoff:i(t,"handoff"),force:!!t.force},n);await h(n,r.release),l(r,n),n.profile&&d(`profile:command=pause-task took_ms=${Date.now()-o}`)}async function Ue(e,t,a,n){await R(n);let o=c(n),r=Date.now(),s=await G(e,t,{...w(a),validateClose:i(a,"validateClose"),force:!!a.force},o);await h(o,s.release),l(s,o),o.profile&&d(`profile:command=close-task took_ms=${Date.now()-r}`)}function me(e){return e.option("--background","Run linked tests in managed background mode").option("--timeout <seconds>","Default run timeout in seconds (requires --run)").option("--progress","Emit stderr run progress (requires --run; automatic in TTY)").option("--env-set <value>","Set run environment (KEY=VALUE, repeatable)",f).option("--env-clear <value>","Clear run environment (NAME, repeatable)",f).option("--shared-host-safe","Apply additive shared-host-safe run defaults").option("--pm-context <mode>","PM test context: schema|tracker|auto|none (default: schema)").option("--override-linked-pm-context","Override stored context with --pm-context").option("--workspace-context <mode>","Source-workspace mode: source|isolated|snapshot (default: source)").option("--override-linked-workspace-context","Override stored context with --workspace-context").option("--allow-untrusted-linked-tests","Execute untrusted linked commands when project policy also permits it").option("--fail-on-context-mismatch","Fail linked PM commands when context item counts differ").option("--fail-on-skipped","Treat skipped linked tests as dependency failures").option("--fail-on-empty-test-run","Fail successful commands reporting zero executed tests").option("--require-assertions-for-pm","Require assertion metadata for linked PM command tests").option("--check-context","Check PM context before execution and report the full execution context").option("--full-output","Report full stdout/stderr of passing rows").option("--auto-pm-context","Route mismatched PM tracker reads through tracker context")}function qt(e){ue(e);let t=e.command("test").argument("<id>","Item id").option("--add <value>","Link isolated test; runs only with --run (CSV/markdown or stdin)",f).option("--add-json <value>","Link isolated test; runs only with --run (JSON object/array or stdin)",f).option("--remove <value>","Remove exact command/path (command=<value>, path=<value>, or stdin -)",f).option("--remove-index <n>","Remove 1-based --list position (repeatable)",f).option("--list","List linked tests without mutating").option("--update <value>","Edit exact command or path=<value>").option("--update-index <n>","Edit current 1-based --list position").option("--set-json <value>","Metadata patch; null clears optional fields").option("--run","Run linked test commands").option("--match <value>","Run matching command/path substring").option("--only-index <n>","Run 1-based --list position").option("--only-last","Run most recently added test").option("--full-history","Return all linked tests after a write");t.option("--acknowledge-linked-tests","Trust current commands in this clone without execution"),me(t).option("--measure <value>","Record name=value[,unit=...][,threshold=...]; requires --run",f).option("--metric-below <value>","Return evidence below name=value").option("--metric-diff <name>","Diff the latest two values").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Manage tests linked to an item and optionally run them.").action(Ie);let a=e.command("test-all").description("Run linked tests across matching items.").option("--status <value>","Filter items by status before running tests").option("--limit <n>","Limit matching items before running linked tests").option("--offset <n>","Skip matching items before running linked tests");me(a).action(Ee),e.command("test-runs-worker",{hidden:!0}).argument("<runId>","Background run id").description("Internal background worker command.").action(async(v,k,ke)=>{let we=c(ke);await ie(v,we)}),e.command("telemetry").argument("[namespace-or-subcommand]","Telemetry subcommand: status, flush, stats, clear (default: status)").argument("[subcommand]","Compatibility alias target for local-analytics: status, flush, stats, clear").option("--limit <n>","Maximum command groups returned by telemetry stats").description("Inspect and manage local telemetry queue/runtime state.").action(Oe),e.command("duplicates").description("Find duplicate clusters across all statuses.").option("--status <value>","Statuses (repeatable or comma-separated)",f,[]).option("--since <value>","Created at or after this time").option("--threshold <value>","Minimum similarity (0-1)").option("--limit <n>","Maximum clusters").option("--exhaustive","Score all pairs within the safety bound").action(Te),e.command("stats").description("Show project tracker statistics.").option("--include-empty","Restore zero-count registered item-type and lifecycle-status buckets").option("--storage","Include aggregate history-stream storage metrics (total streams/lines/bytes, largest + deepest streams, oldest/newest entries)").option("--metadata-coverage","Include metadata coverage % (acceptance_criteria, estimated_minutes, resolution, tags, parent) overall and by type").option("--by-assignee","Include a lifecycle-bucketed item breakdown grouped by assignee").option("--by-tag","Include a lifecycle-bucketed item breakdown grouped by tag").option("--by-priority","Include a lifecycle-bucketed item breakdown grouped by priority").option("--tag-prefix <value>","With --by-tag: only count tags starting with this prefix (e.g. domain:)").option("--field-utilization","Report content-field utilization rates (notes/learnings/files/docs/tests/comments/deps/body) for governance analysis").option("--analytics <json>","Improvement ledger/history analytics JSON").action(De),e.command("health").description("Show project tracker health checks.").option("--strict-directories","Treat optional item-type directories as required failures").option("--require-merge-drivers","Treat absent clone-local merge drivers as a required health failure").option("--check-only","Run read-only health diagnostics without refreshing vectors").option("--check-telemetry","Probe telemetry endpoint health and include network diagnostics").option("--no-refresh","Disable automatic vector refresh attempts during health checks").option("--refresh-vectors","Explicitly enable vector refresh attempts during health checks").option("--verbose-stale-items","Include full stale vectorization ID lists in health output").option("--verbose-author-events","Include every actionable unknown-author event coordinate for review or disposition").option("--brief","Emit compact health details for low-token agent checks").option("--summary","Emit one-line-style status and warning count, also with --full").option("--skip-vectors","Skip vectorization check for a faster run").option("--skip-integrity","Skip item/history file integrity check for a faster run").option("--skip-drift","Skip history drift hash check for a faster run").option("--full","Run every check (slow integrity, drift, vectors too); keeps --summary/--brief").option("--strict-exit","Return non-zero exit when health is not ok and default to actionable summary output; use --full for complete details").option("--fail-on-warn","Alias for --strict-exit").action(Le),e.command("validate").description("Validate metadata, lifecycle policies, files, command references, and history.").option("--check-metadata","Run metadata completeness checks").option("--metadata-profile <value>","Metadata profile (core|strict|custom)").option("--check-resolution","Run closed-item resolution metadata checks").option("--check-completeness","Check declarative lifecycle field requirements").option("--check-lifecycle","Run active-item lifecycle governance drift checks").option("--check-stale-blockers","Include stale blocker-pattern diagnostics in lifecycle checks").option("--dependency-cycle-severity <value>","Set dependency-cycle warning policy for lifecycle checks (off|warn|error)").option("--parent-cycle-severity <value>","Set parent-hierarchy cycle warning policy for lifecycle checks (off|warn|error)").option("--check-files","Run linked-file and orphaned-file checks").option("--check-command-references","Run linked-command PM-ID reference checks").option("--scan-mode <value>","Select file candidate scan mode for --check-files (default|tracked-all|tracked-all-strict)").option("--include-pm-internals","Include PM storage internals in tracked-all candidate scans").option("--verbose-file-lists","Include full file-path lists for validate --check-files details").option("--verbose-diagnostics","Include full diagnostic ID lists").option("--all-affected-ids","Emit complete missing_* affected-ID lists with no truncation (implied by --json)").option("--strict-exit","Return non-zero exit when validation warnings are present").option("--fail-on-warn","Alias for --strict-exit").option("--fix-hints","Add a machine-executable fix_hints[] of pm commands to each failing check's details").option("--auto-fix","Apply safe, deterministic field backfills").option("--dry-run","Preview planned --auto-fix/--prune-missing fixes without applying them").option("--fix-scope <scope>","Grant --auto-fix scopes (metadata, resolution, estimates, timestamps, lifecycle; comma-separated or repeatable). Default: metadata, resolution; other scopes require explicit opt-in",f).option("--prune-missing","Remove deleted-path file/doc links; preserves real files").option("--check-history-drift","Run item/history hash drift checks").option("--check-storage-integrity","Run the post-merge storage-integrity check (unreadable items, history conflict markers, resurrected deletes, unparseable config/schema)").option("--counts","Keep validation counts and totals while omitting per-item diagnostic arrays").option("--full","Return the complete validation diagnostic projection").action(Pe),e.command("gc").option("--dry-run","Preview cleanup targets without deleting files; without this flag, pm gc deletes matched artifacts").option("--scope <value>","Limit cleanup to one or more scopes (comma-separated or repeatable): index, embeddings, runtime, locks, checkpoints, transactions",f).description("Delete optional cache artifacts by default (including expired lock debris) and show a summary.").action(Me);let n=e.command("workspace").description("Inspect workspace state and snapshots.");n.command("position").description("Show merge and history readiness.").action(he),n.command("snapshot").argument("<action>","Action: create, list, inspect, restore, delete").argument("[target]","Optional name for create; name or fingerprint otherwise").description("Manage content-addressed tracker snapshots.").option("--dry-run","Preview restore file, item, stream, and history-entry impact without mutating state").option("--force","Explicitly confirm a whole-workspace snapshot restore").option("--author <value>","Actor recorded on the restore audit event").option("--message <value>","Human-readable restore rationale").action(Fe),e.command("contracts").description("Show machine-readable command and schema contracts for agents.").option("--action <value>","Filter tool schema branches to a specific action").option("--command <value>","Scope contracts output to one CLI command (narrow-by-default)").option("--summary","Return one command+intent row per top-level command for cheap agent bootstrap").option("--schema-only","Return schema-focused output only").option("--flags-only","Return command flag contracts only").option("--availability-only","Return action availability surface only").option("--runtime-only","Include only actions invocable in the current runtime").option("--active-only","Alias for --runtime-only").option("--full","Include full schema and command-flag surfaces (large; default brief output omits heavy sections for unfiltered queries)").action(Ve);let o=e.command("claim").option("--start","Claim and start (id or --next)").argument("[id]","Item id (omit with --next)").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force claim override").option("--if-available","Skip another author's claim (skipped=true)").option("--takeover-stale","Take over an idle claim (stale-work policy)").option("--next","Atomically claim the next caller-available actionable item").option("--type <value>","Filter --next candidates by type").option("--tag <value>","Filter --next candidates by tag").option("--priority <value>","Filter --next candidates by priority").option("--assignee-filter <value>","Filter --next candidates: assigned|unassigned").option("--parent <id>","Scope --next candidates to a subtree").option("--sprint <value>","Filter --next candidates by sprint").option("--release <value>","Filter --next candidates by release").option("--max-attempts <n>","Bound the --next candidate walk (default 10; maximum 100)").option("--include-decisions","Allow --next to claim human-gated Decision items").option("--include-gates","Allow --next to claim outcome gates").option("--include-containers","Allow --next to claim containers with unfinished descendants").option("--token-budget <n>","Bound the estimated tokens used to rank --next candidates").option("--explain-ranking","Include ranking provenance for --next selection").description("Claim an item for active work.").action(Ne);y(o,"--assignee <value>","Alias for --author on lifecycle ownership commands"),y(o,"--token_budget <n>","Alias for --token-budget"),y(o,"--explain_ranking","Alias for --explain-ranking");let r=e.command("release").option("--pause","Use open status").option("--handoff <status>","Needs --message").argument("<id>","Item id").option("--author <value>","Author").option("--message <value>","Message").option("--force","Override ownership").description("Release ownership.").action(Je);y(r,"--assignee <value>","Alias for --author on lifecycle ownership commands");let s=e.command("start-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership or terminal override when required").option("--takeover-stale","Take over an idle claim (stale-work policy)").description("Lifecycle alias: claim an item and move it to in_progress.").action(ye);y(s,"--assignee <value>","Alias for --author on lifecycle ownership commands");let m=e.command("pause-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override when required").description("Lifecycle alias: move an item to open and release its claim.").action(ge);y(m,"--assignee <value>","Alias for --author on lifecycle ownership commands");let g=e.command("close-task",{hidden:!0}).argument("<id>","Item id").argument("[reason]","Close reason text").option("--author <value>","Mutation author").option("--message <value>","History message").option("--validate-close <value>","Close-time validation mode: off|warn|strict").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: close an item and release assignment metadata.").action(Ue);y(g,"--assignee <value>","Alias for --author on lifecycle ownership commands")}export{Nt as _testOnlyRegisterOperations,qt as registerOperationCommands,U as requireClaimTarget};
|
|
2
|
+
//# sourceMappingURL=register-operations-LCHUHKRA.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-SLFRSZK6.js";import{a as N,b as z,c as q,d as K,e as $,f as B}from"./chunk-JQYPSABI.js";import{g as T,i as M}from"./chunk-TWRUA2NH.js";import{Ca as W,Ea as H,ha as j,ia as D,ka as F,na as P,xa as G}from"./chunk-T7RZPIOB.js";import"./chunk-CTM26LUE.js";import"./chunk-OFIYA3PI.js";import"./chunk-KHFUHGL3.js";import"./chunk-AA52P34H.js";import{pa as w,sa as x}from"./chunk-CDUV7DFD.js";import"./chunk-E2LQ6LCJ.js";import"./chunk-PZA7QECY.js";import{T as U}from"./chunk-CATRDGAB.js";import{t as L}from"./chunk-LMDIKSDZ.js";import"./chunk-YEMFOKFG.js";import{Pe as O,Ue as y,Ve as h}from"./chunk-56GUDMXN.js";import{p as I}from"./chunk-D3I5AHNN.js";import"./chunk-5ECCMDSU.js";import"./chunk-FG4TNQQM.js";import{o as C,p as A}from"./chunk-54AQJTUH.js";import"./chunk-WKDKBS4P.js";import{A as d,C as m}from"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";import S from"node:fs/promises";import V from"node:path";async function ae(t,e,o){let a=w(e),i=e.optsWithGlobals(),r=I(process.cwd(),a.path);o==="extension"&&await K(r)&&h(A(C("extension")));let c=a.json===!0||i.outputFormat!==void 0?a:{...a,defaultOutputFormat:await q(r)};if(i.global===!0&&(i.project===!0||i.local===!0))throw new m("--global and --project/--local are mutually exclusive.",d.USAGE);N(i),z({...c,outputFormat:i.outputFormat});let s=j(i.fields,$,"list"),n=await B({pmRoot:r,scope:i.global===!0?"global":"project",name:t});y(s===void 0?n:{...n,extensions:D(n.extensions,s)},c),n.complete||(process.exitCode=d.GENERIC_FAILURE)}var X={extension:"extension",package:void 0};async function _(t,e){if(!t)return;let o=C(t),a=w(e);await L(I(process.cwd(),a.path)).then(r=>r.ux.deprecation_hints)&&h(A(o))}var ie={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function ne(t){let e=t.capability,o=typeof e=="string"?[e]:Array.isArray(e)?e.filter(i=>typeof i=="string"):[],a=[...new Set(o.map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))];if(a.length>1)throw new m(`Multiple scaffold capabilities cannot be combined yet: ${a.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return a[0]}function R(t,e,o="extension"){let a={...t};e!==void 0&&(a[ie[e]]=!0);let i=(...c)=>c.some(s=>a[s]===!0),r=(...c)=>{for(let s of c)if(typeof a[s]=="string")return a[s]};return{init:i("init"),scaffold:i("scaffold"),install:i("install"),uninstall:i("uninstall"),explore:i("explore","list"),manage:i("manage"),describe:i("describe"),markdown:i("markdown"),reload:i("reload"),doctor:i("doctor"),catalog:i("catalog"),adopt:i("adopt"),adoptAll:i("adoptAll","adopt_all","adopt-all"),activate:i("activate"),deactivate:i("deactivate"),migrate:i("migrate"),project:i("project"),local:i("local"),global:i("global"),gh:r("gh"),github:r("github"),ref:r("ref"),capability:ne(t),declarative:i("declarative"),fields:r("fields"),detail:r("detail"),output:r("output"),trace:i("trace"),watch:i("watch"),runtimeProbe:i("runtimeProbe","runtime_probe","runtime-probe"),offline:i("offline"),fixManagedState:i("fixManagedState","fix_managed_state","fix-managed-state"),isolated:i("isolated"),ignoreGlobal:i("ignoreGlobal","ignore_global","ignore-global"),strictExit:i("strictExit","strict_exit","strict-exit"),failOnWarn:i("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:i("dryRun","dry_run","dry-run"),vocabulary:o}}async function re(t){let e=(await S.readdir(process.cwd())).filter(a=>!a.startsWith(".")).sort((a,i)=>a.localeCompare(i)),o=[...t].sort((a,i)=>a.localeCompare(i));return e.length===o.length&&e.every((a,i)=>a===o[i])}async function se(t){let e=(t??[]).map(o=>o.trim()).filter(o=>o.length>0);return e.length<=1?e.length===0?void 0:e:await re(e)?["*"]:e}function J(t,e,o){let a=t.markdown===!0;if(o!==void 0&&o==="")throw new m("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!a)throw new m("--output is only supported with --markdown describe output.",d.USAGE);if(a){if(e.json)throw new m("Cannot combine --json with --markdown.",d.USAGE);if(t.describe!==!0)throw new m("--markdown is only supported by the describe action.",d.USAGE)}}async function le(t){let e=P(t.result.details,t.vocabulary);if(t.outputPath!==void 0){let o=V.resolve(t.outputPath);await S.mkdir(V.dirname(o),{recursive:!0}),await S.writeFile(o,e,"utf8")}if(!t.globalOptions.quiet){for(let o of t.result.warnings)h(`warning: ${o}`);t.outputPath===void 0&&O(e)}}function ce(t,e){let o=!!e.strictExit||!!e.failOnWarn;if(t.action!=="doctor"||!o)return;let a=t.details!==null&&typeof t.details=="object"?t.details:{},i=a.summary!==null&&typeof a.summary=="object"?a.summary:null,r=i&&typeof i.status=="string"?i.status:void 0;(t.warnings.length>0||r!==void 0&&r!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function u(t,e,o,a,i="extension"){let r=w(o),c=Date.now(),s=i==="extension"?"package":i;await _(X[i],o);let n=R(e,a,s),f=(typeof n.output=="string"?n.output:void 0)?.trim();J(n,r,f);let g=await G(t,n,r);n.markdown===!0?await le({result:g,vocabulary:s,outputPath:f,globalOptions:r}):y(g,r),ce(g,n),g.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),r.profile&&h(`profile:command=extension took_ms=${Date.now()-c}`)}function de(t){return t.details!==null&&typeof t.details=="object"?t.details:{}}function pe(t){return t instanceof m?{message:t.message,exit_code:t.exitCode,...t.context}:{message:t instanceof Error?t.message:String(t),exit_code:d.GENERIC_FAILURE}}async function ue(t,e,o){let a=[],i=[],r=d.GENERIC_FAILURE;for(let c of t)try{let s=await G(c,e,o),n=de(s),l=Array.isArray(s.warnings)?s.warnings:[];i.push(...l);let f=s.ok===!0;a.push({target:c,ok:f,extension:n.extension,source:n.source,install_plan:n.install_plan,dry_run:n.dry_run,destination_path:n.destination_path,activated:n.activated,settings_changed:n.settings_changed,previous_state_preserved:n.previous_state_preserved,rollback:n.rollback,command_paths:n.command_paths,action_paths:n.action_paths,runtime_activation_status:n.runtime_activation_status,activation_diagnostics:n.activation_diagnostics,command_discovery:n.command_discovery,verification:n.verification,warnings:l,...f?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let n=pe(s),l=n.exit_code;typeof l=="number"&&r===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(r=l),a.push({target:c,ok:!1,error:n})}return{rows:a,warnings:i,failureExitCode:r}}async function Q(t,e,o,a){let i=a==="extension"?"package":a;await _(X[a],o);let r=await se(t);if(r===void 0||r.length<=1){await u(r?.[0],e,o,"install",i);return}let c=w(o),s=Date.now(),n=R(e,"install",i);if(J(n,c,void 0),[n.gh,n.github].some(b=>typeof b=="string"&&b.trim().length>0))throw new m("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm package install --gh owner/repo","pm package install npm:pm-guide-shell pm-todos"]});let{rows:f,warnings:g,failureExitCode:E}=await ue(r,n,c),k=f.filter(b=>b.ok!==!0).length,te={ok:k===0,action:"install",scope:n.global===!0?"global":"project",installed_count:n.dryRun===!0?0:f.length-k,...n.dryRun===!0?{dry_run:!0,planned_count:f.length-k}:{},failed_count:k,targets:f,warnings:[...new Set(g)].sort((b,oe)=>b.localeCompare(oe))};y(te,c),k>0&&(process.exitCode=E),c.profile&&h(`profile:command=extension took_ms=${Date.now()-s}`)}function fe(t){return t.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function v(t){return t.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function p(t,e){return e==="package"?v(t):fe(t)}function Z(t){return t.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function ee(t,e,o){let a=w(e),i=Date.now();o&&await _("upgrade",e);let r=await M(t,e.optsWithGlobals(),a);y(r,a),r.ok||(process.exitCode=d.GENERIC_FAILURE),a.profile&&h(`profile:command=package-upgrade took_ms=${Date.now()-i}`)}function Y(t,e){let o=e==="package"?"package":"extension",a=e==="package"?"packages":"extensions",i=e,r=t.command(i,{hidden:e==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",x).option("--install",`Install a ${o} source`).option("--dry-run","Preview install without writes or activation").option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${a} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${a} and updates`).option("--offline","Skip remote freshness checks during manage").option("--describe",`Show surfaces registered by a loaded ${o}`).option("--markdown","Render describe as Markdown").option("--output <path>","Write Markdown to a file").option("--reload",`Reload ${a} without import cache`).option("--watch","Use watch mode with --reload").option("--doctor",`Run ${o} diagnostics`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt unmanaged ${o}`).option("--adopt-all",`Adopt all unmanaged ${a}`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(e==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,void 0,e)});e==="package"&&(r.alias("packages"),r.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=r.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${F.join("|")}; default commands)`,x).description(e==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");e==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),p(c,e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"init",e)}),p(r.command("install").option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),e).action(async(s,n,l)=>{await Q(s,l.optsWithGlobals(),l,e)}),p(r.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"uninstall",e)}),p(r.command("explore").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,activation_status").description(`List discovered ${a} in selected scope.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"explore",e)}),p(r.command("inventory").alias("list").argument("[name]",`${o[0].toUpperCase()}${o.slice(1)} name or directory to inspect`).option("--fields <value>",`Render compact comma-separated row fields, for example: ${$.slice(0,3).join(",")},update`).description(`List installed ${a} in the selected scope, with the last observed update, without activating extension code.`),e).action(async(s,n,l)=>{await ae(s,l,e)}),p(r.command("manage").option("--offline","Skip remote freshness checks and report unknown update availability").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,update_available,last_update_remote_version").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).description(`List managed ${a} with update-check metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"manage",e)}),p(r.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"describe",e)}),p(r.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${a} with cache-busted module imports.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"reload",e)}),p(r.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"doctor",e)}),p(r.command("catalog").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"catalog",e)}),p(r.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"adopt",e)}),p(r.command("adopt-all").description(`Adopt all unmanaged ${a} into managed metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"adopt-all",e)}),p(r.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"migrate",e)}),p(r.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"activate",e)}),p(r.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"deactivate",e)}),e==="package"&&Z(v(r.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,n,l)=>{await ee(s,l,!1)})}async function ge(t,e,o){let a=w(o),i=Date.now(),r=await H(t,a,{idPrefix:typeof e.idPrefix=="string"?e.idPrefix:void 0,preset:typeof e.preset=="string"?e.preset:void 0,defaults:e.defaults===!0||e.yes===!0,author:typeof e.author=="string"?e.author:void 0,agentGuidance:typeof e.agentGuidance=="string"?e.agentGuidance:void 0,typePreset:typeof e.typePreset=="string"?e.typePreset:void 0,withPackages:e.withPackages===!0,mergeFence:e.mergeFence!==!1,force:e.force===!0,workspace:typeof e.workspace=="string"?e.workspace:void 0}),s=e.verbose===!0||a.json===!0;y(s?r:W(r,!0),a),a.profile&&h(`profile:command=init took_ms=${Date.now()-i}`)}function me(t,e,o,a){let r=t!==void 0&&new Set(["get","set","list","export"]).has(t);return{resolvedScope:r?U(e):t??"project",resolvedAction:r?t:e??"list",resolvedKey:r?e:o,resolvedValue:r?o:a}}function he(t){return{criterion:Array.isArray(t.criterion)?t.criterion:[],format:typeof t.format=="string"?t.format:void 0,policy:typeof t.policy=="string"?t.policy:void 0,value:typeof t.value=="string"?t.value:void 0,clearCriteria:t.clearCriteria===!0,defaultDepth:typeof t.defaultDepth=="string"?t.defaultDepth:void 0,activityLimit:typeof t.activityLimit=="string"?t.activityLimit:void 0,staleThresholdDays:typeof t.staleThresholdDays=="string"?t.staleThresholdDays:void 0,sectionHierarchy:typeof t.sectionHierarchy=="string"?t.sectionHierarchy:void 0,sectionActivity:typeof t.sectionActivity=="string"?t.sectionActivity:void 0,sectionProgress:typeof t.sectionProgress=="string"?t.sectionProgress:void 0,sectionBlockers:typeof t.sectionBlockers=="string"?t.sectionBlockers:void 0,sectionFiles:typeof t.sectionFiles=="string"?t.sectionFiles:void 0,sectionWorkload:typeof t.sectionWorkload=="string"?t.sectionWorkload:void 0,sectionStaleness:typeof t.sectionStaleness=="string"?t.sectionStaleness:void 0,sectionTests:typeof t.sectionTests=="string"?t.sectionTests:void 0}}async function we(t,e,o,a,i,r){let c=w(r),s=Date.now(),{resolvedScope:n,resolvedAction:l,resolvedKey:f,resolvedValue:g}=me(t,e,o,a),E=await T(n,l,f,he(i),c,typeof g=="string"?g:void 0);y(E,c),c.profile&&h(`profile:command=config took_ms=${Date.now()-s}`)}var Me={normalizeExtensionOptions:R};function Ne(t){t.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(e,o,a)=>{await ge(e,o,a)}),t.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]","Value for set, validated by key. Dotted leaves accept values (e.g. context.default_depth deep); the context group takes --default-depth/--section-* flags.").option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",x).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep|full").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(e,o,a,i,r,c)=>{await we(e,o,a,i,r,c)}),Y(t,"extension"),Y(t,"package"),v(t.command("install",{hidden:!0}).option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(e,o,a)=>{await _("install",a),await Q(e,a.optsWithGlobals(),a,"package")}),Z(v(t.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(e,o,a)=>{await ee(e,a,!0)})}export{Me as _testOnlyRegisterSetup,Ne as registerSetupCommands};
|
|
2
|
-
//# sourceMappingURL=register-setup-
|
|
1
|
+
import"./chunk-SLFRSZK6.js";import{a as N,b as z,c as q,d as K,e as $,f as B}from"./chunk-ZSBPE36C.js";import{g as T,i as M}from"./chunk-CV2B4JUB.js";import{Ca as W,Ea as H,ha as j,ia as D,ka as F,na as P,xa as G}from"./chunk-JFPCL45G.js";import"./chunk-JQHLOSSS.js";import"./chunk-3TK2YOVB.js";import"./chunk-OGVSGXQX.js";import"./chunk-AA52P34H.js";import{pa as w,sa as x}from"./chunk-R6M5OGJH.js";import"./chunk-WLZ5KVM2.js";import"./chunk-PZA7QECY.js";import{T as U}from"./chunk-PY6A7ULK.js";import{u as L}from"./chunk-3E53F7QY.js";import"./chunk-3AZOATC2.js";import{Pe as O,Ue as y,Ve as h}from"./chunk-RWHS77ME.js";import{o as I}from"./chunk-GSLOAEY2.js";import"./chunk-CNZOC6JD.js";import"./chunk-NRCGGNOE.js";import{o as C,p as A}from"./chunk-JV7LREUF.js";import"./chunk-TE6FBDHP.js";import{A as d,C as m}from"./chunk-K672XXGQ.js";import"./chunk-XAWE4EAK.js";import S from"node:fs/promises";import V from"node:path";async function ae(t,e,o){let a=w(e),i=e.optsWithGlobals(),r=I(process.cwd(),a.path);o==="extension"&&await K(r)&&h(A(C("extension")));let c=a.json===!0||i.outputFormat!==void 0?a:{...a,defaultOutputFormat:await q(r)};if(i.global===!0&&(i.project===!0||i.local===!0))throw new m("--global and --project/--local are mutually exclusive.",d.USAGE);N(i),z({...c,outputFormat:i.outputFormat});let s=j(i.fields,$,"list"),n=await B({pmRoot:r,scope:i.global===!0?"global":"project",name:t});y(s===void 0?n:{...n,extensions:D(n.extensions,s)},c),n.complete||(process.exitCode=d.GENERIC_FAILURE)}var X={extension:"extension",package:void 0};async function _(t,e){if(!t)return;let o=C(t),a=w(e);await L(I(process.cwd(),a.path)).then(r=>r.ux.deprecation_hints)&&h(A(o))}var ie={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function ne(t){let e=t.capability,o=typeof e=="string"?[e]:Array.isArray(e)?e.filter(i=>typeof i=="string"):[],a=[...new Set(o.map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))];if(a.length>1)throw new m(`Multiple scaffold capabilities cannot be combined yet: ${a.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return a[0]}function R(t,e,o="extension"){let a={...t};e!==void 0&&(a[ie[e]]=!0);let i=(...c)=>c.some(s=>a[s]===!0),r=(...c)=>{for(let s of c)if(typeof a[s]=="string")return a[s]};return{init:i("init"),scaffold:i("scaffold"),install:i("install"),uninstall:i("uninstall"),explore:i("explore","list"),manage:i("manage"),describe:i("describe"),markdown:i("markdown"),reload:i("reload"),doctor:i("doctor"),catalog:i("catalog"),adopt:i("adopt"),adoptAll:i("adoptAll","adopt_all","adopt-all"),activate:i("activate"),deactivate:i("deactivate"),migrate:i("migrate"),project:i("project"),local:i("local"),global:i("global"),gh:r("gh"),github:r("github"),ref:r("ref"),capability:ne(t),declarative:i("declarative"),fields:r("fields"),detail:r("detail"),output:r("output"),trace:i("trace"),watch:i("watch"),runtimeProbe:i("runtimeProbe","runtime_probe","runtime-probe"),offline:i("offline"),fixManagedState:i("fixManagedState","fix_managed_state","fix-managed-state"),isolated:i("isolated"),ignoreGlobal:i("ignoreGlobal","ignore_global","ignore-global"),strictExit:i("strictExit","strict_exit","strict-exit"),failOnWarn:i("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:i("dryRun","dry_run","dry-run"),vocabulary:o}}async function re(t){let e=(await S.readdir(process.cwd())).filter(a=>!a.startsWith(".")).sort((a,i)=>a.localeCompare(i)),o=[...t].sort((a,i)=>a.localeCompare(i));return e.length===o.length&&e.every((a,i)=>a===o[i])}async function se(t){let e=(t??[]).map(o=>o.trim()).filter(o=>o.length>0);return e.length<=1?e.length===0?void 0:e:await re(e)?["*"]:e}function J(t,e,o){let a=t.markdown===!0;if(o!==void 0&&o==="")throw new m("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!a)throw new m("--output is only supported with --markdown describe output.",d.USAGE);if(a){if(e.json)throw new m("Cannot combine --json with --markdown.",d.USAGE);if(t.describe!==!0)throw new m("--markdown is only supported by the describe action.",d.USAGE)}}async function le(t){let e=P(t.result.details,t.vocabulary);if(t.outputPath!==void 0){let o=V.resolve(t.outputPath);await S.mkdir(V.dirname(o),{recursive:!0}),await S.writeFile(o,e,"utf8")}if(!t.globalOptions.quiet){for(let o of t.result.warnings)h(`warning: ${o}`);t.outputPath===void 0&&O(e)}}function ce(t,e){let o=!!e.strictExit||!!e.failOnWarn;if(t.action!=="doctor"||!o)return;let a=t.details!==null&&typeof t.details=="object"?t.details:{},i=a.summary!==null&&typeof a.summary=="object"?a.summary:null,r=i&&typeof i.status=="string"?i.status:void 0;(t.warnings.length>0||r!==void 0&&r!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function u(t,e,o,a,i="extension"){let r=w(o),c=Date.now(),s=i==="extension"?"package":i;await _(X[i],o);let n=R(e,a,s),f=(typeof n.output=="string"?n.output:void 0)?.trim();J(n,r,f);let g=await G(t,n,r);n.markdown===!0?await le({result:g,vocabulary:s,outputPath:f,globalOptions:r}):y(g,r),ce(g,n),g.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),r.profile&&h(`profile:command=extension took_ms=${Date.now()-c}`)}function de(t){return t.details!==null&&typeof t.details=="object"?t.details:{}}function pe(t){return t instanceof m?{message:t.message,exit_code:t.exitCode,...t.context}:{message:t instanceof Error?t.message:String(t),exit_code:d.GENERIC_FAILURE}}async function ue(t,e,o){let a=[],i=[],r=d.GENERIC_FAILURE;for(let c of t)try{let s=await G(c,e,o),n=de(s),l=Array.isArray(s.warnings)?s.warnings:[];i.push(...l);let f=s.ok===!0;a.push({target:c,ok:f,extension:n.extension,source:n.source,install_plan:n.install_plan,dry_run:n.dry_run,destination_path:n.destination_path,activated:n.activated,settings_changed:n.settings_changed,previous_state_preserved:n.previous_state_preserved,rollback:n.rollback,command_paths:n.command_paths,action_paths:n.action_paths,runtime_activation_status:n.runtime_activation_status,activation_diagnostics:n.activation_diagnostics,command_discovery:n.command_discovery,verification:n.verification,warnings:l,...f?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let n=pe(s),l=n.exit_code;typeof l=="number"&&r===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(r=l),a.push({target:c,ok:!1,error:n})}return{rows:a,warnings:i,failureExitCode:r}}async function Q(t,e,o,a){let i=a==="extension"?"package":a;await _(X[a],o);let r=await se(t);if(r===void 0||r.length<=1){await u(r?.[0],e,o,"install",i);return}let c=w(o),s=Date.now(),n=R(e,"install",i);if(J(n,c,void 0),[n.gh,n.github].some(b=>typeof b=="string"&&b.trim().length>0))throw new m("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm package install --gh owner/repo","pm package install npm:pm-guide-shell pm-todos"]});let{rows:f,warnings:g,failureExitCode:E}=await ue(r,n,c),k=f.filter(b=>b.ok!==!0).length,te={ok:k===0,action:"install",scope:n.global===!0?"global":"project",installed_count:n.dryRun===!0?0:f.length-k,...n.dryRun===!0?{dry_run:!0,planned_count:f.length-k}:{},failed_count:k,targets:f,warnings:[...new Set(g)].sort((b,oe)=>b.localeCompare(oe))};y(te,c),k>0&&(process.exitCode=E),c.profile&&h(`profile:command=extension took_ms=${Date.now()-s}`)}function fe(t){return t.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function v(t){return t.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function p(t,e){return e==="package"?v(t):fe(t)}function Z(t){return t.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function ee(t,e,o){let a=w(e),i=Date.now();o&&await _("upgrade",e);let r=await M(t,e.optsWithGlobals(),a);y(r,a),r.ok||(process.exitCode=d.GENERIC_FAILURE),a.profile&&h(`profile:command=package-upgrade took_ms=${Date.now()-i}`)}function Y(t,e){let o=e==="package"?"package":"extension",a=e==="package"?"packages":"extensions",i=e,r=t.command(i,{hidden:e==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",x).option("--install",`Install a ${o} source`).option("--dry-run","Preview install without writes or activation").option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${a} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${a} and updates`).option("--offline","Skip remote freshness checks during manage").option("--describe",`Show surfaces registered by a loaded ${o}`).option("--markdown","Render describe as Markdown").option("--output <path>","Write Markdown to a file").option("--reload",`Reload ${a} without import cache`).option("--watch","Use watch mode with --reload").option("--doctor",`Run ${o} diagnostics`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt unmanaged ${o}`).option("--adopt-all",`Adopt all unmanaged ${a}`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(e==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,void 0,e)});e==="package"&&(r.alias("packages"),r.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=r.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${F.join("|")}; default commands)`,x).description(e==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");e==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),p(c,e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"init",e)}),p(r.command("install").option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),e).action(async(s,n,l)=>{await Q(s,l.optsWithGlobals(),l,e)}),p(r.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"uninstall",e)}),p(r.command("explore").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,activation_status").description(`List discovered ${a} in selected scope.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"explore",e)}),p(r.command("inventory").alias("list").argument("[name]",`${o[0].toUpperCase()}${o.slice(1)} name or directory to inspect`).option("--fields <value>",`Render compact comma-separated row fields, for example: ${$.slice(0,3).join(",")},update`).description(`List installed ${a} in the selected scope, with the last observed update, without activating extension code.`),e).action(async(s,n,l)=>{await ae(s,l,e)}),p(r.command("manage").option("--offline","Skip remote freshness checks and report unknown update availability").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,update_available,last_update_remote_version").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).description(`List managed ${a} with update-check metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"manage",e)}),p(r.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"describe",e)}),p(r.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${a} with cache-busted module imports.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"reload",e)}),p(r.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"doctor",e)}),p(r.command("catalog").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"catalog",e)}),p(r.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"adopt",e)}),p(r.command("adopt-all").description(`Adopt all unmanaged ${a} into managed metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"adopt-all",e)}),p(r.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"migrate",e)}),p(r.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"activate",e)}),p(r.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"deactivate",e)}),e==="package"&&Z(v(r.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,n,l)=>{await ee(s,l,!1)})}async function ge(t,e,o){let a=w(o),i=Date.now(),r=await H(t,a,{idPrefix:typeof e.idPrefix=="string"?e.idPrefix:void 0,preset:typeof e.preset=="string"?e.preset:void 0,defaults:e.defaults===!0||e.yes===!0,author:typeof e.author=="string"?e.author:void 0,agentGuidance:typeof e.agentGuidance=="string"?e.agentGuidance:void 0,typePreset:typeof e.typePreset=="string"?e.typePreset:void 0,withPackages:e.withPackages===!0,mergeFence:e.mergeFence!==!1,force:e.force===!0,workspace:typeof e.workspace=="string"?e.workspace:void 0}),s=e.verbose===!0||a.json===!0;y(s?r:W(r,!0),a),a.profile&&h(`profile:command=init took_ms=${Date.now()-i}`)}function me(t,e,o,a){let r=t!==void 0&&new Set(["get","set","list","export"]).has(t);return{resolvedScope:r?U(e):t??"project",resolvedAction:r?t:e??"list",resolvedKey:r?e:o,resolvedValue:r?o:a}}function he(t){return{criterion:Array.isArray(t.criterion)?t.criterion:[],format:typeof t.format=="string"?t.format:void 0,policy:typeof t.policy=="string"?t.policy:void 0,value:typeof t.value=="string"?t.value:void 0,clearCriteria:t.clearCriteria===!0,defaultDepth:typeof t.defaultDepth=="string"?t.defaultDepth:void 0,activityLimit:typeof t.activityLimit=="string"?t.activityLimit:void 0,staleThresholdDays:typeof t.staleThresholdDays=="string"?t.staleThresholdDays:void 0,sectionHierarchy:typeof t.sectionHierarchy=="string"?t.sectionHierarchy:void 0,sectionActivity:typeof t.sectionActivity=="string"?t.sectionActivity:void 0,sectionProgress:typeof t.sectionProgress=="string"?t.sectionProgress:void 0,sectionBlockers:typeof t.sectionBlockers=="string"?t.sectionBlockers:void 0,sectionFiles:typeof t.sectionFiles=="string"?t.sectionFiles:void 0,sectionWorkload:typeof t.sectionWorkload=="string"?t.sectionWorkload:void 0,sectionStaleness:typeof t.sectionStaleness=="string"?t.sectionStaleness:void 0,sectionTests:typeof t.sectionTests=="string"?t.sectionTests:void 0}}async function we(t,e,o,a,i,r){let c=w(r),s=Date.now(),{resolvedScope:n,resolvedAction:l,resolvedKey:f,resolvedValue:g}=me(t,e,o,a),E=await T(n,l,f,he(i),c,typeof g=="string"?g:void 0);y(E,c),c.profile&&h(`profile:command=config took_ms=${Date.now()-s}`)}var Me={normalizeExtensionOptions:R};function Ne(t){t.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(e,o,a)=>{await ge(e,o,a)}),t.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]","Value for set, validated by key. Dotted leaves accept values (e.g. context.default_depth deep); the context group takes --default-depth/--section-* flags.").option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",x).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep|full").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(e,o,a,i,r,c)=>{await we(e,o,a,i,r,c)}),Y(t,"extension"),Y(t,"package"),v(t.command("install",{hidden:!0}).option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(e,o,a)=>{await _("install",a),await Q(e,a.optsWithGlobals(),a,"package")}),Z(v(t.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(e,o,a)=>{await ee(e,a,!0)})}export{Me as _testOnlyRegisterSetup,Ne as registerSetupCommands};
|
|
2
|
+
//# sourceMappingURL=register-setup-IJ7M3VUK.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{$ as m,P as a,Q as b,R as c,S as d,T as e,U as f,V as g,W as h,X as i,Y as j,Z as k,_ as l,aa as n,ba as o,ca as p,da as q,ea as r,fa as s}from"./chunk-TE6FBDHP.js";import"./chunk-K672XXGQ.js";import"./chunk-XAWE4EAK.js";export{a as DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,c as DEFAULT_RUNTIME_STATUS_DEFINITIONS,b as DEFAULT_RUNTIME_WORKFLOW,m as ensureRuntimeSchemaFileScaffold,k as filePathForSchemaSection,f as inspectRuntimeFieldDefinition,e as inspectRuntimeStatusDefinition,n as loadRuntimeSchemaFromOptionalFiles,d as normalizeCliToken,g as normalizeRuntimeSchemaSettings,p as normalizeStatusInputWithRegistry,j as readFieldsFromSchemaFile,i as readStatusesFromSchemaFile,h as readTypeDefinitionsFromSchemaFile,l as resolveItemTypesFilePath,q as resolveRuntimeFieldRegistry,o as resolveRuntimeStatusRegistry,r as runtimeFieldOptionTarget,s as statusIsTerminal};
|
|
2
|
+
//# sourceMappingURL=runtime-schema-OAIUNQRL.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{b as l}from"./chunk-6H36ZHMI.js";import{c as p}from"./chunk-AA52P34H.js";import{A as a,C as m,G as s,
|
|
1
|
+
import{b as l}from"./chunk-6H36ZHMI.js";import{c as p}from"./chunk-AA52P34H.js";import{A as a,C as m,G as s,L as c}from"./chunk-K672XXGQ.js";import"./chunk-XAWE4EAK.js";import{execFile as f}from"node:child_process";import{chmod as h,lstat as u}from"node:fs/promises";import{promisify as w}from"node:util";var x=w(f),g=`#!/bin/sh
|
|
2
2
|
# pm-cli:lossless-merge-settlement:v1
|
|
3
3
|
`;async function A(e,d){let r=(await x("git",["rev-parse","--path-format=absolute","--git-path","hooks/pre-commit"],{cwd:e,env:p(),timeout:1e4})).stdout.trim(),t,o=!1;try{t=await l(r,65536)??"",o=process.platform==="win32"||((await u(r)).mode&73)!==0}catch(n){if(!s(n))throw n}if(t!==void 0&&!t.startsWith(g))throw new m("The pre-commit hook already exists and is not owned by pm; it was preserved.",a.CONFLICT,{code:"merge_settlement_hook_conflict",recovery:{suggested_retry:"pm merge install --dry-run"},nextSteps:["Integrate pm merge reconcile --stage into your existing hook after reviewing its policy, or keep manual settlement. pm never replaces an existing unowned hook."]});let i=`${g}merge_head=$(git rev-parse --git-path MERGE_HEAD) || exit 1
|
|
4
4
|
[ -f "$merge_head" ] || exit 0
|
|
5
5
|
exec ${d} merge reconcile --stage
|
|
6
6
|
`;return{path:r,changed:t!==i||!o,content:i}}async function C(e){e.changed&&(await c(e.path,e.content),await h(e.path,493))}export{A as prepareMergeSettlementHook,C as writeMergeSettlementHook};
|
|
7
|
-
//# sourceMappingURL=settlement-hook-
|
|
7
|
+
//# sourceMappingURL=settlement-hook-BIVNGBZF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as y}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=stage-
|
|
1
|
+
import{a as y}from"./chunk-4QA5O64H.js";import{i as w}from"./chunk-3TK2YOVB.js";import{d as u}from"./chunk-OGVSGXQX.js";import{c as g}from"./chunk-AA52P34H.js";import"./chunk-PZA7QECY.js";import"./chunk-3E53F7QY.js";import"./chunk-3AZOATC2.js";import"./chunk-RWHS77ME.js";import{o as h}from"./chunk-GSLOAEY2.js";import"./chunk-JV7LREUF.js";import"./chunk-TE6FBDHP.js";import{A as d,C as f}from"./chunk-K672XXGQ.js";import"./chunk-XAWE4EAK.js";import{execFile as x}from"node:child_process";import{realpath as R}from"node:fs/promises";import p from"node:path";import{promisify as $}from"node:util";var b=$(x);function c(t){return new f(`Automatic merge settlement refused: ${t}`,d.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function G(t){let e=process.env.GIT_INDEX_FILE;if(e===void 0)return;let s=(await t(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(p.resolve(e)!==p.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function k(t,e){if(e.length===0)return[];let s=e.map(n=>`:(literal)${n}`),a=new Set((await t(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),i=e.filter(n=>!a.has(n)).map(n=>`:(literal)${n}`);if(i.length>0&&(await t(["diff","--cached","--name-only","--diff-filter=D","-z","--",...i])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return i}async function I(t){let{git:e,preview:s,paths:a,newReceiptPathspecs:i}=t,n=!1;try{i.length>0&&(n=!0,await e(["add","--",...i]));let o=await t.apply();if(!o.ok||JSON.stringify(o.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||o.repair.streams.some(m=>!s.repair.streams.some(l=>l.id===m.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return a.length>0&&await e(["add","--",...a.map(m=>`:(literal)${m}`)]),{...o,staged_paths:a,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(o){throw n&&await e(["reset","--quiet","--",...i]),o}}function S(t){if(t.repair.totals.failed>0||t.receipts.missing_history_references_after>0||t.receipts.summaries.some(e=>e.conflict_fields.length>0)||t.repair.streams.some(e=>e.merge_receipt_proof?.trusted!==!0)||t.validation.checks.some(e=>e.name!=="history_drift"&&e.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function q(t){try{return{...t,path:await R(h(process.cwd(),t.path))}}catch{throw c("the tracker root cannot be resolved")}}async function z(t){let{preview:e}=t;S(e);let{path:s}=await q(t.global),a=await w(s);if(a===null)throw c("a Git workspace is required");let i=r=>b("git",r,{cwd:a,env:g(),timeout:1e4});if(await G(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let o=[...new Set([...[...new Set([...e.repair.streams.map(r=>r.id),...e.receipts.summaries.map(r=>r.item_id)])].map(r=>p.join(s,"history",`${r}.jsonl`)),...e.receipts.summaries.map(r=>p.join(s,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>p.relative(a,r).replaceAll("\\","/"));if(o.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let m=await y(a,o);if(m.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${m.map(r=>`${r.path} (${r.source}:${r.line}: ${r.pattern})`).join(", ")}. Remove or narrow the owning ignore rules because merge receipts must travel with the commit.`,d.CONFLICT,{code:"merge_settlement_review_required",reason:"ignored_merge_artifacts",paths:m.map(r=>r.path),nextSteps:["Remove or narrow the named ignore rules, preserve receipt and history files, then retry pm merge reconcile --stage --dry-run before applying pm merge reconcile --stage. Do not force-add ignored proof as a substitute for fixing the shared policy."]});let l=o.map(r=>`:(literal)${r}`),v=e.receipts.summaries.map(r=>p.relative(a,p.join(s,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(l.length>0)try{await i(["diff","--quiet","--",...l])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let _=await k(i,v);return t.dryRun?{...e,staged_paths:[]}:I({...t,git:i,paths:o,newReceiptPathspecs:_})}export{q as resolveMergeSettlementGlobal,z as stageLosslessMergeReconciliation};
|
|
2
|
+
//# sourceMappingURL=stage-7BD7U2BX.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as _,C as w,D as C,E as P,b as g}from"./chunk-JFICNN4T.js";import{A,D as E,p as f,q as m,t as l,z as v}from"./chunk-IRYNVGKH.js";import B from"node:path";var U=Object.freeze({decision:"human",milestone:"gate"}),V=["title","description","status","priority","tags","body","deadline","estimatedMinutes","acceptanceCriteria","author","message","assignee"],z=["dep","comment","note","learning","file","test","doc"],I=["deadline","estimatedMinutes","acceptanceCriteria","definitionOfReady","order","goal","objective","value","impact","outcome","whyNow","assignee","parent","reviewer","risk","confidence","sprint","release","blockedBy","blockedReason","unblockNote","reporter","severity","environment","reproSteps","resolution","expectedResult","actualResult","affectedVersion","fixedVersion","component","regression","customerImpact"],G=["title","description","type","status","priority","tags","body",...I,"author","message","dep","comment","note","learning","file","test","doc","reminder","event","typeOption","field"],K=["title","description","body","status","closeReason","priority","type","tags",...I,"author","message","comment","note","learning","file","test","doc","reminder","event","typeOption","field","ownershipMetadataBypass","ownershipDependencyBypass","force"],S={"close-reason":"closeReason",close_reason:"closeReason","estimated-minutes":"estimatedMinutes",estimated_minutes:"estimatedMinutes",estimate:"estimatedMinutes","acceptance-criteria":"acceptanceCriteria",acceptance_criteria:"acceptanceCriteria",ac:"acceptanceCriteria","definition-of-ready":"definitionOfReady",definition_of_ready:"definitionOfReady",rank:"order","why-now":"whyNow",why_now:"whyNow","blocked-by":"blockedBy",blocked_by:"blockedBy","blocked-reason":"blockedReason",blocked_reason:"blockedReason","unblock-note":"unblockNote",unblock_note:"unblockNote","repro-steps":"reproSteps",repro_steps:"reproSteps","expected-result":"expectedResult",expected_result:"expectedResult","actual-result":"actualResult",actual_result:"actualResult","affected-version":"affectedVersion",affected_version:"affectedVersion","fixed-version":"fixedVersion",fixed_version:"fixedVersion","customer-impact":"customerImpact",customer_impact:"customerImpact","type-option":"typeOption",type_option:"typeOption",type_options:"typeOption"},Y={...S},X={...S},N=[["deadline","--deadline"],["estimatedMinutes","--estimate/--estimated-minutes"],["acceptanceCriteria","--acceptance-criteria/--ac"],["definitionOfReady","--definition-of-ready"],["order","--order/--rank"],["goal","--goal"],["objective","--objective"],["value","--value"],["impact","--impact"],["outcome","--outcome"],["whyNow","--why-now"],["assignee","--assignee"],["parent","--parent"],["reviewer","--reviewer"],["risk","--risk"],["confidence","--confidence"],["sprint","--sprint"],["release","--release"],["blockedBy","--blocked-by"],["blockedReason","--blocked-reason"],["unblockNote","--unblock-note"],["reporter","--reporter"],["severity","--severity"],["environment","--environment"],["reproSteps","--repro-steps"],["resolution","--resolution"],["expectedResult","--expected-result"],["actualResult","--actual-result"],["affectedVersion","--affected-version"],["fixedVersion","--fixed-version"],["component","--component"],["regression","--regression"],["customerImpact","--customer-impact"]],L=[["comment","--comment"],["note","--note"],["learning","--learning"],["file","--file"],["test","--test"],["doc","--doc"],["reminder","--reminder"],["event","--event"],["typeOption","--type-option"]];function M(t){return Object.fromEntries(t)}var H=M([["title","--title"],["description","--description"],["type","--type"],["status","--status"],["priority","--priority"],["tags","--tags"],["body","--body"],...N,["author","--author"],["message","--message"],["dep","--dep"],...L]),W=M([["title","--title"],["description","--description"],["body","--body"],["status","--status"],["closeReason","--close-reason"],["priority","--priority"],["type","--type"],["tags","--tags"],...N,...L,["author","--author"],["message","--message"],["force","--force"]]);function Q(t){return t.trim().replace(/^--+/,"").toLowerCase()}function Z(t){return t==="create"?G:K}function J(t){return t==="create"?Y:X}function k(t,e){let o=Q(e);if(o.length===0)return;let n=J(t)[o];return n||Z(t).find(r=>r.toLowerCase()===o)}function Ne(t,e){return(t==="create"?H:W)[e]??`--${e.replace(/([A-Z])/g,"-$1").toLowerCase()}`}function T(t){let e=te(t);return e.length===0?"items":e.endsWith("s")?e:`${e}s`}function ee(t){let e=t.trim(),n=e.replaceAll("\\","/").replace(/^\/+/,""),r=B.posix.normalize(n);if(e.includes("\0")||/^[A-Za-z]:/.test(r)||r==="."||r===".."||r.startsWith("../"))throw new Error(`Item type folder "${t}" must stay inside the pm tracker root.`);return r}function te(t){let e=t.trim().toLowerCase(),o="",n=!1;for(let r of e){let s=r.charCodeAt(0),c=s>=97&&s<=122,u=s>=48&&s<=57;if(c||u){n&&o.length>0&&(o+="-"),o+=r,n=!1;continue}o.length>0&&(n=!0)}return o}function oe(t){return C(t,{resolvePolicyCommand:w})}function ne(t,e){return t.required_create_fields?_(t.required_create_fields):e?.required_create_fields??[]}function re(t,e){return t.required_create_repeatables?_(t.required_create_repeatables):e?.required_create_repeatables??[]}function ie(t,e){return t.options?t.options:e?.options?[...e.options]:[]}function se(t,e){return t.command_option_policies?t.command_option_policies:e?.command_option_policies?[...e.command_option_policies]:[]}function ae(t,e){let o=e?.name??t.name,n=t.description??e?.description,r=t.default_status??e?.default_status,s=ee(t.folder??e?.folder??T(o)),c={name:o,execution_role:t.execution_role,folder:s,aliases:_([...e?.aliases??[],...t.aliases??[]]),required_create_fields:ne(t,e),required_create_repeatables:re(t,e),options:ie(t,e),command_option_policies:se(t,e)};return n&&(c.description=n),r&&(c.default_status=r),c}function x(t,e){for(let o of t){let n=oe(o);if(!n)continue;let r=n.name.toLowerCase(),s=e.get(r);e.set(r,ae({...n,execution_role:n.execution_role??s?.execution_role},s))}}function ce(t){if(!t)return[];let e=[];for(let o of t.item_types??[]){let n=o.types;if(Array.isArray(n))for(let r of n){let s=P(r,"extension").definition;s&&e.push(s)}}return e}function Le(t,e=null){let o=new Map;for(let i of g)o.set(i.toLowerCase(),{name:i,execution_role:U[i.toLowerCase()]??"agent",folder:l[i],aliases:[],required_create_fields:[...V],required_create_repeatables:[...z],options:[],command_option_policies:[]});x(t.item_types?.definitions??[],o),x(ce(e),o);let n=[...o.values()].sort((i,p)=>i.name.localeCompare(p.name)),r={},s={},c={};for(let i of n){r[i.name]=i,c[i.name]=i.folder,s[i.name.toLowerCase()]=i.name;for(let p of i.aliases)s[p.toLowerCase()]=i.name}let u=[...new Set(n.map(i=>i.folder))].sort((i,p)=>i.localeCompare(p));return{types:n.map(i=>i.name),folders:u,type_to_folder:c,by_type:r,alias_to_type:s}}function pe(t,e){if(t!==void 0)return e.alias_to_type[t.trim().toLowerCase()]}function ue(t,e){let o=pe(t,e);if(o)return e.by_type[o]}function le(t,e,o,n){for(let r of n){let s=k(o,r);if(s){t.required.add(s);continue}t.errors.push(`Unsupported base required option "${r}" for command "${o}" on type "${e.name}"`)}}function O(t,e,o){if(o){t.add(e);return}t.delete(e)}function de(t,e,o,n){let r=k(o,n.option);if(!r){t.errors.push(`Unsupported command_option_policies option "${n.option}" for command "${o}" on type "${e.name}"`);return}n.required!==void 0&&O(t.required,r,n.required),n.visible!==void 0&&O(t.hidden,r,!n.visible),n.enabled!==void 0&&O(t.disabled,r,!n.enabled)}function fe(t,e,o){for(let n of e.command_option_policies)n.command===o&&de(t,e,o,n)}function me(t,e,o){for(let n of t.required)t.disabled.has(n)&&t.errors.push(`Option "${n}" cannot be both required and disabled for command "${o}" on type "${e.name}"`)}function Me(t,e,o){let n=[],r=new Set,s=new Set,c=new Set,u={required:r,hidden:s,disabled:c,errors:n};return le(u,t,e,o),fe(u,t,e),me(u,t,e),{required:[...r],hidden:[...s].sort((i,p)=>i.localeCompare(p)),disabled:[...c].sort((i,p)=>i.localeCompare(p)),errors:n}}function _e(t){let e=new Map;for(let o of t.options){e.set(o.key.toLowerCase(),o);for(let n of o.aliases??[])e.set(n.toLowerCase(),o)}return e}function ye(t,e,o){let n=t.values;if(n.length===0)return e;let s=new Map(n.map(c=>[c.toLowerCase(),c])).get(e.toLowerCase());if(!s){o.push(`Invalid value "${e}" for type option "${t.key}". Allowed: ${n.join(", ")}`);return}return s}function ke(t,e,o){let n=ue(t,o);if(!n)return{normalized:void 0,errors:[`Unknown type "${t}"`]};let r=[],s=_e(n),c={};for(let[i,p]of Object.entries(e??{})){let d=i.trim(),b=p.trim();if(d.length===0){r.push("type option keys must not be empty");continue}if(b.length===0){r.push(`type option "${d}" must not be empty`);continue}let h=s.get(d.toLowerCase());if(!h){let F=n.options.map(q=>q.key).join(", ");r.push(n.options.length>0?`Unknown type option "${d}" for type "${n.name}". Allowed: ${F}`:`Type "${n.name}" does not define any configurable type options`);continue}let R=ye(h,b,r);R!==void 0&&(c[h.key]=R)}for(let i of n.options)i.required&&!(i.key in c)&&r.push(`Missing required type option "${i.key}" for type "${n.name}"`);let u=Object.keys(c).sort((i,p)=>i.localeCompare(p));return u.length===0?{normalized:void 0,errors:r}:{normalized:Object.fromEntries(u.map(i=>[i,c[i]])),errors:r}}import{readFileSync as he,readdirSync as $e,realpathSync as j,statSync as $}from"node:fs";import Ee from"node:os";import a from"node:path";var Oe={json_markdown:".md",toon:".toon"},Te={".md":"json_markdown",".toon":"toon"};var Ge=[".md",".toon"];function y(t){try{return $(t),!0}catch{return!1}}function be(t){let e=a.resolve(t),o=[];for(;a.dirname(e)!==e;)try{return a.join(j(e),...o)}catch(n){if(!E(n))throw n;o.unshift(a.basename(e)),e=a.dirname(e)}return a.join(j(e),...o)}function Re(t){try{return $(t),!0}catch(e){if(E(e))return!1;throw e}}function ge(t){try{let e=JSON.parse(he(t,"utf8"));return typeof e!="object"||e===null||Array.isArray(e)?!1:"id_prefix"in e||"item_format"in e}catch{return!1}}function ve(t){let e=be(t);for(;;){let o=a.join(e,f),n=a.join(o,m);if(y(n))return o;let r=a.join(e,m);if(y(r)&&ge(r))return e;if(Re(a.join(e,".git")))return o;let s=a.dirname(e);if(s===e)return;e=s}}function Ae(t){return ve(t)??a.resolve(t,f)}function Ke(t,e){let o=process.env.PM_PATH,n=e?.trim()||o?.trim();if(n){let r=a.resolve(t,n);if(!y(D(r))){let s=a.join(r,f);if(y(D(s)))return s}return r}return Ae(t)}function Ye(t){let e=a.resolve(t),o=a.dirname(e);return a.basename(e)==="pm"&&a.basename(o)===".agents"?a.dirname(o):e}function Xe(t){let e=process.env.PM_GLOBAL_PATH?.trim(),o=e&&e.length>0?e:a.join(Ee.homedir(),".pm-cli");return a.resolve(t,o)}function D(t){return a.join(t,m)}function we(t,e,o=l){let n=o[e]??T(e);return a.join(t,n)}function He(t,e,o,n="toon",r=l){return a.join(we(t,e,r),`${o}${Oe[n]}`)}function We(t){let e=t.replaceAll("\\","/"),o=a.posix.extname(e).toLowerCase();return Te[o]??null}function Qe(t,e){if(!/^(?!\.{1,2}$)[^/\\:\0]+$/.test(e))throw new A("Invalid history item id: expected a single filename.",v.USAGE);return a.join(t,"history",`${e}.jsonl`)}function Ze(t,e){return a.join(t,"locks",`${e}.lock`)}function Je(t){return a.join(t,"runtime")}export{U as a,I as b,k as c,Ne as d,T as e,ee as f,Le as g,pe as h,ue as i,Me as j,ke as k,Ge as l,Ae as m,Ke as n,Ye as o,Xe as p,D as q,He as r,We as s,Qe as t,Ze as u,Je as v};
|
|
2
|
+
//# sourceMappingURL=chunk-26P6C6OO.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as Ke,b as $}from"./chunk-CWQLW4ZO.js";import{Cc as Ue,Gc as He,Ic as F,Mb as q,Wd as Be,_d as Je,eb as De,gb as Ve,hd as ce,id as le,nc as We,sc as M,zc as $e}from"./chunk-BPBKHY6H.js";import{C as Fe,c as C,d as b,f as l,u as se}from"./chunk-TX24L7RQ.js";import{o as qe,q as A}from"./chunk-26P6C6OO.js";import{D as Le,P as R,V as z,Z as L,aa as Me,r as Ie}from"./chunk-JFICNN4T.js";import{A as p,C as Re,D as W,F as T,H as ze,I as ie,J as ae,u as Ne,x as c,y as N,z as m}from"./chunk-IRYNVGKH.js";import{AsyncLocalStorage as Jt}from"node:async_hooks";import{lstat as Kt,realpath as lt}from"node:fs/promises";import dt from"node:path";import Dt from"node:fs/promises";import P from"node:path";var j="_workspace";function U(e){return P.join(e,"history",`${j}.jsonl`)}function Vt(e,t){return{metadata:{id:j,title:"Workspace state",description:"Audited singleton workspace document state.",type:"Chore",status:"open",priority:2,tags:["workspace-history"],created_at:t,updated_at:t,documents:e},body:""}}function H(e,t=e.length){let n=$e();for(let r of e.slice(0,t))n=He(n,r.patch).document;return Ue(n)}function de(e){return"documents"in e.metadata&&typeof e.metadata.documents=="object"&&e.metadata.documents!==null&&!Array.isArray(e.metadata.documents)?e.metadata.documents:{}}function B(e){throw new p(`Workspace history verification failed: ${e.join(", ")}`,m.CONFLICT,{code:"workspace_history_chain_invalid",reason:"workspace_history_chain_verification_failed",verification_errors:[...e],required:"Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",why:"Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",examples:["pm history _workspace --verify --json","pm validate --check-history-drift --fix-hints --json"],nextSteps:["Inspect the exact verification_errors and preserve the corrupt stream as evidence.","Use the history-drift remediation returned by validate before retrying the refused operation."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify --json"}})}function Ge(e,t){let n=P.resolve(t),r=P.relative(e,n).replaceAll("\\","/");if(r.length===0||r===".."||r.startsWith("../")||P.isAbsolute(r))throw new TypeError("Workspace history document path must stay inside the tracker root");return{documentPath:r,absolutePath:n}}async function sr(e){let t=await M(U(e),j),n=F(t);n.ok||B(n.errors);let r=de(t.length===0?N:H(t)),o=[],i=[],a=[],s=[];for(let d of Object.keys(r).sort()){let u;try{let f=Ge(e,P.resolve(e,d));if(u=await T(f.absolutePath),u===null){a.push(d);continue}let h=JSON.parse(u);(C(h)===C(r[d])?o:i).push(d)}catch{s.push(d)}}return{ok:i.length===0&&a.length===0&&s.length===0,document_count:Object.keys(r).length,matching_documents:o,mismatched_documents:i,missing_documents:a,unreadable_documents:s}}async function Ye(e){let t=U(e.pmRoot),n=await M(t,j),r=F(n);r.ok||B(r.errors);let o=e.idempotencyKey===void 0?void 0:n.find(h=>h.op===`${e.op}:${e.idempotencyKey}`);if(o)return{entry:o,historyPath:t};let i=se(),a=n.length===0?N:H(n),s=de(a),d=s[e.documentPath];if(d!==void 0&&C(d)!==C(e.before))throw new p(`Workspace history state for "${e.documentPath}" changed outside the audited mutation path.`,m.CONFLICT,{code:"workspace_history_state_conflict",reason:"out_of_band_workspace_state",required:"Reconcile the singleton document with its matching _workspace history state before retrying the mutation.",why:"Accepting the write would make the append-only audit stream describe a state that was not actually observed.",examples:["pm history _workspace --verify","pm validate --check-history-drift --fix-hints"],nextSteps:["Review the version-control change that altered the singleton and preserve the intended document plus its matching workspace history.","Rerun the original mutation only after the on-disk singleton agrees with the latest audited workspace state."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify"}});let u=Vt({...s,[e.documentPath]:e.after},n.length===0?i:a.metadata.created_at),f=ce({nowIso:i,author:e.author,op:e.idempotencyKey===void 0?e.op:`${e.op}:${e.idempotencyKey}`,before:a,after:u,message:e.message});return await le(t,f),{entry:f,historyPath:t}}async function cr(e){let t=await q(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await Ye(e)}finally{await t()}}async function lr(e){let t=await q(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let n=U(e.pmRoot),r=await M(n,j),o=F(r);o.ok||B(o.errors);let i=r.length===0?N:H(r),a=ce({nowIso:se(),author:e.author,op:e.op,before:i,after:i,message:e.message,context:e.context});return await le(n,a),{entry:a,historyPath:n}}finally{await t()}}async function Xe(e,t){if(t===e.raw)return!1;let n=t===null?null:JSON.parse(t),r=JSON.parse(e.raw);await ae(e.filePath,e.raw);try{(t!==null||e.recordCreation!==!1)&&await Ye({pmRoot:e.pmRoot,documentPath:P.relative(e.pmRoot,e.filePath).replaceAll("\\","/"),before:n,after:r,op:e.op,idempotencyKey:e.idempotencyKey,author:e.author,lockTtlSeconds:e.lockTtlSeconds,lockWaitMs:e.lockWaitMs,message:e.message})}catch(o){throw t===null?await Dt.rm(e.filePath,{force:!0}):await ae(e.filePath,t),o}return!0}async function Qe(e){let{documentPath:t}=Ge(e.pmRoot,e.filePath),n=await q(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let r=await T(e.filePath);if(e.dryRun===!0||e.idempotencyKey!==void 0){let i=await M(U(e.pmRoot),j),a=F(i);a.ok||B(a.errors);let s=de(i.length===0?N:H(i))[t];if(s!==void 0&&C(s)!==C(r===null?null:JSON.parse(r)))throw new p(`Workspace history state for "${t}" changed outside the audited mutation path.`,m.CONFLICT,{code:"workspace_history_state_conflict"});if(e.idempotencyKey!==void 0&&i.some(d=>d.op===`${e.op}:${e.idempotencyKey}`))return{changed:!1,result:void 0,replayed:!0}}let o=await e.mutate(r);return JSON.parse(o.raw),e.dryRun===!0?{changed:r!==o.raw,result:o.result}:{changed:await Xe({...e,raw:o.raw},r),result:o.result}}finally{await n()}}async function dr(e){let t=await q(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await Xe(e,await T(e.filePath))}finally{await t()}}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ue(e,t,n,r=[]){if(b(e,t)&&(r.length>0||J(n)))return n;if(b(e,n)||b(t,n))return t;if((e===void 0||J(e))&&J(t)&&J(n)){let o=e??{},i=new Set([...Object.keys(o),...Object.keys(t),...Object.keys(n)]);return Object.fromEntries([...i].flatMap(a=>{let s=ue(Object.hasOwn(o,a)?o[a]:void 0,Object.hasOwn(t,a)?t[a]:void 0,Object.hasOwn(n,a)?n[a]:void 0,[...r,a]);return s===void 0?[]:[[a,s]]}))}throw new p(`Settings changed concurrently at ${r.join(".")||"<root>"}; read the latest settings and reapply the intended change.`,m.CONFLICT,{reason:"stale_settings_snapshot",required:"Read a fresh settings snapshot and reapply the intended change.",why:"Another writer changed the same setting after this snapshot was read.",examples:["pm config project export --json"],nextSteps:["Read the current settings, then retry the original config operation."]})}var Wt={Epic:2880,Feature:480,Story:480,Milestone:2880,Task:120,Issue:60,Bug:60,Chore:30,Decision:15,Plan:120},Ze=120;function _e(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function tt(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n.toLowerCase(),r);return t}var $t=tt(Wt),et=new WeakMap;function Ut(e){let t=et.get(e);if(t)return t;let n=tt(e);return et.set(e,n),n}function hr(e,t){let n=(e??"").trim().toLowerCase();if(n.length===0)return Ze;if(t){let o=Ut(t).get(n);if(_e(o))return Math.floor(o)}let r=$t.get(n);return _e(r)?Math.floor(r):Ze}function fe(e){let t={};if(e===null||typeof e!="object"||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let o=n.trim();o.length===0||!_e(r)||(t[o]=Math.floor(r))}return t}import{stat as Ht}from"node:fs/promises";var K=new Map;function nt(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}async function Bt(e){try{let t=await Ht(e);return{path:e,mtime_ms:t.mtimeMs,size:t.size}}catch{return{path:e,mtime_ms:null,size:null}}}async function v(e){let t=nt(e),n=await Promise.all(t.map(r=>Bt(r)));return n.sort((r,o)=>r.path.localeCompare(o.path)),n}function D(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],o=t[n];if(r.path!==o.path||r.mtime_ms!==o.mtime_ms||r.size!==o.size)return!1}return!0}function rt(e){return K.get(e)}function G(e,t){let n=nt(t.tracked_paths),r=[...t.signatures].map(o=>({path:o.path,mtime_ms:o.mtime_ms,size:o.size})).sort((o,i)=>o.path.localeCompare(i.path));K.set(e,{tracked_paths:n,signatures:r,value:t.value})}function O(e){if(e){K.delete(e);return}K.clear()}var ye=new Jt;async function Mr(e,t,n=()=>!0){let r=new Set([dt.resolve(e)]);try{r.add(await lt(e))}catch{}let o=!1,i=[r,()=>!o&&n()];try{return await ye.run([...ye.getStore()??[],i],t)}finally{o=!0}}function Gt(e){let t=dt.resolve(e);return ye.getStore()?.some(([n,r])=>n.has(t)&&r())??!1}var Yt="settings:write",ut=Symbol("pm.settings.persist_source"),_t=Symbol("pm.settings.fallback_origin"),ft=Symbol("pm.settings.fallback_baseline"),Xt=128,Qt=new Set(["off","advisory","strict"]);function ot(e){return structuredClone(Ne[e])}function Zt(e){return e==="minimal"||e==="default"||e==="strict"||e==="custom"?e:c.governance.preset}var en=new Set(Ie);function mt(e){return en.has(e)}function it(e,t){let n=typeof t.create_default_type=="string"?t.create_default_type.trim():void 0;return n&&n.length>0&&(e.create_default_type=n),(t.workflow_enforcement==="off"||t.workflow_enforcement==="warn"||t.workflow_enforcement==="strict")&&(e.workflow_enforcement=t.workflow_enforcement),mt(t.start_blocker_enforcement)&&(e.start_blocker_enforcement=t.start_blocker_enforcement),t.require_close_reason===!1&&(e.require_close_reason=!1),e.duplicate_detection_mode=t.duplicate_detection_mode,e.duplicate_detection_threshold=t.duplicate_detection_threshold,e.duplicate_detection_limit=t.duplicate_detection_limit,e}function tn(e){return e.preset==="custom"?it({preset:"custom",ownership_enforcement:e.ownership_enforcement,create_mode_default:e.create_mode_default,close_validation_default:e.close_validation_default,parent_reference:e.parent_reference,metadata_profile:e.metadata_profile,force_required_for_stale_lock:e.force_required_for_stale_lock},e):it({preset:e.preset},e)}function nn(e){let t=typeof e.create_default_type=="string"?e.create_default_type.trim():void 0,n={};t&&t.length>0&&(n.create_default_type=t),(e.workflow_enforcement==="off"||e.workflow_enforcement==="warn"||e.workflow_enforcement==="strict")&&(n.workflow_enforcement=e.workflow_enforcement),mt(e.start_blocker_enforcement)&&(n.start_blocker_enforcement=e.start_blocker_enforcement),typeof e.require_close_reason=="boolean"&&(n.require_close_reason=e.require_close_reason),Qt.has(String(e.duplicate_detection_mode))&&(n.duplicate_detection_mode=e.duplicate_detection_mode);let r=e.duplicate_detection_threshold;[typeof r=="number",Number.isFinite(r),Number(r)>=0,Number(r)<=1].every(Boolean)&&(n.duplicate_detection_threshold=r);let o=e.duplicate_detection_limit;return[typeof o=="number",Number.isSafeInteger(o),Number(o)>=0,Number(o)<=20].every(Boolean)&&(n.duplicate_detection_limit=o),n}function pt(e){let t=e.governance??{},n=Zt(t.preset),r=nn(t);if(n==="custom"){let a=ot("default"),s=r.require_close_reason??a.require_close_reason;return{preset:n,ownership_enforcement:t.ownership_enforcement??a.ownership_enforcement,create_mode_default:t.create_mode_default??a.create_mode_default,close_validation_default:t.close_validation_default??a.close_validation_default,parent_reference:t.parent_reference??a.parent_reference,metadata_profile:t.metadata_profile??a.metadata_profile,force_required_for_stale_lock:t.force_required_for_stale_lock??a.force_required_for_stale_lock,...r,require_close_reason:s,duplicate_detection_mode:r.duplicate_detection_mode??a.duplicate_detection_mode,duplicate_detection_threshold:r.duplicate_detection_threshold??a.duplicate_detection_threshold,duplicate_detection_limit:r.duplicate_detection_limit??a.duplicate_detection_limit}}let o=ot(n),i=r.require_close_reason??o.require_close_reason;return{preset:n,...o,...r,require_close_reason:i}}function ge(){return structuredClone(c)}function ht(e){return e==="cache_only"||e==="semantic_configured"||e==="semantic_auto"?e:c.search.mutation_refresh_policy}function yt(e){return e==="auto"||e==="keyword"||e==="semantic"||e==="hybrid"?e:"auto"}function wt(e){return typeof e=="boolean"?e:c.search.query_expansion.enabled}function kt(e){return typeof e!="string"?c.search.query_expansion.provider:e.trim()}function gt(e){return typeof e=="boolean"?e:c.search.rerank.enabled}function bt(e){return typeof e!="string"?c.search.rerank.model:e.trim()}function xt(e){return typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>0?e:c.search.rerank.top_k}function vt(e){if(typeof e!="string")return c.vector_store.collection_name;let n=e.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_").slice(0,Xt);return n.length>0?n:c.vector_store.collection_name}function me(e){return{present:Array.isArray(e),values:Array.isArray(e)?structuredClone(e):[]}}function St(e,t){let n=e.schema,r=me(n?.statuses),o=me(n?.fields),i=me(n?.type_workflows);return{persisted_settings:structuredClone(e),source_settings:structuredClone(e),has_source_item_type_definitions:Array.isArray(e.item_types?.definitions),source_item_type_definitions:I(e.item_types?.definitions),has_source_schema_statuses:r.present,source_schema_statuses:r.values,has_source_schema_fields:o.present,source_schema_fields:o.values,has_source_schema_type_workflows:i.present,source_schema_type_workflows:i.values,runtime_item_type_definitions:I(t.item_types?.definitions),runtime_schema_statuses:structuredClone(t.schema.statuses),runtime_schema_fields:structuredClone(t.schema.fields),runtime_schema_type_workflows:structuredClone(t.schema.type_workflows??[])}}function be(e,t){Object.defineProperty(e,ut,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Et(e){let t=e[ut];if(!(!t||typeof t!="object"))return t}function Y(e){let t=structuredClone(e.settings),n=Et(e.settings);n&&be(t,n);let r=xe(e.settings);return r!==void 0&&Ct(t,r),{settings:t,metadata:{has_explicit_item_format:e.metadata.has_explicit_item_format},warnings:[...e.warnings]}}function rn(e,t,n){let r=z(t);return[n,L(e,r.files.types,R.types),L(e,r.files.statuses,R.statuses),L(e,r.files.fields,R.fields),L(e,r.files.workflows,R.workflows)]}async function on(e,t,n){let r=await v(t);G(e,{tracked_paths:t,signatures:r,value:Y(n)})}async function an(e,t,n){try{await on(e,t,n)}catch{O(e)}}function at(e,t){return e.find(n=>n.path===t)}function sn(e,t,n){for(let r of n){let o=at(e,r),i=at(t,r);if(!o||!i||!D([o],[i]))return!1}return!0}async function pe(e,t,n,r,o){try{let i=await v(t);if(!sn(r,i,o)){O(e);return}G(e,{tracked_paths:t,signatures:i,value:Y(n)})}catch{O(e)}}function cn(e,t){let n=z(e.schema),r=I(e.item_types?.definitions);if(!t)return{item_type_definitions:r,schema_statuses:n.statuses,schema_fields:n.fields,schema_type_workflows:n.type_workflows};let o=n.type_workflows??[],i=b(r,t.runtime_item_type_definitions),a=b(n.statuses,t.runtime_schema_statuses),s=b(n.fields,t.runtime_schema_fields),d=b(o,t.runtime_schema_type_workflows);return{item_type_definitions:i?t.has_source_item_type_definitions?I(t.source_item_type_definitions):[]:r,schema_statuses:a?t.has_source_schema_statuses?structuredClone(t.source_schema_statuses):[]:n.statuses,schema_fields:s?t.has_source_schema_fields?structuredClone(t.source_schema_fields):[]:n.fields,schema_type_workflows:d?t.has_source_schema_type_workflows?structuredClone(t.source_schema_type_workflows):void 0:n.type_workflows}}function Ct(e,t){Object.defineProperty(e,_t,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Fr(e){return xe(e)!==void 0}function xe(e){let t=e[_t];return typeof t=="string"?t:void 0}function ln(e){return e[ft]}function dn(e,t){Object.defineProperty(e,ft,{value:t,writable:!0,configurable:!0,enumerable:!1})}function x(e){let t=ge();return e!==void 0&&Ct(t,e),{settings:t,metadata:{has_explicit_item_format:!1},warnings:e?[e]:[]}}function Ot(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.item_format;return t==="toon"||t==="json_markdown"}function we(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Tt(e){let t=c.agent_guidance,n=e?.template_version;return{prompt_completed:e?.prompt_completed===!0,declined:e?.declined===!0,declined_at:typeof e?.declined_at=="string"?e.declined_at:t.declined_at,template_version:typeof n=="number"&&Number.isInteger(n)&&n>0?n:t.template_version,last_checked_files:we(e?.last_checked_files??t.last_checked_files)}}function k(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function un(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.mode}function _n(e){return e==="off"||e==="warn"||e==="enforce"?e:c.extensions.policy.trust_mode}function At(e){return e==="none"||e==="restricted"||e==="strict"?e:c.extensions.policy.default_sandbox_profile}function fn(e){let t=e.name.trim().toLowerCase();if(t.length===0)return null;let n={name:t};e.disabled===!0&&(n.disabled=!0),e.require_trusted===!0&&(n.require_trusted=!0),e.require_provenance===!0&&(n.require_provenance=!0),e.sandbox_profile!==void 0&&(n.sandbox_profile=At(e.sandbox_profile));let r=k(e.allowed_capabilities),o=k(e.blocked_capabilities),i=k(e.allowed_surfaces),a=k(e.blocked_surfaces),s=k(e.allowed_commands),d=k(e.blocked_commands),u=k(e.allowed_actions),f=k(e.blocked_actions),h=k(e.allowed_services),g=k(e.blocked_services);return r.length>0&&(n.allowed_capabilities=r),o.length>0&&(n.blocked_capabilities=o),i.length>0&&(n.allowed_surfaces=i),a.length>0&&(n.blocked_surfaces=a),s.length>0&&(n.allowed_commands=s),d.length>0&&(n.blocked_commands=d),u.length>0&&(n.allowed_actions=u),f.length>0&&(n.blocked_actions=f),h.length>0&&(n.allowed_services=h),g.length>0&&(n.blocked_services=g),n}function mn(e){let t=new Map;for(let n of e??[]){let r=fn(n);r&&t.set(r.name,r)}return[...t.values()].sort((n,r)=>n.name.localeCompare(r.name))}function he(e){return e==="block"||e==="warn"?e:void 0}function pn(e){if(typeof e=="string")return he(e);if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=he(e.global),n=he(e.project);return t===void 0&&n===void 0?void 0:{...t!==void 0?{global:t}:{},...n!==void 0?{project:n}:{}}}}function y(e,t){return k(e?.[t]??c.extensions.policy[t])}function Pt(e){let t=pn(e?.pm_max_version_exceeded_mode);return{mode:un(e?.mode),trust_mode:_n(e?.trust_mode),...t!==void 0?{pm_max_version_exceeded_mode:t}:{},require_provenance:e?.require_provenance===!0,trusted_extensions:y(e,"trusted_extensions"),default_sandbox_profile:At(e?.default_sandbox_profile),allowed_extensions:y(e,"allowed_extensions"),blocked_extensions:y(e,"blocked_extensions"),allowed_capabilities:y(e,"allowed_capabilities"),blocked_capabilities:y(e,"blocked_capabilities"),allowed_surfaces:y(e,"allowed_surfaces"),blocked_surfaces:y(e,"blocked_surfaces"),allowed_commands:y(e,"allowed_commands"),blocked_commands:y(e,"blocked_commands"),allowed_actions:y(e,"allowed_actions"),blocked_actions:y(e,"blocked_actions"),allowed_services:y(e,"allowed_services"),blocked_services:y(e,"blocked_services"),extension_overrides:mn(e?.extension_overrides??c.extensions.policy.extension_overrides)}}function jt(e){return[...new Set((e??[]).map(n=>n.trim().toLowerCase().replaceAll("-","_")))].filter(n=>n.length>0).sort((n,r)=>n.localeCompare(r)).filter(n=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(n))}function S(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function _(e,t){return e===void 0?t:e}function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function ke(e){return Array.isArray(e)?e:[]}function hn(e,t,n){return{...t.validation,...e.validation,parent_reference:n.parent_reference,metadata_profile:n.metadata_profile,metadata_required_fields:jt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:S(e.validation?.lifecycle_stale_blocker_reason_patterns??t.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:S(e.validation?.lifecycle_closure_like_blocked_reason_patterns??t.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:S(e.validation?.lifecycle_closure_like_resolution_patterns??t.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:S(e.validation?.lifecycle_closure_like_actual_result_patterns??t.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:fe(e.validation?.estimate_defaults_by_type)}}function yn(e,t){return{enabled:e.telemetry?.enabled??t.telemetry.enabled,first_run_prompt_completed:e.telemetry?.first_run_prompt_completed??t.telemetry.first_run_prompt_completed,capture_level:e.telemetry?.capture_level??t.telemetry.capture_level,endpoint:e.telemetry?.endpoint??t.telemetry.endpoint,installation_id:e.telemetry?.installation_id??t.telemetry.installation_id,retention_days:e.telemetry?.retention_days??t.telemetry.retention_days}}function wn(e,t){return{...t.search,...e.search,default_mode:yt(e.search?.default_mode),mutation_refresh_policy:ht(e.search?.mutation_refresh_policy),query_expansion:{...t.search.query_expansion,...e.search?.query_expansion,enabled:wt(e.search?.query_expansion?.enabled),provider:kt(e.search?.query_expansion?.provider)},rerank:{...t.search.rerank,...e.search?.rerank,enabled:gt(e.search?.rerank?.enabled),model:bt(e.search?.rerank?.model),top_k:xt(e.search?.rerank?.top_k)}}}function kn(e,t){return{adapter:e.vector_store.adapter??t.vector_store.adapter,collection_name:vt(e.vector_store.collection_name),qdrant:{...t.vector_store.qdrant,...e.vector_store.qdrant},lancedb:{...t.vector_store.lancedb,...e.vector_store.lancedb}}}function gn(e,t){return e.item_format==="json_markdown"?"toon":e.item_format??t.item_format}function bn(e,t){return{default_depth:e.context?.default_depth??t.context.default_depth,activity_limit:e.context?.activity_limit??t.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??t.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??t.context.next_ranking_policy,sections:{...t.context.sections,...e.context?.sections}}}function xn(e,t){return{openai:{...t.providers.openai,...e.providers.openai},ollama:{...t.providers.ollama,...e.providers.ollama}}}async function vn(e,t){let n=await Me(e,t.schema);return{settings:{...t,item_types:{definitions:I([...t.item_types.definitions,...ke(n.type_definitions_from_file)])},schema:n.schema},warnings:n.warnings}}function I(e){let t=(e??[]).map(r=>Le(r)).filter(r=>r!==null),n=new Map;for(let r of t)n.set(r.name.toLowerCase(),r);return[...n.values()].sort((r,o)=>r.name.localeCompare(o.name))}function X(e){let t=ge(),n=pt({governance:e.governance??{preset:"default"}});return{...t,...e,item_format:gn(e,t),locks:{...t.locks,...e.locks},ids:{...t.ids,...e.ids},agent_identity:structuredClone(e.agent_identity??t.agent_identity),mutation_guard:{...t.mutation_guard,...e.mutation_guard},checkpoints:{...t.checkpoints,...e.checkpoints},output:{...t.output,...e.output},ux:{...t.ux,...e.ux},history:{...t.history,...e.history,compact_policy:{...t.history.compact_policy,...e.history?.compact_policy}},validation:hn(e,t,n),governance:n,workflow:{definition_of_done:[...e.workflow?.definition_of_done??t.workflow.definition_of_done]},testing:{record_results_to_items:e.testing?.record_results_to_items??t.testing.record_results_to_items,allow_untrusted_linked_tests:e.testing?.allow_untrusted_linked_tests??t.testing.allow_untrusted_linked_tests},telemetry:yn(e,t),agent_guidance:Tt(e.agent_guidance??t.agent_guidance),item_types:{definitions:I(e.item_types?.definitions)},schema:z(e.schema??t.schema),context:bn(e,t),extensions:{enabled:[...e.extensions.enabled],disabled:[...e.extensions.disabled],policy:Pt(e.extensions.policy??t.extensions.policy)},search:wn(e,t),providers:xn(e,t),vector_store:kn(e,t)}}function Sn(e){e.agent_identity=l(e.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);let t=e.agent_identity;Object.hasOwn(t,"identity_vocabulary")&&(t.identity_vocabulary=l(w(t.identity_vocabulary),["version","aliases"])),e.agent_identity.harness_signals=ke(e.agent_identity.harness_signals).map(n=>l(w(n),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"])),e.locks=l(e.locks,["ttl_seconds","wait_ms"]),e.ids=l(e.ids,["token_length"]),e.mutation_guard=l(e.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]),e.checkpoints=l(e.checkpoints,["retention_days"]),e.output=l(e.output,["default_format"]),e.ux=l(e.ux,["deprecation_hints"]),e.history=l(e.history,["missing_stream","compact_policy"]),e.validation=l(e.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]),e.governance=l(e.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]),e.workflow=l(e.workflow,["definition_of_done"]),e.testing=l(e.testing,["record_results_to_items","allow_untrusted_linked_tests"]),e.telemetry=l(e.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]),e.agent_guidance=l(e.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]),e.item_types=l(e.item_types,["definitions"]),e.schema=l(e.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]),e.schema.files=l(w(e.schema.files),["types","statuses","fields","workflows"]),e.schema.workflow=l(w(e.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]),e.context=l(e.context,["default_depth","activity_limit","stale_threshold_days","next_ranking_policy","sections"]),e.context.sections=l(w(e.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]),e.extensions=l(e.extensions,["enabled","disabled","policy"]),e.extensions.policy=l(w(e.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","allowed_extensions","blocked_extensions","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services","extension_overrides"]),e.extensions.policy.extension_overrides=ke(e.extensions.policy.extension_overrides).map(n=>l(w(n),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"])),e.search=l(e.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","default_mode","mutation_refresh_policy","query_expansion","rerank"]),e.search.query_expansion=l(w(e.search.query_expansion),["enabled","provider"]),e.search.rerank=l(w(e.search.rerank),["enabled","model","top_k"]),e.providers=l(e.providers,["openai","ollama"]),e.providers.openai=l(w(e.providers.openai),["base_url","api_key","model"]),e.providers.ollama=l(w(e.providers.ollama),["base_url","model"]),e.vector_store=l(e.vector_store,["adapter","collection_name","qdrant","lancedb"]),e.vector_store.qdrant=l(w(e.vector_store.qdrant),["url","api_key"]),e.vector_store.lancedb=l(w(e.vector_store.lancedb),["path"])}function En(e){return{...e,locks:_(e.locks,c.locks),ids:_(e.ids,c.ids),agent_identity:_(e.agent_identity,c.agent_identity),mutation_guard:_(e.mutation_guard,c.mutation_guard),checkpoints:_(e.checkpoints,c.checkpoints),output:_(e.output,c.output),ux:_(e.ux,c.ux),history:_(e.history,c.history),validation:_(e.validation,c.validation),workflow:_(e.workflow,c.workflow),testing:_(e.testing,c.testing),telemetry:_(e.telemetry,c.telemetry),agent_guidance:_(e.agent_guidance,c.agent_guidance),item_types:_(e.item_types,c.item_types),schema:_(e.schema,c.schema),context:_(e.context,c.context),extensions:_(e.extensions,c.extensions),search:_(e.search,c.search),providers:_(e.providers,c.providers),vector_store:_(e.vector_store,c.vector_store)}}function Cn(e,t){return{...e.validation,parent_reference:t.parent_reference,metadata_profile:t.metadata_profile,metadata_required_fields:jt(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:S(e.validation?.lifecycle_stale_blocker_reason_patterns??c.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:S(e.validation?.lifecycle_closure_like_blocked_reason_patterns??c.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:S(e.validation?.lifecycle_closure_like_resolution_patterns??c.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:S(e.validation?.lifecycle_closure_like_actual_result_patterns??c.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:fe(e.validation?.estimate_defaults_by_type)}}function On(e){return{...c.search,...e.search,default_mode:yt(e.search?.default_mode),mutation_refresh_policy:ht(e.search?.mutation_refresh_policy),query_expansion:{...c.search.query_expansion,...e.search?.query_expansion,enabled:wt(e.search?.query_expansion?.enabled),provider:kt(e.search?.query_expansion?.provider)},rerank:{...c.search.rerank,...e.search?.rerank,enabled:gt(e.search?.rerank?.enabled),model:bt(e.search?.rerank?.model),top_k:xt(e.search?.rerank?.top_k)}}}function Tn(e){return{default_depth:e.context?.default_depth??c.context.default_depth,activity_limit:e.context?.activity_limit??c.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??c.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??c.context.next_ranking_policy,sections:{...c.context.sections,...e.context?.sections}}}function An(e){return{...e.vector_store,adapter:e.vector_store?.adapter??c.vector_store.adapter,collection_name:vt(e.vector_store?.collection_name),qdrant:{...e.vector_store?.qdrant},lancedb:{...e.vector_store?.lancedb}}}function Pn(e,t,n,r){return{...e,item_format:"toon",validation:Cn(e,t),governance:t,agent_guidance:Tt(e.agent_guidance),item_types:{definitions:r.item_type_definitions},schema:{...n,statuses:r.schema_statuses,fields:r.schema_fields,type_workflows:r.schema_type_workflows},search:On(e),context:Tn(e),extensions:{enabled:we(e.extensions?.enabled),disabled:we(e.extensions?.disabled),policy:Pt(e.extensions?.policy)},vector_store:An(e)}}function It(e,t){for(let n of Object.keys(t)){let r=Reflect.get(t,n),o=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof o=="object"&&o!==null&&!Array.isArray(o)?It(o,r):e[n]=structuredClone(r)}}function ve(e,t,n){let r=new Set([...Object.keys(t),...Object.keys(n)]);for(let o of r){let i=t[o],a=n[o];if(!b(i,a)){if(a===void 0){delete e[o];continue}if(typeof i=="object"&&i!==null&&!Array.isArray(i)&&typeof a=="object"&&a!==null&&!Array.isArray(a)){let s=e[o],d=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{};ve(d,i,a),Object.keys(d).length>0?e[o]=d:delete e[o];continue}e[o]=structuredClone(a)}}}var Q=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function st(e,t){let n=En(e),r=pt(n),o=z(n.schema),i=cn(n,t),a=Pn(n,r,o,i),s=l({...a,governance:tn(r)},Q);return Sn(s),s}function Nt(e,t={}){let n=t.source===void 0?t.persist_source:St(t.source.validated,X(t.source.validated)),r=st(e,n);if(n){let o=X(n.source_settings);o.item_types={definitions:structuredClone(n.runtime_item_type_definitions)},o.schema={...o.schema,statuses:structuredClone(n.runtime_schema_statuses),fields:structuredClone(n.runtime_schema_fields),type_workflows:structuredClone(n.runtime_schema_type_workflows)};let i=st(o,n);t.source!==void 0&&It(i,t.source.validated);let a=structuredClone(t.source===void 0?n.source_settings:t.source.raw);return ve(a,i,r),`${JSON.stringify(l(a,Q),null,2)}
|
|
2
|
+
`}return`${JSON.stringify(r,null,2)}
|
|
3
|
+
`}async function jn(e){let t;try{t=await lt(e)}catch(s){if(W(s))return x();throw s}let n=A(t),r;try{r=await Kt(n)}catch(s){if(W(s))return x();throw s}if(!r.isFile())throw ie("settings.json");let o;try{o=await ze(n,ie("settings.json"))}catch(s){if(W(s))return x();throw s}let i;try{i=JSON.parse(o)}catch{return x("settings_read_invalid_json")}let a=$(i);return a.success?{settings:X(a.data),metadata:{has_explicit_item_format:Ot(i)},warnings:a.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:x("settings_read_invalid_schema")}async function Rt(e){if(Gt(e))return jn(e);let t=A(e),n=[t];await Je({path:t,scope:"project"});let r=rt(e);if(r){let u=await v(r.tracked_paths);if(D(u,r.signatures))return Y(r.value)}let o=await v([t]),i;try{i=await T(t)}catch{return x("settings_read_fs_error")}if(i===null){let u=x();return await pe(e,[t],u,o,[t]),u}let a=await v([t]);if(!D(o,a))return O(e),Rt(e);let s;try{s=JSON.parse(i)}catch{let u=x("settings_read_invalid_json");return await pe(e,[t],u,a,[t]),u}let d=$(s);if(!d.success){let u=x("settings_read_invalid_schema");return await pe(e,[t],u,a,[t]),u}try{let u=X(d.data),f=rn(e,u.schema,t);n=f;let h=await v(f),g=await vn(e,u),Pe=await v(f),oe=g.settings;be(oe,St(d.data,oe));let je={settings:oe,metadata:{has_explicit_item_format:Ot(s)},warnings:[...d.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...g.warnings]};return D(h,Pe)?G(e,{tracked_paths:f,signatures:Pe,value:Y(je)}):O(e),je}catch{let u=x("settings_read_merge_failed");return await an(e,n,u),u}}function In(e,t=[],n=null){let r=Se(n)??{},o=t.filter(a=>!Object.hasOwn(r,a));if(o.length===0)return e;let i=JSON.parse(e);for(let a of o)Reflect.deleteProperty(i,a);return`${JSON.stringify(i,null,2)}
|
|
4
|
+
`}var Nn=/^[A-Za-z0-9_-]+$/u,Rn=new Set(["__proto__","constructor","prototype"]);function Se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function zn(e){for(let t of e)if(t.split(".").find(o=>!Nn.test(o)||Rn.has(o))!==void 0)throw new p(`Settings write assignedPaths entry "${t}" is not a dotted settings path.`,m.USAGE,{code:"settings_write_assigned_path_invalid",reason:"assigned_path_segment_invalid",field:t,why:"Assigned paths name settings keys; an empty, reserved or non-identifier segment cannot address one safely.",nextSteps:["Pass dotted settings keys such as context.next_ranking_policy in assignedPaths."]})}function zt(e,t){return Se(Object.hasOwn(e,t)?e[t]:void 0)}function ct(e,t){let n=e;for(let r of t)if(n=zt(n,r),n===void 0)return;return n}function Ln(e,t){let n=e;for(let r of t){let o=zt(n,r);o===void 0&&(o={},n[r]=o),n=o}return n}function qn(e,t,n){for(let r of n){let o=r.split("."),i=o.pop(),a=ct(t,o);if(a===void 0)continue;if(Object.hasOwn(a,i)){Ln(e,o)[i]=structuredClone(a[i]);continue}if(!Ke.includes(o[0]??i))continue;let s=ct(e,o);s!==void 0&&delete s[i]}}function Mn(e,t,n,r,o){let i=o??JSON.parse(Nt(ge())),a=structuredClone(Se(e)??{});ve(a,i,t),qn(a,t,r);let s=$(a);if(!s.success){let d=s.path;throw new p(`Existing settings.json fails validation at ${d}; the settings write was refused and nothing was changed.`,m.USAGE,{code:"settings_write_invalid_existing_schema",reason:"existing_settings_schema_invalid",field:d,original_code:n,why:"The stored settings could not be read, so writing would either keep an invalid document or replace intended project configuration with defaults.",nextSteps:[`Fix or remove ${d} in settings.json, then retry the original command.`,"A configurable setting can also be repaired explicitly, even to its default value, with pm config <scope> set <dotted.key> <value>.","Run pm health to confirm the settings warning has cleared."]})}return`${JSON.stringify(l(a,Q),null,2)}
|
|
5
|
+
`}function Fn(e){try{return JSON.parse(e)}catch{throw new p("Existing settings.json is malformed; the settings write was refused.",m.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}}async function Dr(e){return(await Rt(e)).settings}async function Vr(e,t,n=Yt,r={}){let o=r.assignedPaths??[];zn(o);let i=A(e),a=Et(t),s=a?void 0:xe(t),d=Nt(t,{persist_source:a}),u=JSON.parse(d),f=!1;try{if(await Qe({pmRoot:e,filePath:i,mutate:h=>{let g=h===null?null:Fn(h);return h!==null&&r.skipIfStored?.(g)===!0?(f=!0,{raw:h,result:void 0}):s!==void 0&&h!==null?{raw:Mn(g,u,s,o,ln(t)),result:void 0}:{raw:a?`${JSON.stringify(l(ue(a.persisted_settings,u,g),Q),null,2)}
|
|
6
|
+
`:In(d,r.omitSections,g),result:void 0}},op:n,author:We(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),f)return;a?be(t,{...a,persisted_settings:structuredClone(u)}):s!==void 0&&dn(t,structuredClone(u)),await Be({path:i,scope:"project",op:n})}finally{O(e)}}import Lt from"node:fs";import V from"node:path";import{createRequire as Dn}from"node:module";var qt="@unbrained/pm-cli";var Ce=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,Oe="2026.8.31";function Z(e){let t=e.match(Ce);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function te(e,t){let n=Z(e),r=Z(t);if(!n||!r)return null;for(let o=0;o<n.length;o+=1){let i=n[o]-r[o];if(i!==0)return Math.sign(i)}return 0}function Ee(e){return te(e,Oe)!==-1?3:2}function ee(e){try{let t=JSON.parse(Lt.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Vn(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(r=>({inclusive:r[1]==="<=",version:r[2]})),n=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return n?[...t,{inclusive:!0,version:n[1]}]:t}function Wn(e){let t=e.split("||").map(n=>Vn(n));return{bounded:t.some(n=>n.length>0),compatible:t.some(n=>n.every(r=>{let o=te(Oe,r.version);return o!==null&&(r.inclusive?o!==1:o===-1)}))}}function Mt(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let n=e[t];if(typeof n!="object"||n===null)return[];let r=n[qt];return typeof r=="string"?[r.trim()]:[]})}function $n(e){return Mt(e).flatMap(t=>{let n=/^[<!]/u.test(t)?void 0:t.match(Ce)?.[0];if(!n)return[];let r=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),o=Wn(t);return[{version:n,constraint:r?"exact":o.bounded?"range":"minimum",...r?{}:{declaration:t},history_epoch_compatible:r?te(n,Oe)!==-1:o.compatible}]})}function Un(e){let n=ee(V.join(e,"package-lock.json"))?.packages;if(typeof n!="object"||n===null)return;let r=n["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let o=r.version;return typeof o=="string"?o:void 0}function Hn(e,t){try{let n=Lt.readFileSync(V.join(e,t),"utf8").split(/\r?\n/u),r=n.findIndex(d=>d.includes(qt));if(r<0)return;let o=n[r].match(/^\s*/u)[0].length,i=[n[r]];for(let d=r+1;d<n.length;d+=1){let u=n[d],f=u.trim(),h=u.match(/^\s*/u)[0].length;if(f.length>0&&h<=o)break;i.push(u)}return i.join(`
|
|
7
|
+
`).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??i[0].match(Ce)?.[0]}catch{return}}function Bn(e){let t=[],n=ee(V.join(e,"package.json"));n&&t.push(...$n(n).map(a=>({...a,source:"package.json"})));let o=ee(V.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof o=="string"&&Z(o)&&t.push({version:o,source:"installed-package",constraint:"exact",history_epoch_compatible:Ee(o)===3});let i=Un(e);i&&Z(i)&&t.push({version:i,source:"package-lock.json",constraint:"exact",history_epoch_compatible:Ee(i)===3});for(let a of["pnpm-lock.yaml","yarn.lock"]){let s=Hn(e,a);s&&t.push({version:s,source:a,constraint:"exact",history_epoch_compatible:Ee(s)===3})}return t}function Jn(e,t){if(t<=1)return;let{minVersion:n,lt:r}=Dn(import.meta.url)("semver"),o=Mt(ee(V.join(e,"package.json"))??{}).find(a=>{try{let s=n(a);return s!==null&&r(s,"2026.10.10")}catch{return!1}}),i=o===void 0?Bn(e).find(a=>te(a.version,"2026.10.10")===-1):{version:o,source:"package.json"};if(i)throw new p(`The project selects pm ${i.version}, which cannot safely refuse item format ${t}.`,m.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:i.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function Yr(e,t){let n=Ve(e);n<=1||(Jn(qe(t),n),e.pm_format_version=n)}import Ae from"node:fs/promises";import ne from"node:path";function E(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function Ft(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:Fe(t),suggested_retry_args:t}}function re(e){return new p(`Tracker root is not a directory at ${e}.`,m.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function Te(e){return new p(`Tracker root is not readable at ${e}.`,m.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function Kn(e){let t=ne.resolve(e),n=ne.parse(t).root,r=ne.dirname(t);for(;r!==n;){let o;try{o=await Ae.stat(r)}catch(i){if(E(i,"ENOTDIR"))throw re(e);if(!E(i,"ENOENT"))throw i;r=ne.dirname(r);continue}if(!o.isDirectory())throw re(e);return}}async function Gn(e){let t;try{t=await Ae.stat(e)}catch(n){throw E(n,"ENOENT")?(await Kn(e),new p(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,m.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:Ft(e)})):E(n,"ENOTDIR")?re(e):E(n,"EACCES")||E(n,"EPERM")?Te(e):n}if(!t.isDirectory())throw re(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw Te(e);try{await(await Ae.opendir(e)).close()}catch(n){throw E(n,"EACCES")||E(n,"EPERM")?Te(e):n}}async function io(e){if(await Gn(e),!await Re(A(e)))throw new p(`Tracker is not initialized at ${e}. Run pm init first.`,m.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:Ft(e)})}export{j as a,U as b,sr as c,cr as d,lr as e,Qe as f,dr as g,hr as h,O as i,Mr as j,Gt as k,pt as l,Fr as m,vn as n,X as o,Nt as p,Rt as q,Dr as r,Vr as s,Bn as t,Jn as u,Yr as v,Gn as w,io as x};
|
|
8
|
+
//# sourceMappingURL=chunk-2CQFGJQ6.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{D as Ie,E as Te,H as Le,T as Se,f as Ee}from"./chunk-TSZVCALS.js";import{r as be,x as Re}from"./chunk-2CQFGJQ6.js";import{a as N,b as R}from"./chunk-X6CXWWNB.js";import{Le as me,Mf as xe,Nf as ve,Qe as ge,Sd as z,Sf as Ce,Td as fe,Ze as he,cf as _e,ge as Y,jf as ye,kf as ke,nb as G,of as we,t as E,xe as A,y as de}from"./chunk-BPBKHY6H.js";import{C as F,c as le}from"./chunk-TX24L7RQ.js";import{g as ae,n as ue}from"./chunk-26P6C6OO.js";import{ba as pe}from"./chunk-JFICNN4T.js";import{A as w,z as x}from"./chunk-IRYNVGKH.js";function v(){let e=E();for(let n of z()?.relationship_kinds??[])for(let o of n.definitions)e.register(o);return e}function M(e){if(typeof e!="string")return;let n=e.trim().toLowerCase();return n.length>0?n:void 0}function K(e){return[e.parent_id,e.child_id,e.source,e.kind,e.holder_id,e.target_id??""].join("\0")}function Qe(e,n){let o=new Set,t=[];for(let r of[...e].sort()){if(o.has(r))continue;o.add(r);let i=[{nodeId:r,children:[...n.get(r)??[]].sort(),nextChild:0}];for(;i.length>0;){let s=i.at(-1),c=s.children[s.nextChild];c===void 0?(t.push(s.nodeId),i.pop()):(s.nextChild+=1,o.has(c)||(o.add(c),i.push({nodeId:c,children:[...n.get(c)??[]].sort(),nextChild:0})))}}return t}function Ze(e,n){let o=[...e].sort(),t=Qe(o,n),r=new Set,i=et(o,n),s=[];for(let c of t.reverse()){if(r.has(c))continue;let d=tt(c,i,r);(d.length>1||n.get(d[0])?.has(d[0]))&&s.push(d)}return s.sort((c,d)=>c.join("\0").localeCompare(d.join("\0")))}function et(e,n){let o=new Map(e.map(t=>[t,new Set]));for(let[t,r]of n)for(let i of r)o.get(i)?.add(t);return o}function tt(e,n,o){let t=[],r=[e];for(o.add(e);r.length>0;){let i=r.pop();t.push(i);for(let s of[...n.get(i)].sort())o.has(s)||(o.add(s),r.push(s))}return t.sort()}function Oe(e){let n=new Map;for(let o of e){let t=M(o?.id);t&&!n.has(t)&&n.set(t,o)}return n}function nt(e,n,o){let t=M(n.parent);if(!(!t||!o.has(t)))return{parent_id:t,child_id:e,source:"scalar_parent",kind:"parent",holder_id:e,child_cardinality:"one"}}function ot(e,n,o,t){let r=M(n?.id),i=t.resolve(n?.kind);if(!r||!o.has(r)||!i?.hierarchy)return;let s=i.hierarchyDirection==="source_parent";return{parent_id:s?e:r,child_id:s?r:e,source:"dependency",kind:i.kind,holder_id:e,target_id:r,child_cardinality:s?i.incoming:i.outgoing}}function De(e,n){let o=new Map;for(let[t,r]of e){let i=nt(t,r,e);i&&o.set(K(i),i);for(let s of r.dependencies??[]){let c=ot(t,s,e,n);c&&o.set(K(c),c)}}return[...o.values()].sort((t,r)=>K(t).localeCompare(K(r)))}function un(e,n=v()){return De(Oe(e),n)}function rt(e,n,o){let t=new Set(e.filter(r=>r.child_cardinality==="one").map(r=>r.child_id));return[...n].filter(([r,i])=>i.length>1&&t.has(r)).map(([r,i])=>({child_id:r,parent_ids:[...i],legacy_terminal:o.has(r)&&i.every(s=>o.has(s))})).sort((r,i)=>r.child_id.localeCompare(i.child_id))}function it(e,n,o){let t=new Map;for(let i of n){if(i.source!=="dependency")continue;let s=t.get(i.child_id)??new Set;s.add(i.parent_id),t.set(i.child_id,s)}let r=[];for(let[i,s]of e){let c=M(s.parent);if(!c||!e.has(c))continue;let d=[...t.get(i)??[]].filter(u=>u!==c).sort();d.length!==0&&r.push({child_id:i,scalar_parent_id:c,dependency_parent_ids:d,legacy_terminal:o.has(i)&&o.has(c)&&d.every(u=>o.has(u))})}return r.sort((i,s)=>i.child_id.localeCompare(s.child_id))}function H(e,n=t=>t==="closed"||t==="canceled",o=v()){let t=Oe(e),r=De(t,o),i=st(r),s=new Set([...t].filter(([,d])=>n(d.status)).map(([d])=>d)),c=Ze([...t.keys()],new Map([...i.children_by_parent].map(([d,u])=>[d,new Set(u)]))).map(d=>({item_ids:d,legacy_terminal:d.every(u=>s.has(u))}));return{relations:r,cycles:c,cardinality_violations:rt(r,i.parents_by_child,s),divergences:it(t,r,s)}}function ln(e){return e.source==="scalar_parent"?`${e.parent_id} -> ${e.child_id} (scalar parent on ${e.holder_id})`:`${e.parent_id} -> ${e.child_id} (${e.kind} dependency on ${e.holder_id})`}function st(e){let n=new Map,o=new Map;for(let t of e){let r=n.get(t.child_id)??new Set;r.add(t.parent_id),n.set(t.child_id,r);let i=o.get(t.parent_id)??new Set;i.add(t.child_id),o.set(t.parent_id,i)}return{parents_by_child:new Map([...n].map(([t,r])=>[t,[...r].sort()])),children_by_parent:new Map([...o].map(([t,r])=>[t,[...r].sort()]))}}function J(e,n){let o=new Set(n);return e.every(t=>o.has(t))}function pn(e,n,o,t,r){let i=M(o);if(!i)return;let s=H(e,t,r),c=H(n,t,r),d=c.divergences.find(a=>!s.divergences.some(p=>p.child_id===a.child_id&&p.scalar_parent_id===a.scalar_parent_id&&J(a.dependency_parent_ids,p.dependency_parent_ids)));if(d){let a=[d.scalar_parent_id,...d.dependency_parent_ids].sort();throw new w(`Hierarchy mutation would assign ${d.child_id} to multiple parents: ${a.join(", ")}.`,x.CONFLICT,{code:"hierarchy_parent_divergence_created",source_id:i,target_id:d.child_id,verification_errors:a})}let u=c.cardinality_violations.find(a=>(a.child_id===i||a.parent_ids.includes(i))&&!s.cardinality_violations.some(p=>p.child_id===a.child_id&&J(a.parent_ids,p.parent_ids)));if(u)throw new w(`Hierarchy mutation would assign ${u.child_id} to multiple parents: ${u.parent_ids.join(", ")}.`,x.CONFLICT,{code:"hierarchy_cardinality_created",source_id:i,target_id:u.child_id,verification_errors:u.parent_ids});let l=c.cycles.find(a=>a.item_ids.includes(i)&&!s.cycles.some(p=>J(a.item_ids,p.item_ids)));if(l)throw new w(`Hierarchy mutation would create a cycle: ${l.item_ids.join(" -> ")}.`,x.CONFLICT,{code:"hierarchy_cycle_created",source_id:i,verification_errors:l.item_ids})}var ct="global";function hn(e){let n=e?.trim();if(n)return R(n)?ct:n}function _n(e,n,o){return dt(e,n,o)}function dt(e,n,o){let t=e.trim();return R(o)||N(t)?t:Ee(t,n)}function L(e){if(typeof e!="string")return;let n=e.trim();if(!(!n||["none","null","n/a","na"].includes(n.toLowerCase())))return n}function $(e){let n=L(e);return n?.toLowerCase()==="no-active-blocker"?void 0:n}function B(e,n,o=!0){let t=L(e);return o&&(R(n)||t!==void 0&&N(t))}function Q(e,n){return B(e,n)?`external\0${e}`:`local\0${e.toLowerCase()}`}function Ae(e,n,o,t){return B(e,n)?t.get(e):o.get(e.toLowerCase())}function T(e,n){let o=e.toLowerCase(),t=n.toLowerCase();return o!==t?o<t?-1:1:e!==n?e<n?-1:1:0}function at(e){let n=new Map;for(let o of e.dependencies??[]){if(typeof o!="object"||o===null)continue;let t=o,r=L(t.id);if(!r)continue;let i=typeof t.kind=="string"?t.kind:"related",s=`${i}\0${Q(r,t.source_kind)}`,c=n.get(s);c?c.count+=1:n.set(s,{target_id:r,kind:i,count:1})}return n}function ut(e,n=o=>o==="closed"||o==="canceled"){let o=[];for(let t of e)if(!(typeof t?.id!="string"||t.id.trim().length===0))for(let r of at(t).values())r.count<2||o.push({holder_id:t.id.trim(),target_id:r.target_id,kind:r.kind,occurrences:r.count,holder_status:t.status,legacy_terminal:n(t.status)});return o.sort((t,r)=>{let i=T(t.holder_id,r.holder_id);if(i!==0)return i;let s=T(t.target_id,r.target_id);return s!==0?s:T(t.kind,r.kind)})}function lt(e,n,o,t,r){if(typeof o!="object"||o===null)return;let i=L(o.id);if(!i||Q(i,o.source_kind)!==Q(n))return;let s=r.resolve(typeof o.kind=="string"?o.kind:"related");if(!(s?.ordering!==!0||(s.precedence??"source_before_target")!=="source_before_target"))return{holder_id:e.id.trim(),target_id:i,dependency_kind:s.kind,holder_status:e.status,legacy_terminal:t(e.status)}}function pt(e,n=t=>t==="closed"||t==="canceled",o=v()){let t=new Map;for(let r of e){if(typeof r?.id!="string"||r.id.trim().length===0)continue;let i=L(r.blocked_by);if(i)for(let s of r.dependencies??[]){let c=lt(r,i,s,n,o);c&&t.set(`${c.holder_id.toLowerCase()}\0${c.target_id.toLowerCase()}\0${c.dependency_kind}`,c)}}return[...t.values()].sort((r,i)=>{let s=T(r.holder_id,i.holder_id);if(s!==0)return s;let c=T(r.target_id,i.target_id);return c!==0?c:T(r.dependency_kind,i.dependency_kind)})}function Z(e,n=o=>o==="closed"||o==="canceled"){let o=e.filter(d=>typeof d?.id=="string"&&d.id.trim().length>0),t=new Set(o.map(d=>d.id.trim().toLowerCase())),r=new Map,i=(d,u,l,a,p)=>{let m=L(u);if(!m||t.has(m.toLowerCase())||B(m,void 0,p))return;let f={holder_id:d.id.trim(),target_id:m,kind:l,source:a,holder_status:d.status,legacy_terminal:n(d.status),no_active_blocker_sentinel:m.toLowerCase()==="no-active-blocker"};r.set(`${f.holder_id}::${f.target_id}::${f.kind}::${f.source}`,f)};for(let d of o){i(d,d.parent,"parent","parent",!1),i(d,d.blocked_by,"blocked_by","blocked_by",!0);for(let u of d.dependencies??[]){if(typeof u!="object"||u===null)continue;let l=u;R(l.source_kind)||i(d,l.id,typeof l.kind=="string"?l.kind:"related","dependency",!0)}}let s=[...r.values()].sort((d,u)=>d.holder_id.localeCompare(u.holder_id)||d.target_id.localeCompare(u.target_id)||d.kind.localeCompare(u.kind)||d.source.localeCompare(u.source)),c=s.filter(d=>d.legacy_terminal);return{active:s.filter(d=>!d.legacy_terminal),legacy_terminal:c,no_active_blocker_sentinels:s.filter(d=>d.no_active_blocker_sentinel)}}function ft(e){let n=new Map;for(let o of[...e.active,...e.legacy_terminal]){if(o.no_active_blocker_sentinel)continue;let t=o.target_id.trim(),r=t.toLowerCase();n.has(r)||n.set(r,t)}return[...n.values()].sort((o,t)=>o.localeCompare(t))}function mt(e){let n=new Map;for(let o of e){let t=$(o.blocked_by);t&&B(t)&&!n.has(t)&&n.set(t,t);for(let r of o.dependencies??[]){if(typeof r!="object"||r===null||!B(r.id,r.source_kind))continue;let i=$(r.id);i&&!n.has(i)&&n.set(i,i)}}return[...n.values()].sort((o,t)=>o.localeCompare(t))}var Ne=new WeakMap;function En(e){return e.hierarchyIntegrity??Ne.get(e)}function gt(e,n=v()){let o={};for(let t of e)for(let r of t.dependencies??[]){if(typeof r!="object"||r===null)continue;let i=r.kind;if(typeof i!="string")continue;let s=i.trim().toLowerCase().replaceAll("-","_"),c=n.resolve(i);c&&s!==c.kind&&(o[s]=(o[s]??0)+1)}return Object.fromEntries(Object.entries(o).sort(([t],[r])=>t.localeCompare(r)))}function ee(e,n,o){let t=o??v(),r=e.filter(f=>typeof f?.id=="string"&&f.id.trim().length>0),i=new Map(r.map(f=>[f.id.trim().toLowerCase(),f.id.trim()])),s=Z(r,n),c=ft(s);for(let f of c)i.set(f.toLowerCase(),f);let d=mt(r),u=new Set(i.keys()),l=new Map;for(let f of d){let _=f;for(;u.has(_.toLowerCase());)_=`external:${_}`;l.set(f,_),u.add(_.toLowerCase())}let a=r.map(f=>{let _=$(f.parent),g=$(f.blocked_by),h=(f.dependencies??[]).flatMap(k=>{if(typeof k!="object"||k===null)return[];let y=k,C=$(y.id);return C?[{id:Ae(C,y.source_kind,i,l),kind:typeof y.kind=="string"?y.kind:"related"}]:[]});return{id:f.id.trim(),..._?{parent:i.get(_.toLowerCase())}:{},...g?{blocked_by:Ae(g,void 0,i,l)}:{},dependencies:h}}),p=H(r,n,t),m={graph:de.fromItems([...a,...c.map(f=>({id:f})),...d.map(f=>({id:l.get(f)}))],t),details:[...r.map(f=>({id:f.id.trim(),title:f.title,status:f.status,...typeof f.type=="string"&&f.type.trim().length>0?{type:f.type.trim()}:{}})),...c.map(f=>({id:f,title:`[missing] ${f}`,status:"missing"})),...d.map(f=>({id:l.get(f),title:`[external] ${f}`,status:"external"}))],missingIdSet:new Set(c.map(f=>f.toLowerCase())),dangling:s,duplicateRows:ut(r,n),orderingContradictions:pt(r,n,t),legacyAliasCounts:gt(r,t),hierarchyIntegrity:p};return Ne.set(m,p),m}import{createHash as ht}from"node:crypto";var _t=64,yt=8;function kt(e,n){let o=(e.dependencies??[]).map(t=>{if(typeof t!="object"||t===null)return"";let r=t;return`${typeof r.kind=="string"?r.kind:"related"}:${typeof r.id=="string"?r.id:""}`}).sort().join(",");return[e.id,e.title,e.status,n(e.status)?"1":"0",typeof e.type=="string"?e.type.trim():"",e.parent??"",e.blocked_by??"",o].join("\0")}function $e(e,n=t=>t==="closed"||t==="canceled",o=E()){let t=e.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0).map(i=>kt(i,n)).sort(),r=o.list().map(i=>le(i)).sort();return ht("sha256").update(t.join("")).update("").update(r.join("")).digest("hex")}function Me(e,n,o){let t=n??o;if(!Number.isInteger(t)||t<1)throw new TypeError(`Invalid ${e} bound: ${String(n)}`);return t}var te=class{#e=new Map;#t;#n;constructor(n={}){this.#t=Me("maxResultsPerWorkspace",n.maxResultsPerWorkspace,_t),this.#n=Me("maxWorkspaces",n.maxWorkspaces,yt)}lookup(n,o,t){let r=this.#e.get(n),i=!0;(r===void 0||r.fingerprint!==o)&&(r={fingerprint:o,assembly:t(),results:new Map},i=!1,!this.#e.has(n)&&this.#e.size>=this.#n&&this.#e.delete(this.#e.keys().next().value)),this.#e.delete(n),this.#e.set(n,r);let s=r,c=this.#t;return{assembly:s.assembly,assemblyReused:i,fingerprint:o,memoize(d,u){let l=s.results.get(d);if(l!==void 0||s.results.has(d))return s.results.delete(d),s.results.set(d,l),{value:structuredClone(l),reused:!0};let a=u();return s.results.size>=c&&s.results.delete(s.results.keys().next().value),s.results.set(d,structuredClone(a)),{value:a,reused:!1}}}}clear(){this.#e.clear()}},Be=new te;function Pe(){return Be}function Sn(){Be.clear()}var U=1200,wt=["prerequisite","dependent","ancestor","descendant","provenance","related"],xt=new TextEncoder;function ne(e,n,o){let t=e??n;if(!Number.isInteger(t)||t<1)throw new TypeError(`Relationship context ${o} must be positive`);return t}function P(e){return Math.max(1,Math.ceil(xt.encode(JSON.stringify(e)).byteLength/4))}function W(e,n,o){let t=o.resolve(e.kind);if(t?.ordering){let i=(t.precedence??"source_before_target")==="source_before_target"?e.source:e.target;return n===i?"prerequisite":"dependent"}if(t?.hierarchy){let i=t.hierarchyDirection==="source_parent"?e.source:e.target;return n===i?"ancestor":"descendant"}return e.kind==="discovered_from"||e.kind==="incident_from"?"provenance":"related"}function vt(e,n,o,t){let r=e.filter(i=>i.source===n&&i.target===o||i.target===n&&i.source===o).map(i=>W(i,o,t));return[...new Set(r)].sort()}function Ct(e){return wt.find(n=>e.includes(n))}function Et(e,n,o,t){let r=t.direction??"both",i=t.maxDepth??3;if(!Number.isInteger(i)||i<0)throw new TypeError("Relationship context maxDepth must be non-negative");let s=new Set([n]),c=[{id:n,distance:0}],d=[],u=0,l=!1;for(let a=0;a<c.length;a+=1){t.signal?.throwIfAborted();let p=c[a];if(p.distance>=i&&l)continue;let m=e.neighborEdges(p.id,{direction:r,kinds:t.kinds,signal:t.signal});if(u+=m.meta.inspectedEdges,p.distance>=i){m.value.some(f=>!s.has(f.id))&&(l=!0);continue}for(let{id:f,edge:_}of m.value){if(s.has(f))continue;s.add(f);let g={id:f,distance:p.distance+1,via:p.id,role:W(_,f,o)};d.push(g),c.push(g)}}return{rows:d,visitedNodes:c.length,inspectedEdges:u,depthTruncated:l}}function bt(e,n,o,t){let r={prerequisite:0,dependent:0,ancestor:0,descendant:0,provenance:0,related:0},i=e.neighborEdges(n,{direction:t.direction??"both",kinds:t.kinds,signal:t.signal}).value;for(let{id:s,edge:c}of i)r[W(c,s,o)]+=1;return{directEdges:r,directTotal:i.length,rootEdges:i.map(({edge:s})=>s)}}function Rt(e,n,o,t){let r=new Set;for(let i of n){let s=i.source===o?i.target:i.source,c=W(i,s,t);(c==="prerequisite"||c==="ancestor")&&r.add(s)}return[...e].sort((i,s)=>Number(r.has(s.id))-Number(r.has(i.id))||i.distance-s.distance||i.id.localeCompare(s.id))}function It(e,n){let o=e.distance===1?vt(n.rootEdges,n.rootId,e.id,n.registry):[];return{...n.details.get(e.id)??{id:e.id},distance:e.distance,role:o.length>0?Ct(o):e.role,via:e.via,reasons:o.length>0?o:[`${e.role} via ${e.via} (depth ${e.distance})`]}}function Tt(e){let n=[],o=e.initialTokens,t=0;for(let r of e.candidates){if(n.length>=e.nodeLimit)break;let i=It(r,e),s=P(i);if(o+s>e.tokenBudget)break;let c=e.rootEdges.filter(d=>d.source===r.id||d.target===r.id).reduce((d,u)=>d+P(u),0);if(o+t+s+c>e.tokenBudget){if(n.length>0)break}else t+=c;n.push(i),o+=s}if(e.candidates.length>0&&n.length===0)throw new TypeError("Relationship context tokenBudget cannot fit one node");return{nodes:n,usedTokens:o}}function Lt(e){let n=e.options.kinds?new Set(e.options.kinds.map(i=>e.registry.require(i).kind)):void 0,o=e.graph.edges().filter(i=>{if(!e.included.has(i.source)||!e.included.has(i.target))return!1;if(n===void 0||n.has(i.kind))return!0;let s=e.registry.resolve(i.kind)?.inverse;return s!==void 0&&n.has(s)}).sort((i,s)=>+(s.source===e.rootId||s.target===e.rootId)-+(i.source===e.rootId||i.target===e.rootId)),t=[],r=e.initialTokens;for(let i of o){if(t.length>=e.edgeLimit)break;let s=P(i);r+s>e.tokenBudget||(t.push(i),r+=s)}return{edges:t,usedTokens:r,candidateCount:o.length}}function Ue(e,n,o,t={}){if(!e.nodes().includes(n))throw new TypeError(`Relationship node not found: ${n}`);let r=ne(t.nodeLimit,20,"nodeLimit"),i=ne(t.edgeLimit,40,"edgeLimit"),s=ne(t.tokenBudget,U,"tokenBudget"),c=t.registry??E(),d=new Map(o.map(I=>[I.id,I])),u=d.get(n)??{id:n},{evidence:l=[],...a}=u,p=[...l],m=Et(e,n,c,t),{rootEdges:f,..._}=bt(e,n,c,t),g=Rt(m.rows,f,n,c),h=ye("relationship-context",{rootId:n,direction:t.direction??"both",kinds:[...t.kinds??[]].sort(),maxDepth:t.maxDepth??3,ordering:"required-root-evidence-first-v1"}),k=we(g,t.cursor,h,({id:I})=>I,"--cursor"),y=g.slice(k),C=P(a)+P(p);if(C>s)throw new TypeError("Relationship context tokenBudget cannot fit root and evidence");let O=Tt({candidates:y,details:d,rootEdges:f,rootId:n,registry:c,nodeLimit:r,tokenBudget:s,initialTokens:C}),{nodes:D}=O,Ve=new Set([n,...D.map(({id:I})=>I)]),ie=Lt({graph:e,rootId:n,included:Ve,options:t,registry:c,edgeLimit:i,tokenBudget:s,initialTokens:O.usedTokens}),{edges:X,usedTokens:Ye}=ie,j=k+D.length,q=j<g.length,se=D.at(-1),V=ie.candidateCount-X.length,ce=m.depthTruncated||q||V>0,Je={rootId:n,...a.status===void 0?{}:{rootStatus:a.status},..._,discoveredNodes:g.length,returnedNodes:D.length,returnedEdges:X.length,omittedNodes:g.length-j,omittedEdges:V,evidenceCount:p.length,hasMore:q};return{root:a,summary:Je,nodes:D,edges:X,evidence:p,meta:{exact:!0,truncated:ce,completeness:ce?"truncated":"complete",nodeLimit:r,edgeLimit:i,tokenBudget:s,usedTokens:Ye,visitedNodes:m.visitedNodes,inspectedEdges:m.inspectedEdges,omittedNodes:g.length-j,omittedEdges:V,...q&&se?{nextCursor:ke(h,se.id,j-1)}:{}}}}var St=["tree","graph","context"],Ot=["none","repeated"],Dt=["outgoing","incoming","both"],At=32,Nt=200,Mt=400,$t=16e3;function Bt(e){let n=e?.trim().toLowerCase()??"tree";if(St.includes(n))return n;throw new w(`Invalid --format value "${e}". Use "tree", "graph", or "context".`,x.USAGE)}function S(e,n){if(e===void 0)return;let o=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(o)||o<1)throw new w(`Invalid --${n} value "${e}". Use a positive integer.`,x.USAGE);return o}function Fe(e){if(e===void 0)return;let n=typeof e=="number"?e:Number(e.trim());if(!Number.isInteger(n)||n<0)throw new w(`Invalid --max-depth value "${e}". Use a non-negative integer.`,x.USAGE);return n}function Pt(e){let n=e?.trim().toLowerCase()??"none";if(Ot.includes(n))return n;throw new w(`Invalid --collapse value "${e}". Use "none" or "repeated".`,x.USAGE)}function Ut(e){let n=e?.trim().toLowerCase()??"both";if(Dt.includes(n))return n;throw new w(`Invalid --direction value "${e}". Use "outgoing", "incoming", or "both".`,x.USAGE)}function jt(e,n=E()){if(e===void 0)return;let o=(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0);if(o.length===0)return;let t=new Set;for(let r of o){let i=n.resolve(r);if(!i){let s=n.list().map(c=>c.kind).join(", ");throw new w(`Invalid --kind value "${r}". Registered kinds: ${s}.`,x.USAGE)}t.add(i.kind)}return[...t].sort()}function Ft(e){if(!e||e.length===0)return[];let n=e.map(({id:t,kind:r})=>({id:t.trim(),kind:r.trim().toLowerCase()})).sort((t,r)=>{let i=t.kind.localeCompare(r.kind);return i!==0?i:t.id.localeCompare(r.id)}),o=new Map;for(let t of n){let r=`${t.kind.toLowerCase()}::${t.id.toLowerCase()}`;o.has(r)||o.set(r,{id:t.id,kind:t.kind})}return[...o.values()]}function Gt(e){return{id:e.id,title:e.title,type:e.type,status:e.status,dependencies:Ft(e.dependencies)}}function zt(e){return A(new TextEncoder().encode(JSON.stringify({...e,dependencies:void 0})).byteLength)}function Kt(e,n,o,t,r,i,s,c,d){for(let u of n.dependencies){let l=Math.max(1,Math.ceil(JSON.stringify({from:e.id,to:u.id,kind:u.kind}).length/3));if(c.nodes>=c.nodeLimit){e.truncated=!0,c.reasons.add("node_limit");break}if(c.edges>=c.edgeLimit){e.truncated=!0,c.reasons.add("edge_limit");break}if(c.estimatedTokens+l>=c.tokenBudget){e.truncated=!0,c.reasons.add("token_budget");break}c.edges+=1,c.estimatedTokens+=l,e.dependencies.push(Ge(u.id,o,t,r,i,s,c,d+1,u.kind))}}function Ht(e,n,o,t,r,i,s,c){return s.estimatedTokens>=s.tokenBudget&&n?.dependencies.length?(e.truncated=!0,s.reasons.add("token_budget"),!0):!n||e.cycle?!0:t!==void 0&&c>=t?(n.dependencies.length>0&&(e.truncated=!0,s.reasons.add("max_depth")),!0):r==="repeated"&&i.has(o)?(e.collapsed=!0,!0):!1}function Ge(e,n,o,t,r,i,s,c=0,d){let u=e.trim().toLowerCase(),l=n.get(u),a={id:l?.id??e,title:l?.title,type:l?.type,status:l?.status,via:d,missing:!l,cycle:o.has(u),dependencies:[]};if(s.nodes+=1,s.estimatedTokens+=zt(a),Ht(a,l,u,t,r,i,s,c))return a;r==="repeated"&&i.add(u);let p=new Set(o);return p.add(u),Kt(a,l,n,p,t,r,i,s,c),a}function je(e,n){return!e||e.missing&&!n.missing?n:{...e,title:e.title??n.title,type:e.type??n.type,status:e.status??n.status}}function Wt(e){let n=new Map,o=new Map,t=[e];for(;t.length>0;){let c=t.pop();n.set(c.id,je(n.get(c.id),{id:c.id,title:c.title,type:c.type,status:c.status,missing:c.missing}));for(let d of c.dependencies){n.set(d.id,je(n.get(d.id),{id:d.id,title:d.title,type:d.type,status:d.status,missing:d.missing}));let u=d.via??"related",l=`${c.id}::${d.id}::${u}`;o.has(l)||o.set(l,{from:c.id,to:d.id,kind:u}),d.cycle||t.push(d)}}let r=[...n.values()].sort((c,d)=>c.id.localeCompare(d.id)),i=[...o.values()].sort((c,d)=>{let u=c.from.localeCompare(d.from);if(u!==0)return u;let l=c.to.localeCompare(d.to);return l!==0?l:c.kind.localeCompare(d.kind)}),s=r.filter(c=>c.missing).map(c=>c.id);return{root_id:e.id,nodes:r,edges:i,missing_ids:s}}function ze(e,n,o){let t=new Set,r=new Set,i=new Set,s=new Set,c=[{id:e,depth:0}],d=0;for(;d<c.length;){let u=c[d++],l=u.id.trim().toLowerCase();t.add(l);let a=n.get(l);if(!a){i.add(l);continue}if(!(o!==void 0&&u.depth>=o)&&!s.has(l)){s.add(l);for(let p of a.dependencies)r.add(`${l}::${p.id.trim().toLowerCase()}::${p.kind}`),c.push({id:p.id,depth:u.depth+1})}}return{node_count:t.size,edge_count:r.size,edge_basis:"deduplicated_directed",missing_count:i.size}}function Xt(e,n=E()){let o=Fe(e.maxDepth),t=S(e.nodeLimit,"node-limit"),r=S(e.edgeLimit,"edge-limit"),i=S(e.tokenBudget,"token-budget"),s=jt(e.kind,n);return{direction:Ut(e.direction),...s===void 0?{}:{kinds:s},...o===void 0?{}:{maxDepth:o},...t===void 0?{}:{nodeLimit:t},...r===void 0?{}:{edgeLimit:r},...i===void 0?{}:{tokenBudget:i},...e.cursor?.trim()?{cursor:e.cursor.trim()}:{}}}function qt(e,n,o,t){return Ue(e.graph,n,e.details.map(r=>r.id===n&&t.length>0?{...r,evidence:t}:r),o)}function oe(e,n,o,t){for(let r of o.slice(0,t)){let i=r?.trim();i&&e.push(`${n}:${i}`)}}async function Vt(e,n,o,t){let r=await Ie(e,n,o.id_prefix,o.item_format,t);if(!r)return[];let{document:i}=await Te(r,{schema:o.schema}),s=i.metadata,c=s.files??[],d=s.tests??[],u=s.docs??[],l=[["files",c.length],["tests",d.length],["docs",u.length],["comments",(s.comments??[]).length],["notes",(s.notes??[]).length],["learnings",(s.learnings??[]).length]];if(l.every(([,p])=>p===0))return[];let a=[`linked:${l.map(([p,m])=>`${p}=${m}`).join(",")}`];return oe(a,"file",c.map(p=>p.path),3),oe(a,"test",d.map(p=>p.command??p.path),2),oe(a,"doc",u.map(p=>p.path),2),a}function Yt(e){let{canonicalId:n,context:o,missingCount:t,missingReferences:r,referenceLimit:i,summaryOnly:s}=e;return{id:n,format:"context",node_count:o.nodes.length+1,edge_count:o.edges.length,edge_basis:"deduplicated_directed",missing_count:t,missing_scope:"traversal",missing_reference_count:r.length,...s?{}:{missing_references:r.slice(0,i),context:o}}}function Jt(e){let{row:n,missingReachableSet:o,packetIds:t,filteredKinds:r,registry:i}=e;if(n.no_active_blocker_sentinel||!o.has(n.target_id.trim().toLowerCase())||!t.has(n.holder_id))return!1;if(r===void 0)return!0;let s=i.resolve(n.kind);return s!==void 0&&(r.has(s.kind)||s.inverse!==void 0&&r.has(s.inverse))}function Ke(e,n){let o=fe(),t=n.commandOptionsOverride??(o?.command==="deps"?o.options:n.commandOptions);return xe("deps",{...t,...n.global,resolvedOutputFormat:n.format},e)}function re(e,n){let o=Ke(e,n),t=r=>Ce(r,n.format,n.global.lean===!0);return t(n.global.tokenAccounting===!0?ve(o,t):o)}function He(e,n,o){let t;for(;;){let r=A(new TextEncoder().encode(re(e,n)).byteLength);if(r===t)return r;o(r),t=r}}function We(e){return e instanceof TypeError&&e.message.startsWith("Relationship context tokenBudget cannot fit ")}function Xe(e){let{assembly:n,canonicalId:o,contextOptions:t,rootEvidence:r,summaryOnly:i,rendering:s,missingCount:c,missingReferences:d}=e,u=t.edgeLimit??40,l=Math.min(u,d.length),a=t.tokenBudget,p;for(;;){let m=qt(n,o,{...t,...a===void 0?{}:{tokenBudget:a}},r);p??=m.meta.tokenBudget,a??=p;let f=Yt({canonicalId:o,context:m,missingCount:c,missingReferences:d,referenceLimit:l,summaryOnly:i});if(i){if(A(new TextEncoder().encode(re(b(f,!0,s.legacyAliasCounts),s)).byteLength)>p)throw new TypeError("Relationship context tokenBudget cannot fit the rendered summary");return f}if(m.meta.tokenBudget=p,m.meta.usedTokens=He(b(f,!1,s.legacyAliasCounts),s,h=>{m.meta.usedTokens=h}),m.meta.usedTokens<=p)return f;if(l>0){l-=1;continue}let _=a,g=_*p/m.meta.usedTokens;a=Math.min(_-1,Math.max(1,Math.floor(g*.9)))}}function qe(e,n){let o=e.contextOptions,t={...e.rendering.global,outputFormat:e.rendering.format},r=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","context","--output-format",e.rendering.format,"--token-budget"],i=r.length;r.push(String(n));let s=new Set(["--pm-path","--format","--output-format","--token-budget"]),c={format:"context",tokenBudget:n,kind:o.kinds},d=[["--max-depth","maxDepth",o.maxDepth],["--node-limit","nodeLimit",o.nodeLimit],["--edge-limit","edgeLimit",o.edgeLimit],["--direction","direction",o.direction],["--cursor","cursor",o.cursor],["--output-include","outputInclude",t.outputInclude],["--output-limit","outputLimit",t.outputLimit],["--output-budget","outputBudget",t.outputBudget],["--output-session","outputSession",t.outputSession],["--output-cursor","outputCursor",t.outputCursor]];for(let[a,p,m]of d)m!==void 0&&(r.push(a,String(m)),s.add(a),c[p]=m);for(let a of o.kinds??[])r.push("--kind",a),s.add("--kind");let u=[["--summary","summary",e.summaryOnly],["--full","full",e.rendering.commandOptions.full],["--json","json",t.json],["--lean","lean",t.lean],["--output-row-contract","outputRowContract",t.outputRowContract],["--token-accounting","tokenAccounting",t.tokenAccounting],["--no-extensions","noExtensions",t.noExtensions],["--no-pager","noPager",t.noPager]];for(let[a,p,m]of u)m===!0&&(r.push(a),s.add(a),c[p]=!0);let l=ge.find(a=>a.command==="deps");return Reflect.set(c,me,{canonical_include_modes:[],cli_invocation_observed:!0,explicit_legacy_aliases:Object.values(l.dimensions).flatMap(a=>a.legacy_aliases.flatMap(p=>s.has(p.flag)?[p.flag]:[]))}),he("deps",c),Y(c.summary===!0,c.full===!0,"--summary"),t.outputInclude=c.outputInclude,{args:r,budgetIndex:i,summaryOnly:c.summary===!0,rendering:{...e.rendering,global:t,commandOptionsOverride:c}}}function Qt(e,n,o){let t={...n.rendering,commandOptionsOverride:{...n.rendering.commandOptionsOverride,tokenBudget:o}},r;try{r=Xe({...e,contextOptions:{...e.contextOptions,tokenBudget:o},summaryOnly:n.summaryOnly,rootEvidence:n.summaryOnly?[]:e.rootEvidence,rendering:t})}catch(s){if(!We(s))throw s;return"native_floor"}let i=Ke(b(r,n.summaryOnly,t.legacyAliasCounts),t);return _e(i)?"output_constraints":"fits"}async function Zt(e,n){let o=e.contextOptions.tokenBudget??U,t=qe(e,o),i=(t.summaryOnly?1:1+Math.min(e.contextOptions.edgeLimit??40,e.missingReferences.length))*(e.assembly.details.reduce((p,m)=>p+m.id.length+m.title.length+m.status.length+(m.type?.length??0),e.assembly.graph.edges().length+e.missingReferences.length)+(t.summaryOnly?[]:e.rootEvidence).reduce((p,m)=>p+m.length,0)),{findContextBudgetRecovery:s}=await import("./context-budget-recovery-CSJV3TY3.js"),c=s({requested:o,initialBudget:U,workUnits:i,probe:p=>Qt(e,t,p)}),d=["--pm-path",e.pmRoot,"item","deps",e.canonicalId,"--format","tree","--summary"],u=F(d),l=c.feasible_tokens===null?d:[...t.args];c.feasible_tokens!==null&&(l[t.budgetIndex]=String(c.feasible_tokens));let a=F(l);return Se("Relationship context tokenBudget cannot fit the required rendered packet",{exitCode:x.USAGE,cause:n,context:{code:"invalid_argument_value",field:"tokenBudget",value:String(o),required:c.feasible_tokens===null?"Inspect the compact summary and review the output constraints.":"Retry the preserved context query with --token-budget "+c.feasible_tokens+".",why:"Budget advice is verified against the current query. A minimum is reported only after every smaller positive budget is checked.",examples:[a,u],nextSteps:[a],recovery:{recovery_mode:"compact",suggested_flags:["--token-budget"],token_budget:c,suggested_retry_args:l,suggested_retry:a,next_best_command:u,fallback_candidates:[{source:"relationship_summary",command:u,reason:"Inspect bounded counts separately from context rows."}]}}})}async function en(e){let{pmRoot:n,assembly:o,canonicalId:t,options:r,rootEvidence:i,summaryOnly:s,rendering:c}=e,d=Xt(r,o.graph.registry()),u=o.graph.closure(t,{direction:d.direction,...d.kinds===void 0?{}:{kinds:d.kinds},maxDepth:d.maxDepth??3}),l=u.value.filter(h=>o.missingIdSet.has(h.toLowerCase())),a=new Set(l.map(h=>h.toLowerCase())),p=o.graph.registry(),m=d.kinds?new Set(d.kinds.map(h=>p.require(h).kind)):void 0,f=new Set([t,...u.value]),_=[...o.dangling.active,...o.dangling.legacy_terminal].filter(h=>Jt({row:h,missingReachableSet:a,packetIds:f,filteredKinds:m,registry:p})),g={pmRoot:n,assembly:o,canonicalId:t,contextOptions:d,rootEvidence:i,summaryOnly:s,rendering:c,missingCount:l.length,missingReferences:_};try{return Xe(g)}catch(h){if(h instanceof w&&h.code==="invalid_query_cursor"){let k=qe({...g,contextOptions:{...d,cursor:void 0},rendering:{...c,global:{...c.global,outputCursor:void 0}}},d.tokenBudget??U),y=F(k.args);throw new w(h.message,h.exitCode,{...h.context,nextSteps:[...h.context.nextSteps,y],recovery:{suggested_retry:y,suggested_retry_args:k.args}})}throw We(h)?await Zt(g,h):h}}function tn(e){let n=[e],o;for(;n.length>0;){let t=n.pop();t.dependencies.length>0&&(o=t,n.push(...t.dependencies))}return o?(o.dependencies.pop(),o.truncated=!0,!0):!1}function nn(e,n,o,t,r,i,s){let c=r??At,d=S(o.nodeLimit,"node-limit")??Nt,u=S(o.edgeLimit,"edge-limit")??Mt,l=S(o.tokenBudget,"token-budget")??$t,a={nodeLimit:d,edgeLimit:u,tokenBudget:l,nodes:0,edges:0,estimatedTokens:0,reasons:new Set},p=Ge(e,t,new Set,c,n==="graph"?"repeated":i,new Set,a),m=ze(e,t,void 0),f;for(;;){let _=Wt(p),g=a.reasons.size===0?void 0:{reasons:[...a.reasons].sort(),limits:{max_depth:c,node_limit:d,edge_limit:u,token_budget:l},estimated_tokens:0,total_node_count:m.node_count,total_edge_count:m.edge_count,omitted_node_count:Math.max(0,m.node_count-_.nodes.length),omitted_edge_count:Math.max(0,m.edge_count-_.edges.length)},h={id:e,format:n,node_count:_.nodes.length,edge_count:_.edges.length,edge_basis:"deduplicated_directed",missing_count:_.missing_ids.length,...g?{truncation:g}:{}};if(f=n==="tree"?{...h,tree:p}:{...h,graph:_},(f.truncation===void 0?A(new TextEncoder().encode(re(b(f,!1,s.legacyAliasCounts),s)).byteLength):He(b(f,!1,s.legacyAliasCounts),s,y=>{f.truncation.estimated_tokens=y}))<=l)return f;if(!tn(p))return a.reasons.add("token_budget"),f;a.reasons.add("token_budget")}}function b(e,n,o={}){let t={name:e.format==="tree"?"dependency_tree":e.format==="graph"?"dependency_graph":"relationship_context",restore_with:"--full"},r=e.context?.meta.truncated?[{name:"relationship_context_bounds",restore_with:"--token-budget <n> --node-limit <n> --edge-limit <n> --max-depth <n>"}]:[];return{...e,legacy_alias_counts:o,projection:{mode:n?"summary":"full",declared_field_groups:[t,...r],included_field_groups:n?[]:[t.name]}}}async function ro(e,n,o){let t=ue(process.cwd(),o.path);await Re(t);let r=Bt(n.format),i=Fe(n.maxDepth),s=Pt(n.collapse);Y(n.summary===!0,n.full===!0,"--summary");let c=n.summary===!0,d=await be(t),u=ae(d,z()),l=await Le(t,d.item_format,u.type_to_folder,void 0,d.schema),a=pe(d.schema),p=new Map(l.map(g=>[g.id.trim().toLowerCase(),Gt(g)])),m=Z(l,g=>G(g,a));for(let g of[...m.active,...m.legacy_terminal]){let h=p.get(g.holder_id.trim().toLowerCase()),k=g.kind.trim().toLowerCase();h&&!h.dependencies.some(y=>y.id.trim().toLowerCase()===g.target_id.trim().toLowerCase()&&y.kind===k)&&h.dependencies.push({id:g.target_id,kind:k})}if(!p.has(e.trim().toLowerCase()))throw new w(`Item ${e} not found`,x.NOT_FOUND);let f=o.outputFormat??(o.json===!0||o.json===void 0&&o.defaultOutputFormat==="json"?"json":"toon");if(r==="context"){let g=p.get(e.trim().toLowerCase()).id,h=c?[]:await Vt(t,g,d,u.type_to_folder),k=O=>G(O,a),y=v(),C=Pe().lookup(t,$e(l,k,y),()=>ee(l,k,y));return b(await en({pmRoot:t,assembly:C.assembly,canonicalId:g,options:n,rootEvidence:h,summaryOnly:c,rendering:{format:f,global:o,commandOptions:n,legacyAliasCounts:C.assembly.legacyAliasCounts}}),c,C.assembly.legacyAliasCounts)}let _=Object.fromEntries(Object.entries(ee(l,g=>G(g,a)).legacyAliasCounts));return c?b({id:e,format:r,...ze(e,p,i)},!0,_):b(nn(e,r,n,p,i,s,{format:f,global:o,commandOptions:n,legacyAliasCounts:_}),!1,_)}export{hn as a,_n as b,dt as c,v as d,un as e,H as f,ln as g,st as h,pn as i,$ as j,ut as k,pt as l,Z as m,ft as n,En as o,ee as p,$e as q,te as r,Pe as s,Sn as t,U as u,Ue as v,S as w,Fe as x,Ut as y,jt as z,ro as A};
|
|
2
|
+
//# sourceMappingURL=chunk-42SU4LK3.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as W,c as j}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as W,c as j}from"./chunk-NO5MUY4I.js";import{jb as V}from"./chunk-NZA2LP4Y.js";import{D as $,E as D,K as q,U as G}from"./chunk-TSZVCALS.js";import{r as F}from"./chunk-2CQFGJQ6.js";import{Sd as U,ed as A,ia as R,kd as f,ld as T,md as _,nd as b,od as N,ra as y,rd as O,sc as S,sd as k,td as H,ud as L,vd as M,wd as P,xd as l}from"./chunk-BPBKHY6H.js";import{D as E,E as C}from"./chunk-TX24L7RQ.js";import{g as v,n as w,t as I}from"./chunk-26P6C6OO.js";import{A as d,y as g,z as m}from"./chunk-IRYNVGKH.js";var B="item_revision_conflict",ee=10,J=/^[0-9a-f]{64}$/u;function p(e,n){return new d(`Invalid expected revision ${JSON.stringify(e)}: ${n}.`,m.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 K(e){let n=typeof e=="string"?e.trim().toLowerCase():"";if(!J.test(n))throw p(String(e),"the revision is not a 64-character hexadecimal item_hash");return n}function te(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw p(String(t),"expected a string");let i=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(i.length===0)throw p(t,"the value is empty");let r=o=>C(t)===t?o:E;return i.map(o=>{let c=o.lastIndexOf("="),s=c===-1?void 0:o.slice(0,c).trim();if(s!==void 0&&s.length===0)throw p(r(o),"the item id before = is empty");let a=c===-1?o:o.slice(c+1);if(!J.test(a.trim().toLowerCase()))throw p(r(a),"the revision is not a 64-character hexadecimal item_hash");let h=K(a);return s===void 0?{itemHash:h}:{id:s,itemHash:h}})})}async function X(e,n){let t=await F(e),i=v(t,U()).type_to_folder,r=await $(e,n,t.id_prefix,t.item_format,i);if(r){let{document:o}=await D(r,{schema:t.schema});if(o.metadata.id!==await j(r.itemPath,r.id))throw new d(`Item file ${r.id} embeds the id ${o.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,m.CONFLICT,{code:"item_identity_conflict",item_id:r.id,required:`Repair ${r.id}'s identity first (pm validate reports it; pm restore ${r.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:o.metadata.id,document:o}}try{return{id:(await W(e,n,t,i)).id,document:g}}catch{throw await q(e,n,t.id_prefix,i)}}function x(e){return w(e.cwd??process.cwd(),e.pmRoot)}async function Te(e,n={}){let t=await X(x(n),e);return{id:t.id,item_hash:A(t.document)}}async function Y(e,n,t){let i=[];for(let r of n){let o=r.id??t;if(o===void 0||o.trim().length===0)throw new d("A bare expected revision needs an item to bind to.",m.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 X(e,o)).id,itemHash:r.itemHash})}return i}function ie(e){return[...new Set(e.patch.map(n=>{let t=n.path.split("/");return String(t[1]==="metadata"?t[2]:t[1])}))].sort()}async function ne(e,n,t){let i;try{i=await S(I(e,n),n)}catch{return}let r=-1;for(let s=i.length-1;s>=0;s-=1){let a=i[s];if(a.after_hash===t){r=s+1;break}if(a.before_hash===t){r=s;break}}if(r===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let o=i.slice(r),c=o.slice(-ee);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ie(s)})),changes_since_omitted:o.length-c.length}}async function be(e,n){if(!u(e))return{};let t=await Q(e,n);return{error_code:B,expected_revision:String(t.context.expected_revision),current_revision:String(t.context.current_revision),details:t.context.details}}function u(e){return G(e)&&e.context.code===B}function Ne(e){let n=e.find(t=>u(t));if(n!==void 0)throw n}function Oe(){return new d("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",m.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 oe(e,n){if(n===void 0||!u(e)||typeof e.context.item_id!="string"||M(e))return e;let t=e.context.reason===k;if(!t&&e.context.reason!==O)return e;let i=P(l(e,new d(e.message,e.exitCode,{...e.context,...H(e.context.item_id,t,n)})));return i.stack=e.stack,i}async function Q(e,n,t){if(!L(e,n))return e;let i=oe(e,t);if(!u(i)||i.context.details!==void 0)return i;let r=i.context.item_id,o=i.context.expected_revision;if(typeof r!="string"||typeof o!="string")return i;let c;try{c=await ne(n,r,o)}catch{return i}if(c===void 0)return i;let s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(h=>({ts:h.ts,op:h.op,author:h.author,fields:[...h.fields]})),changes_since_omitted:c.changes_since_omitted},a=l(i,new d(i.message,i.exitCode,{...i.context,details:s}));return a.stack=i.stack,a}async function Z(e,n,t){try{return{result:await T(e,n),...b(e)}}catch(i){throw e.pmRoot===void 0?i:await Q(i,e.pmRoot,t)}}function re(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",x(e)]}}async function ke(e,n,t={}){return Z(await se(e,t),n,re(t))}async function se(e,n={}){let t=x(n),i=e.map(({id:o,itemHash:c})=>({id:o,itemHash:K(c)})),r=f();return _(r,t,await Y(t,i)),r}function He(e){let n=N(e);return n===void 0||n.length>0}function ce(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var z=new Set(R);function ae(e,n={}){let t=e.trim().replace(/\s+/gu,"-"),i=z.has(t)?t:e;if(z.has(i)&&(!V(i)||i==="deps")&&!y.has(i))throw de(i);if((i==="test"||i==="test-all")&&n.background===!0)throw new d(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,m.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 de(e){return new d(`--expect-hash guards item writes, and ${e} is not a mutation.`,m.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function he(e,n){if(n.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let t=e,i=Array.isArray(t.warnings)?t.warnings:[];return{...t,warnings:[...i,...n.map(ce)]}}async function Le(e){let n=e.expectHash;if(n!==void 0&&typeof n!="string"&&!(Array.isArray(n)&&n.every(o=>typeof o=="string")))throw p(JSON.stringify(n)??String(n),"expected a string or an array of strings");let t=te(n);if(t.length===0)return e.run();ae(e.action,{background:e.background===!0||e.options?.background===!0});let i=f();_(i,e.pmRoot,await Y(e.pmRoot,t,e.defaultId));let r=await Z(i,e.run,e.invocation);return he(r.result,r.unchecked)}export{B as a,ee as b,K as c,te as d,Te as e,Y as f,ne as g,be as h,u as i,Ne as j,Oe as k,oe as l,Q as m,Z as n,ke as o,se as p,He as q,ce as r,ae as s,de as t,Le as u};
|
|
2
|
+
//# sourceMappingURL=chunk-5NSWNLFE.js.map
|