@unbrained/pm-cli 2026.10.19 → 2026.10.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +58 -0
  3. package/dist/cli/error-guidance.d.ts +15 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/main.js +1 -1
  6. package/dist/cli/register-list-query.js +2 -2
  7. package/dist/cli/register-operations.js +1 -1
  8. package/dist/cli/register-structured-mutation.js +1 -1
  9. package/dist/cli-bundle/bundle-manifest.json +1 -1
  10. package/dist/cli-bundle/chunks/{chunk-4MJ6WBMA.js → chunk-2B5HAZFK.js} +2 -2
  11. package/dist/cli-bundle/chunks/chunk-4D25HF3V.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-LBEMB3BW.js → chunk-4OYU5OXQ.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-4XFVAXA4.js → chunk-5PZ7JNMI.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-C6SAXKBO.js +3 -0
  15. package/dist/cli-bundle/chunks/chunk-DIKQ2AL5.js +2 -0
  16. package/dist/cli-bundle/chunks/chunk-DIR3YEFD.js +2 -0
  17. package/dist/cli-bundle/chunks/{chunk-O2ZRRLAP.js → chunk-DJQVNDXO.js} +3 -3
  18. package/dist/cli-bundle/chunks/chunk-DR6DUBTU.js +30 -0
  19. package/dist/cli-bundle/chunks/{chunk-5GZSX5HU.js → chunk-EMGMLKRV.js} +47 -47
  20. package/dist/cli-bundle/chunks/chunk-GWIGZDRS.js +3 -0
  21. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-QG4LMU7A.js → chunk-KBSVPUFD.js} +46 -45
  23. package/dist/cli-bundle/chunks/{chunk-NX7Q4LGN.js → chunk-MOC5BJHW.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-MZZIAC6S.js +20 -0
  25. package/dist/cli-bundle/chunks/{chunk-DMFM5R4G.js → chunk-NNB65OOO.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-D3EDNAN7.js → chunk-QPV6UD55.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-6DS5CAN2.js → chunk-TMXWWOPJ.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-H3XYP24A.js → chunk-V3XONSVC.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-V5GJTXYW.js +126 -0
  30. package/dist/cli-bundle/chunks/chunk-XAWE4EAK.js +2 -0
  31. package/dist/cli-bundle/chunks/{chunk-XH7C3A5N.js → chunk-ZNKFMIVA.js} +6 -6
  32. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +2 -0
  33. package/dist/cli-bundle/{focused-chunks/indexed-receipt-blobs-QW2VWWJE.js → chunks/indexed-receipt-blobs-65XXSPPR.js} +2 -2
  34. package/dist/cli-bundle/chunks/mutation-admission-FNWOVJLN.js +2 -0
  35. package/dist/cli-bundle/chunks/{register-list-query-WQUVDJIH.js → register-list-query-6PT5Y2EZ.js} +5 -5
  36. package/dist/cli-bundle/chunks/{register-mutation-IWIBQIO3.js → register-mutation-TAIQV46L.js} +4 -4
  37. package/dist/cli-bundle/chunks/register-operations-ONIRO22G.js +2 -0
  38. package/dist/cli-bundle/chunks/register-setup-OQMUZBJV.js +2 -0
  39. package/dist/cli-bundle/chunks/{settlement-hook-UNFMCKKQ.js → settlement-hook-UVFYSBMU.js} +2 -2
  40. package/dist/cli-bundle/chunks/stage-FCPVFO3B.js +2 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-32ZKLRWM.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-3TEIACFU.js → chunk-3LWH2RJC.js} +3 -3
  43. package/dist/cli-bundle/focused-chunks/{chunk-OV2WVLUR.js → chunk-44353U27.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-4HJVAUFX.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-SKYLOPU2.js → chunk-5IMM7GOF.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-JBJJW2WL.js → chunk-6QSZHRM7.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/chunk-7UD7XTOE.js +12 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-H6BVQ63U.js → chunk-CUWNNU4N.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-E2S42XCT.js +2 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-GRSQGMRR.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-HYMYAGSY.js → chunk-HNCMYF2W.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-WZTEFFQI.js → chunk-IAGFXKMZ.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-JI3RXXRN.js +78 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-JMZPZQHR.js +26 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-RLRMNFLF.js → chunk-KVYUQS6Y.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-O3M6YWVL.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-P5D7MHDS.js +20 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-PDOWLRHC.js +8 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/chunk-T27TLSEU.js +65 -0
  62. package/dist/cli-bundle/focused-chunks/{chunk-GWTV45SB.js → chunk-VD64TPXI.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-JDBO7SMR.js → chunk-VE6MTRH5.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/chunk-XE7P7N5X.js +8 -0
  65. package/dist/cli-bundle/focused-chunks/chunk-YIWDX6KO.js +91 -0
  66. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +2 -0
  67. package/dist/cli-bundle/{chunks/indexed-receipt-blobs-BVSHK4WQ.js → focused-chunks/indexed-receipt-blobs-CRP6HAZY.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/mutation-admission-KM57KDDF.js +2 -0
  69. package/dist/cli-bundle/focused-chunks/{settlement-hook-X4FNHTOD.js → settlement-hook-MNCHFCAX.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/stage-UJYGWNZ7.js +2 -0
  71. package/dist/cli-bundle/main.js +21 -21
  72. package/dist/cli-bundle/sdk-authoring.js +1 -1
  73. package/dist/cli-bundle/sdk-contracts.js +2 -2
  74. package/dist/cli-bundle/sdk-core.js +23 -23
  75. package/dist/cli-bundle/sdk-governance.js +1 -1
  76. package/dist/cli-bundle/sdk-graph.js +1 -1
  77. package/dist/cli-bundle/sdk-merge.js +58 -57
  78. package/dist/cli-bundle/sdk-query.js +1 -1
  79. package/dist/cli-bundle/sdk-runtime.js +1 -1
  80. package/dist/cli-bundle/sdk-testing.js +1 -1
  81. package/dist/cli-bundle/sdk.js +8 -8
  82. package/dist/core/fs/fs-utils.d.ts +2 -2
  83. package/dist/core/fs/fs-utils.js +1 -1
  84. package/dist/core/history/event-index.js +2 -2
  85. package/dist/core/item/actionability.js +1 -1
  86. package/dist/core/lock/lock-gc.d.ts +12 -5
  87. package/dist/core/lock/lock-gc.js +1 -1
  88. package/dist/core/lock/lock-owner.d.ts +33 -0
  89. package/dist/core/lock/lock-owner.js +2 -0
  90. package/dist/core/lock/lock.d.ts +11 -22
  91. package/dist/core/lock/lock.js +4 -3
  92. package/dist/core/output/output.d.ts +7 -2
  93. package/dist/core/output/output.js +5 -5
  94. package/dist/core/shared/errors.d.ts +50 -0
  95. package/dist/core/shared/errors.js +1 -1
  96. package/dist/core/store/settings.js +2 -2
  97. package/dist/mcp/server.js +1 -1
  98. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  99. package/dist/sdk/core.d.ts +1 -1
  100. package/dist/sdk/core.js +1 -1
  101. package/dist/sdk/dependencies/context-budget-recovery.d.ts +21 -0
  102. package/dist/sdk/dependencies/context-budget-recovery.js +2 -0
  103. package/dist/sdk/dependencies.js +1 -1
  104. package/dist/sdk/errors.d.ts +4 -1
  105. package/dist/sdk/errors.js +1 -1
  106. package/dist/sdk/extension-command-context.js +2 -2
  107. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  108. package/dist/sdk/governance/assurance-action.js +1 -1
  109. package/dist/sdk/governance/assurance.js +1 -1
  110. package/dist/sdk/governance/health.js +2 -2
  111. package/dist/sdk/index.d.ts +1 -1
  112. package/dist/sdk/index.js +1 -1
  113. package/dist/sdk/item-transaction.d.ts +13 -0
  114. package/dist/sdk/item-transaction.js +1 -1
  115. package/dist/sdk/lifecycle/structured-mutation-plan.d.ts +14 -1
  116. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  117. package/dist/sdk/output/list-envelope.d.ts +7 -0
  118. package/dist/sdk/output/list-envelope.js +2 -0
  119. package/dist/sdk/output.d.ts +1 -0
  120. package/dist/sdk/output.js +2 -2
  121. package/dist/sdk/pagination.d.ts +3 -3
  122. package/dist/sdk/pagination.js +1 -1
  123. package/dist/sdk/public-surface.json +1 -1
  124. package/dist/sdk/query/context.js +2 -2
  125. package/dist/sdk/query/list.d.ts +2 -0
  126. package/dist/sdk/query/list.js +1 -1
  127. package/dist/sdk/query/projection-contracts.d.ts +1 -1
  128. package/dist/sdk/query/projection-contracts.js +1 -1
  129. package/dist/sdk/relationship-context.d.ts +2 -0
  130. package/dist/sdk/relationship-context.js +1 -1
  131. package/dist/sdk/runtime/mutation-admission.d.ts +2 -0
  132. package/dist/sdk/runtime/mutation-admission.js +2 -0
  133. package/dist/sdk/runtime-input.d.ts +2 -0
  134. package/dist/sdk/runtime-input.js +1 -1
  135. package/dist/sdk/runtime.js +1 -1
  136. package/dist/sdk/structured-mutations.d.ts +2 -0
  137. package/dist/sdk/structured-mutations.js +1 -1
  138. package/dist/sdk/test/execution.d.ts +1 -0
  139. package/dist/sdk/test/execution.js +2 -2
  140. package/docs/AGENT_RUNTIME_PRIMITIVES.md +9 -0
  141. package/docs/ASSURANCE.md +17 -2
  142. package/docs/COMMANDS.md +31 -3
  143. package/docs/CONFIGURATION.md +29 -0
  144. package/docs/CONTEXT_RELEVANCE.md +15 -0
  145. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +26 -3
  146. package/docs/PR_REVIEW_LOOP.md +32 -12
  147. package/docs/SCRIPTING.md +10 -0
  148. package/docs/SDK.md +144 -0
  149. package/docs/TESTING.md +43 -1
  150. package/docs/agent-task-token-baseline.json +1 -1
  151. package/marketplace.json +1 -1
  152. package/package.json +1 -1
  153. package/packages/pm-beads/package.json +1 -1
  154. package/packages/pm-calendar/package.json +1 -1
  155. package/packages/pm-command-kit/package.json +1 -1
  156. package/packages/pm-digital-twin/package.json +1 -1
  157. package/packages/pm-governance-audit/package.json +1 -1
  158. package/packages/pm-guide-shell/package.json +1 -1
  159. package/packages/pm-kanban/package.json +1 -1
  160. package/packages/pm-lifecycle-hooks/package.json +1 -1
  161. package/packages/pm-linked-test-adapters/package.json +1 -1
  162. package/packages/pm-search-advanced/package.json +1 -1
  163. package/packages/pm-templates/package.json +1 -1
  164. package/packages/pm-todos/package.json +1 -1
  165. package/packages/pm-vcs/package.json +1 -1
  166. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  167. package/plugins/pm-claude/package.json +1 -1
  168. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  169. package/plugins/pm-codex/package.json +1 -1
  170. package/plugins/pm-codex/plugin.json +1 -1
  171. package/runtime-dependencies.json +1 -1
  172. package/dist/cli-bundle/chunks/chunk-4CXQSRSP.js +0 -126
  173. package/dist/cli-bundle/chunks/chunk-4ICKT4GH.js +0 -3
  174. package/dist/cli-bundle/chunks/chunk-OEJ3G7XT.js +0 -20
  175. package/dist/cli-bundle/chunks/chunk-QBNEZII5.js +0 -30
  176. package/dist/cli-bundle/chunks/chunk-QKAAZWGC.js +0 -3
  177. package/dist/cli-bundle/chunks/chunk-TK3G3GAP.js +0 -2
  178. package/dist/cli-bundle/chunks/register-operations-SUWOZNDU.js +0 -2
  179. package/dist/cli-bundle/chunks/register-setup-QGM5YJW7.js +0 -2
  180. package/dist/cli-bundle/chunks/stage-7DELI4Z5.js +0 -2
  181. package/dist/cli-bundle/focused-chunks/chunk-2IEWB6MB.js +0 -2
  182. package/dist/cli-bundle/focused-chunks/chunk-5YTOYBTZ.js +0 -65
  183. package/dist/cli-bundle/focused-chunks/chunk-BJMPRB7A.js +0 -91
  184. package/dist/cli-bundle/focused-chunks/chunk-ENZMATOY.js +0 -20
  185. package/dist/cli-bundle/focused-chunks/chunk-EOQ6W25I.js +0 -8
  186. package/dist/cli-bundle/focused-chunks/chunk-FEN7WOOP.js +0 -12
  187. package/dist/cli-bundle/focused-chunks/chunk-JCLC6HKT.js +0 -8
  188. package/dist/cli-bundle/focused-chunks/chunk-KLJN44VY.js +0 -2
  189. package/dist/cli-bundle/focused-chunks/chunk-L4PL3GZR.js +0 -2
  190. package/dist/cli-bundle/focused-chunks/chunk-PXDR77TO.js +0 -78
  191. package/dist/cli-bundle/focused-chunks/chunk-Y54ONBEX.js +0 -25
  192. package/dist/cli-bundle/focused-chunks/stage-MZSVQYO4.js +0 -2
@@ -1,3 +1,3 @@
1
- import{ha as le,za as ce}from"./chunk-H3XYP24A.js";import{Mc as k,Sc as R,hc as ie,hd as oe,re as se}from"./chunk-4CXQSRSP.js";import{A as X,Aa as x,Af as re,Bd as te,Oc as O,Uf as ne,ha as I,hi as ae,ji as w,pa as P,qa as J,tc as ee,xa as b,za as Z}from"./chunk-QG4LMU7A.js";import{B as s,D as l,F as G}from"./chunk-QKAAZWGC.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="544840da-22f5-5734-81ec-e12c5612545c")}catch{}})();var Ue=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function _e(e){let t=e?.trim();if(!t||t==="__proto__"||t.length>128)throw new Error("A legacy author must contain 1-128 characters.");return t}function ze(e){let t=e?.trim().toLowerCase();if(!t||!Ue.test(t))throw new Error("A canonical harness must be a lowercase dash-separated namespace.");return t}function je(e){return Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)))}function Fe(e,t){let r=new Set;for(let n of(e??[]).slice(0,1e4)){let i=n.trim().slice(0,128);i.length===0||i.startsWith("harness:")||Object.hasOwn(t,i)||r.add(i)}return r.size}function Me(e,t){let r=_e(t.legacy_author),n=ze(t.canonical_harness);if(r===n||r===`harness:${n}`||r.startsWith("harness:"))throw new Error(`The legacy author "${r}" is already canonical and must not be aliased.`);return e[r]===n?!1:(e[r]=n,!0)}function Ve(e,t){if(t.operation==="add")return Me(e,t);if(t.operation==="remove"){let n=_e(t.legacy_author);return Object.hasOwn(e,n)?(delete e[n],!0):!1}if(t.operation==="clear"){let n=Object.keys(e).length>0;for(let i of Object.keys(e))delete e[i];return n}let r=t.operation;throw new Error(`Unsupported vocabulary operation: ${String(r)}`)}function T(e){return{version:e?.version??1,alias_count:Object.keys(e?.aliases??{}).length}}function de(e,t){let r=e?.version??1,n={...e?.aliases},i=Ve(n,t),a={version:i?r+1:r,aliases:je(n)};return{vocabulary:a,preview:{operation:t.operation,changed:i,version_before:r,version_after:a.version,alias_count:Object.keys(a.aliases).length,residual_author_count:Fe(t.observed_authors,a.aliases)}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78e92b9c-f3da-594e-8158-00409222308f")}catch{}})();var ue=new Set(["item_format"]),fe=new Set(["definition_of_done","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"]),Ke=new Set(["history_missing_stream_policy","sprint_release_format_policy","parent_reference_policy","metadata_validation_profile","governance_preset","governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default","governance_require_close_reason","governance_create_default_type","governance_workflow_enforcement","governance_parent_reference_policy","governance_metadata_validation_profile","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking","agent_identity_vocabulary"]),Ye=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking"]),Be={off:"disabled",on:"enabled",true:"enabled",false:"disabled",enabled:"enabled",disabled:"disabled"};function We(e){let t=e.trim().toLowerCase().replaceAll("-","_");if(ue.has(t)||fe.has(t)||Ke.has(t)||t==="context")return t}function He(e){let t=e.trim().toLowerCase();return Be[t]??e}function ge(e,t){let r=We(e);return r===void 0?{routable:!1,reason:`Unknown config key "${e}" cannot route a positional value.`}:r==="context"?{routable:!1,reason:"Config set context does not accept a positional value. Use --default-depth, --activity-limit, --stale-threshold-days, or --section-<name> flags."}:ue.has(r)?{routable:!0,flag:"format",value:t}:fe.has(r)?{routable:!0,flag:"criterion",values:[t]}:{routable:!0,flag:"policy",value:Ye.has(r)?He(t):t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ae4f6da-17c5-5024-89a2-bb0a4be9a683")}catch{}})();var C=[{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_default_mode",path:"search.default_mode",kind:"string",choices:["auto","keyword","semantic","hybrid"],summary:"Mode a bare pm search runs in: auto (hybrid when semantic search is explicitly configured and runnable, else keyword), or a pinned keyword, semantic, or hybrid."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Bounded jittered wait in milliseconds before a contended item mutation fails with lock_conflict; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],Qe=new Map(C.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function me(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return Qe.get(t)}function Xe(e,t){let r=t.trim().toLowerCase();return r==="true"||r==="1"||r==="yes"||r==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:r==="false"||r==="0"||r==="no"||r==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function Je(e,t,r){return e.non_empty===!0&&r.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(r)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function Ze(e,t,r){if(r.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let n=Number(r);return Number.isFinite(n)?{ok:!0,value:n}:{ok:!1,error:{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function xe(e,t,r){return!Number.isInteger(r)||r<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&r<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&r>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function et(e,t,r){return r<0||r>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function tt(e,t,r){return e.min!==void 0&&r<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function pe(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let r=t.trim();if(e.kind==="boolean")return Xe(e,t);if(e.kind==="string")return Je(e,t,r);let n=Ze(e,t,r);return n.ok?e.kind==="integer"?xe(e,t,n.value):e.kind==="ratio"?et(e,t,n.value):tt(e,t,n.value):{ok:!1,error:n.error}}function N(e,t){let r=t.path.split("."),n=e;for(let i of r){if(typeof n!="object"||n===null)return null;let a=Object.getOwnPropertyDescriptor(n,i);if(!a||!Object.hasOwn(a,"value"))return null;n=a.value}return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?n:null}function ye(e,t,r){let n=t.path.split(".");if(n.some(o=>o.length===0||["__proto__","constructor","prototype"].includes(o)))throw new Error("Unsafe settings path");let i=e;for(let o=0;o<n.length-1;o+=1){let d=n[o],c=Object.getOwnPropertyDescriptor(i,d)?.value;if(typeof c!="object"||c===null||Array.isArray(c)){let _={};Object.defineProperty(i,d,{value:_,writable:!0,enumerable:!0,configurable:!0}),i=_}else i=c}let a=n[n.length-1];return Object.getOwnPropertyDescriptor(i,a)?.value===r?!1:(Object.defineProperty(i,a,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d9b6f2ba-2c5e-52ea-891d-53124601fb89")}catch{}})();var he=["project","global"],p={definition_of_done:["definition-of-done","definition_of_done"],item_format:["item-format","item_format"],history_missing_stream_policy:["history-missing-stream-policy","history_missing_stream_policy"],sprint_release_format_policy:["sprint-release-format-policy","sprint_release_format_policy"],parent_reference_policy:["parent-reference-policy","parent_reference_policy"],metadata_validation_profile:["metadata-validation-profile","metadata_validation_profile"],metadata_required_fields:["metadata-required-fields","metadata_required_fields"],lifecycle_stale_blocker_reason_patterns:["lifecycle-stale-blocker-reason-patterns","lifecycle_stale_blocker_reason_patterns"],lifecycle_closure_like_blocked_reason_patterns:["lifecycle-closure-like-blocked-reason-patterns","lifecycle_closure_like_blocked_reason_patterns"],lifecycle_closure_like_resolution_patterns:["lifecycle-closure-like-resolution-patterns","lifecycle_closure_like_resolution_patterns"],lifecycle_closure_like_actual_result_patterns:["lifecycle-closure-like-actual-result-patterns","lifecycle_closure_like_actual_result_patterns"],governance_preset:["governance-preset","governance_preset"],governance_ownership_enforcement:["governance-ownership-enforcement","governance_ownership_enforcement"],governance_create_mode_default:["governance-create-mode-default","governance_create_mode_default"],governance_close_validation_default:["governance-close-validation-default","governance_close_validation_default"],governance_require_close_reason:["governance-require-close-reason","governance_require_close_reason"],governance_create_default_type:["governance-create-default-type","governance_create_default_type"],governance_workflow_enforcement:["governance-workflow-enforcement","governance_workflow_enforcement"],governance_parent_reference_policy:["governance-parent-reference-policy","governance_parent_reference_policy"],governance_metadata_validation_profile:["governance-metadata-validation-profile","governance_metadata_validation_profile"],governance_force_required_for_stale_lock:["governance-force-required-for-stale-lock","governance_force_required_for_stale_lock"],test_result_tracking:["test-result-tracking","test_result_tracking"],untrusted_linked_test_execution:["untrusted-linked-test-execution","untrusted_linked_test_execution"],telemetry_tracking:["telemetry-tracking","telemetry_tracking"],agent_identity_vocabulary:["agent-identity-vocabulary","agent_identity_vocabulary"],context:["context"]},rt=Object.keys(p).map(e=>p[e][0]),nt=Object.fromEntries(Object.keys(p).flatMap(e=>p[e].map(t=>[t,e]))),at={definition_of_done:"Definition of Done criteria list.",item_format:"Default item file format.",history_missing_stream_policy:"Missing history stream handling policy.",sprint_release_format_policy:"Sprint/release format validation policy.",parent_reference_policy:"Parent reference validation policy.",metadata_validation_profile:"Validate metadata profile policy (core|strict|custom).",metadata_required_fields:"Validate custom metadata required-fields list.",lifecycle_stale_blocker_reason_patterns:"Validate lifecycle stale-blocker reason substring patterns (criteria list).",lifecycle_closure_like_blocked_reason_patterns:"Validate lifecycle closure-like blocked_reason substring patterns (criteria list).",lifecycle_closure_like_resolution_patterns:"Validate lifecycle closure-like resolution substring patterns (criteria list).",lifecycle_closure_like_actual_result_patterns:"Validate lifecycle closure-like actual_result substring patterns (criteria list).",governance_preset:"Governance preset policy (minimal|default|strict|custom).",governance_ownership_enforcement:"Governance ownership enforcement policy (none|warn|strict).",governance_create_mode_default:"Governance default create mode (progressive|strict).",governance_close_validation_default:"Governance default close validation mode (off|warn|strict).",governance_require_close_reason:"Governance close-reason requirement policy (enabled|disabled).",governance_create_default_type:"Governance default item type for `pm create` when --type is omitted.",governance_workflow_enforcement:"Governance per-type transition enforcement mode (off|warn|strict).",governance_parent_reference_policy:"Governance parent reference policy (warn|strict_error).",governance_metadata_validation_profile:"Governance metadata validation profile (core|strict|custom).",governance_force_required_for_stale_lock:"Governance stale-lock force policy (enabled|disabled).",test_result_tracking:"Item-level linked test result persistence policy.",untrusted_linked_test_execution:"Permit an explicit per-run override for commands not trusted by this clone.",telemetry_tracking:"Telemetry usage reporting policy.",agent_identity_vocabulary:"Versioned exact legacy-author interpretation vocabulary (summary only).",context:"Context command settings (depth, section toggles, limits)."},it=["lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"],ot=new Set(["metadata_required_fields",...it]),st=new Set(["test_result_tracking","untrusted_linked_test_execution","telemetry_tracking"]),lt=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock"]),ct=new Set(["governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default"]),_t=new Set(["governance_parent_reference_policy","governance_metadata_validation_profile","governance_workflow_enforcement"]),dt=new Set(["governance_preset","governance_create_default_type"]),be=e=>ot.has(e),ut=e=>ct.has(e),ft=e=>_t.has(e),gt=e=>dt.has(e);function $(e){return e==="definition_of_done"||be(e)}function ke(e){if(he.includes(e))return e;throw new l(`Invalid config scope "${e}". Allowed: ${he.join(", ")}`,s.USAGE)}function Ce(e){if(e==="get"||e==="set"||e==="list"||e==="export")return e;throw ie({command_path:"config",token:e.trim()||"<empty>",allowed:["export","get","list","set"],token_kind:"action"})}function Ee(e){let t=nt[e];if(t)return t;let r=C.map(n=>n.key).join(", ");throw new l(`Invalid config key "${e}". Supported: ${rt.join(", ")} (underscore variants also accepted). Nested leaf settings: ${r}.`,s.USAGE)}function Ae(e,t){let r=[...new Set((e??[]).map(n=>n.trim()).filter(n=>n.length>0))].sort((n,i)=>n.localeCompare(i));if(t){if(r.length>0)throw new l("Config set definition-of-done cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set definition-of-done requires at least one non-empty --criterion value (or --clear-criteria to clear)",s.USAGE);return r}function Se(e){let t=e?.trim().toLowerCase();if(t==="toon")return"toon";throw t==="json_markdown"?new l("Config set item-format no longer accepts json_markdown. Markdown item files are legacy read/migration input only.",s.USAGE):new l("Config set item-format requires --format toon",s.USAGE)}function z(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="auto_create"||t==="strict_error")return t;throw new l("Config set history-missing-stream-policy requires --policy with one of: auto_create, strict_error",s.USAGE)}function qe(e){return j(e,"test-result-tracking")}function j(e,t){let r=e?.trim().toLowerCase().replaceAll("-","_");if(r==="enabled"||r==="disabled")return r;throw new l(`Config set ${t} requires --policy with one of: enabled, disabled`,s.USAGE)}function F(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set telemetry-tracking requires --policy with one of: enabled, disabled",s.USAGE)}function E(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="core"||t==="strict"||t==="custom")return t;throw new l("Config set metadata-validation-profile requires --policy with one of: core, strict, custom",s.USAGE)}function M(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="minimal"||t==="default"||t==="strict"||t==="custom")return t;throw new l("Config set governance-preset requires --policy with one of: minimal, default, strict, custom",s.USAGE)}function V(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="none"||t==="warn"||t==="strict")return t;throw new l("Config set governance-ownership-enforcement requires --policy with one of: none, warn, strict",s.USAGE)}function K(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="progressive"||t==="strict")return t;throw new l("Config set governance-create-mode-default requires --policy with one of: progressive, strict",s.USAGE)}function Y(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-close-validation-default requires --policy with one of: off, warn, strict",s.USAGE)}function B(e){let t=typeof e=="string"?e.trim().toLowerCase().replaceAll("-","_"):void 0;if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-workflow-enforcement requires one of: off, warn, strict",s.USAGE)}function W(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-force-required-for-stale-lock requires --policy with one of: enabled, disabled",s.USAGE)}function H(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-require-close-reason requires --policy with one of: enabled, disabled",s.USAGE)}var mt={test_result_tracking:"test-result-tracking",untrusted_linked_test_execution:"untrusted-linked-test-execution"};function D(e,t){let r=mt[e];if(r)return j(t,r);switch(e){case"history_missing_stream_policy":return z(t);case"sprint_release_format_policy":return R(t);case"parent_reference_policy":case"governance_parent_reference_policy":return k(t);case"metadata_validation_profile":case"governance_metadata_validation_profile":return E(t);case"governance_preset":return M(t);case"governance_ownership_enforcement":return V(t);case"governance_create_mode_default":return K(t);case"governance_close_validation_default":return Y(t);case"governance_require_close_reason":return H(t);case"governance_workflow_enforcement":return B(t);case"governance_force_required_for_stale_lock":return W(t);case"telemetry_tracking":return F(t);default:return t.trim().toLowerCase().replaceAll("-","_")}}var ve={author:"author",acceptance_criteria:"acceptance_criteria","acceptance-criteria":"acceptance_criteria",estimated_minutes:"estimated_minutes","estimated-minutes":"estimated_minutes",estimate:"estimated_minutes",close_reason:"close_reason","close-reason":"close_reason",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release"},pt=["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"];function Ge(e,t){let r=[...new Set((e??[]).map(a=>a.trim()).filter(a=>a.length>0))];if(t){if(r.length>0)throw new l("Config set metadata-required-fields cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set metadata-required-fields requires at least one --criterion value (or --clear-criteria to clear)",s.USAGE);let n=r.map(a=>a.toLowerCase().replaceAll("-","_")),i=n.filter(a=>ve[a]===void 0);if(i.length>0)throw new l(`Config set metadata-required-fields received unsupported values: ${i.join(", ")}. Supported values: ${pt.join(", ")}`,s.USAGE);return[...new Set(n.map(a=>ve[a]))].sort((a,o)=>a.localeCompare(o))}function yt(e,t,r){let n=[...new Set((t??[]).map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))].sort((i,a)=>i.localeCompare(a));if(r){if(n.length>0)throw new l(`Config set ${p[e][0]} cannot combine --clear-criteria with --criterion values`,s.USAGE);return[]}if(n.length===0)throw new l(`Config set ${p[e][0]} requires at least one --criterion value (or --clear-criteria to clear)`,s.USAGE);return n}function Ie(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function ht(e,t){if(e==="list"||e==="export"){if(typeof t=="string"&&t.trim().length>0)throw new l(`Config action "${e}" does not accept <key>`,s.USAGE);return}if(typeof t!="string"||t.trim().length===0)throw new l(`Config action "${e}" requires <key>`,s.USAGE);return Ee(t)}function Pe(e){if(!e)throw new l("Config action requires <key>",s.USAGE)}var vt={definition_of_done:e=>[...e.workflow.definition_of_done],item_format:e=>e.item_format,history_missing_stream_policy:e=>e.history.missing_stream,sprint_release_format_policy:e=>e.validation.sprint_release_format,parent_reference_policy:e=>e.validation.parent_reference,metadata_validation_profile:e=>e.validation.metadata_profile,metadata_required_fields:e=>[...e.validation.metadata_required_fields],lifecycle_stale_blocker_reason_patterns:e=>[...e.validation.lifecycle_stale_blocker_reason_patterns],lifecycle_closure_like_blocked_reason_patterns:e=>[...e.validation.lifecycle_closure_like_blocked_reason_patterns],lifecycle_closure_like_resolution_patterns:e=>[...e.validation.lifecycle_closure_like_resolution_patterns],lifecycle_closure_like_actual_result_patterns:e=>[...e.validation.lifecycle_closure_like_actual_result_patterns],governance_preset:e=>e.governance.preset,governance_ownership_enforcement:e=>e.governance.ownership_enforcement,governance_create_mode_default:e=>e.governance.create_mode_default,governance_close_validation_default:e=>e.governance.close_validation_default,governance_require_close_reason:e=>e.governance.require_close_reason?"enabled":"disabled",governance_create_default_type:e=>e.governance.create_default_type??"",governance_workflow_enforcement:e=>e.governance.workflow_enforcement??"off",governance_parent_reference_policy:e=>e.governance.parent_reference,governance_metadata_validation_profile:e=>e.governance.metadata_profile,governance_force_required_for_stale_lock:e=>e.governance.force_required_for_stale_lock?"enabled":"disabled",test_result_tracking:e=>e.testing.record_results_to_items?"enabled":"disabled",untrusted_linked_test_execution:e=>e.testing.allow_untrusted_linked_tests?"enabled":"disabled",telemetry_tracking:e=>e.telemetry.enabled?"enabled":"disabled",agent_identity_vocabulary:e=>T(e.agent_identity?.identity_vocabulary),context:e=>({default_depth:e.context.default_depth,activity_limit:e.context.activity_limit,stale_threshold_days:e.context.stale_threshold_days,sections:{...e.context.sections}})};function Q(e,t){return vt[t](e)}function g(e,t){return t.length===0?e:{...e,warnings:t}}async function wt(e,t){let r=process.cwd(),n=e==="project"?b(r,t.path):Z(r),i=x(n);return e==="project"&&await re(n),{pmRoot:n,settingsPath:i}}function bt(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="true"||t==="enabled"||t==="on"||t==="1")return!0;if(t==="false"||t==="disabled"||t==="off"||t==="0")return!1;throw new l(`Context section toggle must be true|false|enabled|disabled, got "${e}"`,s.USAGE)}function we(e,t){let r=e.trim(),n=Number(r);if(/^\d+$/u.test(r)&&Number.isSafeInteger(n)&&n>0)return n;throw new l(`Context ${t} must be a positive integer`,s.USAGE)}async function kt(e,t,r,n,i){let a=!1,o=e.context;if(t.defaultDepth!==void 0){let c=t.defaultDepth.trim().toLowerCase();if(!I.includes(c))throw new l(`Context --default-depth must be one of ${I.join("|")}`,s.USAGE);o.default_depth!==c&&(o.default_depth=c,a=!0)}if(t.activityLimit!==void 0){let c=we(t.activityLimit,"--activity-limit");o.activity_limit!==c&&(o.activity_limit=c,a=!0)}if(t.staleThresholdDays!==void 0){let c=we(t.staleThresholdDays,"--stale-threshold-days");o.stale_threshold_days!==c&&(o.stale_threshold_days=c,a=!0)}let d=[["hierarchy",t.sectionHierarchy],["activity",t.sectionActivity],["progress",t.sectionProgress],["blockers",t.sectionBlockers],["files",t.sectionFiles],["workload",t.sectionWorkload],["staleness",t.sectionStaleness],["tests",t.sectionTests]];for(let[c,_]of d){let m=bt(_);if(m!==void 0){let y=c;o.sections[y]!==m&&(o.sections[y]=m,a=!0)}}return a&&await w(r.pmRoot,e,"config:set:context"),g({scope:n,key:"context",context_settings:{default_depth:o.default_depth,activity_limit:o.activity_limit,stale_threshold_days:o.stale_threshold_days,sections:{...o.sections}},settings_path:r.settingsPath,changed:a},i)}function Ct(e,t,r){if(r.value!==void 0&&r.value!==t)throw new l(`Config set ${e} received both positional value "${t}" and --value "${r.value}". Pass only one.`,s.USAGE);return{...r,value:t}}function Oe(e,t,r,n,i,a){if(i===void 0)return a;if(e!=="set")throw new l(`Config action "${e}" does not accept a positional value. Only "set" takes <value>.`,s.USAGE);if(typeof t!="string"||t.trim().length===0)throw new l('Config action "set" requires <key> before a positional <value>.',s.USAGE);if(n)return Ct(t,i,a);Pe(r);let o=ge(r,i);if(!o.routable)throw new l(o.reason,s.USAGE);if(o.flag==="criterion"){if(a.criterion!==void 0&&a.criterion.length>0)throw new l(`Config set ${t} received both positional value "${i}" and --criterion. Pass criteria via --criterion only when supplying more than one value.`,s.USAGE);return{...a,criterion:o.values}}if(o.flag==="format")return{...a,format:o.value};if(a.policy!==void 0&&D(r,a.policy)!==D(r,o.value))throw new l(`Config set ${t} received both positional value "${i}" and --policy "${a.policy}". Pass only one.`,s.USAGE);return{...a,policy:o.value}}function Et(e){let t=Object.keys(p).map(n=>({key:n,aliases:p[n],value_kind:n==="context"||n==="agent_identity_vocabulary"?"object":$(n)?"string_array":"enum",set_flags:n==="context"?["--default-depth","--activity-limit","--stale-threshold-days","--section-<name>"]:n==="agent_identity_vocabulary"?["--policy","--value","--criterion"]:$(n)?["--criterion","--clear-criteria"]:n==="item_format"?["--format"]:["--policy"],summary:at[n],value:Q(e.settings,n)})),r=C.map(n=>({key:n.key,canonical_key:n.key.replaceAll("_","-"),path:n.path,kind:n.kind,value:N(e.settings,n),summary:n.summary,...n.choices?{choices:[...n.choices]}:{},...n.min===void 0?{}:{min:n.min},...n.max===void 0?{}:{max:n.max}}));return g({scope:e.scope,keys:t,nested_settings:r,count:t.length,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function At(e){let t=Object.fromEntries(Object.keys(p).map(r=>[r,Q(e.settings,r)]));return g({scope:e.scope,values:t,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function St(e,t){let r=Q(e.settings,t),n={scope:e.scope,key:t,settings_path:e.target.settingsPath,changed:!1};return t==="item_format"?g({...n,format:e.settings.item_format,has_explicit_item_format:e.metadata.has_explicit_item_format},e.warnings):t==="context"?g({...n,context_settings:r},e.warnings):t==="agent_identity_vocabulary"?g({...n,identity_vocabulary:r},e.warnings):Array.isArray(r)?g({...n,criteria:r},e.warnings):g({...n,policy:r},e.warnings)}async function qt(e,t,r,n){if(t==="get"){let d=N(e.settings,r);return g({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:d},settings_path:e.target.settingsPath,changed:!1},e.warnings)}let i=n.value;if(typeof i!="string")throw new l(`Config set ${r.key} requires a value. Pass it positionally (\`pm config ${e.scope} set ${r.key} <value>\`) or via --value.`,s.USAGE);let a=pe(r,i);if(!a.ok)throw new l(a.error.message,s.USAGE);let o=ye(e.settings,r,a.parsed.value);return o&&await w(e.target.pmRoot,e.settings,`config:set:${r.path}`),g({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:a.parsed.value},settings_path:e.target.settingsPath,changed:o},e.warnings)}async function u(e,t,r){t&&await w(e.target.pmRoot,e.settings,r)}function L(e,t,r){return e!==r||t!==r}function f(e,t,r,n){return g({scope:e.scope,key:t,policy:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}function U(e,t,r,n){return g({scope:e.scope,key:t,criteria:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function Gt(e,t){let r=Se(t.format),n=e.settings.item_format!==r||!e.metadata.has_explicit_item_format,i;if(n){let a=P(e.settings,O()),o=await se(e.target.pmRoot,r,"config:set:item_format:migrate",a.type_to_folder,e.settings.schema);i={target_format:o.target_format,scanned:o.scanned,migrated:o.migrated,removed:o.removed,warnings:o.warnings},e.settings.item_format=r,await w(e.target.pmRoot,e.settings,"config:set:item_format")}return g({scope:e.scope,key:"item_format",format:e.settings.item_format,has_explicit_item_format:!0,migration:i,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function It(e,t,r){if(t==="history_missing_stream_policy"){let a=z(r.policy),o=e.settings.history.missing_stream!==a;return e.settings.history.missing_stream=a,await u(e,o,"config:set:history_missing_stream_policy"),f(e,t,e.settings.history.missing_stream,o)}if(t==="sprint_release_format_policy"){let a=R(r.policy),o=e.settings.validation.sprint_release_format!==a;return e.settings.validation.sprint_release_format=a,await u(e,o,"config:set:sprint_release_format_policy"),f(e,t,e.settings.validation.sprint_release_format,o)}if(t==="parent_reference_policy"){let a=k(r.policy),o=e.settings.validation.parent_reference!==a||e.settings.governance.preset!=="custom"||e.settings.governance.parent_reference!==a;return e.settings.validation.parent_reference=a,e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,await u(e,o,"config:set:parent_reference_policy"),f(e,t,e.settings.validation.parent_reference,o)}let n=E(r.policy),i=e.settings.validation.metadata_profile!==n||e.settings.governance.preset!=="custom"||e.settings.governance.metadata_profile!==n;return e.settings.validation.metadata_profile=n,e.settings.governance.preset="custom",e.settings.governance.metadata_profile=n,await u(e,i,"config:set:metadata_validation_profile"),f(e,t,e.settings.validation.metadata_profile,i)}async function Pt(e,t,r){if(t==="metadata_required_fields"){let o=Ge(r.criterion,r.clearCriteria),d=o.length!==e.settings.validation.metadata_required_fields.length||o.some((c,_)=>c!==e.settings.validation.metadata_required_fields[_]);return e.settings.validation.metadata_required_fields=o,await u(e,d,"config:set:metadata_required_fields"),U(e,t,[...e.settings.validation.metadata_required_fields],d)}let n={lifecycle_stale_blocker_reason_patterns:e.settings.validation.lifecycle_stale_blocker_reason_patterns,lifecycle_closure_like_blocked_reason_patterns:e.settings.validation.lifecycle_closure_like_blocked_reason_patterns,lifecycle_closure_like_resolution_patterns:e.settings.validation.lifecycle_closure_like_resolution_patterns,lifecycle_closure_like_actual_result_patterns:e.settings.validation.lifecycle_closure_like_actual_result_patterns}[t],i=yt(t,r.criterion,r.clearCriteria),a=i.length!==n.length||i.some((o,d)=>o!==n[d]);return n.splice(0,n.length,...i),await u(e,a,`config:set:${t}`),U(e,t,[...n],a)}async function Ot(e,t,r){if(t==="governance_preset"){let c=M(r.policy),_=e.settings.governance.preset!==c;return e.settings.governance.preset=c,await u(e,_,"config:set:governance_preset"),f(e,t,e.settings.governance.preset,_)}let n=typeof r.policy=="string",i=n?r.policy.trim():"";if(n&&i.length===0){let c=e.settings.governance.create_default_type!==void 0;return delete e.settings.governance.create_default_type,await u(e,c,"config:set:governance_create_default_type"),f(e,t,e.settings.governance.create_default_type??"",c)}if(i.length===0)throw new l('Config set governance-create-default-type requires an item type value (or an empty value "" to clear it)',s.USAGE);let a=P(e.settings,O()),o=J(i,a);if(!o)throw new l(oe(i,a.types,ne(e.target.pmRoot,e.settings.schema)),s.USAGE);let d=e.settings.governance.create_default_type!==o;return e.settings.governance.create_default_type=o,await u(e,d,"config:set:governance_create_default_type"),f(e,t,e.settings.governance.create_default_type,d)}async function Rt(e,t,r){if(t==="governance_ownership_enforcement"){let a=V(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.ownership_enforcement!==a;return e.settings.governance.preset="custom",e.settings.governance.ownership_enforcement=a,await u(e,o,"config:set:governance_ownership_enforcement"),f(e,t,e.settings.governance.ownership_enforcement,o)}if(t==="governance_create_mode_default"){let a=K(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.create_mode_default!==a;return e.settings.governance.preset="custom",e.settings.governance.create_mode_default=a,await u(e,o,"config:set:governance_create_mode_default"),f(e,t,e.settings.governance.create_mode_default,o)}let n=Y(r.policy),i=e.settings.governance.preset!=="custom"||e.settings.governance.close_validation_default!==n;return e.settings.governance.preset="custom",e.settings.governance.close_validation_default=n,await u(e,i,"config:set:governance_close_validation_default"),f(e,t,e.settings.governance.close_validation_default,i)}async function Tt(e,t,r){if(t==="governance_parent_reference_policy"){let a=k(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.parent_reference,e.settings.validation.parent_reference,a);return e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,e.settings.validation.parent_reference=a,await u(e,o,"config:set:governance_parent_reference_policy"),f(e,t,e.settings.governance.parent_reference,o)}if(t==="governance_metadata_validation_profile"){let a=E(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.metadata_profile,e.settings.validation.metadata_profile,a);return e.settings.governance.preset="custom",e.settings.governance.metadata_profile=a,e.settings.validation.metadata_profile=a,await u(e,o,"config:set:governance_metadata_validation_profile"),f(e,t,e.settings.governance.metadata_profile,o)}let n=B(r.policy),i=(e.settings.governance.workflow_enforcement??"off")!==n;return e.settings.governance.workflow_enforcement=n,await u(e,i,"config:set:governance_workflow_enforcement"),f(e,t,e.settings.governance.workflow_enforcement,i)}async function Nt(e,t,r){if(t==="governance_require_close_reason"){let a=H(r.policy)==="enabled",o=e.settings.governance.require_close_reason!==a;return e.settings.governance.require_close_reason=a,await u(e,o,"config:set:governance_require_close_reason"),f(e,t,e.settings.governance.require_close_reason?"enabled":"disabled",o)}let n=W(r.policy)==="enabled",i=e.settings.governance.preset!=="custom"||e.settings.governance.force_required_for_stale_lock!==n;return e.settings.governance.preset="custom",e.settings.governance.force_required_for_stale_lock=n,await u(e,i,"config:set:governance_force_required_for_stale_lock"),f(e,t,e.settings.governance.force_required_for_stale_lock?"enabled":"disabled",i)}async function $t(e,t,r){if(t==="test_result_tracking"){let a=qe(r.policy)==="enabled",o=e.settings.testing.record_results_to_items!==a;return e.settings.testing.record_results_to_items=a,await u(e,o,"config:set:test_result_tracking"),f(e,t,e.settings.testing.record_results_to_items?"enabled":"disabled",o)}if(t==="untrusted_linked_test_execution"){let a=j(r.policy,"untrusted-linked-test-execution")==="enabled",o=e.settings.testing.allow_untrusted_linked_tests!==a;return e.settings.testing.allow_untrusted_linked_tests=a,await u(e,o,"config:set:untrusted_linked_test_execution"),f(e,t,e.settings.testing.allow_untrusted_linked_tests?"enabled":"disabled",o)}let n=F(r.policy)==="enabled",i=e.settings.telemetry.enabled!==n||!e.settings.telemetry.first_run_prompt_completed;return e.settings.telemetry.enabled=n,e.settings.telemetry.first_run_prompt_completed=!0,await u(e,i,"config:set:telemetry_tracking"),f(e,t,e.settings.telemetry.enabled?"enabled":"disabled",i)}async function Dt(e,t,r){let n=Ae(r.criterion,r.clearCriteria),i=n.length!==e.settings.workflow.definition_of_done.length||n.some((a,o)=>a!==e.settings.workflow.definition_of_done[o]);return e.settings.workflow.definition_of_done=n,await u(e,i,"config:set:definition_of_done"),U(e,t,[...e.settings.workflow.definition_of_done],i)}function Lt(e){let t=e?.trim().toLowerCase().replaceAll("_","-"),r=t?.startsWith("preview-")===!0,n=r?t.slice(8):t;if(n==="add"||n==="remove"||n==="clear")return{operation:n,dryRun:r};throw new l("Config set agent-identity-vocabulary requires --policy add|remove|clear|preview-add|preview-remove|preview-clear",s.USAGE)}function Ut(e,t){if(e==="add"){let r=t?.lastIndexOf("=")??-1;if(r<=0||r===t.length-1)throw new l('Config set agent-identity-vocabulary --policy add requires --value "<legacy-author>=<canonical-harness>"',s.USAGE);return{legacy_author:t.slice(0,r),canonical_harness:t.slice(r+1)}}if(e==="remove"){if(t===void 0)throw new l("Config set agent-identity-vocabulary --policy remove requires --value <legacy-author>",s.USAGE);return{legacy_author:t}}if(t!==void 0)throw new l("Config set agent-identity-vocabulary --policy clear does not accept --value",s.USAGE);return{}}async function zt(e,t){let{operation:r,dryRun:n}=Lt(t.policy),i=Ut(r,t.value),a;try{a=de(e.settings.agent_identity?.identity_vocabulary,{operation:r,...i,observed_authors:t.criterion})}catch(o){throw new l(o.message,s.USAGE)}return a.preview.changed&&!n&&(e.settings.agent_identity={...e.settings.agent_identity,identity_vocabulary:a.vocabulary},await u(e,!0,`config:set:agent_identity.identity_vocabulary:${r}:v${a.preview.version_after}`)),g({scope:e.scope,key:"agent_identity_vocabulary",identity_vocabulary:T(n?e.settings.agent_identity?.identity_vocabulary:a.vocabulary),vocabulary_mutation:a.preview,settings_path:e.target.settingsPath,changed:a.preview.changed&&!n},e.warnings)}async function jt(e,t,r){if(r.clearCriteria===!0&&!$(t))throw new l("--clear-criteria is only supported with config set criteria-list keys",s.USAGE);return t==="item_format"?Gt(e,r):t==="context"?kt(e.settings,r,e.target,e.scope,e.warnings):t==="agent_identity_vocabulary"?zt(e,r):t==="definition_of_done"?Dt(e,t,r):be(t)?Pt(e,t,r):st.has(t)?$t(e,t,r):lt.has(t)?Nt(e,t,r):ut(t)?Rt(e,t,r):ft(t)?Tt(e,t,r):gt(t)?Ot(e,t,r):It(e,t,r)}async function Cr(e,t,r,n,i,a){let o=ke(e),d=Ce(t),c=d==="get"||d==="set"?me(r):void 0,_=c?void 0:ht(d,r),m=Oe(d,r,_,c,a,n),y=await wt(o,i),{settings:h,metadata:De,warnings:Le}=await ae(y.pmRoot),v={scope:o,target:y,settings:h,metadata:De,warnings:Ie(Le)};return c?qt(v,d,c,m):d==="list"?Et(v):d==="export"?At(v):(Pe(_),d==="get"?St(v,_):jt(v,_,m))}var Er={hasGovernanceValidationMirrorChange:L,applyPositionalValue:Oe,normalizeAction:Ce,normalizeCriteria:Ae,normalizeGovernanceCloseValidationDefault:Y,normalizeGovernanceCreateModeDefault:K,normalizeGovernanceForceRequiredForStaleLockPolicy:W,normalizeGovernanceOwnershipEnforcement:V,normalizeGovernancePreset:M,normalizeGovernanceRequireCloseReasonPolicy:H,normalizeGovernanceWorkflowEnforcement:B,normalizeHistoryMissingStreamPolicy:z,normalizeItemFormat:Se,normalizeKey:Ee,normalizeMetadataRequiredFields:Ge,normalizePolicyForConflict:D,normalizeScope:ke,normalizeTelemetryTrackingPolicy:F,normalizeTestResultTrackingPolicy:qe,normalizeValidateMetadataProfile:E,normalizeWarnings:Ie};import{execFile as Ft}from"node:child_process";import Mt from"node:path";import{promisify as Vt}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7fe99df0-8454-5667-9205-0b861ba212d1")}catch{}})();var Kt=Vt(Ft),Te="@unbrained/pm-cli",Yt="latest",Bt={global:["--global"],project:[]};function Re(e){let t=e.project===!0||e.local===!0||e.scope==="project",r=e.global===!0||e.scope==="global";if(t&&r)throw new l('Options "--project/--local" and "--global" are mutually exclusive.',s.USAGE);return r?"global":"project"}function S(e){return e.trim().toLowerCase()}function Ne(e,t){let r=S(t);return[e.name,e.directory,e.source.input,e.source.location,e.source.package,e.source.repository,e.source.owner&&e.source.repo?`${e.source.owner}/${e.source.repo}`:void 0].some(n=>typeof n=="string"&&S(n)===r)}function Wt(e,t){let r=b(process.cwd(),t.path),n=ee(r,process.cwd());return{selected_root:e==="global"?n.global:n.project}}async function Ht(e,t,r){try{let n=await Kt(e,t,{cwd:r?.cwd,encoding:"utf8"});return{stdout:n.stdout,stderr:n.stderr}}catch(n){let i=typeof n=="object"&&n!==null&&"stderr"in n?String(n.stderr??""):"",a=i.trim().length>0?i.trim():n instanceof Error?n.message:String(n);throw new l(`Command failed: ${e} ${t.join(" ")}
1
+ import{ha as le,za as ce}from"./chunk-V3XONSVC.js";import{Mc as k,Sc as R,hc as ie,hd as oe,re as se}from"./chunk-V5GJTXYW.js";import{A as X,Aa as x,Cd as te,Oc as O,Of as re,gg as ne,ha as I,pa as P,qa as J,tc as ee,vi as ae,xa as b,xi as w,za as Z}from"./chunk-KBSVPUFD.js";import{A as s,C as l,E as G}from"./chunk-GWIGZDRS.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="544840da-22f5-5734-81ec-e12c5612545c")}catch{}})();var Ue=/^[a-z0-9]+(?:-[a-z0-9]+)*$/u;function _e(e){let t=e?.trim();if(!t||t==="__proto__"||t.length>128)throw new Error("A legacy author must contain 1-128 characters.");return t}function ze(e){let t=e?.trim().toLowerCase();if(!t||!Ue.test(t))throw new Error("A canonical harness must be a lowercase dash-separated namespace.");return t}function je(e){return Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)))}function Fe(e,t){let r=new Set;for(let n of(e??[]).slice(0,1e4)){let i=n.trim().slice(0,128);i.length===0||i.startsWith("harness:")||Object.hasOwn(t,i)||r.add(i)}return r.size}function Me(e,t){let r=_e(t.legacy_author),n=ze(t.canonical_harness);if(r===n||r===`harness:${n}`||r.startsWith("harness:"))throw new Error(`The legacy author "${r}" is already canonical and must not be aliased.`);return e[r]===n?!1:(e[r]=n,!0)}function Ve(e,t){if(t.operation==="add")return Me(e,t);if(t.operation==="remove"){let n=_e(t.legacy_author);return Object.hasOwn(e,n)?(delete e[n],!0):!1}if(t.operation==="clear"){let n=Object.keys(e).length>0;for(let i of Object.keys(e))delete e[i];return n}let r=t.operation;throw new Error(`Unsupported vocabulary operation: ${String(r)}`)}function T(e){return{version:e?.version??1,alias_count:Object.keys(e?.aliases??{}).length}}function de(e,t){let r=e?.version??1,n={...e?.aliases},i=Ve(n,t),a={version:i?r+1:r,aliases:je(n)};return{vocabulary:a,preview:{operation:t.operation,changed:i,version_before:r,version_after:a.version,alias_count:Object.keys(a.aliases).length,residual_author_count:Fe(t.observed_authors,a.aliases)}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78e92b9c-f3da-594e-8158-00409222308f")}catch{}})();var ue=new Set(["item_format"]),fe=new Set(["definition_of_done","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"]),Ke=new Set(["history_missing_stream_policy","sprint_release_format_policy","parent_reference_policy","metadata_validation_profile","governance_preset","governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default","governance_require_close_reason","governance_create_default_type","governance_workflow_enforcement","governance_parent_reference_policy","governance_metadata_validation_profile","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking","agent_identity_vocabulary"]),Ye=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock","test_result_tracking","untrusted_linked_test_execution","telemetry_tracking"]),Be={off:"disabled",on:"enabled",true:"enabled",false:"disabled",enabled:"enabled",disabled:"disabled"};function We(e){let t=e.trim().toLowerCase().replaceAll("-","_");if(ue.has(t)||fe.has(t)||Ke.has(t)||t==="context")return t}function He(e){let t=e.trim().toLowerCase();return Be[t]??e}function ge(e,t){let r=We(e);return r===void 0?{routable:!1,reason:`Unknown config key "${e}" cannot route a positional value.`}:r==="context"?{routable:!1,reason:"Config set context does not accept a positional value. Use --default-depth, --activity-limit, --stale-threshold-days, or --section-<name> flags."}:ue.has(r)?{routable:!0,flag:"format",value:t}:fe.has(r)?{routable:!0,flag:"criterion",values:[t]}:{routable:!0,flag:"policy",value:Ye.has(r)?He(t):t}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2ae4f6da-17c5-5024-89a2-bb0a4be9a683")}catch{}})();var C=[{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_default_mode",path:"search.default_mode",kind:"string",choices:["auto","keyword","semantic","hybrid"],summary:"Mode a bare pm search runs in: auto (hybrid when semantic search is explicitly configured and runnable, else keyword), or a pinned keyword, semantic, or hybrid."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Bounded jittered wait in milliseconds before a contended item mutation fails with lock_conflict; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],Qe=new Map(C.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function me(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return Qe.get(t)}function Xe(e,t){let r=t.trim().toLowerCase();return r==="true"||r==="1"||r==="yes"||r==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:r==="false"||r==="0"||r==="no"||r==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function Je(e,t,r){return e.non_empty===!0&&r.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(r)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function Ze(e,t,r){if(r.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let n=Number(r);return Number.isFinite(n)?{ok:!0,value:n}:{ok:!1,error:{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function xe(e,t,r){return!Number.isInteger(r)||r<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&r<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&r>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function et(e,t,r){return r<0||r>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function tt(e,t,r){return e.min!==void 0&&r<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:r}}}function pe(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let r=t.trim();if(e.kind==="boolean")return Xe(e,t);if(e.kind==="string")return Je(e,t,r);let n=Ze(e,t,r);return n.ok?e.kind==="integer"?xe(e,t,n.value):e.kind==="ratio"?et(e,t,n.value):tt(e,t,n.value):{ok:!1,error:n.error}}function N(e,t){let r=t.path.split("."),n=e;for(let i of r){if(typeof n!="object"||n===null)return null;let a=Object.getOwnPropertyDescriptor(n,i);if(!a||!Object.hasOwn(a,"value"))return null;n=a.value}return typeof n=="string"||typeof n=="number"||typeof n=="boolean"?n:null}function ye(e,t,r){let n=t.path.split(".");if(n.some(o=>o.length===0||["__proto__","constructor","prototype"].includes(o)))throw new Error("Unsafe settings path");let i=e;for(let o=0;o<n.length-1;o+=1){let d=n[o],c=Object.getOwnPropertyDescriptor(i,d)?.value;if(typeof c!="object"||c===null||Array.isArray(c)){let _={};Object.defineProperty(i,d,{value:_,writable:!0,enumerable:!0,configurable:!0}),i=_}else i=c}let a=n[n.length-1];return Object.getOwnPropertyDescriptor(i,a)?.value===r?!1:(Object.defineProperty(i,a,{value:r,writable:!0,enumerable:!0,configurable:!0}),!0)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d9b6f2ba-2c5e-52ea-891d-53124601fb89")}catch{}})();var he=["project","global"],p={definition_of_done:["definition-of-done","definition_of_done"],item_format:["item-format","item_format"],history_missing_stream_policy:["history-missing-stream-policy","history_missing_stream_policy"],sprint_release_format_policy:["sprint-release-format-policy","sprint_release_format_policy"],parent_reference_policy:["parent-reference-policy","parent_reference_policy"],metadata_validation_profile:["metadata-validation-profile","metadata_validation_profile"],metadata_required_fields:["metadata-required-fields","metadata_required_fields"],lifecycle_stale_blocker_reason_patterns:["lifecycle-stale-blocker-reason-patterns","lifecycle_stale_blocker_reason_patterns"],lifecycle_closure_like_blocked_reason_patterns:["lifecycle-closure-like-blocked-reason-patterns","lifecycle_closure_like_blocked_reason_patterns"],lifecycle_closure_like_resolution_patterns:["lifecycle-closure-like-resolution-patterns","lifecycle_closure_like_resolution_patterns"],lifecycle_closure_like_actual_result_patterns:["lifecycle-closure-like-actual-result-patterns","lifecycle_closure_like_actual_result_patterns"],governance_preset:["governance-preset","governance_preset"],governance_ownership_enforcement:["governance-ownership-enforcement","governance_ownership_enforcement"],governance_create_mode_default:["governance-create-mode-default","governance_create_mode_default"],governance_close_validation_default:["governance-close-validation-default","governance_close_validation_default"],governance_require_close_reason:["governance-require-close-reason","governance_require_close_reason"],governance_create_default_type:["governance-create-default-type","governance_create_default_type"],governance_workflow_enforcement:["governance-workflow-enforcement","governance_workflow_enforcement"],governance_parent_reference_policy:["governance-parent-reference-policy","governance_parent_reference_policy"],governance_metadata_validation_profile:["governance-metadata-validation-profile","governance_metadata_validation_profile"],governance_force_required_for_stale_lock:["governance-force-required-for-stale-lock","governance_force_required_for_stale_lock"],test_result_tracking:["test-result-tracking","test_result_tracking"],untrusted_linked_test_execution:["untrusted-linked-test-execution","untrusted_linked_test_execution"],telemetry_tracking:["telemetry-tracking","telemetry_tracking"],agent_identity_vocabulary:["agent-identity-vocabulary","agent_identity_vocabulary"],context:["context"]},rt=Object.keys(p).map(e=>p[e][0]),nt=Object.fromEntries(Object.keys(p).flatMap(e=>p[e].map(t=>[t,e]))),at={definition_of_done:"Definition of Done criteria list.",item_format:"Default item file format.",history_missing_stream_policy:"Missing history stream handling policy.",sprint_release_format_policy:"Sprint/release format validation policy.",parent_reference_policy:"Parent reference validation policy.",metadata_validation_profile:"Validate metadata profile policy (core|strict|custom).",metadata_required_fields:"Validate custom metadata required-fields list.",lifecycle_stale_blocker_reason_patterns:"Validate lifecycle stale-blocker reason substring patterns (criteria list).",lifecycle_closure_like_blocked_reason_patterns:"Validate lifecycle closure-like blocked_reason substring patterns (criteria list).",lifecycle_closure_like_resolution_patterns:"Validate lifecycle closure-like resolution substring patterns (criteria list).",lifecycle_closure_like_actual_result_patterns:"Validate lifecycle closure-like actual_result substring patterns (criteria list).",governance_preset:"Governance preset policy (minimal|default|strict|custom).",governance_ownership_enforcement:"Governance ownership enforcement policy (none|warn|strict).",governance_create_mode_default:"Governance default create mode (progressive|strict).",governance_close_validation_default:"Governance default close validation mode (off|warn|strict).",governance_require_close_reason:"Governance close-reason requirement policy (enabled|disabled).",governance_create_default_type:"Governance default item type for `pm create` when --type is omitted.",governance_workflow_enforcement:"Governance per-type transition enforcement mode (off|warn|strict).",governance_parent_reference_policy:"Governance parent reference policy (warn|strict_error).",governance_metadata_validation_profile:"Governance metadata validation profile (core|strict|custom).",governance_force_required_for_stale_lock:"Governance stale-lock force policy (enabled|disabled).",test_result_tracking:"Item-level linked test result persistence policy.",untrusted_linked_test_execution:"Permit an explicit per-run override for commands not trusted by this clone.",telemetry_tracking:"Telemetry usage reporting policy.",agent_identity_vocabulary:"Versioned exact legacy-author interpretation vocabulary (summary only).",context:"Context command settings (depth, section toggles, limits)."},it=["lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns"],ot=new Set(["metadata_required_fields",...it]),st=new Set(["test_result_tracking","untrusted_linked_test_execution","telemetry_tracking"]),lt=new Set(["governance_require_close_reason","governance_force_required_for_stale_lock"]),ct=new Set(["governance_ownership_enforcement","governance_create_mode_default","governance_close_validation_default"]),_t=new Set(["governance_parent_reference_policy","governance_metadata_validation_profile","governance_workflow_enforcement"]),dt=new Set(["governance_preset","governance_create_default_type"]),be=e=>ot.has(e),ut=e=>ct.has(e),ft=e=>_t.has(e),gt=e=>dt.has(e);function $(e){return e==="definition_of_done"||be(e)}function ke(e){if(he.includes(e))return e;throw new l(`Invalid config scope "${e}". Allowed: ${he.join(", ")}`,s.USAGE)}function Ce(e){if(e==="get"||e==="set"||e==="list"||e==="export")return e;throw ie({command_path:"config",token:e.trim()||"<empty>",allowed:["export","get","list","set"],token_kind:"action"})}function Ee(e){let t=nt[e];if(t)return t;let r=C.map(n=>n.key).join(", ");throw new l(`Invalid config key "${e}". Supported: ${rt.join(", ")} (underscore variants also accepted). Nested leaf settings: ${r}.`,s.USAGE)}function Ae(e,t){let r=[...new Set((e??[]).map(n=>n.trim()).filter(n=>n.length>0))].sort((n,i)=>n.localeCompare(i));if(t){if(r.length>0)throw new l("Config set definition-of-done cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set definition-of-done requires at least one non-empty --criterion value (or --clear-criteria to clear)",s.USAGE);return r}function Se(e){let t=e?.trim().toLowerCase();if(t==="toon")return"toon";throw t==="json_markdown"?new l("Config set item-format no longer accepts json_markdown. Markdown item files are legacy read/migration input only.",s.USAGE):new l("Config set item-format requires --format toon",s.USAGE)}function z(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="auto_create"||t==="strict_error")return t;throw new l("Config set history-missing-stream-policy requires --policy with one of: auto_create, strict_error",s.USAGE)}function qe(e){return j(e,"test-result-tracking")}function j(e,t){let r=e?.trim().toLowerCase().replaceAll("-","_");if(r==="enabled"||r==="disabled")return r;throw new l(`Config set ${t} requires --policy with one of: enabled, disabled`,s.USAGE)}function F(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set telemetry-tracking requires --policy with one of: enabled, disabled",s.USAGE)}function E(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="core"||t==="strict"||t==="custom")return t;throw new l("Config set metadata-validation-profile requires --policy with one of: core, strict, custom",s.USAGE)}function M(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="minimal"||t==="default"||t==="strict"||t==="custom")return t;throw new l("Config set governance-preset requires --policy with one of: minimal, default, strict, custom",s.USAGE)}function V(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="none"||t==="warn"||t==="strict")return t;throw new l("Config set governance-ownership-enforcement requires --policy with one of: none, warn, strict",s.USAGE)}function K(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="progressive"||t==="strict")return t;throw new l("Config set governance-create-mode-default requires --policy with one of: progressive, strict",s.USAGE)}function Y(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-close-validation-default requires --policy with one of: off, warn, strict",s.USAGE)}function B(e){let t=typeof e=="string"?e.trim().toLowerCase().replaceAll("-","_"):void 0;if(t==="off"||t==="warn"||t==="strict")return t;if(t==="none"||t==="disabled")return"off";throw new l("Config set governance-workflow-enforcement requires one of: off, warn, strict",s.USAGE)}function W(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-force-required-for-stale-lock requires --policy with one of: enabled, disabled",s.USAGE)}function H(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="enabled"||t==="disabled")return t;throw new l("Config set governance-require-close-reason requires --policy with one of: enabled, disabled",s.USAGE)}var mt={test_result_tracking:"test-result-tracking",untrusted_linked_test_execution:"untrusted-linked-test-execution"};function D(e,t){let r=mt[e];if(r)return j(t,r);switch(e){case"history_missing_stream_policy":return z(t);case"sprint_release_format_policy":return R(t);case"parent_reference_policy":case"governance_parent_reference_policy":return k(t);case"metadata_validation_profile":case"governance_metadata_validation_profile":return E(t);case"governance_preset":return M(t);case"governance_ownership_enforcement":return V(t);case"governance_create_mode_default":return K(t);case"governance_close_validation_default":return Y(t);case"governance_require_close_reason":return H(t);case"governance_workflow_enforcement":return B(t);case"governance_force_required_for_stale_lock":return W(t);case"telemetry_tracking":return F(t);default:return t.trim().toLowerCase().replaceAll("-","_")}}var ve={author:"author",acceptance_criteria:"acceptance_criteria","acceptance-criteria":"acceptance_criteria",estimated_minutes:"estimated_minutes","estimated-minutes":"estimated_minutes",estimate:"estimated_minutes",close_reason:"close_reason","close-reason":"close_reason",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release"},pt=["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"];function Ge(e,t){let r=[...new Set((e??[]).map(a=>a.trim()).filter(a=>a.length>0))];if(t){if(r.length>0)throw new l("Config set metadata-required-fields cannot combine --clear-criteria with --criterion values",s.USAGE);return[]}if(r.length===0)throw new l("Config set metadata-required-fields requires at least one --criterion value (or --clear-criteria to clear)",s.USAGE);let n=r.map(a=>a.toLowerCase().replaceAll("-","_")),i=n.filter(a=>ve[a]===void 0);if(i.length>0)throw new l(`Config set metadata-required-fields received unsupported values: ${i.join(", ")}. Supported values: ${pt.join(", ")}`,s.USAGE);return[...new Set(n.map(a=>ve[a]))].sort((a,o)=>a.localeCompare(o))}function yt(e,t,r){let n=[...new Set((t??[]).map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))].sort((i,a)=>i.localeCompare(a));if(r){if(n.length>0)throw new l(`Config set ${p[e][0]} cannot combine --clear-criteria with --criterion values`,s.USAGE);return[]}if(n.length===0)throw new l(`Config set ${p[e][0]} requires at least one --criterion value (or --clear-criteria to clear)`,s.USAGE);return n}function Ie(e){return[...new Set(e)].sort((t,r)=>t.localeCompare(r))}function ht(e,t){if(e==="list"||e==="export"){if(typeof t=="string"&&t.trim().length>0)throw new l(`Config action "${e}" does not accept <key>`,s.USAGE);return}if(typeof t!="string"||t.trim().length===0)throw new l(`Config action "${e}" requires <key>`,s.USAGE);return Ee(t)}function Pe(e){if(!e)throw new l("Config action requires <key>",s.USAGE)}var vt={definition_of_done:e=>[...e.workflow.definition_of_done],item_format:e=>e.item_format,history_missing_stream_policy:e=>e.history.missing_stream,sprint_release_format_policy:e=>e.validation.sprint_release_format,parent_reference_policy:e=>e.validation.parent_reference,metadata_validation_profile:e=>e.validation.metadata_profile,metadata_required_fields:e=>[...e.validation.metadata_required_fields],lifecycle_stale_blocker_reason_patterns:e=>[...e.validation.lifecycle_stale_blocker_reason_patterns],lifecycle_closure_like_blocked_reason_patterns:e=>[...e.validation.lifecycle_closure_like_blocked_reason_patterns],lifecycle_closure_like_resolution_patterns:e=>[...e.validation.lifecycle_closure_like_resolution_patterns],lifecycle_closure_like_actual_result_patterns:e=>[...e.validation.lifecycle_closure_like_actual_result_patterns],governance_preset:e=>e.governance.preset,governance_ownership_enforcement:e=>e.governance.ownership_enforcement,governance_create_mode_default:e=>e.governance.create_mode_default,governance_close_validation_default:e=>e.governance.close_validation_default,governance_require_close_reason:e=>e.governance.require_close_reason?"enabled":"disabled",governance_create_default_type:e=>e.governance.create_default_type??"",governance_workflow_enforcement:e=>e.governance.workflow_enforcement??"off",governance_parent_reference_policy:e=>e.governance.parent_reference,governance_metadata_validation_profile:e=>e.governance.metadata_profile,governance_force_required_for_stale_lock:e=>e.governance.force_required_for_stale_lock?"enabled":"disabled",test_result_tracking:e=>e.testing.record_results_to_items?"enabled":"disabled",untrusted_linked_test_execution:e=>e.testing.allow_untrusted_linked_tests?"enabled":"disabled",telemetry_tracking:e=>e.telemetry.enabled?"enabled":"disabled",agent_identity_vocabulary:e=>T(e.agent_identity?.identity_vocabulary),context:e=>({default_depth:e.context.default_depth,activity_limit:e.context.activity_limit,stale_threshold_days:e.context.stale_threshold_days,sections:{...e.context.sections}})};function Q(e,t){return vt[t](e)}function g(e,t){return t.length===0?e:{...e,warnings:t}}async function wt(e,t){let r=process.cwd(),n=e==="project"?b(r,t.path):Z(r),i=x(n);return e==="project"&&await re(n),{pmRoot:n,settingsPath:i}}function bt(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t==="true"||t==="enabled"||t==="on"||t==="1")return!0;if(t==="false"||t==="disabled"||t==="off"||t==="0")return!1;throw new l(`Context section toggle must be true|false|enabled|disabled, got "${e}"`,s.USAGE)}function we(e,t){let r=e.trim(),n=Number(r);if(/^\d+$/u.test(r)&&Number.isSafeInteger(n)&&n>0)return n;throw new l(`Context ${t} must be a positive integer`,s.USAGE)}async function kt(e,t,r,n,i){let a=!1,o=e.context;if(t.defaultDepth!==void 0){let c=t.defaultDepth.trim().toLowerCase();if(!I.includes(c))throw new l(`Context --default-depth must be one of ${I.join("|")}`,s.USAGE);o.default_depth!==c&&(o.default_depth=c,a=!0)}if(t.activityLimit!==void 0){let c=we(t.activityLimit,"--activity-limit");o.activity_limit!==c&&(o.activity_limit=c,a=!0)}if(t.staleThresholdDays!==void 0){let c=we(t.staleThresholdDays,"--stale-threshold-days");o.stale_threshold_days!==c&&(o.stale_threshold_days=c,a=!0)}let d=[["hierarchy",t.sectionHierarchy],["activity",t.sectionActivity],["progress",t.sectionProgress],["blockers",t.sectionBlockers],["files",t.sectionFiles],["workload",t.sectionWorkload],["staleness",t.sectionStaleness],["tests",t.sectionTests]];for(let[c,_]of d){let m=bt(_);if(m!==void 0){let y=c;o.sections[y]!==m&&(o.sections[y]=m,a=!0)}}return a&&await w(r.pmRoot,e,"config:set:context"),g({scope:n,key:"context",context_settings:{default_depth:o.default_depth,activity_limit:o.activity_limit,stale_threshold_days:o.stale_threshold_days,sections:{...o.sections}},settings_path:r.settingsPath,changed:a},i)}function Ct(e,t,r){if(r.value!==void 0&&r.value!==t)throw new l(`Config set ${e} received both positional value "${t}" and --value "${r.value}". Pass only one.`,s.USAGE);return{...r,value:t}}function Oe(e,t,r,n,i,a){if(i===void 0)return a;if(e!=="set")throw new l(`Config action "${e}" does not accept a positional value. Only "set" takes <value>.`,s.USAGE);if(typeof t!="string"||t.trim().length===0)throw new l('Config action "set" requires <key> before a positional <value>.',s.USAGE);if(n)return Ct(t,i,a);Pe(r);let o=ge(r,i);if(!o.routable)throw new l(o.reason,s.USAGE);if(o.flag==="criterion"){if(a.criterion!==void 0&&a.criterion.length>0)throw new l(`Config set ${t} received both positional value "${i}" and --criterion. Pass criteria via --criterion only when supplying more than one value.`,s.USAGE);return{...a,criterion:o.values}}if(o.flag==="format")return{...a,format:o.value};if(a.policy!==void 0&&D(r,a.policy)!==D(r,o.value))throw new l(`Config set ${t} received both positional value "${i}" and --policy "${a.policy}". Pass only one.`,s.USAGE);return{...a,policy:o.value}}function Et(e){let t=Object.keys(p).map(n=>({key:n,aliases:p[n],value_kind:n==="context"||n==="agent_identity_vocabulary"?"object":$(n)?"string_array":"enum",set_flags:n==="context"?["--default-depth","--activity-limit","--stale-threshold-days","--section-<name>"]:n==="agent_identity_vocabulary"?["--policy","--value","--criterion"]:$(n)?["--criterion","--clear-criteria"]:n==="item_format"?["--format"]:["--policy"],summary:at[n],value:Q(e.settings,n)})),r=C.map(n=>({key:n.key,canonical_key:n.key.replaceAll("_","-"),path:n.path,kind:n.kind,value:N(e.settings,n),summary:n.summary,...n.choices?{choices:[...n.choices]}:{},...n.min===void 0?{}:{min:n.min},...n.max===void 0?{}:{max:n.max}}));return g({scope:e.scope,keys:t,nested_settings:r,count:t.length,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function At(e){let t=Object.fromEntries(Object.keys(p).map(r=>[r,Q(e.settings,r)]));return g({scope:e.scope,values:t,settings_path:e.target.settingsPath,changed:!1},e.warnings)}function St(e,t){let r=Q(e.settings,t),n={scope:e.scope,key:t,settings_path:e.target.settingsPath,changed:!1};return t==="item_format"?g({...n,format:e.settings.item_format,has_explicit_item_format:e.metadata.has_explicit_item_format},e.warnings):t==="context"?g({...n,context_settings:r},e.warnings):t==="agent_identity_vocabulary"?g({...n,identity_vocabulary:r},e.warnings):Array.isArray(r)?g({...n,criteria:r},e.warnings):g({...n,policy:r},e.warnings)}async function qt(e,t,r,n){if(t==="get"){let d=N(e.settings,r);return g({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:d},settings_path:e.target.settingsPath,changed:!1},e.warnings)}let i=n.value;if(typeof i!="string")throw new l(`Config set ${r.key} requires a value. Pass it positionally (\`pm config ${e.scope} set ${r.key} <value>\`) or via --value.`,s.USAGE);let a=pe(r,i);if(!a.ok)throw new l(a.error.message,s.USAGE);let o=ye(e.settings,r,a.parsed.value);return o&&await w(e.target.pmRoot,e.settings,`config:set:${r.path}`),g({scope:e.scope,key:r.key,nested_setting:{key:r.key,path:r.path,kind:r.kind,value:a.parsed.value},settings_path:e.target.settingsPath,changed:o},e.warnings)}async function u(e,t,r){t&&await w(e.target.pmRoot,e.settings,r)}function L(e,t,r){return e!==r||t!==r}function f(e,t,r,n){return g({scope:e.scope,key:t,policy:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}function U(e,t,r,n){return g({scope:e.scope,key:t,criteria:r,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function Gt(e,t){let r=Se(t.format),n=e.settings.item_format!==r||!e.metadata.has_explicit_item_format,i;if(n){let a=P(e.settings,O()),o=await se(e.target.pmRoot,r,"config:set:item_format:migrate",a.type_to_folder,e.settings.schema);i={target_format:o.target_format,scanned:o.scanned,migrated:o.migrated,removed:o.removed,warnings:o.warnings},e.settings.item_format=r,await w(e.target.pmRoot,e.settings,"config:set:item_format")}return g({scope:e.scope,key:"item_format",format:e.settings.item_format,has_explicit_item_format:!0,migration:i,settings_path:e.target.settingsPath,changed:n},e.warnings)}async function It(e,t,r){if(t==="history_missing_stream_policy"){let a=z(r.policy),o=e.settings.history.missing_stream!==a;return e.settings.history.missing_stream=a,await u(e,o,"config:set:history_missing_stream_policy"),f(e,t,e.settings.history.missing_stream,o)}if(t==="sprint_release_format_policy"){let a=R(r.policy),o=e.settings.validation.sprint_release_format!==a;return e.settings.validation.sprint_release_format=a,await u(e,o,"config:set:sprint_release_format_policy"),f(e,t,e.settings.validation.sprint_release_format,o)}if(t==="parent_reference_policy"){let a=k(r.policy),o=e.settings.validation.parent_reference!==a||e.settings.governance.preset!=="custom"||e.settings.governance.parent_reference!==a;return e.settings.validation.parent_reference=a,e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,await u(e,o,"config:set:parent_reference_policy"),f(e,t,e.settings.validation.parent_reference,o)}let n=E(r.policy),i=e.settings.validation.metadata_profile!==n||e.settings.governance.preset!=="custom"||e.settings.governance.metadata_profile!==n;return e.settings.validation.metadata_profile=n,e.settings.governance.preset="custom",e.settings.governance.metadata_profile=n,await u(e,i,"config:set:metadata_validation_profile"),f(e,t,e.settings.validation.metadata_profile,i)}async function Pt(e,t,r){if(t==="metadata_required_fields"){let o=Ge(r.criterion,r.clearCriteria),d=o.length!==e.settings.validation.metadata_required_fields.length||o.some((c,_)=>c!==e.settings.validation.metadata_required_fields[_]);return e.settings.validation.metadata_required_fields=o,await u(e,d,"config:set:metadata_required_fields"),U(e,t,[...e.settings.validation.metadata_required_fields],d)}let n={lifecycle_stale_blocker_reason_patterns:e.settings.validation.lifecycle_stale_blocker_reason_patterns,lifecycle_closure_like_blocked_reason_patterns:e.settings.validation.lifecycle_closure_like_blocked_reason_patterns,lifecycle_closure_like_resolution_patterns:e.settings.validation.lifecycle_closure_like_resolution_patterns,lifecycle_closure_like_actual_result_patterns:e.settings.validation.lifecycle_closure_like_actual_result_patterns}[t],i=yt(t,r.criterion,r.clearCriteria),a=i.length!==n.length||i.some((o,d)=>o!==n[d]);return n.splice(0,n.length,...i),await u(e,a,`config:set:${t}`),U(e,t,[...n],a)}async function Ot(e,t,r){if(t==="governance_preset"){let c=M(r.policy),_=e.settings.governance.preset!==c;return e.settings.governance.preset=c,await u(e,_,"config:set:governance_preset"),f(e,t,e.settings.governance.preset,_)}let n=typeof r.policy=="string",i=n?r.policy.trim():"";if(n&&i.length===0){let c=e.settings.governance.create_default_type!==void 0;return delete e.settings.governance.create_default_type,await u(e,c,"config:set:governance_create_default_type"),f(e,t,e.settings.governance.create_default_type??"",c)}if(i.length===0)throw new l('Config set governance-create-default-type requires an item type value (or an empty value "" to clear it)',s.USAGE);let a=P(e.settings,O()),o=J(i,a);if(!o)throw new l(oe(i,a.types,ne(e.target.pmRoot,e.settings.schema)),s.USAGE);let d=e.settings.governance.create_default_type!==o;return e.settings.governance.create_default_type=o,await u(e,d,"config:set:governance_create_default_type"),f(e,t,e.settings.governance.create_default_type,d)}async function Rt(e,t,r){if(t==="governance_ownership_enforcement"){let a=V(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.ownership_enforcement!==a;return e.settings.governance.preset="custom",e.settings.governance.ownership_enforcement=a,await u(e,o,"config:set:governance_ownership_enforcement"),f(e,t,e.settings.governance.ownership_enforcement,o)}if(t==="governance_create_mode_default"){let a=K(r.policy),o=e.settings.governance.preset!=="custom"||e.settings.governance.create_mode_default!==a;return e.settings.governance.preset="custom",e.settings.governance.create_mode_default=a,await u(e,o,"config:set:governance_create_mode_default"),f(e,t,e.settings.governance.create_mode_default,o)}let n=Y(r.policy),i=e.settings.governance.preset!=="custom"||e.settings.governance.close_validation_default!==n;return e.settings.governance.preset="custom",e.settings.governance.close_validation_default=n,await u(e,i,"config:set:governance_close_validation_default"),f(e,t,e.settings.governance.close_validation_default,i)}async function Tt(e,t,r){if(t==="governance_parent_reference_policy"){let a=k(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.parent_reference,e.settings.validation.parent_reference,a);return e.settings.governance.preset="custom",e.settings.governance.parent_reference=a,e.settings.validation.parent_reference=a,await u(e,o,"config:set:governance_parent_reference_policy"),f(e,t,e.settings.governance.parent_reference,o)}if(t==="governance_metadata_validation_profile"){let a=E(r.policy),o=e.settings.governance.preset!=="custom"||L(e.settings.governance.metadata_profile,e.settings.validation.metadata_profile,a);return e.settings.governance.preset="custom",e.settings.governance.metadata_profile=a,e.settings.validation.metadata_profile=a,await u(e,o,"config:set:governance_metadata_validation_profile"),f(e,t,e.settings.governance.metadata_profile,o)}let n=B(r.policy),i=(e.settings.governance.workflow_enforcement??"off")!==n;return e.settings.governance.workflow_enforcement=n,await u(e,i,"config:set:governance_workflow_enforcement"),f(e,t,e.settings.governance.workflow_enforcement,i)}async function Nt(e,t,r){if(t==="governance_require_close_reason"){let a=H(r.policy)==="enabled",o=e.settings.governance.require_close_reason!==a;return e.settings.governance.require_close_reason=a,await u(e,o,"config:set:governance_require_close_reason"),f(e,t,e.settings.governance.require_close_reason?"enabled":"disabled",o)}let n=W(r.policy)==="enabled",i=e.settings.governance.preset!=="custom"||e.settings.governance.force_required_for_stale_lock!==n;return e.settings.governance.preset="custom",e.settings.governance.force_required_for_stale_lock=n,await u(e,i,"config:set:governance_force_required_for_stale_lock"),f(e,t,e.settings.governance.force_required_for_stale_lock?"enabled":"disabled",i)}async function $t(e,t,r){if(t==="test_result_tracking"){let a=qe(r.policy)==="enabled",o=e.settings.testing.record_results_to_items!==a;return e.settings.testing.record_results_to_items=a,await u(e,o,"config:set:test_result_tracking"),f(e,t,e.settings.testing.record_results_to_items?"enabled":"disabled",o)}if(t==="untrusted_linked_test_execution"){let a=j(r.policy,"untrusted-linked-test-execution")==="enabled",o=e.settings.testing.allow_untrusted_linked_tests!==a;return e.settings.testing.allow_untrusted_linked_tests=a,await u(e,o,"config:set:untrusted_linked_test_execution"),f(e,t,e.settings.testing.allow_untrusted_linked_tests?"enabled":"disabled",o)}let n=F(r.policy)==="enabled",i=e.settings.telemetry.enabled!==n||!e.settings.telemetry.first_run_prompt_completed;return e.settings.telemetry.enabled=n,e.settings.telemetry.first_run_prompt_completed=!0,await u(e,i,"config:set:telemetry_tracking"),f(e,t,e.settings.telemetry.enabled?"enabled":"disabled",i)}async function Dt(e,t,r){let n=Ae(r.criterion,r.clearCriteria),i=n.length!==e.settings.workflow.definition_of_done.length||n.some((a,o)=>a!==e.settings.workflow.definition_of_done[o]);return e.settings.workflow.definition_of_done=n,await u(e,i,"config:set:definition_of_done"),U(e,t,[...e.settings.workflow.definition_of_done],i)}function Lt(e){let t=e?.trim().toLowerCase().replaceAll("_","-"),r=t?.startsWith("preview-")===!0,n=r?t.slice(8):t;if(n==="add"||n==="remove"||n==="clear")return{operation:n,dryRun:r};throw new l("Config set agent-identity-vocabulary requires --policy add|remove|clear|preview-add|preview-remove|preview-clear",s.USAGE)}function Ut(e,t){if(e==="add"){let r=t?.lastIndexOf("=")??-1;if(r<=0||r===t.length-1)throw new l('Config set agent-identity-vocabulary --policy add requires --value "<legacy-author>=<canonical-harness>"',s.USAGE);return{legacy_author:t.slice(0,r),canonical_harness:t.slice(r+1)}}if(e==="remove"){if(t===void 0)throw new l("Config set agent-identity-vocabulary --policy remove requires --value <legacy-author>",s.USAGE);return{legacy_author:t}}if(t!==void 0)throw new l("Config set agent-identity-vocabulary --policy clear does not accept --value",s.USAGE);return{}}async function zt(e,t){let{operation:r,dryRun:n}=Lt(t.policy),i=Ut(r,t.value),a;try{a=de(e.settings.agent_identity?.identity_vocabulary,{operation:r,...i,observed_authors:t.criterion})}catch(o){throw new l(o.message,s.USAGE)}return a.preview.changed&&!n&&(e.settings.agent_identity={...e.settings.agent_identity,identity_vocabulary:a.vocabulary},await u(e,!0,`config:set:agent_identity.identity_vocabulary:${r}:v${a.preview.version_after}`)),g({scope:e.scope,key:"agent_identity_vocabulary",identity_vocabulary:T(n?e.settings.agent_identity?.identity_vocabulary:a.vocabulary),vocabulary_mutation:a.preview,settings_path:e.target.settingsPath,changed:a.preview.changed&&!n},e.warnings)}async function jt(e,t,r){if(r.clearCriteria===!0&&!$(t))throw new l("--clear-criteria is only supported with config set criteria-list keys",s.USAGE);return t==="item_format"?Gt(e,r):t==="context"?kt(e.settings,r,e.target,e.scope,e.warnings):t==="agent_identity_vocabulary"?zt(e,r):t==="definition_of_done"?Dt(e,t,r):be(t)?Pt(e,t,r):st.has(t)?$t(e,t,r):lt.has(t)?Nt(e,t,r):ut(t)?Rt(e,t,r):ft(t)?Tt(e,t,r):gt(t)?Ot(e,t,r):It(e,t,r)}async function Cr(e,t,r,n,i,a){let o=ke(e),d=Ce(t),c=d==="get"||d==="set"?me(r):void 0,_=c?void 0:ht(d,r),m=Oe(d,r,_,c,a,n),y=await wt(o,i),{settings:h,metadata:De,warnings:Le}=await ae(y.pmRoot),v={scope:o,target:y,settings:h,metadata:De,warnings:Ie(Le)};return c?qt(v,d,c,m):d==="list"?Et(v):d==="export"?At(v):(Pe(_),d==="get"?St(v,_):jt(v,_,m))}var Er={hasGovernanceValidationMirrorChange:L,applyPositionalValue:Oe,normalizeAction:Ce,normalizeCriteria:Ae,normalizeGovernanceCloseValidationDefault:Y,normalizeGovernanceCreateModeDefault:K,normalizeGovernanceForceRequiredForStaleLockPolicy:W,normalizeGovernanceOwnershipEnforcement:V,normalizeGovernancePreset:M,normalizeGovernanceRequireCloseReasonPolicy:H,normalizeGovernanceWorkflowEnforcement:B,normalizeHistoryMissingStreamPolicy:z,normalizeItemFormat:Se,normalizeKey:Ee,normalizeMetadataRequiredFields:Ge,normalizePolicyForConflict:D,normalizeScope:ke,normalizeTelemetryTrackingPolicy:F,normalizeTestResultTrackingPolicy:qe,normalizeValidateMetadataProfile:E,normalizeWarnings:Ie};import{execFile as Ft}from"node:child_process";import Mt from"node:path";import{promisify as Vt}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7fe99df0-8454-5667-9205-0b861ba212d1")}catch{}})();var Kt=Vt(Ft),Te="@unbrained/pm-cli",Yt="latest",Bt={global:["--global"],project:[]};function Re(e){let t=e.project===!0||e.local===!0||e.scope==="project",r=e.global===!0||e.scope==="global";if(t&&r)throw new l('Options "--project/--local" and "--global" are mutually exclusive.',s.USAGE);return r?"global":"project"}function S(e){return e.trim().toLowerCase()}function Ne(e,t){let r=S(t);return[e.name,e.directory,e.source.input,e.source.location,e.source.package,e.source.repository,e.source.owner&&e.source.repo?`${e.source.owner}/${e.source.repo}`:void 0].some(n=>typeof n=="string"&&S(n)===r)}function Wt(e,t){let r=b(process.cwd(),t.path),n=ee(r,process.cwd());return{selected_root:e==="global"?n.global:n.project}}async function Ht(e,t,r){try{let n=await Kt(e,t,{cwd:r?.cwd,encoding:"utf8"});return{stdout:n.stdout,stderr:n.stderr}}catch(n){let i=typeof n=="object"&&n!==null&&"stderr"in n?String(n.stderr??""):"",a=i.trim().length>0?i.trim():n instanceof Error?n.message:String(n);throw new l(`Command failed: ${e} ${t.join(" ")}
2
2
  ${a}`,s.GENERIC_FAILURE)}}function q(e){return typeof e.tag=="string"&&e.tag.trim().length>0?e.tag.trim():Yt}function A(e){return typeof e.packageName=="string"&&e.packageName.trim().length>0?e.packageName.trim():Te}async function Qt(e,t){let r=e.commandRunner??Ht,n=A(e),i=q(e),a=`${n}@${i}`,o=["npm","install","-g",a];e.repair===!0&&o.push("--force");let d=X(import.meta.url,["../../.."]),c={requested:!0,status:"planned",package:n,target:a,command:o,before_version:d,...n===Te?{migration_guidance:["Calendar scheduling commands are package-owned. If calendar is absent, run pm package install calendar --project; use pm calendar meet, pm calendar event, or pm calendar remind."]}:{},repair:e.repair===!0};if(t)return c;try{await r(o[0],o.slice(1));let _=await r("pm",["--version"]);return{...c,status:"updated",after_version:_.stdout.trim()||void 0}}catch(_){return{...c,status:"failed",error:_ instanceof Error?_.message:String(_)}}}function Xt(e){return Mt.isAbsolute(e)||e.startsWith(".")||e.startsWith("..")||e.startsWith("file:")}function Jt(e,t){if(e.kind==="npm"){let r=e.input.startsWith("npm:")?e.input.slice(4).trim():e.input.trim();return!Xt(r)&&e.package&&e.package.trim().length>0?`npm:${e.package.trim()}@${t}`:e.input.startsWith("npm:")?e.input:`npm:${e.input}`}return e.input}async function Zt(e,t){let r=Jt(e,t);return e.kind!=="local"||await G(r)?r:await G(e.location)?e.location:r}function xt(e,t,r,n){let i=["pm","package","install",t,r==="global"?"--global":"--project"];return e.kind==="github"&&n&&n.trim().length>0&&i.push("--ref",n.trim()),i}async function $e(e,t){let r=Wt(e,t);return(await le(r.selected_root)).state.entries.filter(n=>n.scope===e)}async function er(e,t,r){let n=await $e(e,t);return n.find(i=>Ne(i,r.name))??n.find(i=>S(i.directory)===S(r.directory))}async function tr(e,t,r,n,i){let a=q(t),o=await Zt(e.source,a),d=xt(e.source,o,n,e.source.ref),c={name:e.name,directory:e.directory,scope:n,source:e.source,status:"planned",command:d,previous_version:e.manifest_version};if(i)return c;try{await ce(o,{install:!0,project:n==="project",global:n==="global",ref:e.source.kind==="github"?e.source.ref:void 0},r);let _=await er(n,r,e);return{...c,status:"updated",installed_version:_?.manifest_version}}catch(_){return{...c,status:"failed",error:_ instanceof Error?_.message:String(_)}}}function rr(e,t,r,n){let i=[r?e.status:void 0,...t.map(a=>a.status)].filter(a=>typeof a=="string");return{requested_cli:r,requested_packages:n,planned:i.filter(a=>a==="planned").length,updated:i.filter(a=>a==="updated").length,skipped:i.filter(a=>a==="skipped").length,failed:i.filter(a=>a==="failed").length}}async function Rr(e,t,r){let n=typeof e=="string"&&e.trim().length>0?e.trim():void 0;if(t.cliOnly===!0&&t.packagesOnly===!0){let h=["package","upgrade",...n?[n]:[],"--packages-only","--dry-run",...Bt[Re(t)]];throw new l('Options "--cli-only" and "--packages-only" are mutually exclusive.',s.USAGE,{code:"package_upgrade_modes_mutually_exclusive",recovery:{suggested_retry:te(h),suggested_retry_args:h}})}let i=Re(t),a=t.dryRun===!0;if(t.cliOnly===!0&&n)throw new l('A package target cannot be used with "--cli-only".',s.USAGE);let o=!(t.packagesOnly===!0||n),d=t.cliOnly!==!0,c=o?await Qt(t,a):{requested:!1,status:"skipped",package:A(t),target:`${A(t)}@${q(t)}`,command:["npm","install","-g",`${A(t)}@${q(t)}`],repair:t.repair===!0,reason:"not_requested"},_=d?await $e(i,r):[];if(n&&(_=_.filter(h=>Ne(h,n)),_.length===0))throw new l(`Managed package "${n}" was not found in ${i} scope.`,s.NOT_FOUND);let m=[];for(let h of _)m.push(await tr(h,t,r,i,a));let y=rr(c,m,o,d);return{ok:y.failed===0,action:"upgrade",dry_run:a,scope:i,target:n,cli:c,packages:m,summary:y}}export{me as a,pe as b,N as c,ye as d,T as e,de as f,Cr as g,Er as h,Rr as i};
3
- //# sourceMappingURL=chunk-DMFM5R4G.js.map
3
+ //# sourceMappingURL=chunk-NNB65OOO.js.map
@@ -1,2 +1,2 @@
1
- import{da as p,ea as i,fa as v,ga as _}from"./chunk-H3XYP24A.js";import{za as h}from"./chunk-QG4LMU7A.js";import u from"node:fs/promises";import c from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
- //# sourceMappingURL=chunk-D3EDNAN7.js.map
1
+ import{da as p,ea as i,fa as v,ga as _}from"./chunk-V3XONSVC.js";import{za as h}from"./chunk-KBSVPUFD.js";import u from"node:fs/promises";import c from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
+ //# sourceMappingURL=chunk-QPV6UD55.js.map
@@ -1,3 +1,3 @@
1
- import{e as k,g as I,h as A,i as _,o as T,q as C}from"./chunk-XH7C3A5N.js";import{Fb as b,Gb as v,Hb as R}from"./chunk-OEJ3G7XT.js";import{Ef as f,Hf as g,Ic as x,If as a,Zf as w,qe as H}from"./chunk-4CXQSRSP.js";import{Sc as E,tf as D,wf as m,xf as y}from"./chunk-QG4LMU7A.js";import{B as c,D as p}from"./chunk-QKAAZWGC.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="631e56aa-4d7e-58b6-bbea-a0d320716b82")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0bcdd63c-5fd3-585d-a6c5-9393029ef864")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4dce4f19-071c-54a8-be0d-5975d9e3b34b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f330a0c5-a967-5383-9c27-efa4a39e0f0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a178bd8b-fc53-5633-84d5-621b61930581")}catch{}})();function O(t,e){if(typeof t!="string")return;let o=Number.parseInt(t,10);if(!/^\d+$/.test(t.trim())||!Number.isSafeInteger(o))throw new p(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function S(t,e,o){let r=f(o),n=Date.now(),i=await x(a(e,"ids")),l=i===void 0?void 0:H(i),d=O(e.allOver,"--all-over"),u=O(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new p("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let s=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||d!==void 0||s!==void 0)&&typeof e.before=="string")throw new p("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(I(t,{ids:l,allOver:d,scope:s}),t!==void 0&&u!==void 0)throw new p("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(t===void 0){let h=await A({ids:l,scope:s,allOver:d,minEntries:u,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await k(t,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r)}r.profile&&y(`profile:command=history-compact took_ms=${Date.now()-n}`)}async function N(t,e,o,r){let n=f(r),i=Date.now(),l=await C(t,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},n);await w(n,l),m(l,n),n.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function B(t,e){let o=f(e),r=await T({verify:a(t,"verify"),output:a(t,"output"),hashAlgorithm:a(t,"hashAlgorithm")},o);"format"in r?(E(r),o.quiet||D(`${JSON.stringify(r,null,2)}
1
+ import{a as k,c as I,d as A,e as _,k as T,m as C}from"./chunk-ZNKFMIVA.js";import{Db as b,Eb as v,Fb as R}from"./chunk-MZZIAC6S.js";import{Ef as f,Hf as g,Ic as x,If as a,Zf as w,qe as H}from"./chunk-V5GJTXYW.js";import{Hf as D,Kf as m,Lf as y,Tc as E}from"./chunk-KBSVPUFD.js";import{A as c,C as p}from"./chunk-GWIGZDRS.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="631e56aa-4d7e-58b6-bbea-a0d320716b82")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0bcdd63c-5fd3-585d-a6c5-9393029ef864")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4dce4f19-071c-54a8-be0d-5975d9e3b34b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f330a0c5-a967-5383-9c27-efa4a39e0f0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a178bd8b-fc53-5633-84d5-621b61930581")}catch{}})();function O(t,e){if(typeof t!="string")return;let o=Number.parseInt(t,10);if(!/^\d+$/.test(t.trim())||!Number.isSafeInteger(o))throw new p(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function S(t,e,o){let r=f(o),n=Date.now(),i=await x(a(e,"ids")),l=i===void 0?void 0:H(i),d=O(e.allOver,"--all-over"),u=O(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new p("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let s=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||d!==void 0||s!==void 0)&&typeof e.before=="string")throw new p("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(I(t,{ids:l,allOver:d,scope:s}),t!==void 0&&u!==void 0)throw new p("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(t===void 0){let h=await A({ids:l,scope:s,allOver:d,minEntries:u,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await k(t,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r)}r.profile&&y(`profile:command=history-compact took_ms=${Date.now()-n}`)}async function N(t,e,o,r){let n=f(r),i=Date.now(),l=await C(t,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},n);await w(n,l),m(l,n),n.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function B(t,e){let o=f(e),r=await T({verify:a(t,"verify"),output:a(t,"output"),hashAlgorithm:a(t,"hashAlgorithm")},o);"format"in r?(E(r),o.quiet||D(`${JSON.stringify(r,null,2)}
2
2
  `)):m(r,o),"ok"in r&&!r.ok&&(process.exitCode=c.GENERIC_FAILURE)}function Z(t,e){t.command(e?"attest":"history-attest",{hidden:!e}).summary("Export or verify history proof.").option("--verify <file>","Compare retained streams with a detached JSON proof").option("--output <file>","Create a proof file and return a compact receipt").option("--hash-algorithm <name>","Bundle digest algorithm: sha256 (default) or sha512").description("Export exact-byte history commitments, or verify an independently retained proof without tracker writes.").action(B),t.command("restore",{hidden:!e}).summary("Restore a version.").argument("<id>","Item id").argument("<target>","Restore target timestamp or version number").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(N),t.command(e?"redact":"history-redact",{hidden:!e}).summary("Redact sensitive values.").argument("<id>","Item id").option("--literal <value>","Literal string to redact (repeatable)",g).option("--regex <value>","Regex pattern to redact (repeatable; accepts /pattern/flags or raw pattern)",g).option("--replacement <value>",'Replacement string (default: "[redacted]")').option("--dry-run","Preview redaction impact without writing item/history files").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the redaction marker entry").option("--force","Force ownership/lock override").description("Redact sensitive literals/patterns from an item history stream and recompute hashes.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=Array.isArray(r.literal)?r.literal:void 0,u=Array.isArray(r.regex)?r.regex:void 0,s=await _(o,{literal:d,regex:u,replacement:a(r,"replacement"),dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force},i);s.changed&&!s.dry_run&&await w(i,s),m(s,i),i.profile&&y(`profile:command=history-redact took_ms=${Date.now()-l}`)}),t.command(e?"repair":"history-repair",{hidden:!e}).summary("Repair drift.").argument("[id]","Item id (omit with --all)").option("--salvage-tail","Recover invalid tail; requires verified prefix").option("--all","Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run","Preview the re-anchor impact without writing the history file").option("--normalize-provenance","Remove invalid provenance; return aggregate-only evidence").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the repair marker entry").option("--force","Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=r.all===!0;v(o,d);let u={dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force,normalizeProvenance:r.normalizeProvenance===!0,salvageTail:r.salvageTail===!0};if(d){let s=await R(u,i);m(s,i),s.totals.failed>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let s=await b(o,u,i);m(s,i)}i.profile&&y(`profile:command=history-repair took_ms=${Date.now()-l}`)}),t.command(e?"compact":"history-compact",{hidden:!e}).summary("Compact streams.").argument("[id]","Item id (omit when using a bulk selector)").option("--before <value>","Compact entries strictly before this version number or ISO timestamp (single-id mode only)").option("--ids <value>","Bulk IDs: comma/newline text, - stdin, or @path file").option("--all-over <n>","Bulk: compact every stream with more than N entries").option("--closed","Bulk: compact only closed (terminal) items' streams").option("--all-streams","Bulk: compact every history stream regardless of lifecycle state").option("--min-entries <n>","Bulk: skip streams with at most N entries (already compact; default 3)").option("--dry-run","Preview compaction impact without writing the history file").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the compaction marker entry").option("--force","Force ownership/lock override").description("Compact item history streams into a synthetic baseline plus retained tail entries. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to compact many.").action(S)}export{Z as a};
3
- //# sourceMappingURL=chunk-6DS5CAN2.js.map
3
+ //# sourceMappingURL=chunk-TMXWWOPJ.js.map
@@ -1,4 +1,4 @@
1
- import{$c as Ce,E as Ja,H as It,I as At,L as Oe,Q as qa,R as mn,_c as Ba,ad as tt,bd as Ha,cd as Ka,dd as ae,ed as ze,fd as Va,g as be,gd as re,hc as Wa,hf as Tt,k as Fa,l as Ma,m as ke,n as Ua,o as za,qe as Ya,y as Ga}from"./chunk-4CXQSRSP.js";import{i as Za,n as Qa,p as ei}from"./chunk-O2ZRRLAP.js";import{Aa as ga,Ac as Oa,Ad as Ra,Af as Me,Bb as ka,Bd as Qe,Cb as xa,Cc as Et,Db as Sa,Dc as Ca,Ec as Pa,G as pa,Gb as Ea,Hb as $a,Oc as J,Pb as Ia,Pe as A,Pf as I,Q as kt,Qf as V,R as rn,Rb as Aa,Rf as Na,S as on,Sa as xt,Sf as H,Ta as ya,Tf as ee,Ua as sn,Ub as Te,Ug as ja,Uh as pn,Va as cn,Vf as Da,Wa as dn,We as ne,Wh as La,Xf as et,Xh as Ue,Ya as _a,Yc as W,Za as wa,Zf as $t,Zg as K,ab as va,di as pe,hb as ba,ii as C,j as sa,ji as ve,na as ma,oa as ua,pa as q,rc as ln,sc as Ta,tc as St,v as B,vc as _e,xa as F,xc as we,ya as fa,z as ye,za as ha}from"./chunk-QG4LMU7A.js";import{f as Xa}from"./chunk-LBEMB3BW.js";import{B as h,D as f,F as k,G as bt,H as ge,I as G,L as le,b as ca,e as vt,n as da,u as nn,w as la,z as an}from"./chunk-QKAAZWGC.js";import{mkdir as gs,readFile as ys}from"node:fs/promises";import ii from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fae5539-4eb8-5eba-bfd6-a191c89448ec")}catch{}})();var un=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},_s="sdk-workspace-transaction",ws=/^[a-zA-Z0-9._-]+$/,vs=30,bs=3e3;function ri(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!ws.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function ti(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function ks(e){return{pmRoot:ti(e.pmRoot,"Transaction pmRoot"),transactionId:ri(e.transactionId,"Transaction id"),author:ti(e.author,"Transaction author")}}function ni(e,t,n){let a=e??t;if(!Number.isInteger(a)||a<=0)throw new TypeError(`${n} must be a positive integer`);return a}function oi(e,t){return ii.join(e,"transactions","sdk",`${t}.json`)}async function xe(e,t){t.updatedAt=A();let n=oi(e,t.transactionId);await gs(ii.dirname(n),{recursive:!0}),await le(n,`${JSON.stringify(t,null,2)}
1
+ import{$c as Ce,E as Ja,H as It,I as At,L as Oe,Q as qa,R as mn,_c as Ba,ad as tt,bd as Ha,cd as Ka,dd as ae,ed as ze,fd as Va,g as be,gd as re,hc as Wa,k as Fa,l as Ma,m as ke,n as Ua,nf as Tt,o as za,qe as Ya,y as Ga}from"./chunk-V5GJTXYW.js";import{i as Za,n as Qa,p as ei}from"./chunk-DJQVNDXO.js";import{$e as ne,Aa as ga,Ac as Oa,Bb as ka,Bd as Ra,Cb as xa,Cc as Et,Cd as Qe,Db as Sa,Dc as Ca,Ec as Pa,G as pa,Gb as Ea,Hb as $a,Oc as J,Of as Me,Pb as Ia,Q as kt,R as rn,Rb as Aa,Re as A,S as on,Sa as xt,Ta as ya,Ua as sn,Ub as Te,Va as cn,Wa as dn,Ya as _a,Za as wa,Zc as W,ab as va,bg as I,cg as V,dg as Na,eg as H,fg as ee,gh as ja,gi as pn,hb as ba,hg as Da,ii as La,j as sa,jg as et,ji as Ue,lg as $t,lh as K,na as ma,oa as ua,pa as q,rc as ln,ri as pe,sc as Ta,tc as St,v as B,vc as _e,wi as C,xa as F,xc as we,xi as ve,ya as fa,z as ye,za as ha}from"./chunk-KBSVPUFD.js";import{f as Xa}from"./chunk-4OYU5OXQ.js";import{A as h,C as f,E as k,F as bt,G as ge,H as G,K as le,a as ca,d as vt,m as da,t as nn,v as la,y as an}from"./chunk-GWIGZDRS.js";import{mkdir as gs,readFile as ys}from"node:fs/promises";import ii from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fae5539-4eb8-5eba-bfd6-a191c89448ec")}catch{}})();var un=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},_s="sdk-workspace-transaction",ws=/^[a-zA-Z0-9._-]+$/,vs=30,bs=3e3;function ri(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!ws.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function ti(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function ks(e){return{pmRoot:ti(e.pmRoot,"Transaction pmRoot"),transactionId:ri(e.transactionId,"Transaction id"),author:ti(e.author,"Transaction author")}}function ni(e,t,n){let a=e??t;if(!Number.isInteger(a)||a<=0)throw new TypeError(`${n} must be a positive integer`);return a}function oi(e,t){return ii.join(e,"transactions","sdk",`${t}.json`)}async function xe(e,t){t.updatedAt=A();let n=oi(e,t.transactionId);await gs(ii.dirname(n),{recursive:!0}),await le(n,`${JSON.stringify(t,null,2)}
2
2
  `)}function xs(e){return Number.isInteger(e.attempt)&&typeof e.author=="string"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string"}function Pe(e){return Object.assign(Object.create(null),e)}function Ss(e,t){try{let n=JSON.stringify(e,(a,i)=>{if(typeof i=="number"&&!Number.isFinite(i))throw new TypeError(`${t} contains a non-finite number`);if(i===void 0||typeof i=="function"||typeof i=="symbol")throw new TypeError(`${t} contains a non-JSON value`);return i});return JSON.parse(n)}catch(n){throw new TypeError(`${t} must be JSON serializable`,{cause:n})}}function fn(e,t){return e===void 0?void 0:Ss(e,t)}function hn(e,t,n,a){let i=fn(n,a);i===void 0?delete e[t]:e[t]=i}function ai(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gn(e,t){return Array.isArray(e)&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n))}function Es(e,t){if(!gn(e.startedStepIds,t)||!gn(e.completedStepIds,t)||!ai(e.results)||!ai(e.compensationData))return!1;let n=e.startedStepIds,a=new Set(n),i=e.completedStepIds,r=new Set(i);return Object.keys(e.compensationData).some(o=>!a.has(o))||Object.keys(e.results).some(o=>!r.has(o))?!1:e.status==="committed"?t.every(o=>r.has(o)):e.status!=="compensated"||r.size===0&&a.size===0}function Ot(e,t){return new f(`Workspace transaction ${e} journal is invalid (${t})`,h.CONFLICT,{code:"transaction_journal_invalid",required:"A valid durable journal is required before transaction recovery can continue.",why:"Corrupt journal data cannot establish which steps applied or still require compensation.",nextSteps:["Preserve the journal and inspect its integrity or restore a verified backup before retrying.","Do not switch to a new transaction id to bypass an unreadable journal; previously applied work may remain."]})}function $s(e){return new f(`Workspace transaction ${e} journal does not match the supplied plan`,h.CONFLICT,{code:"transaction_plan_mismatch",required:"Replay the exact plan that started this transaction, or start a new transaction with a different id.",why:"A journal records the plan it is resuming; applying a different plan under the same id could skip or duplicate steps.",nextSteps:["Re-run with the original document to resume or replay it.","Pass --transaction-id <new-id> (or a new transactionId over MCP) to commit the changed plan as its own transaction.","Run pm ops gc --scope transactions --dry-run to inspect abandoned journals before pruning them."]})}function Is(e,t,n){let a;try{a=JSON.parse(e)}catch{throw Ot(t,"invalid JSON")}if(!a||typeof a!="object"||Array.isArray(a))throw Ot(t,"expected an object");let i=a;if(!(i.schemaVersion===1&&i.transactionId===t))throw Ot(t,"schema version or transaction id does not match the journal file");let r=i.stepIds;if(!Array.isArray(r)||!gn(r,r)||!Es(i,r)||!xs(i)||typeof i.status!="string"||!["applying","compensating","compensated","committed"].includes(i.status))throw Ot(t,"invalid lifecycle, metadata, status or step ids");if(!(i.status==="compensated"||r.length===n.length&&r.every((o,s)=>o===n[s])))throw $s(t);return{...i,results:Pe(i.results),compensationData:Pe(i.compensationData)}}async function As(e,t,n,a,i){let r=i,o=r!==void 0;if(r?.status==="compensating"&&await si(e,r),r===void 0||r.status==="compensated"){let s=A();r={schemaVersion:1,transactionId:t,author:n,status:"applying",attempt:(r?.attempt??0)+1,createdAt:r?.createdAt??s,updatedAt:s,stepIds:a,startedStepIds:[],completedStepIds:[],results:Pe(),compensationData:Pe()},await xe(e.pmRoot,r),await me(e,r,"prepared")}return{journal:r,recovered:o}}async function Ts(e,t,n){try{await Cs(t,e.steps),await xe(e.pmRoot,t);let a=new Set(t.completedStepIds),i=new Set(t.startedStepIds);for(let r of e.steps){if(a.has(r.id))continue;let o=await r.inspect(),s=fn(o.result,`Step ${r.id} result`);if(o.state!=="applied"){let d=await r.prepareCompensation?.();hn(t.compensationData,r.id,d,`Step ${r.id} compensation data`),i.add(r.id),t.startedStepIds=e.steps.map(l=>l.id).filter(l=>i.has(l)),await xe(e.pmRoot,t);let c=await r.apply();s=fn(c,`Step ${r.id} result`)}await me(e,t,"step_applied",r.id),a.add(r.id),t.completedStepIds=e.steps.map(d=>d.id).filter(d=>a.has(d)),hn(t.results,r.id,s,`Step ${r.id} result`),await xe(e.pmRoot,t),await me(e,t,"step_recorded",r.id)}return await me(e,t,"committing"),t.status="committed",await xe(e.pmRoot,t),await me(e,t,"committed"),{transactionId:t.transactionId,status:"committed",recovered:n,results:Pe(t.results)}}catch(a){if(a instanceof un||t.status==="committed")throw a;try{await si(e,t)}catch(i){throw new AggregateError([a,i],`Workspace transaction failed and compensation failed: ${String(i)}`,{cause:i})}throw a}}async function Os(e,t,n){try{return Is(await ys(oi(e,t),"utf8"),t,n)}catch(a){if(a!==null&&typeof a=="object"&&"code"in a&&ge(a))return;throw a}}async function me(e,t,n,a){await e.onTransition?.({transactionId:t.transactionId,attempt:t.attempt,transition:n,...a===void 0?{}:{stepId:a}})}async function Cs(e,t){let n=new Set,a=Pe();for(let i of t){let r=await i.inspect();r.state==="applied"&&(n.add(i.id),hn(a,i.id,r.result,`Step ${i.id} result`))}e.results=a,e.completedStepIds=t.map(i=>i.id).filter(i=>n.has(i))}async function si(e,t){t.status="compensating",await xe(e.pmRoot,t),await me(e,t,"compensating");let n=new Set(t.completedStepIds),a=new Set(t.startedStepIds);for(let i of[...e.steps].reverse()){if(!a.has(i.id)&&!n.has(i.id))continue;let r;try{r=a.has(i.id)&&(await i.inspect()).state==="applied"}catch{r=a.has(i.id)}r&&(await me(e,t,"step_compensating",i.id),await i.compensate(t.compensationData[i.id])),n.delete(i.id),a.delete(i.id),t.completedStepIds=e.steps.map(o=>o.id).filter(o=>n.has(o)),t.startedStepIds=e.steps.map(o=>o.id).filter(o=>a.has(o)),delete t.results[i.id],delete t.compensationData[i.id],await xe(e.pmRoot,t),await me(e,t,"step_compensated",i.id)}t.status="compensated",await xe(e.pmRoot,t),await me(e,t,"compensated")}async function ci(e){let{pmRoot:t,transactionId:n,author:a}=ks(e),i=ni(e.lockTtlSeconds,vs,"Transaction lock TTL"),r=ni(e.lockWaitMs,bs,"Transaction lock wait"),o=[...e.steps];if(o.length===0)throw new TypeError("Workspace transaction requires at least one step");let s=o.map(l=>{let p=ri(l.id,"Transaction step id");if(p!==l.id)throw new TypeError("Transaction step id must not contain surrounding whitespace");return p});if(new Set(s).size!==s.length)throw new TypeError("Workspace transaction step ids must be unique");let d={...e,pmRoot:t,transactionId:n,author:a,steps:o,lockTtlSeconds:i,lockWaitMs:r},c=await ne(t,_s,i,a,!1,!1,r);try{let l=await Os(t,n,s),p=l!==void 0;if(l?.status==="committed")return{transactionId:n,status:"committed",recovered:!0,results:Pe(l.results)};let m=await As(d,n,a,s,l);return await Ts(d,m.journal,p||m.recovered)}finally{await c()}}import Ps from"node:fs/promises";import Rs from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7be00b26-4a56-5399-94f6-f2f67cc5c1e6")}catch{}})();function yn(e){return Rs.join(e,"extension-migrations.json")}function di(e,t){let n=e.definition.id;return typeof n=="string"&&n.trim().length>0?n.trim():`migration-${String(t+1).padStart(3,"0")}`}function li(e,t){return`${e.layer}:${e.name}:${t}`}async function Ns(e){let t=yn(e);if(!await k(t))return{version:1,updated_at:"",entries:[]};let n=JSON.parse(await Ps.readFile(t,"utf8"));return{version:1,updated_at:typeof n.updated_at=="string"?n.updated_at:"",entries:Array.isArray(n.entries)?n.entries.filter(a=>typeof a?.key=="string"&&(a.status==="applied"||a.status==="failed")):[]}}async function Ds(e,t){let n=await Ns(e),a=new Map(n.entries.map(i=>[i.key,i]));return t.forEach((i,r)=>{let o=di(i,r),s=a.get(li(i,o));s&&(i.definition.status=s.status,s.status==="failed"?i.definition.reason=s.error:(delete i.definition.reason,delete i.definition.error,delete i.definition.message))}),n}async function js(e){let t=await Ds(e.pmRoot,e.migrations),n=new Map(t.entries.map(l=>[l.key,l])),a=[],i=!1,r=e.migrations.map((l,p)=>({migration:l,index:p})).filter(({migration:l})=>e.scope===void 0||l.layer===e.scope);for(let{migration:l,index:p}of r){let m=di(l,p),y=li(l,m),g=n.get(y),_=String(l.definition.status??"pending").toLowerCase(),u=g?.status??(_==="applied"||_==="failed"?_:"pending");if(u==="applied"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"skipped"});continue}if(e.dryRun===!0){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"pending"});continue}let w=l.runtime_definition?.run??l.definition.run;if(typeof w!="function"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"pending"});continue}let v=new Date().toISOString();try{await Promise.resolve(w({id:m,command:"migration",layer:l.layer,extension:l.name,pm_root:e.pmRoot,status:u}));let S={key:y,layer:l.layer,extension:l.name,id:m,status:"applied",attempted_at:v};n.set(y,S),l.definition.status="applied",delete l.definition.reason,delete l.definition.error,delete l.definition.message,a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"applied"}),i=!0}catch(S){let x=S instanceof Error?S.message:String(S),T={key:y,layer:l.layer,extension:l.name,id:m,status:"failed",attempted_at:v,error:x};n.set(y,T),l.definition.status="failed",l.definition.reason=x,a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"failed",error:x}),i=!0}}if(i){let l=await C(e.pmRoot),p={version:1,updated_at:new Date().toISOString(),entries:[...n.values()].sort((m,y)=>m.key.localeCompare(y.key))};await Ue({pmRoot:e.pmRoot,filePath:yn(e.pmRoot),raw:`${JSON.stringify(p,null,2)}
3
3
  `,op:"extension_migrations_apply",author:e.author,lockTtlSeconds:l.locks.ttl_seconds,lockWaitMs:l.locks.wait_ms})}let o=a.filter(l=>l.outcome==="pending").length,s=a.filter(l=>l.outcome==="applied").length,d=a.filter(l=>l.outcome==="skipped").length,c=a.filter(l=>l.outcome==="failed").length;return{ok:c===0,dry_run:e.dryRun===!0,state_path:yn(e.pmRoot),total:a.length,pending_count:o,applied_count:s,skipped_count:d,failed_count:c,migrations:a}}async function pi(e){let t=await C(e.resolvedRoots.settings_root),n=await _e({pmRoot:e.resolvedRoots.pm_root,settings:t,cwd:process.cwd(),noExtensions:e.global.noExtensions===!0}),a=await we(n);e.warnings.push(...n.warnings,...a.warnings);let i=await js({pmRoot:e.resolvedRoots.pm_root,migrations:a.registrations.migrations,author:typeof e.global.author=="string"&&e.global.author.trim().length>0?e.global.author.trim():"pm-extension-migration",dryRun:e.options.dryRun===!0,...e.scope==="global"?{scope:"global"}:{}});return e.withResult({migration:i,load_failure_count:n.failed.length,activation_failure_count:a.failed.length},i.ok)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="184c43e0-a543-5b0b-ac09-9139ba5ded6a")}catch{}})();var Ls=[["beforeCommand","before_command"],["beforeMutation","before_mutation"],["afterCommand","after_command"],["onWrite","on_write"],["onRead","on_read"],["onIndex","on_index"]];function Ge(e,t={}){let n=new Set;t.extensionName!==void 0&&n.add(Et(t.extensionName));for(let u of t.extensionNames??[])n.add(Et(u));let a=u=>n.size===0||n.has(Et(u)),i=(u,w)=>mi(u.filter(v=>a(v.name)).map(w)),r=(u,w)=>mi(u.filter(v=>a(v.name)).flatMap(w)),{registrations:o,commands:s,parsers:d,preflight:c,services:l,renderers:p,hooks:m}=e,y=r(o.relationship_kinds??[],u=>u.definitions.map(w=>w.kind)),g=p.overrides.filter(u=>a(u.name)&&((u.commands?.length??0)>0||u.resultDiscriminator!==void 0)).map(u=>({format:u.format,commands:[...u.commands??[]],result_discriminator:u.resultDiscriminator!==void 0})).sort((u,w)=>u.format.localeCompare(w.format)),_=i(o.assurance_providers??[],u=>u.definition.id);return{capabilities:Ca(e,t),commands:i(o.commands,u=>u.command),command_overrides:i(s.overrides,u=>u.command),command_handlers:i(s.handlers,u=>u.command),hooks:Ls.filter(([u])=>m[u].some(w=>a(w.name))).map(([,u])=>u),flag_commands:i(o.flags,u=>u.target_command),item_types:r(o.item_types,u=>u.types.map(w=>w.name)),item_fields:r(o.item_fields,u=>u.fields.map(w=>w.name)),...y.length>0?{relationship_kinds:y}:{},migrations:r(o.migrations,u=>typeof u.definition.id=="string"?[u.definition.id]:[]),profiles:i(o.profiles,u=>u.profile.name),importers:i(o.importers,u=>u.importer),exporters:i(o.exporters,u=>u.exporter),search_providers:i(o.search_providers,u=>u.definition.name),vector_store_adapters:i(o.vector_store_adapters,u=>u.definition.name),..._.length>0?{assurance_providers:_}:{},parser_overrides:i(d.overrides,u=>u.command),service_overrides:i(l.overrides,u=>u.service),renderer_overrides:i(p.overrides,u=>u.format),...g.length>0?{renderer_ownership:g}:{},preflight_overrides:c.overrides.filter(u=>a(u.name)).length,preflight_ownership:c.overrides.filter(u=>a(u.name)).map(u=>({commands:[...u.commands??[]]}))}}function mi(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="caa9f916-c7ce-5e74-a00b-dd0fc6a41b5d")}catch{}})();var nt={type:"string",minLength:1,maxLength:128,pattern:"\\S"},Ct={type:"array",minItems:1,maxItems:sn,items:nt},ui={...Ct,items:{...nt,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},Fs={type:"object",additionalProperties:!1,required:["id","rule"],properties:{id:{type:"string",minLength:1,maxLength:128,pattern:"^[a-zA-Z0-9][a-zA-Z0-9._-]*$"},description:{type:"string",minLength:1,maxLength:500,pattern:"\\S"},effect:{enum:["advise","warn","refuse"]},subject:{type:"object",additionalProperties:!1,properties:{...Object.fromEntries(["types","tags","statuses","operations","parents"].map(e=>[e,Ct])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:nt,id:nt}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:ui}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:Ct}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:ui,authors:Ct}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:sn,items:{type:"array",minItems:2,maxItems:2,items:nt}}}}]}}},Tu={$schema:"https://json-schema.org/draft/2020-12/schema",title:"pm workflow policy registry",type:"object",additionalProperties:!1,required:["version","policies"],properties:{version:{const:1},enforcement:{enum:["advise","refuse"],default:"advise"},policies:{type:"array",maxItems:ya,items:Fs}}};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="808f3bb5-cca5-5f9c-b557-7923c79ae6ce")}catch{}})();async function Ru(e,t,n,a){let i=await ke(e).catch(()=>null);return i===null?{check:{name:"completeness",status:"error",ok:!1,details:{policy_registry_readable:!1,policy_registry_path:"schema/policies.json",remediation_hint:"Repair schema/policies.json, then rerun pm validate."}},warnings:["validate_completeness_policy_registry_unreadable"]}:fi(i,t,n,a)}function Ms(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function fi(e,t,n=5,a=!1){let i=[],r=new Map,o=e.policies.filter(u=>u.rule.kind==="require_fields"),s=o.filter(u=>u.subject?.operations===void 0),d=new Set,c=0,l=0,p=0,m=0,y=0,g=va(e);for(let u of t){let w=g({operation:"",author:"",before:u,after:u,completeness_only:!0});c+=+(w.decisions.length>0),l+=w.decisions.length,w.decisions.forEach(x=>d.add(x.policy_id));let v=w.decisions.filter(x=>!x.satisfied);if(v.length===0)continue;m+=1;let S=r.get(u.type)??{items:0,violations:0,missing_fields:0};S.items+=1;for(let x of v)p+=1,S.violations+=1,S.missing_fields+=x.missing_fields.length,x.effect==="refuse"&&(y+=1),i.length<n&&i.push({id:u.id,type:u.type,status:u.status,decision:x});r.set(u.type,S)}let _=a||y>0?"error":p>0?"warn":"ok";return{check:{name:"completeness",status:_,ok:_==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:o.length,state_requirement_count:s.length,applicable_requirement_count:d.size,requirement_application_count:l,governed_items:c,ungoverned_items:t.length-c,contract_status:Ms(o.length,t.length,c),applied_policy_ids:[...d].sort().slice(0,Math.max(0,n)),applied_policy_ids_truncated:d.size>Math.max(0,n),checked_items:t.length,incomplete_items:m,violation_count:p,refused_violations:y,missing_by_type:Object.fromEntries(r),violations:i,violations_truncated:i.length<p,enforcement:e.enforcement}},warnings:[...p>0?[`validate_completeness_missing_fields:${p}`]:[],...a?["validate_completeness_source_incomplete"]:[]]}}import Us from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0c3bed4d-4a17-5004-a1c5-65f6acec2a9b")}catch{}})();function zs(){return{version:1,enforcement:"advise",policies:[...[["Epic",["goal","objective","body"]],["Story",["description","value","acceptance_criteria"]],["Decision",["body","resolution"]],["Feature",["acceptance_criteria","expected_result"]],["Task",["description"]],["Issue",["repro_steps","expected_result"]],["Chore",["description"]]].map(([e,t])=>({id:`completeness-${e.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${e} work reaches completion.`,subject:{types:[e],statuses:["closed"]},rule:{kind:"require_fields",fields:[...t]}})),{id:"completeness-resolution",effect:"advise",subject:{statuses:["closed"]},rule:{kind:"require_fields",fields:["resolution","expected_result","actual_result"]}}]}}function yi(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{throw new f("Policy definition must be valid JSON.",h.USAGE)}if(typeof t!="object"||t===null||Array.isArray(t))throw new f("Policy definition must be an object.",h.USAGE);return t}async function Gs(e,t){let n=F(process.cwd(),e.path);await Me(n);let a=await C(n);return{pmRoot:n,settings:a,author:K(t,a.author_default)}}function hi(e,t,n,a){if(e==="policy-mode")return dn({...n,enforcement:t});let i=n.policies.filter(s=>s.id!==t);if(e==="policy-remove")return{...n,policies:i};let r=cn(a.definition),o=dn({...n,policies:[...i,r].sort((s,d)=>s.id.localeCompare(d.id))});if(Buffer.byteLength(`${JSON.stringify(o,null,2)}
4
4
  `)>Fa)throw new f("Policy registry exceeds its byte ceiling.",h.USAGE);return o}async function gi(e,t,n,a){if(n.dryRun)return{policy_result:!0,action:e,changed:!1,result:hi(e,t,await ke(a.pmRoot),n)};let i=await La({pmRoot:a.pmRoot,filePath:Us.join(a.pmRoot,"schema","policies.json"),op:`schema:${e}`,author:a.author,message:n.message,lockTtlSeconds:a.settings.locks.ttl_seconds,lockWaitMs:a.settings.locks.wait_ms,mutate(r){let o=hi(e,t,Ma(r),n);return{raw:`${JSON.stringify(o,null,2)}
@@ -67,4 +67,4 @@ Agent guidance check
67
67
  `),X.write(`Telemetry helps improve reliability and can be disabled anytime via pm config.
68
68
  `);let d=t?"Y/n":"y/N",c=await n.question(`Enable telemetry for this project? [${d}] `),l=ns(c,t);return X.write(`
69
69
  `),{prefix:i,preset:s,telemetry_enabled:l}}finally{n.close()}}function Xm(e){return{presetFromOption:aa(e.preset),useDefaults:e.defaults===!0,authorFromOption:Zo(e.author),installBundledPackages:e.withPackages===!0,agentGuidanceMode:ts(e.agentGuidance),typePreset:Xo(e.typePreset)}}function Zm(e){let t=[];return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&t.push("id_prefix"),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&t.push("governance_preset"),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&t.push("author_default"),t}function Qm(e,t,n,a){if(t.length===0||n)return;let i=a.discovery==="ancestor";throw new f(`${i?`No tracker exists in ${a.requested_cwd}; pm init found an ancestor tracker at ${a.tracker_root}. `:""}Refusing to update existing tracker settings at ${e} without --force.`,h.USAGE,{code:"init_existing_settings_requires_force",type:"urn:pm-cli:error:init_existing_settings_requires_force",required:`--force for ${t.join(", ")}`,why:i?"Ancestor discovery is useful for normal commands, but init must make the selected existing workspace explicit before changing its identity or policy settings.":"pm init is safe to rerun, but changing id prefix, governance preset, or default author on an existing tracker can corrupt long-lived project context when an agent meant to initialize a sandbox path.",resolved_path:a.tracker_root,requested_path:a.requested_cwd,suggested_path:a.suggested_current_tracker_root,examples:["pm init --yes","pm init ./sandbox-pm --yes",...i?['pm init <name> --yes --pm-path "$PWD/.agents/pm"']:[],"pm init acme --yes --force"],nextSteps:[...i?['To create a new tracker in the current directory, rerun with --pm-path "$PWD/.agents/pm".']:[],"If you meant to initialize a sandbox tracker, pass a path-like positional such as ./sandbox-pm or /tmp/pm-test.","If you intentionally want to rewrite this existing tracker's init-managed settings, rerun with --force."]})}function eu(e){let t=!1;return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&(e.settings.id_prefix=e.normalizedPrefix,e.warnings.push(`updated:id_prefix:${e.normalizedPrefix}`),t=!0),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&(ia(e.settings,e.presetFromOption),e.warnings.push(`updated:governance_preset:${e.presetFromOption}`),t=!0),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&(e.settings.author_default=e.authorFromOption,e.warnings.push(`updated:author_default:${e.authorFromOption}`),t=!0),t}async function tu(e){let t=await C(e.pmRoot);e.warnings.push(`already_exists:${e.settingsPath}`);let n=Zm({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption});return Qm(e.settingsPath,n,e.options.force===!0,e.target),eu({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption,warnings:e.warnings})&&await ve(e.pmRoot,t),{settings:t,normalizedPrefix:e.normalizedPrefix,chosenPreset:e.normalizedOptions.presetFromOption,wizardUsed:!1}}async function nu(e){let t=e.normalizedPrefix,n=e.normalizedOptions.presetFromOption,a,i=!1;if(e.normalizedOptions.presetFromOption===void 0&&!e.normalizedOptions.useDefaults&&process.stdin.isTTY===!0&&process.stdout.isTTY===!0){let d=await cs(t,an.telemetry.enabled);t=d.prefix,n=d.preset,a=d.telemetry_enabled,i=!0}let r=n??"minimal",o=Km();o.id_prefix=t,ia(o,r);let s=ja()?.trim()||void 0;return o.author_default=e.normalizedOptions.authorFromOption??s??"",a!==void 0&&(o.telemetry.enabled=a,o.telemetry.first_run_prompt_completed=!0),await ve(e.pmRoot,o),{settings:o,normalizedPrefix:t,chosenPreset:n,wizardUsed:i}}async function Ho(e){return e.settingsExists?await tu(e):await nu({pmRoot:e.pmRoot,normalizedPrefix:e.normalizedPrefix,normalizedOptions:e.normalizedOptions})}async function au(e){let t=await Bo({pm_root:e.pmRoot,cwd:e.cwd,mode:e.agentGuidanceMode,interactive:process.stdin.isTTY===!0&&process.stdout.isTTY===!0,settings:e.settings});return e.warnings.push(...t.warnings),t.settings_changed&&await ve(e.pmRoot,e.settings),{...t.summary,next_steps:t.next_steps}}async function iu(e,t){let n=[],a=[],i=await Da(e,t.schema);for(let r of i.created_paths)n.push(r),a.push(...await W({path:r,scope:"project",op:"init:runtime_schema_file"}));return{createdDirs:n,warnings:a}}async function ru(e){if(e.typePreset===void 0)return;let t=await is(e.pmRoot,e.settings,e.typePreset);return e.warnings.push(`registered_type_preset:${e.typePreset}`),e.warnings.push(...await W({path:t.file,scope:"project",op:"init:type_preset"})),t}async function ou(e){let t=q(e.settings,J()).folders.filter(a=>!nn.includes(a)),n=await ss(e.pmRoot,t);e.createdDirs.push(...n.createdDirs),e.warnings.push(...n.warnings)}function su(e){let t=j.resolve(e.tracker_root),n=j.dirname(t);return j.basename(t)==="pm"&&j.basename(n)===".agents"?j.dirname(n):e.workspace_root}async function cu(e,t,n,a){if(!e)return;let i=await Kn("all",{install:!0,project:!0},{...t,path:n});a.push(...i.warnings);let r=as(i),o=r.packages.filter(s=>!s.ok).map(s=>s.alias);if(!r.installed_all||o.length>0)throw new f(`pm init --with-packages did not install all bundled packages successfully${o.length>0?`: ${o.join(", ")}`:"."}`,h.GENERIC_FAILURE);return r}function ds(e){let t=a=>Qe([...e.target.mode==="workspace-discovery"?[]:["--pm-path",e.target.tracker_root],...a]),n=[`Create your first item: ${t(["create","--type","Task","--title","<title>"])}`,`List active items: ${t(["list"])}`,`Get agent-friendly project context: ${t(["context"])}`];e.installBundledPackages?n.push(`Explore newly-available commands: ${t(["cal"])}, ${t(["templates"])}, ${t(["guide"])}`):(n.push(`Add optional packages for richer workflows: ${t(["install","calendar","--project"])}, ${t(["install","templates","--project"])}, ${t(["install","guide-shell","--project"])}`),n.push(`Or install everything bundled: ${t(["init","--with-packages"])} (idempotent on re-run)`)),e.registeredTypePreset&&n.push(`Inspect registered preset types: ${t(["schema","list"])}, ${t(["schema","show",e.registeredTypePreset.registered[0]??e.registeredTypePreset.updated[0]])}`),n.push("Supported agent harnesses are attributed automatically; use --author or PM_AUTHOR only when an explicit identity override is required.");for(let a of e.agentGuidanceNextSteps){let i=e.target.mode==="workspace-discovery"?a:a.replace(/\bpm (?=[a-z])/g,()=>`${t([])} `);n.includes(i)||n.push(i)}return n}async function ls(e,t,n,a=ei){if(t===null){n.push("merge_fence_skipped:not_git_repository:run pm merge install after moving the tracker into a Git repository");return}try{let i=await a({pmRoot:e,workspaceRoot:t});i.gitattributes.changed&&n.push(`updated:merge_fence:${i.gitattributes.path}`)}catch(i){if(!(i instanceof f))throw i;n.push(`merge_fence_skipped:install_failed:${i.context.code??"pm_error"}:${i.message}:run pm merge install after resolving the Git repository error`)}}async function du(e,t,n,a){if(e==null||n==="status")return;let i=await Xa(e,{pmRoot:t});i.changed&&a.push(`updated:gitignore:${i.path}`)}async function Ow(e,t,n={}){let a=t[Bm],i=typeof a=="string"?a:process.cwd(),r=Qo(i,t,e,n.workspace),o=r.pmRoot;e=es(r.prefixArg,n.idPrefix);let s=Xm(n);await os(o,r.target.mode==="tracker-path",n.force===!0);let d=[],c=[],l=j.join(o,"settings.json"),p=await k(l),m;p&&(m=await Ho({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:be(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target}));let y=await ss(o,nn);d.push(...y.createdDirs),c.push(...y.warnings),m??=await Ho({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:be(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target});let{settings:g}=m,_=su(r.target),u=await Za(_??j.dirname(o)),w=_??u,v=await au({pmRoot:o,cwd:w??i,agentGuidanceMode:s.agentGuidanceMode,settings:g,warnings:c}),S=await iu(o,g);d.push(...S.createdDirs),c.push(...S.warnings);let x=await ru({pmRoot:o,settings:g,typePreset:s.typePreset,warnings:c});x&&(g=await C(o)),await ou({pmRoot:o,settings:g,createdDirs:d,warnings:c}),await du(w,o,s.agentGuidanceMode,c),!p&&n.mergeFence!==!1&&s.agentGuidanceMode!=="status"&&await ls(o,u,c);let T=await cu(s.installBundledPackages,t,o,c),te=ds({installBundledPackages:s.installBundledPackages,registeredTypePreset:x,agentGuidanceNextSteps:v.next_steps,target:r.target});return{ok:!0,path:o,target:r.target,settings:g,created_dirs:d,warnings:c,governance_preset:g.governance.preset,wizard_used:m.wizardUsed,...x?{registered_type_preset:x}:{},...T?{installed_packages:T}:{},next_steps:te,agent_guidance:v}}export{un as a,ks as b,ci as c,yn as d,Ns as e,Ds as f,js as g,pi as h,Il as i,Ge as j,$i as k,We as l,Be as m,Ii as n,xi as o,Je as p,qe as q,Si as r,Fs as s,Tu as t,Ru as u,fi as v,zs as w,Yu as x,Ri as y,Li as z,$c as A,Ic as B,Qg as C,ny as D,ay as E,ht as F,iy as G,ry as H,oy as I,sy as J,cy as K,dy as L,ly as M,py as N,my as O,uy as P,fy as Q,hy as R,gy as S,yy as T,_y as U,wy as V,vy as W,by as X,ky as Y,xy as Z,Sy as _,Ey as $,$y as aa,Iy as ba,Ay as ca,Z as da,b as ea,Sn as fa,qc as ga,se as ha,Rt as ia,Ac as ja,at as ka,Nt as la,Zi as ma,sr as na,Ln as oa,vr as pa,Wh as qa,Vl as ra,eo as sa,to as ta,Jn as ua,Pr as va,kl as wa,lp as xa,Nr as ya,Kn as za,No as Aa,iw as Ba,Bo as Ca,Bm as Da,Aw as Ea,Tw as Fa,Ow as Ga};
70
- //# sourceMappingURL=chunk-H3XYP24A.js.map
70
+ //# sourceMappingURL=chunk-V3XONSVC.js.map