@unbrained/pm-cli 2026.9.6 → 2026.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (719) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +12 -4
  2. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +19 -10
  3. package/.agents/skills/pm-extensions/SKILL.md +6 -0
  4. package/.agents/skills/pm-sdk/SKILL.md +11 -2
  5. package/.agents/skills/pm-user/SKILL.md +5 -0
  6. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +95 -0
  7. package/.claude-plugin/marketplace.json +2 -2
  8. package/CHANGELOG.md +218 -182
  9. package/dist/cli/after-command-context-usage.js +1 -48
  10. package/dist/cli/argv-utils.js +1 -40
  11. package/dist/cli/bootstrap-args.js +1 -9
  12. package/dist/cli/bundle-integrity.js +2 -110
  13. package/dist/cli/commander-usage.js +11 -771
  14. package/dist/cli/commands/activity.js +1 -9
  15. package/dist/cli/commands/aggregate.js +1 -5
  16. package/dist/cli/commands/append.js +1 -5
  17. package/dist/cli/commands/claim.js +1 -5
  18. package/dist/cli/commands/close-many.js +1 -5
  19. package/dist/cli/commands/close.js +1 -9
  20. package/dist/cli/commands/comments.js +1 -5
  21. package/dist/cli/commands/config.js +1 -9
  22. package/dist/cli/commands/context.js +1 -9
  23. package/dist/cli/commands/contracts.js +1 -5
  24. package/dist/cli/commands/copy.js +1 -9
  25. package/dist/cli/commands/create.js +1 -9
  26. package/dist/cli/commands/delete.js +1 -9
  27. package/dist/cli/commands/deps.js +1 -9
  28. package/dist/cli/commands/docs.js +1 -9
  29. package/dist/cli/commands/duplicates.js +1 -9
  30. package/dist/cli/commands/eval.js +1 -9
  31. package/dist/cli/commands/extension/describe.js +1 -5
  32. package/dist/cli/commands/extension/scaffold.js +1 -5
  33. package/dist/cli/commands/extension/shared.js +1 -5
  34. package/dist/cli/commands/extension.js +1 -9
  35. package/dist/cli/commands/files.js +1 -9
  36. package/dist/cli/commands/focus.js +1 -9
  37. package/dist/cli/commands/gc.js +1 -9
  38. package/dist/cli/commands/get.js +1 -9
  39. package/dist/cli/commands/graph.js +1 -10
  40. package/dist/cli/commands/health.js +1 -9
  41. package/dist/cli/commands/history-compact.js +1 -10
  42. package/dist/cli/commands/history-redact.js +1 -11
  43. package/dist/cli/commands/history-repair.js +1 -10
  44. package/dist/cli/commands/history.js +1 -5
  45. package/dist/cli/commands/index.js +1 -58
  46. package/dist/cli/commands/init-agent-guidance.js +1 -9
  47. package/dist/cli/commands/init.js +1 -9
  48. package/dist/cli/commands/learnings.js +1 -5
  49. package/dist/cli/commands/lifecycle-transitions.js +1 -5
  50. package/dist/cli/commands/list.js +1 -9
  51. package/dist/cli/commands/merge.js +1 -11
  52. package/dist/cli/commands/next.js +1 -9
  53. package/dist/cli/commands/notes.js +1 -5
  54. package/dist/cli/commands/plan.js +1 -9
  55. package/dist/cli/commands/profile.js +1 -9
  56. package/dist/cli/commands/restore.js +1 -9
  57. package/dist/cli/commands/scheduling-shortcuts.js +1 -9
  58. package/dist/cli/commands/schema.js +1 -10
  59. package/dist/cli/commands/search.js +1 -9
  60. package/dist/cli/commands/stats.js +1 -9
  61. package/dist/cli/commands/telemetry.js +1 -9
  62. package/dist/cli/commands/test-all.js +1 -9
  63. package/dist/cli/commands/test-runs.js +1 -9
  64. package/dist/cli/commands/test.js +1 -9
  65. package/dist/cli/commands/update-many.js +1 -5
  66. package/dist/cli/commands/update.js +1 -9
  67. package/dist/cli/commands/upgrade.js +1 -5
  68. package/dist/cli/commands/validate.js +1 -15
  69. package/dist/cli/context-intent-invocation.js +1 -20
  70. package/dist/cli/description-stdin.js +1 -17
  71. package/dist/cli/error-guidance.js +1 -1353
  72. package/dist/cli/extension-command-help.js +5 -636
  73. package/dist/cli/extension-command-options.js +1 -427
  74. package/dist/cli/extension-recovery.js +1 -126
  75. package/dist/cli/help-content.js +2 -1001
  76. package/dist/cli/help-json-payload.js +4 -570
  77. package/dist/cli/main.d.ts +4 -0
  78. package/dist/cli/main.js +5 -2573
  79. package/dist/cli/migration-gates.js +1 -289
  80. package/dist/cli/public.js +1 -20
  81. package/dist/cli/register-annotations.js +1 -270
  82. package/dist/cli/register-assurance.js +1 -62
  83. package/dist/cli/register-files-lookup.js +1 -56
  84. package/dist/cli/register-history-activity.d.ts +8 -0
  85. package/dist/cli/register-history-activity.js +2 -0
  86. package/dist/cli/register-history-author.js +1 -38
  87. package/dist/cli/register-history-maintenance.d.ts +9 -0
  88. package/dist/cli/register-history-maintenance.js +2 -0
  89. package/dist/cli/register-list-query.js +10 -943
  90. package/dist/cli/register-mutation-options.js +1 -9
  91. package/dist/cli/register-mutation.js +19 -1893
  92. package/dist/cli/register-operations.js +1 -920
  93. package/dist/cli/register-setup.js +1 -716
  94. package/dist/cli/register-structured-mutation.js +1 -196
  95. package/dist/cli/registration-helpers.js +1 -5
  96. package/dist/cli/runtime-compatibility-boundary.js +4 -42
  97. package/dist/cli/schema-registration-helpers.js +1 -73
  98. package/dist/cli/search-refresh.js +1 -13
  99. package/dist/cli/stats-analytics-json.js +1 -68
  100. package/dist/cli/telemetry-flush.js +1 -10
  101. package/dist/cli-bundle/bundle-manifest.json +164 -156
  102. package/dist/cli-bundle/chunks/chunk-3BZZA6A3.js +5 -0
  103. package/dist/cli-bundle/chunks/chunk-AMRDVX36.js +235 -0
  104. package/dist/cli-bundle/chunks/chunk-DAM4CBBR.js +2202 -0
  105. package/dist/cli-bundle/chunks/{chunk-WYRZZ5ZE.js → chunk-DEZPZOQ7.js} +2 -2
  106. package/dist/cli-bundle/chunks/chunk-FLDWYEND.js +77 -0
  107. package/dist/cli-bundle/chunks/{chunk-NPN5I67J.js → chunk-G5ADGQ2D.js} +3 -3
  108. package/dist/cli-bundle/chunks/chunk-JAAEYHUA.js +2 -0
  109. package/dist/cli-bundle/chunks/{chunk-JX4DH4WC.js → chunk-KR3RP4FH.js} +3 -3
  110. package/dist/cli-bundle/chunks/chunk-LEZOUXG6.js +2 -0
  111. package/dist/cli-bundle/chunks/chunk-NSAPNEYH.js +2 -0
  112. package/dist/cli-bundle/chunks/chunk-QOEKOECV.js +29 -0
  113. package/dist/cli-bundle/chunks/chunk-RHSFOMHU.js +2 -0
  114. package/dist/cli-bundle/chunks/chunk-XOD2PCB6.js +20 -0
  115. package/dist/cli-bundle/chunks/{chunk-JT6XF6GE.js → chunk-YVEQ2AMO.js} +4 -4
  116. package/dist/cli-bundle/chunks/register-list-query-KSK3R63M.js +11 -0
  117. package/dist/cli-bundle/chunks/register-mutation-IQ5C7U6O.js +20 -0
  118. package/dist/cli-bundle/chunks/{register-operations-I5W3KMGB.js → register-operations-DWVHR2NC.js} +2 -2
  119. package/dist/cli-bundle/chunks/register-setup-BQ5SVD4B.js +2 -0
  120. package/dist/cli-bundle/focused-chunks/chunk-3WRPWLA7.js +3 -0
  121. package/dist/cli-bundle/focused-chunks/chunk-7MBUII7U.js +2 -0
  122. package/dist/cli-bundle/focused-chunks/chunk-COPBO5HW.js +8 -0
  123. package/dist/cli-bundle/focused-chunks/chunk-DUN4IXYN.js +20 -0
  124. package/dist/cli-bundle/focused-chunks/{chunk-LIJIA4TY.js → chunk-EE5QSM4Z.js} +3 -3
  125. package/dist/cli-bundle/focused-chunks/chunk-HJVARYM3.js +6 -0
  126. package/dist/cli-bundle/focused-chunks/chunk-IAUOUGVR.js +177 -0
  127. package/dist/cli-bundle/focused-chunks/chunk-KOOMJ54F.js +2 -0
  128. package/dist/cli-bundle/focused-chunks/chunk-MZDXX7JY.js +56 -0
  129. package/dist/cli-bundle/focused-chunks/{chunk-M6PBRFSH.js → chunk-OPFHFGDD.js} +2 -2
  130. package/dist/cli-bundle/focused-chunks/chunk-QHNETP77.js +9 -0
  131. package/dist/cli-bundle/focused-chunks/{chunk-3BZEOXLT.js → chunk-RMWES4M6.js} +2 -2
  132. package/dist/cli-bundle/focused-chunks/chunk-RXT4P5QH.js +10 -0
  133. package/dist/cli-bundle/focused-chunks/chunk-SDOL6FM2.js +12 -0
  134. package/dist/cli-bundle/focused-chunks/chunk-SQV4AAUC.js +2 -0
  135. package/dist/cli-bundle/focused-chunks/{chunk-PEFABF7E.js → chunk-WE3IUNIW.js} +3 -3
  136. package/dist/cli-bundle/focused-chunks/chunk-YALOUBWJ.js +2 -0
  137. package/dist/cli-bundle/main.js +20 -20
  138. package/dist/cli-bundle/sdk-authoring.js +1 -1
  139. package/dist/cli-bundle/sdk-contracts.js +2 -2
  140. package/dist/cli-bundle/sdk-core.js +29 -29
  141. package/dist/cli-bundle/sdk-governance.js +1 -1
  142. package/dist/cli-bundle/sdk-graph.js +1 -1
  143. package/dist/cli-bundle/sdk-merge.js +42 -42
  144. package/dist/cli-bundle/sdk-query.js +1 -1
  145. package/dist/cli-bundle/sdk-runtime.js +1 -1
  146. package/dist/cli-bundle/sdk-testing.js +1 -1
  147. package/dist/cli-bundle/sdk.js +11 -11
  148. package/dist/cli.js +1 -104
  149. package/dist/core/checkpoint/checkpoint-gc.js +1 -169
  150. package/dist/core/checkpoint/mutation-checkpoint.js +2 -133
  151. package/dist/core/config/nested-settings.js +1 -534
  152. package/dist/core/config/positional-value.js +1 -109
  153. package/dist/core/diagnostics/remediation.js +1 -506
  154. package/dist/core/extensions/activation-summary-markdown.js +2 -145
  155. package/dist/core/extensions/activation-summary.js +1 -92
  156. package/dist/core/extensions/activation-transaction.js +1 -46
  157. package/dist/core/extensions/capability-usage.js +1 -173
  158. package/dist/core/extensions/command-hook-context.js +1 -13
  159. package/dist/core/extensions/command-metadata-contract.js +1 -22
  160. package/dist/core/extensions/command-visibility-tier.js +1 -29
  161. package/dist/core/extensions/contribution-inventory.js +1 -173
  162. package/dist/core/extensions/exporter-output-contract.js +1 -66
  163. package/dist/core/extensions/extension-candidate.js +1 -18
  164. package/dist/core/extensions/extension-capability-aliases.js +1 -158
  165. package/dist/core/extensions/extension-hook-runtime.js +1 -699
  166. package/dist/core/extensions/extension-policy.js +1 -599
  167. package/dist/core/extensions/extension-registries.js +1 -62
  168. package/dist/core/extensions/extension-runtime-helpers.js +1 -33
  169. package/dist/core/extensions/extension-types.js +1 -102
  170. package/dist/core/extensions/flag-definition-validation.js +1 -52
  171. package/dist/core/extensions/flag-value-types.js +1 -64
  172. package/dist/core/extensions/index.js +1 -526
  173. package/dist/core/extensions/item-field-types.js +1 -39
  174. package/dist/core/extensions/item-fields.js +1 -261
  175. package/dist/core/extensions/loader.js +1 -2223
  176. package/dist/core/extensions/manifest-schema.js +1 -69
  177. package/dist/core/extensions/module-graph-snapshot.js +1 -33
  178. package/dist/core/extensions/preflight-ownership.js +1 -41
  179. package/dist/core/extensions/registration-validation.js +1 -82
  180. package/dist/core/extensions/registration-values.js +1 -209
  181. package/dist/core/extensions/reserved-host-flags.js +1 -36
  182. package/dist/core/extensions/runtime-registrations.js +1 -67
  183. package/dist/core/extensions/service-ownership.js +1 -19
  184. package/dist/core/extensions/version-compat.js +1 -216
  185. package/dist/core/fs/fs-utils.js +2 -158
  186. package/dist/core/fs/host-environment-errors.js +1 -141
  187. package/dist/core/fs/index.js +1 -9
  188. package/dist/core/fs/path-utils.js +1 -17
  189. package/dist/core/governance/content-fields.js +1 -160
  190. package/dist/core/governance/issue-codes.js +1 -151
  191. package/dist/core/governance/metadata-coverage.js +1 -358
  192. package/dist/core/history/drift-cache.js +3 -72
  193. package/dist/core/history/drift-scan.js +1 -342
  194. package/dist/core/history/event-classification.js +1 -109
  195. package/dist/core/history/event-index.js +8 -784
  196. package/dist/core/history/history-compact-bulk.js +1 -104
  197. package/dist/core/history/history-diff.js +1 -158
  198. package/dist/core/history/history-rewrite.d.ts +6 -1
  199. package/dist/core/history/history-rewrite.js +1 -107
  200. package/dist/core/history/history-storage-stats.js +1 -102
  201. package/dist/core/history/history-stream-policy.js +1 -62
  202. package/dist/core/history/history.js +2 -617
  203. package/dist/core/history/identity.js +1 -30
  204. package/dist/core/history/index.js +1 -9
  205. package/dist/core/history/projection.js +1 -196
  206. package/dist/core/history/read.d.ts +9 -0
  207. package/dist/core/history/read.js +1 -57
  208. package/dist/core/history/replay.js +2 -439
  209. package/dist/core/history/version-address.js +1 -32
  210. package/dist/core/history/workspace-history.js +2 -433
  211. package/dist/core/io/body-file.js +1 -62
  212. package/dist/core/io/bulk-ids-input.js +1 -112
  213. package/dist/core/item/actionability.js +1 -327
  214. package/dist/core/item/dependency-reference.js +1 -20
  215. package/dist/core/item/id.js +1 -112
  216. package/dist/core/item/index.js +1 -12
  217. package/dist/core/item/item-format-version.js +1 -78
  218. package/dist/core/item/item-format.js +5 -1473
  219. package/dist/core/item/item-record.js +1 -23
  220. package/dist/core/item/item-type-definition.js +1 -133
  221. package/dist/core/item/parent-reference-policy.js +1 -57
  222. package/dist/core/item/parse.js +2 -603
  223. package/dist/core/item/plan-lifecycle.js +1 -19
  224. package/dist/core/item/priority.js +1 -61
  225. package/dist/core/item/sprint-release-format.js +1 -38
  226. package/dist/core/item/status-filter.js +1 -115
  227. package/dist/core/item/status.js +1 -43
  228. package/dist/core/item/toon-decode.js +1 -29
  229. package/dist/core/item/type-registry.js +1 -715
  230. package/dist/core/item/type-synonyms.js +1 -38
  231. package/dist/core/lock/index.js +1 -9
  232. package/dist/core/lock/lock-gc.js +1 -240
  233. package/dist/core/lock/lock.js +3 -590
  234. package/dist/core/output/mutation-projection.js +1 -217
  235. package/dist/core/output/output-control.js +1 -25
  236. package/dist/core/output/output.js +11 -494
  237. package/dist/core/output/query-summary.js +1 -58
  238. package/dist/core/output/tabular.js +1 -77
  239. package/dist/core/packages/manifest.js +1 -244
  240. package/dist/core/packages/root.js +1 -84
  241. package/dist/core/profile/profile-describe.js +1 -83
  242. package/dist/core/profile/profile-lint.js +1 -415
  243. package/dist/core/profile/profile-plan.js +0 -0
  244. package/dist/core/profile/profile-presets.js +1 -370
  245. package/dist/core/reproducibility/context.js +1 -82
  246. package/dist/core/schema/fields-file.js +2 -288
  247. package/dist/core/schema/item-types-file.js +2 -296
  248. package/dist/core/schema/runtime-field-filters.js +1 -49
  249. package/dist/core/schema/runtime-field-values.js +1 -313
  250. package/dist/core/schema/runtime-schema.js +2 -826
  251. package/dist/core/schema/status-defs-file.js +2 -227
  252. package/dist/core/schema/status-token.js +1 -31
  253. package/dist/core/schema/type-inference.js +1 -95
  254. package/dist/core/schema/type-presets.js +1 -87
  255. package/dist/core/schema/type-workflows.js +1 -104
  256. package/dist/core/search/background-refresh.js +2 -286
  257. package/dist/core/search/bm25.js +1 -146
  258. package/dist/core/search/cache.js +2 -534
  259. package/dist/core/search/corpus.js +1 -311
  260. package/dist/core/search/embedding-batches.js +1 -163
  261. package/dist/core/search/eval.js +1 -225
  262. package/dist/core/search/http-client.js +1 -75
  263. package/dist/core/search/providers.js +1 -242
  264. package/dist/core/search/relevance.js +1 -244
  265. package/dist/core/search/semantic-defaults.js +1 -199
  266. package/dist/core/search/staleness.js +1 -30
  267. package/dist/core/search/vector-stores.js +2 -664
  268. package/dist/core/search/vectorization-metadata.js +1 -81
  269. package/dist/core/sentry/helpers.js +1 -272
  270. package/dist/core/sentry/instrument.js +1 -387
  271. package/dist/core/session/session-state.js +1 -260
  272. package/dist/core/shared/agent-session-context.js +1 -133
  273. package/dist/core/shared/author.js +1 -1172
  274. package/dist/core/shared/command-types.js +1 -4
  275. package/dist/core/shared/conflict-markers.js +1 -31
  276. package/dist/core/shared/constants.js +1 -405
  277. package/dist/core/shared/errors.js +1 -20
  278. package/dist/core/shared/html-entity-decode.js +1 -131
  279. package/dist/core/shared/index.js +1 -12
  280. package/dist/core/shared/item-metadata-contract.js +1 -89
  281. package/dist/core/shared/lazy-module.js +1 -16
  282. package/dist/core/shared/levenshtein.js +1 -61
  283. package/dist/core/shared/memo.js +1 -19
  284. package/dist/core/shared/numeric-parsers.js +1 -20
  285. package/dist/core/shared/option-alias-visibility.js +1 -67
  286. package/dist/core/shared/primitives.js +1 -127
  287. package/dist/core/shared/serial-queue.js +1 -79
  288. package/dist/core/shared/serialization.js +1 -210
  289. package/dist/core/shared/split-comma-list.js +1 -30
  290. package/dist/core/shared/text-normalization.js +1 -38
  291. package/dist/core/shared/time.js +1 -306
  292. package/dist/core/store/index.js +1 -12
  293. package/dist/core/store/item-format-migration.js +1 -125
  294. package/dist/core/store/item-metadata-cache.js +1 -1116
  295. package/dist/core/store/item-metadata-query-index.js +9 -394
  296. package/dist/core/store/item-metadata-read-work.js +1 -43
  297. package/dist/core/store/item-store.js +1 -693
  298. package/dist/core/store/paths.d.ts +1 -1
  299. package/dist/core/store/paths.js +1 -214
  300. package/dist/core/store/settings-read-cache.js +1 -85
  301. package/dist/core/store/settings-validator.js +1 -421
  302. package/dist/core/store/settings.js +3 -1309
  303. package/dist/core/store/tracker-preflight.js +1 -141
  304. package/dist/core/telemetry/consent.js +5 -108
  305. package/dist/core/telemetry/observability.js +1 -246
  306. package/dist/core/telemetry/runtime.js +4 -1988
  307. package/dist/core/test/background-runs.js +4 -945
  308. package/dist/core/test/item-test-run-tracking.js +1 -63
  309. package/dist/core/test/run-selectors.js +1 -120
  310. package/dist/core/validate/estimate-defaults.js +1 -89
  311. package/dist/core/validate/fix-planning.js +1 -189
  312. package/dist/core/validate/linked-artifact-reference.js +1 -36
  313. package/dist/core/validate/missing-by-type.js +1 -34
  314. package/dist/core/validate/missing-link-owners.js +1 -95
  315. package/dist/core/validate/stale-file-classification.js +1 -82
  316. package/dist/mcp/http-server.js +5 -448
  317. package/dist/mcp/legacy-adapter.js +1 -77
  318. package/dist/mcp/runtime-capabilities.js +1 -200
  319. package/dist/mcp/server.js +4 -1233
  320. package/dist/mcp/tool-definitions.js +1 -804
  321. package/dist/sdk/actionability.js +1 -13
  322. package/dist/sdk/agent/closed-domain-contracts.js +1 -161
  323. package/dist/sdk/agent/command-recovery.js +1 -59
  324. package/dist/sdk/agent/command-suggestions.js +1 -66
  325. package/dist/sdk/agent/create-option-policy.js +1 -31
  326. package/dist/sdk/agent/identity-config.js +1 -106
  327. package/dist/sdk/agent/item-addressing.js +1 -207
  328. package/dist/sdk/agent/refusal-closure-census.js +1 -151
  329. package/dist/sdk/agent/refusal-closure.js +1 -133
  330. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -193
  331. package/dist/sdk/agent/refusal-reachability.js +1 -593
  332. package/dist/sdk/agent/subcommand-recovery.js +1 -83
  333. package/dist/sdk/agent/task-transcript-contracts.js +1 -197
  334. package/dist/sdk/agent/tracker-preflight-contracts.js +1 -126
  335. package/dist/sdk/agent-capability-contracts.js +1 -428
  336. package/dist/sdk/agent-session-context.js +1 -9
  337. package/dist/sdk/annotations.js +1 -448
  338. package/dist/sdk/author-attribution.js +1 -468
  339. package/dist/sdk/authoring.js +1 -20
  340. package/dist/sdk/cli-bootstrap.js +1 -838
  341. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +1 -1
  342. package/dist/sdk/cli-contracts/agent-output-contracts.js +4 -476
  343. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -79
  344. package/dist/sdk/cli-contracts/command-aliases.d.ts +4 -0
  345. package/dist/sdk/cli-contracts/command-aliases.js +1 -107
  346. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -151
  347. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1081
  348. package/dist/sdk/cli-contracts/commander-types.js +1 -159
  349. package/dist/sdk/cli-contracts/completeness.js +1 -393
  350. package/dist/sdk/cli-contracts/enum-contracts.js +1 -222
  351. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1947
  352. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -347
  353. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -986
  354. package/dist/sdk/cli-contracts/registration-helpers.js +7 -990
  355. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
  356. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -2090
  357. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -324
  358. package/dist/sdk/cli-contracts/string-lists.js +1 -16
  359. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -461
  360. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -2167
  361. package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -1
  362. package/dist/sdk/cli-contracts/tool-schema.js +1 -1664
  363. package/dist/sdk/cli-contracts/typed-action-inputs.js +1 -4
  364. package/dist/sdk/cli-contracts.d.ts +1 -1
  365. package/dist/sdk/cli-contracts.js +1 -17
  366. package/dist/sdk/cli-program.js +1 -49
  367. package/dist/sdk/command-line.d.ts +2 -5
  368. package/dist/sdk/command-line.js +1 -78
  369. package/dist/sdk/comments.js +1 -133
  370. package/dist/sdk/compile-cache.js +1 -73
  371. package/dist/sdk/completion.js +157 -837
  372. package/dist/sdk/compose.js +1 -1090
  373. package/dist/sdk/config.js +1 -1204
  374. package/dist/sdk/context/recency.js +1 -33
  375. package/dist/sdk/context/semantic-session-attribution.js +1 -82
  376. package/dist/sdk/context/usage-egress.js +1 -29
  377. package/dist/sdk/context/usage-ledger.js +3 -185
  378. package/dist/sdk/context-intent-contracts.js +1 -709
  379. package/dist/sdk/context-intent-runtime.js +1 -115
  380. package/dist/sdk/context-packing.js +1 -218
  381. package/dist/sdk/context-relevance.js +1 -503
  382. package/dist/sdk/context-signal-store.js +2 -426
  383. package/dist/sdk/context-usage.js +1 -367
  384. package/dist/sdk/contracts.js +1 -23
  385. package/dist/sdk/core-governance.js +1 -14
  386. package/dist/sdk/core.js +1 -14
  387. package/dist/sdk/corpus-shape.js +1 -401
  388. package/dist/sdk/define.js +1 -220
  389. package/dist/sdk/dependencies.js +1 -718
  390. package/dist/sdk/dependency-flag-validation.js +1 -156
  391. package/dist/sdk/dependency-provenance.js +1 -135
  392. package/dist/sdk/docs.js +1 -14
  393. package/dist/sdk/duplicates.js +1 -40
  394. package/dist/sdk/environment/agent-environment.js +1 -466
  395. package/dist/sdk/environment/host-environment-errors.js +1 -8
  396. package/dist/sdk/environment/project-runtime-compatibility.js +1 -481
  397. package/dist/sdk/environment/source-context.js +1 -28
  398. package/dist/sdk/environment/tracker-preflight.js +1 -9
  399. package/dist/sdk/error-code-catalog.js +1 -153
  400. package/dist/sdk/error-runtime.js +1 -58
  401. package/dist/sdk/errors.js +1 -58
  402. package/dist/sdk/eval.js +1 -190
  403. package/dist/sdk/extension/author-manifest.js +1 -92
  404. package/dist/sdk/extension/bundled-catalog.js +1 -332
  405. package/dist/sdk/extension/concurrency.js +1 -25
  406. package/dist/sdk/extension/copy-scope.d.ts +2 -0
  407. package/dist/sdk/extension/copy-scope.js +2 -0
  408. package/dist/sdk/extension/custom-field-collisions.js +1 -30
  409. package/dist/sdk/extension/describe.js +3 -189
  410. package/dist/sdk/extension/doctor.js +1 -606
  411. package/dist/sdk/extension/install-plan.d.ts +69 -0
  412. package/dist/sdk/extension/install-plan.js +2 -0
  413. package/dist/sdk/extension/install-receipts.d.ts +7 -0
  414. package/dist/sdk/extension/install-receipts.js +2 -0
  415. package/dist/sdk/extension/install-runtime.js +3 -313
  416. package/dist/sdk/extension/install-snapshot.js +1 -66
  417. package/dist/sdk/extension/install-sources.js +5 -1057
  418. package/dist/sdk/extension/managed-state.js +2 -252
  419. package/dist/sdk/extension/migrations.js +2 -174
  420. package/dist/sdk/extension/output-ownership.js +1 -25
  421. package/dist/sdk/extension/runtime-summary.js +1 -18
  422. package/dist/sdk/extension/scaffold.js +4 -2308
  423. package/dist/sdk/extension/shared.js +1 -147
  424. package/dist/sdk/extension/source-resolution.js +1 -65
  425. package/dist/sdk/extension/update-check.js +1 -67
  426. package/dist/sdk/extension-command-context.js +1 -44
  427. package/dist/sdk/extension-contracts.js +1 -73
  428. package/dist/sdk/extension.d.ts +7 -2
  429. package/dist/sdk/extension.js +1 -2196
  430. package/dist/sdk/files.js +1 -535
  431. package/dist/sdk/flag-invocation-contracts.d.ts +0 -5
  432. package/dist/sdk/flag-invocation-contracts.js +1 -344
  433. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -2224
  434. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -2236
  435. package/dist/sdk/generated-error-code-catalog.js +1 -16
  436. package/dist/sdk/governance/assurance-action-contracts.js +1 -4
  437. package/dist/sdk/governance/assurance-action.js +1 -411
  438. package/dist/sdk/governance/assurance-limits.js +1 -10
  439. package/dist/sdk/governance/assurance-mutation-error.js +1 -81
  440. package/dist/sdk/governance/assurance-presets.js +1 -135
  441. package/dist/sdk/governance/assurance-runtime.js +1 -238
  442. package/dist/sdk/governance/assurance.js +4 -1182
  443. package/dist/sdk/governance/boundary-fixtures.js +1 -200
  444. package/dist/sdk/governance/coverage-assurance.js +1 -60
  445. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -188
  446. package/dist/sdk/governance/defect-recurrence-graph.js +1 -120
  447. package/dist/sdk/governance/defect-recurrence-signals.js +1 -24
  448. package/dist/sdk/governance/defect-recurrence.js +1 -623
  449. package/dist/sdk/governance/extension-host-version.js +1 -115
  450. package/dist/sdk/governance/gc.js +1 -368
  451. package/dist/sdk/governance/health.js +1 -2367
  452. package/dist/sdk/governance/hierarchy-validation.js +1 -108
  453. package/dist/sdk/governance/linked-file-report.js +1 -71
  454. package/dist/sdk/governance/merge-receipt-history.js +1 -206
  455. package/dist/sdk/governance/provenance-health.js +1 -282
  456. package/dist/sdk/governance/reindex.js +4 -761
  457. package/dist/sdk/governance/stale-work.js +1 -82
  458. package/dist/sdk/governance/status-role-diagnostics.js +1 -35
  459. package/dist/sdk/governance/storage-integrity.js +1 -280
  460. package/dist/sdk/governance/tracked-runtime-cache.js +1 -106
  461. package/dist/sdk/governance/upgrade.js +2 -327
  462. package/dist/sdk/governance/validate-history-drift.js +1 -81
  463. package/dist/sdk/governance/validate-item-reader.js +1 -17
  464. package/dist/sdk/governance/validate-normalization.js +1 -36
  465. package/dist/sdk/governance/validate.js +1 -2261
  466. package/dist/sdk/governance/workspace-position.js +1 -163
  467. package/dist/sdk/governance.d.ts +1 -0
  468. package/dist/sdk/governance.js +1 -31
  469. package/dist/sdk/graph/adapter.js +1 -181
  470. package/dist/sdk/graph/analytics.js +1 -474
  471. package/dist/sdk/graph/assembly.js +1 -377
  472. package/dist/sdk/graph/cache.js +1 -160
  473. package/dist/sdk/graph/centrality.js +1 -258
  474. package/dist/sdk/graph/conformance.js +1 -130
  475. package/dist/sdk/graph/deadline-scheduling.d.ts +90 -0
  476. package/dist/sdk/graph/deadline-scheduling.js +2 -0
  477. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  478. package/dist/sdk/graph/durable-cache.js +1 -361
  479. package/dist/sdk/graph/governance-contracts.js +1 -34
  480. package/dist/sdk/graph/governance.d.ts +13 -1
  481. package/dist/sdk/graph/governance.js +1 -735
  482. package/dist/sdk/graph/hierarchy-integrity.js +1 -310
  483. package/dist/sdk/graph/index.d.ts +3 -2
  484. package/dist/sdk/graph/index.js +1 -26
  485. package/dist/sdk/graph/lifecycle-coverage.d.ts +32 -0
  486. package/dist/sdk/graph/lifecycle-coverage.js +2 -0
  487. package/dist/sdk/graph/mutation-advisory.js +1 -176
  488. package/dist/sdk/graph/remediation.js +1 -197
  489. package/dist/sdk/graph/run.d.ts +15 -1
  490. package/dist/sdk/graph/run.js +1 -768
  491. package/dist/sdk/graph/scheduling.js +1 -124
  492. package/dist/sdk/graph/traversal.js +1 -284
  493. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -27
  494. package/dist/sdk/graph.js +1 -15
  495. package/dist/sdk/guide-topics.js +1 -707
  496. package/dist/sdk/guide.js +1 -279
  497. package/dist/sdk/history/maintenance.d.ts +71 -0
  498. package/dist/sdk/history/maintenance.js +2 -0
  499. package/dist/sdk/history/salvage.js +2 -247
  500. package/dist/sdk/history/subject.d.ts +19 -0
  501. package/dist/sdk/history/subject.js +2 -0
  502. package/dist/sdk/history-analytics.js +1 -282
  503. package/dist/sdk/history-compact.js +1 -527
  504. package/dist/sdk/history-mcp.js +1 -68
  505. package/dist/sdk/history-provenance.js +1 -182
  506. package/dist/sdk/history-read.js +1 -96
  507. package/dist/sdk/history-redact.d.ts +1 -14
  508. package/dist/sdk/history-redact.js +1 -643
  509. package/dist/sdk/history-repair.d.ts +5 -0
  510. package/dist/sdk/history-repair.js +1 -657
  511. package/dist/sdk/improvement-ledger-validation.js +1 -62
  512. package/dist/sdk/improvement-ledger.js +2 -257
  513. package/dist/sdk/index.d.ts +4 -0
  514. package/dist/sdk/index.js +1 -183
  515. package/dist/sdk/init-agent-guidance.js +2 -496
  516. package/dist/sdk/init.js +2 -820
  517. package/dist/sdk/invocation-author.js +1 -39
  518. package/dist/sdk/item-children.js +1 -90
  519. package/dist/sdk/item-metadata-index.js +1 -15
  520. package/dist/sdk/item-schedule.js +1 -27
  521. package/dist/sdk/item-transaction.js +1 -396
  522. package/dist/sdk/learnings.js +1 -29
  523. package/dist/sdk/lifecycle/append.js +2 -53
  524. package/dist/sdk/lifecycle/claim.d.ts +2 -0
  525. package/dist/sdk/lifecycle/claim.js +1 -242
  526. package/dist/sdk/lifecycle/close-many.js +1 -438
  527. package/dist/sdk/lifecycle/close.js +1 -468
  528. package/dist/sdk/lifecycle/copy.js +1 -212
  529. package/dist/sdk/lifecycle/create.js +1 -1949
  530. package/dist/sdk/lifecycle/delete.js +1 -45
  531. package/dist/sdk/lifecycle/event-validation-messages.js +1 -91
  532. package/dist/sdk/lifecycle/focus.js +1 -91
  533. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -24
  534. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -149
  535. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -40
  536. package/dist/sdk/lifecycle/mcp-actions.d.ts +2 -0
  537. package/dist/sdk/lifecycle/mcp-actions.js +1 -51
  538. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -46
  539. package/dist/sdk/lifecycle/mutation-command-options.js +1 -9
  540. package/dist/sdk/lifecycle/plan.js +1 -1606
  541. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -147
  542. package/dist/sdk/lifecycle/reopen.js +1 -68
  543. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +1 -143
  544. package/dist/sdk/lifecycle/restore.d.ts +1 -0
  545. package/dist/sdk/lifecycle/restore.js +1 -330
  546. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -295
  547. package/dist/sdk/lifecycle/update-many.js +1 -861
  548. package/dist/sdk/lifecycle/update.js +1 -2136
  549. package/dist/sdk/lifecycle-completion.js +1 -92
  550. package/dist/sdk/lifecycle-policy.js +1 -120
  551. package/dist/sdk/linked-artifacts.js +1 -530
  552. package/dist/sdk/mcp/apps.js +4 -133
  553. package/dist/sdk/mcp/authorization.js +1 -404
  554. package/dist/sdk/mcp/discovery.js +1 -494
  555. package/dist/sdk/mcp/interactions.js +1 -336
  556. package/dist/sdk/mcp/protocol.d.ts +7 -0
  557. package/dist/sdk/mcp/protocol.js +1 -184
  558. package/dist/sdk/mcp/skills.js +1 -389
  559. package/dist/sdk/mcp/subscriptions.js +1 -211
  560. package/dist/sdk/mcp/tasks.js +2 -430
  561. package/dist/sdk/mcp/transport.js +1 -260
  562. package/dist/sdk/merge/abandoned-receipts.js +1 -46
  563. package/dist/sdk/merge/driver.js +1 -212
  564. package/dist/sdk/merge/index.js +1 -16
  565. package/dist/sdk/merge/install.js +3 -561
  566. package/dist/sdk/merge/receipt-file-boundary.js +1 -46
  567. package/dist/sdk/merge/receipt-operation.js +1 -96
  568. package/dist/sdk/merge/receipt-schema.js +1 -397
  569. package/dist/sdk/merge/receipts.js +4 -525
  570. package/dist/sdk/merge/reconcile.js +1 -352
  571. package/dist/sdk/merge/three-way.js +3 -775
  572. package/dist/sdk/merge.js +1 -10
  573. package/dist/sdk/mutation-events.js +1 -292
  574. package/dist/sdk/mutation-guard.js +1 -216
  575. package/dist/sdk/notes.js +1 -139
  576. package/dist/sdk/output-contracts.js +1 -172
  577. package/dist/sdk/output-projection.js +1 -430
  578. package/dist/sdk/output-token-accounting.js +1 -140
  579. package/dist/sdk/output.js +1 -64
  580. package/dist/sdk/ownership-source.js +1 -21
  581. package/dist/sdk/package-import-adapters.js +1 -442
  582. package/dist/sdk/package-migrations.js +1 -20
  583. package/dist/sdk/package-runtime-options.js +1 -80
  584. package/dist/sdk/pagination.js +1 -162
  585. package/dist/sdk/profile.js +1 -454
  586. package/dist/sdk/provenance.js +1 -258
  587. package/dist/sdk/public-surface.json +1 -1
  588. package/dist/sdk/query/activity.js +1 -401
  589. package/dist/sdk/query/aggregate.d.ts +16 -0
  590. package/dist/sdk/query/aggregate.js +1 -390
  591. package/dist/sdk/query/calendar.js +1 -964
  592. package/dist/sdk/query/complete-list.js +1 -215
  593. package/dist/sdk/query/context.js +1 -1702
  594. package/dist/sdk/query/duplicate-candidates.js +1 -70
  595. package/dist/sdk/query/get.js +1 -450
  596. package/dist/sdk/query/history.js +1 -186
  597. package/dist/sdk/query/item-filter-options.js +1 -9
  598. package/dist/sdk/query/light-metadata.js +1 -18
  599. package/dist/sdk/query/list-filter-shared.js +1 -81
  600. package/dist/sdk/query/list.js +1 -1304
  601. package/dist/sdk/query/multi-value-filters.js +1 -78
  602. package/dist/sdk/query/next.js +1 -513
  603. package/dist/sdk/query/parsers.js +1 -44
  604. package/dist/sdk/query/projection-contracts.js +1 -184
  605. package/dist/sdk/query/search-contracts.js +1 -230
  606. package/dist/sdk/query/search-pagination.js +1 -35
  607. package/dist/sdk/query/search-rendering.js +1 -105
  608. package/dist/sdk/query/search.js +2 -1987
  609. package/dist/sdk/query.js +1 -35
  610. package/dist/sdk/read-output/continuation.js +1 -194
  611. package/dist/sdk/read-output-budget.js +1 -135
  612. package/dist/sdk/read-output-contracts.js +1 -1225
  613. package/dist/sdk/read-output-rows.js +1 -186
  614. package/dist/sdk/read-output-session.js +1 -208
  615. package/dist/sdk/relationship-analytics.js +1 -410
  616. package/dist/sdk/relationship-context.js +1 -284
  617. package/dist/sdk/relationship-history.js +4 -519
  618. package/dist/sdk/relationship-kinds/contract.js +1 -22
  619. package/dist/sdk/relationship-migration.js +1 -77
  620. package/dist/sdk/relationships.js +1 -579
  621. package/dist/sdk/reproducibility/process.js +1 -87
  622. package/dist/sdk/runtime-action-aliases.js +1 -59
  623. package/dist/sdk/runtime-extended-actions.js +1 -177
  624. package/dist/sdk/runtime-input.js +1 -614
  625. package/dist/sdk/runtime-primitives.js +1 -84
  626. package/dist/sdk/runtime-public-contracts.js +1 -4
  627. package/dist/sdk/runtime-stats-options.js +1 -38
  628. package/dist/sdk/runtime.js +1 -1928
  629. package/dist/sdk/scheduling-shortcuts.js +1 -63
  630. package/dist/sdk/schema-migration.js +3 -856
  631. package/dist/sdk/schema.js +1 -1376
  632. package/dist/sdk/search-refresh-worker.js +1 -18
  633. package/dist/sdk/similarity-scoring.js +1 -53
  634. package/dist/sdk/similarity.js +1 -326
  635. package/dist/sdk/start-task-status.js +1 -14
  636. package/dist/sdk/stats.js +1 -270
  637. package/dist/sdk/structured-mutations.js +1 -580
  638. package/dist/sdk/telemetry-flush.js +1 -13
  639. package/dist/sdk/telemetry.js +1 -405
  640. package/dist/sdk/templates.js +2 -292
  641. package/dist/sdk/test/batch.js +2 -509
  642. package/dist/sdk/test/entry.js +1 -70
  643. package/dist/sdk/test/execution.js +6 -2211
  644. package/dist/sdk/test/linked-command-detection.js +1 -546
  645. package/dist/sdk/test/measurements.js +1 -91
  646. package/dist/sdk/test/parsers.js +1 -545
  647. package/dist/sdk/test/runs.js +1 -193
  648. package/dist/sdk/test/trust.js +2 -206
  649. package/dist/sdk/testing.js +4 -1391
  650. package/dist/sdk/traceability/runtime-files-lookup.js +1 -32
  651. package/dist/sdk/traceability/source-traceability.js +1 -292
  652. package/dist/sdk/tracker-root-discovery.js +1 -9
  653. package/dist/sdk/workspace-contracts-cache.js +1 -28
  654. package/dist/sdk/workspace-contracts.js +1 -33
  655. package/dist/sdk/workspace-memory.js +2 -318
  656. package/dist/sdk/workspace-recipe.js +1 -71
  657. package/dist/sdk/workspace-snapshot.js +4 -613
  658. package/dist/sdk/workspace-transaction-gc.js +1 -149
  659. package/dist/sdk/workspace-transaction.js +2 -363
  660. package/dist/sdk/workspace.js +3 -127
  661. package/dist/types/index.js +1 -9
  662. package/dist/types.js +1 -245
  663. package/docs/AGENT_GUIDE.md +1 -1
  664. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +167 -0
  665. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +9 -3
  666. package/docs/EXTENSIONS.md +1 -0
  667. package/docs/HISTORY_MAINTENANCE.md +125 -0
  668. package/docs/MCP_2026_07_28_CONFORMANCE.md +20 -10
  669. package/docs/PACKAGE_EVIDENCE.md +92 -0
  670. package/docs/PLANNING_MEASUREMENTS.md +183 -0
  671. package/docs/README.md +3 -0
  672. package/docs/RELEASING.md +1 -0
  673. package/docs/SCRIPTING.md +21 -0
  674. package/docs/TESTING.md +23 -0
  675. package/docs/generated/FLAG_LEXICON_BUDGETS.md +5 -5
  676. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +2 -2
  677. package/marketplace.json +2 -2
  678. package/package.json +1 -1
  679. package/packages/pm-beads/package.json +1 -1
  680. package/packages/pm-calendar/package.json +1 -1
  681. package/packages/pm-command-kit/package.json +1 -1
  682. package/packages/pm-digital-twin/package.json +1 -1
  683. package/packages/pm-governance-audit/package.json +1 -1
  684. package/packages/pm-guide-shell/package.json +1 -1
  685. package/packages/pm-kanban/package.json +1 -1
  686. package/packages/pm-lifecycle-hooks/package.json +1 -1
  687. package/packages/pm-linked-test-adapters/package.json +1 -1
  688. package/packages/pm-search-advanced/package.json +1 -1
  689. package/packages/pm-templates/package.json +1 -1
  690. package/packages/pm-todos/package.json +1 -1
  691. package/packages/pm-vcs/package.json +1 -1
  692. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  693. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  694. package/scripts/finalize-build.mjs +45 -3
  695. package/dist/cli-bundle/chunks/chunk-AZDFJGH6.js +0 -9
  696. package/dist/cli-bundle/chunks/chunk-BAX2BYUW.js +0 -2111
  697. package/dist/cli-bundle/chunks/chunk-CKOL5U7J.js +0 -77
  698. package/dist/cli-bundle/chunks/chunk-OF76PSDQ.js +0 -5
  699. package/dist/cli-bundle/chunks/chunk-QUWFABDM.js +0 -232
  700. package/dist/cli-bundle/chunks/chunk-QWRRFYK3.js +0 -2
  701. package/dist/cli-bundle/chunks/chunk-RWWBOWJ5.js +0 -2
  702. package/dist/cli-bundle/chunks/chunk-WGAOYSYH.js +0 -40
  703. package/dist/cli-bundle/chunks/chunk-WI2AYPA7.js +0 -2
  704. package/dist/cli-bundle/chunks/register-list-query-5JL52D33.js +0 -11
  705. package/dist/cli-bundle/chunks/register-mutation-ZPG7KMVP.js +0 -20
  706. package/dist/cli-bundle/chunks/register-setup-H4SVAVX7.js +0 -2
  707. package/dist/cli-bundle/focused-chunks/chunk-AL5ON6K6.js +0 -2
  708. package/dist/cli-bundle/focused-chunks/chunk-CHC2IDXA.js +0 -6
  709. package/dist/cli-bundle/focused-chunks/chunk-CK6QFAPZ.js +0 -20
  710. package/dist/cli-bundle/focused-chunks/chunk-EZR3GHFE.js +0 -2
  711. package/dist/cli-bundle/focused-chunks/chunk-H2WJWK7L.js +0 -56
  712. package/dist/cli-bundle/focused-chunks/chunk-NTPY5GSO.js +0 -3
  713. package/dist/cli-bundle/focused-chunks/chunk-P5O7MP5Y.js +0 -2
  714. package/dist/cli-bundle/focused-chunks/chunk-PDMW2E36.js +0 -177
  715. package/dist/cli-bundle/focused-chunks/chunk-QTVCLMSZ.js +0 -6
  716. package/dist/cli-bundle/focused-chunks/chunk-QTZRBUYA.js +0 -8
  717. package/dist/cli-bundle/focused-chunks/chunk-SGQST3PQ.js +0 -12
  718. package/dist/cli-bundle/focused-chunks/chunk-UKHASMMP.js +0 -10
  719. package/dist/cli-bundle/focused-chunks/chunk-ZPEKQHOC.js +0 -2
