@unbrained/pm-cli 2026.5.18 → 2026.5.27

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 (369) hide show
  1. package/CHANGELOG.md +953 -472
  2. package/README.md +4 -11
  3. package/dist/cli/bootstrap-args.d.ts +18 -1
  4. package/dist/cli/bootstrap-args.js +143 -3
  5. package/dist/cli/bootstrap-args.js.map +1 -1
  6. package/dist/cli/commander-usage.js +147 -10
  7. package/dist/cli/commander-usage.js.map +1 -1
  8. package/dist/cli/commands/annotation-command.d.ts +49 -0
  9. package/dist/cli/commands/annotation-command.js +135 -0
  10. package/dist/cli/commands/annotation-command.js.map +1 -0
  11. package/dist/cli/commands/append.js +5 -8
  12. package/dist/cli/commands/append.js.map +1 -1
  13. package/dist/cli/commands/calendar.js +3 -6
  14. package/dist/cli/commands/calendar.js.map +1 -1
  15. package/dist/cli/commands/claim.js +15 -24
  16. package/dist/cli/commands/claim.js.map +1 -1
  17. package/dist/cli/commands/close.js +63 -10
  18. package/dist/cli/commands/close.js.map +1 -1
  19. package/dist/cli/commands/comments.d.ts +5 -0
  20. package/dist/cli/commands/comments.js +27 -117
  21. package/dist/cli/commands/comments.js.map +1 -1
  22. package/dist/cli/commands/completion.d.ts +2 -2
  23. package/dist/cli/commands/completion.js +203 -63
  24. package/dist/cli/commands/completion.js.map +1 -1
  25. package/dist/cli/commands/config.d.ts +1 -1
  26. package/dist/cli/commands/config.js +82 -4
  27. package/dist/cli/commands/config.js.map +1 -1
  28. package/dist/cli/commands/context.js +4 -10
  29. package/dist/cli/commands/context.js.map +1 -1
  30. package/dist/cli/commands/contracts.js +168 -36
  31. package/dist/cli/commands/contracts.js.map +1 -1
  32. package/dist/cli/commands/create.js +53 -313
  33. package/dist/cli/commands/create.js.map +1 -1
  34. package/dist/cli/commands/dedupe-audit.js +7 -4
  35. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  36. package/dist/cli/commands/delete.d.ts +3 -0
  37. package/dist/cli/commands/delete.js +11 -9
  38. package/dist/cli/commands/delete.js.map +1 -1
  39. package/dist/cli/commands/docs.d.ts +2 -12
  40. package/dist/cli/commands/docs.js +8 -316
  41. package/dist/cli/commands/docs.js.map +1 -1
  42. package/dist/cli/commands/event-validation-messages.d.ts +3 -0
  43. package/dist/cli/commands/event-validation-messages.js +44 -0
  44. package/dist/cli/commands/event-validation-messages.js.map +1 -0
  45. package/dist/cli/commands/extension/bundled-catalog.d.ts +14 -0
  46. package/dist/cli/commands/extension/bundled-catalog.js +268 -0
  47. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -0
  48. package/dist/cli/commands/extension/doctor.d.ts +31 -0
  49. package/dist/cli/commands/extension/doctor.js +345 -0
  50. package/dist/cli/commands/extension/doctor.js.map +1 -0
  51. package/dist/cli/commands/extension/install-sources.d.ts +37 -0
  52. package/dist/cli/commands/extension/install-sources.js +384 -0
  53. package/dist/cli/commands/extension/install-sources.js.map +1 -0
  54. package/dist/cli/commands/extension/managed-state.d.ts +48 -0
  55. package/dist/cli/commands/extension/managed-state.js +172 -0
  56. package/dist/cli/commands/extension/managed-state.js.map +1 -0
  57. package/dist/cli/commands/extension/scaffold.d.ts +14 -0
  58. package/dist/cli/commands/extension/scaffold.js +169 -0
  59. package/dist/cli/commands/extension/scaffold.js.map +1 -0
  60. package/dist/cli/commands/extension/shared.d.ts +14 -0
  61. package/dist/cli/commands/extension/shared.js +106 -0
  62. package/dist/cli/commands/extension/shared.js.map +1 -0
  63. package/dist/cli/commands/extension.d.ts +37 -68
  64. package/dist/cli/commands/extension.js +157 -1319
  65. package/dist/cli/commands/extension.js.map +1 -1
  66. package/dist/cli/commands/files.d.ts +1 -12
  67. package/dist/cli/commands/files.js +14 -318
  68. package/dist/cli/commands/files.js.map +1 -1
  69. package/dist/cli/commands/gc.js +17 -4
  70. package/dist/cli/commands/gc.js.map +1 -1
  71. package/dist/cli/commands/get.d.ts +3 -2
  72. package/dist/cli/commands/get.js +52 -9
  73. package/dist/cli/commands/get.js.map +1 -1
  74. package/dist/cli/commands/health.d.ts +10 -0
  75. package/dist/cli/commands/health.js +269 -76
  76. package/dist/cli/commands/health.js.map +1 -1
  77. package/dist/cli/commands/history-redact.d.ts +8 -0
  78. package/dist/cli/commands/history-redact.js +35 -113
  79. package/dist/cli/commands/history-redact.js.map +1 -1
  80. package/dist/cli/commands/history-repair.d.ts +33 -0
  81. package/dist/cli/commands/history-repair.js +172 -0
  82. package/dist/cli/commands/history-repair.js.map +1 -0
  83. package/dist/cli/commands/history.d.ts +4 -4
  84. package/dist/cli/commands/history.js +10 -88
  85. package/dist/cli/commands/history.js.map +1 -1
  86. package/dist/cli/commands/index.d.ts +3 -1
  87. package/dist/cli/commands/index.js +5 -3
  88. package/dist/cli/commands/index.js.map +1 -1
  89. package/dist/cli/commands/init.d.ts +28 -0
  90. package/dist/cli/commands/init.js +23 -2
  91. package/dist/cli/commands/init.js.map +1 -1
  92. package/dist/cli/commands/learnings.js +20 -119
  93. package/dist/cli/commands/learnings.js.map +1 -1
  94. package/dist/cli/commands/legacy-none-tokens.d.ts +3 -0
  95. package/dist/cli/commands/legacy-none-tokens.js +39 -0
  96. package/dist/cli/commands/legacy-none-tokens.js.map +1 -0
  97. package/dist/cli/commands/linked-artifacts.d.ts +96 -0
  98. package/dist/cli/commands/linked-artifacts.js +335 -0
  99. package/dist/cli/commands/linked-artifacts.js.map +1 -0
  100. package/dist/cli/commands/linked-test-entry.d.ts +3 -0
  101. package/dist/cli/commands/linked-test-entry.js +62 -0
  102. package/dist/cli/commands/linked-test-entry.js.map +1 -0
  103. package/dist/cli/commands/linked-test-parsers.d.ts +28 -0
  104. package/dist/cli/commands/linked-test-parsers.js +192 -0
  105. package/dist/cli/commands/linked-test-parsers.js.map +1 -0
  106. package/dist/cli/commands/list.js +49 -24
  107. package/dist/cli/commands/list.js.map +1 -1
  108. package/dist/cli/commands/normalize.js +4 -3
  109. package/dist/cli/commands/normalize.js.map +1 -1
  110. package/dist/cli/commands/notes.js +20 -119
  111. package/dist/cli/commands/notes.js.map +1 -1
  112. package/dist/cli/commands/plan.d.ts +3 -0
  113. package/dist/cli/commands/plan.js +184 -22
  114. package/dist/cli/commands/plan.js.map +1 -1
  115. package/dist/cli/commands/recurrence-parsers.d.ts +26 -0
  116. package/dist/cli/commands/recurrence-parsers.js +98 -0
  117. package/dist/cli/commands/recurrence-parsers.js.map +1 -0
  118. package/dist/cli/commands/restore.js +24 -56
  119. package/dist/cli/commands/restore.js.map +1 -1
  120. package/dist/cli/commands/schema.d.ts +31 -0
  121. package/dist/cli/commands/schema.js +98 -0
  122. package/dist/cli/commands/schema.js.map +1 -0
  123. package/dist/cli/commands/search.js +154 -42
  124. package/dist/cli/commands/search.js.map +1 -1
  125. package/dist/cli/commands/templates.d.ts +4 -0
  126. package/dist/cli/commands/templates.js +89 -17
  127. package/dist/cli/commands/templates.js.map +1 -1
  128. package/dist/cli/commands/test/linked-command-detection.d.ts +37 -0
  129. package/dist/cli/commands/test/linked-command-detection.js +200 -0
  130. package/dist/cli/commands/test/linked-command-detection.js.map +1 -0
  131. package/dist/cli/commands/test-all.js +4 -8
  132. package/dist/cli/commands/test-all.js.map +1 -1
  133. package/dist/cli/commands/test.d.ts +2 -2
  134. package/dist/cli/commands/test.js +12 -357
  135. package/dist/cli/commands/test.js.map +1 -1
  136. package/dist/cli/commands/update-many.js +6 -9
  137. package/dist/cli/commands/update-many.js.map +1 -1
  138. package/dist/cli/commands/update.js +167 -401
  139. package/dist/cli/commands/update.js.map +1 -1
  140. package/dist/cli/commands/validate.d.ts +3 -1
  141. package/dist/cli/commands/validate.js +23 -71
  142. package/dist/cli/commands/validate.js.map +1 -1
  143. package/dist/cli/error-guidance.d.ts +1 -0
  144. package/dist/cli/error-guidance.js +100 -6
  145. package/dist/cli/error-guidance.js.map +1 -1
  146. package/dist/cli/extension-command-help.d.ts +0 -1
  147. package/dist/cli/extension-command-help.js +2 -13
  148. package/dist/cli/extension-command-help.js.map +1 -1
  149. package/dist/cli/extension-command-options.d.ts +1 -0
  150. package/dist/cli/extension-command-options.js +106 -7
  151. package/dist/cli/extension-command-options.js.map +1 -1
  152. package/dist/cli/help-content.d.ts +0 -1
  153. package/dist/cli/help-content.js +13 -9
  154. package/dist/cli/help-content.js.map +1 -1
  155. package/dist/cli/help-json-payload.d.ts +1 -0
  156. package/dist/cli/help-json-payload.js +33 -3
  157. package/dist/cli/help-json-payload.js.map +1 -1
  158. package/dist/cli/main.d.ts +11 -0
  159. package/dist/cli/main.js +109 -55
  160. package/dist/cli/main.js.map +1 -1
  161. package/dist/cli/register-list-query.d.ts +5 -2
  162. package/dist/cli/register-list-query.js +254 -192
  163. package/dist/cli/register-list-query.js.map +1 -1
  164. package/dist/cli/register-mutation.d.ts +1 -1
  165. package/dist/cli/register-mutation.js +247 -64
  166. package/dist/cli/register-mutation.js.map +1 -1
  167. package/dist/cli/register-operations.js +17 -12
  168. package/dist/cli/register-operations.js.map +1 -1
  169. package/dist/cli/register-setup.js +33 -16
  170. package/dist/cli/register-setup.js.map +1 -1
  171. package/dist/cli/registration-helpers.d.ts +0 -2
  172. package/dist/cli/registration-helpers.js +14 -40
  173. package/dist/cli/registration-helpers.js.map +1 -1
  174. package/dist/cli.js +25 -4
  175. package/dist/cli.js.map +1 -1
  176. package/dist/core/config/positional-value.d.ts +44 -0
  177. package/dist/core/config/positional-value.js +109 -0
  178. package/dist/core/config/positional-value.js.map +1 -0
  179. package/dist/core/extensions/extension-capability-aliases.d.ts +14 -0
  180. package/dist/core/extensions/extension-capability-aliases.js +159 -0
  181. package/dist/core/extensions/extension-capability-aliases.js.map +1 -0
  182. package/dist/core/extensions/extension-hook-runtime.d.ts +13 -0
  183. package/dist/core/extensions/extension-hook-runtime.js +414 -0
  184. package/dist/core/extensions/extension-hook-runtime.js.map +1 -0
  185. package/dist/core/extensions/extension-policy.d.ts +69 -0
  186. package/dist/core/extensions/extension-policy.js +481 -0
  187. package/dist/core/extensions/extension-policy.js.map +1 -0
  188. package/dist/core/extensions/extension-registries.d.ts +8 -0
  189. package/dist/core/extensions/extension-registries.js +52 -0
  190. package/dist/core/extensions/extension-registries.js.map +1 -0
  191. package/dist/core/extensions/extension-runtime-helpers.d.ts +6 -0
  192. package/dist/core/extensions/extension-runtime-helpers.js +29 -0
  193. package/dist/core/extensions/extension-runtime-helpers.js.map +1 -0
  194. package/dist/core/extensions/extension-types.d.ts +13 -39
  195. package/dist/core/extensions/extension-types.js +34 -2
  196. package/dist/core/extensions/extension-types.js.map +1 -1
  197. package/dist/core/extensions/index.d.ts +7 -1
  198. package/dist/core/extensions/index.js +11 -14
  199. package/dist/core/extensions/index.js.map +1 -1
  200. package/dist/core/extensions/loader.d.ts +4 -22
  201. package/dist/core/extensions/loader.js +23 -1146
  202. package/dist/core/extensions/loader.js.map +1 -1
  203. package/dist/core/fs/path-utils.d.ts +1 -0
  204. package/dist/core/fs/path-utils.js +12 -0
  205. package/dist/core/fs/path-utils.js.map +1 -0
  206. package/dist/core/history/drift-scan.d.ts +22 -0
  207. package/dist/core/history/drift-scan.js +149 -0
  208. package/dist/core/history/drift-scan.js.map +1 -0
  209. package/dist/core/history/history-rewrite.d.ts +43 -0
  210. package/dist/core/history/history-rewrite.js +48 -0
  211. package/dist/core/history/history-rewrite.js.map +1 -0
  212. package/dist/core/history/history.js +5 -4
  213. package/dist/core/history/history.js.map +1 -1
  214. package/dist/core/history/replay.d.ts +82 -0
  215. package/dist/core/history/replay.js +250 -0
  216. package/dist/core/history/replay.js.map +1 -0
  217. package/dist/core/item/item-format.js +11 -8
  218. package/dist/core/item/item-format.js.map +1 -1
  219. package/dist/core/item/item-record.d.ts +19 -0
  220. package/dist/core/item/item-record.js +24 -0
  221. package/dist/core/item/item-record.js.map +1 -0
  222. package/dist/core/item/item-type-definition.d.ts +52 -0
  223. package/dist/core/item/item-type-definition.js +123 -0
  224. package/dist/core/item/item-type-definition.js.map +1 -0
  225. package/dist/core/item/parse.js +3 -2
  226. package/dist/core/item/parse.js.map +1 -1
  227. package/dist/core/item/priority.d.ts +23 -0
  228. package/dist/core/item/priority.js +55 -0
  229. package/dist/core/item/priority.js.map +1 -0
  230. package/dist/core/item/status.d.ts +14 -1
  231. package/dist/core/item/status.js +22 -2
  232. package/dist/core/item/status.js.map +1 -1
  233. package/dist/core/item/toon-decode.d.ts +19 -0
  234. package/dist/core/item/toon-decode.js +69 -0
  235. package/dist/core/item/toon-decode.js.map +1 -0
  236. package/dist/core/item/type-registry.js +13 -84
  237. package/dist/core/item/type-registry.js.map +1 -1
  238. package/dist/core/output/mutation-projection.d.ts +31 -0
  239. package/dist/core/output/mutation-projection.js +103 -0
  240. package/dist/core/output/mutation-projection.js.map +1 -0
  241. package/dist/core/output/output.d.ts +2 -0
  242. package/dist/core/output/output.js +5 -3
  243. package/dist/core/output/output.js.map +1 -1
  244. package/dist/core/packages/manifest.js +3 -9
  245. package/dist/core/packages/manifest.js.map +1 -1
  246. package/dist/core/schema/item-types-file.d.ts +85 -0
  247. package/dist/core/schema/item-types-file.js +243 -0
  248. package/dist/core/schema/item-types-file.js.map +1 -0
  249. package/dist/core/schema/runtime-schema.d.ts +2 -1
  250. package/dist/core/schema/runtime-schema.js +17 -45
  251. package/dist/core/schema/runtime-schema.js.map +1 -1
  252. package/dist/core/search/semantic-defaults.js +3 -3
  253. package/dist/core/search/semantic-defaults.js.map +1 -1
  254. package/dist/core/search/vector-stores.js +46 -9
  255. package/dist/core/search/vector-stores.js.map +1 -1
  256. package/dist/core/sentry/helpers.d.ts +1 -1
  257. package/dist/core/sentry/helpers.js +20 -3
  258. package/dist/core/sentry/helpers.js.map +1 -1
  259. package/dist/core/shared/author.d.ts +1 -0
  260. package/dist/core/shared/author.js +9 -0
  261. package/dist/core/shared/author.js.map +1 -0
  262. package/dist/core/shared/command-types.d.ts +1 -0
  263. package/dist/core/shared/command-types.js +2 -2
  264. package/dist/core/shared/command-types.js.map +1 -1
  265. package/dist/core/shared/constants.d.ts +10 -1
  266. package/dist/core/shared/constants.js +56 -58
  267. package/dist/core/shared/constants.js.map +1 -1
  268. package/dist/core/shared/lazy-module.d.ts +1 -0
  269. package/dist/core/shared/lazy-module.js +11 -0
  270. package/dist/core/shared/lazy-module.js.map +1 -0
  271. package/dist/core/shared/option-alias-visibility.d.ts +44 -0
  272. package/dist/core/shared/option-alias-visibility.js +76 -0
  273. package/dist/core/shared/option-alias-visibility.js.map +1 -0
  274. package/dist/core/shared/primitives.d.ts +23 -0
  275. package/dist/core/shared/primitives.js +39 -2
  276. package/dist/core/shared/primitives.js.map +1 -1
  277. package/dist/core/shared/text-normalization.d.ts +0 -1
  278. package/dist/core/shared/text-normalization.js +2 -5
  279. package/dist/core/shared/text-normalization.js.map +1 -1
  280. package/dist/core/store/front-matter-cache.d.ts +16 -2
  281. package/dist/core/store/front-matter-cache.js +99 -33
  282. package/dist/core/store/front-matter-cache.js.map +1 -1
  283. package/dist/core/store/item-store.d.ts +2 -0
  284. package/dist/core/store/item-store.js +76 -110
  285. package/dist/core/store/item-store.js.map +1 -1
  286. package/dist/core/store/settings-validator.d.ts +106 -0
  287. package/dist/core/store/settings-validator.js +279 -0
  288. package/dist/core/store/settings-validator.js.map +1 -0
  289. package/dist/core/store/settings.js +6 -343
  290. package/dist/core/store/settings.js.map +1 -1
  291. package/dist/core/telemetry/runtime.js +5 -3
  292. package/dist/core/telemetry/runtime.js.map +1 -1
  293. package/dist/mcp/server.js +138 -39
  294. package/dist/mcp/server.js.map +1 -1
  295. package/dist/sdk/cli-contracts/enum-contracts.d.ts +20 -0
  296. package/dist/sdk/cli-contracts/enum-contracts.js +156 -0
  297. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -0
  298. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +14 -0
  299. package/dist/sdk/cli-contracts/tool-option-contracts.js +243 -0
  300. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -0
  301. package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +11 -0
  302. package/dist/sdk/cli-contracts/tool-parameter-tables.js +901 -0
  303. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -0
  304. package/dist/sdk/cli-contracts.d.ts +18 -33
  305. package/dist/sdk/cli-contracts.js +96 -1238
  306. package/dist/sdk/cli-contracts.js.map +1 -1
  307. package/dist/sdk/package-import-adapters.d.ts +74 -0
  308. package/dist/sdk/package-import-adapters.js +186 -0
  309. package/dist/sdk/package-import-adapters.js.map +1 -0
  310. package/dist/sdk/package-runtime-options.d.ts +26 -0
  311. package/dist/sdk/package-runtime-options.js +71 -0
  312. package/dist/sdk/package-runtime-options.js.map +1 -0
  313. package/dist/sdk/runtime.d.ts +27 -1
  314. package/dist/sdk/runtime.js +48 -3
  315. package/dist/sdk/runtime.js.map +1 -1
  316. package/dist/types.d.ts +6 -0
  317. package/dist/types.js +10 -2
  318. package/dist/types.js.map +1 -1
  319. package/docs/AGENT_GUIDE.md +13 -11
  320. package/docs/ARCHITECTURE.md +1 -1
  321. package/docs/CLAUDE_CODE_PLUGIN.md +5 -28
  322. package/docs/CODEX_PLUGIN.md +5 -5
  323. package/docs/COMMANDS.md +58 -9
  324. package/docs/CONFIGURATION.md +16 -1
  325. package/docs/EXTENSIONS.md +4 -63
  326. package/docs/RELEASING.md +12 -8
  327. package/docs/SDK.md +11 -2
  328. package/marketplace.json +7 -3
  329. package/package.json +18 -14
  330. package/packages/pm-beads/extensions/beads/index.js +2 -49
  331. package/packages/pm-beads/extensions/beads/index.ts +2 -54
  332. package/packages/pm-beads/extensions/beads/runtime-loader.js +86 -0
  333. package/packages/pm-beads/extensions/beads/runtime-loader.ts +88 -0
  334. package/packages/pm-beads/extensions/beads/runtime.js +26 -115
  335. package/packages/pm-beads/extensions/beads/runtime.ts +33 -132
  336. package/packages/pm-calendar/README.md +3 -1
  337. package/packages/pm-calendar/extensions/calendar/index.js +66 -2
  338. package/packages/pm-calendar/extensions/calendar/index.ts +71 -2
  339. package/packages/pm-calendar/extensions/calendar/runtime.js +1 -0
  340. package/packages/pm-calendar/extensions/calendar/runtime.ts +1 -0
  341. package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +14 -41
  342. package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +25 -41
  343. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +10 -50
  344. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +17 -50
  345. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +8 -40
  346. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +10 -40
  347. package/packages/pm-search-advanced/README.md +8 -0
  348. package/packages/pm-search-advanced/extensions/search-advanced/index.js +75 -1
  349. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +74 -0
  350. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +58 -33
  351. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +60 -33
  352. package/packages/pm-templates/extensions/templates/runtime.js +11 -202
  353. package/packages/pm-templates/extensions/templates/runtime.ts +38 -230
  354. package/packages/pm-todos/extensions/todos/index.js +3 -50
  355. package/packages/pm-todos/extensions/todos/index.ts +3 -55
  356. package/packages/pm-todos/extensions/todos/runtime-loader.js +86 -0
  357. package/packages/pm-todos/extensions/todos/runtime-loader.ts +88 -0
  358. package/packages/pm-todos/extensions/todos/runtime.js +24 -117
  359. package/packages/pm-todos/extensions/todos/runtime.ts +32 -129
  360. package/plugins/pm-claude/README.md +2 -2
  361. package/plugins/pm-claude/commands/pm-planner.md +1 -15
  362. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +5 -2
  363. package/plugins/pm-claude/skills/pm-planner/SKILL.md +3 -21
  364. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +15 -6
  365. package/plugins/pm-codex/skills/pm-native/SKILL.md +1 -13
  366. package/PRD.md +0 -1734
  367. package/dist/core/output/command-aware.d.ts +0 -1
  368. package/dist/core/output/command-aware.js +0 -397
  369. package/dist/core/output/command-aware.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"help-json-payload.js","sources":["cli/help-json-payload.ts"],"sourceRoot":"/","sourcesContent":["import { Command } from \"commander\";\nimport {\n commandOptionFlagLabel,\n resolveCommandOptionPolicyState,\n resolveItemTypeRegistry,\n resolveTypeDefinition,\n} from \"../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../core/shared/constants.js\";\nimport { printError, writeStdout } from \"../core/output/output.js\";\nimport {\n type HelpOptionSummary,\n type ExtensionCommandHelpDescriptor,\n buildDynamicExtensionHelpOptionSummaries,\n mergeHelpOptionSummaries,\n findCommandByPath,\n findDirectChildCommand,\n commandAliases,\n} from \"./extension-command-help.js\";\nimport {\n normalizeHelpCommandPath,\n resolveHelpDetailMode,\n resolveHelpNarrative,\n} from \"./help-content.js\";\nimport { getCommandPath } from \"./registration-helpers.js\";\nimport {\n parseBootstrapGlobalOptions,\n parseBootstrapHelpRequest,\n parseBootstrapCommandName,\n parseBootstrapTypeValue,\n} from \"./bootstrap-args.js\";\nimport { extractProvidedOptionFlags, renderPmCommand } from \"./argv-utils.js\";\nimport { formatCommanderErrorForJson } from \"./error-guidance.js\";\nimport {\n BUILTIN_TYPE_HELP_VALUES,\n buildUnknownCommandGuidanceFromRuntime,\n} from \"./commander-usage.js\";\n\nexport interface HelpArgumentSummary {\n name: string;\n required: boolean;\n variadic: boolean;\n description: string | null;\n}\n\nexport interface HelpSubcommandSummary {\n name: string;\n aliases: string[];\n description: string;\n}\n\nexport function resolveCommandFromPathTokens(root: Command, pathTokens: string[]): Command | null {\n if (pathTokens.length === 0) {\n return root;\n }\n return findCommandByPath(root, pathTokens);\n}\n\nexport function extractOptionValueName(flags: string): string | null {\n const match = flags.match(/[<[]([^>\\]]+)[>\\]]/);\n if (!match) {\n return null;\n }\n const value = match[1]?.trim();\n return value && value.length > 0 ? value : null;\n}\n\nexport function readOptionAttributeName(option: unknown): string | null {\n const optionRecord = option as {\n attributeName?: (() => string) | string;\n };\n if (typeof optionRecord.attributeName === \"function\") {\n const value = optionRecord.attributeName();\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : null;\n }\n if (typeof optionRecord.attributeName === \"string\" && optionRecord.attributeName.trim().length > 0) {\n return optionRecord.attributeName.trim();\n }\n return null;\n}\n\nexport function buildOptionAliasMap(options: unknown[]): Map<string, string[]> {\n const aliasMap = new Map<string, string[]>();\n for (const option of options) {\n const optionRecord = option as {\n long?: string;\n };\n const attributeName = readOptionAttributeName(option);\n if (!attributeName || typeof optionRecord.long !== \"string\" || optionRecord.long.trim().length === 0) {\n continue;\n }\n const existing = aliasMap.get(attributeName) ?? [];\n existing.push(optionRecord.long.trim());\n aliasMap.set(attributeName, existing);\n }\n for (const [attributeName, values] of aliasMap.entries()) {\n aliasMap.set(\n attributeName,\n [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((left, right) =>\n left.localeCompare(right),\n ),\n );\n }\n return aliasMap;\n}\n\nfunction renderAttemptedCommand(argv: string[]): string {\n return renderPmCommand(argv);\n}\n\nexport function buildHelpOptionSummaries(command: Command): HelpOptionSummary[] {\n const options = (command.options ?? []) as unknown[];\n const optionAliasMap = buildOptionAliasMap(options);\n return options.map((option) => {\n const optionRecord = option as {\n flags?: string;\n long?: string;\n short?: string;\n description?: string;\n mandatory?: boolean;\n variadic?: boolean;\n defaultValue?: unknown;\n };\n const flags = typeof optionRecord.flags === \"string\" ? optionRecord.flags.trim() : \"\";\n const description = typeof optionRecord.description === \"string\" ? optionRecord.description.trim() : \"\";\n const attributeName = readOptionAttributeName(option);\n const aliasCandidates = attributeName ? optionAliasMap.get(attributeName) ?? [] : [];\n const aliases = aliasCandidates\n .filter((entry) => entry !== optionRecord.long)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n const aliasForMatch = description.match(/^Alias for ([^ ]+)/i);\n const aliasFor = aliasForMatch && aliasForMatch[1] ? aliasForMatch[1].trim() : null;\n const required =\n optionRecord.mandatory === true || description.includes(\"[required]\") || description.toLowerCase().includes(\"required;\");\n const valueRequired = flags.includes(\"<\");\n const takesValue = valueRequired || flags.includes(\"[\");\n const summary: HelpOptionSummary = {\n flags,\n long: typeof optionRecord.long === \"string\" ? optionRecord.long : null,\n short: typeof optionRecord.short === \"string\" ? optionRecord.short : null,\n description,\n takes_value: takesValue,\n value_required: valueRequired,\n value_name: extractOptionValueName(flags),\n variadic: optionRecord.variadic === true,\n required,\n aliases,\n alias_for: aliasFor,\n };\n if (optionRecord.defaultValue !== undefined) {\n summary.default_value = optionRecord.defaultValue;\n }\n return summary;\n });\n}\n\nexport function buildHelpArgumentSummaries(command: Command): HelpArgumentSummary[] {\n const commandRecord = command as unknown as {\n registeredArguments?: Array<{\n name?: (() => string) | string;\n required?: boolean;\n variadic?: boolean;\n description?: string;\n }>;\n _args?: Array<{\n name?: (() => string) | string;\n required?: boolean;\n variadic?: boolean;\n description?: string;\n }>;\n };\n const argumentsList = Array.isArray(commandRecord.registeredArguments)\n ? commandRecord.registeredArguments\n : Array.isArray(commandRecord._args)\n ? commandRecord._args\n : [];\n\n return argumentsList.map((argument) => {\n const rawName =\n typeof argument.name === \"function\"\n ? argument.name()\n : typeof argument.name === \"string\"\n ? argument.name\n : \"argument\";\n const description = typeof argument.description === \"string\" && argument.description.trim().length > 0\n ? argument.description.trim()\n : null;\n return {\n name: rawName.trim(),\n required: argument.required === true,\n variadic: argument.variadic === true,\n description,\n };\n });\n}\n\nexport function buildHelpSubcommandSummaries(command: Command): HelpSubcommandSummary[] {\n return command.commands\n .map((entry) => ({\n name: entry.name().trim(),\n aliases: commandAliases(entry),\n description: entry.description().trim(),\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport function buildJsonHelpPayload(\n rootProgram: Command,\n targetCommand: Command,\n argv: string[],\n requestedPath: string[],\n extensionDescriptors: ReadonlyMap<string, ExtensionCommandHelpDescriptor>,\n): Record<string, unknown> {\n const detailMode = resolveHelpDetailMode(argv);\n const resolvedPath = normalizeHelpCommandPath(getCommandPath(targetCommand));\n const commandPath = resolvedPath.length > 0 ? resolvedPath : undefined;\n const fallbackNarrative = resolveHelpNarrative(commandPath, detailMode);\n const extensionDescriptor = commandPath ? extensionDescriptors.get(commandPath) : undefined;\n const extensionExamples = extensionDescriptor?.examples ?? [];\n const extensionFailureHints = extensionDescriptor?.failure_hints ?? [];\n const narrative = extensionDescriptor\n ? {\n intent: extensionDescriptor.intent ?? extensionDescriptor.description ?? fallbackNarrative.intent,\n examples:\n detailMode === \"detailed\"\n ? extensionExamples.length > 0\n ? [...extensionExamples]\n : [...fallbackNarrative.examples]\n : extensionExamples.length > 0\n ? [extensionExamples[0]]\n : [...fallbackNarrative.examples],\n tips:\n detailMode === \"detailed\"\n ? extensionFailureHints.length > 0\n ? [...extensionFailureHints]\n : [...fallbackNarrative.tips]\n : [],\n detail_mode: detailMode,\n }\n : fallbackNarrative;\n const optionSummaries = mergeHelpOptionSummaries(\n buildHelpOptionSummaries(targetCommand),\n buildDynamicExtensionHelpOptionSummaries(extensionDescriptor),\n );\n const subcommands = buildHelpSubcommandSummaries(targetCommand);\n return {\n format: \"pm_help_v1\",\n detail_mode: detailMode,\n root_command: rootProgram.name(),\n requested_path: requestedPath,\n resolved_path: resolvedPath.length > 0 ? resolvedPath : rootProgram.name(),\n description: targetCommand.description(),\n usage: targetCommand.usage(),\n intent: narrative.intent,\n examples: narrative.examples,\n tips: narrative.tips,\n arguments: buildHelpArgumentSummaries(targetCommand),\n options: optionSummaries,\n subcommands,\n has_subcommands: subcommands.length > 0,\n };\n}\n\nexport async function maybeRenderBootstrapJsonHelp(\n rootProgram: Command,\n argv: string[],\n extensionDescriptors: ReadonlyMap<string, ExtensionCommandHelpDescriptor>,\n): Promise<boolean> {\n const bootstrapGlobal = parseBootstrapGlobalOptions(argv);\n if (!bootstrapGlobal.json) {\n return false;\n }\n const helpRequest = parseBootstrapHelpRequest(argv);\n if (!helpRequest.requested) {\n return false;\n }\n const targetCommand = resolveCommandFromPathTokens(rootProgram, helpRequest.commandPathTokens);\n if (!targetCommand) {\n if (!bootstrapGlobal.quiet) {\n const unknownMessage = `unknown command '${helpRequest.commandPathTokens.join(\" \")}'`;\n const runtimeContext = buildUnknownCommandGuidanceFromRuntime(unknownMessage, rootProgram, extensionDescriptors);\n const envelope = formatCommanderErrorForJson(\n unknownMessage,\n \"help\",\n BUILTIN_TYPE_HELP_VALUES,\n EXIT_CODE.USAGE,\n {\n ...(runtimeContext ?? {}),\n attemptedCommand: renderAttemptedCommand(argv),\n normalizedInvocationArgs: [...argv],\n providedOptionFlags: extractProvidedOptionFlags(argv),\n },\n );\n printError(JSON.stringify(envelope, null, 2));\n }\n process.exitCode = EXIT_CODE.USAGE;\n return true;\n }\n if (!bootstrapGlobal.quiet) {\n const payload = buildJsonHelpPayload(rootProgram, targetCommand, argv, helpRequest.commandPathTokens, extensionDescriptors);\n writeStdout(`${JSON.stringify(payload, null, 2)}\\n`);\n }\n process.exitCode = EXIT_CODE.SUCCESS;\n return true;\n}\n\nexport function buildCreateUpdatePolicyHelpText(\n commandName: \"create\" | \"update\",\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>,\n argv: string[],\n): string {\n const selectedTypeRaw = parseBootstrapTypeValue(argv);\n if (!selectedTypeRaw) {\n const allowed = typeRegistry.types.join(\"|\");\n const lines = [\n \"\",\n \"Type-aware option policies:\",\n \" pass --type <value> with --help to render required/disabled/hidden option policy details for that type.\",\n ` active type values: ${allowed}`,\n ];\n if (commandName === \"create\") {\n lines.push(\n \" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows.\",\n );\n }\n return lines.join(\"\\n\");\n }\n\n const typeDefinition = resolveTypeDefinition(selectedTypeRaw, typeRegistry);\n if (!typeDefinition) {\n const allowed = typeRegistry.types.join(\"|\");\n return [\n \"\",\n `Type-aware option policies: type \"${selectedTypeRaw}\" is not in the active registry.`,\n ` active type values: ${allowed}`,\n ].join(\"\\n\");\n }\n\n const baseRequired =\n commandName === \"create\"\n ? new Set<string>([\"title\", \"description\", \"type\", ...typeDefinition.required_create_fields, ...typeDefinition.required_create_repeatables])\n : new Set<string>();\n const policyState = resolveCommandOptionPolicyState(typeDefinition, commandName, baseRequired);\n const toFlags = (options: string[]): string =>\n options.length > 0 ? options.map((option) => commandOptionFlagLabel(commandName, option)).join(\", \") : \"none\";\n\n const lines = [\n \"\",\n `Type-aware option policies for ${typeDefinition.name}:`,\n ` required: ${toFlags(policyState.required)}`,\n ` disabled: ${toFlags(policyState.disabled)}`,\n ` hidden: ${toFlags(policyState.hidden)}`,\n ];\n if (commandName === \"create\" && [\"Reminder\", \"Meeting\", \"Event\"].includes(typeDefinition.name)) {\n lines.push(\n \" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy.\",\n );\n lines.push(\" strict parity remains available via --create-mode strict.\");\n }\n if (typeDefinition.options.length === 0) {\n lines.push(\" type options: none\");\n } else {\n lines.push(\" type options:\");\n for (const option of typeDefinition.options) {\n const requiredLabel = option.required ? \" (required)\" : \"\";\n const aliases = option.aliases ?? [];\n lines.push(` - ${option.key}${requiredLabel}`);\n lines.push(` values: ${option.values.length > 0 ? option.values.join(\"|\") : \"any non-empty string\"}`);\n lines.push(` aliases: ${aliases.length > 0 ? aliases.join(\"|\") : \"none\"}`);\n if (option.description && option.description.trim().length > 0) {\n lines.push(` description: ${option.description.trim()}`);\n }\n }\n }\n if (policyState.errors.length > 0) {\n lines.push(` config errors: ${policyState.errors.join(\"; \")}`);\n }\n return lines.join(\"\\n\");\n}\n\nexport function attachCreateUpdatePolicyHelpText(\n rootProgram: Command,\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>,\n argv: string[],\n): void {\n const bootstrapCommand = parseBootstrapCommandName(argv);\n if (bootstrapCommand !== \"create\" && bootstrapCommand !== \"update\") {\n return;\n }\n const command = findDirectChildCommand(rootProgram, bootstrapCommand);\n if (!command) {\n return;\n }\n command.addHelpText(\"after\", buildCreateUpdatePolicyHelpText(bootstrapCommand, typeRegistry, argv));\n}\n"],"names":[],"mappings":";;AACA,OAAO,EACL,sBAAsB,EACtB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AC;IACH,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,oBAAoB,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,WAAoB,EACpB,YAAwD,EACxD,IAAc;IAEd,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,+BAA+B,CAAC,gBAAgB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACtG,CAAC","debugId":"49c2174d-1221-5026-b8ae-5dfab9778c90"}
