@unbrained/pm-cli 2026.5.24 → 2026.5.28

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 (246) hide show
  1. package/CHANGELOG.md +953 -522
  2. package/README.md +2 -10
  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 +134 -11
  7. package/dist/cli/commander-usage.js.map +1 -1
  8. package/dist/cli/commands/append.js +4 -3
  9. package/dist/cli/commands/append.js.map +1 -1
  10. package/dist/cli/commands/claim.js +5 -4
  11. package/dist/cli/commands/claim.js.map +1 -1
  12. package/dist/cli/commands/close.d.ts +3 -0
  13. package/dist/cli/commands/close.js +26 -3
  14. package/dist/cli/commands/close.js.map +1 -1
  15. package/dist/cli/commands/completion.d.ts +2 -2
  16. package/dist/cli/commands/completion.js +109 -56
  17. package/dist/cli/commands/completion.js.map +1 -1
  18. package/dist/cli/commands/config.d.ts +1 -1
  19. package/dist/cli/commands/config.js +82 -4
  20. package/dist/cli/commands/config.js.map +1 -1
  21. package/dist/cli/commands/create.js +7 -272
  22. package/dist/cli/commands/create.js.map +1 -1
  23. package/dist/cli/commands/delete.js +4 -3
  24. package/dist/cli/commands/delete.js.map +1 -1
  25. package/dist/cli/commands/docs.d.ts +1 -12
  26. package/dist/cli/commands/docs.js +8 -312
  27. package/dist/cli/commands/docs.js.map +1 -1
  28. package/dist/cli/commands/extension/bundled-catalog.d.ts +14 -0
  29. package/dist/cli/commands/extension/bundled-catalog.js +268 -0
  30. package/dist/cli/commands/extension/bundled-catalog.js.map +1 -0
  31. package/dist/cli/commands/extension/doctor.d.ts +31 -0
  32. package/dist/cli/commands/extension/doctor.js +345 -0
  33. package/dist/cli/commands/extension/doctor.js.map +1 -0
  34. package/dist/cli/commands/extension/install-sources.d.ts +37 -0
  35. package/dist/cli/commands/extension/install-sources.js +384 -0
  36. package/dist/cli/commands/extension/install-sources.js.map +1 -0
  37. package/dist/cli/commands/extension/managed-state.d.ts +48 -0
  38. package/dist/cli/commands/extension/managed-state.js +172 -0
  39. package/dist/cli/commands/extension/managed-state.js.map +1 -0
  40. package/dist/cli/commands/extension/scaffold.d.ts +14 -0
  41. package/dist/cli/commands/extension/scaffold.js +202 -0
  42. package/dist/cli/commands/extension/scaffold.js.map +1 -0
  43. package/dist/cli/commands/extension/shared.d.ts +14 -0
  44. package/dist/cli/commands/extension/shared.js +106 -0
  45. package/dist/cli/commands/extension/shared.js.map +1 -0
  46. package/dist/cli/commands/extension.d.ts +36 -68
  47. package/dist/cli/commands/extension.js +143 -1422
  48. package/dist/cli/commands/extension.js.map +1 -1
  49. package/dist/cli/commands/files.d.ts +1 -12
  50. package/dist/cli/commands/files.js +11 -308
  51. package/dist/cli/commands/files.js.map +1 -1
  52. package/dist/cli/commands/get.js +4 -3
  53. package/dist/cli/commands/get.js.map +1 -1
  54. package/dist/cli/commands/health.js +17 -3
  55. package/dist/cli/commands/health.js.map +1 -1
  56. package/dist/cli/commands/history-redact.js +23 -18
  57. package/dist/cli/commands/history-redact.js.map +1 -1
  58. package/dist/cli/commands/history-repair.js +24 -18
  59. package/dist/cli/commands/history-repair.js.map +1 -1
  60. package/dist/cli/commands/legacy-none-tokens.d.ts +3 -0
  61. package/dist/cli/commands/legacy-none-tokens.js +39 -0
  62. package/dist/cli/commands/legacy-none-tokens.js.map +1 -0
  63. package/dist/cli/commands/linked-artifacts.d.ts +96 -0
  64. package/dist/cli/commands/linked-artifacts.js +335 -0
  65. package/dist/cli/commands/linked-artifacts.js.map +1 -0
  66. package/dist/cli/commands/linked-test-parsers.d.ts +28 -0
  67. package/dist/cli/commands/linked-test-parsers.js +192 -0
  68. package/dist/cli/commands/linked-test-parsers.js.map +1 -0
  69. package/dist/cli/commands/list.js +19 -5
  70. package/dist/cli/commands/list.js.map +1 -1
  71. package/dist/cli/commands/normalize.js +4 -3
  72. package/dist/cli/commands/normalize.js.map +1 -1
  73. package/dist/cli/commands/plan.d.ts +5 -0
  74. package/dist/cli/commands/plan.js +56 -8
  75. package/dist/cli/commands/plan.js.map +1 -1
  76. package/dist/cli/commands/recurrence-parsers.d.ts +26 -0
  77. package/dist/cli/commands/recurrence-parsers.js +98 -0
  78. package/dist/cli/commands/recurrence-parsers.js.map +1 -0
  79. package/dist/cli/commands/restore.js +19 -8
  80. package/dist/cli/commands/restore.js.map +1 -1
  81. package/dist/cli/commands/search.js +5 -8
  82. package/dist/cli/commands/search.js.map +1 -1
  83. package/dist/cli/commands/test/linked-command-detection.d.ts +37 -0
  84. package/dist/cli/commands/test/linked-command-detection.js +200 -0
  85. package/dist/cli/commands/test/linked-command-detection.js.map +1 -0
  86. package/dist/cli/commands/test.d.ts +1 -2
  87. package/dist/cli/commands/test.js +8 -350
  88. package/dist/cli/commands/test.js.map +1 -1
  89. package/dist/cli/commands/update-many.js +4 -3
  90. package/dist/cli/commands/update-many.js.map +1 -1
  91. package/dist/cli/commands/update.js +83 -356
  92. package/dist/cli/commands/update.js.map +1 -1
  93. package/dist/cli/commands/validate.js +32 -12
  94. package/dist/cli/commands/validate.js.map +1 -1
  95. package/dist/cli/error-guidance.d.ts +1 -0
  96. package/dist/cli/error-guidance.js +6 -2
  97. package/dist/cli/error-guidance.js.map +1 -1
  98. package/dist/cli/main.d.ts +11 -0
  99. package/dist/cli/main.js +76 -28
  100. package/dist/cli/main.js.map +1 -1
  101. package/dist/cli/register-list-query.d.ts +4 -1
  102. package/dist/cli/register-list-query.js +242 -203
  103. package/dist/cli/register-list-query.js.map +1 -1
  104. package/dist/cli/register-mutation.js +73 -11
  105. package/dist/cli/register-mutation.js.map +1 -1
  106. package/dist/cli/register-operations.js +3 -3
  107. package/dist/cli/register-operations.js.map +1 -1
  108. package/dist/cli/register-setup.js +12 -7
  109. package/dist/cli/register-setup.js.map +1 -1
  110. package/dist/cli/registration-helpers.js +3 -2
  111. package/dist/cli/registration-helpers.js.map +1 -1
  112. package/dist/cli.js +4 -3
  113. package/dist/cli.js.map +1 -1
  114. package/dist/core/config/positional-value.d.ts +44 -0
  115. package/dist/core/config/positional-value.js +109 -0
  116. package/dist/core/config/positional-value.js.map +1 -0
  117. package/dist/core/extensions/extension-capability-aliases.d.ts +14 -0
  118. package/dist/core/extensions/extension-capability-aliases.js +159 -0
  119. package/dist/core/extensions/extension-capability-aliases.js.map +1 -0
  120. package/dist/core/extensions/extension-hook-runtime.d.ts +13 -0
  121. package/dist/core/extensions/extension-hook-runtime.js +414 -0
  122. package/dist/core/extensions/extension-hook-runtime.js.map +1 -0
  123. package/dist/core/extensions/extension-policy.d.ts +69 -0
  124. package/dist/core/extensions/extension-policy.js +481 -0
  125. package/dist/core/extensions/extension-policy.js.map +1 -0
  126. package/dist/core/extensions/extension-registries.d.ts +8 -0
  127. package/dist/core/extensions/extension-registries.js +52 -0
  128. package/dist/core/extensions/extension-registries.js.map +1 -0
  129. package/dist/core/extensions/extension-runtime-helpers.d.ts +6 -0
  130. package/dist/core/extensions/extension-runtime-helpers.js +29 -0
  131. package/dist/core/extensions/extension-runtime-helpers.js.map +1 -0
  132. package/dist/core/extensions/extension-types.d.ts +13 -39
  133. package/dist/core/extensions/extension-types.js +34 -2
  134. package/dist/core/extensions/extension-types.js.map +1 -1
  135. package/dist/core/extensions/index.d.ts +7 -0
  136. package/dist/core/extensions/index.js +11 -2
  137. package/dist/core/extensions/index.js.map +1 -1
  138. package/dist/core/extensions/loader.d.ts +4 -22
  139. package/dist/core/extensions/loader.js +22 -1139
  140. package/dist/core/extensions/loader.js.map +1 -1
  141. package/dist/core/history/drift-scan.d.ts +11 -0
  142. package/dist/core/history/drift-scan.js +114 -32
  143. package/dist/core/history/drift-scan.js.map +1 -1
  144. package/dist/core/history/history-rewrite.d.ts +43 -0
  145. package/dist/core/history/history-rewrite.js +48 -0
  146. package/dist/core/history/history-rewrite.js.map +1 -0
  147. package/dist/core/history/history.js +5 -4
  148. package/dist/core/history/history.js.map +1 -1
  149. package/dist/core/history/replay.js +4 -3
  150. package/dist/core/history/replay.js.map +1 -1
  151. package/dist/core/item/item-record.d.ts +19 -0
  152. package/dist/core/item/item-record.js +24 -0
  153. package/dist/core/item/item-record.js.map +1 -0
  154. package/dist/core/output/mutation-projection.d.ts +31 -0
  155. package/dist/core/output/mutation-projection.js +103 -0
  156. package/dist/core/output/mutation-projection.js.map +1 -0
  157. package/dist/core/output/output.d.ts +2 -0
  158. package/dist/core/output/output.js +5 -3
  159. package/dist/core/output/output.js.map +1 -1
  160. package/dist/core/schema/runtime-schema.js +8 -38
  161. package/dist/core/schema/runtime-schema.js.map +1 -1
  162. package/dist/core/search/vector-stores.js +46 -9
  163. package/dist/core/search/vector-stores.js.map +1 -1
  164. package/dist/core/sentry/helpers.d.ts +1 -1
  165. package/dist/core/sentry/helpers.js +20 -3
  166. package/dist/core/sentry/helpers.js.map +1 -1
  167. package/dist/core/shared/command-types.d.ts +1 -0
  168. package/dist/core/shared/command-types.js +2 -2
  169. package/dist/core/shared/command-types.js.map +1 -1
  170. package/dist/core/shared/constants.d.ts +10 -1
  171. package/dist/core/shared/constants.js +56 -58
  172. package/dist/core/shared/constants.js.map +1 -1
  173. package/dist/core/shared/levenshtein.js +23 -7
  174. package/dist/core/shared/levenshtein.js.map +1 -1
  175. package/dist/core/shared/primitives.d.ts +23 -0
  176. package/dist/core/shared/primitives.js +39 -2
  177. package/dist/core/shared/primitives.js.map +1 -1
  178. package/dist/core/store/front-matter-cache.d.ts +16 -2
  179. package/dist/core/store/front-matter-cache.js +99 -33
  180. package/dist/core/store/front-matter-cache.js.map +1 -1
  181. package/dist/core/store/item-store.js +8 -73
  182. package/dist/core/store/item-store.js.map +1 -1
  183. package/dist/mcp/server.js +76 -28
  184. package/dist/mcp/server.js.map +1 -1
  185. package/dist/sdk/cli-contracts/enum-contracts.d.ts +20 -0
  186. package/dist/sdk/cli-contracts/enum-contracts.js +156 -0
  187. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -0
  188. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +14 -0
  189. package/dist/sdk/cli-contracts/tool-option-contracts.js +243 -0
  190. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -0
  191. package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +11 -0
  192. package/dist/sdk/cli-contracts/tool-parameter-tables.js +901 -0
  193. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -0
  194. package/dist/sdk/cli-contracts.d.ts +11 -33
  195. package/dist/sdk/cli-contracts.js +30 -1356
  196. package/dist/sdk/cli-contracts.js.map +1 -1
  197. package/dist/sdk/package-import-adapters.d.ts +74 -0
  198. package/dist/sdk/package-import-adapters.js +186 -0
  199. package/dist/sdk/package-import-adapters.js.map +1 -0
  200. package/dist/sdk/package-runtime-options.d.ts +26 -0
  201. package/dist/sdk/package-runtime-options.js +71 -0
  202. package/dist/sdk/package-runtime-options.js.map +1 -0
  203. package/dist/sdk/runtime.d.ts +2 -0
  204. package/dist/sdk/runtime.js +4 -2
  205. package/dist/sdk/runtime.js.map +1 -1
  206. package/docs/AGENT_GUIDE.md +6 -10
  207. package/docs/CLAUDE_CODE_PLUGIN.md +5 -28
  208. package/docs/CODEX_PLUGIN.md +5 -5
  209. package/docs/COMMANDS.md +19 -3
  210. package/docs/CONFIGURATION.md +15 -0
  211. package/docs/EXTENSIONS.md +4 -63
  212. package/docs/RELEASING.md +4 -4
  213. package/marketplace.json +7 -3
  214. package/package.json +9 -6
  215. package/packages/pm-beads/extensions/beads/index.js +2 -49
  216. package/packages/pm-beads/extensions/beads/index.ts +2 -54
  217. package/packages/pm-beads/extensions/beads/runtime-loader.js +86 -0
  218. package/packages/pm-beads/extensions/beads/runtime-loader.ts +88 -0
  219. package/packages/pm-beads/extensions/beads/runtime.js +26 -115
  220. package/packages/pm-beads/extensions/beads/runtime.ts +33 -132
  221. package/packages/pm-calendar/extensions/calendar/index.js +47 -2
  222. package/packages/pm-calendar/extensions/calendar/index.ts +52 -2
  223. package/packages/pm-calendar/extensions/calendar/runtime.js +1 -0
  224. package/packages/pm-calendar/extensions/calendar/runtime.ts +1 -0
  225. package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +14 -41
  226. package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +25 -41
  227. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +10 -50
  228. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +17 -50
  229. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +8 -40
  230. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +10 -40
  231. package/packages/pm-search-advanced/extensions/search-advanced/index.js +1 -1
  232. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +4 -37
  233. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +6 -37
  234. package/packages/pm-todos/extensions/todos/index.js +3 -50
  235. package/packages/pm-todos/extensions/todos/index.ts +3 -55
  236. package/packages/pm-todos/extensions/todos/runtime-loader.js +86 -0
  237. package/packages/pm-todos/extensions/todos/runtime-loader.ts +88 -0
  238. package/packages/pm-todos/extensions/todos/runtime.js +24 -117
  239. package/packages/pm-todos/extensions/todos/runtime.ts +32 -129
  240. package/plugins/pm-claude/README.md +2 -2
  241. package/plugins/pm-claude/commands/pm-planner.md +1 -15
  242. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +5 -2
  243. package/plugins/pm-claude/skills/pm-planner/SKILL.md +3 -21
  244. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +15 -6
  245. package/plugins/pm-codex/skills/pm-native/SKILL.md +1 -13
  246. package/PRD.md +0 -1734
