@unbrained/pm-cli 2026.10.4 → 2026.10.6

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 (751) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +37 -1
  3. package/dist/cli/after-command-context-usage.js +1 -1
  4. package/dist/cli/argv-utils.js +1 -1
  5. package/dist/cli/bootstrap-args.js +1 -1
  6. package/dist/cli/bundle-integrity.js +2 -2
  7. package/dist/cli/command-namespaces.js +1 -1
  8. package/dist/cli/commander-usage.d.ts +1 -1
  9. package/dist/cli/commander-usage.js +7 -4
  10. package/dist/cli/commands/annotations/comments.js +1 -1
  11. package/dist/cli/commands/annotations/docs.js +1 -1
  12. package/dist/cli/commands/annotations/files.js +1 -1
  13. package/dist/cli/commands/annotations/learnings.js +1 -1
  14. package/dist/cli/commands/annotations/notes.js +1 -1
  15. package/dist/cli/commands/extension/describe.js +1 -1
  16. package/dist/cli/commands/extension/extension.js +1 -1
  17. package/dist/cli/commands/extension/scaffold.js +1 -1
  18. package/dist/cli/commands/extension/shared.js +1 -1
  19. package/dist/cli/commands/governance/gc.js +1 -1
  20. package/dist/cli/commands/governance/health.js +1 -1
  21. package/dist/cli/commands/governance/telemetry.js +1 -1
  22. package/dist/cli/commands/governance/validate.js +1 -1
  23. package/dist/cli/commands/history/activity.js +1 -1
  24. package/dist/cli/commands/history/history-compact.js +1 -1
  25. package/dist/cli/commands/history/history-redact.js +1 -1
  26. package/dist/cli/commands/history/history-repair.js +1 -1
  27. package/dist/cli/commands/history/history.js +1 -1
  28. package/dist/cli/commands/history/restore.js +1 -1
  29. package/dist/cli/commands/lifecycle/append.js +1 -1
  30. package/dist/cli/commands/lifecycle/claim.js +1 -1
  31. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  32. package/dist/cli/commands/lifecycle/close.js +1 -1
  33. package/dist/cli/commands/lifecycle/copy.js +1 -1
  34. package/dist/cli/commands/lifecycle/create.js +1 -1
  35. package/dist/cli/commands/lifecycle/delete.js +1 -1
  36. package/dist/cli/commands/lifecycle/focus.js +1 -1
  37. package/dist/cli/commands/lifecycle/plan.js +1 -1
  38. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  39. package/dist/cli/commands/lifecycle/update.js +1 -1
  40. package/dist/cli/commands/query/aggregate.js +1 -1
  41. package/dist/cli/commands/query/context.js +1 -1
  42. package/dist/cli/commands/query/deps.js +1 -1
  43. package/dist/cli/commands/query/duplicates.js +1 -1
  44. package/dist/cli/commands/query/eval.js +1 -1
  45. package/dist/cli/commands/query/get.js +1 -1
  46. package/dist/cli/commands/query/graph.js +1 -1
  47. package/dist/cli/commands/query/list.js +1 -1
  48. package/dist/cli/commands/query/next.js +1 -1
  49. package/dist/cli/commands/query/search.js +1 -1
  50. package/dist/cli/commands/query/stats.js +1 -1
  51. package/dist/cli/commands/test/test-all.js +1 -1
  52. package/dist/cli/commands/test/test-runs.js +1 -1
  53. package/dist/cli/commands/test/test.js +1 -1
  54. package/dist/cli/commands/workspace/config.js +1 -1
  55. package/dist/cli/commands/workspace/contracts.js +1 -1
  56. package/dist/cli/commands/workspace/init.js +1 -1
  57. package/dist/cli/commands/workspace/merge.js +1 -1
  58. package/dist/cli/commands/workspace/profile.js +1 -1
  59. package/dist/cli/commands/workspace/schema.js +1 -1
  60. package/dist/cli/commands/workspace/upgrade.js +1 -1
  61. package/dist/cli/context-intent-invocation.js +1 -1
  62. package/dist/cli/description-stdin.js +1 -1
  63. package/dist/cli/error-guidance.js +3 -1
  64. package/dist/cli/extension-command-help.js +5 -3
  65. package/dist/cli/extension-command-options.js +1 -1
  66. package/dist/cli/extension-recovery.js +1 -1
  67. package/dist/cli/help-content.js +5 -2
  68. package/dist/cli/help-json-payload.js +6 -3
  69. package/dist/cli/invocation-profile.js +2 -2
  70. package/dist/cli/main.js +5 -5
  71. package/dist/cli/migration-gates.js +1 -1
  72. package/dist/cli/option-values.js +1 -1
  73. package/dist/cli/public.js +1 -1
  74. package/dist/cli/register-annotations.js +1 -1
  75. package/dist/cli/register-assurance.js +1 -1
  76. package/dist/cli/register-files-lookup.js +1 -1
  77. package/dist/cli/register-history-activity.js +1 -1
  78. package/dist/cli/register-history-author.js +1 -1
  79. package/dist/cli/register-history-maintenance.js +2 -2
  80. package/dist/cli/register-list-query.js +10 -10
  81. package/dist/cli/register-mutation-options.js +1 -1
  82. package/dist/cli/register-mutation.js +2 -2
  83. package/dist/cli/register-operations.js +1 -1
  84. package/dist/cli/register-setup.js +1 -1
  85. package/dist/cli/register-structured-mutation.js +1 -1
  86. package/dist/cli/registration-helpers.js +1 -1
  87. package/dist/cli/runtime/activation.js +1 -1
  88. package/dist/cli/runtime/invocation-options.js +1 -1
  89. package/dist/cli/runtime/projection-retry.js +1 -1
  90. package/dist/cli/runtime/selection.js +1 -1
  91. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  92. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  93. package/dist/cli/schema/registration.js +2 -2
  94. package/dist/cli/schema-registration-helpers.js +1 -1
  95. package/dist/cli/search-refresh.js +1 -1
  96. package/dist/cli/stats-analytics-json.js +1 -1
  97. package/dist/cli/telemetry-flush.js +1 -1
  98. package/dist/cli-bundle/bundle-manifest.json +163 -163
  99. package/dist/cli-bundle/chunks/{chunk-SMKHR6BM.js → chunk-25EW53VO.js} +89 -88
  100. package/dist/cli-bundle/chunks/chunk-3CCVTV6Q.js +8 -0
  101. package/dist/cli-bundle/chunks/chunk-3REXBTST.js +3 -0
  102. package/dist/cli-bundle/chunks/chunk-4WB55TBC.js +80 -0
  103. package/dist/cli-bundle/chunks/{chunk-7CE2DJMA.js → chunk-6STTPXOC.js} +2 -2
  104. package/dist/cli-bundle/chunks/chunk-ATB4ZZBQ.js +20 -0
  105. package/dist/cli-bundle/chunks/chunk-D4G43LBV.js +238 -0
  106. package/dist/cli-bundle/chunks/chunk-K6D6DMRT.js +31 -0
  107. package/dist/cli-bundle/chunks/chunk-KIRHWPZB.js +2 -0
  108. package/dist/cli-bundle/chunks/chunk-O67BH435.js +6 -0
  109. package/dist/cli-bundle/chunks/chunk-R7CG2DB7.js +2 -0
  110. package/dist/cli-bundle/chunks/chunk-RJHLD64E.js +3 -0
  111. package/dist/cli-bundle/chunks/chunk-TUKO5NF7.js +2 -0
  112. package/dist/cli-bundle/chunks/chunk-UZ7BIUCI.js +2 -0
  113. package/dist/cli-bundle/chunks/{chunk-GZMWISWW.js → chunk-XJD47LUH.js} +3 -3
  114. package/dist/cli-bundle/chunks/{register-list-query-QBGXO5JJ.js → register-list-query-53WYLNZT.js} +11 -11
  115. package/dist/cli-bundle/chunks/register-mutation-34XXUBVI.js +20 -0
  116. package/dist/cli-bundle/chunks/register-operations-WANO6EIM.js +2 -0
  117. package/dist/cli-bundle/chunks/register-setup-WT37UPBQ.js +2 -0
  118. package/dist/cli-bundle/focused-chunks/chunk-6KFKQD2D.js +165 -0
  119. package/dist/cli-bundle/focused-chunks/chunk-FOHRPFIT.js +2 -0
  120. package/dist/cli-bundle/focused-chunks/chunk-GRQXL5G5.js +8 -0
  121. package/dist/cli-bundle/focused-chunks/{chunk-467EW5RL.js → chunk-JZ4WGUVH.js} +3 -3
  122. package/dist/cli-bundle/focused-chunks/chunk-NM3PM6O6.js +3 -0
  123. package/dist/cli-bundle/focused-chunks/chunk-OT7HK7SG.js +2 -0
  124. package/dist/cli-bundle/focused-chunks/{chunk-Q6DJ5DFQ.js → chunk-PCLU34KB.js} +2 -2
  125. package/dist/cli-bundle/focused-chunks/{chunk-HFAW3FJQ.js → chunk-PSXFFQFT.js} +2 -2
  126. package/dist/cli-bundle/focused-chunks/chunk-QQIE4L42.js +2 -0
  127. package/dist/cli-bundle/focused-chunks/chunk-RPUNVKXK.js +2 -0
  128. package/dist/cli-bundle/focused-chunks/chunk-RXSVJPZ7.js +3 -0
  129. package/dist/cli-bundle/focused-chunks/chunk-SPN5QTZ3.js +30 -0
  130. package/dist/cli-bundle/focused-chunks/chunk-SUZJNPGB.js +6 -0
  131. package/dist/cli-bundle/focused-chunks/chunk-W4BG5HHS.js +2 -0
  132. package/dist/cli-bundle/focused-chunks/chunk-Y5HXFDTZ.js +20 -0
  133. package/dist/cli-bundle/focused-chunks/chunk-ZK5SOOPC.js +75 -0
  134. package/dist/cli-bundle/focused-chunks/chunk-ZQK2XUSS.js +12 -0
  135. package/dist/cli-bundle/main.js +25 -25
  136. package/dist/cli-bundle/sdk-authoring.js +1 -1
  137. package/dist/cli-bundle/sdk-contracts.js +2 -2
  138. package/dist/cli-bundle/sdk-core.js +25 -24
  139. package/dist/cli-bundle/sdk-governance.js +1 -1
  140. package/dist/cli-bundle/sdk-graph.js +1 -1
  141. package/dist/cli-bundle/sdk-merge.js +55 -55
  142. package/dist/cli-bundle/sdk-query.js +1 -1
  143. package/dist/cli-bundle/sdk-runtime.js +1 -1
  144. package/dist/cli-bundle/sdk-testing.js +1 -1
  145. package/dist/cli-bundle/sdk.js +10 -10
  146. package/dist/cli.js +1 -1
  147. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  148. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  149. package/dist/core/config/nested-settings.js +1 -1
  150. package/dist/core/config/positional-value.js +1 -1
  151. package/dist/core/diagnostics/remediation.js +1 -1
  152. package/dist/core/extensions/activation-summary-markdown.js +2 -1
  153. package/dist/core/extensions/activation-summary.js +1 -1
  154. package/dist/core/extensions/activation-transaction.js +1 -1
  155. package/dist/core/extensions/capability-usage.js +1 -1
  156. package/dist/core/extensions/command-hook-context.js +1 -1
  157. package/dist/core/extensions/command-metadata-contract.js +1 -1
  158. package/dist/core/extensions/command-visibility-tier.js +1 -1
  159. package/dist/core/extensions/contribution-inventory.js +1 -1
  160. package/dist/core/extensions/exporter-output-contract.js +1 -1
  161. package/dist/core/extensions/extension-candidate.js +1 -1
  162. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  163. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  164. package/dist/core/extensions/extension-policy.js +1 -1
  165. package/dist/core/extensions/extension-registries.js +1 -1
  166. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  167. package/dist/core/extensions/extension-types.d.ts +2 -0
  168. package/dist/core/extensions/extension-types.js +1 -1
  169. package/dist/core/extensions/flag-definition-validation.js +1 -1
  170. package/dist/core/extensions/flag-value-types.js +1 -1
  171. package/dist/core/extensions/index.js +1 -1
  172. package/dist/core/extensions/item-field-types.js +1 -1
  173. package/dist/core/extensions/item-fields.js +1 -1
  174. package/dist/core/extensions/loader.js +1 -1
  175. package/dist/core/extensions/manifest-parser.js +1 -1
  176. package/dist/core/extensions/manifest-schema.js +1 -1
  177. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  178. package/dist/core/extensions/preflight-ownership.js +1 -1
  179. package/dist/core/extensions/registration-contracts.js +1 -1
  180. package/dist/core/extensions/registration-validation.js +1 -1
  181. package/dist/core/extensions/registration-values.js +1 -1
  182. package/dist/core/extensions/reserved-host-flags.js +1 -1
  183. package/dist/core/extensions/runtime-registrations.js +1 -1
  184. package/dist/core/extensions/service-ownership.js +1 -1
  185. package/dist/core/extensions/version-compat.js +1 -1
  186. package/dist/core/fs/atomic-create.js +1 -1
  187. package/dist/core/fs/fs-utils.js +2 -2
  188. package/dist/core/fs/host-environment-errors.js +1 -1
  189. package/dist/core/fs/index.js +1 -1
  190. package/dist/core/fs/path-utils.js +1 -1
  191. package/dist/core/governance/content-fields.js +1 -1
  192. package/dist/core/governance/issue-codes.js +1 -1
  193. package/dist/core/governance/metadata-coverage.js +1 -1
  194. package/dist/core/history/digest.js +1 -1
  195. package/dist/core/history/drift-cache.js +3 -3
  196. package/dist/core/history/drift-scan.d.ts +4 -0
  197. package/dist/core/history/drift-scan.js +1 -1
  198. package/dist/core/history/event-classification.js +1 -1
  199. package/dist/core/history/event-index.js +8 -7
  200. package/dist/core/history/history-compact-bulk.js +1 -1
  201. package/dist/core/history/history-diff.js +1 -1
  202. package/dist/core/history/history-rewrite.js +1 -1
  203. package/dist/core/history/history-storage-stats.js +1 -1
  204. package/dist/core/history/history-stream-policy.js +1 -1
  205. package/dist/core/history/history.js +2 -2
  206. package/dist/core/history/identity.js +1 -1
  207. package/dist/core/history/index.js +1 -1
  208. package/dist/core/history/operation-contract.js +1 -1
  209. package/dist/core/history/projection.js +1 -1
  210. package/dist/core/history/read.js +1 -1
  211. package/dist/core/history/replay.js +2 -1
  212. package/dist/core/history/tombstone.js +1 -1
  213. package/dist/core/history/version-address.js +1 -1
  214. package/dist/core/history/workspace-history.js +2 -2
  215. package/dist/core/io/body-file.js +1 -1
  216. package/dist/core/io/bulk-ids-input.js +2 -1
  217. package/dist/core/item/actionability.js +1 -1
  218. package/dist/core/item/dependency-reference.js +1 -1
  219. package/dist/core/item/id.js +1 -1
  220. package/dist/core/item/index.js +1 -1
  221. package/dist/core/item/item-format-version.js +1 -1
  222. package/dist/core/item/item-format.js +6 -4
  223. package/dist/core/item/item-record.js +1 -1
  224. package/dist/core/item/item-type-definition.js +1 -1
  225. package/dist/core/item/parent-reference-policy.js +1 -1
  226. package/dist/core/item/parse.js +8 -2
  227. package/dist/core/item/plan-lifecycle.js +1 -1
  228. package/dist/core/item/priority.js +1 -1
  229. package/dist/core/item/sprint-release-format.js +1 -1
  230. package/dist/core/item/status-filter.js +1 -1
  231. package/dist/core/item/status.js +1 -1
  232. package/dist/core/item/toon-decode.js +1 -1
  233. package/dist/core/item/type-registry.js +1 -1
  234. package/dist/core/item/type-synonyms.js +1 -1
  235. package/dist/core/lock/index.js +1 -1
  236. package/dist/core/lock/lock-gc.js +1 -1
  237. package/dist/core/lock/lock.js +3 -3
  238. package/dist/core/output/mutation-projection.js +1 -1
  239. package/dist/core/output/output-control.js +1 -1
  240. package/dist/core/output/output.js +22 -10
  241. package/dist/core/output/query-summary.js +1 -1
  242. package/dist/core/output/tabular.js +3 -1
  243. package/dist/core/packages/manifest.js +1 -1
  244. package/dist/core/packages/root.js +1 -1
  245. package/dist/core/policy/workflow-policy-schema.js +1 -1
  246. package/dist/core/policy/workflow-policy-store.js +1 -1
  247. package/dist/core/policy/workflow-policy.js +1 -1
  248. package/dist/core/profile/profile-describe.js +1 -1
  249. package/dist/core/profile/profile-lint.js +1 -1
  250. package/dist/core/profile/profile-plan.js +1 -1
  251. package/dist/core/profile/profile-presets.js +25 -1
  252. package/dist/core/reproducibility/context.js +1 -1
  253. package/dist/core/schema/fields-file.js +2 -2
  254. package/dist/core/schema/item-types-file.js +2 -2
  255. package/dist/core/schema/runtime-field-filters.js +1 -1
  256. package/dist/core/schema/runtime-field-values.js +1 -1
  257. package/dist/core/schema/runtime-schema.js +2 -2
  258. package/dist/core/schema/status-defs-file.js +2 -2
  259. package/dist/core/schema/status-token.js +1 -1
  260. package/dist/core/schema/type-inference.js +1 -1
  261. package/dist/core/schema/type-presets.js +1 -1
  262. package/dist/core/schema/type-workflows.js +1 -1
  263. package/dist/core/search/background-refresh.js +2 -2
  264. package/dist/core/search/bm25.js +1 -1
  265. package/dist/core/search/cache.js +2 -2
  266. package/dist/core/search/corpus.js +1 -1
  267. package/dist/core/search/embedding-batches.js +1 -1
  268. package/dist/core/search/eval-thresholds.js +1 -1
  269. package/dist/core/search/eval.js +1 -1
  270. package/dist/core/search/http-client.js +1 -1
  271. package/dist/core/search/providers.js +1 -1
  272. package/dist/core/search/relevance.js +1 -1
  273. package/dist/core/search/semantic-defaults.js +1 -1
  274. package/dist/core/search/staleness.js +1 -1
  275. package/dist/core/search/vector-stores.js +2 -2
  276. package/dist/core/search/vectorization-metadata.js +1 -1
  277. package/dist/core/sentry/helpers.js +1 -1
  278. package/dist/core/sentry/instrument.js +1 -1
  279. package/dist/core/session/session-state.js +1 -1
  280. package/dist/core/shared/agent-session-context.js +1 -1
  281. package/dist/core/shared/author.js +5 -1
  282. package/dist/core/shared/command-line.js +1 -1
  283. package/dist/core/shared/command-types.js +1 -1
  284. package/dist/core/shared/conflict-markers.js +1 -1
  285. package/dist/core/shared/constants.js +1 -1
  286. package/dist/core/shared/errors.js +1 -1
  287. package/dist/core/shared/html-entity-decode.js +1 -1
  288. package/dist/core/shared/index.js +1 -1
  289. package/dist/core/shared/item-metadata-contract.js +1 -1
  290. package/dist/core/shared/lazy-module.js +1 -1
  291. package/dist/core/shared/levenshtein.js +1 -1
  292. package/dist/core/shared/memo.js +1 -1
  293. package/dist/core/shared/numeric-parsers.js +1 -1
  294. package/dist/core/shared/option-alias-visibility.js +1 -1
  295. package/dist/core/shared/primitives.js +1 -1
  296. package/dist/core/shared/secret-rules.js +1 -1
  297. package/dist/core/shared/serial-queue.js +1 -1
  298. package/dist/core/shared/serialization.js +1 -1
  299. package/dist/core/shared/split-comma-list.js +1 -1
  300. package/dist/core/shared/text-normalization.js +1 -1
  301. package/dist/core/shared/time.js +2 -1
  302. package/dist/core/store/index.js +1 -1
  303. package/dist/core/store/item-format-migration.js +1 -1
  304. package/dist/core/store/item-metadata-cache.js +1 -1
  305. package/dist/core/store/item-metadata-query-index.js +7 -7
  306. package/dist/core/store/item-metadata-read-work.js +1 -1
  307. package/dist/core/store/item-store.js +1 -1
  308. package/dist/core/store/paths.js +1 -1
  309. package/dist/core/store/settings-concurrency.js +1 -1
  310. package/dist/core/store/settings-read-cache.js +1 -1
  311. package/dist/core/store/settings-validator.js +1 -1
  312. package/dist/core/store/settings.js +3 -3
  313. package/dist/core/store/tracker-preflight.js +1 -1
  314. package/dist/core/telemetry/consent.js +2 -2
  315. package/dist/core/telemetry/observability.js +1 -1
  316. package/dist/core/telemetry/policy.js +1 -1
  317. package/dist/core/telemetry/read-sampling.js +2 -2
  318. package/dist/core/telemetry/runtime.js +9 -5
  319. package/dist/core/test/background-runs.js +3 -3
  320. package/dist/core/test/item-test-run-tracking.js +1 -1
  321. package/dist/core/test/run-selectors.js +1 -1
  322. package/dist/core/validate/estimate-defaults.js +1 -1
  323. package/dist/core/validate/fix-planning.js +1 -1
  324. package/dist/core/validate/linked-artifact-reference.js +1 -1
  325. package/dist/core/validate/missing-by-type.js +1 -1
  326. package/dist/core/validate/missing-link-owners.js +1 -1
  327. package/dist/core/validate/stale-file-classification.js +1 -1
  328. package/dist/mcp/http-server.js +6 -4
  329. package/dist/mcp/legacy-adapter.js +1 -1
  330. package/dist/mcp/runtime-capabilities.js +1 -1
  331. package/dist/mcp/server.js +4 -4
  332. package/dist/mcp/tool-definitions.js +1 -1
  333. package/dist/sdk/actionability.js +1 -1
  334. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  335. package/dist/sdk/agent/command-recovery.js +1 -1
  336. package/dist/sdk/agent/command-suggestions.js +1 -1
  337. package/dist/sdk/agent/create-option-policy.js +1 -1
  338. package/dist/sdk/agent/identity-config.js +1 -1
  339. package/dist/sdk/agent/item-addressing.js +1 -1
  340. package/dist/sdk/agent/refusal-closure-census.js +2 -1
  341. package/dist/sdk/agent/refusal-closure.js +1 -1
  342. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  343. package/dist/sdk/agent/refusal-reachability.js +3 -1
  344. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  345. package/dist/sdk/agent/task-transcript-contracts.js +1 -1
  346. package/dist/sdk/agent/tracker-preflight-contracts.js +1 -1
  347. package/dist/sdk/agent-capability-contracts.js +3 -1
  348. package/dist/sdk/agent-session-context.js +1 -1
  349. package/dist/sdk/annotations.js +1 -1
  350. package/dist/sdk/author-attribution.js +1 -1
  351. package/dist/sdk/authoring.js +1 -1
  352. package/dist/sdk/cli-bootstrap.d.ts +5 -1
  353. package/dist/sdk/cli-bootstrap.js +1 -1
  354. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -3
  355. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  356. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  357. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  358. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  359. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  360. package/dist/sdk/cli-contracts/completeness.js +1 -1
  361. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  362. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  363. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -1
  364. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  365. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  366. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  367. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  368. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  369. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  370. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  371. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  372. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  373. package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -1
  374. package/dist/sdk/cli-contracts.js +1 -1
  375. package/dist/sdk/cli-program.js +1 -1
  376. package/dist/sdk/command-line.js +1 -1
  377. package/dist/sdk/comments.js +1 -1
  378. package/dist/sdk/compile-cache.js +1 -1
  379. package/dist/sdk/completion/bash.js +2 -1
  380. package/dist/sdk/completion/fish.js +13 -7
  381. package/dist/sdk/completion/shared.js +1 -1
  382. package/dist/sdk/completion/zsh.js +14 -8
  383. package/dist/sdk/completion.js +1 -1
  384. package/dist/sdk/compose.js +1 -1
  385. package/dist/sdk/config.js +1 -1
  386. package/dist/sdk/context/recency.js +1 -1
  387. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  388. package/dist/sdk/context/usage-egress.js +1 -1
  389. package/dist/sdk/context/usage-ledger.js +6 -3
  390. package/dist/sdk/context-intent-contracts.js +1 -1
  391. package/dist/sdk/context-intent-runtime.js +1 -1
  392. package/dist/sdk/context-packing.js +1 -1
  393. package/dist/sdk/context-relevance.js +1 -1
  394. package/dist/sdk/context-signal-store.js +2 -2
  395. package/dist/sdk/context-usage.js +1 -1
  396. package/dist/sdk/contracts.js +1 -1
  397. package/dist/sdk/core-governance.js +1 -1
  398. package/dist/sdk/core.js +1 -1
  399. package/dist/sdk/corpus-shape.js +1 -1
  400. package/dist/sdk/define.js +1 -1
  401. package/dist/sdk/dependencies.js +1 -1
  402. package/dist/sdk/dependency-flag-validation.js +1 -1
  403. package/dist/sdk/dependency-provenance.js +1 -1
  404. package/dist/sdk/docs.js +1 -1
  405. package/dist/sdk/duplicates.js +1 -1
  406. package/dist/sdk/environment/agent-environment.js +1 -1
  407. package/dist/sdk/environment/host-environment-errors.js +1 -1
  408. package/dist/sdk/environment/project-runtime-compatibility.js +2 -1
  409. package/dist/sdk/environment/source-context.js +1 -1
  410. package/dist/sdk/environment/tracker-preflight.js +1 -1
  411. package/dist/sdk/error-code-catalog.js +1 -1
  412. package/dist/sdk/error-runtime.js +1 -1
  413. package/dist/sdk/errors.js +1 -1
  414. package/dist/sdk/eval.js +1 -1
  415. package/dist/sdk/extension/author-manifest.js +1 -1
  416. package/dist/sdk/extension/bundled-catalog.js +1 -1
  417. package/dist/sdk/extension/concurrency.js +1 -1
  418. package/dist/sdk/extension/copy-scope.js +1 -1
  419. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  420. package/dist/sdk/extension/describe.js +4 -2
  421. package/dist/sdk/extension/doctor.js +1 -1
  422. package/dist/sdk/extension/install-plan.js +1 -1
  423. package/dist/sdk/extension/install-receipts.js +1 -1
  424. package/dist/sdk/extension/install-runtime.js +3 -3
  425. package/dist/sdk/extension/install-snapshot.js +1 -1
  426. package/dist/sdk/extension/install-sources.js +5 -5
  427. package/dist/sdk/extension/managed-state.d.ts +2 -0
  428. package/dist/sdk/extension/managed-state.js +2 -2
  429. package/dist/sdk/extension/managed-update-status.d.ts +3 -0
  430. package/dist/sdk/extension/managed-update-status.js +2 -0
  431. package/dist/sdk/extension/migrations.js +2 -2
  432. package/dist/sdk/extension/output-ownership.js +1 -1
  433. package/dist/sdk/extension/runtime-summary.js +1 -1
  434. package/dist/sdk/extension/scaffold.js +11 -4
  435. package/dist/sdk/extension/shared.js +1 -1
  436. package/dist/sdk/extension/source-resolution.d.ts +2 -6
  437. package/dist/sdk/extension/source-resolution.js +1 -1
  438. package/dist/sdk/extension/static-inventory.js +1 -1
  439. package/dist/sdk/extension/update-check.d.ts +10 -0
  440. package/dist/sdk/extension/update-check.js +1 -1
  441. package/dist/sdk/extension-command-context.js +2 -1
  442. package/dist/sdk/extension-contracts.js +1 -1
  443. package/dist/sdk/extension.d.ts +4 -0
  444. package/dist/sdk/extension.js +1 -1
  445. package/dist/sdk/files.js +1 -1
  446. package/dist/sdk/flag-invocation-contracts.js +1 -1
  447. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  448. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  449. package/dist/sdk/generated-error-code-catalog.js +1 -1
  450. package/dist/sdk/governance/assurance-action-contracts.js +1 -1
  451. package/dist/sdk/governance/assurance-action.js +1 -1
  452. package/dist/sdk/governance/assurance-limits.js +1 -1
  453. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  454. package/dist/sdk/governance/assurance-presets.js +1 -1
  455. package/dist/sdk/governance/assurance-runtime.js +1 -1
  456. package/dist/sdk/governance/assurance.js +4 -4
  457. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  458. package/dist/sdk/governance/closure-timestamps.js +1 -1
  459. package/dist/sdk/governance/coverage-assurance.js +1 -1
  460. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  461. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  462. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  463. package/dist/sdk/governance/defect-recurrence.js +1 -1
  464. package/dist/sdk/governance/extension-host-version.js +1 -1
  465. package/dist/sdk/governance/gc.js +1 -1
  466. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  467. package/dist/sdk/governance/health.js +2 -1
  468. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  469. package/dist/sdk/governance/linked-file-report.js +1 -1
  470. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  471. package/dist/sdk/governance/provenance-health.js +4 -1
  472. package/dist/sdk/governance/reindex.js +5 -4
  473. package/dist/sdk/governance/stale-work.js +1 -1
  474. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  475. package/dist/sdk/governance/storage-integrity.js +1 -1
  476. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  477. package/dist/sdk/governance/upgrade.js +2 -2
  478. package/dist/sdk/governance/validate-history-drift.js +1 -1
  479. package/dist/sdk/governance/validate-item-reader.js +1 -1
  480. package/dist/sdk/governance/validate-normalization.js +1 -1
  481. package/dist/sdk/governance/validate.js +1 -1
  482. package/dist/sdk/governance/workflow-completeness.js +1 -1
  483. package/dist/sdk/governance/workflow-policy.js +3 -3
  484. package/dist/sdk/governance/workspace-position.js +2 -1
  485. package/dist/sdk/governance.js +1 -1
  486. package/dist/sdk/graph/adapter.js +1 -1
  487. package/dist/sdk/graph/analytics.js +1 -1
  488. package/dist/sdk/graph/assembly.js +1 -1
  489. package/dist/sdk/graph/cache.js +1 -1
  490. package/dist/sdk/graph/centrality.js +1 -1
  491. package/dist/sdk/graph/conformance.js +1 -1
  492. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  493. package/dist/sdk/graph/durable-cache.js +1 -1
  494. package/dist/sdk/graph/governance-contracts.js +1 -1
  495. package/dist/sdk/graph/governance.js +1 -1
  496. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  497. package/dist/sdk/graph/index.js +1 -1
  498. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  499. package/dist/sdk/graph/mutation-advisory.js +1 -1
  500. package/dist/sdk/graph/query-contracts.js +1 -1
  501. package/dist/sdk/graph/remediation.js +1 -1
  502. package/dist/sdk/graph/run.js +1 -1
  503. package/dist/sdk/graph/scheduling.js +1 -1
  504. package/dist/sdk/graph/traversal.js +1 -1
  505. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  506. package/dist/sdk/graph.js +1 -1
  507. package/dist/sdk/guide-topics.js +1 -1
  508. package/dist/sdk/guide.js +8 -1
  509. package/dist/sdk/history/attestation-command.js +1 -1
  510. package/dist/sdk/history/attestation-contract.js +1 -1
  511. package/dist/sdk/history/attestation-scan.js +1 -1
  512. package/dist/sdk/history/attestation.js +1 -1
  513. package/dist/sdk/history/maintenance.js +1 -1
  514. package/dist/sdk/history/salvage.js +3 -2
  515. package/dist/sdk/history/subject.js +1 -1
  516. package/dist/sdk/history-analytics.js +1 -1
  517. package/dist/sdk/history-compact.js +1 -1
  518. package/dist/sdk/history-mcp.js +1 -1
  519. package/dist/sdk/history-provenance.js +1 -1
  520. package/dist/sdk/history-read.js +1 -1
  521. package/dist/sdk/history-redact.js +1 -1
  522. package/dist/sdk/history-repair.js +1 -1
  523. package/dist/sdk/improvement-ledger-validation.js +1 -1
  524. package/dist/sdk/improvement-ledger.js +2 -2
  525. package/dist/sdk/index.js +1 -1
  526. package/dist/sdk/init-agent-guidance.js +16 -2
  527. package/dist/sdk/init.js +16 -2
  528. package/dist/sdk/invocation-author.js +1 -1
  529. package/dist/sdk/item-children.js +1 -1
  530. package/dist/sdk/item-metadata-index.js +1 -1
  531. package/dist/sdk/item-schedule.js +1 -1
  532. package/dist/sdk/item-transaction.js +1 -1
  533. package/dist/sdk/learnings.js +1 -1
  534. package/dist/sdk/lifecycle/append.js +4 -2
  535. package/dist/sdk/lifecycle/claim.js +1 -1
  536. package/dist/sdk/lifecycle/close-many.js +1 -1
  537. package/dist/sdk/lifecycle/close.js +1 -1
  538. package/dist/sdk/lifecycle/copy.js +1 -1
  539. package/dist/sdk/lifecycle/create.js +1 -1
  540. package/dist/sdk/lifecycle/delete.js +1 -1
  541. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  542. package/dist/sdk/lifecycle/focus.js +1 -1
  543. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  544. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  545. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  546. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  547. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  548. package/dist/sdk/lifecycle/mutation-command-options.js +1 -1
  549. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  550. package/dist/sdk/lifecycle/plan.js +1 -1
  551. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  552. package/dist/sdk/lifecycle/reopen.js +1 -1
  553. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -1
  554. package/dist/sdk/lifecycle/restore.js +1 -1
  555. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  556. package/dist/sdk/lifecycle/task-composition.js +1 -1
  557. package/dist/sdk/lifecycle/update-many.js +1 -1
  558. package/dist/sdk/lifecycle/update.js +2 -1
  559. package/dist/sdk/lifecycle-completion.js +1 -1
  560. package/dist/sdk/lifecycle-policy.js +1 -1
  561. package/dist/sdk/linked-artifacts.js +2 -1
  562. package/dist/sdk/mcp/apps.js +1 -1
  563. package/dist/sdk/mcp/authorization.js +1 -1
  564. package/dist/sdk/mcp/discovery.js +1 -1
  565. package/dist/sdk/mcp/interactions.js +1 -1
  566. package/dist/sdk/mcp/protocol.js +1 -1
  567. package/dist/sdk/mcp/skills.js +3 -1
  568. package/dist/sdk/mcp/subscriptions.js +1 -1
  569. package/dist/sdk/mcp/tasks.js +2 -2
  570. package/dist/sdk/mcp/transport.js +1 -1
  571. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  572. package/dist/sdk/merge/driver.js +1 -1
  573. package/dist/sdk/merge/index.js +1 -1
  574. package/dist/sdk/merge/install.js +4 -2
  575. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  576. package/dist/sdk/merge/receipt-operation.js +1 -1
  577. package/dist/sdk/merge/receipt-schema.js +1 -1
  578. package/dist/sdk/merge/receipts.js +4 -4
  579. package/dist/sdk/merge/reconcile.js +1 -1
  580. package/dist/sdk/merge/three-way.js +3 -2
  581. package/dist/sdk/merge/worktree-config.js +1 -1
  582. package/dist/sdk/merge.js +1 -1
  583. package/dist/sdk/mutation-events.js +1 -1
  584. package/dist/sdk/mutation-guard.js +1 -1
  585. package/dist/sdk/notes.js +1 -1
  586. package/dist/sdk/output-contracts.js +1 -1
  587. package/dist/sdk/output-projection.js +1 -1
  588. package/dist/sdk/output-token-accounting.js +1 -1
  589. package/dist/sdk/output.js +2 -1
  590. package/dist/sdk/ownership-source.js +1 -1
  591. package/dist/sdk/package-import-adapters.js +1 -1
  592. package/dist/sdk/package-migrations.js +1 -1
  593. package/dist/sdk/package-runtime-options.js +1 -1
  594. package/dist/sdk/pagination.js +1 -1
  595. package/dist/sdk/profile.js +5 -1
  596. package/dist/sdk/provenance.js +1 -1
  597. package/dist/sdk/public-surface.json +1 -1
  598. package/dist/sdk/query/activity.js +1 -1
  599. package/dist/sdk/query/aggregate.js +1 -1
  600. package/dist/sdk/query/calendar.js +4 -1
  601. package/dist/sdk/query/complete-list.js +1 -1
  602. package/dist/sdk/query/context.js +2 -1
  603. package/dist/sdk/query/duplicate-candidates.js +1 -1
  604. package/dist/sdk/query/get.d.ts +14 -2
  605. package/dist/sdk/query/get.js +1 -1
  606. package/dist/sdk/query/history.js +1 -1
  607. package/dist/sdk/query/item-filter-options.js +1 -1
  608. package/dist/sdk/query/light-metadata.js +1 -1
  609. package/dist/sdk/query/list-filter-shared.js +1 -1
  610. package/dist/sdk/query/list.js +1 -1
  611. package/dist/sdk/query/multi-value-filters.js +1 -1
  612. package/dist/sdk/query/next-ready-budget.js +1 -1
  613. package/dist/sdk/query/next.js +2 -1
  614. package/dist/sdk/query/parsers.js +1 -1
  615. package/dist/sdk/query/projection-contracts.js +1 -1
  616. package/dist/sdk/query/search/corpus.js +2 -1
  617. package/dist/sdk/query/search/filters.js +1 -1
  618. package/dist/sdk/query/search/input.js +1 -1
  619. package/dist/sdk/query/search/lexical.js +1 -1
  620. package/dist/sdk/query/search/response.js +1 -1
  621. package/dist/sdk/query/search/semantic.js +3 -2
  622. package/dist/sdk/query/search/types.js +1 -1
  623. package/dist/sdk/query/search-contracts.js +1 -1
  624. package/dist/sdk/query/search-pagination.js +1 -1
  625. package/dist/sdk/query/search-rendering.js +1 -1
  626. package/dist/sdk/query/search.js +1 -1
  627. package/dist/sdk/query/workspace-contracts.js +1 -1
  628. package/dist/sdk/query.js +1 -1
  629. package/dist/sdk/read-output/continuation.js +1 -1
  630. package/dist/sdk/read-output/options.js +1 -1
  631. package/dist/sdk/read-output/provenance.js +1 -1
  632. package/dist/sdk/read-output-budget.js +1 -1
  633. package/dist/sdk/read-output-contracts.js +1 -1
  634. package/dist/sdk/read-output-rows.js +1 -1
  635. package/dist/sdk/read-output-session.js +1 -1
  636. package/dist/sdk/relationship-analytics.js +1 -1
  637. package/dist/sdk/relationship-context.js +1 -1
  638. package/dist/sdk/relationship-history.js +7 -4
  639. package/dist/sdk/relationship-kinds/contract.js +1 -1
  640. package/dist/sdk/relationship-migration.js +1 -1
  641. package/dist/sdk/relationships.js +1 -1
  642. package/dist/sdk/reproducibility/process.js +1 -1
  643. package/dist/sdk/runtime/actions.js +1 -1
  644. package/dist/sdk/runtime/context.js +1 -1
  645. package/dist/sdk/runtime/schema-preview.js +1 -1
  646. package/dist/sdk/runtime/schema.js +1 -1
  647. package/dist/sdk/runtime-action-aliases.js +1 -1
  648. package/dist/sdk/runtime-extended-actions.js +1 -1
  649. package/dist/sdk/runtime-input.js +1 -1
  650. package/dist/sdk/runtime-primitives.js +1 -1
  651. package/dist/sdk/runtime-public-contracts.js +1 -1
  652. package/dist/sdk/runtime-stats-options.js +1 -1
  653. package/dist/sdk/runtime.js +1 -1
  654. package/dist/sdk/scheduling-shortcuts.js +1 -1
  655. package/dist/sdk/schema-migration.js +4 -3
  656. package/dist/sdk/schema.js +7 -1
  657. package/dist/sdk/search-refresh-worker.js +1 -1
  658. package/dist/sdk/similarity-scoring.js +1 -1
  659. package/dist/sdk/similarity.js +1 -1
  660. package/dist/sdk/start-task-status.js +1 -1
  661. package/dist/sdk/stats.js +1 -1
  662. package/dist/sdk/structured-mutations.js +1 -1
  663. package/dist/sdk/telemetry-flush.js +1 -1
  664. package/dist/sdk/telemetry.js +4 -3
  665. package/dist/sdk/templates.js +26 -2
  666. package/dist/sdk/test/batch.js +2 -2
  667. package/dist/sdk/test/entry.js +1 -1
  668. package/dist/sdk/test/execution.d.ts +2 -1
  669. package/dist/sdk/test/execution.js +6 -5
  670. package/dist/sdk/test/json-path.js +1 -1
  671. package/dist/sdk/test/linked-command-detection.js +1 -1
  672. package/dist/sdk/test/measurements.js +1 -1
  673. package/dist/sdk/test/parsers.js +1 -1
  674. package/dist/sdk/test/runs.js +1 -1
  675. package/dist/sdk/test/trust.js +2 -2
  676. package/dist/sdk/test/workspace-snapshot.js +1 -1
  677. package/dist/sdk/testing.js +7 -4
  678. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  679. package/dist/sdk/traceability/source-traceability.js +2 -1
  680. package/dist/sdk/tracker-root-discovery.js +1 -1
  681. package/dist/sdk/workspace-contracts-cache.js +1 -1
  682. package/dist/sdk/workspace-contracts.js +1 -1
  683. package/dist/sdk/workspace-memory.js +2 -2
  684. package/dist/sdk/workspace-recipe.js +1 -1
  685. package/dist/sdk/workspace-snapshot.js +5 -4
  686. package/dist/sdk/workspace-transaction-gc.js +1 -1
  687. package/dist/sdk/workspace-transaction.js +2 -2
  688. package/dist/sdk/workspace.js +3 -2
  689. package/dist/types/index.js +1 -1
  690. package/dist/types.js +1 -1
  691. package/docs/AGENT_EVIDENCE_CONSISTENCY.md +88 -0
  692. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +36 -0
  693. package/docs/GET_READ_EVIDENCE.md +84 -0
  694. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +23 -0
  695. package/docs/PR_REVIEW_LOOP.md +21 -4
  696. package/docs/README.md +3 -0
  697. package/docs/RELEASING.md +18 -0
  698. package/docs/SDK_CONFIGURATION_SAFETY.md +123 -0
  699. package/docs/generated/FLAG_LEXICON_BUDGETS.md +3 -3
  700. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  701. package/marketplace.json +2 -2
  702. package/package.json +3 -3
  703. package/packages/pm-beads/package.json +1 -1
  704. package/packages/pm-calendar/package.json +1 -1
  705. package/packages/pm-command-kit/package.json +1 -1
  706. package/packages/pm-digital-twin/package.json +1 -1
  707. package/packages/pm-governance-audit/package.json +1 -1
  708. package/packages/pm-guide-shell/package.json +1 -1
  709. package/packages/pm-kanban/package.json +1 -1
  710. package/packages/pm-lifecycle-hooks/package.json +1 -1
  711. package/packages/pm-linked-test-adapters/package.json +1 -1
  712. package/packages/pm-search-advanced/package.json +1 -1
  713. package/packages/pm-templates/package.json +1 -1
  714. package/packages/pm-todos/package.json +1 -1
  715. package/packages/pm-vcs/extensions/vcs/index.ts +4 -2
  716. package/packages/pm-vcs/package.json +1 -1
  717. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  718. package/plugins/pm-claude/package.json +2 -2
  719. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  720. package/plugins/pm-codex/package.json +2 -2
  721. package/plugins/pm-codex/plugin.json +1 -1
  722. package/scripts/finalize-build.mjs +3 -2
  723. package/dist/cli-bundle/chunks/chunk-7UVXKI7K.js +0 -2
  724. package/dist/cli-bundle/chunks/chunk-D7Z2ZMJL.js +0 -3
  725. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  726. package/dist/cli-bundle/chunks/chunk-J52QIRRZ.js +0 -80
  727. package/dist/cli-bundle/chunks/chunk-JDKD3WGG.js +0 -6
  728. package/dist/cli-bundle/chunks/chunk-JQ7DW663.js +0 -2
  729. package/dist/cli-bundle/chunks/chunk-QXIDOOWT.js +0 -20
  730. package/dist/cli-bundle/chunks/chunk-SGFQQXFD.js +0 -2
  731. package/dist/cli-bundle/chunks/chunk-V3U77H3V.js +0 -31
  732. package/dist/cli-bundle/chunks/chunk-XZDWAYJC.js +0 -3
  733. package/dist/cli-bundle/chunks/chunk-Y6VRBTP3.js +0 -238
  734. package/dist/cli-bundle/chunks/chunk-YAAFYFS4.js +0 -8
  735. package/dist/cli-bundle/chunks/register-mutation-53ZLT4RX.js +0 -20
  736. package/dist/cli-bundle/chunks/register-operations-OBK2FXUU.js +0 -2
  737. package/dist/cli-bundle/chunks/register-setup-HM3OCBH2.js +0 -2
  738. package/dist/cli-bundle/focused-chunks/chunk-2JFYR56O.js +0 -2
  739. package/dist/cli-bundle/focused-chunks/chunk-32EVUSS4.js +0 -8
  740. package/dist/cli-bundle/focused-chunks/chunk-5GUSO2P4.js +0 -20
  741. package/dist/cli-bundle/focused-chunks/chunk-6XBRADQQ.js +0 -3
  742. package/dist/cli-bundle/focused-chunks/chunk-7O4NUJVO.js +0 -2
  743. package/dist/cli-bundle/focused-chunks/chunk-CURTIIQT.js +0 -2
  744. package/dist/cli-bundle/focused-chunks/chunk-IJUWEEEB.js +0 -6
  745. package/dist/cli-bundle/focused-chunks/chunk-JCVMOSWQ.js +0 -2
  746. package/dist/cli-bundle/focused-chunks/chunk-JMJK2L4Z.js +0 -3
  747. package/dist/cli-bundle/focused-chunks/chunk-KG3H4UZZ.js +0 -30
  748. package/dist/cli-bundle/focused-chunks/chunk-MHQ2XICU.js +0 -2
  749. package/dist/cli-bundle/focused-chunks/chunk-RJV6QVJE.js +0 -75
  750. package/dist/cli-bundle/focused-chunks/chunk-ZE2JZ7R6.js +0 -12
  751. package/dist/cli-bundle/focused-chunks/chunk-ZLEN4HZD.js +0 -165
