@unbrained/pm-cli 2026.10.19 → 2026.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +33 -0
  3. package/dist/cli/error-guidance.d.ts +7 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/register-structured-mutation.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-QBNEZII5.js → chunk-2GGGOD7P.js} +13 -13
  8. package/dist/cli-bundle/chunks/{chunk-4CXQSRSP.js → chunk-7NHA5K77.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-NX7Q4LGN.js → chunk-7ZOIZ2AZ.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-6DS5CAN2.js → chunk-GHJOMRSF.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-O2ZRRLAP.js → chunk-KU4Q3MSI.js} +3 -3
  12. package/dist/cli-bundle/chunks/{chunk-DMFM5R4G.js → chunk-LS55VKRK.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-QG4LMU7A.js → chunk-PNPE2OVJ.js} +43 -43
  14. package/dist/cli-bundle/chunks/chunk-PTL3TBT6.js +20 -0
  15. package/dist/cli-bundle/chunks/{chunk-LBEMB3BW.js → chunk-QETMESEB.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-4MJ6WBMA.js → chunk-QMZ73FCW.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-QQYCB2LO.js +2 -0
  18. package/dist/cli-bundle/chunks/chunk-TZU6U5ZE.js +3 -0
  19. package/dist/cli-bundle/chunks/{chunk-H3XYP24A.js → chunk-VLJLWZBO.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-XAWE4EAK.js +2 -0
  21. package/dist/cli-bundle/chunks/chunk-YECCKB4E.js +3 -0
  22. package/dist/cli-bundle/chunks/{chunk-5GZSX5HU.js → chunk-YT2Z3JPC.js} +3 -3
  23. package/dist/cli-bundle/chunks/{chunk-4XFVAXA4.js → chunk-YTHI5DTH.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-D3EDNAN7.js → chunk-YW6SIKYP.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-XH7C3A5N.js → chunk-ZA3XXHEE.js} +6 -6
  26. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +2 -0
  27. package/dist/cli-bundle/{focused-chunks/indexed-receipt-blobs-QW2VWWJE.js → chunks/indexed-receipt-blobs-U7VGKIYC.js} +2 -2
  28. package/dist/cli-bundle/chunks/{register-list-query-WQUVDJIH.js → register-list-query-NNDV6F6I.js} +3 -3
  29. package/dist/cli-bundle/chunks/{register-mutation-IWIBQIO3.js → register-mutation-3GCBSNQS.js} +4 -4
  30. package/dist/cli-bundle/chunks/register-operations-YKDGNKUL.js +2 -0
  31. package/dist/cli-bundle/chunks/register-setup-AOUZQQWB.js +2 -0
  32. package/dist/cli-bundle/chunks/{settlement-hook-UNFMCKKQ.js → settlement-hook-CLRGA6O7.js} +2 -2
  33. package/dist/cli-bundle/chunks/stage-6QXYRMSU.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-WZTEFFQI.js → chunk-37SU7BZI.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-5YTOYBTZ.js → chunk-6IU7BESB.js} +3 -3
  36. package/dist/cli-bundle/focused-chunks/chunk-AS3MOBO3.js +25 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-PXDR77TO.js → chunk-AW35RDKA.js} +22 -22
  38. package/dist/cli-bundle/focused-chunks/{chunk-RLRMNFLF.js → chunk-E4II2D2B.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-FEN7WOOP.js → chunk-F7FD25TG.js} +12 -12
  40. package/dist/cli-bundle/focused-chunks/{chunk-JDBO7SMR.js → chunk-GYHZ7W6O.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-EOQ6W25I.js → chunk-H5Q2HUU6.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-3TEIACFU.js → chunk-HUZAXSIJ.js} +3 -3
  43. package/dist/cli-bundle/focused-chunks/{chunk-JBJJW2WL.js → chunk-J6EYUGAR.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-JEXZEIAX.js +91 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-ENZMATOY.js → chunk-KDGUIIRU.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-H6BVQ63U.js → chunk-KKRFSI2N.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-GWTV45SB.js → chunk-LJPUJ2KK.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-MQ42BFGX.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/{chunk-HYMYAGSY.js → chunk-NI6NS44Q.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-L4PL3GZR.js → chunk-VAYS754X.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-SKYLOPU2.js → chunk-VLSER3XW.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-JCLC6HKT.js → chunk-VS6VTWTZ.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-OV2WVLUR.js → chunk-ZGEK57KD.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +2 -0
  55. package/dist/cli-bundle/{chunks/indexed-receipt-blobs-BVSHK4WQ.js → focused-chunks/indexed-receipt-blobs-H2G6CCGO.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{settlement-hook-X4FNHTOD.js → settlement-hook-5SNBBT7C.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{stage-MZSVQYO4.js → stage-EMTISXR7.js} +2 -2
  58. package/dist/cli-bundle/main.js +21 -21
  59. package/dist/cli-bundle/sdk-authoring.js +1 -1
  60. package/dist/cli-bundle/sdk-contracts.js +2 -2
  61. package/dist/cli-bundle/sdk-core.js +21 -21
  62. package/dist/cli-bundle/sdk-governance.js +1 -1
  63. package/dist/cli-bundle/sdk-graph.js +1 -1
  64. package/dist/cli-bundle/sdk-merge.js +55 -55
  65. package/dist/cli-bundle/sdk-query.js +1 -1
  66. package/dist/cli-bundle/sdk-runtime.js +1 -1
  67. package/dist/cli-bundle/sdk-testing.js +1 -1
  68. package/dist/cli-bundle/sdk.js +8 -8
  69. package/dist/core/fs/fs-utils.d.ts +2 -2
  70. package/dist/core/fs/fs-utils.js +1 -1
  71. package/dist/core/history/event-index.js +2 -2
  72. package/dist/core/output/output.d.ts +7 -2
  73. package/dist/core/output/output.js +5 -5
  74. package/dist/core/shared/errors.d.ts +48 -0
  75. package/dist/core/shared/errors.js +1 -1
  76. package/dist/core/store/settings.js +2 -2
  77. package/dist/mcp/server.js +1 -1
  78. package/dist/sdk/core.d.ts +1 -1
  79. package/dist/sdk/core.js +1 -1
  80. package/dist/sdk/dependencies/context-budget-recovery.d.ts +21 -0
  81. package/dist/sdk/dependencies/context-budget-recovery.js +2 -0
  82. package/dist/sdk/dependencies.js +1 -1
  83. package/dist/sdk/errors.d.ts +4 -1
  84. package/dist/sdk/errors.js +1 -1
  85. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  86. package/dist/sdk/index.d.ts +1 -1
  87. package/dist/sdk/index.js +1 -1
  88. package/dist/sdk/item-transaction.d.ts +13 -0
  89. package/dist/sdk/item-transaction.js +1 -1
  90. package/dist/sdk/lifecycle/structured-mutation-plan.d.ts +14 -1
  91. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  92. package/dist/sdk/output/list-envelope.d.ts +7 -0
  93. package/dist/sdk/output/list-envelope.js +2 -0
  94. package/dist/sdk/output.d.ts +1 -0
  95. package/dist/sdk/output.js +2 -2
  96. package/dist/sdk/public-surface.json +1 -1
  97. package/dist/sdk/relationship-context.d.ts +2 -0
  98. package/dist/sdk/relationship-context.js +1 -1
  99. package/dist/sdk/structured-mutations.d.ts +2 -0
  100. package/dist/sdk/structured-mutations.js +1 -1
  101. package/docs/COMMANDS.md +14 -0
  102. package/docs/PR_REVIEW_LOOP.md +32 -12
  103. package/docs/SCRIPTING.md +10 -0
  104. package/docs/SDK.md +77 -0
  105. package/docs/TESTING.md +25 -1
  106. package/marketplace.json +1 -1
  107. package/package.json +1 -1
  108. package/packages/pm-beads/package.json +1 -1
  109. package/packages/pm-calendar/package.json +1 -1
  110. package/packages/pm-command-kit/package.json +1 -1
  111. package/packages/pm-digital-twin/package.json +1 -1
  112. package/packages/pm-governance-audit/package.json +1 -1
  113. package/packages/pm-guide-shell/package.json +1 -1
  114. package/packages/pm-kanban/package.json +1 -1
  115. package/packages/pm-lifecycle-hooks/package.json +1 -1
  116. package/packages/pm-linked-test-adapters/package.json +1 -1
  117. package/packages/pm-search-advanced/package.json +1 -1
  118. package/packages/pm-templates/package.json +1 -1
  119. package/packages/pm-todos/package.json +1 -1
  120. package/packages/pm-vcs/package.json +1 -1
  121. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  122. package/plugins/pm-claude/package.json +1 -1
  123. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  124. package/plugins/pm-codex/package.json +1 -1
  125. package/plugins/pm-codex/plugin.json +1 -1
  126. package/runtime-dependencies.json +1 -1
  127. package/dist/cli-bundle/chunks/chunk-4ICKT4GH.js +0 -3
  128. package/dist/cli-bundle/chunks/chunk-OEJ3G7XT.js +0 -20
  129. package/dist/cli-bundle/chunks/chunk-QKAAZWGC.js +0 -3
  130. package/dist/cli-bundle/chunks/chunk-TK3G3GAP.js +0 -2
  131. package/dist/cli-bundle/chunks/register-operations-SUWOZNDU.js +0 -2
  132. package/dist/cli-bundle/chunks/register-setup-QGM5YJW7.js +0 -2
  133. package/dist/cli-bundle/chunks/stage-7DELI4Z5.js +0 -2
  134. package/dist/cli-bundle/focused-chunks/chunk-2IEWB6MB.js +0 -2
  135. package/dist/cli-bundle/focused-chunks/chunk-BJMPRB7A.js +0 -91
  136. package/dist/cli-bundle/focused-chunks/chunk-KLJN44VY.js +0 -2
  137. package/dist/cli-bundle/focused-chunks/chunk-Y54ONBEX.js +0 -25
@@ -1,3 +0,0 @@
1
- var g=Object.defineProperty;var M=(e,t)=>{for(var o in t)g(e,o,{get:t[o],enumerable:!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]="826dab45-600c-58df-a150-eacecfb6ef95")}catch{}})();var T=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],U=2,v=Object.freeze({migration:"schema",validation:"schema"}),Y=Object.freeze({version:2,capabilities:[...T],legacy_aliases:{...v}}),q=["off","warn","enforce"],W=["off","warn","enforce"],X=["none","restricted","strict"],K=["block","warn"],B=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],j=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function p(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}(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]="3d6df465-e82e-57d8-a687-6c2e720c99c1")}catch{}})();var m=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],k=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","design","external_ref","definition_of_ready","order",...m,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],I=k;(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]="9a92abe3-1900-5a69-a35d-6aa592c83da0")}catch{}})();var O=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),N=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),J=".agents/pm",Q="settings.json",H="Closed at creation via pm create",A=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],D=["decisions","events","reminders","milestones","meetings","plans"],Z=[...A,...D],ee={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},S={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},R=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],_={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function E(e){return e?[...e]:void 0}var te={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...R],lifecycle_closure_like_blocked_reason_patterns:[..._.blocked_reason],lifecycle_closure_like_resolution_patterns:[..._.resolution],lifecycle_closure_like_actual_result_patterns:[..._.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...S.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1,allow_untrusted_linked_tests:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:O.map(e=>({...e,aliases:E(e.aliases),roles:E(e.roles)})),fields:[],workflow:{...N},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:p()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",default_mode:"auto",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},re={metadata:{},body:""},h={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},C=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});function oe(e){let t=(e??"").trim().toLowerCase();if(t.length===0)return"unknown";let o=C[t];return typeof o=="string"?o:t.includes("conflict")||t.includes("locked")?"conflict":t.startsWith("unknown_")||t.startsWith("missing_required_")?"usage":t.startsWith("invalid_")||t.endsWith("_not_found")||t.includes("validation")?"validation":t.endsWith("_error")||t.endsWith("_failed")?"runtime":"unknown"}(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]="06acc04a-fd01-541b-bb84-720824d15b8b")}catch{}})();var c=class extends Error{exitCode;code;context;constructor(t,o,i={}){super(t),this.name="PmCliError",this.exitCode=o,this.context=i,this.code=i.code}};import*as r from"node:fs/promises";import{constants as u}from"node:fs";import d from"node:path";import L from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78969134-5a5b-50b5-9601-9b1b8dbcf8ac")}catch{}})();var x=[10,25,50,100];async function w(e){await r.mkdir(e,{recursive:!0})}async function _e(e){try{return await r.access(e),!0}catch{return!1}}function y(e){return F(e)||s(e,"ENOTDIR")}function F(e){return s(e,"ENOENT")}async function ue(e){try{return await r.readFile(e,"utf8")}catch(t){if(y(t))return null;throw t}}async function fe(e,t){let o=await r.open(e,u.O_RDONLY|u.O_NOFOLLOW|u.O_NONBLOCK);try{if(!(await o.stat()).isFile())throw t;return await o.readFile("utf8")}finally{await o.close()}}function pe(){return new c("Transaction preview requires regular files and directories.",h.USAGE,{code:"transaction_preview_non_regular_file",required:"regular files and directories within the configured tracker storage",why:"Preview does not follow linked entries or read special files.",nextSteps:["Inspect the configured tracker storage, settings, schema and session entries for links, directories used as files, or special files.","Restore the intended regular files and directories, then retry the original dry-run command."]})}async function me(e,t,o={}){let i=d.dirname(e);o.createParentDirectories!==!1&&await w(i);let n=d.join(i,`.${d.basename(e)}.${process.pid}.${Date.now()}.${L.randomBytes(4).toString("hex")}.tmp`);await r.writeFile(n,t,"utf8");try{await r.rename(n,e)}catch(a){if(process.platform==="win32"&&(s(a,"EPERM")||s(a,"EBUSY"))){let f=a;for(let b of x){await new Promise(l=>setTimeout(l,b));try{await r.rename(n,e);return}catch(l){if(f=l,!s(l,"EPERM")&&!s(l,"EBUSY"))break}}try{await r.unlink(n)}catch{}throw f}if(s(a,"EXDEV")){try{await r.copyFile(n,e)}finally{try{await r.unlink(n)}catch{}}return}try{await r.unlink(n)}catch{}throw a}}async function Ee(e,t){let o=d.dirname(e);await w(o);let i=await r.open(e,"a");try{await i.writeFile(`${t}
2
- `,"utf8")}finally{await i.close()}}async function he(e){try{await r.unlink(e)}catch(t){if(!y(t))throw t}}function s(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}export{M as a,T as b,U as c,v as d,Y as e,q as f,W as g,X as h,K as i,B as j,j as k,p as l,m,I as n,O as o,N as p,J as q,Q as r,H as s,A as t,Z as u,ee as v,S as w,R as x,_ as y,te as z,re as A,h as B,oe as C,c as D,w as E,_e as F,y as G,F as H,ue as I,fe as J,pe as K,me as L,Ee as M,he as N};
3
- //# sourceMappingURL=chunk-QKAAZWGC.js.map
@@ -1,2 +0,0 @@
1
- import{a as he}from"./chunk-4MJ6WBMA.js";import{Rb as je,Sb as Fe,Ub as V,Xb as Pe,Ya as z,Zb as Ge,_b as xe,a as ye,uc as qe}from"./chunk-5GZSX5HU.js";import{yc as De}from"./chunk-QBNEZII5.js";import{b as Oe,c as J}from"./chunk-H3XYP24A.js";import{L as Me,Ya as Re,cb as ke,g as Ae,i as O,r as Ie,rf as Ce,uf as Ne,wc as $e,yc as Ue}from"./chunk-4CXQSRSP.js";import{$g as L,Ag as Se,Db as me,Nc as fe,Oc as q,Pa as le,Qf as we,Sf as K,Tf as ge,Wf as ve,Zf as _e,_f as E,_h as be,ag as Ee,ci as Te,ii as M,pa as x,ya as pe}from"./chunk-QG4LMU7A.js";import{B as u,D as c,H as G,J as ue,K as I,m as se,r as A,u as ce,z as de}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]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}catch{}})();import Xe from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var S=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...se,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function R(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return S.has(t)?t:e}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function k(e,t,n){let i=e?.estimatedMinutes;if(!(i===void 0||typeof i=="string"))throw new c(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,u.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="78df5b0f-51cd-5c24-a1ee-a1d8433be5df")}catch{}})();var W=["op","id","reason","options","unique","match"],St=[...W,"ref"],Ke=[...St,"item"],bt="mutate-",Le="row-",Je=["schema_version","mutations"],Ze="[a-z][a-z0-9._-]{0,63}",ze=new RegExp(`^${Ze}$`,"u"),Qe=new RegExp(`(^|,)id=@(${Ze})(?=,|$)`,"gu"),Ve=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),$=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],et=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),Tt=new Set([...et,"completed_at","id"]),tt={create:Ce.map(e=>e.target),update:Ne.map(e=>e.target),close:Re.map(e=>Ve(e.flag)).filter(e=>e!=="reason"),release:ke.map(e=>Ve(e.flag))};function nt(e){let t=Xe.createHash("sha256").update(e).digest("hex");return`${bt}${t.slice(0,24)}`}function vi(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new c("createCompensation must be close or delete.",u.USAGE);t.createCompensation=n}for(let i of["lockTtlSeconds","lockWaitMs"]){let r=e[i];if(r===void 0)continue;let o=typeof r=="number"||typeof r=="string"&&r.trim().length>0?Number(r):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new c(`${i} must be a positive safe integer.`,u.USAGE);t[i]=o}return t}function f(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function U(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),i;for(let r of t){let o=me(e,r,n);o!==null&&(i===void 0||o<i.distance)&&(i={key:r,distance:o})}return i?.key}function b(e,t,n){let i=U(t,n);return new c(i===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${i}"?`,u.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[i===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${i}".`]})}function H(e,t){try{return JSON.parse(e)}catch(n){let i=n instanceof Error?n.message:String(n);throw new c(`${t} must be valid JSON: ${i}`,u.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function At(e,t){if(!f(e))throw new c(`Mutation ${t+1} must be an object.`,u.USAGE);for(let n of Object.keys(e))if(!W.includes(n))throw b(`mutation ${t+1}`,n,W);return e}function It(e,t,n,i){if(e===void 0)return;if(!f(e))throw new c(`Mutation ${n+1} options must be an object.`,u.USAGE);let r=[...tt[t],...ot(t,i)];for(let o of Object.keys(e))if(!r.includes(o))throw b(`mutation ${n+1} ${t} options`,o,r);return k(e,t,n),e}function We(e,t,n,i){if(e===void 0)return;let r=i==="unique"?"create":"update";if(t!==r)throw new c(`Mutation ${n+1} ${i} is only valid for ${r} operations.`,u.USAGE);let o=f(e)&&typeof e.key=="string"?e.key.trim():"";if(!f(e)||o.length===0||e.value===void 0||e.value===null)throw new c(`Mutation ${n+1} ${i} must be an object with a non-empty key and a value.`,u.USAGE);return{key:o,value:e.value}}function Mt(e,t,n){let i=At(e,t),{op:r,id:o,reason:a}=i;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new c(`Mutation ${t+1} op must be create, update, close, or release.`,u.USAGE);let s=It(i.options,r,t,n),d=We(i.unique,r,t,"unique"),p=We(i.match,r,t,"match");if(typeof o!="string"||o.trim().length===0)throw new c(`Mutation ${t+1} requires a non-empty id.`,u.USAGE);let l=o.trim();if(r==="close"){if(typeof a!="string"||a.trim().length===0)throw new c(`Mutation ${t+1} close requires a non-empty reason.`,u.USAGE);return{op:r,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:l,...s===void 0?{}:{options:s}};if(!f(s))throw new c(`Mutation ${t+1} ${r} requires an options object.`,u.USAGE);return{op:r,id:l,options:s,...d===void 0?{}:{unique:d},...p===void 0?{}:{match:p}}}function it(e,t={}){let n=H(e,"Mutation batch"),i=Array.isArray(n)?n:f(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(i===void 0||i.length===0)throw new c("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",u.USAGE);let r=t.runtimeFields??[];return i.map((o,a)=>{let s=Mt(o,a,r);return s.options!==void 0&&$e(s.options),s})}function Ot(e,t,n){let i=Xe.createHash("sha256").update(e).update("\0").update(t).digest("hex"),r=BigInt(`0x${i.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ae(n)}${r}`}function Be(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),i=t[n];if(i===void 0)throw new c(`Unknown mutation reference "${e}".`,u.USAGE);return i}function Ye(e,t){if(typeof e!="string")return e;let n=e.replace(Qe,(i,r,o)=>{let a=t[o];if(a===void 0)throw new c(`Unknown mutation reference "@${o}".`,u.USAGE);return`${r}id=${a}`});if(/(^|,)id=@/u.test(n))throw new c(`Malformed mutation reference in dependency "${e}".`,u.USAGE);return n}function Rt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(Qe)].map(t=>t[1]).filter(t=>t!==void 0)}function kt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let p=f(s.options)?s.options:{},l=Array.isArray(p.dep)?p.dep:p.dep===void 0?[]:[p.dep];n.set(d,[p.parent,p.blockedBy,...l].flatMap(Rt))}let i=new Set,r=new Set,o=a=>{if(i.has(a))throw new c(`Mutation reference cycle includes "@${a}".`,u.USAGE);if(!r.has(a)){i.add(a);for(let s of n.get(a))n.has(s)&&o(s);i.delete(a),r.add(a)}};for(let a of n.keys())o(a)}function $t(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),i=n[0];if(!i.ok&&(i.line.startsWith("[")||i.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&f(o.value)))return null;let r=[];for(let o of n){if(!o.ok)throw new c(`Mutation document line ${o.number} must be one valid JSON object: ${he(o.error)}`,u.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!f(o.value))throw new c(`Mutation document line ${o.number} must be a JSON object.`,u.USAGE);r.push(o.value)}return r}function Ut(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function Ct(e){let t;try{t=H(e,"Mutation document")}catch(n){let i=$t(e);if(i===null)throw n;return{schema_version:1,mutations:i}}return Array.isArray(t)?{schema_version:1,mutations:t}:f(t)&&!Ut(t)?{schema_version:1,mutations:[t]}:t}function Nt(e,t){let n=Object.hasOwn(e,"op")?Dt(e,t):jt(e,t);if(n.op==="create"&&n.id===void 0&&f(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new c(`Mutation ${t+1} item id must be a string.`,u.USAGE);n.id=n.item.id}return n}function Dt(e,t){for(let n of Object.keys(e))if(!Ke.includes(n))throw b(`mutation ${t+1}`,n,Ke);if(e.item!==void 0&&e.op!=="create")throw new c(`Mutation ${t+1} item documents are only valid for create operations.`,u.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new c(`Mutation ${t+1} must declare either item or options, not both.`,u.USAGE);return{...e}}function jt(e,t){let{ref:n,id:i,item:r,...o}=e,a=r!==void 0?r:o;if(r!==void 0&&Object.keys(o).length>0)throw new c(`Mutation ${t+1} must not mix item document keys with top-level fields.`,u.USAGE);if(!f(a))throw new c(`Mutation ${t+1} item document must be an object.`,u.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...i===void 0?{}:{id:i},item:a}}function Ft(e){let t=Ct(e);if(!f(t))throw new c("Mutation document must be a JSON array or object.",u.USAGE);for(let n of Object.keys(t))if(!Je.includes(n))throw b("mutation document",n,Je);if(t.schema_version!==void 0&&t.schema_version!==1)throw new c("Mutation document schema_version must be 1.",u.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new c("Mutation document requires a non-empty mutations array.",u.USAGE);return t.mutations.map((n,i)=>{if(!f(n))throw new c(`Mutation ${i+1} must be an object.`,u.USAGE);return Nt(n,i)})}function Pt(e,t,n){let i=new Set(Object.values(st(t,n,Object.create(null))));for(let r of t)r.op==="create"&&typeof r.id=="string"&&r.id.trim().length>0&&i.add(O(r.id,n.idPrefix));return{...e,existing:e.existing.filter(r=>!i.has(r.id))}}function Gt(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,i]of e.entries()){if(i.op!=="create"||i.ref!==void 0||typeof i.id=="string"&&i.id.trim().length>0)continue;let r=`${Le}${n+1}`;if(t.has(r))throw new c(`Mutation ${n+1} receives the synthesized ref "${r}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${Le}<n> aliases are reserved for rows without one.`,u.USAGE);i.ref=r}}function rt(e,t,n){let i=Qt(JSON.stringify(e),t,{},n);return delete i.stdinJson,delete i.documentAnnotationSnapshot,i}function ot(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function xt(e,t){for(let n of e)f(n.item)&&(n.options=rt(n.item,"create",t),delete n.item)}function at(e,t){return t.some(n=>n.metadata_key===e)?e:R(e)}function B(e,t,n){let i=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(f(e.item)){if(e.item[t]!==void 0)return e.item[t];if(at(i,n)===t&&e.item[i]!==void 0)return e.item[i]}let r=f(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&r[E(o)]!==void 0?r[E(o)]:r[t]!==void 0?r[t]:r[i]!==void 0?r[i]:(Array.isArray(r.field)?r.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function qt(e,t){return e<t?-1:+(e!==t)}function Y(e){return Array.isArray(e)?e.map(Y):f(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>qt(t,n)).map(([t,n])=>[t,Y(n)])):e}function g(e){return typeof e=="string"?e.trim():JSON.stringify(Y(e))}function Kt(e,t,n,i,r){let o=t.key.trim();if(o.length===0)throw new c("Upsert key must be a non-empty field name.",u.USAGE);let a=Lt(t.existing),s=new Map,d=new Set;for(let[p,l]of e.entries()){if(l.op!=="create")continue;let y=Jt(l,o,p,s,i),w=zt(a.get(y)??[],o,y);if(w===void 0){l.unique={key:o,value:B(l,o,i)};continue}let h=O(w,n);typeof l.ref=="string"&&(r[l.ref]=h),Vt(l,h,i,{key:o,value:B(l,o,i)}),d.add(p)}return d}function Lt(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let i=g(n.value);t.set(i,[...t.get(i)??[],n.id])}return t}function Jt(e,t,n,i,r){let o=B(e,t,r);if(o==null||o==="")throw new c(`Mutation ${n+1} is missing the upsert key "${t}".`,u.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=g(o),s=i.get(a);if(s!==void 0)throw new c(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,u.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return i.set(a,n),a}function zt(e,t,n){if(e.length>1)throw new c(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,u.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function Vt(e,t,n,i){let r=new Set([...tt.update,...ot("update",n)]),o=f(e.item)?rt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>r.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=i}function st(e,t,n){for(let[i,r]of e.entries())if(r.ref!==void 0){if(r.op!=="create")throw new c(`Mutation ${i+1} ref is only valid for create operations.`,u.USAGE);if(typeof r.ref!="string"||!ze.test(r.ref))throw new c(`Mutation ${i+1} ref must match ${ze.source}.`,u.USAGE);if(n[r.ref]!==void 0)throw new c(`Duplicate mutation ref "${r.ref}".`,u.USAGE);n[r.ref]=typeof r.id=="string"&&r.id.trim().length>0?O(r.id,t.idPrefix):Ot(t.transactionId,r.ref,t.idPrefix)}return n}function ct(e,t){let n=Ft(e);Gt(n);let i=n.map(l=>typeof l.ref=="string"?l.ref:void 0),r=Object.create(null),o=t.upsert===void 0?new Set:Kt(n,Pt(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],r);xt(n,t.runtimeFields??[]),st(n,t,r),kt(n,i);let a=n.map(l=>{let y={...l},w=typeof y.ref=="string"?y.ref:void 0;if(delete y.ref,w!==void 0?y.id=r[w]:y.id=Be(y.id,r),f(y.options)){let h={...y.options};for(let _ of["parent","blockedBy"])h[_]!==void 0&&(h[_]=Be(h[_],r));Array.isArray(h.dep)?h.dep=h.dep.map(_=>Ye(_,r)):h.dep!==void 0&&(h.dep=Ye(h.dep,r)),y.options=h}return y}),s=it(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new c("Duplicate resolved create id in mutation document.",u.USAGE);let p=s.map((l,y)=>{let w=i[y];return{index:y,...typeof w=="string"?{ref:w}:{},id:l.id,op:l.op,...o.has(y)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:r,rows:p}}function Wt(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let i=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(i)?JSON.stringify(i):i}`}).join(",")}function Bt(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(f))throw new c(`${n} must be an array of objects.`,u.USAGE);return e.map(i=>Wt(i,t))}}function Yt(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function He(e,t,n=!1){for(let[i,r,o]of De){let a=t[i],s=Bt(n&&["comments","notes","learnings"].includes(i)&&Array.isArray(a)?a.filter(d=>!f(d)||d.created_at===void 0):a,o,i);s!==void 0&&s.length>0&&(e[r]=s)}}function Ht(e,t){for(let n of Object.keys(e)){if(t){if(!$.includes(n))throw b("item envelope",n,$);continue}if(!S.has(n)&&U(n,[...S])===void 0&&U(n,$)==="item")throw b("item envelope",n,$)}}function Xt(e){let t=Object.hasOwn(e,"item");Ht(e,t);let n=t?e.item:e;if(!f(n))throw new c("Item document item must be an object.",u.USAGE);return{item:n,...t&&f(e.linked)?{linked:e.linked}:{}}}function Zt(e,t,n,i,r,o){if((i==="update"?Tt:et).has(t))return;let a=r.find(s=>s.metadata_key===t&&s.commands.includes(i));if(a!==void 0){let s=Ee(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!S.has(t)){if(U(t,[...S])!==void 0)throw b("item document",t,[...S]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=Yt(t,n))}function Qt(e,t,n={},i=[]){let r=H(e,"Item document");if(!f(r))throw new c("Item document must be a JSON object.",u.USAGE);let{item:o,linked:a}=Xt(r),s={};for(let[d,p]of Object.entries(o)){let l=at(d,i);l!==d&&Object.hasOwn(o,l)||Zt(s,l,p,t,i,n)}if(He(s,o,t==="update"),a!==void 0&&He(s,a),t==="update"){let d=Object.fromEntries(["comments","notes","learnings"].filter(p=>Object.hasOwn(o,p)).map(p=>[p,o[p].filter(l=>f(l)&&l.created_at!==void 0)]));Object.keys(d).length>0&&(s.documentAnnotationSnapshot=d)}return{...s,...Object.fromEntries(Object.entries(n).filter(([,d])=>d!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0}}function _i(e){return it(JSON.stringify(e))}import ee from"node:crypto";import{constants as X}from"node:fs";import{cp as en,lstat as ut,mkdir as tn,mkdtemp as pt,open as nn,readdir as rn,realpath as lt,rm as mt,stat as te,writeFile as ft}from"node:fs/promises";import{tmpdir as yt}from"node:os";import m 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]="03112259-10b6-53a9-8e6b-e541ac8c7d5d")}catch{}})();async function ne(e,t){if(!Te(e))return{schema:K(t.schema),typeDefinitionsFromFile:[]};let n=await mn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function ie(e,t,n,i){let r=x({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},q());return(await Me(e,t.item_format,r.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[i];return a==null?[]:[{id:o.id,value:a}]})}function ht(e){let t=new Map,n=async i=>{let r=await M(e),o=await ne(e,r),a=new Map;for(let s of await ie(e,r,o,i)){let d=g(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(i){let r=t.get(i)??n(i);return t.set(i,r),r},async recordCreate(i){for(let[r,o]of t){let a=i[r];if(a==null)continue;let s=await o,d=g(a);s.set(d,[...s.get(d)??[],String(i.id)])}},invalidate(){t.clear()}}}async function on(e,t){let n=g(t.value),i=(await e.lookup(t.key)).get(n)??[];if(i.length!==0)throw new c(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${i.join(", ")}; the plan was resolved before it existed.`,u.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function an(e,t,n){let i=e.metadata[n.key],r=g(n.value);if(g(i)!==r)throw new c(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(r)}; the plan selected it before the key changed.`,u.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function dt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function j(e,t){let n={...e,...t};return e===void 0?n:Ue(e,n)}async function v(e,t){try{let n=(await z(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof c&&n.exitCode===u.NOT_FOUND)return;throw n}}function re(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),i=ee.createHash("sha256").update(le(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${i}`}function sn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function T(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function F(e,t,n,i){let r=await L(m.join(e,"history",`${t}.jsonl`),t),o=T(n,i,"apply"),a=T(n,i,"compensate");for(let s=r.length-1;s>=0;s-=1){let d=r[s].message;if(d===o)return!0;if(d===a)return!1}return!1}async function oe(e,t){let n=await v(e,t.id);if(n?.updatedAt===void 0)throw new c(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,u.NOT_FOUND);return{target_updated_at:n.updatedAt}}async function P(e,t,n,i){let r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i.target_updated_at:void 0;typeof r=="string"&&await v(e.pmRoot,t)!==void 0&&await xe(t,r,{force:!0,author:e.author,message:T(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot})}function wt(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);if(i===void 0)return{state:"pending"};if(i.closedAt!==void 0){let r=await L(m.join(e.pmRoot,"history",`${i.id}.jsonl`),i.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(r.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new c(`Created item ${i.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,u.CONFLICT,{code:"transaction_create_compensated",item_id:i.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${i.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:i.id,op:"create"}}},async apply(){t.unique!==void 0&&await on(e.uniqueIndex,t.unique);let i=(await je(j(t.options,{author:e.author,id:t.id}),{pmRoot:e.pmRoot})).item;return await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){let i=await v(e.pmRoot,t.id);if(i!==void 0){if(e.createCompensation==="delete"){await Ge(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}i.closedAt===void 0&&await V(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function cn(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=()=>Fe(t.id,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),r=t.match,o=(r===void 0?await i():await Ie({pmRoot:e.pmRoot,id:String((await z(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:a=>an(a,t.id,r)},i)).item;return e.uniqueIndex.invalidate(),{id:String(o.id),op:"update"}},async compensate(i){await P(e,t.id,n,i)}}}function dn(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"close"}}:i.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:i.id,op:"close"}}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=(await V(t.id,t.reason,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"close"}},async compensate(i){await P(e,t.id,n,i)}}}function un(e,t,n){return{id:n,async inspect(){let i=await v(e.pmRoot,t.id);return i===void 0?{state:"pending"}:await F(e.pmRoot,i.id,e.transactionId,n)?{state:"applied",result:{id:i.id,op:"release"}}:i.assignee!==void 0||i.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:i.id,op:"release"}}},async prepareCompensation(){return oe(e.pmRoot,t)},async apply(){let i=(await Pe(t.id,j(t.options,{author:e.author,message:T(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(i.id),op:"release"}},async compensate(i){await P(e,t.id,n,i)}}}function gt(e,t,n){let i=re(t,n);switch(t.op){case"create":return wt(e,t,i);case"update":return cn(e,t,i);case"close":return dn(e,t,i);case"release":return un(e,t,i)}}function pn(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`);if(e.op==="create"&&e.unique!==void 0&&!dt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!dt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);k(e.options,e.op,t)}function vt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,i]of e.entries()){if(pn(i,n),i.op!=="create"||i.unique===void 0)continue;let{key:r,value:o}=i.unique,a=t.get(r)??new Map,s=g(o),d=a.get(s);if(d!==void 0)throw new c(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${r}".`,u.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(r,a)}}async function Z(e,t,n){try{return await n()}catch(i){throw i instanceof c?new c(i.message,i.exitCode,{...i.context,transaction_operation:{index:t,op:e.op,id:e.id}}):i}}function _t(e,t,n,i){let r=m.relative(e,t);return["locks","runtime","search"].includes(r.split(m.sep)[0])?i.some(o=>r===o||r.startsWith(`${o}${m.sep}`)||o.startsWith(`${r}${m.sep}`)):r===""||n===void 0||n.some(o=>r===o||r.startsWith(`${o}${m.sep}`)||o.startsWith(`${r}${m.sep}`))}async function N(e){let t=await ut(e);if(t.isSymbolicLink())await te(e);else if(t.isDirectory()||t.isFile())return t;throw I()}async function ln(e){let t=await nn(e,X.O_RDONLY|X.O_NOFOLLOW|X.O_NONBLOCK);try{let n=await t.stat();if(!n.isFile())throw I();let i=ee.createHash("sha256");if(n.size>0)for await(let r of t.createReadStream({highWaterMark:64*1024,end:n.size-1,autoClose:!1}))i.update(r);return i.digest()}finally{await t.close()}}async function Q(e,t,n){let i=ee.createHash("sha256");async function r(o){for(let a of(await rn(o)).sort()){let s=m.join(o,a);_t(e,s,t,n)&&((await N(s)).isDirectory()?await r(s):(i.update(JSON.stringify(m.relative(e,s))),i.update(await ln(s))))}}return await r(e),i.digest("hex")}function C(){return new c("Tracker changed while preparing the transaction preview; retry against stable state.",u.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function ae(e){if(!G(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),i=n;for(;;)try{let r=await ut(i);return i!==n&&r.isDirectory()}catch(r){if(!G(r))return!1;let o=m.dirname(i);if(o===i)return!1;i=o}}async function D(e,t){let n=m.join(e,t);try{let i=e;for(let r of t.split(m.sep).slice(0,-1))i=m.join(i,r),await N(i);if(!(await N(n)).isFile())throw I();return await ue(n,I())}catch(i){if(await ae(i))return;throw i}}async function Et(e,t,n,i){let r=K(n);for(let[o,a]of Object.entries(r.files)){let s=m.relative(e,ge(e,a,we[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new c("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",u.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});r.files[o]=s;let d=await D(e,s);if(i?.set(s,d),d!==void 0){let p=m.join(t,s);await tn(m.dirname(p),{recursive:!0}),await ft(p,d)}}return ve(t,r)}async function mn(e,t){await te(e);let n=await pt(m.join(yt(),"pm-schema-plan-"));try{let i=await lt(e);return await Et(i,m.join(n,"configuration"),t)}catch(i){throw await ae(i)?C():i}finally{await mt(n,{recursive:!0,force:!0})}}async function fn(e,t,n){let i=new Map,r=await D(e,A);i.set(A,r);let o;try{o=JSON.parse(r??"null")}catch{o=null}let a=be(o),s=a.success?a.data:void 0,d=await Et(e,t,s?.schema,i),p=d.schema,l=m.relative(e,Se(e));i.set(l,await D(e,l));let y=x({...de,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),w=pe(e)===e?[...ce.filter(Boolean),A,ye,"transactions",...y.folders,...i.keys()].map(_=>m.normalize(_)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:p.files}});return{configuration:i,ownedPaths:w,stagedSettings:h,registryFolders:y.folders}}async function yn(e,t,n){await te(e);try{let i=await lt(e),r=await fn(i,m.join(m.dirname(t),"configuration"),n),o=[...r.configuration.keys(),...r.registryFolders].map(p=>m.normalize(p)),a=await Q(i,r.ownedPaths,o);await en(i,t,{recursive:!0,dereference:!1,filter:async p=>_t(i,p,r.ownedPaths,o)?(await N(p),!0):!1});let[s,d]=await Promise.all([Q(i,r.ownedPaths,o),Q(t,r.ownedPaths,o)]);if(a!==s||a!==d)throw C();for(let[p,l]of r.configuration)if(await D(t,p)!==l)throw C();r.stagedSettings!==void 0&&await ft(m.join(t,A),r.stagedSettings)}catch(i){throw await ae(i)?C():i}}async function Wi(e){let t=Oe(e),n=[...e.mutations];vt(n);let i=q(),r=await pt(m.join(yt(),"pm-transaction-preview-")),o=m.join(r,"tracker");try{await yn(t.pmRoot,o,i);let a=!1;return await qe({path:o,noExtensions:!0},async()=>{fe(i);let s={...t,pmRoot:o,createCompensation:"close",uniqueIndex:ht(o)},d=n.map((p,l)=>{let y=gt(s,p,l);return{...y,inspect:()=>Z(p,l,()=>y.inspect()),prepareCompensation:()=>Z(p,l,async()=>y.prepareCompensation?.()),apply:()=>Z(p,l,()=>y.apply())}});await J({...t,pmRoot:o,steps:d,onTransition:({transition:p})=>{p==="committed"&&(a=!0)}})}),{validated:a,state:a?"staged_snapshot":"replayed_committed_plan",unresolved_commit_constraints:["concurrent_tracker_changes","extension_mutation_guards_and_hooks"]}}finally{await mt(r,{recursive:!0,force:!0})}}async function hn(e){let t=[...e.mutations];vt(t);let n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:n,uniqueIndex:ht(e.pmRoot)},r=await J({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((a,s)=>gt(i,a,s)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),o={};for(let[a,s]of t.entries()){let d=re(s,a),p=r.results[d];o[sn(s,a)]=p}return{transactionId:r.transactionId,status:"committed",recovered:r.recovered,results:o}}function wn(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function Bi(e){return hn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:wn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Yi={buildCreateStep:wt,bulkHistoryMarker:T,compensateByRestore:P,deriveStepId:re,isUpdateMarkerApplied:F,readItemSnapshot:v};(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]="3c45eeb2-58f2-58f9-ad24-e439967b99ef")}catch{}})();async function rr(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new c("Upsert key must be a non-empty field name.",u.USAGE);let n=e.settings??await M(e.pmRoot),i=e.transactionId?.trim()??"",r=i.length>0?i:nt(e.input),o=await ne(e.pmRoot,n),a=_e(o.schema).definitions,s=(a.find(p=>p.metadata_key===t)??a.find(p=>p.key===t||E(p)===t))?.metadata_key??R(t),d=s===void 0?void 0:{key:s,existing:await ie(e.pmRoot,n,o,s)};return{...ct(e.input,{transactionId:r,idPrefix:n.id_prefix,runtimeFields:a,...d===void 0?{}:{upsert:d}}),transaction_id:r,transaction_id_source:i.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{nt as a,vi as b,it as c,g as d,ct as e,Qt as f,_i as g,ne as h,ie as i,mn as j,Wi as k,hn as l,wn as m,Bi as n,Yi as o,rr as p};
2
- //# sourceMappingURL=chunk-TK3G3GAP.js.map
@@ -1,2 +0,0 @@
1
- import"./chunk-SGFQQXFD.js";import{$c as G,Id as te,Ld as ae,Nd as ne,Pb as V,Ud as oe,Vd as re,Wc as q,Wd as C,_c as $,ad as H,ae as ie,bd as W,cd as j,dd as B,fc as N,fd as I,ga as O,gd as z,hd as Y,id as K,jd as X,kd as Q,lc as U,md as Z,nd as ee,oc as J,tb as F}from"./chunk-QBNEZII5.js";import"./chunk-OEJ3G7XT.js";import"./chunk-RUKSEZE7.js";import"./chunk-DEZPZOQ7.js";import"./chunk-H3XYP24A.js";import{Af as M,Ef as c,Hf as f,If as i,Jf as g,Zf as y,hc as _,yf as P,zf as L}from"./chunk-4CXQSRSP.js";import"./chunk-O2ZRRLAP.js";import{Sc as x,Zg as R,ii as A,k as T,l as E,wf as l,xa as v,xf as u}from"./chunk-QG4LMU7A.js";import"./chunk-LBEMB3BW.js";import"./chunk-VS565KBX.js";import{B as d,D as m}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]="c3d9f24a-7089-5d60-ab12-93d03b86da80")}catch{}})();var se=new Map([["measurements","boolean"],["metric","string"],["measurementLimit","number"],["observe","string_array"],["direction","direction"],["measurementSource","string"],["measurementItem","string"],["measurementRevision","string"],["author","string"],["message","string"],["provenanceCoverage","boolean"],["fleetAttribution","boolean"],["since","string"],["eventLimit","number"],["minimumSample","number"]]),ke=new Set(["higher","lower","target"]),ve=[...se.keys()].sort((e,t)=>e.localeCompare(t)).join(", ");function xe(e,t){return e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="number"?typeof t=="number":e==="string_array"?Array.isArray(t)&&t.every(a=>typeof a=="string"):e==="direction"&&ke.has(t)}function le(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch(a){throw new m(`--analytics must be valid JSON: ${String(a)}`,d.USAGE)}if(t===null||typeof t!="object"||Array.isArray(t))throw new m("--analytics must be a JSON object.",d.USAGE);for(let[a,n]of Object.entries(t)){let o=se.get(a);if(!xe(o,n))throw new m(o===void 0?`Unknown --analytics field "${a}". Accepted fields: ${ve}.`:`--analytics field "${a}" must be ${o.replace("_"," ")}.`,d.USAGE)}return 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]="dcd8c925-34ee-5faa-9132-1be43961c749")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="29db968f-30ad-5f3c-bf95-e33be18614c6")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="524ade8e-33d6-5353-b01d-c7baddc956e8")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="02e10fe1-c111-5c09-8dbe-a67f2b97f0d0")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3d4a8db3-8a53-50b4-a96c-1affff2207a3")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d008ca8f-41bf-54fb-9b56-bc1d4af9f226")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="de197522-9007-5e21-8f9c-06cbf63707d1")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a5e0162a-bbf1-50fe-8912-a820de155e90")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9ee008b9-3751-5794-8d01-1f6d3123d6cd")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b6fa277d-ccf2-5413-95d5-0790283203d5")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2d59e10e-c85b-542a-8859-b20a08e809fa")}catch{}})();var ce=(e,t)=>N(e,t,{runUpdate:(a,n,o)=>q(a,n,o)});(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]="3952425a-adce-59dd-84b6-97ac571eaa73")}catch{}})();async function Ae(e,t,a,n,o){let r=c(o),s=e==="run",p=e==="verdicts",w=e==="presets"||e==="apply",k=e==="promote",h=await U({action:e,...s||p||w||k?{}:{kind:t},id:s||p||k?a??t:a,preset:w?a??t:void 0,definition:i(n,"definition"),trigger:i(n,"trigger"),tree:i(n,"tree"),gate:i(n,"gate"),limit:i(n,"limit"),dry_run:n.dryRun===!0,fullChangedFields:r.fullChangedFields,idOnly:r.idOnly,author:i(n,"author"),message:i(n,"message"),owner:i(n,"owner"),apply:n.apply===!0,enforcement:i(n,"enforcement")},r);l(h,r),typeof h=="object"&&h!==null&&"exit_code"in h&&h.exit_code===1&&(process.exitCode=1)}function de(e){e.command("assurance").argument("<action>","Action; inspect `pm contracts --command assurance`").argument("[kind]","Declaration kind or run gate id").argument("[id]","Declaration/gate id").description("Manage SDK-owned assurance contracts.").option("--definition <json>","Put declaration JSON").option("--trigger <value>","Gate trigger").option("--tree <value>","Revision identity").option("--gate <id>","Verdict gate filter").option("--limit <number>","Verdict limit").option("--dry-run","Evaluate without recording").option("--author <value>","Mutation author").option("--message <value>","Mutation rationale").option("--owner <item-id>","Preset/derivation owner").option("--apply","Persist derived proposals").option("--enforcement <level>","Promote to warn or block").action(Ae)}(function(){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]="8d5029c0-2d6e-5d39-8239-545a5841694e")}catch{}})();function _e(e,t){let a=e?.trim().toLowerCase(),n=t?.trim().toLowerCase();if(a===void 0||a.length===0)return n;if(a==="local-analytics")return n&&n.length>0?n:"status";if(n!==void 0&&n.length>0)throw _({command_path:"telemetry",token:`${e} ${t}`,allowed:["status","flush","stats","clear","local-analytics"],token_kind:"path",examples:["pm telemetry stats --limit 10","pm telemetry local-analytics status --json"]});return a}function Ie(e){return{addValues:Array.isArray(e.add)?e.add:[],addJsonValues:Array.isArray(e.addJson)?e.addJson:[],removeValues:Array.isArray(e.remove)?e.remove:[],removeIndexValues:Array.isArray(e.removeIndex)?e.removeIndex:[]}}function fe(e,t){if(e.background===!0){if(e.run!==!0)throw new m("--background requires --run",d.USAGE);if(e.acknowledgeLinkedTests===!0)throw new m("--background cannot be combined with --acknowledge-linked-tests; acknowledgement is a non-executing foreground operation",d.USAGE);if(e.update!==void 0||e.updateIndex!==void 0||e.setJson!==void 0||t.addValues.length>0||t.addJsonValues.length>0||t.removeValues.length>0||t.removeIndexValues.length>0)throw new m("--background does not support --add/--add-json/--remove/--remove-index or metadata edits; update linked tests first, then run in background",d.USAGE)}}async function Ce(e,t,a,n){let o=await C({kind:"test",commandArgs:P(e,{...t,add:n.addValues,addJson:n.addJsonValues,remove:n.removeValues,removeIndex:n.removeIndexValues}),targetId:e,author:typeof t.author=="string"?t.author:void 0,noExtensions:a.noExtensions===!0},a);l(o,a)}function De(e){return{update:typeof e.update=="string"?e.update:void 0,updateIndex:typeof e.updateIndex=="string"||typeof e.updateIndex=="number"?e.updateIndex:void 0,setJson:typeof e.setJson=="string"?e.setJson:void 0}}function D(e,t){return{add:t.addValues,addJson:t.addJsonValues,remove:t.removeValues,removeIndex:t.removeIndexValues,...De(e),list:!!e.list,run:!!e.run,match:typeof e.match=="string"?e.match:void 0,onlyIndex:typeof e.onlyIndex=="string"||typeof e.onlyIndex=="number"?e.onlyIndex:void 0,onlyLast:!!e.onlyLast,timeout:typeof e.timeout=="string"?e.timeout:void 0,progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:typeof e.pmContext=="string"?e.pmContext:void 0,overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:typeof e.workspaceContext=="string"?e.workspaceContext:void 0,overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,acknowledgeLinkedTests:!!e.acknowledgeLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,autoPmContext:!!e.autoPmContext,author:typeof e.author=="string"?e.author:void 0,message:typeof e.message=="string"?e.message:void 0,force:!!e.force,measure:Array.isArray(e.measure)?e.measure:[],metricBelow:typeof e.metricBelow=="string"?e.metricBelow:void 0,metricDiff:typeof e.metricDiff=="string"?e.metricDiff:void 0}}var Nt={buildRunTestOptions:D,buildRunTestAllOptions:pe,runWorkspacePositionAction:ye,validateBackgroundTestOptions:fe};async function Se(e,t,a,n){let o=await oe(e,D(t,n),a);(t.update!==void 0||t.updateIndex!==void 0||t.setJson!==void 0||n.addValues.length>0||n.addJsonValues.length>0||n.removeValues.length>0||t.run===!0||n.removeIndexValues.length>0)&&await y(a,o),l(o,a),(o.run_results.some(r=>r.status==="failed"||r.status==="refused")||o.fail_on_skipped_triggered===!0)&&(process.exitCode=d.DEPENDENCY_FAILED)}async function Te(e,t,a){let n=c(a),o=Date.now(),r=Ie(t);t.background===!0&&ne(e,D(t,r),n,v(process.cwd(),n.path),!0),fe(t,r),t.background===!0?await Ce(e,t,n,r):await Se(e,t,n,r),n.profile&&u(`profile:command=test took_ms=${Date.now()-o}`)}function b(e){let t=i(e,"author"),a=i(e,"assignee");if(t!==void 0&&a!==void 0&&t!==a)throw new m("Lifecycle ownership received conflicting --author and --assignee values; use one actor value for both aliases.",d.USAGE,{code:"conflicting_lifecycle_owner",examples:["pm claim pm-123","pm claim pm-123 --start","pm release pm-123"]});return{author:t??a,message:i(e,"message")}}async function Ee(e,t){let a=c(t),n=Date.now();if(e.background===!0){let r=await C({kind:"test-all",commandArgs:L(e),statusFilter:i(e,"status"),noExtensions:a.noExtensions===!0},a);l(r,a),a.profile&&u(`profile:command=test-all took_ms=${Date.now()-n}`);return}let o=await re(pe(e),a);await y(a,{ids:o.results.map(r=>r.id)}),l(o,a),(o.failed>0||o.fail_on_skipped_triggered===!0)&&(process.exitCode=d.DEPENDENCY_FAILED),a.profile&&u(`profile:command=test-all took_ms=${Date.now()-n}`)}function pe(e){return{status:i(e,"status"),limit:i(e,"limit"),offset:i(e,"offset"),timeout:i(e,"timeout"),progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:i(e,"pmContext"),overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:i(e,"workspaceContext"),overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,autoPmContext:!!e.autoPmContext}}async function Re(e,t,a,n){let o=c(n),r=Date.now(),s=await ae({subcommand:_e(e,t),limit:i(a,"limit")},o);l(s,o),o.profile&&u(`profile:command=telemetry took_ms=${Date.now()-r}`)}async function Oe(e,t){let a=c(t),n=Date.now(),o=le(i(e,"analytics")),r=await te(a,{includeEmpty:e.includeEmpty===!0,storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:i(e,"tagPrefix"),fieldUtilization:e.fieldUtilization===!0,...o});r.recorded_observations?.some(s=>s.changed)===!0&&await y(a,{ids:r.recorded_observations?.flatMap(s=>s.observation.item_id?[s.observation.item_id]:[])}),l(r,a),a.profile&&u(`profile:command=stats took_ms=${Date.now()-n}`)}async function Pe(e,t){let a=c(t),n=Date.now(),o=i(e,"threshold"),r=i(e,"limit"),s=await F(a,{...e.exhaustive===!0?{exhaustive:!0}:{},status:Array.isArray(e.status)&&e.status.length>0?e.status:void 0,since:i(e,"since"),...o===void 0?{}:{threshold:Number(o)},...r===void 0?{}:{limit:Number(r)}});l(s,a),a.profile&&u(`profile:command=duplicates took_ms=${Date.now()-n}`)}async function Le(e,t){let a=c(t),n=Date.now(),o=!!e.strictExit||!!e.failOnWarn,r=await V(a,{strictExit:o,strictDirectories:!!e.strictDirectories,requireMergeDrivers:!!e.requireMergeDrivers,checkOnly:!!e.checkOnly,checkTelemetry:!!e.checkTelemetry,noRefresh:!!e.noRefresh,refreshVectors:!!e.refreshVectors,verboseStaleItems:!!e.verboseStaleItems,verboseAuthorEvents:!!e.verboseAuthorEvents,brief:!!e.brief,summary:!!e.summary||o,skipVectors:!!e.skipVectors,skipIntegrity:!!e.skipIntegrity,skipDrift:!!e.skipDrift,full:!!e.full});l(r,a),o&&!r.ok&&(x({...r,exit_code:d.GENERIC_FAILURE,error_code:"health_findings",error_category:"validation",command_resolution:"health_findings",resolution_stage:"execute"}),process.exitCode=d.GENERIC_FAILURE),a.profile&&u(`profile:command=health took_ms=${Date.now()-n}`)}async function Me(e,t){let a=c(t),n=Date.now(),o=await ce({checkMetadata:!!e.checkMetadata,metadataProfile:i(e,"metadataProfile"),checkResolution:!!e.checkResolution,checkCompleteness:!!e.checkCompleteness,checkLifecycle:!!e.checkLifecycle,checkStaleBlockers:!!e.checkStaleBlockers,dependencyCycleSeverity:i(e,"dependencyCycleSeverity"),parentCycleSeverity:i(e,"parentCycleSeverity"),checkFiles:!!e.checkFiles,checkCommandReferences:!!e.checkCommandReferences,scanMode:i(e,"scanMode"),includePmInternals:!!e.includePmInternals,verboseFileLists:!!e.verboseFileLists,verboseDiagnostics:!!e.verboseDiagnostics,allAffectedIds:!!e.allAffectedIds,checkHistoryDrift:!!e.checkHistoryDrift,checkStorageIntegrity:!!e.checkStorageIntegrity,fixHints:!!e.fixHints,autoFix:!!e.autoFix,dryRun:!!e.dryRun,fixScope:Array.isArray(e.fixScope)?e.fixScope:void 0,pruneMissing:!!e.pruneMissing,counts:!!e.counts,full:!!e.full},a);l(o,a),(e.strictExit||e.failOnWarn)&&(o.has_warnings||!o.ok)&&(x({...o,exit_code:d.GENERIC_FAILURE,error_code:"validation_findings",error_category:"validation",command_resolution:"validation_findings",resolution_stage:"execute"}),process.exitCode=d.GENERIC_FAILURE),a.profile&&u(`profile:command=validate took_ms=${Date.now()-n}`)}async function Fe(e,t){let a=c(t),n=Date.now(),o=await J(a,{dryRun:e.dryRun===!0,scope:Array.isArray(e.scope)?e.scope:[]});l(o,a),a.profile&&u(`profile:command=gc took_ms=${Date.now()-n}`)}async function Ve(e,t,a,n){let o=c(n),r=v(process.cwd(),o.path),s=e.trim().toLowerCase();if(!I.some(p=>p===s))throw _({command_path:"workspace snapshot",token:e,allowed:I,display_name:"workspace snapshot",token_kind:"action",examples:["pm workspace snapshot create before-migration","pm workspace snapshot restore before-migration"]});if(s==="list"){l(await K(r),o);return}if(s==="create"){l(await z(r,t===void 0?{}:{name:t}),o);return}if(t===void 0)throw new m(`pm workspace snapshot ${s} requires a snapshot name or fingerprint`,d.USAGE);if(s==="inspect"){l(await Y(r,t),o);return}if(s==="restore"){if(a.dryRun===!0){l(await X(r,t),o);return}let p=await A(r);l(await Q(r,t,{force:a.force===!0,author:R(i(a,"author"),p.author_default),message:i(a,"message"),lockTtlSeconds:p.locks.ttl_seconds,lockWaitMs:p.locks.wait_ms}),o);return}l(await Z(r,t),o)}async function ye(e,t){let a=c(t);l(await ee(a),a)}async function Ne(e,t){let a=c(t),n=Date.now(),o=await O({action:i(e,"action"),command:i(e,"command"),summary:!!e.summary,schemaOnly:!!e.schemaOnly,flagsOnly:!!e.flagsOnly,availabilityOnly:!!e.availabilityOnly,runtimeOnly:!!e.runtimeOnly||!!e.activeOnly,full:!!e.full},a);l(o,a),a.profile&&u(`profile:command=contracts took_ms=${Date.now()-n}`)}async function Ue(e,t,a){if(t.start===!0){ue(e,!1),await ge(e,t,a);return}let n=c(a),o=Date.now(),r={...b(t),ifAvailable:t.ifAvailable===!0,maxAttempts:t.maxAttempts};ue(e,t.next===!0);let s=t.next===!0?await G(!!t.force,n,r,{type:typeof t.type=="string"?t.type:void 0,tag:typeof t.tag=="string"?t.tag:void 0,priority:t.priority,assigneeFilter:typeof t.assigneeFilter=="string"?t.assigneeFilter:void 0,parent:typeof t.parent=="string"?t.parent:void 0,sprint:typeof t.sprint=="string"?t.sprint:void 0,release:typeof t.release=="string"?t.release:void 0,includeDecisions:t.includeDecisions===!0,includeGates:t.includeGates===!0,includeContainers:t.includeContainers===!0,tokenBudget:t.tokenBudget??t.token_budget,explainRanking:t.explainRanking===!0||t.explain_ranking===!0}):await $(e,!!t.force,n,r);await y(n,s),l(s,n),n.profile&&u(`profile:command=claim took_ms=${Date.now()-o}`)}function ue(e,t){if(!t&&!e)throw new m("Specify an item id or pass --next",d.USAGE);if(t&&e)throw new m("Specify either an item id or --next, not both",d.USAGE)}async function Je(e,t,a){if(t.pause===!0){await he(e,t,a);return}let n=c(a),o=Date.now(),r=await H(e,!!t.force,n,{...b(t),ownershipReleaseBypass:t.ownershipReleaseBypass===!0,handoff:t.handoff});await y(n,r),l(await M("release",[e],t,n,r),n),n.profile&&u(`profile:command=release took_ms=${Date.now()-o}`)}async function S(e){let t=c(e),a=T(e.name());!a||t.json||t.quiet||(await A(v(process.cwd(),t.path))).ux?.deprecation_hints&&u(E(a))}async function ge(e,t,a){await S(a);let n=c(a),o=Date.now(),r=await W(e,{...b(t),force:!!t.force,next:t.next===!0,ifAvailable:t.ifAvailable===!0},n);await y(n,r.update),l(r,n),n.profile&&u(`profile:command=start-task took_ms=${Date.now()-o}`)}async function he(e,t,a){await S(a);let n=c(a),o=Date.now(),r=await j(e,{...b(t),handoff:i(t,"handoff"),force:!!t.force},n);await y(n,r.release),l(r,n),n.profile&&u(`profile:command=pause-task took_ms=${Date.now()-o}`)}async function qe(e,t,a,n){await S(n);let o=c(n),r=Date.now(),s=await B(e,t,{...b(a),validateClose:i(a,"validateClose"),force:!!a.force},o);await y(o,s.release),l(s,o),o.profile&&u(`profile:command=close-task took_ms=${Date.now()-r}`)}function me(e){return e.option("--background","Run linked tests in managed background mode").option("--timeout <seconds>","Default run timeout in seconds").option("--progress","Emit stderr progress (automatic in TTY)").option("--env-set <value>","Set run environment (KEY=VALUE, repeatable)",f).option("--env-clear <value>","Clear run environment (NAME, repeatable)",f).option("--shared-host-safe","Apply additive shared-host-safe run defaults").option("--pm-context <mode>","PM test context: schema|tracker|auto|none (default: schema)").option("--override-linked-pm-context","Override stored context with --pm-context").option("--workspace-context <mode>","Source-workspace mode: source|isolated|snapshot (default: source)").option("--override-linked-workspace-context","Override stored context with --workspace-context").option("--allow-untrusted-linked-tests","Execute untrusted linked commands when project policy also permits it").option("--fail-on-context-mismatch","Fail linked PM commands when context item counts differ").option("--fail-on-skipped","Treat skipped linked tests as dependency failures").option("--fail-on-empty-test-run","Fail successful commands reporting zero executed tests").option("--require-assertions-for-pm","Require assertion metadata for linked PM command tests").option("--check-context","Check PM context before execution").option("--auto-pm-context","Route mismatched PM tracker reads through tracker context")}function Ut(e){de(e);let t=e.command("test").argument("<id>","Item id").option("--add <value>","Add verified isolated test (CSV/markdown or stdin)",f).option("--add-json <value>","Add verified isolated test (JSON object/array or stdin)",f).option("--remove <value>","Remove exact command/path (command=<value>, path=<value>, or stdin -)",f).option("--remove-index <n>","Remove 1-based --list position (repeatable)",f).option("--list","List linked tests without mutating").option("--update <value>","Edit exact command or path=<value>").option("--update-index <n>","Edit current 1-based --list position").option("--set-json <value>","Metadata patch; null clears optional fields").option("--run","Run linked test commands").option("--match <value>","Run matching command/path substring").option("--only-index <n>","Run 1-based --list position").option("--only-last","Run most recently added test");t.option("--acknowledge-linked-tests","Trust current commands in this clone without execution"),me(t).option("--measure <value>","Record name=value[,unit=...][,threshold=...]; requires --run",f).option("--metric-below <value>","Return evidence below name=value").option("--metric-diff <name>","Diff the latest two values").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Manage tests linked to an item and optionally run them.").action(Te);let a=e.command("test-all").description("Run linked tests across matching items.").option("--status <value>","Filter items by status before running tests").option("--limit <n>","Limit matching items before running linked tests").option("--offset <n>","Skip matching items before running linked tests");me(a).action(Ee),e.command("test-runs-worker",{hidden:!0}).argument("<runId>","Background run id").description("Internal background worker command.").action(async(k,h,be)=>{let we=c(be);await ie(k,we)}),e.command("telemetry").argument("[namespace-or-subcommand]","Telemetry subcommand: status, flush, stats, clear (default: status)").argument("[subcommand]","Compatibility alias target for local-analytics: status, flush, stats, clear").option("--limit <n>","Maximum command groups returned by telemetry stats").description("Inspect and manage local telemetry queue/runtime state.").action(Re),e.command("duplicates").description("Find duplicate clusters across all statuses.").option("--status <value>","Statuses (repeatable or comma-separated)",f,[]).option("--since <value>","Created at or after this time").option("--threshold <value>","Minimum similarity (0-1)").option("--limit <n>","Maximum clusters").option("--exhaustive","Score all pairs within the safety bound").action(Pe),e.command("stats").description("Show project tracker statistics.").option("--include-empty","Restore zero-count registered item-type and lifecycle-status buckets").option("--storage","Include aggregate history-stream storage metrics (total streams/lines/bytes, largest + deepest streams, oldest/newest entries)").option("--metadata-coverage","Include metadata coverage % (acceptance_criteria, estimated_minutes, resolution, tags, parent) overall and by type").option("--by-assignee","Include a lifecycle-bucketed item breakdown grouped by assignee").option("--by-tag","Include a lifecycle-bucketed item breakdown grouped by tag").option("--by-priority","Include a lifecycle-bucketed item breakdown grouped by priority").option("--tag-prefix <value>","With --by-tag: only count tags starting with this prefix (e.g. domain:)").option("--field-utilization","Report content-field utilization rates (notes/learnings/files/docs/tests/comments/deps/body) for governance analysis").option("--analytics <json>","Improvement ledger/history analytics JSON").action(Oe),e.command("health").description("Show project tracker health checks.").option("--strict-directories","Treat optional item-type directories as required failures").option("--require-merge-drivers","Treat absent clone-local merge drivers as a required health failure").option("--check-only","Run read-only health diagnostics without refreshing vectors").option("--check-telemetry","Probe telemetry endpoint health and include network diagnostics").option("--no-refresh","Disable automatic vector refresh attempts during health checks").option("--refresh-vectors","Explicitly enable vector refresh attempts during health checks").option("--verbose-stale-items","Include full stale vectorization ID lists in health output").option("--verbose-author-events","Include every actionable unknown-author event coordinate for review or disposition").option("--brief","Emit compact health details for low-token agent checks").option("--summary","Emit one-line-style health status with check names and warning count").option("--skip-vectors","Skip vectorization check for a faster run").option("--skip-integrity","Skip item/history file integrity check for a faster run").option("--skip-drift","Skip history drift hash check for a faster run").option("--full","Run all checks including slow integrity, drift, and vectorization checks").option("--strict-exit","Return non-zero exit when health is not ok and default to actionable summary output; use --full for complete details").option("--fail-on-warn","Alias for --strict-exit").action(Le),e.command("validate").description("Validate metadata, lifecycle policies, files, command references, and history.").option("--check-metadata","Run metadata completeness checks").option("--metadata-profile <value>","Metadata profile (core|strict|custom)").option("--check-resolution","Run closed-item resolution metadata checks").option("--check-completeness","Check declarative lifecycle field requirements").option("--check-lifecycle","Run active-item lifecycle governance drift checks").option("--check-stale-blockers","Include stale blocker-pattern diagnostics in lifecycle checks").option("--dependency-cycle-severity <value>","Set dependency-cycle warning policy for lifecycle checks (off|warn|error)").option("--parent-cycle-severity <value>","Set parent-hierarchy cycle warning policy for lifecycle checks (off|warn|error)").option("--check-files","Run linked-file and orphaned-file checks").option("--check-command-references","Run linked-command PM-ID reference checks").option("--scan-mode <value>","Select file candidate scan mode for --check-files (default|tracked-all|tracked-all-strict)").option("--include-pm-internals","Include PM storage internals in tracked-all candidate scans").option("--verbose-file-lists","Include full file-path lists for validate --check-files details").option("--verbose-diagnostics","Include full diagnostic ID lists").option("--all-affected-ids","Emit complete missing_* affected-ID lists with no truncation (implied by --json)").option("--strict-exit","Return non-zero exit when validation warnings are present").option("--fail-on-warn","Alias for --strict-exit").option("--fix-hints","Add a machine-executable fix_hints[] of pm commands to each failing check's details").option("--auto-fix","Apply safe, deterministic field backfills").option("--dry-run","Preview planned --auto-fix/--prune-missing fixes without applying them").option("--fix-scope <scope>","Grant --auto-fix scopes (metadata, resolution, estimates, timestamps, lifecycle; comma-separated or repeatable). Default: metadata, resolution; other scopes require explicit opt-in",f).option("--prune-missing","Remove deleted-path file/doc links; preserves real files").option("--check-history-drift","Run item/history hash drift checks").option("--check-storage-integrity","Run the post-merge storage-integrity check (unreadable items, history conflict markers, resurrected deletes, unparseable config/schema)").option("--counts","Keep validation counts and totals while omitting per-item diagnostic arrays").option("--full","Return the complete validation diagnostic projection").action(Me),e.command("gc").option("--dry-run","Preview cleanup targets without deleting files; without this flag, pm gc deletes matched artifacts").option("--scope <value>","Limit cleanup to one or more scopes (comma-separated or repeatable): index, embeddings, runtime, locks, checkpoints, transactions",f).description("Delete optional cache artifacts by default (including expired lock debris) and show a summary.").action(Fe);let n=e.command("workspace").description("Inspect workspace state and snapshots.");n.command("position").description("Show merge and history readiness.").action(ye),n.command("snapshot").argument("<action>","Action: create, list, inspect, restore, delete").argument("[target]","Optional name for create; name or fingerprint otherwise").description("Manage content-addressed tracker snapshots.").option("--dry-run","Preview restore file, item, stream, and history-entry impact without mutating state").option("--force","Explicitly confirm a whole-workspace snapshot restore").option("--author <value>","Actor recorded on the restore audit event").option("--message <value>","Human-readable restore rationale").action(Ve),e.command("contracts").description("Show machine-readable command and schema contracts for agents.").option("--action <value>","Filter tool schema branches to a specific action").option("--command <value>","Scope contracts output to one CLI command (narrow-by-default)").option("--summary","Return one command+intent row per top-level command for cheap agent bootstrap").option("--schema-only","Return schema-focused output only").option("--flags-only","Return command flag contracts only").option("--availability-only","Return action availability surface only").option("--runtime-only","Include only actions invocable in the current runtime").option("--active-only","Alias for --runtime-only").option("--full","Include full schema and command-flag surfaces (large; default brief output omits heavy sections for unfiltered queries)").action(Ne);let o=e.command("claim").option("--start","Claim and start an explicit item").argument("[id]","Item id (omit with --next)").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force claim override").option("--if-available","Skip another author's claim (skipped=true)").option("--next","Atomically claim the next caller-available actionable item").option("--type <value>","Filter --next candidates by type").option("--tag <value>","Filter --next candidates by tag").option("--priority <value>","Filter --next candidates by priority").option("--assignee-filter <value>","Filter --next candidates: assigned|unassigned").option("--parent <id>","Scope --next candidates to a subtree").option("--sprint <value>","Filter --next candidates by sprint").option("--release <value>","Filter --next candidates by release").option("--max-attempts <n>","Bound the --next candidate walk (default 10; maximum 100)").option("--include-decisions","Allow --next to claim human-gated Decision items").option("--include-gates","Allow --next to claim outcome gates").option("--include-containers","Allow --next to claim containers with unfinished descendants").option("--token-budget <n>","Bound the estimated tokens used to rank --next candidates").option("--explain-ranking","Include ranking provenance for --next selection").description("Claim an item for active work.").action(Ue);g(o,"--assignee <value>","Alias for --author on lifecycle ownership commands"),g(o,"--token_budget <n>","Alias for --token-budget"),g(o,"--explain_ranking","Alias for --explain-ranking");let r=e.command("release").option("--pause","Use open status").option("--handoff <status>","Needs --message").argument("<id>","Item id").option("--author <value>","Author").option("--message <value>","Message").option("--force","Override ownership").description("Release ownership.").action(Je);g(r,"--assignee <value>","Alias for --author on lifecycle ownership commands");let s=e.command("start-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: claim an item and move it to in_progress.").action(ge);g(s,"--assignee <value>","Alias for --author on lifecycle ownership commands");let p=e.command("pause-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override when required").description("Lifecycle alias: move an item to open and release its claim.").action(he);g(p,"--assignee <value>","Alias for --author on lifecycle ownership commands");let w=e.command("close-task",{hidden:!0}).argument("<id>","Item id").argument("[reason]","Close reason text").option("--author <value>","Mutation author").option("--message <value>","History message").option("--validate-close <value>","Close-time validation mode: off|warn|strict").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: close an item and release assignment metadata.").action(qe);g(w,"--assignee <value>","Alias for --author on lifecycle ownership commands")}export{Nt as _testOnlyRegisterOperations,Ut as registerOperationCommands,ue as requireClaimTarget};
2
- //# sourceMappingURL=register-operations-SUWOZNDU.js.map
@@ -1,2 +0,0 @@
1
- import"./chunk-DEZPZOQ7.js";import{a as P}from"./chunk-D3EDNAN7.js";import{g as j,i as T}from"./chunk-DMFM5R4G.js";import{Ea as O,Ga as L,na as R,qa as U,za as I}from"./chunk-H3XYP24A.js";import{Ef as b,Hf as v}from"./chunk-4CXQSRSP.js";import"./chunk-O2ZRRLAP.js";import{ii as S,k as $,l as G,tf as D,wf as w,xa as E,xf as y}from"./chunk-QG4LMU7A.js";import"./chunk-LBEMB3BW.js";import"./chunk-VS565KBX.js";import{B as d,D as h}from"./chunk-QKAAZWGC.js";import C from"node:fs/promises";import W 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]="26ea7f42-d5f7-5ada-afd9-389dadc4d138")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0b0e08e0-f6e7-59c4-ac96-9f47b172727a")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d975120a-964e-5b19-ae10-8ba011ba9bf8")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="108609fa-51fc-5bd0-ac54-de2ad14a66c6")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b36466e6-5574-5509-909a-e8599f11664c")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e5e1e242-6864-5a72-adb9-0eda4c65a0c3")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c70e67b1-fa46-518f-8630-b9e002c12936")}catch{}})();var M={extension:"extension",package:void 0};async function _(e,t){if(!e)return;let o=$(e),i=b(t);await S(E(process.cwd(),i.path)).then(a=>a.ux.deprecation_hints)&&y(G(o))}var V={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function X(e){let t=e.capability,o=typeof t=="string"?[t]:Array.isArray(t)?t.filter(a=>typeof a=="string"):[],i=[...new Set(o.map(a=>a.trim().toLowerCase()).filter(a=>a.length>0))];if(i.length>1)throw new h(`Multiple scaffold capabilities cannot be combined yet: ${i.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return i[0]}function A(e,t,o="extension"){let i={...e};t!==void 0&&(i[V[t]]=!0);let a=(...c)=>c.some(s=>i[s]===!0),r=(...c)=>{for(let s of c)if(typeof i[s]=="string")return i[s]};return{init:a("init"),scaffold:a("scaffold"),install:a("install"),uninstall:a("uninstall"),explore:a("explore","list"),manage:a("manage"),describe:a("describe"),markdown:a("markdown"),reload:a("reload"),doctor:a("doctor"),catalog:a("catalog"),adopt:a("adopt"),adoptAll:a("adoptAll","adopt_all","adopt-all"),activate:a("activate"),deactivate:a("deactivate"),migrate:a("migrate"),project:a("project"),local:a("local"),global:a("global"),gh:r("gh"),github:r("github"),ref:r("ref"),capability:X(e),declarative:a("declarative"),fields:r("fields"),detail:r("detail"),output:r("output"),trace:a("trace"),watch:a("watch"),runtimeProbe:a("runtimeProbe","runtime_probe","runtime-probe"),offline:a("offline"),fixManagedState:a("fixManagedState","fix_managed_state","fix-managed-state"),isolated:a("isolated"),ignoreGlobal:a("ignoreGlobal","ignore_global","ignore-global"),strictExit:a("strictExit","strict_exit","strict-exit"),failOnWarn:a("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:a("dryRun","dry_run","dry-run"),vocabulary:o}}async function Y(e){let t=(await C.readdir(process.cwd())).filter(i=>!i.startsWith(".")).sort((i,a)=>i.localeCompare(a)),o=[...e].sort((i,a)=>i.localeCompare(a));return t.length===o.length&&t.every((i,a)=>i===o[a])}async function J(e){let t=(e??[]).map(o=>o.trim()).filter(o=>o.length>0);return t.length<=1?t.length===0?void 0:t:await Y(t)?["*"]:t}function H(e,t,o){let i=e.markdown===!0;if(o!==void 0&&o==="")throw new h("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!i)throw new h("--output is only supported with --markdown describe output.",d.USAGE);if(i){if(t.json)throw new h("Cannot combine --json with --markdown.",d.USAGE);if(e.describe!==!0)throw new h("--markdown is only supported by the describe action.",d.USAGE)}}async function Q(e){let t=U(e.result.details,e.vocabulary);if(e.outputPath!==void 0){let o=W.resolve(e.outputPath);await C.mkdir(W.dirname(o),{recursive:!0}),await C.writeFile(o,t,"utf8")}if(!e.globalOptions.quiet){for(let o of e.result.warnings)y(`warning: ${o}`);e.outputPath===void 0&&D(t)}}function Z(e,t){let o=!!t.strictExit||!!t.failOnWarn;if(e.action!=="doctor"||!o)return;let i=e.details!==null&&typeof e.details=="object"?e.details:{},a=i.summary!==null&&typeof i.summary=="object"?i.summary:null,r=a&&typeof a.status=="string"?a.status:void 0;(e.warnings.length>0||r!==void 0&&r!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function g(e,t,o,i,a="extension"){let r=b(o),c=Date.now(),s=a==="extension"?"package":a;await _(M[a],o);let n=A(t,i,s),l=(typeof n.output=="string"?n.output:void 0)?.trim();H(n,r,l);let f=await I(e,n,r);n.markdown===!0?await Q({result:f,vocabulary:s,outputPath:l,globalOptions:r}):w(f,r),Z(f,n),f.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),r.profile&&y(`profile:command=extension took_ms=${Date.now()-c}`)}function ee(e){return e.details!==null&&typeof e.details=="object"?e.details:{}}function te(e){return e instanceof h?{message:e.message,exit_code:e.exitCode,...e.context}:{message:e instanceof Error?e.message:String(e),exit_code:d.GENERIC_FAILURE}}async function oe(e,t,o){let i=[],a=[],r=d.GENERIC_FAILURE;for(let c of e)try{let s=await I(c,t,o),n=ee(s),l=Array.isArray(s.warnings)?s.warnings:[];a.push(...l);let f=s.ok===!0;i.push({target:c,ok:f,extension:n.extension,source:n.source,install_plan:n.install_plan,dry_run:n.dry_run,destination_path:n.destination_path,activated:n.activated,settings_changed:n.settings_changed,command_paths:n.command_paths,action_paths:n.action_paths,runtime_activation_status:n.runtime_activation_status,activation_diagnostics:n.activation_diagnostics,command_discovery:n.command_discovery,verification:n.verification,warnings:l,...f?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let n=te(s),l=n.exit_code;typeof l=="number"&&r===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(r=l),i.push({target:c,ok:!1,error:n})}return{rows:i,warnings:a,failureExitCode:r}}async function z(e,t,o,i){let a=i==="extension"?"package":i;await _(M[i],o);let r=await J(e);if(r===void 0||r.length<=1){await g(r?.[0],t,o,"install",a);return}let c=b(o),s=Date.now(),n=A(t,"install",a);if(H(n,c,void 0),[n.gh,n.github].some(k=>typeof k=="string"&&k.trim().length>0))throw new h("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm package install --gh owner/repo","pm package install npm:pm-guide-shell pm-todos"]});let{rows:l,warnings:f,failureExitCode:m}=await oe(r,n,c),u=l.filter(k=>k.ok!==!0).length,K={ok:u===0,action:"install",scope:n.global===!0?"global":"project",installed_count:n.dryRun===!0?0:l.length-u,...n.dryRun===!0?{dry_run:!0,planned_count:l.length-u}:{},failed_count:u,targets:l,warnings:[...new Set(f)].sort((k,B)=>k.localeCompare(B))};w(K,c),u>0&&(process.exitCode=m),c.profile&&y(`profile:command=extension took_ms=${Date.now()-s}`)}function ae(e){return e.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function x(e){return e.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function p(e,t){return t==="package"?x(e):ae(e)}function N(e){return e.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function q(e,t,o){let i=b(t),a=Date.now();o&&await _("upgrade",t);let r=await T(e,t.optsWithGlobals(),i);w(r,i),r.ok||(process.exitCode=d.GENERIC_FAILURE),i.profile&&y(`profile:command=package-upgrade took_ms=${Date.now()-a}`)}function F(e,t){let o=t==="package"?"package":"extension",i=t==="package"?"packages":"extensions",a=t,r=e.command(a,{hidden:t==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",v).option("--install",`Install a ${o} source`).option("--dry-run","Preview install without writes or activation").option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${i} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${i} and updates`).option("--offline","Skip remote freshness checks during manage").option("--describe",`Show surfaces registered by a loaded ${o}`).option("--markdown","Render describe as Markdown").option("--output <path>","Write Markdown to a file").option("--reload",`Reload ${i} without import cache`).option("--watch","Use watch mode with --reload").option("--doctor",`Run ${o} diagnostics`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt unmanaged ${o}`).option("--adopt-all",`Adopt all unmanaged ${i}`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${i} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${i} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(t==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,void 0,t)});t==="package"&&(r.alias("packages"),r.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=r.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${R.join("|")}; default commands)`,v).description(t==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");t==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),p(c,t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"init",t)}),p(r.command("install").option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),t).action(async(s,n,l)=>{await z(s,l.optsWithGlobals(),l,t)}),p(r.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"uninstall",t)}),p(r.command("explore").description(`List discovered ${i} in selected scope.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"explore",t)}),p(r.command("inventory").argument("[name]",`${o[0].toUpperCase()}${o.slice(1)} name or directory to inspect`).description(`Read configured ${o} install and enablement state without activating extension code.`),t).action(async(s,n,l)=>{let f=b(l),m=l.optsWithGlobals();if(m.global===!0&&(m.project===!0||m.local===!0))throw new h("--global and --project/--local are mutually exclusive.",d.USAGE);let u=await P({pmRoot:E(process.cwd(),f.path),scope:m.global===!0?"global":"project",name:s});w(u,f),u.complete||(process.exitCode=d.GENERIC_FAILURE)}),p(r.command("manage").option("--offline","Skip remote freshness checks and report unknown update availability").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${i} before diagnostics/update checks`).description(`List managed ${i} with update-check metadata.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"manage",t)}),p(r.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"describe",t)}),p(r.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${i} with cache-busted module imports.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"reload",t)}),p(r.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${i} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${i} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"doctor",t)}),p(r.command("catalog").alias("list").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"catalog",t)}),p(r.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"adopt",t)}),p(r.command("adopt-all").description(`Adopt all unmanaged ${i} into managed metadata.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"adopt-all",t)}),p(r.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),t).action(async(s,n)=>{await g(void 0,n.optsWithGlobals(),n,"migrate",t)}),p(r.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"activate",t)}),p(r.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),t).action(async(s,n,l)=>{await g(s,l.optsWithGlobals(),l,"deactivate",t)}),t==="package"&&N(x(r.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,n,l)=>{await q(s,l,!1)})}async function ie(e,t,o){let i=b(o),a=Date.now(),r=await L(e,i,{idPrefix:typeof t.idPrefix=="string"?t.idPrefix:void 0,preset:typeof t.preset=="string"?t.preset:void 0,defaults:t.defaults===!0||t.yes===!0,author:typeof t.author=="string"?t.author:void 0,agentGuidance:typeof t.agentGuidance=="string"?t.agentGuidance:void 0,typePreset:typeof t.typePreset=="string"?t.typePreset:void 0,withPackages:t.withPackages===!0,mergeFence:t.mergeFence!==!1,force:t.force===!0,workspace:typeof t.workspace=="string"?t.workspace:void 0}),c=t.verbose===!0||i.json===!0;w(c?r:O(r,!0),i),i.profile&&y(`profile:command=init took_ms=${Date.now()-a}`)}function ne(e,t,o,i){let a=e!==void 0&&new Set(["get","set","list","export"]).has(e);return{resolvedScope:a?"project":e??"project",resolvedAction:a?e:t??"list",resolvedKey:a?t:o,resolvedValue:a?o:i}}function re(e){return{criterion:Array.isArray(e.criterion)?e.criterion:[],format:typeof e.format=="string"?e.format:void 0,policy:typeof e.policy=="string"?e.policy:void 0,value:typeof e.value=="string"?e.value:void 0,clearCriteria:e.clearCriteria===!0,defaultDepth:typeof e.defaultDepth=="string"?e.defaultDepth:void 0,activityLimit:typeof e.activityLimit=="string"?e.activityLimit:void 0,staleThresholdDays:typeof e.staleThresholdDays=="string"?e.staleThresholdDays:void 0,sectionHierarchy:typeof e.sectionHierarchy=="string"?e.sectionHierarchy:void 0,sectionActivity:typeof e.sectionActivity=="string"?e.sectionActivity:void 0,sectionProgress:typeof e.sectionProgress=="string"?e.sectionProgress:void 0,sectionBlockers:typeof e.sectionBlockers=="string"?e.sectionBlockers:void 0,sectionFiles:typeof e.sectionFiles=="string"?e.sectionFiles:void 0,sectionWorkload:typeof e.sectionWorkload=="string"?e.sectionWorkload:void 0,sectionStaleness:typeof e.sectionStaleness=="string"?e.sectionStaleness:void 0,sectionTests:typeof e.sectionTests=="string"?e.sectionTests:void 0}}async function se(e,t,o,i,a,r){let c=b(r),s=Date.now(),{resolvedScope:n,resolvedAction:l,resolvedKey:f,resolvedValue:m}=ne(e,t,o,i),u=await j(n,l,f,re(a),c,typeof m=="string"?m:void 0);w(u,c),c.profile&&y(`profile:command=config took_ms=${Date.now()-s}`)}var Re={normalizeExtensionOptions:A};function Ue(e){e.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(t,o,i)=>{await ie(t,o,i)}),e.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]",'Optional value for set: routed to the right typed flag by key (e.g. config set telemetry-tracking off, config set item-format toon, config set definition-of-done "Tests pass"). Equivalent to --policy/--format/--criterion. context keys still require --default-depth/--section-* flags.').option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",v).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(t,o,i,a,r,c)=>{await se(t,o,i,a,r,c)}),F(e,"extension"),F(e,"package"),x(e.command("install",{hidden:!0}).option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(t,o,i)=>{await _("install",i),await z(t,i.optsWithGlobals(),i,"package")}),N(x(e.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(t,o,i)=>{await q(t,i,!0)})}export{Re as _testOnlyRegisterSetup,Ue as registerSetupCommands};
2
- //# sourceMappingURL=register-setup-QGM5YJW7.js.map
@@ -1,2 +0,0 @@
1
- import{i as w}from"./chunk-O2ZRRLAP.js";import{xa as h}from"./chunk-QG4LMU7A.js";import{d as u}from"./chunk-LBEMB3BW.js";import{b as g}from"./chunk-VS565KBX.js";import{B as m,D as f}from"./chunk-QKAAZWGC.js";import{execFile as y}from"node:child_process";import{realpath as v}from"node:fs/promises";import l from"node:path";import{promisify as _}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]="fe5937fc-def3-5ed4-9663-70a6e9d258a1")}catch{}})();var b=_(y);function c(e){return new f(`Automatic merge settlement refused: ${e}`,m.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function x(e){let t=process.env.GIT_INDEX_FILE;if(t===void 0)return;let s=(await e(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(l.resolve(t)!==l.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function R(e,t){if(t.length===0)return[];let s=t.map(a=>`:(literal)${a}`),o=new Set((await e(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),r=t.filter(a=>!o.has(a)).map(a=>`:(literal)${a}`);if(r.length>0&&(await e(["diff","--cached","--name-only","--diff-filter=D","-z","--",...r])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return r}async function k(e){let{git:t,preview:s,paths:o,newReceiptPathspecs:r}=e,a=!1;try{r.length>0&&(await t(["add","--",...r]),a=!0);let n=await e.apply();if(!n.ok||JSON.stringify(n.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||n.repair.streams.some(p=>!s.repair.streams.some(d=>d.id===p.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return o.length>0&&await t(["add","--",...o.map(p=>`:(literal)${p}`)]),{...n,staged_paths:o,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(n){throw a&&await t(["reset","--quiet","--",...r]),n}}function G(e){if(e.repair.totals.failed>0||e.receipts.missing_history_references_after>0||e.receipts.summaries.some(t=>t.conflict_fields.length>0)||e.repair.streams.some(t=>t.merge_receipt_proof?.trusted!==!0)||e.validation.checks.some(t=>t.name!=="history_drift"&&t.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function I(e){try{return{...e,path:await v(h(process.cwd(),e.path))}}catch{throw c("the tracker root cannot be resolved")}}async function N(e){let{preview:t}=e;G(t);let{path:s}=await I(e.global),o=await w(s);if(o===null)throw c("a Git workspace is required");let r=i=>b("git",i,{cwd:o,env:g(),timeout:1e4});if(await x(r),(await r(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let a=[...new Set([...[...new Set([...t.repair.streams.map(i=>i.id),...t.receipts.summaries.map(i=>i.item_id)])].map(i=>l.join(s,"history",`${i}.jsonl`)),...t.receipts.summaries.map(i=>l.join(s,"merge-receipts",`${i.receipt_id}.json`))])].map(i=>l.relative(o,i).replaceAll("\\","/"));if(a.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let n=a.map(i=>`:(literal)${i}`),p=t.receipts.summaries.map(i=>l.relative(o,l.join(s,"merge-receipts",`${i.receipt_id}.json`)).replaceAll("\\","/"));if(n.length>0)try{await r(["diff","--quiet","--",...n])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let d=await R(r,p);return e.dryRun?{...t,staged_paths:[]}:k({...e,git:r,paths:a,newReceiptPathspecs:d})}export{I as resolveMergeSettlementGlobal,N as stageLosslessMergeReconciliation};
2
- //# sourceMappingURL=stage-7DELI4Z5.js.map