@@ -1 +1 @@
1
- {"version":3,"file":"error-guidance.js","sources":["cli/error-guidance.ts"],"sourceRoot":"/","sourcesContent":["import type { PmCliErrorContext, PmCliErrorRecoveryPayload } from \"../core/shared/errors.js\";\nimport { renderPmCommand } from \"./argv-utils.js\";\n\ninterface GuidanceMessage {\n code: string;\n type: string;\n title: string;\n happened: string;\n required: string;\n why?: string;\n examples?: string[];\n nextSteps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface JsonErrorEnvelope {\n type: string;\n code: string;\n title: string;\n detail: string;\n required: string;\n exit_code: number;\n why?: string;\n examples?: string[];\n next_steps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface ErrorClassification {\n type: string;\n code: string;\n title: string;\n detail: string;\n required: string;\n why?: string;\n examples?: string[];\n next_steps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface CommanderGuidanceContext {\n unknownCommandExamples?: string[];\n unknownCommandNextSteps?: string[];\n attemptedCommand?: string;\n normalizedInvocationArgs?: string[];\n providedOptionFlags?: string[];\n unknownOptionSuggestions?: string[];\n suggestedRetryCommand?: string;\n}\n\nfunction errorType(code: string): string {\n return `urn:pm-cli:error:${code}`;\n}\n\nfunction makeGuidanceMessage(params: Omit<GuidanceMessage, \"type\">): GuidanceMessage {\n return {\n ...params,\n type: errorType(params.code),\n };\n}\n\ninterface PackageCommandHint {\n /** Published package name shown to the user (e.g. @unbrained/pm-guide-shell). */\n packageName: string;\n /** Exact CLI command that installs the bundled package by its install alias. */\n installCommand: string;\n}\n\n// Catalog of command tokens that are provided by optional first-party packages\n// rather than core. When an unknown-command error names one of these, we surface\n// a concrete install hint so agents/humans aren't left guessing. The install\n// command uses the bundled alias accepted by `pm install <alias>` (see\n// packages/pm-*/package.json `pm.aliases` and extension.ts install_command).\nconst KNOWN_PACKAGE_COMMAND_HINTS: Readonly<Record<string, PackageCommandHint>> = {\n guide: { packageName: \"@unbrained/pm-guide-shell\", installCommand: \"pm install guide-shell\" },\n templates: { packageName: \"@unbrained/pm-templates\", installCommand: \"pm install templates\" },\n calendar: { packageName: \"@unbrained/pm-calendar\", installCommand: \"pm install calendar\" },\n cal: { packageName: \"@unbrained/pm-calendar\", installCommand: \"pm install calendar\" },\n};\n\nfunction resolveKnownPackageCommandHint(commandToken: string): PackageCommandHint | undefined {\n const primary = commandToken.trim().split(/\\s+/)[0]?.toLowerCase();\n if (!primary) {\n return undefined;\n }\n return KNOWN_PACKAGE_COMMAND_HINTS[primary];\n}\n\nfunction renderList(title: string, entries: string[]): string[] {\n if (entries.length === 0) {\n return [];\n }\n return [title, ...entries.map((entry) => ` - ${entry}`)];\n}\n\nfunction normalizeRecoveryPayload(payload: PmCliErrorRecoveryPayload | undefined): PmCliErrorRecoveryPayload | undefined {\n if (!payload || typeof payload !== \"object\") {\n return undefined;\n }\n const normalized: PmCliErrorRecoveryPayload = {};\n if (typeof payload.attempted_command === \"string\" && payload.attempted_command.trim().length > 0) {\n normalized.attempted_command = payload.attempted_command.trim();\n }\n if (Array.isArray(payload.normalized_args)) {\n const args = payload.normalized_args.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (args.length > 0) {\n normalized.normalized_args = args;\n }\n }\n if (Array.isArray(payload.provided_fields)) {\n const fields = payload.provided_fields.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (fields.length > 0) {\n normalized.provided_fields = fields;\n }\n }\n if (Array.isArray(payload.missing)) {\n const missing = payload.missing.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (missing.length > 0) {\n normalized.missing = missing;\n }\n }\n if (typeof payload.suggested_retry === \"string\" && payload.suggested_retry.trim().length > 0) {\n normalized.suggested_retry = payload.suggested_retry.trim();\n }\n return Object.keys(normalized).length > 0 ? normalized : undefined;\n}\n\nfunction renderRecoveryBundle(recovery: PmCliErrorRecoveryPayload | undefined): string[] {\n const normalized = normalizeRecoveryPayload(recovery);\n if (!normalized) {\n return [];\n }\n const lines = [\"Recovery bundle:\"];\n if (normalized.attempted_command) {\n lines.push(` attempted_command: ${normalized.attempted_command}`);\n }\n if (normalized.normalized_args && normalized.normalized_args.length > 0) {\n lines.push(` normalized_args: ${normalized.normalized_args.join(\" \")}`);\n }\n if (normalized.provided_fields && normalized.provided_fields.length > 0) {\n lines.push(` provided_fields: ${normalized.provided_fields.join(\", \")}`);\n }\n if (normalized.missing && normalized.missing.length > 0) {\n lines.push(` missing: ${normalized.missing.join(\", \")}`);\n }\n if (normalized.suggested_retry) {\n lines.push(` suggested_retry: ${normalized.suggested_retry}`);\n }\n return lines;\n}\n\nexport function renderGuidanceMessage(message: GuidanceMessage): string {\n const lines: string[] = [\n `Error: ${message.title}`,\n \"\",\n \"What happened:\",\n ` ${message.happened}`,\n \"\",\n \"What is required:\",\n ` ${message.required}`,\n ];\n if (message.why) {\n lines.push(\"\", \"Why:\");\n lines.push(` ${message.why}`);\n }\n if (message.examples && message.examples.length > 0) {\n lines.push(\"\");\n lines.push(...renderList(\"Examples:\", message.examples));\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n lines.push(\"\");\n lines.push(...renderList(\"Next steps:\", message.nextSteps));\n }\n const recoveryLines = renderRecoveryBundle(message.recovery);\n if (recoveryLines.length > 0) {\n lines.push(\"\");\n lines.push(...recoveryLines);\n }\n return lines.join(\"\\n\");\n}\n\nfunction guidanceToJsonEnvelope(message: GuidanceMessage, exitCode: number): JsonErrorEnvelope {\n const payload: JsonErrorEnvelope = {\n type: message.type,\n code: message.code,\n title: message.title,\n detail: message.happened,\n required: message.required,\n exit_code: exitCode,\n };\n if (message.why) {\n payload.why = message.why;\n }\n if (message.examples && message.examples.length > 0) {\n payload.examples = message.examples;\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n payload.next_steps = message.nextSteps;\n }\n if (message.recovery) {\n payload.recovery = message.recovery;\n }\n return payload;\n}\n\nfunction guidanceToClassification(message: GuidanceMessage): ErrorClassification {\n const payload: ErrorClassification = {\n type: message.type,\n code: message.code,\n title: message.title,\n detail: message.happened,\n required: message.required,\n };\n if (message.why) {\n payload.why = message.why;\n }\n if (message.examples && message.examples.length > 0) {\n payload.examples = message.examples;\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n payload.next_steps = message.nextSteps;\n }\n if (message.recovery) {\n payload.recovery = message.recovery;\n }\n return payload;\n}\n\nfunction normalizeMessage(message: string): string {\n return message.replace(/\\(outputHelp\\)/g, \"\").trim();\n}\n\nfunction normalizeContextList(values: string[] | undefined): string[] | undefined {\n if (!Array.isArray(values)) {\n return undefined;\n }\n const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction dedupeStrings(values: string[]): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n result.push(value);\n }\n return result;\n}\n\nfunction inferCommandNameFromRecovery(recovery: PmCliErrorRecoveryPayload | undefined): string | undefined {\n const args = recovery?.normalized_args;\n if (!Array.isArray(args) || args.length === 0) {\n return undefined;\n }\n const firstCommandArg = args.find((arg) => arg.trim().length > 0 && !arg.startsWith(\"-\"));\n return firstCommandArg?.trim();\n}\n\nfunction inferAllowedValuesFromMessage(message: string): string[] {\n const match = message.match(/\\bmust be one of:?\\s+([A-Za-z0-9_.|,\\- ]+)/i);\n if (!match) {\n return [];\n }\n return match[1]\n .split(/[|,]/)\n .map((entry) => entry.trim())\n .filter((entry) => /^[A-Za-z0-9_.-]+$/.test(entry));\n}\n\nfunction buildAllowedValueRetryCommand(recovery: PmCliErrorRecoveryPayload | undefined, allowedValues: string[]): string | undefined {\n const args = recovery?.normalized_args;\n const fields = recovery?.provided_fields;\n const replacement = allowedValues[0];\n if (!Array.isArray(args) || !Array.isArray(fields) || !replacement) {\n return undefined;\n }\n for (const field of fields) {\n const index = args.findIndex((arg) => arg === field);\n if (index >= 0 && index < args.length - 1 && !args[index + 1]?.startsWith(\"-\")) {\n const nextArgs = [...args];\n nextArgs[index + 1] = replacement;\n return renderPmCommand(nextArgs);\n }\n }\n return undefined;\n}\n\nfunction buildFallbackTitleFromMessage(message: string): string | undefined {\n const firstLine = message.split(/\\r?\\n/)[0]?.trim() ?? \"\";\n if (firstLine.length === 0) {\n return undefined;\n }\n if (firstLine.length <= 120) {\n return firstLine;\n }\n return `${firstLine.slice(0, 117)}...`;\n}\n\nfunction applyPmCliErrorContext(\n guidance: GuidanceMessage,\n rawMessage: string,\n context: PmCliErrorContext | undefined,\n): GuidanceMessage {\n if (!context) {\n return guidance;\n }\n const normalizedRawMessage = normalizeMessage(rawMessage);\n const code = typeof context.code === \"string\" && context.code.trim().length > 0 ? context.code.trim() : guidance.code;\n const type = typeof context.type === \"string\" && context.type.trim().length > 0 ? context.type.trim() : errorType(code);\n const examples = normalizeContextList(context.examples) ?? guidance.examples;\n const nextSteps = normalizeContextList(context.nextSteps) ?? guidance.nextSteps;\n const fallbackTitle = guidance.code === \"command_failed\" && context.code ? buildFallbackTitleFromMessage(normalizedRawMessage) : undefined;\n const recovery = normalizeRecoveryPayload(context.recovery) ?? guidance.recovery;\n return {\n ...guidance,\n code,\n type,\n title: fallbackTitle ?? guidance.title,\n happened: normalizedRawMessage.length > 0 ? normalizedRawMessage : guidance.happened,\n required: typeof context.required === \"string\" && context.required.trim().length > 0 ? context.required.trim() : guidance.required,\n why: typeof context.why === \"string\" && context.why.trim().length > 0 ? context.why.trim() : guidance.why,\n examples,\n nextSteps,\n recovery,\n };\n}\n\nfunction buildPmCliErrorGuidance(rawMessage: string, context?: PmCliErrorContext): GuidanceMessage {\n const message = normalizeMessage(rawMessage);\n\n const trackerNotInitialized = message.match(/^Tracker is not initialized at (.+)\\. Run pm init first\\.$/);\n if (trackerNotInitialized) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"tracker_not_initialized\",\n title: \"Tracker is not initialized\",\n happened: `pm data path does not contain initialized tracker metadata (${trackerNotInitialized[1]}).`,\n required: \"Initialize tracker storage before running this command.\",\n why: \"Most commands require settings and tracker directories created by pm init.\",\n examples: [\"pm init\", \"pm init acme\"],\n nextSteps: ['Run \"pm init\", then rerun your original command.'],\n }),\n rawMessage,\n context,\n );\n }\n\n const itemNotFound = message.match(/^Item ([^ ]+) not found$/);\n if (itemNotFound) {\n const badId = itemNotFound[1];\n const isPlaceholder = /^(undefined|null|<.*>|\\[.*\\]|{.*}|)$/.test(badId);\n const happened = isPlaceholder\n ? `The item ID \"${badId}\" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`\n : `No item with id \"${badId}\" exists in the active tracker scope.`;\n const nextSteps = isPlaceholder\n ? [\n \"Check that the variable holding the item ID is defined before passing it to pm.\",\n 'Use \"pm list-open --limit 20\" to find valid IDs.',\n ]\n : [\"Confirm the active --path/PM_PATH scope, then retry with a valid id.\"];\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"item_not_found\",\n title: \"Item ID not found\",\n happened,\n required: \"Use an existing item ID from current tracker data.\",\n why: \"Mutation and read commands operate only on known IDs.\",\n examples: ['pm list-open --limit 20', 'pm search \"<keyword>\" --limit 10'],\n nextSteps,\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.includes(\"is assigned to\") && message.includes(\"Use --force to override\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"ownership_conflict\",\n title: \"Ownership conflict\",\n happened: message,\n required:\n \"Run as assigned owner, use audit flags for safe non-owner updates, or use --force only for approved override scenarios.\",\n why: \"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.\",\n examples: [\n 'pm update pm-a1b2 --allow-audit-update --description \"...\" --author \"audit-agent\"',\n 'pm update pm-a1b2 --allow-audit-dep-update --dep \"...\" --author \"audit-agent\"',\n 'pm comments pm-a1b2 \"...\" --allow-audit-comment --author \"audit-agent\"',\n 'pm claim pm-a1b2 --author \"codex-agent\"',\n 'pm release pm-a1b2 --allow-audit-release --author \"reviewer\"',\n 'pm update pm-a1b2 --status in_progress --force',\n ],\n nextSteps: [\n \"Use --allow-audit-update for metadata-only non-owner updates (excludes lifecycle/ownership fields).\",\n \"Use --allow-audit-dep-update for dependency-only non-owner additions.\",\n \"Use --allow-audit-comment on comments/notes/learnings for append-only audit entries.\",\n \"Use --force for PM audits and systematic metadata updates performed by leads/maintainers.\",\n \"Use --force when correcting known stale metadata after coordinating ownership changes.\",\n 'For non-terminal reassignment, prefer \"pm claim <ID> --author <you>\" before running other mutations.',\n 'For assignee handoff release workflows, prefer \"pm release <ID> --allow-audit-release --author <you>\" before using --force.',\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.includes(\"is locked\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"lock_conflict\",\n title: \"Lock conflict\",\n happened: message,\n required: \"Wait for lock release, or use --force where supported if lock is stale and safe to override.\",\n why: \"Locking protects item files from concurrent write races.\",\n examples: ['pm update pm-a1b2 --status in_progress --force --author \"codex-agent\"'],\n }),\n rawMessage,\n context,\n );\n }\n\n const missingRequiredOption = message.match(/^Missing required option /);\n const missingRequiredOptions = message.match(/^Missing required options /);\n if (missingRequiredOption || missingRequiredOptions) {\n const plural = Boolean(missingRequiredOptions);\n const missingOptionFlag = !plural ? message.replace(/^Missing required option\\s+/, \"\").trim() : null;\n const missingOptionRequired = missingOptionFlag\n ? `Pass ${missingOptionFlag} with a valid value before running the command.`\n : \"Provide the required option for this command invocation.\";\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"missing_required_option\",\n title: plural ? \"Missing required options\" : missingOptionFlag ? `Missing required option ${missingOptionFlag}` : \"Missing required option\",\n happened: message,\n required: plural\n ? \"Provide every required option for this command invocation.\"\n : missingOptionRequired,\n why: \"Required options define command intent and enforce deterministic write contracts.\",\n examples: [\n 'pm create --title \"Task title\" --description \"Task details\" --type Task --create-mode progressive',\n 'pm create --title \"Task title\" --description \"Task details\" --type Task --status open --priority 1 --message \"Create task\" --dep \"id=pm-epic01,kind=parent,author=codex-agent,created_at=now\" --comment \"author=codex-agent,created_at=now,text=Why this task exists.\" --note \"author=codex-agent,created_at=now,text=Initial implementation note.\" --learning \"author=codex-agent,created_at=now,text=Durable lesson placeholder.\" --file \"path=src/example.ts,scope=project\" --test \"command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240\" --doc \"path=README.md,scope=project\"',\n ],\n nextSteps: [\n 'Run \"pm <command> --help\" to view required and recommended flags.',\n \"For staged triage without placeholder linkage values, use --create-mode progressive.\",\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.startsWith(\"No update flags provided\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"no_update_fields\",\n title: \"No update fields supplied\",\n happened: \"The update command was called without any field-changing flags.\",\n required:\n \"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.\",\n why: \"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.\",\n examples: [\n 'pm update pm-a1b2 --status in_progress --message \"Start implementation\"',\n 'pm update pm-a1b2 --description \"Clarified implementation scope\" --message \"Clarify task intent\"',\n 'pm append pm-a1b2 --body \"Detailed progress notes\" --message \"Append progress notes\"',\n ],\n nextSteps: [\n \"Choose the item field you intend to change, then pair that change with --message for history context.\",\n \"Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context.\",\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.startsWith(\"Invalid \") || message.includes(\" must be \") || message.includes(\" requires \")) {\n const recovery = normalizeRecoveryPayload(context?.recovery);\n const commandName = inferCommandNameFromRecovery(recovery);\n const helpExample = commandName ? `pm ${commandName} --help` : \"pm <command> --help\";\n const allowedValues = inferAllowedValuesFromMessage(message);\n const retryExample = buildAllowedValueRetryCommand(recovery, allowedValues);\n const examples = retryExample ? [retryExample, helpExample] : [helpExample, \"pm contracts --command <command> --flags-only --json\"];\n const nextSteps = allowedValues.length > 0\n ? [`Allowed values: ${allowedValues.join(\"|\")}`, `Run \"${helpExample}\" to confirm command-specific constraints.`]\n : [\"Check allowed values in command help, then rerun with corrected input.\"];\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"invalid_argument_value\",\n title: \"Invalid argument value\",\n happened: message,\n required: \"Use values that match documented command constraints.\",\n why: \"Validation protects data consistency and deterministic behavior across commands.\",\n examples,\n nextSteps,\n }),\n rawMessage,\n context,\n );\n }\n\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"command_failed\",\n title: \"Command failed\",\n happened: message,\n required: \"Adjust command input or tracker state and retry.\",\n why: \"pm enforces explicit, deterministic contracts for data and command semantics.\",\n examples: [\"pm --help\", \"pm <command> --help\"],\n }),\n rawMessage,\n context,\n );\n}\n\nfunction commandExampleForRequiredOption(commandName: string | undefined, optionFlag: string, allowedTypes: string): string[] {\n if (commandName === \"create\" && optionFlag.startsWith(\"--type\")) {\n const firstAllowed = allowedTypes.split(\"|\")[0] || \"Task\";\n return [\n `pm create --title \"Example title\" --description \"Example description\" --type ${firstAllowed} --status open --priority 1 --message \"Create item\" --create-mode progressive`,\n ];\n }\n if (commandName === \"update\") {\n return ['pm update pm-a1b2 --status in_progress --message \"Start implementation\"'];\n }\n return [`pm ${commandName ?? \"<command>\"} --help`];\n}\n\nfunction normalizeRequiredOptionLabel(rawValue: string): string {\n const normalized = rawValue.trim();\n const firstLongFlag = normalized.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0];\n return firstLongFlag ?? normalized;\n}\n\nfunction renderPmCommandFromArgs(argv: string[] | undefined): string | undefined {\n if (!Array.isArray(argv) || argv.length === 0) {\n return undefined;\n }\n return renderPmCommand(argv);\n}\n\nfunction normalizeOptionFlags(values: string[] | undefined): string[] | undefined {\n if (!Array.isArray(values)) {\n return undefined;\n }\n const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction buildCommanderRecoveryPayload(\n context: CommanderGuidanceContext | undefined,\n overrides: Partial<PmCliErrorRecoveryPayload> = {},\n): PmCliErrorRecoveryPayload | undefined {\n const providedFields = normalizeOptionFlags(context?.providedOptionFlags);\n const normalizedArgs =\n Array.isArray(context?.normalizedInvocationArgs) && context?.normalizedInvocationArgs.length > 0\n ? context.normalizedInvocationArgs\n : undefined;\n const attemptedCommand = typeof context?.attemptedCommand === \"string\" ? context.attemptedCommand : renderPmCommandFromArgs(normalizedArgs);\n const retryCommand = typeof context?.suggestedRetryCommand === \"string\" ? context.suggestedRetryCommand : undefined;\n return normalizeRecoveryPayload({\n attempted_command: attemptedCommand,\n normalized_args: normalizedArgs,\n provided_fields: providedFields,\n suggested_retry: retryCommand,\n ...overrides,\n });\n}\n\nfunction appendIfMissing(entries: string[], value: string | undefined): string[] {\n if (!value || entries.includes(value)) {\n return entries;\n }\n return [...entries, value];\n}\n\nfunction buildCommanderErrorGuidance(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): GuidanceMessage {\n const message = normalizeMessage(rawMessage);\n\n const requiredOption = message.match(/required option '([^']+)' not specified/);\n if (requiredOption) {\n const optionFlag = normalizeRequiredOptionLabel(requiredOption[1]);\n const isType = optionFlag.startsWith(\"--type\");\n const retryCommand = context?.suggestedRetryCommand;\n const providedFlags = normalizeOptionFlags(context?.providedOptionFlags);\n const missing = [optionFlag];\n const examples = commandExampleForRequiredOption(commandName, optionFlag, allowedTypes);\n const examplesWithRetry = retryCommand ? appendIfMissing(examples, retryCommand) : examples;\n const nextStepsBase = isType\n ? [`Allowed type values: ${allowedTypes}`, `Run \"pm ${commandName ?? \"create\"} --help --type <value>\" for type-aware policy details.`]\n : [`Run \"pm ${commandName ?? \"<command>\"} --help\" for required option guidance.`];\n const nextStepsWithRetry = retryCommand\n ? appendIfMissing(nextStepsBase, `Replay with preserved arguments: ${retryCommand}`)\n : nextStepsBase;\n const nextSteps =\n providedFlags && providedFlags.length > 0\n ? appendIfMissing(nextStepsWithRetry, `Already provided options: ${providedFlags.join(\", \")}`)\n : nextStepsWithRetry;\n return makeGuidanceMessage({\n code: \"missing_required_option\",\n title: `Missing required option ${optionFlag}`,\n happened: `Commander rejected the command because ${optionFlag} was not provided.`,\n required: `Pass ${optionFlag} with a valid value before running the command.`,\n why: isType\n ? \"--type selects item contract and policy routing, including required/disabled option rules.\"\n : \"Required flags define mandatory command intent and prevent ambiguous execution.\",\n examples: examplesWithRetry,\n nextSteps,\n recovery: buildCommanderRecoveryPayload(context, { missing }),\n });\n }\n\n const missingArgument = message.match(/missing required argument '([^']+)'/);\n if (missingArgument) {\n const argumentName = missingArgument[1];\n return makeGuidanceMessage({\n code: \"missing_required_argument\",\n title: `Missing required argument ${argumentName}`,\n happened: `Command invocation omitted positional argument ${argumentName}.`,\n required: `Provide ${argumentName} in the expected command position.`,\n why: \"Positional arguments identify the target entity or action context for the command.\",\n examples: [`pm ${commandName ?? \"<command>\"} --help`],\n recovery: buildCommanderRecoveryPayload(context, { missing: [argumentName] }),\n });\n }\n\n const unknownOption = message.match(/unknown option '([^']+)'/);\n if (unknownOption) {\n const optionName = unknownOption[1];\n const suggestions = normalizeOptionFlags(context?.unknownOptionSuggestions);\n const retryCommand = context?.suggestedRetryCommand;\n if (commandName === \"update\" && (optionName === \"--file\" || optionName === \"--doc\")) {\n return makeGuidanceMessage({\n code: \"unsupported_update_option\",\n title: `Unsupported option ${optionName} for update`,\n happened: `pm update does not accept ${optionName} for linked artifact mutations.`,\n required: \"Use dedicated linked-artifact commands instead of pm update for files/docs changes.\",\n why: \"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.\",\n examples: [\n 'pm files pm-a1b2 --add \"path=src/cli/main.ts,scope=project,note=implementation surface\"',\n 'pm docs pm-a1b2 --add \"path=README.md,scope=project,note=user-facing contract\"',\n ],\n nextSteps: ['Run \"pm files --help\" and \"pm docs --help\" for add/remove payload formats.'],\n recovery: buildCommanderRecoveryPayload(context, {\n missing: suggestions,\n }),\n });\n }\n const nextSteps = [\n \"Run command help to confirm the exact option contracts for this command path.\",\n ...(suggestions && suggestions.length > 0 ? [`Nearest supported options: ${suggestions.join(\", \")}`] : []),\n ...(retryCommand ? [`Replay with suggested correction: ${retryCommand}`] : []),\n ];\n const examples = [\n ...(retryCommand ? [retryCommand] : []),\n `pm ${commandName ?? \"<command>\"} --help`,\n ];\n return makeGuidanceMessage({\n code: \"unknown_option\",\n title: `Unknown option ${optionName}`,\n happened: `Commander does not recognize option ${optionName} for this command path.`,\n required: \"Use supported options only, or move option to the correct subcommand.\",\n why: \"Option contracts are command-specific and intentionally validated.\",\n examples,\n nextSteps,\n recovery: buildCommanderRecoveryPayload(context, {\n missing: suggestions,\n }),\n });\n }\n\n const unknownCommand = message.match(/unknown command '([^']+)'/);\n if (unknownCommand) {\n const commandToken = unknownCommand[1];\n const runtimeExamples = normalizeContextList(context?.unknownCommandExamples);\n const runtimeNextSteps = normalizeContextList(context?.unknownCommandNextSteps);\n const packageHint = resolveKnownPackageCommandHint(commandToken);\n const baseExamples = runtimeExamples ?? [\"pm --help\"];\n const baseNextSteps = runtimeNextSteps ?? [\"Verify spelling and active extensions, then rerun.\"];\n if (packageHint) {\n const installStep = `\"${commandToken}\" is provided by the ${packageHint.packageName} package. Install it with: ${packageHint.installCommand}`;\n return makeGuidanceMessage({\n code: \"unknown_command\",\n title: `Unknown command ${commandToken}`,\n happened: `pm does not expose command path \"${commandToken}\" in current runtime configuration. It is shipped by the optional ${packageHint.packageName} package.`,\n required: `Install the ${packageHint.packageName} package, or use a valid command name or subcommand path.`,\n why: \"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.\",\n examples: dedupeStrings([packageHint.installCommand, ...baseExamples]),\n nextSteps: dedupeStrings([installStep, ...baseNextSteps]),\n recovery: buildCommanderRecoveryPayload(context),\n });\n }\n return makeGuidanceMessage({\n code: \"unknown_command\",\n title: `Unknown command ${commandToken}`,\n happened: `pm does not expose command path \"${commandToken}\" in current runtime configuration.`,\n required: \"Use a valid command name or subcommand path.\",\n why: \"Command registry includes core commands plus active extension command handlers.\",\n examples: baseExamples,\n nextSteps: baseNextSteps,\n recovery: buildCommanderRecoveryPayload(context),\n });\n }\n\n return makeGuidanceMessage({\n code: \"invalid_command_usage\",\n title: \"Invalid command usage\",\n happened: message,\n required: \"Use the command with valid arguments and options.\",\n why: \"Commander validates CLI contracts before execution.\",\n examples: [\"pm --help\", `pm ${commandName ?? \"<command>\"} --help`],\n recovery: buildCommanderRecoveryPayload(context),\n });\n}\n\nexport function formatPmCliErrorForDisplay(rawMessage: string, context?: PmCliErrorContext): string {\n return renderGuidanceMessage(buildPmCliErrorGuidance(rawMessage, context));\n}\n\nexport function classifyPmCliError(rawMessage: string, context?: PmCliErrorContext): ErrorClassification {\n return guidanceToClassification(buildPmCliErrorGuidance(rawMessage, context));\n}\n\nexport function formatPmCliErrorForJson(rawMessage: string, exitCode: number, context?: PmCliErrorContext): JsonErrorEnvelope {\n return guidanceToJsonEnvelope(buildPmCliErrorGuidance(rawMessage, context), exitCode);\n}\n\nexport function formatCommanderErrorForDisplay(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): string {\n return renderGuidanceMessage(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context));\n}\n\nexport function classifyCommanderError(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): ErrorClassification {\n return guidanceToClassification(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context));\n}\n\nexport function formatCommanderErrorForJson(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n exitCode: number,\n context?: CommanderGuidanceContext,\n): JsonErrorEnvelope {\n return guidanceToJsonEnvelope(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context), exitCode);\n}\n\nexport function formatUnknownErrorForJson(rawMessage: string, exitCode: number): JsonErrorEnvelope {\n const guidance = buildUnknownErrorGuidance(rawMessage);\n return guidanceToJsonEnvelope(guidance, exitCode);\n}\n\nfunction buildUnknownErrorGuidance(rawMessage: string): GuidanceMessage {\n return makeGuidanceMessage({\n code: \"unknown_error\",\n title: \"Unhandled error\",\n happened: normalizeMessage(rawMessage),\n required: \"Inspect command input and runtime state, then retry.\",\n why: \"Unexpected runtime failures can occur from environment or extension-level issues.\",\n examples: [\"pm --help\", \"pm health --json\"],\n });\n}\n\nexport function classifyUnknownError(rawMessage: string): ErrorClassification {\n return guidanceTo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O,CAAC,CAAC,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,UAAkB,EAClB,WAA+B,EAC/B,YAAoB,EACpB,OAAkC;IAElC,OAAO,wBAAwB,CAAC,2BAA2B,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/G,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,UAAkB,EAClB,WAA+B,EAC/B,YAAoB,EACpB,QAAgB,EAChB,OAAkC;IAElC,OAAO,sBAAsB,CAAC,2BAA2B,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AACvH,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAkB,EAAE,QAAgB;IAC5E,MAAM,QAAQ,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACvD,OAAO,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,yBAAyB,CAAC,UAAkB;IACnD,OAAO,mBAAmB,CAAC;QACzB,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,iBAAiB;QACxB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC;QACtC,QAAQ,EAAE,sDAAsD;QAChE,GAAG,EAAE,mFAAmF;QACxF,QAAQ,EAAE,CAAC,WAAW,EAAE,kBAAkB,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACrD,OAAO,wBAAwB,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;AACzE,CAAC","debugId":"7eb93c83-f192-549a-a611-93a00dbf6b01"}
1
+ {"version":3,"file":"error-guidance.js","sources":["cli/error-guidance.ts"],"sourceRoot":"/","sourcesContent":["import type { PmCliErrorContext, PmCliErrorRecoveryPayload } from \"../core/shared/errors.js\";\nimport { renderPmCommand } from \"./argv-utils.js\";\n\ninterface GuidanceMessage {\n code: string;\n type: string;\n title: string;\n happened: string;\n required: string;\n why?: string;\n examples?: string[];\n nextSteps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface JsonErrorEnvelope {\n type: string;\n code: string;\n title: string;\n detail: string;\n required: string;\n exit_code: number;\n why?: string;\n examples?: string[];\n next_steps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface ErrorClassification {\n type: string;\n code: string;\n title: string;\n detail: string;\n required: string;\n why?: string;\n examples?: string[];\n next_steps?: string[];\n recovery?: PmCliErrorRecoveryPayload;\n}\n\nexport interface CommanderGuidanceContext {\n unknownCommandExamples?: string[];\n unknownCommandNextSteps?: string[];\n attemptedCommand?: string;\n normalizedInvocationArgs?: string[];\n providedOptionFlags?: string[];\n unknownOptionSuggestions?: string[];\n unknownOptionOtherCommands?: string[];\n suggestedRetryCommand?: string;\n}\n\nfunction errorType(code: string): string {\n return `urn:pm-cli:error:${code}`;\n}\n\nfunction makeGuidanceMessage(params: Omit<GuidanceMessage, \"type\">): GuidanceMessage {\n return {\n ...params,\n type: errorType(params.code),\n };\n}\n\ninterface PackageCommandHint {\n /** Published package name shown to the user (e.g. @unbrained/pm-guide-shell). */\n packageName: string;\n /** Exact CLI command that installs the bundled package by its install alias. */\n installCommand: string;\n}\n\n// Catalog of command tokens that are provided by optional first-party packages\n// rather than core. When an unknown-command error names one of these, we surface\n// a concrete install hint so agents/humans aren't left guessing. The install\n// command uses the bundled alias accepted by `pm install <alias>` (see\n// packages/pm-*/package.json `pm.aliases` and extension.ts install_command).\nconst KNOWN_PACKAGE_COMMAND_HINTS: Readonly<Record<string, PackageCommandHint>> = {\n guide: { packageName: \"@unbrained/pm-guide-shell\", installCommand: \"pm install guide-shell\" },\n templates: { packageName: \"@unbrained/pm-templates\", installCommand: \"pm install templates\" },\n calendar: { packageName: \"@unbrained/pm-calendar\", installCommand: \"pm install calendar\" },\n cal: { packageName: \"@unbrained/pm-calendar\", installCommand: \"pm install calendar\" },\n};\n\nfunction resolveKnownPackageCommandHint(commandToken: string): PackageCommandHint | undefined {\n const primary = commandToken.trim().split(/\\s+/)[0]?.toLowerCase();\n if (!primary) {\n return undefined;\n }\n return KNOWN_PACKAGE_COMMAND_HINTS[primary];\n}\n\nfunction renderList(title: string, entries: string[]): string[] {\n if (entries.length === 0) {\n return [];\n }\n return [title, ...entries.map((entry) => ` - ${entry}`)];\n}\n\nfunction normalizeRecoveryPayload(payload: PmCliErrorRecoveryPayload | undefined): PmCliErrorRecoveryPayload | undefined {\n if (!payload || typeof payload !== \"object\") {\n return undefined;\n }\n const normalized: PmCliErrorRecoveryPayload = {};\n if (typeof payload.attempted_command === \"string\" && payload.attempted_command.trim().length > 0) {\n normalized.attempted_command = payload.attempted_command.trim();\n }\n if (Array.isArray(payload.normalized_args)) {\n const args = payload.normalized_args.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (args.length > 0) {\n normalized.normalized_args = args;\n }\n }\n if (Array.isArray(payload.provided_fields)) {\n const fields = payload.provided_fields.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (fields.length > 0) {\n normalized.provided_fields = fields;\n }\n }\n if (Array.isArray(payload.missing)) {\n const missing = payload.missing.map((entry) => entry.trim()).filter((entry) => entry.length > 0);\n if (missing.length > 0) {\n normalized.missing = missing;\n }\n }\n if (typeof payload.suggested_retry === \"string\" && payload.suggested_retry.trim().length > 0) {\n normalized.suggested_retry = payload.suggested_retry.trim();\n }\n return Object.keys(normalized).length > 0 ? normalized : undefined;\n}\n\nfunction renderRecoveryBundle(recovery: PmCliErrorRecoveryPayload | undefined): string[] {\n const normalized = normalizeRecoveryPayload(recovery);\n if (!normalized) {\n return [];\n }\n const lines = [\"Recovery bundle:\"];\n if (normalized.attempted_command) {\n lines.push(` attempted_command: ${normalized.attempted_command}`);\n }\n if (normalized.normalized_args && normalized.normalized_args.length > 0) {\n lines.push(` normalized_args: ${normalized.normalized_args.join(\" \")}`);\n }\n if (normalized.provided_fields && normalized.provided_fields.length > 0) {\n lines.push(` provided_fields: ${normalized.provided_fields.join(\", \")}`);\n }\n if (normalized.missing && normalized.missing.length > 0) {\n lines.push(` missing: ${normalized.missing.join(\", \")}`);\n }\n if (normalized.suggested_retry) {\n lines.push(` suggested_retry: ${normalized.suggested_retry}`);\n }\n return lines;\n}\n\nexport function renderGuidanceMessage(message: GuidanceMessage): string {\n const lines: string[] = [\n `Error: ${message.title}`,\n \"\",\n \"What happened:\",\n ` ${message.happened}`,\n \"\",\n \"What is required:\",\n ` ${message.required}`,\n ];\n if (message.why) {\n lines.push(\"\", \"Why:\");\n lines.push(` ${message.why}`);\n }\n if (message.examples && message.examples.length > 0) {\n lines.push(\"\");\n lines.push(...renderList(\"Examples:\", message.examples));\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n lines.push(\"\");\n lines.push(...renderList(\"Next steps:\", message.nextSteps));\n }\n const recoveryLines = renderRecoveryBundle(message.recovery);\n if (recoveryLines.length > 0) {\n lines.push(\"\");\n lines.push(...recoveryLines);\n }\n return lines.join(\"\\n\");\n}\n\nfunction guidanceToJsonEnvelope(message: GuidanceMessage, exitCode: number): JsonErrorEnvelope {\n const payload: JsonErrorEnvelope = {\n type: message.type,\n code: message.code,\n title: message.title,\n detail: message.happened,\n required: message.required,\n exit_code: exitCode,\n };\n if (message.why) {\n payload.why = message.why;\n }\n if (message.examples && message.examples.length > 0) {\n payload.examples = message.examples;\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n payload.next_steps = message.nextSteps;\n }\n if (message.recovery) {\n payload.recovery = message.recovery;\n }\n return payload;\n}\n\nfunction guidanceToClassification(message: GuidanceMessage): ErrorClassification {\n const payload: ErrorClassification = {\n type: message.type,\n code: message.code,\n title: message.title,\n detail: message.happened,\n required: message.required,\n };\n if (message.why) {\n payload.why = message.why;\n }\n if (message.examples && message.examples.length > 0) {\n payload.examples = message.examples;\n }\n if (message.nextSteps && message.nextSteps.length > 0) {\n payload.next_steps = message.nextSteps;\n }\n if (message.recovery) {\n payload.recovery = message.recovery;\n }\n return payload;\n}\n\nfunction normalizeMessage(message: string): string {\n return message.replace(/\\(outputHelp\\)/g, \"\").trim();\n}\n\nfunction normalizeContextList(values: string[] | undefined): string[] | undefined {\n if (!Array.isArray(values)) {\n return undefined;\n }\n const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction dedupeStrings(values: string[]): string[] {\n const seen = new Set<string>();\n const result: string[] = [];\n for (const value of values) {\n if (seen.has(value)) {\n continue;\n }\n seen.add(value);\n result.push(value);\n }\n return result;\n}\n\nfunction inferCommandNameFromRecovery(recovery: PmCliErrorRecoveryPayload | undefined): string | undefined {\n const args = recovery?.normalized_args;\n if (!Array.isArray(args) || args.length === 0) {\n return undefined;\n }\n const firstCommandArg = args.find((arg) => arg.trim().length > 0 && !arg.startsWith(\"-\"));\n return firstCommandArg?.trim();\n}\n\nfunction inferAllowedValuesFromMessage(message: string): string[] {\n const match = message.match(/\\bmust be one of:?\\s+([A-Za-z0-9_.|,\\- ]+)/i);\n if (!match) {\n return [];\n }\n return match[1]\n .split(/[|,]/)\n .map((entry) => entry.trim())\n .filter((entry) => /^[A-Za-z0-9_.-]+$/.test(entry));\n}\n\nfunction buildAllowedValueRetryCommand(recovery: PmCliErrorRecoveryPayload | undefined, allowedValues: string[]): string | undefined {\n const args = recovery?.normalized_args;\n const fields = recovery?.provided_fields;\n const replacement = allowedValues[0];\n if (!Array.isArray(args) || !Array.isArray(fields) || !replacement) {\n return undefined;\n }\n for (const field of fields) {\n const index = args.findIndex((arg) => arg === field);\n if (index >= 0 && index < args.length - 1 && !args[index + 1]?.startsWith(\"-\")) {\n const nextArgs = [...args];\n nextArgs[index + 1] = replacement;\n return renderPmCommand(nextArgs);\n }\n }\n return undefined;\n}\n\nfunction buildFallbackTitleFromMessage(message: string): string | undefined {\n const firstLine = message.split(/\\r?\\n/)[0]?.trim() ?? \"\";\n if (firstLine.length === 0) {\n return undefined;\n }\n if (firstLine.length <= 120) {\n return firstLine;\n }\n return `${firstLine.slice(0, 117)}...`;\n}\n\nfunction applyPmCliErrorContext(\n guidance: GuidanceMessage,\n rawMessage: string,\n context: PmCliErrorContext | undefined,\n): GuidanceMessage {\n if (!context) {\n return guidance;\n }\n const normalizedRawMessage = normalizeMessage(rawMessage);\n const code = typeof context.code === \"string\" && context.code.trim().length > 0 ? context.code.trim() : guidance.code;\n const type = typeof context.type === \"string\" && context.type.trim().length > 0 ? context.type.trim() : errorType(code);\n const examples = normalizeContextList(context.examples) ?? guidance.examples;\n const nextSteps = normalizeContextList(context.nextSteps) ?? guidance.nextSteps;\n const fallbackTitle = guidance.code === \"command_failed\" && context.code ? buildFallbackTitleFromMessage(normalizedRawMessage) : undefined;\n const recovery = normalizeRecoveryPayload(context.recovery) ?? guidance.recovery;\n return {\n ...guidance,\n code,\n type,\n title: fallbackTitle ?? guidance.title,\n happened: normalizedRawMessage.length > 0 ? normalizedRawMessage : guidance.happened,\n required: typeof context.required === \"string\" && context.required.trim().length > 0 ? context.required.trim() : guidance.required,\n why: typeof context.why === \"string\" && context.why.trim().length > 0 ? context.why.trim() : guidance.why,\n examples,\n nextSteps,\n recovery,\n };\n}\n\nfunction buildPmCliErrorGuidance(rawMessage: string, context?: PmCliErrorContext): GuidanceMessage {\n const message = normalizeMessage(rawMessage);\n\n const trackerNotInitialized = message.match(/^Tracker is not initialized at (.+)\\. Run pm init first\\.$/);\n if (trackerNotInitialized) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"tracker_not_initialized\",\n title: \"Tracker is not initialized\",\n happened: `pm data path does not contain initialized tracker metadata (${trackerNotInitialized[1]}).`,\n required: \"Initialize tracker storage before running this command.\",\n why: \"Most commands require settings and tracker directories created by pm init.\",\n examples: [\"pm init\", \"pm init acme\"],\n nextSteps: ['Run \"pm init\", then rerun your original command.'],\n }),\n rawMessage,\n context,\n );\n }\n\n const itemNotFound = message.match(/^Item ([^ ]+) not found$/);\n if (itemNotFound) {\n const badId = itemNotFound[1];\n const isPlaceholder = /^(undefined|null|<.*>|\\[.*\\]|{.*}|)$/.test(badId);\n const happened = isPlaceholder\n ? `The item ID \"${badId}\" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`\n : `No item with id \"${badId}\" exists in the active tracker scope.`;\n const nextSteps = isPlaceholder\n ? [\n \"Check that the variable holding the item ID is defined before passing it to pm.\",\n 'Use \"pm list-open --limit 20\" to find valid IDs.',\n ]\n : [\"Confirm the active --path/PM_PATH scope, then retry with a valid id.\"];\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"item_not_found\",\n title: \"Item ID not found\",\n happened,\n required: \"Use an existing item ID from current tracker data.\",\n why: \"Mutation and read commands operate only on known IDs.\",\n examples: ['pm list-open --limit 20', 'pm search \"<keyword>\" --limit 10'],\n nextSteps,\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.includes(\"is assigned to\") && message.includes(\"Use --force to override\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"ownership_conflict\",\n title: \"Ownership conflict\",\n happened: message,\n required:\n \"Run as assigned owner, use audit flags for safe non-owner updates, or use --force only for approved override scenarios.\",\n why: \"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.\",\n examples: [\n 'pm update pm-a1b2 --allow-audit-update --description \"...\" --author \"audit-agent\"',\n 'pm update pm-a1b2 --allow-audit-dep-update --dep \"...\" --author \"audit-agent\"',\n 'pm comments pm-a1b2 \"...\" --allow-audit-comment --author \"audit-agent\"',\n 'pm claim pm-a1b2 --author \"codex-agent\"',\n 'pm release pm-a1b2 --allow-audit-release --author \"reviewer\"',\n 'pm update pm-a1b2 --status in_progress --force',\n ],\n nextSteps: [\n \"Use --allow-audit-update for metadata-only non-owner updates (excludes lifecycle/ownership fields).\",\n \"Use --allow-audit-dep-update for dependency-only non-owner additions.\",\n \"Use --allow-audit-comment on comments/notes/learnings for append-only audit entries.\",\n \"Use --force for PM audits and systematic metadata updates performed by leads/maintainers.\",\n \"Use --force when correcting known stale metadata after coordinating ownership changes.\",\n 'For non-terminal reassignment, prefer \"pm claim <ID> --author <you>\" before running other mutations.',\n 'For assignee handoff release workflows, prefer \"pm release <ID> --allow-audit-release --author <you>\" before using --force.',\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.includes(\"is locked\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"lock_conflict\",\n title: \"Lock conflict\",\n happened: message,\n required: \"Wait for lock release, or use --force where supported if lock is stale and safe to override.\",\n why: \"Locking protects item files from concurrent write races.\",\n examples: ['pm update pm-a1b2 --status in_progress --force --author \"codex-agent\"'],\n }),\n rawMessage,\n context,\n );\n }\n\n const missingRequiredOption = message.match(/^Missing required option /);\n const missingRequiredOptions = message.match(/^Missing required options /);\n if (missingRequiredOption || missingRequiredOptions) {\n const plural = Boolean(missingRequiredOptions);\n const missingOptionFlag = !plural ? message.replace(/^Missing required option\\s+/, \"\").trim() : null;\n const missingOptionRequired = missingOptionFlag\n ? `Pass ${missingOptionFlag} with a valid value before running the command.`\n : \"Provide the required option for this command invocation.\";\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"missing_required_option\",\n title: plural ? \"Missing required options\" : missingOptionFlag ? `Missing required option ${missingOptionFlag}` : \"Missing required option\",\n happened: message,\n required: plural\n ? \"Provide every required option for this command invocation.\"\n : missingOptionRequired,\n why: \"Required options define command intent and enforce deterministic write contracts.\",\n examples: [\n 'pm create --title \"Task title\" --description \"Task details\" --type Task --create-mode progressive',\n 'pm create --title \"Task title\" --description \"Task details\" --type Task --status open --priority 1 --message \"Create task\" --dep \"id=pm-epic01,kind=parent,author=codex-agent,created_at=now\" --comment \"author=codex-agent,created_at=now,text=Why this task exists.\" --note \"author=codex-agent,created_at=now,text=Initial implementation note.\" --learning \"author=codex-agent,created_at=now,text=Durable lesson placeholder.\" --file \"path=src/example.ts,scope=project\" --test \"command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240\" --doc \"path=README.md,scope=project\"',\n ],\n nextSteps: [\n 'Run \"pm <command> --help\" to view required and recommended flags.',\n \"For staged triage without placeholder linkage values, use --create-mode progressive.\",\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.startsWith(\"No update flags provided\")) {\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"no_update_fields\",\n title: \"No update fields supplied\",\n happened: \"The update command was called without any field-changing flags.\",\n required:\n \"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.\",\n why: \"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.\",\n examples: [\n 'pm update pm-a1b2 --status in_progress --message \"Start implementation\"',\n 'pm update pm-a1b2 --description \"Clarified implementation scope\" --message \"Clarify task intent\"',\n 'pm append pm-a1b2 --body \"Detailed progress notes\" --message \"Append progress notes\"',\n ],\n nextSteps: [\n \"Choose the item field you intend to change, then pair that change with --message for history context.\",\n \"Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context.\",\n ],\n }),\n rawMessage,\n context,\n );\n }\n\n if (message.startsWith(\"Invalid \") || message.includes(\" must be \") || message.includes(\" requires \")) {\n const recovery = normalizeRecoveryPayload(context?.recovery);\n const commandName = inferCommandNameFromRecovery(recovery);\n const helpExample = commandName ? `pm ${commandName} --help` : \"pm <command> --help\";\n const allowedValues = inferAllowedValuesFromMessage(message);\n const retryExample = buildAllowedValueRetryCommand(recovery, allowedValues);\n const examples = retryExample ? [retryExample, helpExample] : [helpExample, \"pm contracts --command <command> --flags-only --json\"];\n const nextSteps = allowedValues.length > 0\n ? [`Allowed values: ${allowedValues.join(\"|\")}`, `Run \"${helpExample}\" to confirm command-specific constraints.`]\n : [\"Check allowed values in command help, then rerun with corrected input.\"];\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"invalid_argument_value\",\n title: \"Invalid argument value\",\n happened: message,\n required: \"Use values that match documented command constraints.\",\n why: \"Validation protects data consistency and deterministic behavior across commands.\",\n examples,\n nextSteps,\n }),\n rawMessage,\n context,\n );\n }\n\n return applyPmCliErrorContext(\n makeGuidanceMessage({\n code: \"command_failed\",\n title: \"Command failed\",\n happened: message,\n required: \"Adjust command input or tracker state and retry.\",\n why: \"pm enforces explicit, deterministic contracts for data and command semantics.\",\n examples: [\"pm --help\", \"pm <command> --help\"],\n }),\n rawMessage,\n context,\n );\n}\n\nfunction commandExampleForRequiredOption(commandName: string | undefined, optionFlag: string, allowedTypes: string): string[] {\n if (commandName === \"create\" && optionFlag.startsWith(\"--type\")) {\n const firstAllowed = allowedTypes.split(\"|\")[0] || \"Task\";\n return [\n `pm create --title \"Example title\" --description \"Example description\" --type ${firstAllowed} --status open --priority 1 --message \"Create item\" --create-mode progressive`,\n ];\n }\n if (commandName === \"update\") {\n return ['pm update pm-a1b2 --status in_progress --message \"Start implementation\"'];\n }\n return [`pm ${commandName ?? \"<command>\"} --help`];\n}\n\nfunction normalizeRequiredOptionLabel(rawValue: string): string {\n const normalized = rawValue.trim();\n const firstLongFlag = normalized.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0];\n return firstLongFlag ?? normalized;\n}\n\nfunction renderPmCommandFromArgs(argv: string[] | undefined): string | undefined {\n if (!Array.isArray(argv) || argv.length === 0) {\n return undefined;\n }\n return renderPmCommand(argv);\n}\n\nfunction normalizeOptionFlags(values: string[] | undefined): string[] | undefined {\n if (!Array.isArray(values)) {\n return undefined;\n }\n const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);\n return normalized.length > 0 ? normalized : undefined;\n}\n\nfunction buildCommanderRecoveryPayload(\n context: CommanderGuidanceContext | undefined,\n overrides: Partial<PmCliErrorRecoveryPayload> = {},\n): PmCliErrorRecoveryPayload | undefined {\n const providedFields = normalizeOptionFlags(context?.providedOptionFlags);\n const normalizedArgs =\n Array.isArray(context?.normalizedInvocationArgs) && context?.normalizedInvocationArgs.length > 0\n ? context.normalizedInvocationArgs\n : undefined;\n const attemptedCommand = typeof context?.attemptedCommand === \"string\" ? context.attemptedCommand : renderPmCommandFromArgs(normalizedArgs);\n const retryCommand = typeof context?.suggestedRetryCommand === \"string\" ? context.suggestedRetryCommand : undefined;\n return normalizeRecoveryPayload({\n attempted_command: attemptedCommand,\n normalized_args: normalizedArgs,\n provided_fields: providedFields,\n suggested_retry: retryCommand,\n ...overrides,\n });\n}\n\nfunction appendIfMissing(entries: string[], value: string | undefined): string[] {\n if (!value || entries.includes(value)) {\n return entries;\n }\n return [...entries, value];\n}\n\nfunction buildCommanderErrorGuidance(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): GuidanceMessage {\n const message = normalizeMessage(rawMessage);\n\n const requiredOption = message.match(/required option '([^']+)' not specified/);\n if (requiredOption) {\n const optionFlag = normalizeRequiredOptionLabel(requiredOption[1]);\n const isType = optionFlag.startsWith(\"--type\");\n const retryCommand = context?.suggestedRetryCommand;\n const providedFlags = normalizeOptionFlags(context?.providedOptionFlags);\n const missing = [optionFlag];\n const examples = commandExampleForRequiredOption(commandName, optionFlag, allowedTypes);\n const examplesWithRetry = retryCommand ? appendIfMissing(examples, retryCommand) : examples;\n const nextStepsBase = isType\n ? [`Allowed type values: ${allowedTypes}`, `Run \"pm ${commandName ?? \"create\"} --help --type <value>\" for type-aware policy details.`]\n : [`Run \"pm ${commandName ?? \"<command>\"} --help\" for required option guidance.`];\n const nextStepsWithRetry = retryCommand\n ? appendIfMissing(nextStepsBase, `Replay with preserved arguments: ${retryCommand}`)\n : nextStepsBase;\n const nextSteps =\n providedFlags && providedFlags.length > 0\n ? appendIfMissing(nextStepsWithRetry, `Already provided options: ${providedFlags.join(\", \")}`)\n : nextStepsWithRetry;\n return makeGuidanceMessage({\n code: \"missing_required_option\",\n title: `Missing required option ${optionFlag}`,\n happened: `Commander rejected the command because ${optionFlag} was not provided.`,\n required: `Pass ${optionFlag} with a valid value before running the command.`,\n why: isType\n ? \"--type selects item contract and policy routing, including required/disabled option rules.\"\n : \"Required flags define mandatory command intent and prevent ambiguous execution.\",\n examples: examplesWithRetry,\n nextSteps,\n recovery: buildCommanderRecoveryPayload(context, { missing }),\n });\n }\n\n const missingArgument = message.match(/missing required argument '([^']+)'/);\n if (missingArgument) {\n const argumentName = missingArgument[1];\n return makeGuidanceMessage({\n code: \"missing_required_argument\",\n title: `Missing required argument ${argumentName}`,\n happened: `Command invocation omitted positional argument ${argumentName}.`,\n required: `Provide ${argumentName} in the expected command position.`,\n why: \"Positional arguments identify the target entity or action context for the command.\",\n examples: [`pm ${commandName ?? \"<command>\"} --help`],\n recovery: buildCommanderRecoveryPayload(context, { missing: [argumentName] }),\n });\n }\n\n const unknownOption = message.match(/unknown option '([^']+)'/);\n if (unknownOption) {\n const optionName = unknownOption[1];\n const suggestions = normalizeOptionFlags(context?.unknownOptionSuggestions);\n const retryCommand = context?.suggestedRetryCommand;\n if (commandName === \"update\" && (optionName === \"--file\" || optionName === \"--doc\")) {\n return makeGuidanceMessage({\n code: \"unsupported_update_option\",\n title: `Unsupported option ${optionName} for update`,\n happened: `pm update does not accept ${optionName} for linked artifact mutations.`,\n required: \"Use dedicated linked-artifact commands instead of pm update for files/docs changes.\",\n why: \"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.\",\n examples: [\n 'pm files pm-a1b2 --add \"path=src/cli/main.ts,scope=project,note=implementation surface\"',\n 'pm docs pm-a1b2 --add \"path=README.md,scope=project,note=user-facing contract\"',\n ],\n nextSteps: ['Run \"pm files --help\" and \"pm docs --help\" for add/remove payload formats.'],\n recovery: buildCommanderRecoveryPayload(context, {\n missing: suggestions,\n }),\n });\n }\n const otherCommands = normalizeContextList(context?.unknownOptionOtherCommands);\n const nextSteps = [\n \"Run command help to confirm the exact option contracts for this command path.\",\n ...(suggestions && suggestions.length > 0 ? [`Nearest supported options: ${suggestions.join(\", \")}`] : []),\n ...(otherCommands && otherCommands.length > 0\n ? [`${optionName} is a valid option on: ${otherCommands.join(\", \")}. If you meant one of those, run that command instead.`]\n : []),\n ...(retryCommand ? [`Replay with suggested correction: ${retryCommand}`] : []),\n ];\n const examples = [\n ...(retryCommand ? [retryCommand] : []),\n `pm ${commandName ?? \"<command>\"} --help`,\n ];\n return makeGuidanceMessage({\n code: \"unknown_option\",\n title: `Unknown option ${optionName}`,\n happened: `Commander does not recognize option ${optionName} for this command path.`,\n required: \"Use supported options only, or move option to the correct subcommand.\",\n why: \"Option contracts are command-specific and intentionally validated.\",\n examples,\n nextSteps,\n recovery: buildCommanderRecoveryPayload(context, {\n missing: suggestions,\n }),\n });\n }\n\n const unknownCommand = message.match(/unknown command '([^']+)'/);\n if (unknownCommand) {\n const commandToken = unknownCommand[1];\n const runtimeExamples = normalizeContextList(context?.unknownCommandExamples);\n const runtimeNextSteps = normalizeContextList(context?.unknownCommandNextSteps);\n const packageHint = resolveKnownPackageCommandHint(commandToken);\n const baseExamples = runtimeExamples ?? [\"pm --help\"];\n const baseNextSteps = runtimeNextSteps ?? [\"Verify spelling and active extensions, then rerun.\"];\n if (packageHint) {\n const installStep = `\"${commandToken}\" is provided by the ${packageHint.packageName} package. Install it with: ${packageHint.installCommand}`;\n return makeGuidanceMessage({\n code: \"unknown_command\",\n title: `Unknown command ${commandToken}`,\n happened: `pm does not expose command path \"${commandToken}\" in current runtime configuration. It is shipped by the optional ${packageHint.packageName} package.`,\n required: `Install the ${packageHint.packageName} package, or use a valid command name or subcommand path.`,\n why: \"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.\",\n examples: dedupeStrings([packageHint.installCommand, ...baseExamples]),\n nextSteps: dedupeStrings([installStep, ...baseNextSteps]),\n recovery: buildCommanderRecoveryPayload(context),\n });\n }\n return makeGuidanceMessage({\n code: \"unknown_command\",\n title: `Unknown command ${commandToken}`,\n happened: `pm does not expose command path \"${commandToken}\" in current runtime configuration.`,\n required: \"Use a valid command name or subcommand path.\",\n why: \"Command registry includes core commands plus active extension command handlers.\",\n examples: baseExamples,\n nextSteps: baseNextSteps,\n recovery: buildCommanderRecoveryPayload(context),\n });\n }\n\n return makeGuidanceMessage({\n code: \"invalid_command_usage\",\n title: \"Invalid command usage\",\n happened: message,\n required: \"Use the command with valid arguments and options.\",\n why: \"Commander validates CLI contracts before execution.\",\n examples: [\"pm --help\", `pm ${commandName ?? \"<command>\"} --help`],\n recovery: buildCommanderRecoveryPayload(context),\n });\n}\n\nexport function formatPmCliErrorForDisplay(rawMessage: string, context?: PmCliErrorContext): string {\n return renderGuidanceMessage(buildPmCliErrorGuidance(rawMessage, context));\n}\n\nexport function classifyPmCliError(rawMessage: string, context?: PmCliErrorContext): ErrorClassification {\n return guidanceToClassification(buildPmCliErrorGuidance(rawMessage, context));\n}\n\nexport function formatPmCliErrorForJson(rawMessage: string, exitCode: number, context?: PmCliErrorContext): JsonErrorEnvelope {\n return guidanceToJsonEnvelope(buildPmCliErrorGuidance(rawMessage, context), exitCode);\n}\n\nexport function formatCommanderErrorForDisplay(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): string {\n return renderGuidanceMessage(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context));\n}\n\nexport function classifyCommanderError(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n context?: CommanderGuidanceContext,\n): ErrorClassification {\n return guidanceToClassification(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context));\n}\n\nexport function formatCommanderErrorForJson(\n rawMessage: string,\n commandName: string | undefined,\n allowedTypes: string,\n exitCode: number,\n context?: CommanderGuidanceContext,\n): JsonErrorEnvelope {\n return guidanceToJsonEnvelope(buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context), exitCode);\n}\n\nexport function formatUnknownErrorForJson(rawMessage: string, exitCode: number): JsonErrorEnvelope {\n const guidance = buildUnknownErrorGuidance(rawMessage);\n return guidanceToJsonEnvelope(guidance, exitCode);\n}\n\nfunction buildUnknownErrorGuidance(rawMessage: string): GuidanceMessage {\n return makeGuidanceMessage({\n code: \"unknown_error\",\n title: \"Unhandled error\",\n happened: normalizeMessage(rawMessage),\n required: \"Inspect command input and runtime state, then retry.\",\n why: \"Unexpected runtime failures can occur from environment or extension-level issues.\",\n examples: [\"pm --help\", \"pm health --json\"],\n });\n}\n\nexport function classifyUnknownError(rawMessage: string): ErrorClassification {\n return guidanceToClassification(buildUnknownErrorGuidance(rawMessage));\n}\n"],"names":[],"mappings":";;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAkDlD,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,oBAAoB,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAqC;IAChE,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;KAC7B,CAAC;AACJ,CAAC;AASD,+EAA+E;AAC/E,iFAAiF;AACjF,6EAA6E;AAC7E,uEAAuE;AACvE,6EAA6E;AAC7E,MAAM,2BAA2B,GAAiD;IAChF,KAAK,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE,cAAc,EAAE,wBAAwB,EAAE;IAC7F,SAAS,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,cAAc,EAAE,sBAAsB,EAAE;IAC7F,QAAQ,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,cAAc,EAAE,qBAAqB,EAAE;IAC1F,GAAG,EAAE,EAAE,WAAW,EAAE,wBAAwB,EAAE,cAAc,EAAE,qBAAqB,EAAE;CACtF,CAAC;AAEF,SAAS,8BAA8B,CAAC,YAAoB;IAC1D,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IACnE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,2BAA2B,CAAC,OAAO,CAAC,CAAC;AAC9C,C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,UAAU,CAAC;QACtC,QAAQ,EAAE,sDAAsD;QAChE,GAAG,EAAE,mFAAmF;QACxF,QAAQ,EAAE,CAAC,WAAW,EAAE,kBAAkB,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAkB;IACrD,OAAO,wBAAwB,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;AACzE,CAAC","debugId":"98367a9e-b72b-56c3-a337-fcc10e562f6e"}
@@ -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]="bb46ecaf-3f2f-526b-b6fa-4d87511ede62")}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";
@@ -70,6 +71,35 @@ function describeUnknownError(error) {
70
71
  }