1
+ {"version":3,"file":"help-json-payload.js","sources":["cli/help-json-payload.ts"],"sourceRoot":"/","sourcesContent":["import { Command } from \"commander\";\nimport {\n commandOptionFlagLabel,\n resolveCommandOptionPolicyState,\n resolveItemTypeRegistry,\n resolveTypeDefinition,\n} from \"../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../core/shared/constants.js\";\nimport { printError, writeStdout } from \"../core/output/output.js\";\nimport {\n type HelpOptionSummary,\n type ExtensionCommandHelpDescriptor,\n buildDynamicExtensionHelpOptionSummaries,\n mergeHelpOptionSummaries,\n findCommandByPath,\n findDirectChildCommand,\n commandAliases,\n} from \"./extension-command-help.js\";\nimport {\n normalizeHelpCommandPath,\n resolveHelpDetailMode,\n resolveHelpNarrative,\n} from \"./help-content.js\";\nimport { getCommandPath } from \"./registration-helpers.js\";\nimport {\n parseBootstrapGlobalOptions,\n parseBootstrapHelpRequest,\n parseBootstrapCommandName,\n parseBootstrapTypeValue,\n} from \"./bootstrap-args.js\";\nimport { extractProvidedOptionFlags, renderPmCommand } from \"./argv-utils.js\";\nimport { formatCommanderErrorForJson } from \"./error-guidance.js\";\nimport {\n BUILTIN_TYPE_HELP_VALUES,\n buildUnknownCommandGuidanceFromRuntime,\n} from \"./commander-usage.js\";\n\nexport interface HelpArgumentSummary {\n name: string;\n required: boolean;\n variadic: boolean;\n description: string | null;\n}\n\nexport interface HelpSubcommandSummary {\n name: string;\n aliases: string[];\n description: string;\n}\n\nexport function resolveCommandFromPathTokens(root: Command, pathTokens: string[]): Command | null {\n if (pathTokens.length === 0) {\n return root;\n }\n return findCommandByPath(root, pathTokens);\n}\n\nexport function extractOptionValueName(flags: string): string | null {\n const match = flags.match(/[<[]([^>\\]]+)[>\\]]/);\n if (!match) {\n return null;\n }\n const value = match[1]?.trim();\n return value && value.length > 0 ? value : null;\n}\n\nexport function readOptionAttributeName(option: unknown): string | null {\n const optionRecord = option as {\n attributeName?: (() => string) | string;\n };\n if (typeof optionRecord.attributeName === \"function\") {\n const value = optionRecord.attributeName();\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : null;\n }\n if (typeof optionRecord.attributeName === \"string\" && optionRecord.attributeName.trim().length > 0) {\n return optionRecord.attributeName.trim();\n }\n return null;\n}\n\nexport function buildOptionAliasMap(options: unknown[]): Map<string, string[]> {\n const aliasMap = new Map<string, string[]>();\n for (const option of options) {\n const optionRecord = option as {\n long?: string;\n };\n const attributeName = readOptionAttributeName(option);\n if (!attributeName || typeof optionRecord.long !== \"string\" || optionRecord.long.trim().length === 0) {\n continue;\n }\n const existing = aliasMap.get(attributeName) ?? [];\n existing.push(optionRecord.long.trim());\n aliasMap.set(attributeName, existing);\n }\n for (const [attributeName, values] of aliasMap.entries()) {\n aliasMap.set(\n attributeName,\n [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((left, right) =>\n left.localeCompare(right),\n ),\n );\n }\n return aliasMap;\n}\n\nfunction renderAttemptedCommand(argv: string[]): string {\n return renderPmCommand(argv);\n}\n\nexport function buildHelpOptionSummaries(command: Command): HelpOptionSummary[] {\n const options = (command.options ?? []) as unknown[];\n const optionAliasMap = buildOptionAliasMap(options);\n return options.map((option) => {\n const optionRecord = option as {\n flags?: string;\n long?: string;\n short?: string;\n description?: string;\n mandatory?: boolean;\n variadic?: boolean;\n defaultValue?: unknown;\n };\n const flags = typeof optionRecord.flags === \"string\" ? optionRecord.flags.trim() : \"\";\n const description = typeof optionRecord.description === \"string\" ? optionRecord.description.trim() : \"\";\n const attributeName = readOptionAttributeName(option);\n const aliasCandidates = attributeName ? optionAliasMap.get(attributeName) ?? [] : [];\n const aliases = aliasCandidates\n .filter((entry) => entry !== optionRecord.long)\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n const aliasForMatch = description.match(/^Alias for ([^ ]+)/i);\n const aliasFor = aliasForMatch && aliasForMatch[1] ? aliasForMatch[1].trim() : null;\n const required =\n optionRecord.mandatory === true || description.includes(\"[required]\") || description.toLowerCase().includes(\"required;\");\n const valueRequired = flags.includes(\"<\");\n const takesValue = valueRequired || flags.includes(\"[\");\n const summary: HelpOptionSummary = {\n flags,\n long: typeof optionRecord.long === \"string\" ? optionRecord.long : null,\n short: typeof optionRecord.short === \"string\" ? optionRecord.short : null,\n description,\n takes_value: takesValue,\n value_required: valueRequired,\n value_name: extractOptionValueName(flags),\n variadic: optionRecord.variadic === true,\n required,\n aliases,\n alias_for: aliasFor,\n };\n if (optionRecord.defaultValue !== undefined) {\n summary.default_value = optionRecord.defaultValue;\n }\n return summary;\n });\n}\n\nexport function compactHelpOptionAliases(options: HelpOptionSummary[]): HelpOptionSummary[] {\n const canonicalByLong = new Map<string, HelpOptionSummary>();\n const aliasOptions: HelpOptionSummary[] = [];\n for (const option of options) {\n if (option.alias_for && option.long) {\n aliasOptions.push(option);\n continue;\n }\n if (option.long) {\n canonicalByLong.set(option.long, option);\n }\n }\n for (const aliasOption of aliasOptions) {\n if (!aliasOption.alias_for || !aliasOption.long) {\n continue;\n }\n const canonical = canonicalByLong.get(aliasOption.alias_for);\n if (!canonical) {\n continue;\n }\n const aliases = new Set([...(canonical.aliases ?? []), aliasOption.long]);\n canonical.aliases = [...aliases].sort((left, right) => left.localeCompare(right));\n }\n return options.filter((option) => {\n if (!option.alias_for || !option.long) {\n return true;\n }\n return !canonicalByLong.has(option.alias_for);\n });\n}\n\nexport function buildHelpArgumentSummaries(command: Command): HelpArgumentSummary[] {\n const commandRecord = command as unknown as {\n registeredArguments?: Array<{\n name?: (() => string) | string;\n required?: boolean;\n variadic?: boolean;\n description?: string;\n }>;\n _args?: Array<{\n name?: (() => string) | string;\n required?: boolean;\n variadic?: boolean;\n description?: string;\n }>;\n };\n const argumentsList = Array.isArray(commandRecord.registeredArguments)\n ? commandRecord.registeredArguments\n : Array.isArray(commandRecord._args)\n ? commandRecord._args\n : [];\n\n return argumentsList.map((argument) => {\n const rawName =\n typeof argument.name === \"function\"\n ? argument.name()\n : typeof argument.name === \"string\"\n ? argument.name\n : \"argument\";\n const description = typeof argument.description === \"string\" && argument.description.trim().length > 0\n ? argument.description.trim()\n : null;\n return {\n name: rawName.trim(),\n required: argument.required === true,\n variadic: argument.variadic === true,\n description,\n };\n });\n}\n\nexport function buildHelpSubcommandSummaries(command: Command): HelpSubcommandSummary[] {\n return command.commands\n .map((entry) => ({\n name: entry.name().trim(),\n aliases: commandAliases(entry),\n description: entry.description().trim(),\n }))\n .sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport function buildJsonHelpPayload(\n rootProgram: Command,\n targetCommand: Command,\n argv: string[],\n requestedPath: string[],\n extensionDescriptors: ReadonlyMap<string, ExtensionCommandHelpDescriptor>,\n): Record<string, unknown> {\n const detailMode = resolveHelpDetailMode(argv);\n const resolvedPath = normalizeHelpCommandPath(getCommandPath(targetCommand));\n const commandPath = resolvedPath.length > 0 ? resolvedPath : undefined;\n const fallbackNarrative = resolveHelpNarrative(commandPath, detailMode);\n const extensionDescriptor = commandPath ? extensionDescriptors.get(commandPath) : undefined;\n const extensionExamples = extensionDescriptor?.examples ?? [];\n const extensionFailureHints = extensionDescriptor?.failure_hints ?? [];\n const narrative = extensionDescriptor\n ? {\n intent: extensionDescriptor.intent ?? extensionDescriptor.description ?? fallbackNarrative.intent,\n examples:\n detailMode === \"detailed\"\n ? extensionExamples.length > 0\n ? [...extensionExamples]\n : [...fallbackNarrative.examples]\n : extensionExamples.length > 0\n ? [extensionExamples[0]]\n : [...fallbackNarrative.examples],\n tips:\n detailMode === \"detailed\"\n ? extensionFailureHints.length > 0\n ? [...extensionFailureHints]\n : [...fallbackNarrative.tips]\n : [],\n detail_mode: detailMode,\n }\n : fallbackNarrative;\n const optionSummaries = compactHelpOptionAliases(\n mergeHelpOptionSummaries(\n buildHelpOptionSummaries(targetCommand),\n buildDynamicExtensionHelpOptionSummaries(extensionDescriptor),\n ),\n );\n const subcommands = buildHelpSubcommandSummaries(targetCommand);\n return {\n format: \"pm_help_v1\",\n detail_mode: detailMode,\n root_command: rootProgram.name(),\n requested_path: requestedPath,\n resolved_path: resolvedPath.length > 0 ? resolvedPath : rootProgram.name(),\n description: targetCommand.description(),\n usage: targetCommand.usage(),\n intent: narrative.intent,\n examples: narrative.examples,\n tips: narrative.tips,\n arguments: buildHelpArgumentSummaries(targetCommand),\n options: optionSummaries,\n subcommands,\n has_subcommands: subcommands.length > 0,\n };\n}\n\nexport async function maybeRenderBootstrapJsonHelp(\n rootProgram: Command,\n argv: string[],\n extensionDescriptors: ReadonlyMap<string, ExtensionCommandHelpDescriptor>,\n): Promise<boolean> {\n const bootstrapGlobal = parseBootstrapGlobalOptions(argv);\n if (!bootstrapGlobal.json) {\n return false;\n }\n const helpRequest = parseBootstrapHelpRequest(argv);\n if (!helpRequest.requested) {\n return false;\n }\n const targetCommand = resolveCommandFromPathTokens(rootProgram, helpRequest.commandPathTokens);\n if (!targetCommand) {\n if (!bootstrapGlobal.quiet) {\n const unknownMessage = `unknown command '${helpRequest.commandPathTokens.join(\" \")}'`;\n const runtimeContext = buildUnknownCommandGuidanceFromRuntime(unknownMessage, rootProgram, extensionDescriptors);\n const envelope = formatCommanderErrorForJson(\n unknownMessage,\n \"help\",\n BUILTIN_TYPE_HELP_VALUES,\n EXIT_CODE.USAGE,\n {\n ...(runtimeContext ?? {}),\n attemptedCommand: renderAttemptedCommand(argv),\n normalizedInvocationArgs: [...argv],\n providedOptionFlags: extractProvidedOptionFlags(argv),\n },\n );\n printError(JSON.stringify(envelope, null, 2));\n }\n process.exitCode = EXIT_CODE.USAGE;\n return true;\n }\n if (!bootstrapGlobal.quiet) {\n const payload = buildJsonHelpPayload(rootProgram, targetCommand, argv, helpRequest.commandPathTokens, extensionDescriptors);\n writeStdout(`${JSON.stringify(payload, null, 2)}\\n`);\n }\n process.exitCode = EXIT_CODE.SUCCESS;\n return true;\n}\n\nexport function buildCreateUpdatePolicyHelpText(\n commandName: \"create\" | \"update\",\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>,\n argv: string[],\n): string {\n const selectedTypeRaw = parseBootstrapTypeValue(argv);\n if (!selectedTypeRaw) {\n const allowed = typeRegistry.types.join(\"|\");\n const lines = [\n \"\",\n \"Type-aware option policies:\",\n \" pass --type <value> with --help to render required/disabled/hidden option policy details for that type.\",\n ` active type values: ${allowed}`,\n ];\n if (commandName === \"create\") {\n lines.push(\n \" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows.\",\n );\n }\n return lines.join(\"\\n\");\n }\n\n const typeDefinition = resolveTypeDefinition(selectedTypeRaw, typeRegistry);\n if (!typeDefinition) {\n const allowed = typeRegistry.types.join(\"|\");\n return [\n \"\",\n `Type-aware option policies: type \"${selectedTypeRaw}\" is not in the active registry.`,\n ` active type values: ${allowed}`,\n ].join(\"\\n\");\n }\n\n const baseRequired =\n commandName === \"create\"\n ? new Set<string>([\"title\", \"description\", \"type\", ...typeDefinition.required_create_fields, ...typeDefinition.required_create_repeatables])\n : new Set<string>();\n const policyState = resolveCommandOptionPolicyState(typeDefinition, commandName, baseRequired);\n const toFlags = (options: string[]): string =>\n options.length > 0 ? options.map((option) => commandOptionFlagLabel(commandName, option)).join(\", \") : \"none\";\n\n const lines = [\n \"\",\n `Type-aware option policies for ${typeDefinition.name}:`,\n ` required: ${toFlags(policyState.required)}`,\n ` disabled: ${toFlags(policyState.disabled)}`,\n ` hidden: ${toFlags(policyState.hidden)}`,\n ];\n if (commandName === \"create\" && [\"Reminder\", \"Meeting\", \"Event\"].includes(typeDefinition.name)) {\n lines.push(\n \" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy.\",\n );\n lines.push(\" strict parity remains available via --create-mode strict.\");\n }\n if (typeDefinition.options.length === 0) {\n lines.push(\" type options: none\");\n } else {\n lines.push(\" type options:\");\n for (const option of typeDefinition.options) {\n const requiredLabel = option.required ? \" (required)\" : \"\";\n const aliases = option.aliases ?? [];\n lines.push(` - ${option.key}${requiredLabel}`);\n lines.push(` values: ${option.values.length > 0 ? option.values.join(\"|\") : \"any non-empty string\"}`);\n lines.push(` aliases: ${aliases.length > 0 ? aliases.join(\"|\") : \"none\"}`);\n if (option.description && option.description.trim().length > 0) {\n lines.push(` description: ${option.description.trim()}`);\n }\n }\n }\n if (policyState.errors.length > 0) {\n lines.push(` config errors: ${policyState.errors.join(\"; \")}`);\n }\n return lines.join(\"\\n\");\n}\n\nexport function attachCreateUpdatePolicyHelpText(\n rootProgram: Command,\n typeRegistry: ReturnType<typeof resolveItemTypeRegistry>,\n argv: string[],\n): void {\n const bootstrapCommand = parseBootstrapCommandName(argv);\n if (bootstrapCommand !== \"create\" && bootstrapCommand !== \"update\") {\n return;\n }\n const command = findDirectChildCommand(rootProgram, bootstrapCommand);\n if (!command) {\n return;\n }\n command.addHelpText(\"after\", buildCreateUpdatePolicyHelp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IAAI,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/D,KAAK,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,oBAAoB,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gCAAgC,CAC9C,WAAoB,EACpB,YAAwD,EACxD,IAAc;IAEd,MAAM,gBAAgB,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,KAAK,QAAQ,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,+BAA+B,CAAC,gBAAgB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AACtG,CAAC","debugId":"8ed1b6f2-0119-5667-be8f-8a1e245d795f"}
@@ -1,2 +1,13 @@
1
1
  #!/usr/bin/env node
2
+ declare function readThrownExitCode(error: unknown): number | undefined;
3
+ declare function normalizeThrownExitCode(exitCode: number): number;
4
+ declare function isCommanderError(error: unknown): boolean;
5
+ declare function wrapThrownErrorForSentry(error: unknown, message: string): Error;
6
+ export declare function runPmCli(rawArgv?: string[]): Promise<void>;
7
+ export declare const _testOnly: {
8
+ isCommanderError: typeof isCommanderError;
9
+ normalizeThrownExitCode: typeof normalizeThrownExitCode;
10
+ readThrownExitCode: typeof readThrownExitCode;
11
+ wrapThrownErrorForSentry: typeof wrapThrownErrorForSentry;
12
+ };
2
13
  export {};
package/dist/cli/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !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]="fa3533db-abe8-515b-9879-5faf8c891e25")}catch(e){}}();
3
+ !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]="253a39d8-edf5-592c-8b3e-ed509a8a6f11")}catch(e){}}();
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
6
  import { Command } from "commander";
