@unbrained/pm-cli 2026.9.7 → 2026.9.8

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 (718) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +12 -4
  2. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +19 -10
  3. package/.agents/skills/pm-extensions/SKILL.md +6 -0
  4. package/.agents/skills/pm-sdk/SKILL.md +11 -2
  5. package/.agents/skills/pm-user/SKILL.md +5 -0
  6. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +95 -0
  7. package/.claude-plugin/marketplace.json +2 -2
  8. package/CHANGELOG.md +211 -181
  9. package/dist/cli/after-command-context-usage.js +1 -48
  10. package/dist/cli/argv-utils.js +1 -40
  11. package/dist/cli/bootstrap-args.js +1 -9
  12. package/dist/cli/bundle-integrity.js +2 -110
  13. package/dist/cli/commander-usage.js +11 -771
  14. package/dist/cli/commands/activity.js +1 -9
  15. package/dist/cli/commands/aggregate.js +1 -5
  16. package/dist/cli/commands/append.js +1 -5
  17. package/dist/cli/commands/claim.js +1 -5
  18. package/dist/cli/commands/close-many.js +1 -5
  19. package/dist/cli/commands/close.js +1 -9
  20. package/dist/cli/commands/comments.js +1 -5
  21. package/dist/cli/commands/config.js +1 -9
  22. package/dist/cli/commands/context.js +1 -9
  23. package/dist/cli/commands/contracts.js +1 -5
  24. package/dist/cli/commands/copy.js +1 -9
  25. package/dist/cli/commands/create.js +1 -9
  26. package/dist/cli/commands/delete.js +1 -9
  27. package/dist/cli/commands/deps.js +1 -9
  28. package/dist/cli/commands/docs.js +1 -9
  29. package/dist/cli/commands/duplicates.js +1 -9
  30. package/dist/cli/commands/eval.js +1 -9
  31. package/dist/cli/commands/extension/describe.js +1 -5
  32. package/dist/cli/commands/extension/scaffold.js +1 -5
  33. package/dist/cli/commands/extension/shared.js +1 -5
  34. package/dist/cli/commands/extension.js +1 -9
  35. package/dist/cli/commands/files.js +1 -9
  36. package/dist/cli/commands/focus.js +1 -9
  37. package/dist/cli/commands/gc.js +1 -9
  38. package/dist/cli/commands/get.js +1 -9
  39. package/dist/cli/commands/graph.js +1 -10
  40. package/dist/cli/commands/health.js +1 -9
  41. package/dist/cli/commands/history-compact.js +1 -10
  42. package/dist/cli/commands/history-redact.js +1 -11
  43. package/dist/cli/commands/history-repair.js +1 -10
  44. package/dist/cli/commands/history.js +1 -5
  45. package/dist/cli/commands/index.js +1 -58
  46. package/dist/cli/commands/init-agent-guidance.js +1 -9
  47. package/dist/cli/commands/init.js +1 -9
  48. package/dist/cli/commands/learnings.js +1 -5
  49. package/dist/cli/commands/lifecycle-transitions.js +1 -5
  50. package/dist/cli/commands/list.js +1 -9
  51. package/dist/cli/commands/merge.js +1 -11
  52. package/dist/cli/commands/next.js +1 -9
  53. package/dist/cli/commands/notes.js +1 -5
  54. package/dist/cli/commands/plan.js +1 -9
  55. package/dist/cli/commands/profile.js +1 -9
  56. package/dist/cli/commands/restore.js +1 -9
  57. package/dist/cli/commands/scheduling-shortcuts.js +1 -9
  58. package/dist/cli/commands/schema.js +1 -10
  59. package/dist/cli/commands/search.js +1 -9
  60. package/dist/cli/commands/stats.js +1 -9
  61. package/dist/cli/commands/telemetry.js +1 -9
  62. package/dist/cli/commands/test-all.js +1 -9
  63. package/dist/cli/commands/test-runs.js +1 -9
  64. package/dist/cli/commands/test.js +1 -9
  65. package/dist/cli/commands/update-many.js +1 -5
  66. package/dist/cli/commands/update.js +1 -9
  67. package/dist/cli/commands/upgrade.js +1 -5
  68. package/dist/cli/commands/validate.js +1 -15
  69. package/dist/cli/context-intent-invocation.js +1 -20
  70. package/dist/cli/description-stdin.js +1 -17
  71. package/dist/cli/error-guidance.js +1 -1353
  72. package/dist/cli/extension-command-help.js +5 -636
  73. package/dist/cli/extension-command-options.js +1 -427
  74. package/dist/cli/extension-recovery.js +1 -126
  75. package/dist/cli/help-content.js +2 -1001
  76. package/dist/cli/help-json-payload.js +4 -570
  77. package/dist/cli/main.d.ts +4 -0
  78. package/dist/cli/main.js +5 -2573
  79. package/dist/cli/migration-gates.js +1 -289
  80. package/dist/cli/public.js +1 -20
  81. package/dist/cli/register-annotations.js +1 -270
  82. package/dist/cli/register-assurance.js +1 -62
  83. package/dist/cli/register-files-lookup.js +1 -56
  84. package/dist/cli/register-history-activity.d.ts +8 -0
  85. package/dist/cli/register-history-activity.js +2 -0
  86. package/dist/cli/register-history-author.js +1 -38
  87. package/dist/cli/register-history-maintenance.d.ts +9 -0
  88. package/dist/cli/register-history-maintenance.js +2 -0
  89. package/dist/cli/register-list-query.js +10 -943
  90. package/dist/cli/register-mutation-options.js +1 -9
  91. package/dist/cli/register-mutation.js +19 -1893
  92. package/dist/cli/register-operations.js +1 -920
  93. package/dist/cli/register-setup.js +1 -716
  94. package/dist/cli/register-structured-mutation.js +1 -196
  95. package/dist/cli/registration-helpers.js +1 -5
  96. package/dist/cli/runtime-compatibility-boundary.js +4 -42
  97. package/dist/cli/schema-registration-helpers.js +1 -73
  98. package/dist/cli/search-refresh.js +1 -13
  99. package/dist/cli/stats-analytics-json.js +1 -68
  100. package/dist/cli/telemetry-flush.js +1 -10
  101. package/dist/cli-bundle/bundle-manifest.json +164 -156
  102. package/dist/cli-bundle/chunks/chunk-3BZZA6A3.js +5 -0
  103. package/dist/cli-bundle/chunks/chunk-AMRDVX36.js +235 -0
  104. package/dist/cli-bundle/chunks/chunk-DAM4CBBR.js +2202 -0
  105. package/dist/cli-bundle/chunks/{chunk-WYRZZ5ZE.js → chunk-DEZPZOQ7.js} +2 -2
  106. package/dist/cli-bundle/chunks/chunk-FLDWYEND.js +77 -0
  107. package/dist/cli-bundle/chunks/{chunk-NPN5I67J.js → chunk-G5ADGQ2D.js} +3 -3
  108. package/dist/cli-bundle/chunks/chunk-JAAEYHUA.js +2 -0
  109. package/dist/cli-bundle/chunks/{chunk-JX4DH4WC.js → chunk-KR3RP4FH.js} +3 -3
  110. package/dist/cli-bundle/chunks/chunk-LEZOUXG6.js +2 -0
  111. package/dist/cli-bundle/chunks/chunk-NSAPNEYH.js +2 -0
  112. package/dist/cli-bundle/chunks/chunk-QOEKOECV.js +29 -0
  113. package/dist/cli-bundle/chunks/chunk-RHSFOMHU.js +2 -0
  114. package/dist/cli-bundle/chunks/chunk-XOD2PCB6.js +20 -0
  115. package/dist/cli-bundle/chunks/{chunk-JT6XF6GE.js → chunk-YVEQ2AMO.js} +4 -4
  116. package/dist/cli-bundle/chunks/register-list-query-KSK3R63M.js +11 -0
  117. package/dist/cli-bundle/chunks/register-mutation-IQ5C7U6O.js +20 -0
  118. package/dist/cli-bundle/chunks/{register-operations-I5W3KMGB.js → register-operations-DWVHR2NC.js} +2 -2
  119. package/dist/cli-bundle/chunks/register-setup-BQ5SVD4B.js +2 -0
  120. package/dist/cli-bundle/focused-chunks/chunk-3WRPWLA7.js +3 -0
  121. package/dist/cli-bundle/focused-chunks/chunk-7MBUII7U.js +2 -0
  122. package/dist/cli-bundle/focused-chunks/chunk-COPBO5HW.js +8 -0
  123. package/dist/cli-bundle/focused-chunks/chunk-DUN4IXYN.js +20 -0
  124. package/dist/cli-bundle/focused-chunks/{chunk-LIJIA4TY.js → chunk-EE5QSM4Z.js} +3 -3
  125. package/dist/cli-bundle/focused-chunks/chunk-HJVARYM3.js +6 -0
  126. package/dist/cli-bundle/focused-chunks/chunk-IAUOUGVR.js +177 -0
  127. package/dist/cli-bundle/focused-chunks/chunk-KOOMJ54F.js +2 -0
  128. package/dist/cli-bundle/focused-chunks/chunk-MZDXX7JY.js +56 -0
  129. package/dist/cli-bundle/focused-chunks/{chunk-M6PBRFSH.js → chunk-OPFHFGDD.js} +2 -2
  130. package/dist/cli-bundle/focused-chunks/chunk-QHNETP77.js +9 -0
  131. package/dist/cli-bundle/focused-chunks/{chunk-3BZEOXLT.js → chunk-RMWES4M6.js} +2 -2
  132. package/dist/cli-bundle/focused-chunks/chunk-RXT4P5QH.js +10 -0
  133. package/dist/cli-bundle/focused-chunks/chunk-SDOL6FM2.js +12 -0
  134. package/dist/cli-bundle/focused-chunks/chunk-SQV4AAUC.js +2 -0
  135. package/dist/cli-bundle/focused-chunks/{chunk-PEFABF7E.js → chunk-WE3IUNIW.js} +3 -3
  136. package/dist/cli-bundle/focused-chunks/chunk-YALOUBWJ.js +2 -0
  137. package/dist/cli-bundle/main.js +20 -20
  138. package/dist/cli-bundle/sdk-authoring.js +1 -1
  139. package/dist/cli-bundle/sdk-contracts.js +2 -2
  140. package/dist/cli-bundle/sdk-core.js +29 -29
  141. package/dist/cli-bundle/sdk-governance.js +1 -1
  142. package/dist/cli-bundle/sdk-graph.js +1 -1
  143. package/dist/cli-bundle/sdk-merge.js +42 -42
  144. package/dist/cli-bundle/sdk-query.js +1 -1
  145. package/dist/cli-bundle/sdk-runtime.js +1 -1
  146. package/dist/cli-bundle/sdk-testing.js +1 -1
  147. package/dist/cli-bundle/sdk.js +11 -11
  148. package/dist/cli.js +1 -104
  149. package/dist/core/checkpoint/checkpoint-gc.js +1 -169
  150. package/dist/core/checkpoint/mutation-checkpoint.js +2 -133
  151. package/dist/core/config/nested-settings.js +1 -534
  152. package/dist/core/config/positional-value.js +1 -109
  153. package/dist/core/diagnostics/remediation.js +1 -506
  154. package/dist/core/extensions/activation-summary-markdown.js +2 -145
  155. package/dist/core/extensions/activation-summary.js +1 -92
  156. package/dist/core/extensions/activation-transaction.js +1 -46
  157. package/dist/core/extensions/capability-usage.js +1 -173
  158. package/dist/core/extensions/command-hook-context.js +1 -13
  159. package/dist/core/extensions/command-metadata-contract.js +1 -22
  160. package/dist/core/extensions/command-visibility-tier.js +1 -29
  161. package/dist/core/extensions/contribution-inventory.js +1 -173
  162. package/dist/core/extensions/exporter-output-contract.js +1 -66
  163. package/dist/core/extensions/extension-candidate.js +1 -18
  164. package/dist/core/extensions/extension-capability-aliases.js +1 -158
  165. package/dist/core/extensions/extension-hook-runtime.js +1 -699
  166. package/dist/core/extensions/extension-policy.js +1 -599
  167. package/dist/core/extensions/extension-registries.js +1 -62
  168. package/dist/core/extensions/extension-runtime-helpers.js +1 -33
  169. package/dist/core/extensions/extension-types.js +1 -102
  170. package/dist/core/extensions/flag-definition-validation.js +1 -52
  171. package/dist/core/extensions/flag-value-types.js +1 -64
  172. package/dist/core/extensions/index.js +1 -526
  173. package/dist/core/extensions/item-field-types.js +1 -39
  174. package/dist/core/extensions/item-fields.js +1 -261
  175. package/dist/core/extensions/loader.js +1 -2223
  176. package/dist/core/extensions/manifest-schema.js +1 -69
  177. package/dist/core/extensions/module-graph-snapshot.js +1 -33
  178. package/dist/core/extensions/preflight-ownership.js +1 -41
  179. package/dist/core/extensions/registration-validation.js +1 -82
  180. package/dist/core/extensions/registration-values.js +1 -209
  181. package/dist/core/extensions/reserved-host-flags.js +1 -36
  182. package/dist/core/extensions/runtime-registrations.js +1 -67
  183. package/dist/core/extensions/service-ownership.js +1 -19
  184. package/dist/core/extensions/version-compat.js +1 -216
  185. package/dist/core/fs/fs-utils.js +2 -158
  186. package/dist/core/fs/host-environment-errors.js +1 -141
  187. package/dist/core/fs/index.js +1 -9
  188. package/dist/core/fs/path-utils.js +1 -17
  189. package/dist/core/governance/content-fields.js +1 -160
  190. package/dist/core/governance/issue-codes.js +1 -151
  191. package/dist/core/governance/metadata-coverage.js +1 -358
  192. package/dist/core/history/drift-cache.js +3 -72
  193. package/dist/core/history/drift-scan.js +1 -342
  194. package/dist/core/history/event-classification.js +1 -109
  195. package/dist/core/history/event-index.js +8 -784
  196. package/dist/core/history/history-compact-bulk.js +1 -104
  197. package/dist/core/history/history-diff.js +1 -158
  198. package/dist/core/history/history-rewrite.d.ts +6 -1
  199. package/dist/core/history/history-rewrite.js +1 -107
  200. package/dist/core/history/history-storage-stats.js +1 -102
  201. package/dist/core/history/history-stream-policy.js +1 -62
  202. package/dist/core/history/history.js +2 -617
  203. package/dist/core/history/identity.js +1 -30
  204. package/dist/core/history/index.js +1 -9
  205. package/dist/core/history/projection.js +1 -196
  206. package/dist/core/history/read.d.ts +9 -0
  207. package/dist/core/history/read.js +1 -57
  208. package/dist/core/history/replay.js +2 -439
  209. package/dist/core/history/version-address.js +1 -32
  210. package/dist/core/history/workspace-history.js +2 -433
  211. package/dist/core/io/body-file.js +1 -62
  212. package/dist/core/io/bulk-ids-input.js +1 -112
  213. package/dist/core/item/actionability.js +1 -327
  214. package/dist/core/item/dependency-reference.js +1 -20
  215. package/dist/core/item/id.js +1 -112
  216. package/dist/core/item/index.js +1 -12
  217. package/dist/core/item/item-format-version.js +1 -78
  218. package/dist/core/item/item-format.js +5 -1473
  219. package/dist/core/item/item-record.js +1 -23
  220. package/dist/core/item/item-type-definition.js +1 -133
  221. package/dist/core/item/parent-reference-policy.js +1 -57
  222. package/dist/core/item/parse.js +2 -603
  223. package/dist/core/item/plan-lifecycle.js +1 -19
  224. package/dist/core/item/priority.js +1 -61
  225. package/dist/core/item/sprint-release-format.js +1 -38
  226. package/dist/core/item/status-filter.js +1 -115
  227. package/dist/core/item/status.js +1 -43
  228. package/dist/core/item/toon-decode.js +1 -29
  229. package/dist/core/item/type-registry.js +1 -715
  230. package/dist/core/item/type-synonyms.js +1 -38
  231. package/dist/core/lock/index.js +1 -9
  232. package/dist/core/lock/lock-gc.js +1 -240
  233. package/dist/core/lock/lock.js +3 -590
  234. package/dist/core/output/mutation-projection.js +1 -217
  235. package/dist/core/output/output-control.js +1 -25
  236. package/dist/core/output/output.js +11 -494
  237. package/dist/core/output/query-summary.js +1 -58
  238. package/dist/core/output/tabular.js +1 -77
  239. package/dist/core/packages/manifest.js +1 -244
  240. package/dist/core/packages/root.js +1 -84
  241. package/dist/core/profile/profile-describe.js +1 -83
  242. package/dist/core/profile/profile-lint.js +1 -415
  243. package/dist/core/profile/profile-plan.js +0 -0
  244. package/dist/core/profile/profile-presets.js +1 -370
  245. package/dist/core/reproducibility/context.js +1 -82
  246. package/dist/core/schema/fields-file.js +2 -288
  247. package/dist/core/schema/item-types-file.js +2 -296
  248. package/dist/core/schema/runtime-field-filters.js +1 -49
  249. package/dist/core/schema/runtime-field-values.js +1 -313
  250. package/dist/core/schema/runtime-schema.js +2 -826
  251. package/dist/core/schema/status-defs-file.js +2 -227
  252. package/dist/core/schema/status-token.js +1 -31
  253. package/dist/core/schema/type-inference.js +1 -95
  254. package/dist/core/schema/type-presets.js +1 -87
  255. package/dist/core/schema/type-workflows.js +1 -104
  256. package/dist/core/search/background-refresh.js +2 -286
  257. package/dist/core/search/bm25.js +1 -146
  258. package/dist/core/search/cache.js +2 -534
  259. package/dist/core/search/corpus.js +1 -311
  260. package/dist/core/search/embedding-batches.js +1 -163
  261. package/dist/core/search/eval.js +1 -225
  262. package/dist/core/search/http-client.js +1 -75
  263. package/dist/core/search/providers.js +1 -242
  264. package/dist/core/search/relevance.js +1 -244
  265. package/dist/core/search/semantic-defaults.js +1 -199
  266. package/dist/core/search/staleness.js +1 -30
  267. package/dist/core/search/vector-stores.js +2 -664
  268. package/dist/core/search/vectorization-metadata.js +1 -81
  269. package/dist/core/sentry/helpers.js +1 -272
  270. package/dist/core/sentry/instrument.js +1 -387
  271. package/dist/core/session/session-state.js +1 -260
  272. package/dist/core/shared/agent-session-context.js +1 -133
  273. package/dist/core/shared/author.js +1 -1172
  274. package/dist/core/shared/command-types.js +1 -4
  275. package/dist/core/shared/conflict-markers.js +1 -31
  276. package/dist/core/shared/constants.js +1 -405
  277. package/dist/core/shared/errors.js +1 -20
  278. package/dist/core/shared/html-entity-decode.js +1 -131
  279. package/dist/core/shared/index.js +1 -12
  280. package/dist/core/shared/item-metadata-contract.js +1 -89
  281. package/dist/core/shared/lazy-module.js +1 -16
  282. package/dist/core/shared/levenshtein.js +1 -61
  283. package/dist/core/shared/memo.js +1 -19
  284. package/dist/core/shared/numeric-parsers.js +1 -20
  285. package/dist/core/shared/option-alias-visibility.js +1 -67
  286. package/dist/core/shared/primitives.js +1 -127
  287. package/dist/core/shared/serial-queue.js +1 -79
  288. package/dist/core/shared/serialization.js +1 -210
  289. package/dist/core/shared/split-comma-list.js +1 -30
  290. package/dist/core/shared/text-normalization.js +1 -38
  291. package/dist/core/shared/time.js +1 -306
  292. package/dist/core/store/index.js +1 -12
  293. package/dist/core/store/item-format-migration.js +1 -125
  294. package/dist/core/store/item-metadata-cache.js +1 -1116
  295. package/dist/core/store/item-metadata-query-index.js +9 -394
  296. package/dist/core/store/item-metadata-read-work.js +1 -43
  297. package/dist/core/store/item-store.js +1 -693
  298. package/dist/core/store/paths.d.ts +1 -1
  299. package/dist/core/store/paths.js +1 -214
  300. package/dist/core/store/settings-read-cache.js +1 -85
  301. package/dist/core/store/settings-validator.js +1 -421
  302. package/dist/core/store/settings.js +3 -1309
  303. package/dist/core/store/tracker-preflight.js +1 -141
  304. package/dist/core/telemetry/consent.js +5 -108
  305. package/dist/core/telemetry/observability.js +1 -246
  306. package/dist/core/telemetry/runtime.js +4 -1988
  307. package/dist/core/test/background-runs.js +4 -945
  308. package/dist/core/test/item-test-run-tracking.js +1 -63
  309. package/dist/core/test/run-selectors.js +1 -120
  310. package/dist/core/validate/estimate-defaults.js +1 -89
  311. package/dist/core/validate/fix-planning.js +1 -189
  312. package/dist/core/validate/linked-artifact-reference.js +1 -36
  313. package/dist/core/validate/missing-by-type.js +1 -34
  314. package/dist/core/validate/missing-link-owners.js +1 -95
  315. package/dist/core/validate/stale-file-classification.js +1 -82
  316. package/dist/mcp/http-server.js +5 -448
  317. package/dist/mcp/legacy-adapter.js +1 -77
  318. package/dist/mcp/runtime-capabilities.js +1 -200
  319. package/dist/mcp/server.js +4 -1233
  320. package/dist/mcp/tool-definitions.js +1 -804
  321. package/dist/sdk/actionability.js +1 -13
  322. package/dist/sdk/agent/closed-domain-contracts.js +1 -161
  323. package/dist/sdk/agent/command-recovery.js +1 -59
  324. package/dist/sdk/agent/command-suggestions.js +1 -66
  325. package/dist/sdk/agent/create-option-policy.js +1 -31
  326. package/dist/sdk/agent/identity-config.js +1 -106
  327. package/dist/sdk/agent/item-addressing.js +1 -207
  328. package/dist/sdk/agent/refusal-closure-census.js +1 -151
  329. package/dist/sdk/agent/refusal-closure.js +1 -133
  330. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -193
  331. package/dist/sdk/agent/refusal-reachability.js +1 -593
  332. package/dist/sdk/agent/subcommand-recovery.js +1 -83
  333. package/dist/sdk/agent/task-transcript-contracts.js +1 -197
  334. package/dist/sdk/agent/tracker-preflight-contracts.js +1 -126
  335. package/dist/sdk/agent-capability-contracts.js +1 -428
  336. package/dist/sdk/agent-session-context.js +1 -9
  337. package/dist/sdk/annotations.js +1 -448
  338. package/dist/sdk/author-attribution.js +1 -468
  339. package/dist/sdk/authoring.js +1 -20
  340. package/dist/sdk/cli-bootstrap.js +1 -838
  341. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +1 -1
  342. package/dist/sdk/cli-contracts/agent-output-contracts.js +4 -476
  343. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -79
  344. package/dist/sdk/cli-contracts/command-aliases.d.ts +4 -0
  345. package/dist/sdk/cli-contracts/command-aliases.js +1 -107
  346. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -151
  347. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1081
  348. package/dist/sdk/cli-contracts/commander-types.js +1 -159
  349. package/dist/sdk/cli-contracts/completeness.js +1 -393
  350. package/dist/sdk/cli-contracts/enum-contracts.js +1 -222
  351. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1947
  352. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -347
  353. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -986
  354. package/dist/sdk/cli-contracts/registration-helpers.js +7 -990
  355. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
  356. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -2090
  357. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -324
  358. package/dist/sdk/cli-contracts/string-lists.js +1 -16
  359. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -461
  360. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -2167
  361. package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -1
  362. package/dist/sdk/cli-contracts/tool-schema.js +1 -1664
  363. package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -4
  364. package/dist/sdk/cli-contracts.d.ts +1 -1
  365. package/dist/sdk/cli-contracts.js +1 -17
  366. package/dist/sdk/cli-program.js +1 -49
  367. package/dist/sdk/command-line.d.ts +2 -5
  368. package/dist/sdk/command-line.js +1 -78
  369. package/dist/sdk/comments.js +1 -133
  370. package/dist/sdk/compile-cache.js +1 -73
  371. package/dist/sdk/completion.js +157 -837
  372. package/dist/sdk/compose.js +1 -1090
  373. package/dist/sdk/config.js +1 -1204
  374. package/dist/sdk/context/recency.js +1 -33
  375. package/dist/sdk/context/semantic-session-attribution.js +1 -82
  376. package/dist/sdk/context/usage-egress.js +1 -29
  377. package/dist/sdk/context/usage-ledger.js +3 -185
  378. package/dist/sdk/context-intent-contracts.js +1 -709
  379. package/dist/sdk/context-intent-runtime.js +1 -115
  380. package/dist/sdk/context-packing.js +1 -218
  381. package/dist/sdk/context-relevance.js +1 -503
  382. package/dist/sdk/context-signal-store.js +2 -426
  383. package/dist/sdk/context-usage.js +1 -367
  384. package/dist/sdk/contracts.js +1 -23
  385. package/dist/sdk/core-governance.js +1 -14
  386. package/dist/sdk/core.js +1 -14
  387. package/dist/sdk/corpus-shape.js +1 -401
  388. package/dist/sdk/define.js +1 -220
  389. package/dist/sdk/dependencies.js +1 -718
  390. package/dist/sdk/dependency-flag-validation.js +1 -156
  391. package/dist/sdk/dependency-provenance.js +1 -135
  392. package/dist/sdk/docs.js +1 -14
  393. package/dist/sdk/duplicates.js +1 -40
  394. package/dist/sdk/environment/agent-environment.js +1 -466
  395. package/dist/sdk/environment/host-environment-errors.js +1 -8
  396. package/dist/sdk/environment/project-runtime-compatibility.js +1 -481
  397. package/dist/sdk/environment/source-context.js +1 -28
  398. package/dist/sdk/environment/tracker-preflight.js +1 -9
  399. package/dist/sdk/error-code-catalog.js +1 -153
  400. package/dist/sdk/error-runtime.js +1 -58
  401. package/dist/sdk/errors.js +1 -58
  402. package/dist/sdk/eval.js +1 -190
  403. package/dist/sdk/extension/author-manifest.js +1 -92
  404. package/dist/sdk/extension/bundled-catalog.js +1 -332
  405. package/dist/sdk/extension/concurrency.js +1 -25
  406. package/dist/sdk/extension/copy-scope.d.ts +2 -0
  407. package/dist/sdk/extension/copy-scope.js +2 -0
  408. package/dist/sdk/extension/custom-field-collisions.js +1 -30
  409. package/dist/sdk/extension/describe.js +3 -189
  410. package/dist/sdk/extension/doctor.js +1 -606
  411. package/dist/sdk/extension/install-plan.d.ts +69 -0
  412. package/dist/sdk/extension/install-plan.js +2 -0
  413. package/dist/sdk/extension/install-receipts.d.ts +7 -0
  414. package/dist/sdk/extension/install-receipts.js +2 -0
  415. package/dist/sdk/extension/install-runtime.js +3 -313
  416. package/dist/sdk/extension/install-snapshot.js +1 -66
  417. package/dist/sdk/extension/install-sources.js +5 -1057
  418. package/dist/sdk/extension/managed-state.js +2 -252
  419. package/dist/sdk/extension/migrations.js +2 -174
  420. package/dist/sdk/extension/output-ownership.js +1 -25
  421. package/dist/sdk/extension/runtime-summary.js +1 -18
  422. package/dist/sdk/extension/scaffold.js +4 -2308
  423. package/dist/sdk/extension/shared.js +1 -147
  424. package/dist/sdk/extension/source-resolution.js +1 -65
  425. package/dist/sdk/extension/update-check.js +1 -67
  426. package/dist/sdk/extension-command-context.js +1 -44
  427. package/dist/sdk/extension-contracts.js +1 -73
  428. package/dist/sdk/extension.d.ts +7 -2
  429. package/dist/sdk/extension.js +1 -2196
  430. package/dist/sdk/files.js +1 -535
  431. package/dist/sdk/flag-invocation-contracts.d.ts +0 -5
  432. package/dist/sdk/flag-invocation-contracts.js +1 -344
  433. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -2224
  434. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -2236
  435. package/dist/sdk/generated-error-code-catalog.js +1 -16
  436. package/dist/sdk/governance/assurance-action-contracts.js +1 -4
  437. package/dist/sdk/governance/assurance-action.js +1 -411
  438. package/dist/sdk/governance/assurance-limits.js +1 -10
  439. package/dist/sdk/governance/assurance-mutation-error.js +1 -81
  440. package/dist/sdk/governance/assurance-presets.js +1 -135
  441. package/dist/sdk/governance/assurance-runtime.js +1 -238
  442. package/dist/sdk/governance/assurance.js +4 -1182
  443. package/dist/sdk/governance/boundary-fixtures.js +1 -200
  444. package/dist/sdk/governance/coverage-assurance.js +1 -60
  445. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -188
  446. package/dist/sdk/governance/defect-recurrence-graph.js +1 -120
  447. package/dist/sdk/governance/defect-recurrence-signals.js +1 -24
  448. package/dist/sdk/governance/defect-recurrence.js +1 -623
  449. package/dist/sdk/governance/extension-host-version.js +1 -115
  450. package/dist/sdk/governance/gc.js +1 -368
  451. package/dist/sdk/governance/health.js +1 -2367
  452. package/dist/sdk/governance/hierarchy-validation.js +1 -108
  453. package/dist/sdk/governance/linked-file-report.js +1 -71
  454. package/dist/sdk/governance/merge-receipt-history.js +1 -206
  455. package/dist/sdk/governance/provenance-health.js +1 -282
  456. package/dist/sdk/governance/reindex.js +4 -761
  457. package/dist/sdk/governance/stale-work.js +1 -82
  458. package/dist/sdk/governance/status-role-diagnostics.js +1 -35
  459. package/dist/sdk/governance/storage-integrity.js +1 -280
  460. package/dist/sdk/governance/tracked-runtime-cache.js +1 -106
  461. package/dist/sdk/governance/upgrade.js +2 -327
  462. package/dist/sdk/governance/validate-history-drift.js +1 -81
  463. package/dist/sdk/governance/validate-item-reader.js +1 -17
  464. package/dist/sdk/governance/validate-normalization.js +1 -36
  465. package/dist/sdk/governance/validate.js +1 -2261
  466. package/dist/sdk/governance/workspace-position.js +1 -163
  467. package/dist/sdk/governance.d.ts +1 -0
  468. package/dist/sdk/governance.js +1 -31
  469. package/dist/sdk/graph/adapter.js +1 -181
  470. package/dist/sdk/graph/analytics.js +1 -474
  471. package/dist/sdk/graph/assembly.js +1 -377
  472. package/dist/sdk/graph/cache.js +1 -160
  473. package/dist/sdk/graph/centrality.js +1 -258
  474. package/dist/sdk/graph/conformance.js +1 -130
  475. package/dist/sdk/graph/deadline-scheduling.d.ts +90 -0
  476. package/dist/sdk/graph/deadline-scheduling.js +2 -0
  477. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  478. package/dist/sdk/graph/durable-cache.js +1 -361
  479. package/dist/sdk/graph/governance-contracts.js +1 -34
  480. package/dist/sdk/graph/governance.d.ts +13 -1
  481. package/dist/sdk/graph/governance.js +1 -735
  482. package/dist/sdk/graph/hierarchy-integrity.js +1 -310
  483. package/dist/sdk/graph/index.d.ts +3 -2
  484. package/dist/sdk/graph/index.js +1 -26
  485. package/dist/sdk/graph/lifecycle-coverage.d.ts +32 -0
  486. package/dist/sdk/graph/lifecycle-coverage.js +2 -0
  487. package/dist/sdk/graph/mutation-advisory.js +1 -176
  488. package/dist/sdk/graph/remediation.js +1 -197
  489. package/dist/sdk/graph/run.d.ts +15 -1
  490. package/dist/sdk/graph/run.js +1 -768
  491. package/dist/sdk/graph/scheduling.js +1 -124
  492. package/dist/sdk/graph/traversal.js +1 -284
  493. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -27
  494. package/dist/sdk/graph.js +1 -15
  495. package/dist/sdk/guide-topics.js +1 -707
  496. package/dist/sdk/guide.js +1 -279
  497. package/dist/sdk/history/maintenance.d.ts +71 -0
  498. package/dist/sdk/history/maintenance.js +2 -0
  499. package/dist/sdk/history/salvage.js +2 -247
  500. package/dist/sdk/history/subject.d.ts +19 -0
  501. package/dist/sdk/history/subject.js +2 -0
  502. package/dist/sdk/history-analytics.js +1 -282
  503. package/dist/sdk/history-compact.js +1 -527
  504. package/dist/sdk/history-mcp.js +1 -68
  505. package/dist/sdk/history-provenance.js +1 -182
  506. package/dist/sdk/history-read.js +1 -96
  507. package/dist/sdk/history-redact.d.ts +1 -14
  508. package/dist/sdk/history-redact.js +1 -643
  509. package/dist/sdk/history-repair.d.ts +5 -0
  510. package/dist/sdk/history-repair.js +1 -657
  511. package/dist/sdk/improvement-ledger-validation.js +1 -62
  512. package/dist/sdk/improvement-ledger.js +2 -257
  513. package/dist/sdk/index.d.ts +4 -0
  514. package/dist/sdk/index.js +1 -183
  515. package/dist/sdk/init-agent-guidance.js +2 -496
  516. package/dist/sdk/init.js +2 -820
  517. package/dist/sdk/invocation-author.js +1 -39
  518. package/dist/sdk/item-children.js +1 -90
  519. package/dist/sdk/item-metadata-index.js +1 -15
  520. package/dist/sdk/item-schedule.js +1 -27
  521. package/dist/sdk/item-transaction.js +1 -396
  522. package/dist/sdk/learnings.js +1 -29
  523. package/dist/sdk/lifecycle/append.js +2 -53
  524. package/dist/sdk/lifecycle/claim.d.ts +2 -0
  525. package/dist/sdk/lifecycle/claim.js +1 -242
  526. package/dist/sdk/lifecycle/close-many.js +1 -438
  527. package/dist/sdk/lifecycle/close.js +1 -468
  528. package/dist/sdk/lifecycle/copy.js +1 -212
  529. package/dist/sdk/lifecycle/create.js +1 -1949
  530. package/dist/sdk/lifecycle/delete.js +1 -45
  531. package/dist/sdk/lifecycle/event-validation-messages.js +1 -91
  532. package/dist/sdk/lifecycle/focus.js +1 -91
  533. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -24
  534. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -149
  535. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -40
  536. package/dist/sdk/lifecycle/mcp-actions.d.ts +2 -0
  537. package/dist/sdk/lifecycle/mcp-actions.js +1 -51
  538. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -46
  539. package/dist/sdk/lifecycle/mutation-command-options.js +1 -9
  540. package/dist/sdk/lifecycle/plan.js +1 -1606
  541. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -147
  542. package/dist/sdk/lifecycle/reopen.js +1 -68
  543. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +1 -143
  544. package/dist/sdk/lifecycle/restore.d.ts +1 -0
  545. package/dist/sdk/lifecycle/restore.js +1 -330
  546. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -295
  547. package/dist/sdk/lifecycle/update-many.js +1 -861
  548. package/dist/sdk/lifecycle/update.js +1 -2136
  549. package/dist/sdk/lifecycle-completion.js +1 -92
  550. package/dist/sdk/lifecycle-policy.js +1 -120
  551. package/dist/sdk/linked-artifacts.js +1 -530
  552. package/dist/sdk/mcp/apps.js +4 -133
  553. package/dist/sdk/mcp/authorization.js +1 -404
  554. package/dist/sdk/mcp/discovery.js +1 -494
  555. package/dist/sdk/mcp/interactions.js +1 -336
  556. package/dist/sdk/mcp/protocol.d.ts +7 -0
  557. package/dist/sdk/mcp/protocol.js +1 -184
  558. package/dist/sdk/mcp/skills.js +1 -389
  559. package/dist/sdk/mcp/subscriptions.js +1 -211
  560. package/dist/sdk/mcp/tasks.js +2 -430
  561. package/dist/sdk/mcp/transport.js +1 -260
  562. package/dist/sdk/merge/abandoned-receipts.js +1 -46
  563. package/dist/sdk/merge/driver.js +1 -212
  564. package/dist/sdk/merge/index.js +1 -16
  565. package/dist/sdk/merge/install.js +3 -561
  566. package/dist/sdk/merge/receipt-file-boundary.js +1 -46
  567. package/dist/sdk/merge/receipt-operation.js +1 -96
  568. package/dist/sdk/merge/receipt-schema.js +1 -397
  569. package/dist/sdk/merge/receipts.js +4 -525
  570. package/dist/sdk/merge/reconcile.js +1 -352
  571. package/dist/sdk/merge/three-way.js +3 -775
  572. package/dist/sdk/merge.js +1 -10
  573. package/dist/sdk/mutation-events.js +1 -292
  574. package/dist/sdk/mutation-guard.js +1 -216
  575. package/dist/sdk/notes.js +1 -139
  576. package/dist/sdk/output-contracts.js +1 -172
  577. package/dist/sdk/output-projection.js +1 -430
  578. package/dist/sdk/output-token-accounting.js +1 -140
  579. package/dist/sdk/output.js +1 -64
  580. package/dist/sdk/ownership-source.js +1 -21
  581. package/dist/sdk/package-import-adapters.js +1 -442
  582. package/dist/sdk/package-migrations.js +1 -20
  583. package/dist/sdk/package-runtime-options.js +1 -80
  584. package/dist/sdk/pagination.js +1 -162
  585. package/dist/sdk/profile.js +1 -454
  586. package/dist/sdk/provenance.js +1 -258
  587. package/dist/sdk/public-surface.json +1 -1
  588. package/dist/sdk/query/activity.js +1 -401
  589. package/dist/sdk/query/aggregate.d.ts +16 -0
  590. package/dist/sdk/query/aggregate.js +1 -390
  591. package/dist/sdk/query/calendar.js +1 -964
  592. package/dist/sdk/query/complete-list.js +1 -215
  593. package/dist/sdk/query/context.js +1 -1702
  594. package/dist/sdk/query/duplicate-candidates.js +1 -70
  595. package/dist/sdk/query/get.js +1 -450
  596. package/dist/sdk/query/history.js +1 -186
  597. package/dist/sdk/query/item-filter-options.js +1 -9
  598. package/dist/sdk/query/light-metadata.js +1 -18
  599. package/dist/sdk/query/list-filter-shared.js +1 -81
  600. package/dist/sdk/query/list.js +1 -1304
  601. package/dist/sdk/query/multi-value-filters.js +1 -78
  602. package/dist/sdk/query/next.js +1 -513
  603. package/dist/sdk/query/parsers.js +1 -44
  604. package/dist/sdk/query/projection-contracts.js +1 -184
  605. package/dist/sdk/query/search-contracts.js +1 -230
  606. package/dist/sdk/query/search-pagination.js +1 -35
  607. package/dist/sdk/query/search-rendering.js +1 -105
  608. package/dist/sdk/query/search.js +2 -1987
  609. package/dist/sdk/query.js +1 -35
  610. package/dist/sdk/read-output/continuation.js +1 -194
  611. package/dist/sdk/read-output-budget.js +1 -135
  612. package/dist/sdk/read-output-contracts.js +1 -1225
  613. package/dist/sdk/read-output-rows.js +1 -186
  614. package/dist/sdk/read-output-session.js +1 -208
  615. package/dist/sdk/relationship-analytics.js +1 -410
  616. package/dist/sdk/relationship-context.js +1 -284
  617. package/dist/sdk/relationship-history.js +4 -519
  618. package/dist/sdk/relationship-kinds/contract.js +1 -22
  619. package/dist/sdk/relationship-migration.js +1 -77
  620. package/dist/sdk/relationships.js +1 -579
  621. package/dist/sdk/reproducibility/process.js +1 -87
  622. package/dist/sdk/runtime-action-aliases.js +1 -59
  623. package/dist/sdk/runtime-extended-actions.js +1 -177
  624. package/dist/sdk/runtime-input.js +1 -614
  625. package/dist/sdk/runtime-primitives.js +1 -84
  626. package/dist/sdk/runtime-public-contracts.js +1 -4
  627. package/dist/sdk/runtime-stats-options.js +1 -38
  628. package/dist/sdk/runtime.js +1 -1928
  629. package/dist/sdk/scheduling-shortcuts.js +1 -63
  630. package/dist/sdk/schema-migration.js +3 -856
  631. package/dist/sdk/schema.js +1 -1376
  632. package/dist/sdk/search-refresh-worker.js +1 -18
  633. package/dist/sdk/similarity-scoring.js +1 -53
  634. package/dist/sdk/similarity.js +1 -326
  635. package/dist/sdk/start-task-status.js +1 -14
  636. package/dist/sdk/stats.js +1 -270
  637. package/dist/sdk/structured-mutations.js +1 -580
  638. package/dist/sdk/telemetry-flush.js +1 -13
  639. package/dist/sdk/telemetry.js +1 -405
  640. package/dist/sdk/templates.js +2 -292
  641. package/dist/sdk/test/batch.js +2 -509
  642. package/dist/sdk/test/entry.js +1 -70
  643. package/dist/sdk/test/execution.js +6 -2211
  644. package/dist/sdk/test/linked-command-detection.js +1 -546
  645. package/dist/sdk/test/measurements.js +1 -91
  646. package/dist/sdk/test/parsers.js +1 -545
  647. package/dist/sdk/test/runs.js +1 -193
  648. package/dist/sdk/test/trust.js +2 -206
  649. package/dist/sdk/testing.js +4 -1391
  650. package/dist/sdk/traceability/runtime-files-lookup.js +1 -32
  651. package/dist/sdk/traceability/source-traceability.js +1 -292
  652. package/dist/sdk/tracker-root-discovery.js +1 -9
  653. package/dist/sdk/workspace-contracts-cache.js +1 -28
  654. package/dist/sdk/workspace-contracts.js +1 -33
  655. package/dist/sdk/workspace-memory.js +2 -318
  656. package/dist/sdk/workspace-recipe.js +1 -71
  657. package/dist/sdk/workspace-snapshot.js +4 -613
  658. package/dist/sdk/workspace-transaction-gc.js +1 -149
  659. package/dist/sdk/workspace-transaction.js +2 -363
  660. package/dist/sdk/workspace.js +3 -127
  661. package/dist/types/index.js +1 -9
  662. package/dist/types.js +1 -245
  663. package/docs/AGENT_GUIDE.md +1 -1
  664. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +167 -0
  665. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +9 -3
  666. package/docs/EXTENSIONS.md +1 -0
  667. package/docs/HISTORY_MAINTENANCE.md +125 -0
  668. package/docs/MCP_2026_07_28_CONFORMANCE.md +20 -10
  669. package/docs/PACKAGE_EVIDENCE.md +92 -0
  670. package/docs/PLANNING_MEASUREMENTS.md +183 -0
  671. package/docs/README.md +3 -0
  672. package/docs/SCRIPTING.md +21 -0
  673. package/docs/TESTING.md +23 -0
  674. package/docs/generated/FLAG_LEXICON_BUDGETS.md +5 -5
  675. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +2 -2
  676. package/marketplace.json +2 -2
  677. package/package.json +1 -1
  678. package/packages/pm-beads/package.json +1 -1
  679. package/packages/pm-calendar/package.json +1 -1
  680. package/packages/pm-command-kit/package.json +1 -1
  681. package/packages/pm-digital-twin/package.json +1 -1
  682. package/packages/pm-governance-audit/package.json +1 -1
  683. package/packages/pm-guide-shell/package.json +1 -1
  684. package/packages/pm-kanban/package.json +1 -1
  685. package/packages/pm-lifecycle-hooks/package.json +1 -1
  686. package/packages/pm-linked-test-adapters/package.json +1 -1
  687. package/packages/pm-search-advanced/package.json +1 -1
  688. package/packages/pm-templates/package.json +1 -1
  689. package/packages/pm-todos/package.json +1 -1
  690. package/packages/pm-vcs/package.json +1 -1
  691. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  692. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  693. package/scripts/finalize-build.mjs +45 -3
  694. package/dist/cli-bundle/chunks/chunk-AZDFJGH6.js +0 -9
  695. package/dist/cli-bundle/chunks/chunk-BAX2BYUW.js +0 -2111
  696. package/dist/cli-bundle/chunks/chunk-CKOL5U7J.js +0 -77
  697. package/dist/cli-bundle/chunks/chunk-OF76PSDQ.js +0 -5
  698. package/dist/cli-bundle/chunks/chunk-QUWFABDM.js +0 -232
  699. package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +0 -2
  700. package/dist/cli-bundle/chunks/chunk-RWWBOWJ5.js +0 -2
  701. package/dist/cli-bundle/chunks/chunk-WGAOYSYH.js +0 -40
  702. package/dist/cli-bundle/chunks/chunk-WI2AYPA7.js +0 -2
  703. package/dist/cli-bundle/chunks/register-list-query-5JL52D33.js +0 -11
  704. package/dist/cli-bundle/chunks/register-mutation-ZPG7KMVP.js +0 -20
  705. package/dist/cli-bundle/chunks/register-setup-H4SVAVX7.js +0 -2
  706. package/dist/cli-bundle/focused-chunks/chunk-AL5ON6K6.js +0 -2
  707. package/dist/cli-bundle/focused-chunks/chunk-CHC2IDXA.js +0 -6
  708. package/dist/cli-bundle/focused-chunks/chunk-CK6QFAPZ.js +0 -20
  709. package/dist/cli-bundle/focused-chunks/chunk-EZR3GHFE.js +0 -2
  710. package/dist/cli-bundle/focused-chunks/chunk-H2WJWK7L.js +0 -56
  711. package/dist/cli-bundle/focused-chunks/chunk-NTPY5GSO.js +0 -3
  712. package/dist/cli-bundle/focused-chunks/chunk-P5O7MP5Y.js +0 -2
  713. package/dist/cli-bundle/focused-chunks/chunk-PDMW2E36.js +0 -177
  714. package/dist/cli-bundle/focused-chunks/chunk-QTVCLMSZ.js +0 -6
  715. package/dist/cli-bundle/focused-chunks/chunk-QTZRBUYA.js +0 -8
  716. package/dist/cli-bundle/focused-chunks/chunk-SGQST3PQ.js +0 -12
  717. package/dist/cli-bundle/focused-chunks/chunk-UKHASMMP.js +0 -10
  718. package/dist/cli-bundle/focused-chunks/chunk-ZPEKQHOC.js +0 -2
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import{A as Wt,B as ar,C as Bt,E as sr,d as qo,h as q,i as Oe,j as P,k as tr,l as k,m as nr,r as rt,s as or,t as rr,v as ir,w as Q,x as Ht,y as zt,z as Gt}from"./chunks/chunk-RWWBOWJ5.js";import{A as Go,Wa as er,f as zo}from"./chunks/chunk-BAX2BYUW.js";import"./chunks/chunk-JX4DH4WC.js";import"./chunks/chunk-OF76PSDQ.js";import{Ic as Yo,gc as Jo,jd as ot,md as Xo,nd as Zo,od as Z,pd as Qo}from"./chunks/chunk-WGAOYSYH.js";import{Ea as Ko,ma as Vo}from"./chunks/chunk-CKOL5U7J.js";import"./chunks/chunk-AZDFJGH6.js";import"./chunks/chunk-WYRZZ5ZE.js";import{$a as z,$m as Ho,$n as Bo,Ac as co,Af as bo,Ag as Eo,Bc as lo,Bg as So,Bn as nt,C as g,Cc as V,Cn as jt,D as Et,Dc as mo,Dn as Ut,E as v,Ec as uo,En as Te,Fc as Y,Fe as Je,Fn as $,G as xe,Gc as po,Gn as Wo,Hc as Be,Hf as Xe,Hn as qt,Ic as se,Jc as ce,K as St,Kd as It,Ki as Ro,Li as me,Mc as fo,Mi as I,Na as Tt,Nc as Ve,Ng as Ao,Ni as Io,Nn as D,Oj as Po,Pb as to,Pj as Nt,Qa as J,Qj as Mt,Rg as To,Rj as Dt,Sa as Qn,Sj as ke,Ta as We,Tc as Rt,Te as S,Tj as Ft,Uc as Ke,Ue as Ye,Uj as No,Vc as go,Vj as Ee,Wa as Ot,Wc as ho,Xa as eo,Xb as no,Ya as R,Yj as Mo,Zb as oo,Zj as Do,aa as Kn,an as tt,ba as Jn,bh as X,c as H,ca as At,ch as Oo,dh as de,dj as Ze,ej as $o,fh as Pt,fl as Qe,gh as w,hg as xo,hl as Ae,ig as $t,il as et,ja as Yn,ka as Xn,kk as Se,lc as ro,ma as Zn,mc as ve,nk as Fo,oc as Ce,pc as io,qk as Lo,vk as Lt,we as yo,wk as jo,xe as wo,xf as le,xg as vo,xk as Uo,yc as ao,yf as _o,yg as Co,zc as so,zg as ko}from"./chunks/chunk-QUWFABDM.js";import{Command as Nn,CommanderError as Qc}from"commander";(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]="8eca3029-0d1f-569a-84ce-5ccd0b92a272")}catch{}})();var Oa=new Set(["__proto__","prototype","constructor"]),cr=Symbol("looseOptionOccurrences");function Re(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,o)=>o.toUpperCase())}function Ra(e,t,n){let o=e[t];if(o===void 0){e[t]=n;return}if(Array.isArray(o)){o.push(n),e[t]=o;return}e[t]=[o,n]}function Vt(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let a=n.indexOf("=");if(a>=0)return{consumed:1,key:n.slice(1,a).trim(),value:n.slice(a+1)};let s=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:s,value:c}:{consumed:1,key:s,value:!0}}let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(2,o).trim(),value:n.slice(o+1)};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let r=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:r,value:i}:{consumed:1,key:r,value:!0}}function it(e){return Oa.has(e)}function lr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Kn(t)}function Ie(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let r=Re(n.slice(2));r.length>0&&!it(r)&&t.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){let r=Re(o.slice(1));r.length>0&&!it(r)&&t.push(r)}return[...new Set(t)]}function dr(e){let t=new Set;for(let n of e)for(let o of Ie(n))t.add(o);return t}function Ia(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Re(t.slice(2));if(n.length>0&&!it(n))return n}return Ie(e)[0]??null}function $a(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Kt(e,t,n){if(t.length===0)return;let o=new Set,r=new Map,i=[],a=[];for(let s of t){let c=Ie(s),d=$a(s);d!==null&&a.push(d);for(let l of c)o.add(l),s.enabled===!1&&r.set(l,d);s.required===!0&&s.enabled!==!1&&c.length>0&&i.push({keys:c,label:d})}for(let s of Object.keys(e)){if(!o.has(s)){let d=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new v(`Unknown option '--${s}' for extension command '${n}'.${d}`,g.USAGE)}let c=r.get(s);if(c)throw new v(`Option '${c}' is disabled for extension command '${n}'.`,g.USAGE)}for(let s of i)if(!s.keys.some(c=>Object.hasOwn(e,c)))throw new v(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function Pa(e){return typeof e=="string"||e==null?e:String(e)}function Na(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Ma(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var Da={string:Pa,number:Na,boolean:Ma};function at(e,t){return Array.isArray(e)?e.map(n=>at(n,t)):Da[t](e)}function mr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):Jn(e);return t?o.map(r=>at(r,t)):o}function Fa(e,t,n,o){return n?mr(e,t,o):t?at(e,t):e}function La(e,t,n){let o=e[cr];if(!o||o.length===0)return n;let r=new Set(t);return o.filter(i=>r.has(i.key)).map(i=>i.value)}function ur(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[r,i]of Object.entries(e))o[r]=i;for(let r of t){let i=Ia(r);if(!i)continue;let a=r.list===!0,s=Ie(r);for(let l of s)if(!(l===i||!Object.hasOwn(o,l))){if(Object.hasOwn(o,i)){if(!a){delete o[l];continue}let m=o[i],u=o[l];o[i]=[...Array.isArray(m)?m:[m],...Array.isArray(u)?u:[u]].filter(p=>p!=null),delete o[l];continue}o[i]=o[l],delete o[l]}let c=lr(r),d=r.repeatable===!0;if(!Object.hasOwn(o,i)){r.default!==void 0&&(o[i]=Fa(r.default,c,a,d));continue}if(a){o[i]=mr(La(n,s,o[i]),c,d);continue}c&&(o[i]=at(o[i],c))}return o}function pr(e){let t=Object.create(null),n=[];Object.defineProperty(t,cr,{value:n});let o=0;for(;o<e.length;){let r=Vt(e,o);if(!r){o+=1;continue}let i=Re(r.key);if(i.length===0||it(i)){o+=r.consumed;continue}Ra(t,i,r.value),n.push({...r,key:i}),o+=r.consumed}return t}function fr(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Vt(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Jt(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=lr(a);for(let c of Ie(a))n.add(c),s==="boolean"&&o.add(c)}if(n.size===0)return[...e];let r=[],i=0;for(;i<e.length;){if(e[i]==="--"){r.push(...e.slice(i+1));break}let a=Vt(e,i);if(a){let s=Re(a.key);if(n.has(s)){let c=e[i],d=o.has(s)&&!c.includes("=")?1:a.consumed;i+=d;continue}}r.push(e[i]),i+=1}return 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]="c0186e30-9c25-5539-b778-1ef2ee21764a")}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]="1399e88f-710a-5e5c-b4b3-70e35ec401cf")}catch{}})();var gr=new WeakMap;function hr(e,t){gr.set(e,t)}function ee(e){return gr.get(e)}function yr(e){return e.length>0?[e[0]]:[]}function ja(e){let t=["","Intent:",` ${e.why}`],n=yr(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
3
- `)}function Ua(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
4
- `)}function wr(e,t){return t==="detailed"?Ua(e):ja(e)}function N(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var qa={cal:"calendar",ctx:"context"};function Ha(e,t){return e.commands.find(n=>n.name()===t)??null}function za(e,t){let n=e;for(let o of t){let r=Ha(n,o);if(!r)return null;n=r}return n}function Yt(e,t,n,o){let r=za(e,t.split(" ").filter(i=>i.length>0));r&&r.addHelpText("after",wr(n,o))}function Zt(e){return e.includes("--explain")?"detailed":"compact"}function ue(e){return e.includes("--all")||e.includes("--explain")}var _r={init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm install ./my-package --project","pm install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm extension explore --project","pm extension manage --global","pm extension describe sample-ext --project","pm extension doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm extension init ./my-extension","pm extension init ./my-hook-extension --capability hooks","pm extension init ./my-search-extension --capability search","pm extension init ./my-sync-extension --capability importers","pm extension init ./my-domain-extension --capability schema","pm extension init ./my-output-extension --capability renderers","pm extension --install --project ./my-sync-extension","pm extension --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm extension install ./my-extension --project","pm extension --install --project ./my-extension","pm extension doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm extension doctor --project --detail summary","pm extension doctor --project --detail deep --trace","pm extension doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm extension catalog --project","pm extension catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm install '*' --project","pm install ./packages/pm-todos --project","pm install npm:@scope/pm-package --global","pm install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm upgrade --dry-run","pm upgrade --packages-only --project","pm upgrade todos --dry-run","pm upgrade --cli-only --repair","pm upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list-all --limit 50","pm list-all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list-open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list-in-progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list-blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list-closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list-canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list-draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' in one read: the single highest-priority ready item with rationale, plus the ranked ready and blocked queues (project management = context management).",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspects item mutation timeline and audit trail.",examples:["pm history pm-a1b2 --limit 20","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "All acceptance criteria met" --message "Close after verification"','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list-all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list-all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:['pm claim pm-a1b2 --message "Claim for implementation"','pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim takeover for non-terminal items does not require --force; --force is reserved for terminal/lock overrides.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:['pm release pm-a1b2 --message "Release after closure"']},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm start-task pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm pause-task pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close-task pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}},Xt={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm install guide-shell --project","pm list-open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]};function Ga(e){let t=N(e??"");return t?qa[t]??t:""}function Wa(e){let t=Ga(e);return t?_r[t]??Xt:Xt}function br(e,t){let n=Wa(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:yr(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function Ba(){let e=le.filter(({lifecycle:n})=>n==="permanent"),t=le.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${bo(n)})`)].join(`
5
- `)}function Va(e,t,n,o){let r=new Set(Xo);e.configureHelp({visibleCommands(i){let a=t.visibleCommands(i);return n?a.filter(s=>(ee(s)??Z(s.name()))!=="internal"):i!==e?a:a.filter(s=>o.has(s))},visibleOptions(i){let a=t.visibleOptions(i);return i!==e||n?a:a.filter(s=>r.has(s.flags))}})}function Ka(e,t,n,o){let r=new Set(Qo("core")),i=e.createHelp();i.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let a=()=>`${i.formatHelp(e,i)}${o}
6
- `,s=t.visibleCommands(e);for(let c of s)ee(c)===void 0&&(c.name()==="help"||r.has(c.name()))&&n.add(c);for(let c of s)ee(c)==="core"&&(n.add(c),Zo(a()).within_budget||n.delete(c))}function xr(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ue(t),r=new Set;Va(e,n,o,r);let i=Zt(t),a=wr(Xt,i);e.addHelpText("after",a),o&&e.addHelpText("after",Ba()),Ka(e,n,r,a);for(let[l,m]of Object.entries(_r))Yt(e,l,m,i);let s=N(P(t).commandPathTokens.join(" ")),c=Ae(s);if(c){Yt(e,c.parent,{why:c.description,examples:[c.example],tips:[`Action path: pm ${c.command}`,et(c.accepted_flags)]},i);return}let d=Qe.filter(({parent:l})=>l===s);d.length>0&&Yt(e,s,{why:`Dispatches one declared positional action: ${d.map(({action:l})=>l).join("|")}.`,examples:d.map(({example:l})=>l),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="095bd18e-bfc9-58d8-bcdc-14f47f7a238a")}catch{}})();async function vr(e,t){await jo(e,{ok:t.ok,error:t.error,result:ce(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function Cr(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Ao({pmRoot:e.pmRoot,result:ce()})}catch(o){t=o}let n=await I(e.pmRoot);if(await To({pmRoot:e.pmRoot,author:Je(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw 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]="1b6eea75-9da4-5cc1-9e26-dde9fcb863d1")}catch{}})();function F(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function te(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return F(t)}function K(e){let t=new Set,n=[];for(let o of e){let r=te(o);r&&(t.has(r)||n.push(r),t.add(r))}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]="ca79853d-468c-5522-b5f9-6509c66e3d9b")}catch{}})();function lt(e){let{why:t,title:n,...o}=e;return o}var Ja=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function Ya(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Ja.has(e.code)}function Tr(e){return`urn:pm-cli:error:${e}`}function x(e){return{...e,type:Tr(e.code)}}var pe={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},kr={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Er={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},st={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Xa={guide:pe,shell:pe,completion:pe,"completion-statuses":pe,"completion-tags":pe,"completion-types":pe,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:kr,cal:kr,reindex:Er,"search-advanced":Er,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":st,"dedupe-audit":st,"dedupe-merge":st,normalize:st};function Za(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Xa[t]}function Qt(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function Qa(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function es(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function en(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function G(e,t,n){if(t==="parsed_positionals"){if(!Array.isArray(n))return;let r=n.map(i=>({role:typeof i?.role=="string"?i.role.trim():"",value:typeof i?.value=="string"?i.value.trim():""})).filter(i=>i.role.length>0&&i.value.length>0);r.length>0&&(e.parsed_positionals=r);return}let o=Qa(n);o&&(e[t]=o)}function fe(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),en(t,"attempted_command",e.attempted_command),G(t,"normalized_args",e.normalized_args),G(t,"parsed_positionals",e.parsed_positionals),G(t,"provided_fields",e.provided_fields),G(t,"missing",e.missing),G(t,"missing_required_fields",e.missing_required_fields),G(t,"suggested_flags",e.suggested_flags),G(t,"allowed_values",e.allowed_values),G(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),en(t,"suggested_retry",e.suggested_retry),G(t,"suggested_retry_args",e.suggested_retry_args),typeof e.retry_after_ms=="number"&&Number.isSafeInteger(e.retry_after_ms)&&e.retry_after_ms>=0&&(t.retry_after_ms=e.retry_after_ms);let n=es(e.fallback_candidates);return n&&(t.fallback_candidates=n),en(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function tn(e,t,n){n&&e.push(` ${t}: ${n}`)}function ne(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function ts(e){let t=fe(e);if(!t)return[];let n=["Recovery bundle:"];if(tn(n,"suggested_retry",t.suggested_retry),tn(n,"attempted_command",t.attempted_command),ne(n,"normalized_args",t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(ne(n,"provided_fields",t.provided_fields,", "),ne(n,"missing",t.missing,", "),ne(n,"missing_required_fields",t.missing_required_fields,", "),ne(n,"suggested_flags",t.suggested_flags,", "),ne(n,"allowed_values",t.allowed_values,", "),ne(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),typeof t.retry_after_ms=="number"&&n.push(` retry_after_ms: ${t.retry_after_ms}`),tn(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}function Or(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...Qt("Next steps:",e.nextSteps))),t.push("","What happened:",` ${e.happened}`),e.why&&(t.push("","Why:"),t.push(` ${e.why}`)),e.examples&&e.examples.length>0&&(t.push(""),t.push(...Qt("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...Qt("Verification errors:",e.verificationErrors)));let n=ts(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
7
- `)}function Rr(e,t){return Ya(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function ns(e,t){if(e.flag)return e.flag;let n=r=>{let i=r.split("=",1)[0];return Oe([i]).length>0&&!["--help","--no-changed-fields","--version"].includes(i)&&t.some(a=>a===i||a.startsWith(`${i}=`))},o=[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(r=>r[0]).find(r=>n(r));return o||e.recovery?.provided_fields?.map(r=>r.split("=",1)[0]).find(r=>n(r))}function os(e,t,n){if(e.value!==void 0)return e.value;if(n){let r=t.find(a=>a===n||a.startsWith(`${n}=`));if(r?.startsWith(`${n}=`))return r.slice(n.length+1);let i=t.indexOf(n);return i>=0?t[i+1]:void 0}let o=e.recovery?.allowed_values;if(o?.length)return t.find((r,i)=>i>0&&!r.startsWith("-")&&!o.includes(r))}function rs(e,t){let n=e.recovery?.normalized_args??[],o=ns(e,n),r=os(e,n,o);return{surface:o??e.recovery?.missing?.[0]??Ir(e.recovery)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function is(e,t){return Rr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:rs(e,t)},e)}function on(e,t){let n=e.recovery,o=!!n?.suggested_retry||!!n?.suggested_retry_args?.length||!!n?.allowed_values?.length||!!n?.candidate_commands?.length||!!e.nextSteps?.length;return xo(is(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function rn(e){return Rr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function dt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function as(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function oe(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Sr(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function Ir(e){return rr(e?.normalized_args)}function ss(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function cs(e,t){let n=e?.normalized_args,o=e?.provided_fields,r=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!r))for(let i of o){let a=n.findIndex(s=>s===i);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=r,S(s)}}}function ls(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function ct(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function W(e,t,n){if(!n)return e;let o=dt(t),r=ct(n.code,e.code),i=ct(n.type,Tr(r)),a=oe(n.examples)??e.examples,s=oe(n.nextSteps)??e.nextSteps,c=oe(n.verification_errors)??e.verificationErrors,d=e.code==="command_failed"&&n.code?ls(o):void 0,l=fe(n.recovery),m=l&&e.recovery?fe({...e.recovery,...l}):l??e.recovery;return{...e,code:r,type:i,title:d??e.title,happened:o.length>0?o:e.happened,required:ct(n.required,e.required),why:ct(n.why,e.why),examples:a,nextSteps:s,verificationErrors:c,flag:n.flag,value:n.value,unmatchedSelectors:n.unmatched_selectors,availableDependencies:n.available_dependencies,recovery:m}}function ds(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let r=o[1],i=eo(process.cwd(),r);return W(x(i?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${r}, but found a tracker at ${i}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${i} <command>`,`PM_PATH=${i} pm <command>`],nextSteps:[`Re-run with "--pm-path ${i}" or export PM_PATH=${i}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function ms(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let r=o[1],i=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(r),a=i?`The item ID "${r}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${r}" exists in the active tracker scope.`;return W(x({code:"item_not_found",title:"Item ID not found",happened:a,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:i?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function us(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:W(x({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function ps(e,t,n){return t.includes("is locked")?W(x({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, or use --force where supported if lock is stale and safe to override.",why:"Locking protects item files from concurrent write races.",examples:["pm update pm-a1b2 --status in_progress --force"]}),e,n):null}function fs(e,t,n){let o=t.match(/^Missing required option /),r=t.match(/^Missing required options /);if(!o&&!r)return null;let i=!!r,a=i?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",c=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return W(x({code:"missing_required_option",title:i?"Missing required options":`Missing required option ${s}`,happened:t,required:i?"Provide every required option for this command invocation.":c,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function gs(e,t,n){return t.startsWith("No update flags provided")?W(x({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function hs(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=fe(n?.recovery),r=Ir(o),i=r?`pm ${r} --help`:"pm <command> --help",a=ss(t),s=fe({...o,allowed_values:o?.allowed_values??a}),c=cs(o,a),d=c?[c,i]:[i,"pm contracts --command <command> --flags-only --json"],l=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${i}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return W(x({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:d,nextSteps:l,recovery:s}),e,n)}function an(e,t){let n=dt(e),o=ds(e,n,t)??ms(e,n,t)??us(e,n,t)??ps(e,n,t)??fs(e,n,t)??gs(e,n,t)??hs(e,n,t);return o||W(x({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function ys(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function ws(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function _s(e){if(!(!Array.isArray(e)||e.length===0))return S(e)}function sn(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function L(e,t={}){let n=sn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,r=typeof e?.attemptedCommand=="string"?e.attemptedCommand:_s(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return fe({attempted_command:r,normalized_args:o,provided_fields:n,suggested_retry:i,...t})}function nn(e,t){return!t||e.includes(t)?e:[...e,t]}var bs=new Set(["--add","--add-json","--remove"]),xs=new Set(["command","cmd","path"]);function vs(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if(bs.has(o))return o}}function Cs(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let r=e[o];if(r!=="--add"&&r!=="--remove")continue;let i=e[o+1];if(typeof i!="string"||!xs.has(i))return;let a=[];for(let d=o+2;d<e.length;d+=1){let l=e[d];if(l.startsWith("--")&&l.length>2)break;a.push(l)}if(a.length<2)return;let s=`${i}=${a.join(" ")}`,c=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return S(c)}}function ks(e,t,n,o){let r=e.match(/required option '([^']+)' not specified/);if(!r)return null;let i=ws(r[1]),a=i.startsWith("--type"),s=o?.suggestedRetryCommand,c=sn(o?.providedOptionFlags),d=[i],l=ys(t,i,n),m=s?nn(l,s):l,u=a?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],p=s?nn(u,`Replay with preserved arguments: ${s}`):u,f=c&&c.length>0?nn(p,`Already provided options: ${c.join(", ")}`):p;return x({code:"missing_required_option",title:`Missing required option ${i}`,happened:`Commander rejected the command because ${i} was not provided.`,required:`Pass ${i} with a valid value before running the command.`,why:a?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:L(o,{missing:d})})}function Es(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let r=o[1];return x({code:"missing_required_argument",title:`Missing required argument ${r}`,happened:`Command invocation omitted positional argument ${r}.`,required:`Provide ${r} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:L(n,{missing:[r]})})}function Ss(e,t,n){return x({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:L(t,{suggested_flags:n})})}var As={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function Ts(e){let t=oe(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Os(e,t,n,o,r){let i=o.otherCommands.slice(0,3),a=o.candidateTotal-i.length,s=a>0?` and ${String(a)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,i.length?`${e} is accepted by ${i.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,r?`Replay with suggested correction: ${r}`:void 0].filter(c=>typeof c=="string")}function Rs(e,t){if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(i=>i===t||i.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(i=>i===t||i.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let r=Oe(n.filter((i,a)=>a!==o));return{retryCommand:S(r),suggestedRetryArgs:r}}function Is(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let r=n??{},i=o[1],a=sn(r.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:c}=Rs(r,i);if(t==="update"&&(i==="--file"||i==="--doc"))return Ss(i,n,a);let d=Ts(r),l=Os(i,t,a,d,s),m=[s,`pm ${t??"<command>"} --help`].filter(u=>typeof u=="string");return x({code:"unknown_option",title:`Unknown option ${i}`,happened:`Commander does not recognize option ${i} for this command path.`,required:As[d.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:l,recovery:L(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:c,candidate_commands:d.otherCommands,candidate_commands_total:d.candidateTotal||void 0,candidate_commands_truncated:r.unknownOptionOtherCommandsTruncated,option_scope:d.optionScope})})}function $s(e,t,n,o,r){let i=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,a=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return x({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:Sr([t.installCommand,...n]),nextSteps:Sr([i,...a]),recovery:L(r)})}function Ps(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],r=oe(t?.unknownCommandExamples),i=oe(t?.unknownCommandNextSteps),a=Za(o),s=r??["pm --help"],c=i??["Verify spelling and active extensions, then rerun."],d=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),l=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!l||!d.has(l))?$s(o,a,s,c,t):x({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:c,recovery:L(t)})}function Ns(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=oe(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let r=e?.suggestedRetryCommand;return x({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...r?[r]:[],`pm ${t} --help`],nextSteps:r?[`Retry with the declared hyphenated action: ${r}`]:["Choose one value from recovery.allowed_values."],recovery:L(e,{allowed_values:o,suggested_retry:r})})}function Ms(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,r=vs(o);if(!r)return null;let i=Cs(o);return x({code:"linked_test_value_not_quoted",title:`Linked-test ${r} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${r} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${r} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...i?[i]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...i?[`Replay with the value re-joined into one argument: ${i}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:L(n,i?{suggested_retry:i}:{})})}var Ds=new Set(["comments","docs","files","learnings","notes","test"]);function Fs(e,t,n){if(!/too many arguments/i.test(e)||!Ds.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],r=o.findIndex(d=>d===t),i=o[r+1],a=o[r+2],s=n?.verifiedCollectionItemId?.trim();if(i?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let c=`pm ${t} ${s} --add <value>`;return x({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[c,`pm ${t} --help`],recovery:L(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:c})})}var Ls=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),Ar=new Set(["context","ctx"]);function js(e,t,n){if(!/too many arguments/i.test(e)||!Ar.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],r=o.findIndex(d=>Ar.has(d)),i=r===-1?1:r+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let d=!1;for(let l of o.slice(i)){if(d){d=!1;continue}let m=l.split("=")[0];if(Ls.has(m)){d=!l.includes("=");continue}if(!l.startsWith("-")){s=l;break}}}if(!s)return null;let c=`pm get ${s}`;return x({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${c} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[c,`pm context --parent ${s}`],recovery:L(n,{suggested_retry:c})})}function cn(e,t,n,o){let r=dt(e),i=ks(r,t,n,o)??Es(r,t,o)??Is(r,t,o)??Ps(r,o)??Ns(o)??Fs(r,t,o)??Ms(r,t,o)??js(r,t,o);return i||x({code:"invalid_command_usage",title:"Invalid command usage",happened:r,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:L(o)})}function $r(e,t){let n=an(e,t);return $t(Or(n),n.required).output}function Pr(e,t){return rn(an(e,t))}function ln(e,t,n){return on(an(e,n),t)}function Nr(e,t,n,o){let r=cn(e,t,n,o);return $t(Or(r),r.required).output}function dn(e,t,n,o){return rn(cn(e,t,n,o))}function mt(e,t,n,o,r){return on(cn(e,t,n,r),o)}function Mr(e,t){let n=Dr(e);return on(n,t)}function Dr(e){let t=dt(e);return as(t)?x({code:"module_import_failed",title:"Module import failed",happened:t,required:"Ensure the active checkout is built and any package or extension entry file exists before retrying.",why:"Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",examples:["pnpm build","pm package manage --doctor --project","pm health --check-only --json"],nextSteps:["Rebuild the checkout or package that provides the missing module.","Run package doctor for installed extensions when the failure follows package installation or activation.","Rerun the original pm command after the runtime files are present."]}):x({code:"unknown_error",title:"Unhandled error",happened:t,required:"Inspect command input and runtime state, then retry.",why:"Unexpected runtime failures can occur from environment or extension-level issues.",examples:["pm --help","pm health --json"]})}function Fr(e){return rn(Dr(e))}import{Option as Us}from"commander";(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]="99d39b7c-ec26-5c95-85c0-ac28112a6fe6")}catch{}})();function _(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function jr(e,t){let n=new Map;for(let o of e){let r=_(o.command);for(let i of t){if(i.layer!==o.layer||i.name!==o.name)continue;let a=_(i.command),s=a.split(" "),c=s.at(-1),d=s.slice(1).join(" "),l=d?`${s[0]}-${c} ${d}`:`${s[0]}-${c}`;if(c&&r===l){n.set(r,a);break}}}return n}function mn(e,t,n,o){if(!t||!n)return;let r,i=0;for(let[s,c]of e.entries()){if(c!==t)continue;let d=e.slice(s);for(let[l,m]of o.entries()){let u=l.split(" ");u.length>i&&u.every((p,f)=>d[f]===p)&&(r=m,i=u.length)}}let a=r?.flags.find(s=>s.long===n||s.short===n);if(a)return ut(a).takesValue}function A(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function B(e){return typeof e=="boolean"?e:void 0}function ut(e){let t=A(e.value_type)??A(e.type),n=A(e.value_name),o=t!=="boolean"&&(n!==null||t!==null||B(e.required)===!0||B(e.list)===!0);return{takesValue:o,valueName:o?n??"value":null}}function qs(e){if(B(e.visible)===!1)return null;let n=A(e.long);if(!n||!n.startsWith("--")||n.length<3)return null;let o=A(e.short),r=o&&o.startsWith("-")&&!o.startsWith("--")?`${o}, `:"",i=A(e.value_name),a=i?` <${i}>`:"",s=A(e.description)??"Extension-provided option.",c=[];B(e.required)===!0&&c.push("required"),B(e.enabled)===!1&&c.push("disabled");let d=c.length>0?` [${c.join(", ")}]`:"";return`${r}${n}${a} ${s}${d}`}function Ur(e){let t=[...new Set(e.map(qs).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
2
+ import{A as sr,B as Kt,D as cr,d as zo,g as q,h as pe,i as P,j as it,k,l as or,q as at,r as rr,s as ir,u as ar,v as Q,w as Gt,x as Wt,y as Bt,z as Vt}from"./chunks/chunk-RHSFOMHU.js";import{A as Bo,Ra as nr,f as Wo}from"./chunks/chunk-DAM4CBBR.js";import"./chunks/chunk-KR3RP4FH.js";import"./chunks/chunk-3BZZA6A3.js";import{Ib as Xo,Lc as rt,Oc as Qo,Pc as er,Qc as Z,Rc as tr,ic as Zo}from"./chunks/chunk-QOEKOECV.js";import{Ea as Yo,ma as Jo}from"./chunks/chunk-FLDWYEND.js";import"./chunks/chunk-XOD2PCB6.js";import"./chunks/chunk-DEZPZOQ7.js";import{$c as vo,$j as Ee,Ce as bo,De as xo,Ec as mo,Ek as Ut,Fc as po,Fk as qo,Gc as uo,Gg as ko,Gk as Ho,Hc as fo,Hg as Eo,I as g,Ic as V,Ig as So,J as At,Jc as go,Jg as Ao,K as x,Kc as ho,Kg as To,Kn as ot,Lc as Y,Le as Ye,Ln as qt,M as xe,Mc as yo,Mn as Ht,Nc as Ve,Nn as Oe,Oc as ce,On as $,Pc as le,Pn as Vo,Q as Tt,Qd as Pt,Qf as Ze,Qn as zt,Sc as wo,Ta as Rt,Tc as Ke,Ti as $o,Ui as me,Vb as io,Vi as I,Wa as J,Wg as Oo,Wi as Po,Wn as D,Xj as Mo,Ya as oo,Yj as Dt,Za as Be,Zc as $t,Zj as Ft,_c as Je,_g as Ro,_j as Lt,ab as It,ad as _o,ak as jt,bb as ro,bc as ao,bk as Do,c as We,cb as R,ck as Se,d as se,dc as so,e as Yn,ef as S,fb as z,ff as Xe,fk as Fo,g as Xn,ga as Zn,gk as Lo,ha as Qn,i as H,ia as Ot,in as Go,io as Ko,jn as nt,kh as X,lh as Io,mh as de,mj as Qe,nj as No,oh as Mt,ol as et,pa as eo,ph as w,qa as to,qg as Co,ql as Te,rc as co,rg as Nt,rl as tt,sa as no,sc as Ce,tk as Ae,uc as ke,vc as lo,wk as jo,zk as Uo}from"./chunks/chunk-AMRDVX36.js";import{Command as Dn,CommanderError as el}from"commander";(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]="93ca07c1-857b-57ae-8530-a315a24d0fe5")}catch{}})();var Ra=new Set(["__proto__","prototype","constructor"]),lr=Symbol("looseOptionOccurrences");function Re(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,o)=>o.toUpperCase())}function Ia(e,t,n){let o=e[t];if(o===void 0){e[t]=n;return}if(Array.isArray(o)){o.push(n),e[t]=o;return}e[t]=[o,n]}function Jt(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let a=n.indexOf("=");if(a>=0)return{consumed:1,key:n.slice(1,a).trim(),value:n.slice(a+1)};let s=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:s,value:c}:{consumed:1,key:s,value:!0}}let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(2,o).trim(),value:n.slice(o+1)};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let r=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:r,value:i}:{consumed:1,key:r,value:!0}}function st(e){return Ra.has(e)}function dr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Zn(t)}function Ie(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let r=Re(n.slice(2));r.length>0&&!st(r)&&t.push(r)}if(o.startsWith("-")&&!o.startsWith("--")){let r=Re(o.slice(1));r.length>0&&!st(r)&&t.push(r)}return[...new Set(t)]}function mr(e){let t=new Set;for(let n of e)for(let o of Ie(n))t.add(o);return t}function $a(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Re(t.slice(2));if(n.length>0&&!st(n))return n}return Ie(e)[0]??null}function Pa(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Yt(e,t,n){if(t.length===0)return;let o=new Set,r=new Map,i=[],a=[];for(let s of t){let c=Ie(s),d=Pa(s);d!==null&&a.push(d);for(let l of c)o.add(l),s.enabled===!1&&r.set(l,d);s.required===!0&&s.enabled!==!1&&c.length>0&&i.push({keys:c,label:d})}for(let s of Object.keys(e)){if(!o.has(s)){let d=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new x(`Unknown option '--${s}' for extension command '${n}'.${d}`,g.USAGE)}let c=r.get(s);if(c)throw new x(`Option '${c}' is disabled for extension command '${n}'.`,g.USAGE)}for(let s of i)if(!s.keys.some(c=>Object.hasOwn(e,c)))throw new x(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function Na(e){return typeof e=="string"||e==null?e:String(e)}function Ma(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Da(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var Fa={string:Na,number:Ma,boolean:Da};function ct(e,t){return Array.isArray(e)?e.map(n=>ct(n,t)):Fa[t](e)}function pr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(r=>r!=null&&r!==""):Qn(e);return t?o.map(r=>ct(r,t)):o}function La(e,t,n,o){return n?pr(e,t,o):t?ct(e,t):e}function ja(e,t,n){let o=e[lr];if(!o||o.length===0)return n;let r=new Set(t);return o.filter(i=>r.has(i.key)).map(i=>i.value)}function ur(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[r,i]of Object.entries(e))o[r]=i;for(let r of t){let i=$a(r);if(!i)continue;let a=r.list===!0,s=Ie(r);for(let l of s)if(!(l===i||!Object.hasOwn(o,l))){if(Object.hasOwn(o,i)){if(!a){delete o[l];continue}let m=o[i],p=o[l];o[i]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[l];continue}o[i]=o[l],delete o[l]}let c=dr(r),d=r.repeatable===!0;if(!Object.hasOwn(o,i)){r.default!==void 0&&(o[i]=La(r.default,c,a,d));continue}if(a){o[i]=pr(ja(n,s,o[i]),c,d);continue}c&&(o[i]=ct(o[i],c))}return o}function fr(e){let t=Object.create(null),n=[];Object.defineProperty(t,lr,{value:n});let o=0;for(;o<e.length;){let r=Jt(e,o);if(!r){o+=1;continue}let i=Re(r.key);if(i.length===0||st(i)){o+=r.consumed;continue}Ia(t,i,r.value),n.push({...r,key:i}),o+=r.consumed}return t}function gr(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Jt(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Xt(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=dr(a);for(let c of Ie(a))n.add(c),s==="boolean"&&o.add(c)}if(n.size===0)return[...e];let r=[],i=0;for(;i<e.length;){if(e[i]==="--"){r.push(...e.slice(i+1));break}let a=Jt(e,i);if(a){let s=Re(a.key);if(n.has(s)){let c=e[i],d=o.has(s)&&!c.includes("=")?1:a.consumed;i+=d;continue}}r.push(e[i]),i+=1}return 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]="dacf3952-3ae1-57fa-840a-c8a43cf855a5")}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]="2271dc24-733a-5f76-9aee-c34793c3408f")}catch{}})();var hr=new WeakMap;function yr(e,t){hr.set(e,t)}function ee(e){return hr.get(e)}function wr(e){return e.length>0?[e[0]]:[]}function Ua(e){let t=["","Intent:",` ${e.why}`],n=wr(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
3
+ `)}function qa(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
4
+ `)}function vr(e,t){return t==="detailed"?qa(e):Ua(e)}function N(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var Ha={cal:"calendar",ctx:"context"};function za(e,t){return e.commands.find(n=>n.name()===t)??null}function Ga(e,t){let n=e;for(let o of t){let r=za(n,o);if(!r)return null;n=r}return n}function Zt(e,t,n,o){let r=Ga(e,t.split(" ").filter(i=>i.length>0));r&&r.addHelpText("after",vr(n,o))}function en(e){return e.includes("--explain")?"detailed":"compact"}function ue(e){return e.includes("--all")||e.includes("--explain")}var _r={init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm install ./my-package --project","pm install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm extension explore --project","pm extension manage --global","pm extension describe sample-ext --project","pm extension doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm extension init ./my-extension","pm extension init ./my-hook-extension --capability hooks","pm extension init ./my-search-extension --capability search","pm extension init ./my-sync-extension --capability importers","pm extension init ./my-domain-extension --capability schema","pm extension init ./my-output-extension --capability renderers","pm extension --install --project ./my-sync-extension","pm extension --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm extension install ./my-extension --project","pm extension --install --project ./my-extension","pm extension doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm extension doctor --project --detail summary","pm extension doctor --project --detail deep --trace","pm extension doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm extension catalog --project","pm extension catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm install '*' --project","pm install ./packages/pm-todos --project","pm install npm:@scope/pm-package --global","pm install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm upgrade --dry-run","pm upgrade --packages-only --project","pm upgrade todos --dry-run","pm upgrade --cli-only --repair","pm upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list-all --limit 50","pm list-all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list-open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list-in-progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list-blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list-closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list-canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list-draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' in one read: the single highest-priority ready item with rationale, plus the ranked ready and blocked queues (project management = context management).",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspects item mutation timeline and audit trail.",examples:["pm history pm-a1b2 --limit 20","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "All acceptance criteria met" --message "Close after verification"','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list-all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list-all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:['pm claim pm-a1b2 --message "Claim for implementation"','pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim takeover for non-terminal items does not require --force; --force is reserved for terminal/lock overrides.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:['pm release pm-a1b2 --message "Release after closure"']},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm start-task pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm pause-task pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close-task pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}},Qt={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm install guide-shell --project","pm list-open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]};function Wa(e){let t=N(e??"");return t?Ha[t]??t:""}function Ba(e){let t=Wa(e);return t?_r[t]??Qt:Qt}function br(e,t){let n=Ba(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:wr(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function Va(){let e=se.filter(({lifecycle:n})=>n==="permanent"),t=se.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${Xn(n)})`)].join(`
5
+ `)}function Ka(e,t,n,o){let r=new Set(Qo);e.configureHelp({visibleCommands(i){let a=t.visibleCommands(i);return n?a.filter(s=>(ee(s)??Z(s.name()))!=="internal"):i!==e?a:a.filter(s=>o.has(s))},visibleOptions(i){let a=t.visibleOptions(i);return i!==e||n?a:a.filter(s=>r.has(s.flags))}})}function Ja(e,t,n,o){let r=new Set(tr("core")),i=e.createHelp();i.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let a=()=>`${i.formatHelp(e,i)}${o}
6
+ `,s=t.visibleCommands(e);for(let c of s)ee(c)===void 0&&(c.name()==="help"||r.has(c.name()))&&n.add(c);for(let c of s)ee(c)==="core"&&(n.add(c),er(a()).within_budget||n.delete(c))}function xr(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ue(t),r=new Set;Ka(e,n,o,r);let i=en(t),a=vr(Qt,i);e.addHelpText("after",a),o&&e.addHelpText("after",Va()),Ja(e,n,r,a);for(let[l,m]of Object.entries(_r))Zt(e,l,m,i);let s=N(P(t).commandPathTokens.join(" ")),c=Te(s);if(c){Zt(e,c.parent,{why:c.description,examples:[c.example],tips:[`Action path: pm ${c.command}`,tt(c.accepted_flags)]},i);return}let d=et.filter(({parent:l})=>l===s);d.length>0&&Zt(e,s,{why:`Dispatches one declared positional action: ${d.map(({action:l})=>l).join("|")}.`,examples:d.map(({example:l})=>l),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="1c4a4bc4-d26a-5f51-bac0-2a132dad1f56")}catch{}})();async function Cr(e,t){await qo(e,{ok:t.ok,error:t.error,result:le(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function kr(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await Oo({pmRoot:e.pmRoot,result:le()})}catch(o){t=o}let n=await I(e.pmRoot);if(await Ro({pmRoot:e.pmRoot,author:Ye(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw 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]="0429ff6a-ec0d-5c20-9fa7-0ed05b154523")}catch{}})();function F(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function te(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return F(t)}function K(e){let t=new Set,n=[];for(let o of e){let r=te(o);r&&(t.has(r)||n.push(r),t.add(r))}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]="a2919889-aa1a-54a6-8a2f-95d4484b9e65")}catch{}})();function mt(e){let{why:t,title:n,...o}=e;return o}var Ya=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function Xa(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Ya.has(e.code)}function Or(e){return`urn:pm-cli:error:${e}`}function b(e){return{...e,type:Or(e.code)}}var fe={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Er={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Sr={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},lt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Za={guide:fe,shell:fe,completion:fe,"completion-statuses":fe,"completion-tags":fe,"completion-types":fe,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Er,cal:Er,reindex:Sr,"search-advanced":Sr,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":lt,"dedupe-audit":lt,"dedupe-merge":lt,normalize:lt};function Qa(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Za[t]}function tn(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function es(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function ts(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function nn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function G(e,t,n){if(t==="parsed_positionals"){if(!Array.isArray(n))return;let r=n.map(i=>({role:typeof i?.role=="string"?i.role.trim():"",value:typeof i?.value=="string"?i.value.trim():""})).filter(i=>i.role.length>0&&i.value.length>0);r.length>0&&(e.parsed_positionals=r);return}let o=es(n);o&&(e[t]=o)}function ge(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),nn(t,"attempted_command",e.attempted_command),G(t,"normalized_args",e.normalized_args),G(t,"parsed_positionals",e.parsed_positionals),G(t,"provided_fields",e.provided_fields),G(t,"missing",e.missing),G(t,"missing_required_fields",e.missing_required_fields),G(t,"suggested_flags",e.suggested_flags),G(t,"allowed_values",e.allowed_values),G(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),nn(t,"suggested_retry",e.suggested_retry),G(t,"suggested_retry_args",e.suggested_retry_args),typeof e.retry_after_ms=="number"&&Number.isSafeInteger(e.retry_after_ms)&&e.retry_after_ms>=0&&(t.retry_after_ms=e.retry_after_ms);let n=ts(e.fallback_candidates);return n&&(t.fallback_candidates=n),nn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function on(e,t,n){n&&e.push(` ${t}: ${n}`)}function ne(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function ns(e){let t=ge(e);if(!t)return[];let n=["Recovery bundle:"];if(on(n,"suggested_retry",t.suggested_retry),on(n,"attempted_command",t.attempted_command),ne(n,"normalized_args",t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(ne(n,"provided_fields",t.provided_fields,", "),ne(n,"missing",t.missing,", "),ne(n,"missing_required_fields",t.missing_required_fields,", "),ne(n,"suggested_flags",t.suggested_flags,", "),ne(n,"allowed_values",t.allowed_values,", "),ne(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),typeof t.retry_after_ms=="number"&&n.push(` retry_after_ms: ${t.retry_after_ms}`),on(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}function Rr(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...tn("Next steps:",e.nextSteps))),t.push("","What happened:",` ${e.happened}`),e.why&&(t.push("","Why:"),t.push(` ${e.why}`)),e.examples&&e.examples.length>0&&(t.push(""),t.push(...tn("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...tn("Verification errors:",e.verificationErrors)));let n=ns(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
7
+ `)}function Ir(e,t){return Xa(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function os(e,t){if(e.flag)return e.flag;let n=r=>{let i=r.split("=",1)[0];return pe([i]).length>0&&!["--help","--no-changed-fields","--version"].includes(i)&&t.some(a=>a===i||a.startsWith(`${i}=`))},o=[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(r=>r[0]).find(r=>n(r));return o||e.recovery?.provided_fields?.map(r=>r.split("=",1)[0]).find(r=>n(r))}function rs(e,t,n){if(e.value!==void 0)return e.value;if(n){let r=t.find(a=>a===n||a.startsWith(`${n}=`));if(r?.startsWith(`${n}=`))return r.slice(n.length+1);let i=t.indexOf(n);return i>=0?t[i+1]:void 0}let o=e.recovery?.allowed_values;if(o?.length)return t.find((r,i)=>i>0&&!r.startsWith("-")&&!o.includes(r))}function is(e,t){let n=e.recovery?.normalized_args??[],o=os(e,n),r=rs(e,n,o);return{surface:o??e.recovery?.missing?.[0]??$r(e.recovery)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function as(e,t){return Ir({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:is(e,t)},e)}function an(e,t){let n=e.recovery,o=!!n?.suggested_retry||!!n?.suggested_retry_args?.length||!!n?.allowed_values?.length||!!n?.candidate_commands?.length||!!e.nextSteps?.length;return Co(as(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function sn(e){return Ir({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function pt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function ss(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function oe(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Ar(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function $r(e){return ir(e?.normalized_args)}function cs(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function ls(e,t){let n=e?.normalized_args,o=e?.provided_fields,r=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!r))for(let i of o){let a=n.findIndex(s=>s===i);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=r,S(s)}}}function ds(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function dt(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function W(e,t,n){if(!n)return e;let o=pt(t),r=dt(n.code,e.code),i=dt(n.type,Or(r)),a=oe(n.examples)??e.examples,s=oe(n.nextSteps)??e.nextSteps,c=oe(n.verification_errors)??e.verificationErrors,d=e.code==="command_failed"&&n.code?ds(o):void 0,l=ge(n.recovery),m=l&&e.recovery?ge({...e.recovery,...l}):l??e.recovery;return{...e,code:r,type:i,title:d??e.title,happened:o.length>0?o:e.happened,required:dt(n.required,e.required),why:dt(n.why,e.why),examples:a,nextSteps:s,verificationErrors:c,flag:n.flag,value:n.value,unmatchedSelectors:n.unmatched_selectors,availableDependencies:n.available_dependencies,recovery:m}}function ms(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let r=o[1],i=ro(process.cwd(),r);return W(b(i?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${r}, but found a tracker at ${i}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${i} <command>`,`PM_PATH=${i} pm <command>`],nextSteps:[`Re-run with "--pm-path ${i}" or export PM_PATH=${i}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function ps(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let r=o[1],i=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(r),a=i?`The item ID "${r}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${r}" exists in the active tracker scope.`;return W(b({code:"item_not_found",title:"Item ID not found",happened:a,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:i?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function us(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:W(b({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function fs(e,t,n){return t.includes("is locked")?W(b({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, or use --force where supported if lock is stale and safe to override.",why:"Locking protects item files from concurrent write races.",examples:["pm update pm-a1b2 --status in_progress --force"]}),e,n):null}function gs(e,t,n){let o=t.match(/^Missing required option /),r=t.match(/^Missing required options /);if(!o&&!r)return null;let i=!!r,a=i?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",c=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return W(b({code:"missing_required_option",title:i?"Missing required options":`Missing required option ${s}`,happened:t,required:i?"Provide every required option for this command invocation.":c,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function hs(e,t,n){return t.startsWith("No update flags provided")?W(b({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function ys(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=ge(n?.recovery),r=$r(o),i=r?`pm ${r} --help`:"pm <command> --help",a=cs(t),s=ge({...o,allowed_values:o?.allowed_values??a}),c=ls(o,a),d=c?[c,i]:[i,"pm contracts --command <command> --flags-only --json"],l=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${i}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return W(b({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:d,nextSteps:l,recovery:s}),e,n)}function cn(e,t){let n=pt(e),o=ms(e,n,t)??ps(e,n,t)??us(e,n,t)??fs(e,n,t)??gs(e,n,t)??hs(e,n,t)??ys(e,n,t);return o||W(b({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function ws(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function vs(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function _s(e){if(!(!Array.isArray(e)||e.length===0))return S(e)}function ln(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function L(e,t={}){let n=ln(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,r=typeof e?.attemptedCommand=="string"?e.attemptedCommand:_s(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return ge({attempted_command:r,normalized_args:o,provided_fields:n,suggested_retry:i,...t})}function rn(e,t){return!t||e.includes(t)?e:[...e,t]}var bs=new Set(["--add","--add-json","--remove"]),xs=new Set(["command","cmd","path"]);function Cs(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if(bs.has(o))return o}}function ks(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let r=e[o];if(r!=="--add"&&r!=="--remove")continue;let i=e[o+1];if(typeof i!="string"||!xs.has(i))return;let a=[];for(let d=o+2;d<e.length;d+=1){let l=e[d];if(l.startsWith("--")&&l.length>2)break;a.push(l)}if(a.length<2)return;let s=`${i}=${a.join(" ")}`,c=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return S(c)}}function Es(e,t,n,o){let r=e.match(/required option '([^']+)' not specified/);if(!r)return null;let i=vs(r[1]),a=i.startsWith("--type"),s=o?.suggestedRetryCommand,c=ln(o?.providedOptionFlags),d=[i],l=ws(t,i,n),m=s?rn(l,s):l,p=a?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],u=s?rn(p,`Replay with preserved arguments: ${s}`):p,f=c&&c.length>0?rn(u,`Already provided options: ${c.join(", ")}`):u;return b({code:"missing_required_option",title:`Missing required option ${i}`,happened:`Commander rejected the command because ${i} was not provided.`,required:`Pass ${i} with a valid value before running the command.`,why:a?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:L(o,{missing:d})})}function Ss(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let r=o[1];return b({code:"missing_required_argument",title:`Missing required argument ${r}`,happened:`Command invocation omitted positional argument ${r}.`,required:`Provide ${r} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:L(n,{missing:[r]})})}function As(e,t,n){return b({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:L(t,{suggested_flags:n})})}var Ts={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function Os(e){let t=oe(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Rs(e,t,n,o,r){let i=o.otherCommands.slice(0,3),a=o.candidateTotal-i.length,s=a>0?` and ${String(a)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,i.length?`${e} is accepted by ${i.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,r?`Replay with suggested correction: ${r}`:void 0].filter(c=>typeof c=="string")}function Is(e,t){if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(i=>i===t||i.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(i=>i===t||i.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let r=pe(n.filter((i,a)=>a!==o));return{retryCommand:S(r),suggestedRetryArgs:r}}function $s(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let r=n??{},i=o[1],a=ln(r.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:c}=Is(r,i);if(t==="update"&&(i==="--file"||i==="--doc"))return As(i,n,a);let d=Os(r),l=Rs(i,t,a,d,s),m=[s,`pm ${t??"<command>"} --help`].filter(p=>typeof p=="string");return b({code:"unknown_option",title:`Unknown option ${i}`,happened:`Commander does not recognize option ${i} for this command path.`,required:Ts[d.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:l,recovery:L(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:c,candidate_commands:d.otherCommands,candidate_commands_total:d.candidateTotal||void 0,candidate_commands_truncated:r.unknownOptionOtherCommandsTruncated,option_scope:d.optionScope})})}function Ps(e,t,n,o,r){let i=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,a=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return b({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:Ar([t.installCommand,...n]),nextSteps:Ar([i,...a]),recovery:L(r)})}function Ns(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],r=oe(t?.unknownCommandExamples),i=oe(t?.unknownCommandNextSteps),a=Qa(o),s=r??["pm --help"],c=i??["Verify spelling and active extensions, then rerun."],d=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),l=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!l||!d.has(l))?Ps(o,a,s,c,t):b({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:c,recovery:L(t)})}function Ms(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=oe(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let r=e?.suggestedRetryCommand;return b({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...r?[r]:[],`pm ${t} --help`],nextSteps:r?[`Retry with the declared hyphenated action: ${r}`]:["Choose one value from recovery.allowed_values."],recovery:L(e,{allowed_values:o,suggested_retry:r})})}function Ds(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,r=Cs(o);if(!r)return null;let i=ks(o);return b({code:"linked_test_value_not_quoted",title:`Linked-test ${r} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${r} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${r} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...i?[i]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...i?[`Replay with the value re-joined into one argument: ${i}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:L(n,i?{suggested_retry:i}:{})})}var Fs=new Set(["comments","docs","files","learnings","notes","test"]);function Ls(e,t,n){if(!/too many arguments/i.test(e)||!Fs.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],r=o.findIndex(d=>d===t),i=o[r+1],a=o[r+2],s=n?.verifiedCollectionItemId?.trim();if(i?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let c=`pm ${t} ${s} --add <value>`;return b({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[c,`pm ${t} --help`],recovery:L(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:c})})}var js=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),Tr=new Set(["context","ctx"]);function Us(e,t,n){if(!/too many arguments/i.test(e)||!Tr.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],r=o.findIndex(d=>Tr.has(d)),i=r===-1?1:r+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let d=!1;for(let l of o.slice(i)){if(d){d=!1;continue}let m=l.split("=")[0];if(js.has(m)){d=!l.includes("=");continue}if(!l.startsWith("-")){s=l;break}}}if(!s)return null;let c=`pm get ${s}`;return b({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${c} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[c,`pm context --parent ${s}`],recovery:L(n,{suggested_retry:c})})}function dn(e,t,n,o){let r=pt(e),i=Es(r,t,n,o)??Ss(r,t,o)??$s(r,t,o)??Ns(r,o)??Ms(o)??Ls(r,t,o)??Ds(r,t,o)??Us(r,t,o);return i||b({code:"invalid_command_usage",title:"Invalid command usage",happened:r,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:L(o)})}function Pr(e,t){let n=cn(e,t);return Nt(Rr(n),n.required).output}function Nr(e,t){return sn(cn(e,t))}function mn(e,t,n){return an(cn(e,n),t)}function Mr(e,t,n,o){let r=dn(e,t,n,o);return Nt(Rr(r),r.required).output}function pn(e,t,n,o){return sn(dn(e,t,n,o))}function ut(e,t,n,o,r){return an(dn(e,t,n,r),o)}function Dr(e,t){let n=Fr(e);return an(n,t)}function Fr(e){let t=pt(e);return ss(t)?b({code:"module_import_failed",title:"Module import failed",happened:t,required:"Ensure the active checkout is built and any package or extension entry file exists before retrying.",why:"Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",examples:["pnpm build","pm package manage --doctor --project","pm health --check-only --json"],nextSteps:["Rebuild the checkout or package that provides the missing module.","Run package doctor for installed extensions when the failure follows package installation or activation.","Rerun the original pm command after the runtime files are present."]}):b({code:"unknown_error",title:"Unhandled error",happened:t,required:"Inspect command input and runtime state, then retry.",why:"Unexpected runtime failures can occur from environment or extension-level issues.",examples:["pm --help","pm health --json"]})}function Lr(e){return sn(Fr(e))}import{Option as qs}from"commander";(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]="3c82c125-73b7-5f75-bc3c-3d83d4b7d7f8")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Ur(e,t){let n=new Map;for(let o of e){let r=v(o.command);for(let i of t){if(i.layer!==o.layer||i.name!==o.name)continue;let a=v(i.command),s=a.split(" "),c=s.at(-1),d=s.slice(1).join(" "),l=d?`${s[0]}-${c} ${d}`:`${s[0]}-${c}`;if(c&&r===l){n.set(r,a);break}}}return n}function un(e,t,n,o){if(!t||!n)return;let r,i=0;for(let[s,c]of e.entries()){if(c!==t)continue;let d=e.slice(s);for(let[l,m]of o.entries()){let p=l.split(" ");p.length>i&&p.every((u,f)=>d[f]===u)&&(r=m,i=p.length)}}let a=r?.flags.find(s=>s.long===n||s.short===n);if(a)return ft(a).takesValue}function A(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function B(e){return typeof e=="boolean"?e:void 0}function ft(e){let t=A(e.value_type)??A(e.type),n=A(e.value_name),o=t!=="boolean"&&(n!==null||t!==null||B(e.required)===!0||B(e.list)===!0);return{takesValue:o,valueName:o?n??"value":null}}function Hs(e){if(B(e.visible)===!1)return null;let n=A(e.long);if(!n||!n.startsWith("--")||n.length<3)return null;let o=A(e.short),r=o&&o.startsWith("-")&&!o.startsWith("--")?`${o}, `:"",i=A(e.value_name),a=i?` <${i}>`:"",s=A(e.description)??"Extension-provided option.",c=[];B(e.required)===!0&&c.push("required"),B(e.enabled)===!1&&c.push("disabled");let d=c.length>0?` [${c.join(", ")}]`:"";return`${r}${n}${a} ${s}${d}`}function qr(e){let t=[...new Set(e.map(Hs).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
8
8
  Extension-provided flags:
9
9
  ${t.join(`
10
- `)}`}function qr(e){let t=new Map;for(let r of e){let i=_(r.target_command);if(i.length===0)continue;let a=t.get(i)??[];a.push(...r.flags),t.set(i,a)}let n=[...t.entries()].sort(([r],[i])=>r.localeCompare(i)),o=new Map;for(let[r,i]of n){let a=Ur(i);a&&o.set(r,a)}return o}function Hr(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function Lr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let r=o.trim();r.length===0||n.has(r)||(n.add(r),t.push(r))}return t}function Hs(e){return Array.isArray(e)?e.map(t=>{let n=typeof t.name=="string"?t.name.trim():"";if(n.length===0)return null;let o={name:n,required:t.required===!0,variadic:t.variadic===!0};return typeof t.description=="string"&&t.description.trim().length>0&&(o.description=t.description.trim()),o}).filter(t=>t!==null):[]}function zs(e){let t=new Map;for(let n of e){let o=_(n.command);if(o.length===0)continue;let r=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,i=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:Hr(o,n.action),description:r,intent:i,examples:Lr(n.examples),failure_hints:Lr(n.failure_hints),arguments:Hs(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",source:{layer:n.layer,name:n.name,package:n.source_package}})}return t}function Gs(e){let t=new Map;for(let n of e){let o=_(n.target_command);if(o.length===0)continue;let r=t.get(o)??[];r.push(...n.flags),t.set(o,r)}return t}function Ws(e,t,n){let o=new Set;for(let r of e){let i=_(r);i.length>0&&o.add(i)}for(let r of t.keys())o.add(r);for(let r of n.keys())o.add(r);return o}function Bs(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function zr(e,t,n,o=new Map){let r=zs(t),i=Gs(n),a=Ws(e,r,i),s=new Map,c=[...a].sort((d,l)=>d.localeCompare(l));for(let d of c){let l=Bs(d,r,o)??r.get(d),m=i.get(d)??(l?i.get(l.command):void 0)??[];if(l){s.set(d,{...l,command:d,flags:m});continue}s.set(d,{command:d,action:Hr(d,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function Vs(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Gr(e,t){for(let n of t.arguments)e.argument(Vs(n),n.description??"Extension argument.")}function Wr(e){if(B(e.visible)===!1)return null;let n=A(e.long),o=A(e.short),r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,i=n&&n.startsWith("--")&&n.length>2?n:null,a=[r,i].filter(s=>s!==null);return a.length>0?a:null}function Ks(e){let t=Wr(e);if(!t)return null;let{valueName:n}=ut(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Js(e){let t=Wr(e);if(!t)return null;let{valueName:n}=ut(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Br(e){let t=A(e.description)??"Extension-provided option.",n=[];B(e.required)===!0&&n.push("required"),B(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"";return`${t}${o}`}function Vr(e,t){let n=A(t.long),o=A(t.short);return e.options.some(r=>{let i=r;return n!==null&&i.long===n||o!==null&&i.short===o})}function un(e,t){for(let n of t){if(Vr(e,n))continue;let o=Js(n);if(!o)continue;let r=Br(n);if(n.list!==!0){e.option(o,r);continue}e.addOption(new Us(o,r).argParser((i,a=[])=>[...Array.isArray(a)?a:[a],i]))}}function pn(e,t){return Ur(t.filter(n=>!Vr(e,n)))}function Ys(e){let t=Ks(e);if(!t)return null;let n=A(e.long),o=A(e.short),r=n&&n.startsWith("--")&&n.length>2?n:null,i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:a,valueName:s}=ut(e),c=B(e.required)===!0;return{flags:t,long:r,short:i,description:Br(e),takes_value:a,value_required:a,value_name:s,variadic:!1,required:c,aliases:[],alias_for:null}}function Kr(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let r=Ys(o);!r||n.has(r.flags)||(n.add(r.flags),t.push(r))}return t}function Jr(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(r=>r.flags));for(let r of t)o.has(r.flags)||(o.add(r.flags),n.push(r));return n}function Yr(e){let t=[];if(e.intent&&t.push(`Intent: ${e.intent}`),e.action&&t.push(`Action contract: ${e.action}`),e.examples.length>0){t.push("Examples:");for(let n of e.examples)t.push(` - ${n}`)}if(e.failure_hints.length>0){t.push("Common failure hints:");for(let n of e.failure_hints)t.push(` - ${n}`)}return t.length===0?null:`
10
+ `)}`}function Hr(e){let t=new Map;for(let r of e){let i=v(r.target_command);if(i.length===0)continue;let a=t.get(i)??[];a.push(...r.flags),t.set(i,a)}let n=[...t.entries()].sort(([r],[i])=>r.localeCompare(i)),o=new Map;for(let[r,i]of n){let a=qr(i);a&&o.set(r,a)}return o}function zr(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function jr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let r=o.trim();r.length===0||n.has(r)||(n.add(r),t.push(r))}return t}function zs(e){return Array.isArray(e)?e.map(t=>{let n=typeof t.name=="string"?t.name.trim():"";if(n.length===0)return null;let o={name:n,required:t.required===!0,variadic:t.variadic===!0};return typeof t.description=="string"&&t.description.trim().length>0&&(o.description=t.description.trim()),o}).filter(t=>t!==null):[]}function Gs(e){let t=new Map;for(let n of e){let o=v(n.command);if(o.length===0)continue;let r=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,i=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:zr(o,n.action),description:r,intent:i,examples:jr(n.examples),failure_hints:jr(n.failure_hints),arguments:zs(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",source:{layer:n.layer,name:n.name,package:n.source_package}})}return t}function Ws(e){let t=new Map;for(let n of e){let o=v(n.target_command);if(o.length===0)continue;let r=t.get(o)??[];r.push(...n.flags),t.set(o,r)}return t}function Bs(e,t,n){let o=new Set;for(let r of e){let i=v(r);i.length>0&&o.add(i)}for(let r of t.keys())o.add(r);for(let r of n.keys())o.add(r);return o}function Vs(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Gr(e,t,n,o=new Map){let r=Gs(t),i=Ws(n),a=Bs(e,r,i),s=new Map,c=[...a].sort((d,l)=>d.localeCompare(l));for(let d of c){let l=Vs(d,r,o)??r.get(d),m=i.get(d)??(l?i.get(l.command):void 0)??[];if(l){s.set(d,{...l,command:d,flags:m});continue}s.set(d,{command:d,action:zr(d,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function Ks(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Wr(e,t){for(let n of t.arguments)e.argument(Ks(n),n.description??"Extension argument.")}function Br(e){if(B(e.visible)===!1)return null;let n=A(e.long),o=A(e.short),r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,i=n&&n.startsWith("--")&&n.length>2?n:null,a=[r,i].filter(s=>s!==null);return a.length>0?a:null}function Js(e){let t=Br(e);if(!t)return null;let{valueName:n}=ft(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Ys(e){let t=Br(e);if(!t)return null;let{valueName:n}=ft(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Vr(e){let t=A(e.description)??"Extension-provided option.",n=[];B(e.required)===!0&&n.push("required"),B(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"";return`${t}${o}`}function Kr(e,t){let n=A(t.long),o=A(t.short);return e.options.some(r=>{let i=r;return n!==null&&i.long===n||o!==null&&i.short===o})}function fn(e,t){for(let n of t){if(Kr(e,n))continue;let o=Ys(n);if(!o)continue;let r=Vr(n);if(n.list!==!0){e.option(o,r);continue}e.addOption(new qs(o,r).argParser((i,a=[])=>[...Array.isArray(a)?a:[a],i]))}}function gn(e,t){return qr(t.filter(n=>!Kr(e,n)))}function Xs(e){let t=Js(e);if(!t)return null;let n=A(e.long),o=A(e.short),r=n&&n.startsWith("--")&&n.length>2?n:null,i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:a,valueName:s}=ft(e),c=B(e.required)===!0;return{flags:t,long:r,short:i,description:Vr(e),takes_value:a,value_required:a,value_name:s,variadic:!1,required:c,aliases:[],alias_for:null}}function Jr(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let r=Xs(o);!r||n.has(r.flags)||(n.add(r.flags),t.push(r))}return t}function Yr(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(r=>r.flags));for(let r of t)o.has(r.flags)||(o.add(r.flags),n.push(r));return n}function Xr(e){let t=[];if(e.intent&&t.push(`Intent: ${e.intent}`),e.action&&t.push(`Action contract: ${e.action}`),e.examples.length>0){t.push("Examples:");for(let n of e.examples)t.push(` - ${n}`)}if(e.failure_hints.length>0){t.push("Common failure hints:");for(let n of e.failure_hints)t.push(` - ${n}`)}return t.length===0?null:`
11
11
  Extension command metadata:
12
12
  ${t.join(`
13
- `)}`}function fn(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function $e(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:fn(o).includes(n))??null}function ge(e,t){let n=e;for(let o of t){let r=$e(n,o);if(!r)return null;n=r}return n}var Xr=new WeakSet;function Zr(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let r=t[o],i=$e(n,r);if(i){n=i;continue}let a=n.command(r);Xr.add(a),o<t.length-1?(a.description("Extension-provided command group."),a.action(()=>{a.help()})):a.description("Extension-provided command path."),n=a}return n}function Xs(e,t){let n=e,o=[];for(let r of t){let i=$e(n,r);if(!i)return null;if(o.push(r),!Xr.has(i))return{core_path:o.join(" "),extension_path:t.join(" ")};n=i}return null}function Zs(e,t,n,o){let r=t.split(" ").filter(s=>s.length>0),i=Xs(e,r);if(!i||i.core_path===t&&!n.has(t))return null;let a=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${i.extension_path}:core_owner=pm-cli:${i.core_path}:extension_owner=${a}`}function Qr(e,t,n,o,r){return[...new Set([...t,...n.keys()])].filter(i=>i.trim().length>0).sort((i,a)=>i.localeCompare(a)).filter(i=>{let a=Zs(e,i,o,n.get(i));return a?(r(a),!1):!0})}function ei(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(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]="33842ea7-43c9-52a3-a9ec-75f190a5fd6f")}catch{}})();function Qs(e,t){let n=xe(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function ec(e){return xe(e.status)?.toLowerCase()??"pending"}function tc(e){return e.mandatory===!0}function nc(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function oi(e){let t=[];return e.forEach((n,o)=>{if(!tc(n.definition))return;let r=ec(n.definition);r!=="applied"&&t.push({layer:n.layer,name:n.name,id:Qs(n.definition,o),status:r})}),t.sort(nc),t}function ti(e){return Array.isArray(e)&&e.length>0}var oc=new Set(["create","beads import","todos import"]),rc=new Set(["restore","update","close","delete","append","claim","release"]),ic=new Set(["comments","notes","learnings"]),ac=new Set(["files","docs","test"]),sc=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function gn(e,t){let n=t.force===!0;return oc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:rc.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:ic.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:ac.has(e)?{isMutation:ti(t.add)||ti(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function cc(e,t,n){if(gn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Do(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(r=>sc.has(r.trim().toLowerCase())):!1}function ni(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function lc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let r=[];if(xe(t[1])||r.push("source"),xe(n.to)||r.push("--to"),r.length!==0)throw new v(`Schema migration requires ${r.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:r.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:r,suggested_flags:r.filter(i=>i.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function dc(e,t,n,o,r){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||ni(n.status)!==ni(r.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let a=J(r,Y()),s=await Ze(o,i,r.id_prefix,r.item_format,a.type_to_folder);if(!s)return;let c=await $o(s,{schema:r.schema}),d=typeof n.assignee=="string"?n.assignee.trim():void 0;(d===void 0?c.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(d.toLowerCase())&&d)||w(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function hn(e,t,n,o,r){if(!cc(e,t,n)||(lc(e,t,n),!await H(z(r))))return;let i=await me(r);o.json!==!0&&await dc(e,t,n,r,i.settings);let a=Mo({author:Je(o.author,i.settings.author_default),payload:{command:e,args:t,options:n},settings:i.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)w(`warning:${s}`)}function ri(e,t,n){if(n.length===0)return;let o=gn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let r=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),i=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new v(`Write command "${e}" blocked by unresolved mandatory extension migrations (${r.join(",")}). ${i}`,g.CONFLICT)}async function yn(e,t,n,o){if(!gn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await H(z(n)))return;let{settings:i,metadata:a,warnings:s}=await me(n);for(let c of s)w(`warning:${c}`);if(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(Ro(i),await Io(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let c=J(i,Y());await Fo(n,i.item_format,"item_format:pre_mutation_sync",c.type_to_folder,i.schema)}}(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]="adb5b95f-be2d-5bcf-b376-09f6094e0bda")}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]="18758585-648f-5422-80e4-fbc7478c3cf3")}catch{}})();var Pe=Zn.join("|"),mc={calendar:"calendar",cal:"calendar",reindex:"search-advanced","search-advanced":"search-advanced",guide:"guide-shell",completion:"guide-shell",templates:"templates","test-runs":"linked-test-adapters",beads:"beads",todos:"todos"},uc={comments:{"--body":["--add"],"--text":["--add"],"--comment":["--add"]},notes:{"--body":["--add"],"--text":["--add"],"--note":["--add"]},learnings:{"--body":["--add"],"--text":["--add"],"--learning":["--add"]},update:{"--add-tag":["--add-tags"],"--remove-tag":["--remove-tags"],"--tag":["--tags"]},create:{"--add-tag":["--add-tags"],"--tag":["--tags"]}},ii=["add-field","add-status","add-type","apply-preset","list","list-fields","remap-status","remove-field","remove-status","remove-type","rename-field","rename-type","show","show-field","show-status"];function pc(e,t){let n=uc[e];if(!n)return[];let o=F(t);for(let[r,i]of Object.entries(n))if(F(r)===o)return i;return[]}function wn(e,t,n){if(n.length===0)return e;if(t){let a=n.find(l=>l.declared_command_match===!0),{token_accounting:s,...c}=JSON.parse(e),d={...c,...a?{extension_command_failure:{code:"extension_command_activation_failed",extension:a.name,layer:a.layer,error:a.error,recovery_commands:a.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?d:X(d,l=>`${JSON.stringify(l,null,2)}
13
+ `)}`}function hn(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function $e(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:hn(o).includes(n))??null}function he(e,t){let n=e;for(let o of t){let r=$e(n,o);if(!r)return null;n=r}return n}var Zr=new WeakSet;function Qr(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let r=t[o],i=$e(n,r);if(i){n=i;continue}let a=n.command(r);Zr.add(a),o<t.length-1?(a.description("Extension-provided command group."),a.action(()=>{a.help()})):a.description("Extension-provided command path."),n=a}return n}function Zs(e,t){let n=e,o=[];for(let r of t){let i=$e(n,r);if(!i)return null;if(o.push(r),!Zr.has(i))return{core_path:o.join(" "),extension_path:t.join(" ")};n=i}return null}function Qs(e,t,n,o){let r=t.split(" ").filter(s=>s.length>0),i=Zs(e,r);if(!i||i.core_path===t&&!n.has(t))return null;let a=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${i.extension_path}:core_owner=pm-cli:${i.core_path}:extension_owner=${a}`}function ei(e,t,n,o,r){return[...new Set([...t,...n.keys()])].filter(i=>i.trim().length>0).sort((i,a)=>i.localeCompare(a)).filter(i=>{let a=Qs(e,i,o,n.get(i));return a?(r(a),!1):!0})}function ti(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(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]="840b471e-c996-57e2-b97c-3a84bd68f050")}catch{}})();function ec(e,t){let n=xe(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function tc(e){return xe(e.status)?.toLowerCase()??"pending"}function nc(e){return e.mandatory===!0}function oc(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function ri(e){let t=[];return e.forEach((n,o)=>{if(!nc(n.definition))return;let r=tc(n.definition);r!=="applied"&&t.push({layer:n.layer,name:n.name,id:ec(n.definition,o),status:r})}),t.sort(oc),t}function ni(e){return Array.isArray(e)&&e.length>0}var rc=new Set(["create","beads import","todos import"]),ic=new Set(["restore","update","close","delete","append","claim","release"]),ac=new Set(["comments","notes","learnings"]),sc=new Set(["files","docs","test"]),cc=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function yn(e,t){let n=t.force===!0;return rc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:ic.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:ac.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:sc.has(e)?{isMutation:ni(t.add)||ni(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function lc(e,t,n){if(yn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Lo(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(r=>cc.has(r.trim().toLowerCase())):!1}function oi(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function dc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let r=[];if(xe(t[1])||r.push("source"),xe(n.to)||r.push("--to"),r.length!==0)throw new x(`Schema migration requires ${r.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:r.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:r,suggested_flags:r.filter(i=>i.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function mc(e,t,n,o,r){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||oi(n.status)!==oi(r.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let a=J(r,Y()),s=await Qe(o,i,r.id_prefix,r.item_format,a.type_to_folder);if(!s)return;let c=await No(s,{schema:r.schema}),d=typeof n.assignee=="string"?n.assignee.trim():void 0;(d===void 0?c.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(d.toLowerCase())&&d)||w(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function wn(e,t,n,o,r){if(!lc(e,t,n)||(dc(e,t,n),!await H(z(r))))return;let i=await me(r);o.json!==!0&&await mc(e,t,n,r,i.settings);let a=Fo({author:Ye(o.author,i.settings.author_default),payload:{command:e,args:t,options:n},settings:i.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)w(`warning:${s}`)}function ii(e,t,n){if(n.length===0)return;let o=yn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let r=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),i=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new x(`Write command "${e}" blocked by unresolved mandatory extension migrations (${r.join(",")}). ${i}`,g.CONFLICT)}async function vn(e,t,n,o){if(!yn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await H(z(n)))return;let{settings:i,metadata:a,warnings:s}=await me(n);for(let c of s)w(`warning:${c}`);if(o.enforce_item_format_gate&&!a.has_explicit_item_format&&($o(i),await Po(n,i,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let c=J(i,Y());await jo(n,i.item_format,"item_format:pre_mutation_sync",c.type_to_folder,i.schema)}}(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]="4647d40c-70a2-5ffe-a91f-d43e9c522114")}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]="61341599-3083-5e96-b455-65290be67c1b")}catch{}})();var Pe=no.join("|"),pc={calendar:"calendar",cal:"calendar",reindex:"search-advanced","search-advanced":"search-advanced",guide:"guide-shell",completion:"guide-shell",templates:"templates","test-runs":"linked-test-adapters",beads:"beads",todos:"todos"},uc={comments:{"--body":["--add"],"--text":["--add"],"--comment":["--add"]},notes:{"--body":["--add"],"--text":["--add"],"--note":["--add"]},learnings:{"--body":["--add"],"--text":["--add"],"--learning":["--add"]},update:{"--add-tag":["--add-tags"],"--remove-tag":["--remove-tags"],"--tag":["--tags"]},create:{"--add-tag":["--add-tags"],"--tag":["--tags"]}},ai=["add-field","add-status","add-type","apply-preset","list","list-fields","remap-status","remove-field","remove-status","remove-type","rename-field","rename-type","show","show-field","show-status"];function fc(e,t){let n=uc[e];if(!n)return[];let o=F(t);for(let[r,i]of Object.entries(n))if(F(r)===o)return i;return[]}function _n(e,t,n){if(n.length===0)return e;if(t){let a=n.find(l=>l.declared_command_match===!0),{token_accounting:s,...c}=JSON.parse(e),d={...c,...a?{extension_command_failure:{code:"extension_command_activation_failed",extension:a.name,layer:a.layer,error:a.error,recovery_commands:a.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?d:X(d,l=>`${JSON.stringify(l,null,2)}
14
14
  `),null,2)}let o=n.map(a=>`- ${a.layer}:${a.name}: ${a.error}`).join(`
15
15
  `),r=n.find(a=>a.declared_command_match===!0);if(!r)return`${e}
16
16
  Extension activation failures:
@@ -22,17 +22,17 @@ ${i}`:""}
22
22
 
23
23
  ${e}
24
24
  Extension activation failures:
25
- ${o}`}function _n(e){return P(e).commandPathTokens[0]??k(e)??"<command>"}function fc(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let r=o.shift();if(!r)continue;let i=N($(r)),a=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!a&&n.add(i),o.push(...r.commands)}for(let r of t.keys()){let i=N(r),a=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!a&&n.add(i)}return[...n].sort((r,i)=>r.localeCompare(i))}function ai(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let r=n.split(" ");if(n===o)return 0;if(r.includes(o))return 1;if(r.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let i=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let s of r){let c=At(s,o,i);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function si(e){return F(e).slice(2).replace(/-/g,"")}function bn(e){return S(e)}function gc(e){let t=e.split(" ")[0]?.trim().toLowerCase();if(!t)return null;let n=mc[t];return n?`If this command comes from an optional package, install it with: pm install ${n}`:null}function ci(e){let t=Vo(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function hc(e,t){let n=ci(e);if(n.length===0)return[];let o=[];for(let r of t.values()){let i=new Set,a=r.source;if(a)for(let c of[a.name,a.package]){let d=ci(c??"");d.length>0&&i.add(d)}if(i.size===0)continue;[...i].some(c=>c===n||c.includes(n)||n.includes(c))&&o.push(r.command)}return[...new Set(o)].sort((r,i)=>r.localeCompare(i))}function Ne(e,t){let n=new Set,o=t??tt(e);for(let r of o){r.flag.startsWith("--")&&n.add(F(r.flag));for(let i of r.aliases??[])i.startsWith("--")&&n.add(F(i))}return[...n].sort((r,i)=>r.localeCompare(i))}function yc(e,t){if(!e.startsWith("--"))return[];let n=si(e);if(n.length===0)return[];let o=n.length>=8?2:1,r=[];for(let i of t){let a=si(i);if(a===n)continue;if(n.length>=3&&a.startsWith(n)){r.push({flag:i,rank:0,distance:a.length-n.length});continue}let s=At(n,a,o);s===null||s<=0||r.push({flag:i,rank:1,distance:s})}return r.sort((i,a)=>i.rank!==a.rank?i.rank-a.rank:i.distance!==a.distance?i.distance-a.distance:i.flag.localeCompare(a.flag)).map(i=>i.flag).slice(0,3)}var pt,wc=new Set(["ctx","packages","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","start-task","pause-task","close-task","help"]);function _c(){if(pt)return pt;let e=new Map;for(let t of Xe)if(!wc.has(t))for(let n of Ne(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return pt=e,pt}function bc(e,t){if(!e.startsWith("--"))return[];let n=_c().get(F(e));if(!n)return[];let o=t?.trim().toLowerCase(),r=new Set(Ne(o));return n.filter(i=>i!==o).map(i=>({command:i,sharedFlagCount:Ne(i).filter(a=>r.has(a)).length})).sort((i,a)=>i.sharedFlagCount!==a.sharedFlagCount?a.sharedFlagCount-i.sharedFlagCount:i.command.localeCompare(a.command)).map(({command:i})=>i)}function xc(e,t,n){for(let o=0;o<e.length;o+=1){let r=e[o];if(!r.startsWith("--"))continue;let i=r.indexOf("="),a=i>=0?r.slice(0,i):r;if(F(a)!==F(t))continue;let s=[...e];return s[o]=i>=0?`${n}${r.slice(i)}`:n,s}}function vc(e){let t=new Set(e.commandPaths),n=i=>Math.min(ai(i,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?ai(i,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,r=(i,a)=>{if(!Number.isFinite(a)||!t.has(i))return;let s=o.get(i);(s===void 0||a<s)&&o.set(i,a)};for(let i of e.commandPaths)r(i,n(i));for(let[i,a]of Object.entries(_o))i!=="read"&&r(a,n(i));return[...o.entries()].sort(([i,a],[s,c])=>a!==c?a-c:i.localeCompare(s)).map(([i])=>i)}function Cc(e){let t=sr(e.commandPaths,e.primaryToken),n=vc(e),o=hc(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return li([...t,...n,...o])}function kc(e){return[...new Set(e.map(n=>n.split(" ")[0]).filter(n=>n.length>0))].sort((n,o)=>n.localeCompare(o))}function Ec(e,t){let n=e.map(o=>`pm ${o} --help`);return t?[...new Set([...n,"pm --help --all"])]:[...new Set(["pm --help --all",...n])]}function xn(e,t,n){let o=e.match(/unknown command '([^']+)'/i);if(!o||typeof o[1]!="string")return;let r=N(o[1]);if(r.length===0)return;let i=fc(t,n);if(i.length===0)return;let a=r.split(" ")[0],s=Cc({commandPaths:i,normalizedUnknown:r,primaryToken:a,extensionDescriptors:n}),c=kc(i),d=(s.length>0?s:c).slice(0,3),l=Ec(d,s.length>0),m=gc(r),u=s.length>0?`Did you mean: ${d.join(", ")}?`:null;return{unknownCommandExamples:l,unknownCommandNextSteps:[...u?[u]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',"Use one of the suggested command paths above with --help to inspect valid flags and usage.",...m?[m]:[]]}}function li(e){return Array.from(new Set(e))}function Sc(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
26
- `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function Ac(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n!==","&&n!==":"&&n!==";")break;t-=1}return e.slice(0,t)}function Tc(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:(typeof o.aliases=="function"?o.aliases():[]).some(i=>i.trim().toLowerCase()===n))}function Me(e,t){if(t.length===0)return!0;let n=e;for(let[o,r]of t.entries()){let i=Tc(n,r);if(!i){let a=n.registeredArguments;return a.length>0&&(n.commands.length===0||a[0]?.required===!0)&&(a.at(-1)?.variadic===!0||t.length-o<=a.length)}n=i}return!0}async function Oc(e,t,n,o){try{let r=R(process.cwd(),e.path);if(!await H(z(r)))return{allowedTypes:Pe};let i=await I(r),a=e.noExtensions?void 0:Y(),s=J(i,a),c;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let d=n.findIndex(m=>m===o),l=n[d+2];if(n[d+1]?.toLowerCase()==="add"&&l!==void 0&&!l.startsWith("-"))try{c=(await Ze(r,l,i.id_prefix,i.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Pe,pmRoot:r,settings:i,typeToFolder:s.type_to_folder,verifiedCollectionItemId:c}}catch{return{allowedTypes:Pe}}}function Rc(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?li([...pc(t,n[1]),...yc(n[1],Ne(t))]):void 0,r=n?bc(n[1],t):[],i=n!==null&&Ne(t).includes(F(n[1]));return{match:n,suggestions:o,otherCommands:r,scope:i?"declared_on_path":r.length>0?"declared_elsewhere":"declared_nowhere"}}function Ic(e,t,n){if(!t||!n||n.length===0)return;let o=xc(e,t[1],n[0]);return o?bn(o):void 0}function $c(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?Ac(Sc(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let r=k(t);if(r)return ir(t,r,[o])}function Pc(e,t){if(!/too many arguments/i.test(e)||k(t)!=="schema")return;let n=tr(t),o=t[n+1]?.trim().toLowerCase(),r=t[n+2]?.trim().toLowerCase();if(!o||!r)return;let i=`${o}-${r}`;if(!ii.includes(i))return;let a=[...t.slice(0,n+1),i,...t.slice(n+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${o} ${r}`,unknownSubcommandAllowedValues:[...ii],suggestedRetryCommand:bn(a)}}async function De(e,t,n,o={}){let i=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=rt(process.argv.slice(2)).argv,s=q(a),c=k(a),d=bn(a),l=K(a),m=await Oc(s,i,a,c),u=m.allowedTypes,p=xn(i,t,n),f=Rc(i,c),y=Pc(i,a),h=y?.suggestedRetryCommand??Ic(a,f.match,f.suggestions)??$c(i,a);return{message:i,commandName:c,allowedTypes:u,attemptedCommand:d,normalizedInvocationArgs:[...a],providedOptionFlags:l,unknownOptionSuggestions:f.suggestions,unknownOptionOtherCommands:f.otherCommands.length>0?f.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:f.otherCommands.length>0?f.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:f.otherCommands.length>12||void 0,unknownOptionScope:f.scope,suggestedRetryCommand:h,verifiedCollectionItemId:m.verifiedCollectionItemId,...y,...p,...o}}async function vn(e,t,n,o={}){let r=await De(e,t,n,o),{message:i,commandName:a,allowedTypes:s,unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:l,normalizedInvocationArgs:m,providedOptionFlags:u,unknownOptionSuggestions:p,unknownOptionOtherCommands:f,unknownOptionOtherCommandsTotal:y,unknownOptionOtherCommandsTruncated:h,unknownOptionScope:C,unknownSubcommandPath:O,unknownSubcommandToken:U,unknownSubcommandAllowedValues:M,suggestedRetryCommand:ie,verifiedCollectionItemId:kt,failedExtensions:Ge}=r,be=Nr(i,a,s,{unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:l,normalizedInvocationArgs:m,providedOptionFlags:u,unknownOptionSuggestions:p,unknownOptionOtherCommands:f,unknownOptionOtherCommandsTotal:y,unknownOptionOtherCommandsTruncated:h,unknownOptionScope:C,unknownSubcommandPath:O,unknownSubcommandToken:U,unknownSubcommandAllowedValues:M,suggestedRetryCommand:ie,verifiedCollectionItemId:kt,failedExtensions:Ge}),ae=await ho("help_format",{message:be,command:a,allowed_types:s});return ae.handled&&typeof ae.result=="string"?ae.result:be}async function Cn(e,t,n,o=!1,r={}){let i=await De(e,t,n,r),a=mt(i.message,i.commandName,i.allowedTypes,g.USAGE,{unknownCommandExamples:i.unknownCommandExamples,unknownCommandNextSteps:i.unknownCommandNextSteps,attemptedCommand:i.attemptedCommand,normalizedInvocationArgs:i.normalizedInvocationArgs,providedOptionFlags:i.providedOptionFlags,unknownOptionSuggestions:i.unknownOptionSuggestions,unknownOptionOtherCommands:i.unknownOptionOtherCommands,unknownOptionOtherCommandsTotal:i.unknownOptionOtherCommandsTotal,unknownOptionOtherCommandsTruncated:i.unknownOptionOtherCommandsTruncated,unknownOptionScope:i.unknownOptionScope,unknownSubcommandPath:i.unknownSubcommandPath,unknownSubcommandToken:i.unknownSubcommandToken,unknownSubcommandAllowedValues:i.unknownSubcommandAllowedValues,suggestedRetryCommand:i.suggestedRetryCommand,verifiedCollectionItemId:i.verifiedCollectionItemId,failedExtensions:i.failedExtensions}),s=o?lt(a):a,c=q(i.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(c?X(s,d=>`${JSON.stringify(d,null,2)}
27
- `):s,null,2)}import he 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]="f3543bab-fa67-5e91-a700-0cbee84f2dc8")}catch{}})();async function kn(e,t={},n=[]){let o={readSettings:I,loadExtensions:ve,activateExtensions:Ce,resolveImplicitPmRoot:Ot,...t};try{let r=await o.readSettings(e),i=await o.loadExtensions({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(i);return[...i.failed,...a.failed].map(s=>{let c=(i.effective??[]).find(u=>u.layer===s.layer&&u.name===s.name),d=[...c?.contributions?.commands??[],...c?.contributions?.command_handlers??[],...c?.activation?.commands??[]].map(N).filter((u,p,f)=>u.length>0&&f.indexOf(u)===p).sort((u,p)=>u.localeCompare(p)),l=n.map(N),m=d.some(u=>l.some(p=>p===u||p.startsWith(`${u} `)));return{layer:s.layer,name:s.name,error:s.error,...d.length>0?{declared_commands:d}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(r){return[{layer:"runtime",name:"extension-loader",error:r instanceof Error?r.message:String(r)}]}}async function di(e,t,n={},o=[]){if(e!=="unknown_command")return[];let r=await kn(t,n,o),i={readSettings:I,loadExtensions:ve,activateExtensions:Ce,resolveImplicitPmRoot:Ot,...n};try{let a=i.resolveImplicitPmRoot(process.cwd());if(he.resolve(a)===he.resolve(t))return r;let[s,c]=await Promise.all([i.readSettings(t),i.readSettings(a)]),[d,l]=await Promise.all([i.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),i.loadExtensions({pmRoot:a,settings:c,cwd:process.cwd(),noExtensions:!1})]),m=new Set(d.loaded.flatMap(p=>p.activation?.commands??[])),u=[...new Set(l.loaded.flatMap(p=>p.activation?.commands??[]))].filter(p=>!m.has(p)).sort((p,f)=>p.localeCompare(f));if(u.length===0)return r;r.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${he.resolve(t)} extension_discovery_root=${d.roots.project}; cwd_storage_root=${he.resolve(a)} cwd_extension_discovery_root=${l.roots.project}; the selected --pm-path runtime is missing ${u.length} workspace command path(s): ${u.slice(0,8).join(", ")}${u.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${he.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${he.resolve(t)} install <package> --project".`})}catch{}return 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]="e4324332-da8f-5ae1-b0e3-b6d0e9674f98")}catch{}})();var mi={core:0,standard:1,full:2,internal:3};function ui(e,t,n=!0){let o=t.get(e);if(o)return o;if(!n)return;let r=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(r.length===0)return;let i=r.reduce((s,c)=>mi[c.tier]<mi[s]?c.tier:s,"internal"),a=new Set(r.map(({family:s})=>s));return{tier:i,family:a.size===1?r[0].family:"extensions"}}function Nc(e,t){if(t.length===0)return e;let n=ge(e,t);if(n)return n;let o=t.join(" ");if(!Xe.some(r=>r===o)&&!Ho(o)&&!Ae(o)&&!Me(e,t))return null;for(let r=t.length-1;r>0;r-=1){let i=ge(e,t.slice(0,r));if(i)return i}return t.length===1?e:null}function Mc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function pi(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function Dc(e){let t=new Map;for(let n of e){let o=n,r=pi(n);if(!r||typeof o.long!="string"||o.long.trim().length===0)continue;let i=t.get(r)??[];i.push(o.long.trim()),t.set(r,i)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(r=>r.trim()).filter(r=>r.length>0))].sort((r,i)=>r.localeCompare(i)));return t}function Fc(e){return S(e)}function Lc(e){let t=e.options??[],n=Dc(t);return t.map(o=>{let r=o,i=typeof r.flags=="string"?r.flags.trim():"",a=typeof r.description=="string"?r.description.trim():"",s=pi(o),d=(s?n.get(s)??[]:[]).filter(h=>h!==r.long).map(h=>h.trim()).filter(h=>h.length>0),l=a.match(/^Alias for ([^ ]+)/i),m=l&&l[1]?l[1].trim():null,u=r.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),p=i.includes("<"),f=p||i.includes("["),y={flags:i,long:typeof r.long=="string"?r.long:null,short:typeof r.short=="string"?r.short:null,description:a,takes_value:f,value_required:p,value_name:Mc(i),variadic:r.variadic===!0,required:u,aliases:d,alias_for:m};return r.defaultValue!==void 0&&(y.default_value=r.defaultValue),y})}function jc(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let r=o.alias_for,i=t.get(r);if(!i)continue;let a=o.long,s=new Set([...i.aliases??[],a]);i.aliases=[...s].sort((c,d)=>c.localeCompare(d))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function Uc(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(o=>{let r=typeof o.name=="function"?o.name():typeof o.name=="string"?o.name:"argument",i=typeof o.description=="string"&&o.description.trim().length>0?o.description.trim():null;return{name:r.trim(),required:o.required===!0||i?.toLowerCase().startsWith("required;")===!0,variadic:o.variadic===!0,description:i}})}function qc(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(i=>i.name()!=="help"||e.parent===null).filter(i=>!n||(ee(i)??Z(i.name()))!=="internal").map(i=>{let a=N($(i)),s=a.split(" ")[0],c=ee(i),d=ui(a,t,c!==void 0),l=le.find(({alias:m})=>m===a);return{name:i.name().trim(),aliases:fn(i),description:i.description().trim(),tier:d?.tier??c??Z(s),family:d?.family??ot(s),...l?{alias_for:l.canonical,alias_lifecycle:l.lifecycle,...l.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,a)=>i.name.localeCompare(a.name))}function Hc(e,t,n){if(!n)return t;let o=n.examples??[],r=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?r.length>0?[...r]:[...t.tips]:[],detail_mode:e}}function zc(e,t){return e===void 0?null:t?.tier??Z(e)}function Gc(e,t){return e===void 0?null:t?.family??ot(e)}function Wc(e,t,n){if(!(t!==e||!n))return le.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Bc(e,t,n,o,r=new Map,i=!1){if(!e){let s=Uc(t),c=qc(t,r,i),d=new Set(c.map(({name:l})=>l));return{arguments:s,options:o,subcommands:[...c,...Qe.filter(({parent:l,action:m})=>l===n&&!d.has(m)).map(({action:l,description:m})=>({name:l,aliases:[],description:m,tier:Z(n.split(" ")[0]),family:ot(n.split(" ")[0])}))].sort((l,m)=>l.name.localeCompare(m.name)),usage:[n,s.reduce((l,m)=>m.required?l.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):l,t.usage())].filter(l=>l.length>0).join(" ")}}let a=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:c,variadic:d,value_kind:l,polymorphic:m})=>({name:s,required:c,variadic:d,description:m?`Polymorphic ${l} value; inspect the action contract before mutation.`:`${l.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:c})=>s!==null&&a.has(s)||c.some(d=>a.has(d))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:c,variadic:d})=>{let l=d?`${s}...`:s;return c?`<${l}>`:`[${l}]`})].join(" ")}}function Vc(e,t,n,o,r){let i=Zt(n),a=ue(n),s=N($(t)),c=N(o.join(" ")),d=c.length>s.length?c:s,l=Ae(d),m=l?.command??s,u=m.length>0?m:void 0,p=u?.split(" ")[0],f=br(u,i),y=u?r.get(u):void 0,h=u?ui(u,r,ee(t)!==void 0):void 0,C=Hc(i,f,y),O=jc(Jr(Lc(t),Kr(y))),U=Bc(l,t,m,O,r,a),M=Wc(e,t,a);return{format:"pm_help_v1",detail_mode:i,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:zc(p,h),capability_family:Gc(p,h),description:l?.description??t.description(),usage:U.usage,intent:l?.description??C.intent,examples:l?[l.example]:C.examples,tips:l?[et(l.accepted_flags)]:C.tips,arguments:U.arguments,options:U.options,subcommands:U.subcommands,has_subcommands:U.subcommands.length>0,...M===void 0?{}:{command_aliases:M}}}async function fi(e,t,n){let o=q(t);if(!o.json)return!1;let r=P(t);if(!r.requested)return!1;let i=Nc(e,r.commandPathTokens);if(!i){if(!o.quiet){let a=`unknown command '${r.commandPathTokens.join(" ")}'`,s=xn(a,e,n),c=mt(a,"help",Pe,g.USAGE,{...s,attemptedCommand:Fc(t),normalizedInvocationArgs:[...t],providedOptionFlags:K(t)}),d=o.tokenAccounting?X(c,l=>`${JSON.stringify(l,null,2)}
25
+ ${o}`}function bn(e){return P(e).commandPathTokens[0]??k(e)??"<command>"}function gc(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let r=o.shift();if(!r)continue;let i=N($(r)),a=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!a&&n.add(i),o.push(...r.commands)}for(let r of t.keys()){let i=N(r),a=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!a&&n.add(i)}return[...n].sort((r,i)=>r.localeCompare(i))}function si(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let r=n.split(" ");if(n===o)return 0;if(r.includes(o))return 1;if(r.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let i=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let s of r){let c=Ot(s,o,i);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function ci(e){return F(e).slice(2).replace(/-/g,"")}function xn(e){return S(e)}function hc(e){let t=e.split(" ")[0]?.trim().toLowerCase();if(!t)return null;let n=pc[t];return n?`If this command comes from an optional package, install it with: pm install ${n}`:null}function li(e){let t=Jo(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function yc(e,t){let n=li(e);if(n.length===0)return[];let o=[];for(let r of t.values()){let i=new Set,a=r.source;if(a)for(let c of[a.name,a.package]){let d=li(c??"");d.length>0&&i.add(d)}if(i.size===0)continue;[...i].some(c=>c===n||c.includes(n)||n.includes(c))&&o.push(r.command)}return[...new Set(o)].sort((r,i)=>r.localeCompare(i))}function Ne(e,t){let n=new Set,o=t??nt(e);for(let r of o){r.flag.startsWith("--")&&n.add(F(r.flag));for(let i of r.aliases??[])i.startsWith("--")&&n.add(F(i))}return[...n].sort((r,i)=>r.localeCompare(i))}function wc(e,t){if(!e.startsWith("--"))return[];let n=ci(e);if(n.length===0)return[];let o=n.length>=8?2:1,r=[];for(let i of t){let a=ci(i);if(a===n)continue;if(n.length>=3&&a.startsWith(n)){r.push({flag:i,rank:0,distance:a.length-n.length});continue}let s=Ot(n,a,o);s===null||s<=0||r.push({flag:i,rank:1,distance:s})}return r.sort((i,a)=>i.rank!==a.rank?i.rank-a.rank:i.distance!==a.distance?i.distance-a.distance:i.flag.localeCompare(a.flag)).map(i=>i.flag).slice(0,3)}var gt,vc=new Set(["ctx","packages","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","start-task","pause-task","close-task","help"]);function _c(){if(gt)return gt;let e=new Map;for(let t of Ze)if(!vc.has(t))for(let n of Ne(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return gt=e,gt}function bc(e,t){if(!e.startsWith("--"))return[];let n=_c().get(F(e));if(!n)return[];let o=t?.trim().toLowerCase(),r=new Set(Ne(o));return n.filter(i=>i!==o).map(i=>({command:i,sharedFlagCount:Ne(i).filter(a=>r.has(a)).length})).sort((i,a)=>i.sharedFlagCount!==a.sharedFlagCount?a.sharedFlagCount-i.sharedFlagCount:i.command.localeCompare(a.command)).map(({command:i})=>i)}function xc(e,t,n){for(let o=0;o<e.length;o+=1){let r=e[o];if(!r.startsWith("--"))continue;let i=r.indexOf("="),a=i>=0?r.slice(0,i):r;if(F(a)!==F(t))continue;let s=[...e];return s[o]=i>=0?`${n}${r.slice(i)}`:n,s}}function Cc(e){let t=new Set(e.commandPaths),n=i=>Math.min(si(i,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?si(i,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,r=(i,a)=>{if(!Number.isFinite(a)||!t.has(i))return;let s=o.get(i);(s===void 0||a<s)&&o.set(i,a)};for(let i of e.commandPaths)r(i,n(i));for(let[i,a]of Object.entries(Yn))i!=="read"&&r(a,n(i));return[...o.entries()].sort(([i,a],[s,c])=>a!==c?a-c:i.localeCompare(s)).map(([i])=>i)}function kc(e){let t=cr(e.commandPaths,e.primaryToken),n=Cc(e),o=yc(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return di([...t,...n,...o])}function Ec(e){return[...new Set(e.map(n=>n.split(" ")[0]).filter(n=>n.length>0))].sort((n,o)=>n.localeCompare(o))}function Sc(e,t){let n=e.map(o=>`pm ${o} --help`);return t?[...new Set([...n,"pm --help --all"])]:[...new Set(["pm --help --all",...n])]}function Cn(e,t,n){let o=e.match(/unknown command '([^']+)'/i);if(!o||typeof o[1]!="string")return;let r=N(o[1]);if(r.length===0)return;let i=gc(t,n);if(i.length===0)return;let a=r.split(" ")[0],s=kc({commandPaths:i,normalizedUnknown:r,primaryToken:a,extensionDescriptors:n}),c=Ec(i),d=(s.length>0?s:c).slice(0,3),l=Sc(d,s.length>0),m=hc(r),p=s.length>0?`Did you mean: ${d.join(", ")}?`:null;return{unknownCommandExamples:l,unknownCommandNextSteps:[...p?[p]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',"Use one of the suggested command paths above with --help to inspect valid flags and usage.",...m?[m]:[]]}}function di(e){return Array.from(new Set(e))}function Ac(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
26
+ `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function Tc(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n!==","&&n!==":"&&n!==";")break;t-=1}return e.slice(0,t)}function Oc(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:(typeof o.aliases=="function"?o.aliases():[]).some(i=>i.trim().toLowerCase()===n))}function Me(e,t){if(t.length===0)return!0;let n=e;for(let[o,r]of t.entries()){let i=Oc(n,r);if(!i){let a=n.registeredArguments;return a.length>0&&(n.commands.length===0||a[0]?.required===!0)&&(a.at(-1)?.variadic===!0||t.length-o<=a.length)}n=i}return!0}async function Rc(e,t,n,o){try{let r=R(process.cwd(),e.path);if(!await H(z(r)))return{allowedTypes:Pe};let i=await I(r),a=e.noExtensions?void 0:Y(),s=J(i,a),c;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let d=n.findIndex(m=>m===o),l=n[d+2];if(n[d+1]?.toLowerCase()==="add"&&l!==void 0&&!l.startsWith("-"))try{c=(await Qe(r,l,i.id_prefix,i.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Pe,pmRoot:r,settings:i,typeToFolder:s.type_to_folder,verifiedCollectionItemId:c}}catch{return{allowedTypes:Pe}}}function Ic(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?di([...fc(t,n[1]),...wc(n[1],Ne(t))]):void 0,r=n?bc(n[1],t):[],i=n!==null&&Ne(t).includes(F(n[1]));return{match:n,suggestions:o,otherCommands:r,scope:i?"declared_on_path":r.length>0?"declared_elsewhere":"declared_nowhere"}}function $c(e,t,n){if(!t||!n||n.length===0)return;let o=xc(e,t[1],n[0]);return o?xn(o):void 0}function Pc(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?Tc(Ac(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let r=k(t);if(r)return ar(t,r,[o])}function Nc(e,t){if(!/too many arguments/i.test(e)||k(t)!=="schema")return;let n=it(t),o=t[n+1]?.trim().toLowerCase(),r=t[n+2]?.trim().toLowerCase();if(!o||!r)return;let i=`${o}-${r}`;if(!ai.includes(i))return;let a=[...t.slice(0,n+1),i,...t.slice(n+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${o} ${r}`,unknownSubcommandAllowedValues:[...ai],suggestedRetryCommand:xn(a)}}async function De(e,t,n,o={}){let i=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=at(process.argv.slice(2)).argv,s=q(a),c=k(a),d=xn(a),l=K(a),m=await Rc(s,i,a,c),p=m.allowedTypes,u=Cn(i,t,n),f=Ic(i,c),y=Nc(i,a),h=y?.suggestedRetryCommand??$c(a,f.match,f.suggestions)??Pc(i,a);return{message:i,commandName:c,allowedTypes:p,attemptedCommand:d,normalizedInvocationArgs:[...a],providedOptionFlags:l,unknownOptionSuggestions:f.suggestions,unknownOptionOtherCommands:f.otherCommands.length>0?f.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:f.otherCommands.length>0?f.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:f.otherCommands.length>12||void 0,unknownOptionScope:f.scope,suggestedRetryCommand:h,verifiedCollectionItemId:m.verifiedCollectionItemId,...y,...u,...o}}async function kn(e,t,n,o={}){let r=await De(e,t,n,o),{message:i,commandName:a,allowedTypes:s,unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:l,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:f,unknownOptionOtherCommandsTotal:y,unknownOptionOtherCommandsTruncated:h,unknownOptionScope:C,unknownSubcommandPath:O,unknownSubcommandToken:U,unknownSubcommandAllowedValues:M,suggestedRetryCommand:ie,verifiedCollectionItemId:St,failedExtensions:Ge}=r,be=Mr(i,a,s,{unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:l,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:f,unknownOptionOtherCommandsTotal:y,unknownOptionOtherCommandsTruncated:h,unknownOptionScope:C,unknownSubcommandPath:O,unknownSubcommandToken:U,unknownSubcommandAllowedValues:M,suggestedRetryCommand:ie,verifiedCollectionItemId:St,failedExtensions:Ge}),ae=await _o("help_format",{message:be,command:a,allowed_types:s});return ae.handled&&typeof ae.result=="string"?ae.result:be}async function En(e,t,n,o=!1,r={}){let i=await De(e,t,n,r),a=ut(i.message,i.commandName,i.allowedTypes,g.USAGE,{unknownCommandExamples:i.unknownCommandExamples,unknownCommandNextSteps:i.unknownCommandNextSteps,attemptedCommand:i.attemptedCommand,normalizedInvocationArgs:i.normalizedInvocationArgs,providedOptionFlags:i.providedOptionFlags,unknownOptionSuggestions:i.unknownOptionSuggestions,unknownOptionOtherCommands:i.unknownOptionOtherCommands,unknownOptionOtherCommandsTotal:i.unknownOptionOtherCommandsTotal,unknownOptionOtherCommandsTruncated:i.unknownOptionOtherCommandsTruncated,unknownOptionScope:i.unknownOptionScope,unknownSubcommandPath:i.unknownSubcommandPath,unknownSubcommandToken:i.unknownSubcommandToken,unknownSubcommandAllowedValues:i.unknownSubcommandAllowedValues,suggestedRetryCommand:i.suggestedRetryCommand,verifiedCollectionItemId:i.verifiedCollectionItemId,failedExtensions:i.failedExtensions}),s=o?mt(a):a,c=q(i.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(c?X(s,d=>`${JSON.stringify(d,null,2)}
27
+ `):s,null,2)}import ye 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]="989fc265-7deb-5456-8a83-0f1fa8d2d9b2")}catch{}})();async function Sn(e,t={},n=[]){let o={readSettings:I,loadExtensions:Ce,activateExtensions:ke,resolveImplicitPmRoot:It,...t};try{let r=await o.readSettings(e),i=await o.loadExtensions({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(i);return[...i.failed,...a.failed].map(s=>{let c=(i.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),d=[...c?.contributions?.commands??[],...c?.contributions?.command_handlers??[],...c?.activation?.commands??[]].map(N).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),l=n.map(N),m=d.some(p=>l.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...d.length>0?{declared_commands:d}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(r){return[{layer:"runtime",name:"extension-loader",error:r instanceof Error?r.message:String(r)}]}}async function mi(e,t,n={},o=[]){if(e!=="unknown_command")return[];let r=await Sn(t,n,o),i={readSettings:I,loadExtensions:Ce,activateExtensions:ke,resolveImplicitPmRoot:It,...n};try{let a=i.resolveImplicitPmRoot(process.cwd());if(ye.resolve(a)===ye.resolve(t))return r;let[s,c]=await Promise.all([i.readSettings(t),i.readSettings(a)]),[d,l]=await Promise.all([i.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),i.loadExtensions({pmRoot:a,settings:c,cwd:process.cwd(),noExtensions:!1})]),m=new Set(d.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(l.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,f)=>u.localeCompare(f));if(p.length===0)return r;r.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${ye.resolve(t)} extension_discovery_root=${d.roots.project}; cwd_storage_root=${ye.resolve(a)} cwd_extension_discovery_root=${l.roots.project}; the selected --pm-path runtime is missing ${p.length} workspace command path(s): ${p.slice(0,8).join(", ")}${p.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${ye.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${ye.resolve(t)} install <package> --project".`})}catch{}return 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]="481ed602-8144-59ae-9ac6-223f7a57ecef")}catch{}})();var pi={core:0,standard:1,full:2,internal:3};function ui(e,t,n=!0){let o=t.get(e);if(o)return o;if(!n)return;let r=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(r.length===0)return;let i=r.reduce((s,c)=>pi[c.tier]<pi[s]?c.tier:s,"internal"),a=new Set(r.map(({family:s})=>s));return{tier:i,family:a.size===1?r[0].family:"extensions"}}function Mc(e,t){if(t.length===0)return e;let n=he(e,t);if(n)return n;let o=t.join(" ");if(!Ze.some(r=>r===o)&&!Go(o)&&!Te(o)&&!Me(e,t))return null;for(let r=t.length-1;r>0;r-=1){let i=he(e,t.slice(0,r));if(i)return i}return t.length===1?e:null}function Dc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function fi(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function Fc(e){let t=new Map;for(let n of e){let o=n,r=fi(n);if(!r||typeof o.long!="string"||o.long.trim().length===0)continue;let i=t.get(r)??[];i.push(o.long.trim()),t.set(r,i)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(r=>r.trim()).filter(r=>r.length>0))].sort((r,i)=>r.localeCompare(i)));return t}function Lc(e){return S(e)}function jc(e){let t=e.options??[],n=Fc(t);return t.map(o=>{let r=o,i=typeof r.flags=="string"?r.flags.trim():"",a=typeof r.description=="string"?r.description.trim():"",s=fi(o),d=(s?n.get(s)??[]:[]).filter(h=>h!==r.long).map(h=>h.trim()).filter(h=>h.length>0),l=a.match(/^Alias for ([^ ]+)/i),m=l&&l[1]?l[1].trim():null,p=r.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),u=i.includes("<"),f=u||i.includes("["),y={flags:i,long:typeof r.long=="string"?r.long:null,short:typeof r.short=="string"?r.short:null,description:a,takes_value:f,value_required:u,value_name:Dc(i),variadic:r.variadic===!0,required:p,aliases:d,alias_for:m};return r.defaultValue!==void 0&&(y.default_value=r.defaultValue),y})}function Uc(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let r=o.alias_for,i=t.get(r);if(!i)continue;let a=o.long,s=new Set([...i.aliases??[],a]);i.aliases=[...s].sort((c,d)=>c.localeCompare(d))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function qc(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(o=>{let r=typeof o.name=="function"?o.name():typeof o.name=="string"?o.name:"argument",i=typeof o.description=="string"&&o.description.trim().length>0?o.description.trim():null;return{name:r.trim(),required:o.required===!0||i?.toLowerCase().startsWith("required;")===!0,variadic:o.variadic===!0,description:i}})}function Hc(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(i=>i.name()!=="help"||e.parent===null).filter(i=>!n||(ee(i)??Z(i.name()))!=="internal").map(i=>{let a=N($(i)),s=a.split(" ")[0],c=ee(i),d=ui(a,t,c!==void 0),l=se.find(({alias:m})=>m===a);return{name:i.name().trim(),aliases:hn(i),description:i.description().trim(),tier:d?.tier??c??Z(s),family:d?.family??rt(s),...l?{alias_for:l.canonical,alias_lifecycle:l.lifecycle,...l.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((i,a)=>i.name.localeCompare(a.name))}function zc(e,t,n){if(!n)return t;let o=n.examples??[],r=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?r.length>0?[...r]:[...t.tips]:[],detail_mode:e}}function Gc(e,t){return e===void 0?null:t?.tier??Z(e)}function Wc(e,t){return e===void 0?null:t?.family??rt(e)}function Bc(e,t,n){if(!(t!==e||!n))return se.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Vc(e,t,n,o,r=new Map,i=!1){if(!e){let s=qc(t),c=Hc(t,r,i),d=new Set(c.map(({name:l})=>l));return{arguments:s,options:o,subcommands:[...c,...et.filter(({parent:l,action:m})=>l===n&&!d.has(m)).map(({action:l,description:m})=>({name:l,aliases:[],description:m,tier:Z(n.split(" ")[0]),family:rt(n.split(" ")[0])}))].sort((l,m)=>l.name.localeCompare(m.name)),usage:[n,s.reduce((l,m)=>m.required?l.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):l,t.usage())].filter(l=>l.length>0).join(" ")}}let a=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:c,variadic:d,value_kind:l,polymorphic:m})=>({name:s,required:c,variadic:d,description:m?`Polymorphic ${l} value; inspect the action contract before mutation.`:`${l.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:c})=>s!==null&&a.has(s)||c.some(d=>a.has(d))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:c,variadic:d})=>{let l=d?`${s}...`:s;return c?`<${l}>`:`[${l}]`})].join(" ")}}function Kc(e,t,n,o,r){let i=en(n),a=ue(n),s=N($(t)),c=N(o.join(" ")),d=c.length>s.length?c:s,l=Te(d),m=l?.command??s,p=m.length>0?m:void 0,u=p?.split(" ")[0],f=br(p,i),y=p?r.get(p):void 0,h=p?ui(p,r,ee(t)!==void 0):void 0,C=zc(i,f,y),O=Uc(Yr(jc(t),Jr(y))),U=Vc(l,t,m,O,r,a),M=Bc(e,t,a);return{format:"pm_help_v1",detail_mode:i,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:Gc(u,h),capability_family:Wc(u,h),description:l?.description??t.description(),usage:U.usage,intent:l?.description??C.intent,examples:l?[l.example]:C.examples,tips:l?[tt(l.accepted_flags)]:C.tips,arguments:U.arguments,options:U.options,subcommands:U.subcommands,has_subcommands:U.subcommands.length>0,...M===void 0?{}:{command_aliases:M}}}async function gi(e,t,n){let o=q(t);if(!o.json)return!1;let r=P(t);if(!r.requested)return!1;let i=Mc(e,r.commandPathTokens);if(!i){if(!o.quiet){let a=`unknown command '${r.commandPathTokens.join(" ")}'`,s=Cn(a,e,n),c=ut(a,"help",Pe,g.USAGE,{...s,attemptedCommand:Lc(t),normalizedInvocationArgs:[...t],providedOptionFlags:K(t)}),d=o.tokenAccounting?X(c,l=>`${JSON.stringify(l,null,2)}
28
28
  `):c;de(`${JSON.stringify(d,null,2)}
29
- `)}return process.exitCode=g.USAGE,!0}if(!o.quiet){let a=Vc(e,i,t,r.commandPathTokens,n);Oo(`${JSON.stringify(a,null,2)}
30
- `)}return process.exitCode=g.SUCCESS,!0}function Kc(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
31
- `)}function Jc(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",r=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${r.length>0?r.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function Yc(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let r of[...t.required_create_fields,...t.required_create_repeatables])o.add(r);return{progressive:n,strict:o}}function Xc(e,t,n,o){let r=new Set(n),i=o.filter(c=>!r.has(c)),a=c=>c.length>0?c.map(d=>Tt("create",d)).join(", "):"none";e.push(` required in strict mode: ${a(i)}`);let s=i.map(Yo).filter(c=>c!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function Zc(e,t,n){let o=or(n);if(!o)return Kc(e,t);let r=Qn(o,t);if(!r){let y=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${y}`].join(`
32
- `)}let i=n.indexOf("--"),a=i<0?n:n.slice(0,i),s=a.findIndex(y=>y==="--create-mode"||y.startsWith("--create-mode=")),c=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],d=e==="create"&&c?.toLowerCase()==="strict",l=Yc(e,r),m=We(r,e,l.progressive),u=We(r,e,d?l.strict:l.progressive),p=y=>y.length>0?y.map(h=>Tt(e,h)).join(", "):"none",f=["",`Type-aware option policies for ${r.name}:`,` required: ${p(u.required)}`,` disabled: ${p(u.disabled)}`,` hidden: ${p(u.hidden)}`];if(e==="create"){let y=We(r,e,l.strict);Xc(f,r,m.required,y.required)}return Jc(f,r),u.errors.length>0&&f.push(` config errors: ${u.errors.join("; ")}`),f.join(`
33
- `)}function gi(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let r=$e(e,o);r&&r.addHelpText("after",Zc(o,t,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]="fa92f987-990a-5159-8c45-f055d5a15da2")}catch{}})();async function hi(e,t,n,o){if(n)return null;let r=e.some(a=>a==="--for"||a.startsWith("--for=")),i=k(e)==="contracts"&&e.includes("--full");return r||i?await o(t):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]="2b73baa7-f63e-5a3b-a8cb-659ac26d7c67")}catch{}})();var En="PM_CLI_PACKAGE_ROOT",ht=Symbol.for("pm.readOutputInvocationProvenance");function Mn(e,t){let n=Reflect.get(e,ht);n!==void 0&&Reflect.set(t,ht,n)}function Ci(e,t,n){let o=Co(t,n);if(!o)return;let r=e;for(;r.parent;)r=r.parent;let i=r.rawArgs,a=new Set(K(i.slice(2))),s=vo.find(l=>l.command===o),c=Object.values(s.dimensions).flatMap(l=>l.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),d=Reflect.get(n,ht);Reflect.set(n,ht,{canonical_include_modes:d?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),Mn(n,e)}function el(){return Yn(import.meta.url,["../.."])}(typeof process.env[En]!="string"||process.env[En]?.trim().length===0)&&(process.env[En]=el());var we=null,j=null;function tl(e){we=e}function nl(e){T=e}var ol=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),rl=new Set(["parse","preflight","execute","unknown"]),il=new Set(["usage","validation","conflict","runtime","unknown"]),Fe=null,re=null,T=new Map,Dn=250,al=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),sl=new Set(["1","true","yes","on"]),cl=Se(()=>import("./chunks/register-setup-H4SVAVX7.js")),ll=Se(()=>import("./chunks/register-list-query-5JL52D33.js")),dl=Se(()=>import("./chunks/register-mutation-ZPG7KMVP.js")),ml=Se(()=>import("./chunks/register-operations-I5W3KMGB.js"));function gt(e){return S(e)}function ki(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>te(o)??o))];return n.length>0?n:void 0}function ul(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=K(t),r=new Set(o.map(l=>te(l)??l)),i=ki(e),a=t.find(l=>b.commands.some(m=>m.name()===l)),s=a?b.commands.find(l=>l.name()===a):void 0,c=new Set([...b.options,...s?.options??[]].flatMap(l=>l.flags.split(/[ ,|]+/).map(m=>te(m)).filter(m=>m!==void 0))),d=i?.filter(l=>{let m=te(l)??l;return r.has(m)?!1:c.has(m)||mn(t,a,m,T)!==void 0});return d&&d.length>0?d:void 0}function pl(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let r=n?.[0],i=r?te(r):void 0,a=e.find(u=>b.commands.some(p=>p.name()===u)),s=a?b.commands.find(u=>u.name()===a):void 0,c=i?s?.options.find(u=>u.flags.split(/[ ,|]+/).includes(i)):void 0,d=mn(e,a,i,T),l=i?c?.isBoolean()===!0||d===!1?[i]:[i,"<value>"]:[],m=i?gt([...e,...l]):t;return m===t?void 0:m}function fl(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let r=e[o];r!=null&&(n[o]=r)}return n}function gl(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...fl(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ei(e,t,n){let o=Ye(t),r=o.includes("--explain"),i=e?.recovery,a=i&&o.includes("history-redact")?{...i,...i.attempted_command?{attempted_command:gt(o)}:{},...i.normalized_args?{normalized_args:[...o]}:{},...i.suggested_retry?{suggested_retry:gt(o)}:{},...i.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:i;if(a?.recovery_mode==="compact"&&!r)return{...e,recovery:a};let s=gt(o),c=K(o),d=ul(n,o,a),l=pl(o,s,d,a),m=gl({invocationArgv:o,attemptedCommand:s,providedFields:c,inferredMissing:d,suggestedRetry:l,existingRecovery:a});return{...e,recovery:m}}function ye(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let r=o.trim();if(r.length>0)return r}}}function Si(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Fn(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function Ai(e){if(!e)return;let t=e.trim().toLowerCase();if(ol.has(t))return t}function Ti(e){if(!e)return;let t=e.trim().toLowerCase();if(rl.has(t))return t}function Oi(e){if(!e)return;let t=e.trim().toLowerCase();if(il.has(t))return t}function Ri(e){let t=ye(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(Si(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let r=Fn(e,"failed");if(typeof r=="number"&&r>0)return`failed_runs:${r}`;let i=e?.run_results;if(Array.isArray(i)){let a=i.filter(s=>St(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function Ii(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function $i(){let e=St(ce()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Fn(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,r=Jo(o),i=ye(e,"error_code","errorCode")??Ii(r,o),a=Oi(ye(e,"error_category","errorCategory"))??(r?void 0:Et(i)),s=r?void 0:Ri(e)??`command_exit_${o}`,c=Ai(ye(e,"command_resolution","commandResolution"))??Nt({ok:r,errorCode:i,errorCategory:a}),d=Ti(ye(e,"resolution_stage","resolutionStage"))??"execute";return{ok:r,error:s,exit_code:o,error_code:i,error_category:a,command_resolution:c,resolution_stage:d}}async function qe(e){let t=j;j=null,await vr(t,e);let n=we;if(we=null,!n){Ve();return}let o=[],r=fo();try{await Cr({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?r?.map(i=>i.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await oo(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:ce(),affected:r}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{Ve()}!n.globalOptions.json&&o.length>0&&w(`[pm] warning: afterCommand hook_warnings=${D(o)}`),n.profileEnabled&&o.length>0&&w(`profile:extensions hook_warnings=${D(o)}`)}async function Pi(){await Po()}function Ni(e){return sl.has((process.env[e]??"").trim().toLowerCase())}function Mi(e){return Ni("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!al.has(Math.trunc(e))}async function yt(e){return Mi(e.exit_code)?(await Pi(),No(e),!0):!1}async function Di(e){let t=Q(e.error),n=Fr(t);e.bootstrapGlobal.json?w(JSON.stringify(Mr(t,g.GENERIC_FAILURE),null,2)):w(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",r="runtime_failed";try{await Pi(),Ft(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,r=i.commandResolution,ke(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:r,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to report error: ${Q(i)}`)}try{await qe({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:r,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to run error hooks: ${Q(i)}`)}try{await Ee()}catch(i){e.bootstrapGlobal.json||w(`Failed to flush error reporting: ${Q(i)}`)}}function yi(e,t,n,o){Ci(e,t,o);let r=n.outputInclude;if(r===void 0)return;let{selectors:i,modes:a}=So(t,r,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;Mn(o,e);let s=Eo(t);for(let d of a){let l=s.get(d),m=o[l];e.setOptionValueWithSource(l,m,"cli")}let c=i.length>0?i.join(","):void 0;c===void 0?delete n.outputInclude:n.outputInclude=c;for(let d=e;d;d=d.parent)d.setOptionValueWithSource("outputInclude",c,"cli");jt(e,n)}function Le(e,t,n=[]){let r={...e.optsWithGlobals()};Mn(e,r),delete r.json,delete r.quiet,delete r.path,delete r.pmPath,delete r.noExtensions,delete r.extensions,delete r.profile,delete r.pager,delete r.changedFields,delete r.fullChangedFields,delete r.idOnly,delete r.lean,delete r.tokenAccounting,delete r.outputInclude,delete r.outputLimit,delete r.outputBudget,delete r.outputFormat,delete r.outputSession;let i=pr(t);for(let[a,s]of Object.entries(i))r[a]===void 0&&(r[a]=s);if(n.length>0){let a=dr(n),s=tt($(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),c={...i};for(let d of a)r[d]!==void 0&&(c[d]=r[d]);return Kt(c,[...s,...n],$(e)),ur(r,n,i)}return r}function Tn(e,t){let n=_(t);return n.length===0?[]:e.flags.filter(o=>_(o.target_command)===n).flatMap(o=>o.flags)}function wt(e,t,n){let o=Tn(e,t),r=[t],i=[];for(let a of n){if(a.startsWith("-"))break;r.push(a);let s=Tn(e,r.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Ln(e){return e.arguments??[]}function wi(e){let t=Ln(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Fi(e,t){if(!e)return!1;let n=_(t);return e.importers.some(o=>_(`${o.importer} import`)===n)||e.exporters.some(o=>_(`${o.exporter} export`)===n)}function Li(e,t){let n=Ln(e),o=n.filter(c=>c.required).length,i=n.some(c=>c.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new v(`Missing required argument for extension command '${e.command}'. Usage: ${wi(e)}${s}`,g.USAGE);if(t.length>i){let c=t.slice(i).join(" ");throw new v(`Too many arguments for extension command '${e.command}': ${c}. Usage: ${wi(e)}${s}`,g.USAGE)}}function hl(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function yl(e,t,n){if(n.length>0){Kt(t,n,e.command);return}let o=Object.keys(t).filter(r=>t[r]!==void 0).sort();if(o.length!==0)throw new v(`Unknown option '${o.map(hl).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function ji(e,t,n,o){e&&(Li(e,t),yl(e,n,o))}var wl={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},Sn=new Map;function On(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function Ui(e,t){return e.options.some(n=>n.long===t)}function qi(e,t){return e.options.some(n=>n.short===t)}function Rn(e,t,n,o){let r=t.trim();if(!r)return;let i=n.length>0?n:`Runtime schema field (${t})`;if(r.startsWith("-")&&!r.startsWith("--")){if(qi(e,r))return;if(o){e.option(`${r} <value>`,`${i} (repeatable)`,qt);return}e.option(`${r} <value>`,i);return}let a=r.startsWith("--")?r:`--${r}`;if(!Ui(e,a)){if(o){e.option(`${a} <value>`,`${i} (repeatable)`,qt);return}e.option(`${a} <value>`,i)}}async function Hi(e,t){let n=wl[e];if(!n)return[];let o=`${t}:${n}`,r=Sn.get(o);if(r)return r;if(!await H(z(t)))return Sn.set(o,[]),[];let i=await I(t),s=(It(i.schema).command_to_fields.get(n)??[]).flatMap(c=>[c.cli_flag,...c.cli_aliases].map(l=>({long:`--${l}`,type:On(c.type),value_type:On(c.type)})));return Sn.set(o,s),s}async function zi(e,t){let n=q(t),o=R(process.cwd(),n.path);if(!await H(z(o)))return;let r=re?.key===qn(o)?re.snapshot:null,i=r===null?await I(o):r.settings,a=It(i.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let c of s){let d=ge(e,c.path.split(" "));if(d)for(let l of a.command_to_fields.get(c.command)??[]){let m=l.description??"";Rn(d,l.cli_flag,m,l.repeatable);for(let u of l.cli_aliases)Rn(d,u,`Alias for --${l.cli_flag}`,l.repeatable)}}}async function jn(e,t,n,o,r){let i=k(n);if(!(i!=="create"&&i!=="update"))try{let a=r??await I(t),s=J(a,o);gi(e,s,n)}catch{}}function In(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Gi(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Un(e){return e.some(t=>t==="--profile")}function qn(e){return`pm-root:${e}`}function Wi(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=_(n);o.length!==0&&t.push(o)}return t}function He(e){let t=_(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(r=>r.length>0);for(let r of Wi(e.commandArgs))o.push(...r.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n)]}function Bi(e,t){let n=_(e);if(n.length===0)return!1;let o=He(t);for(let r of o)if(r===n||r.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(r=>n.startsWith(`${r} `)):!1}function Hn(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...E(n.commands),...E(n.command_handlers),...E(n.command_overrides),...E(n.flag_commands),...E(n.parser_overrides),..._i(n.preflight_ownership),..._i(n.renderer_ownership)]:[]}function E(e){return e??[]}function _i(e){return E(e).flatMap(t=>t.commands)}function _t(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Vi=new Set(["hooks","parser","preflight","renderers"]),Ki=new Set(["commands","schema","services","importers"]),_l=new Set(["reindex","search","search-advanced"]),bl=new Set(["--template"]);function je(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Ji(e){let t=_(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return _l.has(n??t)}function Yi(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function zn(e){return _(e.commandPath??"")==="create"&&Yi(e,bl)}function Xi(e){return e.some(t=>{let n=_(t);return n==="templates"||n.startsWith("templates ")})}function $n(e,t){return e.some(n=>Bi(n,t))||zn(t)&&Xi(e)}function Zi(e){return[E(e.hooks).length,(e.preflight_overrides??0)-E(e.preflight_ownership).length,E(e.item_types).length,E(e.item_fields).length,E(e.relationship_kinds).length,E(e.service_overrides).length,E(e.assurance_providers).length,E(e.renderer_overrides).length-E(e.renderer_ownership).length].some(n=>n>0)}function Qi(e,t){let n=e.activation?.commands??[];if(n.length>0)return $n(n,t);let o=Hn(e);if($n(o,t)||_t(e).has("search")&&Ji(t.commandPath))return!0;if(e.contributions)return Zi(e.contributions)}function Gn(e,t){let n=Qi(e,t);if(n!==void 0)return n;let o=_t(e);return!!(je(o,Vi)||je(o,Ki))}function bt(e,t){return e.effective.length===0?!1:_(t.commandPath??"").length>0?e.effective.some(o=>Gn(o,t)):e.effective.some(o=>{let r=_t(o);return Hn(o).length>0||je(r,Vi)||je(r,Ki)||r.has("search")})}function Wn(e){let t=He(e).filter(r=>r.split(" ").every(i=>!i.startsWith("-"))).sort((r,i)=>i.length-r.length)[0]??_(e.commandPath??"");if(t.length===0)return"all";let n=zn(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function ea(e){return Wn(e)==="all"?void 0:t=>Gn(t,e)}function ze(e){let t=P(e);if(t.requested&&t.commandPathTokens.length>0){let[r,...i]=t.commandPathTokens;return{commandPath:r,commandArgs:i,allowCommandPrefixMatch:!0}}let n=Oe(e),o=n.findIndex(r=>r.trim().length>0&&!r.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function ta(e){let t=e.args.map(String);if(_($(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.template.trim().length>0&&t.push("--template")}return t}function Pn(e){for(let t of e)t.startsWith("settings_read_")&&w(`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function na(e,t){e.profile&&(w(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&w(`profile:extensions activation_warnings=${D(t.activationWarnings)}`))}function xt(e,t,n){if(!e)return;let o=_(n.commandPath??"")||"<none>";w(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function vt(e,t=me){let n=qn(e);if(re?.key===n)return re.snapshot;try{let o=Date.now(),{settings:r,warnings:i}=await t(e),a=await ro({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:r,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...i]};return re={key:n,snapshot:s},s}catch{return re={key:n,snapshot:null},null}}async function _e(e,t,n=I){let o=t?Wn(t):"all",r=Gi(e,o);if(Fe?.key===r)return Fe.snapshot;try{let i=await n(e),a=await ve({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?ea(t):void 0}),s=await Ce({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(p=>_(p.command)))].filter(p=>p.length>0).sort((p,f)=>p.localeCompare(f)),d=qr(s.registrations.flags),l=jr(s.commands.handlers,s.registrations.commands),m=zr(c,s.registrations.commands,s.registrations.flags,l),u={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:i,commandHandlers:c,commandFlagHelp:d,commandDescriptors:m,commandAliases:l,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:p,module:f})=>({name:p,module:f}))};return Fe={key:r,snapshot:u},u}catch{return Fe={key:r,snapshot:null},null}}async function oa(e){let t=Te(e);if(t.noExtensions){let a=R(process.cwd(),t.path);return await H(z(a))&&Pn((await me(a)).warnings),null}let n=R(process.cwd(),t.path),o=await vt(n);if(!o)return null;Pn(o.settingsReadWarnings);let r={commandPath:$(e),commandArgs:ta(e)};if(!bt(o.discovery,r))return xt(t.profile,o,r),null;let i=await _e(n,r);return i?(na(t,i),{hooks:i.hooks,commands:i.commands,parsers:i.parsers,preflight:i.preflight,services:i.services,renderers:i.renderers,registrations:i.registrations,pmRoot:n}):null}async function ra(e){let t=await _e(e);return t?new Map(t.commandDescriptors):T}async function ia(e,t){return(await Ko({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function aa(e,t){let n=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return zo(e,er.forActiveExtensionHost({pmRoot:e,author:n}))}async function sa(e,t,n,o=[]){let r=$(e),i=Jt(e.args.map(String),o),a={...t},s={...n},c=R(process.cwd(),n.path),d=await Ke({command:r,args:i,options:a,global:s,pm_root:c});n.profile&&d.warnings.length>0&&w(`profile:extensions parser_warnings=${D(d.warnings)}`),i=d.context.args,a=d.context.options,s=d.context.global,ji(T.get(_(r)),i,a,o),se(void 0),Be({command:r,args:i,options:{...a},global:{...s},pm_root:c});let l=await Rt({command:r,args:i,options:a,global:s,pm_root:c,sdk:aa(c,s)});if(s.profile&&l.warnings.length>0&&w(`profile:extensions command_handler_warnings=${D(l.warnings)}`),!l.handled){if(l.warnings.length>0){let m=l.warnings[0],u=l.errorMessage?.trim(),p=u?` ${u}`:"";throw new v(`Command "${r}" failed in extension handler (${m}).${p}`,g.GENERIC_FAILURE,{code:l.errorCode??"command_failed",nextSteps:l.remediation?[l.remediation]:void 0})}throw new v(`Command "${r}" is provided by extensions and is not currently available.`,g.NOT_FOUND)}return l.exitCode!==void 0&&(process.exitCode=l.exitCode),se(l.result),l.result}var bi=Symbol("pm.wrappedActionHandler");function xl(e,t){let n=e[e.length-1];return n instanceof Nn?n:t}function xi(e,t,n){e&&n.length>0&&w(`profile:extensions ${t}=${D(n)}`)}function vl(e){let t=T.get(_(e.commandPath));if(!t||!Fi(e.activeRegistrations,e.commandPath))return;let n=Ln(t).length===0?fr(e.commandArgs):Jt(e.commandArgs,e.extensionFlagDefinitions);Li(t,n)}function Cl(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function ca(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[bi]!==!0){let r=o._actionHandler;o._actionHandler=async function(...a){let s=xl(a,n),c=Date.now();Ut(s);let d=Te(s),l=$(s),m=R(process.cwd(),d.path),u=s.args.map(String),p=Y(),f=p?wt(p,l,u):[],y=await Hi(l,m),h=Le(s,u,[...f,...y]),C=await Ke({command:l,args:u,options:h,global:d,pm_root:m});xi(d.profile,"parser_warnings",C.warnings),u=C.context.args,h=C.context.options,d=C.context.global,vl({activeRegistrations:p,commandPath:l,commandArgs:u,extensionFlagDefinitions:f}),d=await Wo(d),jt(s,d),Cl(s,a,u),nt(s,h),se(void 0),Be({command:l,args:u,options:{...h},global:{...d},pm_root:m});let O=await Rt({command:l,args:u,options:h,global:d,pm_root:m,sdk:aa(m,d)});if(xi(d.profile,"command_handler_warnings",O.warnings),O.handled){se(O.result),Pt(O.result,{...d,command:l,commandArgs:u,commandOptions:h,pmRoot:m}),d.profile&&w(`profile:command=${l} took_ms=${Date.now()-c}`);return}return await r.apply(this,a)},o[bi]=!0}for(let r of n.commands)t(r)};t(e)}async function ft(e){T=new Map,V({overrides:[]}),e&&await jn(e.rootProgram,e.pmRoot,e.invocationArgv,to(),e.settings)}function kl(e,t,n,o){if(t?.flags&&t.flags.length>0){un(e,t.flags);let r=pn(e,t.flags);r&&e.addHelpText("after",r)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function la(e,t,n){let o={core:0,standard:1,full:2,internal:3},r=(i,a)=>{let s=a.join(" "),c=[...n.entries()].filter(([l])=>l===s||l.startsWith(`${s} `)).map(([,l])=>l),d=c.length===0?"standard":c.reduce((l,m)=>o[m.tier]<o[l]?m.tier:l,"internal");hr(i,d);for(let l of i.commands)r(l,[...a,l.name()])};for(let i of e.commands)t.has(i.name())||r(i,[i.name()])}async function da(e,t){let n=q(t),o=R(process.cwd(),n.path);if(n.noExtensions){await ft({rootProgram:e,pmRoot:o,invocationArgv:t});return}let r=await vt(o),i=ze(t);if(!r){await ft();return}if(!bt(r.discovery,i)){await ft({rootProgram:e,pmRoot:o,invocationArgv:t,settings:r.settings}),xt(Un(t),r,i);return}let a=await _e(o,i);if(!a){await ft({rootProgram:e,pmRoot:o,invocationArgv:t,settings:r.settings});return}V(a.services),T=new Map(a.commandDescriptors),await jn(e,o,t,a.registrations,a.settings);let s=Qr(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,l=>ei(a.activationWarnings,w,l)),c=new Set(e.commands.map(l=>l.name())),d=l=>{let m=l.split(" ").filter(O=>O.length>0),u=a.commandDescriptors.get(l),p=ge(e,m),f=a.commandFlagHelp.get(l),y=u?Yr(u):null;if(p){kl(p,u,f,y);return}let h=Zr(e,m);u?.description&&h.description(u.description);let C=f;u&&(Gr(h,u),u.flags.length>0&&(un(h,u.flags),C=pn(h,u.flags)??void 0)),C&&h.addHelpText("after",C),y&&h.addHelpText("after",y),h.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...O)=>{let U=O[O.length-1],M=U instanceof Nn?U:h,ie=Te(M),kt=Date.now(),Ge=wt(a.registrations,l,M.args.map(String)),be=Le(M,M.args.map(String),Ge),ae=await sa(M,be,ie,Ge);await Bo(ie,ae),Pt(ae,{...ie,command:l,commandArgs:M.args.map(String),commandOptions:be,pmRoot:o}),ie.profile&&w(`profile:command=${l} took_ms=${Date.now()-kt}`)})};for(let l of s)d(l);la(e,c,a.commandDescriptors)}var Ue=Xn(import.meta.url,["../.."])??"0.0.0",b=Bt(Ue);function ma(e){e.hook("preAction",async(t,n)=>{we=null,j=null,Ve(),Ut(n);let o=n.optsWithGlobals(),r=Te(n),i=$(n),a=n.args.map(String),s=Le(n,a),c={...r};ko(i,{...s,outputInclude:o.outputInclude,outputLimit:o.outputLimit,outputBudget:o.outputBudget,outputFormat:o.outputFormat,outputSession:o.outputSession,outputCursor:o.outputCursor}),yi(n,i,c,s),await Lo(i,c);let d=R(process.cwd(),r.path),l=await oa(n);if(!l){we=io({commandName:i,commandArgs:a,commandOptions:s,globalOptions:c,pmRoot:d}),j=await Lt({command:i,pm_version:Ue,args:a,options:s,global:c,pm_root:d}),Mt(i,a,s,{source_context:j?.source_context,source_context_source:j?.source_context_source}),Dt(i),await yn(i,s,d,In()),await hn(i,a,s,c,d);return}ao(l.hooks),so(l.commands),co(l.parsers),lo(l.preflight),V(l.services),mo(l.renderers),uo(l.registrations);let m=wt(l.registrations,i,a);s=Le(n,a,m),yi(n,i,c,s);let u=await Ke({command:i,args:a,options:s,global:c,pm_root:l.pmRoot});c.profile&&u.warnings.length>0&&w(`profile:extensions parser_warnings=${D(u.warnings)}`),a=u.context.args,s=u.context.options,c=u.context.global,nt(n,s);let p=await go({command:i,args:a,options:s,global:c,pm_root:l.pmRoot,decision:In()});c.profile&&p.warnings.length>0&&w(`profile:extensions preflight_warnings=${D(p.warnings)}`),a=p.context.args,s=p.context.options,c=p.context.global,nt(n,s);let f=p.decision;await yn(i,s,l.pmRoot,f),await hn(i,a,s,c,l.pmRoot);let y=f.run_extension_migrations?await ia(l.registrations.migrations,l.pmRoot):[];c.profile&&y.length>0&&w(`profile:extensions migration_warnings=${D(y)}`);let h=oi(l.registrations.migrations);we={hooks:l.hooks,commandName:i,commandArgs:a,commandOptions:{...s},globalOptions:{...c},pmRoot:l.pmRoot,profileEnabled:!!c.profile,migrationBlockers:h},se(void 0),Be({command:i,args:a,options:{...s},global:{...c},pm_root:l.pmRoot}),j=await Lt({command:i,pm_version:Ue,args:a,options:s,global:c,pm_root:l.pmRoot}),Mt(i,a,s,{source_context:j?.source_context,source_context_source:j?.source_context_source}),Dt(i);let C=await no(l.hooks,{command:i,args:a,options:{...s},global:{...c},pm_root:l.pmRoot});c.profile&&C.length>0&&w(`profile:extensions hook_warnings=${D(C)}`),f.enforce_mandatory_migration_gate&&ri(i,s,h)}),e.hook("postAction",async()=>{let t=$i();ke(t.ok,t.error,{error_code:t.error_code,error_category:t.error_category,exit_code:t.exit_code,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage}),await qe(t)})}ma(b);var El=new Set(["--version","-V"]),Sl=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),ua=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),pa=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","learnings","notes","plan","restore","update","update-many","create"]),Al=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Tl=new Set(["claim","close-task","pause-task","release","start-task","test"]),An={setup:!0,listQuery:!0,mutation:!0,operation:!0},Ol=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function Ct(e){return e.some(t=>El.has(t))}function fa(e){if(Ct(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||P(e).requested)return An;let t=k(e);if(!t)return An;let n=t.trim().toLowerCase();return Sl.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:ua.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:pa.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Al.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:An}function ga(e){return e.length===0||P(e).requested||e.includes("--explain")&&k(e)===void 0}var vi=Symbol("pmCliIdempotentTopLevelRegistration");function ha(e){let t=e;if(t[vi])return;t[vi]=!0;let n=e.command.bind(e);e.command=((o,...r)=>{let i=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===i||a.aliases().includes(i))?new Nn(i):n(o,...r)})}async function Rl(e,t){if(ha(e),t.setup){let{registerSetupCommands:n}=await cl();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await ll(),o=typeof t.targetCommandName=="string"&&ua.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await dl();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await ml();n(e)}}function ya(e,t){return Ct(t)?!1:ue(t)||P(t).requested?!0:!!k(t)}function wa(e){if(Ct(e))return!1;let t=k(e);return t?Ol.has(t):!1}function Il(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,r=e.normalizedTokens.map(d=>{let l=d.indexOf("=");return l>=0?d.slice(0,l):d}).find(d=>d==="--literal"||d==="--regex"||d==="--replacement"),i=r?e.argv.map(d=>{let l=d.indexOf("=");return(l>=0?d.slice(0,l):d)===o?l>=0?`${r}${d.slice(l)}`:r:d}):e.argv,a=Ye(i),s=r&&n>=0?`${o}=[redacted]`:t,c=r&&e.normalizedDisplay.includes("=")?`${r}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function _a(e){let t=e.commandName;if(!t)return;let n=e.trace.find(d=>d.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(d=>d.length>0),r=o.length>0?o.join(" "):"the canonical flag",i=pa.has(t)||Tl.has(t),a=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",c=Il({argv:e.argv,normalizedDisplay:r,normalizedTokens:o,rawFrom:n.from});throw new v(`Refusing to auto-correct ${s} ${c.sourceDisplay} to ${c.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:a,examples:[S(c.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:c.argv,suggested_retry:S(c.argv)}})}function $l(e){return async t=>{let n=Et(t.errorCode),o=Nt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Uo({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:Ue,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function ba(e){if(e.bootstrapGlobal.noExtensions)return;let t=ze(e.invocationArgv),n=await vt(e.bootstrapPmRoot);if(n&&bt(n.discovery,t)){let o=await _e(e.bootstrapPmRoot,t);xa(o);return}n&&xt(Un(e.invocationArgv),n,t),V({overrides:[]})}function xa(e){if(!e){V({overrides:[]});return}V(e.services)}async function Bn(e){ke(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await qe({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function va(){ke(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await qe({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function Ca(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof v)&&(Gt(e.error)||!n))return!1;let o=Q(e.error),r=e.error instanceof v?e.error.exitCode:zt(t),i=e.error instanceof v?e.error.context:void 0,a=Ei(i,e.invocationArgv,o),s=Pr(o,a),c=e.bootstrapGlobal.lean?lt(ln(o,r,a)):ln(o,r,a),d=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?X(c,p=>`${JSON.stringify(p,null,2)}
34
- `):c,null,2):$r(o,a);e.jsonErrors?de(`${d}
35
- `):w(d);let{errorCategory:l,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:r,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),u=await yt({command:e.attemptedCommand,error_code:s.code,error_category:l,exit_code:r,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:j?.source_context});return await Bn({errorMessage:o,exitCode:r,classificationCode:s.code,errorCategory:l,commandResolution:m,resolutionStage:"execute"}),u&&(Ft(Wt(e.error,o)),await Ee(Dn)),process.exitCode=r,!0}async function ka(e,t){let n=_n(e.invocationArgv),o=`unknown command '${n}'`,r=R(process.cwd(),e.bootstrapGlobal.path),i=await ra(r),a=ze(e.invocationArgv),s=await kn(r,{},He(a)),c=await De({message:o},b,i,{failedExtensions:s}),d=dn(c.message,c.commandName,c.allowedTypes,{unknownCommandExamples:c.unknownCommandExamples,unknownCommandNextSteps:c.unknownCommandNextSteps,attemptedCommand:c.attemptedCommand,normalizedInvocationArgs:c.normalizedInvocationArgs,providedOptionFlags:c.providedOptionFlags,unknownOptionSuggestions:c.unknownOptionSuggestions,suggestedRetryCommand:c.suggestedRetryCommand,failedExtensions:s}),{errorCategory:l,commandResolution:m}=await e.emitTelemetryCommandError({command:n,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await yt({command:n,error_code:d.code,error_category:l,exit_code:g.USAGE,error_message:d.detail,command_resolution:m,resolution_stage:"parse"}),p=e.jsonErrors?await Cn({message:o},b,i,e.bootstrapGlobal.lean===!0,{failedExtensions:s}):await vn({message:o},b,i,{failedExtensions:s}),f=wn(p,e.jsonErrors,s);await Bn({errorMessage:o,exitCode:g.USAGE,classificationCode:d.code,errorCategory:l,commandResolution:m,resolutionStage:"parse"}),e.jsonErrors?de(`${f}
36
- `):w(f),u&&await Ee(Dn),process.exitCode=g.USAGE}async function Ea(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let r=P(e.invocationArgv);return r.requested&&!Me(b,r.commandPathTokens)?(await ka(e,t),!0):(await va(),!0)}async function Sa(e,t){let n=await De(e.error,b,T),o=dn(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:r,commandResolution:i}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await yt({command:e.attemptedCommand,error_code:o.code,error_category:r,exit_code:g.USAGE,error_message:o.detail,command_resolution:i,resolution_stage:"parse",source_context:j?.source_context}),s=e.jsonErrors?await Cn(e.error,b,T,e.bootstrapGlobal.lean===!0):await vn(e.error,b,T),c=await di(o.code,e.bootstrapPmRoot,{},He(ze(e.invocationArgv))),d=wn(s,e.jsonErrors,c);await Bn({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:r,commandResolution:i,resolutionStage:"parse"}),e.jsonErrors?de(`${d}
37
- `):w(d),a&&await Ee(Dn),process.exitCode=g.USAGE}function Aa(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return typeof t=="string"&&(t==="commander.version"||t.startsWith("commander."))?!0:String(e.message??"").includes("(outputHelp)")}async function Ta(e){let t=e.error.code,n=String(e.error.message??"");if(!await Ea(e,t,n)){if(t==="commander.version"){await va();return}await Sa(e,t)}}async function Vn(e){let t=q(e.invocationArgv),n=R(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:$l({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await ba({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await Ca(o,Ht(e.error))){if(Aa(e.error)){await Ta(o);return}await Di({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}async function Pl(e){b=Bt(Ue),ma(b),Fe=null,re=null,T=new Map,po();let t=[...e],n,o;try{let r=rt(e);t=r.argv;let i=[process.argv[0],process.argv[1],...t],a=t.length===0,s=q(t);if(s.authorMissingValue)throw new v("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});n=ar(s.author),_a(r),o=nr(t);let c=fa(t);if(await Rl(b,c),ga(t)&&xr(b,t),ya(b,t)?await da(b,t):(T=new Map,V({overrides:[]})),wa(t)&&await zi(b,t),ca(b),await fi(b,t,T))return;let m=P(t);if(m.requested&&!Me(b,m.commandPathTokens))throw new Qc(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(a||ue(t)&&k(t)===void 0){b.outputHelp();return}let u=R(process.cwd(),s.path),p=await I(u),f=await hi(t,u,s.noExtensions,_e);await Go({pmRoot:u,packages:f?.contextIntentPackages},()=>yo({env:{...process.env,PM_PATH:u},argv:i,cwd:process.cwd()},()=>wo(p.agent_identity.harness_signals,()=>b.parseAsync(i),{probesEnabled:p.agent_identity?.probes_enabled})))}catch(r){await Vn({error:r,invocationArgv:t})}finally{o?.(),n?.()}}async function pm(e=process.argv.slice(2)){try{await qo(process.env,()=>Pl(e))}catch(t){await Vn({error:t,invocationArgv:[...e]})}}var fm={activationCommandMatchesProbe:Bi,applyDynamicExtensionRootHelpVisibility:la,bootstrapProfileEnabled:Un,buildBootstrapActivationProbe:ze,buildPostActionTelemetryOutcome:$i,buildPmCliRecoveryContext:Ei,buildRuntimeExtensionDiscoverySnapshotCacheKey:qn,buildRuntimeExtensionActivationScope:Wn,buildRuntimeExtensionSnapshotCacheKey:Gi,buildRuntimeExtensionFilterForProbe:ea,addRuntimeFieldOption:Rn,collectActivationCommandCandidates:He,collectExtensionFlagDefinitionsForCommand:Tn,collectExtensionFlagDefinitionsForInvocation:wt,collectLeadingCommandArgs:Wi,collectParsedActivationCommandArgs:ta,collectRuntimeFieldLooseFlagDefinitionsForCommand:Hi,commandHasLongOption:Ui,commandHasShortOption:qi,commandPathNeedsSearchExtensions:Ji,commandPathNeedsTemplateExtensions:zn,describeUnknownError:Q,defaultPreflightDecision:In,discoveryNeedsActivationForProbe:bt,emitExtensionProfile:na,emitExtensionSkippedProfile:xt,emitSettingsReadWarnings:Pn,ensureIdempotentTopLevelCommandRegistration:ha,enforceExplicitRetryForFlagTypos:_a,envFlagEnabled:Ni,executeRegisteredRuntimeMigrations:ia,extractCommandScopedOptions:Le,extensionActivationCommands:Hn,extensionCapabilities:_t,extensionNeedsActivationForProbe:Gn,extensionProvidesTemplatesRuntime:Xi,hasAnyCapability:je,hasGlobalExtensionContributions:Zi,handleGenericRunPmCliError:Di,handleRunPmCliCommanderError:Ta,handleRunPmCliError:Vn,handleRunPmCliHelpDisplayError:Ea,handleRunPmCliKnownError:Ca,handleRunPmCliCommanderUsageError:Sa,handleUnknownHelpCommandError:ka,inferMissingFieldsFromErrorMessage:ki,inferPostActionErrorCode:Ii,inferPostActionFailureMessage:Ri,invocationRequestsVersion:Ct,isCommanderError:Gt,loadRuntimeExtensionCommandDescriptorsForRecovery:ra,loadRuntimeExtensionDiscoverySnapshot:vt,loadRuntimeExtensionSnapshot:_e,maybeLoadRuntimeExtensions:oa,maybeAttachCreateUpdatePolicyHelpText:jn,maybeLogHandledCliErrorToSentry:yt,matchesStaticExtensionCommand:$n,normalizeTelemetryCommandResolution:Ai,normalizeTelemetryErrorCategory:Oi,normalizeTelemetryResolutionStage:Ti,normalizeThrownExitCode:zt,probeUsesAnyFlag:Yi,prepareExtensionServicesForRunPmCliError:ba,readRecordBoolean:Si,readRecordNumber:Fn,readRecordString:ye,recordCliReadOutputInvocationProvenance:Ci,registerDynamicExtensionCommandPaths:da,registerRuntimeSchemaFieldFlags:zi,resolveCoreCommandRegistrationSelection:fa,resolveStaticExtensionActivationDecision:Qi,resolveUnknownHelpToken:_n,readThrownExitCode:Ht,runAndClearAfterCommandHooks:qe,runRequiredExtensionCommand:sa,shouldAttachRichHelpTextForInvocation:ga,shouldLogHandledErrorToSentry:Mi,shouldRegisterDynamicExtensionPaths:ya,shouldRegisterRuntimeSchemaFlags:wa,shouldHandleRunPmCliCommanderError:Aa,setActiveExtensionHookContextForTest:tl,setActiveRuntimeExtensionCommandDescriptorsForTest:nl,setRecoveredExtensionServices:xa,toLooseFieldDefinitionType:On,isImporterOrExporterCommandPath:Fi,validateDynamicExtensionCommandInvocation:ji,wrapProgramActionsForExtensionHandlers:ca,wrapThrownErrorForSentry:Wt};export{fm as _testOnly,pm as runPmCli};
29
+ `)}return process.exitCode=g.USAGE,!0}if(!o.quiet){let a=Kc(e,i,t,r.commandPathTokens,n);Io(`${JSON.stringify(a,null,2)}
30
+ `)}return process.exitCode=g.SUCCESS,!0}function Jc(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
31
+ `)}function Yc(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",r=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${r.length>0?r.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function Xc(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let r of[...t.required_create_fields,...t.required_create_repeatables])o.add(r);return{progressive:n,strict:o}}function Zc(e,t,n,o){let r=new Set(n),i=o.filter(c=>!r.has(c)),a=c=>c.length>0?c.map(d=>Rt("create",d)).join(", "):"none";e.push(` required in strict mode: ${a(i)}`);let s=i.map(Zo).filter(c=>c!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function Qc(e,t,n){let o=rr(n);if(!o)return Jc(e,t);let r=oo(o,t);if(!r){let y=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${y}`].join(`
32
+ `)}let i=n.indexOf("--"),a=i<0?n:n.slice(0,i),s=a.findIndex(y=>y==="--create-mode"||y.startsWith("--create-mode=")),c=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],d=e==="create"&&c?.toLowerCase()==="strict",l=Xc(e,r),m=Be(r,e,l.progressive),p=Be(r,e,d?l.strict:l.progressive),u=y=>y.length>0?y.map(h=>Rt(e,h)).join(", "):"none",f=["",`Type-aware option policies for ${r.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let y=Be(r,e,l.strict);Zc(f,r,m.required,y.required)}return Yc(f,r),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
33
+ `)}function hi(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let r=$e(e,o);r&&r.addHelpText("after",Qc(o,t,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]="939abfaf-7563-5490-bd76-90d188aa0940")}catch{}})();async function yi(e,t,n,o){if(n)return null;let r=e.some(a=>a==="--for"||a.startsWith("--for=")),i=k(e)==="contracts"&&e.includes("--full");return r||i?await o(t):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]="bec161fa-a929-5f40-89b9-e41ffa0aa80d")}catch{}})();var An="PM_CLI_PACKAGE_ROOT",wt=Symbol.for("pm.readOutputInvocationProvenance");function Fn(e,t){let n=Reflect.get(e,wt);n!==void 0&&Reflect.set(t,wt,n)}function ki(e,t,n){let o=Eo(t,n);if(!o)return;let r=e;for(;r.parent;)r=r.parent;let i=r.rawArgs,a=new Set(K(i.slice(2))),s=ko.find(l=>l.command===o),c=Object.values(s.dimensions).flatMap(l=>l.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),d=Reflect.get(n,wt);Reflect.set(n,wt,{canonical_include_modes:d?.canonical_include_modes??[],explicit_legacy_aliases:c,cli_invocation_observed:!0}),Fn(n,e)}function tl(){return eo(import.meta.url,["../.."])}(typeof process.env[An]!="string"||process.env[An]?.trim().length===0)&&(process.env[An]=tl());var ve=null,j=null;function nl(e){ve=e}function ol(e){T=e}var rl=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),il=new Set(["parse","preflight","execute","unknown"]),al=new Set(["usage","validation","conflict","runtime","unknown"]),Fe=null,re=null,T=new Map,Ln=250,sl=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),cl=new Set(["1","true","yes","on"]),ll=Ae(()=>import("./chunks/register-setup-BQ5SVD4B.js")),dl=Ae(()=>import("./chunks/register-list-query-KSK3R63M.js")),ml=Ae(()=>import("./chunks/register-mutation-IQ5C7U6O.js")),pl=Ae(()=>import("./chunks/register-operations-DWVHR2NC.js"));function yt(e){return S(e)}function Ei(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>te(o)??o))];return n.length>0?n:void 0}function ul(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=K(t),r=new Set(o.map(l=>te(l)??l)),i=Ei(e),a=t.find(l=>_.commands.some(m=>m.name()===l)),s=a?_.commands.find(l=>l.name()===a):void 0,c=new Set([..._.options,...s?.options??[]].flatMap(l=>l.flags.split(/[ ,|]+/).map(m=>te(m)).filter(m=>m!==void 0))),d=i?.filter(l=>{let m=te(l)??l;return r.has(m)?!1:c.has(m)||un(t,a,m,T)!==void 0});return d&&d.length>0?d:void 0}function fl(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let r=n?.[0],i=r?te(r):void 0,a=e.find(p=>_.commands.some(u=>u.name()===p)),s=a?_.commands.find(p=>p.name()===a):void 0,c=i?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(i)):void 0,d=un(e,a,i,T),l=i?c?.isBoolean()===!0||d===!1?[i]:[i,"<value>"]:[],m=i?yt([...e,...l]):t;return m===t?void 0:m}function gl(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let r=e[o];r!=null&&(n[o]=r)}return n}function hl(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...gl(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Si(e,t,n){let o=Xe(t),r=pe(o),i=it(r),[a,s]=i===void 0?[]:r.slice(i,i+2),c=o.includes("--explain"),d=e?.recovery,l=d&&(a==="history-redact"||a==="history"&&s==="redact")?{...d,...d.attempted_command?{attempted_command:yt(o)}:{},...d.normalized_args?{normalized_args:[...o]}:{},...d.suggested_retry?{suggested_retry:yt(o)}:{},...d.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:d;if(l?.recovery_mode==="compact"&&!c)return{...e,recovery:l};let m=yt(o),p=K(o),u=ul(n,o,l),f=fl(o,m,u,l),y=hl({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:l});return{...e,recovery:y}}function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let r=o.trim();if(r.length>0)return r}}}function Ai(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function jn(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function Ti(e){if(!e)return;let t=e.trim().toLowerCase();if(rl.has(t))return t}function Oi(e){if(!e)return;let t=e.trim().toLowerCase();if(il.has(t))return t}function Ri(e){if(!e)return;let t=e.trim().toLowerCase();if(al.has(t))return t}function Ii(e){let t=we(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(Ai(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let r=jn(e,"failed");if(typeof r=="number"&&r>0)return`failed_runs:${r}`;let i=e?.run_results;if(Array.isArray(i)){let a=i.filter(s=>Tt(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function $i(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Pi(){let e=Tt(le()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=jn(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,r=Xo(o),i=we(e,"error_code","errorCode")??$i(r,o),a=Ri(we(e,"error_category","errorCategory"))??(r?void 0:At(i)),s=r?void 0:Ii(e)??`command_exit_${o}`,c=Ti(we(e,"command_resolution","commandResolution"))??Dt({ok:r,errorCode:i,errorCategory:a}),d=Oi(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:r,error:s,exit_code:o,error_code:i,error_category:a,command_resolution:c,resolution_stage:d}}async function qe(e){let t=j;j=null,await Cr(t,e);let n=ve;if(ve=null,!n){Ke();return}let o=[],r=wo();try{await kr({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?r?.map(i=>i.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await so(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:le(),affected:r}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{Ke()}!n.globalOptions.json&&o.length>0&&w(`[pm] warning: afterCommand hook_warnings=${D(o)}`),n.profileEnabled&&o.length>0&&w(`profile:extensions hook_warnings=${D(o)}`)}async function Ni(){await Mo()}function Mi(e){return cl.has((process.env[e]??"").trim().toLowerCase())}function Di(e){return Mi("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!sl.has(Math.trunc(e))}async function vt(e){return Di(e.exit_code)?(await Ni(),Do(e),!0):!1}async function Fi(e){let t=Q(e.error),n=Lr(t);e.bootstrapGlobal.json?w(JSON.stringify(Dr(t,g.GENERIC_FAILURE),null,2)):w(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",r="runtime_failed";try{await Ni(),jt(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,r=i.commandResolution,Ee(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:r,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to report error: ${Q(i)}`)}try{await qe({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:r,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to run error hooks: ${Q(i)}`)}try{await Se()}catch(i){e.bootstrapGlobal.json||w(`Failed to flush error reporting: ${Q(i)}`)}}function wi(e,t,n,o){ki(e,t,o);let r=n.outputInclude;if(r===void 0)return;let{selectors:i,modes:a}=To(t,r,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;Fn(o,e);let s=Ao(t);for(let d of a){let l=s.get(d),m=o[l];e.setOptionValueWithSource(l,m,"cli")}let c=i.length>0?i.join(","):void 0;c===void 0?delete n.outputInclude:n.outputInclude=c;for(let d=e;d;d=d.parent)d.setOptionValueWithSource("outputInclude",c,"cli");qt(e,n)}function Le(e,t,n=[]){let r={...e.optsWithGlobals()};Fn(e,r),delete r.json,delete r.quiet,delete r.path,delete r.pmPath,delete r.noExtensions,delete r.extensions,delete r.profile,delete r.pager,delete r.changedFields,delete r.fullChangedFields,delete r.idOnly,delete r.lean,delete r.tokenAccounting,delete r.outputInclude,delete r.outputLimit,delete r.outputBudget,delete r.outputFormat,delete r.outputSession;let i=fr(t);for(let[a,s]of Object.entries(i))r[a]===void 0&&(r[a]=s);if(n.length>0){let a=mr(n),s=nt($(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),c={...i};for(let d of a)r[d]!==void 0&&(c[d]=r[d]);return Yt(c,[...s,...n],$(e)),ur(r,n,i)}return r}function Rn(e,t){let n=v(t);return n.length===0?[]:e.flags.filter(o=>v(o.target_command)===n).flatMap(o=>o.flags)}function _t(e,t,n){let o=Rn(e,t),r=[t],i=[];for(let a of n){if(a.startsWith("-"))break;r.push(a);let s=Rn(e,r.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Un(e){return e.arguments??[]}function vi(e){let t=Un(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Li(e,t){if(!e)return!1;let n=v(t);return e.importers.some(o=>v(`${o.importer} import`)===n)||e.exporters.some(o=>v(`${o.exporter} export`)===n)}function ji(e,t){let n=Un(e),o=n.filter(c=>c.required).length,i=n.some(c=>c.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new x(`Missing required argument for extension command '${e.command}'. Usage: ${vi(e)}${s}`,g.USAGE);if(t.length>i){let c=t.slice(i).join(" ");throw new x(`Too many arguments for extension command '${e.command}': ${c}. Usage: ${vi(e)}${s}`,g.USAGE)}}function yl(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function wl(e,t,n){if(n.length>0){Yt(t,n,e.command);return}let o=Object.keys(t).filter(r=>t[r]!==void 0).sort();if(o.length!==0)throw new x(`Unknown option '${o.map(yl).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function Ui(e,t,n,o){e&&(ji(e,t),wl(e,n,o))}var vl={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},Tn=new Map;function In(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function qi(e,t){return e.options.some(n=>n.long===t)}function Hi(e,t){return e.options.some(n=>n.short===t)}function $n(e,t,n,o){let r=t.trim();if(!r)return;let i=n.length>0?n:`Runtime schema field (${t})`;if(r.startsWith("-")&&!r.startsWith("--")){if(Hi(e,r))return;if(o){e.option(`${r} <value>`,`${i} (repeatable)`,zt);return}e.option(`${r} <value>`,i);return}let a=r.startsWith("--")?r:`--${r}`;if(!qi(e,a)){if(o){e.option(`${a} <value>`,`${i} (repeatable)`,zt);return}e.option(`${a} <value>`,i)}}async function zi(e,t){let n=vl[e];if(!n)return[];let o=`${t}:${n}`,r=Tn.get(o);if(r)return r;if(!await H(z(t)))return Tn.set(o,[]),[];let i=await I(t),s=(Pt(i.schema).command_to_fields.get(n)??[]).flatMap(c=>[c.cli_flag,...c.cli_aliases].map(l=>({long:`--${l}`,type:In(c.type),value_type:In(c.type)})));return Tn.set(o,s),s}async function Gi(e,t){let n=q(t),o=R(process.cwd(),n.path);if(!await H(z(o)))return;let r=re?.key===zn(o)?re.snapshot:null,i=r===null?await I(o):r.settings,a=Pt(i.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let c of s){let d=he(e,c.path.split(" "));if(d)for(let l of a.command_to_fields.get(c.command)??[]){let m=l.description??"";$n(d,l.cli_flag,m,l.repeatable);for(let p of l.cli_aliases)$n(d,p,`Alias for --${l.cli_flag}`,l.repeatable)}}}async function qn(e,t,n,o,r){let i=k(n);if(!(i!=="create"&&i!=="update"))try{let a=r??await I(t),s=J(a,o);hi(e,s,n)}catch{}}function Pn(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Wi(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Hn(e){return e.some(t=>t==="--profile")}function zn(e){return`pm-root:${e}`}function Bi(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=v(n);o.length!==0&&t.push(o)}return t}function He(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(r=>r.length>0);for(let r of Bi(e.commandArgs))o.push(...r.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(r=>[r,We(r)]))]}function Vi(e,t){let n=v(e);if(n.length===0)return!1;let o=He(t);for(let r of o)if(r===n||r.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(r=>n.startsWith(`${r} `)):!1}function Gn(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...E(n.commands),...E(n.command_handlers),...E(n.command_overrides),...E(n.flag_commands),...E(n.parser_overrides),..._i(n.preflight_ownership),..._i(n.renderer_ownership)]:[]}function E(e){return e??[]}function _i(e){return E(e).flatMap(t=>t.commands)}function bt(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Ki=new Set(["hooks","parser","preflight","renderers"]),Ji=new Set(["commands","schema","services","importers"]),_l=new Set(["reindex","search","search-advanced"]),bl=new Set(["--template"]);function je(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Yi(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return _l.has(n??t)}function Xi(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function Wn(e){return v(e.commandPath??"")==="create"&&Xi(e,bl)}function Zi(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Nn(e,t){return e.some(n=>Vi(n,t))||Wn(t)&&Zi(e)}function Qi(e){return[E(e.hooks).length,(e.preflight_overrides??0)-E(e.preflight_ownership).length,E(e.item_types).length,E(e.item_fields).length,E(e.relationship_kinds).length,E(e.service_overrides).length,E(e.assurance_providers).length,E(e.renderer_overrides).length-E(e.renderer_ownership).length].some(n=>n>0)}function ea(e,t){let n=e.activation?.commands??[];if(n.length>0)return Nn(n,t);let o=Gn(e);if(Nn(o,t)||bt(e).has("search")&&Yi(t.commandPath))return!0;if(e.contributions)return Qi(e.contributions)}function Bn(e,t){let n=ea(e,t);if(n!==void 0)return n;let o=bt(e);return!!(je(o,Ki)||je(o,Ji))}function xt(e,t){return e.effective.length===0?!1:v(t.commandPath??"").length>0?e.effective.some(o=>Bn(o,t)):e.effective.some(o=>{let r=bt(o);return Gn(o).length>0||je(r,Ki)||je(r,Ji)||r.has("search")})}function Vn(e){let t=He(e).filter(r=>r.split(" ").every(i=>!i.startsWith("-"))).sort((r,i)=>i.length-r.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Wn(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function ta(e){return Vn(e)==="all"?void 0:t=>Bn(t,e)}function ze(e){let t=P(e);if(t.requested&&t.commandPathTokens.length>0){let[r,...i]=t.commandPathTokens;return{commandPath:r,commandArgs:i,allowCommandPrefixMatch:!0}}let n=pe(e),o=n.findIndex(r=>r.trim().length>0&&!r.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function na(e){let t=e.args.map(String);if(v($(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.template.trim().length>0&&t.push("--template")}return t}function Mn(e){for(let t of e)t.startsWith("settings_read_")&&w(`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function oa(e,t){e.profile&&(w(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&w(`profile:extensions activation_warnings=${D(t.activationWarnings)}`))}function Ct(e,t,n){if(!e)return;let o=v(n.commandPath??"")||"<none>";w(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function kt(e,t=me){let n=zn(e);if(re?.key===n)return re.snapshot;try{let o=Date.now(),{settings:r,warnings:i}=await t(e),a=await co({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:r,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...i]};return re={key:n,snapshot:s},s}catch{return re={key:n,snapshot:null},null}}async function _e(e,t,n=I){let o=t?Vn(t):"all",r=Wi(e,o);if(Fe?.key===r)return Fe.snapshot;try{let i=await n(e),a=await Ce({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?ta(t):void 0}),s=await ke({...a,loaded:a.loaded}),c=[...new Set(s.commands.handlers.map(u=>v(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),d=Hr(s.registrations.flags),l=Ur(s.commands.handlers,s.registrations.commands),m=Gr(c,s.registrations.commands,s.registrations.flags,l),p={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:i,commandHandlers:c,commandFlagHelp:d,commandDescriptors:m,commandAliases:l,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:u,module:f})=>({name:u,module:f}))};return Fe={key:r,snapshot:p},p}catch{return Fe={key:r,snapshot:null},null}}async function ra(e){let t=Oe(e);if(t.noExtensions){let a=R(process.cwd(),t.path);return await H(z(a))&&Mn((await me(a)).warnings),null}let n=R(process.cwd(),t.path),o=await kt(n);if(!o)return null;Mn(o.settingsReadWarnings);let r={commandPath:$(e),commandArgs:na(e)};if(!xt(o.discovery,r))return Ct(t.profile,o,r),null;let i=await _e(n,r);return i?(oa(t,i),{hooks:i.hooks,commands:i.commands,parsers:i.parsers,preflight:i.preflight,services:i.services,renderers:i.renderers,registrations:i.registrations,pmRoot:n}):null}async function ia(e){let t=await _e(e);return t?new Map(t.commandDescriptors):T}async function aa(e,t){return(await Yo({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function sa(e,t){let n=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return Wo(e,nr.forActiveExtensionHost({pmRoot:e,author:n}))}async function ca(e,t,n,o=[]){let r=$(e),i=Xt(e.args.map(String),o),a={...t},s={...n},c=R(process.cwd(),n.path),d=await Je({command:r,args:i,options:a,global:s,pm_root:c});n.profile&&d.warnings.length>0&&w(`profile:extensions parser_warnings=${D(d.warnings)}`),i=d.context.args,a=d.context.options,s=d.context.global,Ui(T.get(v(r)),i,a,o),ce(void 0),Ve({command:r,args:i,options:{...a},global:{...s},pm_root:c});let l=await $t({command:r,args:i,options:a,global:s,pm_root:c,sdk:sa(c,s)});if(s.profile&&l.warnings.length>0&&w(`profile:extensions command_handler_warnings=${D(l.warnings)}`),!l.handled){if(l.warnings.length>0){let m=l.warnings[0],p=l.errorMessage?.trim(),u=p?` ${p}`:"";throw new x(`Command "${r}" failed in extension handler (${m}).${u}`,g.GENERIC_FAILURE,{code:l.errorCode??"command_failed",nextSteps:l.remediation?[l.remediation]:void 0})}throw new x(`Command "${r}" is provided by extensions and is not currently available.`,g.NOT_FOUND)}return l.exitCode!==void 0&&(process.exitCode=l.exitCode),ce(l.result),l.result}var bi=Symbol("pm.wrappedActionHandler");function xl(e,t){let n=e[e.length-1];return n instanceof Dn?n:t}function xi(e,t,n){e&&n.length>0&&w(`profile:extensions ${t}=${D(n)}`)}function Cl(e){let t=T.get(v(e.commandPath));if(!t||!Li(e.activeRegistrations,e.commandPath))return;let n=Un(t).length===0?gr(e.commandArgs):Xt(e.commandArgs,e.extensionFlagDefinitions);ji(t,n)}function kl(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function la(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[bi]!==!0){let r=o._actionHandler;o._actionHandler=async function(...a){let s=xl(a,n),c=Date.now();Ht(s);let d=Oe(s),l=We($(s)),m=R(process.cwd(),d.path),p=s.args.map(String),u=Y(),f=u?_t(u,l,p):[],y=await zi(l,m),h=Le(s,p,[...f,...y]),C=await Je({command:l,args:p,options:h,global:d,pm_root:m});xi(d.profile,"parser_warnings",C.warnings),p=C.context.args,h=C.context.options,d=C.context.global,Cl({activeRegistrations:u,commandPath:l,commandArgs:p,extensionFlagDefinitions:f}),d=await Vo(d),qt(s,d),kl(s,a,p),ot(s,h),ce(void 0),Ve({command:l,args:p,options:{...h},global:{...d},pm_root:m});let O=await $t({command:l,args:p,options:h,global:d,pm_root:m,sdk:sa(m,d)});if(xi(d.profile,"command_handler_warnings",O.warnings),O.handled){ce(O.result),Mt(O.result,{...d,command:l,commandArgs:p,commandOptions:h,pmRoot:m}),d.profile&&w(`profile:command=${l} took_ms=${Date.now()-c}`);return}return await r.apply(this,a)},o[bi]=!0}for(let r of n.commands)t(r)};t(e)}async function ht(e){T=new Map,V({overrides:[]}),e&&await qn(e.rootProgram,e.pmRoot,e.invocationArgv,io(),e.settings)}function El(e,t,n,o){if(t?.flags&&t.flags.length>0){fn(e,t.flags);let r=gn(e,t.flags);r&&e.addHelpText("after",r)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function da(e,t,n){let o={core:0,standard:1,full:2,internal:3},r=(i,a)=>{let s=a.join(" "),c=[...n.entries()].filter(([l])=>l===s||l.startsWith(`${s} `)).map(([,l])=>l),d=c.length===0?"standard":c.reduce((l,m)=>o[m.tier]<o[l]?m.tier:l,"internal");yr(i,d);for(let l of i.commands)r(l,[...a,l.name()])};for(let i of e.commands)t.has(i.name())||r(i,[i.name()])}async function ma(e,t){let n=q(t),o=R(process.cwd(),n.path);if(n.noExtensions){await ht({rootProgram:e,pmRoot:o,invocationArgv:t});return}let r=await kt(o),i=ze(t);if(!r){await ht();return}if(!xt(r.discovery,i)){await ht({rootProgram:e,pmRoot:o,invocationArgv:t,settings:r.settings}),Ct(Hn(t),r,i);return}let a=await _e(o,i);if(!a){await ht({rootProgram:e,pmRoot:o,invocationArgv:t,settings:r.settings});return}V(a.services),T=new Map(a.commandDescriptors),await qn(e,o,t,a.registrations,a.settings);let s=ei(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,l=>ti(a.activationWarnings,w,l)),c=new Set(e.commands.map(l=>l.name())),d=l=>{let m=l.split(" ").filter(O=>O.length>0),p=a.commandDescriptors.get(l),u=he(e,m),f=a.commandFlagHelp.get(l),y=p?Xr(p):null;if(u){El(u,p,f,y);return}let h=Qr(e,m);p?.description&&h.description(p.description);let C=f;p&&(Wr(h,p),p.flags.length>0&&(fn(h,p.flags),C=gn(h,p.flags)??void 0)),C&&h.addHelpText("after",C),y&&h.addHelpText("after",y),h.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...O)=>{let U=O[O.length-1],M=U instanceof Dn?U:h,ie=Oe(M),St=Date.now(),Ge=_t(a.registrations,l,M.args.map(String)),be=Le(M,M.args.map(String),Ge),ae=await ca(M,be,ie,Ge);await Ko(ie,ae),Mt(ae,{...ie,command:l,commandArgs:M.args.map(String),commandOptions:be,pmRoot:o}),ie.profile&&w(`profile:command=${l} took_ms=${Date.now()-St}`)})};for(let l of s)d(l);da(e,c,a.commandDescriptors)}var Ue=to(import.meta.url,["../.."])??"0.0.0",_=Kt(Ue);function pa(e){e.hook("preAction",async(t,n)=>{ve=null,j=null,Ke(),Ht(n);let o=n.optsWithGlobals(),r=Oe(n),i=We($(n)),a=n.args.map(String),s=Le(n,a),c={...r};So(i,{...s,outputInclude:o.outputInclude,outputLimit:o.outputLimit,outputBudget:o.outputBudget,outputFormat:o.outputFormat,outputSession:o.outputSession,outputCursor:o.outputCursor}),wi(n,i,c,s),await Uo(i,c);let d=R(process.cwd(),r.path),l=await ra(n);if(!l){ve=lo({commandName:i,commandArgs:a,commandOptions:s,globalOptions:c,pmRoot:d}),j=await Ut({command:i,pm_version:Ue,args:a,options:s,global:c,pm_root:d}),Ft(i,a,s,{source_context:j?.source_context,source_context_source:j?.source_context_source}),Lt(i),await vn(i,s,d,Pn()),await wn(i,a,s,c,d);return}mo(l.hooks),po(l.commands),uo(l.parsers),fo(l.preflight),V(l.services),go(l.renderers),ho(l.registrations);let m=_t(l.registrations,i,a);s=Le(n,a,m),wi(n,i,c,s);let p=await Je({command:i,args:a,options:s,global:c,pm_root:l.pmRoot});c.profile&&p.warnings.length>0&&w(`profile:extensions parser_warnings=${D(p.warnings)}`),a=p.context.args,s=p.context.options,c=p.context.global,ot(n,s);let u=await vo({command:i,args:a,options:s,global:c,pm_root:l.pmRoot,decision:Pn()});c.profile&&u.warnings.length>0&&w(`profile:extensions preflight_warnings=${D(u.warnings)}`),a=u.context.args,s=u.context.options,c=u.context.global,ot(n,s);let f=u.decision;await vn(i,s,l.pmRoot,f),await wn(i,a,s,c,l.pmRoot);let y=f.run_extension_migrations?await aa(l.registrations.migrations,l.pmRoot):[];c.profile&&y.length>0&&w(`profile:extensions migration_warnings=${D(y)}`);let h=ri(l.registrations.migrations);ve={hooks:l.hooks,commandName:i,commandArgs:a,commandOptions:{...s},globalOptions:{...c},pmRoot:l.pmRoot,profileEnabled:!!c.profile,migrationBlockers:h},ce(void 0),Ve({command:i,args:a,options:{...s},global:{...c},pm_root:l.pmRoot}),j=await Ut({command:i,pm_version:Ue,args:a,options:s,global:c,pm_root:l.pmRoot}),Ft(i,a,s,{source_context:j?.source_context,source_context_source:j?.source_context_source}),Lt(i);let C=await ao(l.hooks,{command:i,args:a,options:{...s},global:{...c},pm_root:l.pmRoot});c.profile&&C.length>0&&w(`profile:extensions hook_warnings=${D(C)}`),f.enforce_mandatory_migration_gate&&ii(i,s,h)}),e.hook("postAction",async()=>{let t=Pi();Ee(t.ok,t.error,{error_code:t.error_code,error_category:t.error_category,exit_code:t.exit_code,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage}),await qe(t)})}pa(_);var Sl=new Set(["--version","-V"]),Al=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),ua=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),fa=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Tl=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Ol=new Set(["claim","close-task","pause-task","release","start-task","test"]),On={setup:!0,listQuery:!0,mutation:!0,operation:!0},Rl=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function Et(e){return e.some(t=>Sl.has(t))}function ga(e){if(Et(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||P(e).requested)return On;let t=k(e);if(!t)return On;let n=t.trim().toLowerCase();return Al.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:ua.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:fa.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Tl.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:On}function ha(e){return e.length===0||P(e).requested||e.includes("--explain")&&k(e)===void 0}var Ci=Symbol("pmCliIdempotentTopLevelRegistration");function ya(e){let t=e;if(t[Ci])return;t[Ci]=!0;let n=e.command.bind(e);e.command=((o,...r)=>{let i=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===i||a.aliases().includes(i))?new Dn(i):n(o,...r)})}async function Il(e,t){if(ya(e),t.setup){let{registerSetupCommands:n}=await ll();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await dl(),o=typeof t.targetCommandName=="string"&&ua.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await ml();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await pl();n(e)}}function wa(e,t){return Et(t)?!1:ue(t)||P(t).requested?!0:!!k(t)}function va(e){if(Et(e))return!1;let t=k(e);return t?Rl.has(t):!1}function $l(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,r=e.normalizedTokens.map(d=>{let l=d.indexOf("=");return l>=0?d.slice(0,l):d}).find(d=>d==="--literal"||d==="--regex"||d==="--replacement"),i=r?e.argv.map(d=>{let l=d.indexOf("=");return(l>=0?d.slice(0,l):d)===o?l>=0?`${r}${d.slice(l)}`:r:d}):e.argv,a=Xe(i),s=r&&n>=0?`${o}=[redacted]`:t,c=r&&e.normalizedDisplay.includes("=")?`${r}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:c,sourceDisplay:s}}function _a(e){let t=e.commandName;if(!t)return;let n=e.trace.find(d=>d.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(d=>d.length>0),r=o.length>0?o.join(" "):"the canonical flag",i=fa.has(t)||Ol.has(t),a=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",c=$l({argv:e.argv,normalizedDisplay:r,normalizedTokens:o,rawFrom:n.from});throw new x(`Refusing to auto-correct ${s} ${c.sourceDisplay} to ${c.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:a,examples:[S(c.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:c.argv,suggested_retry:S(c.argv)}})}function Pl(e){return async t=>{let n=At(t.errorCode),o=Dt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Ho({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:Ue,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function ba(e){if(e.bootstrapGlobal.noExtensions)return;let t=ze(e.invocationArgv),n=await kt(e.bootstrapPmRoot);if(n&&xt(n.discovery,t)){let o=await _e(e.bootstrapPmRoot,t);xa(o);return}n&&Ct(Hn(e.invocationArgv),n,t),V({overrides:[]})}function xa(e){if(!e){V({overrides:[]});return}V(e.services)}async function Kn(e){Ee(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await qe({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function Ca(){Ee(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await qe({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function ka(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof x)&&(Bt(e.error)||!n))return!1;let o=Q(e.error),r=e.error instanceof x?e.error.exitCode:Wt(t),i=e.error instanceof x?e.error.context:void 0,a=Si(i,e.invocationArgv,o),s=Nr(o,a),c=e.bootstrapGlobal.lean?mt(mn(o,r,a)):mn(o,r,a),d=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?X(c,u=>`${JSON.stringify(u,null,2)}
34
+ `):c,null,2):Pr(o,a);e.jsonErrors?de(`${d}
35
+ `):w(d);let{errorCategory:l,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:r,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await vt({command:e.attemptedCommand,error_code:s.code,error_category:l,exit_code:r,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:j?.source_context});return await Kn({errorMessage:o,exitCode:r,classificationCode:s.code,errorCategory:l,commandResolution:m,resolutionStage:"execute"}),p&&(jt(Vt(e.error,o)),await Se(Ln)),process.exitCode=r,!0}async function Ea(e,t){let n=bn(e.invocationArgv),o=`unknown command '${n}'`,r=R(process.cwd(),e.bootstrapGlobal.path),i=await ia(r),a=ze(e.invocationArgv),s=await Sn(r,{},He(a)),c=await De({message:o},_,i,{failedExtensions:s}),d=pn(c.message,c.commandName,c.allowedTypes,{unknownCommandExamples:c.unknownCommandExamples,unknownCommandNextSteps:c.unknownCommandNextSteps,attemptedCommand:c.attemptedCommand,normalizedInvocationArgs:c.normalizedInvocationArgs,providedOptionFlags:c.providedOptionFlags,unknownOptionSuggestions:c.unknownOptionSuggestions,suggestedRetryCommand:c.suggestedRetryCommand,failedExtensions:s}),{errorCategory:l,commandResolution:m}=await e.emitTelemetryCommandError({command:n,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),p=await vt({command:n,error_code:d.code,error_category:l,exit_code:g.USAGE,error_message:d.detail,command_resolution:m,resolution_stage:"parse"}),u=e.jsonErrors?await En({message:o},_,i,e.bootstrapGlobal.lean===!0,{failedExtensions:s}):await kn({message:o},_,i,{failedExtensions:s}),f=_n(u,e.jsonErrors,s);await Kn({errorMessage:o,exitCode:g.USAGE,classificationCode:d.code,errorCategory:l,commandResolution:m,resolutionStage:"parse"}),e.jsonErrors?de(`${f}
36
+ `):w(f),p&&await Se(Ln),process.exitCode=g.USAGE}async function Sa(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let r=P(e.invocationArgv);return r.requested&&!Me(_,r.commandPathTokens)?(await Ea(e,t),!0):(await Ca(),!0)}async function Aa(e,t){let n=await De(e.error,_,T),o=pn(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:r,commandResolution:i}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await vt({command:e.attemptedCommand,error_code:o.code,error_category:r,exit_code:g.USAGE,error_message:o.detail,command_resolution:i,resolution_stage:"parse",source_context:j?.source_context}),s=e.jsonErrors?await En(e.error,_,T,e.bootstrapGlobal.lean===!0):await kn(e.error,_,T),c=await mi(o.code,e.bootstrapPmRoot,{},He(ze(e.invocationArgv))),d=_n(s,e.jsonErrors,c);await Kn({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:r,commandResolution:i,resolutionStage:"parse"}),e.jsonErrors?de(`${d}
37
+ `):w(d),a&&await Se(Ln),process.exitCode=g.USAGE}function Ta(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return typeof t=="string"&&(t==="commander.version"||t.startsWith("commander."))?!0:String(e.message??"").includes("(outputHelp)")}async function Oa(e){let t=e.error.code,n=String(e.error.message??"");if(!await Sa(e,t,n)){if(t==="commander.version"){await Ca();return}await Aa(e,t)}}async function Jn(e){let t=q(e.invocationArgv),n=R(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:Pl({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await ba({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await ka(o,Gt(e.error))){if(Ta(e.error)){await Oa(o);return}await Fi({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}async function Nl(e){_=Kt(Ue),pa(_),Fe=null,re=null,T=new Map,yo();let t=[...e],n,o;try{let r=at(e);t=r.argv;let i=[process.argv[0],process.argv[1],...t],a=t.length===0,s=q(t);if(s.authorMissingValue)throw new x("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});n=sr(s.author),_a(r),o=or(t);let c=ga(t);if(await Il(_,c),ha(t)&&xr(_,t),wa(_,t)?await ma(_,t):(T=new Map,V({overrides:[]})),va(t)&&await Gi(_,t),la(_),await gi(_,t,T))return;let m=P(t);if(m.requested&&!Me(_,m.commandPathTokens))throw new el(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(a||ue(t)&&k(t)===void 0){_.outputHelp();return}let p=R(process.cwd(),s.path),u=await I(p),f=await yi(t,p,s.noExtensions,_e);await Bo({pmRoot:p,packages:f?.contextIntentPackages},()=>bo({env:{...process.env,PM_PATH:p},argv:i,cwd:process.cwd()},()=>xo(u.agent_identity.harness_signals,()=>_.parseAsync(i),{probesEnabled:u.agent_identity?.probes_enabled})))}catch(r){await Jn({error:r,invocationArgv:t})}finally{o?.(),n?.()}}async function gm(e=process.argv.slice(2)){try{await zo(process.env,()=>Nl(e))}catch(t){await Jn({error:t,invocationArgv:[...e]})}}var hm={activationCommandMatchesProbe:Vi,applyDynamicExtensionRootHelpVisibility:da,bootstrapProfileEnabled:Hn,buildBootstrapActivationProbe:ze,buildPostActionTelemetryOutcome:Pi,buildPmCliRecoveryContext:Si,buildRuntimeExtensionDiscoverySnapshotCacheKey:zn,buildRuntimeExtensionActivationScope:Vn,buildRuntimeExtensionSnapshotCacheKey:Wi,buildRuntimeExtensionFilterForProbe:ta,addRuntimeFieldOption:$n,collectActivationCommandCandidates:He,collectExtensionFlagDefinitionsForCommand:Rn,collectExtensionFlagDefinitionsForInvocation:_t,collectLeadingCommandArgs:Bi,collectParsedActivationCommandArgs:na,collectRuntimeFieldLooseFlagDefinitionsForCommand:zi,commandHasLongOption:qi,commandHasShortOption:Hi,commandPathNeedsSearchExtensions:Yi,commandPathNeedsTemplateExtensions:Wn,describeUnknownError:Q,defaultPreflightDecision:Pn,discoveryNeedsActivationForProbe:xt,emitExtensionProfile:oa,emitExtensionSkippedProfile:Ct,emitSettingsReadWarnings:Mn,ensureIdempotentTopLevelCommandRegistration:ya,enforceExplicitRetryForFlagTypos:_a,envFlagEnabled:Mi,executeRegisteredRuntimeMigrations:aa,extractCommandScopedOptions:Le,extensionActivationCommands:Gn,extensionCapabilities:bt,extensionNeedsActivationForProbe:Bn,extensionProvidesTemplatesRuntime:Zi,hasAnyCapability:je,hasGlobalExtensionContributions:Qi,handleGenericRunPmCliError:Fi,handleRunPmCliCommanderError:Oa,handleRunPmCliError:Jn,handleRunPmCliHelpDisplayError:Sa,handleRunPmCliKnownError:ka,handleRunPmCliCommanderUsageError:Aa,handleUnknownHelpCommandError:Ea,inferMissingFieldsFromErrorMessage:Ei,inferPostActionErrorCode:$i,inferPostActionFailureMessage:Ii,invocationRequestsVersion:Et,isCommanderError:Bt,loadRuntimeExtensionCommandDescriptorsForRecovery:ia,loadRuntimeExtensionDiscoverySnapshot:kt,loadRuntimeExtensionSnapshot:_e,maybeLoadRuntimeExtensions:ra,maybeAttachCreateUpdatePolicyHelpText:qn,maybeLogHandledCliErrorToSentry:vt,matchesStaticExtensionCommand:Nn,normalizeTelemetryCommandResolution:Ti,normalizeTelemetryErrorCategory:Ri,normalizeTelemetryResolutionStage:Oi,normalizeThrownExitCode:Wt,probeUsesAnyFlag:Xi,prepareExtensionServicesForRunPmCliError:ba,readRecordBoolean:Ai,readRecordNumber:jn,readRecordString:we,recordCliReadOutputInvocationProvenance:ki,registerDynamicExtensionCommandPaths:ma,registerRuntimeSchemaFieldFlags:Gi,resolveCoreCommandRegistrationSelection:ga,resolveStaticExtensionActivationDecision:ea,resolveUnknownHelpToken:bn,readThrownExitCode:Gt,runAndClearAfterCommandHooks:qe,runRequiredExtensionCommand:ca,shouldAttachRichHelpTextForInvocation:ha,shouldLogHandledErrorToSentry:Di,shouldRegisterDynamicExtensionPaths:wa,shouldRegisterRuntimeSchemaFlags:va,shouldHandleRunPmCliCommanderError:Ta,setActiveExtensionHookContextForTest:nl,setActiveRuntimeExtensionCommandDescriptorsForTest:ol,setRecoveredExtensionServices:xa,toLooseFieldDefinitionType:In,isImporterOrExporterCommandPath:Li,validateDynamicExtensionCommandInvocation:Ui,wrapProgramActionsForExtensionHandlers:la,wrapThrownErrorForSentry:Vt};export{hm as _testOnly,gm as runPmCli};
38
38
  //# sourceMappingURL=main.js.map