71
72
  return "Unknown failure";
72
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
+ }
73
103
  function renderAttemptedCommand(argv) {
74
104
  return renderPmCommand(argv);
75
105
  }
@@ -115,12 +145,6 @@ function buildPmCliRecoveryContext(context, invocationArgv, rawMessage) {
115
145
  recovery,
116
146
  };
117
147
  }
118
- function asRecord(value) {
119
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
120
- return null;
121
- }
122
- return value;
123
- }
124
148
  function readRecordString(record, ...keys) {
125
149
  if (!record) {
126
150
  return undefined;
@@ -213,7 +237,7 @@ function inferPostActionFailureMessage(result) {
213
237
  const runResults = result?.run_results;
214
238
  if (Array.isArray(runResults)) {
215
239
  const failedRuns = runResults.filter((entry) => {
216
- const row = asRecord(entry);
240
+ const row = asRecordOrNull(entry);
217
241
  return row?.status === "failed";
218
242
  }).length;
219
243
  if (failedRuns > 0) {
@@ -241,7 +265,7 @@ function inferPostActionErrorCode(ok, exitCode) {
241
265
  return "command_failed";
242
266
  }
243
267
  function buildPostActionTelemetryOutcome() {
244
- const result = asRecord(getActiveCommandResult());
268
+ const result = asRecordOrNull(getActiveCommandResult());
245
269
  const processExitCode = typeof process.exitCode === "number" && Number.isFinite(process.exitCode)
246
270
  ? Math.max(0, Math.trunc(process.exitCode))
247
271
  : undefined;
@@ -318,6 +342,9 @@ function extractCommandScopedOptions(command, commandArgs, extensionFlagDefiniti
318
342
  delete scoped.extensions;
319
343
  delete scoped.profile;
320
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;
321
348
  const looseOptions = parseLooseCommandOptions(commandArgs);
322
349
  if (extensionFlagDefinitions.length > 0) {
323
350
  validateLooseCommandOptionsWithFlagDefinitions(looseOptions, extensionFlagDefinitions, getCommandPath(command));
@@ -664,7 +691,9 @@ async function runRequiredExtensionCommand(command, options, globalOptions) {
664
691
  if (!extensionCommandResult.handled) {
665
692
  if (extensionCommandResult.warnings.length > 0) {
666
693
  const warningCode = extensionCommandResult.warnings[0];
667
- 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);
668
697
  }
669
698
  throw new PmCliError(`Command "${commandPath}" is provided by extensions and is not currently available.`, EXIT_CODE.NOT_FOUND);
670
699
  }
@@ -871,6 +900,7 @@ program
871
900
  })
872
901
  .option("--json", "Output JSON instead of TOON")
873
902
  .option("--quiet", "Suppress stdout output")
903
+ .option("--no-changed-fields", "Omit the changed_fields array from mutation output (keeps changed_field_count)")
874
904
  .option("--path <dir>", "Override PM path for this command")
875
905
  .option("--no-extensions", "Disable extension loading")
876
906
  .option("--no-pager", "Disable pager integration for help and long output")
@@ -1119,6 +1149,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1119
1149
  listQuery: false,
1120
1150
  mutation: false,
1121
1151
  operation: false,
1152
+ targetCommandName: normalizedCommand,
1122
1153
  };
1123
1154
  }
1124
1155
  if (LIST_QUERY_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1127,6 +1158,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1127
1158
  listQuery: true,
1128
1159
  mutation: false,
1129
1160
  operation: false,
1161
+ targetCommandName: normalizedCommand,
1130
1162
  };
1131
1163
  }
1132
1164
  if (MUTATION_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1135,6 +1167,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1135
1167
  listQuery: false,
1136
1168
  mutation: true,
1137
1169
  operation: false,
1170
+ targetCommandName: normalizedCommand,
1138
1171
  };
1139
1172
  }
1140
1173
  if (OPERATION_COMMAND_NAMES.has(normalizedCommand)) {
@@ -1143,6 +1176,7 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1143
1176
  listQuery: false,
1144
1177
  mutation: false,
1145
1178
  operation: true,
1179
+ targetCommandName: normalizedCommand,
1146
1180
  };
1147
1181
  }
1148
1182
  return REGISTER_ALL_CORE_COMMAND_FAMILIES;
@@ -1158,7 +1192,11 @@ async function registerCoreCommandFamilies(rootProgram, selection) {
1158
1192
  }
1159
1193
  if (selection.listQuery) {
1160
1194
  const { registerListQueryCommands } = await loadListQueryRegistrationModule();
1161
- 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);
1162
1200
  }