@@ -11,6 +11,7 @@ import { resolveItemTypeRegistry, } from "../core/item/type-registry.js";
11
11
  import { resolveRuntimeFieldRegistry, } from "../core/schema/runtime-schema.js";
12
12
  import { EXIT_CODE, resolveTelemetryErrorCategory } from "../core/shared/constants.js";
13
13
  import { PmCliError } from "../core/shared/errors.js";
14
+ import { asRecordOrNull } from "../core/shared/primitives.js";
14
15
  import { printError, printResult, writeStdout } from "../core/output/output.js";
15
16
  import { maybeRunFirstUseTelemetryPrompt } from "../core/telemetry/consent.js";
16
17
  import { emitTelemetryErrorEvent, finishTelemetryCommand, startTelemetryCommand, } from "../core/telemetry/runtime.js";
@@ -19,11 +20,12 @@ import { sentryCaptureCliError, sentryFinishCommandSpan, sentryFlush, sentryLogC
19
20
  import { ensureSentryInit } from "../core/sentry/instrument.js";
20
21
  import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
21
22
  import { readSettings } from "../core/store/settings.js";
22
- import { coerceLooseCommandOptionsWithFlagDefinitions, parseLooseCommandOptions } from "./extension-command-options.js";
23
+ import { coerceLooseCommandOptionsWithFlagDefinitions, parseLooseCommandOptions, validateLooseCommandOptionsWithFlagDefinitions, } from "./extension-command-options.js";
23
24
  import { attachRichHelpText } from "./help-content.js";
24
25
  import { extractProvidedOptionFlags, normalizeLongOptionFlag, renderPmCommand, } from "./argv-utils.js";
25
26
  import { classifyCommanderError, classifyPmCliError, classifyUnknownError, formatPmCliErrorForDisplay, formatPmCliErrorForJson, formatUnknownErrorForJson, } from "./error-guidance.js";
26
27
  import { applyDefaultOutputFormat, clearResolvedGlobalOptions, collect, formatHookWarnings, getCommandPath, getGlobalOptions, invalidateSearchCachesForMutation, setResolvedGlobalOptions, } from "./registration-helpers.js";
28
+ import { createLazyModule } from "../core/shared/lazy-module.js";
27
29
  import { normalizeExtensionCommandPath, collectDynamicExtensionFlagHelpByCommand, collectExtensionCommandHelpDescriptors, applyDynamicExtensionArguments, buildDynamicExtensionCommandMetadataHelp, findCommandByPath, ensureCommandPath, } from "./extension-command-help.js";
28
30
  import { parseBootstrapGlobalOptions, applyBootstrapPagerPolicy, parseBootstrapHelpRequest, parseBootstrapCommandName, normalizeBootstrapInvocation, } from "./bootstrap-args.js";
29
31
  import { collectMandatoryMigrationBlockers, enforceMandatoryMigrationWriteGate, enforceItemFormatWriteGateAndPreflightMigration, resolveMigrationId, resolveNormalizedMigrationStatus, } from "./migration-gates.js";
@@ -56,26 +58,10 @@ const TELEMETRY_RESOLUTION_STAGE_SET = new Set(["parse", "preflight", "execute",
56
58
  const TELEMETRY_ERROR_CATEGORY_SET = new Set(["usage", "validation", "conflict", "runtime", "unknown"]);
57
59
  let runtimeExtensionSnapshotCache = null;
58
60
  let activeRuntimeExtensionCommandDescriptors = new Map();
59
- let setupRegistrationModulePromise = null;
60
- let listQueryRegistrationModulePromise = null;
61
- let mutationRegistrationModulePromise = null;
62
- let operationRegistrationModulePromise = null;
63
- async function loadSetupRegistrationModule() {
64
- setupRegistrationModulePromise ??= import("./register-setup.js");
65
- return setupRegistrationModulePromise;
66
- }
67
- async function loadListQueryRegistrationModule() {
68
- listQueryRegistrationModulePromise ??= import("./register-list-query.js");
69
- return listQueryRegistrationModulePromise;
70
- }
71
- async function loadMutationRegistrationModule() {
72
- mutationRegistrationModulePromise ??= import("./register-mutation.js");
73
- return mutationRegistrationModulePromise;
74
- }
75
- async function loadOperationRegistrationModule() {
76
- operationRegistrationModulePromise ??= import("./register-operations.js");
77
- return operationRegistrationModulePromise;
78
- }
61
+ const loadSetupRegistrationModule = createLazyModule(() => import("./register-setup.js"));
62
+ const loadListQueryRegistrationModule = createLazyModule(() => import("./register-list-query.js"));
63
+ const loadMutationRegistrationModule = createLazyModule(() => import("./register-mutation.js"));
64
+ const loadOperationRegistrationModule = createLazyModule(() => import("./register-operations.js"));
79
65
  function describeUnknownError(error) {
80
66
  if (error instanceof PmCliError) {
81
67
  return error.message;
@@ -85,6 +71,35 @@ function describeUnknownError(error) {
85
71
  }
86
72
  return "Unknown failure";
87
73
  }
74
+ function readThrownExitCode(error) {
75
+ if (typeof error !== "object" || error === null || !("exitCode" in error)) {
76
+ return undefined;
77
+ }
78
+ const exitCode = error.exitCode;
79
+ return typeof exitCode === "number" && Number.isFinite(exitCode) ? exitCode : undefined;
80
+ }
81
+ function normalizeThrownExitCode(exitCode) {
82
+ const normalized = Math.trunc(exitCode);
83
+ return normalized > EXIT_CODE.SUCCESS ? normalized : EXIT_CODE.GENERIC_FAILURE;
84
+ }
85
+ function isCommanderError(error) {
86
+ return (typeof error === "object" &&
87
+ error !== null &&
88
+ "code" in error &&
89
+ typeof error.code === "string" &&
90
+ error.code.startsWith("commander."));
91
+ }
92
+ function wrapThrownErrorForSentry(error, message) {
93
+ if (error instanceof Error) {
94
+ return error;
95
+ }
96
+ const wrapped = new Error(message);
97
+ const exitCode = readThrownExitCode(error);
98
+ if (exitCode !== undefined) {
99
+ wrapped.exitCode = normalizeThrownExitCode(exitCode);
100
+ }
101
+ return wrapped;
102
+ }
88
103
  function renderAttemptedCommand(argv) {
89
104
  return renderPmCommand(argv);
90
105
  }
@@ -100,10 +115,10 @@ function buildPmCliRecoveryContext(context, invocationArgv, rawMessage) {
100
115
  const attemptedCommand = renderAttemptedCommand(invocationArgv);
101
116
  const providedFields = extractProvidedOptionFlags(invocationArgv);
102
117
  const providedSet = new Set(providedFields.map((flag) => normalizeLongOptionFlag(flag) ?? flag));
103
- const rawInferred = inferMissingFieldsFromErrorMessage(rawMessage);
118
+ const existingRecovery = context?.recovery;
119
+ const rawInferred = existingRecovery?.suggested_retry ? undefined : inferMissingFieldsFromErrorMessage(rawMessage);
104
120
  const trulyMissing = rawInferred?.filter((flag) => !providedSet.has(normalizeLongOptionFlag(flag) ?? flag));
105
121
  const inferredMissing = trulyMissing && trulyMissing.length > 0 ? trulyMissing : undefined;
106
- const existingRecovery = context?.recovery;
107
122
  let suggestedRetry = existingRecovery?.suggested_retry;
108
123
  if (!suggestedRetry && inferredMissing && inferredMissing.length > 0) {
109
124
  const missingFlag = inferredMissing[0];
@@ -130,12 +145,6 @@ function buildPmCliRecoveryContext(context, invocationArgv, rawMessage) {
130
145
  recovery,
131
146
  };
132
147
  }
133
- function asRecord(value) {
134
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
135
- return null;
136
- }
137
- return value;
138
- }
139
148
  function readRecordString(record, ...keys) {
140
149
  if (!record) {
141
150
  return undefined;
@@ -228,7 +237,7 @@ function inferPostActionFailureMessage(result) {
228
237
  const runResults = result?.run_results;
229
238
  if (Array.isArray(runResults)) {
230
239
  const failedRuns = runResults.filter((entry) => {
231
- const row = asRecord(entry);
240
+ const row = asRecordOrNull(entry);
232
241
  return row?.status === "failed";
233
242
  }).length;
234
243
  if (failedRuns > 0) {
@@ -256,7 +265,7 @@ function inferPostActionErrorCode(ok, exitCode) {
256
265
  return "command_failed";
257
266
  }
258
267
  function buildPostActionTelemetryOutcome() {
259
- const result = asRecord(getActiveCommandResult());
268
+ const result = asRecordOrNull(getActiveCommandResult());
260
269
  const processExitCode = typeof process.exitCode === "number" && Number.isFinite(process.exitCode)
261
270
  ? Math.max(0, Math.trunc(process.exitCode))
262
271
  : undefined;
@@ -333,7 +342,13 @@ function extractCommandScopedOptions(command, commandArgs, extensionFlagDefiniti
333
342
  delete scoped.extensions;
334
343
  delete scoped.profile;
335
344
  delete scoped.pager;
345
+ // --no-changed-fields is a global output control (commander exposes it as `changedFields`),
346
+ // not a per-command mutation field; strip it so it never counts as an update input.
347
+ delete scoped.changedFields;
336
348
  const looseOptions = parseLooseCommandOptions(commandArgs);
349
+ if (extensionFlagDefinitions.length > 0) {
350
+ validateLooseCommandOptionsWithFlagDefinitions(looseOptions, extensionFlagDefinitions, getCommandPath(command));
351
+ }
337
352
  for (const [key, value] of Object.entries(looseOptions)) {
338
353
  if (scoped[key] === undefined) {
339
354
  scoped[key] = value;
@@ -353,6 +368,22 @@ function collectExtensionFlagDefinitionsForCommand(registrations, commandPath) {
353
368
  .filter((entry) => normalizeExtensionCommandPath(entry.target_command) === normalizedCommandPath)
354
369
  .flatMap((entry) => entry.flags);
355
370
  }
371
+ function collectExtensionFlagDefinitionsForInvocation(registrations, commandPath, commandArgs) {
372
+ const exact = collectExtensionFlagDefinitionsForCommand(registrations, commandPath);
373
+ const pathParts = [commandPath];
374
+ let nestedMatch = [];
375
+ for (const arg of commandArgs) {
376
+ if (arg.startsWith("-")) {
377
+ break;
378
+ }
379
+ pathParts.push(arg);
380
+ const nested = collectExtensionFlagDefinitionsForCommand(registrations, pathParts.join(" "));
381
+ if (nested.length > 0) {
382
+ nestedMatch = nested;
383
+ }
384
+ }
385
+ return nestedMatch.length > 0 ? nestedMatch : exact;
386
+ }
356
387
  const RUNTIME_FIELD_COMMAND_BY_COMMAND_PATH = {
357
388
  create: "create",
358
389
  update: "update",
@@ -660,7 +691,9 @@ async function runRequiredExtensionCommand(command, options, globalOptions) {
660
691
  if (!extensionCommandResult.handled) {
661
692
  if (extensionCommandResult.warnings.length > 0) {
662
693
  const warningCode = extensionCommandResult.warnings[0];
663
- throw new PmCliError(`Command "${commandPath}" failed in extension handler (${warningCode}).`, EXIT_CODE.GENERIC_FAILURE);
694
+ const cause = extensionCommandResult.errorMessage?.trim();
695
+ const causeSuffix = cause ? ` ${cause}` : "";
696
+ throw new PmCliError(`Command "${commandPath}" failed in extension handler (${warningCode}).${causeSuffix}`, EXIT_CODE.GENERIC_FAILURE);
664
697
  }
665
698
  throw new PmCliError(`Command "${commandPath}" is provided by extensions and is not currently available.`, EXIT_CODE.NOT_FOUND);
666
699
  }
@@ -684,7 +717,7 @@ function wrapProgramActionsForExtensionHandlers(rootProgram) {
684
717
  let commandArgs = actionCommand.args.map(String);
685
718
  const activeRegistrations = getActiveExtensionRegistrations();
686
719
  const extensionFlagDefinitions = activeRegistrations
687
- ? collectExtensionFlagDefinitionsForCommand(activeRegistrations, commandPath)
720
+ ? collectExtensionFlagDefinitionsForInvocation(activeRegistrations, commandPath, commandArgs)
688
721
  : [];
689
722
  const runtimeFieldFlagDefinitions = await collectRuntimeFieldLooseFlagDefinitionsForCommand(commandPath, pmRoot);
690
723
  let commandOptions = extractCommandScopedOptions(actionCommand, commandArgs, [
@@ -816,10 +849,12 @@ async function registerDynamicExtensionCommandPaths(rootProgram, invocationArgv)
816
849
  dynamicCommand
817
850
  .allowUnknownOption(true)
818
851
  .allowExcessArguments(true)
819
- .action(async (_options, command) => {
852
+ .action(async (...actionArgs) => {
853
+ const maybeCommand = actionArgs[actionArgs.length - 1];
854
+ const command = maybeCommand instanceof Command ? maybeCommand : dynamicCommand;
820
855
  const globalOptions = getGlobalOptions(command);
821
856
  const startedAt = Date.now();
822
- const extensionFlagDefinitions = collectExtensionFlagDefinitionsForCommand(snapshot.registrations, commandPath);
857
+ const extensionFlagDefinitions = collectExtensionFlagDefinitionsForInvocation(snapshot.registrations, commandPath, command.args.map(String));
823
858
  const scopedOptions = extractCommandScopedOptions(command, command.args.map(String), extensionFlagDefinitions);
824
859
  const result = await runRequiredExtensionCommand(command, scopedOptions, globalOptions);
825
860
  await invalidateSearchCachesForMutation(globalOptions, result);
@@ -865,6 +900,7 @@ program
865
900
  })
866
901
  .option("--json", "Output JSON instead of TOON")
867
902
  .option("--quiet", "Suppress stdout output")
903
+ .option("--no-changed-fields", "Omit the changed_fields array from mutation output (keeps changed_field_count)")
868
904
  .option("--path <dir>", "Override PM path for this command")
869
905
  .option("--no-extensions", "Disable extension loading")
870
906
  .option("--no-pager", "Disable pager integration for help and long output")
@@ -908,7 +944,7 @@ program.hook("preAction", async (_thisCommand, actionCommand) => {
908
944
  setActiveExtensionServices(runtimeExtensions.services);
909
945
  setActiveExtensionRenderers(runtimeExtensions.renderers);
910
946
  setActiveExtensionRegistrations(runtimeExtensions.registrations);
911
- const extensionFlagDefinitions = collectExtensionFlagDefinitionsForCommand(runtimeExtensions.registrations, commandPath);
947
+ const extensionFlagDefinitions = collectExtensionFlagDefinitionsForInvocation(runtimeExtensions.registrations, commandPath, commandArgs);
912
948
  commandOptions = extractCommandScopedOptions(actionCommand, commandArgs, extensionFlagDefinitions);
913
949
  const parserOverride = await runActiveParserOverride({
914
950
  command: commandPath,
@@ -1113,6 +1149,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1113
1149
  listQuery: false,
1114
1150
  mutation: false,
1115
1151
  operation: false,
1152
+ targetCommandName: normalizedCommand,
1116
1153
  };
1117
1154
  }
1118
1155
  if (LIST_QUERY_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1121,6 +1158,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1121
1158
  listQuery: true,
1122
1159
  mutation: false,
1123
1160
  operation: false,
1161
+ targetCommandName: normalizedCommand,
1124
1162
  };
1125
1163
  }
1126
1164
  if (MUTATION_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1129,6 +1167,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1129
1167
  listQuery: false,
1130
1168
  mutation: true,
1131
1169
  operation: false,
1170
+ targetCommandName: normalizedCommand,
1132
1171
  };
1133
1172
  }
1134
1173
  if (OPERATION_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1137,6 +1176,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1137
1176
  listQuery: false,
1138
1177
  mutation: false,
1139
1178
  operation: true,
1179
+ targetCommandName: normalizedCommand,
1140
1180
  };
1141
1181
  }
1142
1182
  return REGISTER_ALL_CORE_COMMAND_FAMILIES;
@@ -1152,7 +1192,11 @@ async function registerCoreCommandFamilies(rootProgram, selection) {
1152
1192
  }
1153
1193
  if (selection.listQuery) {
1154
1194
  const { registerListQueryCommands } = await loadListQueryRegistrationModule();
1155
- registerListQueryCommands(rootProgram);
1195
+ const commandFilter = typeof selection.targetCommandName === "string" &&
1196
+ LIST_QUERY_COMMAND_NAMES.has(selection.targetCommandName)
1197
+ ? new Set([selection.targetCommandName])
1198
+ : undefined;
1199
+ registerListQueryCommands(rootProgram, commandFilter ? { commandFilter } : undefined);
1156
1200
  }
1157
1201
  if (selection.mutation) {
1158
1202
  const { registerMutationCommands } = await loadMutationRegistrationModule();
@@ -1199,8 +1243,8 @@ function shouldRegisterRuntimeSchemaFlags(invocationArgv) {
1199
1243
  }
1200
1244
  return RUNTIME_SCHEMA_FLAG_BOOTSTRAP_COMMANDS.has(commandName);
1201
1245
  }
1202
- const bootstrapInvocation = normalizeBootstrapInvocation(process.argv.slice(2));
1203
- async function main() {
1246
+ export async function runPmCli(rawArgv = process.argv.slice(2)) {
1247
+ const bootstrapInvocation = normalizeBootstrapInvocation(rawArgv);
1204
1248
  const invocationArgv = bootstrapInvocation.argv;
1205
1249
  const invocationProcessArgv = [process.argv[0], process.argv[1], ...invocationArgv];
1206
1250
  const isBareInvocation = invocationArgv.length === 0;
@@ -1268,14 +1312,19 @@ async function main() {
1268
1312
  const bootstrapSnapshot = await loadRuntimeExtensionSnapshot(bootstrapPmRoot);
1269
1313
  setActiveExtensionServices(bootstrapSnapshot?.services ?? { overrides: [] });
1270
1314
  }
1271
- if (error instanceof PmCliError) {
1272
- const enrichedContext = buildPmCliRecoveryContext(error.context, invocationArgv, error.message);
1273
- const classification = classifyPmCliError(error.message, enrichedContext);
1315
+ const numericExitCode = readThrownExitCode(error);
1316
+ if (error instanceof PmCliError ||
1317
+ (!isCommanderError(error) && typeof numericExitCode === "number" && Number.isFinite(numericExitCode))) {
1318
+ const errorMessage = describeUnknownError(error);
1319
+ const exitCode = error instanceof PmCliError ? error.exitCode : normalizeThrownExitCode(numericExitCode);
1320
+ const context = error instanceof PmCliError ? error.context : undefined;
1321
+ const enrichedContext = buildPmCliRecoveryContext(context, invocationArgv, errorMessage);
1322
+ const classification = classifyPmCliError(errorMessage, enrichedContext);
1274
1323
  const { errorCategory, commandResolution } = await emitTelemetryCommandError({
1275
1324
  command: attemptedCommand,
1276
1325
  errorCode: classification.code,
1277
1326
  errorMessage: classification.detail,
1278
- exitCode: error.exitCode,
1327
+ exitCode,
1279
1328
  options: {
1280
1329
  bootstrap_global_options: bootstrapGlobal,
1281
1330
  },
@@ -1286,37 +1335,37 @@ async function main() {
1286
1335
  command: attemptedCommand,
1287
1336
  error_code: classification.code,
1288
1337
  error_category: errorCategory,
1289
- exit_code: error.exitCode,
1338
+ exit_code: exitCode,
1290
1339
  error_message: classification.detail,
1291
1340
  command_resolution: commandResolution,
1292
1341
  resolution_stage: "execute",
1293
1342
  source_context: activeTelemetryCommandContext?.source_context,
1294
1343
  });
1295
- sentryFinishCommandSpan(false, error.message, {
1344
+ sentryFinishCommandSpan(false, errorMessage, {
1296
1345
  error_code: classification.code,
1297
1346
  error_category: errorCategory,
1298
- exit_code: error.exitCode,
1347
+ exit_code: exitCode,
1299
1348
  command_resolution: commandResolution,
1300
1349
  resolution_stage: "execute",
1301
1350
  });
1302
1351
  await runAndClearAfterCommandHooks({
1303
1352
  ok: false,
1304
- error: error.message,
1305
- exit_code: error.exitCode,
1353
+ error: errorMessage,
1354
+ exit_code: exitCode,
1306
1355
  error_code: classification.code,
1307
1356
  error_category: errorCategory,
1308
1357
  command_resolution: commandResolution,
1309
1358
  resolution_stage: "execute",
1310
1359
  });
1311
- sentryCaptureCliError(error);
1360
+ sentryCaptureCliError(wrapThrownErrorForSentry(error, errorMessage));
1312
1361
  if (jsonErrors) {
1313
- printError(JSON.stringify(formatPmCliErrorForJson(error.message, error.exitCode, enrichedContext), null, 2));
1362
+ printError(JSON.stringify(formatPmCliErrorForJson(errorMessage, exitCode, enrichedContext), null, 2));
1314
1363
  }
1315
1364
  else {
1316
- printError(formatPmCliErrorForDisplay(error.message, enrichedContext));
1365
+ printError(formatPmCliErrorForDisplay(errorMessage, enrichedContext));
1317
1366
  }
1318
1367
  await sentryFlush();
1319
- process.exitCode = error.exitCode;
1368
+ process.exitCode = exitCode;
1320
1369
  return;
1321
1370
  }
1322
1371
  if (typeof error === "object" && error !== null && "code" in error) {
@@ -1521,6 +1570,11 @@ async function main() {
1521
1570
  process.exitCode = EXIT_CODE.GENERIC_FAILURE;
1522
1571
  }
1523
1572
  }
1524
- void main();
1573
+ export const _testOnly = {
1574
+ isCommanderError,
1575
+ normalizeThrownExitCode,
1576
+ readThrownExitCode,
1577
+ wrapThrownErrorForSentry,
1578
+ };
1525
1579
  //# sourceMappingURL=main.js.map
1526
- //# debugId=fa3533db-abe8-515b-9879-5faf8c891e25
1580
+ //# debugId=253a39d8-edf5-592c-8b3e-ed509a8a6f11