@unbrained/pm-cli 2026.11.26 → 2026.11.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-BITDGTAX.js → chunk-2YD2AERA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-54AQJTUH.js +3 -0
- package/dist/cli-bundle/chunks/chunk-56DKWGHE.js +2 -0
- package/dist/cli-bundle/chunks/chunk-56GUDMXN.js +113 -0
- package/dist/cli-bundle/chunks/chunk-5ECCMDSU.js +2 -0
- package/dist/cli-bundle/chunks/chunk-6RBD2AKU.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-PQSEEVOA.js → chunk-C4O5TZY3.js} +46 -46
- package/dist/cli-bundle/chunks/chunk-CATRDGAB.js +125 -0
- package/dist/cli-bundle/chunks/{chunk-5FY2VHRF.js → chunk-CDUV7DFD.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-CTM26LUE.js +4 -0
- package/dist/cli-bundle/chunks/chunk-D3I5AHNN.js +2 -0
- package/dist/cli-bundle/chunks/chunk-E2LQ6LCJ.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-B2GM6KOM.js → chunk-FG4TNQQM.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-JQYPSABI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-LMDIKSDZ.js +9 -0
- package/dist/cli-bundle/chunks/chunk-LRGYV6QQ.js +2 -0
- package/dist/cli-bundle/chunks/chunk-MO6PPUI6.js +2 -0
- package/dist/cli-bundle/chunks/chunk-O2SWNEBW.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-5AAIRHNE.js → chunk-O2WNNIKK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LNZKNVMT.js → chunk-OFIYA3PI.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-DYL2N3OC.js → chunk-Q6BGQRCB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-RGE3XW3A.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SP6CDM6B.js +31 -0
- package/dist/cli-bundle/chunks/{chunk-T3GJPXIZ.js → chunk-T7RZPIOB.js} +14 -14
- package/dist/cli-bundle/chunks/{chunk-MNFCJNQA.js → chunk-T7UTG56V.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-TWRUA2NH.js +3 -0
- package/dist/cli-bundle/chunks/chunk-WKDKBS4P.js +4 -0
- package/dist/cli-bundle/chunks/chunk-YEMFOKFG.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZDL45VTB.js → chunk-YLS2N4SN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FWBR3OW7.js → chunk-ZXERHBMA.js} +2 -2
- package/dist/cli-bundle/chunks/field-definition-losses-JFMMMVTV.js +2 -0
- package/dist/cli-bundle/chunks/field-option-collisions-G4LQ2646.js +2 -0
- package/dist/cli-bundle/{focused-chunks/item-revision-RPTXN7WW.js → chunks/item-revision-O7L3AA2W.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-4XC74ULD.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-A45DFDEO.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-SIUIMAEO.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-EKSCZWEZ.js → register-list-query-FCPGG2UT.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-ZIAOKKUJ.js → register-mutation-VD3JX23I.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-KHJD4GFZ.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-EWAZZWPL.js +2 -0
- package/dist/cli-bundle/chunks/runtime-schema-3RAXYNG5.js +2 -0
- package/dist/cli-bundle/chunks/{settlement-hook-ESAAEBRM.js → settlement-hook-KWBOSRDZ.js} +2 -2
- package/dist/cli-bundle/chunks/stage-UIDZMTE5.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-5MZXU6HB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-64DSKZJN.js +100 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YSZZSV6M.js → chunk-7EKKUYN5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7P6OGPEG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-A5B43EWU.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-AHCOSTL7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-CQLOYNJY.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-E4C6T3NL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-3GQRWIT5.js → chunk-HCWDMFWA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GQBWI4KA.js → chunk-J4V3J5MC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-JD45Y2BR.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-KMGI5GZP.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-MSLRDKWL.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-O33WUEAF.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-QNWNUQSJ.js → chunk-OEMI52ZS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-AAB3ZR7Z.js → chunk-Q6JCMFGU.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-RBOWKXFV.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-TF57RHS2.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TNVLDU7Z.js → chunk-VNU3IFBL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-X5ZVPFK7.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-XVCMYFQU.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RDELKGLS.js → chunk-Y7EC2L2G.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-FQWKESMI.js → chunk-YC3PFFDE.js} +56 -56
- package/dist/cli-bundle/focused-chunks/{chunk-QSRXF6XS.js → chunk-YX75PQFO.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KEZ4VXYD.js → chunk-Z4FWJGQG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZHHFOQSL.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZUAPUBJK.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-NXUFVQ33.js → chunk-ZYHGQIQ7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/field-definition-losses-NUZO3JCP.js +2 -0
- package/dist/cli-bundle/focused-chunks/field-option-collisions-63YQ2J3N.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-revision-PV5O6F5Y.js +2 -0
- package/dist/cli-bundle/focused-chunks/item-transaction-S5QXBGAT.js +2 -0
- package/dist/cli-bundle/{chunks/mutation-actor-HGG47KXV.js → focused-chunks/mutation-actor-2AAUJG2Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-X7HHNERR.js +2 -0
- package/dist/cli-bundle/focused-chunks/runtime-schema-5J2ONRNV.js +2 -0
- package/dist/cli-bundle/focused-chunks/stage-56RYPMBK.js +2 -0
- package/dist/cli-bundle/main.js +2 -2
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +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 +2 -2
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/item-fields.d.ts +15 -1
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/schema/runtime-schema.d.ts +20 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/shared/command-line.d.ts +2 -2
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
- package/dist/sdk/extension/command-options.d.ts +8 -0
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/profile.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/schema/field-definition-losses.js +2 -0
- package/dist/sdk/schema/field-option-collisions.js +1 -1
- package/dist/sdk/schema.js +2 -2
- package/docs/COMMANDS.md +1 -1
- package/docs/CONFIGURATION.md +3 -1
- package/docs/EXTENSIONS.md +1 -1
- package/docs/MUTATION_INTEGRITY.md +47 -0
- package/docs/SDK.md +3 -1
- package/docs/SDK_AUDITED_MUTATIONS.md +12 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-5BPDT7G2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-7F3UFYZA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CBBKXTJG.js +0 -2
- package/dist/cli-bundle/chunks/chunk-DUJSME77.js +0 -3
- package/dist/cli-bundle/chunks/chunk-GQXK4KKH.js +0 -31
- package/dist/cli-bundle/chunks/chunk-HOLQZ56F.js +0 -8
- package/dist/cli-bundle/chunks/chunk-HTGN24XM.js +0 -3
- package/dist/cli-bundle/chunks/chunk-IGW3RVJC.js +0 -3
- package/dist/cli-bundle/chunks/chunk-KCRRTJ4X.js +0 -125
- package/dist/cli-bundle/chunks/chunk-KES4VHU4.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NDS4MXZX.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QMM46SJM.js +0 -4
- package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +0 -3
- package/dist/cli-bundle/chunks/chunk-WZOJSHJT.js +0 -113
- package/dist/cli-bundle/chunks/chunk-XRCE4QNL.js +0 -9
- package/dist/cli-bundle/chunks/field-option-collisions-CGRJEAPQ.js +0 -2
- package/dist/cli-bundle/chunks/item-revision-FGDR5NSF.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-LLHIRY6O.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-ECVBZ5FM.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-3QYD5H4H.js +0 -2
- package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +0 -2
- package/dist/cli-bundle/chunks/stage-RSCSUYEJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3BR5NWQI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-AVLB4L7M.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-FW5Q26HA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IWEGGRRD.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-JUG3BAZZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-NSFS3VWP.js +0 -100
- package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-R6QFPHWW.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-RFJ3MEFP.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-RMJKVQYE.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-UA2JNKMY.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-VV2QF5IE.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-WHHFPATO.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-YNRW2FWB.js +0 -2
- package/dist/cli-bundle/focused-chunks/field-option-collisions-WV6GPYYP.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-A6MVNPT7.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-6ZVW6OME.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-2DA4CINP.js +0 -2
- package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +0 -2
- package/dist/cli-bundle/focused-chunks/stage-RG3PKST7.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{E as u,nb as h}from"./chunk-J4V3J5MC.js";import{M as r,N as A,R as F,S as w}from"./chunk-O33WUEAF.js";import{D as y,O as k,Y as d}from"./chunk-X5ZVPFK7.js";import{A as f,m as _,z as c}from"./chunk-NGFDPEP7.js";function S(e){return e.trim().toLowerCase().replace(/^-+/u,"")}function v(e){let n=S(e),i=w({key:n,cli_flag:n,cli_aliases:[]});return[...new Set([...i,F(n)])]}var $=new Set(_.filter(e=>!y.has(e))),E={flag:"--help",short:"-h"},C=new Map;function b(e){let n=C.get(e);if(n===void 0){let i=new Map,o=new Map;for(let l of[...h(e),...u,E]){for(let t of[l.flag,...l.aliases??[]].flatMap(v))i.has(t)||i.set(t,l.flag);l.short!==void 0&&!o.has(l.short)&&o.set(l.short,l.flag)}n={long:i,short:o},C.set(e,n)}return n}function D(e,n){return r(e)?n.short.get(e.trim()):v(e).map(i=>n.long.get(i)).find(i=>i!==void 0)}function p(e){let n=[];for(let i of e){let o=a=>r(a)?a.trim():S(a),l=[...new Set([i.cli_flag,...i.cli_aliases].map(o))],t=o(i.key);for(let a of i.commands)n.push(...T(i.key,l,l.includes(t)?void 0:t,a.replaceAll("_","-")))}return n.sort((i,o)=>i.field.localeCompare(o.field)||i.command.localeCompare(o.command)||i.option.localeCompare(o.option))}function T(e,n,i,o){let l=b(o),t=new Map;for(let a of i===void 0?n:[...n,i]){if($.has(e)&&a.replaceAll("-","_")===e)continue;let s=D(a,l);s===void 0||t.has(s)||a===i&&s===E.flag||t.set(s,{field:e,command:o,field_flag:r(a)?a:`--${a.replaceAll("_","-")}`,option:s})}return[...t.values()]}function I(e){return p([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases,commands:e.commands}])}function g(e){return e.flatMap(n=>[...new Set([n.cli_flag,...n.cli_aliases])].flatMap(i=>{let o=A(i);return o===void 0?[]:[{field:n.key,spelling:i,reason:o}]}))}function M(e,n){return[...O(e.key,n?.cliFlag,n?.aliases),...g([{key:e.key,cli_flag:e.cliFlag??e.key.replaceAll("_","-"),cli_aliases:e.cliAliases}])]}function L(e){return`${JSON.stringify(e.spelling)} ${e.reason}`}function R(e){return`${e.field_flag} shadows built-in ${e.option} on pm ${e.command}`}function q(e,n){let i=d(e).definitions,o=p(i),l=g(i),t=l.length===0?{details:{},warnings:[]}:{details:{schema_field_flag_invalid_count:l.length,schema_field_flag_invalid:l.slice(0,n),schema_field_flag_invalid_truncated:l.length>n,schema_field_flag_invalid_fix_hint:"Re-register the field with one flag and one spelling per alias: pm schema add-field <key> --cli-flag <flag> --alias <alias>. A short alias is one dash and one character. Edit a field defined inline in settings.json there."},warnings:[`validate_schema_field_flag_invalid:${l.length}`]};return o.length===0?t:{details:{...t.details,schema_field_option_collision_count:o.length,schema_field_option_collisions:o.slice(0,n),schema_field_option_collisions_truncated:o.length>n,schema_field_option_collision_fix_hint:"Rename a file-backed field without losing item values: pm schema rename-field <key> --to <new-key>. For a colliding flag, alias or command list, re-register the same key: pm schema add-field <key> --cli-flag <flag> --commands <commands>. Edit a field defined inline in settings.json there."},warnings:[...t.warnings,`validate_schema_field_option_collision:${o.length}`]}}function z(e,n){m(e.key,M(e,n)),x(e.key,e.commands,I(e))}function O(e,n,i){return[n,...Array.isArray(i)?i:[]].filter(o=>typeof o=="string"&&k(o).length===0).map(o=>({field:e,spelling:o,reason:"is empty"}))}function H(e){m(e.key,O(e.key,e.cli_flag,e.cli_aliases));let n=d({fields:[e]}).definitions;m(e.key,g(n)),x(e.key,n.flatMap(i=>i.commands),p(n))}function m(e,n){if(n.length!==0)throw new f(`Cannot define custom field "${e}": flag ${n.map(L).join("; ")}. The command it is registered for could not register it as one option.`,c.USAGE,{code:"schema_field_flag_invalid",field:e,flag:n[0].spelling,required:"Each custom field flag and alias must be one option spelling: a long name without spaces, pipes, commas, '=' or brackets, or a short flag of one dash and one character.",nextSteps:[`Pass one spelling per --alias, for example pm schema add-field ${e} --alias <first> --alias <second>.`]})}function x(e,n,i){if(i.length===0)return;let o={key:e,commands:n},l=new Set(i.map(a=>a.command)),t=o.commands.filter(a=>!l.has(a.replaceAll("_","-")));throw new f(`Cannot define custom field "${o.key}": ${i.map(R).join("; ")}. The built-in option would stop working for that command.`,c.USAGE,{code:"schema_field_option_collision",field:o.key,flag:i[0].option,required:"A custom field's key, flag and aliases must differ from every built-in option of each command it is registered for.",nextSteps:[`Rename the field with a project-specific prefix, for example pm schema add-field project_${o.key}.`,...t.length>0?[`Or register "${o.key}" only where its option is free: --commands ${t.join(",")}.`]:[]]})}export{p as a,I as b,g as c,M as d,L as e,R as f,q as g,z as h,H as i};
|
|
2
|
+
//# sourceMappingURL=chunk-ZUAPUBJK.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{r as D,s as V}from"./chunk-
|
|
1
|
+
import{r as D,s as V}from"./chunk-E4C6T3NL.js";import{d as g,j as q,l as k}from"./chunk-5MZXU6HB.js";import{Mb as N,jf as j,mf as z,pf as M,t as C,y as m}from"./chunk-64DSKZJN.js";import{c as O}from"./chunk-O33WUEAF.js";import{A as x,E as _,I as L,z as S}from"./chunk-NGFDPEP7.js";import{constants as p}from"node:fs";import{lstat as A,mkdir as $,open as P}from"node:fs/promises";import h from"node:path";function E(r,e){if(typeof r!="string"||r.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return r.trim()}function R(r,e){let t=e.require(r.kind),n=t.direction==="undirected"?[r.source,r.target].sort().join("\0"):`${r.source}\0${r.target}`;return`${t.kind}\0${n}`}function Q(r){return Object.freeze({...r,...r.payload===void 0?{}:{payload:Object.freeze(structuredClone(r.payload))}})}function U(r,e,t,n){let i=t.require(r.kind),o=n.outgoingOne.get(`${i.kind}\0${r.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${i.kind}`);let s=n.incomingOne.get(`${i.kind}\0${r.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${i.kind}`);let c=R(r,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function Y(r){let e=new Map;for(let t of r)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function X(r,e,t){if(r.expectedVersion!==void 0&&r.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${r.expectedVersion}, current ${e}`);let n=E(r.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(r.action!=="add"&&r.action!=="remove"&&r.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${r.action}`);if(!Number.isFinite(Date.parse(r.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(r.relationshipId,"relationshipId"),author:E(r.author,"author"),timestamp:new Date(r.timestamp).toISOString()}}function Z(r,e,t,n,i,o){let s=t.has(e);if(r.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(r.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(r.action==="remove")return;if(!r.edge)throw new TypeError(`Relationship ${r.action} event requires an edge`);let c=typeof r.edge.source=="string"?r.edge.source.trim():"",d=typeof r.edge.target=="string"?r.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[r.edge],i).edges()[0];return U(a,e,i,o),Q(a)}var I=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??C()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,i=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(i)||i<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=i)yield Object.freeze(this.#i.slice(o,Math.min(o+i,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let i=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)i=t(i,d),o+=1,s=d;return Object.freeze({state:i,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(R(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(R(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=X(e,this.version,this.#o),n=this.#e.get(t.relationshipId),i=Z(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...i===void 0?{}:{edge:i},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,i),this.#s(t.relationshipId,i)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=Y(t),i=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:i.edges(),graph:i})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=j("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(z(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let i=M(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:i.rows,hasMore:i.has_more,...i.next_cursor?{nextCursor:i.next_cursor}:{}}}},ee="relationship-event-store",W=p.O_NOFOLLOW;function w(r){return N(r,ee,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(r,e="relationships/events.jsonl"){let t=h.resolve(r),n=h.resolve(t,e),i=h.relative(t,n);if(i.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(i===".."||i.startsWith(`..${h.sep}`)||h.isAbsolute(i))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await A(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of i.split(h.sep)){s=h.join(s,c);try{if((await A(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(_(d))break;throw d}}return n}async function y(r,e,t){let n=new I(e,{registry:t}),i,o;try{o=await P(r,p.O_RDONLY|W),i=await o.readFile("utf8")}catch(c){if(_(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=i.split(`
|
|
2
2
|
`);for(let c=0;c<s.length;c+=1){let d=s[c].trim();if(!d)continue;let a;try{a=JSON.parse(d)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(a.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:a.eventId,relationshipId:a.relationshipId,action:a.action,...a.edge===void 0?{}:{edge:a.edge},author:a.author,timestamp:a.timestamp,...a.reason===void 0?{}:{reason:a.reason},expectedVersion:n.version})}return{log:n,raw:i}}function te(r,e,t,n){let i=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new m(t,[e.edge],n).edges()[0]),r.eventId===e.eventId.trim()&&r.relationshipId===e.relationshipId.trim()&&r.action===e.action&&r.author===e.author.trim()&&Number.isFinite(i)&&r.timestamp===new Date(i).toISOString()&&r.reason===(e.reason?.trim()||void 0)&&O(r.edge)===O(o)}var F=class r{#t;#n;#i;#o;#e;constructor(e,t,n,i){this.#t=e.pmRoot,this.#n=t,this.#i=e.registry,this.#o=n,this.#e=i}static async open(e){let t=Object.freeze([...e.nodes]),n=await l(e.pmRoot,e.relativePath),i=await w(e.pmRoot);try{await l(e.pmRoot,n);let{log:o}=await y(n,t,e.registry);return new r(e,t,n,o)}finally{await i()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await w(this.#t);try{let n=await l(this.#t,this.#o),{log:i}=await y(n,this.#n,this.#i),o=i.append(e);await $(h.dirname(n),{recursive:!0}),await l(this.#t,n);let s=await P(n,p.O_APPEND|p.O_CREAT|p.O_WRONLY|W);try{await s.appendFile(`${JSON.stringify(o)}
|
|
3
3
|
`,"utf8")}finally{await s.close()}return this.#e=i,o}finally{await t()}}async appendBatch(e,t={}){let n=await w(this.#t);try{let i=await l(this.#t,this.#o),{log:o,raw:s}=await y(i,this.#n,this.#i),c=o.version,d=new Map(o.events().map(f=>[f.eventId,f])),a=[],T=[];for(let f of e){let u=f.eventId.trim(),v=d.get(u);if(v!==void 0){if(t.existingEventPolicy==="skip_identical"&&te(v,f,this.#n,this.#i)){T.push(v.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${u}`)}let b=o.append(f);d.set(b.eventId,b),a.push(b)}if(a.length>0){let f=s.length===0||s.endsWith(`
|
|
4
4
|
`)?s:`${s}
|
|
5
5
|
`;await $(h.dirname(i),{recursive:!0}),await l(this.#t,i),await L(i,`${f}${a.map(u=>JSON.stringify(u)).join(`
|
|
6
6
|
`)}
|
|
7
7
|
`)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(a),skipped_event_ids:Object.freeze(T)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await w(this.#t);try{let t=await l(this.#t,this.#o);return(await y(t,this.#n,this.#i)).log}finally{await e()}}};function K(r){return[...r].sort().join("\0")}function ne(r,e,t){let n=r.successors.get(e);n?n.push(t):r.successors.set(e,[t]);let i=r.predecessors.get(t);i?i.push(e):r.predecessors.set(t,[e])}function G(r,e,t,n,i){let o=e.resolve(i);if(o?.ordering!==!0)return;let s=q(n),c=s===void 0?void 0:r.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let d=(o.precedence??"source_before_target")==="source_before_target";ne(r,d?t:c,d?c:t)}function ie(r,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=r.filter(i=>typeof i?.id=="string"&&i.id.trim().length>0);for(let i of n){let o=i.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let i of n){let o=i.id.trim();G(t,e,o,i.blocked_by,"blocked_by");for(let s of i.dependencies??[])typeof s!="object"||s===null||G(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let i of[t.successors,t.predecessors])for(let o of i.values())o.sort();return t}function re(r,e){let t=new Set([e]),n=[e];for(;n.length>0;){let i=n.pop();for(let o of[r.successors,r.predecessors])for(let s of o.get(i)??[])t.has(s)||(t.add(s),n.push(s))}return t}function oe(r,e){let t=new Map;for(let n of e){let i=(r.successors.get(n)??[]).filter(o=>e.has(o));i.length>0&&t.set(n,i)}return t}function H(r,e,t){let n=ie(r,e),i=n.canonicalIds.get(t.trim().toLowerCase());if(i===void 0)return{cycles:[],successors:new Map,canonical:t};let o=oe(n,re(n,i));return{cycles:D(o).filter(s=>s.includes(i)),successors:o,canonical:i}}function se(r,e,t){let n=new Set(e),i=n.has(t)?t:e[0];if(r.get(i)?.includes(i))return[i,i];for(let o of r.get(i)??[]){if(!n.has(o))continue;let s=ae(r,n,i,o);if(s)return s}return[...e,e[0]]}function ae(r,e,t,n){let i=[[n]],o=new Set([t,n]);for(;i.length>0;){let s=i.shift(),c=s.at(-1);for(let d of r.get(c)??[]){if(d===t)return[t,...s,t];!e.has(d)||o.has(d)||(o.add(d),i.push([...s,d]))}}}function ve(r,e,t){let n=g(),i=H(r,n,t),o=H(e,n,t),s=new Set(i.cycles.map(K)),c=new Set(k(r,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...k(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${V(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(K(a))).map(a=>`ordering_cycle_created:${se(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}function Ee(r,e){let t=e.resolve(r);return t?.hierarchy===!0||t?.outgoing==="one"||t?.incoming==="one"}function J(r,e,t,n,i){let o=JSON.stringify([e,t,n]),s=r.get(o);s===void 0&&(s={kind:e,direction:t,node_id:n,endpoints:new Set},r.set(o,s)),s.endpoints.add(i)}function B(r,e){let t=new Map;for(let n of r)for(let i of n.dependencies??[]){let o=e.resolve(i.kind);o===void 0||o.hierarchy||(o.outgoing==="one"&&J(t,o.kind,"outgoing",n.id,i.id),o.incoming==="one"&&J(t,o.kind,"incoming",i.id,n.id))}return t}function $e(r,e,t=g()){let n=B(r,t),i=B(e,t);for(let o of[...i.keys()].sort()){let s=i.get(o);if(s.endpoints.size<=1)continue;let c=n.get(o);if(![...s.endpoints].every(d=>c?.endpoints.has(d)))throw new x(`Relationship ${s.kind} permits only one ${s.direction} endpoint for ${s.node_id}.`,S.USAGE,{code:"dependency_cardinality_created",field:"dependencies",value:s.kind,relationship_cardinality:{kind:s.kind,direction:s.direction,node_id:s.node_id,endpoint_ids:[...s.endpoints].sort()},required:"The final dependency set must satisfy the active relationship kind's one-edge cardinality.",nextSteps:["Drop extra --dep seeds, or remove conflicting rows with update --dep-remove before adding another edge.","Choose another kind only when its declared semantics match the intended relationship."]})}}export{I as a,F as b,ve as c,Ee as d,$e as e};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-ZYHGQIQ7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-KMGI5GZP.js";import"./chunk-AHCOSTL7.js";import"./chunk-A5B43EWU.js";import"./chunk-X5ZVPFK7.js";import"./chunk-NGFDPEP7.js";export{a as readFieldsFileDefinitions,b as scanFieldDefinitionLosses};
|
|
2
|
+
//# sourceMappingURL=field-definition-losses-NUZO3JCP.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-ZUAPUBJK.js";import"./chunk-J4V3J5MC.js";import"./chunk-BWOVFE5B.js";import"./chunk-O33WUEAF.js";import"./chunk-X5ZVPFK7.js";import"./chunk-NGFDPEP7.js";export{i as assertFieldDefinitionOptionsAvailable,h as assertFieldOptionsAvailable,e as describeFieldFlagSpellingDefectLine,f as describeFieldOptionCollision,d as resolveAddFieldFlagSpellingDefects,b as resolveAddFieldOptionCollisions,c as resolveFieldFlagSpellingDefects,a as resolveFieldOptionCollisions,g as scanFieldOptionCollisions};
|
|
2
|
+
//# sourceMappingURL=field-option-collisions-63YQ2J3N.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"./chunk-7P6OGPEG.js";import"./chunk-TF57RHS2.js";import"./chunk-XVCMYFQU.js";import"./chunk-CQLOYNJY.js";import"./chunk-BKPUUW5O.js";import"./chunk-JD45Y2BR.js";import"./chunk-RBOWKXFV.js";import"./chunk-AHCOSTL7.js";import"./chunk-X6CXWWNB.js";import{kd as a,ld as b,md as c,nd as d}from"./chunk-64DSKZJN.js";import"./chunk-O33WUEAF.js";import"./chunk-A5B43EWU.js";import"./chunk-X5ZVPFK7.js";import"./chunk-NGFDPEP7.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
|
|
2
|
+
//# sourceMappingURL=item-revision-PV5O6F5Y.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{B as Le,C as Je,E as Z,H as We,J as Be,K as Ve,M as Ye,N as He,a as Pe,p as H}from"./chunk-ZHHFOQSL.js";import"./chunk-Y7EC2L2G.js";import"./chunk-Z4FWJGQG.js";import{A as V,B as Ge,C as Y,D as qe,y as ze,z as j}from"./chunk-YC3PFFDE.js";import"./chunk-OEMI52ZS.js";import"./chunk-KMGI5GZP.js";import"./chunk-IIP6LZ5E.js";import"./chunk-7P6OGPEG.js";import"./chunk-7EKKUYN5.js";import"./chunk-4SX2BN4V.js";import"./chunk-AIDL2ZNT.js";import"./chunk-HCWDMFWA.js";import"./chunk-ZUAPUBJK.js";import"./chunk-K53OIT5J.js";import"./chunk-Q6JCMFGU.js";import{T as Ne,W as je}from"./chunk-VNU3IFBL.js";import"./chunk-ZYHGQIQ7.js";import"./chunk-E4C6T3NL.js";import{Ha as Ke}from"./chunk-YX75PQFO.js";import"./chunk-MSLRDKWL.js";import"./chunk-TF57RHS2.js";import{H as W}from"./chunk-XVCMYFQU.js";import{sa as _e,ya as Se}from"./chunk-J4V3J5MC.js";import"./chunk-5MZXU6HB.js";import"./chunk-CQLOYNJY.js";import"./chunk-BKPUUW5O.js";import{H as xe,N as De,h as B}from"./chunk-JD45Y2BR.js";import{k as Fe,q as N}from"./chunk-RBOWKXFV.js";import{b as Ue}from"./chunk-AHCOSTL7.js";import"./chunk-BWOVFE5B.js";import"./chunk-X6CXWWNB.js";import{$c as C,Ab as Ae,Bb as $e,Cb as J,Ob as Te,Rd as Ie,Sd as k,Xd as Me,Yd as Ce,ed as Re,h as ye,jd as T,oc as ke,sc as M,tb as ve}from"./chunk-64DSKZJN.js";import{c as E}from"./chunk-O33WUEAF.js";import{h as K,p as ge}from"./chunk-A5B43EWU.js";import{L as Ee,Q as L,S as Oe,V as be}from"./chunk-X5ZVPFK7.js";import{A as p,E as q,G as we,H as $,l as le,q as A,s as me,x as he,z as l}from"./chunk-NGFDPEP7.js";import oe from"node:crypto";import{constants as te,readFileSync as It}from"node:fs";import{cp as Mt,lstat as it,mkdir as Ct,mkdtemp as ot,open as Nt,readdir as jt,realpath as st,rm as at,stat as se,writeFile as ct}from"node:fs/promises";import{tmpdir as dt}from"node:os";import u from"node:path";var Et=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...le,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function X(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new p(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,l.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}var Ot=["op","id","reason","options","unique","match"],bt=[...Ot,"ref"],xn=[...bt,"item"];var Xe="[a-z][a-z0-9._-]{0,63}",Dn=new RegExp(`^${Xe}$`,"u"),Pn=new RegExp(`(^|,)id=@(${Xe})(?=,|$)`,"gu"),Ze=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase());var vt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),zn=new Set([...vt,"completed_at","id"]),Gn={create:Ne.map(e=>e.target),update:je.map(e=>e.target),close:_e.map(e=>Ze(e.flag)).filter(e=>e!=="reason"),release:Se.map(e=>Ze(e.flag))};function At(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $t(e,t){return e<t?-1:+(e!==t)}function Q(e){return Array.isArray(e)?e.map(Q):At(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>$t(t,n)).map(([t,n])=>[t,Q(n)])):e}function O(e){return typeof e=="string"?e.trim():JSON.stringify(Q(e))}var Tt=["id","updated_at","pm_format_version","type"],kt="import";function Qe(e,t){if(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/u.test(e)||e in Object.prototype)throw new TypeError(`${t} names an invalid field ${JSON.stringify(e)}; use a front-matter field name of letters, digits and underscores`);if(Tt.includes(e))throw new TypeError(`${t} cannot change "${e}"; the item writer derives it, or an update row owns it`)}function U(e){return Array.isArray(e)?`array of ${e.length}`:typeof e}var Rt=["__proto__","constructor","prototype"];function et(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype}function R(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?Array.from(e).every(R):et(e)?Object.entries(e).every(([t,n])=>!Rt.includes(t)&&R(n)):!1}function ee(e,t){let{set:n,unset:r}=e;if(n!==void 0&&!et(n))throw new TypeError(`${t} set must be a plain object of front-matter fields`);if(r!==void 0&&!Array.isArray(r))throw new TypeError(`${t} unset must be an array of front-matter field names`);let i=Object.keys(n??{}),s=r??[];if(i.length+s.length===0)throw new TypeError(`${t} requires at least one field in set or unset`);for(let o of i)if(Qe(o,t),n[o]===null||!R(n[o]))throw new TypeError(`${t} set "${o}" must be a non-null JSON value (no undefined, non-finite number, sparse array, class instance, or __proto__/constructor/prototype key); remove a field with unset`);for(let o of s){if(Qe(o,t),o==="body"||o==="front_matter")throw new TypeError(`${t} cannot unset "${o}"; the item format reserves that name`);if(i.includes(o))throw new TypeError(`${t} both sets and unsets "${o}"`)}if(new Set(s).size!==s.length)throw new TypeError(`${t} unset repeats a field`)}async function tt(e){ee(e,`Finalization of ${e.id}`);let t=await N(e.pmRoot),n={schema:t.schema,extensionFieldNames:ye(k())},r=await De({pmRoot:e.pmRoot,settings:t,id:e.id,op:kt,author:e.author,message:e.message,force:e.force===!0,extensionFieldNames:n.extensionFieldNames,mutate:i=>{let s=structuredClone(i.metadata),o=i.metadata;for(let[c,f]of Object.entries(e.set??{}))o[c]=structuredClone(f);for(let c of e.unset??[])delete o[c];let a;try{ve(i.metadata);let c=J(i,n),f=J(Ae($e(c,n),n),n);if(E(f)!==E(c))throw new TypeError("the stored item reads back as a different document; a set field collides with a name the item format reserves");a=c.metadata;let h=Object.entries(e.set??{}).find(([m,w])=>U(a[m])!==U(w));if(h!==void 0)throw new TypeError(`set "${h[0]}" is not stored as declared (${U(h[1])} normalizes to ${a[h[0]]===void 0?"an absent field":U(a[h[0]])})`)}catch(c){throw new p(`Finalization of ${e.id} would not store a readable item with the declared fields: ${c.message}`,l.USAGE,{code:"finalization_invalid_document",item_id:e.id,required:"Declare set and unset fields that leave a valid item under the workspace schema, with each set value in the shape its field stores.",why:"A finalization writes front-matter fields exactly, so the patched document is read back through the item reader, and each declared value is checked against what would be stored, before anything is written.",nextSteps:[`Run pm get ${e.id} --json to compare the current fields with the finalization, then correct the patch and retry the transaction.`]})}return{changedFields:[...new Set([...Object.keys(s),...Object.keys(a)])].filter(c=>Object.hasOwn(s,c)!==Object.hasOwn(a,c)||E(s[c])!==E(a[c])).sort((c,f)=>c.localeCompare(f))}}});return{item:r.item,changedFields:r.changedFields}}async function Ut(e,t){if(!Fe(e))return{schema:L(t.schema),typeDefinitionsFromFile:[]};let n=await Ht(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Ft(e,t,n,r){let i=K({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},k());return(await xe(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function ae(e){let t=new Map,n=async r=>{let i=await N(e),s=await Ut(e,i),o=new Map;for(let a of await Ft(e,i,s,r)){let d=O(a.value);o.set(d,[...o.get(d)??[],a.id])}return o};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,s]of t){let o=r[i];if(o==null)continue;let a=await s,d=O(o);a.set(d,[...a.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function xt(e,t){let n=O(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new p(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,l.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function ut(e,t,n){let r=e.metadata[n.key],i=O(n.value);if(O(r)!==i)throw new p(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,l.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function nt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function P(e,t){let n={...e,...t};return e===void 0?n:W(e,n)}async function _(e,t){try{let r=(await H(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(n){if(n instanceof p&&n.exitCode===l.NOT_FOUND)return;throw n}}function ce(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=oe.createHash("sha256").update(E(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function Dt(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function y(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function de(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function v(e,t,n,r){let i=await M(u.join(e,"history",`${t}.jsonl`),t),s=y(n,r,"apply"),o=y(n,r,"compensate");for(let a=i.length-1;a>=0;a-=1){let d=i[a].message;if(de(d,s))return!0;if(d===o)return!1}return!1}async function z(e,t){let n=await _(e,t.id);if(n?.updatedAt===void 0)throw new p(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,l.NOT_FOUND);let r=await M(u.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new p(`Bulk ${t.op} target ${t.id} has no restorable history`,l.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(B(r)+r.length),target_history_hash:C(r),target_history_length:r.length}}function b(e,t,n){return new p(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,l.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function ft(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Pt(e,t,n){let{expectedHistory:r,length:i,version:s}=t;if(C(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||C(e.slice(0,i))!==r||s!==String(B(e)+i))throw b(n,n.itemId,n.stepId);let o=y(n.transactionId,n.stepId,"apply"),a=e.slice(i),d=m=>de(m.message,o)||m.context?.item_transaction_step===o,c=y(n.transactionId,n.stepId,"compensate");if(a.filter(m=>d(m)||m.message===c).at(-1)?.message===c)return!1;let f=a.filter(d);if(f.length===0)return!1;let h=e.at(-1).after_hash===f.at(-1).after_hash&&a.every(m=>ft(m,n.transactionId));if(f.length!==a.length&&!h)throw b(n,n.itemId,n.stepId);return!0}async function pt(e,t){let n=u.join(e,"history",`${t}.jsonl`),r=await ke(n,t);return{history:r.entries,assertOwnedUnderLock:(i,s)=>{let o;try{o=It(n).equals(r.raw_bytes)&&Re(i)===r.entries.at(-1).after_hash}catch(a){throw Object.assign(s(),{cause:a})}if(!o)throw s()}}}async function I(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let s=i.target_updated_at,o=await _(e.pmRoot,t);if(o===void 0)return;let{history:a,assertOwnedUnderLock:d}=await pt(e.pmRoot,o.id),c=i.target_history_hash,f=typeof c=="string";if(typeof c=="string"){if(!Pt(a,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:o.id,stepId:n}))return}else{if(o.updatedAt===s)return;if(!await v(e.pmRoot,o.id,e.transactionId,n))throw b(e,o.id,n)}let h=()=>Ve(t,typeof i.target_version=="string"?i.target_version:s,{force:!0,author:e.author,message:y(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await T({pmRoot:e.pmRoot,id:o.id,validate:m=>{d(m,()=>b(e,o.id,n))},compensation:mt(e,t,n,"restore",f)},h)}var lt=new WeakMap;function mt(e,t,n,r,i){let s=i?ze(e.pmRoot,e.transactionId):void 0,o=s===void 0?void 0:lt.get(s);if(!(o?.stepId!==n||o.itemId!==t||o.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function ht(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await M(u.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),s=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(d=>d.op==="close").at(-1)?.patch.some(d=>d.op==="add"||d.op==="replace"?d.path==="/metadata/close_reason"&&d.value===s:!1)??!1)throw new p(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,l.CONFLICT,{code:"transaction_create_compensated",item_id:r.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await xt(e.uniqueIndex,t.unique);let r=await Le(P(t.options,{author:e.author,id:t.id,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await zt(e,t.id,n)}}}async function zt(e,t,n){let r=await _(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:s}=await pt(e.pmRoot,r.id),o=y(e.transactionId,n,"apply"),a=y(e.transactionId,n,"compensate"),d=i.filter(c=>de(c.message,o)||c.message===a).at(-1);if(d?.message!==a){if(d===void 0||!i.every(c=>ft(c,e.transactionId)))throw b(e,r.id,n);await T({pmRoot:e.pmRoot,id:r.id,validate:c=>{s(c,()=>b(e,r.id,n))},compensation:mt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:a};e.createCompensation==="delete"?await Be(t,c,{pmRoot:e.pmRoot}):await Z(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Gt(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let r=()=>Je(t.id,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,s=i,a=(await T({pmRoot:e.pmRoot,id:await yt(e.pmRoot,t.id),validate:d=>{s!==void 0&&ut(d,t.id,s)},committed:d=>{i!==void 0&&(s={key:i.key,value:structuredClone(d.metadata[i.key])})},historyContext:{item_transaction_step:y(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await I(e,t.id,n,r)}}}async function yt(e,t){return String((await H(t,{},{pmRoot:e})).item.id)}function qt(e,t,n){let r=y(e.transactionId,n,"apply");return{id:n,compensatePending:!0,async inspect(){let i=await _(e.pmRoot,t.id);return i===void 0||!await v(e.pmRoot,i.id,e.transactionId,n)?{state:"pending"}:{state:"applied",result:{id:i.id,op:t.op}}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let i=await yt(e.pmRoot,t.id),{match:s}=t;return await He(e.pmRoot,()=>T({pmRoot:e.pmRoot,id:i,validate:o=>{s!==void 0&&ut(o,t.id,s)},historyContext:{item_transaction_step:r}},()=>tt({pmRoot:e.pmRoot,id:i,author:e.author,message:r,force:t.force,...t.set===void 0?{}:{set:t.set},...t.unset===void 0?{}:{unset:t.unset}}))),e.uniqueIndex.invalidate(),{id:i,op:t.op}},async compensate(i){await I(e,t.id,n,i)}}}function Kt(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let i=(await Z(t.id,t.reason,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"close"}},async compensate(r){await I(e,t.id,n,r)}}}function Lt(e,t,n){return{id:n,async inspect(){let r=await _(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await v(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return z(e.pmRoot,t)},async apply(){let i=(await We(t.id,P(t.options,{author:e.author,message:y(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"release"}},async compensate(r){await I(e,t.id,n,r)}}}function ue(e,t,n){let r=ce(t,n),i=Jt(e,t,r);return lt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function Jt(e,t,n){switch(t.op){case"create":return ht(e,t,n);case"update":return Gt(e,t,n);case"close":return Kt(e,t,n);case"release":return Lt(e,t,n);case"finalize":return qt(e,t,n)}}function Wt(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release","finalize"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, release, or finalize`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(Bt(e,t),e.op==="finalize"){Vt(e,t);return}X(e.options,e.op,t)}function Bt(e,t){if(e.op==="create"&&e.unique!==void 0&&!nt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if((e.op==="update"||e.op==="finalize")&&e.match!==void 0&&!nt(e.match))throw new TypeError(`Bulk ${e.op} mutation ${t+1} match must be an object with a non-empty key and a value`)}var rt=["op","id","set","unset","match","force"];function Vt(e,t){let n=`Bulk finalize mutation ${t+1}`,r=Object.keys(e).filter(i=>!rt.includes(i));if(r.length>0)throw new TypeError(`${n} has unsupported keys: ${r.join(", ")}; a finalization carries only ${rt.join(", ")}`);if(e.force!==void 0&&typeof e.force!="boolean")throw new TypeError(`${n} force must be a boolean`);if(e.match!==void 0&&!R(e.match))throw new TypeError(`${n} match must be a plain object with a JSON value`);ee(e,n)}function ie(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Wt(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:s}=r.unique,o=t.get(i)??new Map,a=O(s),d=o.get(a);if(d!==void 0)throw new p(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${i}".`,l.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});o.set(a,n),t.set(i,o)}}function wt(e){let t=[...e];ie(t);let n=t.map(r=>{let i=structuredClone(r);return r.op!=="finalize"&&i.op!=="finalize"&&r.options!==void 0&&i.options!==void 0&&W(r.options,i.options),i});return ie(n),n}function gt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:gt(r,i)})}async function ne(e,t,n){try{return await n()}catch(r){throw r instanceof p?new p(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function _t(e,t,n,r){let i=u.relative(e,t),s=i.split(u.sep);return s[0]==="extensions"&&s[2]==="node_modules"&&!r.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`))?!1:["locks","runtime","search"].includes(i.split(u.sep)[0])?r.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`)):i===""||n===void 0||n.some(o=>i===o||i.startsWith(`${o}${u.sep}`)||o.startsWith(`${i}${u.sep}`))}async function x(e,t){let n=await it(t);if(n.isSymbolicLink())await se(t);else if(n.isDirectory()||n.isFile())return n;throw $(u.relative(e,t))}async function Yt(e,t){let n=await Nt(t,te.O_RDONLY|te.O_NOFOLLOW|te.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(u.relative(e,t));let i=oe.createHash("sha256");if(r.size>0)for await(let s of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(s);return i.digest()}finally{await n.close()}}async function re(e,t,n){let r=oe.createHash("sha256");async function i(s){for(let o of(await jt(s)).sort()){let a=u.join(s,o);_t(e,a,t,n)&&((await x(e,a)).isDirectory()?await i(a):(r.update(JSON.stringify(u.relative(e,a))),r.update(await Yt(e,a))))}}return await i(e),r.digest("hex")}function F(){return new p("Tracker changed while preparing the transaction preview; retry against stable state.",l.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function fe(e){if(!q(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=u.resolve(t),r=n;for(;;)try{let i=await it(r);return r!==n&&i.isDirectory()}catch(i){if(!q(i))return!1;let s=u.dirname(r);if(s===r)return!1;r=s}}async function D(e,t){let n=u.join(e,t);try{let r=e;for(let i of t.split(u.sep).slice(0,-1))r=u.join(r,i),await x(e,r);if(!(await x(e,n)).isFile())throw $(t);return await we(n,$(t))}catch(r){if(await fe(r))return;throw r}}async function St(e,t,n,r){let i=L(n);for(let[s,o]of Object.entries(i.files)){let a=u.relative(e,Oe(e,o,Ee[s]));if(a===""||!u.resolve(e,a).startsWith(u.join(e,u.sep)))throw new p("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",l.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${s}`});i.files[s]=a;let d=await D(e,a);if(r?.set(a,d),d!==void 0){let c=u.join(t,a);await Ct(u.dirname(c),{recursive:!0}),await ct(c,d)}}return be(t,i)}async function Ht(e,t){await se(e);let n=await ot(u.join(dt(),"pm-schema-plan-"));try{let r=await st(e);return await St(r,u.join(n,"configuration"),t)}catch(r){throw await fe(r)?F():r}finally{await at(n,{recursive:!0,force:!0})}}async function Zt(e,t,n){let r=new Map,i=await D(e,A);r.set(A,i);let s;try{s=JSON.parse(i??"null")}catch{s=null}let o=Ue(s),a=o.success?o.data:void 0,d=await St(e,t,a?.schema,r),c=d.schema,f=u.relative(e,Te(e));r.set(f,await D(e,f));let h=K({...he,item_types:{definitions:[...a?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),m=ge(e)===e?[...me.filter(Boolean),A,Pe,"transactions",...h.folders,...r.keys()].map(g=>u.normalize(g)):void 0,w=a===void 0?void 0:JSON.stringify({...s,schema:{...a.schema,files:c.files}});return{configuration:r,ownedPaths:m,stagedSettings:w,registryFolders:h.folders}}async function Xt(e,t,n){await se(e);try{let r=await st(e),i=await Zt(r,u.join(u.dirname(t),"configuration"),n),s=[...i.configuration.keys(),...i.registryFolders].map(c=>u.normalize(c)),o=await re(r,i.ownedPaths,s);await Mt(r,t,{recursive:!0,dereference:!1,filter:async c=>_t(r,c,i.ownedPaths,s)?(await x(r,c),!0):!1});let[a,d]=await Promise.all([re(r,i.ownedPaths,s),re(t,i.ownedPaths,s)]);if(o!==a||o!==d)throw F();for(let[c,f]of i.configuration)if(await D(t,c)!==f)throw F();i.stagedSettings!==void 0&&await ct(u.join(t,A),i.stagedSettings)}catch(r){throw await fe(r)?F():r}}async function Ir(e){let t=j(e),n=wt(e.mutations),r=k(),i=Ce(),s=await ot(u.join(dt(),"pm-transaction-preview-")),o=u.join(s,"tracker");try{await Xt(t.pmRoot,o,r);let a=!1,d=[],c=[],f=new Set;return await Me(i,()=>Ye({path:o,noExtensions:!0},async()=>{Ie(r);let h={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ae(o)},m=n.map((w,g)=>{let S=ue({...h,onCreateWarnings:(G,pe)=>{pe.length>0&&d.push({index:g,id:G,op:"create",warnings:pe})}},w,g);return{...S,inspect:()=>ne(w,g,()=>S.inspect()),prepareCompensation:()=>ne(w,g,async()=>S.prepareCompensation?.()),apply:()=>ne(w,g,async()=>{let G=await S.apply();return f.add(g),G})}});if(await V({...t,pmRoot:o,steps:m,onTransition:({transition:w})=>{w==="committed"&&(a=!0)}}),a)for(let[w,g]of n.entries()){let S=(await Ke(g.id,{path:o},{full:!0})).item;c.push({index:w,id:String(S.id),op:g.op,execution:f.has(w)?"applied":"adopted",item:S,commit_time_fields:gt(S)})}})),{records:c,validated:a,state:a?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await at(s,{recursive:!0,force:!0})}}async function Qt(e){let t=j(e),n=wt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:ae(t.pmRoot)},s=await V({...t,steps:n.map((a,d)=>ue(i,a,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[a,d]of n.entries()){let c=ce(d,a),f=s.results[c];o[Dt(d,a)]=f}return{transactionId:s.transactionId,status:"committed",recovered:s.recovered,results:o}}function en(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function Mr(e){return Qt({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:en(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Cr={buildCreateStep:ht,bulkHistoryMarker:y,compensateByRestore:I,deriveStepId:ce,isUpdateMarkerApplied:v,readItemSnapshot:_};async function Nr(e,t){let n=await Ge(e,t);return n===void 0?void 0:{journal:n,planDigest:Y(n)}}function tn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new p("Transaction has no supported item recovery plan",l.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;ie(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:ae(e.pmRoot)};return r.map((s,o)=>ue(i,s,o))}async function jr(e){let t=j(e),n=await qe({...e,...t,resolveSteps:r=>tn({...e,...t},r)});return{journal:n,planDigest:Y(n)}}export{Cr as _testOnlyItemTransaction,jr as abandonItemTransaction,en as buildItemCompletionMutations,Mr as commitItemCompletion,Qt as commitItemMutations,Ft as listUpsertKeyCandidates,Ht as loadGuardedRuntimeSchema,Ir as previewItemMutations,Nr as readItemTransaction,Ut as resolveTransactionSchema};
|
|
2
|
+
//# sourceMappingURL=item-transaction-S5QXBGAT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{kc as t,lc as r,mc as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=mutation-actor-
|
|
1
|
+
import{kc as t,lc as r,mc as s}from"./chunk-64DSKZJN.js";import"./chunk-O33WUEAF.js";import"./chunk-A5B43EWU.js";import"./chunk-X5ZVPFK7.js";import"./chunk-NGFDPEP7.js";function c(n){let e=r(n),o={...e.harness===void 0?{}:{harness:e.harness},...e.model===void 0?{}:{model:e.model},...e.model_source===void 0?{}:{model_source:e.model_source},...e.instance===void 0?{}:{instance:e.instance}};return Object.freeze({author:n,author_source:t(n),principal:s(n),...Object.keys(o).length===0?{}:{agent:Object.freeze(o)}})}export{c as resolveMutationActor};
|
|
2
|
+
//# sourceMappingURL=mutation-actor-2AAUJG2Z.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Q as y,t as _,y as f}from"./chunk-OEMI52ZS.js";import"./chunk-Q6JCMFGU.js";import{T as A,W as L,a as T}from"./chunk-VNU3IFBL.js";import"./chunk-XVCMYFQU.js";import{F as g,Pa as C,Va as E}from"./chunk-J4V3J5MC.js";import"./chunk-JD45Y2BR.js";import{q as M}from"./chunk-RBOWKXFV.js";import"./chunk-AHCOSTL7.js";import"./chunk-BWOVFE5B.js";import"./chunk-X6CXWWNB.js";import{a as w}from"./chunk-64DSKZJN.js";import{T as b}from"./chunk-O33WUEAF.js";import{o as S}from"./chunk-A5B43EWU.js";import{Y as R,Z as N}from"./chunk-X5ZVPFK7.js";import{A as m}from"./chunk-NGFDPEP7.js";function l(e,t,n,i=!1){let s=[...n].map(o=>({candidate:o,distance:w(t,o,3)})).filter(o=>o.distance!==null).sort((o,d)=>o.distance-d.distance||o.candidate.localeCompare(d.candidate))[0]?.candidate,a=i?`Put mutation fields under options (options.${t}).`:s?`Did you mean "${s}"?`:"Use the declared command options or the field option for registered item fields.";throw new m(`Unknown ${e} ${i?"argument":"option"} "${t}". ${a} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:t,required:a,nextSteps:[a]})}var p=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function $(e){let t=e==="create"?A:L,i=(e==="create"?C:E).map(({flag:s})=>s.slice(2).replace(/-([a-z])/gu,(a,o)=>o.toUpperCase()));return new Set([...t.flatMap(s=>[s.target,...s.keys]),...i,"author","message","force","fullChangedFields","idOnly",...p])}function F(e){if(e!==void 0&&!f(e))throw new m("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1})}async function v(e,t){let i=R((await M(S(process.cwd(),t))).schema).command_to_fields.get(e)??[];return{targets:i.map(s=>N(s)),reads:s=>i.some(a=>b({[s]:!0},a)===!0)}}async function h(e,t,n,i,s,a=(o,d)=>l(e,o,d)){let o=[...n].filter(r=>!i.has(r));if(o.length===0)return;let d=await v(t,s);for(let r of d.targets)i.add(r);for(let r of o)d.reads(r)||a(r,i)}async function ee(e,t,n,i,s){if(_(t))return;let a=$(e),o=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...p,...s,...e==="update"?["id"]:[]]);for(let r of Object.keys(t))o.has(r)||l(e,r,a,a.has(r));let d=t.options;F(d),await h(e,e,new Set([...Object.keys(d??{}),...Object.keys(n)]),a,i)}var I=new Set([...y].filter(e=>e!=="filterStatus"&&(e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"))),k=e=>e.replace(/_([a-z])/gu,(t,n)=>n.toUpperCase()),O=new Map([["for","Bound the selection with list.limit."],["tokenBudget","Bound the selection with list.limit."],["token_budget","Bound the selection with list.limit."],["all",'State the status selection as filterStatus: "all" beside the list record.'],["status","State the status selection as filterStatus beside the list record."]]),K=["compact","brief","fields","includeBody","full"];async function U(e,t){let n=K.filter(s=>Object.hasOwn(e,s));if(n.length===0)return;let i=await v("list",t);for(let s of n)i.reads(s)&&c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,"The bulk selection clears this list option, so the schema field's filter under that name is not applied; select the rows another way.")}var j=["excludeTerminal","lifecycleBucket","dependencyBlocked"];function P(){let e=g.map(({flag:n})=>n.replace(/^--(?:no-)?/u,"").replace(/-([a-z])/gu,(i,s)=>s.toUpperCase())),t=new Set([...e,...T.flatMap(n=>n.keys),"filterEstimateMissing",...j]);for(let n of O.keys())t.delete(n);return t}function c(e,t,n,i="unknown_mutation_option"){throw new m(`${e} ${n} No changes were made.`,2,{code:"invalid_argument_value",reason:i,changed:!1,field:t,required:n,nextSteps:[n]})}function D(){let e=$("update");e.delete("id");for(let t of e)/File$|^stdin/u.test(t)&&e.delete(t);return e.add("documentAnnotationSnapshot"),e}function B(e){for(let t of["list","update"]){let n=e[t];n!=null&&!f(n)&&c(`update-many "${t}" must be an object.`,t,`Pass ${t} as an object, or omit it.`,"invalid_mutation_option_value")}}async function x(e,t,n){Object.hasOwn(e,"id")&&l("update-many list","id",new Set(["ids"])),Object.hasOwn(e,"status")&&c('update-many "list.status" is not read beside this selection.',"list.status",O.get("status"));let i=[...t].find(s=>I.has(s));i!==void 0&&c(`update-many "${i}" is not read beside this selection.`,i,`Put the selection inside list, or drop the list record; a flat "${i}" beside it is not read.`),await U(e,n),await h("update-many list","list",Object.keys(e),P(),n,(s,a)=>{let o=O.get(s);o===void 0&&l("update-many list",s,a),c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,o)})}function Y(e,t,n){for(let i of e)t.has(i)||(n.has(i)&&c(`Unknown update-many option "${i}".`,i,`Put update fields inside update (update.${i}); beside a nested update record an outer key selects rows or controls the run.`),l("update-many",i,t))}async function te(e,t,n){if(_(e))return;let i=e.options;F(i);let s=D(),a=new Set([...y,"author","message","force","fullChangedFields","idOnly",...p]),o=new Set([...s,...a]),d=new Set(["action","options","path","cwd","author","noExtensions","no_extensions","fullChangedFields","idOnly",...p]);for(let u of Object.keys(e))d.has(u)||l("update-many",u,o,o.has(u));let r=new Set([...Object.keys(i??{}),...Object.keys(t)].map(u=>p.includes(k(u))?k(u):u));if(B(t),f(t.list)&&await x(t.list,r,n),!f(t.update)){await h("update-many","update_many",r,o,n);return}Y(r,a,s),await h("update-many","update_many",Object.keys(t.update),s,n)}export{ee as assertNativeMutationOptions,te as assertNativeUpdateManyOptions};
|
|
2
|
+
//# sourceMappingURL=mutation-admission-X7HHNERR.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{L as a,M as b,N as c,O as d,P as e,Q as f,R as g,S as h,T as i,U as j,V as k,W as l,X as m,Y as n,Z as o,_ as p}from"./chunk-X5ZVPFK7.js";import"./chunk-NGFDPEP7.js";export{a as DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,c as DEFAULT_RUNTIME_STATUS_DEFINITIONS,b as DEFAULT_RUNTIME_WORKFLOW,j as ensureRuntimeSchemaFileScaffold,h as filePathForSchemaSection,e as inspectRuntimeFieldDefinition,k as loadRuntimeSchemaFromOptionalFiles,d as normalizeCliToken,f as normalizeRuntimeSchemaSettings,m as normalizeStatusInputWithRegistry,g as readFieldsFromSchemaFile,i as resolveItemTypesFilePath,n as resolveRuntimeFieldRegistry,l as resolveRuntimeStatusRegistry,o as runtimeFieldOptionTarget,p as statusIsTerminal};
|
|
2
|
+
//# sourceMappingURL=runtime-schema-5J2ONRNV.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as w,j as y}from"./chunk-7EKKUYN5.js";import{b as u}from"./chunk-4SX2BN4V.js";import{c as g}from"./chunk-AIDL2ZNT.js";import"./chunk-BKPUUW5O.js";import"./chunk-RBOWKXFV.js";import"./chunk-AHCOSTL7.js";import"./chunk-64DSKZJN.js";import"./chunk-O33WUEAF.js";import{o as h}from"./chunk-A5B43EWU.js";import"./chunk-X5ZVPFK7.js";import{A as f,z as d}from"./chunk-NGFDPEP7.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-56RYPMBK.js.map
|
package/dist/cli-bundle/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Sa}from"./chunks/chunk-HZZLSBIJ.js";import"./chunks/chunk-SLFRSZK6.js";import{A as va,B as Ca,C as Wn,E as xa,F as ba,H as ka,I as Bn,a as jn,d as N,e as j,f as $,g as S,h as E,i as Br,n as pe,o as Tt,p as Vr,q as Jr,r as Qr,v as ea,w as ha,x as ya,y as _a,z as wa}from"./chunks/chunk-
|
|
1
|
+
import{a as Sa}from"./chunks/chunk-HZZLSBIJ.js";import"./chunks/chunk-SLFRSZK6.js";import{A as va,B as Ca,C as Wn,E as xa,F as ba,H as ka,I as Bn,a as jn,d as N,e as j,f as $,g as S,h as E,i as Br,n as pe,o as Tt,p as Vr,q as Jr,r as Qr,v as ea,w as ha,x as ya,y as _a,z as wa}from"./chunks/chunk-2YD2AERA.js";import{Wa as ga,f as Gr,k as zr}from"./chunks/chunk-C4O5TZY3.js";import"./chunks/chunk-O2WNNIKK.js";import{A as aa,B as sa,C as Nt,F as ca,G as la,H as Q,I as da,Qc as pa,Rd as fa,b as Te,ca as ma,l as Zr,q as Hn,r as Gn,s as oa,t as ia,u as ra,v as zn,w as $t,x as Qe}from"./chunks/chunk-SP6CDM6B.js";import"./chunks/chunk-T7UTG56V.js";import"./chunks/chunk-MO6PPUI6.js";import"./chunks/chunk-6H36ZHMI.js";import"./chunks/chunk-MGJMQSN4.js";import"./chunks/chunk-LRGYV6QQ.js";import"./chunks/chunk-TWRUA2NH.js";import{k as Wr}from"./chunks/chunk-T7RZPIOB.js";import{d as ua}from"./chunks/chunk-CTM26LUE.js";import"./chunks/chunk-OFIYA3PI.js";import"./chunks/chunk-KHFUHGL3.js";import"./chunks/chunk-AA52P34H.js";import{Ka as na,a as Kr,b as Yr,d as Xr,ma as It,na as Pt,oa as Un,pa as Ze,qa as A,ra as ta,sa as qn,wa as W}from"./chunks/chunk-CDUV7DFD.js";import{A as Ur,B as qr,C as Dn,D as Hr,n as Mn,p as Dr,u as Fn,w as jr}from"./chunks/chunk-56DKWGHE.js";import"./chunks/chunk-E2LQ6LCJ.js";import"./chunks/chunk-PZA7QECY.js";import{Ac as Nn,Bc as Ir,Cc as Oe,Fc as Pr,Jc as $r,K as Ni,Xb as An,bc as Cr,ec as xr,fc as br,hc as kr,id as Ye,lc as Sr,ld as Nr,mb as kt,mc as Er,nb as vr,nc as Rn,pc as Ar,qc as me,rc as On,rd as Lr,sc as Tn,tc as In,uc as Pn,vc as St,wc as $n,wd as Ln,xc as Rr,xd as Mr,yc as Or,yd as Fr,zc as Tr}from"./chunks/chunk-CATRDGAB.js";import{l as bt,o as yr,p as _r,s as Re,t as F,u as wr}from"./chunks/chunk-LMDIKSDZ.js";import"./chunks/chunk-YEMFOKFG.js";import{$g as Sn,Ge as Z,Ib as wt,Ig as ar,Jd as Ui,Jg as Je,Kd as qi,Lg as Ke,Md as Hi,Mg as sr,Nd as Gi,Od as zi,Pd as Wi,Pe as Yi,Q as Ee,Qd as Bi,Qe as ie,R as We,Rd as Vi,Rf as tr,Sf as nr,T as Be,Ue as kn,Ve as x,Vg as cr,Wg as lr,X as Ve,Xg as dr,Yg as mr,Zg as re,_g as ur,ah as le,ba as gn,bh as pr,ch as vt,fg as or,fh as Ae,ga as _t,gh as de,ja as hn,jh as fr,kh as Ct,ld as _n,md as wn,nd as Di,od as ji,pe as Ji,pf as Xi,qd as vn,qf as Zi,r as ze,rd as Cn,rf as Qi,sd as xn,sf as er,te as Ki,tg as ir,th as En,ud as bn,uh as xt,vg as rr,vh as gr,wh as hr,xb as Mi,yb as Fi}from"./chunks/chunk-56GUDMXN.js";import{e as mn,h as ce,j as Oi,k as yt,n as un,o as Ti,p as P,r as Ii,s as X}from"./chunks/chunk-D3I5AHNN.js";import"./chunks/chunk-5ECCMDSU.js";import{E as Rt,F as ue,mb as Ot,nb as G,p as Et,r as Xe,s as At}from"./chunks/chunk-FG4TNQQM.js";import{G as Pi,H as $i,I as J,Z as Li,h as M,j as V,k as H,m as K,n as dn,o as D,p as Ai,x as _,y as pn,z as fn}from"./chunks/chunk-54AQJTUH.js";import{Y as yn,a as Ri}from"./chunks/chunk-WKDKBS4P.js";import{A as g,B as ht,C as I,E as Y}from"./chunks/chunk-6OIHST4I.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as Jc}from"node:async_hooks";var Ie=new Jc;function Ea(e){let t=Ie.getStore();return t===void 0?e:t!==null}function fe(e,t=`warning:${e}`){let n=Ie.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):x(t)}function et(e){let t=Ie.getStore();if(!t?.size)return e;let n=Reflect.get(e,"warnings"),o=[...t].filter(([a,s])=>s!==`warning:${a}`).map(([a,s])=>({code:a,message:s})),i=Reflect.get(e,"warning_details"),r={...e,warnings:[...Array.isArray(n)?n:[],...t.keys()],...o.length>0?{warning_details:[...Array.isArray(i)?i:[],...o]}:{}};return t.clear(),r}function Vn(e){if(!Ie.getStore()?.size)return e;let{token_accounting:t,...n}=et(JSON.parse(e));return JSON.stringify(t===void 0?n:Z(n,o=>`${JSON.stringify(o,null,2)}
|
|
2
2
|
`),null,2)}async function Aa(e,t){if(!e){await Ie.run(null,t);return}let n=new Map;await Ie.run(n,async()=>{await t(),n.size>0&&ie(`${JSON.stringify(et({type:"warning"}))}
|
|
3
3
|
`)})}import{AsyncLocalStorage as Kc}from"node:async_hooks";var Jn=new Kc,Ra=new WeakMap;function Yc(e){let t=e.outputFormat!==void 0?["--output-format",e.outputFormat]:e.json===!0?["--json"]:[];return{scopeArgs:Ee(e),outputArgs:t}}var Oa=new WeakMap;function Xc(e,t){let n=e.registeredArguments.findIndex(o=>o.name()==="id");if(!(n===-1||e.name()==="plan"&&t[0]==="create"))return t[n]}function Kn(e,t){return t.some(n=>n.path!==e.path||n.args.length!==e.args.length||n.args.some((o,i)=>o!==e.args[i]))}async function Yn(e){if(e.expectHash===void 0)return;let t=Mn(e.expectHash),n=e.commandPath.trim().toLowerCase();if(Dn(n,e.commandOptions),e.rewritten===!0)throw Fn();let o=Jn.getStore();if(o===void 0)throw new TypeError("--expect-hash was parsed outside an invocation revision scope");let i=await Dr(e.pmRoot,t,Xc(e.command,e.commandArgs));Qi(o,e.pmRoot,i),Oa.set(o,n),e.globalOptions!==void 0&&Ra.set(o,Yc(e.globalOptions))}function Xn(e,t,n){let o=Jn.getStore(),i=o===void 0?void 0:Oa.get(o);if(i!==void 0){if(Kn(e,[t]))throw Fn();Dn(i,n)}}function Ta(e,t){if(t!==void 0)throw Mn(t),Hr(e)}function Zc(e){for(let t of er(e).unchecked)fe(qr(t))}async function Qc(e,t){return e.pmRoot===void 0?t:jr(t,e.pmRoot,Ra.get(e))}async function Ia(e){let t=Xi();try{await e(n=>Jn.run(t,()=>Zi(t,n)))}catch(n){throw await Qc(t,n)}Zc(t)}import{Command as hi,CommanderError as gc}from"commander";function B(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function ge(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return B(t)}function ee(e){let t=new Set,n=[];for(let o of e){let i=ge(o);i&&(t.has(i)||n.push(i),t.add(i))}return n}var Zn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Lt=new Set(["--full","--brief","--compact"]);function el(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function Qn(e,t=E([...e])){let n=G(t),o=new Set([...Kr,...Yr,...Xr].flatMap(s=>s.keys.map(c=>`--${c.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),i=new Map([...ue,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,s.flag]))),r=new Map([...ue,...n].flatMap(s=>[s.flag,...s.aliases??[]].map(c=>[c,el(s,o)])));for(let s of Zn)r.set(s,!0);for(let s of Lt)r.set(s,!1);let a=new Map;for(let s=0;s<e.length;s+=1){let c=e[s];if(c==="--")break;if(!c.startsWith("-"))continue;let l=c.split("=")[0];if(!r.has(l)&&!c.includes("="))return;let d=r.get(l)===!0&&!c.includes("=");a.set(s,{flag:i.get(l)??l,consumesValue:d}),d&&(s+=1)}return a}function tl(e){let t=Qn(e);return t===void 0?void 0:new Map([...t].map(([n,{flag:o}])=>[n,o]))}function Pa(e,t,n){let o=new Set;for(let[i,r]of t)n.has(r)&&(o.add(i),Zn.has(r)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,r)=>!o.has(r))}function nl(e,t){let n=t.find(i=>Lt.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Lt.has(i));return o.length===1?o[0]:n}function $a(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,i={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return i;let r=tl(e);if(!r)return i;let a;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return i;let c=[...r].find(([l,d])=>d==="--fields")?.[0]??-1;if(c<0)return i;a=Pa(e,r,new Set(["--fields"])),a.splice(c,0,"--fields",o[s+1])}else{let s=nl(r,o);if(s===void 0||![...r.values()].includes(s))return i;let c=new Set([...Zn,...Lt].filter(l=>l!==s));a=Pa(e,r,c)}return{...n,suggested_retry:_(a),suggested_retry_args:a}}var Na=new Set(Gi);function ol(e){return e.includes("@")&&e.includes(":")}function il(e){let t=S([...e]);if(t===void 0)return;let n=e[t+1],o=n===void 0||n.startsWith("-")?void 0:`${e[t]} ${n}`;return o!==void 0&&Ot(o)?o:e[t]}function rl(e){let t=Te(e??"",G(e));return new Set(t.filter(n=>n.takes_value).flatMap(n=>[n.flag,...n.aliases??[]]))}function La(e,t,n,o=[],i=()=>!1){if(t!==Hi)return n;let r=n===void 0?void 0:{...n,suggested_retry:void 0,suggested_retry_args:void 0},a=il(e),s=Qn(e,a);if(s===void 0||o===null||e.some(ol)||i())return r;let c=al(e,s,rl(a));if(c===void 0||c.size===0)return r;let l=[...o,...e.filter((d,m)=>!c.has(m))];return{...n,suggested_retry:_(l),suggested_retry_args:l}}function al(e,t,n){let o=new Set;for(let[r,{flag:a,consumesValue:s}]of t){if(!Na.has(a))continue;let c=e[r-1];if(c!==void 0&&!c.includes("=")&&n.has(c)||s&&e[r+1]?.startsWith("-")===!0)return;o.add(r),s&&o.add(r+1)}return e.some((r,a)=>!o.has(a)&&Na.has(r.split("=",1)[0]))?void 0:o}var sl=new Set(["normalized_args","suggested_retry_args","provided_fields","parsed_positionals","normalizedInvocationArgs","providedOptionFlags","suggestedRetryArgs"]),cl=new Set(["code","original_code","type","recovery_mode","option_scope","diagnostic_class"]),Ma=`URL credentials in this invocation were replaced with ${pn}; restore them before replaying any command shown here.`;function ll(e){return`URL credentials in this invocation were replaced with ${pn}. Those in ${e} caused this refusal, so do not restore them: give ${e} a value without URL credentials, and restore any other redacted credentials before replaying.`}function he(e){return e.map(fn)}function dl(e,t){return e==="producer"||t==="details"?"producer":e==="schema"&&t==="recovery"?"schema":"typed"}function ml(e,t,n){let o=J(e);o!==e&&(n.changed=!0);let i=o;for(let r=2;Object.hasOwn(t,i);r+=1)i=`${o} (${r})`;return i}function ul(e,t,n){let o=J(n?fn(e):e);return o!==e&&(t.changed=!0),o}function pl(e,t,n){return e!=="schema"?!1:t==="urlCredentialsRejected"||cl.has(t)&&typeof n=="string"}function eo(e,t,n,o){if(typeof e=="string"&&t.ownSteps.has(e))return e;if(typeof e=="string")return ul(e,t,n);if(typeof e!="object"||e===null)return e;let i=t.copies.get(e);if(i!==void 0)return i;if(Array.isArray(e)){let a=[];t.copies.set(e,a);for(let s of e)a.push(eo(s,t,n,o));return a}let r={};t.copies.set(e,r);for(let[a,s]of Object.entries(e)){if(pl(o,a,s)){r[a]=s;continue}let c=o==="producer"?ml(a,r,t):a;r[c]=eo(s,t,n||sl.has(a),dl(o,a))}return r}function Mt(e){let t=e.urlCredentialsRejected,n=t===void 0?Ma:ll(t.source),o=new Set([Ma,n]),i={copies:new Map,changed:!1,ownSteps:o},r=eo(e,i,!1,"schema");if(!i.changed&&!$i())return e;r.recovery&&(r.recovery={...r.recovery,suggested_retry:void 0,suggested_retry_args:void 0});let a=(r.nextSteps??[]).filter(s=>!o.has(s));return r.nextSteps=[n,...a],r}var fl="project_schema_field_requires_declared_flag";function gl(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o.startsWith("--field=")?t.push({index:n,width:1,assignment:o.slice(8)}):o==="--field"&&n+1<e.length&&(t.push({index:n,width:2,assignment:e[n+1]}),n+=1)}return t}function Fa(e,t,n,o){let i=o?.suggested_flags?.[0];if(t!==fl||n===void 0||i===void 0)return o;let r=gl(e).filter(({assignment:d})=>d.split("=",1)[0].trim()===n&&d.includes("="));if(r.length!==1)return o;let[a]=r,s=a.assignment.trim(),c=s.slice(s.indexOf("=")+1),l=[...e.slice(0,a.index),i,c,...e.slice(a.index+a.width)];return{...o,suggested_retry:_(l),suggested_retry_args:l}}var to=Zr;function hl(e,t,n,o,i){let r=[],a=e.indexOf(n,t);if(a<0||e.slice(t,a).some(s=>s.startsWith("-")))return r;for(let s=a+1;s<e.length;s+=1){let c=e[s];if(c==="--")break;c===`${o}=${i}`?r.push({index:s,width:1}):c===o&&e[s+1]===i&&(r.push({index:s,width:2}),s+=1)}return r}function Da(e,t,n,o,i=[]){let r=o?.suggested_flags?.[0];if(t!==to||n===void 0||r===void 0||o.suggested_retry_args===void 0)return o;let a={...o,suggested_retry:void 0,suggested_retry_args:void 0},s=S([...e]);if(s===void 0||i===null)return a;let c=o.suggested_retry_args,l=hl(e,s,c[0],n,r);if(l.length!==1)return a;let{index:d,width:m}=l[0],u=[...e.slice(0,d),r,...e.slice(d+m)];if(!yl(u,d,n,r,c))return a;let p=[...i,...u];return{...o,suggested_retry:_(p),suggested_retry_args:p}}function yl(e,t,n,o,i){let r=i.lastIndexOf(o);return r<0||i.slice(r).some((a,s)=>e[t+s]!==a)?!1:!e.some((a,s)=>s!==t&&(a===n||a.startsWith(`${n}=`)))}var no="close_validation_missing_fields";function _l(e,t,n,o){let i=e.slice(t+1);if(!i.includes("--"))return[...e,...o];if(!i.some(r=>n.has(r.split("=",1)[0])))return[...e.slice(0,t+1),...o,...i]}function wl(e,t){let n=e.slice(0,e.length-2*t),o=n.length;for(;o>0&&n[o-1].startsWith("--expect-hash=");)o-=1;return n.slice(o)}function ja(e,t,n,o=[]){let i=n?.missing;if(t!==no||i===void 0||i.length===0)return n;let r=n.suggested_retry_args;if(r===void 0)return n;let a={...n,suggested_retry:void 0,suggested_retry_args:void 0},s=S([...e]);if(s===void 0||o===null)return a;let c=G(e[s].trim().toLowerCase()),l=i.map(f=>c.find(y=>y.flag===f||y.aliases?.includes(f)===!0));if(l.some(f=>f===void 0))return a;let d=new Set(l.flatMap(f=>[f.flag,...f.aliases??[]])),m=wl(r,i.length),u=_l(e,s,d,[...i.flatMap(f=>[f,"<value>"]),...m]);if(u===void 0)return a;let p=[...o,...u];return{...n,suggested_retry:_(p),suggested_retry_args:p}}async function Ua(e,t){await Mr(e,{ok:t.ok,error:t.error,result:de(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function qa(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Ji({pmRoot:e.pmRoot,result:de()})}catch(o){t=o}let n=await F(e.pmRoot);if(await Ki({pmRoot:e.pmRoot,author:wt(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw t}var Ha=new WeakMap;function Ft(e,t){Ha.set(e,t)}function ye(e){return Ha.get(e)}function Ga(e){return e.length>0?[e[0]]:[]}function vl(e){let t=["","Intent:",` ${e.why}`],n=Ga(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
|
|
4
4
|
`)}function Cl(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
|
|
@@ -36,7 +36,7 @@ Extension command metadata:
|
|
|
36
36
|
`)}return process.exitCode=g.SUCCESS,!0}function ou(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
|
|
37
37
|
`)}function iu(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",i=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${i.length>0?i.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function ru(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let i of[...t.required_create_fields,...t.required_create_repeatables])o.add(i);return{progressive:n,strict:o}}function au(e,t,n,o){let i=new Set(n),r=o.filter(c=>!i.has(c)),a=c=>c.length>0?c.map(l=>mn("create",l)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(pa).filter(c=>c!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function su(e,t,n){let o=Jr(n);if(!o)return ou(e,t);let i=Oi(o,t);if(!i){let y=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${y}`].join(`
|
|
38
38
|
`)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(y=>y==="--create-mode"||y.startsWith("--create-mode=")),c=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],l=e==="create"&&c?.toLowerCase()==="strict",d=ru(e,i),m=yt(i,e,d.progressive),u=yt(i,e,l?d.strict:d.progressive),p=y=>y.length>0?y.map(h=>mn(e,h)).join(", "):"none",f=["",`Type-aware option policies for ${i.name}:`,` required: ${p(u.required)}`,` disabled: ${p(u.disabled)}`,` hidden: ${p(u.hidden)}`];if(e==="create"){let y=yt(i,e,d.strict);au(f,i,m.required,y.required)}return iu(f,i),u.errors.length>0&&f.push(` config errors: ${u.errors.join("; ")}`),f.join(`
|
|
39
|
-
`)}function Gs(e,t,n){let o=E(n);if(o!=="create"&&o!=="update")return;let i=rt(e,o);i&&i.addHelpText("after",su(o,t,n))}function cu(e,t){let n=Ve(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function lu(e){return Ve(e.status)?.toLowerCase()??"pending"}function du(e){return e.mandatory===!0}function mu(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function Bs(e){let t=[];return e.forEach((n,o)=>{if(!du(n.definition))return;let i=lu(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:cu(n.definition,o),status:i})}),t.sort(mu),t}function zs(e){return Array.isArray(e)&&e.length>0}var uu=new Set(["create","beads import","todos import"]),pu=new Set(["restore","update","close","delete","append","claim","release"]),fu=new Set(["comments","notes","learnings"]),gu=new Set(["files","docs","test"]),hu=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function No(e,t){let n=t.force===!0;return uu.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:pu.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:fu.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:gu.has(e)?{isMutation:zs(t.add)||zs(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function yu(e,t,n){if(No(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return $r(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>hu.has(i.trim().toLowerCase())):!1}function Ws(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _u(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(Ve(t[1])||i.push("source"),Ve(n.to)||i.push("--to"),i.length!==0)throw new I(`Schema migration requires ${i.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:i.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function wu(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Ws(n.status)!==Ws(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=ce(i,le()),s=await kt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let c=await vr(s,{schema:i.schema}),l=typeof n.assignee=="string"?n.assignee.trim():void 0;(l===void 0?c.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(l.toLowerCase())&&l)||x(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Lo(e,t,n,o,i){if(!yu(e,t,n)||(_u(e,t,n),!await Y(X(i))))return;let r=await Re(i);Ea(o.json===!0)||await wu(e,t,n,i,r.settings);let a=Pr({author:wt(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)fe(s)}function Vs(e,t,n){if(n.length===0)return;let o=No(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new I(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,g.CONFLICT)}async function Mo(e,t,n,o){if(!No(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await Y(X(n)))return;let{settings:r,metadata:a,warnings:s}=await Re(n);for(let c of s)fe(c);if(!_r(r)&&(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(yr(r),await wr(n,r,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let c=ce(r,le());await Nr(n,r.item_format,"item_format:pre_mutation_sync",c.type_to_folder,r.schema)}}function Fo(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=v(n);o.length!==0&&t.push(o)}return t}function De(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of Fo(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,H(i)]))]}function Do(e,t){let n=v(e);if(n.length===0)return!1;let o=De(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function Vt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...L(n.commands),...L(n.command_handlers),...L(n.command_overrides),...L(n.flag_commands),...L(n.parser_overrides),...Js(n.preflight_ownership),...Js(n.renderer_ownership)]:[]}function L(e){return e??[]}function Js(e){return L(e).flatMap(t=>t.commands)}function st(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Ks=new Set(["hooks","parser","preflight","renderers"]),Ys=new Set(["commands","schema","services","importers"]),vu=new Set(["reindex","search","search-advanced"]),Cu=new Set(["--template"]);function Fe(e,t){for(let n of t)if(e.has(n))return!0;return!1}function jo(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return vu.has(n??t)}function Uo(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function Jt(e){return v(e.commandPath??"")==="create"&&Uo(e,Cu)}function qo(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Bt(e,t){return e.some(n=>Do(n,t))||Jt(t)&&qo(e)}function Ho(e){return[L(e.hooks).length,(e.preflight_overrides??0)-L(e.preflight_ownership).length,L(e.item_types).length,L(e.item_fields).length,L(e.relationship_kinds).length,L(e.service_overrides).length,L(e.assurance_providers).length,L(e.renderer_overrides).length-L(e.renderer_ownership).length].some(n=>n>0)}function Go(e,t){let n=e.activation?.commands??[];if(n.length>0)return Bt(n,t);let o=Vt(e);if(Bt(o,t)||st(e).has("search")&&jo(t.commandPath))return!0;if(e.contributions)return Ho(e.contributions)}function Kt(e,t){let n=Go(e,t);if(n!==void 0)return n;let o=st(e);return!!(Fe(o,Ks)||Fe(o,Ys))}function ct(e,t){return e.effective.length===0?!1:lt(t)!=="all"?e.effective.some(o=>Kt(o,t)):e.effective.some(o=>{let i=st(o);return Vt(o).length>0||Fe(i,Ks)||Fe(i,Ys)||i.has("search")})}function lt(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=De(e).filter(i=>i.split(" ").every(r=>!r.startsWith("-"))).sort((i,r)=>r.length-i.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Jt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function zo(e){return lt(e)==="all"?void 0:t=>Kt(t,e)}function je(e){let t=$(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=j(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function Wo(e){let t=e.args.map(String);if(v(A(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.template.trim().length>0&&t.push("--template")}return t}var Yt=Symbol.for("pm.readOutputInvocationProvenance"),xu=new Map(ue.filter(e=>e.reservation_scope==="root_only").map(e=>[$t({long:e.flag}),e.flag]));function se(e,t){let n=Reflect.get(e,Yt);n!==void 0&&Reflect.set(t,Yt,n)}function Bo(e,t,n){let o=qi(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(ee(r.slice(2))),s=Ui.find(d=>d.command===o),c=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),l=Reflect.get(n,Yt);Reflect.set(n,Yt,{canonical_include_modes:l?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),se(n,e)}function bu(e){let t=e.optsWithGlobals(),n=A(e);if(H(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(c=>c.long===r.long))throw new I(`Unknown option '${r.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let c=i.getOptionValue(a);e.setOptionValueWithSource(a,c,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function Vo(e,t,n,o){Bo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=Vi(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;se(o,e);let s=Bi(t);for(let l of a){let d=s.get(l),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let c=r.length>0?r.join(","):void 0;c===void 0?delete n.outputInclude:n.outputInclude=c;for(let l=e;l;l=l.parent)l.setOptionValueWithSource("outputInclude",c,"cli");Pt(e,n)}function Ue(e,t,n=[],o){let r={...bu(e)};se(e,r),delete r.json,delete r.quiet,delete r.path,delete r.pmPath,delete r.noExtensions,delete r.extensions,delete r.profile,delete r.pager,delete r.changedFields,delete r.fullChangedFields,delete r.idOnly,delete r.lean,delete r.tokenAccounting,delete r.outputInclude,delete r.outputLimit,delete r.outputBudget,delete r.outputFormat,delete r.outputSession,delete r.expectHash;let a=ia(t);for(let[s,c]of Object.entries(a))r[s]===void 0&&(r[s]=c);if(n.length>0){let s=Hn(n),c=G(A(e)).map(u=>({long:u.flag,short:u.short,aliases:u.aliases})),l={...a};for(let u of s)r[u]!==void 0&&(l[u]=r[u]);Gn(l,[...c,...n],A(e),o);let d=sa(a,nc(e),n),m=oa(r,n,d,A(e));return se(r,m),m}return r}function Qs(e,t,n){let o=Hn(t.map(({long:a})=>({long:a}))),i=[...xu].find(([a])=>e[a]!==void 0&&!o.has(a));if(i===void 0)return;let r=i[1];throw new I(`Unknown option '${r}' for extension command '${n}'. ${r} is a root-only pm flag and this command does not declare it.`,g.USAGE,{code:"unknown_option",flag:r,required:`Remove ${r}, or use it on the root command (pm --help ${r}).`,nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function dt(e,t,n){let o=Qe(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Qe(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Xt(e){return e.arguments??[]}function Xs(e){let t=Xt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Jo(e,t){if(!e)return!1;let n=v(t);return e.importers.some(o=>v(`${o.importer} import`)===n)||e.exporters.some(o=>v(`${o.exporter} export`)===n)}var ec=Symbol("pm.commandOptionTokens"),Zs=Symbol("pm.capturesOptionTokens");function tc(e){if(Reflect.get(e,Zs)===!0)return;Reflect.set(e,Zs,!0);let t=e.parseOptions.bind(e);e.parseOptions=n=>(Reflect.set(e,ec,[...n]),t(n))}function ku(e){let t=new Map;for(let n of e.options){let o={arity:n.required?"required":n.optional?"optional":"none",key:n.attributeName(),variadic:n.variadic};for(let i of[n.short,n.long])i&&t.set(i,o)}return t}function Su(e){let t=Reflect.get(e,"_passThroughOptions")===!0;return!t&&Reflect.get(e,"_enablePositionalOptions")!==!0?{}:{stop:{atSubcommand:n=>e.commands.some(o=>o.name()===n||o.aliases().includes(n)),atFirstUnrecognized:t}}}function nc(e){let t=[];for(let o=e;o?.parent;o=o.parent)t.unshift(o);let n=[];for(let o of t){let i=Reflect.get(o,ec);if(i===void 0)continue;let r=ku(o),a=[];for(let s=o;s;s=s.parent)a.push(s);n.push({tokens:i,optionOf:s=>r.get(s),includesLooseFlags:o===e,negativeNumbersAreValues:!a.some(s=>s.options.some(c=>c.short!==void 0&&/^-\d$/u.test(c.short))),...Su(o)})}return n}function oc(e,t,n){t.length!==0&&aa(nc(e),t,n)}function Ko(e,t){let n=Xt(e),o=n.filter(c=>c.required).length,r=n.some(c=>c.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new I(`Missing required argument for extension command '${e.command}'. Usage: ${Xs(e)}${s}`,g.USAGE);if(t.length>r){let c=t.slice(r).join(" ");throw new I(`Too many arguments for extension command '${e.command}': ${c}. Usage: ${Xs(e)}${s}`,g.USAGE)}}function Eu(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Zt(e,t){return{definitions:e,inheritedFlags:Rt({readOutput:t}).map(n=>n.flag)}}function Au(e,t,n){let o=Object.keys(e).filter(r=>e[r]!==void 0).sort().map(Eu);if(o.length===0)return;let{inheritedFlags:i}=Zt([],n);throw new I(`Unknown option '${o.join(", ")}' for extension command '${t}'. This command declares no flags; it accepts only the host flags ${i.join(", ")}.`,g.USAGE,{code:"unknown_option",flag:o[0],required:`Remove ${o.join(", ")}, or ask the package to declare it with api.registerFlags.`,nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function Ru(e,t,n){let o=e.read_output_declared===!0;if(n.length>0){Gn(t,n,e.command,Zt(n,o));return}Au(t,e.command,o)}function Yo(e,t,n,o){e&&(Ko(e,t),Ru(e,n,o))}import{Command as ic}from"commander";var Ou=new Set(["--version","-V"]);function mt(e){let t;try{t=pe(e).argv}catch{return!1}let n=Vr(t),o=S(n);return o===void 0?!1:["package","packages","extension"].includes(n[o])&&["inventory","list"].includes(Tt(n.slice(o+1))??"")}function rc(e){if(j(e)[0]!=="item"||!e.includes("--dry-run"))return;let n=new ic().configureOutput({writeErr:()=>{}}).exitOverride(),o=new Set;for(let r of ue)for(let a of[r.flag,r.short,...r.aliases??[]]){if(a===void 0||o.has(a))continue;o.add(a);let s=r.value_name!==void 0||r.flag==="--pm-path";n.option(`${a}${s?" <value>":""}`)}try{n.parseOptions(e)}catch{}let i=n.opts();return{path:i.pmPath??i.path}}var Tu=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Xo=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),ac=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Iu=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Pu=new Set(["claim","close-task","pause-task","release","start-task","test"]),xe={setup:!0,listQuery:!0,mutation:!0,operation:!0},$u=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function ut(e){return e.some(t=>Ou.has(t))}function Nu(e,t){if(!M.some(o=>o.canonical_argv[0]===t))return;let n=new ic().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Te(t,G(t))){let i=o.takes_value?o.value_required?" <value>":" [value]":"";for(let r of[o.flag,o.short,...o.aliases??[]])r!==void 0&&n.option(`${r}${i}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return xe;let i=V([t,...o.operands])?.alias;if(M.some(r=>r.alias===i))return{...xe,targetCommandName:i}}catch{return xe}}function Zo(e){if(ut(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||$(e).requested)return xe;let t=E(e);if(!t)return xe;let n=t.trim().toLowerCase(),o=j(e),i=V(o)?.alias;if(M.some(a=>a.alias===i))return{...xe,targetCommandName:i};let r=Nu(o,n==="ctx"?"context":n);return r||(Tu.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Xo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:ac.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Iu.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:xe)}function Qo(e){return e.length===0||$(e).requested||e.includes("--explain")&&E(e)===void 0}function ei(e,t){return mt(t)||ut(t)?!1:ae(t)||$(t).requested?!0:!!E(t)}function ti(e){if(ut(e))return!1;let t=E(e);return t?$u.has(t):!1}function Lu(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(l=>{let d=l.indexOf("=");return d>=0?l.slice(0,d):l}).find(l=>l==="--literal"||l==="--regex"||l==="--replacement"),r=i?e.argv.map(l=>{let d=l.indexOf("=");return(d>=0?l.slice(0,d):l)===o?d>=0?`${i}${l.slice(d)}`:i:l}):e.argv,a=We(r),s=i&&n>=0?`${o}=[redacted]`:t,c=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function ni(e){let t=e.commandName;if(!t)return;let n=e.trace.find(l=>l.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(l=>l.length>0),i=o.length>0?o.join(" "):"the canonical flag",r=ac.has(t)||Pu.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",c=Lu({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new I(`Refusing to auto-correct ${s} ${c.sourceDisplay} to ${c.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:a,examples:[_(c.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:c.argv,suggested_retry:_(c.argv)}})}var Mu=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),Fu=new Set(["parse","preflight","execute","unknown"]),Du=new Set(["usage","validation","conflict","runtime","unknown"]);function be(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function oi(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Qt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function ii(e){if(!e)return;let t=e.trim().toLowerCase();if(Mu.has(t))return t}function ri(e){if(!e)return;let t=e.trim().toLowerCase();if(Fu.has(t))return t}function ai(e){if(!e)return;let t=e.trim().toLowerCase();if(Du.has(t))return t}function si(e){let t=be(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(oi(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let i=Qt(e,"failed");if(typeof i=="number"&&i>0)return`failed_runs:${i}`;let r=e?.run_results;if(Array.isArray(r)){let a=r.filter(s=>gn(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function ci(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function li(){let e=gn(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Qt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,i=ma(o),r=be(e,"error_code","errorCode")??ci(i,o),a=ai(be(e,"error_category","errorCategory"))??(i?void 0:ht(r)),s=i?void 0:si(e)??`command_exit_${o}`,c=ii(be(e,"command_resolution","commandResolution"))??St({ok:i,errorCode:r,errorCategory:a}),l=ri(be(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,command_resolution:c,resolution_stage:l}}var di="PM_CLI_PACKAGE_ROOT",hc=Symbol("pm.deprecatedAliasInvocation"),nn=new Map;for(let e of K){let t=e.alias.split(" ")[0],n=nn.get(t)??[];n.push(e),nn.set(t,n)}for(let e of nn.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function ju(){return tr(import.meta.url,["../.."])}(typeof process.env[di]!="string"||process.env[di]?.trim().length===0)&&(process.env[di]=ju());var Se=null,q=null,on=null;function Uu(e){Se=e}function qu(e){T=e}var pt=null,ke=null,T=new Map,yi=250,Hu=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),Gu=new Set(["1","true","yes","on"]),zu=Ye(()=>import("./chunks/register-setup-3QYD5H4H.js")),Wu=Ye(()=>import("./chunks/register-list-query-EKSCZWEZ.js")),Bu=Ye(()=>import("./chunks/register-mutation-ZIAOKKUJ.js")),Vu=Ye(()=>import("./chunks/register-operations-ECVBZ5FM.js"));function tn(e){return _(e)}function yc(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>ge(o)??o))];return n.length>0?n:void 0}function Ju(e,t,n,o){if(n?.suggested_retry||o===no||o===to||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=ee(t),r=new Set(i.map(m=>ge(m)??m)),a=yc(e),s=t.find(m=>w.commands.some(u=>u.name()===m)),c=s?w.commands.find(m=>m.name()===s):void 0,l=new Set([...w.options,...c?.options??[]].flatMap(m=>m.flags.split(/[ ,|]+/).map(u=>ge(u)).filter(u=>u!==void 0))),d=a?.filter(m=>{let u=ge(m)??m;return r.has(u)?!1:l.has(u)||So(t,s,u,T)!==void 0});return d&&d.length>0?d:void 0}function Ku(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?ge(i):void 0,a=e.find(u=>w.commands.some(p=>p.name()===u)),s=a?w.commands.find(u=>u.name()===a):void 0,c=r?s?.options.find(u=>u.flags.split(/[ ,|]+/).includes(r)):void 0,l=So(e,a,r,T),d=r?c?.isBoolean()===!0||l===!1?[r]:[r,"<value>"]:[],m=r?tn([...e,...d]):t;return m===t?void 0:m}function Yu(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let i=e[o];i!==void 0&&(o==="allowed_values"||i!==null)&&(n[o]=i)}return n}function Xu(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...Yu(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function sc(e,t){return{...e,recovery:t}}function Zu(e,t){if(t===void 0)return;let n=Fa(e,t.code,t.field,$a(e,t.code,t.recovery)),o=Qu(e),i=Da(e,t.code,t.field,n,o),r=La(e,t.code,i,o,()=>Ur(P(process.cwd(),N(e).path)));return ja(e,t.code,r,o)}var cc=" ";function Qu(e){let t=e.map(i=>i===""?cc:/^--(?:pm-)?path=$/u.test(i)?`${i}${cc}`:i),n=N(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=Ee({});return n!==void 0&&o.length>0?null:o}function _c(e,t,n){let o=We(t),i=j(o),r=S(i),[a,s]=r===void 0?[]:i.slice(r,r+2),c=o.includes("--explain");e=e===void 0?void 0:xr(e);let l=Zu(o,e),d=l&&(a==="history-redact"||a==="history"&&s==="redact")?{...l,...l.attempted_command?{attempted_command:tn(o)}:{},...l.normalized_args?{normalized_args:[...o]}:{},...l.suggested_retry?{suggested_retry:tn(o)}:{},...l.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:l;if(d?.recovery_mode==="compact"&&!c)return sc(e,d);let m=tn(o),u=ee(o),p=Ju(n,o,d,e?.code),f=Ku(o,m,p,d),y=Xu({invocationArgv:o,attemptedCommand:m,providedFields:u,inferredMissing:p,suggestedRetry:f,existingRecovery:d});return sc(e,y)}async function ft(e){let t=q;q=null,await Ua(t,e);let n=Se;if(Se=null,!n){Ct();return}let o=[],i=fr();try{await qa({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await rr(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:de(),affected:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{Ct()}!n.globalOptions.json&&o.length>0&&x(`[pm] warning: afterCommand hook_warnings=${W(o)}`),n.profileEnabled&&o.length>0&&x(`profile:extensions hook_warnings=${W(o)}`)}async function wc(e,t){await Er();let n=q,o=Se,i=n?.command??o?.commandName??e,r=n??An(o?.globalOptions??t),a=T.get(v(i))?.source;$n(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:r.source_context,source_context_source:r.source_context_source,pm_version:n?.pm_version??He,extension:a})}function vc(e){return Gu.has((process.env[e]??"").trim().toLowerCase())}function Cc(e){return vc("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Hu.has(Math.trunc(e))}async function rn(e,t){return Cc(e.exit_code)?(await wc(e.command,t),Ir({...e,source_context:e.source_context??An(t).source_context}),!0):!1}async function xc(e){let t=J(me(e.error)),n=gs(t);e.bootstrapGlobal.json?x(JSON.stringify(et(ps(t,g.GENERIC_FAILURE)),null,2)):x(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await wc(e.attemptedCommand,e.bootstrapGlobal),Nn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,await cn(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||x(`Failed to report error: ${me(r)}`)}try{await ft({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||x(`Failed to run error hooks: ${me(r)}`)}try{await Oe()}catch(r){e.bootstrapGlobal.json||x(`Failed to flush error reporting: ${me(r)}`)}}var ep={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},mi=new Map;function ui(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function bc(e,t){return e.options.some(n=>n.long===t)}function kc(e,t){return e.options.some(n=>n.short===t)}function pi(e,t,n,o){let i=t.trim();if(!i||!Li(i))return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(kc(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,qn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!bc(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,qn);return}e.option(`${a} <value>`,r)}}async function Sc(e,t){let n=ep[e];if(!n)return[];let o=`${t}:${n}`,i=mi.get(o);if(i)return i;if(!await Y(X(t)))return mi.set(o,[]),[];let r=await F(t),s=(yn(r.schema).command_to_fields.get(n)??[]).flatMap(c=>[c.cli_flag,...c.cli_aliases].map(d=>({long:`--${d}`,type:ui(c.type),value_type:ui(c.type)})));return mi.set(o,s),s}async function Ec(e,t){let n=N(t),o=P(process.cwd(),n.path);if(!await Y(X(o)))return;let i=ke?.key===vi(o)?ke.snapshot:null,r=i===null?await F(o):i.settings,a=yn(r.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let c of s){let l=oe(e,c.path.split(" "));if(l)for(let d of a.command_to_fields.get(c.command)??[]){let m=d.description??"";pi(l,d.cli_flag,m,d.repeatable);for(let u of d.cli_aliases)pi(l,u,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function _i(e,t,n,o,i){let r=E(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await F(t),s=ce(a,o);Gs(e,s,n)}catch{}}function fi(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Ac(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function wi(e){return e.some(t=>t==="--profile")}function vi(e){return`pm-root:${e}`}function gi(e){for(let t of e)t.startsWith("settings_read_")&&fe(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function Rc(e,t){e.profile&&(x(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&x(`profile:extensions activation_warnings=${W(t.activationWarnings)}`))}function an(e,t,n){if(!e)return;let o=v(n.commandPath??"")||"<none>";x(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function sn(e,t=Re){let n=vi(e);if(ke?.key===n)return ke.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await ar({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return ke={key:n,snapshot:s},s}catch{return ke={key:n,snapshot:null},null}}async function Ge(e,t,n=F){let o=t?lt(t):"all",i=Ac(e,o);if(pt?.key===i)return pt.snapshot;try{let r=await n(e),a=await Je({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?zo(t):void 0}),s=await Ke({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(p=>v(p.command)))].filter(p=>p.length>0).sort((p,f)=>p.localeCompare(f)),l=Es(s.registrations.flags),d=ks(s.commands.handlers,s.registrations.commands),m=Rs(c,s.registrations.commands,s.registrations.flags,d),u={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:r,commandHandlers:c,commandFlagHelp:l,commandDescriptors:m,commandAliases:d,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:p,module:f})=>({name:p,module:f}))};return pt={key:i,snapshot:u},u}catch{return pt={key:i,snapshot:null},null}}async function Oc(e){let t=Ze(e);if(t.noExtensions){let a=P(process.cwd(),t.path);return await Y(X(a))&&gi((await Re(a)).warnings),null}let n=P(process.cwd(),t.path),o=await sn(n);if(!o)return null;gi(o.settingsReadWarnings);let i={commandPath:A(e),commandArgs:Wo(e)};if(!ct(o.discovery,i))return an(t.profile,o,i),null;let r=await Ge(n,i);return r?(Rc(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function Ci(e){let t=await Ge(e);return t?new Map(t.commandDescriptors):T}async function tp(e,t){return!e.requested||t.noExtensions||Le(w,e.commandPathTokens)?T:Ci(P(process.cwd(),t.path))}async function Tc(e,t){return(await Wr({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function Ic(e,t,n){let o=t.author;return zr(e,ga.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function Pc(e,t,n,o=[]){let i=A(e),r=zn(e.args.map(String),o),a={...t};delete a.author;let s={...n},c=P(process.cwd(),n.path),l={args:[...r],path:n.path},d=await xt({command:i,args:r,options:a,global:s,pm_root:c});n.profile&&d.warnings.length>0&&x(`profile:extensions parser_warnings=${W(d.warnings)}`),r=d.context.args,a=d.context.options,s=d.context.global,Xn(l,{args:r,path:s.path},a),Yo(T.get(v(i)),r,a,o),Ae(void 0),vt({command:i,args:r,options:{...a},global:{...s},pm_root:c});let m=await En({command:i,args:r,options:a,global:s,pm_root:c,sdk:Ic(c,s,i)});if(s.profile&&m.warnings.length>0&&x(`profile:extensions command_handler_warnings=${W(m.warnings)}`),!m.handled)throw m.warnings.length>0?Ar(i,m):new I(`Command "${i}" is provided by extensions and is not currently available.`,g.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),Ae(m.result),m.result}var lc=Symbol("pm.wrappedActionHandler");function np(e,t){let n=e[e.length-1];return n instanceof hi?n:t}function dc(e,t,n){e&&n.length>0&&x(`profile:extensions ${t}=${W(n)}`)}function op(e){let t=T.get(v(e.commandPath));if(!t||!Jo(e.activeRegistrations,e.commandPath))return;let n=Xt(t).length===0?ra(e.commandArgs):zn(e.commandArgs,e.extensionFlagDefinitions);Ko(t,n)}function ip(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function xi(e,t,n){if(!at(e))return;let o=T.get(v(t))?.read_output_declared===!0;return Zt(n,o)}function $c(e){let t=n=>{let o=n;if(tc(n),typeof o._actionHandler=="function"&&o[lc]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let s=np(a,n),c=Date.now();Un(s);let l=Ze(s),d=H(A(s));if(["package inventory","packages inventory","extension inventory"].includes(d))return Ta(d,l.expectHash),await i.apply(this,a);let m=P(process.cwd(),l.path),u=s.args.map(String),p=le(),f=p?dt(p,d,u):[],y=await Sc(d,m),h=xi(s,d,f),C=Ue(s,u,[...f,...y],h);oc(s,f,d),T.has(v(d))&&delete C.author,h!==void 0&&Qs(C,f,d);let R={args:[...u],path:l.path},O=await xt({command:d,args:u,options:C,global:l,pm_root:m});dc(l.profile,"parser_warnings",O.warnings),u=O.context.args,C=O.context.options,se(s,C),l=O.context.global,Xn(R,{args:u,path:l.path},C),op({activeRegistrations:p,commandPath:d,commandArgs:u,extensionFlagDefinitions:f}),l=await ta(l),Pt(s,l),ip(s,a,u),It(s,C),Ae(void 0),vt({command:d,args:u,options:{...C},global:{...l},pm_root:m});let k=await En({command:d,args:u,options:C,global:l,pm_root:m,sdk:Ic(m,l,d)});if(dc(l.profile,"command_handler_warnings",k.warnings),k.handled){Ae(k.result),kn(k.result,{...l,command:d,commandArgs:u,commandOptions:C,pmRoot:m}),l.profile&&x(`profile:command=${d} took_ms=${Date.now()-c}`);return}return await i.apply(this,a)},o[lc]=!0}for(let i of n.commands)t(i)};t(e)}async function en(e){T=new Map,re({overrides:[]}),e&&await _i(e.rootProgram,e.pmRoot,e.invocationArgv,or(),e.settings)}function rp(e,t,n,o){if(t?.flags&&t.flags.length>0){Ro(e,t.flags);let i=Oo(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);t&&at(e)&&e.addHelpText("after",Io(t)),o&&e.addHelpText("after",o)}function ap(e,t,n,o){t&&e.addHelpText("after",t),n&&e.addHelpText("after",Io(n)),o&&e.addHelpText("after",o)}function Nc(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.join(" "),c=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),l=c.length===0?"standard":c.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");Ft(r,l);for(let d of r.commands)i(d,[...a,d.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function Lc(e,t){let n=N(t),o=P(process.cwd(),n.path);if(n.noExtensions){await en({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await sn(o),r=je(t);if(!i){await en();return}if(!ct(i.discovery,r)){await en({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),an(wi(t),i,r);return}let a=await Ge(o,r);if(!a){await en({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}re(a.services),T=new Map(a.commandDescriptors),await _i(e,o,t,a.registrations,a.settings);let s=Ls(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>Ms(a.activationWarnings,x,d)),c=new Set(e.commands.map(d=>d.name())),l=d=>{let m=d.split(" ").filter(R=>R.length>0),u=a.commandDescriptors.get(d),p=oe(e,m),f=a.commandFlagHelp.get(d),y=u?$s(u):null;if(p){rp(p,u,f,y);return}let h=Ns(e,m);u?.description&&h.description(u.description);let C=f;u&&(Os(h,u),u.flags.length>0&&(Ro(h,u.flags),C=Oo(h,u.flags)??void 0)),ap(h,C,u,y),h.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...R)=>{let O=R[R.length-1],k=O instanceof hi?O:h,gt=Ze(k),Vc=Date.now(),ln=dt(a.registrations,d,k.args.map(String)),Si=Ue(k,k.args.map(String),ln,xi(k,d,ln)),Ei=await Pc(k,Si,gt,ln);await na(gt,Ei),kn(Ei,{...gt,command:d,commandArgs:k.args.map(String),commandOptions:Si,pmRoot:o}),gt.profile&&x(`profile:command=${d} took_ms=${Date.now()-Vc}`)})};for(let d of s)l(d);Nc(e,c,a.commandDescriptors)}var He=nr(import.meta.url,["../.."])??"0.0.0",w=jn(He);async function mc(e){if(!q)return;let t=Reflect.get(e,hc);typeof t=="string"&&await fa(t)}async function uc(e,t,n){let o=A(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function pc(e,t,n){!q||!await Rn(!0)||($n(e,t,n,{source_context:q.source_context,source_context_source:q.source_context_source}),Rr(e),on=q)}async function cn(e,t,n){let o=on;if(!o)return;on=null;let i=!1;try{let r=await F(o.global_pm_root);i=r.telemetry.enabled&&r.telemetry.installation_id===o.installation_id}catch{}await Rn(i)?Tr(e,t,n):Or()}async function sp(e){let t=await Oc(e);return Sn(t?.registrations??null),t}function Mc(e,t){t&&mt(t)||(e.hook("preAction",async(n,o)=>{Se=null,q=null,on=null,Ct(),Un(o);let i=o.optsWithGlobals(),r=Ze(o),a=H(A(o)),s=o.args.map(String),c={args:[...s],path:r.path},l=Ue(o,s),d={...r},m=P(process.cwd(),r.path),u=await sp(o);if(Wi(a,{...l,...zi(a,o.processedArgs),outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),Vo(o,a,d,l),await uc(o,void 0,()=>Lr(a,d)),!u){Se=sr({commandName:a,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:m}),q=await Ln({command:a,pm_version:He,args:s,options:l,global:d,pm_root:m}),await mc(e),await pc(a,s,l),await Mo(a,l,m,fi()),await Lo(a,s,l,d,m),await Yn({command:o,commandPath:a,commandArgs:s,commandOptions:l,expectHash:r.expectHash,pmRoot:m,globalOptions:d});return}cr(u.hooks),lr(u.commands),dr(u.parsers),mr(u.preflight),re(u.services),ur(u.renderers),Sn(u.registrations);let p=dt(u.registrations,a,s);l=Ue(o,s,p,xi(o,a,p)),Vo(o,a,d,l);let f=await xt({command:a,args:s,options:l,global:d,pm_root:u.pmRoot});d.profile&&f.warnings.length>0&&x(`profile:extensions parser_warnings=${W(f.warnings)}`),s=f.context.args,l=f.context.options,se(o,l),d=f.context.global;let y={args:[...s],path:d.path};It(o,l);let h=await gr({command:a,args:s,options:l,global:d,pm_root:u.pmRoot,decision:fi()});d.profile&&h.warnings.length>0&&x(`profile:extensions preflight_warnings=${W(h.warnings)}`),s=h.context.args,l=h.context.options,se(o,l),d=h.context.global,It(o,l);let C=h.decision;await Mo(a,l,u.pmRoot,C),await Lo(a,s,l,d,u.pmRoot),await Yn({command:o,commandPath:a,commandArgs:c.args,commandOptions:l,expectHash:r.expectHash,pmRoot:u.pmRoot,rewritten:Kn(c,[y,{args:s,path:d.path}]),globalOptions:{...d,path:r.path,noExtensions:r.noExtensions}});let R=C.run_extension_migrations?await uc(o,[],()=>Tc(u.registrations.migrations,u.pmRoot)):[];d.profile&&R.length>0&&x(`profile:extensions migration_warnings=${W(R)}`);let O=Bs(u.registrations.migrations);Se={hooks:u.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:u.pmRoot,profileEnabled:!!d.profile,migrationBlockers:O},Ae(void 0),vt({command:a,args:s,options:{...l},global:{...d},pm_root:u.pmRoot}),q=await Ln({command:a,pm_version:He,args:s,options:l,global:d,pm_root:u.pmRoot}),await mc(e),await pc(a,s,l);let k=await ir(u.hooks,{command:a,args:s,options:{...l},global:{...d},pm_root:u.pmRoot});d.profile&&k.length>0&&x(`profile:extensions hook_warnings=${W(k)}`),C.enforce_mandatory_migration_gate&&Vs(a,l,O)}),e.hook("postAction",async()=>{let n=li();await cn(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await ft(n),await Oe()}))}Mc(w);var fc=Symbol("pmCliIdempotentTopLevelRegistration");function Fc(e){let t=e;if(t[fc])return;t[fc]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new hi(r):n(o,...i)})}async function cp(e,t){if(Fc(e),t.setup){let{registerSetupCommands:n}=await zu();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Wu(),o=typeof t.targetCommandName=="string"&&Xo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Bu();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Vu();n(e)}}function qe(e){return e.rawInvocationArgv??e.invocationArgv}function lp(e){return async t=>{let n=ht(t.errorCode),o=St({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Fr({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:He,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function Dc(e){if(e.bootstrapGlobal.noExtensions||mt(e.invocationArgv))return;let t=je(e.invocationArgv),n=await sn(e.bootstrapPmRoot);if(n&&ct(n.discovery,t)){let o=await Ge(e.bootstrapPmRoot,t);jc(o);return}n&&an(wi(e.invocationArgv),n,t),re({overrides:[]})}function jc(e){if(!e){re({overrides:[]});return}re(e.services)}async function bi(e){await cn(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ft({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function Uc(){await cn(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ft({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function qc(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof I)&&(In(e.error)||!n))return!1;let o=J(me(e.error)),i=e.error instanceof I?e.error.exitCode:Tn(t),r=e.error instanceof I||Sr(e.error)?e.error.context:void 0,a=_c(r,e.invocationArgv,o),s=ms(o,a),c=et(e.bootstrapGlobal.lean?jt(yo(o,i,a)):yo(o,i,a)),l=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?Z(c,p=>`${JSON.stringify(p,null,2)}
|
|
39
|
+
`)}function Gs(e,t,n){let o=E(n);if(o!=="create"&&o!=="update")return;let i=rt(e,o);i&&i.addHelpText("after",su(o,t,n))}function cu(e,t){let n=Ve(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function lu(e){return Ve(e.status)?.toLowerCase()??"pending"}function du(e){return e.mandatory===!0}function mu(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function Bs(e){let t=[];return e.forEach((n,o)=>{if(!du(n.definition))return;let i=lu(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:cu(n.definition,o),status:i})}),t.sort(mu),t}function zs(e){return Array.isArray(e)&&e.length>0}var uu=new Set(["create","beads import","todos import"]),pu=new Set(["restore","update","close","delete","append","claim","release"]),fu=new Set(["comments","notes","learnings"]),gu=new Set(["files","docs","test"]),hu=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function No(e,t){let n=t.force===!0;return uu.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:pu.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:fu.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:gu.has(e)?{isMutation:zs(t.add)||zs(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function yu(e,t,n){if(No(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return $r(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>hu.has(i.trim().toLowerCase())):!1}function Ws(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _u(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(Ve(t[1])||i.push("source"),Ve(n.to)||i.push("--to"),i.length!==0)throw new I(`Schema migration requires ${i.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:i.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function wu(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Ws(n.status)!==Ws(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=ce(i,le()),s=await kt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let c=await vr(s,{schema:i.schema}),l=typeof n.assignee=="string"?n.assignee.trim():void 0;(l===void 0?c.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(l.toLowerCase())&&l)||x(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Lo(e,t,n,o,i){if(!yu(e,t,n)||(_u(e,t,n),!await Y(X(i))))return;let r=await Re(i);Ea(o.json===!0)||await wu(e,t,n,i,r.settings);let a=Pr({author:wt(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)fe(s)}function Vs(e,t,n){if(n.length===0)return;let o=No(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new I(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,g.CONFLICT)}async function Mo(e,t,n,o){if(!No(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await Y(X(n)))return;let{settings:r,metadata:a,warnings:s}=await Re(n);for(let c of s)fe(c);if(!_r(r)&&(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(yr(r),await wr(n,r,"item_format:auto_select_default")),o.run_preflight_item_format_sync)){let c=ce(r,le());await Nr(n,r.item_format,"item_format:pre_mutation_sync",c.type_to_folder,r.schema)}}function Fo(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=v(n);o.length!==0&&t.push(o)}return t}function De(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of Fo(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,H(i)]))]}function Do(e,t){let n=v(e);if(n.length===0)return!1;let o=De(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function Vt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...L(n.commands),...L(n.command_handlers),...L(n.command_overrides),...L(n.flag_commands),...L(n.parser_overrides),...Js(n.preflight_ownership),...Js(n.renderer_ownership)]:[]}function L(e){return e??[]}function Js(e){return L(e).flatMap(t=>t.commands)}function st(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Ks=new Set(["hooks","parser","preflight","renderers"]),Ys=new Set(["commands","schema","services","importers"]),vu=new Set(["reindex","search","search-advanced"]),Cu=new Set(["--template"]);function Fe(e,t){for(let n of t)if(e.has(n))return!0;return!1}function jo(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return vu.has(n??t)}function Uo(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function Jt(e){return v(e.commandPath??"")==="create"&&Uo(e,Cu)}function qo(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Bt(e,t){return e.some(n=>Do(n,t))||Jt(t)&&qo(e)}function Ho(e){return[L(e.hooks).length,(e.preflight_overrides??0)-L(e.preflight_ownership).length,L(e.item_types).length,L(e.item_fields).length,L(e.relationship_kinds).length,L(e.service_overrides).length,L(e.assurance_providers).length,L(e.renderer_overrides).length-L(e.renderer_ownership).length].some(n=>n>0)}function Go(e,t){let n=e.activation?.commands??[];if(n.length>0)return Bt(n,t);let o=Vt(e);if(Bt(o,t)||st(e).has("search")&&jo(t.commandPath))return!0;if(e.contributions)return Ho(e.contributions)}function Kt(e,t){let n=Go(e,t);if(n!==void 0)return n;let o=st(e);return!!(Fe(o,Ks)||Fe(o,Ys))}function ct(e,t){return e.effective.length===0?!1:lt(t)!=="all"?e.effective.some(o=>Kt(o,t)):e.effective.some(o=>{let i=st(o);return Vt(o).length>0||Fe(i,Ks)||Fe(i,Ys)||i.has("search")})}function lt(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=De(e).filter(i=>i.split(" ").every(r=>!r.startsWith("-"))).sort((i,r)=>r.length-i.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Jt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function zo(e){return lt(e)==="all"?void 0:t=>Kt(t,e)}function je(e){let t=$(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=j(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function Wo(e){let t=e.args.map(String);if(v(A(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.template.trim().length>0&&t.push("--template")}return t}var Yt=Symbol.for("pm.readOutputInvocationProvenance"),xu=new Map(ue.filter(e=>e.reservation_scope==="root_only").map(e=>[$t({long:e.flag}),e.flag]));function se(e,t){let n=Reflect.get(e,Yt);n!==void 0&&Reflect.set(t,Yt,n)}function Bo(e,t,n){let o=qi(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(ee(r.slice(2))),s=Ui.find(d=>d.command===o),c=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),l=Reflect.get(n,Yt);Reflect.set(n,Yt,{canonical_include_modes:l?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),se(n,e)}function bu(e){let t=e.optsWithGlobals(),n=A(e);if(H(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(c=>c.long===r.long))throw new I(`Unknown option '${r.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let c=i.getOptionValue(a);e.setOptionValueWithSource(a,c,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function Vo(e,t,n,o){Bo(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=Vi(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;se(o,e);let s=Bi(t);for(let l of a){let d=s.get(l),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let c=r.length>0?r.join(","):void 0;c===void 0?delete n.outputInclude:n.outputInclude=c;for(let l=e;l;l=l.parent)l.setOptionValueWithSource("outputInclude",c,"cli");Pt(e,n)}function Ue(e,t,n=[],o){let r={...bu(e)};se(e,r),delete r.json,delete r.quiet,delete r.path,delete r.pmPath,delete r.noExtensions,delete r.extensions,delete r.profile,delete r.pager,delete r.changedFields,delete r.fullChangedFields,delete r.idOnly,delete r.lean,delete r.tokenAccounting,delete r.outputInclude,delete r.outputLimit,delete r.outputBudget,delete r.outputFormat,delete r.outputSession,delete r.expectHash;let a=ia(t);for(let[s,c]of Object.entries(a))r[s]===void 0&&(r[s]=c);if(n.length>0){let s=Hn(n),c=G(A(e)).map(u=>({long:u.flag,short:u.short,aliases:u.aliases})),l={...a};for(let u of s)r[u]!==void 0&&(l[u]=r[u]);Gn(l,[...c,...n],A(e),o);let d=sa(a,nc(e),n),m=oa(r,n,d,A(e));return se(r,m),m}return r}function Qs(e,t,n){let o=Hn(t.map(({long:a})=>({long:a}))),i=[...xu].find(([a])=>e[a]!==void 0&&!o.has(a));if(i===void 0)return;let r=i[1];throw new I(`Unknown option '${r}' for extension command '${n}'. ${r} is a root-only pm flag and this command does not declare it.`,g.USAGE,{code:"unknown_option",flag:r,required:`Remove ${r}, or use it on the root command (pm --help ${r}).`,nextSteps:[`Run pm contracts --command ${n} --flags-only --json to list the flags this command accepts.`]})}function dt(e,t,n){let o=Qe(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Qe(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Xt(e){return e.arguments??[]}function Xs(e){let t=Xt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Jo(e,t){if(!e)return!1;let n=v(t);return e.importers.some(o=>v(`${o.importer} import`)===n)||e.exporters.some(o=>v(`${o.exporter} export`)===n)}var ec=Symbol("pm.commandOptionTokens"),Zs=Symbol("pm.capturesOptionTokens");function tc(e){if(Reflect.get(e,Zs)===!0)return;Reflect.set(e,Zs,!0);let t=e.parseOptions.bind(e);e.parseOptions=n=>(Reflect.set(e,ec,[...n]),t(n))}function ku(e){let t=new Map;for(let n of e.options){let o={arity:n.required?"required":n.optional?"optional":"none",key:n.attributeName(),variadic:n.variadic};for(let i of[n.short,n.long])i&&t.set(i,o)}return t}function Su(e){let t=Reflect.get(e,"_passThroughOptions")===!0;return!t&&Reflect.get(e,"_enablePositionalOptions")!==!0?{}:{stop:{atSubcommand:n=>e.commands.some(o=>o.name()===n||o.aliases().includes(n)),atFirstUnrecognized:t}}}function nc(e){let t=[];for(let o=e;o?.parent;o=o.parent)t.unshift(o);let n=[];for(let o of t){let i=Reflect.get(o,ec);if(i===void 0)continue;let r=ku(o),a=[];for(let s=o;s;s=s.parent)a.push(s);n.push({tokens:i,optionOf:s=>r.get(s),includesLooseFlags:o===e,negativeNumbersAreValues:!a.some(s=>s.options.some(c=>c.short!==void 0&&/^-\d$/u.test(c.short))),...Su(o)})}return n}function oc(e,t,n){t.length!==0&&aa(nc(e),t,n)}function Ko(e,t){let n=Xt(e),o=n.filter(c=>c.required).length,r=n.some(c=>c.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new I(`Missing required argument for extension command '${e.command}'. Usage: ${Xs(e)}${s}`,g.USAGE);if(t.length>r){let c=t.slice(r).join(" ");throw new I(`Too many arguments for extension command '${e.command}': ${c}. Usage: ${Xs(e)}${s}`,g.USAGE)}}function Eu(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Zt(e,t){return{definitions:e,inheritedFlags:Rt({readOutput:t}).map(n=>n.flag)}}function Au(e,t,n){let o=Object.keys(e).filter(r=>e[r]!==void 0).sort().map(Eu);if(o.length===0)return;let{inheritedFlags:i}=Zt([],n);throw new I(`Unknown option '${o.join(", ")}' for extension command '${t}'. This command declares no flags; it accepts only the host flags ${i.join(", ")}.`,g.USAGE,{code:"unknown_option",flag:o[0],required:`Remove ${o.join(", ")}, or ask the package to declare it with api.registerFlags.`,nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function Ru(e,t,n){let o=e.read_output_declared===!0;if(n.length>0){Gn(t,n,e.command,Zt(n,o));return}Au(t,e.command,o)}function Yo(e,t,n,o){e&&(Ko(e,t),Ru(e,n,o))}import{Command as ic}from"commander";var Ou=new Set(["--version","-V"]);function mt(e){let t;try{t=pe(e).argv}catch{return!1}let n=Vr(t),o=S(n);return o===void 0?!1:["package","packages","extension"].includes(n[o])&&["inventory","list"].includes(Tt(n.slice(o+1))??"")}function rc(e){if(j(e)[0]!=="item"||!e.includes("--dry-run"))return;let n=new ic().configureOutput({writeErr:()=>{}}).exitOverride(),o=new Set;for(let r of ue)for(let a of[r.flag,r.short,...r.aliases??[]]){if(a===void 0||o.has(a))continue;o.add(a);let s=r.value_name!==void 0||r.flag==="--pm-path";n.option(`${a}${s?" <value>":""}`)}try{n.parseOptions(e)}catch{}let i=n.opts();return{path:i.pmPath??i.path}}var Tu=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Xo=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),ac=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Iu=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Pu=new Set(["claim","close-task","pause-task","release","start-task","test"]),xe={setup:!0,listQuery:!0,mutation:!0,operation:!0},$u=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function ut(e){return e.some(t=>Ou.has(t))}function Nu(e,t){if(!M.some(o=>o.canonical_argv[0]===t))return;let n=new ic().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Te(t,G(t))){let i=o.takes_value?o.value_required?" <value>":" [value]":"";for(let r of[o.flag,o.short,...o.aliases??[]])r!==void 0&&n.option(`${r}${i}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return xe;let i=V([t,...o.operands])?.alias;if(M.some(r=>r.alias===i))return{...xe,targetCommandName:i}}catch{return xe}}function Zo(e){if(ut(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||$(e).requested)return xe;let t=E(e);if(!t)return xe;let n=t.trim().toLowerCase(),o=j(e),i=V(o)?.alias;if(M.some(a=>a.alias===i))return{...xe,targetCommandName:i};let r=Nu(o,n==="ctx"?"context":n);return r||(Tu.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Xo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:ac.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Iu.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:xe)}function Qo(e){return e.length===0||$(e).requested||e.includes("--explain")&&E(e)===void 0}function ei(e,t){return mt(t)||ut(t)?!1:ae(t)||$(t).requested?!0:!!E(t)}function ti(e){if(ut(e))return!1;let t=E(e);return t?$u.has(t):!1}function Lu(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(l=>{let d=l.indexOf("=");return d>=0?l.slice(0,d):l}).find(l=>l==="--literal"||l==="--regex"||l==="--replacement"),r=i?e.argv.map(l=>{let d=l.indexOf("=");return(d>=0?l.slice(0,d):l)===o?d>=0?`${i}${l.slice(d)}`:i:l}):e.argv,a=We(r),s=i&&n>=0?`${o}=[redacted]`:t,c=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function ni(e){let t=e.commandName;if(!t)return;let n=e.trace.find(l=>l.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(l=>l.length>0),i=o.length>0?o.join(" "):"the canonical flag",r=ac.has(t)||Pu.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",c=Lu({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new I(`Refusing to auto-correct ${s} ${c.sourceDisplay} to ${c.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:a,examples:[_(c.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:c.argv,suggested_retry:_(c.argv)}})}var Mu=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),Fu=new Set(["parse","preflight","execute","unknown"]),Du=new Set(["usage","validation","conflict","runtime","unknown"]);function be(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function oi(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Qt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function ii(e){if(!e)return;let t=e.trim().toLowerCase();if(Mu.has(t))return t}function ri(e){if(!e)return;let t=e.trim().toLowerCase();if(Fu.has(t))return t}function ai(e){if(!e)return;let t=e.trim().toLowerCase();if(Du.has(t))return t}function si(e){let t=be(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(oi(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let i=Qt(e,"failed");if(typeof i=="number"&&i>0)return`failed_runs:${i}`;let r=e?.run_results;if(Array.isArray(r)){let a=r.filter(s=>gn(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function ci(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function li(){let e=gn(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Qt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,i=ma(o),r=be(e,"error_code","errorCode")??ci(i,o),a=ai(be(e,"error_category","errorCategory"))??(i?void 0:ht(r)),s=i?void 0:si(e)??`command_exit_${o}`,c=ii(be(e,"command_resolution","commandResolution"))??St({ok:i,errorCode:r,errorCategory:a}),l=ri(be(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,command_resolution:c,resolution_stage:l}}var di="PM_CLI_PACKAGE_ROOT",hc=Symbol("pm.deprecatedAliasInvocation"),nn=new Map;for(let e of K){let t=e.alias.split(" ")[0],n=nn.get(t)??[];n.push(e),nn.set(t,n)}for(let e of nn.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function ju(){return tr(import.meta.url,["../.."])}(typeof process.env[di]!="string"||process.env[di]?.trim().length===0)&&(process.env[di]=ju());var Se=null,q=null,on=null;function Uu(e){Se=e}function qu(e){T=e}var pt=null,ke=null,T=new Map,yi=250,Hu=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),Gu=new Set(["1","true","yes","on"]),zu=Ye(()=>import("./chunks/register-setup-EWAZZWPL.js")),Wu=Ye(()=>import("./chunks/register-list-query-FCPGG2UT.js")),Bu=Ye(()=>import("./chunks/register-mutation-VD3JX23I.js")),Vu=Ye(()=>import("./chunks/register-operations-KHJD4GFZ.js"));function tn(e){return _(e)}function yc(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>ge(o)??o))];return n.length>0?n:void 0}function Ju(e,t,n,o){if(n?.suggested_retry||o===no||o===to||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let i=ee(t),r=new Set(i.map(m=>ge(m)??m)),a=yc(e),s=t.find(m=>w.commands.some(u=>u.name()===m)),c=s?w.commands.find(m=>m.name()===s):void 0,l=new Set([...w.options,...c?.options??[]].flatMap(m=>m.flags.split(/[ ,|]+/).map(u=>ge(u)).filter(u=>u!==void 0))),d=a?.filter(m=>{let u=ge(m)??m;return r.has(u)?!1:l.has(u)||So(t,s,u,T)!==void 0});return d&&d.length>0?d:void 0}function Ku(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?ge(i):void 0,a=e.find(u=>w.commands.some(p=>p.name()===u)),s=a?w.commands.find(u=>u.name()===a):void 0,c=r?s?.options.find(u=>u.flags.split(/[ ,|]+/).includes(r)):void 0,l=So(e,a,r,T),d=r?c?.isBoolean()===!0||l===!1?[r]:[r,"<value>"]:[],m=r?tn([...e,...d]):t;return m===t?void 0:m}function Yu(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let i=e[o];i!==void 0&&(o==="allowed_values"||i!==null)&&(n[o]=i)}return n}function Xu(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...Yu(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function sc(e,t){return{...e,recovery:t}}function Zu(e,t){if(t===void 0)return;let n=Fa(e,t.code,t.field,$a(e,t.code,t.recovery)),o=Qu(e),i=Da(e,t.code,t.field,n,o),r=La(e,t.code,i,o,()=>Ur(P(process.cwd(),N(e).path)));return ja(e,t.code,r,o)}var cc=" ";function Qu(e){let t=e.map(i=>i===""?cc:/^--(?:pm-)?path=$/u.test(i)?`${i}${cc}`:i),n=N(t).path;if(n!==void 0&&n.trim()!=="")return[];let o=Ee({});return n!==void 0&&o.length>0?null:o}function _c(e,t,n){let o=We(t),i=j(o),r=S(i),[a,s]=r===void 0?[]:i.slice(r,r+2),c=o.includes("--explain");e=e===void 0?void 0:xr(e);let l=Zu(o,e),d=l&&(a==="history-redact"||a==="history"&&s==="redact")?{...l,...l.attempted_command?{attempted_command:tn(o)}:{},...l.normalized_args?{normalized_args:[...o]}:{},...l.suggested_retry?{suggested_retry:tn(o)}:{},...l.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:l;if(d?.recovery_mode==="compact"&&!c)return sc(e,d);let m=tn(o),u=ee(o),p=Ju(n,o,d,e?.code),f=Ku(o,m,p,d),y=Xu({invocationArgv:o,attemptedCommand:m,providedFields:u,inferredMissing:p,suggestedRetry:f,existingRecovery:d});return sc(e,y)}async function ft(e){let t=q;q=null,await Ua(t,e);let n=Se;if(Se=null,!n){Ct();return}let o=[],i=fr();try{await qa({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await rr(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:de(),affected:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{Ct()}!n.globalOptions.json&&o.length>0&&x(`[pm] warning: afterCommand hook_warnings=${W(o)}`),n.profileEnabled&&o.length>0&&x(`profile:extensions hook_warnings=${W(o)}`)}async function wc(e,t){await Er();let n=q,o=Se,i=n?.command??o?.commandName??e,r=n??An(o?.globalOptions??t),a=T.get(v(i))?.source;$n(i,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:r.source_context,source_context_source:r.source_context_source,pm_version:n?.pm_version??He,extension:a})}function vc(e){return Gu.has((process.env[e]??"").trim().toLowerCase())}function Cc(e){return vc("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Hu.has(Math.trunc(e))}async function rn(e,t){return Cc(e.exit_code)?(await wc(e.command,t),Ir({...e,source_context:e.source_context??An(t).source_context}),!0):!1}async function xc(e){let t=J(me(e.error)),n=gs(t);e.bootstrapGlobal.json?x(JSON.stringify(et(ps(t,g.GENERIC_FAILURE)),null,2)):x(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await wc(e.attemptedCommand,e.bootstrapGlobal),Nn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,await cn(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||x(`Failed to report error: ${me(r)}`)}try{await ft({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||x(`Failed to run error hooks: ${me(r)}`)}try{await Oe()}catch(r){e.bootstrapGlobal.json||x(`Failed to flush error reporting: ${me(r)}`)}}var ep={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},mi=new Map;function ui(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function bc(e,t){return e.options.some(n=>n.long===t)}function kc(e,t){return e.options.some(n=>n.short===t)}function pi(e,t,n,o){let i=t.trim();if(!i||!Li(i))return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(kc(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,qn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!bc(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,qn);return}e.option(`${a} <value>`,r)}}async function Sc(e,t){let n=ep[e];if(!n)return[];let o=`${t}:${n}`,i=mi.get(o);if(i)return i;if(!await Y(X(t)))return mi.set(o,[]),[];let r=await F(t),s=(yn(r.schema).command_to_fields.get(n)??[]).flatMap(c=>[c.cli_flag,...c.cli_aliases].map(d=>({long:`--${d}`,type:ui(c.type),value_type:ui(c.type)})));return mi.set(o,s),s}async function Ec(e,t){let n=N(t),o=P(process.cwd(),n.path);if(!await Y(X(o)))return;let i=ke?.key===vi(o)?ke.snapshot:null,r=i===null?await F(o):i.settings,a=yn(r.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let c of s){let l=oe(e,c.path.split(" "));if(l)for(let d of a.command_to_fields.get(c.command)??[]){let m=d.description??"";pi(l,d.cli_flag,m,d.repeatable);for(let u of d.cli_aliases)pi(l,u,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function _i(e,t,n,o,i){let r=E(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await F(t),s=ce(a,o);Gs(e,s,n)}catch{}}function fi(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Ac(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function wi(e){return e.some(t=>t==="--profile")}function vi(e){return`pm-root:${e}`}function gi(e){for(let t of e)t.startsWith("settings_read_")&&fe(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function Rc(e,t){e.profile&&(x(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&x(`profile:extensions activation_warnings=${W(t.activationWarnings)}`))}function an(e,t,n){if(!e)return;let o=v(n.commandPath??"")||"<none>";x(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function sn(e,t=Re){let n=vi(e);if(ke?.key===n)return ke.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await ar({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return ke={key:n,snapshot:s},s}catch{return ke={key:n,snapshot:null},null}}async function Ge(e,t,n=F){let o=t?lt(t):"all",i=Ac(e,o);if(pt?.key===i)return pt.snapshot;try{let r=await n(e),a=await Je({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?zo(t):void 0}),s=await Ke({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(p=>v(p.command)))].filter(p=>p.length>0).sort((p,f)=>p.localeCompare(f)),l=Es(s.registrations.flags),d=ks(s.commands.handlers,s.registrations.commands),m=Rs(c,s.registrations.commands,s.registrations.flags,d),u={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:r,commandHandlers:c,commandFlagHelp:l,commandDescriptors:m,commandAliases:d,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:p,module:f})=>({name:p,module:f}))};return pt={key:i,snapshot:u},u}catch{return pt={key:i,snapshot:null},null}}async function Oc(e){let t=Ze(e);if(t.noExtensions){let a=P(process.cwd(),t.path);return await Y(X(a))&&gi((await Re(a)).warnings),null}let n=P(process.cwd(),t.path),o=await sn(n);if(!o)return null;gi(o.settingsReadWarnings);let i={commandPath:A(e),commandArgs:Wo(e)};if(!ct(o.discovery,i))return an(t.profile,o,i),null;let r=await Ge(n,i);return r?(Rc(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function Ci(e){let t=await Ge(e);return t?new Map(t.commandDescriptors):T}async function tp(e,t){return!e.requested||t.noExtensions||Le(w,e.commandPathTokens)?T:Ci(P(process.cwd(),t.path))}async function Tc(e,t){return(await Wr({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function Ic(e,t,n){let o=t.author;return zr(e,ga.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function Pc(e,t,n,o=[]){let i=A(e),r=zn(e.args.map(String),o),a={...t};delete a.author;let s={...n},c=P(process.cwd(),n.path),l={args:[...r],path:n.path},d=await xt({command:i,args:r,options:a,global:s,pm_root:c});n.profile&&d.warnings.length>0&&x(`profile:extensions parser_warnings=${W(d.warnings)}`),r=d.context.args,a=d.context.options,s=d.context.global,Xn(l,{args:r,path:s.path},a),Yo(T.get(v(i)),r,a,o),Ae(void 0),vt({command:i,args:r,options:{...a},global:{...s},pm_root:c});let m=await En({command:i,args:r,options:a,global:s,pm_root:c,sdk:Ic(c,s,i)});if(s.profile&&m.warnings.length>0&&x(`profile:extensions command_handler_warnings=${W(m.warnings)}`),!m.handled)throw m.warnings.length>0?Ar(i,m):new I(`Command "${i}" is provided by extensions and is not currently available.`,g.NOT_FOUND);return m.exitCode!==void 0&&(process.exitCode=m.exitCode),Ae(m.result),m.result}var lc=Symbol("pm.wrappedActionHandler");function np(e,t){let n=e[e.length-1];return n instanceof hi?n:t}function dc(e,t,n){e&&n.length>0&&x(`profile:extensions ${t}=${W(n)}`)}function op(e){let t=T.get(v(e.commandPath));if(!t||!Jo(e.activeRegistrations,e.commandPath))return;let n=Xt(t).length===0?ra(e.commandArgs):zn(e.commandArgs,e.extensionFlagDefinitions);Ko(t,n)}function ip(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function xi(e,t,n){if(!at(e))return;let o=T.get(v(t))?.read_output_declared===!0;return Zt(n,o)}function $c(e){let t=n=>{let o=n;if(tc(n),typeof o._actionHandler=="function"&&o[lc]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let s=np(a,n),c=Date.now();Un(s);let l=Ze(s),d=H(A(s));if(["package inventory","packages inventory","extension inventory"].includes(d))return Ta(d,l.expectHash),await i.apply(this,a);let m=P(process.cwd(),l.path),u=s.args.map(String),p=le(),f=p?dt(p,d,u):[],y=await Sc(d,m),h=xi(s,d,f),C=Ue(s,u,[...f,...y],h);oc(s,f,d),T.has(v(d))&&delete C.author,h!==void 0&&Qs(C,f,d);let R={args:[...u],path:l.path},O=await xt({command:d,args:u,options:C,global:l,pm_root:m});dc(l.profile,"parser_warnings",O.warnings),u=O.context.args,C=O.context.options,se(s,C),l=O.context.global,Xn(R,{args:u,path:l.path},C),op({activeRegistrations:p,commandPath:d,commandArgs:u,extensionFlagDefinitions:f}),l=await ta(l),Pt(s,l),ip(s,a,u),It(s,C),Ae(void 0),vt({command:d,args:u,options:{...C},global:{...l},pm_root:m});let k=await En({command:d,args:u,options:C,global:l,pm_root:m,sdk:Ic(m,l,d)});if(dc(l.profile,"command_handler_warnings",k.warnings),k.handled){Ae(k.result),kn(k.result,{...l,command:d,commandArgs:u,commandOptions:C,pmRoot:m}),l.profile&&x(`profile:command=${d} took_ms=${Date.now()-c}`);return}return await i.apply(this,a)},o[lc]=!0}for(let i of n.commands)t(i)};t(e)}async function en(e){T=new Map,re({overrides:[]}),e&&await _i(e.rootProgram,e.pmRoot,e.invocationArgv,or(),e.settings)}function rp(e,t,n,o){if(t?.flags&&t.flags.length>0){Ro(e,t.flags);let i=Oo(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);t&&at(e)&&e.addHelpText("after",Io(t)),o&&e.addHelpText("after",o)}function ap(e,t,n,o){t&&e.addHelpText("after",t),n&&e.addHelpText("after",Io(n)),o&&e.addHelpText("after",o)}function Nc(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.join(" "),c=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),l=c.length===0?"standard":c.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");Ft(r,l);for(let d of r.commands)i(d,[...a,d.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function Lc(e,t){let n=N(t),o=P(process.cwd(),n.path);if(n.noExtensions){await en({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await sn(o),r=je(t);if(!i){await en();return}if(!ct(i.discovery,r)){await en({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),an(wi(t),i,r);return}let a=await Ge(o,r);if(!a){await en({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}re(a.services),T=new Map(a.commandDescriptors),await _i(e,o,t,a.registrations,a.settings);let s=Ls(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>Ms(a.activationWarnings,x,d)),c=new Set(e.commands.map(d=>d.name())),l=d=>{let m=d.split(" ").filter(R=>R.length>0),u=a.commandDescriptors.get(d),p=oe(e,m),f=a.commandFlagHelp.get(d),y=u?$s(u):null;if(p){rp(p,u,f,y);return}let h=Ns(e,m);u?.description&&h.description(u.description);let C=f;u&&(Os(h,u),u.flags.length>0&&(Ro(h,u.flags),C=Oo(h,u.flags)??void 0)),ap(h,C,u,y),h.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...R)=>{let O=R[R.length-1],k=O instanceof hi?O:h,gt=Ze(k),Vc=Date.now(),ln=dt(a.registrations,d,k.args.map(String)),Si=Ue(k,k.args.map(String),ln,xi(k,d,ln)),Ei=await Pc(k,Si,gt,ln);await na(gt,Ei),kn(Ei,{...gt,command:d,commandArgs:k.args.map(String),commandOptions:Si,pmRoot:o}),gt.profile&&x(`profile:command=${d} took_ms=${Date.now()-Vc}`)})};for(let d of s)l(d);Nc(e,c,a.commandDescriptors)}var He=nr(import.meta.url,["../.."])??"0.0.0",w=jn(He);async function mc(e){if(!q)return;let t=Reflect.get(e,hc);typeof t=="string"&&await fa(t)}async function uc(e,t,n){let o=A(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function pc(e,t,n){!q||!await Rn(!0)||($n(e,t,n,{source_context:q.source_context,source_context_source:q.source_context_source}),Rr(e),on=q)}async function cn(e,t,n){let o=on;if(!o)return;on=null;let i=!1;try{let r=await F(o.global_pm_root);i=r.telemetry.enabled&&r.telemetry.installation_id===o.installation_id}catch{}await Rn(i)?Tr(e,t,n):Or()}async function sp(e){let t=await Oc(e);return Sn(t?.registrations??null),t}function Mc(e,t){t&&mt(t)||(e.hook("preAction",async(n,o)=>{Se=null,q=null,on=null,Ct(),Un(o);let i=o.optsWithGlobals(),r=Ze(o),a=H(A(o)),s=o.args.map(String),c={args:[...s],path:r.path},l=Ue(o,s),d={...r},m=P(process.cwd(),r.path),u=await sp(o);if(Wi(a,{...l,...zi(a,o.processedArgs),outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),Vo(o,a,d,l),await uc(o,void 0,()=>Lr(a,d)),!u){Se=sr({commandName:a,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:m}),q=await Ln({command:a,pm_version:He,args:s,options:l,global:d,pm_root:m}),await mc(e),await pc(a,s,l),await Mo(a,l,m,fi()),await Lo(a,s,l,d,m),await Yn({command:o,commandPath:a,commandArgs:s,commandOptions:l,expectHash:r.expectHash,pmRoot:m,globalOptions:d});return}cr(u.hooks),lr(u.commands),dr(u.parsers),mr(u.preflight),re(u.services),ur(u.renderers),Sn(u.registrations);let p=dt(u.registrations,a,s);l=Ue(o,s,p,xi(o,a,p)),Vo(o,a,d,l);let f=await xt({command:a,args:s,options:l,global:d,pm_root:u.pmRoot});d.profile&&f.warnings.length>0&&x(`profile:extensions parser_warnings=${W(f.warnings)}`),s=f.context.args,l=f.context.options,se(o,l),d=f.context.global;let y={args:[...s],path:d.path};It(o,l);let h=await gr({command:a,args:s,options:l,global:d,pm_root:u.pmRoot,decision:fi()});d.profile&&h.warnings.length>0&&x(`profile:extensions preflight_warnings=${W(h.warnings)}`),s=h.context.args,l=h.context.options,se(o,l),d=h.context.global,It(o,l);let C=h.decision;await Mo(a,l,u.pmRoot,C),await Lo(a,s,l,d,u.pmRoot),await Yn({command:o,commandPath:a,commandArgs:c.args,commandOptions:l,expectHash:r.expectHash,pmRoot:u.pmRoot,rewritten:Kn(c,[y,{args:s,path:d.path}]),globalOptions:{...d,path:r.path,noExtensions:r.noExtensions}});let R=C.run_extension_migrations?await uc(o,[],()=>Tc(u.registrations.migrations,u.pmRoot)):[];d.profile&&R.length>0&&x(`profile:extensions migration_warnings=${W(R)}`);let O=Bs(u.registrations.migrations);Se={hooks:u.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:u.pmRoot,profileEnabled:!!d.profile,migrationBlockers:O},Ae(void 0),vt({command:a,args:s,options:{...l},global:{...d},pm_root:u.pmRoot}),q=await Ln({command:a,pm_version:He,args:s,options:l,global:d,pm_root:u.pmRoot}),await mc(e),await pc(a,s,l);let k=await ir(u.hooks,{command:a,args:s,options:{...l},global:{...d},pm_root:u.pmRoot});d.profile&&k.length>0&&x(`profile:extensions hook_warnings=${W(k)}`),C.enforce_mandatory_migration_gate&&Vs(a,l,O)}),e.hook("postAction",async()=>{let n=li();await cn(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await ft(n),await Oe()}))}Mc(w);var fc=Symbol("pmCliIdempotentTopLevelRegistration");function Fc(e){let t=e;if(t[fc])return;t[fc]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new hi(r):n(o,...i)})}async function cp(e,t){if(Fc(e),t.setup){let{registerSetupCommands:n}=await zu();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Wu(),o=typeof t.targetCommandName=="string"&&Xo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Bu();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Vu();n(e)}}function qe(e){return e.rawInvocationArgv??e.invocationArgv}function lp(e){return async t=>{let n=ht(t.errorCode),o=St({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Fr({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:He,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function Dc(e){if(e.bootstrapGlobal.noExtensions||mt(e.invocationArgv))return;let t=je(e.invocationArgv),n=await sn(e.bootstrapPmRoot);if(n&&ct(n.discovery,t)){let o=await Ge(e.bootstrapPmRoot,t);jc(o);return}n&&an(wi(e.invocationArgv),n,t),re({overrides:[]})}function jc(e){if(!e){re({overrides:[]});return}re(e.services)}async function bi(e){await cn(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ft({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function Uc(){await cn(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ft({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function qc(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof I)&&(In(e.error)||!n))return!1;let o=J(me(e.error)),i=e.error instanceof I?e.error.exitCode:Tn(t),r=e.error instanceof I||Sr(e.error)?e.error.context:void 0,a=_c(r,e.invocationArgv,o),s=ms(o,a),c=et(e.bootstrapGlobal.lean?jt(yo(o,i,a)):yo(o,i,a)),l=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?Z(c,p=>`${JSON.stringify(p,null,2)}
|
|
40
40
|
`):c,null,2):ls(o,a,{lean:e.bootstrapGlobal.lean===!0});e.jsonErrors?ie(`${l}
|
|
41
41
|
`):x(l);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:i,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),u=await rn({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:i,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:q?.source_context},e.bootstrapGlobal);return await bi({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),u&&(Nn(Pn(e.error,o)),await Oe(yi)),process.exitCode=i,!0}async function Hc(e,t){let n=$(e.invocationArgv).commandPathTokens.join(" ")||vo(e.invocationArgv),o=H(n),i=`unknown command '${n}'`,r=P(process.cwd(),e.bootstrapGlobal.path),a=e.bootstrapGlobal.noExtensions?T:await Ci(r),s=je(e.invocationArgv),c=e.bootstrapGlobal.noExtensions?[]:await $o(r,{},De(s)),l=await it({message:i},w,a,{failedExtensions:c},qe(e)),d=_o(l.message,l.commandName,l.allowedTypes,{unknownCommandExamples:l.unknownCommandExamples,unknownCommandNextSteps:l.unknownCommandNextSteps,attemptedCommand:l.attemptedCommand,normalizedInvocationArgs:l.normalizedInvocationArgs,providedOptionFlags:l.providedOptionFlags,unknownOptionSuggestions:l.unknownOptionSuggestions,suggestedRetryCommand:l.suggestedRetryCommand,failedExtensions:c}),{errorCategory:m,commandResolution:u}=await e.emitTelemetryCommandError({command:o,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),p=await rn({command:o,error_code:d.code,error_category:m,exit_code:g.USAGE,error_message:d.detail,command_resolution:u,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await ko({message:i},w,a,e.bootstrapGlobal.lean===!0,{failedExtensions:c},qe(e)):await bo({message:i},w,a,{failedExtensions:c},qe(e)),y=wo(f,e.jsonErrors,c);await bi({errorMessage:i,exitCode:g.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:u,resolutionStage:"parse"}),e.jsonErrors?ie(`${Vn(y)}
|
|
42
42
|
`):x(y),p&&await Oe(yi),process.exitCode=g.USAGE}async function Gc(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let i=$(e.invocationArgv);return i.requested&&!Le(w,i.commandPathTokens)?(await Hc(e,t),!0):(await Uc(),!0)}async function zc(e,t){let n=await it(e.error,w,T,{},qe(e)),o=_o(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:i,commandResolution:r}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await rn({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:g.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:q?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await ko(e.error,w,T,e.bootstrapGlobal.lean===!0,{},qe(e)):await bo(e.error,w,T,{},qe(e)),c=await Fs(o.code,e.bootstrapPmRoot,{},De(je(e.invocationArgv))),l=wo(s,e.jsonErrors,c);await bi({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?ie(`${Vn(l)}
|