1163
1201
  if (selection.mutation) {
1164
1202
  const { registerMutationCommands } = await loadMutationRegistrationModule();
@@ -1205,8 +1243,8 @@ function shouldRegisterRuntimeSchemaFlags(invocationArgv) {
1205
1243
  }
1206
1244
  return RUNTIME_SCHEMA_FLAG_BOOTSTRAP_COMMANDS.has(commandName);
1207
1245
  }
1208
- const bootstrapInvocation = normalizeBootstrapInvocation(process.argv.slice(2));
1209
- async function main() {
1246
+ export async function runPmCli(rawArgv = process.argv.slice(2)) {
1247
+ const bootstrapInvocation = normalizeBootstrapInvocation(rawArgv);
1210
1248
  const invocationArgv = bootstrapInvocation.argv;
1211
1249
  const invocationProcessArgv = [process.argv[0], process.argv[1], ...invocationArgv];
1212
1250
  const isBareInvocation = invocationArgv.length === 0;
@@ -1274,14 +1312,19 @@ async function main() {
1274
1312
  const bootstrapSnapshot = await loadRuntimeExtensionSnapshot(bootstrapPmRoot);
1275
1313
  setActiveExtensionServices(bootstrapSnapshot?.services ?? { overrides: [] });
1276
1314
  }
1277
- if (error instanceof PmCliError) {
1278
- const enrichedContext = buildPmCliRecoveryContext(error.context, invocationArgv, error.message);
1279
- 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);
1280
1323
  const { errorCategory, commandResolution } = await emitTelemetryCommandError({
1281
1324
  command: attemptedCommand,
1282
1325
  errorCode: classification.code,
1283
1326
  errorMessage: classification.detail,
1284
- exitCode: error.exitCode,
1327
+ exitCode,
1285
1328
  options: {
1286
1329
  bootstrap_global_options: bootstrapGlobal,
1287
1330
  },
@@ -1292,37 +1335,37 @@ async function main() {
1292
1335
  command: attemptedCommand,
1293
1336
  error_code: classification.code,
1294
1337
  error_category: errorCategory,
1295
- exit_code: error.exitCode,
1338
+ exit_code: exitCode,
1296
1339
  error_message: classification.detail,
1297
1340
  command_resolution: commandResolution,
1298
1341
  resolution_stage: "execute",
1299
1342
  source_context: activeTelemetryCommandContext?.source_context,
1300
1343
  });
1301
- sentryFinishCommandSpan(false, error.message, {
1344
+ sentryFinishCommandSpan(false, errorMessage, {
1302
1345
  error_code: classification.code,
1303
1346
  error_category: errorCategory,
1304
- exit_code: error.exitCode,
1347
+ exit_code: exitCode,
1305
1348
  command_resolution: commandResolution,
1306
1349
  resolution_stage: "execute",
1307
1350
  });
1308
1351
  await runAndClearAfterCommandHooks({
1309
1352
  ok: false,
1310
- error: error.message,
1311
- exit_code: error.exitCode,
1353
+ error: errorMessage,
1354
+ exit_code: exitCode,
1312
1355
  error_code: classification.code,
1313
1356
  error_category: errorCategory,
1314
1357
  command_resolution: commandResolution,
1315
1358
  resolution_stage: "execute",
1316
1359
  });
1317
- sentryCaptureCliError(error);
1360
+ sentryCaptureCliError(wrapThrownErrorForSentry(error, errorMessage));
1318
1361
  if (jsonErrors) {
1319
- printError(JSON.stringify(formatPmCliErrorForJson(error.message, error.exitCode, enrichedContext), null, 2));
1362
+ printError(JSON.stringify(formatPmCliErrorForJson(errorMessage, exitCode, enrichedContext), null, 2));
1320
1363
  }
1321
1364
  else {
1322
- printError(formatPmCliErrorForDisplay(error.message, enrichedContext));
1365
+ printError(formatPmCliErrorForDisplay(errorMessage, enrichedContext));
1323
1366
  }
1324
1367
  await sentryFlush();
1325
- process.exitCode = error.exitCode;
1368
+ process.exitCode = exitCode;
1326
1369
  return;
1327
1370
  }
1328
1371
  if (typeof error === "object" && error !== null && "code" in error) {
@@ -1527,6 +1570,11 @@ async function main() {
1527
1570
  process.exitCode = EXIT_CODE.GENERIC_FAILURE;
1528
1571
  }
1529
1572
  }
1530
- void main();
1573
+ export const _testOnly = {
1574
+ isCommanderError,
1575
+ normalizeThrownExitCode,
1576
+ readThrownExitCode,
1577
+ wrapThrownErrorForSentry,
1578
+ };
1531
1579
  //# sourceMappingURL=main.js.map
1532
- //# debugId=bb46ecaf-3f2f-526b-b6fa-4d87511ede62
1580
+ //# debugId=253a39d8-edf5-592c-8b3e-ed509a8a6f11