@unbrained/pm-cli 2026.5.10 → 2026.5.11

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 (124) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/.pi/README.md +10 -1
  3. package/.pi/agents/pm-triage-agent.md +19 -0
  4. package/.pi/agents/pm-verification-agent.md +21 -0
  5. package/.pi/chains/pm-native-delivery.chain.md +11 -0
  6. package/.pi/extensions/pm-cli/index.js +276 -36
  7. package/.pi/skills/pm-native/SKILL.md +6 -2
  8. package/CHANGELOG.md +7 -0
  9. package/README.md +9 -1
  10. package/dist/cli/argv-utils.d.ts +5 -0
  11. package/dist/cli/argv-utils.js +34 -0
  12. package/dist/cli/argv-utils.js.map +1 -0
  13. package/dist/cli/bootstrap-args.d.ts +15 -0
  14. package/dist/cli/bootstrap-args.js +211 -0
  15. package/dist/cli/bootstrap-args.js.map +1 -1
  16. package/dist/cli/commander-usage.js +109 -3
  17. package/dist/cli/commander-usage.js.map +1 -1
  18. package/dist/cli/commands/completion.js +7 -3
  19. package/dist/cli/commands/completion.js.map +1 -1
  20. package/dist/cli/commands/contracts.d.ts +19 -0
  21. package/dist/cli/commands/contracts.js +33 -1
  22. package/dist/cli/commands/contracts.js.map +1 -1
  23. package/dist/cli/commands/create.js +112 -51
  24. package/dist/cli/commands/create.js.map +1 -1
  25. package/dist/cli/commands/docs.js +9 -2
  26. package/dist/cli/commands/docs.js.map +1 -1
  27. package/dist/cli/commands/extension.d.ts +3 -1
  28. package/dist/cli/commands/extension.js +174 -2
  29. package/dist/cli/commands/extension.js.map +1 -1
  30. package/dist/cli/commands/files.js +9 -2
  31. package/dist/cli/commands/files.js.map +1 -1
  32. package/dist/cli/commands/init.d.ts +2 -0
  33. package/dist/cli/commands/init.js +21 -1
  34. package/dist/cli/commands/init.js.map +1 -1
  35. package/dist/cli/commands/metadata-normalizers.d.ts +4 -0
  36. package/dist/cli/commands/metadata-normalizers.js +37 -0
  37. package/dist/cli/commands/metadata-normalizers.js.map +1 -0
  38. package/dist/cli/commands/reindex.js +173 -135
  39. package/dist/cli/commands/reindex.js.map +1 -1
  40. package/dist/cli/commands/search.js +16 -6
  41. package/dist/cli/commands/search.js.map +1 -1
  42. package/dist/cli/commands/test.js +9 -2
  43. package/dist/cli/commands/test.js.map +1 -1
  44. package/dist/cli/commands/update.js +70 -39
  45. package/dist/cli/commands/update.js.map +1 -1
  46. package/dist/cli/error-guidance.d.ts +9 -1
  47. package/dist/cli/error-guidance.js +147 -6
  48. package/dist/cli/error-guidance.js.map +1 -1
  49. package/dist/cli/help-json-payload.js +11 -1
  50. package/dist/cli/help-json-payload.js.map +1 -1
  51. package/dist/cli/main.js +69 -6
  52. package/dist/cli/main.js.map +1 -1
  53. package/dist/cli/register-setup.js +14 -0
  54. package/dist/cli/register-setup.js.map +1 -1
  55. package/dist/cli/telemetry-flush.d.ts +2 -0
  56. package/dist/cli/telemetry-flush.js +4 -0
  57. package/dist/cli/telemetry-flush.js.map +1 -0
  58. package/dist/cli.js +1 -2
  59. package/dist/cli.js.map +1 -1
  60. package/dist/core/extensions/extension-types.d.ts +72 -0
  61. package/dist/core/extensions/extension-types.js +24 -0
  62. package/dist/core/extensions/extension-types.js.map +1 -1
  63. package/dist/core/extensions/loader.d.ts +1 -0
  64. package/dist/core/extensions/loader.js +766 -7
  65. package/dist/core/extensions/loader.js.map +1 -1
  66. package/dist/core/lock/lock.js +2 -0
  67. package/dist/core/lock/lock.js.map +1 -1
  68. package/dist/core/sentry/instrument.d.ts +15 -0
  69. package/dist/core/sentry/instrument.js +35 -3
  70. package/dist/core/sentry/instrument.js.map +1 -1
  71. package/dist/core/shared/constants.js +20 -0
  72. package/dist/core/shared/constants.js.map +1 -1
  73. package/dist/core/shared/errors.d.ts +8 -0
  74. package/dist/core/shared/errors.js.map +1 -1
  75. package/dist/core/shared/levenshtein.d.ts +1 -0
  76. package/dist/core/shared/levenshtein.js +37 -0
  77. package/dist/core/shared/levenshtein.js.map +1 -0
  78. package/dist/core/store/paths.js +34 -1
  79. package/dist/core/store/paths.js.map +1 -1
  80. package/dist/core/store/settings.js +210 -1
  81. package/dist/core/store/settings.js.map +1 -1
  82. package/dist/core/telemetry/runtime.d.ts +1 -0
  83. package/dist/core/telemetry/runtime.js +102 -3
  84. package/dist/core/telemetry/runtime.js.map +1 -1
  85. package/dist/mcp/server.js +3 -1
  86. package/dist/mcp/server.js.map +1 -1
  87. package/dist/pi/native.js +57 -4
  88. package/dist/pi/native.js.map +1 -1
  89. package/dist/sdk/cli-contracts.d.ts +21 -1
  90. package/dist/sdk/cli-contracts.js +250 -0
  91. package/dist/sdk/cli-contracts.js.map +1 -1
  92. package/dist/sdk/index.d.ts +12 -1
  93. package/dist/sdk/index.js +8 -1
  94. package/dist/sdk/index.js.map +1 -1
  95. package/dist/types.d.ts +41 -0
  96. package/dist/types.js.map +1 -1
  97. package/docs/CLAUDE_CODE_PLUGIN.md +39 -0
  98. package/docs/EXTENSIONS.md +687 -0
  99. package/docs/MIGRATION_CLI_SIMPLIFICATION.md +64 -0
  100. package/docs/PI_PACKAGE.md +95 -10
  101. package/docs/SDK.md +441 -0
  102. package/docs/examples/ci/github-actions-pm-extension-gate.yml +53 -0
  103. package/docs/examples/ci/gitlab-ci-pm-extension-gate.yml +41 -0
  104. package/docs/examples/ci/jenkins-pm-extension-gate.Jenkinsfile +45 -0
  105. package/docs/examples/policy-restricted-extension/README.md +74 -0
  106. package/docs/examples/policy-restricted-extension/index.js +21 -0
  107. package/docs/examples/policy-restricted-extension/manifest.json +21 -0
  108. package/docs/examples/policy-restricted-extension/package.json +8 -0
  109. package/docs/examples/sdk-app-embedding/README.md +39 -0
  110. package/docs/examples/sdk-app-embedding/package.json +9 -0
  111. package/docs/examples/sdk-app-embedding/run-embedded-pm.mjs +61 -0
  112. package/docs/examples/sdk-contract-consumer/README.md +57 -0
  113. package/docs/examples/sdk-contract-consumer/inspect-contracts.mjs +47 -0
  114. package/docs/examples/sdk-contract-consumer/package.json +10 -0
  115. package/docs/examples/starter-extension/README.md +57 -42
  116. package/docs/examples/starter-extension/manifest.json +15 -0
  117. package/marketplace.json +3 -3
  118. package/package.json +1 -1
  119. package/plugins/pm-cli-claude/.claude-plugin/plugin.json +2 -2
  120. package/plugins/pm-cli-claude/README.md +55 -14
  121. package/plugins/pm-cli-claude/agents/pm-delivery-chain.md +88 -0
  122. package/plugins/pm-cli-claude/agents/pm-triage-agent.md +83 -0
  123. package/plugins/pm-cli-claude/agents/pm-verification-agent.md +88 -0
  124. package/plugins/pm-cli-claude/hooks/session-start.mjs +87 -22