@@ -1,1929 +1,2 @@
1
- /**
2
- * @module sdk/runtime
3
- *
4
- * Defines public SDK APIs and package-author helpers for Runtime.
5
- */
6
-
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="422ff60b-97b1-5477-a7b8-ed4f983155e0")}catch(e){}}();
8
- export { PM_GITIGNORE_END, PM_GITIGNORE_START, ensurePmGitignore, getPmGitignoreBlock, } from "./workspace.js";
9
- export { SEARCH_EXTENSION_FLAG_DEFINITIONS } from "./extension-contracts.js";
10
- export * from "./cli-contracts/agent-output-contracts.js";
11
- import { AsyncLocalStorage } from "node:async_hooks";
12
- import path from "node:path";
13
- import { createEmptyExtensionCommandRegistry, createEmptyExtensionHookRegistry, createEmptyExtensionParserRegistry, createEmptyExtensionPreflightRegistry, createEmptyExtensionRegistrationRegistry, createEmptyExtensionRendererRegistry, createEmptyExtensionServiceRegistry, } from "../core/extensions/extension-registries.js";
14
- import { activateExtensions, deactivateExtensions, loadExtensions, runActiveCommandHandler, runWithIsolatedExtensionRuntime, setActiveExtensionCommands, setActiveExtensionHooks, setActiveExtensionParsers, setActiveExtensionPreflight, setActiveExtensionRegistrations, setActiveExtensionRenderers, setActiveExtensionServices, } from "../core/extensions/index.js";
15
- import { pathExists } from "../core/fs/fs-utils.js";
16
- import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
17
- import { projectMutationResult } from "../core/output/mutation-projection.js";
18
- import { withQuerySummary } from "../core/output/query-summary.js";
19
- import { EXIT_CODE } from "../core/shared/constants.js";
20
- import { PmCliError } from "../core/shared/errors.js";
21
- import { asRecordClone } from "../core/shared/primitives.js";
22
- import { createAsyncReadWriteGate } from "../core/shared/serial-queue.js";
23
- import { resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, } from "../core/schema/runtime-schema.js";
24
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
25
- import { readSettings } from "../core/store/settings.js";
26
- import { listClientItemMetadataLight } from "./query/light-metadata.js";
27
- import { certifyCompleteListResult, createCompleteListOptions } from "./query/complete-list.js";
28
- export { PmCompleteListValidationError, assertCompleteListResult, certifyCompleteListResult, createCompleteListOptions, inspectCompleteListResult } from "./query/complete-list.js";
29
- import { buildWorkspaceExtensionCommandContracts, buildWorkspaceFieldContracts, } from "./workspace-contracts.js";
30
- import { PM_TOOL_ACTIONS } from "./cli-contracts/enum-contracts.js";
31
- import { clearWorkspaceContractsCache, memoizeWorkspaceExtensionRegistrations, } from "./workspace-contracts-cache.js";
32
- import { SDK_ACTION_ALIASES } from "./runtime-action-aliases.js";
33
- import { createExtensionCommandSdk } from "./extension-command-context.js";
34
- import { createUnknownSubcommandError } from "./agent/subcommand-recovery.js";
35
- import { applyContextIntentProjection, attachReadOutputContracts, } from "./context-intent-contracts.js";
36
- import { finalizeContextUsageEgress } from "./context/usage-egress.js";
37
- import { runWithDiscoveredContextIntentContracts, } from "./context-intent-runtime.js";
38
- import { normalizeReadOutputIncludeModeOptions, validateReadOutputOptions, } from "./read-output-contracts.js";
39
- export { clearWorkspaceContractsCache } from "./workspace-contracts-cache.js";
40
- import { normalizeActivityProjectionOptions, runActivity, } from "./query/activity.js";
41
- import { runAssuranceDispatch } from "./governance/assurance-action.js";
42
- import { runAggregate, } from "./query/aggregate.js";
43
- import { runAppend } from "./lifecycle/append.js";
44
- import { runClaim, runClaimNext, runRelease } from "./lifecycle/claim.js";
45
- import { runCloseMany } from "./lifecycle/close-many.js";
46
- import { normalizeAnnotationTransportOptions } from "./annotations.js";
47
- import { runComments } from "./comments.js";
48
- import { runHistory } from "./query/history.js";
49
- import { runLearnings } from "./learnings.js";
50
- import { runNotes } from "./notes.js";
51
- import { runUpdateMany } from "./lifecycle/update-many.js";
52
- import { runUpgrade, } from "./governance/upgrade.js";
53
- import { runCreate } from "./lifecycle/create.js";
54
- import { runUpdate } from "./lifecycle/update.js";
55
- import { runPlan, } from "./lifecycle/plan.js";
56
- import { runContext, } from "./query/context.js";
57
- import { runNext } from "./query/next.js";
58
- import { runClose } from "./lifecycle/close.js";
59
- import { runCopy } from "./lifecycle/copy.js";
60
- import { runDelete } from "./lifecycle/delete.js";
61
- import { runRestore } from "./lifecycle/restore.js";
62
- import { runFocus } from "./lifecycle/focus.js";
63
- import { runGet } from "./query/get.js";
64
- import { runGc, } from "./governance/gc.js";
65
- import { runHealth, } from "./governance/health.js";
66
- import { runValidate, } from "./governance/validate.js";
67
- import { runExtension, } from "./extension.js";
68
- import { runConfig } from "./config.js";
69
- import { INIT_INVOCATION_CWD, runInit } from "./init.js";
70
- import { runRuntimeEvalAction, runRuntimeEventsAction, runRuntimeMergeAction, runRuntimeSchedulingAction, runRuntimeWorkspaceAction, } from "./runtime-extended-actions.js";
71
- import { acknowledgeUnknownAuthorHistoryEventsFromTransport, } from "./author-attribution.js";
72
- import { PROFILE_SUBCOMMANDS, runProfileApply, runProfileLint, runProfileList, runProfileShow, } from "./profile.js";
73
- import { runHistoryRedact, } from "./history-redact.js";
74
- import { runMcpHistoryCompactAction, runMcpHistoryRepairAction, } from "./history-mcp.js";
75
- import { runMcpCloseAction, runMcpReopenAction } from "./lifecycle/mcp-actions.js";
76
- import { actionGlobalOptions as globalOptions, closeManyOptionsFromFlat, extensionOptionsFromArgs, graphOptionsFromFlat, mutationListOptions, mutationOptionsWithOverrides, normalizeActionName, normalizeCommandPath, normalizeMcpOptionsArrays, normalizeMcpUpdateOptions, optionsWithAuthor, parseRuntimeInteger as parseMcpInteger, readRuntimeScalarString as readScalarString, readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank, readRuntimeString as readString, readRuntimeStringArray as readStringArray, resolveRuntimeLimit, shouldInvalidateWorkspaceContractsCacheAfterAction, updateManyOptionsFromFlat, withAddNoteOption, withFilesDiscoveryOptions, withMutationCompaction, } from "./runtime-input.js";
77
- import { runDeps } from "./dependencies.js";
78
- import { runDocs } from "./docs.js";
79
- import { runGraph, } from "./graph/run.js";
80
- import { runFiles, runFilesDiscover, runFilesLookup } from "./files.js";
81
- import { runtimeFilesLookupOptions } from "./traceability/runtime-files-lookup.js";
82
- import { runContracts, } from "./cli-contracts/runtime-contracts.js";
83
- import { runList } from "./query/list.js";
84
- import { runSearch, } from "./query/search.js";
85
- import { runStats, } from "./stats.js";
86
- import { statsCommandOptionsFromRuntime } from "./runtime-stats-options.js";
87
- import { runDuplicates, } from "./duplicates.js";
88
- import { runTelemetry } from "./telemetry.js";
89
- import { runTest } from "./test/execution.js";
90
- import { runTestAll } from "./test/batch.js";
91
- import { resolveStartTaskInProgressStatus } from "./start-task-status.js";
92
- import { SCHEMA_SUBCOMMANDS, runSchemaAddField, runSchemaAddStatus, runSchemaAddType, runSchemaApplyPreset, runSchemaInferTypes, runSchemaList, runSchemaListFields, runSchemaEvolutionMigration, runSchemaRemoveField, runSchemaRemoveStatus, runSchemaRemoveType, runSchemaShow, runSchemaShowField, runSchemaShowStatus, } from "./schema.js";
93
- export { getActiveExtensionRegistrations, runActiveOnReadHooks, runActiveOnWriteHooks, } from "../core/extensions/index.js";
94
- export { pathExists, readFileIfExists, removeFileIfExists, writeFileAtomic, } from "../core/fs/fs-utils.js";
95
- export { appendHistoryEntry, createHistoryEntry, } from "../core/history/history.js";
96
- export { classifyHistoryEvent, HISTORY_EVENT_CLASSIFICATION_VERSION, MAINTENANCE_HISTORY_OPERATIONS, SUBSTANTIVE_HISTORY_OPERATIONS } from "../core/history/event-classification.js";
97
- export { generateItemId, normalizeItemId, normalizeRawItemId, } from "../core/item/id.js";
98
- export { readBooleanOption, readCsvListOption, readStringOption, } from "./package-runtime-options.js";
99
- export { PM_CLI_EXPECTED_ERROR_NAME, createPmCliExpectedError, isPmCliExpectedError, } from "./errors.js";
100
- export { commitImportedItem, emptyImportedDocument, ensureTrackerInitialized, selectImportAuthor, toEstimatedMinutesValue, toImportBoolean, toImportConfidence, toImportInteger, toImportLinkedDocs, toImportLinkedFiles, toImportLinkedTests, toImportLogEntries, toImportNormalizedEnum, toImportNumberMap, toImportPriority, toImportStatus, toImportStringList, toImportStringMap, toImportTags, toNonEmptyImportString, } from "./package-import-adapters.js";
101
- export { canonicalDocument, normalizeItemMetadata, serializeItemDocument, splitFrontMatter, } from "../core/item/item-format.js";
102
- export { BASELINE_ITEM_FORMAT_VERSION, CURRENT_ITEM_FORMAT_VERSION, classifyItemFormatVersion, effectiveItemFormatVersion, normalizeItemFormatVersion, scanItemFormatVersions, } from "../core/item/item-format-version.js";
103
- export { parseTags } from "../core/item/parse.js";
104
- export { isTerminalStatus, normalizeStatusInput } from "../core/item/status.js";
105
- export { resolveItemTypeRegistry } from "../core/item/type-registry.js";
106
- export { acquireLock } from "../core/lock/lock.js";
107
- export { resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, } from "../core/schema/runtime-schema.js";
108
- export { EXIT_CODE };
109
- export { PmCliError } from "../core/shared/errors.js";
110
- export { isTimestampLiteral, nowIso } from "../core/shared/time.js";
111
- export { jaccardSimilarity, normalizeSimilarityText, scoreItemSimilarity, tokenizeSimilarityText, } from "./similarity-scoring.js";
112
- export { listAllItemMetadata, listAllItemMetadataLight, locateItem, readLocatedItem, } from "../core/store/item-store.js";
113
- export { getHistoryPath, getItemPath, getSettingsPath, resolveImplicitPmRoot, resolvePmRoot, } from "../core/store/paths.js";
114
- export { readSettings } from "../core/store/settings.js";
115
- export { runAggregate, } from "./query/aggregate.js";
116
- export { CONTEXT_OUTPUT_VALUES, runContext, } from "./query/context.js";
117
- export { runGet } from "./query/get.js";
118
- export { runList, } from "./query/list.js";
119
- export { closeItem, runClose, } from "./lifecycle/close.js";
120
- export { runCopy, } from "./lifecycle/copy.js";
121
- export { runDelete, } from "./lifecycle/delete.js";
122
- export { runFocus, } from "./lifecycle/focus.js";
123
- export { runRestore, } from "./lifecycle/restore.js";
124
- export { DEFAULT_TERMINAL_TRANSITION_POLICY, applyTerminalOrderingPolicy, requireTerminalReason, resolveTerminalReason, } from "./lifecycle-policy.js";
125
- export { runUpdate } from "./lifecycle/update.js";
126
- export { runReopen } from "./lifecycle/reopen.js";
127
- export { NEXT_OUTPUT_VALUES, runNext, } from "./query/next.js";
128
- export { runSearch, } from "./query/search.js";
129
- export { runStats, } from "./stats.js";
130
- export { runDuplicates, } from "./duplicates.js";
131
- export { renderCalendarMarkdown, renderCalendarToon, resolveCalendarOutputFormat, runCalendar, } from "./query/calendar.js";
132
- export { renderGuideMarkdown, resolveGuideOutputFormat, runGuide, } from "./guide.js";
133
- export { runCompletion, } from "./completion.js";
134
- export { runReindex, } from "./governance/reindex.js";
135
- export { loadCreateTemplateOptions, runTemplatesList, runTemplatesSave, runTemplatesShow, } from "./templates.js";
136
- export { runTestRunsList, runTestRunsLogs, runTestRunsResume, runTestRunsStatus, runTestRunsStop, } from "./test/runs.js";
137
- export { CONFIDENCE_TEXT_VALUES, DEPENDENCY_KIND_VALUES, BUILTIN_ITEM_TYPE_VALUES, ISSUE_SEVERITY_VALUES, ITEM_TYPE_VALUES, RISK_VALUES, STATUS_VALUES, } from "../types/index.js";
138
- const ACTIVE_EXTENSION_HOST_CONTEXT = Symbol("pm.active-extension-host-context");
139
- function splitFullClientMutationOptions(options) {
140
- return { fullChangedFields: true, options };
141
- }
142
- /**
143
- * Programmatic pm client for custom tools, CI jobs, bots, and embedded runtimes.
144
- *
145
- * Extension registries are request-local, so calls that resolve workspaces from
146
- * `pmRoot` can activate and dispatch concurrently without leaking registrations
147
- * across clients. Calls with an explicit `cwd` remain serialized because
148
- * `process.chdir` is process-global.
149
- *
150
- * Convenience methods accept command options only. Use {@link PmClient.run} for
151
- * per-call runtime overrides such as `cwd`, `path`, or `noExtensions`.
152
- */
153
- export class PmClient {
154
- defaults;
155
- /** Create a client with workspace, author, and extension-loading defaults. */
156
- constructor(options = {}) {
157
- this.defaults = {
158
- ...(options.pmRoot === undefined ? {} : { path: options.pmRoot }),
159
- ...(options.cwd === undefined ? {} : { cwd: options.cwd }),
160
- ...(options.author === undefined ? {} : { author: options.author }),
161
- ...(options.noExtensions === undefined
162
- ? {}
163
- : { noExtensions: options.noExtensions }),
164
- };
165
- }
166
- /** Create a native-action client that reuses an extension host's active schema context. */
167
- static forActiveExtensionHost(options) {
168
- const client = new PmClient({ ...options, noExtensions: true });
169
- client.defaults[ACTIVE_EXTENSION_HOST_CONTEXT] = true;
170
- return client;
171
- }
172
- /** Run any native or extension-contributed action through the SDK dispatcher. */
173
- run(action, args = {}) {
174
- return runAction({ ...this.defaults, ...args, action });
175
- }
176
- runTyped(action, args = {}) {
177
- return this.run(action, args);
178
- }
179
- /** Return the same context snapshot produced by `pm context`. */
180
- context(options = {}) {
181
- return this.runTyped("context", { options });
182
- }
183
- /** Read every item through the scalar-only metadata cache without materializing heavy collections or bodies. */
184
- listAllItemMetadataLight() {
185
- return listClientItemMetadataLight(this.defaults.path, this.defaults.cwd);
186
- }
187
- /** List items with the MCP/agent compact defaults. */
188
- list(options = {}) {
189
- return this.runTyped("list", { options });
190
- }
191
- /** Return every status and full item row only after fail-closed corpus certification. */
192
- async listAllComplete(options = {}) { return certifyCompleteListResult(await this.list(createCompleteListOptions(options))); }
193
- /** Search items with the MCP/agent compact defaults. */
194
- search(query, options = {}) {
195
- return this.runTyped("search", { query, options });
196
- }
197
- /** Read one item by id. */
198
- get(id, options = {}) {
199
- return this.runTyped("get", { id, options });
200
- }
201
- /** Return the ranked next-work recommendation produced by `pm next`. */
202
- next(options = {}) {
203
- return this.runTyped("next", { options });
204
- }
205
- /** Group matching items with the same semantics as `pm aggregate`. */
206
- aggregate(options = {}) {
207
- return this.runTyped("aggregate", { options });
208
- }
209
- /** Return project tracker statistics with the same sections as `pm stats`. */
210
- stats(options = {}) {
211
- return this.runTyped("stats", { options });
212
- }
213
- /** Discover existing duplicate clusters without mutating tracker state. */
214
- duplicates(options = {}) {
215
- return this.runTyped("duplicates", { options });
216
- }
217
- /** List or mutate comments, including lock-scoped idempotent appends. */
218
- comments(id, options = {}) {
219
- return this.runTyped("comments", { id, options });
220
- }
221
- /** List or mutate private notes, including lock-scoped idempotent appends. */
222
- notes(id, options = {}) {
223
- return this.runTyped("notes", { id, options });
224
- }
225
- /** List or mutate durable learnings, including lock-scoped idempotent appends. */
226
- learnings(id, options = {}) {
227
- return this.runTyped("learnings", { id, options });
228
- }
229
- /** Add, remove, clear, or list linked project files for an item. */
230
- files(id, options = {}) {
231
- return this.runTyped("files", { id, options });
232
- }
233
- /** Discover and optionally attach changed files for an item. */
234
- filesDiscover(id, options = {}) {
235
- return this.runTyped("files-discover", { id, options });
236
- }
237
- /** Find the items that reference one or more source paths. */
238
- filesLookup(options) {
239
- return this.runTyped("files-lookup", { options });
240
- }
241
- /** Add, remove, clear, or list linked documentation for an item. */
242
- docs(id, options = {}) {
243
- return this.runTyped("docs", { id, options });
244
- }
245
- /** Inspect item dependency relationships. */
246
- deps(id, options = {}) {
247
- return this.runTyped("deps", { id, options });
248
- }
249
- /** Run bounded workspace graph traversal, analytics, or governance-audit queries. */
250
- graph(subcommand, ids = {}, options = {}) {
251
- return this.runTyped("graph", { subcommand, ...ids, options });
252
- }
253
- /** Append markdown/body text to an item through the mutation pipeline. */
254
- append(id, body, options = {}) {
255
- return this.runTyped("append", {
256
- id,
257
- ...splitFullClientMutationOptions(mutationOptionsWithOverrides(options, { body })),
258
- });
259
- }
260
- /** Initialize a workspace with the same semantics as `pm init`. */
261
- init(prefix, options = {}) {
262
- return this.runTyped("init", {
263
- ...(prefix === undefined ? {} : { prefix }),
264
- options,
265
- });
266
- }
267
- /** Read or update project/global configuration. */
268
- config(scope, configAction, key, value, options = {}) {
269
- return this.runTyped("config", {
270
- scope,
271
- configAction,
272
- ...(key === undefined ? {} : { key }),
273
- ...(value === undefined ? {} : { value }),
274
- options,
275
- });
276
- }
277
- /** Run the schema customization surface. */
278
- schema(subcommand, options = {}) {
279
- return this.runTyped("schema", { options: { ...options, subcommand } });
280
- }
281
- /** List built-in, custom, and extension-provided schema types/statuses. */
282
- schemaList() {
283
- return this.runTyped("schema", { options: { subcommand: "list" } });
284
- }
285
- /** Show a schema item type definition. */
286
- schemaShow(name) {
287
- return this.runTyped("schema", { name, options: { subcommand: "show" } });
288
- }
289
- /** Register or replace a custom item type. */
290
- schemaAddType(name, options = {}) {
291
- return this.runTyped("schema", {
292
- name,
293
- options: { ...options, subcommand: "add-type" },
294
- });
295
- }
296
- /** Remove a custom item type. */
297
- schemaRemoveType(name, options = {}) {
298
- return this.runTyped("schema", {
299
- name,
300
- options: { ...options, subcommand: "remove-type" },
301
- });
302
- }
303
- /** Register or replace a custom status. */
304
- schemaAddStatus(name, options = {}) {
305
- return this.runTyped("schema", {
306
- name,
307
- options: { ...options, subcommand: "add-status" },
308
- });
309
- }
310
- /** Remove a custom status. */
311
- schemaRemoveStatus(name, options = {}) {
312
- return this.runTyped("schema", {
313
- name,
314
- options: { ...options, subcommand: "remove-status" },
315
- });
316
- }
317
- /** Register or replace a runtime custom field. */
318
- schemaAddField(name, options = {}) {
319
- return this.runTyped("schema", {
320
- name,
321
- options: { ...options, subcommand: "add-field" },
322
- });
323
- }
324
- /** Remove a runtime custom field. */
325
- schemaRemoveField(name, options = {}) {
326
- return this.runTyped("schema", {
327
- name,
328
- options: { ...options, subcommand: "remove-field" },
329
- });
330
- }
331
- /** List runtime custom fields. */
332
- schemaListFields() {
333
- return this.runTyped("schema", { options: { subcommand: "list-fields" } });
334
- }
335
- /** Show one runtime custom field definition. */
336
- schemaShowField(name) {
337
- return this.runTyped("schema", {
338
- name,
339
- options: { subcommand: "show-field" },
340
- });
341
- }
342
- /** Apply a built-in type preset to the workspace schema. */
343
- schemaApplyPreset(typePreset, options = {}) {
344
- return this.runTyped("schema", {
345
- typePreset,
346
- options: { ...options, subcommand: "apply-preset" },
347
- });
348
- }
349
- /** Infer item types from the current tracker and optionally apply them. */
350
- schemaInferTypes(options = {}) {
351
- return this.runTyped("schema", {
352
- options: { ...options, subcommand: "add-type", infer: true },
353
- });
354
- }
355
- /** Rename a custom item type and migrate every affected item atomically. */
356
- schemaRenameType(from, to, options) {
357
- return this.runTyped("schema", {
358
- name: from,
359
- options: { ...options, subcommand: "rename-type", to },
360
- });
361
- }
362
- /** Rename a custom metadata field and migrate every affected item atomically. */
363
- schemaRenameField(from, to, options, type) {
364
- return this.runTyped("schema", {
365
- name: from,
366
- options: {
367
- ...options,
368
- subcommand: "rename-field",
369
- to,
370
- ...(type ? { fieldTypeScope: type } : {}),
371
- },
372
- });
373
- }
374
- /** Remap a custom lifecycle status and migrate every affected item atomically. */
375
- schemaRemapStatus(from, to, options) {
376
- return this.runTyped("schema", {
377
- name: from,
378
- options: { ...options, subcommand: "remap-status", to },
379
- });
380
- }
381
- /** Show one runtime status definition. */
382
- schemaShowStatus(name) {
383
- return this.runTyped("schema", {
384
- name,
385
- options: { subcommand: "show-status" },
386
- });
387
- }
388
- /** Run the profile customization surface. */
389
- profile(subcommand, options = {}) {
390
- return this.runTyped("profile", { options: { ...options, subcommand } });
391
- }
392
- /** List available project profiles. */
393
- profileList() {
394
- return this.runTyped("profile", { options: { subcommand: "list" } });
395
- }
396
- /** Show a project profile. */
397
- profileShow(name) {
398
- return this.runTyped("profile", { name, options: { subcommand: "show" } });
399
- }
400
- /** Apply a project profile. */
401
- profileApply(name, options = {}) {
402
- return this.runTyped("profile", {
403
- name,
404
- options: { ...options, subcommand: "apply" },
405
- });
406
- }
407
- /** Lint a project profile. */
408
- profileLint(name) {
409
- return this.runTyped("profile", { name, options: { subcommand: "lint" } });
410
- }
411
- /** Run project validation checks. */
412
- validate(options = {}) {
413
- return this.runTyped("validate", { options });
414
- }
415
- /** Run project health checks. */
416
- health(options = {}) {
417
- return this.runTyped("health", { options });
418
- }
419
- /** Run tracker cache/runtime garbage collection. */
420
- gc(options = {}) {
421
- return this.runTyped("gc", { options });
422
- }
423
- /** Declare, inspect, or evaluate a project assurance contract. */
424
- assurance(input) {
425
- return this.runTyped("assurance", { options: { ...input, subcommand: input.action } });
426
- }
427
- /** Redact sensitive values while preserving an audited, verified history chain. */
428
- historyRedact(id, options) {
429
- return this.runTyped("history-redact", { id, options });
430
- }
431
- /** Repair and re-anchor one drifted history stream. */
432
- historyRepair(id, options = {}) {
433
- return this.runTyped("history-repair", { id, options });
434
- }
435
- /** Scan and repair every drifted history stream in one resilient pass. */
436
- historyRepairAll(options = {}) {
437
- return this.runTyped("history-repair", {
438
- options: { ...options, all: true },
439
- });
440
- }
441
- /** Compact one history stream into a verified checkpoint and retained tail. */
442
- historyCompact(id, options = {}) {
443
- return this.runTyped("history-compact", { id, options });
444
- }
445
- /** Compact an explicit or policy-selected set of history streams. */
446
- historyCompactBulk(options) {
447
- return this.runTyped("history-compact", { options });
448
- }
449
- /** Disposition immutable unknown-author events through append-only audit history. */
450
- historyAuthorAcknowledge(options) {
451
- return this.runTyped("history-author-acknowledge", {
452
- historyEvent: (options.events ?? []).map((event) => `${event.item_id}:${String(event.line)}`),
453
- allActionable: options.all_actionable === true,
454
- dryRun: options.dry_run === true, planFingerprint: options.plan_fingerprint, limit: options.coordinate_limit,
455
- attributedAuthor: options.attributed_author,
456
- reviewer: options.reviewer,
457
- reason: options.reason,
458
- });
459
- }
460
- /** Run any typed plan workflow primitive through the shared CLI/MCP engine. */
461
- plan(subcommand, id, options = {}, stepRef, reorderTo) {
462
- return this.runTyped("plan", {
463
- ...(id === undefined ? {} : { id }),
464
- ...(stepRef === undefined ? {} : { stepRef }),
465
- ...(reorderTo === undefined ? {} : { reorderTo }),
466
- options: mutationOptionsWithOverrides(options, { subcommand }),
467
- });
468
- }
469
- /** Create a durable plan with optional ordered seed steps. */
470
- planCreate(options) {
471
- return this.plan("create", undefined, options);
472
- }
473
- /** Read a plan using brief, standard, deep, or field-projected output. */
474
- planShow(id, options = {}) {
475
- return this.plan("show", id, options);
476
- }
477
- /** Append an ordered step to a plan. */
478
- planAddStep(id, options) {
479
- return this.plan("add-step", id, options);
480
- }
481
- /** Update any mutable property of an existing plan step. */
482
- planUpdateStep(id, stepRef, options) {
483
- return this.plan("update-step", id, options, stepRef);
484
- }
485
- /** Complete a plan step and record its evidence. */
486
- planCompleteStep(id, stepRef, options = {}) {
487
- return this.plan("complete-step", id, options, stepRef);
488
- }
489
- /** Block a plan step with an actionable reason. */
490
- planBlockStep(id, stepRef, options) {
491
- return this.plan("block-step", id, options, stepRef);
492
- }
493
- /** Reorder a plan step while preserving stable step identifiers. */
494
- planReorderStep(id, stepRef, reorderTo, options = {}) {
495
- return this.plan("reorder-step", id, options, stepRef, reorderTo);
496
- }
497
- /** Remove a step from a plan and compact the remaining order. */
498
- planRemoveStep(id, stepRef, options = {}) {
499
- return this.plan("remove-step", id, options, stepRef);
500
- }
501
- /** Link a tracker item to a plan step. */
502
- planLink(id, stepRef, options) {
503
- return this.plan("link", id, options, stepRef);
504
- }
505
- /** Remove tracker-item links from a plan step. */
506
- planUnlink(id, stepRef, options) {
507
- return this.plan("unlink", id, options, stepRef);
508
- }
509
- /** Append a durable plan decision. */
510
- planDecision(id, options) {
511
- return this.plan("decision", id, options);
512
- }
513
- /** Append a durable plan discovery. */
514
- planDiscovery(id, options) {
515
- return this.plan("discovery", id, options);
516
- }
517
- /** Append a plan validation expectation or result. */
518
- planValidation(id, options) {
519
- return this.plan("validation", id, options);
520
- }
521
- /** Update the bounded resume context for a stateless future agent. */
522
- planResume(id, options) {
523
- return this.plan("resume", id, options);
524
- }
525
- /** Approve a plan for execution. */
526
- planApprove(id, options = {}) {
527
- return this.plan("approve", id, options);
528
- }
529
- /** Materialize selected plan steps into governed tracker items. */
530
- planMaterialize(id, options) {
531
- return this.plan("materialize", id, options);
532
- }
533
- /** Create an item using the same mutation path as `pm create`. Options are contract-typed (pm-x29o): unknown keys and non-scalar values fail `tsc`; runtime-schema custom fields go through the repeatable `field` option, and {@link PmClient.run} stays the wide escape hatch. */
534
- create(options = {}) {
535
- return this.runTyped("create", splitFullClientMutationOptions(options));
536
- }
537
- /** Update an item using the same mutation path as `pm update`. Options are contract-typed (pm-x29o): unknown keys and non-scalar values fail `tsc`; runtime-schema custom fields go through the repeatable `field` option, and {@link PmClient.run} stays the wide escape hatch. */
538
- update(id, options = {}) {
539
- return this.runTyped("update", {
540
- id,
541
- ...splitFullClientMutationOptions(options),
542
- });
543
- }
544
- /** Reopen terminal work as a recurrence through the canonical update path. */
545
- reopen(id, reason, options = {}) {
546
- return this.runTyped("item-reopen", {
547
- id,
548
- reason,
549
- fullChangedFields: true,
550
- options,
551
- });
552
- }
553
- /** Close an item using the same mutation path as `pm close`. Options are contract-typed (pm-x29o); the close reason is the positional parameter, so the option bag omits `reason`/`text`. */
554
- close(id, reason, options = {}) {
555
- return this.runTyped("close", {
556
- id,
557
- reason,
558
- ...splitFullClientMutationOptions(options),
559
- });
560
- }
561
- /** Claim an item using the same mutation path as `pm claim`. */
562
- claim(id, options = {}) {
563
- return this.runTyped("claim", {
564
- id,
565
- ...splitFullClientMutationOptions(options),
566
- });
567
- }
568
- /** Atomically claim the highest-ranked available item using the public next-work filters. */
569
- claimNext(options = {}) {
570
- return this.runTyped("claim", {
571
- next: true,
572
- ...splitFullClientMutationOptions(options),
573
- });
574
- }
575
- /** Release an item's active claim using the same mutation path as `pm release`. */
576
- release(id, options = {}) {
577
- return this.runTyped("release", {
578
- id,
579
- ...splitFullClientMutationOptions(options),
580
- });
581
- }
582
- /** Copy an item using the same mutation path as `pm copy`. */
583
- copy(id, options = {}) {
584
- return this.runTyped("copy", {
585
- id,
586
- ...splitFullClientMutationOptions(options),
587
- });
588
- }
589
- /** Delete an item using the same mutation path as `pm delete`. */
590
- delete(id, options = {}) {
591
- return this.runTyped("delete", {
592
- id,
593
- ...splitFullClientMutationOptions(options),
594
- });
595
- }
596
- /** Restore an item to a history version or timestamp using `pm restore`. */
597
- restore(id, target, options = {}) {
598
- return this.runTyped("restore", {
599
- fullChangedFields: true,
600
- id,
601
- options: { ...options, target },
602
- });
603
- }
604
- /** Set, clear, or read workspace focus using the same path as `pm focus`. */
605
- focus(id, options = {}) {
606
- return this.runTyped("focus", {
607
- ...(id === undefined ? {} : { id }),
608
- ...splitFullClientMutationOptions(options),
609
- });
610
- }
611
- /** Claim an item and transition it to the workspace in-progress status. */
612
- startTask(id, options = {}) {
613
- return this.runTyped("start-task", {
614
- id,
615
- ...splitFullClientMutationOptions(options),
616
- });
617
- }
618
- /** Move an item back to the workspace open status and release the claim. */
619
- pauseTask(id, options = {}) {
620
- return this.runTyped("pause-task", {
621
- id,
622
- ...splitFullClientMutationOptions(options),
623
- });
624
- }
625
- /** Close an item and release its active assignment. */
626
- closeTask(id, reason, options = {}) {
627
- return this.runTyped("close-task", {
628
- id,
629
- reason,
630
- ...splitFullClientMutationOptions(options),
631
- });
632
- }
633
- /** Run the extension lifecycle surface with the same result shape as `pm extension`. */
634
- extension(target, options = {}) {
635
- return this.runTyped("extension", {
636
- ...(target === undefined ? {} : { target }),
637
- options,
638
- });
639
- }
640
- /** List project or global extensions without constructing command-line argv. */
641
- extensionList(options = {}) {
642
- return this.extension("list", options);
643
- }
644
- /** Enable an installed extension using the same action as `pm extension activate`. */
645
- extensionActivate(target, options = {}) {
646
- return this.runTyped("extension-activate", { target, options });
647
- }
648
- /** Disable an installed extension using the same action as `pm extension deactivate`. */
649
- extensionDeactivate(target, options = {}) {
650
- return this.runTyped("extension-deactivate", { target, options });
651
- }
652
- /** Run the package lifecycle surface with package vocabulary preserved. */
653
- package(target, options = {}) {
654
- return this.runTyped("package", {
655
- ...(target === undefined ? {} : { target }),
656
- options: { ...options, vocabulary: "package" },
657
- });
658
- }
659
- /** List project or global packages through the package lifecycle primitive. */
660
- packageList(options = {}) {
661
- return this.package("list", options);
662
- }
663
- /** Install a package or extension source using the same action as `pm package install`. */
664
- packageInstall(target, options = {}) {
665
- return this.runTyped("package-install", { target, options });
666
- }
667
- /** Uninstall a package or extension using the same action as `pm package uninstall`. */
668
- packageUninstall(target, options = {}) {
669
- return this.runTyped("package-uninstall", { target, options });
670
- }
671
- /** Read package lifecycle diagnostics using the same action as `pm package doctor`. */
672
- packageDoctor(options = {}) {
673
- return this.runTyped("package-doctor", { options });
674
- }
675
- /** Inspect managed package state using the same action as `pm package manage`. */
676
- packageManage(target, options = {}) {
677
- return this.runTyped("package-manage", {
678
- ...(target === undefined ? {} : { target }),
679
- options,
680
- });
681
- }
682
- /** Describe installed package surfaces using the same action as `pm package describe`. */
683
- packageDescribe(target, options = {}) {
684
- return this.runTyped("package-describe", {
685
- ...(target === undefined ? {} : { target }),
686
- options,
687
- });
688
- }
689
- /** Reload installed package extensions using the same action as `pm package reload`. */
690
- packageReload(options = {}) {
691
- return this.runTyped("package-reload", { options });
692
- }
693
- /** Read bundled package catalog metadata using the same action as `pm package catalog`. */
694
- packageCatalog(options = {}) { return this.runTyped("package-catalog", { options }); }
695
- /** Enable an installed package using the same action as `pm package activate`. */
696
- packageActivate(target, options = {}) {
697
- return this.runTyped("package-activate", { target, options });
698
- }
699
- /** Disable an installed package using the same action as `pm package deactivate`. */
700
- packageDeactivate(target, options = {}) {
701
- return this.runTyped("package-deactivate", { target, options });
702
- }
703
- /** Plan or apply active package migrations with durable workspace receipts. */
704
- packageMigrate(options = {}) {
705
- return this.package(undefined, { ...options, migrate: true });
706
- }
707
- /** Upgrade the pm CLI and/or managed packages through the public SDK dispatcher. */
708
- upgrade(target, options = {}) {
709
- return this.runTyped("upgrade", {
710
- ...(target === undefined ? {} : { target }),
711
- options,
712
- });
713
- }
714
- }
715
- /** Return the same context snapshot produced by `pm context` without constructing a reusable client. */
716
- export function context(options = {}, clientOptions = {}) {
717
- return new PmClient(clientOptions).context(options);
718
- }
719
- /** List items with the MCP/agent compact defaults without constructing a reusable client. */
720
- export function list(options = {}, clientOptions = {}) {
721
- return new PmClient(clientOptions).list(options);
722
- }
723
- /** Return every status and full item row with fail-closed corpus proof. */
724
- export function listAllComplete(options = {}, clientOptions = {}) { return new PmClient(clientOptions).listAllComplete(options); }
725
- /** Search items with the MCP/agent compact defaults without constructing a reusable client. */
726
- export function search(query, options = {}, clientOptions = {}) {
727
- return new PmClient(clientOptions).search(query, options);
728
- }
729
- /** Read one item by id without constructing a reusable client. */
730
- export function get(id, options = {}, clientOptions = {}) {
731
- return new PmClient(clientOptions).get(id, options);
732
- }
733
- /** Return the ranked next-work recommendation produced by `pm next` without constructing a reusable client. */
734
- export function next(options = {}, clientOptions = {}) {
735
- return new PmClient(clientOptions).next(options);
736
- }
737
- /** Group matching items with the same semantics as `pm aggregate` without constructing a reusable client. */
738
- export function aggregate(options = {}, clientOptions = {}) {
739
- return new PmClient(clientOptions).aggregate(options);
740
- }
741
- /** Return project tracker statistics with the same sections as `pm stats` without constructing a reusable client. */
742
- export function stats(options = {}, clientOptions = {}) {
743
- return new PmClient(clientOptions).stats(options);
744
- }
745
- /** Discover duplicate clusters without constructing a reusable client. */
746
- export function duplicates(options = {}, clientOptions = {}) {
747
- return new PmClient(clientOptions).duplicates(options);
748
- }
749
- /** List or mutate comments with optional idempotency without constructing a client. */
750
- export function comments(id, options = {}, clientOptions = {}) {
751
- return new PmClient(clientOptions).comments(id, options);
752
- }
753
- /** List or mutate private notes with optional idempotency without constructing a client. */
754
- export function notes(id, options = {}, clientOptions = {}) {
755
- return new PmClient(clientOptions).notes(id, options);
756
- }
757
- /** List or mutate durable learnings with optional idempotency without constructing a client. */
758
- export function learnings(id, options = {}, clientOptions = {}) {
759
- return new PmClient(clientOptions).learnings(id, options);
760
- }
761
- /** Manage linked item files without constructing a reusable client. */
762
- export function files(id, options = {}, clientOptions = {}) {
763
- return new PmClient(clientOptions).files(id, options);
764
- }
765
- /** Discover linked item files without constructing a reusable client. */
766
- export function filesDiscover(id, options = {}, clientOptions = {}) {
767
- return new PmClient(clientOptions).filesDiscover(id, options);
768
- }
769
- /** Resolve items linked to source paths without constructing a reusable client. */
770
- export function filesLookup(options, clientOptions = {}) {
771
- return new PmClient(clientOptions).filesLookup(options);
772
- }
773
- /** Manage linked item docs without constructing a reusable client. */
774
- export function docs(id, options = {}, clientOptions = {}) {
775
- return new PmClient(clientOptions).docs(id, options);
776
- }
777
- /** Inspect item dependency relationships without constructing a reusable client. */
778
- export function deps(id, options = {}, clientOptions = {}) {
779
- return new PmClient(clientOptions).deps(id, options);
780
- }
781
- /** Run bounded workspace graph queries without constructing a reusable client. */
782
- export function graph(subcommand, ids = {}, options = {}, clientOptions = {}) {
783
- return new PmClient(clientOptions).graph(subcommand, ids, options);
784
- }
785
- /** Append markdown/body text to an item without constructing a reusable client. */
786
- export function append(id, body, options = {}, clientOptions = {}) {
787
- return new PmClient(clientOptions).append(id, body, options);
788
- }
789
- /** Initialize a workspace without constructing a reusable client. */
790
- export function init(prefix, options = {}, clientOptions = {}) {
791
- return new PmClient(clientOptions).init(prefix, options);
792
- }
793
- /** Read or update configuration without constructing a reusable client. */
794
- export function config(scope, configAction, key, value, options = {}, clientOptions = {}) {
795
- return new PmClient(clientOptions).config(scope, configAction, key, value, options);
796
- }
797
- /** Run the schema customization surface without constructing a reusable client. */
798
- export function schema(subcommand, options = {}, clientOptions = {}) {
799
- return new PmClient(clientOptions).schema(subcommand, options);
800
- }
801
- /** List schema definitions without constructing a reusable client. */
802
- export function schemaList(clientOptions = {}) {
803
- return new PmClient(clientOptions).schemaList();
804
- }
805
- /** Show a schema item type without constructing a reusable client. */
806
- export function schemaShow(name, clientOptions = {}) {
807
- return new PmClient(clientOptions).schemaShow(name);
808
- }
809
- /** Register a custom item type without constructing a reusable client. */
810
- export function schemaAddType(name, options = {}, clientOptions = {}) {
811
- return new PmClient(clientOptions).schemaAddType(name, options);
812
- }
813
- /** Remove a custom item type without constructing a reusable client. */
814
- export function schemaRemoveType(name, options = {}, clientOptions = {}) {
815
- return new PmClient(clientOptions).schemaRemoveType(name, options);
816
- }
817
- /** Register a custom status without constructing a reusable client. */
818
- export function schemaAddStatus(name, options = {}, clientOptions = {}) {
819
- return new PmClient(clientOptions).schemaAddStatus(name, options);
820
- }
821
- /** Remove a custom status without constructing a reusable client. */
822
- export function schemaRemoveStatus(name, options = {}, clientOptions = {}) {
823
- return new PmClient(clientOptions).schemaRemoveStatus(name, options);
824
- }
825
- /** Register a custom field without constructing a reusable client. */
826
- export function schemaAddField(name, options = {}, clientOptions = {}) {
827
- return new PmClient(clientOptions).schemaAddField(name, options);
828
- }
829
- /** Remove a custom field without constructing a reusable client. */
830
- export function schemaRemoveField(name, options = {}, clientOptions = {}) {
831
- return new PmClient(clientOptions).schemaRemoveField(name, options);
832
- }
833
- /** List custom fields without constructing a reusable client. */
834
- export function schemaListFields(clientOptions = {}) {
835
- return new PmClient(clientOptions).schemaListFields();
836
- }
837
- /** Show a custom field without constructing a reusable client. */
838
- export function schemaShowField(name, clientOptions = {}) {
839
- return new PmClient(clientOptions).schemaShowField(name);
840
- }
841
- /** Apply a schema preset without constructing a reusable client. */
842
- export function schemaApplyPreset(typePreset, options = {}, clientOptions = {}) {
843
- return new PmClient(clientOptions).schemaApplyPreset(typePreset, options);
844
- }
845
- /** Infer schema types without constructing a reusable client. */
846
- export function schemaInferTypes(options = {}, clientOptions = {}) {
847
- return new PmClient(clientOptions).schemaInferTypes(options);
848
- }
849
- /** Rename a custom item type without constructing a reusable client. */
850
- export function schemaRenameType(from, to, options, clientOptions = {}) {
851
- return new PmClient(clientOptions).schemaRenameType(from, to, options);
852
- }
853
- /** Rename a custom field without constructing a reusable client. */
854
- export function schemaRenameField(from, to, options, type, clientOptions = {}) {
855
- return new PmClient(clientOptions).schemaRenameField(from, to, options, type);
856
- }
857
- /** Remap a custom status without constructing a reusable client. */
858
- export function schemaRemapStatus(from, to, options, clientOptions = {}) {
859
- return new PmClient(clientOptions).schemaRemapStatus(from, to, options);
860
- }
861
- /** Show a custom status without constructing a reusable client. */
862
- export function schemaShowStatus(name, clientOptions = {}) {
863
- return new PmClient(clientOptions).schemaShowStatus(name);
864
- }
865
- /** Run the profile customization surface without constructing a reusable client. */
866
- export function profile(subcommand, options = {}, clientOptions = {}) {
867
- return new PmClient(clientOptions).profile(subcommand, options);
868
- }
869
- /** List profiles without constructing a reusable client. */
870
- export function profileList(clientOptions = {}) {
871
- return new PmClient(clientOptions).profileList();
872
- }
873
- /** Show a profile without constructing a reusable client. */
874
- export function profileShow(name, clientOptions = {}) {
875
- return new PmClient(clientOptions).profileShow(name);
876
- }
877
- /** Apply a profile without constructing a reusable client. */
878
- export function profileApply(name, options = {}, clientOptions = {}) {
879
- return new PmClient(clientOptions).profileApply(name, options);
880
- }
881
- /** Lint a profile without constructing a reusable client. */
882
- export function profileLint(name, clientOptions = {}) {
883
- return new PmClient(clientOptions).profileLint(name);
884
- }
885
- /** Validate a tracker without constructing a reusable client. */
886
- export function validate(options = {}, clientOptions = {}) {
887
- return new PmClient(clientOptions).validate(options);
888
- }
889
- /** Run health checks without constructing a reusable client. */
890
- export function health(options = {}, clientOptions = {}) {
891
- return new PmClient(clientOptions).health(options);
892
- }
893
- /** Run cache/runtime garbage collection without constructing a reusable client. */
894
- export function gc(options = {}, clientOptions = {}) {
895
- return new PmClient(clientOptions).gc(options);
896
- }
897
- /** Redact one history stream without constructing a reusable client. */
898
- export function historyRedact(id, options, clientOptions = {}) {
899
- return new PmClient(clientOptions).historyRedact(id, options);
900
- }
901
- /** Repair one history stream without constructing a reusable client. */
902
- export function historyRepair(id, options = {}, clientOptions = {}) {
903
- return new PmClient(clientOptions).historyRepair(id, options);
904
- }
905
- /** Repair all drifted history streams without constructing a reusable client. */
906
- export function historyRepairAll(options = {}, clientOptions = {}) {
907
- return new PmClient(clientOptions).historyRepairAll(options);
908
- }
909
- /** Compact one history stream without constructing a reusable client. */
910
- export function historyCompact(id, options = {}, clientOptions = {}) {
911
- return new PmClient(clientOptions).historyCompact(id, options);
912
- }
913
- /** Compact selected history streams without constructing a reusable client. */
914
- export function historyCompactBulk(options, clientOptions = {}) {
915
- return new PmClient(clientOptions).historyCompactBulk(options);
916
- }
917
- /** Create an item without constructing a reusable client. */
918
- export function create(options = {}, clientOptions = {}) {
919
- return new PmClient(clientOptions).create(options);
920
- }
921
- /** Update an item without constructing a reusable client. */
922
- export function update(id, options = {}, clientOptions = {}) {
923
- return new PmClient(clientOptions).update(id, options);
924
- }
925
- /** Reopen terminal work as a recurrence without constructing a reusable client. */
926
- export function reopen(id, reason, options = {}, clientOptions = {}) {
927
- return new PmClient(clientOptions).reopen(id, reason, options);
928
- }
929
- /** Close an item without constructing a reusable client. */
930
- export function close(id, reason, options = {}, clientOptions = {}) {
931
- return new PmClient(clientOptions).close(id, reason, options);
932
- }
933
- /** Claim an item without constructing a reusable client. */
934
- export function claim(id, options = {}, clientOptions = {}) {
935
- return new PmClient(clientOptions).claim(id, options);
936
- }
937
- /** Atomically select and claim ranked work without constructing a reusable client. */
938
- export function claimNext(options = {}, clientOptions = {}) {
939
- return new PmClient(clientOptions).claimNext(options);
940
- }
941
- /** Release an item's active claim without constructing a reusable client. */
942
- export function release(id, options = {}, clientOptions = {}) {
943
- return new PmClient(clientOptions).release(id, options);
944
- }
945
- /** Copy an item without constructing a reusable client. */
946
- export function copy(id, options = {}, clientOptions = {}) {
947
- return new PmClient(clientOptions).copy(id, options);
948
- }
949
- /** Delete an item without constructing a reusable client. */
950
- export function deleteItem(id, options = {}, clientOptions = {}) {
951
- return new PmClient(clientOptions).delete(id, options);
952
- }
953
- /** Restore an item without constructing a reusable client. */
954
- export function restore(id, target, options = {}, clientOptions = {}) {
955
- return new PmClient(clientOptions).restore(id, target, options);
956
- }
957
- /** Set, clear, or read workspace focus without constructing a reusable client. */
958
- export function focus(id, options = {}, clientOptions = {}) {
959
- return new PmClient(clientOptions).focus(id, options);
960
- }
961
- /** Claim an item and transition it to in-progress without constructing a client. */
962
- export function startTask(id, options = {}, clientOptions = {}) {
963
- return new PmClient(clientOptions).startTask(id, options);
964
- }
965
- /** Move an item to open and release it without constructing a client. */
966
- export function pauseTask(id, options = {}, clientOptions = {}) {
967
- return new PmClient(clientOptions).pauseTask(id, options);
968
- }
969
- /** Close an item and release its active assignment without constructing a client. */
970
- export function closeTask(id, reason, options = {}, clientOptions = {}) {
971
- return new PmClient(clientOptions).closeTask(id, reason, options);
972
- }
973
- /** Run the extension lifecycle surface without constructing a reusable client. */
974
- export function extension(target, options = {}, clientOptions = {}) {
975
- return new PmClient(clientOptions).extension(target, options);
976
- }
977
- /** List extensions without constructing a reusable client. */
978
- export function extensionList(options = {}, clientOptions = {}) {
979
- return new PmClient(clientOptions).extensionList(options);
980
- }
981
- /** Enable an extension without constructing a reusable client. */
982
- export function extensionActivate(target, options = {}, clientOptions = {}) {
983
- return new PmClient(clientOptions).extensionActivate(target, options);
984
- }
985
- /** Disable an extension without constructing a reusable client. */
986
- export function extensionDeactivate(target, options = {}, clientOptions = {}) {
987
- return new PmClient(clientOptions).extensionDeactivate(target, options);
988
- }
989
- /** Run the package lifecycle surface without constructing a reusable client. */
990
- export function packageLifecycle(target, options = {}, clientOptions = {}) {
991
- return new PmClient(clientOptions).package(target, options);
992
- }
993
- /** List packages without constructing a reusable client. */
994
- export function packageList(options = {}, clientOptions = {}) {
995
- return new PmClient(clientOptions).packageList(options);
996
- }
997
- /** Install a package or extension source without constructing a reusable client. */
998
- export function packageInstall(target, options = {}, clientOptions = {}) {
999
- return new PmClient(clientOptions).packageInstall(target, options);
1000
- }
1001
- /** Uninstall a package or extension without constructing a reusable client. */
1002
- export function packageUninstall(target, options = {}, clientOptions = {}) {
1003
- return new PmClient(clientOptions).packageUninstall(target, options);
1004
- }
1005
- /** Read package lifecycle diagnostics without constructing a reusable client. */
1006
- export function packageDoctor(options = {}, clientOptions = {}) {
1007
- return new PmClient(clientOptions).packageDoctor(options);
1008
- }
1009
- /** Inspect managed package state without constructing a reusable client. */
1010
- export function packageManage(target, options = {}, clientOptions = {}) {
1011
- return new PmClient(clientOptions).packageManage(target, options);
1012
- }
1013
- /** Describe package surfaces without constructing a reusable client. */
1014
- export function packageDescribe(target, options = {}, clientOptions = {}) {
1015
- return new PmClient(clientOptions).packageDescribe(target, options);
1016
- }
1017
- /** Reload package extensions without constructing a reusable client. */
1018
- export function packageReload(options = {}, clientOptions = {}) {
1019
- return new PmClient(clientOptions).packageReload(options);
1020
- }
1021
- /** Read bundled package catalog metadata without constructing a reusable client. */
1022
- export function packageCatalog(options = {}, clientOptions = {}) { return new PmClient(clientOptions).packageCatalog(options); }
1023
- /** Enable a package without constructing a reusable client. */
1024
- export function packageActivate(target, options = {}, clientOptions = {}) {
1025
- return new PmClient(clientOptions).packageActivate(target, options);
1026
- }
1027
- /** Disable a package without constructing a reusable client. */
1028
- export function packageDeactivate(target, options = {}, clientOptions = {}) {
1029
- return new PmClient(clientOptions).packageDeactivate(target, options);
1030
- }
1031
- /** Upgrade the pm CLI and/or managed packages without constructing a reusable client. */
1032
- export function upgrade(target, options = {}, clientOptions = {}) {
1033
- return new PmClient(clientOptions).upgrade(target, options);
1034
- }
1035
- /**
1036
- * Process-lifetime memo of activated extension registrations, keyed by resolved
1037
- * pm root + cwd + extension settings. `getWorkspaceContracts` is frequently
1038
- * called by importers and package runtimes that cannot thread a registry
1039
- * through; without the memo each call re-discovers, re-imports, and re-activates
1040
- * every extension.
1041
- *
1042
- * Invalidation story: entries are size-bounded and otherwise live until cleared.
1043
- * One-shot CLI processes are trivially correct. Long-lived hosts (e.g. the MCP
1044
- * server) must either pass `options.extensionRegistrations` (which bypasses the
1045
- * memo) or call {@link clearWorkspaceContractsCache} after installing/removing/
1046
- * toggling extensions or editing settings. Settings themselves are re-read on
1047
- * every call — only the extension load+activate step is memoized.
1048
- */
1049
- function buildWorkspaceExtensionRegistrationsCacheKey(pmRoot, settings, cwd) {
1050
- return JSON.stringify([
1051
- path.resolve(pmRoot),
1052
- path.resolve(cwd ?? process.cwd()),
1053
- settings.extensions.enabled,
1054
- settings.extensions.disabled,
1055
- settings.extensions.policy,
1056
- ]);
1057
- }
1058
- async function resolveWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
1059
- const cacheKey = buildWorkspaceExtensionRegistrationsCacheKey(pmRoot, settings, cwd);
1060
- return memoizeWorkspaceExtensionRegistrations(cacheKey, () => loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd));
1061
- }
1062
- /** Implements get workspace contracts for the public runtime surface of this module. */
1063
- export async function getWorkspaceContracts(pmRoot, options = {}) {
1064
- const settings = await readSettings(pmRoot);
1065
- const extensionRegistrations = options.extensionRegistrations ??
1066
- (options.noExtensions === true
1067
- ? null
1068
- : await resolveWorkspaceExtensionRegistrations(pmRoot, settings, options.cwd));
1069
- const typeRegistry = resolveItemTypeRegistry(settings, extensionRegistrations);
1070
- const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
1071
- const fieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
1072
- return {
1073
- types: [...typeRegistry.types],
1074
- statuses: statusRegistry.definitions.map((definition) => definition.id),
1075
- openStatus: statusRegistry.open_status,
1076
- closeStatus: statusRegistry.close_status,
1077
- canceledStatus: statusRegistry.canceled_status,
1078
- fields: buildWorkspaceFieldContracts(fieldRegistry.definitions),
1079
- extensionCommands: buildWorkspaceExtensionCommandContracts(extensionRegistrations?.commands ?? []),
1080
- };
1081
- }
1082
- /** Implements get contracts for the public runtime surface of this module. */
1083
- export async function getContracts(pmRootOrOptions, options = {}) {
1084
- const resolvedOptions = typeof pmRootOrOptions === "string"
1085
- ? { ...options, pmRoot: pmRootOrOptions }
1086
- : (pmRootOrOptions ?? options);
1087
- const global = {
1088
- json: true,
1089
- quiet: resolvedOptions.quiet ?? true,
1090
- noExtensions: resolvedOptions.noExtensions ?? false,
1091
- noPager: true,
1092
- profile: resolvedOptions.profile ?? false,
1093
- path: resolvedOptions.pmRoot,
1094
- };
1095
- return runContracts(resolvedOptions, global);
1096
- }
1097
- /** Read a required non-empty string from an action argument bag. */
1098
- export function readRequiredString(args, key) {
1099
- const value = readString(args, key);
1100
- if (!value) {
1101
- throw new PmCliError(`Missing required argument: ${key}`, 64);
1102
- }
1103
- return value;
1104
- }
1105
- // pm-zpoyg9: request-local registries permit independent activation cycles to
1106
- // overlap, but explicit cwd calls still mutate process-global state. The gate
1107
- // retains reader concurrency while making cwd mutation exclusive against every
1108
- // activation path, including callers that resolve paths through process.cwd().
1109
- const extensionActivationGate = createAsyncReadWriteGate();
1110
- const activeExtensionScope = new AsyncLocalStorage();
1111
- /** Publishes empty active extension registries so built-in fallback actions cannot observe stale or partially published extension state from a failed activation cycle. */
1112
- function resetActiveExtensionRegistries() {
1113
- setActiveExtensionHooks(createEmptyExtensionHookRegistry());
1114
- setActiveExtensionCommands(createEmptyExtensionCommandRegistry());
1115
- setActiveExtensionParsers(createEmptyExtensionParserRegistry());
1116
- setActiveExtensionPreflight(createEmptyExtensionPreflightRegistry());
1117
- setActiveExtensionServices(createEmptyExtensionServiceRegistry());
1118
- setActiveExtensionRenderers(createEmptyExtensionRendererRegistry());
1119
- setActiveExtensionRegistrations(createEmptyExtensionRegistrationRegistry());
1120
- }
1121
- /**
1122
- * Run `run` with workspace extensions loaded, activated, and published to the
1123
- * process-global active registries, then torn down afterwards. pm-zumn: built-in native
1124
- * actions (pm_list/pm_profile/pm_schema/pm_create/...) read
1125
- * `getActiveExtensionRegistrations()` for custom item types, fields, and profiles, so
1126
- * they must activate extensions exactly like the CLI (main.ts activates for every
1127
- * command). Previously only the dynamic-extension dispatch activated, leaving
1128
- * extension-contributed schema and profiles invisible over MCP for every built-in
1129
- * action. Activation is skipped (`run` receives `null`) when extensions are disabled or
1130
- * no workspace exists yet (for example `init`). EVERY action — activating or not — is
1131
- * isolated through an async-local registry context. Calls with an explicit `cwd`
1132
- * acquire exclusive access because `process.chdir` is process-global; calls that use
1133
- * workspace/path arguments share read access and remain concurrent when no cwd writer
1134
- * was already scheduled.
1135
- */
1136
- async function withActiveExtensions(global, explicitCwd, resolutionCwd, run) {
1137
- return runWithIsolatedExtensionRuntime(() => explicitCwd === undefined
1138
- ? extensionActivationGate.read(() => withActiveExtensionsExclusively(global, resolutionCwd, run))
1139
- : extensionActivationGate.write(() => withCwd(explicitCwd, () => withActiveExtensionsExclusively(global, resolutionCwd, run))));
1140
- }
1141
- /**
1142
- * Execute direct SDK work while workspace extensions are loaded and published
1143
- * to request-local active registries. Use this for SDK operations that bypass
1144
- * {@link runAction} but still create or update extension-owned item shapes.
1145
- */
1146
- export async function runWithActiveExtensions(options, run) {
1147
- const explicitCwd = options.cwd;
1148
- const resolutionCwd = explicitCwd ?? process.cwd();
1149
- return withActiveExtensions(globalOptions({ path: options.path, noExtensions: options.noExtensions }), explicitCwd, resolutionCwd, () => activeExtensionScope.run(true, run));
1150
- }
1151
- /**
1152
- * Body of one activation cycle. {@link withActiveExtensions} supplies an
1153
- * async-local registry context; explicit-cwd callers additionally hold the
1154
- * process-wide cwd queue. Returns early with `run(null)` when extensions are
1155
- * disabled or no workspace
1156
- * exists yet, so those built-in actions also observe a stable (empty) registry. MCP and
1157
- * PmClient callers reload + reactivate extensions per request, so each call is a fresh
1158
- * cycle with teardown in a finally to release resources opened during activate() (the
1159
- * long-running-server reload contract, pm-k1e4). Load/activate failures are swallowed and
1160
- * `run` is invoked with `null`, mirroring the CLI's resilient snapshot loader
1161
- * (loadRuntimeExtensionSnapshot) so a broken extension can never break a built-in action.
1162
- */
1163
- async function withActiveExtensionsExclusively(global, cwd, run) {
1164
- const pmRoot = resolvePmRoot(cwd, global.path);
1165
- if (global.noExtensions) {
1166
- resetActiveExtensionRegistries();
1167
- return runWithDiscoveredContextIntentContracts({ pmRoot }, () => run(null));
1168
- }
1169
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
1170
- resetActiveExtensionRegistries();
1171
- return run(null);
1172
- }
1173
- let active = null;
1174
- let activated;
1175
- try {
1176
- const settings = await readSettings(pmRoot);
1177
- const loadResult = await loadExtensions({
1178
- pmRoot,
1179
- settings,
1180
- cwd,
1181
- noExtensions: false,
1182
- });
1183
- const activationResult = await activateExtensions({
1184
- ...loadResult,
1185
- loaded: loadResult.loaded,
1186
- });
1187
- // Record the teardown handle BEFORE publishing the registries so a throw from any
1188
- // setActive* setter still runs deactivateExtensions for resources opened during
1189
- // activate() instead of silently leaking them.
1190
- activated = { loadResult, activationResult };
1191
- setActiveExtensionHooks(activationResult.hooks);
1192
- setActiveExtensionCommands(activationResult.commands);
1193
- setActiveExtensionParsers(activationResult.parsers);
1194
- setActiveExtensionPreflight(activationResult.preflight);
1195
- setActiveExtensionServices(activationResult.services);
1196
- setActiveExtensionRenderers(activationResult.renderers);
1197
- setActiveExtensionRegistrations(activationResult.registrations);
1198
- active = {
1199
- registrations: activationResult.registrations,
1200
- commands: activationResult.commands,
1201
- pmRoot,
1202
- packages: loadResult.loaded,
1203
- };
1204
- }
1205
- catch (error) {
1206
- resetActiveExtensionRegistries();
1207
- // CLI parity (loadRuntimeExtensionSnapshot): a load/activate failure must never
1208
- // break a built-in action — fall back to running with no active extensions. Surface
1209
- // the cause on stderr so a broken extension is diagnosable instead of being silently
1210
- // indistinguishable from a workspace that simply has no extensions.
1211
- console.error("[pm-sdk] extension activation failed; continuing without active extensions:", error);
1212
- }
1213
- try {
1214
- return await runWithDiscoveredContextIntentContracts({ pmRoot, packages: active?.packages }, () => run(active));
1215
- }
1216
- finally {
1217
- // Reset the process-global active registries FIRST so a torn-down extension's
1218
- // overrides/hooks cannot leak into a later request in this long-running server
1219
- // (for example a subsequent pm_list/pm_create) even if teardown below misbehaves.
1220
- resetActiveExtensionRegistries();
1221
- // Best-effort teardown of extensions that activated successfully. Skipped when
1222
- // activation never completed (nothing was set up); guarded so an unexpected throw
1223
- // cannot escape the finally.
1224
- if (activated) {
1225
- await deactivateExtensions(activated.loadResult, activated.activationResult).catch(() => undefined);
1226
- }
1227
- }
1228
- }
1229
- /**
1230
- * Resolve `action` against the active extension command registrations and dispatch it.
1231
- * Reached by runAction's default case for dynamic (non-built-in) actions after
1232
- * {@link withActiveExtensions} has published the active registries. `active` is `null`
1233
- * when no extensions are active (disabled, no workspace, or activation failed), in
1234
- * which case no extension command can match and the action is reported unsupported.
1235
- */
1236
- async function dispatchActiveExtensionAction(action, args, options, global, active) {
1237
- if (!active) {
1238
- throw new PmCliError(`Unsupported native pm action: ${action}`, EXIT_CODE.USAGE);
1239
- }
1240
- const normalizedAction = normalizeActionName(action);
1241
- const definition = active.registrations.commands.find((entry) => normalizeActionName(entry.action) === normalizedAction);
1242
- const command = definition?.command ??
1243
- active.commands.handlers.find((entry) => normalizeActionName(entry.command) === normalizedAction)?.command;
1244
- if (!command) {
1245
- throw new PmCliError(`Unsupported native pm action: ${action}`, EXIT_CODE.USAGE);
1246
- }
1247
- const handlerResult = await runActiveCommandHandler({
1248
- command: normalizeCommandPath(command),
1249
- args: readStringArray(options.args ?? args.args),
1250
- options: extensionOptionsFromArgs(args, options),
1251
- global,
1252
- pm_root: active.pmRoot,
1253
- sdk: createExtensionCommandSdk(active.pmRoot, PmClient.forActiveExtensionHost({
1254
- pmRoot: active.pmRoot,
1255
- author: typeof global.author === "string" && global.author.trim()
1256
- ? global.author.trim()
1257
- : "pm-extension",
1258
- })),
1259
- });
1260
- if (!handlerResult.handled) {
1261
- const suffix = handlerResult.warnings.length > 0
1262
- ? ` (${handlerResult.warnings.join(", ")})`
1263
- : "";
1264
- throw new PmCliError(`Unsupported native pm action: ${action}${suffix}`, EXIT_CODE.USAGE);
1265
- }
1266
- return handlerResult.result;
1267
- }
1268
- async function withCwd(cwd, run) {
1269
- // Only ever called with an explicit, non-empty cwd (readString filters blanks), from
1270
- // inside the serialized activation queue, so the chdir/restore is exclusive per request
1271
- // and can never be clobbered by a concurrent caller.
1272
- const previous = process.cwd();
1273
- process.chdir(cwd);
1274
- try {
1275
- return await run();
1276
- }
1277
- finally {
1278
- process.chdir(previous);
1279
- }
1280
- }
1281
- function resolveSdkActionInput(args) {
1282
- const rawAction = readRequiredString(args, "action");
1283
- const normalizedAction = normalizeActionName(rawAction);
1284
- const alias = getOwnHandler(SDK_ACTION_ALIASES, normalizedAction);
1285
- const action = alias?.action ?? normalizedAction;
1286
- const resolvedArgs = { ...args, action };
1287
- if (alias?.options !== undefined) {
1288
- resolvedArgs.options = { ...alias.options, ...asRecordClone(args.options) };
1289
- }
1290
- if (action === "package") {
1291
- resolvedArgs.options = {
1292
- ...asRecordClone(resolvedArgs.options),
1293
- vocabulary: "package",
1294
- };
1295
- }
1296
- return { action, args: resolvedArgs };
1297
- }
1298
- /** Execute one native or extension-contributed pm action in-process. */
1299
- export async function runAction(args) {
1300
- const resolved = resolveSdkActionInput(args);
1301
- const global = globalOptions(resolved.args);
1302
- const invalidateWorkspaceContractsCache = shouldInvalidateWorkspaceContractsCacheAfterAction(resolved.action);
1303
- // pm-zumn: dispatch every action (built-in and dynamic) inside one extension
1304
- // activation cycle so built-in actions see extension-contributed item types, fields,
1305
- // and profiles, consistent with the CLI. Snapshot the effective resolution cwd HERE,
1306
- // at request entry (the explicit args.cwd, else the server's current directory), so the
1307
- // queued cycle resolves against the directory the request arrived in rather than a value
1308
- // process.cwd() might hold by the time the task runs. Only an explicit cwd additionally
1309
- // pins process.cwd() (inside the serialized slot) for the built-in handler.
1310
- const explicitCwd = readString(resolved.args, "cwd");
1311
- const resolutionCwd = explicitCwd ?? process.cwd();
1312
- if (resolved.action === "init") {
1313
- global[INIT_INVOCATION_CWD] = resolutionCwd;
1314
- }
1315
- if (resolved.action !== "init" ||
1316
- global.path !== undefined ||
1317
- (process.env.PM_PATH?.trim().length ?? 0) > 0) {
1318
- global.path = resolvePmRoot(resolutionCwd, global.path);
1319
- }
1320
- try {
1321
- if (args[ACTIVE_EXTENSION_HOST_CONTEXT] === true ||
1322
- activeExtensionScope.getStore() === true) {
1323
- return await dispatchAction(resolved.action, resolved.args, global, null);
1324
- }
1325
- return await withActiveExtensions(global, explicitCwd, resolutionCwd, (activeExtensions) => dispatchAction(resolved.action, resolved.args, global, activeExtensions));
1326
- }
1327
- finally {
1328
- if (invalidateWorkspaceContractsCache) {
1329
- clearWorkspaceContractsCache();
1330
- }
1331
- }
1332
- }
1333
- function getOwnHandler(handlers, key) {
1334
- return Object.prototype.hasOwnProperty.call(handlers, key)
1335
- ? handlers[key]
1336
- : undefined;
1337
- }
1338
- function readMcpTarget(ctx) {
1339
- return readString(ctx.args, "target") ?? readString(ctx.options, "target");
1340
- }
1341
- function requireMcpItemId(ctx, source = ctx.options) {
1342
- return ctx.id ?? readRequiredString(source, "id");
1343
- }
1344
- async function runMcpListAction(ctx) {
1345
- const listOptions = applyContextIntentProjection("list", ctx.options);
1346
- if (listOptions.compact === undefined &&
1347
- listOptions.brief === undefined &&
1348
- listOptions.full === undefined &&
1349
- listOptions.fields === undefined &&
1350
- listOptions.includeBody === undefined) {
1351
- listOptions.compact = true;
1352
- }
1353
- // pm-rmjy: echo applied filters + projection mode so agents get structured confirmation.
1354
- return withQuerySummary((await runList(readString(ctx.args, "status") ?? readString(listOptions, "status"), listOptions, ctx.global)), listOptions);
1355
- }
1356
- async function runMcpSearchAction(ctx) {
1357
- const query = readRequiredString(ctx.args, "query");
1358
- const searchOptions = applyContextIntentProjection("search", ctx.options, [query]);
1359
- if (searchOptions.compact === undefined &&
1360
- searchOptions.full === undefined &&
1361
- searchOptions.fields === undefined) {
1362
- searchOptions.compact = true;
1363
- }
1364
- return withQuerySummary((await runSearch(query, searchOptions, ctx.global)), searchOptions);
1365
- }
1366
- async function runMcpCreateAction(ctx) {
1367
- const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1368
- return projectMutationResult(await runCreate(runnerOptions, ctx.global), {
1369
- changedFields,
1370
- compactEnvelope: changedFields === "compact" && !idOnly,
1371
- idOnly,
1372
- });
1373
- }
1374
- async function runMcpCopyAction(ctx) {
1375
- const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1376
- const copyOptions = {
1377
- ...runnerOptions,
1378
- ...(runnerOptions.title === undefined && typeof ctx.args.title === "string"
1379
- ? { title: ctx.args.title }
1380
- : {}),
1381
- ...(runnerOptions.message === undefined &&
1382
- typeof ctx.args.message === "string"
1383
- ? { message: ctx.args.message }
1384
- : {}),
1385
- };
1386
- return projectMutationResult(await runCopy(requireMcpItemId(ctx, copyOptions), copyOptions, ctx.global), {
1387
- changedFields,
1388
- compactEnvelope: changedFields === "compact" && !idOnly,
1389
- idOnly,
1390
- });
1391
- }
1392
- async function runMcpUpdateAction(ctx) {
1393
- const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1394
- return projectMutationResult(await runUpdate(requireMcpItemId(ctx, runnerOptions), runnerOptions, ctx.global), {
1395
- changedFields,
1396
- compactEnvelope: changedFields === "compact" && !idOnly,
1397
- idOnly,
1398
- });
1399
- }
1400
- function runMcpCommentsAction(ctx) {
1401
- const commentOptions = normalizeAnnotationTransportOptions(ctx.options);
1402
- const isListing = commentOptions.add === undefined &&
1403
- commentOptions.stdin === undefined &&
1404
- commentOptions.file === undefined &&
1405
- commentOptions.edit === undefined &&
1406
- commentOptions.delete === undefined;
1407
- if (isListing) {
1408
- commentOptions.includeMeta = true;
1409
- if (commentOptions.limit === undefined &&
1410
- commentOptions.fullHistory !== true) {
1411
- commentOptions.limit = "20";
1412
- }
1413
- }
1414
- return runComments(requireMcpItemId(ctx), commentOptions, ctx.global);
1415
- }
1416
- function runMcpFilesLookupAction(ctx, paths) {
1417
- return runFilesLookup(runtimeFilesLookupOptions(ctx.options, paths, parseMcpInteger), ctx.global);
1418
- }
1419
- function runMcpFilesAction(ctx) {
1420
- const lookupPaths = readStringArray(ctx.options.lookupPath);
1421
- if (lookupPaths && lookupPaths.length > 0) {
1422
- return runMcpFilesLookupAction(ctx, lookupPaths);
1423
- }
1424
- const fileId = requireMcpItemId(ctx);
1425
- return ctx.options.discover === true
1426
- ? runFilesDiscover(fileId, withFilesDiscoveryOptions(ctx.options), ctx.global)
1427
- : runFiles(fileId, withAddNoteOption(ctx.options), ctx.global);
1428
- }
1429
- function runMcpTelemetryAction(ctx) {
1430
- return runTelemetry({
1431
- subcommand: readString(ctx.args, "subcommand") ??
1432
- readString(ctx.options, "subcommand"),
1433
- limit: resolveRuntimeLimit(ctx.args, ctx.options),
1434
- }, ctx.global);
1435
- }
1436
- function runMcpHealthAction(ctx) {
1437
- const healthOptions = { ...ctx.options };
1438
- if (healthOptions.brief === undefined &&
1439
- healthOptions.summary === undefined &&
1440
- healthOptions.full === undefined) {
1441
- healthOptions.summary = true;
1442
- }
1443
- return runHealth(ctx.global, healthOptions);
1444
- }
1445
- function runMcpConfigAction(ctx) {
1446
- const configAction = readString(ctx.args, "configAction") ??
1447
- readString(ctx.options, "configAction") ??
1448
- readString(ctx.options, "action");
1449
- if (configAction === undefined)
1450
- throw new PmCliError("Missing required argument: configAction", 64);
1451
- const value = readString(ctx.args, "value") ?? readString(ctx.options, "value");
1452
- const options = readString(ctx.options, "policy") !== undefined && value !== undefined ? { ...ctx.options, value } : ctx.options;
1453
- return runConfig(readString(ctx.args, "scope") ??
1454
- readString(ctx.options, "scope") ??
1455
- "project", configAction, readString(ctx.args, "key") ?? readString(ctx.options, "key"), options, ctx.global, readString(ctx.options, "policy") === undefined ? value : undefined);
1456
- }
1457
- function runMcpActivityAction(ctx) {
1458
- const options = ctx.options;
1459
- return runActivity(normalizeActivityProjectionOptions(options), ctx.global);
1460
- }
1461
- function parseMcpIntegerPrefix(value, label) {
1462
- if (typeof value === "number") {
1463
- if (!Number.isFinite(value) || !Number.isInteger(value)) {
1464
- throw new PmCliError(`${label} must be a finite integer.`, 64);
1465
- }
1466
- return value;
1467
- }
1468
- if (typeof value === "string" && value.trim().length > 0) {
1469
- const trimmed = value.trim();
1470
- if (!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(trimmed)) {
1471
- throw new PmCliError(`${label} must be a finite integer.`, 64);
1472
- }
1473
- const parsed = Number.parseInt(trimmed, 10);
1474
- if (!Number.isInteger(parsed)) {
1475
- throw new PmCliError(`${label} must be a finite integer.`, 64);
1476
- }
1477
- return parsed;
1478
- }
1479
- return undefined;
1480
- }
1481
- function runMcpPlanAction(ctx) {
1482
- const subcommand = readString(ctx.args, "subcommand") ??
1483
- readRequiredString(ctx.options, "subcommand");
1484
- const planRecord = ctx.options;
1485
- return runPlan({
1486
- subcommand: subcommand,
1487
- id: typeof ctx.id === "string"
1488
- ? ctx.id
1489
- : typeof planRecord.id === "string"
1490
- ? planRecord.id
1491
- : undefined,
1492
- stepRef: readMcpPlanStepRef(ctx),
1493
- reorderTo: parseMcpIntegerPrefix(planRecord.reorderTo ?? ctx.args.reorderTo, "plan reorderTo"),
1494
- options: ctx.options,
1495
- global: ctx.global,
1496
- });
1497
- }
1498
- function readMcpPlanStepRef(ctx) {
1499
- return typeof ctx.options.stepRef === "string"
1500
- ? ctx.options.stepRef
1501
- : typeof ctx.args.stepRef === "string"
1502
- ? ctx.args.stepRef
1503
- : undefined;
1504
- }
1505
- function createMcpSchemaContext(ctx) {
1506
- const subcommand = readString(ctx.args, "subcommand") ??
1507
- readRequiredString(ctx.options, "subcommand");
1508
- const aliasSource = ctx.args.alias ?? ctx.options.alias;
1509
- return {
1510
- ctx,
1511
- subcommand: subcommand.trim().toLowerCase(),
1512
- name: readString(ctx.args, "name") ?? readString(ctx.options, "name"),
1513
- author: readString(ctx.args, "author") ?? readString(ctx.options, "author"),
1514
- force: ctx.args.force === true || ctx.options.force === true,
1515
- aliases: aliasSource === undefined ? undefined : readStringArray(aliasSource),
1516
- };
1517
- }
1518
- function runMcpSchemaReadOrRemoveAction(schema) {
1519
- const { ctx, subcommand, name, author, force } = schema;
1520
- const simpleHandlers = {
1521
- list: () => runSchemaList(ctx.global),
1522
- show: () => runSchemaShow(name, ctx.global),
1523
- "show-status": () => runSchemaShowStatus(name, ctx.global),
1524
- "list-fields": () => runSchemaListFields(ctx.global),
1525
- "show-field": () => runSchemaShowField(name, ctx.global),
1526
- "remove-type": () => runSchemaRemoveType(name, { author, force }, ctx.global),
1527
- "remove-field": () => runSchemaRemoveField(name, { author, force }, ctx.global),
1528
- "remove-status": () => runSchemaRemoveStatus(name, { author, force }, ctx.global),
1529
- "apply-preset": () => runSchemaApplyPreset(readString(ctx.args, "typePreset") ??
1530
- readString(ctx.options, "typePreset"), { author, force }, ctx.global),
1531
- };
1532
- const handler = getOwnHandler(simpleHandlers, subcommand);
1533
- return handler ? handler() : null;
1534
- }
1535
- function runMcpSchemaAddFieldAction(schema) {
1536
- const { ctx, name, author, force, aliases } = schema;
1537
- const commandsSource = ctx.args.commands ?? ctx.options.commands;
1538
- const requiredTypesSource = ctx.args.requiredTypes ?? ctx.options.requiredTypes;
1539
- return runSchemaAddField(name, {
1540
- type: readString(ctx.args, "fieldType") ??
1541
- readString(ctx.options, "fieldType"),
1542
- commands: commandsSource === undefined
1543
- ? undefined
1544
- : readStringArray(commandsSource),
1545
- description: readString(ctx.args, "description") ??
1546
- readString(ctx.options, "description"),
1547
- cliFlag: readString(ctx.args, "cliFlag") ?? readString(ctx.options, "cliFlag"),
1548
- alias: aliases,
1549
- required: ctx.args.required === true || ctx.options.required === true,
1550
- requiredOnCreate: ctx.args.requiredOnCreate === true ||
1551
- ctx.options.requiredOnCreate === true,
1552
- allowUnset: !(ctx.args.allowUnset === false || ctx.options.allowUnset === false),
1553
- requiredTypes: requiredTypesSource === undefined
1554
- ? undefined
1555
- : readStringArray(requiredTypesSource),
1556
- author,
1557
- force,
1558
- }, ctx.global);
1559
- }
1560
- function runMcpSchemaAddStatusAction(schema) {
1561
- const { ctx, name, author, force, aliases } = schema;
1562
- const roleSource = ctx.args.role ?? ctx.options.role;
1563
- return runSchemaAddStatus(name, {
1564
- role: roleSource === undefined ? undefined : readStringArray(roleSource),
1565
- alias: aliases,
1566
- description: readString(ctx.args, "description") ??
1567
- readString(ctx.options, "description"),
1568
- order: parseMcpInteger(ctx.args.order ?? ctx.options.order, "schema add-status order"),
1569
- author,
1570
- force,
1571
- }, ctx.global);
1572
- }
1573
- function runMcpSchemaAddTypeAction(schema) {
1574
- const { ctx, name, author, force, aliases } = schema;
1575
- return runSchemaAddType(name, {
1576
- description: readString(ctx.args, "description") ??
1577
- readString(ctx.options, "description"),
1578
- defaultStatus: readString(ctx.args, "defaultStatus") ??
1579
- readString(ctx.args, "default_status") ??
1580
- readString(ctx.options, "defaultStatus") ??
1581
- readString(ctx.options, "default_status"),
1582
- folder: readString(ctx.args, "folder") ?? readString(ctx.options, "folder"),
1583
- alias: aliases,
1584
- author,
1585
- force,
1586
- }, ctx.global);
1587
- }
1588
- function runMcpSchemaMigrationAction(schema) {
1589
- const { ctx, subcommand, name, author, force } = schema;
1590
- const to = readString(ctx.args, "to") ?? readRequiredString(ctx.options, "to");
1591
- const migrationId = readString(ctx.args, "migrationId") ??
1592
- readString(ctx.args, "migration_id") ??
1593
- readString(ctx.options, "migrationId") ??
1594
- readString(ctx.options, "migration_id");
1595
- const fieldTypeScope = readString(ctx.args, "fieldTypeScope") ??
1596
- readString(ctx.options, "fieldTypeScope") ??
1597
- readString(ctx.args, "type") ??
1598
- readString(ctx.options, "type");
1599
- const request = subcommand === "rename-type"
1600
- ? { kind: "rename-type", from: name ?? "", to }
1601
- : subcommand === "rename-field"
1602
- ? {
1603
- kind: "rename-field",
1604
- from: name ?? "",
1605
- to,
1606
- ...(fieldTypeScope === undefined ? {} : { type: fieldTypeScope }),
1607
- }
1608
- : { kind: "remap-status", from: name ?? "", to };
1609
- return runSchemaEvolutionMigration(request, {
1610
- migrationId,
1611
- dryRun: ctx.args.dryRun === true || ctx.options.dryRun === true,
1612
- author,
1613
- force,
1614
- }, ctx.global);
1615
- }
1616
- function runMcpSchemaAction(ctx) {
1617
- const schema = createMcpSchemaContext(ctx);
1618
- const simpleResult = runMcpSchemaReadOrRemoveAction(schema);
1619
- if (simpleResult !== null) {
1620
- return simpleResult;
1621
- }
1622
- if (schema.subcommand === "rename-type" ||
1623
- schema.subcommand === "rename-field" ||
1624
- schema.subcommand === "remap-status") {
1625
- return runMcpSchemaMigrationAction(schema);
1626
- }
1627
- if (schema.subcommand === "add-field") {
1628
- return runMcpSchemaAddFieldAction(schema);
1629
- }
1630
- if (schema.subcommand === "add-status") {
1631
- return runMcpSchemaAddStatusAction(schema);
1632
- }
1633
- if (schema.subcommand === "add-type") {
1634
- if (ctx.args.infer === true || ctx.options.infer === true) {
1635
- return runSchemaInferTypes({
1636
- minCount: parseMcpInteger(ctx.args.minCount ?? ctx.options.minCount, "schema infer minCount"),
1637
- apply: ctx.args.apply === true || ctx.options.apply === true,
1638
- author: schema.author,
1639
- force: schema.force,
1640
- }, ctx.global);
1641
- }
1642
- return runMcpSchemaAddTypeAction(schema);
1643
- }
1644
- throw createUnknownSubcommandError({
1645
- command_path: "schema",
1646
- token: schema.subcommand,
1647
- allowed: SCHEMA_SUBCOMMANDS,
1648
- exit_code: 64,
1649
- });
1650
- }
1651
- function runMcpProfileAction(ctx) {
1652
- const subcommand = readString(ctx.args, "subcommand") ??
1653
- readRequiredString(ctx.options, "subcommand");
1654
- const normalizedSubcommand = subcommand.trim().toLowerCase();
1655
- const profileName = readString(ctx.args, "name") ?? readString(ctx.options, "name");
1656
- const handlers = {
1657
- list: () => runProfileList(),
1658
- show: () => runProfileShow(profileName),
1659
- lint: () => runProfileLint(profileName),
1660
- apply: () => runProfileApply(profileName, {
1661
- dryRun: ctx.args.dryRun === true || ctx.options.dryRun === true,
1662
- author: readString(ctx.args, "author") ?? readString(ctx.options, "author"),
1663
- force: ctx.args.force === true || ctx.options.force === true,
1664
- }, ctx.global),
1665
- };
1666
- const handler = getOwnHandler(handlers, normalizedSubcommand);
1667
- if (!handler) {
1668
- throw createUnknownSubcommandError({
1669
- command_path: "profile",
1670
- token: subcommand,
1671
- allowed: PROFILE_SUBCOMMANDS,
1672
- exit_code: 64,
1673
- });
1674
- }
1675
- return handler();
1676
- }
1677
- async function runMcpAppendAction(ctx) {
1678
- const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1679
- return projectMutationResult(await runAppend(requireMcpItemId(ctx, runnerOptions), runnerOptions, ctx.global), {
1680
- changedFields,
1681
- compactEnvelope: changedFields === "compact" && !idOnly,
1682
- idOnly,
1683
- });
1684
- }
1685
- async function runMcpUpdateManyAction(ctx) {
1686
- const { changedFields, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1687
- return projectMutationResult(await runUpdateMany(updateManyOptionsFromFlat(runnerOptions), ctx.global), { changedFields });
1688
- }
1689
- async function runMcpCloseManyAction(ctx) {
1690
- const { changedFields, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1691
- const topLevelReason = readString(ctx.args, "reason");
1692
- const closeManyRunnerOptions = topLevelReason !== undefined && runnerOptions.reason === undefined
1693
- ? { ...runnerOptions, reason: topLevelReason }
1694
- : { ...runnerOptions };
1695
- if (ctx.force && closeManyRunnerOptions.force === undefined) {
1696
- closeManyRunnerOptions.force = true;
1697
- }
1698
- return projectMutationResult(await runCloseMany(closeManyOptionsFromFlat(closeManyRunnerOptions), ctx.global), { changedFields });
1699
- }
1700
- async function runMcpRestoreAction(ctx) {
1701
- const { changedFields, idOnly, runnerOptions } = withMutationCompaction(ctx.args, ctx.options);
1702
- const target = readString(runnerOptions, "target") ??
1703
- readRequiredString(ctx.args, "target");
1704
- return projectMutationResult(await runRestore(requireMcpItemId(ctx, runnerOptions), target, runnerOptions, ctx.global), {
1705
- changedFields,
1706
- compactEnvelope: changedFields === "compact" && !idOnly,
1707
- idOnly,
1708
- });
1709
- }
1710
- async function runMcpStartTaskAction(ctx) {
1711
- const pmRoot = resolvePmRoot(process.cwd(), ctx.global.path);
1712
- const settings = await readSettings(pmRoot);
1713
- const inProgressStatus = resolveStartTaskInProgressStatus(resolveRuntimeStatusRegistry(settings.schema));
1714
- const id = requireMcpItemId(ctx);
1715
- const claimResult = await runClaim(id, ctx.force, ctx.global, ctx.options);
1716
- const updateResult = await runUpdate(id, mutationOptionsWithOverrides(ctx.options, { status: inProgressStatus, force: ctx.force }, ["assignee"]), ctx.global);
1717
- return { id, action: "start_task", claim: claimResult, update: updateResult };
1718
- }
1719
- async function runMcpPauseTaskAction(ctx) {
1720
- const pmRoot = resolvePmRoot(process.cwd(), ctx.global.path);
1721
- const settings = await readSettings(pmRoot);
1722
- const id = requireMcpItemId(ctx);
1723
- const openStatus = resolveRuntimeStatusRegistry(settings.schema).open_status;
1724
- const updateResult = await runUpdate(id, mutationOptionsWithOverrides(ctx.options, { status: openStatus, force: ctx.force }, ["assignee"]), ctx.global);
1725
- const releaseResult = await runRelease(id, ctx.force, ctx.global, ctx.options);
1726
- return {
1727
- id,
1728
- action: "pause_task",
1729
- update: updateResult,
1730
- release: releaseResult,
1731
- };
1732
- }
1733
- async function runMcpCloseTaskAction(ctx) {
1734
- const id = requireMcpItemId(ctx);
1735
- const closeReason = readString(ctx.args, "reason") ??
1736
- readString(ctx.args, "text") ??
1737
- readString(ctx.options, "reason") ??
1738
- readString(ctx.options, "text");
1739
- const closeResult = await runClose(id, closeReason, { ...ctx.options, force: ctx.force }, ctx.global);
1740
- const releaseResult = await runRelease(id, ctx.force, ctx.global, ctx.options);
1741
- return {
1742
- id,
1743
- action: "close_task",
1744
- close: closeResult,
1745
- release: releaseResult,
1746
- };
1747
- }
1748
- /** Dispatch the graph action merging flat MCP parameters onto runner options. */
1749
- function runMcpGraphAction(ctx) {
1750
- const merged = { ...ctx.args, ...ctx.options };
1751
- return runGraph(readRequiredString(merged, "subcommand"), readString(merged, "id") ?? ctx.id, readString(merged, "target"), graphOptionsFromFlat(merged), ctx.global);
1752
- }
1753
- function runMcpHistoryAuthorAcknowledgeAction(ctx) {
1754
- return acknowledgeUnknownAuthorHistoryEventsFromTransport(resolvePmRoot(process.cwd(), ctx.global.path), { ...ctx.args, ...ctx.options });
1755
- }
1756
- const SDK_ACTION_HANDLERS = {
1757
- init: (ctx) => runInit(readString(ctx.args, "prefix"), ctx.global, ctx.options),
1758
- context: (ctx) => runContext(applyContextIntentProjection("context", ctx.options), ctx.global),
1759
- next: (ctx) => runNext(applyContextIntentProjection("next", ctx.options), ctx.global),
1760
- eval: runRuntimeEvalAction,
1761
- events: runRuntimeEventsAction,
1762
- merge: runRuntimeMergeAction,
1763
- workspace: runRuntimeWorkspaceAction,
1764
- meet: runRuntimeSchedulingAction,
1765
- event: runRuntimeSchedulingAction,
1766
- remind: runRuntimeSchedulingAction,
1767
- list: runMcpListAction,
1768
- get: (ctx) => {
1769
- const id = requireMcpItemId(ctx);
1770
- return runGet(id, ctx.global, applyContextIntentProjection("get", ctx.options, [id]));
1771
- },
1772
- search: runMcpSearchAction,
1773
- /** Normalize MCP duplicate controls before delegating to the shared SDK action. */
1774
- duplicates: (ctx) => {
1775
- const status = typeof ctx.options.status === "string"
1776
- ? [ctx.options.status]
1777
- : readStringArray(ctx.options.status);
1778
- return runDuplicates(ctx.global, {
1779
- exhaustive: ctx.options.exhaustive === true,
1780
- ...(status.length === 0 ? {} : { status }),
1781
- since: readString(ctx.options, "since"),
1782
- threshold: typeof ctx.options.threshold === "number"
1783
- ? ctx.options.threshold
1784
- : undefined,
1785
- limit: ctx.options.limit === "default"
1786
- ? undefined
1787
- : parseMcpInteger(ctx.options.limit, "limit"),
1788
- });
1789
- },
1790
- create: runMcpCreateAction,
1791
- copy: runMcpCopyAction,
1792
- focus: (ctx) => runFocus(ctx.id, { clear: ctx.options.clear === true || ctx.args.clear === true }, ctx.global),
1793
- update: runMcpUpdateAction,
1794
- "item-reopen": runMcpReopenAction,
1795
- restore: runMcpRestoreAction,
1796
- claim: (ctx) => ctx.options.next === true || ctx.args.next === true
1797
- ? runClaimNext(ctx.force, ctx.global, { ...ctx.options, ...ctx.args }, { ...ctx.options, ...ctx.args })
1798
- : runClaim(requireMcpItemId(ctx), ctx.force, ctx.global, ctx.options),
1799
- release: (ctx) => runRelease(requireMcpItemId(ctx), ctx.force, ctx.global, ctx.options),
1800
- "start-task": runMcpStartTaskAction,
1801
- "pause-task": runMcpPauseTaskAction,
1802
- "close-task": runMcpCloseTaskAction,
1803
- close: runMcpCloseAction,
1804
- comments: runMcpCommentsAction,
1805
- notes: (ctx) => runNotes(requireMcpItemId(ctx), normalizeAnnotationTransportOptions(ctx.options), ctx.global),
1806
- learnings: (ctx) => runLearnings(requireMcpItemId(ctx), normalizeAnnotationTransportOptions(ctx.options), ctx.global),
1807
- files: runMcpFilesAction,
1808
- docs: (ctx) => runDocs(requireMcpItemId(ctx), withAddNoteOption(ctx.options), ctx.global),
1809
- test: (ctx) => runTest(requireMcpItemId(ctx), ctx.options, ctx.global),
1810
- "test-all": (ctx) => runTestAll(ctx.options, ctx.global),
1811
- telemetry: runMcpTelemetryAction,
1812
- validate: (ctx) => runValidate(ctx.options, ctx.global, {
1813
- runUpdate: (id, options, global) => runUpdate(id, options, global),
1814
- }),
1815
- health: runMcpHealthAction,
1816
- assurance: (ctx) => runAssuranceDispatch(ctx.args, ctx.options, ctx.global),
1817
- contracts: (ctx) => runContracts(ctx.options, ctx.global),
1818
- config: runMcpConfigAction,
1819
- activity: runMcpActivityAction,
1820
- aggregate: (ctx) => runAggregate(ctx.options, ctx.global),
1821
- extension: (ctx) => runExtension(readMcpTarget(ctx), ctx.options, ctx.global),
1822
- package: (ctx) => runExtension(readMcpTarget(ctx), ctx.options, ctx.global),
1823
- install: (ctx) => runExtension(readMcpTarget(ctx), { ...ctx.options, install: true }, ctx.global),
1824
- upgrade: (ctx) => runUpgrade(readMcpTarget(ctx), ctx.options, ctx.global),
1825
- delete: (ctx) => runDelete(requireMcpItemId(ctx), ctx.options, ctx.global),
1826
- deps: (ctx) => runDeps(requireMcpItemId(ctx), ctx.options, ctx.global),
1827
- graph: runMcpGraphAction,
1828
- "files-discover": (ctx) => runFilesDiscover(requireMcpItemId(ctx), ctx.options, ctx.global),
1829
- "files-lookup": (ctx) => runMcpFilesLookupAction(ctx, readStringArray(ctx.options.paths)),
1830
- history: (ctx) => runHistory(requireMcpItemId(ctx), ctx.options, ctx.global),
1831
- "history-redact": (ctx) => runHistoryRedact(requireMcpItemId(ctx), ctx.options, ctx.global),
1832
- "history-repair": runMcpHistoryRepairAction,
1833
- "history-compact": runMcpHistoryCompactAction,
1834
- "history-author-acknowledge": runMcpHistoryAuthorAcknowledgeAction,
1835
- plan: runMcpPlanAction,
1836
- schema: runMcpSchemaAction,
1837
- profile: runMcpProfileAction,
1838
- stats: (ctx) => runStats(ctx.global, statsCommandOptionsFromRuntime(ctx.options)),
1839
- append: runMcpAppendAction,
1840
- "update-many": runMcpUpdateManyAction,
1841
- "close-many": runMcpCloseManyAction,
1842
- gc: (ctx) => runGc(ctx.global, ctx.options),
1843
- };
1844
- /**
1845
- * Derive the SDK dispatch coverage matrix from the live action and alias
1846
- * registries instead of a hand-maintained test list.
1847
- */
1848
- export function analyzeSdkActionCoverage(actions = PM_TOOL_ACTIONS) {
1849
- return actions.map((action) => {
1850
- const normalized = normalizeActionName(action);
1851
- const alias = getOwnHandler(SDK_ACTION_ALIASES, normalized);
1852
- const resolvedAction = alias?.action ?? normalized;
1853
- const covered = getOwnHandler(SDK_ACTION_HANDLERS, resolvedAction) !== undefined;
1854
- return {
1855
- action,
1856
- resolved_action: resolvedAction,
1857
- covered,
1858
- route: covered ? (alias ? "alias" : "native") : "missing",
1859
- };
1860
- });
1861
- }
1862
- async function dispatchAction(action, args, global, activeExtensions) {
1863
- const options = optionsWithAuthor(args, action);
1864
- validateReadOutputOptions(action, options);
1865
- normalizeReadOutputIncludeModeOptions(action, options);
1866
- const ctx = {
1867
- action,
1868
- args,
1869
- options,
1870
- id: readString(args, "id"),
1871
- force: args.force === true || options.force === true,
1872
- global,
1873
- activeExtensions,
1874
- };
1875
- const handler = getOwnHandler(SDK_ACTION_HANDLERS, action);
1876
- const result = handler
1877
- ? await handler(ctx)
1878
- : await dispatchActiveExtensionAction(action, args, options, global, activeExtensions);
1879
- options.resolvedOutputFormat = "json";
1880
- const projected = attachReadOutputContracts(action, options, result);
1881
- await finalizeContextUsageEgress(resolvePmRoot(process.cwd(), global.path), projected);
1882
- return projected;
1883
- }
1884
- const actionRunnerTestHooks = {
1885
- closeManyOptionsFromFlat,
1886
- extensionOptionsFromArgs,
1887
- globalOptions,
1888
- mutationListOptions,
1889
- normalizeActionName,
1890
- normalizeCommandPath,
1891
- normalizeMcpUpdateOptions,
1892
- normalizeMcpOptionsArrays,
1893
- optionsWithAuthor,
1894
- readRequiredString,
1895
- readScalarString,
1896
- readScalarStringAllowBlank,
1897
- readStringArray,
1898
- updateManyOptionsFromFlat,
1899
- withAddNoteOption,
1900
- withFilesDiscoveryOptions,
1901
- withMutationCompaction,
1902
- };
1903
- if (process.env.NODE_ENV === "test" ||
1904
- process.env.VITEST !== undefined ||
1905
- process.env.VITEST_WORKER_ID !== undefined) {
1906
- globalThis.__pmCliActionRunnerTestHooks = actionRunnerTestHooks;
1907
- }
1908
- async function loadWorkspaceExtensionRegistrations(pmRoot, settings, cwd) {
1909
- const loadResult = await loadExtensions({
1910
- pmRoot,
1911
- settings,
1912
- cwd: cwd ?? process.cwd(),
1913
- noExtensions: false,
1914
- });
1915
- const activationResult = await activateExtensions(loadResult);
1916
- try {
1917
- return activationResult.registrations;
1918
- }
1919
- finally {
1920
- try {
1921
- await deactivateExtensions(loadResult, activationResult);
1922
- }
1923
- catch {
1924
- // Workspace contract reads should stay best-effort even if teardown itself fails.
1925
- }
1926
- }
1927
- }
1
+ !(function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="556364bc-5faa-5412-a327-e409564fbadf")}catch(e2){}})();import{PM_GITIGNORE_END,PM_GITIGNORE_START,ensurePmGitignore,getPmGitignoreBlock}from"./workspace.js";import{SEARCH_EXTENSION_FLAG_DEFINITIONS}from"./extension-contracts.js";export*from"./cli-contracts/agent-output-contracts.js";import{AsyncLocalStorage}from"node:async_hooks";import path from"node:path";import{createEmptyExtensionCommandRegistry,createEmptyExtensionHookRegistry,createEmptyExtensionParserRegistry,createEmptyExtensionPreflightRegistry,createEmptyExtensionRegistrationRegistry,createEmptyExtensionRendererRegistry,createEmptyExtensionServiceRegistry}from"../core/extensions/extension-registries.js";import{activateExtensions,deactivateExtensions,loadExtensions,runActiveCommandHandler,runWithIsolatedExtensionRuntime,setActiveExtensionCommands,setActiveExtensionHooks,setActiveExtensionParsers,setActiveExtensionPreflight,setActiveExtensionRegistrations,setActiveExtensionRenderers,setActiveExtensionServices}from"../core/extensions/index.js";import{pathExists}from"../core/fs/fs-utils.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{projectMutationResult}from"../core/output/mutation-projection.js";import{withQuerySummary}from"../core/output/query-summary.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{asRecordClone}from"../core/shared/primitives.js";import{createAsyncReadWriteGate}from"../core/shared/serial-queue.js";import{resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry}from"../core/schema/runtime-schema.js";import{getSettingsPath,resolvePmRoot}from"../core/store/paths.js";import{readSettings}from"../core/store/settings.js";import{listClientItemMetadataLight}from"./query/light-metadata.js";import{certifyCompleteListResult,createCompleteListOptions}from"./query/complete-list.js";import{PmCompleteListValidationError,assertCompleteListResult,certifyCompleteListResult as certifyCompleteListResult2,createCompleteListOptions as createCompleteListOptions2,inspectCompleteListResult}from"./query/complete-list.js";import{buildWorkspaceExtensionCommandContracts,buildWorkspaceFieldContracts}from"./workspace-contracts.js";import{PM_TOOL_ACTIONS}from"./cli-contracts/enum-contracts.js";import{clearWorkspaceContractsCache,memoizeWorkspaceExtensionRegistrations}from"./workspace-contracts-cache.js";import{SDK_ACTION_ALIASES}from"./runtime-action-aliases.js";import{createExtensionCommandSdk}from"./extension-command-context.js";import{createUnknownSubcommandError}from"./agent/subcommand-recovery.js";import{applyContextIntentProjection,attachReadOutputContracts}from"./context-intent-contracts.js";import{finalizeContextUsageEgress}from"./context/usage-egress.js";import{runWithDiscoveredContextIntentContracts}from"./context-intent-runtime.js";import{normalizeReadOutputIncludeModeOptions,validateReadOutputOptions}from"./read-output-contracts.js";import{clearWorkspaceContractsCache as clearWorkspaceContractsCache2}from"./workspace-contracts-cache.js";import{normalizeActivityProjectionOptions,runActivity}from"./query/activity.js";import{runAssuranceDispatch}from"./governance/assurance-action.js";import{runAggregate}from"./query/aggregate.js";import{runAppend}from"./lifecycle/append.js";import{runClaim,runRelease}from"./lifecycle/claim.js";import{runCloseMany}from"./lifecycle/close-many.js";import{normalizeAnnotationTransportOptions}from"./annotations.js";import{runComments}from"./comments.js";import{runHistory}from"./query/history.js";import{runLearnings}from"./learnings.js";import{runNotes}from"./notes.js";import{runUpdateMany}from"./lifecycle/update-many.js";import{runUpgrade}from"./governance/upgrade.js";import{runCreate}from"./lifecycle/create.js";import{runUpdate}from"./lifecycle/update.js";import{runPlan}from"./lifecycle/plan.js";import{runContext}from"./query/context.js";import{runNext}from"./query/next.js";import{runClose}from"./lifecycle/close.js";import{runCopy}from"./lifecycle/copy.js";import{runDelete}from"./lifecycle/delete.js";import{runRestore}from"./lifecycle/restore.js";import{runFocus}from"./lifecycle/focus.js";import{runGet}from"./query/get.js";import{runGc}from"./governance/gc.js";import{runHealth}from"./governance/health.js";import{runValidate}from"./governance/validate.js";import{runExtension}from"./extension.js";import{runConfig}from"./config.js";import{INIT_INVOCATION_CWD,runInit}from"./init.js";import{runRuntimeEvalAction,runRuntimeEventsAction,runRuntimeMergeAction,runRuntimeSchedulingAction,runRuntimeWorkspaceAction}from"./runtime-extended-actions.js";import{acknowledgeUnknownAuthorHistoryEventsFromTransport}from"./author-attribution.js";import{PROFILE_SUBCOMMANDS,runProfileApply,runProfileLint,runProfileList,runProfileShow}from"./profile.js";import{runHistoryRedact}from"./history-redact.js";import{runMcpHistoryCompactAction,runMcpHistoryRepairAction}from"./history-mcp.js";import{runMcpClaimAction,runMcpCloseAction,runMcpReopenAction}from"./lifecycle/mcp-actions.js";import{actionGlobalOptions as globalOptions,closeManyOptionsFromFlat,extensionOptionsFromArgs,graphOptionsFromFlat,mutationListOptions,mutationOptionsWithOverrides,normalizeActionName,normalizeCommandPath,normalizeMcpOptionsArrays,normalizeMcpUpdateOptions,optionsWithAuthor,parseRuntimeInteger as parseMcpInteger,readRuntimeScalarString as readScalarString,readRuntimeScalarStringAllowBlank as readScalarStringAllowBlank,readRuntimeString as readString,readRuntimeStringArray as readStringArray,resolveRuntimeLimit,shouldInvalidateWorkspaceContractsCacheAfterAction,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction}from"./runtime-input.js";import{runDeps}from"./dependencies.js";import{runDocs}from"./docs.js";import{runGraph}from"./graph/run.js";import{runFiles,runFilesDiscover,runFilesLookup}from"./files.js";import{runtimeFilesLookupOptions}from"./traceability/runtime-files-lookup.js";import{runContracts}from"./cli-contracts/runtime-contracts.js";import{runList}from"./query/list.js";import{runSearch}from"./query/search.js";import{runStats}from"./stats.js";import{statsCommandOptionsFromRuntime}from"./runtime-stats-options.js";import{runDuplicates}from"./duplicates.js";import{runTelemetry}from"./telemetry.js";import{runTest}from"./test/execution.js";import{runTestAll}from"./test/batch.js";import{resolveStartTaskInProgressStatus}from"./start-task-status.js";import{SCHEMA_SUBCOMMANDS,runSchemaAddField,runSchemaAddStatus,runSchemaAddType,runSchemaApplyPreset,runSchemaInferTypes,runSchemaList,runSchemaListFields,runSchemaEvolutionMigration,runSchemaRemoveField,runSchemaRemoveStatus,runSchemaRemoveType,runSchemaShow,runSchemaShowField,runSchemaShowStatus}from"./schema.js";import{getActiveExtensionRegistrations,runActiveOnReadHooks,runActiveOnWriteHooks}from"../core/extensions/index.js";import{pathExists as pathExists2,readFileIfExists,removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{classifyHistoryEvent,HISTORY_EVENT_CLASSIFICATION_VERSION,MAINTENANCE_HISTORY_OPERATIONS,SUBSTANTIVE_HISTORY_OPERATIONS}from"../core/history/event-classification.js";import{generateItemId,normalizeItemId,normalizeRawItemId}from"../core/item/id.js";import{readBooleanOption,readCsvListOption,readStringOption}from"./package-runtime-options.js";import{PM_CLI_EXPECTED_ERROR_NAME,createPmCliExpectedError,isPmCliExpectedError}from"./errors.js";import{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString}from"./package-import-adapters.js";import{canonicalDocument,normalizeItemMetadata,serializeItemDocument,splitFrontMatter}from"../core/item/item-format.js";import{BASELINE_ITEM_FORMAT_VERSION,CURRENT_ITEM_FORMAT_VERSION,classifyItemFormatVersion,effectiveItemFormatVersion,normalizeItemFormatVersion,scanItemFormatVersions}from"../core/item/item-format-version.js";import{parseTags}from"../core/item/parse.js";import{isTerminalStatus,normalizeStatusInput}from"../core/item/status.js";import{resolveItemTypeRegistry as resolveItemTypeRegistry2}from"../core/item/type-registry.js";import{acquireLock}from"../core/lock/lock.js";import{resolveRuntimeFieldRegistry as resolveRuntimeFieldRegistry2,resolveRuntimeStatusRegistry as resolveRuntimeStatusRegistry2}from"../core/schema/runtime-schema.js";import{PmCliError as PmCliError2}from"../core/shared/errors.js";import{isTimestampLiteral,nowIso}from"../core/shared/time.js";import{jaccardSimilarity,normalizeSimilarityText,scoreItemSimilarity,tokenizeSimilarityText}from"./similarity-scoring.js";import{listAllItemMetadata,listAllItemMetadataLight,locateItem,readLocatedItem}from"../core/store/item-store.js";import{getHistoryPath,getItemPath,getSettingsPath as getSettingsPath2,resolveImplicitPmRoot,resolvePmRoot as resolvePmRoot2}from"../core/store/paths.js";import{readSettings as readSettings2}from"../core/store/settings.js";import{runAggregate as runAggregate2}from"./query/aggregate.js";import{CONTEXT_OUTPUT_VALUES,runContext as runContext2}from"./query/context.js";import{runGet as runGet2}from"./query/get.js";import{runList as runList2}from"./query/list.js";import{closeItem,runClose as runClose2}from"./lifecycle/close.js";import{runCopy as runCopy2}from"./lifecycle/copy.js";import{runDelete as runDelete2}from"./lifecycle/delete.js";import{runFocus as runFocus2}from"./lifecycle/focus.js";import{runRestore as runRestore2}from"./lifecycle/restore.js";import{DEFAULT_TERMINAL_TRANSITION_POLICY,applyTerminalOrderingPolicy,requireTerminalReason,resolveTerminalReason}from"./lifecycle-policy.js";import{runUpdate as runUpdate2}from"./lifecycle/update.js";import{runReopen}from"./lifecycle/reopen.js";import{NEXT_OUTPUT_VALUES,runNext as runNext2}from"./query/next.js";import{runSearch as runSearch2}from"./query/search.js";import{runStats as runStats2}from"./stats.js";import{runDuplicates as runDuplicates2}from"./duplicates.js";import{renderCalendarMarkdown,renderCalendarToon,resolveCalendarOutputFormat,runCalendar}from"./query/calendar.js";import{renderGuideMarkdown,resolveGuideOutputFormat,runGuide}from"./guide.js";import{runCompletion}from"./completion.js";import{runReindex}from"./governance/reindex.js";import{loadCreateTemplateOptions,runTemplatesList,runTemplatesSave,runTemplatesShow}from"./templates.js";import{runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop}from"./test/runs.js";import{CONFIDENCE_TEXT_VALUES,DEPENDENCY_KIND_VALUES,BUILTIN_ITEM_TYPE_VALUES,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,RISK_VALUES,STATUS_VALUES}from"../types/index.js";const ACTIVE_EXTENSION_HOST_CONTEXT=Symbol("pm.active-extension-host-context");function splitFullClientMutationOptions(options){return{fullChangedFields:true,options}}class PmClient{defaults;constructor(options={}){this.defaults={...options.pmRoot===void 0?{}:{path:options.pmRoot},...options.cwd===void 0?{}:{cwd:options.cwd},...options.author===void 0?{}:{author:options.author},...options.noExtensions===void 0?{}:{noExtensions:options.noExtensions}}}static forActiveExtensionHost(options){const client=new PmClient({...options,noExtensions:true});client.defaults[ACTIVE_EXTENSION_HOST_CONTEXT]=true;return client}run(action,args={}){return runAction({...this.defaults,...args,action})}runTyped(action,args={}){return this.run(action,args)}context(options={}){return this.runTyped("context",{options})}listAllItemMetadataLight(){return listClientItemMetadataLight(this.defaults.path,this.defaults.cwd)}list(options={}){return this.runTyped("list",{options})}async listAllComplete(options={}){return certifyCompleteListResult(await this.list(createCompleteListOptions(options)))}search(query,options={}){return this.runTyped("search",{query,options})}get(id,options={}){return this.runTyped("get",{id,options})}next(options={}){return this.runTyped("next",{options})}aggregate(options={}){return this.runTyped("aggregate",{options})}stats(options={}){return this.runTyped("stats",{options})}duplicates(options={}){return this.runTyped("duplicates",{options})}comments(id,options={}){return this.runTyped("comments",{id,options})}notes(id,options={}){return this.runTyped("notes",{id,options})}learnings(id,options={}){return this.runTyped("learnings",{id,options})}files(id,options={}){return this.runTyped("files",{id,options})}filesDiscover(id,options={}){return this.runTyped("files-discover",{id,options})}filesLookup(options){return this.runTyped("files-lookup",{options})}docs(id,options={}){return this.runTyped("docs",{id,options})}deps(id,options={}){return this.runTyped("deps",{id,options})}graph(subcommand,ids={},options={}){return this.runTyped("graph",{subcommand,...ids,options})}append(id,body,options={}){return this.runTyped("append",{id,...splitFullClientMutationOptions(mutationOptionsWithOverrides(options,{body}))})}init(prefix,options={}){return this.runTyped("init",{...prefix===void 0?{}:{prefix},options})}config(scope,configAction,key,value,options={}){return this.runTyped("config",{scope,configAction,...key===void 0?{}:{key},...value===void 0?{}:{value},options})}schema(subcommand,options={}){return this.runTyped("schema",{options:{...options,subcommand}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(name){return this.runTyped("schema",{name,options:{subcommand:"show"}})}schemaAddType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-type"}})}schemaRemoveType(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-type"}})}schemaAddStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-status"}})}schemaRemoveStatus(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-status"}})}schemaAddField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"add-field"}})}schemaRemoveField(name,options={}){return this.runTyped("schema",{name,options:{...options,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(name){return this.runTyped("schema",{name,options:{subcommand:"show-field"}})}schemaApplyPreset(typePreset,options={}){return this.runTyped("schema",{typePreset,options:{...options,subcommand:"apply-preset"}})}schemaInferTypes(options={}){return this.runTyped("schema",{options:{...options,subcommand:"add-type",infer:true}})}schemaRenameType(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-type",to}})}schemaRenameField(from,to,options,type){return this.runTyped("schema",{name:from,options:{...options,subcommand:"rename-field",to,...type?{fieldTypeScope:type}:{}}})}schemaRemapStatus(from,to,options){return this.runTyped("schema",{name:from,options:{...options,subcommand:"remap-status",to}})}schemaShowStatus(name){return this.runTyped("schema",{name,options:{subcommand:"show-status"}})}profile(subcommand,options={}){return this.runTyped("profile",{options:{...options,subcommand}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(name){return this.runTyped("profile",{name,options:{subcommand:"show"}})}profileApply(name,options={}){return this.runTyped("profile",{name,options:{...options,subcommand:"apply"}})}profileLint(name){return this.runTyped("profile",{name,options:{subcommand:"lint"}})}validate(options={}){return this.runTyped("validate",{options})}health(options={}){return this.runTyped("health",{options})}gc(options={}){return this.runTyped("gc",{options})}assurance(input){return this.runTyped("assurance",{options:{...input,subcommand:input.action}})}historyRedact(id,options){return this.runTyped("history-redact",{id,options})}historyRepair(id,options={}){return this.runTyped("history-repair",{id,options})}historyRepairAll(options={}){return this.runTyped("history-repair",{options:{...options,all:true}})}historyCompact(id,options={}){return this.runTyped("history-compact",{id,options})}historyCompactBulk(options){return this.runTyped("history-compact",{options})}historyAuthorAcknowledge(options){return this.runTyped("history-author-acknowledge",{historyEvent:(options.events??[]).map(event=>`${event.item_id}:${String(event.line)}`),allActionable:options.all_actionable===true,dryRun:options.dry_run===true,planFingerprint:options.plan_fingerprint,limit:options.coordinate_limit,attributedAuthor:options.attributed_author,reviewer:options.reviewer,reason:options.reason})}plan(subcommand,id,options={},stepRef,reorderTo){return this.runTyped("plan",{...id===void 0?{}:{id},...stepRef===void 0?{}:{stepRef},...reorderTo===void 0?{}:{reorderTo},options:mutationOptionsWithOverrides(options,{subcommand})})}planCreate(options){return this.plan("create",void 0,options)}planShow(id,options={}){return this.plan("show",id,options)}planAddStep(id,options){return this.plan("add-step",id,options)}planUpdateStep(id,stepRef,options){return this.plan("update-step",id,options,stepRef)}planCompleteStep(id,stepRef,options={}){return this.plan("complete-step",id,options,stepRef)}planBlockStep(id,stepRef,options){return this.plan("block-step",id,options,stepRef)}planReorderStep(id,stepRef,reorderTo,options={}){return this.plan("reorder-step",id,options,stepRef,reorderTo)}planRemoveStep(id,stepRef,options={}){return this.plan("remove-step",id,options,stepRef)}planLink(id,stepRef,options){return this.plan("link",id,options,stepRef)}planUnlink(id,stepRef,options){return this.plan("unlink",id,options,stepRef)}planDecision(id,options){return this.plan("decision",id,options)}planDiscovery(id,options){return this.plan("discovery",id,options)}planValidation(id,options){return this.plan("validation",id,options)}planResume(id,options){return this.plan("resume",id,options)}planApprove(id,options={}){return this.plan("approve",id,options)}planMaterialize(id,options){return this.plan("materialize",id,options)}create(options={}){return this.runTyped("create",splitFullClientMutationOptions(options))}update(id,options={}){return this.runTyped("update",{id,...splitFullClientMutationOptions(options)})}reopen(id,reason,options={}){return this.runTyped("item-reopen",{id,reason,fullChangedFields:true,options})}close(id,reason,options={}){return this.runTyped("close",{id,reason,...splitFullClientMutationOptions(options)})}claim(id,options={}){return this.runTyped("claim",{id,...splitFullClientMutationOptions(options)})}claimNext(options={}){return this.runTyped("claim",{next:true,...splitFullClientMutationOptions(options)})}release(id,options={}){return this.runTyped("release",{id,...splitFullClientMutationOptions(options)})}copy(id,options={}){return this.runTyped("copy",{id,...splitFullClientMutationOptions(options)})}delete(id,options={}){return this.runTyped("delete",{id,...splitFullClientMutationOptions(options)})}restore(id,target,options={}){return this.runTyped("restore",{fullChangedFields:true,id,options:{...options,target}})}focus(id,options={}){return this.runTyped("focus",{...id===void 0?{}:{id},...splitFullClientMutationOptions(options)})}startTask(id,options={}){return this.runTyped("start-task",{id,...splitFullClientMutationOptions(options)})}pauseTask(id,options={}){return this.runTyped("pause-task",{id,...splitFullClientMutationOptions(options)})}closeTask(id,reason,options={}){return this.runTyped("close-task",{id,reason,...splitFullClientMutationOptions(options)})}extension(target,options={}){return this.runTyped("extension",{...target===void 0?{}:{target},options})}extensionList(options={}){return this.extension("list",options)}extensionActivate(target,options={}){return this.runTyped("extension-activate",{target,options})}extensionDeactivate(target,options={}){return this.runTyped("extension-deactivate",{target,options})}package(target,options={}){return this.runTyped("package",{...target===void 0?{}:{target},options:{...options,vocabulary:"package"}})}packageList(options={}){return this.package("list",options)}packageInstall(target,options={}){return this.runTyped("package-install",{target,options})}packageUninstall(target,options={}){return this.runTyped("package-uninstall",{target,options})}packageDoctor(options={}){return this.runTyped("package-doctor",{options})}packageManage(target,options={}){return this.runTyped("package-manage",{...target===void 0?{}:{target},options})}packageDescribe(target,options={}){return this.runTyped("package-describe",{...target===void 0?{}:{target},options})}packageReload(options={}){return this.runTyped("package-reload",{options})}packageCatalog(options={}){return this.runTyped("package-catalog",{options})}packageActivate(target,options={}){return this.runTyped("package-activate",{target,options})}packageDeactivate(target,options={}){return this.runTyped("package-deactivate",{target,options})}packageMigrate(options={}){return this.package(void 0,{...options,migrate:true})}upgrade(target,options={}){return this.runTyped("upgrade",{...target===void 0?{}:{target},options})}}function context(options={},clientOptions={}){return new PmClient(clientOptions).context(options)}function list(options={},clientOptions={}){return new PmClient(clientOptions).list(options)}function listAllComplete(options={},clientOptions={}){return new PmClient(clientOptions).listAllComplete(options)}function search(query,options={},clientOptions={}){return new PmClient(clientOptions).search(query,options)}function get(id,options={},clientOptions={}){return new PmClient(clientOptions).get(id,options)}function next(options={},clientOptions={}){return new PmClient(clientOptions).next(options)}function aggregate(options={},clientOptions={}){return new PmClient(clientOptions).aggregate(options)}function stats(options={},clientOptions={}){return new PmClient(clientOptions).stats(options)}function duplicates(options={},clientOptions={}){return new PmClient(clientOptions).duplicates(options)}function comments(id,options={},clientOptions={}){return new PmClient(clientOptions).comments(id,options)}function notes(id,options={},clientOptions={}){return new PmClient(clientOptions).notes(id,options)}function learnings(id,options={},clientOptions={}){return new PmClient(clientOptions).learnings(id,options)}function files(id,options={},clientOptions={}){return new PmClient(clientOptions).files(id,options)}function filesDiscover(id,options={},clientOptions={}){return new PmClient(clientOptions).filesDiscover(id,options)}function filesLookup(options,clientOptions={}){return new PmClient(clientOptions).filesLookup(options)}function docs(id,options={},clientOptions={}){return new PmClient(clientOptions).docs(id,options)}function deps(id,options={},clientOptions={}){return new PmClient(clientOptions).deps(id,options)}function graph(subcommand,ids={},options={},clientOptions={}){return new PmClient(clientOptions).graph(subcommand,ids,options)}function append(id,body,options={},clientOptions={}){return new PmClient(clientOptions).append(id,body,options)}function init(prefix,options={},clientOptions={}){return new PmClient(clientOptions).init(prefix,options)}function config(scope,configAction,key,value,options={},clientOptions={}){return new PmClient(clientOptions).config(scope,configAction,key,value,options)}function schema(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).schema(subcommand,options)}function schemaList(clientOptions={}){return new PmClient(clientOptions).schemaList()}function schemaShow(name,clientOptions={}){return new PmClient(clientOptions).schemaShow(name)}function schemaAddType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddType(name,options)}function schemaRemoveType(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveType(name,options)}function schemaAddStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddStatus(name,options)}function schemaRemoveStatus(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveStatus(name,options)}function schemaAddField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaAddField(name,options)}function schemaRemoveField(name,options={},clientOptions={}){return new PmClient(clientOptions).schemaRemoveField(name,options)}function schemaListFields(clientOptions={}){return new PmClient(clientOptions).schemaListFields()}function schemaShowField(name,clientOptions={}){return new PmClient(clientOptions).schemaShowField(name)}function schemaApplyPreset(typePreset,options={},clientOptions={}){return new PmClient(clientOptions).schemaApplyPreset(typePreset,options)}function schemaInferTypes(options={},clientOptions={}){return new PmClient(clientOptions).schemaInferTypes(options)}function schemaRenameType(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRenameType(from,to,options)}function schemaRenameField(from,to,options,type,clientOptions={}){return new PmClient(clientOptions).schemaRenameField(from,to,options,type)}function schemaRemapStatus(from,to,options,clientOptions={}){return new PmClient(clientOptions).schemaRemapStatus(from,to,options)}function schemaShowStatus(name,clientOptions={}){return new PmClient(clientOptions).schemaShowStatus(name)}function profile(subcommand,options={},clientOptions={}){return new PmClient(clientOptions).profile(subcommand,options)}function profileList(clientOptions={}){return new PmClient(clientOptions).profileList()}function profileShow(name,clientOptions={}){return new PmClient(clientOptions).profileShow(name)}function profileApply(name,options={},clientOptions={}){return new PmClient(clientOptions).profileApply(name,options)}function profileLint(name,clientOptions={}){return new PmClient(clientOptions).profileLint(name)}function validate(options={},clientOptions={}){return new PmClient(clientOptions).validate(options)}function health(options={},clientOptions={}){return new PmClient(clientOptions).health(options)}function gc(options={},clientOptions={}){return new PmClient(clientOptions).gc(options)}function historyRedact(id,options,clientOptions={}){return new PmClient(clientOptions).historyRedact(id,options)}function historyRepair(id,options={},clientOptions={}){return new PmClient(clientOptions).historyRepair(id,options)}function historyRepairAll(options={},clientOptions={}){return new PmClient(clientOptions).historyRepairAll(options)}function historyCompact(id,options={},clientOptions={}){return new PmClient(clientOptions).historyCompact(id,options)}function historyCompactBulk(options,clientOptions={}){return new PmClient(clientOptions).historyCompactBulk(options)}function create(options={},clientOptions={}){return new PmClient(clientOptions).create(options)}function update(id,options={},clientOptions={}){return new PmClient(clientOptions).update(id,options)}function reopen(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).reopen(id,reason,options)}function close(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).close(id,reason,options)}function claim(id,options={},clientOptions={}){return new PmClient(clientOptions).claim(id,options)}function claimNext(options={},clientOptions={}){return new PmClient(clientOptions).claimNext(options)}function release(id,options={},clientOptions={}){return new PmClient(clientOptions).release(id,options)}function copy(id,options={},clientOptions={}){return new PmClient(clientOptions).copy(id,options)}function deleteItem(id,options={},clientOptions={}){return new PmClient(clientOptions).delete(id,options)}function restore(id,target,options={},clientOptions={}){return new PmClient(clientOptions).restore(id,target,options)}function focus(id,options={},clientOptions={}){return new PmClient(clientOptions).focus(id,options)}function startTask(id,options={},clientOptions={}){return new PmClient(clientOptions).startTask(id,options)}function pauseTask(id,options={},clientOptions={}){return new PmClient(clientOptions).pauseTask(id,options)}function closeTask(id,reason,options={},clientOptions={}){return new PmClient(clientOptions).closeTask(id,reason,options)}function extension(target,options={},clientOptions={}){return new PmClient(clientOptions).extension(target,options)}function extensionList(options={},clientOptions={}){return new PmClient(clientOptions).extensionList(options)}function extensionActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionActivate(target,options)}function extensionDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).extensionDeactivate(target,options)}function packageLifecycle(target,options={},clientOptions={}){return new PmClient(clientOptions).package(target,options)}function packageList(options={},clientOptions={}){return new PmClient(clientOptions).packageList(options)}function packageInstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageInstall(target,options)}function packageUninstall(target,options={},clientOptions={}){return new PmClient(clientOptions).packageUninstall(target,options)}function packageDoctor(options={},clientOptions={}){return new PmClient(clientOptions).packageDoctor(options)}function packageManage(target,options={},clientOptions={}){return new PmClient(clientOptions).packageManage(target,options)}function packageDescribe(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDescribe(target,options)}function packageReload(options={},clientOptions={}){return new PmClient(clientOptions).packageReload(options)}function packageCatalog(options={},clientOptions={}){return new PmClient(clientOptions).packageCatalog(options)}function packageActivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageActivate(target,options)}function packageDeactivate(target,options={},clientOptions={}){return new PmClient(clientOptions).packageDeactivate(target,options)}function upgrade(target,options={},clientOptions={}){return new PmClient(clientOptions).upgrade(target,options)}function buildWorkspaceExtensionRegistrationsCacheKey(pmRoot,settings,cwd){return JSON.stringify([path.resolve(pmRoot),path.resolve(cwd??process.cwd()),settings.extensions.enabled,settings.extensions.disabled,settings.extensions.policy])}async function resolveWorkspaceExtensionRegistrations(pmRoot,settings,cwd){const cacheKey=buildWorkspaceExtensionRegistrationsCacheKey(pmRoot,settings,cwd);return memoizeWorkspaceExtensionRegistrations(cacheKey,()=>loadWorkspaceExtensionRegistrations(pmRoot,settings,cwd))}async function getWorkspaceContracts(pmRoot,options={}){const settings=await readSettings(pmRoot);const extensionRegistrations=options.extensionRegistrations??(options.noExtensions===true?null:await resolveWorkspaceExtensionRegistrations(pmRoot,settings,options.cwd));const typeRegistry=resolveItemTypeRegistry(settings,extensionRegistrations);const statusRegistry=resolveRuntimeStatusRegistry(settings.schema);const fieldRegistry=resolveRuntimeFieldRegistry(settings.schema);return{types:[...typeRegistry.types],statuses:statusRegistry.definitions.map(definition=>definition.id),openStatus:statusRegistry.open_status,closeStatus:statusRegistry.close_status,canceledStatus:statusRegistry.canceled_status,fields:buildWorkspaceFieldContracts(fieldRegistry.definitions),extensionCommands:buildWorkspaceExtensionCommandContracts(extensionRegistrations?.commands??[])}}async function getContracts(pmRootOrOptions,options={}){const resolvedOptions=typeof pmRootOrOptions==="string"?{...options,pmRoot:pmRootOrOptions}:pmRootOrOptions??options;const global2={json:true,quiet:resolvedOptions.quiet??true,noExtensions:resolvedOptions.noExtensions??false,noPager:true,profile:resolvedOptions.profile??false,path:resolvedOptions.pmRoot};return runContracts(resolvedOptions,global2)}function readRequiredString(args,key){const value=readString(args,key);if(!value){throw new PmCliError(`Missing required argument: ${key}`,64)}return value}const extensionActivationGate=createAsyncReadWriteGate();const activeExtensionScope=new AsyncLocalStorage;function resetActiveExtensionRegistries(){setActiveExtensionHooks(createEmptyExtensionHookRegistry());setActiveExtensionCommands(createEmptyExtensionCommandRegistry());setActiveExtensionParsers(createEmptyExtensionParserRegistry());setActiveExtensionPreflight(createEmptyExtensionPreflightRegistry());setActiveExtensionServices(createEmptyExtensionServiceRegistry());setActiveExtensionRenderers(createEmptyExtensionRendererRegistry());setActiveExtensionRegistrations(createEmptyExtensionRegistrationRegistry())}async function withActiveExtensions(global2,explicitCwd,resolutionCwd,run){return runWithIsolatedExtensionRuntime(()=>explicitCwd===void 0?extensionActivationGate.read(()=>withActiveExtensionsExclusively(global2,resolutionCwd,run)):extensionActivationGate.write(()=>withCwd(explicitCwd,()=>withActiveExtensionsExclusively(global2,resolutionCwd,run))))}async function runWithActiveExtensions(options,run){const explicitCwd=options.cwd;const resolutionCwd=explicitCwd??process.cwd();return withActiveExtensions(globalOptions({path:options.path,noExtensions:options.noExtensions}),explicitCwd,resolutionCwd,()=>activeExtensionScope.run(true,run))}async function withActiveExtensionsExclusively(global2,cwd,run){const pmRoot=resolvePmRoot(cwd,global2.path);if(global2.noExtensions){resetActiveExtensionRegistries();return runWithDiscoveredContextIntentContracts({pmRoot},()=>run(null))}if(!await pathExists(getSettingsPath(pmRoot))){resetActiveExtensionRegistries();return run(null)}let active=null;let activated;try{const settings=await readSettings(pmRoot);const loadResult=await loadExtensions({pmRoot,settings,cwd,noExtensions:false});const activationResult=await activateExtensions({...loadResult,loaded:loadResult.loaded});activated={loadResult,activationResult};setActiveExtensionHooks(activationResult.hooks);setActiveExtensionCommands(activationResult.commands);setActiveExtensionParsers(activationResult.parsers);setActiveExtensionPreflight(activationResult.preflight);setActiveExtensionServices(activationResult.services);setActiveExtensionRenderers(activationResult.renderers);setActiveExtensionRegistrations(activationResult.registrations);active={registrations:activationResult.registrations,commands:activationResult.commands,pmRoot,packages:loadResult.loaded}}catch(error){resetActiveExtensionRegistries();console.error("[pm-sdk] extension activation failed; continuing without active extensions:",error)}try{return await runWithDiscoveredContextIntentContracts({pmRoot,packages:active?.packages},()=>run(active))}finally{resetActiveExtensionRegistries();if(activated){await deactivateExtensions(activated.loadResult,activated.activationResult).catch(()=>void 0)}}}async function dispatchActiveExtensionAction(action,args,options,global2,active){if(!active){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const normalizedAction=normalizeActionName(action);const definition=active.registrations.commands.find(entry=>normalizeActionName(entry.action)===normalizedAction);const command=definition?.command??active.commands.handlers.find(entry=>normalizeActionName(entry.command)===normalizedAction)?.command;if(!command){throw new PmCliError(`Unsupported native pm action: ${action}`,EXIT_CODE.USAGE)}const handlerResult=await runActiveCommandHandler({command:normalizeCommandPath(command),args:readStringArray(options.args??args.args),options:extensionOptionsFromArgs(args,options),global:global2,pm_root:active.pmRoot,sdk:createExtensionCommandSdk(active.pmRoot,PmClient.forActiveExtensionHost({pmRoot:active.pmRoot,author:typeof global2.author==="string"&&global2.author.trim()?global2.author.trim():"pm-extension"}))});if(!handlerResult.handled){const suffix=handlerResult.warnings.length>0?` (${handlerResult.warnings.join(", ")})`:"";throw new PmCliError(`Unsupported native pm action: ${action}${suffix}`,EXIT_CODE.USAGE)}return handlerResult.result}async function withCwd(cwd,run){const previous=process.cwd();process.chdir(cwd);try{return await run()}finally{process.chdir(previous)}}function resolveSdkActionInput(args){const rawAction=readRequiredString(args,"action");const normalizedAction=normalizeActionName(rawAction);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalizedAction);const action=alias?.action??normalizedAction;const resolvedArgs={...args,action};if(alias?.options!==void 0){resolvedArgs.options={...alias.options,...asRecordClone(args.options)}}if(action==="package"){resolvedArgs.options={...asRecordClone(resolvedArgs.options),vocabulary:"package"}}return{action,args:resolvedArgs}}async function runAction(args){const resolved=resolveSdkActionInput(args);const global2=globalOptions(resolved.args);const invalidateWorkspaceContractsCache=shouldInvalidateWorkspaceContractsCacheAfterAction(resolved.action);const explicitCwd=readString(resolved.args,"cwd");const resolutionCwd=explicitCwd??process.cwd();if(resolved.action==="init"){global2[INIT_INVOCATION_CWD]=resolutionCwd}if(resolved.action!=="init"||global2.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0){global2.path=resolvePmRoot(resolutionCwd,global2.path)}try{if(args[ACTIVE_EXTENSION_HOST_CONTEXT]===true||activeExtensionScope.getStore()===true){return await dispatchAction(resolved.action,resolved.args,global2,null)}return await withActiveExtensions(global2,explicitCwd,resolutionCwd,activeExtensions=>dispatchAction(resolved.action,resolved.args,global2,activeExtensions))}finally{if(invalidateWorkspaceContractsCache){clearWorkspaceContractsCache()}}}function getOwnHandler(handlers,key){return Object.prototype.hasOwnProperty.call(handlers,key)?handlers[key]:void 0}function readMcpTarget(ctx){return readString(ctx.args,"target")??readString(ctx.options,"target")}function requireMcpItemId(ctx,source=ctx.options){return ctx.id??readRequiredString(source,"id")}async function runMcpListAction(ctx){const listOptions=applyContextIntentProjection("list",ctx.options);if(listOptions.compact===void 0&&listOptions.brief===void 0&&listOptions.full===void 0&&listOptions.fields===void 0&&listOptions.includeBody===void 0){listOptions.compact=true}return withQuerySummary(await runList(readString(ctx.args,"status")??readString(listOptions,"status"),listOptions,ctx.global),listOptions)}async function runMcpSearchAction(ctx){const query=readRequiredString(ctx.args,"query");const searchOptions=applyContextIntentProjection("search",ctx.options,[query]);if(searchOptions.compact===void 0&&searchOptions.full===void 0&&searchOptions.fields===void 0){searchOptions.compact=true}return withQuerySummary(await runSearch(query,searchOptions,ctx.global),searchOptions)}async function runMcpCreateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runCreate(runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpCopyAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const copyOptions={...runnerOptions,...runnerOptions.title===void 0&&typeof ctx.args.title==="string"?{title:ctx.args.title}:{},...runnerOptions.message===void 0&&typeof ctx.args.message==="string"?{message:ctx.args.message}:{}};return projectMutationResult(await runCopy(requireMcpItemId(ctx,copyOptions),copyOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdate(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}function runMcpCommentsAction(ctx){const commentOptions=normalizeAnnotationTransportOptions(ctx.options);const isListing=commentOptions.add===void 0&&commentOptions.stdin===void 0&&commentOptions.file===void 0&&commentOptions.edit===void 0&&commentOptions.delete===void 0;if(isListing){commentOptions.includeMeta=true;if(commentOptions.limit===void 0&&commentOptions.fullHistory!==true){commentOptions.limit="20"}}return runComments(requireMcpItemId(ctx),commentOptions,ctx.global)}function runMcpFilesLookupAction(ctx,paths){return runFilesLookup(runtimeFilesLookupOptions(ctx.options,paths,parseMcpInteger),ctx.global)}function runMcpFilesAction(ctx){const lookupPaths=readStringArray(ctx.options.lookupPath);if(lookupPaths&&lookupPaths.length>0){return runMcpFilesLookupAction(ctx,lookupPaths)}const fileId=requireMcpItemId(ctx);return ctx.options.discover===true?runFilesDiscover(fileId,withFilesDiscoveryOptions(ctx.options),ctx.global):runFiles(fileId,withAddNoteOption(ctx.options),ctx.global)}function runMcpTelemetryAction(ctx){return runTelemetry({subcommand:readString(ctx.args,"subcommand")??readString(ctx.options,"subcommand"),limit:resolveRuntimeLimit(ctx.args,ctx.options)},ctx.global)}function runMcpHealthAction(ctx){const healthOptions={...ctx.options};if(healthOptions.brief===void 0&&healthOptions.summary===void 0&&healthOptions.full===void 0){healthOptions.summary=true}return runHealth(ctx.global,healthOptions)}function runMcpConfigAction(ctx){const configAction=readString(ctx.args,"configAction")??readString(ctx.options,"configAction")??readString(ctx.options,"action");if(configAction===void 0)throw new PmCliError("Missing required argument: configAction",64);const value=readString(ctx.args,"value")??readString(ctx.options,"value");const options=readString(ctx.options,"policy")!==void 0&&value!==void 0?{...ctx.options,value}:ctx.options;return runConfig(readString(ctx.args,"scope")??readString(ctx.options,"scope")??"project",configAction,readString(ctx.args,"key")??readString(ctx.options,"key"),options,ctx.global,readString(ctx.options,"policy")===void 0?value:void 0)}function runMcpActivityAction(ctx){const options=ctx.options;return runActivity(normalizeActivityProjectionOptions(options),ctx.global)}function parseMcpIntegerPrefix(value,label){if(typeof value==="number"){if(!Number.isFinite(value)||!Number.isInteger(value)){throw new PmCliError(`${label} must be a finite integer.`,64)}return value}if(typeof value==="string"&&value.trim().length>0){const trimmed=value.trim();if(!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(trimmed)){throw new PmCliError(`${label} must be a finite integer.`,64)}const parsed=Number.parseInt(trimmed,10);if(!Number.isInteger(parsed)){throw new PmCliError(`${label} must be a finite integer.`,64)}return parsed}return void 0}function runMcpPlanAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const planRecord=ctx.options;return runPlan({subcommand,id:typeof ctx.id==="string"?ctx.id:typeof planRecord.id==="string"?planRecord.id:void 0,stepRef:readMcpPlanStepRef(ctx),reorderTo:parseMcpIntegerPrefix(planRecord.reorderTo??ctx.args.reorderTo,"plan reorderTo"),options:ctx.options,global:ctx.global})}function readMcpPlanStepRef(ctx){return typeof ctx.options.stepRef==="string"?ctx.options.stepRef:typeof ctx.args.stepRef==="string"?ctx.args.stepRef:void 0}function createMcpSchemaContext(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const aliasSource=ctx.args.alias??ctx.options.alias;return{ctx,subcommand:subcommand.trim().toLowerCase(),name:readString(ctx.args,"name")??readString(ctx.options,"name"),author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true,aliases:aliasSource===void 0?void 0:readStringArray(aliasSource)}}function runMcpSchemaReadOrRemoveAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const simpleHandlers={list:()=>runSchemaList(ctx.global),show:()=>runSchemaShow(name,ctx.global),"show-status":()=>runSchemaShowStatus(name,ctx.global),"list-fields":()=>runSchemaListFields(ctx.global),"show-field":()=>runSchemaShowField(name,ctx.global),"remove-type":()=>runSchemaRemoveType(name,{author,force},ctx.global),"remove-field":()=>runSchemaRemoveField(name,{author,force},ctx.global),"remove-status":()=>runSchemaRemoveStatus(name,{author,force},ctx.global),"apply-preset":()=>runSchemaApplyPreset(readString(ctx.args,"typePreset")??readString(ctx.options,"typePreset"),{author,force},ctx.global)};const handler=getOwnHandler(simpleHandlers,subcommand);return handler?handler():null}function runMcpSchemaAddFieldAction(schema2){const{ctx,name,author,force,aliases}=schema2;const commandsSource=ctx.args.commands??ctx.options.commands;const requiredTypesSource=ctx.args.requiredTypes??ctx.options.requiredTypes;return runSchemaAddField(name,{type:readString(ctx.args,"fieldType")??readString(ctx.options,"fieldType"),commands:commandsSource===void 0?void 0:readStringArray(commandsSource),description:readString(ctx.args,"description")??readString(ctx.options,"description"),cliFlag:readString(ctx.args,"cliFlag")??readString(ctx.options,"cliFlag"),alias:aliases,required:ctx.args.required===true||ctx.options.required===true,requiredOnCreate:ctx.args.requiredOnCreate===true||ctx.options.requiredOnCreate===true,allowUnset:!(ctx.args.allowUnset===false||ctx.options.allowUnset===false),requiredTypes:requiredTypesSource===void 0?void 0:readStringArray(requiredTypesSource),author,force},ctx.global)}function runMcpSchemaAddStatusAction(schema2){const{ctx,name,author,force,aliases}=schema2;const roleSource=ctx.args.role??ctx.options.role;return runSchemaAddStatus(name,{role:roleSource===void 0?void 0:readStringArray(roleSource),alias:aliases,description:readString(ctx.args,"description")??readString(ctx.options,"description"),order:parseMcpInteger(ctx.args.order??ctx.options.order,"schema add-status order"),author,force},ctx.global)}function runMcpSchemaAddTypeAction(schema2){const{ctx,name,author,force,aliases}=schema2;return runSchemaAddType(name,{description:readString(ctx.args,"description")??readString(ctx.options,"description"),defaultStatus:readString(ctx.args,"defaultStatus")??readString(ctx.args,"default_status")??readString(ctx.options,"defaultStatus")??readString(ctx.options,"default_status"),folder:readString(ctx.args,"folder")??readString(ctx.options,"folder"),alias:aliases,author,force},ctx.global)}function runMcpSchemaMigrationAction(schema2){const{ctx,subcommand,name,author,force}=schema2;const to=readString(ctx.args,"to")??readRequiredString(ctx.options,"to");const migrationId=readString(ctx.args,"migrationId")??readString(ctx.args,"migration_id")??readString(ctx.options,"migrationId")??readString(ctx.options,"migration_id");const fieldTypeScope=readString(ctx.args,"fieldTypeScope")??readString(ctx.options,"fieldTypeScope")??readString(ctx.args,"type")??readString(ctx.options,"type");const request=subcommand==="rename-type"?{kind:"rename-type",from:name??"",to}:subcommand==="rename-field"?{kind:"rename-field",from:name??"",to,...fieldTypeScope===void 0?{}:{type:fieldTypeScope}}:{kind:"remap-status",from:name??"",to};return runSchemaEvolutionMigration(request,{migrationId,dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author,force},ctx.global)}function runMcpSchemaAction(ctx){const schema2=createMcpSchemaContext(ctx);const simpleResult=runMcpSchemaReadOrRemoveAction(schema2);if(simpleResult!==null){return simpleResult}if(schema2.subcommand==="rename-type"||schema2.subcommand==="rename-field"||schema2.subcommand==="remap-status"){return runMcpSchemaMigrationAction(schema2)}if(schema2.subcommand==="add-field"){return runMcpSchemaAddFieldAction(schema2)}if(schema2.subcommand==="add-status"){return runMcpSchemaAddStatusAction(schema2)}if(schema2.subcommand==="add-type"){if(ctx.args.infer===true||ctx.options.infer===true){return runSchemaInferTypes({minCount:parseMcpInteger(ctx.args.minCount??ctx.options.minCount,"schema infer minCount"),apply:ctx.args.apply===true||ctx.options.apply===true,author:schema2.author,force:schema2.force},ctx.global)}return runMcpSchemaAddTypeAction(schema2)}throw createUnknownSubcommandError({command_path:"schema",token:schema2.subcommand,allowed:SCHEMA_SUBCOMMANDS,exit_code:64})}function runMcpProfileAction(ctx){const subcommand=readString(ctx.args,"subcommand")??readRequiredString(ctx.options,"subcommand");const normalizedSubcommand=subcommand.trim().toLowerCase();const profileName=readString(ctx.args,"name")??readString(ctx.options,"name");const handlers={list:()=>runProfileList(),show:()=>runProfileShow(profileName),lint:()=>runProfileLint(profileName),apply:()=>runProfileApply(profileName,{dryRun:ctx.args.dryRun===true||ctx.options.dryRun===true,author:readString(ctx.args,"author")??readString(ctx.options,"author"),force:ctx.args.force===true||ctx.options.force===true},ctx.global)};const handler=getOwnHandler(handlers,normalizedSubcommand);if(!handler){throw createUnknownSubcommandError({command_path:"profile",token:subcommand,allowed:PROFILE_SUBCOMMANDS,exit_code:64})}return handler()}async function runMcpAppendAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runAppend(requireMcpItemId(ctx,runnerOptions),runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpUpdateManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);return projectMutationResult(await runUpdateMany(updateManyOptionsFromFlat(runnerOptions),ctx.global),{changedFields})}async function runMcpCloseManyAction(ctx){const{changedFields,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const topLevelReason=readString(ctx.args,"reason");const closeManyRunnerOptions=topLevelReason!==void 0&&runnerOptions.reason===void 0?{...runnerOptions,reason:topLevelReason}:{...runnerOptions};if(ctx.force&&closeManyRunnerOptions.force===void 0){closeManyRunnerOptions.force=true}return projectMutationResult(await runCloseMany(closeManyOptionsFromFlat(closeManyRunnerOptions),ctx.global),{changedFields})}async function runMcpRestoreAction(ctx){const{changedFields,idOnly,runnerOptions}=withMutationCompaction(ctx.args,ctx.options);const target=readString(runnerOptions,"target")??readRequiredString(ctx.args,"target");return projectMutationResult(await runRestore(requireMcpItemId(ctx,runnerOptions),target,runnerOptions,ctx.global),{changedFields,compactEnvelope:changedFields==="compact"&&!idOnly,idOnly})}async function runMcpStartTaskAction(ctx){const pmRoot=resolvePmRoot(process.cwd(),ctx.global.path);const settings=await readSettings(pmRoot);const inProgressStatus=resolveStartTaskInProgressStatus(resolveRuntimeStatusRegistry(settings.schema));const id=requireMcpItemId(ctx);const claimResult=await runClaim(id,ctx.force,ctx.global,ctx.options);const updateResult=await runUpdate(id,mutationOptionsWithOverrides(ctx.options,{status:inProgressStatus,force:ctx.force},["assignee"]),ctx.global);return{id,action:"start_task",claim:claimResult,update:updateResult}}async function runMcpPauseTaskAction(ctx){const pmRoot=resolvePmRoot(process.cwd(),ctx.global.path);const settings=await readSettings(pmRoot);const id=requireMcpItemId(ctx);const openStatus=resolveRuntimeStatusRegistry(settings.schema).open_status;const updateResult=await runUpdate(id,mutationOptionsWithOverrides(ctx.options,{status:openStatus,force:ctx.force},["assignee"]),ctx.global);const releaseResult=await runRelease(id,ctx.force,ctx.global,ctx.options);return{id,action:"pause_task",update:updateResult,release:releaseResult}}async function runMcpCloseTaskAction(ctx){const id=requireMcpItemId(ctx);const closeReason=readString(ctx.args,"reason")??readString(ctx.args,"text")??readString(ctx.options,"reason")??readString(ctx.options,"text");const closeResult=await runClose(id,closeReason,{...ctx.options,force:ctx.force},ctx.global);const releaseResult=await runRelease(id,ctx.force,ctx.global,ctx.options);return{id,action:"close_task",close:closeResult,release:releaseResult}}function runMcpGraphAction(ctx){const merged={...ctx.args,...ctx.options};return runGraph(readRequiredString(merged,"subcommand"),readString(merged,"id")??ctx.id,readString(merged,"target"),graphOptionsFromFlat(merged),ctx.global)}function runMcpHistoryAuthorAcknowledgeAction(ctx){return acknowledgeUnknownAuthorHistoryEventsFromTransport(resolvePmRoot(process.cwd(),ctx.global.path),{...ctx.args,...ctx.options})}const SDK_ACTION_HANDLERS={init:ctx=>runInit(readString(ctx.args,"prefix"),ctx.global,ctx.options),context:ctx=>runContext(applyContextIntentProjection("context",ctx.options),ctx.global),next:ctx=>runNext(applyContextIntentProjection("next",ctx.options),ctx.global),eval:runRuntimeEvalAction,events:runRuntimeEventsAction,merge:runRuntimeMergeAction,workspace:runRuntimeWorkspaceAction,meet:runRuntimeSchedulingAction,event:runRuntimeSchedulingAction,remind:runRuntimeSchedulingAction,list:runMcpListAction,get:ctx=>{const id=requireMcpItemId(ctx);return runGet(id,ctx.global,applyContextIntentProjection("get",ctx.options,[id]))},search:runMcpSearchAction,duplicates:ctx=>{const status=typeof ctx.options.status==="string"?[ctx.options.status]:readStringArray(ctx.options.status);return runDuplicates(ctx.global,{exhaustive:ctx.options.exhaustive===true,...status.length===0?{}:{status},since:readString(ctx.options,"since"),threshold:typeof ctx.options.threshold==="number"?ctx.options.threshold:void 0,limit:ctx.options.limit==="default"?void 0:parseMcpInteger(ctx.options.limit,"limit")})},create:runMcpCreateAction,copy:runMcpCopyAction,focus:ctx=>runFocus(ctx.id,{clear:ctx.options.clear===true||ctx.args.clear===true},ctx.global),update:runMcpUpdateAction,"item-reopen":runMcpReopenAction,restore:runMcpRestoreAction,claim:runMcpClaimAction,release:ctx=>runRelease(requireMcpItemId(ctx),ctx.force,ctx.global,ctx.options),"start-task":runMcpStartTaskAction,"pause-task":runMcpPauseTaskAction,"close-task":runMcpCloseTaskAction,close:runMcpCloseAction,comments:runMcpCommentsAction,notes:ctx=>runNotes(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),learnings:ctx=>runLearnings(requireMcpItemId(ctx),normalizeAnnotationTransportOptions(ctx.options),ctx.global),files:runMcpFilesAction,docs:ctx=>runDocs(requireMcpItemId(ctx),withAddNoteOption(ctx.options),ctx.global),test:ctx=>runTest(requireMcpItemId(ctx),ctx.options,ctx.global),"test-all":ctx=>runTestAll(ctx.options,ctx.global),telemetry:runMcpTelemetryAction,validate:ctx=>runValidate(ctx.options,ctx.global,{runUpdate:(id,options,global2)=>runUpdate(id,options,global2)}),health:runMcpHealthAction,assurance:ctx=>runAssuranceDispatch(ctx.args,ctx.options,ctx.global),contracts:ctx=>runContracts(ctx.options,ctx.global),config:runMcpConfigAction,activity:runMcpActivityAction,aggregate:ctx=>runAggregate(ctx.options,ctx.global),extension:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),package:ctx=>runExtension(readMcpTarget(ctx),ctx.options,ctx.global),install:ctx=>runExtension(readMcpTarget(ctx),{...ctx.options,install:true},ctx.global),upgrade:ctx=>runUpgrade(readMcpTarget(ctx),ctx.options,ctx.global),delete:ctx=>runDelete(requireMcpItemId(ctx),ctx.options,ctx.global),deps:ctx=>runDeps(requireMcpItemId(ctx),ctx.options,ctx.global),graph:runMcpGraphAction,"files-discover":ctx=>runFilesDiscover(requireMcpItemId(ctx),ctx.options,ctx.global),"files-lookup":ctx=>runMcpFilesLookupAction(ctx,readStringArray(ctx.options.paths)),history:ctx=>runHistory(requireMcpItemId(ctx),ctx.options,ctx.global),"history-redact":ctx=>runHistoryRedact(requireMcpItemId(ctx),ctx.options,ctx.global),"history-repair":runMcpHistoryRepairAction,"history-compact":runMcpHistoryCompactAction,"history-author-acknowledge":runMcpHistoryAuthorAcknowledgeAction,plan:runMcpPlanAction,schema:runMcpSchemaAction,profile:runMcpProfileAction,stats:ctx=>runStats(ctx.global,statsCommandOptionsFromRuntime(ctx.options)),append:runMcpAppendAction,"update-many":runMcpUpdateManyAction,"close-many":runMcpCloseManyAction,gc:ctx=>runGc(ctx.global,ctx.options)};function analyzeSdkActionCoverage(actions=PM_TOOL_ACTIONS){return actions.map(action=>{const normalized=normalizeActionName(action);const alias=getOwnHandler(SDK_ACTION_ALIASES,normalized);const resolvedAction=alias?.action??normalized;const covered=getOwnHandler(SDK_ACTION_HANDLERS,resolvedAction)!==void 0;return{action,resolved_action:resolvedAction,covered,route:covered?alias?"alias":"native":"missing"}})}async function dispatchAction(action,args,global2,activeExtensions){const options=optionsWithAuthor(args,action);validateReadOutputOptions(action,options);normalizeReadOutputIncludeModeOptions(action,options);const ctx={action,args,options,id:readString(args,"id"),force:args.force===true||options.force===true,global:global2,activeExtensions};const handler=getOwnHandler(SDK_ACTION_HANDLERS,action);const result=handler?await handler(ctx):await dispatchActiveExtensionAction(action,args,options,global2,activeExtensions);options.resolvedOutputFormat="json";const projected=attachReadOutputContracts(action,options,result);await finalizeContextUsageEgress(resolvePmRoot(process.cwd(),global2.path),projected);return projected}const actionRunnerTestHooks={closeManyOptionsFromFlat,extensionOptionsFromArgs,globalOptions,mutationListOptions,normalizeActionName,normalizeCommandPath,normalizeMcpUpdateOptions,normalizeMcpOptionsArrays,optionsWithAuthor,readRequiredString,readScalarString,readScalarStringAllowBlank,readStringArray,updateManyOptionsFromFlat,withAddNoteOption,withFilesDiscoveryOptions,withMutationCompaction};if(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0){globalThis.__pmCliActionRunnerTestHooks=actionRunnerTestHooks}async function loadWorkspaceExtensionRegistrations(pmRoot,settings,cwd){const loadResult=await loadExtensions({pmRoot,settings,cwd:cwd??process.cwd(),noExtensions:false});const activationResult=await activateExtensions(loadResult);try{return activationResult.registrations}finally{try{await deactivateExtensions(loadResult,activationResult)}catch{}}}export{BASELINE_ITEM_FORMAT_VERSION,BUILTIN_ITEM_TYPE_VALUES,CONFIDENCE_TEXT_VALUES,CONTEXT_OUTPUT_VALUES,CURRENT_ITEM_FORMAT_VERSION,DEFAULT_TERMINAL_TRANSITION_POLICY,DEPENDENCY_KIND_VALUES,EXIT_CODE,HISTORY_EVENT_CLASSIFICATION_VERSION,ISSUE_SEVERITY_VALUES,ITEM_TYPE_VALUES,MAINTENANCE_HISTORY_OPERATIONS,NEXT_OUTPUT_VALUES,PM_CLI_EXPECTED_ERROR_NAME,PM_GITIGNORE_END,PM_GITIGNORE_START,PmCliError2 as PmCliError,PmClient,PmCompleteListValidationError,RISK_VALUES,SEARCH_EXTENSION_FLAG_DEFINITIONS,STATUS_VALUES,SUBSTANTIVE_HISTORY_OPERATIONS,acquireLock,aggregate,analyzeSdkActionCoverage,append,appendHistoryEntry,applyTerminalOrderingPolicy,assertCompleteListResult,canonicalDocument,certifyCompleteListResult2 as certifyCompleteListResult,claim,claimNext,classifyHistoryEvent,classifyItemFormatVersion,clearWorkspaceContractsCache2 as clearWorkspaceContractsCache,close,closeItem,closeTask,comments,commitImportedItem,config,context,copy,create,createCompleteListOptions2 as createCompleteListOptions,createHistoryEntry,createPmCliExpectedError,deleteItem,deps,docs,duplicates,effectiveItemFormatVersion,emptyImportedDocument,ensurePmGitignore,ensureTrackerInitialized,extension,extensionActivate,extensionDeactivate,extensionList,files,filesDiscover,filesLookup,focus,gc,generateItemId,get,getActiveExtensionRegistrations,getContracts,getHistoryPath,getItemPath,getPmGitignoreBlock,getSettingsPath2 as getSettingsPath,getWorkspaceContracts,graph,health,historyCompact,historyCompactBulk,historyRedact,historyRepair,historyRepairAll,init,inspectCompleteListResult,isPmCliExpectedError,isTerminalStatus,isTimestampLiteral,jaccardSimilarity,learnings,list,listAllComplete,listAllItemMetadata,listAllItemMetadataLight,loadCreateTemplateOptions,locateItem,next,normalizeItemFormatVersion,normalizeItemId,normalizeItemMetadata,normalizeRawItemId,normalizeSimilarityText,normalizeStatusInput,notes,nowIso,packageActivate,packageCatalog,packageDeactivate,packageDescribe,packageDoctor,packageInstall,packageLifecycle,packageList,packageManage,packageReload,packageUninstall,parseTags,pathExists2 as pathExists,pauseTask,profile,profileApply,profileLint,profileList,profileShow,readBooleanOption,readCsvListOption,readFileIfExists,readLocatedItem,readRequiredString,readSettings2 as readSettings,readStringOption,release,removeFileIfExists,renderCalendarMarkdown,renderCalendarToon,renderGuideMarkdown,reopen,requireTerminalReason,resolveCalendarOutputFormat,resolveGuideOutputFormat,resolveImplicitPmRoot,resolveItemTypeRegistry2 as resolveItemTypeRegistry,resolvePmRoot2 as resolvePmRoot,resolveRuntimeFieldRegistry2 as resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry2 as resolveRuntimeStatusRegistry,resolveTerminalReason,restore,runAction,runActiveOnReadHooks,runActiveOnWriteHooks,runAggregate2 as runAggregate,runCalendar,runClose2 as runClose,runCompletion,runContext2 as runContext,runCopy2 as runCopy,runDelete2 as runDelete,runDuplicates2 as runDuplicates,runFocus2 as runFocus,runGet2 as runGet,runGuide,runList2 as runList,runNext2 as runNext,runReindex,runReopen,runRestore2 as runRestore,runSearch2 as runSearch,runStats2 as runStats,runTemplatesList,runTemplatesSave,runTemplatesShow,runTestRunsList,runTestRunsLogs,runTestRunsResume,runTestRunsStatus,runTestRunsStop,runUpdate2 as runUpdate,runWithActiveExtensions,scanItemFormatVersions,schema,schemaAddField,schemaAddStatus,schemaAddType,schemaApplyPreset,schemaInferTypes,schemaList,schemaListFields,schemaRemapStatus,schemaRemoveField,schemaRemoveStatus,schemaRemoveType,schemaRenameField,schemaRenameType,schemaShow,schemaShowField,schemaShowStatus,scoreItemSimilarity,search,selectImportAuthor,serializeItemDocument,splitFrontMatter,startTask,stats,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportInteger,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString,tokenizeSimilarityText,update,upgrade,validate,writeFileAtomic};
1928
2
  //# sourceMappingURL=runtime.js.map
1929
- //# debugId=422ff60b-97b1-5477-a7b8-ed4f983155e0