@@ -1,38 +1,38 @@
1
- import{B as tr,D as nr,E as _n,a as an,b as de,c as sn,d as ln,e as cn,f as dn,i as U,j as M,k as A,l as me,m as x,n as Ti,s as He,t as Ri,u as Ni,y as Di,z as wn}from"./chunks/chunk-JQ7DW663.js";import{Wa as er,f as vi,l as Si}from"./chunks/chunk-SMKHR6BM.js";import"./chunks/chunk-XZDWAYJC.js";import"./chunks/chunk-JDKD3WGG.js";import{F as Ki,Id as Qi,Nc as Zi,b as Gi,d as Ct,g as Wi,h as Vi,i as Y,j as Bi}from"./chunks/chunk-V3U77H3V.js";import{Ga as Ji,g as Ai}from"./chunks/chunk-J52QIRRZ.js";import"./chunks/chunk-QXIDOOWT.js";import"./chunks/chunk-DEZPZOQ7.js";import{$a as Vo,$g as bi,Ac as ne,Aj as qe,Bc as ri,Cc as ai,Ce as mi,Dc as se,De as on,Ec as si,Fc as pt,Fn as We,Gb as Ko,Gc as Ce,Hc as le,I as Ho,If as ce,In as Ui,J as zo,Jf as _i,Kc as li,Kf as xe,Lc as ut,Ln as qi,M as Me,Mf as rn,Nf as _,Oo as xt,Pb as Jo,Po as kt,Q as Zt,Qb as Yo,Qn as gn,Qo as hn,Ra as Qt,Rc as nn,Rn as Hi,Ro as Ve,Sc as ft,Sn as zi,So as E,Tc as ci,Te as pi,To as Yi,Ua as ae,Uc as di,Ue as ui,Uo as yn,Ve as fi,Wa as Wo,Wb as Xo,We as gi,Xa as mt,Xe as hi,Yb as Zo,Yi as wt,Zi as Ei,_a as en,_o as q,ab as R,ae as gt,ah as Ci,cb as Bo,cd as k,db as J,dd as je,e as P,g as W,gl as Oi,h as T,hl as oe,hn as Mi,ih as ht,in as bt,j as V,jc as Qo,jl as Ii,jn as pn,k as Xt,kc as Fe,ki as yt,kl as Pi,kn as un,l as B,lj as _t,ln as ze,m as qo,mc as Le,mg as mn,mi as xi,ml as $i,mn as fn,mp as Xi,na as f,nc as ei,nj as Ue,nn as Fi,oa as dt,oj as vt,on as Ge,pa as C,pi as ke,qa as Go,qi as D,ri as ki,rn as Li,sf as yi,sn as ji,vb as tn,wc as ti,wf as wi,x as K,xc as ni,yc as oi,zc as ii}from"./chunks/chunk-Y6VRBTP3.js";import{Command as No,CommanderError as ka}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]="0429ff6a-ec0d-5c20-9fa7-0ed05b154523")}catch{}})();function H(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function pe(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return H(t)}function X(e){let t=new Set,n=[];for(let o of e){let i=pe(o);i&&(t.has(i)||n.push(i),t.add(i))}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]="bdbd1281-8294-5bda-8053-f9fff4c34bf3")}catch{}})();var vn=new Set(["--fields","--depth","--for","--token-budget"]),Et=new Set(["--full","--brief","--compact"]);function os(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function is(e){let t=oe(x([...e])),n=new Set([...Ii,...Pi,...$i].flatMap(a=>a.keys.map(s=>`--${s.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),o=new Map([...qe,...t].flatMap(a=>[a.flag,...a.aliases??[]].map(s=>[s,a.flag]))),i=new Map([...qe,...t].flatMap(a=>[a.flag,...a.aliases??[]].map(s=>[s,os(a,n)])));for(let a of vn)i.set(a,!0);for(let a of Et)i.set(a,!1);let r=new Map;for(let a=0;a<e.length;a+=1){let s=e[a];if(s==="--")break;if(!s.startsWith("-"))continue;let l=s.split("=")[0];if(!i.has(l)&&!s.includes("="))return;r.set(a,o.get(l)??l),i.get(l)&&!s.includes("=")&&(a+=1)}return r}function or(e,t,n){let o=new Set;for(let[i,r]of t)n.has(r)&&(o.add(i),vn.has(r)&&!e[i].includes("=")&&o.add(i+1));return e.filter((i,r)=>!o.has(r))}function ir(e,t,n){return e.splice(n,0,...t),e}function rs(e,t){let n=t.find(i=>Et.has(i));if(n===void 0)return;let o=[...new Set(e.values())].filter(i=>Et.has(i));return o.length===1?o[0]:n}function rr(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,i={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return i;let r=is(e);if(!r)return i;let a;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return i;let l=[...r].find(([c,d])=>d==="--fields")?.[0]??-1;if(l<0)return i;a=ir(or(e,r,new Set(["--fields"])),["--fields",o[s+1]],l)}else{let s=rs(r,o);if(s===void 0)return i;let l=new Set([...vn,...Et]),c=[...r].find(([d,m])=>l.has(m))?.[0]??-1;if(c<0)return i;a=ir(or(e,r,l),[s],c)}return{...n,suggested_retry:k(a),suggested_retry_args:a}}(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 ar(e,t){await Hi(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 sr(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await yi({pmRoot:e.pmRoot,result:le()})}catch(o){t=o}let n=await D(e.pmRoot);if(await wi({pmRoot:e.pmRoot,author:ht(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]="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]="63db65f1-fdbe-513d-b71a-87490ec9b69e")}catch{}})();var lr=new WeakMap;function St(e,t){lr.set(e,t)}function ue(e){return lr.get(e)}function cr(e){return e.length>0?[e[0]]:[]}function as(e){let t=["","Intent:",` ${e.why}`],n=cr(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(`
1
+ import{B as ti,D as ni,E as _n,a as rn,b as de,c as sn,d as ln,e as cn,f as dn,i as U,j as D,k as S,l as me,m as x,n as Ta,s as ze,t as Ra,u as Na,y as Da,z as wn}from"./chunks/chunk-KIRHWPZB.js";import{Ta as ei,f as va,i as Sa}from"./chunks/chunk-25EW53VO.js";import"./chunks/chunk-3REXBTST.js";import"./chunks/chunk-O67BH435.js";import{F as Ka,Id as Qa,Nc as Za,b as Ga,d as Ct,g as Wa,h as Va,i as Y,j as Ba}from"./chunks/chunk-K6D6DMRT.js";import{Ga as Ja,g as Aa}from"./chunks/chunk-4WB55TBC.js";import"./chunks/chunk-ATB4ZZBQ.js";import"./chunks/chunk-UZ7BIUCI.js";import{$a as Vo,$g as ba,Ac as te,Aj as He,Bc as ia,Cc as ra,Ce as ma,Dc as se,De as on,Ec as sa,Fc as ut,Fn as Ve,Gb as Ko,Gc as Ce,Hc as le,I as Ho,If as ce,In as Ua,J as zo,Jf as _a,Kc as la,Kf as xe,Lc as ft,Ln as qa,M as Me,Mf as an,Nf as w,Oo as xt,Pb as Jo,Po as kt,Q as Zt,Qb as Yo,Qn as gn,Qo as hn,Ra as Qt,Rc as nn,Rn as Ha,Ro as Be,Sc as gt,Sn as za,So as E,Tc as ca,Te as pa,To as Ya,Ua as re,Uc as da,Ue as ua,Uo as yn,Ve as fa,Wa as Wo,Wb as Xo,We as ga,Xa as pt,Xe as ha,Yb as Zo,Yi as wt,Zi as Ea,_a as en,_o as q,ab as T,ae as Ue,ah as Ca,cb as Bo,cd as k,db as J,dd as je,e as I,g as W,gl as Oa,h as O,hl as ne,hn as Ma,ih as ht,in as bt,j as B,jc as Qo,jl as Ia,jn as pn,k as Xt,kc as Fe,ki as yt,kl as $a,kn as un,l as V,lj as _t,ln as Ge,m as qo,mc as Le,mg as mn,mi as xa,ml as Pa,mn as fn,mp as Xa,na as f,nc as ea,nj as qe,nn as Fa,oa as mt,oj as vt,on as We,pa as b,pi as ke,qa as Go,qi as N,ri as ka,rn as La,sf as ya,sn as ja,vb as tn,wc as ta,wf as wa,x as K,xc as na,yc as oa,zc as aa}from"./chunks/chunk-D4G43LBV.js";import{Command as No,CommanderError as kr}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]="50318c14-8c1c-50f3-95d0-fd9ea3f0bb69")}catch{}})();function H(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function pe(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return H(t)}function X(e){let t=new Set,n=[];for(let o of e){let a=pe(o);a&&(t.has(a)||n.push(a),t.add(a))}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]="0b95b409-ef2c-59da-a628-16a2cb4f0ea6")}catch{}})();var vn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Et=new Set(["--full","--brief","--compact"]);function os(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function as(e){let t=ne(x([...e])),n=new Set([...Ia,...$a,...Pa].flatMap(r=>r.keys.map(s=>`--${s.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),o=new Map([...He,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,r.flag]))),a=new Map([...He,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,os(r,n)])));for(let r of vn)a.set(r,!0);for(let r of Et)a.set(r,!1);let i=new Map;for(let r=0;r<e.length;r+=1){let s=e[r];if(s==="--")break;if(!s.startsWith("-"))continue;let l=s.split("=")[0];if(!a.has(l)&&!s.includes("="))return;i.set(r,o.get(l)??l),a.get(l)&&!s.includes("=")&&(r+=1)}return i}function oi(e,t,n){let o=new Set;for(let[a,i]of t)n.has(i)&&(o.add(a),vn.has(i)&&!e[a].includes("=")&&o.add(a+1));return e.filter((a,i)=>!o.has(i))}function is(e,t){let n=t.find(a=>Et.has(a));if(n===void 0)return;let o=[...new Set(e.values())].filter(a=>Et.has(a));return o.length===1?o[0]:n}function ai(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,a={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return a;let i=as(e);if(!i)return a;let r;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return a;let l=[...i].find(([c,d])=>d==="--fields")?.[0]??-1;if(l<0)return a;r=oi(e,i,new Set(["--fields"])),r.splice(l,0,"--fields",o[s+1])}else{let s=is(i,o);if(s===void 0||![...i.values()].includes(s))return a;let l=new Set([...vn,...Et].filter(c=>c!==s));r=oi(e,i,l)}return{...n,suggested_retry:k(r),suggested_retry_args: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]="afa4a7a0-d9de-529d-92dd-3e9704ea00d2")}catch{}})();async function ii(e,t){await Ha(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 ri(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await ya({pmRoot:e.pmRoot,result:le()})}catch(o){t=o}let n=await N(e.pmRoot);if(await wa({pmRoot:e.pmRoot,author:ht(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]="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]="6ec548d1-a26d-5e72-9a7b-0fbd74a86601")}catch{}})();var si=new WeakMap;function St(e,t){si.set(e,t)}function ue(e){return si.get(e)}function li(e){return e.length>0?[e[0]]:[]}function rs(e){let t=["","Intent:",` ${e.why}`],n=li(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(`
2
2
  `)}function ss(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(`
3
- `)}function dr(e,t){return t==="detailed"?ss(e):as(e)}function F(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var ls={cal:"calendar",ctx:"context"};function cs(e,t){return e.commands.find(n=>n.name()===t)??null}function ds(e,t){let n=e;for(let o of t){let i=cs(n,o);if(!i)return null;n=i}return n}function bn(e,t,n,o){let i=ds(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",dr(n,o))}function Cn(e){return e.includes("--explain")?"detailed":"compact"}function ie(e){return e.includes("--all")||e.includes("--explain")}var fe={ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},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?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",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 "Done" --release-assignment --validate-close warn','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 --start",'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 --pause"]},"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."]}};for(let{alias:e,canonical:t}of P){let n=fe[e];n&&(fe[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ee={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."]},mr=V.filter(e=>e.lifecycle==="deprecated");for(let e of mr){let t=fe[e.alias];fe[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ee,...Object.values(fe)])e.examples=e.examples.map(t=>{for(let n of mr){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function ms(e){let t=F(e??"");return t?ls[t]??t:""}function xn(e){let t=ms(e);return t?fe[t]??Ee:Ee}function pr(e,t){let n=xn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:cr(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function ps(){let e=V.filter(({lifecycle:n})=>n==="permanent"),t=V.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(" ")} (${qo(n)})`)].join(`
4
- `)}function us(e,t,n,o){let i=new Set(Wi);e.configureHelp({visibleCommands(r){let a=t.visibleCommands(r);return n?a.filter(s=>(ue(s)??Y(s.name()))!=="internal"):r!==e?a:a.filter(s=>o.has(s))},visibleOptions(r){let a=t.visibleOptions(r);return r!==e||n?a:a.filter(s=>i.has(s.flags))}})}function fs(e,t,n,o){let i=new Set(Bi("core")),r=e.createHelp();r.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let a=()=>`${r.formatHelp(e,r)}${o}
5
- `,s=t.visibleCommands(e);for(let l of s)ue(l)===void 0&&(l.name()==="help"||i.has(l.name()))&&n.add(l);for(let l of s)ue(l)==="core"&&(n.add(l),Vi(a()).within_budget||n.delete(l))}function ur(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ie(t),i=new Set;us(e,n,o,i);let r=Cn(t),a=dr(Ee,r);e.addHelpText("after",a),o&&e.addHelpText("after",ps()),fs(e,n,i,a);for(let[d,m]of Object.entries(fe))bn(e,d,m,r);let s=F(A(t).commandPathTokens.join(" ")),l=Ue(s);if(l){bn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,vt(l.accepted_flags)]},r);return}let c=_t.filter(({parent:d})=>d===s);c.length>0&&bn(e,s,{why:`Dispatches one declared positional action: ${c.map(({action:d})=>d).join("|")}.`,examples:c.map(({example:d})=>d),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="b70452a1-26dc-5f66-bb87-67a5bde7bd30")}catch{}})();function kn(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:i}of P){if(t&&!P.some(c=>c.canonical.startsWith(`${o} `)))continue;let r=e.commands.findIndex(c=>c.name()===n);if(r<0)continue;let a=e.commands[r],s=e;for(let c of i.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===c)??s.command(c).description(`Discover ${c} operations.`);let l=i[i.length-1];if(s.commands.some(c=>c.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(r,1),a.name(l),St(a,Y(o)),s.enablePositionalOptions(),s.addCommand(a)}}(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]="392093b2-4fed-53dc-a686-dae8e6f0a91e")}catch{}})();function Tt(e){let{why:t,title:n,...o}=e;return o}var gs=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function hs(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!gs.has(e.code)}function wr(e){return`urn:pm-cli:error:${e}`}function b(e){return{...e,type:wr(e.code)}}var Se={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},fr={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},gr={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},At={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},ys={guide:Se,shell:Se,completion:Se,"completion-statuses":Se,"completion-tags":Se,"completion-types":Se,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:fr,cal:fr,reindex:gr,"search-advanced":gr,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":At,"dedupe-audit":At,"dedupe-merge":At,normalize:At};function ws(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return ys[t]}function En(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function _s(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 vs(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 Sn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Z(e,t,n){if(t==="parsed_positionals"){if(!Array.isArray(n))return;let i=n.map(r=>({role:typeof r?.role=="string"?r.role.trim():"",value:typeof r?.value=="string"?r.value.trim():""})).filter(r=>r.role.length>0&&r.value.length>0);i.length>0&&(e.parsed_positionals=i);return}let o=_s(n);o&&(e[t]=o)}function Ae(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Sn(t,"attempted_command",e.attempted_command),Z(t,"normalized_args",e.normalized_args),Z(t,"parsed_positionals",e.parsed_positionals),Z(t,"provided_fields",e.provided_fields),Z(t,"missing",e.missing),Z(t,"missing_required_fields",e.missing_required_fields),Z(t,"suggested_flags",e.suggested_flags),Z(t,"allowed_values",e.allowed_values),Z(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),Sn(t,"suggested_retry",e.suggested_retry),Z(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=vs(e.fallback_candidates);return n&&(t.fallback_candidates=n),Sn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function An(e,t,n){n&&e.push(` ${t}: ${n}`)}function ge(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function bs(e){let t=Ae(e);if(!t)return[];let n=["Recovery bundle:"];if(An(n,"suggested_retry",t.suggested_retry),An(n,"attempted_command",t.attempted_command),ge(n,"normalized_args",t.attempted_command?void 0: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(ge(n,"provided_fields",t.provided_fields,", "),ge(n,"missing",t.missing,", "),ge(n,"missing_required_fields",t.missing_required_fields,", "),ge(n,"suggested_flags",t.suggested_flags,", "),ge(n,"allowed_values",t.allowed_values,", "),ge(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}`),An(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 _r(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...En("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(...En("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...En("Verification errors:",e.verificationErrors)));let n=bs(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
6
- `)}function vr(e,t){return t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),hs(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 Cs(e,t){if(e.flag)return e.flag;let n=i=>{let r=i.split("=",1)[0];return M([r]).length>0&&!["--help","--no-changed-fields","--version"].includes(r)&&t.some(a=>a===r||a.startsWith(`${r}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(i=>i[0]).find(i=>n(i))}function xs(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(r=>r===n||r.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let i=t.indexOf(n);return t[i+1]}}function ks(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=M(e.recovery?.normalized_args??[]),o=W(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=Cs(e,i),a=xs(e,i,r);return{surface:r??e.recovery?.missing?.[0]??wn(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Es(e,t){return vr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:ks(e,t)},e)}function Tn(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 mi(Es(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function Rn(e){return vr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function Rt(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 he(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 hr(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function As(e){return wn(e?.normalized_args)}function Os(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 Ts(e,t){let n=e?.normalized_args,o=e?.provided_fields,i=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!i))for(let r of o){let a=n.findIndex(s=>s===r);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=i,k(s)}}}function Rs(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function Ot(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Is(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function Q(e,t,n){if(!n)return e;let o=Rt(t),i=Ot(n.code,e.code),r=Ot(n.type,wr(i)),a=he(n.examples)??e.examples,s=he(n.nextSteps)??e.nextSteps,l=he(n.verification_errors)??e.verificationErrors,c=e.code==="command_failed"&&n.code?Rs(o):void 0,d=Ae(n.recovery),m=d&&e.recovery?Ae({...e.recovery,...d}):d??e.recovery;return{...e,code:i,type:r,title:c??e.title,happened:o.length>0?o:e.happened,required:Ot(n.required,e.required),why:Ot(n.why,e.why),examples:a,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Is(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function Ps(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 i=o[1],r=Vo(process.cwd(),i);return Q(b(r?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${i}, but found a tracker at ${r}.`,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 ${r} <command>`,`PM_PATH=${r} pm <command>`],nextSteps:[`Re-run with "--pm-path ${r}" or export PM_PATH=${r}.`]}:{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 $s(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let i=o[1],r=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(i),a=r?`The item ID "${i}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${i}" exists in the active tracker scope.`;return Q(b({code:"item_not_found",title:"Item ID not found",flag:"id",value:i,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:r?["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 Ns(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:Q(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 Ds(e,t,n){return t.includes("is locked")?Q(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 Ms(e,t,n){let o=t.match(/^Missing required option /),i=t.match(/^Missing required options /);if(!o&&!i)return null;let r=!!i,a=r?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",l=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return Q(b({code:"missing_required_option",title:r?"Missing required options":`Missing required option ${s}`,happened:t,required:r?"Provide every required option for this command invocation.":l,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 Fs(e,t,n){return t.startsWith("No update flags provided")?Q(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 Ls(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Ae(n?.recovery),i=As(o),r=i?`pm ${i} --help`:"pm <command> --help",a=Os(t),s=Ae({...o,allowed_values:o?.allowed_values??a}),l=Ts(o,a),c=l?[l,r]:[r,"pm contracts --command <command> --flags-only --json"],d=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${r}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return Q(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:c,nextSteps:d,recovery:s}),e,n)}function In(e,t){let n=Rt(e),o=Ps(e,n,t)??$s(e,n,t)??Ns(e,n,t)??Ds(e,n,t)??Ms(e,n,t)??Fs(e,n,t)??Ls(e,n,t);return o||Q(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 js(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 Us(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function qs(e){if(!(!Array.isArray(e)||e.length===0))return k(e)}function Pn(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 z(e,t={}){let n=Pn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:qs(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return Ae({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,...t})}function On(e,t){return!t||e.includes(t)?e:[...e,t]}var Hs=new Set(["--add","--add-json","--remove"]),zs=new Set(["command","cmd","path"]);function Gs(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(Hs.has(o))return o}}function Ws(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 i=e[o];if(i!=="--add"&&i!=="--remove")continue;let r=e[o+1];if(typeof r!="string"||!zs.has(r))return;let a=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;a.push(d)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return k(l)}}function Vs(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=Us(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,l=Pn(o?.providedOptionFlags),c=[r],d=js(t,r,n),m=s?On(d,s):d,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?On(p,`Replay with preserved arguments: ${s}`):p,g=l&&l.length>0?On(u,`Already provided options: ${l.join(", ")}`):u;return b({code:"missing_required_option",title:`Missing required option ${r}`,happened:`Commander rejected the command because ${r} was not provided.`,required:`Pass ${r} 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:g,recovery:z(o,{missing:c})})}function Bs(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let i=o[1];return b({code:"missing_required_argument",title:`Missing required argument ${i}`,happened:`Command invocation omitted positional argument ${i}.`,required:`Provide ${i} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:z(n,{missing:[i]})})}function Ks(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:z(t,{suggested_flags:n})})}var Js={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 Ys(e){let t=he(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Xs(e,t,n,o,i){let r=o.otherCommands.slice(0,3),a=o.candidateTotal-r.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,r.length?`${e} is accepted by ${r.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,i?`Replay with suggested correction: ${i}`:void 0].filter(l=>typeof l=="string")}function Zs(e,t){if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(r=>r===t||r.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(r=>r===t||r.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let i=M(n.filter((r,a)=>a!==o));return{retryCommand:k(i),suggestedRetryArgs:i}}function Qs(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=Pn(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=Zs(i,r);if(t==="update"&&(r==="--file"||r==="--doc"))return Ks(r,n,a);let c=Ys(i),d=Xs(r,t,a,c,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(r.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,`pm ${t?B(t)?.canonical??t:"<command>"} --help`].filter(p=>typeof p=="string");return b({code:"unknown_option",title:`Unknown option ${r}`,happened:`Commander does not recognize option ${r} for this command path.`,required:Js[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:d,recovery:z(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:i.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function el(e,t,n,o,i){let r=`"${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:hr([t.installCommand,...n]),nextSteps:hr([r,...a]),recovery:z(i)})}function tl(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=he(t?.unknownCommandExamples),r=he(t?.unknownCommandNextSteps),a=ws(o),s=i??["pm --help"],l=r??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!d||!c.has(d))?el(o,a,s,l,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:l,recovery:z(t)})}function nl(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=he(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let i=e?.suggestedRetryCommand;return b({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value: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:[...i?[i]:[],`pm ${B(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:z(e,{allowed_values:o,suggested_retry:i})})}function ol(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=Gs(o);if(!i)return null;let r=Ws(o);return b({code:"linked_test_value_not_quoted",title:`Linked-test ${i} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${i} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${i} 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:[...r?[r]:[],'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:[...r?[`Replay with the value re-joined into one argument: ${r}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:z(n,r?{suggested_retry:r}:{})})}var il=new Set(["comments","docs","files","learnings","notes","test"]);function rl(e,t,n){if(!/too many arguments/i.test(e)||!il.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>c===t),r=o[i+1],a=o[i+2],s=n?.verifiedCollectionItemId?.trim();if(r?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let l=`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:[l,`pm ${t} --help`],recovery:z(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:l})})}var al=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"]),yr=new Set(["context","ctx"]);function sl(e,t,n){if(!/too many arguments/i.test(e)||!yr.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>yr.has(c)),r=i===-1?1:i+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(r)){if(c){c=!1;continue}let m=d.split("=")[0];if(al.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`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 ${l} 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:[l,`pm context --parent ${s}`],recovery:z(n,{suggested_retry:l})})}function $n(e,t,n,o){let i=Rt(e),r=Vs(i,t,n,o)??Bs(i,t,o)??Qs(i,t,o)??tl(i,o)??nl(o)??rl(i,t,o)??ol(i,t,o)??sl(i,t,o);return r||b({code:"invalid_command_usage",title:"Invalid command usage",happened:i,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:z(o)})}function br(e,t){let n=In(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&n.title==="Tracker is not initialized"&&n.recovery?.suggested_retry_args?[`Error: ${n.title}`,`Run: ${k(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
7
- `):on(_r(n),n.required).output}function Cr(e,t){return Rn(In(e,t))}function Nn(e,t,n){return Tn(In(e,n),t)}function xr(e,t,n,o){let i=$n(e,t,n,o);return on(_r(i),i.required).output}function Dn(e,t,n,o){return Rn($n(e,t,n,o))}function It(e,t,n,o,i){return Tn($n(e,t,n,i),o)}function kr(e,t){let n=Er(e);return Tn(n,t)}function Er(e){let t=Rt(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 Sr(e){return Rn(Er(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="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]="667ad638-d21d-5a49-a00e-1335cb3f10be")}catch{}})();var Be=Go.join("|"),ll={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"},cl={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"]}},Ar=["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 dl(e,t){let n=cl[e];if(!n)return[];let o=H(t);for(let[i,r]of Object.entries(n))if(H(i)===o)return r;return[]}function Mn(e,t,n){if(n.length===0)return e;if(t){let a=n.find(d=>d.declared_command_match===!0),{token_accounting:s,...l}=JSON.parse(e),c={...l,...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?c:ce(c,d=>`${JSON.stringify(d,null,2)}
8
- `),null,2)}let o=n.map(a=>`- ${a.layer}:${a.name}: ${a.error}`).join(`
9
- `),i=n.find(a=>a.declared_command_match===!0);if(!i)return`${e}
3
+ `)}function ci(e,t){return t==="detailed"?ss(e):rs(e)}function M(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var ls={cal:"calendar",ctx:"context"};function cs(e,t){return e.commands.find(n=>n.name()===t)??null}function ds(e,t){let n=e;for(let o of t){let a=cs(n,o);if(!a)return null;n=a}return n}function bn(e,t,n,o){let a=ds(e,t.split(" ").filter(i=>i.length>0));a&&a.addHelpText("after",ci(n,o))}function Cn(e){return e.includes("--explain")?"detailed":"compact"}function oe(e){return e.includes("--all")||e.includes("--explain")}var fe={ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},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?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",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 "Done" --release-assignment --validate-close warn','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 --start",'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 --pause"]},"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."]}};for(let{alias:e,canonical:t}of I){let n=fe[e];n&&(fe[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ee={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."]},di=B.filter(e=>e.lifecycle==="deprecated");for(let e of di){let t=fe[e.alias];fe[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ee,...Object.values(fe)])e.examples=e.examples.map(t=>{for(let n of di){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function ms(e){let t=M(e??"");return t?ls[t]??t:""}function xn(e){let t=ms(e);return t?fe[t]??Ee:Ee}function mi(e,t){let n=xn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:li(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function ps(){let e=B.filter(({lifecycle:n})=>n==="permanent"),t=B.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(" ")} (${qo(n)})`)].join(`
4
+ `)}function us(e,t,n,o){let a=new Set(Wa);e.configureHelp({visibleCommands(i){let r=t.visibleCommands(i);return n?r.filter(s=>(ue(s)??Y(s.name()))!=="internal"):i!==e?r:r.filter(s=>o.has(s))},visibleOptions(i){let r=t.visibleOptions(i);return i!==e||n?r:r.filter(s=>a.has(s.flags))}})}function fs(e,t,n,o){let a=new Set(Ba("core")),i=e.createHelp();i.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let r=()=>`${i.formatHelp(e,i)}${o}
5
+ `,s=t.visibleCommands(e);for(let l of s)ue(l)===void 0&&(l.name()==="help"||a.has(l.name()))&&n.add(l);for(let l of s)ue(l)==="core"&&(n.add(l),Va(r()).within_budget||n.delete(l))}function pi(e,t=process.argv.slice(2)){let n=e.createHelp(),o=oe(t),a=new Set;us(e,n,o,a);let i=Cn(t),r=ci(Ee,i);e.addHelpText("after",r),o&&e.addHelpText("after",ps()),fs(e,n,a,r);for(let[d,m]of Object.entries(fe))bn(e,d,m,i);let s=M(S(t).commandPathTokens.join(" ")),l=qe(s);if(l){bn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,vt(l.accepted_flags)]},i);return}let c=_t.filter(({parent:d})=>d===s);c.length>0&&bn(e,s,{why:`Dispatches one declared positional action: ${c.map(({action:d})=>d).join("|")}.`,examples:c.map(({example:d})=>d),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]="2efeb172-b440-5df6-ad48-4c54087835e0")}catch{}})();function kn(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:a}of I){if(t&&!I.some(c=>c.canonical.startsWith(`${o} `)))continue;let i=e.commands.findIndex(c=>c.name()===n);if(i<0)continue;let r=e.commands[i],s=e;for(let c of a.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===c)??s.command(c).description(`Discover ${c} operations.`);let l=a[a.length-1];if(s.commands.some(c=>c.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(i,1),r.name(l),St(r,Y(o)),s.enablePositionalOptions(),s.addCommand(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]="aaa2e9cf-ebf8-5776-a04e-4ea18e7489ee")}catch{}})();function Tt(e){let{why:t,title:n,...o}=e;return o}var gs=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function hs(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!gs.has(e.code)}function yi(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:yi(e.code)}}var Se={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},ui={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},fi={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},At={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},ys={guide:Se,shell:Se,completion:Se,"completion-statuses":Se,"completion-tags":Se,"completion-types":Se,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:ui,cal:ui,reindex:fi,"search-advanced":fi,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":At,"dedupe-audit":At,"dedupe-merge":At,normalize:At};function ws(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return ys[t]}function En(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function _s(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 vs(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 Sn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Z(e,t,n){if(t==="parsed_positionals"){if(!Array.isArray(n))return;let a=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);a.length>0&&(e.parsed_positionals=a);return}let o=_s(n);o&&(e[t]=o)}function Ae(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Sn(t,"attempted_command",e.attempted_command),Z(t,"normalized_args",e.normalized_args),Z(t,"parsed_positionals",e.parsed_positionals),Z(t,"provided_fields",e.provided_fields),Z(t,"missing",e.missing),Z(t,"missing_required_fields",e.missing_required_fields),Z(t,"suggested_flags",e.suggested_flags),Z(t,"allowed_values",e.allowed_values),Z(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),Sn(t,"suggested_retry",e.suggested_retry),Z(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=vs(e.fallback_candidates);return n&&(t.fallback_candidates=n),Sn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function An(e,t,n){n&&e.push(` ${t}: ${n}`)}function ge(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function bs(e){let t=Ae(e);if(!t)return[];let n=["Recovery bundle:"];if(An(n,"suggested_retry",t.suggested_retry),An(n,"attempted_command",t.attempted_command),ge(n,"normalized_args",t.attempted_command?void 0: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(ge(n,"provided_fields",t.provided_fields,", "),ge(n,"missing",t.missing,", "),ge(n,"missing_required_fields",t.missing_required_fields,", "),ge(n,"suggested_flags",t.suggested_flags,", "),ge(n,"allowed_values",t.allowed_values,", "),ge(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}`),An(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 wi(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...En("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(...En("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...En("Verification errors:",e.verificationErrors)));let n=bs(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
6
+ `)}function _i(e,t){return t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),hs(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 Cs(e,t){if(e.flag)return e.flag;let n=o=>{let a=o.split("=",1)[0];return D([a]).length>0&&!["--help","--no-changed-fields","--version"].includes(a)&&t.some(i=>i===a||i.startsWith(`${a}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(o=>o[0]).find(o=>n(o))}function xs(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(i=>i===n||i.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let a=t.indexOf(n);return t[a+1]}}function ks(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=D(e.recovery?.normalized_args??[]),o=W(n),a=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,i=Cs(e,a),r=xs(e,a,i);return{surface:i??e.recovery?.missing?.[0]??wn(a)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Es(e,t){return _i({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:ks(e,t)},e)}function Tn(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 ma(Es(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function Rn(e){return _i({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function Rt(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 he(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 gi(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function As(e){return wn(e?.normalized_args)}function Os(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 Ts(e,t){let n=e?.normalized_args,o=e?.provided_fields,a=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!a))for(let i of o){let r=n.findIndex(s=>s===i);if(r>=0&&r<n.length-1&&!n[r+1]?.startsWith("-")){let s=[...n];return s[r+1]=a,k(s)}}}function Rs(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function Ot(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Is(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function ae(e,t,n){if(!n)return e;let o=Rt(t),a=Ot(n.code,e.code),i=Ot(n.type,yi(a)),r=he(n.examples)??e.examples,s=he(n.nextSteps)??e.nextSteps,l=he(n.verification_errors)??e.verificationErrors,c=e.code==="command_failed"&&n.code?Rs(o):void 0,d=Ae(n.recovery),m=d&&e.recovery?Ae({...e.recovery,...d}):d??e.recovery;return{...e,code:a,type:i,title:c??e.title,happened:o.length>0?o:e.happened,required:Ot(n.required,e.required),why:Ot(n.why,e.why),examples:r,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Is(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function $s(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 a=o[1],i=Vo(process.cwd(),a);return ae(C(i?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${a}, 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 a=o[1],i=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(a),r=i?`The item ID "${a}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${a}" exists in the active tracker scope.`;return ae(C({code:"item_not_found",title:"Item ID not found",flag:"id",value:a,happened:r,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 Ns(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ae(C({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 Ds(e,t,n){return t.includes("is locked")?ae(C({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 Ms(e,t,n){let o=t.match(/^Missing required option /),a=t.match(/^Missing required options /);if(!o&&!a)return null;let i=!!a,r=i?null:t.replace(/^Missing required option\s+/,"").trim(),s=r??"",l=r?`Pass ${r} with a valid value before running the command.`:"Provide the required option for this command invocation.";return ae(C({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.":l,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 Fs(e,t,n){return t.startsWith("No update flags provided")?ae(C({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 Ls(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Ae(n?.recovery),a=As(o),i=a?`pm ${a} --help`:"pm <command> --help",r=Os(t),s=Ae({...o,allowed_values:o?.allowed_values??r}),l=Ts(o,r),c=l?[l,i]:[i,"pm contracts --command <command> --flags-only --json"],d=r.length>0?[`Allowed values: ${r.join("|")}`,`Run "${i}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return ae(C({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:c,nextSteps:d,recovery:s}),e,n)}function In(e,t){let n=Rt(e);return($s(e,n,t)??Ps(e,n,t)??Ns(e,n,t)??Ds(e,n,t)??Ms(e,n,t)??Fs(e,n,t)??Ls(e,n,t))||ae(C({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 js(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 Us(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function qs(e){if(!(!Array.isArray(e)||e.length===0))return k(e)}function $n(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 z(e,t={}){let n=$n(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,a=typeof e?.attemptedCommand=="string"?e.attemptedCommand:qs(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return Ae({attempted_command:a,normalized_args:o,provided_fields:n,suggested_retry:i,...t})}function On(e,t){return!t||e.includes(t)?e:[...e,t]}var Hs=new Set(["--add","--add-json","--remove"]),zs=new Set(["command","cmd","path"]);function Gs(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(Hs.has(o))return o}}function Ws(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 a=e[o];if(a!=="--add"&&a!=="--remove")continue;let i=e[o+1];if(typeof i!="string"||!zs.has(i))return;let r=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;r.push(d)}if(r.length<2)return;let s=`${i}=${r.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+r.length)];return k(l)}}function Vs(e,t,n,o){let a=e.match(/required option '([^']+)' not specified/);if(!a)return null;let i=Us(a[1]),r=i.startsWith("--type"),s=o?.suggestedRetryCommand,l=$n(o?.providedOptionFlags),c=[i],d=js(t,i,n),m=s?On(d,s):d,p=r?[`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?On(p,`Replay with preserved arguments: ${s}`):p,g=l&&l.length>0?On(u,`Already provided options: ${l.join(", ")}`):u;return C({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:r?"--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:g,recovery:z(o,{missing:c})})}function Bs(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let a=o[1];return C({code:"missing_required_argument",title:`Missing required argument ${a}`,happened:`Command invocation omitted positional argument ${a}.`,required:`Provide ${a} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:z(n,{missing:[a]})})}function Ks(e,t,n){return C({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:z(t,{suggested_flags:n})})}var Js={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 Ys(e){let t=he(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Xs(e,t,n,o,a){let i=o.otherCommands.slice(0,3),r=o.candidateTotal-i.length,s=r>0?` and ${String(r)} 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,a?`Replay with suggested correction: ${a}`:void 0].filter(l=>typeof l=="string")}function Zs(e,t){if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};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 a=D(n.filter((i,r)=>r!==o));return{retryCommand:k(a),suggestedRetryArgs:a}}function Qs(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let a=n??{},i=o[1],r=$n(a.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=Zs(a,i);if(t==="update"&&(i==="--file"||i==="--doc"))return Ks(i,n,r);let c=Ys(a),d=Xs(i,t,r,c,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(i.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,t?`pm ${V(t)?.canonical??t} --help`:"pm --help --all"].filter(p=>typeof p=="string");return C({code:"unknown_option",title:`Unknown option ${i}`,happened:`Commander does not recognize option ${i} for this command path.`,required:Js[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:d,recovery:z(n,{suggested_flags:r.length>0?r:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:a.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function el(e,t,n,o,a){let i=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,r=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return C({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:gi([t.installCommand,...n]),nextSteps:gi([i,...r]),recovery:z(a)})}function tl(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],a=he(t?.unknownCommandExamples),i=he(t?.unknownCommandNextSteps),r=ws(o),s=a??["pm --help"],l=i??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=r?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return r&&(!d||!c.has(d))?el(o,r,s,l,t):C({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:l,recovery:z(t)})}function nl(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=he(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let a=e?.suggestedRetryCommand;return C({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value: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:[...a?[a]:[],`pm ${V(t)?.canonical??t} --help`],nextSteps:a?[`Retry with the declared hyphenated action: ${a}`]:["Choose one value from recovery.allowed_values."],recovery:z(e,{allowed_values:o,suggested_retry:a})})}function ol(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,a=Gs(o);if(!a)return null;let i=Ws(o);return C({code:"linked_test_value_not_quoted",title:`Linked-test ${a} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${a} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${a} 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:z(n,i?{suggested_retry:i}:{})})}var al=new Set(["comments","docs","files","learnings","notes","test"]);function il(e,t,n){if(!/too many arguments/i.test(e)||!al.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>c===t),i=o[a+1],r=o[a+2],s=n?.verifiedCollectionItemId?.trim();if(i?.toLowerCase()!=="add"||!r||r.startsWith("-")||!s||s.toLowerCase()!==r.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return C({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:[l,`pm ${t} --help`],recovery:z(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:l})})}var rl=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"]),hi=new Set(["context","ctx"]);function sl(e,t,n){if(!/too many arguments/i.test(e)||!hi.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>hi.has(c)),i=a===-1?1:a+1,r=e.match(/got \d+:\s*(\S+)/i),s=r?r[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(i)){if(c){c=!1;continue}let m=d.split("=")[0];if(rl.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`pm get ${s}`;return C({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 ${l} 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:[l,`pm context --parent ${s}`],recovery:z(n,{suggested_retry:l})})}function Pn(e,t,n,o){let a=Rt(e);return(Vs(a,t,n,o)??Bs(a,t,o)??Qs(a,t,o)??tl(a,o)??nl(o)??il(a,t,o)??ol(a,t,o)??sl(a,t,o))||C({code:"invalid_command_usage",title:"Invalid command usage",happened:a,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:z(o)})}function vi(e,t){let n=In(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&n.title==="Tracker is not initialized"&&n.recovery?.suggested_retry_args?[`Error: ${n.title}`,`Run: ${k(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
7
+ `):on(wi(n),n.required).output}function bi(e,t){return Rn(In(e,t))}function Nn(e,t,n){return Tn(In(e,n),t)}function Ci(e,t,n,o){let a=Pn(e,t,n,o);return on(wi(a),a.required).output}function Dn(e,t,n,o){return Rn(Pn(e,t,n,o))}function It(e,t,n,o,a){return Tn(Pn(e,t,n,a),o)}function xi(e,t){let n=ki(e);return Tn(n,t)}function ki(e){let t=Rt(e);return Ss(t)?C({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."]}):C({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 Ei(e){return Rn(ki(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="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]="fff71664-962d-55f6-b21e-dd2c7ca0f419")}catch{}})();var Ke=Go.join("|"),ll={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"},cl={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"]}},Si=["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 dl(e,t){let n=cl[e];if(!n)return[];let o=H(t);for(let[a,i]of Object.entries(n))if(H(a)===o)return i;return[]}function Mn(e,t,n){if(n.length===0)return e;if(t){let r=n.find(d=>d.declared_command_match===!0),{token_accounting:s,...l}=JSON.parse(e),c={...l,...r?{extension_command_failure:{code:"extension_command_activation_failed",extension:r.name,layer:r.layer,error:r.error,recovery_commands:r.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?c:ce(c,d=>`${JSON.stringify(d,null,2)}
8
+ `),null,2)}let o=n.map(r=>`- ${r.layer}:${r.name}: ${r.error}`).join(`
9
+ `),a=n.find(r=>r.declared_command_match===!0);if(!a)return`${e}
10
10
  Extension activation failures:
11
- ${o}`;let r=(i.recovery_commands??[]).map(a=>`- ${a}`).join(`
12
- `);return`Extension command unavailable: ${i.layer}:${i.name}
13
- ${i.error}${r.length>0?`
11
+ ${o}`;let i=(a.recovery_commands??[]).map(r=>`- ${r}`).join(`
12
+ `);return`Extension command unavailable: ${a.layer}:${a.name}
13
+ ${a.error}${i.length>0?`
14
14
  Recovery:
15
- ${r}`:""}
15
+ ${i}`:""}
16
16
 
17
17
  ${e}
18
18
  Extension activation failures:
19
- ${o}`}function Fn(e){return A(e).commandPathTokens[0]??x(e)??"<command>"}function ml(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let r=F(E(i)),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r),o.push(...i.commands)}for(let i of t.keys()){let r=F(i),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r)}return[...n].sort((i,r)=>i.localeCompare(r))}function Or(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" ");if(n===o)return 0;if(i.includes(o))return 1;if(i.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let s of i){let l=tn(s,o,r);l!==null&&(a=Math.min(a,l))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function Tr(e){return H(e).slice(2).replace(/-/g,"")}function Ln(e){return k(e)}function pl(e){let t=B(e)?.canonical??Xt[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=ll[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function Rr(e){let t=Ji(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function ul(e,t){let n=Rr(e);if(n.length===0)return[];let o=[];for(let i of t.values()){let r=new Set,a=i.source;if(a)for(let l of[a.name,a.package]){let c=Rr(l??"");c.length>0&&r.add(c)}if(r.size===0)continue;[...r].some(l=>l===n||l.includes(n)||n.includes(l))&&o.push(i.command)}return[...new Set(o)].sort((i,r)=>i.localeCompare(r))}function Ke(e,t){let n=new Set,o=t??oe(e);for(let i of o){i.flag.startsWith("--")&&n.add(H(i.flag));for(let r of i.aliases??[])r.startsWith("--")&&n.add(H(r))}return[...n].sort((i,r)=>i.localeCompare(r))}function fl(e,t){if(!e.startsWith("--"))return[];let n=Tr(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let r of t){let a=Tr(r);if(a===n)continue;if(n.length>=3&&a.startsWith(n)){i.push({flag:r,rank:0,distance:a.length-n.length});continue}let s=tn(n,a,o);s===null||s<=0||i.push({flag:r,rank:1,distance:s})}return i.sort((r,a)=>r.rank!==a.rank?r.rank-a.rank:r.distance!==a.distance?r.distance-a.distance:r.flag.localeCompare(a.flag)).map(r=>r.flag).slice(0,3)}var Pt,gl=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 hl(){if(Pt)return Pt;let e=new Map;for(let t of gt)if(!gl.has(t))for(let n of Ke(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return Pt=e,Pt}function yl(e,t){if(!e.startsWith("--"))return[];let n=hl().get(H(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(Ke(o));return[...new Set(n.filter(r=>r!==o).map(r=>({command:r,sharedFlagCount:Ke(r).filter(a=>i.has(a)).length})).sort((r,a)=>r.sharedFlagCount!==a.sharedFlagCount?a.sharedFlagCount-r.sharedFlagCount:r.command.localeCompare(a.command)).map(({command:r})=>B(r)?.canonical??r))]}function wl(e,t,n){for(let o=0;o<e.length;o+=1){let i=e[o];if(!i.startsWith("--"))continue;let r=i.indexOf("="),a=r>=0?i.slice(0,r):i;if(H(a)!==H(t))continue;let s=[...e];return s[o]=r>=0?`${n}${i.slice(r)}`:n,s}}function _l(e){let t=new Set(e.commandPaths),n=r=>Math.min(Or(r,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?Or(r,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,i=(r,a)=>{if(!Number.isFinite(a)||!t.has(r))return;let s=o.get(r);(s===void 0||a<s)&&o.set(r,a)};for(let r of e.commandPaths)i(r,n(r));for(let[r,a]of Object.entries(Xt))r!=="read"&&i(a,n(r));return[...o.entries()].sort(([r,a],[s,l])=>a!==l?a-l:r.localeCompare(s)).map(([r])=>r)}function vl(e){let t=B(e.normalizedUnknown),n=nr(e.commandPaths,e.primaryToken),o=_l(e),i=ul(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return _n([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...i],e.commandPaths,e.primaryToken).filter(r=>!e.normalizedUnknown.includes(" ")||r!==e.normalizedUnknown)}function bl(e){return[...new Set(e.map(n=>n.split(" ")[0]).filter(n=>n.length>0))].sort((n,o)=>n.localeCompare(o))}function Cl(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 jn(e,t,n){let o=e.match(/unknown command '([^']+)'/i);if(!o||typeof o[1]!="string")return;let i=F(o[1]);if(i.length===0)return;let r=ml(t,n);if(r.length===0)return;let a=pl(i);if(a&&!r.includes(a.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[a.installCommand,`pm ${a.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${i}" is provided by the "${a.packageAlias}" package. Install it with: ${a.installCommand}. Command after installation: pm ${a.canonicalPath}.`],suggestedRetryCommand:a.installCommand};let s=i.split(" ")[0],l=vl({commandPaths:r,normalizedUnknown:i,primaryToken:s,extensionDescriptors:n}),c=bl(r),d=(l.length>0?l:_n(c,r)).slice(0,3),m=Cl(d,l.length>0),p=l.length>0?`Did you mean: ${d.join(", ")}?`:null;return{unknownCommandExamples:m,unknownCommandNextSteps:[...p?[p]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...p?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function xl(e){return Array.from(new Set(e))}function kl(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
20
- `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function El(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 Sl(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(r=>r.trim().toLowerCase()===n))}function Je(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let r=Sl(n,i);if(!r){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=r}return!0}async function Al(e,t,n,o){try{let i=R(process.cwd(),e.path);if(!await K(J(i)))return{allowedTypes:Be};let r=await D(i),a=e.noExtensions?void 0:se(),s=ae(r,a),l;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let c=n.findIndex(m=>m===o),d=n[c+2];if(n[c+1]?.toLowerCase()==="add"&&d!==void 0&&!d.startsWith("-"))try{l=(await wt(i,d,r.id_prefix,r.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Be,pmRoot:i,settings:r,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:Be}}}function Ol(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?xl([...dl(t,n[1]),...fl(n[1],Ke(t))]):void 0,i=n?yl(n[1],t):[],r=n!==null&&Ke(t).includes(H(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:r?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function Tl(e,t,n){if(!t||!n||n.length===0)return;let o=wl(e,t[1],n[0]);return o?Ln(o):void 0}function Rl(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?El(kl(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=x(t);if(i)return tr(t,i,[o])}function Il(e,t){if(!/too many arguments/i.test(e))return;let n=me(t),o=W(t.slice(n));if(o?.alias!=="schema")return;let i=n+o.canonical_argv.length-1,r=t[i+1]?.trim().toLowerCase(),a=t[i+2]?.trim().toLowerCase();if(!r||!a)return;let s=`${r}-${a}`;if(!Ar.includes(s))return;let l=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${r} ${a}`,unknownSubcommandAllowedValues:[...Ar],suggestedRetryCommand:Ln(l)}}async function Ye(e,t,n,o={}){let r=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=He(process.argv.slice(2)).argv,s=U(a),l=me(a),c=W(a.slice(l))?.alias??x(a),d=Ln(a),m=X(a),p=await Al(s,r,a,c),u=p.allowedTypes,g=jn(r,t,n),h=Ol(r,c),y=Il(r,a),S=y?.suggestedRetryCommand??Tl(a,h.match,h.suggestions)??Rl(r,a);return{message:r,commandName:c,allowedTypes:u,attemptedCommand:d,normalizedInvocationArgs:[...a],providedOptionFlags:m,unknownOptionSuggestions:h.suggestions,unknownOptionOtherCommands:h.otherCommands.length>0?h.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:h.otherCommands.length>0?h.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:h.otherCommands.length>12||void 0,unknownOptionScope:h.scope,suggestedRetryCommand:S,verifiedCollectionItemId:p.verifiedCollectionItemId,...y,...g,...o}}async function Un(e,t,n,o={}){let i=await Ye(e,t,n,o),{message:r,commandName:a,allowedTypes:s,unknownCommandExamples:l,unknownCommandNextSteps:c,attemptedCommand:d,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:y,unknownOptionScope:S,unknownSubcommandPath:O,unknownSubcommandToken:G,unknownSubcommandAllowedValues:j,suggestedRetryCommand:ve,verifiedCollectionItemId:Yt,failedExtensions:ct}=i,De=xr(r,a,s,{unknownCommandExamples:l,unknownCommandNextSteps:c,attemptedCommand:d,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:y,unknownOptionScope:S,unknownSubcommandPath:O,unknownSubcommandToken:G,unknownSubcommandAllowedValues:j,suggestedRetryCommand:ve,verifiedCollectionItemId:Yt,failedExtensions:ct}),be=await di("help_format",{message:De,command:a,allowed_types:s});return be.handled&&typeof be.result=="string"?be.result:De}async function qn(e,t,n,o=!1,i={}){let r=await Ye(e,t,n,i),a=It(r.message,r.commandName,r.allowedTypes,f.USAGE,{unknownCommandExamples:r.unknownCommandExamples,unknownCommandNextSteps:r.unknownCommandNextSteps,attemptedCommand:r.attemptedCommand,normalizedInvocationArgs:r.normalizedInvocationArgs,providedOptionFlags:r.providedOptionFlags,unknownOptionSuggestions:r.unknownOptionSuggestions,unknownOptionOtherCommands:r.unknownOptionOtherCommands,unknownOptionOtherCommandsTotal:r.unknownOptionOtherCommandsTotal,unknownOptionOtherCommandsTruncated:r.unknownOptionOtherCommandsTruncated,unknownOptionScope:r.unknownOptionScope,unknownSubcommandPath:r.unknownSubcommandPath,unknownSubcommandToken:r.unknownSubcommandToken,unknownSubcommandAllowedValues:r.unknownSubcommandAllowedValues,suggestedRetryCommand:r.suggestedRetryCommand,verifiedCollectionItemId:r.verifiedCollectionItemId,failedExtensions:r.failedExtensions}),s=o?Tt(a):a,l=U(r.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?ce(s,c=>`${JSON.stringify(c,null,2)}
21
- `):s,null,2)}(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 Ir(e,t,n,o){if(n)return null;let i=e.some(a=>a==="--for"||a.startsWith("--for=")),r=x(e)==="contracts"&&e.includes("--full");return i||r?await o(t):null}import{Option as Pl}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]="2f731313-580e-5554-bf61-f160121a298b")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function $r(e,t){let n=new Map;for(let o of e){let i=v(o.command);for(let r of t){if(r.layer!==o.layer||r.name!==o.name)continue;let a=v(r.command),s=a.split(" "),l=s.at(-1),c=s.slice(1).join(" "),d=c?`${s[0]}-${l} ${c}`:`${s[0]}-${l}`;if(l&&i===d){n.set(i,a);break}}}return n}function Hn(e,t,n,o){if(!t||!n)return;let i,r=0;for(let[s,l]of e.entries()){if(l!==t)continue;let c=e.slice(s);for(let[d,m]of o.entries()){let p=d.split(" ");p.length>r&&p.every((u,g)=>c[g]===u)&&(i=m,r=p.length)}}let a=i?.flags.find(s=>s.long===n||s.short===n);if(a)return $t(a).takesValue}function $(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function ee(e){return typeof e=="boolean"?e:void 0}function $t(e){let t=$(e.value_type)??$(e.type),n=$(e.value_name),o=t!=="boolean"&&(n!==null||t!==null||ee(e.required)===!0||ee(e.list)===!0);return{takesValue:o,valueName:o?n??"value":null}}function $l(e){if(ee(e.visible)===!1)return null;let n=$(e.long);if(!n||!n.startsWith("--")||n.length<3)return null;let o=$(e.short),i=o&&o.startsWith("-")&&!o.startsWith("--")?`${o}, `:"",r=$(e.value_name),a=r?` <${r}>`:"",s=$(e.description)??"Extension-provided option.",l=[];ee(e.required)===!0&&l.push("required"),ee(e.enabled)===!1&&l.push("disabled");let c=l.length>0?` [${l.join(", ")}]`:"";return`${i}${n}${a} ${s}${c}`}function Nr(e){let t=[...new Set(e.map($l).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
19
+ ${o}`}function Fn(e){return S(e).commandPathTokens[0]??x(e)??"<command>"}function Ri(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let a=o.shift();if(!a)continue;let i=M(E(a)),r=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!r&&n.add(i),o.push(...a.commands)}for(let a of t.keys()){let i=M(a),r=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!r&&n.add(i)}return[...n].sort((a,i)=>a.localeCompare(i))}function Ai(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let a=n.split(" ");if(n===o)return 0;if(a.includes(o))return 1;if(a.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let i=o.length>=5?2:1,r=Number.POSITIVE_INFINITY;for(let s of a){let l=tn(s,o,i);l!==null&&(r=Math.min(r,l))}return Number.isFinite(r)?4+r:Number.POSITIVE_INFINITY}function Oi(e){return H(e).slice(2).replace(/-/g,"")}function Ln(e){return k(e)}function ml(e){let t=V(e)?.canonical??Xt[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=ll[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function Ti(e){let t=Ja(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function pl(e,t){let n=Ti(e);if(n.length===0)return[];let o=[];for(let a of t.values()){let i=new Set,r=a.source;if(r)for(let s of[r.name,r.package]){let l=Ti(s??"");l.length>0&&i.add(l)}i.size!==0&&[...i].some(s=>s===n||s.includes(n)||n.includes(s))&&o.push(a.command)}return[...new Set(o)].sort((a,i)=>a.localeCompare(i))}function Je(e,t){let n=new Set,o=t??ne(e);for(let a of o){a.flag.startsWith("--")&&n.add(H(a.flag));for(let i of a.aliases??[])i.startsWith("--")&&n.add(H(i))}return[...n].sort((a,i)=>a.localeCompare(i))}function ul(e,t){if(!e.startsWith("--"))return[];let n=Oi(e);if(n.length===0)return[];let o=n.length>=8?2:1,a=[];for(let i of t){let r=Oi(i);if(r===n)continue;if(n.length>=3&&r.startsWith(n)){a.push({flag:i,rank:0,distance:r.length-n.length});continue}let s=tn(n,r,o);s===null||s<=0||a.push({flag:i,rank:1,distance:s})}return a.sort((i,r)=>i.rank!==r.rank?i.rank-r.rank:i.distance!==r.distance?i.distance-r.distance:i.flag.localeCompare(r.flag)).map(i=>i.flag).slice(0,3)}var $t,fl=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 gl(){if($t)return $t;let e=new Map;for(let t of Ue)if(!fl.has(t))for(let n of Je(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return $t=e,$t}function hl(e,t){if(!e.startsWith("--"))return[];let n=gl().get(H(e));if(!n)return[];let o=t?.trim().toLowerCase(),a=new Set(Je(o));return[...new Set(n.filter(i=>i!==o).map(i=>({command:i,sharedFlagCount:Je(i).filter(r=>a.has(r)).length})).sort((i,r)=>i.sharedFlagCount!==r.sharedFlagCount?r.sharedFlagCount-i.sharedFlagCount:i.command.localeCompare(r.command)).map(({command:i})=>V(i)?.canonical??i))]}function yl(e,t,n){for(let o=0;o<e.length;o+=1){let a=e[o];if(!a.startsWith("--"))continue;let i=a.indexOf("="),r=i>=0?a.slice(0,i):a;if(H(r)!==H(t))continue;let s=[...e];return s[o]=i>=0?`${n}${a.slice(i)}`:n,s}}function wl(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,a=(i,r)=>{if(!Number.isFinite(r)||!t.has(i))return;let s=o.get(i);(s===void 0||r<s)&&o.set(i,r)};for(let i of e.commandPaths)a(i,n(i));for(let[i,r]of Object.entries(Xt))i!=="read"&&a(r,n(i));return[...o.entries()].sort(([i,r],[s,l])=>r!==l?r-l:i.localeCompare(s)).map(([i])=>i)}function _l(e){let t=V(e.normalizedUnknown),n=ni(e.commandPaths,e.primaryToken),o=wl(e),a=pl(e.primaryToken,e.extensionDescriptors).filter(i=>e.commandPaths.includes(i));return _n([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...a],e.commandPaths,e.primaryToken).filter(i=>!e.normalizedUnknown.includes(" ")||i!==e.normalizedUnknown)}function vl(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function bl(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 jn(e,t,n){let o=e.match(/unknown command '([^']+)'/i);if(!o||typeof o[1]!="string")return;let a=M(o[1]);if(a.length===0)return;let i=Ri(t,n);if(i.length===0)return;let r=ml(a);if(r&&!i.includes(r.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[r.installCommand,`pm ${r.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${a}" is provided by the "${r.packageAlias}" package. Install it with: ${r.installCommand}. Command after installation: pm ${r.canonicalPath}.`],suggestedRetryCommand:r.installCommand};let s=a.split(" ")[0],l=_l({commandPaths:i,normalizedUnknown:a,primaryToken:s,extensionDescriptors:n}),c=vl(i),d=(l.length>0?l:_n(c,i)).slice(0,3),m=bl(d,l.length>0),p=l.length>0?`Did you mean: ${d.join(", ")}?`:null;return{unknownCommandExamples:m,unknownCommandNextSteps:[...p?[p]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...p?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function Cl(e){return Array.from(new Set(e))}function xl(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
20
+ `||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function kl(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 El(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(a=>a.trim().toLowerCase()===n))}function Ye(e,t){if(t.length===0)return!0;let n=e;for(let[o,a]of t.entries()){let i=El(n,a);if(!i){let r=n.registeredArguments;return r.length>0&&(n.commands.length===0||r[0]?.required===!0)&&(r.at(-1)?.variadic===!0||t.length-o<=r.length)}n=i}return!0}async function Sl(e,t,n,o){try{let a=T(process.cwd(),e.path);if(!await K(J(a)))return{allowedTypes:Ke};let i=await N(a),r=e.noExtensions?void 0:se(),s=re(i,r),l;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let c=n.findIndex(m=>m===o),d=n[c+2];if(n[c+1]?.toLowerCase()==="add"&&d!==void 0&&!d.startsWith("-"))try{l=(await wt(a,d,i.id_prefix,i.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Ke,pmRoot:a,settings:i,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:Ke}}}function Al(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?Cl([...dl(t,n[1]),...ul(n[1],Je(t))]):void 0,a=n?hl(n[1],t):[],i=n!==null&&Je(t).includes(H(n[1]));return{match:n,suggestions:o,otherCommands:a,scope:i?"declared_on_path":a.length>0?"declared_elsewhere":"declared_nowhere"}}function Ol(e,t,n){if(!t||!n||n.length===0)return;let o=yl(e,t[1],n[0]);return o?Ln(o):void 0}function Tl(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?kl(xl(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let a=x(t);if(a)return ti(t,a,[o])}function Rl(e,t){if(!/too many arguments/i.test(e))return;let n=me(t),o=W(t.slice(n));if(o?.alias!=="schema")return;let a=n+o.canonical_argv.length-1,i=t[a+1]?.trim().toLowerCase(),r=t[a+2]?.trim().toLowerCase();if(!i||!r)return;let s=`${i}-${r}`;if(!Si.includes(s))return;let l=[...t.slice(0,a+1),s,...t.slice(a+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${i} ${r}`,unknownSubcommandAllowedValues:[...Si],suggestedRetryCommand:Ln(l)}}function Il(e,t,n,o){let a=me(t),i=W(t.slice(a))?.alias??x(t);if(!/unknown option /i.test(e)||i===void 0)return i;let r=V(i)?.canonical??i;return Ue.some(s=>s===i)||Ri(n,o).includes(r)?i:void 0}async function Xe(e,t,n,o={}){let a=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",i=ze(process.argv.slice(2)).argv,r=U(i),s=Il(a,i,t,n),l=Ln(i),c=X(i),d=await Sl(r,a,i,s),m=d.allowedTypes,p=jn(a,t,n),u=Al(a,s),g=Rl(a,i),h=g?.suggestedRetryCommand??Ol(i,u.match,u.suggestions)??Tl(a,i);return{message:a,commandName:s,allowedTypes:m,attemptedCommand:l,normalizedInvocationArgs:[...i],providedOptionFlags:c,unknownOptionSuggestions:u.suggestions,unknownOptionOtherCommands:u.otherCommands.length>0?u.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:u.otherCommands.length>0?u.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:u.otherCommands.length>12||void 0,unknownOptionScope:u.scope,suggestedRetryCommand:h,verifiedCollectionItemId:d.verifiedCollectionItemId,...g,...p,...o}}async function Un(e,t,n,o={}){let a=await Xe(e,t,n,o),{message:i,commandName:r,allowedTypes:s,unknownCommandExamples:l,unknownCommandNextSteps:c,attemptedCommand:d,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:v,unknownOptionScope:A,unknownSubcommandPath:L,unknownSubcommandToken:G,unknownSubcommandAllowedValues:j,suggestedRetryCommand:ve,verifiedCollectionItemId:Yt,failedExtensions:dt}=a,De=Ci(i,r,s,{unknownCommandExamples:l,unknownCommandNextSteps:c,attemptedCommand:d,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:v,unknownOptionScope:A,unknownSubcommandPath:L,unknownSubcommandToken:G,unknownSubcommandAllowedValues:j,suggestedRetryCommand:ve,verifiedCollectionItemId:Yt,failedExtensions:dt}),be=await da("help_format",{message:De,command:r,allowed_types:s});return be.handled&&typeof be.result=="string"?be.result:De}async function qn(e,t,n,o=!1,a={}){let i=await Xe(e,t,n,a),r=It(i.message,i.commandName,i.allowedTypes,f.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?Tt(r):r,l=U(i.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?ce(s,c=>`${JSON.stringify(c,null,2)}
21
+ `):s,null,2)}(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]="e57ce782-5c73-5c74-a929-0971a990a355")}catch{}})();async function Ii(e,t,n,o){if(n)return null;let a=e.some(r=>r==="--for"||r.startsWith("--for=")),i=x(e)==="contracts"&&e.includes("--full");return a||i?await o(t):null}import{Option as $l}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]="1f0aec6a-0db1-5a10-b61f-e3b2eb0d9518")}catch{}})();function _(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Pi(e,t){let n=new Map;for(let o of e){let a=_(o.command);for(let i of t){if(i.layer!==o.layer||i.name!==o.name)continue;let r=_(i.command),s=r.split(" "),l=s.at(-1),c=s.slice(1).join(" "),d=c?`${s[0]}-${l} ${c}`:`${s[0]}-${l}`;if(l&&a===d){n.set(a,r);break}}}return n}function Hn(e,t,n,o){if(!t||!n)return;let a,i=0;for(let[s,l]of e.entries()){if(l!==t)continue;let c=e.slice(s);for(let[d,m]of o.entries()){let p=d.split(" ");p.length>i&&p.every((u,g)=>c[g]===u)&&(a=m,i=p.length)}}let r=a?.flags.find(s=>s.long===n||s.short===n);if(r)return Pt(r).takesValue}function $(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Q(e){return typeof e=="boolean"?e:void 0}function Pt(e){let t=$(e.value_type)??$(e.type),n=$(e.value_name),o=t!=="boolean"&&(n!==null||t!==null||Q(e.required)===!0||Q(e.list)===!0);return{takesValue:o,valueName:o?n??"value":null}}function Pl(e){if(Q(e.visible)===!1)return null;let t=$(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=$(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?`${n}, `:"",a=$(e.value_name),i=a?` <${a}>`:"",r=$(e.description)??"Extension-provided option.",s=[];Q(e.required)===!0&&s.push("required"),Q(e.enabled)===!1&&s.push("disabled");let l=s.length>0?` [${s.join(", ")}]`:"";return`${o}${t}${i} ${r}${l}`}function Ni(e){let t=[...new Set(e.map(Pl).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
22
22
  Extension-provided flags:
23
23
  ${t.join(`
24
- `)}`}function Dr(e){let t=new Map;for(let i of e){let r=v(i.target_command);if(r.length===0)continue;let a=t.get(r)??[];a.push(...i.flags),t.set(r,a)}let n=[...t.entries()].sort(([i],[r])=>i.localeCompare(r)),o=new Map;for(let[i,r]of n){let a=Nr(r);a&&o.set(i,a)}return o}function Mr(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function Pr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let i=o.trim();i.length===0||n.has(i)||(n.add(i),t.push(i))}return t}function Nl(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 Dl(e){let t=new Map;for(let n of e){let o=v(n.command);if(o.length===0)continue;let i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,r=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:Mr(o,n.action),description:i,intent:r,examples:Pr(n.examples),failure_hints:Pr(n.failure_hints),arguments:Nl(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 Ml(e){let t=new Map;for(let n of e){let o=v(n.target_command);if(o.length===0)continue;let i=t.get(o)??[];i.push(...n.flags),t.set(o,i)}return t}function Fl(e,t,n){let o=new Set;for(let i of e){let r=v(i);r.length>0&&o.add(r)}for(let i of t.keys())o.add(i);for(let i of n.keys())o.add(i);return o}function Ll(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Fr(e,t,n,o=new Map){let i=Dl(t),r=Ml(n),a=Fl(e,i,r),s=new Map,l=[...a].sort((c,d)=>c.localeCompare(d));for(let c of l){let d=Ll(c,i,o)??i.get(c),m=r.get(c)??(d?r.get(d.command):void 0)??[];if(d){s.set(c,{...d,command:c,flags:m});continue}s.set(c,{command:c,action:Mr(c,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function jl(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Lr(e,t){for(let n of t.arguments)e.argument(jl(n),n.description??"Extension argument.")}function jr(e){if(ee(e.visible)===!1)return null;let n=$(e.long),o=$(e.short),i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,r=n&&n.startsWith("--")&&n.length>2?n:null,a=[i,r].filter(s=>s!==null);return a.length>0?a:null}function Ul(e){let t=jr(e);if(!t)return null;let{valueName:n}=$t(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function ql(e){let t=jr(e);if(!t)return null;let{valueName:n}=$t(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Ur(e){let t=$(e.description)??"Extension-provided option.",n=[];ee(e.required)===!0&&n.push("required"),ee(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"";return`${t}${o}`}function qr(e,t){let n=$(t.long),o=$(t.short);return e.options.some(i=>{let r=i;return n!==null&&r.long===n||o!==null&&r.short===o})}function zn(e,t){for(let n of t){if(qr(e,n))continue;let o=ql(n);if(!o)continue;let i=Ur(n),r=new Pl(o,i);if(r.negate=!1,n.list!==!0){e.addOption(r);continue}e.addOption(r.argParser((a,s=[])=>[...Array.isArray(s)?s:[s],a]))}}function Gn(e,t){return Nr(t.filter(n=>!qr(e,n)))}function Hl(e){let t=Ul(e);if(!t)return null;let n=$(e.long),o=$(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:a,valueName:s}=$t(e),l=ee(e.required)===!0;return{flags:t,long:i,short:r,description:Ur(e),takes_value:a,value_required:a,value_name:s,variadic:!1,required:l,aliases:[],alias_for:null}}function Hr(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=Hl(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function zr(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(i=>i.flags));for(let i of t)o.has(i.flags)||(o.add(i.flags),n.push(i));return n}function Gr(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:`
24
+ `)}`}function Di(e){let t=new Map;for(let a of e){let i=_(a.target_command);if(i.length===0)continue;let r=t.get(i)??[];r.push(...a.flags),t.set(i,r)}let n=[...t.entries()].sort(([a],[i])=>a.localeCompare(i)),o=new Map;for(let[a,i]of n){let r=Ni(i);r&&o.set(a,r)}return o}function Mi(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function $i(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let a=o.trim();a.length===0||n.has(a)||(n.add(a),t.push(a))}return t}function Nl(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 Dl(e){let t=new Map;for(let n of e){let o=_(n.command);if(o.length===0)continue;let a=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:Mi(o,n.action),description:a,intent:i,examples:$i(n.examples),failure_hints:$i(n.failure_hints),arguments:Nl(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 Ml(e){let t=new Map;for(let n of e){let o=_(n.target_command);if(o.length===0)continue;let a=t.get(o)??[];a.push(...n.flags),t.set(o,a)}return t}function Fl(e,t,n){let o=new Set;for(let a of e){let i=_(a);i.length>0&&o.add(i)}for(let a of t.keys())o.add(a);for(let a of n.keys())o.add(a);return o}function Ll(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Fi(e,t,n,o=new Map){let a=Dl(t),i=Ml(n),r=Fl(e,a,i),s=new Map,l=[...r].sort((c,d)=>c.localeCompare(d));for(let c of l){let d=Ll(c,a,o)??a.get(c),m=i.get(c)??(d?i.get(d.command):void 0)??[];if(d){s.set(c,{...d,command:c,flags:m});continue}s.set(c,{command:c,action:Mi(c,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function jl(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Li(e,t){for(let n of t.arguments)e.argument(jl(n),n.description??"Extension argument.")}function ji(e){if(Q(e.visible)===!1)return null;let t=$(e.long),n=$(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?n:null,a=t&&t.startsWith("--")&&t.length>2?t:null,i=[o,a].filter(r=>r!==null);return i.length>0?i:null}function Ul(e){let t=ji(e);if(!t)return null;let{valueName:n}=Pt(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function ql(e){let t=ji(e);if(!t)return null;let{valueName:n}=Pt(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Ui(e){let t=$(e.description)??"Extension-provided option.",n=[];Q(e.required)===!0&&n.push("required"),Q(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"";return`${t}${o}`}function qi(e,t){let n=$(t.long),o=$(t.short);return e.options.some(a=>{let i=a;return n!==null&&i.long===n||o!==null&&i.short===o})}function zn(e,t){for(let n of t){if(qi(e,n))continue;let o=ql(n);if(!o)continue;let a=Ui(n),i=new $l(o,a);if(i.negate=!1,n.list!==!0){e.addOption(i);continue}e.addOption(i.argParser((r,s=[])=>[...Array.isArray(s)?s:[s],r]))}}function Gn(e,t){return Ni(t.filter(n=>!qi(e,n)))}function Hl(e){let t=Ul(e);if(!t)return null;let n=$(e.long),o=$(e.short),a=n&&n.startsWith("--")&&n.length>2?n:null,i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:r,valueName:s}=Pt(e),l=Q(e.required)===!0;return{flags:t,long:a,short:i,description:Ui(e),takes_value:r,value_required:r,value_name:s,variadic:!1,required:l,aliases:[],alias_for:null}}function Hi(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let a=Hl(o);!a||n.has(a.flags)||(n.add(a.flags),t.push(a))}return t}function zi(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(a=>a.flags));for(let a of t)o.has(a.flags)||(o.add(a.flags),n.push(a));return n}function Gi(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:`
25
25
  Extension command metadata:
26
26
  ${t.join(`
27
- `)}`}function Wn(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 Xe(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Wn(o).includes(n))??null}function te(e,t){let n=e;for(let o of t){let i=Xe(n,o);if(!i)return null;n=i}return n}var Vn=new WeakSet;function Wr(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let i=t[o];o>0&&P.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let r=Xe(n,i);if(r){n=r;continue}let a=n.command(i);Vn.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 zl(e,t){let n=t.join(" "),o=P.find(a=>n===a.canonical||n.startsWith(`${a.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let i=e,r=[];for(let a of t){let s=Xe(i,a);if(!s)return null;r.push(a);let l=s.commands.length>0||P.some(c=>c.canonical.startsWith(`${r.join(" ")} `));if(!Vn.has(s)&&(r.length===t.length||!l))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function Gl(e,t,n,o,i=!1){let r=t.split(" ").filter(d=>d.length>0),a=zl(e,r),s=te(e,r),l=P.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Vn.has(s)));if(!a||a.core_path===t&&s!==null&&!n.has(t)&&!i||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${c}`}function Vr(e,t,n,o,i){return[...new Set([...t,...n.keys()])].filter(r=>r.trim().length>0).sort((r,a)=>r.localeCompare(a)).filter(r=>{let a=Gl(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&te(e,r.split(" "))!==null):!0})}function Br(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]="93ca07c1-857b-57ae-8530-a315a24d0fe5")}catch{}})();var Wl=new Set(["__proto__","prototype","constructor"]),Kr=Symbol("looseOptionOccurrences");function Ze(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,o)=>o.toUpperCase())}function Vl(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 Bn(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(),l=e[t+1];return typeof l=="string"&&!l.startsWith("-")?{consumed:2,key:s,value:l}:{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 i=n.slice(2).trim(),r=e[t+1];return typeof r=="string"&&!r.startsWith("-")?{consumed:2,key:i,value:r}:{consumed:1,key:i,value:!0}}function Nt(e){return Wl.has(e)}function Jr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Jo(t)}function Qe(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=Ze(n.slice(2));i.length>0&&!Nt(i)&&t.push(i)}if(o.startsWith("-")&&!o.startsWith("--")){let i=Ze(o.slice(1));i.length>0&&!Nt(i)&&t.push(i)}return[...new Set(t)]}function Yr(e){let t=new Set;for(let n of e)for(let o of Qe(n))t.add(o);return t}function Bl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Ze(t.slice(2));if(n.length>0&&!Nt(n))return n}return Qe(e)[0]??null}function Kl(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 Kn(e,t,n){if(t.length===0)return;let o=new Set,i=new Map,r=[],a=[];for(let s of t){let l=Qe(s),c=Kl(s);c!==null&&a.push(c);for(let d of l)o.add(d),s.enabled===!1&&i.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&r.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new C(`Unknown option '--${s}' for extension command '${n}'.${c}`,f.USAGE)}let l=i.get(s);if(l)throw new C(`Option '${l}' is disabled for extension command '${n}'.`,f.USAGE)}for(let s of r)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new C(`Missing required option '${s.label}' for extension command '${n}'.`,f.USAGE)}function Jl(e){return typeof e=="string"||e==null?e:String(e)}function Yl(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 Xl(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 Zl={string:Jl,number:Yl,boolean:Xl};function Dt(e,t){return Array.isArray(e)?e.map(n=>Dt(n,t)):Zl[t](e)}function Xr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Yo(e);return t?o.map(i=>Dt(i,t)):o}function Ql(e,t,n,o){return n?Xr(e,t,o):t?Dt(e,t):e}function ec(e,t,n){let o=e[Kr];if(!o||o.length===0)return n;let i=new Set(t);return o.filter(r=>i.has(r.key)).map(r=>r.value)}function Zr(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[i,r]of Object.entries(e))o[i]=r;for(let i of t){let r=Bl(i);if(!r)continue;let a=i.list===!0,s=Qe(i);for(let d of s)if(!(d===r||!Object.hasOwn(o,d))){if(Object.hasOwn(o,r)){if(!a){delete o[d];continue}let m=o[r],p=o[d];o[r]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[d];continue}o[r]=o[d],delete o[d]}let l=Jr(i),c=i.repeatable===!0;if(!Object.hasOwn(o,r)){i.default!==void 0&&(o[r]=Ql(i.default,l,a,c));continue}if(a){o[r]=Xr(ec(n,s,o[r]),l,c);continue}l&&(o[r]=Dt(o[r],l))}return o}function Qr(e){let t=Object.create(null),n=[];Object.defineProperty(t,Kr,{value:n});let o=0;for(;o<e.length;){let i=Bn(e,o);if(!i){o+=1;continue}let r=Ze(i.key);if(r.length===0||Nt(r)){o+=i.consumed;continue}Vl(t,r,i.value),n.push({...i,key:r}),o+=i.consumed}return t}function ea(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Bn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Jn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=Jr(a);for(let l of Qe(a))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let i=[],r=0;for(;r<e.length;){if(e[r]==="--"){i.push(...e.slice(r+1));break}let a=Bn(e,r);if(a){let s=Ze(a.key);if(n.has(s)){let l=e[r],c=o.has(s)&&!l.includes("=")?1:a.consumed;r+=c;continue}}i.push(e[r]),r+=1}return i}import Oe 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 Yn(e,t={},n=[]){let o={readSettings:D,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...t};try{let i=await o.readSettings(e),r=await o.loadExtensions({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(r);return[...r.failed,...a.failed].map(s=>{let l=(r.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(F).filter((p,u,g)=>p.length>0&&g.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(F),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(i){return[{layer:"runtime",name:"extension-loader",error:i instanceof Error?i.message:String(i)}]}}async function ta(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Yn(t,n,o),r={readSettings:D,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if(Oe.resolve(a)===Oe.resolve(t))return i;let[s,l]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[c,d]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(c.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,g)=>u.localeCompare(g));if(p.length===0)return i;i.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Oe.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Oe.resolve(a)} cwd_extension_discovery_root=${d.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 ${Oe.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${Oe.resolve(t)} install <package> --project".`})}catch{}return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6fa59b21-fcd4-5056-ae4c-379d57bb7757")}catch{}})();var na={core:0,standard:1,full:2,internal:3};function oa(e,t,n=!0){let o=t.get(T(e));if(o)return o;if(!n)return;let i=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(i.length===0)return;let r=i.reduce((s,l)=>na[l.tier]<na[s]?l.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function ia(e,t){if(t.length===0)return e;let n=te(e,t);if(n)return n;let o=t.join(" ");if(T(o)!==o||!gt.some(i=>i===o)&&!Oi(o)&&!Ue(o)&&!Je(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=te(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function tc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function ra(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 nc(e){let t=new Map;for(let n of e){let o=n,i=ra(n);if(!i||typeof o.long!="string"||o.long.trim().length===0)continue;let r=t.get(i)??[];r.push(o.long.trim()),t.set(i,r)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(i=>i.trim()).filter(i=>i.length>0))].sort((i,r)=>i.localeCompare(r)));return t}function oc(e){return k(e)}function ic(e){let t=e.options??[],n=nc(t);return t.map(o=>{let i=o,r=typeof i.flags=="string"?i.flags.trim():"",a=typeof i.description=="string"?i.description.trim():"",s=ra(o),c=(s?n.get(s)??[]:[]).filter(y=>y!==i.long).map(y=>y.trim()).filter(y=>y.length>0),d=a.match(/^Alias for ([^ ]+)/i),m=d&&d[1]?d[1].trim():null,p=i.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),u=r.includes("<"),g=u||r.includes("["),h={flags:r,long:typeof i.long=="string"?i.long:null,short:typeof i.short=="string"?i.short:null,description:a,takes_value:g,value_required:u,value_name:tc(r),variadic:i.variadic===!0,required:p,aliases:c,alias_for:m};return i.defaultValue!==void 0&&(h.default_value=i.defaultValue),h})}function rc(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 i=o.alias_for,r=t.get(i);if(!r)continue;let a=o.long,s=new Set([...r.aliases??[],a]);r.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function ac(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(o=>{let i=typeof o.name=="function"?o.name():typeof o.name=="string"?o.name:"argument",r=typeof o.description=="string"&&o.description.trim().length>0?o.description.trim():null;return{name:i.trim(),required:o.required===!0||r?.toLowerCase().startsWith("required;")===!0,variadic:o.variadic===!0,description:r}})}function sc(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(r=>r.name()!=="help"||e.parent===null).filter(r=>!n||(ue(r)??Y(r.name()))!=="internal").map(r=>{let a=F(E(r)),s=a,l=ue(r),c=oa(a,t,l!==void 0),d=V.find(({alias:m})=>m===a);return{name:r.name().trim(),aliases:Wn(r),description:r.description().trim(),tier:c?.tier??l??Y(s),family:c?.family??Ct(s),...d?{alias_for:d.canonical,alias_lifecycle:d.lifecycle,...d.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((r,a)=>r.name.localeCompare(a.name))}function lc(e,t,n){if(!n)return t;let o=n.examples??[],i=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"?i.length>0?[...i]:[...t.tips]:[],detail_mode:e}}function cc(e,t,n,o,i){let r=e!==void 0&&xn(e)===Ee,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:pr(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:lc(n,a,o),intentSource:s}}function dc(e,t){return e===void 0?null:t?.tier??Y(e)}function mc(e,t){return e===void 0?null:t?.family??Ct(e)}function pc(e,t,n){if(!(t!==e||!n))return V.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:ia(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function uc(e,t,n,o,i=new Map,r=!1){if(!e){let s=ac(t),l=sc(t,i,r),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,..._t.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Y(n.split(" ")[0]),family:Ct(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let a=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:c,value_kind:d,polymorphic:m})=>({name:s,required:l,variadic:c,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&a.has(s)||l.some(c=>a.has(c))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:c})=>{let d=c?`${s}...`:s;return l?`<${d}>`:`[${d}]`})].join(" ")}}function fc(e,t,n,o,i){let r=Cn(n),a=ie(n),s=F(E(t)),l=F(o.join(" ")),c=l.length>s.length?l:s,d=Ue(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,g=p?i.get(T(p)):void 0,h=p?oa(p,i,ue(t)!==void 0):void 0,{narrative:y,intentSource:S}=cc(p,t.description().trim(),r,g,d!==void 0),O=rc(zr(ic(t),Hr(g))),G=uc(d,t,m,O,i,a),j=pc(e,t,a);return{format:"pm_help_v1",detail_mode:r,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:dc(u,h),capability_family:mc(u,h),description:d?.description??t.description(),usage:G.usage,intent:d?.description??y.intent,intent_source:S,examples:d?[d.example]:y.examples,tips:d?[vt(d.accepted_flags)]:y.tips,arguments:G.arguments,options:G.options,subcommands:G.subcommands,has_subcommands:G.subcommands.length>0,...j===void 0?{}:{command_aliases:j}}}async function aa(e,t,n,o=t){let i=U(t);if(!i.json)return!1;let r=A(t);if(!r.requested)return!1;let a=ia(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=`unknown command '${T(r.commandPathTokens.join(" "))}'`,l=jn(s,e,n),c=It(s,"help",Be,f.USAGE,{...l,attemptedCommand:oc(t),normalizedInvocationArgs:[...t],providedOptionFlags:X(t)}),d=i.tokenAccounting?ce(c,m=>`${JSON.stringify(m,null,2)}
27
+ `)}`}function Wn(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 Ze(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Wn(o).includes(n))??null}function ee(e,t){let n=e;for(let o of t){let a=Ze(n,o);if(!a)return null;n=a}return n}var Vn=new WeakSet;function Wi(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let a=t[o];o>0&&I.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let i=Ze(n,a);if(i){n=i;continue}let r=n.command(a);Vn.add(r),o<t.length-1?(r.description("Extension-provided command group."),r.action(()=>{r.help()})):r.description("Extension-provided command path."),n=r}return n}function zl(e,t){let n=t.join(" "),o=I.find(r=>n===r.canonical||n.startsWith(`${r.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let a=e,i=[];for(let r of t){let s=Ze(a,r);if(!s)return null;i.push(r);let l=s.commands.length>0||I.some(c=>c.canonical.startsWith(`${i.join(" ")} `));if(!Vn.has(s)&&(i.length===t.length||!l))return{core_path:i.join(" "),extension_path:t.join(" ")};a=s}return null}function Gl(e,t,n,o,a=!1){let i=t.split(" ").filter(d=>d.length>0),r=zl(e,i),s=ee(e,i),l=I.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Vn.has(s)));if(!r||r.core_path===t&&s!==null&&!n.has(t)&&!a||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${r.extension_path}:core_owner=pm-cli:${r.core_path}:extension_owner=${c}`}function Vi(e,t,n,o,a){return[...new Set([...t,...n.keys()])].filter(i=>i.trim().length>0).sort((i,r)=>i.localeCompare(r)).filter(i=>{let r=Gl(e,i,o,n.get(i),t.includes(i));return r?(a(r),!o.has(i)&&ee(e,i.split(" "))!==null):!0})}function Bi(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]="c4cd4b1c-7043-53a0-8823-d47339372420")}catch{}})();var Wl=new Set(["__proto__","prototype","constructor"]),Ki=Symbol("looseOptionOccurrences");function Qe(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function Vl(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 Bn(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(1,r).trim(),value:n.slice(r+1)};let s=n.slice(1).trim(),l=e[t+1];return typeof l=="string"&&!l.startsWith("-")?{consumed:2,key:s,value:l}:{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 a=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:a,value:i}:{consumed:1,key:a,value:!0}}function Nt(e){return Wl.has(e)}function Ji(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Jo(t)}function et(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let a=Qe(n.slice(2));a.length>0&&!Nt(a)&&t.push(a)}if(o.startsWith("-")&&!o.startsWith("--")){let a=Qe(o.slice(1));a.length>0&&!Nt(a)&&t.push(a)}return[...new Set(t)]}function Yi(e){let t=new Set;for(let n of e)for(let o of et(n))t.add(o);return t}function Bl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Qe(t.slice(2));if(n.length>0&&!Nt(n))return n}return et(e)[0]??null}function Kl(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 Kn(e,t,n){if(t.length===0)return;let o=new Set,a=new Map,i=[],r=[];for(let s of t){let l=et(s),c=Kl(s);c!==null&&r.push(c);for(let d of l)o.add(d),s.enabled===!1&&a.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&i.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new b(`Unknown option '--${s}' for extension command '${n}'.${c}`,f.USAGE)}let l=a.get(s);if(l)throw new b(`Option '${l}' is disabled for extension command '${n}'.`,f.USAGE)}for(let s of i)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new b(`Missing required option '${s.label}' for extension command '${n}'.`,f.USAGE)}function Jl(e){return typeof e=="string"||e==null?e:String(e)}function Yl(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 Xl(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 Zl={string:Jl,number:Yl,boolean:Xl};function Dt(e,t){return Array.isArray(e)?e.map(n=>Dt(n,t)):Zl[t](e)}function Xi(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(a=>a!=null&&a!==""):Yo(e);return t?o.map(a=>Dt(a,t)):o}function Ql(e,t,n,o){return n?Xi(e,t,o):t?Dt(e,t):e}function ec(e,t,n){let o=e[Ki];if(!o||o.length===0)return n;let a=new Set(t);return o.filter(i=>a.has(i.key)).map(i=>i.value)}function Zi(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[a,i]of Object.entries(e))o[a]=i;for(let a of t){let i=Bl(a);if(!i)continue;let r=a.list===!0,s=et(a);for(let d of s)if(!(d===i||!Object.hasOwn(o,d))){if(Object.hasOwn(o,i)){if(!r){delete o[d];continue}let m=o[i],p=o[d];o[i]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[d];continue}o[i]=o[d],delete o[d]}let l=Ji(a),c=a.repeatable===!0;if(!Object.hasOwn(o,i)){a.default!==void 0&&(o[i]=Ql(a.default,l,r,c));continue}if(r){o[i]=Xi(ec(n,s,o[i]),l,c);continue}l&&(o[i]=Dt(o[i],l))}return o}function Qi(e){let t=Object.create(null),n=[];Object.defineProperty(t,Ki,{value:n});let o=0;for(;o<e.length;){let a=Bn(e,o);if(!a){o+=1;continue}let i=Qe(a.key);if(i.length===0||Nt(i)){o+=a.consumed;continue}Vl(t,i,a.value),n.push({...a,key:i}),o+=a.consumed}return t}function er(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Bn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Jn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let r of t){let s=Ji(r);for(let l of et(r))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let a=[],i=0;for(;i<e.length;){if(e[i]==="--"){a.push(...e.slice(i+1));break}let r=Bn(e,i);if(r){let s=Qe(r.key);if(n.has(s)){let l=e[i],c=o.has(s)&&!l.includes("=")?1:r.consumed;i+=c;continue}}a.push(e[i]),i+=1}return a}import Oe 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]="4a2291ff-7618-518c-8bff-e9aa0e2f8af2")}catch{}})();async function Yn(e,t={},n=[]){let o={readSettings:N,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...t};try{let a=await o.readSettings(e),i=await o.loadExtensions({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),r=await o.activateExtensions(i);return[...i.failed,...r.failed].map(s=>{let l=(i.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(M).filter((p,u,g)=>p.length>0&&g.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(M),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(a){return[{layer:"runtime",name:"extension-loader",error:a instanceof Error?a.message:String(a)}]}}async function tr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let a=await Yn(t,n,o),i={readSettings:N,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...n};try{let r=i.resolveImplicitPmRoot(process.cwd());if(Oe.resolve(r)===Oe.resolve(t))return a;let[s,l]=await Promise.all([i.readSettings(t),i.readSettings(r)]),[c,d]=await Promise.all([i.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),i.loadExtensions({pmRoot:r,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(c.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,g)=>u.localeCompare(g));if(p.length===0)return a;a.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Oe.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Oe.resolve(r)} cwd_extension_discovery_root=${d.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 ${Oe.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Oe.resolve(t)} install <package> --project".`})}catch{}return a}(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]="6bca8bb8-c8f8-5bf5-bd3a-1e3089571238")}catch{}})();var nr={core:0,standard:1,full:2,internal:3};function or(e,t,n=!0){let o=t.get(O(e));if(o)return o;if(!n)return;let a=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(a.length===0)return;let i=a.reduce((s,l)=>nr[l.tier]<nr[s]?l.tier:s,"internal"),r=new Set(a.map(({family:s})=>s));return{tier:i,family:r.size===1?a[0].family:"extensions"}}function ar(e,t){if(t.length===0)return e;let n=ee(e,t);if(n)return n;let o=t.join(" ");if(O(o)!==o||!Ue.some(a=>a===o)&&!Oa(o)&&!qe(o)&&!Ye(e,t))return null;for(let a=t.length-1;a>0;a-=1){let i=ee(e,t.slice(0,a));if(i)return i}return t.length===1?e:null}function tc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function ir(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 nc(e){let t=new Map;for(let n of e){let o=n,a=ir(n);if(!a||typeof o.long!="string"||o.long.trim().length===0)continue;let i=t.get(a)??[];i.push(o.long.trim()),t.set(a,i)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(a=>a.trim()).filter(a=>a.length>0))].sort((a,i)=>a.localeCompare(i)));return t}function oc(e){return k(e)}function ac(e){let t=e.options??[],n=nc(t);return t.map(o=>{let a=o,i=typeof a.flags=="string"?a.flags.trim():"",r=typeof a.description=="string"?a.description.trim():"",s=ir(o),l=(s?n.get(s)??[]:[]).filter(h=>h!==a.long).map(h=>h.trim()).filter(h=>h.length>0),c=r.match(/^Alias for ([^ ]+)/i),d=c&&c[1]?c[1].trim():null,m=a.mandatory===!0||r.includes("[required]")||r.toLowerCase().includes("required;"),p=i.includes("<"),u=p||i.includes("["),g={flags:i,long:typeof a.long=="string"?a.long:null,short:typeof a.short=="string"?a.short:null,description:r,takes_value:u,value_required:p,value_name:tc(i),variadic:a.variadic===!0,required:m,aliases:l,alias_for:d};return a.defaultValue!==void 0&&(g.default_value=a.defaultValue),g})}function ic(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 a=o.alias_for,i=t.get(a);if(!i)continue;let r=o.long,s=new Set([...i.aliases??[],r]);i.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function rc(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(n=>{let o=typeof n.name=="function"?n.name():typeof n.name=="string"?n.name:"argument",a=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():null;return{name:o.trim(),required:n.required===!0||a?.toLowerCase().startsWith("required;")===!0,variadic:n.variadic===!0,description:a}})}function sc(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(a=>a.name()!=="help"||e.parent===null).filter(a=>!n||(ue(a)??Y(a.name()))!=="internal").map(a=>{let i=M(E(a)),r=i,s=ue(a),l=or(i,t,s!==void 0),c=B.find(({alias:d})=>d===i);return{name:a.name().trim(),aliases:Wn(a),description:a.description().trim(),tier:l?.tier??s??Y(r),family:l?.family??Ct(r),...c?{alias_for:c.canonical,alias_lifecycle:c.lifecycle,...c.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((a,i)=>a.name.localeCompare(i.name))}function lc(e,t,n){if(!n)return t;let o=n.examples??[],a=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"?a.length>0?[...a]:[...t.tips]:[],detail_mode:e}}function cc(e,t,n,o,a){let i=e!==void 0&&xn(e)===Ee,r=i?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:mi(e,n),s=a?"positional_action":o?.intent||o?.description?"extension":i?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:lc(n,r,o),intentSource:s}}function dc(e,t){return e===void 0?null:t?.tier??Y(e)}function mc(e,t){return e===void 0?null:t?.family??Ct(e)}function pc(e,t,n){if(!(t!==e||!n))return B.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:ar(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function uc(e,t,n,o,a=new Map,i=!1){if(!e){let s=rc(t),l=sc(t,a,i),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,..._t.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Y(n.split(" ")[0]),family:Ct(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let r=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:c,value_kind:d,polymorphic:m})=>({name:s,required:l,variadic:c,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&r.has(s)||l.some(c=>r.has(c))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:c})=>{let d=c?`${s}...`:s;return l?`<${d}>`:`[${d}]`})].join(" ")}}function fc(e,t,n,o,a){let i=Cn(n),r=oe(n),s=M(E(t)),l=M(o.join(" ")),c=l.length>s.length?l:s,d=qe(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,g=p?a.get(O(p)):void 0,h=p?or(p,a,ue(t)!==void 0):void 0,{narrative:v,intentSource:A}=cc(p,t.description().trim(),i,g,d!==void 0),L=ic(zi(ac(t),Hi(g))),G=uc(d,t,m,L,a,r),j=pc(e,t,r);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:dc(u,h),capability_family:mc(u,h),description:d?.description??t.description(),usage:G.usage,intent:d?.description??v.intent,intent_source:A,examples:d?[d.example]:v.examples,tips:d?[vt(d.accepted_flags)]:v.tips,arguments:G.arguments,options:G.options,subcommands:G.subcommands,has_subcommands:G.subcommands.length>0,...j===void 0?{}:{command_aliases:j}}}async function rr(e,t,n,o=t){let a=U(t);if(!a.json)return!1;let i=S(t);if(!i.requested)return!1;let r=ar(e,i.commandPathTokens);if(!r){if(!a.quiet){let s=`unknown command '${O(i.commandPathTokens.join(" "))}'`,l=jn(s,e,n),c=It(s,"help",Ke,f.USAGE,{...l,attemptedCommand:oc(t),normalizedInvocationArgs:[...t],providedOptionFlags:X(t)}),d=a.tokenAccounting?ce(c,m=>`${JSON.stringify(m,null,2)}
28
28
  `):c;xe(`${JSON.stringify(d,null,2)}
29
- `)}return process.exitCode=f.USAGE,!0}if(!i.quiet){let s=fc(e,a,t,r.commandPathTokens,n),l=A(o).commandPathTokens;s.requested_path=l;let c=B(l.join(" "));c&&(s.resolved_path=c.canonical),a===e&&!ie(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),_i(`${JSON.stringify(s,null,2)}
29
+ `)}return process.exitCode=f.USAGE,!0}if(!a.quiet){let s=fc(e,r,t,i.commandPathTokens,n),l=S(o).commandPathTokens;s.requested_path=l;let c=V(l.join(" "));c&&(s.resolved_path=c.canonical),r===e&&!oe(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),_a(`${JSON.stringify(s,null,2)}
30
30
  `)}return process.exitCode=f.SUCCESS,!0}function gc(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 hc(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",i=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${i.length>0?i.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function yc(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let i of[...t.required_create_fields,...t.required_create_repeatables])o.add(i);return{progressive:n,strict:o}}function wc(e,t,n,o){let i=new Set(n),r=o.filter(l=>!i.has(l)),a=l=>l.length>0?l.map(c=>Qt("create",c)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(Zi).filter(l=>l!==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 _c(e,t,n){let o=Ri(n);if(!o)return gc(e,t);let i=Wo(o,t);if(!i){let h=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${h}`].join(`
32
- `)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],c=e==="create"&&l?.toLowerCase()==="strict",d=yc(e,i),m=mt(i,e,d.progressive),p=mt(i,e,c?d.strict:d.progressive),u=h=>h.length>0?h.map(y=>Qt(e,y)).join(", "):"none",g=["",`Type-aware option policies for ${i.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=mt(i,e,d.strict);wc(g,i,m.required,h.required)}return hc(g,i),p.errors.length>0&&g.push(` config errors: ${p.errors.join("; ")}`),g.join(`
33
- `)}function sa(e,t,n){let o=x(n);if(o!=="create"&&o!=="update")return;let i=Xe(e,o);i&&i.addHelpText("after",_c(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]="840b471e-c996-57e2-b97c-3a84bd68f050")}catch{}})();function vc(e,t){let n=Me(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function bc(e){return Me(e.status)?.toLowerCase()??"pending"}function Cc(e){return e.mandatory===!0}function xc(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 da(e){let t=[];return e.forEach((n,o)=>{if(!Cc(n.definition))return;let i=bc(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:vc(n.definition,o),status:i})}),t.sort(xc),t}function la(e){return Array.isArray(e)&&e.length>0}var kc=new Set(["create","beads import","todos import"]),Ec=new Set(["restore","update","close","delete","append","claim","release"]),Sc=new Set(["comments","notes","learnings"]),Ac=new Set(["files","docs","test"]),Oc=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 Xn(e,t){let n=t.force===!0;return kc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Ec.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Sc.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Ac.has(e)?{isMutation:la(t.add)||la(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Tc(e,t,n){if(Xn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ji(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>Oc.has(i.trim().toLowerCase())):!1}function ca(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Rc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(Me(t[1])||i.push("source"),Me(n.to)||i.push("--to"),i.length!==0)throw new C(`Schema migration requires ${i.join(", ")}.`,f.USAGE,{code:"schema_migration_input_required",required:i.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function Ic(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||ca(n.status)!==ca(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=ae(i,se()),s=await wt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let l=await Ei(s,{schema:i.schema}),c=typeof n.assignee=="string"?n.assignee.trim():void 0;(c===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(c.toLowerCase())&&c)||_(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Zn(e,t,n,o,i){if(!Tc(e,t,n)||(Rc(e,t,n),!await K(J(i))))return;let r=await ke(i);o.json!==!0&&await Ic(e,t,n,i,r.settings);let a=Li({author:ht(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)_(`warning:${s}`)}function ma(e,t,n){if(n.length===0)return;let o=Xn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new C(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,f.CONFLICT)}async function Qn(e,t,n,o){if(!Xn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(J(n)))return;let{settings:r,metadata:a,warnings:s}=await ke(n);for(let l of s)_(`warning:${l}`);if(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(xi(r),await ki(n,r,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let l=ae(r,se());await Ui(n,r.item_format,"item_format:pre_mutation_sync",l.type_to_folder,r.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]="697f96fe-38a0-5530-b54b-22cb442c130f")}catch{}})();function eo(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 Re(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of eo(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,T(i)]))]}function to(e,t){let n=v(e);if(n.length===0)return!1;let o=Re(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function Ft(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...I(n.commands),...I(n.command_handlers),...I(n.command_overrides),...I(n.flag_commands),...I(n.parser_overrides),...pa(n.preflight_ownership),...pa(n.renderer_ownership)]:[]}function I(e){return e??[]}function pa(e){return I(e).flatMap(t=>t.commands)}function et(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var ua=new Set(["hooks","parser","preflight","renderers"]),fa=new Set(["commands","schema","services","importers"]),Pc=new Set(["reindex","search","search-advanced"]),$c=new Set(["--template"]);function Te(e,t){for(let n of t)if(e.has(n))return!0;return!1}function no(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return Pc.has(n??t)}function oo(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 Lt(e){return v(e.commandPath??"")==="create"&&oo(e,$c)}function io(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Mt(e,t){return e.some(n=>to(n,t))||Lt(t)&&io(e)}function ro(e){return[I(e.hooks).length,(e.preflight_overrides??0)-I(e.preflight_ownership).length,I(e.item_types).length,I(e.item_fields).length,I(e.relationship_kinds).length,I(e.service_overrides).length,I(e.assurance_providers).length,I(e.renderer_overrides).length-I(e.renderer_ownership).length].some(n=>n>0)}function ao(e,t){let n=e.activation?.commands??[];if(n.length>0)return Mt(n,t);let o=Ft(e);if(Mt(o,t)||et(e).has("search")&&no(t.commandPath))return!0;if(e.contributions)return ro(e.contributions)}function jt(e,t){let n=ao(e,t);if(n!==void 0)return n;let o=et(e);return!!(Te(o,ua)||Te(o,fa))}function tt(e,t){return e.effective.length===0?!1:nt(t)!=="all"?e.effective.some(o=>jt(o,t)):e.effective.some(o=>{let i=et(o);return Ft(o).length>0||Te(i,ua)||Te(i,fa)||i.has("search")})}function nt(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Re(e).filter(i=>i.split(" ").every(r=>!r.startsWith("-"))).sort((i,r)=>r.length-i.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Lt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function so(e){return nt(e)==="all"?void 0:t=>jt(t,e)}function Ie(e){let t=A(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=M(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function lo(e){let t=e.args.map(String);if(v(E(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.template.trim().length>0&&t.push("--template")}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b9f5ccc6-1a28-5269-983a-fd6e0d0e1a74")}catch{}})();var Ut=Symbol.for("pm.readOutputInvocationProvenance");function re(e,t){let n=Reflect.get(e,Ut);n!==void 0&&Reflect.set(t,Ut,n)}function co(e,t,n){let o=ui(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(X(r.slice(2))),s=pi.find(d=>d.command===o),l=Object.values(s.dimensions).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,Ut);Reflect.set(n,Ut,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),re(n,e)}function Nc(e){let t=e.optsWithGlobals(),n=E(e);if(T(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of i.options){let a=r.attributeName(),s=i.getOptionValueSource(a)==="cli";if(s&&!e.options.some(l=>l.long===r.long))throw new C(`Unknown option '${r.long}' for ${n}`,f.USAGE,{code:"unknown_option",flag:r.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(a)!=="cli"){let l=i.getOptionValue(a);e.setOptionValueWithSource(a,l,"cli")}a in o?t[a]=o[a]:delete t[a]}return t}function mo(e,t,n,o){co(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=hi(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;re(o,e);let s=gi(t);for(let c of a){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=r.length>0?r.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let c=e;c;c=c.parent)c.setOptionValueWithSource("outputInclude",l,"cli");kt(e,n)}function Pe(e,t,n=[]){let i={...Nc(e)};re(e,i),delete i.json,delete i.quiet,delete i.path,delete i.pmPath,delete i.noExtensions,delete i.extensions,delete i.profile,delete i.pager,delete i.changedFields,delete i.fullChangedFields,delete i.idOnly,delete i.lean,delete i.tokenAccounting,delete i.outputInclude,delete i.outputLimit,delete i.outputBudget,delete i.outputFormat,delete i.outputSession;let r=Qr(t);for(let[a,s]of Object.entries(r))i[a]===void 0&&(i[a]=s);if(n.length>0){let a=Yr(n),s=oe(E(e)).map(d=>({long:d.flag,short:d.short,aliases:d.aliases})),l={...r};for(let d of a)i[d]!==void 0&&(l[d]=i[d]);Kn(l,[...s,...n],E(e));let c=Zr(i,n,r);return re(i,c),c}return i}function qt(e,t){let n=v(t);return n.length===0?[]:e.flags.filter(o=>T(v(o.target_command))===T(n)).flatMap(o=>o.flags)}function ot(e,t,n){let o=qt(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=qt(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Ht(e){return e.arguments??[]}function ga(e){let t=Ht(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function po(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 uo(e,t){let n=Ht(e),o=n.filter(l=>l.required).length,r=n.some(l=>l.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new C(`Missing required argument for extension command '${e.command}'. Usage: ${ga(e)}${s}`,f.USAGE);if(t.length>r){let l=t.slice(r).join(" ");throw new C(`Too many arguments for extension command '${e.command}': ${l}. Usage: ${ga(e)}${s}`,f.USAGE)}}function Dc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Mc(e,t,n){if(n.length>0){Kn(t,n,e.command);return}let o=Object.keys(t).filter(i=>t[i]!==void 0).sort();if(o.length!==0)throw new C(`Unknown option '${o.map(Dc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,f.USAGE)}function fo(e,t,n,o){e&&(uo(e,t),Mc(e,n,o))}import{Command as ha}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]="368c57a5-6fd3-5780-8e38-3d9aea4ac3fd")}catch{}})();var Fc=new Set(["--version","-V"]);function it(e){let t=M(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function ya(e){if(M(e)[0]!=="item"||!e.includes("--dry-run"))return;let n=new ha().configureOutput({writeErr:()=>{}}).exitOverride(),o=new Set;for(let r of qe)for(let a of[r.flag,r.short,...r.aliases??[]]){if(a===void 0||o.has(a))continue;o.add(a);let s=r.value_name!==void 0||r.flag==="--pm-path";n.option(`${a}${s?" <value>":""}`)}try{n.parseOptions(e)}catch{}let i=n.opts();return{path:i.pmPath??i.path}}var Lc=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),go=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"]),wa=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"]),jc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Uc=new Set(["claim","close-task","pause-task","release","start-task","test"]),ye={setup:!0,listQuery:!0,mutation:!0,operation:!0},qc=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 rt(e){return e.some(t=>Fc.has(t))}function Hc(e,t){if(!P.some(o=>o.canonical_argv[0]===t))return;let n=new ha().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Gi(t,oe(t))){let i=o.takes_value?o.value_required?" <value>":" [value]":"";for(let r of[o.flag,o.short,...o.aliases??[]])r!==void 0&&n.option(`${r}${i}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return ye;let i=W([t,...o.operands])?.alias;if(P.some(r=>r.alias===i))return{...ye,targetCommandName:i}}catch{return ye}}function ho(e){if(rt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||A(e).requested)return ye;let t=x(e);if(!t)return ye;let n=t.trim().toLowerCase(),o=M(e),i=W(o)?.alias;if(P.some(a=>a.alias===i))return{...ye,targetCommandName:i};let r=Hc(o,n==="ctx"?"context":n);return r||(Lc.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:go.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:wa.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:jc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ye)}function yo(e){return e.length===0||A(e).requested||e.includes("--explain")&&x(e)===void 0}function wo(e,t){return it(t)||rt(t)?!1:ie(t)||A(t).requested?!0:!!x(t)}function _o(e){if(rt(e))return!1;let t=x(e);return t?qc.has(t):!1}function zc(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),r=i?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${i}${c.slice(d)}`:i:c}):e.argv,a=je(r),s=i&&n>=0?`${o}=[redacted]`:t,l=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:l,sourceDisplay:s}}function vo(e){let t=e.commandName;if(!t)return;let n=e.trace.find(c=>c.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(c=>c.length>0),i=o.length>0?o.join(" "):"the canonical flag",r=wa.has(t)||Uc.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",l=zc({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new C(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,f.USAGE,{code:a,examples:[k(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:k(l.argv)}})}(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]="afcf2608-3360-5030-b5ea-b101df5829e7")}catch{}})();var Gc=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"]),Wc=new Set(["parse","preflight","execute","unknown"]),Vc=new Set(["usage","validation","conflict","runtime","unknown"]);function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function bo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function zt(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 Co(e){if(!e)return;let t=e.trim().toLowerCase();if(Gc.has(t))return t}function xo(e){if(!e)return;let t=e.trim().toLowerCase();if(Wc.has(t))return t}function ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Vc.has(t))return t}function Eo(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(bo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let i=zt(e,"failed");if(typeof i=="number"&&i>0)return`failed_runs:${i}`;let r=e?.run_results;if(Array.isArray(r)){let a=r.filter(s=>Zt(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function So(e,t){if(!e)return t===f.USAGE?"invalid_command_usage":t===f.NOT_FOUND?"item_not_found":t===f.CONFLICT?"lock_conflict":t===f.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Ao(){let e=Zt(le()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=zt(e,"exit_code","exitCode"),o=t??n??f.SUCCESS,i=Ki(o),r=we(e,"error_code","errorCode")??So(i,o),a=ko(we(e,"error_category","errorCategory"))??(i?void 0:dt(r)),s=i?void 0:Eo(e)??`command_exit_${o}`,l=Co(we(e,"command_resolution","commandResolution"))??bt({ok:i,errorCode:r,errorCategory:a}),c=xo(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,command_resolution:l,resolution_stage:c}}(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]="a441a914-7d0e-5ed4-8bb9-8b94c540f0a1")}catch{}})();var Oo="PM_CLI_PACKAGE_ROOT",Ea=Symbol("pm.deprecatedAliasInvocation"),Vt=new Map;for(let e of V){let t=e.alias.split(" ")[0],n=Vt.get(t)??[];n.push(e),Vt.set(t,n)}for(let e of Vt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Bc(){return Ho(import.meta.url,["../.."])}(typeof process.env[Oo]!="string"||process.env[Oo]?.trim().length===0)&&(process.env[Oo]=Bc());var $e=null,L=null;function Kc(e){$e=e}function Jc(e){N=e}var at=null,_e=null,N=new Map,Do=250,Yc=new Set([f.USAGE,f.NOT_FOUND,f.CONFLICT]),Xc=new Set(["1","true","yes","on"]),Zc=We(()=>import("./chunks/register-setup-HM3OCBH2.js")),Qc=We(()=>import("./chunks/register-list-query-QBGXO5JJ.js")),ed=We(()=>import("./chunks/register-mutation-53ZLT4RX.js")),td=We(()=>import("./chunks/register-operations-OBK2FXUU.js"));function Wt(e){return k(e)}function Sa(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=>pe(o)??o))];return n.length>0?n:void 0}function nd(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=X(t),i=new Set(o.map(d=>pe(d)??d)),r=Sa(e),a=t.find(d=>w.commands.some(m=>m.name()===d)),s=a?w.commands.find(d=>d.name()===a):void 0,l=new Set([...w.options,...s?.options??[]].flatMap(d=>d.flags.split(/[ ,|]+/).map(m=>pe(m)).filter(m=>m!==void 0))),c=r?.filter(d=>{let m=pe(d)??d;return i.has(m)?!1:l.has(m)||Hn(t,a,m,N)!==void 0});return c&&c.length>0?c:void 0}function od(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?pe(i):void 0,a=e.find(p=>w.commands.some(u=>u.name()===p)),s=a?w.commands.find(p=>p.name()===a):void 0,l=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,c=Hn(e,a,r,N),d=r?l?.isBoolean()===!0||c===!1?[r]:[r,"<value>"]:[],m=r?Wt([...e,...d]):t;return m===t?void 0:m}function id(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let i=e[o];i!=null&&(n[o]=i)}return n}function rd(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,...id(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Aa(e,t,n){let o=je(t),i=M(o),r=me(i),[a,s]=r===void 0?[]:i.slice(r,r+2),l=o.includes("--explain"),c=rr(o,e?.code,e?.recovery),d=c&&(a==="history-redact"||a==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Wt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Wt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=Wt(o),p=X(o),u=nd(n,o,d),g=od(o,m,u,d),h=rd({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:g,existingRecovery:d});return{...e,recovery:h}}async function lt(e){let t=L;L=null,await ar(t,e);let n=$e;if($e=null,!n){ut();return}let o=[],i=li();try{await sr({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Zo(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:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{ut()}!n.globalOptions.json&&o.length>0&&_(`[pm] warning: afterCommand hook_warnings=${q(o)}`),n.profileEnabled&&o.length>0&&_(`profile:extensions hook_warnings=${q(o)}`)}async function Oa(){await Mi()}function Ta(e){return Xc.has((process.env[e]??"").trim().toLowerCase())}function Ra(e){return Ta("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Yc.has(Math.trunc(e))}async function Bt(e){return Ra(e.exit_code)?(await Oa(),Fi(e),!0):!1}async function Ia(e){let t=de(e.error),n=Sr(t);e.bootstrapGlobal.json?_(JSON.stringify(kr(t,f.GENERIC_FAILURE),null,2)):_(t),process.exitCode=f.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await Oa(),fn(e.error);let r=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:f.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=r.errorCategory,i=r.commandResolution,ze(!1,t,{error_code:n.code,error_category:o,exit_code:f.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||_(`Failed to report error: ${de(r)}`)}try{await lt({ok:!1,error:t,exit_code:f.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||_(`Failed to run error hooks: ${de(r)}`)}try{await Ge()}catch(r){e.bootstrapGlobal.json||_(`Failed to flush error reporting: ${de(r)}`)}}var ad={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"},To=new Map;function Ro(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function Pa(e,t){return e.options.some(n=>n.long===t)}function $a(e,t){return e.options.some(n=>n.short===t)}function Io(e,t,n,o){let i=t.trim();if(!i)return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if($a(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,yn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!Pa(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,yn);return}e.option(`${a} <value>`,r)}}async function Na(e,t){let n=ad[e];if(!n)return[];let o=`${t}:${n}`,i=To.get(o);if(i)return i;if(!await K(J(t)))return To.set(o,[]),[];let r=await D(t),s=(mn(r.schema).command_to_fields.get(n)??[]).flatMap(l=>[l.cli_flag,...l.cli_aliases].map(d=>({long:`--${d}`,type:Ro(l.type),value_type:Ro(l.type)})));return To.set(o,s),s}async function Da(e,t){let n=U(t),o=R(process.cwd(),n.path);if(!await K(J(o)))return;let i=_e?.key===Lo(o)?_e.snapshot:null,r=i===null?await D(o):i.settings,a=mn(r.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let l of s){let c=te(e,l.path.split(" "));if(c)for(let d of a.command_to_fields.get(l.command)??[]){let m=d.description??"";Io(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Io(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Mo(e,t,n,o,i){let r=x(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await D(t),s=ae(a,o);sa(e,s,n)}catch{}}function Po(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Ma(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Fo(e){return e.some(t=>t==="--profile")}function Lo(e){return`pm-root:${e}`}function $o(e){for(let t of e)t.startsWith("settings_read_")&&_(`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function Fa(e,t){e.profile&&(_(`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&&_(`profile:extensions activation_warnings=${q(t.activationWarnings)}`))}function Kt(e,t,n){if(!e)return;let o=v(n.commandPath??"")||"<none>";_(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Jt(e,t=ke){let n=Lo(e);if(_e?.key===n)return _e.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await Qo({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return _e={key:n,snapshot:s},s}catch{return _e={key:n,snapshot:null},null}}async function Ne(e,t,n=D){let o=t?nt(t):"all",i=Ma(e,o);if(at?.key===i)return at.snapshot;try{let r=await n(e),a=await Fe({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?so(t):void 0}),s=await Le({...a,loaded:a.loaded}),l=[...new Set(s.commands.handlers.map(u=>v(u.command)))].filter(u=>u.length>0).sort((u,g)=>u.localeCompare(g)),c=Dr(s.registrations.flags),d=$r(s.commands.handlers,s.registrations.commands),m=Fr(l,s.registrations.commands,s.registrations.flags,d),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:r,commandHandlers:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:u,module:g})=>({name:u,module:g}))};return at={key:i,snapshot:p},p}catch{return at={key:i,snapshot:null},null}}async function La(e){let t=Ve(e);if(t.noExtensions){let a=R(process.cwd(),t.path);return await K(J(a))&&$o((await ke(a)).warnings),null}let n=R(process.cwd(),t.path),o=await Jt(n);if(!o)return null;$o(o.settingsReadWarnings);let i={commandPath:E(e),commandArgs:lo(e)};if(!tt(o.discovery,i))return Kt(t.profile,o,i),null;let r=await Ne(n,i);return r?(Fa(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function ja(e){let t=await Ne(e);return t?new Map(t.commandDescriptors):N}async function Ua(e,t){return(await Ai({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 qa(e,t,n){let o=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return Si(e,er.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function Ha(e,t,n,o=[]){let i=E(e),r=Jn(e.args.map(String),o),a={...t},s={...n},l=R(process.cwd(),n.path),c=await ft({command:i,args:r,options:a,global:s,pm_root:l});n.profile&&c.warnings.length>0&&_(`profile:extensions parser_warnings=${q(c.warnings)}`),r=c.context.args,a=c.context.options,s=c.context.global,fo(N.get(v(i)),r,a,o),Ce(void 0),pt({command:i,args:r,options:{...a},global:{...s},pm_root:l});let d=await nn({command:i,args:r,options:a,global:s,pm_root:l,sdk:qa(l,s,i)});if(s.profile&&d.warnings.length>0&&_(`profile:extensions command_handler_warnings=${q(d.warnings)}`),!d.handled){if(d.warnings.length>0){let m=d.warnings[0],p=d.errorMessage?.trim(),u=p?` ${p}`:"";throw new C(`Command "${i}" failed in extension handler (${m}).${u}`,f.GENERIC_FAILURE,{code:d.errorCode??"command_failed",nextSteps:d.remediation?[d.remediation]:void 0})}throw new C(`Command "${i}" is provided by extensions and is not currently available.`,f.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),Ce(d.result),d.result}var _a=Symbol("pm.wrappedActionHandler");function sd(e,t){let n=e[e.length-1];return n instanceof No?n:t}function va(e,t,n){e&&n.length>0&&_(`profile:extensions ${t}=${q(n)}`)}function ld(e){let t=N.get(v(e.commandPath));if(!t||!po(e.activeRegistrations,e.commandPath))return;let n=Ht(t).length===0?ea(e.commandArgs):Jn(e.commandArgs,e.extensionFlagDefinitions);uo(t,n)}function cd(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 za(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[_a]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let s=sd(a,n),l=Date.now();hn(s);let c=Ve(s),d=T(E(s));if(["package inventory","packages inventory","extension inventory"].includes(d))return await i.apply(this,a);let m=R(process.cwd(),c.path),p=s.args.map(String),u=se(),g=u?ot(u,d,p):[],h=await Na(d,m),y=Pe(s,p,[...g,...h]),S=await ft({command:d,args:p,options:y,global:c,pm_root:m});va(c.profile,"parser_warnings",S.warnings),p=S.context.args,y=S.context.options,re(s,y),c=S.context.global,ld({activeRegistrations:u,commandPath:d,commandArgs:p,extensionFlagDefinitions:g}),c=await Yi(c),kt(s,c),cd(s,a,p),xt(s,y),Ce(void 0),pt({command:d,args:p,options:{...y},global:{...c},pm_root:m});let O=await nn({command:d,args:p,options:y,global:c,pm_root:m,sdk:qa(m,c,d)});if(va(c.profile,"command_handler_warnings",O.warnings),O.handled){Ce(O.result),rn(O.result,{...c,command:d,commandArgs:p,commandOptions:y,pmRoot:m}),c.profile&&_(`profile:command=${d} took_ms=${Date.now()-l}`);return}return await i.apply(this,a)},o[_a]=!0}for(let i of n.commands)t(i)};t(e)}async function Gt(e){N=new Map,ne({overrides:[]}),e&&await Mo(e.rootProgram,e.pmRoot,e.invocationArgv,Ko(),e.settings)}function dd(e,t,n,o){if(t?.flags&&t.flags.length>0){zn(e,t.flags);let i=Gn(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Ga(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.join(" "),l=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),c=l.length===0?"standard":l.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");St(r,c);for(let d of r.commands)i(d,[...a,d.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function Wa(e,t){let n=U(t),o=R(process.cwd(),n.path);if(n.noExtensions){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await Jt(o),r=Ie(t);if(!i){await Gt();return}if(!tt(i.discovery,r)){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),Kt(Fo(t),i,r);return}let a=await Ne(o,r);if(!a){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}ne(a.services),N=new Map(a.commandDescriptors),await Mo(e,o,t,a.registrations,a.settings);let s=Vr(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>Br(a.activationWarnings,_,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(O=>O.length>0),p=a.commandDescriptors.get(d),u=te(e,m),g=a.commandFlagHelp.get(d),h=p?Gr(p):null;if(u){dd(u,p,g,h);return}let y=Wr(e,m);p?.description&&y.description(p.description);let S=g;p&&(Lr(y,p),p.flags.length>0&&(zn(y,p.flags),S=Gn(y,p.flags)??void 0)),S&&y.addHelpText("after",S),h&&y.addHelpText("after",h),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...O)=>{let G=O[O.length-1],j=G instanceof No?G:y,ve=Ve(j),Yt=Date.now(),ct=ot(a.registrations,d,j.args.map(String)),De=Pe(j,j.args.map(String),ct),be=await Ha(j,De,ve,ct);await Xi(ve,be),rn(be,{...ve,command:d,commandArgs:j.args.map(String),commandOptions:De,pmRoot:o}),ve.profile&&_(`profile:command=${d} took_ms=${Date.now()-Yt}`)})};for(let d of s)c(d);Ga(e,l,a.commandDescriptors)}var st=zo(import.meta.url,["../.."])??"0.0.0",w=an(st);async function ba(e){if(!L)return;let t=Reflect.get(e,Ea);typeof t=="string"&&await Qi(t)}async function Ca(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}function Va(e,t){t&&it(t)||(e.hook("preAction",async(n,o)=>{$e=null,L=null,ut(),hn(o);let i=o.optsWithGlobals(),r=Ve(o),a=T(E(o)),s=o.args.map(String),l=Pe(o,s),c={...r};fi(a,{...l,outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),mo(o,a,c,l),await Ca(o,void 0,()=>qi(a,c));let d=R(process.cwd(),r.path),m=await La(o);if(!m){$e=ei({commandName:a,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),L=await gn({command:a,pm_version:st,args:s,options:l,global:c,pm_root:d}),await ba(e),pn(a,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),un(a),await Qn(a,l,d,Po()),await Zn(a,s,l,c,d);return}ti(m.hooks),ni(m.commands),oi(m.parsers),ii(m.preflight),ne(m.services),ri(m.renderers),ai(m.registrations);let p=ot(m.registrations,a,s);l=Pe(o,s,p),mo(o,a,c,l);let u=await ft({command:a,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&_(`profile:extensions parser_warnings=${q(u.warnings)}`),s=u.context.args,l=u.context.options,re(o,l),c=u.context.global,xt(o,l);let g=await ci({command:a,args:s,options:l,global:c,pm_root:m.pmRoot,decision:Po()});c.profile&&g.warnings.length>0&&_(`profile:extensions preflight_warnings=${q(g.warnings)}`),s=g.context.args,l=g.context.options,re(o,l),c=g.context.global,xt(o,l);let h=g.decision;await Qn(a,l,m.pmRoot,h),await Zn(a,s,l,c,m.pmRoot);let y=h.run_extension_migrations?await Ca(o,[],()=>Ua(m.registrations.migrations,m.pmRoot)):[];c.profile&&y.length>0&&_(`profile:extensions migration_warnings=${q(y)}`);let S=da(m.registrations.migrations);$e={hooks:m.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:S},Ce(void 0),pt({command:a,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),L=await gn({command:a,pm_version:st,args:s,options:l,global:c,pm_root:m.pmRoot}),await ba(e),pn(a,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),un(a);let O=await Xo(m.hooks,{command:a,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&O.length>0&&_(`profile:extensions hook_warnings=${q(O)}`),h.enforce_mandatory_migration_gate&&ma(a,l,S)}),e.hook("postAction",async()=>{let n=Ao();ze(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await lt(n)}))}Va(w);var xa=Symbol("pmCliIdempotentTopLevelRegistration");function Ba(e){let t=e;if(t[xa])return;t[xa]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new No(r):n(o,...i)})}async function md(e,t){if(Ba(e),t.setup){let{registerSetupCommands:n}=await Zc();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Qc(),o=typeof t.targetCommandName=="string"&&go.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await ed();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await td();n(e)}}function pd(e){return async t=>{let n=dt(t.errorCode),o=bt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await zi({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:st,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 Ka(e){if(e.bootstrapGlobal.noExtensions||it(e.invocationArgv))return;let t=Ie(e.invocationArgv),n=await Jt(e.bootstrapPmRoot);if(n&&tt(n.discovery,t)){let o=await Ne(e.bootstrapPmRoot,t);Ja(o);return}n&&Kt(Fo(e.invocationArgv),n,t),ne({overrides:[]})}function Ja(e){if(!e){ne({overrides:[]});return}ne(e.services)}async function jo(e){ze(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await lt({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 Ya(){ze(!0,void 0,{exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await lt({ok:!0,exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=f.SUCCESS}async function Xa(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof C)&&(cn(e.error)||!n))return!1;let o=de(e.error),i=e.error instanceof C?e.error.exitCode:ln(t),r=e.error instanceof C?e.error.context:void 0,a=Aa(r,e.invocationArgv,o),s=Cr(o,a),l=e.bootstrapGlobal.lean?Tt(Nn(o,i,a)):Nn(o,i,a),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?ce(l,u=>`${JSON.stringify(u,null,2)}
34
- `):l,null,2):br(o,a);e.jsonErrors?xe(`${c}
35
- `):_(c);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:i,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Bt({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:i,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:L?.source_context});return await jo({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(fn(dn(e.error,o)),await Ge(Do)),process.exitCode=i,!0}async function Za(e,t){let n=T(A(e.invocationArgv).commandPathTokens.join(" "))||Fn(e.invocationArgv),o=`unknown command '${n}'`,i=R(process.cwd(),e.bootstrapGlobal.path),r=await ja(i),a=Ie(e.invocationArgv),s=await Yn(i,{},Re(a)),l=await Ye({message:o},w,r,{failedExtensions:s}),c=Dn(l.message,l.commandName,l.allowedTypes,{unknownCommandExamples:l.unknownCommandExamples,unknownCommandNextSteps:l.unknownCommandNextSteps,attemptedCommand:l.attemptedCommand,normalizedInvocationArgs:l.normalizedInvocationArgs,providedOptionFlags:l.providedOptionFlags,unknownOptionSuggestions:l.unknownOptionSuggestions,suggestedRetryCommand:l.suggestedRetryCommand,failedExtensions:s}),{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:n,errorCode:c.code,errorMessage:c.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),p=await Bt({command:n,error_code:c.code,error_category:d,exit_code:f.USAGE,error_message:c.detail,command_resolution:m,resolution_stage:"parse"}),u=e.jsonErrors?await qn({message:o},w,r,e.bootstrapGlobal.lean===!0,{failedExtensions:s}):await Un({message:o},w,r,{failedExtensions:s}),g=Mn(u,e.jsonErrors,s);await jo({errorMessage:o,exitCode:f.USAGE,classificationCode:c.code,errorCategory:d,commandResolution:m,resolutionStage:"parse"}),e.jsonErrors?xe(`${g}
36
- `):_(g),p&&await Ge(Do),process.exitCode=f.USAGE}async function Qa(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let i=A(e.invocationArgv);return i.requested&&!Je(w,i.commandPathTokens)?(await Za(e,t),!0):(await Ya(),!0)}async function es(e,t){let n=await Ye(e.error,w,N),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:i,commandResolution:r}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await Bt({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:f.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:L?.source_context}),s=e.jsonErrors?await qn(e.error,w,N,e.bootstrapGlobal.lean===!0):await Un(e.error,w,N),l=await ta(o.code,e.bootstrapPmRoot,{},Re(Ie(e.invocationArgv))),c=Mn(s,e.jsonErrors,l);await jo({errorMessage:n.message,exitCode:f.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?xe(`${c}
37
- `):_(c),a&&await Ge(Do),process.exitCode=f.USAGE}function ts(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 ns(e){let t=e.error.code,n=String(e.error.message??"");if(!await Qa(e,t,n)){if(t==="commander.version"){await Ya();return}await es(e,t)}}async function Uo(e){let t=U(e.invocationArgv),n=R(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:x(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:pd({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Ka({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await Xa(o,sn(e.error))){if(ts(e.error)){await ns(o);return}await Ia({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function ud(e,t,n){let o=n.requested?n.commandPathTokens:M(t),i=W(o);if(i&&!te(e,[...i.canonical_argv]))throw new ka(f.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function fd(e,t){let n=me(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let a=me(t.slice(n+1));if(a===void 0)return;n+=a+1}let o=Vt.get(t[n]),i=t.slice(n).filter(a=>!["--global","--project","--local"].includes(a)),r=o?.find(a=>a.alias.split(" ").every((s,l)=>i[l]===s));r?.lifecycle==="deprecated"&&Reflect.set(e,Ea,r.alias)}async function gd(e,t){w=an(st),w.hook("preAction",(r,a)=>{t.configurationOnly=["item mutate","item complete"].includes(E(a))&&a.optsWithGlobals().dryRun===!0}),Va(w,e),at=null,_e=null,N=new Map,si();let n=[...e],o,i;try{let r=He(e);n=r.argv,fd(w,e);let a=[process.argv[0],process.argv[1],...n],s=n.length===0,l=U(n);if(l.authorMissingValue)throw new C("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Ni(l.author),vo(r),i=Ti(n);let c=ho(n);await md(w,c),kn(w,!0),wo(w,n)?await Wa(w,n):(N=new Map,ne({overrides:[]})),_o(n)&&await Da(w,n),kn(w);let m=A(n);if(ud(w,n,m),yo(n)&&ur(w,n),za(w),await aa(w,n,N,e))return;if(m.requested&&!Je(w,m.commandPathTokens))throw new ka(f.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||ie(n)&&x(n)===void 0){w.outputHelp();return}if(it(n)){await w.parseAsync(a);return}let u=R(process.cwd(),l.path),g=await D(u),h=await Ir(n,u,l.noExtensions,Ne);await vi({pmRoot:u,packages:h?.contextIntentPackages},()=>bi({env:{...process.env,PM_PATH:u},argv:a,cwd:process.cwd()},()=>Ci(g.agent_identity.harness_signals,()=>w.parseAsync(a),{probesEnabled:g.agent_identity?.probes_enabled})))}catch(r){await Uo({error:r,invocationArgv:n})}finally{i?.(),o?.()}}async function jp(e=process.argv.slice(2)){let t=e;try{t=He(e).argv}catch{}let n=ya(t),o={configurationOnly:n!==void 0},i=()=>o.configurationOnly,r=async()=>{try{await Di(process.env,()=>gd(e,o))}catch(a){await Uo({error:a,invocationArgv:[...e]})}};if(n!==void 0){let a=R(process.cwd(),U(t).path),s=R(process.cwd(),n.path),l=Bo(process.cwd());await yt(a,()=>yt(s,()=>yt(l,r,i),i),i)}else await r()}var Up={activationCommandMatchesProbe:to,applyDynamicExtensionRootHelpVisibility:Ga,bootstrapProfileEnabled:Fo,buildBootstrapActivationProbe:Ie,buildPostActionTelemetryOutcome:Ao,buildPmCliRecoveryContext:Aa,buildRuntimeExtensionDiscoverySnapshotCacheKey:Lo,buildRuntimeExtensionActivationScope:nt,buildRuntimeExtensionSnapshotCacheKey:Ma,buildRuntimeExtensionFilterForProbe:so,addRuntimeFieldOption:Io,collectActivationCommandCandidates:Re,collectExtensionFlagDefinitionsForCommand:qt,collectExtensionFlagDefinitionsForInvocation:ot,collectLeadingCommandArgs:eo,collectParsedActivationCommandArgs:lo,collectRuntimeFieldLooseFlagDefinitionsForCommand:Na,commandHasLongOption:Pa,commandHasShortOption:$a,commandPathNeedsSearchExtensions:no,commandPathNeedsTemplateExtensions:Lt,describeUnknownError:de,defaultPreflightDecision:Po,discoveryNeedsActivationForProbe:tt,emitExtensionProfile:Fa,emitExtensionSkippedProfile:Kt,emitSettingsReadWarnings:$o,ensureIdempotentTopLevelCommandRegistration:Ba,enforceExplicitRetryForFlagTypos:vo,envFlagEnabled:Ta,executeRegisteredRuntimeMigrations:Ua,extractCommandScopedOptions:Pe,extensionActivationCommands:Ft,extensionCapabilities:et,extensionNeedsActivationForProbe:jt,extensionProvidesTemplatesRuntime:io,hasAnyCapability:Te,hasGlobalExtensionContributions:ro,handleGenericRunPmCliError:Ia,handleRunPmCliCommanderError:ns,handleRunPmCliError:Uo,handleRunPmCliHelpDisplayError:Qa,handleRunPmCliKnownError:Xa,handleRunPmCliCommanderUsageError:es,handleUnknownHelpCommandError:Za,inferMissingFieldsFromErrorMessage:Sa,inferPostActionErrorCode:So,inferPostActionFailureMessage:Eo,invocationRequestsVersion:rt,isCommanderError:cn,loadRuntimeExtensionCommandDescriptorsForRecovery:ja,loadRuntimeExtensionDiscoverySnapshot:Jt,loadRuntimeExtensionSnapshot:Ne,maybeLoadRuntimeExtensions:La,maybeAttachCreateUpdatePolicyHelpText:Mo,maybeLogHandledCliErrorToSentry:Bt,matchesStaticExtensionCommand:Mt,normalizeTelemetryCommandResolution:Co,normalizeTelemetryErrorCategory:ko,normalizeTelemetryResolutionStage:xo,normalizeThrownExitCode:ln,probeUsesAnyFlag:oo,prepareExtensionServicesForRunPmCliError:Ka,readRecordBoolean:bo,readRecordNumber:zt,readRecordString:we,recordCliReadOutputInvocationProvenance:co,registerDynamicExtensionCommandPaths:Wa,registerRuntimeSchemaFieldFlags:Da,resolveCoreCommandRegistrationSelection:ho,resolveStaticExtensionActivationDecision:ao,resolveUnknownHelpToken:Fn,readThrownExitCode:sn,runAndClearAfterCommandHooks:lt,runRequiredExtensionCommand:Ha,shouldAttachRichHelpTextForInvocation:yo,shouldLogHandledErrorToSentry:Ra,shouldRegisterDynamicExtensionPaths:wo,shouldRegisterRuntimeSchemaFlags:_o,shouldHandleRunPmCliCommanderError:ts,setActiveExtensionHookContextForTest:Kc,setActiveRuntimeExtensionCommandDescriptorsForTest:Jc,setRecoveredExtensionServices:Ja,toLooseFieldDefinitionType:Ro,isImporterOrExporterCommandPath:po,validateDynamicExtensionCommandInvocation:fo,wrapProgramActionsForExtensionHandlers:za,wrapThrownErrorForSentry:dn};export{Up as _testOnly,jp as runPmCli};
31
+ `)}function hc(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)":"",a=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${a.length>0?a.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 a of[...t.required_create_fields,...t.required_create_repeatables])o.add(a);return{progressive:n,strict:o}}function wc(e,t,n,o){let a=new Set(n),i=o.filter(l=>!a.has(l)),r=l=>l.length>0?l.map(c=>Qt("create",c)).join(", "):"none";e.push(` required in strict mode: ${r(i)}`);let s=i.map(Za).filter(l=>l!==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 _c(e,t,n){let o=Ra(n);if(!o)return gc(e,t);let a=Wo(o,t);if(!a){let h=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${h}`].join(`
32
+ `)}let i=n.indexOf("--"),r=i<0?n:n.slice(0,i),s=r.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:r[s]?.startsWith("--create-mode=")?r[s]?.slice(14):r[s+1],c=e==="create"&&l?.toLowerCase()==="strict",d=yc(e,a),m=pt(a,e,d.progressive),p=pt(a,e,c?d.strict:d.progressive),u=h=>h.length>0?h.map(v=>Qt(e,v)).join(", "):"none",g=["",`Type-aware option policies for ${a.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=pt(a,e,d.strict);wc(g,a,m.required,h.required)}return hc(g,a),p.errors.length>0&&g.push(` config errors: ${p.errors.join("; ")}`),g.join(`
33
+ `)}function sr(e,t,n){let o=x(n);if(o!=="create"&&o!=="update")return;let a=Ze(e,o);a&&a.addHelpText("after",_c(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]="714821f9-dd8f-5958-a751-29e8dfc06471")}catch{}})();function vc(e,t){return Me(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function bc(e){return Me(e.status)?.toLowerCase()??"pending"}function Cc(e){return e.mandatory===!0}function xc(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 dr(e){let t=[];return e.forEach((n,o)=>{if(!Cc(n.definition))return;let a=bc(n.definition);a!=="applied"&&t.push({layer:n.layer,name:n.name,id:vc(n.definition,o),status:a})}),t.sort(xc),t}function lr(e){return Array.isArray(e)&&e.length>0}var kc=new Set(["create","beads import","todos import"]),Ec=new Set(["restore","update","close","delete","append","claim","release"]),Sc=new Set(["comments","notes","learnings"]),Ac=new Set(["files","docs","test"]),Oc=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 Xn(e,t){let n=t.force===!0;return kc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Ec.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Sc.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Ac.has(e)?{isMutation:lr(t.add)||lr(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Tc(e,t,n){if(Xn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ja(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(a=>Oc.has(a.trim().toLowerCase())):!1}function cr(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Rc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let a=[];if(Me(t[1])||a.push("source"),Me(n.to)||a.push("--to"),a.length!==0)throw new b(`Schema migration requires ${a.join(", ")}.`,f.USAGE,{code:"schema_migration_input_required",required:a.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:a,suggested_flags:a.filter(i=>i.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function Ic(e,t,n,o,a){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||cr(n.status)!==cr(a.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let r=re(a,se()),s=await wt(o,i,a.id_prefix,a.item_format,r.type_to_folder);if(!s)return;let l=await Ea(s,{schema:a.schema}),c=typeof n.assignee=="string"?n.assignee.trim():void 0;(c===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(c.toLowerCase())&&c)||w(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Zn(e,t,n,o,a){if(!Tc(e,t,n)||(Rc(e,t,n),!await K(J(a))))return;let i=await ke(a);o.json!==!0&&await Ic(e,t,n,a,i.settings);let r=La({author:ht(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 r.warnings)w(`warning:${s}`)}function mr(e,t,n){if(n.length===0)return;let o=Xn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let a=n.map(r=>`extension_migration_blocking:${r.layer}:${r.name}:${r.id}:${r.status}`),i=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new b(`Write command "${e}" blocked by unresolved mandatory extension migrations (${a.join(",")}). ${i}`,f.CONFLICT)}async function Qn(e,t,n,o){if(!Xn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(J(n)))return;let{settings:a,metadata:i,warnings:r}=await ke(n);for(let s of r)w(`warning:${s}`);if(o.enforce_item_format_gate&&!i.has_explicit_item_format&&(xa(a),await ka(n,a,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let s=re(a,se());await Ua(n,a.item_format,"item_format:pre_mutation_sync",s.type_to_folder,a.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]="c0826cb1-5181-51b3-9ad9-0cd7a3d2c4b3")}catch{}})();function eo(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=_(n);o.length!==0&&t.push(o)}return t}function Re(e){let t=_(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(a=>a.length>0);for(let a of eo(e.commandArgs))o.push(...a.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(a=>[a,O(a)]))]}function to(e,t){let n=_(e);if(n.length===0)return!1;let o=Re(t);for(let a of o)if(a===n||a.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(a=>n.startsWith(`${a} `)):!1}function Ft(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...R(n.commands),...R(n.command_handlers),...R(n.command_overrides),...R(n.flag_commands),...R(n.parser_overrides),...pr(n.preflight_ownership),...pr(n.renderer_ownership)]:[]}function R(e){return e??[]}function pr(e){return R(e).flatMap(t=>t.commands)}function tt(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var ur=new Set(["hooks","parser","preflight","renderers"]),fr=new Set(["commands","schema","services","importers"]),$c=new Set(["reindex","search","search-advanced"]),Pc=new Set(["--template"]);function Te(e,t){for(let n of t)if(e.has(n))return!0;return!1}function no(e){let t=_(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return $c.has(n??t)}function oo(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 Lt(e){return _(e.commandPath??"")==="create"&&oo(e,Pc)}function ao(e){return e.some(t=>{let n=_(t);return n==="templates"||n.startsWith("templates ")})}function Mt(e,t){return e.some(n=>to(n,t))||Lt(t)&&ao(e)}function io(e){return[R(e.hooks).length,(e.preflight_overrides??0)-R(e.preflight_ownership).length,R(e.item_types).length,R(e.item_fields).length,R(e.relationship_kinds).length,R(e.service_overrides).length,R(e.assurance_providers).length,R(e.renderer_overrides).length-R(e.renderer_ownership).length].some(t=>t>0)}function ro(e,t){let n=e.activation?.commands??[];if(n.length>0)return Mt(n,t);let o=Ft(e);if(Mt(o,t)||tt(e).has("search")&&no(t.commandPath))return!0;if(e.contributions)return io(e.contributions)}function jt(e,t){let n=ro(e,t);if(n!==void 0)return n;let o=tt(e);return!!(Te(o,ur)||Te(o,fr))}function nt(e,t){return e.effective.length===0?!1:ot(t)!=="all"?e.effective.some(n=>jt(n,t)):e.effective.some(n=>{let o=tt(n);return Ft(n).length>0||Te(o,ur)||Te(o,fr)||o.has("search")})}function ot(e){if(_(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Re(e).filter(o=>o.split(" ").every(a=>!a.startsWith("-"))).sort((o,a)=>a.length-o.length)[0]??_(e.commandPath??"");if(t.length===0)return"all";let n=Lt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function so(e){return ot(e)==="all"?void 0:t=>jt(t,e)}function Ie(e){let t=S(e);if(t.requested&&t.commandPathTokens.length>0){let[a,...i]=t.commandPathTokens;return{commandPath:a,commandArgs:i,allowCommandPrefixMatch:!0}}let n=D(e),o=n.findIndex(a=>a.trim().length>0&&!a.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function lo(e){let t=e.args.map(String);if(_(E(e))==="create"){let n=e.optsWithGlobals();typeof n.template=="string"&&n.template.trim().length>0&&t.push("--template")}return t}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2fe1a4e5-3c55-5ec3-a729-2216a298c081")}catch{}})();var Ut=Symbol.for("pm.readOutputInvocationProvenance");function ie(e,t){let n=Reflect.get(e,Ut);n!==void 0&&Reflect.set(t,Ut,n)}function co(e,t,n){let o=ua(t,n);if(!o)return;let a=e;for(;a.parent;)a=a.parent;let i=a.rawArgs,r=new Set(X(i.slice(2))),s=pa.find(d=>d.command===o),l=Object.values(s.dimensions).flatMap(d=>d.legacy_aliases.flatMap(m=>r.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,Ut);Reflect.set(n,Ut,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),ie(n,e)}function Nc(e){let t=e.optsWithGlobals(),n=E(e);if(O(n)===n)return t;let o=e.opts();for(let a=e.parent;a?.parent;a=a.parent)for(let i of a.options){let r=i.attributeName(),s=a.getOptionValueSource(r)==="cli";if(s&&!e.options.some(l=>l.long===i.long))throw new b(`Unknown option '${i.long}' for ${n}`,f.USAGE,{code:"unknown_option",flag:i.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(r)!=="cli"){let l=a.getOptionValue(r);e.setOptionValueWithSource(r,l,"cli")}r in o?t[r]=o[r]:delete t[r]}return t}function mo(e,t,n,o){co(e,t,o);let a=n.outputInclude;if(a===void 0)return;let{selectors:i,modes:r}=ha(t,a,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),r.length===0)return;ie(o,e);let s=ga(t);for(let c of r){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=i.length>0?i.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let c=e;c;c=c.parent)c.setOptionValueWithSource("outputInclude",l,"cli");kt(e,n)}function $e(e,t,n=[]){let o={...Nc(e)};ie(e,o),delete o.json,delete o.quiet,delete o.path,delete o.pmPath,delete o.noExtensions,delete o.extensions,delete o.profile,delete o.pager,delete o.changedFields,delete o.fullChangedFields,delete o.idOnly,delete o.lean,delete o.tokenAccounting,delete o.outputInclude,delete o.outputLimit,delete o.outputBudget,delete o.outputFormat,delete o.outputSession;let a=Qi(t);for(let[i,r]of Object.entries(a))o[i]===void 0&&(o[i]=r);if(n.length>0){let i=Yi(n),r=ne(E(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),s={...a};for(let c of i)o[c]!==void 0&&(s[c]=o[c]);Kn(s,[...r,...n],E(e));let l=Zi(o,n,a);return ie(o,l),l}return o}function qt(e,t){let n=_(t);return n.length===0?[]:e.flags.filter(o=>O(_(o.target_command))===O(n)).flatMap(o=>o.flags)}function at(e,t,n){let o=qt(e,t),a=[t],i=[];for(let r of n){if(r.startsWith("-"))break;a.push(r);let s=qt(e,a.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Ht(e){return e.arguments??[]}function gr(e){let t=Ht(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function po(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 uo(e,t){let n=Ht(e),o=n.filter(s=>s.required).length,a=n.some(s=>s.variadic)?Number.POSITIVE_INFINITY:n.length,i=e.failure_hints??[],r=i.length>0?` ${i.join(" ")}`:"";if(t.length<o)throw new b(`Missing required argument for extension command '${e.command}'. Usage: ${gr(e)}${r}`,f.USAGE);if(t.length>a){let s=t.slice(a).join(" ");throw new b(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${gr(e)}${r}`,f.USAGE)}}function Dc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Mc(e,t,n){if(n.length>0){Kn(t,n,e.command);return}let o=Object.keys(t).filter(a=>t[a]!==void 0).sort();if(o.length!==0)throw new b(`Unknown option '${o.map(Dc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,f.USAGE)}function fo(e,t,n,o){e&&(uo(e,t),Mc(e,n,o))}import{Command as hr}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]="0503f6e5-36d9-5afb-a17f-feef2241f984")}catch{}})();var Fc=new Set(["--version","-V"]);function it(e){let t=D(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function yr(e){if(D(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new hr().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let a of He)for(let i of[a.flag,a.short,...a.aliases??[]]){if(i===void 0||n.has(i))continue;n.add(i);let r=a.value_name!==void 0||a.flag==="--pm-path";t.option(`${i}${r?" <value>":""}`)}try{t.parseOptions(e)}catch{}let o=t.opts();return{path:o.pmPath??o.path}}var Lc=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),go=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"]),wr=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"]),jc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Uc=new Set(["claim","close-task","pause-task","release","start-task","test"]),ye={setup:!0,listQuery:!0,mutation:!0,operation:!0},qc=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 rt(e){return e.some(t=>Fc.has(t))}function Hc(e,t){if(!I.some(o=>o.canonical_argv[0]===t))return;let n=new hr().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Ga(t,ne(t))){let a=o.takes_value?o.value_required?" <value>":" [value]":"";for(let i of[o.flag,o.short,...o.aliases??[]])i!==void 0&&n.option(`${i}${a}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return ye;let a=W([t,...o.operands])?.alias;if(I.some(i=>i.alias===a))return{...ye,targetCommandName:a}}catch{return ye}}function ho(e){if(rt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||S(e).requested)return ye;let t=x(e);if(!t)return ye;let n=t.trim().toLowerCase(),o=D(e),a=W(o)?.alias;return I.some(i=>i.alias===a)?{...ye,targetCommandName:a}:Hc(o,n==="ctx"?"context":n)||(Lc.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:go.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:wr.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:jc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ye)}function yo(e){return e.length===0||S(e).requested||e.includes("--explain")&&x(e)===void 0}function wo(e,t){return it(t)||rt(t)?!1:oe(t)||S(t).requested?!0:!!x(t)}function _o(e){if(rt(e))return!1;let t=x(e);return t?qc.has(t):!1}function zc(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,a=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),i=a?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${a}${c.slice(d)}`:a:c}):e.argv,r=je(i),s=a&&n>=0?`${o}=[redacted]`:t,l=a&&e.normalizedDisplay.includes("=")?`${a}=[redacted]`:e.normalizedDisplay;return{argv:r,normalizedDisplay:l,sourceDisplay:s}}function vo(e){let t=e.commandName;if(!t)return;let n=e.trace.find(c=>c.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(c=>c.length>0),a=o.length>0?o.join(" "):"the canonical flag",i=wr.has(t)||Uc.has(t),r=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",l=zc({argv:e.argv,normalizedDisplay:a,normalizedTokens:o,rawFrom:n.from});throw new b(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,f.USAGE,{code:r,examples:[k(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:k(l.argv)}})}(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]="6d83c356-db56-5116-9fe7-e0c27973b36f")}catch{}})();var Gc=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"]),Wc=new Set(["parse","preflight","execute","unknown"]),Vc=new Set(["usage","validation","conflict","runtime","unknown"]);function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let a=o.trim();if(a.length>0)return a}}}function bo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function zt(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 Co(e){if(!e)return;let t=e.trim().toLowerCase();if(Gc.has(t))return t}function xo(e){if(!e)return;let t=e.trim().toLowerCase();if(Wc.has(t))return t}function ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Vc.has(t))return t}function Eo(e){let t=we(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let i=n.find(r=>typeof r=="string"&&r.trim().length>0);if(typeof i=="string")return i.trim()}if(bo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=zt(e,"failed");if(typeof o=="number"&&o>0)return`failed_runs:${o}`;let a=e?.run_results;if(Array.isArray(a)){let i=a.filter(r=>Zt(r)?.status==="failed").length;if(i>0)return`failed_runs:${i}`}}function So(e,t){if(!e)return t===f.USAGE?"invalid_command_usage":t===f.NOT_FOUND?"item_not_found":t===f.CONFLICT?"lock_conflict":t===f.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Ao(){let e=Zt(le()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=zt(e,"exit_code","exitCode"),o=t??n??f.SUCCESS,a=Ka(o),i=we(e,"error_code","errorCode")??So(a,o),r=ko(we(e,"error_category","errorCategory"))??(a?void 0:mt(i)),s=a?void 0:Eo(e)??`command_exit_${o}`,l=Co(we(e,"command_resolution","commandResolution"))??bt({ok:a,errorCode:i,errorCategory:r}),c=xo(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:a,error:s,exit_code:o,error_code:i,error_category:r,command_resolution:l,resolution_stage:c}}(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]="2309d6a4-a061-51d8-be5e-5e1dd62e9b3e")}catch{}})();var Oo="PM_CLI_PACKAGE_ROOT",Er=Symbol("pm.deprecatedAliasInvocation"),Vt=new Map;for(let e of B){let t=e.alias.split(" ")[0],n=Vt.get(t)??[];n.push(e),Vt.set(t,n)}for(let e of Vt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Bc(){return Ho(import.meta.url,["../.."])}(typeof process.env[Oo]!="string"||process.env[Oo]?.trim().length===0)&&(process.env[Oo]=Bc());var Pe=null,F=null;function Kc(e){Pe=e}function Jc(e){P=e}var st=null,_e=null,P=new Map,Do=250,Yc=new Set([f.USAGE,f.NOT_FOUND,f.CONFLICT]),Xc=new Set(["1","true","yes","on"]),Zc=Ve(()=>import("./chunks/register-setup-WT37UPBQ.js")),Qc=Ve(()=>import("./chunks/register-list-query-53WYLNZT.js")),ed=Ve(()=>import("./chunks/register-mutation-34XXUBVI.js")),td=Ve(()=>import("./chunks/register-operations-WANO6EIM.js"));function Wt(e){return k(e)}function Sr(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=>pe(o)??o))];return n.length>0?n:void 0}function nd(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=X(t),a=new Set(o.map(d=>pe(d)??d)),i=Sr(e),r=t.find(d=>y.commands.some(m=>m.name()===d)),s=r?y.commands.find(d=>d.name()===r):void 0,l=new Set([...y.options,...s?.options??[]].flatMap(d=>d.flags.split(/[ ,|]+/).map(m=>pe(m)).filter(m=>m!==void 0))),c=i?.filter(d=>{let m=pe(d)??d;return a.has(m)?!1:l.has(m)||Hn(t,r,m,P)!==void 0});return c&&c.length>0?c:void 0}function od(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let a=n?.[0],i=a?pe(a):void 0,r=e.find(p=>y.commands.some(u=>u.name()===p)),s=r?y.commands.find(p=>p.name()===r):void 0,l=i?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(i)):void 0,c=Hn(e,r,i,P),d=i?l?.isBoolean()===!0||c===!1?[i]:[i,"<value>"]:[],m=i?Wt([...e,...d]):t;return m===t?void 0:m}function ad(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 a=e[o];a!=null&&(n[o]=a)}return n}function id(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,...ad(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ar(e,t,n){let o=je(t),a=D(o),i=me(a),[r,s]=i===void 0?[]:a.slice(i,i+2),l=o.includes("--explain"),c=ai(o,e?.code,e?.recovery),d=c&&(r==="history-redact"||r==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Wt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Wt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=Wt(o),p=X(o),u=nd(n,o,d),g=od(o,m,u,d),h=id({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:g,existingRecovery:d});return{...e,recovery:h}}async function ct(e){let t=F;F=null,await ii(t,e);let n=Pe;if(Pe=null,!n){ft();return}let o=[],a=la();try{await ri({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?a?.map(i=>i.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Zo(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:a}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{ft()}!n.globalOptions.json&&o.length>0&&w(`[pm] warning: afterCommand hook_warnings=${q(o)}`),n.profileEnabled&&o.length>0&&w(`profile:extensions hook_warnings=${q(o)}`)}async function Or(){await Ma()}function Tr(e){return Xc.has((process.env[e]??"").trim().toLowerCase())}function Rr(e){return Tr("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Yc.has(Math.trunc(e))}async function Bt(e){return Rr(e.exit_code)?(await Or(),Fa(e),!0):!1}async function Ir(e){let t=de(e.error),n=Ei(t);e.bootstrapGlobal.json?w(JSON.stringify(xi(t,f.GENERIC_FAILURE),null,2)):w(t),process.exitCode=f.GENERIC_FAILURE;let o="runtime",a="runtime_failed";try{await Or(),fn(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:f.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,a=i.commandResolution,Ge(!1,t,{error_code:n.code,error_category:o,exit_code:f.GENERIC_FAILURE,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to report error: ${de(i)}`)}try{await ct({ok:!1,error:t,exit_code:f.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to run error hooks: ${de(i)}`)}try{await We()}catch(i){e.bootstrapGlobal.json||w(`Failed to flush error reporting: ${de(i)}`)}}var rd={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"},To=new Map;function Ro(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function $r(e,t){return e.options.some(n=>n.long===t)}function Pr(e,t){return e.options.some(n=>n.short===t)}function Io(e,t,n,o){let a=t.trim();if(!a)return;let i=n.length>0?n:`Runtime schema field (${t})`;if(a.startsWith("-")&&!a.startsWith("--")){if(Pr(e,a))return;if(o){e.option(`${a} <value>`,`${i} (repeatable)`,yn);return}e.option(`${a} <value>`,i);return}let r=a.startsWith("--")?a:`--${a}`;if(!$r(e,r)){if(o){e.option(`${r} <value>`,`${i} (repeatable)`,yn);return}e.option(`${r} <value>`,i)}}async function Nr(e,t){let n=rd[e];if(!n)return[];let o=`${t}:${n}`,a=To.get(o);if(a)return a;if(!await K(J(t)))return To.set(o,[]),[];let i=await N(t),r=(mn(i.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:Ro(s.type),value_type:Ro(s.type)})));return To.set(o,r),r}async function Dr(e,t){let n=U(t),o=T(process.cwd(),n.path);if(!await K(J(o)))return;let a=_e?.key===Lo(o)?_e.snapshot:null,i=a===null?await N(o):a.settings,r=mn(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 l of s){let c=ee(e,l.path.split(" "));if(c)for(let d of r.command_to_fields.get(l.command)??[]){let m=d.description??"";Io(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Io(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Mo(e,t,n,o,a){let i=x(n);if(!(i!=="create"&&i!=="update"))try{let r=a??await N(t),s=re(r,o);sr(e,s,n)}catch{}}function $o(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Mr(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Fo(e){return e.some(t=>t==="--profile")}function Lo(e){return`pm-root:${e}`}function Po(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 Fr(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=${q(t.activationWarnings)}`))}function Kt(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 Jt(e,t=ke){let n=Lo(e);if(_e?.key===n)return _e.snapshot;try{let o=Date.now(),{settings:a,warnings:i}=await t(e),r=await Qo({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:a,discovery:r,discoveryMs:Date.now()-o,settingsReadWarnings:[...i]};return _e={key:n,snapshot:s},s}catch{return _e={key:n,snapshot:null},null}}async function Ne(e,t,n=N){let o=t?ot(t):"all",a=Mr(e,o);if(st?.key===a)return st.snapshot;try{let i=await n(e),r=await Fe({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?so(t):void 0}),s=await Le({...r,loaded:r.loaded}),l=[...new Set(s.commands.handlers.map(u=>_(u.command)))].filter(u=>u.length>0).sort((u,g)=>u.localeCompare(g)),c=Di(s.registrations.flags),d=Pi(s.commands.handlers,s.registrations.commands),m=Fi(l,s.registrations.commands,s.registrations.flags,d),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:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...r.warnings],activationWarnings:[...s.warnings],loadedCount:r.loaded.length,loadFailedCount:r.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:r.loaded.map(({name:u,module:g})=>({name:u,module:g}))};return st={key:a,snapshot:p},p}catch{return st={key:a,snapshot:null},null}}async function Lr(e){let t=Be(e);if(t.noExtensions){let r=T(process.cwd(),t.path);return await K(J(r))&&Po((await ke(r)).warnings),null}let n=T(process.cwd(),t.path),o=await Jt(n);if(!o)return null;Po(o.settingsReadWarnings);let a={commandPath:E(e),commandArgs:lo(e)};if(!nt(o.discovery,a))return Kt(t.profile,o,a),null;let i=await Ne(n,a);return i?(Fr(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 jr(e){let t=await Ne(e);return t?new Map(t.commandDescriptors):P}async function Ur(e,t){return(await Aa({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(n=>n.outcome==="failed").map(n=>`extension_migration_failed:${n.layer}:${n.extension}:${n.id}`)}function qr(e,t,n){let o=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return Sa(e,ei.forActiveExtensionHost({pmRoot:e,author:o}),o,_(n))}async function Hr(e,t,n,o=[]){let a=E(e),i=Jn(e.args.map(String),o),r={...t},s={...n},l=T(process.cwd(),n.path),c=await gt({command:a,args:i,options:r,global:s,pm_root:l});n.profile&&c.warnings.length>0&&w(`profile:extensions parser_warnings=${q(c.warnings)}`),i=c.context.args,r=c.context.options,s=c.context.global,fo(P.get(_(a)),i,r,o),Ce(void 0),ut({command:a,args:i,options:{...r},global:{...s},pm_root:l});let d=await nn({command:a,args:i,options:r,global:s,pm_root:l,sdk:qr(l,s,a)});if(s.profile&&d.warnings.length>0&&w(`profile:extensions command_handler_warnings=${q(d.warnings)}`),!d.handled){if(d.warnings.length>0){let m=d.warnings[0],p=d.errorMessage?.trim(),u=p?` ${p}`:"";throw new b(`Command "${a}" failed in extension handler (${m}).${u}`,f.GENERIC_FAILURE,{code:d.errorCode??"command_failed",nextSteps:d.remediation?[d.remediation]:void 0})}throw new b(`Command "${a}" is provided by extensions and is not currently available.`,f.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),Ce(d.result),d.result}var _r=Symbol("pm.wrappedActionHandler");function sd(e,t){let n=e[e.length-1];return n instanceof No?n:t}function vr(e,t,n){e&&n.length>0&&w(`profile:extensions ${t}=${q(n)}`)}function ld(e){let t=P.get(_(e.commandPath));if(!t||!po(e.activeRegistrations,e.commandPath))return;let n=Ht(t).length===0?er(e.commandArgs):Jn(e.commandArgs,e.extensionFlagDefinitions);uo(t,n)}function cd(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 zr(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[_r]!==!0){let a=o._actionHandler;o._actionHandler=async function(...i){let r=sd(i,n),s=Date.now();hn(r);let l=Be(r),c=O(E(r));if(["package inventory","packages inventory","extension inventory"].includes(c))return await a.apply(this,i);let d=T(process.cwd(),l.path),m=r.args.map(String),p=se(),u=p?at(p,c,m):[],g=await Nr(c,d),h=$e(r,m,[...u,...g]),v=await gt({command:c,args:m,options:h,global:l,pm_root:d});vr(l.profile,"parser_warnings",v.warnings),m=v.context.args,h=v.context.options,ie(r,h),l=v.context.global,ld({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await Ya(l),kt(r,l),cd(r,i,m),xt(r,h),Ce(void 0),ut({command:c,args:m,options:{...h},global:{...l},pm_root:d});let A=await nn({command:c,args:m,options:h,global:l,pm_root:d,sdk:qr(d,l,c)});if(vr(l.profile,"command_handler_warnings",A.warnings),A.handled){Ce(A.result),an(A.result,{...l,command:c,commandArgs:m,commandOptions:h,pmRoot:d}),l.profile&&w(`profile:command=${c} took_ms=${Date.now()-s}`);return}return await a.apply(this,i)},o[_r]=!0}for(let a of n.commands)t(a)};t(e)}async function Gt(e){P=new Map,te({overrides:[]}),e&&await Mo(e.rootProgram,e.pmRoot,e.invocationArgv,Ko(),e.settings)}function dd(e,t,n,o){if(t?.flags&&t.flags.length>0){zn(e,t.flags);let a=Gn(e,t.flags);a&&e.addHelpText("after",a)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Gr(e,t,n){let o={core:0,standard:1,full:2,internal:3},a=(i,r)=>{let s=r.join(" "),l=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),c=l.length===0?"standard":l.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");St(i,c);for(let d of i.commands)a(d,[...r,d.name()])};for(let i of e.commands)t.has(i.name())||a(i,[i.name()])}async function Wr(e,t){let n=U(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let a=await Jt(o),i=Ie(t);if(!a){await Gt();return}if(!nt(a.discovery,i)){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings}),Kt(Fo(t),a,i);return}let r=await Ne(o,i);if(!r){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings});return}te(r.services),P=new Map(r.commandDescriptors),await Mo(e,o,t,r.registrations,r.settings);let s=Vi(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>Bi(r.activationWarnings,w,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(L=>L.length>0),p=r.commandDescriptors.get(d),u=ee(e,m),g=r.commandFlagHelp.get(d),h=p?Gi(p):null;if(u){dd(u,p,g,h);return}let v=Wi(e,m);p?.description&&v.description(p.description);let A=g;p&&(Li(v,p),p.flags.length>0&&(zn(v,p.flags),A=Gn(v,p.flags)??void 0)),A&&v.addHelpText("after",A),h&&v.addHelpText("after",h),v.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...L)=>{let G=L[L.length-1],j=G instanceof No?G:v,ve=Be(j),Yt=Date.now(),dt=at(r.registrations,d,j.args.map(String)),De=$e(j,j.args.map(String),dt),be=await Hr(j,De,ve,dt);await Xa(ve,be),an(be,{...ve,command:d,commandArgs:j.args.map(String),commandOptions:De,pmRoot:o}),ve.profile&&w(`profile:command=${d} took_ms=${Date.now()-Yt}`)})};for(let d of s)c(d);Gr(e,l,r.commandDescriptors)}var lt=zo(import.meta.url,["../.."])??"0.0.0",y=rn(lt);async function br(e){if(!F)return;let t=Reflect.get(e,Er);typeof t=="string"&&await Qa(t)}async function Cr(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}function Vr(e,t){t&&it(t)||(e.hook("preAction",async(n,o)=>{Pe=null,F=null,ft(),hn(o);let a=o.optsWithGlobals(),i=Be(o),r=O(E(o)),s=o.args.map(String),l=$e(o,s),c={...i};fa(r,{...l,outputInclude:a.outputInclude,outputLimit:a.outputLimit,outputBudget:a.outputBudget,outputFormat:a.outputFormat,outputSession:a.outputSession,outputCursor:a.outputCursor}),mo(o,r,c,l),await Cr(o,void 0,()=>qa(r,c));let d=T(process.cwd(),i.path),m=await Lr(o);if(!m){Pe=ea({commandName:r,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),F=await gn({command:r,pm_version:lt,args:s,options:l,global:c,pm_root:d}),await br(e),pn(r,s,l,{source_context:F?.source_context,source_context_source:F?.source_context_source}),un(r),await Qn(r,l,d,$o()),await Zn(r,s,l,c,d);return}ta(m.hooks),na(m.commands),oa(m.parsers),aa(m.preflight),te(m.services),ia(m.renderers),ra(m.registrations);let p=at(m.registrations,r,s);l=$e(o,s,p),mo(o,r,c,l);let u=await gt({command:r,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&w(`profile:extensions parser_warnings=${q(u.warnings)}`),s=u.context.args,l=u.context.options,ie(o,l),c=u.context.global,xt(o,l);let g=await ca({command:r,args:s,options:l,global:c,pm_root:m.pmRoot,decision:$o()});c.profile&&g.warnings.length>0&&w(`profile:extensions preflight_warnings=${q(g.warnings)}`),s=g.context.args,l=g.context.options,ie(o,l),c=g.context.global,xt(o,l);let h=g.decision;await Qn(r,l,m.pmRoot,h),await Zn(r,s,l,c,m.pmRoot);let v=h.run_extension_migrations?await Cr(o,[],()=>Ur(m.registrations.migrations,m.pmRoot)):[];c.profile&&v.length>0&&w(`profile:extensions migration_warnings=${q(v)}`);let A=dr(m.registrations.migrations);Pe={hooks:m.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:A},Ce(void 0),ut({command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),F=await gn({command:r,pm_version:lt,args:s,options:l,global:c,pm_root:m.pmRoot}),await br(e),pn(r,s,l,{source_context:F?.source_context,source_context_source:F?.source_context_source}),un(r);let L=await Xo(m.hooks,{command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&L.length>0&&w(`profile:extensions hook_warnings=${q(L)}`),h.enforce_mandatory_migration_gate&&mr(r,l,A)}),e.hook("postAction",async()=>{let n=Ao();Ge(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await ct(n)}))}Vr(y);var xr=Symbol("pmCliIdempotentTopLevelRegistration");function Br(e){let t=e;if(t[xr])return;t[xr]=!0;let n=e.command.bind(e);e.command=((o,...a)=>{let i=o.split(/\s+/u)[0];return e.commands.some(r=>r.name()===i||r.aliases().includes(i))?new No(i):n(o,...a)})}async function md(e,t){if(Br(e),t.setup){let{registerSetupCommands:n}=await Zc();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Qc(),o=typeof t.targetCommandName=="string"&&go.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await ed();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await td();n(e)}}function pd(e){return async t=>{let n=mt(t.errorCode),o=bt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await za({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:lt,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 Kr(e){if(e.bootstrapGlobal.noExtensions||it(e.invocationArgv))return;let t=Ie(e.invocationArgv),n=await Jt(e.bootstrapPmRoot);if(n&&nt(n.discovery,t)){let o=await Ne(e.bootstrapPmRoot,t);Jr(o);return}n&&Kt(Fo(e.invocationArgv),n,t),te({overrides:[]})}function Jr(e){if(!e){te({overrides:[]});return}te(e.services)}async function jo(e){Ge(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ct({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 Yr(){Ge(!0,void 0,{exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ct({ok:!0,exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=f.SUCCESS}async function Xr(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof b)&&(cn(e.error)||!n))return!1;let o=de(e.error),a=e.error instanceof b?e.error.exitCode:ln(t),i=e.error instanceof b?e.error.context:void 0,r=Ar(i,e.invocationArgv,o),s=bi(o,r),l=e.bootstrapGlobal.lean?Tt(Nn(o,a,r)):Nn(o,a,r),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?ce(l,u=>`${JSON.stringify(u,null,2)}
34
+ `):l,null,2):vi(o,r);e.jsonErrors?xe(`${c}
35
+ `):w(c);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:a,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Bt({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:a,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:F?.source_context});return await jo({errorMessage:o,exitCode:a,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(fn(dn(e.error,o)),await We(Do)),process.exitCode=a,!0}async function Zr(e,t){let n=O(S(e.invocationArgv).commandPathTokens.join(" "))||Fn(e.invocationArgv),o=`unknown command '${n}'`,a=T(process.cwd(),e.bootstrapGlobal.path),i=await jr(a),r=Ie(e.invocationArgv),s=await Yn(a,{},Re(r)),l=await Xe({message:o},y,i,{failedExtensions:s}),c=Dn(l.message,l.commandName,l.allowedTypes,{unknownCommandExamples:l.unknownCommandExamples,unknownCommandNextSteps:l.unknownCommandNextSteps,attemptedCommand:l.attemptedCommand,normalizedInvocationArgs:l.normalizedInvocationArgs,providedOptionFlags:l.providedOptionFlags,unknownOptionSuggestions:l.unknownOptionSuggestions,suggestedRetryCommand:l.suggestedRetryCommand,failedExtensions:s}),{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:n,errorCode:c.code,errorMessage:c.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),p=await Bt({command:n,error_code:c.code,error_category:d,exit_code:f.USAGE,error_message:c.detail,command_resolution:m,resolution_stage:"parse"}),u=e.jsonErrors?await qn({message:o},y,i,e.bootstrapGlobal.lean===!0,{failedExtensions:s}):await Un({message:o},y,i,{failedExtensions:s}),g=Mn(u,e.jsonErrors,s);await jo({errorMessage:o,exitCode:f.USAGE,classificationCode:c.code,errorCategory:d,commandResolution:m,resolutionStage:"parse"}),e.jsonErrors?xe(`${g}
36
+ `):w(g),p&&await We(Do),process.exitCode=f.USAGE}async function Qr(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=S(e.invocationArgv);return o.requested&&!Ye(y,o.commandPathTokens)?(await Zr(e,t),!0):(await Yr(),!0)}async function es(e,t){let n=await Xe(e.error,y,P),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:a,commandResolution:i}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),r=await Bt({command:e.attemptedCommand,error_code:o.code,error_category:a,exit_code:f.USAGE,error_message:o.detail,command_resolution:i,resolution_stage:"parse",source_context:F?.source_context}),s=e.jsonErrors?await qn(e.error,y,P,e.bootstrapGlobal.lean===!0):await Un(e.error,y,P),l=await tr(o.code,e.bootstrapPmRoot,{},Re(Ie(e.invocationArgv))),c=Mn(s,e.jsonErrors,l);await jo({errorMessage:n.message,exitCode:f.USAGE,classificationCode:o.code,errorCategory:a,commandResolution:i,resolutionStage:"parse"}),e.jsonErrors?xe(`${c}
37
+ `):w(c),r&&await We(Do),process.exitCode=f.USAGE}function ts(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 ns(e){let t=e.error.code,n=String(e.error.message??"");if(!await Qr(e,t,n)){if(t==="commander.version"){await Yr();return}await es(e,t)}}async function Uo(e){let t=U(e.invocationArgv),n=T(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:x(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:pd({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Kr({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await Xr(o,sn(e.error))){if(ts(e.error)){await ns(o);return}await Ir({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function ud(e,t,n){let o=n.requested?n.commandPathTokens:D(t),a=W(o);if(a&&!ee(e,[...a.canonical_argv]))throw new kr(f.USAGE,"commander.unknownCommand",`unknown command '${a.alias}'`)}function fd(e,t){let n=me(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let r=me(t.slice(n+1));if(r===void 0)return;n+=r+1}let o=Vt.get(t[n]),a=t.slice(n).filter(r=>!["--global","--project","--local"].includes(r)),i=o?.find(r=>r.alias.split(" ").every((s,l)=>a[l]===s));i?.lifecycle==="deprecated"&&Reflect.set(e,Er,i.alias)}async function gd(e,t){y=rn(lt),y.hook("preAction",(i,r)=>{t.configurationOnly=["item mutate","item complete"].includes(E(r))&&r.optsWithGlobals().dryRun===!0}),Vr(y,e),st=null,_e=null,P=new Map,sa();let n=[...e],o,a;try{let i=ze(e);n=i.argv,fd(y,e);let r=[process.argv[0],process.argv[1],...n],s=n.length===0,l=U(n);if(l.authorMissingValue)throw new b("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Na(l.author),vo(i),a=Ta(n);let c=ho(n);await md(y,c),kn(y,!0),wo(y,n)?await Wr(y,n):(P=new Map,te({overrides:[]})),_o(n)&&await Dr(y,n),kn(y);let d=S(n);if(ud(y,n,d),yo(n)&&pi(y,n),zr(y),await rr(y,n,P,e))return;if(d.requested&&!Ye(y,d.commandPathTokens))throw new kr(f.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||oe(n)&&x(n)===void 0){y.outputHelp();return}if(it(n)){await y.parseAsync(r);return}let m=T(process.cwd(),l.path),p=await N(m),u=await Ii(n,m,l.noExtensions,Ne);await va({pmRoot:m,packages:u?.contextIntentPackages},()=>ba({env:{...process.env,PM_PATH:m},argv:r,cwd:process.cwd()},()=>Ca(p.agent_identity.harness_signals,()=>y.parseAsync(r),{probesEnabled:p.agent_identity?.probes_enabled})))}catch(i){await Uo({error:i,invocationArgv:n})}finally{a?.(),o?.()}}async function jp(e=process.argv.slice(2)){let t=e;try{t=ze(e).argv}catch{}let n=yr(t),o={configurationOnly:n!==void 0},a=()=>o.configurationOnly,i=async()=>{try{await Da(process.env,()=>gd(e,o))}catch(r){await Uo({error:r,invocationArgv:[...e]})}};if(n!==void 0){let r=T(process.cwd(),U(t).path),s=T(process.cwd(),n.path),l=Bo(process.cwd());await yt(r,()=>yt(s,()=>yt(l,i,a),a),a)}else await i()}var Up={activationCommandMatchesProbe:to,applyDynamicExtensionRootHelpVisibility:Gr,bootstrapProfileEnabled:Fo,buildBootstrapActivationProbe:Ie,buildPostActionTelemetryOutcome:Ao,buildPmCliRecoveryContext:Ar,buildRuntimeExtensionDiscoverySnapshotCacheKey:Lo,buildRuntimeExtensionActivationScope:ot,buildRuntimeExtensionSnapshotCacheKey:Mr,buildRuntimeExtensionFilterForProbe:so,addRuntimeFieldOption:Io,collectActivationCommandCandidates:Re,collectExtensionFlagDefinitionsForCommand:qt,collectExtensionFlagDefinitionsForInvocation:at,collectLeadingCommandArgs:eo,collectParsedActivationCommandArgs:lo,collectRuntimeFieldLooseFlagDefinitionsForCommand:Nr,commandHasLongOption:$r,commandHasShortOption:Pr,commandPathNeedsSearchExtensions:no,commandPathNeedsTemplateExtensions:Lt,describeUnknownError:de,defaultPreflightDecision:$o,discoveryNeedsActivationForProbe:nt,emitExtensionProfile:Fr,emitExtensionSkippedProfile:Kt,emitSettingsReadWarnings:Po,ensureIdempotentTopLevelCommandRegistration:Br,enforceExplicitRetryForFlagTypos:vo,envFlagEnabled:Tr,executeRegisteredRuntimeMigrations:Ur,extractCommandScopedOptions:$e,extensionActivationCommands:Ft,extensionCapabilities:tt,extensionNeedsActivationForProbe:jt,extensionProvidesTemplatesRuntime:ao,hasAnyCapability:Te,hasGlobalExtensionContributions:io,handleGenericRunPmCliError:Ir,handleRunPmCliCommanderError:ns,handleRunPmCliError:Uo,handleRunPmCliHelpDisplayError:Qr,handleRunPmCliKnownError:Xr,handleRunPmCliCommanderUsageError:es,handleUnknownHelpCommandError:Zr,inferMissingFieldsFromErrorMessage:Sr,inferPostActionErrorCode:So,inferPostActionFailureMessage:Eo,invocationRequestsVersion:rt,isCommanderError:cn,loadRuntimeExtensionCommandDescriptorsForRecovery:jr,loadRuntimeExtensionDiscoverySnapshot:Jt,loadRuntimeExtensionSnapshot:Ne,maybeLoadRuntimeExtensions:Lr,maybeAttachCreateUpdatePolicyHelpText:Mo,maybeLogHandledCliErrorToSentry:Bt,matchesStaticExtensionCommand:Mt,normalizeTelemetryCommandResolution:Co,normalizeTelemetryErrorCategory:ko,normalizeTelemetryResolutionStage:xo,normalizeThrownExitCode:ln,probeUsesAnyFlag:oo,prepareExtensionServicesForRunPmCliError:Kr,readRecordBoolean:bo,readRecordNumber:zt,readRecordString:we,recordCliReadOutputInvocationProvenance:co,registerDynamicExtensionCommandPaths:Wr,registerRuntimeSchemaFieldFlags:Dr,resolveCoreCommandRegistrationSelection:ho,resolveStaticExtensionActivationDecision:ro,resolveUnknownHelpToken:Fn,readThrownExitCode:sn,runAndClearAfterCommandHooks:ct,runRequiredExtensionCommand:Hr,shouldAttachRichHelpTextForInvocation:yo,shouldLogHandledErrorToSentry:Rr,shouldRegisterDynamicExtensionPaths:wo,shouldRegisterRuntimeSchemaFlags:_o,shouldHandleRunPmCliCommanderError:ts,setActiveExtensionHookContextForTest:Kc,setActiveRuntimeExtensionCommandDescriptorsForTest:Jc,setRecoveredExtensionServices:Jr,toLooseFieldDefinitionType:Ro,isImporterOrExporterCommandPath:po,validateDynamicExtensionCommandInvocation:fo,wrapProgramActionsForExtensionHandlers:zr,wrapThrownErrorForSentry:dn};export{Up as _testOnly,jp as runPmCli};
38
38
  //# sourceMappingURL=main.js.map