@@ -1,4 +1,4 @@
1
- import type { PmCliErrorContext } from "../core/shared/errors.js";
1
+ import type { PmCliErrorContext, PmCliErrorRecoveryPayload } from "../core/shared/errors.js";
2
2
  interface GuidanceMessage {
3
3
  code: string;
4
4
  type: string;
@@ -8,6 +8,7 @@ interface GuidanceMessage {
8
8
  why?: string;
9
9
  examples?: string[];
10
10
  nextSteps?: string[];
11
+ recovery?: PmCliErrorRecoveryPayload;
11
12
  }
12
13
  export interface JsonErrorEnvelope {
13
14
  type: string;
@@ -19,6 +20,7 @@ export interface JsonErrorEnvelope {
19
20
  why?: string;
20
21
  examples?: string[];
21
22
  next_steps?: string[];
23
+ recovery?: PmCliErrorRecoveryPayload;
22
24
  }
23
25
  export interface ErrorClassification {
24
26
  type: string;
@@ -29,10 +31,16 @@ export interface ErrorClassification {
29
31
  why?: string;
30
32
  examples?: string[];
31
33
  next_steps?: string[];
34
+ recovery?: PmCliErrorRecoveryPayload;
32
35
  }
33
36
  export interface CommanderGuidanceContext {
34
37
  unknownCommandExamples?: string[];
35
38
  unknownCommandNextSteps?: string[];
39
+ attemptedCommand?: string;
40
+ normalizedInvocationArgs?: string[];
41
+ providedOptionFlags?: string[];
42
+ unknownOptionSuggestions?: string[];
43
+ suggestedRetryCommand?: string;
36
44
  }
37
45
  export declare function renderGuidanceMessage(message: GuidanceMessage): string;
38
46
  export declare function formatPmCliErrorForDisplay(rawMessage: string, context?: PmCliErrorContext): string;
@@ -1,3 +1,4 @@
1
+ import { renderPmCommand } from "./argv-utils.js";
1
2
  function errorType(code) {
2
3
  return `urn:pm-cli:error:${code}`;
3
4
  }
@@ -13,6 +14,60 @@ function renderList(title, entries) {
13
14
  }
14
15
  return [title, ...entries.map((entry) => ` - ${entry}`)];
15
16
  }
17
+ function normalizeRecoveryPayload(payload) {
18
+ if (!payload || typeof payload !== "object") {
19
+ return undefined;
20
+ }
21
+ const normalized = {};
22
+ if (typeof payload.attempted_command === "string" && payload.attempted_command.trim().length > 0) {
23
+ normalized.attempted_command = payload.attempted_command.trim();
24
+ }
25
+ if (Array.isArray(payload.normalized_args)) {
26
+ const args = payload.normalized_args.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
27
+ if (args.length > 0) {
28
+ normalized.normalized_args = args;
29
+ }
30
+ }
31
+ if (Array.isArray(payload.provided_fields)) {
32
+ const fields = payload.provided_fields.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
33
+ if (fields.length > 0) {
34
+ normalized.provided_fields = fields;
35
+ }
36
+ }
37
+ if (Array.isArray(payload.missing)) {
38
+ const missing = payload.missing.map((entry) => entry.trim()).filter((entry) => entry.length > 0);
39
+ if (missing.length > 0) {
40
+ normalized.missing = missing;
41
+ }
42
+ }
43
+ if (typeof payload.suggested_retry === "string" && payload.suggested_retry.trim().length > 0) {
44
+ normalized.suggested_retry = payload.suggested_retry.trim();
45
+ }
46
+ return Object.keys(normalized).length > 0 ? normalized : undefined;
47
+ }
48
+ function renderRecoveryBundle(recovery) {
49
+ const normalized = normalizeRecoveryPayload(recovery);
50
+ if (!normalized) {
51
+ return [];
52
+ }
53
+ const lines = ["Recovery bundle:"];
54
+ if (normalized.attempted_command) {
55
+ lines.push(` attempted_command: ${normalized.attempted_command}`);
56
+ }
57
+ if (normalized.normalized_args && normalized.normalized_args.length > 0) {
58
+ lines.push(` normalized_args: ${normalized.normalized_args.join(" ")}`);
59
+ }
60
+ if (normalized.provided_fields && normalized.provided_fields.length > 0) {
61
+ lines.push(` provided_fields: ${normalized.provided_fields.join(", ")}`);
62
+ }
63
+ if (normalized.missing && normalized.missing.length > 0) {
64
+ lines.push(` missing: ${normalized.missing.join(", ")}`);
65
+ }
66
+ if (normalized.suggested_retry) {
67
+ lines.push(` suggested_retry: ${normalized.suggested_retry}`);
68
+ }
69
+ return lines;
70
+ }
16
71
  export function renderGuidanceMessage(message) {
17
72
  const lines = [
18
73
  `Error: ${message.title}`,
@@ -35,6 +90,11 @@ export function renderGuidanceMessage(message) {
35
90
  lines.push("");
36
91
  lines.push(...renderList("Next steps:", message.nextSteps));
37
92
  }
93
+ const recoveryLines = renderRecoveryBundle(message.recovery);
94
+ if (recoveryLines.length > 0) {
95
+ lines.push("");
96
+ lines.push(...recoveryLines);
97
+ }
38
98
  return lines.join("\n");
39
99
  }
40
100
  function guidanceToJsonEnvelope(message, exitCode) {
@@ -55,6 +115,9 @@ function guidanceToJsonEnvelope(message, exitCode) {
55
115
  if (message.nextSteps && message.nextSteps.length > 0) {
56
116
  payload.next_steps = message.nextSteps;
57
117
  }
118
+ if (message.recovery) {
119
+ payload.recovery = message.recovery;
120
+ }
58
121
  return payload;
59
122
  }
60
123
  function guidanceToClassification(message) {
@@ -74,6 +137,9 @@ function guidanceToClassification(message) {
74
137
  if (message.nextSteps && message.nextSteps.length > 0) {
75
138
  payload.next_steps = message.nextSteps;
76
139
  }
140
+ if (message.recovery) {
141
+ payload.recovery = message.recovery;
142
+ }
77
143
  return payload;
78
144
  }
79
145
  function normalizeMessage(message) {
@@ -106,6 +172,7 @@ function applyPmCliErrorContext(guidance, rawMessage, context) {
106
172
  const examples = normalizeContextList(context.examples) ?? guidance.examples;
107
173
  const nextSteps = normalizeContextList(context.nextSteps) ?? guidance.nextSteps;
108
174
  const fallbackTitle = guidance.code === "command_failed" && context.code ? buildFallbackTitleFromMessage(normalizedRawMessage) : undefined;
175
+ const recovery = normalizeRecoveryPayload(context.recovery) ?? guidance.recovery;
109
176
  return {
110
177
  ...guidance,
111
178
  code,
@@ -116,6 +183,7 @@ function applyPmCliErrorContext(guidance, rawMessage, context) {
116
183
  why: typeof context.why === "string" && context.why.trim().length > 0 ? context.why.trim() : guidance.why,
117
184
  examples,
118
185
  nextSteps,
186
+ recovery,
119
187
  };
120
188
  }
121
189
  function buildPmCliErrorGuidance(rawMessage, context) {
@@ -267,12 +335,65 @@ function commandExampleForRequiredOption(commandName, optionFlag, allowedTypes)
267
335
  }
268
336
  return [`pm ${commandName ?? "<command>"} --help`];
269
337
  }
338
+ function normalizeRequiredOptionLabel(rawValue) {
339
+ const normalized = rawValue.trim();
340
+ const firstLongFlag = normalized.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0];
341
+ return firstLongFlag ?? normalized;
342
+ }
343
+ function renderPmCommandFromArgs(argv) {
344
+ if (!Array.isArray(argv) || argv.length === 0) {
345
+ return undefined;
346
+ }
347
+ return renderPmCommand(argv);
348
+ }
349
+ function normalizeOptionFlags(values) {
350
+ if (!Array.isArray(values)) {
351
+ return undefined;
352
+ }
353
+ const normalized = values.map((value) => value.trim()).filter((value) => value.length > 0);
354
+ return normalized.length > 0 ? normalized : undefined;
355
+ }
356
+ function buildCommanderRecoveryPayload(context, overrides = {}) {
357
+ const providedFields = normalizeOptionFlags(context?.providedOptionFlags);
358
+ const normalizedArgs = Array.isArray(context?.normalizedInvocationArgs) && context?.normalizedInvocationArgs.length > 0
359
+ ? context.normalizedInvocationArgs
360
+ : undefined;
361
+ const attemptedCommand = typeof context?.attemptedCommand === "string" ? context.attemptedCommand : renderPmCommandFromArgs(normalizedArgs);
362
+ const retryCommand = typeof context?.suggestedRetryCommand === "string" ? context.suggestedRetryCommand : undefined;
363
+ return normalizeRecoveryPayload({
364
+ attempted_command: attemptedCommand,
365
+ normalized_args: normalizedArgs,
366
+ provided_fields: providedFields,
367
+ suggested_retry: retryCommand,
368
+ ...overrides,
369
+ });
370
+ }
371
+ function appendIfMissing(entries, value) {
372
+ if (!value || entries.includes(value)) {
373
+ return entries;
374
+ }
375
+ return [...entries, value];
376
+ }
270
377
  function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, context) {
271
378
  const message = normalizeMessage(rawMessage);
272
379
  const requiredOption = message.match(/required option '([^']+)' not specified/);
273
380
  if (requiredOption) {
274
- const optionFlag = requiredOption[1];
381
+ const optionFlag = normalizeRequiredOptionLabel(requiredOption[1]);
275
382
  const isType = optionFlag.startsWith("--type");
383
+ const retryCommand = context?.suggestedRetryCommand;
384
+ const providedFlags = normalizeOptionFlags(context?.providedOptionFlags);
385
+ const missing = [optionFlag];
386
+ const examples = commandExampleForRequiredOption(commandName, optionFlag, allowedTypes);
387
+ const examplesWithRetry = retryCommand ? appendIfMissing(examples, retryCommand) : examples;
388
+ const nextStepsBase = isType
389
+ ? [`Allowed type values: ${allowedTypes}`, `Run "pm ${commandName ?? "create"} --help --type <value>" for type-aware policy details.`]
390
+ : [`Run "pm ${commandName ?? "<command>"} --help" for required option guidance.`];
391
+ const nextStepsWithRetry = retryCommand
392
+ ? appendIfMissing(nextStepsBase, `Replay with preserved arguments: ${retryCommand}`)
393
+ : nextStepsBase;
394
+ const nextSteps = providedFlags && providedFlags.length > 0
395
+ ? appendIfMissing(nextStepsWithRetry, `Already provided options: ${providedFlags.join(", ")}`)
396
+ : nextStepsWithRetry;
276
397
  return makeGuidanceMessage({
277
398
  code: "missing_required_option",
278
399
  title: `Missing required option ${optionFlag}`,
@@ -281,10 +402,9 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
281
402
  why: isType
282
403
  ? "--type selects item contract and policy routing, including required/disabled option rules."
283
404
  : "Required flags define mandatory command intent and prevent ambiguous execution.",
284
- examples: commandExampleForRequiredOption(commandName, optionFlag, allowedTypes),
285
- nextSteps: isType
286
- ? [`Allowed type values: ${allowedTypes}`, `Run "pm ${commandName ?? "create"} --help --type <value>" for type-aware policy details.`]
287
- : [`Run "pm ${commandName ?? "<command>"} --help" for required option guidance.`],
405
+ examples: examplesWithRetry,
406
+ nextSteps,
407
+ recovery: buildCommanderRecoveryPayload(context, { missing }),
288
408
  });
289
409
  }
290
410
  const missingArgument = message.match(/missing required argument '([^']+)'/);
@@ -297,11 +417,14 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
297
417
  required: `Provide ${argumentName} in the expected command position.`,
298
418
  why: "Positional arguments identify the target entity or action context for the command.",
299
419
  examples: [`pm ${commandName ?? "<command>"} --help`],
420
+ recovery: buildCommanderRecoveryPayload(context, { missing: [argumentName] }),
300
421
  });
301
422
  }
