@unbrained/pm-cli 2026.8.14 → 2026.8.16

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 (160) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +51 -11
  3. package/dist/cli/commander-usage.js +17 -4
  4. package/dist/cli/error-guidance.d.ts +7 -0
  5. package/dist/cli/error-guidance.js +65 -25
  6. package/dist/cli/main.js +3 -2
  7. package/dist/cli/register-history-author.js +16 -11
  8. package/dist/cli/register-mutation.js +4 -2
  9. package/dist/cli/register-operations.js +5 -5
  10. package/dist/cli-bundle/bundle-manifest.json +148 -148
  11. package/dist/cli-bundle/chunks/chunk-47OQEOQB.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-XAVMOK6B.js → chunk-73UGEBRS.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-HCIYWD6M.js +35 -0
  14. package/dist/cli-bundle/chunks/{chunk-FIW4P64F.js → chunk-I2LUWWR5.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-SBRKH6OR.js → chunk-IC5W2T34.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-TMJ7URWS.js → chunk-PANOOBIS.js} +9 -9
  17. package/dist/cli-bundle/chunks/{chunk-BFALV3YP.js → chunk-RIS565OA.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TXMEUUUY.js → chunk-TK6N7HGM.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-TOFG2URD.js +197 -0
  20. package/dist/cli-bundle/chunks/{chunk-G5JUB66K.js → chunk-URW4QRMI.js} +65 -59
  21. package/dist/cli-bundle/chunks/{register-list-query-T3EHHNNV.js → register-list-query-EYCXHZAG.js} +2 -2
  22. package/dist/cli-bundle/chunks/register-mutation-7YVIG54J.js +20 -0
  23. package/dist/cli-bundle/chunks/register-operations-KGDNRMCL.js +2 -0
  24. package/dist/cli-bundle/chunks/{register-setup-3YXZ444E.js → register-setup-NVXBOD5I.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-PPFGQDSI.js → chunk-4JPEBFFC.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-5NMFSX26.js +155 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-YOOI3UZX.js → chunk-6ROKKT4X.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-725JSCMP.js +2 -0
  29. package/dist/cli-bundle/focused-chunks/{chunk-XDNAW5OI.js → chunk-C7JUBRFP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-4DQ2YERC.js → chunk-CODV5LUT.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-DQ6SMTBF.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-HAACPSUW.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-WCVE2NIG.js → chunk-J4UFYHOD.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-JX5Z344Q.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-L4RDYBIQ.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-KSEDUWVZ.js → chunk-NJ5RLEFD.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-K7RWWOAG.js → chunk-QYZERYR5.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-SSNDYZTM.js +8 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-T46KLOIB.js +50 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-KFSZ3BP6.js → chunk-TZATVC4G.js} +6 -6
  41. package/dist/cli-bundle/focused-chunks/chunk-WY3WRPVN.js +2 -0
  42. package/dist/cli-bundle/main.js +13 -13
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +32 -35
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +32 -31
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +2 -2
  53. package/dist/core/diagnostics/remediation.js +7 -2
  54. package/dist/core/extensions/reserved-host-flags.js +3 -2
  55. package/dist/core/history/replay.d.ts +14 -1
  56. package/dist/core/history/replay.js +45 -8
  57. package/dist/core/history/workspace-history.js +32 -10
  58. package/dist/core/output/output.d.ts +2 -0
  59. package/dist/core/output/output.js +7 -3
  60. package/dist/core/shared/command-types.d.ts +2 -0
  61. package/dist/core/shared/command-types.js +2 -2
  62. package/dist/core/shared/errors.d.ts +14 -0
  63. package/dist/core/shared/errors.js +2 -2
  64. package/dist/core/store/item-store.js +28 -2
  65. package/dist/mcp/tool-definitions.js +9 -5
  66. package/dist/sdk/agent/refusal-reachability.d.ts +69 -0
  67. package/dist/sdk/agent/refusal-reachability.js +159 -3
  68. package/dist/sdk/author-attribution.d.ts +56 -11
  69. package/dist/sdk/author-attribution.js +174 -50
  70. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  71. package/dist/sdk/cli-bootstrap.js +7 -2
  72. package/dist/sdk/cli-contracts/completeness.js +3 -2
  73. package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
  74. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  75. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
  76. package/dist/sdk/cli-contracts/runtime-contracts.js +23 -7
  77. package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -5
  78. package/dist/sdk/cli-contracts/tool-schema.js +20 -5
  79. package/dist/sdk/cli-program.js +3 -2
  80. package/dist/sdk/completion.js +11 -4
  81. package/dist/sdk/core.d.ts +2 -2
  82. package/dist/sdk/core.js +3 -3
  83. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -2
  84. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +74 -14
  85. package/dist/sdk/governance/assurance-action.d.ts +7 -1
  86. package/dist/sdk/governance/assurance-action.js +7 -6
  87. package/dist/sdk/governance/assurance-mutation-error.d.ts +42 -1
  88. package/dist/sdk/governance/assurance-mutation-error.js +27 -3
  89. package/dist/sdk/governance/assurance-runtime.js +12 -11
  90. package/dist/sdk/governance/assurance.d.ts +9 -0
  91. package/dist/sdk/governance/assurance.js +80 -14
  92. package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
  93. package/dist/sdk/governance/coverage-assurance.js +61 -0
  94. package/dist/sdk/governance/extension-host-version.d.ts +25 -0
  95. package/dist/sdk/governance/extension-host-version.js +116 -0
  96. package/dist/sdk/governance/health.d.ts +32 -1
  97. package/dist/sdk/governance/health.js +119 -27
  98. package/dist/sdk/governance/provenance-health.d.ts +27 -0
  99. package/dist/sdk/governance/provenance-health.js +95 -3
  100. package/dist/sdk/governance/validate.js +7 -8
  101. package/dist/sdk/governance.d.ts +6 -0
  102. package/dist/sdk/governance.js +8 -2
  103. package/dist/sdk/history-repair.d.ts +13 -1
  104. package/dist/sdk/history-repair.js +62 -18
  105. package/dist/sdk/index.d.ts +2 -1
  106. package/dist/sdk/index.js +4 -3
  107. package/dist/sdk/linked-artifacts.js +16 -5
  108. package/dist/sdk/pagination.d.ts +15 -0
  109. package/dist/sdk/pagination.js +9 -5
  110. package/dist/sdk/query/context.d.ts +5 -1
  111. package/dist/sdk/query/context.js +14 -5
  112. package/dist/sdk/read-output/continuation.d.ts +11 -0
  113. package/dist/sdk/read-output/continuation.js +132 -0
  114. package/dist/sdk/read-output-budget.d.ts +1 -1
  115. package/dist/sdk/read-output-budget.js +14 -10
  116. package/dist/sdk/read-output-contracts.d.ts +66 -2
  117. package/dist/sdk/read-output-contracts.js +185 -19
  118. package/dist/sdk/read-output-rows.d.ts +2 -0
  119. package/dist/sdk/read-output-rows.js +15 -2
  120. package/dist/sdk/runtime-input.js +4 -2
  121. package/dist/sdk/runtime.d.ts +2 -5
  122. package/dist/sdk/runtime.js +3 -2
  123. package/docs/ASSURANCE.md +59 -2
  124. package/docs/COMMANDS.md +8 -2
  125. package/docs/READ_OUTPUT_CONTRACTS.md +55 -8
  126. package/docs/RELEASING.md +54 -11
  127. package/docs/SDK_CONTEXT_INTEGRITY.md +94 -4
  128. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
  129. package/marketplace.json +2 -2
  130. package/package.json +3 -3
  131. package/packages/pm-beads/package.json +1 -1
  132. package/packages/pm-calendar/package.json +1 -1
  133. package/packages/pm-command-kit/package.json +1 -1
  134. package/packages/pm-digital-twin/package.json +1 -1
  135. package/packages/pm-governance-audit/package.json +1 -1
  136. package/packages/pm-guide-shell/package.json +1 -1
  137. package/packages/pm-kanban/package.json +1 -1
  138. package/packages/pm-lifecycle-hooks/package.json +1 -1
  139. package/packages/pm-linked-test-adapters/package.json +1 -1
  140. package/packages/pm-search-advanced/package.json +1 -1
  141. package/packages/pm-templates/package.json +1 -1
  142. package/packages/pm-todos/package.json +1 -1
  143. package/packages/pm-vcs/package.json +1 -1
  144. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  145. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  146. package/sdk/public-surface.json +1241 -180
  147. package/dist/cli-bundle/chunks/chunk-BBOFSVAK.js +0 -197
  148. package/dist/cli-bundle/chunks/chunk-YAMTJL6Y.js +0 -34
  149. package/dist/cli-bundle/chunks/chunk-YSVSMJ2B.js +0 -2
  150. package/dist/cli-bundle/chunks/register-mutation-E27WCLSZ.js +0 -20
  151. package/dist/cli-bundle/chunks/register-operations-4R6I7CPY.js +0 -2
  152. package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +0 -8
  153. package/dist/cli-bundle/focused-chunks/chunk-KYUQGTSB.js +0 -2
  154. package/dist/cli-bundle/focused-chunks/chunk-LZ4MV3RH.js +0 -2
  155. package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +0 -155
  156. package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +0 -2
  157. package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +0 -46
  158. package/dist/cli-bundle/focused-chunks/chunk-QUMB2J27.js +0 -2
  159. package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.js +0 -2
@@ -0,0 +1,2 @@
1
+ (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]="294f3a0c-e74d-5963-b966-8a4443855ce3")}catch{}})();var L=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],Be=2,Ge=Object.freeze({migration:"schema",validation:"schema"}),gn=Object.freeze({version:Be,capabilities:[...L],legacy_aliases:{...Ge}}),oe=["off","warn","enforce"],re=["off","warn","enforce"],se=["none","restricted","strict"],yn=["block","warn"],ie=["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"],ae=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function ue(){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]="8b39bc01-0325-5dc6-8492-585c98608076")}catch{}})();var ze=["Epic","Feature","Task","Chore","Issue","Decision","Event","Reminder","Milestone","Meeting","Plan"],En=ze,bn=["draft","open","in_progress","blocked","closed","canceled"],On=["draft","active","blocked","terminal","terminal_done","terminal_canceled","default_open","default_close","default_cancel"],Sn=["string","number","boolean","string_array","array","object"],An=["create","update","update_many","list","search","calendar","context"],wn=["allow","warn","reject"],Tn=["blocks","parent","child","parent_child","child_of","related","related_to","discovered_from","blocked_by","incident_from","epic","implements","supersedes","task","verifies"],kn=["project","global"],Rn=["low","medium","high","critical"],xn=["low","medium","high","critical"],In=["low","medium","high"];var Nn=["minimal","default","strict","custom"],vn=["none","warn","strict"],Cn=["progressive","strict"],Dn=["off","warn","strict"],Mn=["off","warn","strict"];var Un=["daily","weekly","monthly","yearly"],Ke=["mon","tue","wed","thu","fri","sat","sun"];function Ln(e){return Ke.indexOf(e)}var Pn=["draft","research","review","approved","executing","paused","completed","superseded"],jn=["pending","in_progress","completed","blocked","skipped","superseded"],Vn=["codex","claude-code","cursor","generic"],Fn=["related","blocks","blocked_by","depends_on","discovered_from","implements","verifies","supersedes"],Bn=["brief","standard","deep","full"],Gn=["hierarchy","activity","progress","recently_created","unparented","blockers","files","workload","staleness","tests"];(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]="36b908f0-ea19-5adc-8ccd-320ad3c3b1fe")}catch{}})();var $e=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"]}]),Xe=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),$n=".agents/pm",Xn="settings.json";var Ye=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],qe=["decisions","events","reminders","milestones","meetings","plans"],Yn=[...Ye,...qe],qn={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},We=["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"],Wn=["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",...We,"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"],Qe={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}},He=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],P={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 ce(e){return e?[...e]:void 0}var Qn={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"},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:[...He],lifecycle_closure_like_blocked_reason_patterns:[...P.blocked_reason],lifecycle_closure_like_resolution_patterns:[...P.resolution],lifecycle_closure_like_actual_result_patterns:[...P.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...Qe.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!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:$e.map(e=>({...e,aliases:ce(e.aliases),roles:ce(e.roles)})),fields:[],workflow:{...Xe},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:ue()},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:"",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:""}}},Hn={metadata:{},body:""},p={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},Jn=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(){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]="bf08255e-7ef4-5929-8431-2df83d98d0ba")}catch{}})();var _=class extends Error{exitCode;code;context;constructor(t,n,o={}){super(t),this.name="PmCliError",this.exitCode=n,this.context=o,this.code=o.code}};(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]="818ca284-2aaa-5d35-b280-8c963d443b0c")}catch{}})();var Je=[...L],Ze=[...ae],et=[...oe],no=[...re],oo=[...se],tt=[...ie],R=["init","config","extension","package","packages","install","upgrade","create","item","copy","focus","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","aggregate","context","ctx","get","graph","search","duplicates","eval","next","history","events","history-redact","history-repair","history-compact","history-author-acknowledge","merge","schema","profile","activity","restore","update","update-many","close","close-many","delete","append","comments","notes","learnings","files","docs","deps","plan","test","test-all","telemetry","stats","health","validate","assurance","gc","workspace","contracts","claim","release","start-task","pause-task","close-task","meet","event","remind","help"],ro=["ancestors","descendants","predecessors","successors","paths","impact","analyze","audit","communities","redundancy","dominators","slack","centrality","articulation","plan","index"],nt=["init","install","uninstall","explore","manage","describe","reload","doctor","catalog","adopt","adopt-all","activate","deactivate"],de={help:"Commander help rendering has no SDK operation result.",item:"The item namespace only groups lifecycle subcommands already exposed as actions.",packages:"The plural package alias only renders package-oriented help."},le=Object.freeze(R.flatMap(e=>e in de?[]:e==="extension"||e==="package"?[...nt.map(t=>`${e}-${t}`),e]:[e]));function so(e=R,t=le,n=de){let o=new Set(t),r=new Set(e);return{missing_cli_actions:e.filter(s=>!o.has(s)&&n[s]===void 0),waived_cli_actions:e.filter(s=>!o.has(s)&&n[s]!==void 0),stale_waivers:Object.keys(n).filter(s=>!r.has(s)||o.has(s))}}function io(e){return le.includes(e)}function ao(e){return Je.includes(e)}function uo(e){return Ze.includes(e)}function co(e){return et.includes(e)}function lo(e){return tt.includes(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]="0c69ff43-7bbc-5128-9533-bbf15365126b")}catch{}})();var ot=new Set(["applied_bound","completeness","budget_retention_policy","continuation_contract","continuation_kind","continuation_path","filters","omission_receipt","output_budget_truncation","projection","read_output","read_session","row_contract","sorting"]);function x(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function rt(e,t){let n=e;for(let o of t.split(".")){if(!x(n))return;n=n[o]}return n}function j(e,t,n){let o=t.split("."),r={...e},s=e,a=r;for(let i of o.slice(0,-1)){let u=s[i],c={...u};a[i]=c,s=u,a=c}return a[o.at(-1)]=n,r}function fe(e,t,n){let o=g(e).find(s=>s.path===t);if(!o)return e;let r=Array.isArray(o.value)?o.value.slice(n):Object.fromEntries(Object.entries(o.value).slice(n));return j(e,t,r)}function V(e){let t=e.row_contract;return x(t)&&Array.isArray(t.row_keys)?t.row_keys.filter(n=>typeof n=="string"&&n.trim().length>0):Object.entries(e).filter(([,n])=>Array.isArray(n)).map(([n])=>n)}function g(e){return V(e).flatMap(t=>{let n=rt(e,t);return Array.isArray(n)||x(n)?[{path:t,value:n}]:[]})}function _e(e){let t=g(e),n=new Set(t.map(r=>r.path)),o=(r,s)=>{if(Array.isArray(r)){n.has(s)||t.push({path:s,value:r}),r.forEach((a,i)=>o(a,`${s}.${i}`));return}if(x(r))for(let[a,i]of Object.entries(r))s.length===0&&ot.has(a)||o(i,s.length===0?a:`${s}.${a}`)};return o(e,""),t}function I(e){return g(e).reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:Object.keys(n.value).length),0)}function A(e,t){let n=e;for(let o of g(n)){let r=Array.isArray(o.value)?o.value.map((s,a)=>t(s,o.path,a)):Object.fromEntries(Object.entries(o.value).map(([s,a],i)=>[s,t(a,o.path,i)]));n=j(n,o.path,r)}return n}function pe(e,t){let n=e,o=!1;for(let r of g(n)){let s=Array.isArray(r.value)?r.value:Object.entries(r.value);if(s.length<=t)continue;o=!0;let a=Array.isArray(r.value)?s.slice(0,t):Object.fromEntries(s.slice(0,t));n=j(n,r.path,a)}return{result:n,truncated: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]="642f6dec-c0b2-5377-a401-dfa4f8ef6a2a")}catch{}})();var F=256,B=1e4,st=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u,it=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u,at=new Set(["version","id","token_budget","spent_tokens","seen_item_ids"]),ut=[{valid:e=>e.version===1,reason:"version must equal 1."},{valid:e=>typeof e.id=="string"&&st.test(e.id),reason:"id must be 1-64 portable identifier characters."},{valid:e=>Number.isSafeInteger(e.token_budget)&&e.token_budget>=F,reason:`token_budget must be a safe integer of at least ${F}.`},{valid:e=>Number.isSafeInteger(e.spent_tokens)&&e.spent_tokens>=0&&e.spent_tokens<=e.token_budget,reason:"spent_tokens must be a non-negative safe integer no larger than token_budget."},{valid:e=>Array.isArray(e.seen_item_ids)&&e.seen_item_ids.length<=B&&e.seen_item_ids.every(t=>typeof t=="string"&&it.test(t)),reason:`seen_item_ids must contain at most ${B} portable item identifiers.`}];function v(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function N(e){throw new _(`--output-session ${e}`,p.USAGE,{code:"invalid_read_output_session",field:"outputSession"})}function C(e){if(e===void 0)return;let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{N("must be a valid JSON object.")}v(t)||N("must be a JSON object.");let n=Object.keys(t).filter(s=>!at.has(s));n.length>0&&N(`contains unknown field "${n.sort()[0]}".`);let o=ut.find(s=>!s.valid(t));o!==void 0&&N(o.reason);let r=[...new Set(t.seen_item_ids)].sort();return{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:r}}function me(e){if(v(e))return typeof e.id=="string"?e.id:typeof e.item_id=="string"?e.item_id:v(e.item)&&typeof e.item.id=="string"?e.item.id:void 0}function ct(e){let t=new Set,n=0;for(let o of g(e)){let r=Array.isArray(o.value)?o.value:Object.values(o.value);for(let s of r){if(!v(s))continue;if(typeof s.context_ref=="string"){n+=1;continue}let a=me(s);a!==void 0&&t.add(a)}}return{deliveredIds:t,suppressedRepeatCount:n}}function ge(e,t){let n=new Set(t.seen_item_ids);return A(e,o=>{let r=me(o);return r!==void 0&&n.has(r)?{id:r,context_ref:`session:${t.id}:${r}`}:o})}function G(e,t){let{deliveredIds:n,suppressedRepeatCount:o}=ct(e),r=new Set(t.seen_item_ids),s=[...n].filter(m=>!r.has(m)).sort(),a=s.slice(0,B-t.seen_item_ids.length),i=[...t.seen_item_ids,...a].sort(),u=s.length-a.length,c={contract_version:1,id:t.id,measurement_scope:"complete_read_envelope",estimator:"ceil(utf8_bytes / 4)",token_budget:t.token_budget,spent_before_tokens:t.spent_tokens,spent_this_call_tokens:0,charged_this_call_tokens:0,spent_total_tokens:t.spent_tokens,remaining_tokens:t.token_budget-t.spent_tokens,exhausted:!1,seen_before_count:t.seen_item_ids.length,new_item_count:n.size,...u===0?{}:{seen_item_overflow_count:u},suppressed_repeat_count:o,reference_format:"session:<session-id>:<item-id>",restore_reference_with:"pm get <item-id> --brief",next_state:{version:1,id:t.id,token_budget:t.token_budget,spent_tokens:t.spent_tokens,seen_item_ids:i}},f={...e,read_session:c},d=m=>{c.spent_this_call_tokens=m,c.charged_this_call_tokens=Math.min(t.token_budget-t.spent_tokens,m),c.spent_total_tokens=Math.min(t.token_budget,t.spent_tokens+c.charged_this_call_tokens),c.remaining_tokens=Math.max(0,t.token_budget-c.spent_total_tokens),c.exhausted=c.remaining_tokens<F,c.next_state.spent_tokens=c.spent_total_tokens},y=0,l=0;for(let m=0;m<8;m+=1){d(y);let k=Math.ceil(Buffer.byteLength(JSON.stringify(f),"utf8")/4);if(k===y)return f;l=Math.max(l,k),y=k}return d(l),f}function ye(e){return Math.max(0,e.token_budget-e.spent_tokens)}(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]="23b3a820-f205-506b-9507-dbd60087f62e")}catch{}})();var dt=["full","compact","brief","summary","counts"],Eo=["mutation","read","discovery","governance"],lt=new Set(["append","claim","close","close-many","close-task","comments","config","copy","create","delete","docs","event","files","focus","history-author-acknowledge","history-compact","history-redact","history-repair","init","item","learnings","meet","notes","pause-task","release","remind","restore","schema","start-task","update","update-many"]),ft=new Set(["contracts","extension","help","install","package","packages","profile","upgrade"]),_t=new Set(["gc","health","merge","stats","telemetry","test","test-all","validate"]),pt={mutation:2e3,read:4e3,discovery:3e3,governance:6e3},mt=3,gt=2;function yt(e){let[t=""]=e.trim().split(/\s+/u);return lt.has(t)?"mutation":ft.has(t)?"discovery":_t.has(t)?"governance":"read"}function he(e,t=yt(e)){let n=e.trim().replace(/\s+/gu," ");if(n.length===0)throw new TypeError("command must be a non-empty command path");let o=pt[t];return ht({command:n,budget_class:t,default_max_estimated_tokens:o,default_max_estimated_tokens_by_format:{toon:o,json:Math.ceil(o*mt/gt)},degradation_ladder:dt,allows_unbounded_opt_out:!0,token_estimate:"ceil(utf8_bytes / 4)"})}function ht(e){if(!Number.isSafeInteger(e.default_max_estimated_tokens)||e.default_max_estimated_tokens<=0)throw new RangeError("default_max_estimated_tokens must be a positive safe integer");for(let[t,n]of Object.entries(e.default_max_estimated_tokens_by_format))if(!Number.isSafeInteger(n)||n<=0)throw new RangeError(`default_max_estimated_tokens_by_format.${t} must be a positive safe integer`);return e}var Et=R.map(e=>he(e)),bt=new Map(Et.map(e=>[e.command,e]));function Ee(e,t={}){let n=e.trim().replace(/\s+/gu," "),[o]=n.split(" "),r=bt.get(o);return r?{...r,command:n}:t.generateFallback?he(n):null}function bo(e){return Math.ceil(Math.max(0,e)/4)}import{createHash as _n}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]="737ac274-c165-5d1a-8b8e-cb5d57a81c46")}catch{}})();var Ot=8,St=64;function K(e){return Math.ceil(Buffer.byteLength(JSON.stringify(e),"utf8")/4)}function At(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function z(e,t){return typeof e=="string"?e.length<=240?e:(t.compacted=!0,`${e.slice(0,240)}\u2026`):Array.isArray(e)?e.map(n=>z(n,t)):At(e)?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,z(o,t)])):e}function E(e,t){let n=t.estimated_tokens;for(let o=0;o<Ot;o+=1){t.estimated_tokens=n;let r=K(e);if(r===n)return;n=r}t.estimated_tokens=n}function wt(e,t,n,o){for(let r=0;r<St;r+=1){if(E(e,t),t.estimated_tokens<=n)return;let s=_e(e).filter(i=>(Array.isArray(i.value)?i.value.length:Object.keys(i.value).length)>Math.max(1,o.get(i.path)??0)).map(i=>({collection:i,length:Array.isArray(i.value)?i.value.length:Object.keys(i.value).length})).sort((i,u)=>u.length-i.length||i.collection.path.localeCompare(u.collection.path))[0]?.collection;if(!s)return;let a=Math.max(1,o.get(s.path)??0);if(Array.isArray(s.value))s.value.splice(-Math.min(s.value.length-a,Math.max(1,Math.ceil(s.value.length/2))));else{let i=Object.keys(s.value);for(let u of i.slice(-Math.min(i.length-a,Math.max(1,Math.ceil(i.length/2)))))delete s.value[u]}t.rows_compacted=!0,t.compacted_row_paths=[...new Set([...t.compacted_row_paths??[],s.path])].sort((i,u)=>i.localeCompare(u)),e.has_more=!0,e.truncated=!0,typeof e.count=="number"&&(e.count=I(e))}}function be(e,t,n,o=new Map){let r={compacted:!1},s=z(e,r);return t.strings_compacted=r.compacted,s.read_output=t,wt(s,t,n,o),E(s,t),s}import{createHash as Ut}from"node:crypto";import Tt 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]="83232698-197a-5aef-be7c-aa37f3c56822")}catch{}})();function kt(e){if(e===null)return null;if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;if(typeof e=="bigint")return e.toString();if(e===void 0)return"undefined";if(typeof e=="symbol")return e.toString();if(typeof e=="function")return`[function:${e.name||"anonymous"}]`}function Rt(e){let t=Object.keys(e).sort(),n={};for(let o of t){let r=e[o];r!==void 0&&(n[o]=D(r))}return n}function D(e){let t=kt(e);if(t!==void 0)return t;if(Array.isArray(e))return e.map(o=>D(o));if(e instanceof Date)return e.toISOString();let n=e;if(typeof n.toJSON=="function"){let o=n.toJSON();if(o!==e)return D(o)}return Rt(e)}function Oe(e){return JSON.stringify(D(e))}function Se(e,t,n,o){for(let r=0;r<t.length;r+=1)if(!n.has(r)&&o(e,t[r]))return n.add(r),!0;return!1}function xt(e,t){if(e instanceof RegExp||t instanceof RegExp)return e instanceof RegExp&&t instanceof RegExp&&e.toString()===t.toString()}function It(e,t){if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Nt(e,t){if(!(e instanceof Set||t instanceof Set))return;if(!(e instanceof Set&&t instanceof Set)||e.size!==t.size)return!1;let n=[...t],o=new Set;for(let r of e)if(!Se(r,n,o,w))return!1;return!0}function vt(e,t){if(!(e instanceof Map||t instanceof Map))return;if(!(e instanceof Map&&t instanceof Map)||e.size!==t.size)return!1;let n=[...t.entries()],o=new Set;for(let[r,s]of e.entries())if(!Se([r,s],n,o,([i,u],[c,f])=>w(i,c)&&w(u,f)))return!1;return!0}function Ct(e,t){if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((n,o)=>w(n,t[o]))}function Dt(e,t){let n=Object.keys(e).sort((r,s)=>r.localeCompare(s)),o=Object.keys(t).sort((r,s)=>r.localeCompare(s));if(n.length!==o.length)return!1;for(let r=0;r<n.length;r+=1){let s=n[r];if(s!==o[r]||!w(e[s],t[s]))return!1}return!0}var Mt=[xt,It,Nt,vt,Ct];function w(e,t){if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;for(let n of Mt){let o=n(e,t);if(o!==void 0)return o}return Dt(e,t)}function To(e){return Tt.createHash("sha256").update(e,"utf8").digest("hex")}function ko(e,t){let n={};for(let r of t){let s=e[r];s!==void 0&&(n[r]=s)}let o=Object.keys(e).filter(r=>!t.includes(r)).sort((r,s)=>r.localeCompare(s));for(let r of o){let s=e[r];s!==void 0&&(n[r]=s)}return n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d3329fac-693d-566c-a30a-43f8fb37938f")}catch{}})();var $=1,we=4096,Lt=/^[A-Za-z0-9_-]+$/;function Ae(e){return e.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(t,n)=>n.toUpperCase())}function Co(e,t){let n=new Set;for(let o of t)if(o.cursor_semantics==="presentation"){n.add(Ae(o.flag));for(let r of o.aliases??[])n.add(Ae(r))}return Object.fromEntries(Object.entries(e).filter(([o])=>!n.has(o)))}function Do(e,t){return Ut("sha256").update(e).update("\0").update(Oe(t)).digest("hex").slice(0,24)}function X(e,t,n,o){return Buffer.from(JSON.stringify({version:$,fingerprint:e,after_id:t,...n===void 0?{}:{after_index:n},...o===void 0?{}:{snapshot:o}})).toString("base64url")}function b(e){return new _(e,p.USAGE,{code:"invalid_query_cursor",nextSteps:["Repeat the original query without --after to obtain a fresh cursor."]})}function Pt(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;return t.version===$&&typeof t.fingerprint=="string"&&typeof t.after_id=="string"&&t.after_id.length>0&&(t.after_index===void 0||Number.isSafeInteger(t.after_index)&&t.after_index>=0)&&(t.snapshot===void 0||typeof t.snapshot=="string"&&t.snapshot.length>0)}function Y(e){if(typeof e!="string")throw b("Query cursor is malformed.");let t=e.trim();if(t.length===0||t.length>we||!Lt.test(t))throw b("Query cursor is malformed.");let n;try{n=JSON.parse(Buffer.from(t,"base64url").toString("utf8"))}catch{throw b("Query cursor is malformed.")}if(!Pt(n))throw b("Query cursor version or payload is unsupported.");return n}function q(e,t){let n=Y(e);if(n.fingerprint!==t)throw b(`Query cursor does not match the current filters, sort, or query (${n.fingerprint} != ${t}).`);return{after_id:n.after_id,...n.after_index===void 0?{}:{after_index:n.after_index},...n.snapshot===void 0?{}:{snapshot:n.snapshot}}}function Mo(e,t){return q(e,t).after_id}function jt(e,t,n,o){if(t===void 0)return 0;let r=q(t,n),s=e.findIndex(a=>o(a)===r.after_id);if(s<0){if(r.after_index!==void 0)return Math.min(r.after_index,e.length);throw b(`Query cursor item ${r.after_id} is no longer present in this result set.`)}return s+1}function Uo(e,t){if(t.cursor!==void 0&&q(t.cursor,t.fingerprint).snapshot!==t.snapshot)throw b("Query cursor does not match the requested snapshot.");let n=jt(e,t.cursor,t.fingerprint,t.readId),o=e.slice(n,n+t.limit),r=o.length>0&&n+o.length<e.length,s=o.at(-1);return{rows:o,has_more:r,...r&&s!==void 0?{next_cursor:X(t.fingerprint,t.readId(s),n+o.length-1,t.snapshot)}:{}}}var Lo=Object.freeze({version:$,max_length:we});(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]="e9621264-0180-53cf-862f-b59640b971da")}catch{}})();var O=["include","amount","cost","encoding"],Ce=["list","context","search","get","next","health","deps","graph","history","activity","validate","events","contracts","comments","notes","files","docs","stats","aggregate","package-manage","comments-audit","assurance"],De=["canonical","legacy","intent","default"],J={include:"--output-include",amount:"--output-limit",cost:"--output-budget",encoding:"--output-format"},Xo=Object.freeze(O.map(e=>J[e])),Yo=Object.freeze(["--output-session","--output-cursor","--output-row-contract"]),Me={list:{include:["--brief","--compact","--fields","--full"],amount:["--after","--limit","--no-truncate"],cost:["--token-budget"],encoding:["--format","--stream"]},context:{include:["--fields","--section"],amount:["--after","--depth","--limit"],cost:["--token-budget"],encoding:["--format"]},search:{include:["--compact","--fields","--full"],amount:["--after","--limit"],cost:["--token-budget"],encoding:["--format"]},get:{include:["--fields","--full"],amount:["--depth"],cost:["--token-budget"],encoding:["--format"]},next:{amount:["--blocked-limit","--limit"],cost:["--token-budget"],encoding:["--format"]},health:{include:["--brief","--check-only","--full","--summary"]},deps:{include:["--collapse","--full","--summary"],amount:["--edge-limit","--max-depth","--node-limit"],cost:["--token-budget"],encoding:["--format"]},graph:{include:["--full","--summary"],amount:["--after","--limit","--max-depth","--max-paths"]},history:{include:["--compact","--full"],amount:["--limit"],encoding:["--format"]},activity:{include:["--compact","--full"],amount:["--limit","--unbounded"],encoding:["--stream"]},validate:{include:["--counts","--full"]},events:{include:["--full"],amount:["--limit"],encoding:["--follow"]},contracts:{include:["--full","--summary"]},comments:{amount:["--limit"]},notes:{amount:["--limit"]},files:{amount:["--limit","--no-truncate","--offset"]},docs:{},stats:{},aggregate:{},"package-manage":{},"comments-audit":{},assurance:{}},Ue=new Set(["--collapse","--fields","--section"]),Z=Object.freeze({"--after":"--after retains cursor-position semantics; use --output-limit <n> separately to bound returned rows.","--check-only":"--check-only retains health side-effect semantics; --output-include does not suppress vector refresh.","--collapse":"--collapse retains dependency grouping semantics; --output-include does not replace it.","--depth":"--depth retains traversal or detail-depth semantics; --output-limit does not replace it.","--follow":"--follow retains event-tail semantics; --output-format does not enable following.","--max-depth":"--max-depth retains graph traversal-depth semantics; --output-limit does not replace it.","--max-paths":"--max-paths retains graph path-search semantics; use --output-limit separately to bound returned rows.","--no-truncate":"--no-truncate is a compatibility alias; prefer --output-limit unbounded.","--offset":"--offset retains positional pagination semantics; use --output-limit separately to bound returned rows.","--stream":"--stream retains command streaming semantics; --output-format selects only static result encoding.","--unbounded":"--unbounded is a compatibility alias; prefer --output-limit unbounded."});function ee(e){return e.slice(2).replaceAll("-","_")}function Vt(e,t){let n=Z[e];if(n!==void 0)return n;let o=t==="include"?Ue.has(e)?"<csv>":ee(e):t==="amount"?"<n>":t==="cost"?"<tokens>":"<toon|json>";return`${e} is a compatibility alias; prefer ${J[t]} ${o}.`}function Ft(e){let t=Me[e],n=Object.freeze(Object.fromEntries(O.map(o=>[o,Object.freeze({dimension:o,canonical_option:J[o],applicable:!0,inapplicable_reason:null,legacy_aliases:Object.freeze((t[o]??[]).map(r=>Object.freeze({flag:r,semantics:Z[r]===void 0?"replacement":"behavior_preserving",migration_hint:Vt(r,o),visibility:"hidden_alias"})))})])));return Object.freeze({command:e,dimensions:n,precedence:De,budget_retention_policy:e==="assurance"?"verdict_priority":"ordered_prefix"})}var Bt=Object.freeze(Ce.map(Ft)),Gt=new Map(Bt.map(e=>[e.command,e]));function T(e){let t=e.trim().toLowerCase().replaceAll(/\s+/gu," "),n=t==="package manage"||t==="package-manage"?"package-manage":t.split(" ")[0],o=n.startsWith("list-")?"list":n==="ctx"?"context":n;return Ce.includes(o)?o:void 0}var zt=["outputInclude","output_include","outputLimit","output_limit","outputBudget","output_budget","outputFormat","output_format","outputSession","output_session","outputCursor","output_cursor","outputRowContract","output_row_contract"],Kt={comments:["add","body","stdin","file","edit","delete"],notes:["add","addJson","stdin","file","edit","delete"],files:["add","addGlob","remove","migrate","apply","note"],docs:["add","addGlob","remove","migrate","note"]};function $t(e){return zt.some(t=>e[t]!==void 0)}var Xt=[{keys:["outputInclude","output_include"],valid:e=>M(e)!==void 0,message:"--output-include requires at least one comma-separated field or section."},{keys:["outputLimit","output_limit"],valid:e=>e==="unbounded"||S(e)!==void 0,message:"--output-limit must be a positive integer or unbounded."},{keys:["outputBudget","output_budget"],valid:e=>e==="unbounded"||S(e)!==void 0,message:"--output-budget must be a positive integer or unbounded."},{keys:["outputFormat","output_format"],valid:e=>e==="toon"||e==="json",message:"--output-format must be toon or json."},{keys:["outputSession","output_session"],valid:e=>(C(e),!0),message:"--output-session must be a valid session-state object."},{keys:["outputCursor","output_cursor"],valid:e=>typeof e=="string"&&e.trim().length>0,message:"--output-cursor requires a non-empty continuation cursor."}];function qo(e,t){if(!$t(t))return;let n=T(e);if(!n)throw new _(`Universal output controls apply only to read commands; ${e||"this command"} is not a read surface.`,p.USAGE);if((Kt[n]??[]).some(o=>t[o]!==void 0&&t[o]!==!1))throw new _(`Universal output controls cannot be combined with a ${n} mutation.`,p.USAGE);for(let o of Xt){let r=o.keys.map(s=>t[s]).find(s=>s!==void 0);if(r!==void 0&&!o.valid(r))throw new _(o.message,p.USAGE)}}function Le(e){let t=T(e);return t?new Map((Me[t].include??[]).filter(n=>!Ue.has(n)&&Z[n]===void 0).map(n=>[ee(n),Pe(n)])):new Map}function Yt(e,t,n){let o=M(t)??[],r=Le(e),s=[],a=[];for(let i of o){let u=r.get(i);if(u===void 0){s.push(i);continue}n[u]=!0,a.push(i)}return{selectors:s,modes:a}}function Wo(e,t){let n=t.outputInclude??t.output_include;if(n===void 0)return;let{selectors:o,modes:r}=Yt(e,n,t);if(r.length===0)return;let s=o.length>0?o.join(","):void 0;t.outputInclude=s,Object.hasOwn(t,"output_include")&&(t.output_include=s)}function Pe(e){return e.slice(2).replace(/-([a-z])/gu,(t,n)=>n.toUpperCase())}function qt(e,t){let n=Pe(t);if(Object.hasOwn(e,n))return e[n];let o=t.slice(2).replaceAll("-","_");if(Object.hasOwn(e,o))return e[o];if(t==="--no-truncate"&&e.truncate===!1)return!0}function Wt(e){return e!==void 0&&e!==!1&&e!==null}function M(e){let n=(Array.isArray(e)?e:[e]).flatMap(o=>typeof o=="string"?o.split(","):[]).map(o=>o.trim()).filter(Boolean);return n.length>0?[...new Set(n)]:void 0}function S(e){let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/u.test(e.trim())?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:void 0}function Qt(e,t,n){for(let o of e.legacy_aliases){let r=qt(t,o.flag),s={value:r,flag:o.flag};if(Wt(r)&&n(s))return s}}function Te(e,t){let n=M(e);if(n)return{source:"canonical",value:n};if(t)return{source:"legacy",value:M(t.value)??[ee(t.flag)]}}function ke(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=S(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;if(t.flag==="--no-truncate"||t.flag==="--unbounded")return{source:"legacy",value:"unbounded"};let o=S(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function Re(e,t){if(e==="unbounded")return{source:"canonical",value:"unbounded"};let n=S(e);if(n!==void 0)return{source:"canonical",value:n};if(!t)return;let o=S(t.value);return o===void 0?void 0:{source:"legacy",value:o}}function xe(e,t){if(e==="json"||e==="toon")return{source:"canonical",value:e};if(t)return t.flag==="--stream"||t.flag==="--follow"?{source:"legacy",value:"stream"}:t.value==="json"||t.value==="toon"?{source:"legacy",value:t.value}:void 0}function je(e,t){let n=T(e);if(!n)return;let o=Gt.get(n),r={include:l=>Te(void 0,l),amount:l=>ke(void 0,l),cost:l=>Re(void 0,l),encoding:l=>xe(void 0,l)},s=Object.fromEntries(O.map(l=>[l,Qt(o.dimensions[l],t,m=>r[l](m)!==void 0)])),a=O.flatMap(l=>{let m=s[l];return m?[m.flag]:[]}),i=O.flatMap(l=>{let m=s[l];return m?[o.dimensions[l].legacy_aliases.find(Fe=>Fe.flag===m.flag).migration_hint]:[]}),u=xe(t.outputFormat??t.output_format,s.encoding),c=Re(t.outputBudget??t.output_budget,s.cost),f=e.trim().toLowerCase().replaceAll(/\s+/gu," ").split(" ")[0]==="list-all"||s.amount?.flag==="--no-truncate"||s.include?.flag==="--full",d=Ee(e,{generateFallback:!0}),y=u?.value==="json"||t.resolvedOutputFormat==="json"?"json":"toon";return{command:n,include:Te(t.outputInclude??t.output_include,s.include),amount:ke(t.outputLimit??t.output_limit,s.amount),cost:c??(f?{source:"intent",value:"unbounded"}:{source:"default",value:d.default_max_estimated_tokens_by_format[y]}),encoding:u,legacy_aliases_used:a,migration_hints:i,precedence:De}}function h(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var te=new Set(["applied_bound","applied_limit","completeness","continuation_kind","continuation_path","continuation_contract","count","filters","has_more","next_cursor","now","omission_receipt","projection","budget_retention_policy","row_contract","sorting","total","truncated"]),Ht=["collection_counts","notes_count","tests_count"];function Ve(e,t){let n=new Set(t.map(o=>o.split(".")[0]));return Object.fromEntries(Object.entries(e).filter(([o])=>n.has(o)))}function Jt(e){let t=h(e.item)?e.item:{},n=[...new Set([...Object.keys(t),...Ht.filter(r=>Object.hasOwn(t,r))])].sort((r,s)=>r.localeCompare(s)),o=Object.keys(e).filter(r=>r!=="item"&&r!=="read_output"&&!te.has(r)).sort((r,s)=>r.localeCompare(s));return{item:t,itemFields:n,sections:o,valid:[...n,"item",...n.map(r=>`item.${r}`),...o]}}function Zt(e,t){let n=Jt(e),o=t.filter(d=>!n.valid.includes(d));if(o.length>0)throw new _(`Unknown --output-include selector(s) for get: ${o.join(", ")}. Valid selectors: ${n.valid.join(", ")}.`,p.USAGE);let r=t.includes("item"),s=t.flatMap(d=>d.startsWith("item.")?[d.slice(5)]:n.itemFields.includes(d)?[d]:[]).filter((d,y,l)=>l.indexOf(d)===y);if(r&&s.length>0)throw new _("--output-include cannot mix a full item with projected item fields; use item or item.<field>, not both.",p.USAGE);let a=new Set(t.filter(d=>n.sections.includes(d))),i=Object.fromEntries(Object.entries(e).filter(([d])=>te.has(d)||a.has(d)));r?i.item=n.item:s.length>0&&(i.item=Ve(n.item,s));let u=[...r?[]:s.length>0?n.itemFields.filter(d=>!s.includes(d)).map(d=>({name:`item.${d}`,restore_with:`--output-include item.${d}`})):[{name:"item",restore_with:"--output-include item"}],...n.sections.filter(d=>!a.has(d)).map(d=>({name:d,restore_with:`--output-include ${d}`}))],f=[...h(i.omission_receipt)&&Array.isArray(i.omission_receipt.omitted_field_groups)?i.omission_receipt.omitted_field_groups:[],...u];return i.omission_receipt={has_omissions:f.length>0,omitted_field_group_count:f.length,omitted_field_groups:f},i}function Ie(e){let t=0;return A({...e},n=>(h(n)&&Object.keys(n).length>0&&(t+=1),n)),t}function en(e,t,n,o){if(Ie(t)===0||Ie(n)>0)return;let r=[...Le(e).keys()],s=r.length>0?` Declared ${e} projection modes: ${r.join(", ")}.`:` The ${e} surface declares no projection modes; name row fields instead.`;throw new _(`Unknown --output-include selector(s) for ${e}: ${o.join(", ")}. No selector matched any returned row field.${s}`,p.USAGE)}function tn(e,t,n){if(e==="get")return Zt(t,n);let o=V(t),r=n.flatMap(a=>o.flatMap(i=>a.startsWith(`${i}.`)?[a.slice(i.length+1)]:[])),s=n.some(a=>Object.hasOwn(t,a.split(".")[0])&&!o.some(i=>a.startsWith(`${i}.`)));if(o.length>0&&(!s||r.length>0)){let a={...t},i=r.length>0?r:n,u=A(a,c=>h(c)?Ve(c,i):c);return en(e,t,u,i),u}return Object.fromEntries(Object.entries(t).filter(([a])=>n.some(i=>i.split(".")[0]===a)||te.has(a)))}function nn(e,t){if(t==="unbounded")return e;let{result:n,truncated:o}=pe(e,t);return o&&(n.has_more=!0,n.truncated=!0,typeof n.count=="number"&&(n.count=I(n)),n.applied_bound={kind:"output_limit",source:"explicit",value:t}),n}function on(e){return O.filter(t=>e[t]!==void 0&&e[t]?.source!=="default")}function U(e,t,n){let o=G(e,t);for(let r=0;r<8;r+=1){let s=n.estimated_tokens,a=o.read_session.spent_this_call_tokens;E(o,n),o=G(o,t);let i=o.read_session.spent_this_call_tokens;if(n.estimated_tokens===s&&i===a)return o}return o}function Qo(e,t){if(!h(e.read_output))return e;let n=e.read_output,o=C(t.outputSession??t.output_session);return o===void 0?(E(e,n),e):U(e,o,n)}function rn(e,t,n,o){let r={...e};return t.include?.source==="canonical"&&(r=tn(t.command,r,t.include.value)),t.command==="assurance"&&(r=Ne(r)),r=ve(r,t.command,o),t.amount?.source==="canonical"&&(r=nn(r,t.amount.value)),n===void 0?r:ge(r,n)}function sn(e,t){return[...e.cost!==void 0&&e.cost.value!=="unbounded"&&(e.cost.source==="canonical"||e.cost.source==="default")?[{source:e.cost.source,tokens:e.cost.value}]:[],...t===void 0?[]:[{source:"session",tokens:ye(t)}]].sort((o,r)=>o.tokens-r.tokens)[0]}function an(e,t,n,o,r){let s={contract_version:1,command:e.command,requested_dimensions:t,...o.source==="default"?{budget_source:o.source,budget_tokens:o.tokens}:{},precedence:e.precedence,legacy_aliases_used:[],migration_hints:[],estimated_tokens:0,within_budget:!1,strings_compacted:!1,rows_compacted:!1,result_omitted:!0,...n===void 0?{omitted_result_estimated_tokens:r}:{}},a={output_budget_exceeded:{omitted_result:!0,reason:"requested_budget_infeasible",restore_with:"Unbounded",recovery:{outputBudget:"unbounded"}},read_output:s},i=n===void 0?a:U(a,n,s);if(n===void 0&&E(i,s),n!==void 0&&s.estimated_tokens>o.tokens)throw new _("The remaining output-session budget cannot fit its mandatory receipts; start a new session with a larger token_budget.",p.USAGE);return i}function un(e,t,n,o){if(n!==void 0)return!1;let r=t.filter(s=>e[s]?.source==="canonical").length;return e.cost?.value==="unbounded"?r===(e.cost.source==="canonical"?1:0):e.cost?.source==="legacy"&&r===0?!0:r===0&&(e.cost===void 0||K(o)<=e.cost.value)}function cn(e,t,n,o,r,s){if(!n.rows_compacted)return;let a=t.amount?.value==="unbounded"?["amount"]:[],i=new Map(g(e).map(f=>[f.path,Array.isArray(f.value)?f.value.length:Object.keys(f.value).length])),u=[...s.entries()].flatMap(([f,d])=>{let y=i.get(f);if(y>=d.rows)return[];let l=d.baseOffset+y;return[{path:f,cursor:Q({command:t.command,path:f,offset:l,total_rows:d.totalRows,fingerprint:d.fingerprint}),retained_rows:y,remaining_rows:d.totalRows-l,total_rows:d.totalRows}]}),c=u[0];c&&typeof e.next_cursor!="string"&&(e.next_cursor=c.cursor),e.continuation_kind=r?"producer_cursor":c?"output_cursor":"none",e.output_budget_truncation={reason:"output_budget_reached",budget_source:o.source,budget_tokens:o.tokens,overridden_dimensions:a,compacted_row_paths:n.compacted_row_paths,continuation_cursor_rebased:r,continuation_available:u.length>0,recovery_budget_multiplier:1,continuations:u,restore_with:c?"Use recovery binding.":"Increase --output-budget because no declared row collection can be continued.",recovery:c?{cursor:c.cursor,cli:"--output-cursor",sdk:"outputCursor",mcp:"outputCursor"}:{cli:"--output-budget 1200",sdk:{outputBudget:1200},mcp:{outputBudget:1200}}}}function dn(e,t,n,o){if(typeof n!="string"||!Array.isArray(e.items))return!1;let r=e.items.length;if(r===0||r>=t)return!1;let s;try{s=Y(n)}catch{return!1}let a=s.after_index;if(a===void 0)return!1;let i=e.items.at(-1);if(Object.prototype.toString.call(i)!=="[object Object]")return!1;let u=Reflect.get(i,"id");if(typeof u!="string"||u.length===0)return!1;let c=o?a-(t-r):a+r;return c<0?!1:(e.next_cursor=X(s.fingerprint,u,c,s.snapshot),typeof e.applied_limit=="number"&&(e.applied_limit=r),!0)}function ln(e,t,n){let o=new Map(g(e).map(s=>{let a=Array.isArray(s.value)?s.value.length:Object.keys(s.value).length,i=t?.path===s.path;return[s.path,{rows:a,totalRows:i?t.total_rows:a,baseOffset:i?t.offset:0,fingerprint:i?t.fingerprint:W(s.path,s.value)}]})),r=typeof e.next_cursor=="string";return{collectionsBeforeBudget:o,originalItemCount:Array.isArray(e.items)?e.items.length:0,cursorContinuesExistingPage:r,cursorSource:r?e.next_cursor:n.after}}function fn(e,t,n,o,r,s){let a=t.command==="assurance"&&Array.isArray(e.assertions)?e.assertions.filter(c=>h(c)&&c.verdict!=="pass").length:0,i=be(e,n,o.tokens,a>0?new Map([["assertions",a]]):new Map),u=dn(i,s.originalItemCount,s.cursorSource,s.cursorContinuesExistingPage);return cn(i,t,n,o,u,s.collectionsBeforeBudget),r!==void 0&&(i=U(i,r,n)),i}function Ho(e,t,n){let o=je(e,t);if(!o)return n;let r=C(t.outputSession??t.output_session),s=t.outputCursor??t.output_cursor,a=typeof s=="string"?H(s):void 0,i=on(o);if(a===void 0&&un(o,i,r,n))return n;let u=sn(o,r),c=rn(n,o,r,a),f=ln(c,a,t),d={contract_version:1,command:o.command,requested_dimensions:i,...u?.source==="default"?{budget_source:u.source,budget_tokens:u.tokens}:{},precedence:o.precedence,legacy_aliases_used:o.legacy_aliases_used,migration_hints:o.migration_hints,estimated_tokens:0,within_budget:!0,strings_compacted:!1,rows_compacted:!1,result_omitted:!1};return c.read_output=d,c=r===void 0?c:U(c,r,d),E(c,d),u!==void 0&&d.estimated_tokens>u.tokens&&(c=fn(c,o,d,u,r,f)),u!==void 0&&d.estimated_tokens>u.tokens?an(o,i,r,u,d.estimated_tokens):c}function Jo(e){return h(e)&&h(e.output_budget_exceeded)&&e.output_budget_exceeded.omitted_result===!0&&e.output_budget_exceeded.reason==="requested_budget_infeasible"}function Zo(e,t){let n=je(e,t)?.encoding;return n?.value==="json"||n?.value==="toon"?n.value:void 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]="8e523bbc-5745-514e-a1d8-a6ad6ece001a")}catch{}})();var pn=4096;function ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function W(e,t){let n=Array.isArray(t)?t.map((o,r)=>{if(!ne(o))return`index:${String(r)}`;for(let s of["id","assertion_id","measurement_id","event_id"]){let a=o[s];if(typeof a=="string"&&a.length>0)return`${s}:${a}`}return`index:${String(r)}`}):Object.keys(t);return _n("sha256").update(JSON.stringify({path:e,identities:n})).digest("base64url").slice(0,16)}function Q(e){return Buffer.from(JSON.stringify({v:1,c:e.command,p:e.path,o:e.offset,n:e.total_rows,f:e.fingerprint}),"utf8").toString("base64url")}function H(e){if(e.length>pn)throw new _("The read-output continuation cursor is malformed or unsupported.",p.USAGE,{code:"read_output_cursor_invalid"});let t;try{t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{t=null}if(!ne(t)||t.v!==1||T(String(t.c??""))!==t.c||typeof t.p!="string"||t.p.length===0||!Number.isSafeInteger(t.o)||t.o<0||!Number.isSafeInteger(t.n)||t.n<1||typeof t.f!="string"||t.f.length===0)throw new _("The read-output continuation cursor is malformed or unsupported.",p.USAGE,{code:"read_output_cursor_invalid"});return{version:1,command:t.c,path:t.p,offset:t.o,total_rows:t.n,fingerprint:t.f}}function Ne(e){if(!Array.isArray(e.assertions))return e;let t=n=>!ne(n)||n.verdict==="pass"?4:n.verdict==="retired"?3:n.enforcement==="block"?0:n.enforcement==="warn"?1:2;return{...e,assertions:e.assertions.map((n,o)=>({row:n,index:o})).sort((n,o)=>t(n.row)-t(o.row)||n.index-o.index).map(({row:n})=>n),budget_retention_policy:"verdict_priority"}}function ve(e,t,n){if(!n)return e;if(n.command!==t)throw new _(`The read-output cursor belongs to ${n.command}, not ${t}.`,p.USAGE,{code:"read_output_cursor_command_mismatch"});let o=g(e).find(s=>s.path===n.path),r=o?Array.isArray(o.value)?o.value.length:Object.keys(o.value).length:0;if(!o||r!==n.total_rows||n.offset>r||W(n.path,o.value)!==n.fingerprint)throw new _("The read-output continuation no longer matches the declared row collection; restart the bounded read.",p.USAGE,{code:"read_output_cursor_stale"});return fe(e,n.path,n.offset)}(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]="f6e82c93-54e8-53a7-94df-10a573aae933")}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]="08ee7e43-8811-57ed-8bfe-0345ee5d3308")}catch{}})();var mn=Object.freeze([{flag:"--json"},{flag:"--lean"},{flag:"--token-accounting"},{flag:"--output-include",value_name:"fields"},{flag:"--output-limit",value_name:"count"},{flag:"--output-budget",value_name:"tokens"},{flag:"--output-format",value_name:"toon|json"},{flag:"--output-session",value_name:"state"},{flag:"--output-cursor",value_name:"cursor"},{flag:"--output-row-contract"},{flag:"--quiet"},{flag:"--no-changed-fields"},{flag:"--full-changed-fields"},{flag:"--id-only"},{flag:"--pm-path",aliases:["--path"]},{flag:"--no-extensions"},{flag:"--no-pager"},{flag:"--profile"},{flag:"--help"},{flag:"--author",value_name:"id"}]),dr=new Set(mn.flatMap(e=>[e.flag,...e.aliases??[]]));export{L as a,Be as b,Ge as c,gn as d,oe as e,re as f,se as g,yn as h,ie as i,ae as j,ue as k,ze as l,En as m,bn as n,On as o,Sn as p,An as q,wn as r,Tn as s,kn as t,Rn as u,xn as v,In as w,Nn as x,vn as y,Cn as z,Dn as A,Mn as B,Un as C,Ke as D,Ln as E,Pn as F,jn as G,Vn as H,Fn as I,Bn as J,Gn as K,$e as L,Xe as M,$n as N,Xn as O,Ye as P,Yn as Q,qn as R,Wn as S,Qe as T,He as U,P as V,Qn as W,Hn as X,p as Y,_ as Z,mn as _,dr as $,Oe as aa,w as ba,To as ca,ko as da,Je as ea,Ze as fa,et as ga,no as ha,oo as ia,tt as ja,R as ka,ro as la,nt as ma,de as na,le as oa,so as pa,io as qa,ao as ra,uo as sa,co as ta,lo as ua,B as va,C as wa,ge as xa,G as ya,ye as za,dt as Aa,Eo as Ba,yt as Ca,he as Da,ht as Ea,Et as Fa,Ee as Ga,bo as Ha,Q as Ia,H as Ja,Co as Ka,Do as La,X as Ma,Y as Na,q as Oa,Mo as Pa,jt as Qa,Uo as Ra,Lo as Sa,O as Ta,Ce as Ua,Xo as Va,Yo as Wa,Bt as Xa,T as Ya,qo as Za,Le as _a,Yt as $a,Wo as ab,je as bb,Qo as cb,Ho as db,Jo as eb,Zo as fb};
2
+ //# sourceMappingURL=chunk-725JSCMP.js.map
@@ -1,4 +1,4 @@
1
- import{$ as At,Ea as Ct,Ka as vt,V as R,Ya as se,Za as M,_ as It,_a as ae,db as ce,hb as Ue,ia as K,l as Pe,lb as Ve,na as ze,o as ie,oa as $e,ob as qe,pb as je,qa as Fe,rb as de}from"./chunk-PGXJQLCT.js";import{F as U,L as oe,N as Re,O as Me,P as ke,Q as St,Ra as Oe,U as g,W,X as V,Y as b,_ as xt,a as Le,p as F,r as G,s as S,t as T,v as ne}from"./chunk-K7RWWOAG.js";import{R as De,Y as f,Z as m,ba as Ne}from"./chunk-Q4YY3XNF.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function en(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var tn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,rn=/\bnpm_[A-Za-z0-9]{36}\b/,nn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,on=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,sn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Lt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,an=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],Ye=new Map(an.map(e=>[e.action,e]));function cn(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function He(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>He(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>He(o,`${t}.${n}`,r)))}function Dt(e){let t=[];for(let r of He(e)){tn.test(r.value)&&t.push({rule:"github_token",path:r.path}),rn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),nn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),on.test(r.value)&&t.push({rule:"private_key",path:r.path}),sn.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Lt.lastIndex=0;for(let n of r.value.matchAll(Lt)){let o=n[1];if(cn(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function dn(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=Dt(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function ln(e){return Ye.has(e.trim().toLowerCase())}function un(){return[...Ye.keys()].sort((e,t)=>e.localeCompare(t))}function la(e){return Ye.get(e.trim().toLowerCase())}(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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function fn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function fa(e){return fn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Q(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var mn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function le(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function J(e){return[...new Set(le(e).match(/[\p{L}\p{N}]+/gu)??[])]}function X(e){let t=le(e);return{normalized:t,tokens:J(t),issueCodes:[...new Set(t.match(mn)?.map(r=>r.toLowerCase())??[])]}}function ue(e,t){return fe(X(e),X(t))}function fe(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:Q(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pn 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]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function me(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _n(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function Rt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=me(t.in_progress_status),i=[];for(let s of e){if(me(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_n(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function hn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>me(String(o.status))===me(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Fe(pn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Rt(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as gn,readFile as yn}from"node:fs/promises";import Mt 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]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function wn(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function En(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function kt(e,t){return Mt.join(e,"checkpoints",t)}function Nt(e,t,r){return Mt.join(kt(e,t),`${r}.json`)}async function bn(e,t,r,n){let o=kt(e,t);await gn(o,{recursive:!0});let i=Nt(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
1
+ import{$ as At,$a as ae,Ea as Ct,Ka as vt,V as R,Za as se,_ as It,_a as M,eb as ce,ia as K,ib as Ue,l as Pe,mb as Ve,na as ze,o as ie,oa as $e,pb as qe,qa as Fe,qb as je,sb as de}from"./chunk-5NMFSX26.js";import{F as U,L as oe,N as Re,O as Me,P as ke,Q as St,Ra as Oe,U as g,W,X as V,Y as b,_ as xt,a as Le,p as F,r as G,s as S,t as T,v as ne}from"./chunk-QYZERYR5.js";import{R as De,Y as f,Z as m,ba as Ne}from"./chunk-725JSCMP.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function en(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new m(`${t} must be a non-negative number`,f.USAGE);return Math.floor(r)}(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var tn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,rn=/\bnpm_[A-Za-z0-9]{36}\b/,nn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,on=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,sn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,Lt=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,an=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],Ye=new Map(an.map(e=>[e.action,e]));function cn(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function He(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>He(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>He(o,`${t}.${n}`,r)))}function Dt(e){let t=[];for(let r of He(e)){tn.test(r.value)&&t.push({rule:"github_token",path:r.path}),rn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),nn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),on.test(r.value)&&t.push({rule:"private_key",path:r.path}),sn.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),Lt.lastIndex=0;for(let n of r.value.matchAll(Lt)){let o=n[1];if(cn(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function dn(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new m("Mutation author is required by workspace policy.",f.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=Dt(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new m(`Mutation blocked by secret guard (${n}). No detected value was logged.`,f.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function ln(e){return Ye.has(e.trim().toLowerCase())}function un(){return[...Ye.keys()].sort((e,t)=>e.localeCompare(t))}function la(e){return Ye.get(e.trim().toLowerCase())}(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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function fn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function fa(e){return fn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function Q(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var mn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function le(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function J(e){return[...new Set(le(e).match(/[\p{L}\p{N}]+/gu)??[])]}function X(e){let t=le(e);return{normalized:t,tokens:J(t),issueCodes:[...new Set(t.match(mn)?.map(r=>r.toLowerCase())??[])]}}function ue(e,t){return fe(X(e),X(t))}function fe(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:Q(e.tokens,t.tokens),reason:"title_token_jaccard"}}import pn 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]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function me(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function _n(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function Rt(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=me(t.in_progress_status),i=[];for(let s of e){if(me(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=_n(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function hn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>me(String(o.status))===me(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await Fe(pn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),Rt(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as gn,readFile as yn}from"node:fs/promises";import Mt 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]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function wn(e){let t=e.trim();if(!t)throw new m("--rollback requires a non-empty checkpoint ID",f.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new m("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",f.USAGE);return t}function En(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function kt(e,t){return Mt.join(e,"checkpoints",t)}function Nt(e,t,r){return Mt.join(kt(e,t),`${r}.json`)}async function bn(e,t,r,n){let o=kt(e,t);await gn(o,{recursive:!0});let i=Nt(e,t,r);return await T(i,`${JSON.stringify(n,null,2)}
2
2
  `),i}function Tn(e,t){if(!Array.isArray(e.items))throw new m(`Checkpoint ${t} is missing items`,f.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new m(`Checkpoint ${t} contains an invalid item entry`,f.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without ID`,f.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new m(`Checkpoint ${t} contains an item entry without target_updated_at`,f.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function Sn(e,t,r,n){let o=wn(r),i=Nt(e,t,o);if(!await F(i))throw new m(`Checkpoint ${o} not found`,f.NOT_FOUND);let s=await yn(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new m(`Checkpoint ${o} contains invalid JSON: ${b(l)}`,f.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new m(`Checkpoint ${o} is invalid`,f.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new m(`Checkpoint ${o} has unsupported schema version`,f.GENERIC_FAILURE);let d=Tn(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:R(),author:typeof c.author=="string"?c.author:"unknown"}}async function xn(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="ab276268-7a98-5f97-b3f5-300dfd1b5ed5")}catch{}})();function k(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function va(e,t){let r=k(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>k(n.definition.id)===r)??null}function In(e,t){let r=k(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(k(o.runtime_definition?.name)??k(o.definition?.name))===r)??null}function An(e,t){let r=k(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(k(o.runtime_definition?.name)??k(o.definition?.name))===r)??null}(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]="19ff592c-0746-54e8-a304-2006f4845da2")}catch{}})();function Ot(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Be(e){if(e==="/body"||e.startsWith("/body/"))return"body";if(e==="/metadata"||e.startsWith("/metadata/")||e==="/front_matter"||e.startsWith("/front_matter/")){let r=e.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];return r?Ot(r):"metadata"}let t=e.replace(/^\//,"").split("/")[0];return t?Ot(t):"root"}function pe(e,t){return t==="body"?e.body:t==="metadata"?e.metadata:t==="root"?e:e.metadata[t]}function Cn(e,t){let r=t?.windowStartIndex??0,n=t?.field;if(e.length===0||r>=e.length)return[];let o=Ct(),i=[];for(let s=0;s<e.length;s+=1){let a=e[s],c=o,d=vt(o,a.patch),l;d.ok?(l=d.document,o=l):l=c;let u=new Set;for(let p of a.patch)u.add(Be(p.path)),p.from!==void 0&&u.add(Be(p.from));let _=[...u].sort((p,h)=>p.localeCompare(h));if(s>=r)if(n!==void 0){if(!u.has(n))continue;let p={field:n,before:pe(c,n),after:pe(l,n)};i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:[n],changes:[p]})}else{let p=_.map(h=>({field:h,before:pe(c,h),after:pe(l,h)}));i.push({index:s+1,ts:a.ts,op:a.op,author:a.author,patch_ops:a.patch.length,changed_fields:_,changes:p})}}return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7426082f-94a6-5b4e-9748-d3faab2fe1d4")}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]="4a376062-2e23-5991-80a5-27183909caf3")}catch{}})();var vn=new Set(["none","null","undefined"]);function $a(e){let t=e?.trim().toLowerCase().replaceAll("-","_");if(t==="warn"||t==="strict_error")return t;if(t==="strict")return"strict_error";throw new m("Config set parent-reference-policy requires --policy with one of: warn, strict_error (alias: strict)",f.USAGE)}function Ln(e){if(typeof e!="string")throw new m("--parent must be a string. Use --unset parent to clear this field.",f.USAGE);let t=e.trim();if(t.length===0)throw new m("--parent must not be empty. Use --parent none to unset.",f.USAGE);if(Pt(t))throw new m(`--parent must not use placeholder token "${t}". Use --unset parent to clear this field.`,f.USAGE);return t}function Pt(e){return vn.has(e.trim().toLowerCase())}function Dn(e,t){if(t==="strict_error")throw new m(`Parent item "${e}" was not found. Create it first or use --parent none.`,f.USAGE);return{warnings:[`validation_warning:parent_reference_missing:${e}`]}}function Rn(e,t,r){let n=ce(e,r),o=ce(t,r);if(n!==o)return;let i=t!==o||e!==n?` (normalized from parent "${t}" and item "${e}")`:"";throw new m(`Parent item "${o}" cannot be the same as item "${n}"${i}. Use --unset parent to clear this field.`,f.USAGE)}(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]="d5003dd5-f208-5734-9711-dff935d8c851")}catch{}})();var q="-",zt=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function $t(e){let t=e.trim();if(t==="")return[];let n=(Pn(t)??t.split(",")).map(o=>o.trim()).filter(Boolean).map(o=>o.toLowerCase());return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i))}function Ft(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of $t(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function Ut(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function Mn(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function kn(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new m('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',f.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function Nn(e,t){let r=Ut(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of Ft(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function On(e,t){let r=Array.from(new Set(Ut(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(Ft(t));return n.size===0?r:r.filter(o=>!n.has(o))}function Pn(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function Ge(e){return e.replace(/\r\n/g,`
3
3
  `)}function Vt(e){let t=Ge(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
4
4
  `);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
@@ -15,4 +15,4 @@ ${i}`;continue}return null}return r}function qn(e,t){let r=Vt(e).trim();if(!r)th
15
15
  `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=zs(o)),t.push(o))}catch{}}return t}function $s(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function Hr(e,t){let r=Ur(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>xr||$s(i,r)||i.attempts>=Ir){o+=1;continue}n.push(i)}if(n.length>gr){let i=n.length-gr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function Fs(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
16
16
  `),n=r.length>0?`${r}
17
17
  `:"";for(let o=0;;o+=1)try{await T(yt(e),n);return}catch(i){let s=Ar[o];if(s===void 0||!Vr(i))throw i;await qr(s)}}async function Tr(e,t,r,n){return Et(async()=>{let o=await S(yt(e)),i=o===null?[]:jr(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=Hr(s,t);return await Fs(e,a),a.length})}async function Us(e,t){let r=await S(yt(e));if(r===null||r.trim().length===0){await v(e,{pending_otel_spans:0});return}let n=jr(r),{entries:o,prunedCount:i}=Hr(n,t),s=o.filter(h=>Fr(h.next_attempt_after)).slice(0,ss);if(s.length===0){let h=i>0?await Tr(e,t,new Set,new Map):o.length;await v(e,{pending_otel_spans:h});return}let a=R(),c=new Set,d=new Map,l=0,u;await Promise.all(s.map(async h=>{try{let y=await Pr(h.endpoint,{"content-type":"application/json"},JSON.stringify(h.payload));if(y<200||y>=300)throw new Error(`local_otel_export_http_${y}`);c.add(h.id),l+=1}catch(y){u=y instanceof Error?_t(y.message,"redacted"):"local_otel_export_failed";let w=h.attempts+1;d.set(h.id,{attempts:w,next_attempt_after:$r(w)})}}));let _=await Tr(e,t,c,d),p={pending_otel_spans:_,last_otel_attempt_at:a};l>0&&(p.last_otel_success_at=a),u!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=u):_===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await v(e,p)}async function Vs(e,t,r){try{await Ys(e,t,r)}catch{}try{await Us(e,r)}catch{}}async function qs(e,t=ps){try{let r=As(e),n=await es(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=x.join(r,i.name);(await Sr(s)).mtimeMs<o&&await gt(s,{force:!0})}))}catch{}}async function Et(e){let t=Er.catch(()=>{}).then(e);return Er=t.catch(()=>{}),t}async function bt(e){let t=await S(Ce(e));return t===null||t.trim().length===0?[]:zr(t)}async function js(e,t,r){return Et(async()=>{let n=await bt(e),{entries:o}=wt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Ae(e,i),i})}async function Hs(e,t,r,n){return Et(async()=>{let o=await bt(e),{entries:i}=wt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:$r(c)}});return await Ae(e,s),s})}async function Ys(e,t,r){await qs(e);let n=t.trim();if(n.length===0)return;let o=await S(Ce(e));if(o===null||o.trim().length===0){await v(e,{endpoint:n,queue_entries:0});return}let i=zr(o);if(i.length===0){await v(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=wt(i,r);if(s.length===0){await Ae(e,[]),await v(e,{endpoint:n,queue_entries:0});return}let c=s.filter(p=>Os(p)).slice(0,cs);if(c.length===0){a>0&&await Ae(e,s),await v(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(p=>p.event.event_id)),l=R(),u={"content-type":"application/json"},_=process.env.PM_TELEMETRY_INGEST_KEY?.trim();_&&(u["x-pm-telemetry-key"]=_);try{let p=await Pr(n,u,JSON.stringify({schema_version:as,events:c.map(h=>h.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let h=await Hs(e,d,l,r),y=p instanceof Error?_t(p.message,"redacted"):"telemetry_flush_failed";await v(e,{endpoint:n,queue_entries:h.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:y});return}try{let p=await js(e,d,r);await v(e,{endpoint:n,queue_entries:p.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let h=p instanceof Error?_t(p.message,"redacted"):"telemetry_flush_failed",y=await bt(e).catch(()=>s);await v(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:h})}}async function Bs(e){let t=Lr(e);await pt(x.dirname(t),{recursive:!0});try{return await pt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Sr(t);return Date.now()-r.mtimeMs<_s?!1:(await gt(t,{recursive:!0,force:!0}),await pt(t),!0)}catch{return!1}}function Gs(e){try{Zi(e,{recursive:!0,force:!0})}catch{}}function Ws(e){Gs(Cs(e))}async function Ks(e,t,r){let n=await Bs(e);if(Ws(e),!!n)try{await Vs(e,t,r)}finally{try{await gt(Lr(e),{recursive:!0,force:!0})}catch{}}}async function sl(e=Re(process.cwd())){if(!ks())try{if(!(await M(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await Ns(e);await Ks(e,r,n)}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]="a678b9f8-ba36-5127-877f-96bb4acc38c5")}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]="13c02696-29a7-598e-888a-3502fd88bfbe")}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]="a2fad90a-3575-5f3e-8cbe-ac380ac45591")}catch{}})();var Qs=3,Yr=20,Xs=.8,Js=100,Br=1e3,Gr=1e6;function Sp(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`]}function Wr(e){let t=e.limit??Qs,r=e.threshold??Xs;if(!Number.isSafeInteger(t)||t<0||t>Yr)throw new m(`Similarity limit must be an integer from 0 to ${Yr}.`,f.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new m("Similarity threshold must be a number from 0 to 1.",f.USAGE);return{limit:t,threshold:r}}function Zs(e){let t=e.limit??Js;if(!Number.isSafeInteger(t)||t<0||t>Br)throw new m(`Duplicate cluster limit must be an integer from 0 to ${Br}.`,f.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new m("Duplicate cluster --since must be a valid ISO timestamp.",f.USAGE);return{limit:t,since:r}}async function ea(e,t){let r=oe(e.cwd??process.cwd(),e.pmRoot),n=await M(r),o=U(n),i=e.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&i?.length===0)throw new m("Duplicate cluster statuses must include at least one lifecycle status or all.",f.USAGE);let s=Oe(n.schema),a=i?.map(u=>{if(u==="all")return u;let _=K(u,s);if(!_)throw new m(`Unknown duplicate-cluster status "${u}". Allowed: all, ${s.definitions.map(p=>p.id).join(", ")}.`,f.USAGE);return _}),c=a?.includes("all")===!0;if(c&&a?.some(u=>u!=="all"))throw new m('The "all" status cannot be combined with other statuses.',f.USAGE);let d=c?void 0:a,l=d?new Set(d):void 0;return{items:(await de(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(u=>(!l||l.has(u.status))&&(!t||new Date(u.created_at).getTime()>=t.getTime())).sort((u,_)=>u.id.localeCompare(_.id)).map(u=>({item:u,prepared:X(u.title)})),statuses:d}}function Kr(e,t=Gr){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let u of l)r.add(`${u}:${o}`);if(r.size>t)throw new m(`Duplicate sweep exceeded ${Gr} candidate pairs; narrow it with statuses or since.`,f.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var xp={buildDuplicateClusters:Xr,collectDuplicateCandidatePairs:Kr,createDuplicateUnionFind:Qr};function Qr(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function ta(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(u=>Number.parseInt(u,10)),c=fe(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function Xr(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function ra(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...ue(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function na(e,t={}){let r=e.title.trim();if(r.length===0)throw new m("Similarity candidate title must not be empty.",f.USAGE);let{limit:n,threshold:o}=Wr(t),i=oe(t.cwd??process.cwd(),t.pmRoot),s=await M(i),a=U(s),c=await Ve(i,Object.values(a.type_to_folder)),d=J(r),l=c&&d.length>0?await Ue({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(p=>`"${p.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,u=l===null?await de(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,_=ra(r,u,new Set(e.excludeIds??[]),o,n);return{items:_,count:_.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Ip(e={}){let{threshold:t}=Wr({...e,limit:void 0}),{limit:r,since:n}=Zs(e),{items:o,statuses:i}=await ea(e,n),s=Kr(o),a=Qr(o.length),c=ta(o,s,t,a),d=Xr(o,c,a,r);return{clusters:d,count:d.length,threshold:t,source:"metadata_scan",filters:{statuses:i??null,since:e.since??null},cost:{item_count:o.length,candidate_pairs:s.size,scored_pairs:s.size}}}async function Ap(e,t){if(t.mode==="off")return;let r=await na(e,t);if(r.count===0)return;let n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let o=r.items.map(i=>`${i.id} (${i.status}): ${i.title}`).join("; ");throw new m(`Likely duplicate item(s) found: ${o}. Reuse the canonical item or pass --allow-duplicate with explicit intent.`,f.CONFLICT,{code:"likely_duplicate",required:"Reuse an existing item, or explicitly acknowledge the duplicate with --allow-duplicate.",recovery:{suggested_flags:["--allow-duplicate"]}})}return{mode:t.mode,bypassed:n,result:r}}(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]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function Lp(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{En as a,bn as b,Sn as c,xn as d,va as e,In as f,An as g,Be as h,Cn as i,$a as j,Ln as k,Pt as l,Dn as m,Rn as n,$t as o,Mn as p,kn as q,Nn as r,On as s,qn as t,Yn as u,Bn as v,Wn as w,Kn as x,Qn as y,Zn as z,Wa as A,ro as B,ec as C,so as D,co as E,en as F,lo as G,uo as H,he as I,Oo as J,Tc as K,Ke as L,Jt as M,Qe as N,Go as O,Wo as P,Ic as Q,Zt as R,j as S,Je as T,et as U,ct as V,Pc as W,dt as X,Se as Y,sr as Z,xe as _,lt as $,ut as aa,ft as ba,mt as ca,fr as da,mr as ea,nd as fa,an as ga,Dt as ha,dn as ia,ln as ja,un as ka,la,fa as ma,Q as na,le as oa,J as pa,X as qa,ue as ra,fe as sa,Rt as ta,hn as ua,Hi as va,Gi as wa,Ki as xa,Qi as ya,as as za,Ir as Aa,Es as Ba,sl as Ca,Lp as Da,Sp as Ea,xp as Fa,na as Ga,Ip as Ha,Ap as Ia};
18
- //# sourceMappingURL=chunk-XDNAW5OI.js.map
18
+ //# sourceMappingURL=chunk-C7JUBRFP.js.map
@@ -1,6 +1,6 @@
1
- import{c as x}from"./chunk-PPFGQDSI.js";import{Ja as a,La as w,p as m,w as T}from"./chunk-K7RWWOAG.js";import{S as v,Y as f,Z as u,o as _,p as b,q as E}from"./chunk-Q4YY3XNF.js";import C from"node:fs/promises";import p 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let r=Array.isArray(t)?t:[t],n=[];for(let i of r){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);n.push(i.trim())}return[...new Set(n)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},r=e;for(let[n,i]of Object.entries(r)){if(!q(n))continue;let o=G(n,i);o.length>0&&(t[n]=o)}return t}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length>0?[...new Set(t)].sort((r,n)=>r.localeCompare(n)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={image:c(t,"image"),video:c(t,"video")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(r).some(n=>n!==void 0)?r:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let r;try{r=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof r!="object"||r===null||Array.isArray(r))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let n=r,i=n.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof n.name=="string"?n.name:void 0,package_version:typeof n.version=="string"?n.version:void 0,package_private:n.private===!0,package_description:typeof n.description=="string"?n.description:void 0,package_keywords:S(n.keywords),package_homepage:typeof n.homepage=="string"?n.homepage:void 0,package_repository_url:I(n.repository),package_bugs_url:I(n.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let i=p.join(e,n.name);await m(p.join(i,"manifest.json"))&&r.push(i)}return r.sort((n,i)=>n.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let r=(await B(e)).resources.extensions??[],n=new Set;for(let i of r){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!T(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){n.add(o);continue}for(let s of await j(o))n.add(s)}if(r.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))n.add(o);return[...n].sort((i,o)=>i.localeCompare(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]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,r=0;for(let o of e)r=o==="`"?r+1:0,t=Math.max(t,r);let n="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${i}${e}${i}${n}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,r){let n=[`${k(t)} ${e}`,""];return r.length===0?(n.push("_None._",""),n):(n.push(...r.map(i=>`- ${F(i)}`),""),n)}function X(e,t,r){return e===0&&!r?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let r=t.headingLevel??2;if(!Number.isInteger(r)||r<D||r>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let n=Math.min(r+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(r)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,n,g))}return s.push(...X(e.preflight_overrides,n,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
1
+ import{c as x}from"./chunk-4JPEBFFC.js";import{Ja as a,La as w,p as m,w as T}from"./chunk-QYZERYR5.js";import{S as v,Y as f,Z as u,o as _,p as b,q as E}from"./chunk-725JSCMP.js";import C from"node:fs/promises";import p 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]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let r=Array.isArray(t)?t:[t],n=[];for(let i of r){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);n.push(i.trim())}return[...new Set(n)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},r=e;for(let[n,i]of Object.entries(r)){if(!q(n))continue;let o=G(n,i);o.length>0&&(t[n]=o)}return t}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length>0?[...new Set(t)].sort((r,n)=>r.localeCompare(n)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={image:c(t,"image"),video:c(t,"video")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(r).some(n=>n!==void 0)?r:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let r;try{r=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof r!="object"||r===null||Array.isArray(r))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let n=r,i=n.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof n.name=="string"?n.name:void 0,package_version:typeof n.version=="string"?n.version:void 0,package_private:n.private===!0,package_description:typeof n.description=="string"?n.description:void 0,package_keywords:S(n.keywords),package_homepage:typeof n.homepage=="string"?n.homepage:void 0,package_repository_url:I(n.repository),package_bugs_url:I(n.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let i=p.join(e,n.name);await m(p.join(i,"manifest.json"))&&r.push(i)}return r.sort((n,i)=>n.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let r=(await B(e)).resources.extensions??[],n=new Set;for(let i of r){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!T(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){n.add(o);continue}for(let s of await j(o))n.add(s)}if(r.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))n.add(o);return[...n].sort((i,o)=>i.localeCompare(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]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,r=0;for(let o of e)r=o==="`"?r+1:0,t=Math.max(t,r);let n="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${i}${e}${i}${n}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,r){let n=[`${k(t)} ${e}`,""];return r.length===0?(n.push("_None._",""),n):(n.push(...r.map(i=>`- ${F(i)}`),""),n)}function X(e,t,r){return e===0&&!r?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let r=t.headingLevel??2;if(!Number.isInteger(r)||r<D||r>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let n=Math.min(r+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(r)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,n,g))}return s.push(...X(e.preflight_overrides,n,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
2
2
  `).trimEnd()}
3
3
  `}(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]="e3f016bb-8add-5765-bb1a-a7b22423f8d1")}catch{}})();var Q=["agile","ops","research"],Z={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function ke(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${Q.join(", ")}.`)}function ve(e){return Z[e].map(t=>x(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]="575b0c3a-9ce1-504f-a24e-d8854e898f17")}catch{}})();var ee=new Set(b),te=new Set(E),N=new Set([...v.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),ne=["create","update"];function P(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function O(e){return e.replaceAll("_","-")}function re(e,t){let r=new Set;for(let n of e){let i=P(n);i.length>0&&i!==t&&r.add(i)}return[...r].sort((n,i)=>n.localeCompare(i))}function ie(e){let t=new Set;for(let r of e??[]){let n=r.trim();n.length>0&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function oe(e){let t=new Set,r=[];for(let n of e??[]){let i=n.trim().toLowerCase();if(i.length!==0){if(!te.has(i))throw new Error(`Invalid field command "${n}". Allowed: ${E.join(", ")}.`);t.has(i)||(t.add(i),r.push(i))}}return e===void 0||r.length===0?[...ne]:r}function je(e){let t=a(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(N.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...N].sort((g,U)=>g.localeCompare(U)).join(", ")}.`);let r=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!ee.has(r))throw new Error(`Invalid field type "${e.type}". Allowed: ${b.join(", ")}.`);let n=r,i=oe(e.commands),o=P(e.cliFlag),s=o.length>0&&o!==O(t)?o:void 0,d=s??O(t),l=re(e.aliases??[],d),y=e.description?.trim();return{key:t,type:n,commands:i,description:y&&y.length>0?y:void 0,cliFlag:s,cliAliases:l,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:ie(e.requiredTypes)}}function se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function ae(e){let t=se(e);if(!t)return[];let r=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.key!="string"||i.key.trim().length===0||r.push(i)}return r}function Ce(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:ae(t)}}function De(e){return`${JSON.stringify({fields:e.fields},null,2)}
4
4
  `}function $e(e,t){let r=e.fields.find(s=>a(s.key)===t.key),n=r!==void 0,i=e.fields.filter(s=>a(s.key)!==t.key),o={...r,key:t.key,type:t.type,commands:[...t.commands]};return L(o,"description",t.description),L(o,"cli_flag",t.cliFlag),t.cliAliases.length>0?o.cli_aliases=[...t.cliAliases]:delete o.cli_aliases,M(o,"required",t.required),M(o,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?o.allow_unset=!1:delete o.allow_unset,t.requiredTypes.length>0?o.required_types=[...t.requiredTypes]:delete o.required_types,i.push(o),i.sort((s,d)=>a(s.key).localeCompare(a(d.key))),{file:{fields:i},definition:o,replaced:n}}function Fe(e,t){let r=a(t);if(r.length===0)throw new Error("Field key must not be empty.");let n=[],i=e.fields.filter(o=>a(o.key)===r?(n.push(o),!1):!0);return n.length===0?{file:{fields:i},removed:!1}:{file:{fields:i},removed:!0,definition:n[0]}}function L(e,t,r){let n=e;r!==void 0&&r.length>0?n[t]=r:delete n[t]}function M(e,t,r){let n=e;r?n[t]=!0:delete n[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]="3eac0218-43c9-5bd2-8eaf-589d02d2c8ad")}catch{}})();var de=new Set(_),h=new Set(w.map(e=>a(e.id)).filter(e=>e.length>0));function le(e){let t=new Set;for(let r of e){let n=a(r);n.length>0&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function Ue(e){let t=a(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(h.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let r;if(e.roles!==void 0){r=[];let s=new Set;for(let d of e.roles){let l=typeof d=="string"?d.trim().toLowerCase():"";if(l.length!==0){if(!de.has(l))throw new Error(`Invalid status role "${d}". Allowed roles: ${_.join(", ")}.`);s.has(l)||(s.add(l),r.push(l))}}}let n=e.aliases===void 0?void 0:le(e.aliases).filter(s=>s!==t),i=e.description?.trim(),o=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:r,aliases:n,description:i&&i.length>0?i:void 0,order:o}}function ce(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function fe(e){let t=ce(e);if(!t)return[];let r=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.id!="string"||i.id.trim().length===0||r.push(i)}return r}function ze(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:fe(t)}}function Re(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
5
5
  `}function qe(e,t,r){let n=e.statuses.slice(),i=n.findIndex(d=>a(d.id)===t.id),o=i>=0?n[i]:r,s={...o,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),i>=0?n[i]=s:n.push(s),{file:{statuses:n},definition:s,replaced:o!==void 0}}function Ge(e,t){let r=a(t);if(r.length===0)throw new Error("Status id must not be empty.");if(h.has(r))throw new Error(`Cannot remove built-in status "${r}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let n=e.statuses.slice(),i=n.findIndex(s=>a(s.id)===r);if(i<0)return{file:{statuses:n},removed:!1};let[o]=n.splice(i,1);return{file:{statuses:n},removed:!0,definition:o}}function Je(e,t){let r=[e.id,...e.aliases??[]];for(let n of r){let i=a(n);if(i.length===0)continue;let o=t.get(i);if(o!==void 0&&o!==e.id)throw new Error(`Status token "${i}" already belongs to status "${o}". Choose a different id/alias to avoid shadowing it.`)}}export{z as a,R as b,B as c,_e as d,Q as e,Z as f,ke as g,ve as h,je as i,Ce as j,De as k,$e as l,Fe as m,h as n,Ue as o,ze as p,Re as q,qe as r,Ge as s,Je as t,Ee as u};
6
- //# sourceMappingURL=chunk-4DQ2YERC.js.map
6
+ //# sourceMappingURL=chunk-CODV5LUT.js.map