302
423
  const unknownOption = message.match(/unknown option '([^']+)'/);
303
424
  if (unknownOption) {
304
425
  const optionName = unknownOption[1];
426
+ const suggestions = normalizeOptionFlags(context?.unknownOptionSuggestions);
427
+ const retryCommand = context?.suggestedRetryCommand;
305
428
  if (commandName === "update" && (optionName === "--file" || optionName === "--doc")) {
306
429
  return makeGuidanceMessage({
307
430
  code: "unsupported_update_option",
@@ -314,15 +437,31 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
314
437
  'pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"',
315
438
  ],
316
439
  nextSteps: ['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],
440
+ recovery: buildCommanderRecoveryPayload(context, {
441
+ missing: suggestions,
442
+ }),
317
443
  });
318
444
  }
445
+ const nextSteps = [
446
+ "Run command help to confirm the exact option contracts for this command path.",
447
+ ...(suggestions && suggestions.length > 0 ? [`Nearest supported options: ${suggestions.join(", ")}`] : []),
448
+ ...(retryCommand ? [`Replay with suggested correction: ${retryCommand}`] : []),
449
+ ];
450
+ const examples = [
451
+ ...(retryCommand ? [retryCommand] : []),
452
+ `pm ${commandName ?? "<command>"} --help`,
453
+ ];
319
454
  return makeGuidanceMessage({
320
455
  code: "unknown_option",
321
456
  title: `Unknown option ${optionName}`,
322
457
  happened: `Commander does not recognize option ${optionName} for this command path.`,
323
458
  required: "Use supported options only, or move option to the correct subcommand.",
324
459
  why: "Option contracts are command-specific and intentionally validated.",
325
- examples: [`pm ${commandName ?? "<command>"} --help`],
460
+ examples,
461
+ nextSteps,
462
+ recovery: buildCommanderRecoveryPayload(context, {
463
+ missing: suggestions,
464
+ }),
326
465
  });
327
466
  }
328
467
  const unknownCommand = message.match(/unknown command '([^']+)'/);
@@ -338,6 +477,7 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
338
477
  why: "Command registry includes core commands plus active extension command handlers.",
339
478
  examples: runtimeExamples ?? ["pm --help"],
340
479
  nextSteps: runtimeNextSteps ?? ["Verify spelling and active extensions, then rerun."],
480
+ recovery: buildCommanderRecoveryPayload(context),
341
481
  });
342
482
  }
343
483
  return makeGuidanceMessage({
@@ -347,6 +487,7 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
347
487
  required: "Use the command with valid arguments and options.",
348
488
  why: "Commander validates CLI contracts before execution.",
349
489
  examples: ["pm --help", `pm ${commandName ?? "<command>"} --help`],
490
+ recovery: buildCommanderRecoveryPayload(context),
350
491
  });
351
492
  }
352
493
  export function formatPmCliErrorForDisplay(rawMessage, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"error-guidance.js","sourceRoot":"/","sources":["cli/error-guidance.ts"],"names":[],"mappings":"AAyCA,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;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,OAAiB;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CA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AAU,CAAC,CAAC,CAAC;AACzE,CAAC","sourcesContent":["import type { PmCliErrorContext } from \"../core/shared/errors.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}\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}\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}\n\nexport interface CommanderGuidanceContext {\n unknownCommandExamples?: string[];\n unknownCommandNextSteps?: 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\nfunction renderList(title: string, entries: string[]): string[] {\n if (entries.length === 0) {\n return [];\n }\n return [title, ...entries.map((entry) => ` - ${entry}`)];\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 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 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 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 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 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 };\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 \")) {\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: [\"pm create --help\", \"pm update --help\", \"pm calendar --help\"],\n nextSteps: [\"Check allowed values in command help, then rerun with corrected input.\"],\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 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 = requiredOption[1];\n const isType = optionFlag.startsWith(\"--type\");\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: commandExampleForRequiredOption(commandName, optionFlag, allowedTypes),\n nextSteps: 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 });\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 });\n }\n\n const unknownOption = message.match(/unknown option '([^']+)'/);\n if (unknownOption) {\n const optionName = unknownOption[1];\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 });\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: [`pm ${commandName ?? \"<command>\"} --help`],\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 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: runtimeExamples ?? [\"pm --help\"],\n nextSteps: runtimeNextSteps ?? [\"Verify spelling and active extensions, then rerun.\"],\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 });\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"]}
1
+ {"version":3,"file":"error-guidance.js","sourceRoot":"/","sources":["cli/error-guidance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAiDlD,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;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,OAAiB;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,wBAAwB,CAAC,OAA8C;IAC9E,IAAI,CAAC,OAAO,IAAI,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AED,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","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\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 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 \")) {\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: [\"pm create --help\", \"pm update --help\", \"pm calendar --help\"],\n nextSteps: [\"Check allowed values in command help, then rerun with corrected input.\"],\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 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: runtimeExamples ?? [\"pm --help\"],\n nextSteps: runtimeNextSteps ?? [\"Verify spelling and active extensions, then rerun.\"],\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"]}
@@ -5,6 +5,7 @@ import { buildDynamicExtensionHelpOptionSummaries, mergeHelpOptionSummaries, fin
5
5
  import { normalizeHelpCommandPath, resolveHelpDetailMode, resolveHelpNarrative, } from "./help-content.js";
6
6
  import { getCommandPath } from "./registration-helpers.js";
7
7
  import { parseBootstrapGlobalOptions, parseBootstrapHelpRequest, parseBootstrapCommandName, parseBootstrapTypeValue, } from "./bootstrap-args.js";
8
+ import { extractProvidedOptionFlags, renderPmCommand } from "./argv-utils.js";
8
9
  import { formatCommanderErrorForJson } from "./error-guidance.js";
9
10
  import { BUILTIN_TYPE_HELP_VALUES, buildUnknownCommandGuidanceFromRuntime, } from "./commander-usage.js";
10
11
  export function resolveCommandFromPathTokens(root, pathTokens) {
@@ -49,6 +50,9 @@ export function buildOptionAliasMap(options) {
49
50
  }
50
51
  return aliasMap;
51
52
  }
53
+ function renderAttemptedCommand(argv) {
54
+ return renderPmCommand(argv);
55
+ }
52
56
  export function buildHelpOptionSummaries(command) {
53
57
  const options = (command.options ?? []);
54
58
  const optionAliasMap = buildOptionAliasMap(options);
@@ -177,7 +181,13 @@ export async function maybeRenderBootstrapJsonHelp(rootProgram, argv, extensionD
177
181
  if (!targetCommand) {
178
182
  if (!bootstrapGlobal.quiet) {
179
183
  const unknownMessage = `unknown command '${helpRequest.commandPathTokens.join(" ")}'`;
180
- const envelope = formatCommanderErrorForJson(unknownMessage, "help", BUILTIN_TYPE_HELP_VALUES, EXIT_CODE.USAGE, buildUnknownCommandGuidanceFromRuntime(unknownMessage, rootProgram, extensionDescriptors));
184
+ const runtimeContext = buildUnknownCommandGuidanceFromRuntime(unknownMessage, rootProgram, extensionDescriptors);
185
+ const envelope = formatCommanderErrorForJson(unknownMessage, "help", BUILTIN_TYPE_HELP_VALUES, EXIT_CODE.USAGE, {
186
+ ...(runtimeContext ?? {}),
187
+ attemptedCommand: renderAttemptedCommand(argv),
188
+ normalizedInvocationArgs: [...argv],
189
+ providedOptionFlags: extractProvidedOptionFlags(argv),
190
+ });
181
191
  printError(JSON.stringify(envelope, null, 2));
182
192
  }
183
193
  process.exitCode = EXIT_CODE.USAGE;