@unbrained/pm-cli 2026.6.11 → 2026.6.12

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 (180) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cli/commands/completion.js +20 -8
  3. package/dist/cli/commands/completion.js.map +1 -1
  4. package/dist/cli/commands/create.js +6 -3
  5. package/dist/cli/commands/create.js.map +1 -1
  6. package/dist/cli/commands/docs.d.ts +2 -0
  7. package/dist/cli/commands/docs.js +2 -2
  8. package/dist/cli/commands/docs.js.map +1 -1
  9. package/dist/cli/commands/files.d.ts +2 -0
  10. package/dist/cli/commands/files.js +2 -2
  11. package/dist/cli/commands/files.js.map +1 -1
  12. package/dist/cli/commands/health.d.ts +1 -1
  13. package/dist/cli/commands/health.js +77 -2
  14. package/dist/cli/commands/health.js.map +1 -1
  15. package/dist/cli/commands/history-repair.d.ts +36 -0
  16. package/dist/cli/commands/history-repair.js +68 -3
  17. package/dist/cli/commands/history-repair.js.map +1 -1
  18. package/dist/cli/commands/index.d.ts +1 -1
  19. package/dist/cli/commands/index.js +3 -3
  20. package/dist/cli/commands/index.js.map +1 -1
  21. package/dist/cli/commands/linked-artifacts.d.ts +18 -0
  22. package/dist/cli/commands/linked-artifacts.js +26 -3
  23. package/dist/cli/commands/linked-artifacts.js.map +1 -1
  24. package/dist/cli/commands/plan.d.ts +6 -0
  25. package/dist/cli/commands/plan.js +93 -32
  26. package/dist/cli/commands/plan.js.map +1 -1
  27. package/dist/cli/commands/validate.d.ts +20 -0
  28. package/dist/cli/commands/validate.js +292 -28
  29. package/dist/cli/commands/validate.js.map +1 -1
  30. package/dist/cli/help-content.js +7 -3
  31. package/dist/cli/help-content.js.map +1 -1
  32. package/dist/cli/register-mutation.js +47 -16
  33. package/dist/cli/register-mutation.js.map +1 -1
  34. package/dist/cli/register-operations.js +10 -2
  35. package/dist/cli/register-operations.js.map +1 -1
  36. package/dist/cli/register-setup.js +16 -16
  37. package/dist/cli/register-setup.js.map +1 -1
  38. package/dist/cli-bundle/chunks/{chunk-P2PSODAQ.js → chunk-35P4GT6E.js} +110 -9
  39. package/dist/cli-bundle/chunks/chunk-35P4GT6E.js.map +7 -0
  40. package/dist/cli-bundle/chunks/{chunk-B65UUCGQ.js → chunk-37CYVF73.js} +2 -2
  41. package/dist/cli-bundle/chunks/{chunk-J3GD64J2.js → chunk-7AMK6DOW.js} +4 -4
  42. package/dist/cli-bundle/chunks/{chunk-J3GD64J2.js.map → chunk-7AMK6DOW.js.map} +1 -1
  43. package/dist/cli-bundle/chunks/{chunk-IKOH24GZ.js → chunk-AX4GEVQC.js} +3 -3
  44. package/dist/cli-bundle/chunks/{chunk-IKOH24GZ.js.map → chunk-AX4GEVQC.js.map} +2 -2
  45. package/dist/cli-bundle/chunks/chunk-C6SAP27O.js +187 -0
  46. package/dist/cli-bundle/chunks/chunk-C6SAP27O.js.map +1 -0
  47. package/dist/cli-bundle/chunks/chunk-EKS6O2IR.js +217 -0
  48. package/dist/cli-bundle/chunks/chunk-EKS6O2IR.js.map +1 -0
  49. package/dist/cli-bundle/chunks/{chunk-PSD7F7DX.js → chunk-KBPQHXWG.js} +17 -4
  50. package/dist/cli-bundle/chunks/chunk-KBPQHXWG.js.map +1 -0
  51. package/dist/cli-bundle/chunks/{chunk-3SLOMKCJ.js → chunk-L5EPZQIC.js} +2 -2
  52. package/dist/cli-bundle/chunks/chunk-NAWVUHXH.js +220 -0
  53. package/dist/cli-bundle/chunks/chunk-NAWVUHXH.js.map +7 -0
  54. package/dist/cli-bundle/chunks/{chunk-UOO6BYIA.js → chunk-PNYAAB4S.js} +21 -188
  55. package/dist/cli-bundle/chunks/chunk-PNYAAB4S.js.map +1 -0
  56. package/dist/cli-bundle/chunks/chunk-R2OUQVBK.js +190 -0
  57. package/dist/cli-bundle/chunks/chunk-R2OUQVBK.js.map +7 -0
  58. package/dist/cli-bundle/chunks/{chunk-LCSCXBGT.js → chunk-R4VWYWRN.js} +19 -193
  59. package/dist/cli-bundle/chunks/chunk-R4VWYWRN.js.map +7 -0
  60. package/dist/cli-bundle/chunks/{chunk-7RIT3OCD.js → chunk-SO55HRA5.js} +2 -2
  61. package/dist/cli-bundle/chunks/{chunk-FXRU333M.js → chunk-UIG4TW2H.js} +110 -9
  62. package/dist/cli-bundle/chunks/chunk-UIG4TW2H.js.map +1 -0
  63. package/dist/cli-bundle/chunks/{chunk-E5DUIJA4.js → chunk-WPDMBIX6.js} +16 -3
  64. package/dist/cli-bundle/chunks/chunk-WPDMBIX6.js.map +7 -0
  65. package/dist/cli-bundle/chunks/{chunk-IH4MBKK7.js → chunk-XWMF3POR.js} +2 -2
  66. package/dist/cli-bundle/chunks/{contracts-3NKWYKKU.js → contracts-2G66IGIA.js} +2 -2
  67. package/dist/cli-bundle/chunks/{contracts-MIXBWJIB.js → contracts-PJCHYSO5.js} +2 -2
  68. package/dist/cli-bundle/chunks/{create-IFA26O2I.js → create-5433DP3G.js} +2 -2
  69. package/dist/cli-bundle/chunks/{create-JVXYHYH4.js → create-VWLWS34Z.js} +2 -2
  70. package/dist/cli-bundle/chunks/{docs-5WMBVQT2.js → docs-I3BAF5WH.js} +4 -4
  71. package/dist/cli-bundle/chunks/docs-I3BAF5WH.js.map +1 -0
  72. package/dist/cli-bundle/chunks/{docs-MB53UJAJ.js → docs-MXLGZUIT.js} +3 -3
  73. package/dist/cli-bundle/chunks/docs-MXLGZUIT.js.map +7 -0
  74. package/dist/cli-bundle/chunks/{files-GVMNVLCB.js → files-FYP3MDPX.js} +3 -3
  75. package/dist/cli-bundle/chunks/files-FYP3MDPX.js.map +7 -0
  76. package/dist/cli-bundle/chunks/{files-DLB5LJEP.js → files-GUXUM2MB.js} +4 -4
  77. package/dist/cli-bundle/chunks/files-GUXUM2MB.js.map +1 -0
  78. package/dist/cli-bundle/chunks/{gc-2WEPW6D6.js → gc-FENB2ESG.js} +12 -174
  79. package/dist/cli-bundle/chunks/gc-FENB2ESG.js.map +1 -0
  80. package/dist/cli-bundle/chunks/{gc-4Z3IKHAZ.js → gc-KGQG66SA.js} +10 -179
  81. package/dist/cli-bundle/chunks/gc-KGQG66SA.js.map +7 -0
  82. package/dist/cli-bundle/chunks/{health-YO5LRWN4.js → health-7MTXAVR2.js} +71 -4
  83. package/dist/cli-bundle/chunks/health-7MTXAVR2.js.map +7 -0
  84. package/dist/cli-bundle/chunks/{health-4ZYB3IYQ.js → health-E4D7KGHD.js} +72 -5
  85. package/dist/cli-bundle/chunks/health-E4D7KGHD.js.map +1 -0
  86. package/dist/cli-bundle/chunks/{history-repair-KVPFJKOS.js → history-repair-OSQOKJ3E.js} +61 -3
  87. package/dist/cli-bundle/chunks/history-repair-OSQOKJ3E.js.map +7 -0
  88. package/dist/cli-bundle/chunks/{history-repair-RUGKD3YR.js → history-repair-SBK7P34V.js} +62 -4
  89. package/dist/cli-bundle/chunks/history-repair-SBK7P34V.js.map +1 -0
  90. package/dist/cli-bundle/chunks/{plan-VNUG3WZZ.js → plan-2YTQYWGM.js} +52 -12
  91. package/dist/cli-bundle/chunks/plan-2YTQYWGM.js.map +1 -0
  92. package/dist/cli-bundle/chunks/{plan-FQLMJRLZ.js → plan-7IVSICR6.js} +51 -11
  93. package/dist/cli-bundle/chunks/plan-7IVSICR6.js.map +7 -0
  94. package/dist/cli-bundle/chunks/{register-list-query-VHDXWEPP.js → register-list-query-4UPMHONX.js} +3 -3
  95. package/dist/cli-bundle/chunks/{register-list-query-NPE3ECJQ.js → register-list-query-7VOW2C3W.js} +3 -3
  96. package/dist/cli-bundle/chunks/{register-mutation-EAYNLGOS.js → register-mutation-FARSGYRD.js} +43 -26
  97. package/dist/cli-bundle/chunks/{register-mutation-EAYNLGOS.js.map → register-mutation-FARSGYRD.js.map} +2 -2
  98. package/dist/cli-bundle/chunks/{register-mutation-DG53FCBV.js → register-mutation-LJDNVREU.js} +44 -27
  99. package/dist/cli-bundle/chunks/{register-mutation-DG53FCBV.js.map → register-mutation-LJDNVREU.js.map} +1 -1
  100. package/dist/cli-bundle/chunks/{register-operations-AM6KTWB6.js → register-operations-FFTYAL42.js} +17 -13
  101. package/dist/cli-bundle/chunks/register-operations-FFTYAL42.js.map +1 -0
  102. package/dist/cli-bundle/chunks/{register-operations-FWFE64JG.js → register-operations-HCJKDUA6.js} +16 -12
  103. package/dist/cli-bundle/chunks/{register-operations-FWFE64JG.js.map → register-operations-HCJKDUA6.js.map} +2 -2
  104. package/dist/cli-bundle/chunks/{register-setup-IKX5524L.js → register-setup-6AVIUOCC.js} +19 -19
  105. package/dist/cli-bundle/chunks/register-setup-6AVIUOCC.js.map +1 -0
  106. package/dist/cli-bundle/chunks/{register-setup-G4QYI3RX.js → register-setup-KVNLO5OJ.js} +18 -18
  107. package/dist/cli-bundle/chunks/register-setup-KVNLO5OJ.js.map +7 -0
  108. package/dist/cli-bundle/chunks/{update-2EVXOC7V.js → update-36JM7YZT.js} +3 -3
  109. package/dist/cli-bundle/chunks/{update-5A2B6QYB.js → update-I246PCLO.js} +3 -3
  110. package/dist/cli-bundle/chunks/{update-many-V4LA3C4H.js → update-many-F4IKDWZB.js} +3 -3
  111. package/dist/cli-bundle/chunks/{update-many-TUGU5YXQ.js → update-many-NTWZ5YT3.js} +3 -3
  112. package/dist/cli-bundle/chunks/{validate-EQTT6WVX.js → validate-46KCRHL7.js} +448 -36
  113. package/dist/cli-bundle/chunks/validate-46KCRHL7.js.map +1 -0
  114. package/dist/cli-bundle/chunks/{validate-XN4I4DPL.js → validate-CRFMPTYD.js} +468 -35
  115. package/dist/cli-bundle/chunks/validate-CRFMPTYD.js.map +7 -0
  116. package/dist/cli-bundle/main.js +24 -10
  117. package/dist/cli-bundle/main.js.map +2 -2
  118. package/dist/core/diagnostics/remediation.js +19 -6
  119. package/dist/core/diagnostics/remediation.js.map +1 -1
  120. package/dist/core/lock/lock-gc.d.ts +31 -0
  121. package/dist/core/lock/lock-gc.js +120 -62
  122. package/dist/core/lock/lock-gc.js.map +1 -1
  123. package/dist/core/telemetry/consent.js +18 -3
  124. package/dist/core/telemetry/consent.js.map +1 -1
  125. package/dist/core/validate/fix-planning.d.ts +130 -0
  126. package/dist/core/validate/fix-planning.js +202 -0
  127. package/dist/core/validate/fix-planning.js.map +1 -0
  128. package/dist/core/validate/missing-by-type.d.ts +21 -0
  129. package/dist/core/validate/missing-by-type.js +39 -0
  130. package/dist/core/validate/missing-by-type.js.map +1 -0
  131. package/dist/core/validate/stale-file-classification.d.ts +41 -0
  132. package/dist/core/validate/stale-file-classification.js +73 -0
  133. package/dist/core/validate/stale-file-classification.js.map +1 -0
  134. package/dist/mcp/server.js +41 -8
  135. package/dist/mcp/server.js.map +1 -1
  136. package/dist/sdk/cli-contracts/tool-parameter-tables.js +38 -2
  137. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  138. package/dist/sdk/cli-contracts.d.ts +6 -1
  139. package/dist/sdk/cli-contracts.js +74 -7
  140. package/dist/sdk/cli-contracts.js.map +1 -1
  141. package/docs/AGENT_GUIDE.md +6 -1
  142. package/docs/COMMANDS.md +23 -1
  143. package/package.json +1 -1
  144. package/dist/cli-bundle/chunks/chunk-E5DUIJA4.js.map +0 -7
  145. package/dist/cli-bundle/chunks/chunk-FXRU333M.js.map +0 -1
  146. package/dist/cli-bundle/chunks/chunk-LCSCXBGT.js.map +0 -7
  147. package/dist/cli-bundle/chunks/chunk-P2PSODAQ.js.map +0 -7
  148. package/dist/cli-bundle/chunks/chunk-PSD7F7DX.js.map +0 -1
  149. package/dist/cli-bundle/chunks/chunk-UOO6BYIA.js.map +0 -1
  150. package/dist/cli-bundle/chunks/docs-5WMBVQT2.js.map +0 -1
  151. package/dist/cli-bundle/chunks/docs-MB53UJAJ.js.map +0 -7
  152. package/dist/cli-bundle/chunks/files-DLB5LJEP.js.map +0 -1
  153. package/dist/cli-bundle/chunks/files-GVMNVLCB.js.map +0 -7
  154. package/dist/cli-bundle/chunks/gc-2WEPW6D6.js.map +0 -1
  155. package/dist/cli-bundle/chunks/gc-4Z3IKHAZ.js.map +0 -7
  156. package/dist/cli-bundle/chunks/health-4ZYB3IYQ.js.map +0 -1
  157. package/dist/cli-bundle/chunks/health-YO5LRWN4.js.map +0 -7
  158. package/dist/cli-bundle/chunks/history-repair-KVPFJKOS.js.map +0 -7
  159. package/dist/cli-bundle/chunks/history-repair-RUGKD3YR.js.map +0 -1
  160. package/dist/cli-bundle/chunks/plan-FQLMJRLZ.js.map +0 -7
  161. package/dist/cli-bundle/chunks/plan-VNUG3WZZ.js.map +0 -1
  162. package/dist/cli-bundle/chunks/register-operations-AM6KTWB6.js.map +0 -1
  163. package/dist/cli-bundle/chunks/register-setup-G4QYI3RX.js.map +0 -7
  164. package/dist/cli-bundle/chunks/register-setup-IKX5524L.js.map +0 -1
  165. package/dist/cli-bundle/chunks/validate-EQTT6WVX.js.map +0 -1
  166. package/dist/cli-bundle/chunks/validate-XN4I4DPL.js.map +0 -7
  167. /package/dist/cli-bundle/chunks/{chunk-B65UUCGQ.js.map → chunk-37CYVF73.js.map} +0 -0
  168. /package/dist/cli-bundle/chunks/{chunk-3SLOMKCJ.js.map → chunk-L5EPZQIC.js.map} +0 -0
  169. /package/dist/cli-bundle/chunks/{chunk-7RIT3OCD.js.map → chunk-SO55HRA5.js.map} +0 -0
  170. /package/dist/cli-bundle/chunks/{chunk-IH4MBKK7.js.map → chunk-XWMF3POR.js.map} +0 -0
  171. /package/dist/cli-bundle/chunks/{contracts-3NKWYKKU.js.map → contracts-2G66IGIA.js.map} +0 -0
  172. /package/dist/cli-bundle/chunks/{contracts-MIXBWJIB.js.map → contracts-PJCHYSO5.js.map} +0 -0
  173. /package/dist/cli-bundle/chunks/{create-IFA26O2I.js.map → create-5433DP3G.js.map} +0 -0
  174. /package/dist/cli-bundle/chunks/{create-JVXYHYH4.js.map → create-VWLWS34Z.js.map} +0 -0
  175. /package/dist/cli-bundle/chunks/{register-list-query-VHDXWEPP.js.map → register-list-query-4UPMHONX.js.map} +0 -0
  176. /package/dist/cli-bundle/chunks/{register-list-query-NPE3ECJQ.js.map → register-list-query-7VOW2C3W.js.map} +0 -0
  177. /package/dist/cli-bundle/chunks/{update-2EVXOC7V.js.map → update-36JM7YZT.js.map} +0 -0
  178. /package/dist/cli-bundle/chunks/{update-5A2B6QYB.js.map → update-I246PCLO.js.map} +0 -0
  179. /package/dist/cli-bundle/chunks/{update-many-V4LA3C4H.js.map → update-many-F4IKDWZB.js.map} +0 -0
  180. /package/dist/cli-bundle/chunks/{update-many-TUGU5YXQ.js.map → update-many-NTWZ5YT3.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runCreate
3
- } from "./chunk-IKOH24GZ.js";
3
+ } from "./chunk-AX4GEVQC.js";
4
4
  import "./chunk-SXKNJPQ7.js";
5
5
  import "./chunk-TNAP7EJX.js";
6
6
  import "./chunk-XTKJSVWH.js";
@@ -41,7 +41,7 @@ import {
41
41
  !(function() {
42
42
  try {
43
43
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
44
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "91207821-104c-58e1-8a8f-259822fd06d3");
44
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "227d8bfe-b531-50fb-a2f0-b43b2855cd2b");
45
45
  } catch (e2) {
46
46
  }
47
47
  })();
@@ -71,6 +71,10 @@ function resolveAuthor(candidate, fallback) {
71
71
  const trimmed = resolved.trim();
72
72
  return trimmed.length > 0 ? trimmed : "unknown";
73
73
  }
74
+ function toOrderedStepTitles(value) {
75
+ const values = Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
76
+ return values.filter((entry) => entry !== void 0 && entry !== null).map((entry) => (typeof entry === "string" ? entry : String(entry)).trim()).filter((entry) => entry.length > 0);
77
+ }
74
78
  function toArray(value) {
75
79
  if (Array.isArray(value))
76
80
  return value.flatMap((entry) => splitCommaList(entry, { unique: false }));
@@ -497,17 +501,31 @@ async function planCreate(options, global2, ctx) {
497
501
  command: initialValidationCommand || void 0,
498
502
  expected: initialValidationExpected || void 0
499
503
  } : void 0;
500
- if (options.stepTitle?.trim()) {
504
+ const stepTitleFlag = options.stepTitle?.trim();
505
+ const repeatedStepTitles = toOrderedStepTitles(options.step);
506
+ const stepTitles = stepTitleFlag ? [stepTitleFlag, ...repeatedStepTitles] : repeatedStepTitles;
507
+ const hasPerStepDetailOptions = Boolean(options.stepBody?.trim()) || Boolean(options.stepOwner?.trim()) || Boolean(options.stepStatus?.trim()) || Boolean(options.stepEvidence?.trim()) || Boolean(options.stepBlockedReason?.trim()) || Boolean(options.stepReplacement?.trim()) || toArray(options.dependsOn).length > 0 || toArray(options.link).length > 0 || toSpecArray(options.file).length > 0 || toSpecArray(options.test).length > 0 || toSpecArray(options.doc).length > 0;
508
+ if (stepTitles.length > 1 && hasPerStepDetailOptions) {
509
+ throw new PmCliError("pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually", EXIT_CODE.USAGE, {
510
+ code: "ambiguous_option_combination",
511
+ examples: [
512
+ 'pm plan create --title "Execution plan" --step "Read the code" --step "Write the fix"',
513
+ 'pm plan update-step <plan-id> plan-step-001 --step-body "Inspect retry path"'
514
+ ]
515
+ });
516
+ }
517
+ let initialSteps = [];
518
+ if (stepTitles.length === 1) {
501
519
  const status = asStepStatus(options.stepStatus, "pending");
502
520
  const linkedItems = buildLinkInputs(options, "depends_on");
503
521
  const files = toSpecArray(options.file).map(parseStepFile);
504
522
  const tests = toSpecArray(options.test).map(parseStepTest);
505
523
  const docs = toSpecArray(options.doc).map(parseStepDoc);
506
524
  const now = nowIso();
507
- initialStep = {
525
+ initialSteps = [{
508
526
  id: "plan-step-001",
509
527
  order: 1,
510
- title: options.stepTitle.trim(),
528
+ title: stepTitles[0],
511
529
  body: options.stepBody?.trim() || void 0,
512
530
  status,
513
531
  owner: options.stepOwner?.trim() || void 0,
@@ -520,17 +538,30 @@ async function planCreate(options, global2, ctx) {
520
538
  created_at: now,
521
539
  updated_at: now,
522
540
  completed_at: status === "completed" ? now : void 0
523
- };
541
+ }];
542
+ } else if (stepTitles.length > 1) {
543
+ const now = nowIso();
544
+ initialSteps = stepTitles.map((stepTitle, index) => ({
545
+ id: `${STEP_ID_PREFIX}${String(index + 1).padStart(3, "0")}`,
546
+ order: index + 1,
547
+ title: stepTitle,
548
+ status: "pending",
549
+ created_at: now,
550
+ updated_at: now
551
+ }));
552
+ }
553
+ if (initialSteps.length > 0) {
554
+ initialStep = initialSteps[0];
524
555
  const stepped = await mutateItem({
525
556
  pmRoot: ctx.pmRoot,
526
557
  settings: ctx.settings,
527
558
  id: createResult.item.id,
528
559
  op: "plan_create_initial_step",
529
560
  author: resolveAuthor(options.author, ctx.settings.author_default),
530
- message: `plan create initial step "${initialStep.title}"`,
561
+ message: initialSteps.length === 1 ? `plan create initial step "${initialSteps[0].title}"` : `plan create ${initialSteps.length} initial steps`,
531
562
  mutate(doc) {
532
563
  ensurePlanItem(doc.metadata);
533
- doc.metadata.plan_steps = [initialStep];
564
+ doc.metadata.plan_steps = initialSteps;
534
565
  if (initialValidation) {
535
566
  doc.metadata.plan_validation = [...doc.metadata.plan_validation ?? [], initialValidation];
536
567
  }
@@ -553,8 +584,8 @@ async function planCreate(options, global2, ctx) {
553
584
  }
554
585
  });
555
586
  finalMetadata = validated.item;
556
- } else if (options.stepBody?.trim() || options.stepOwner?.trim() || options.stepStatus?.trim() || options.stepEvidence?.trim() || options.stepBlockedReason?.trim() || options.stepReplacement?.trim() || toArray(options.dependsOn).length > 0 || toArray(options.link).length > 0 || toSpecArray(options.file).length > 0 || toSpecArray(options.test).length > 0 || toSpecArray(options.doc).length > 0) {
557
- throw new PmCliError("pm plan create step options require --step-title", EXIT_CODE.USAGE, {
587
+ } else if (hasPerStepDetailOptions) {
588
+ throw new PmCliError("pm plan create step options require --step-title (or a single --step)", EXIT_CODE.USAGE, {
558
589
  code: "missing_required_option",
559
590
  examples: ['pm plan create --title "Execution plan" --step-title "Read the code"']
560
591
  });
@@ -1099,6 +1130,15 @@ async function planMaterialize(id, options, ctx) {
1099
1130
  }
1100
1131
  async function runPlan(input) {
1101
1132
  const ctx = await loadContext(input.global);
1133
+ if (input.subcommand !== "create") {
1134
+ const stepValues = toOrderedStepTitles(input.options.step);
1135
+ if (stepValues.length > 1) {
1136
+ throw new PmCliError(`pm plan ${input.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`, EXIT_CODE.USAGE);
1137
+ }
1138
+ if (stepValues.length === 1 && !input.options.stepTitle?.trim()) {
1139
+ input = { ...input, options: { ...input.options, stepTitle: stepValues[0] } };
1140
+ }
1141
+ }
1102
1142
  switch (input.subcommand) {
1103
1143
  case "create":
1104
1144
  return planCreate(input.options, input.global, ctx);
@@ -1171,4 +1211,4 @@ export {
1171
1211
  PLAN_SUBCOMMANDS,
1172
1212
  runPlan
1173
1213
  };
1174
- //# sourceMappingURL=plan-FQLMJRLZ.js.map
1214
+ //# sourceMappingURL=plan-7IVSICR6.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../cli/commands/plan.ts"],
4
+ "sourcesContent": ["import { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport { resolveItemTypeRegistry, resolveTypeName } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { splitCommaList } from \"../../core/shared/split-comma-list.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport { locateItem, mutateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport type {\n DependencyKind,\n ItemDocument,\n ItemMetadata,\n PlanDecision,\n PlanDiscovery,\n PlanHarness,\n PlanMode,\n PlanStep,\n PlanStepDoc,\n PlanStepFile,\n PlanStepLink,\n PlanStepLinkKind,\n PlanStepStatus,\n PlanStepTest,\n PlanValidationCheck,\n} from \"../../types/index.js\";\nimport {\n PLAN_HARNESS_VALUES,\n PLAN_MODE_VALUES,\n PLAN_STEP_LINK_KIND_VALUES,\n PLAN_STEP_STATUS_VALUES,\n} from \"../../types/index.js\";\nimport { runCreate, type CreateCommandOptions, type CreateResult } from \"./create.js\";\n\nexport const PLAN_SUBCOMMANDS = [\n \"create\",\n \"show\",\n \"add-step\",\n \"update-step\",\n \"complete-step\",\n \"block-step\",\n \"reorder-step\",\n \"remove-step\",\n \"link\",\n \"unlink\",\n \"decision\",\n \"discovery\",\n \"validation\",\n \"resume\",\n \"approve\",\n \"materialize\",\n] as const;\nexport type PlanSubcommand = (typeof PLAN_SUBCOMMANDS)[number];\n\nexport const PLAN_SHOW_DEPTH_VALUES = [\"brief\", \"standard\", \"deep\"] as const;\nexport type PlanShowDepth = (typeof PLAN_SHOW_DEPTH_VALUES)[number];\n\nexport interface PlanCommandOptions {\n title?: string;\n description?: string;\n scope?: string;\n parent?: string;\n related?: string | string[];\n blocks?: string | string[];\n blockedBy?: string | string[];\n harness?: string;\n mode?: string;\n resumeContext?: string;\n tags?: string;\n priority?: string;\n body?: string;\n claim?: boolean;\n fromSearch?: string;\n stepTitle?: string;\n /**\n * pm-6mit: repeatable --step values. On create each value seeds one ordered\n * step (argv order; values are never comma-split so titles may contain\n * commas). On other subcommands a single value aliases stepTitle.\n */\n step?: string | string[];\n stepBody?: string;\n stepOwner?: string;\n stepStatus?: string;\n stepEvidence?: string;\n stepBlockedReason?: string;\n stepReplacement?: string;\n dependsOn?: string | string[];\n link?: string | string[];\n linkKind?: string;\n linkNote?: string;\n promoteToItemDep?: boolean;\n allowMultipleActive?: boolean;\n file?: string | string[];\n test?: string | string[];\n doc?: string | string[];\n decisionText?: string;\n decision?: string;\n decisionRationale?: string;\n decisionEvidence?: string;\n discoveryText?: string;\n discovery?: string;\n validationText?: string;\n validation?: string;\n validationCommand?: string;\n validationExpected?: string;\n depth?: string;\n fields?: string;\n steps?: string;\n materializeType?: string;\n materializeParent?: string;\n materializeTags?: string;\n author?: string;\n message?: string;\n force?: boolean;\n}\n\nexport interface PlanCommandResult {\n action: PlanSubcommand;\n plan: PlanResultPlan;\n step?: PlanStep;\n current_step?: PlanStep | undefined;\n next_actions?: string[];\n materialized?: { id: string; type: string; from_step: string }[];\n // pm-fl0c #10 (2026-05-28): steps that pm plan materialize intentionally\n // skipped (already-completed or already-materialized via an `implements`\n // link). Surfacing these makes `--steps all` idempotent without users\n // having to read history to find out what was done.\n materialize_skipped?: { from_step: string; reason: \"already_completed\" | \"already_materialized\"; existing_id?: string }[];\n warnings: string[];\n generated_at: string;\n}\n\nexport interface PlanResultPlan {\n id: string;\n title: string;\n status: string;\n mode: PlanMode;\n scope?: string;\n harness?: PlanHarness;\n parent?: string;\n resume_context?: string;\n steps_summary: PlanStepSummary;\n current_step?: { id: string; order: number; title: string; status: PlanStepStatus } | undefined;\n blocked_steps?: { id: string; order: number; title: string; blocked_reason?: string }[];\n steps?: PlanStep[];\n decisions?: PlanDecision[];\n discoveries?: PlanDiscovery[];\n validation?: PlanValidationCheck[];\n linked_items?: { id: string; kind: DependencyKind }[];\n}\n\nexport interface PlanStepSummary {\n total: number;\n pending: number;\n in_progress: number;\n blocked: number;\n completed: number;\n skipped: number;\n superseded: number;\n}\n\nconst STEP_ID_PREFIX = \"plan-step-\";\nconst DEFAULT_PLAN_MODE: PlanMode = \"draft\";\n\nfunction resolveAuthor(candidate: string | undefined, fallback: string): string {\n const resolved = candidate ?? process.env.PM_AUTHOR ?? fallback;\n const trimmed = resolved.trim();\n return trimmed.length > 0 ? trimmed : \"unknown\";\n}\n\n/**\n * pm-6mit: ordered step titles from repeated --step values. Unlike toArray\n * this NEVER comma-splits — each --step value is one full step title, so\n * titles containing commas survive intact (also why --step must not be\n * list:true in contracts: the bootstrap coalescer would comma-join values).\n */\nfunction toOrderedStepTitles(value: unknown): string[] {\n const values = Array.isArray(value) ? value : value === undefined || value === null ? [] : [value];\n return values\n .filter((entry) => entry !== undefined && entry !== null)\n .map((entry) => (typeof entry === \"string\" ? entry : String(entry)).trim())\n .filter((entry) => entry.length > 0);\n}\n\nfunction toArray(value: string | string[] | undefined): string[] {\n if (Array.isArray(value)) return value.flatMap((entry) => splitCommaList(entry, { unique: false }));\n if (typeof value === \"string\" && value.trim().length > 0) {\n return splitCommaList(value, { unique: false });\n }\n return [];\n}\n\nfunction toSpecArray(value: string | string[] | undefined): string[] {\n if (Array.isArray(value)) return value.map((entry) => entry.trim()).filter(Boolean);\n if (typeof value === \"string\" && value.trim().length > 0) return [value.trim()];\n return [];\n}\n\nfunction asPlanMode(value: string | undefined, fallback: PlanMode = DEFAULT_PLAN_MODE): PlanMode {\n if (value === undefined) return fallback;\n const normalized = value.trim().toLowerCase();\n const found = PLAN_MODE_VALUES.find((entry) => entry === normalized);\n if (!found) {\n throw new PmCliError(\n `Invalid plan mode \"${value}\". Allowed: ${PLAN_MODE_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return found;\n}\n\nfunction asStepStatus(value: string | undefined, fallback: PlanStepStatus = \"pending\"): PlanStepStatus {\n if (value === undefined) return fallback;\n const normalized = value.trim().toLowerCase();\n const found = PLAN_STEP_STATUS_VALUES.find((entry) => entry === normalized);\n if (!found) {\n throw new PmCliError(\n `Invalid step status \"${value}\". Allowed: ${PLAN_STEP_STATUS_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return found;\n}\n\nfunction asLinkKind(value: string | undefined, fallback: PlanStepLinkKind = \"related\"): PlanStepLinkKind {\n if (value === undefined) return fallback;\n const normalized = value.trim().toLowerCase();\n const found = PLAN_STEP_LINK_KIND_VALUES.find((entry) => entry === normalized);\n if (!found) {\n throw new PmCliError(\n `Invalid step link kind \"${value}\". Allowed: ${PLAN_STEP_LINK_KIND_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return found;\n}\n\nfunction asHarness(value: string | undefined): PlanHarness | undefined {\n if (value === undefined) return undefined;\n const normalized = value.trim().toLowerCase();\n if (normalized.length === 0) return undefined;\n const found = PLAN_HARNESS_VALUES.find((entry) => entry === normalized);\n if (!found) {\n throw new PmCliError(\n `Invalid plan harness \"${value}\". Allowed: ${PLAN_HARNESS_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return found;\n}\n\nfunction asDepth(value: string | undefined): PlanShowDepth {\n if (value === undefined) return \"brief\";\n const normalized = value.trim().toLowerCase();\n const found = PLAN_SHOW_DEPTH_VALUES.find((entry) => entry === normalized);\n if (!found) {\n throw new PmCliError(\n `Invalid --depth \"${value}\". Allowed: ${PLAN_SHOW_DEPTH_VALUES.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return found;\n}\n\nfunction parsePlanFields(raw: string | undefined): string[] | null {\n if (raw === undefined) {\n return null;\n }\n const fields = raw\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0);\n if (fields.length === 0) {\n throw new PmCliError(\"Plan --fields requires a comma-separated list of plan field names\", EXIT_CODE.USAGE);\n }\n return fields;\n}\n\nconst PLAN_FIELD_KEYS = new Set<keyof PlanResultPlan>([\n \"id\",\n \"title\",\n \"status\",\n \"mode\",\n \"scope\",\n \"harness\",\n \"parent\",\n \"resume_context\",\n \"steps_summary\",\n \"current_step\",\n \"blocked_steps\",\n \"steps\",\n \"decisions\",\n \"discoveries\",\n \"validation\",\n \"linked_items\",\n]);\n\nfunction projectPlanForFields(plan: PlanResultPlan, fields: string[]): PlanResultPlan {\n const source = plan as unknown as Record<string, unknown>;\n const projected: Record<string, unknown> = {};\n const unknownFields: string[] = [];\n for (const field of fields) {\n const normalized = field.startsWith(\"plan.\") ? field.slice(\"plan.\".length) : field;\n if (normalized.length === 0) {\n continue;\n }\n if (!PLAN_FIELD_KEYS.has(normalized as keyof PlanResultPlan)) {\n unknownFields.push(field);\n continue;\n }\n if (Object.prototype.hasOwnProperty.call(source, normalized)) {\n projected[normalized] = source[normalized];\n }\n }\n if (unknownFields.length > 0) {\n throw new PmCliError(`Unknown Plan --fields value(s): ${unknownFields.join(\", \")}`, EXIT_CODE.USAGE, {\n nextSteps: [\n `Use --fields ${[...PLAN_FIELD_KEYS].join(\",\")}`,\n \"Run pm plan show <id> --depth brief for compact default fields.\",\n ],\n recovery: {\n provided_fields: unknownFields,\n suggested_retry: `pm plan show <id> --fields ${[...PLAN_FIELD_KEYS].join(\",\")}`,\n },\n });\n }\n return projected as unknown as PlanResultPlan;\n}\n\nfunction parsePairList(raw: string, label: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const entry of raw.split(\",\")) {\n const trimmed = entry.trim();\n if (trimmed.length === 0) continue;\n const equalsIndex = trimmed.indexOf(\"=\");\n if (equalsIndex <= 0) {\n throw new PmCliError(`Invalid ${label} entry \"${trimmed}\"; expected key=value`, EXIT_CODE.USAGE);\n }\n out[trimmed.slice(0, equalsIndex).trim().toLowerCase()] = trimmed.slice(equalsIndex + 1).trim();\n }\n return out;\n}\n\nfunction parseStepFile(spec: string): PlanStepFile {\n const fields = parsePairList(spec, \"--file\");\n if (!fields.path) {\n throw new PmCliError(\"--file requires path=<value>\", EXIT_CODE.USAGE);\n }\n const file: PlanStepFile = { path: fields.path };\n if (fields.scope === \"global\" || fields.scope === \"project\") file.scope = fields.scope;\n if (fields.note) file.note = fields.note;\n return file;\n}\n\nfunction parseStepTest(spec: string): PlanStepTest {\n const fields = parsePairList(spec, \"--test\");\n if (!fields.command && !fields.path) {\n throw new PmCliError(\"--test requires at least command=<value> or path=<value>\", EXIT_CODE.USAGE);\n }\n const test: PlanStepTest = {};\n if (fields.command) test.command = fields.command;\n if (fields.path) test.path = fields.path;\n if (fields.note) test.note = fields.note;\n return test;\n}\n\nfunction parseStepDoc(spec: string): PlanStepDoc {\n const fields = parsePairList(spec, \"--doc\");\n if (!fields.path) {\n throw new PmCliError(\"--doc requires path=<value>\", EXIT_CODE.USAGE);\n }\n const doc: PlanStepDoc = { path: fields.path };\n if (fields.scope === \"global\" || fields.scope === \"project\") doc.scope = fields.scope;\n if (fields.note) doc.note = fields.note;\n return doc;\n}\n\nfunction summarizeSteps(steps: PlanStep[]): PlanStepSummary {\n const summary: PlanStepSummary = {\n total: steps.length,\n pending: 0,\n in_progress: 0,\n blocked: 0,\n completed: 0,\n skipped: 0,\n superseded: 0,\n };\n for (const step of steps) {\n summary[step.status] += 1;\n }\n return summary;\n}\n\nfunction newStepId(existing: PlanStep[]): string {\n const used = new Set(existing.map((step) => step.id));\n for (let cursor = existing.length + 1; cursor < existing.length + 1024; cursor += 1) {\n const candidate = `${STEP_ID_PREFIX}${String(cursor).padStart(3, \"0\")}`;\n if (!used.has(candidate)) return candidate;\n }\n /* c8 ignore next -- step id allocation only fails if 1024 consecutive ids are taken. */\n throw new PmCliError(\"Could not allocate step id (limit reached)\", EXIT_CODE.GENERIC_FAILURE);\n}\n\nfunction resolveStepRef(steps: PlanStep[], ref: string): PlanStep {\n const trimmed = ref.trim();\n if (trimmed.length === 0) {\n throw new PmCliError(\"Step reference cannot be empty\", EXIT_CODE.USAGE);\n }\n const direct = steps.find((step) => step.id === trimmed);\n if (direct) return direct;\n if (/^\\d+$/.test(trimmed)) {\n const order = Number.parseInt(trimmed, 10);\n const byOrder = steps.find((step) => step.order === order);\n if (byOrder) return byOrder;\n }\n throw new PmCliError(`Step \"${ref}\" not found in plan`, EXIT_CODE.NOT_FOUND);\n}\n\ninterface MaterializeTargetResolution {\n targets: PlanStep[];\n skipped: { from_step: string; reason: \"already_completed\" | \"already_materialized\"; existing_id?: string }[];\n}\n\n// pm-fl0c #10 (2026-05-28): skip steps whose status is \"completed\" and steps\n// that already have an `implements` link from a prior materialize run, so\n// `pm plan materialize --steps all` is idempotent and never re-creates fresh\n// Tasks for work already tracked. Explicit step refs are still allowed\n// through (the user asked by ID) but the skip-reason is recorded.\nfunction classifyMaterializeSkip(\n step: PlanStep,\n): { reason: \"already_completed\" | \"already_materialized\"; existing_id?: string } | undefined {\n if (step.status === \"completed\") {\n return { reason: \"already_completed\" };\n }\n const existingImplements = (step.linked_items ?? []).find((link) => link.kind === \"implements\");\n if (existingImplements) {\n return { reason: \"already_materialized\", existing_id: existingImplements.id };\n }\n return undefined;\n}\n\nfunction resolveMaterializeTargets(steps: PlanStep[], refs: string[]): MaterializeTargetResolution {\n const allRefs = refs.filter((ref) => ref.trim().toLowerCase() === \"all\");\n const targets: PlanStep[] = [];\n const skipped: { from_step: string; reason: \"already_completed\" | \"already_materialized\"; existing_id?: string }[] = [];\n if (allRefs.length > 0) {\n if (refs.length > allRefs.length) {\n throw new PmCliError(\"pm plan materialize --steps all cannot be combined with other step refs\", EXIT_CODE.USAGE);\n }\n for (const step of steps.slice().sort((left, right) => left.order - right.order)) {\n const skip = classifyMaterializeSkip(step);\n if (skip) {\n skipped.push({ from_step: step.id, ...skip });\n continue;\n }\n targets.push(step);\n }\n return { targets, skipped };\n }\n const seen = new Set<string>();\n for (const ref of refs) {\n const step = resolveStepRef(steps, ref);\n if (seen.has(step.id)) continue;\n seen.add(step.id);\n const skip = classifyMaterializeSkip(step);\n if (skip) {\n skipped.push({ from_step: step.id, ...skip });\n continue;\n }\n targets.push(step);\n }\n return { targets, skipped };\n}\n\nfunction resolvePlanLogText(kind: \"decision\" | \"discovery\" | \"validation\", options: PlanCommandOptions): string | undefined {\n const canonical =\n kind === \"decision\"\n ? options.decisionText\n : kind === \"discovery\"\n ? options.discoveryText\n : options.validationText;\n const shorthand =\n kind === \"decision\"\n ? options.decision\n : kind === \"discovery\"\n ? options.discovery\n : options.validation;\n return canonical?.trim() || shorthand?.trim() || undefined;\n}\n\nfunction findCurrentStep(steps: PlanStep[]): PlanStep | undefined {\n return steps.find((step) => step.status === \"in_progress\")\n ?? steps.find((step) => step.status === \"pending\");\n}\n\nfunction blockedSteps(steps: PlanStep[]): { id: string; order: number; title: string; blocked_reason?: string }[] {\n return steps\n .filter((step) => step.status === \"blocked\")\n .map((step) => ({ id: step.id, order: step.order, title: step.title, blocked_reason: step.blocked_reason }));\n}\n\nfunction projectPlan(item: ItemMetadata, depth: PlanShowDepth = \"brief\"): PlanResultPlan {\n const steps = (item.plan_steps ?? []).slice().sort((left, right) => left.order - right.order);\n const summary = summarizeSteps(steps);\n const current = findCurrentStep(steps);\n const projection: PlanResultPlan = {\n id: item.id,\n title: item.title,\n status: item.status,\n mode: (item.plan_mode ?? DEFAULT_PLAN_MODE) as PlanMode,\n scope: item.plan_scope,\n harness: item.plan_harness,\n parent: item.parent,\n resume_context: item.plan_resume_context,\n steps_summary: summary,\n current_step: current\n ? { id: current.id, order: current.order, title: current.title, status: current.status }\n : undefined,\n blocked_steps: blockedSteps(steps),\n linked_items: (item.dependencies ?? []).map((dep) => ({ id: dep.id, kind: dep.kind })),\n };\n if (depth === \"standard\" || depth === \"deep\") {\n projection.steps = steps;\n }\n if (depth === \"deep\") {\n projection.decisions = item.plan_decisions ?? [];\n projection.discoveries = item.plan_discoveries ?? [];\n projection.validation = item.plan_validation ?? [];\n }\n return projection;\n}\n\nfunction nextActionsFor(planId: string, plan: PlanResultPlan): string[] {\n const tips: string[] = [];\n if (plan.steps_summary.total === 0) {\n tips.push(`pm plan add-step ${planId} --step-title \"First step\"`);\n }\n if (plan.current_step) {\n tips.push(\n `pm plan update-step ${planId} ${plan.current_step.id} --step-status in_progress`,\n `pm plan complete-step ${planId} ${plan.current_step.id} --step-evidence \"...\"`,\n );\n }\n if (plan.steps_summary.blocked > 0) {\n tips.push(`pm plan show ${planId} --depth standard`);\n }\n if (plan.mode === \"draft\" || plan.mode === \"research\") {\n tips.push(`pm plan approve ${planId} --message \"ready to execute\"`);\n }\n if (plan.steps_summary.completed === plan.steps_summary.total && plan.steps_summary.total > 0) {\n tips.push(`pm close ${planId} \"plan complete\"`);\n }\n return tips;\n}\n\nfunction ensurePlanItem(item: ItemMetadata): void {\n const normalizedType = (item.type ?? \"\").trim().toLowerCase();\n if (normalizedType !== \"plan\") {\n throw new PmCliError(\n `Item ${item.id} is type ${item.type}; pm plan commands require type=Plan. Use pm plan create or pm create --type Plan first.`,\n EXIT_CODE.USAGE,\n {\n code: \"wrong_item_type\",\n required: \"Use pm plan commands only with items whose type is Plan.\",\n why: \"Plan commands read and mutate Plan-specific step, decision, discovery, and validation fields.\",\n examples: [\n `pm get ${item.id} --depth brief`,\n 'pm plan create --title \"Execution plan\" --scope \"<goal>\"',\n ],\n },\n );\n }\n}\n\ninterface PlanWriteContext {\n pmRoot: string;\n settings: Awaited<ReturnType<typeof readSettings>>;\n}\n\nasync function loadContext(global: GlobalOptions): Promise<PlanWriteContext> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n const settings = await readSettings(pmRoot);\n return { pmRoot, settings };\n}\n\nasync function readPlanItem(ctx: PlanWriteContext, id: string): Promise<{ document: ItemDocument; itemId: string }> {\n const typeRegistry = resolveItemTypeRegistry(ctx.settings, getActiveExtensionRegistrations());\n const located = await locateItem(ctx.pmRoot, id, ctx.settings.id_prefix, ctx.settings.item_format, typeRegistry.type_to_folder);\n if (!located) {\n throw new PmCliError(`Plan ${id} not found`, EXIT_CODE.NOT_FOUND);\n }\n const loaded = await readLocatedItem(located, { schema: ctx.settings.schema });\n ensurePlanItem(loaded.document.metadata);\n return { document: loaded.document, itemId: located.id };\n}\n\nasync function planCreate(\n options: PlanCommandOptions,\n global: GlobalOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const title = options.title?.trim();\n if (!title) {\n throw new PmCliError(\"pm plan create requires --title\", EXIT_CODE.USAGE, {\n code: \"missing_required_option\",\n examples: ['pm plan create --title \"Refactor lock retry\" --scope pm-a1b2'],\n });\n }\n const mode = asPlanMode(options.mode, DEFAULT_PLAN_MODE);\n const harness = asHarness(options.harness);\n const fromSearch = options.fromSearch?.trim();\n\n const related = toArray(options.related);\n const blocks = toArray(options.blocks);\n const blockedBy = toArray(options.blockedBy);\n\n const deps: string[] = [];\n if (options.parent) {\n deps.push(`id=${options.parent.trim()},kind=parent`);\n }\n for (const ref of related) deps.push(`id=${ref},kind=related`);\n for (const ref of blocks) deps.push(`id=${ref},kind=blocks`);\n for (const ref of blockedBy) deps.push(`id=${ref},kind=blocked_by`);\n\n const description = options.description?.trim() ?? options.scope?.trim() ?? title;\n const createOptions: CreateCommandOptions = {\n title,\n description,\n type: \"Plan\",\n body: options.body,\n tags: options.tags,\n priority: options.priority,\n parent: options.parent,\n dep: deps.length > 0 ? deps : undefined,\n author: options.author,\n message: options.message ?? (fromSearch ? `plan create (search: ${fromSearch})` : `plan create`),\n };\n\n const createResult: CreateResult = await runCreate(createOptions, global);\n\n // The create command stores type_options. To use real metadata keys, run a follow-up mutate.\n const seedResult = await mutateItem({\n pmRoot: ctx.pmRoot,\n settings: ctx.settings,\n id: createResult.item.id,\n op: \"plan_create_metadata\",\n author: resolveAuthor(options.author, ctx.settings.author_default),\n message: \"seed plan metadata\",\n mutate(doc) {\n const changed: string[] = [];\n doc.metadata.plan_mode = mode;\n changed.push(\"plan_mode\");\n if (harness) {\n doc.metadata.plan_harness = harness;\n changed.push(\"plan_harness\");\n }\n if (options.scope?.trim()) {\n doc.metadata.plan_scope = options.scope.trim();\n changed.push(\"plan_scope\");\n }\n if (options.resumeContext?.trim()) {\n doc.metadata.plan_resume_context = options.resumeContext.trim();\n changed.push(\"plan_resume_context\");\n }\n doc.metadata.plan_steps = doc.metadata.plan_steps ?? [];\n return { changedFields: changed };\n },\n });\n\n let finalMetadata: ItemMetadata = seedResult.item as unknown as ItemMetadata;\n let initialStep: PlanStep | undefined;\n const initialValidationText = options.validationText?.trim();\n const initialValidationCommand = options.validationCommand?.trim();\n const initialValidationExpected = options.validationExpected?.trim();\n const initialValidation =\n initialValidationText || initialValidationCommand || initialValidationExpected\n ? ({\n text: initialValidationText || initialValidationCommand || \"Validation check\",\n command: initialValidationCommand || undefined,\n expected: initialValidationExpected || undefined,\n } satisfies PlanValidationCheck)\n : undefined;\n // pm-6mit: collect ordered initial-step titles. Mixed-usage semantics\n // (documented on pm-6mit): --step-title (when present) is the FIRST step,\n // followed by each repeated --step value in argv order.\n const stepTitleFlag = options.stepTitle?.trim();\n const repeatedStepTitles = toOrderedStepTitles(options.step);\n const stepTitles = stepTitleFlag ? [stepTitleFlag, ...repeatedStepTitles] : repeatedStepTitles;\n const hasPerStepDetailOptions =\n Boolean(options.stepBody?.trim()) ||\n Boolean(options.stepOwner?.trim()) ||\n Boolean(options.stepStatus?.trim()) ||\n Boolean(options.stepEvidence?.trim()) ||\n Boolean(options.stepBlockedReason?.trim()) ||\n Boolean(options.stepReplacement?.trim()) ||\n toArray(options.dependsOn).length > 0 ||\n toArray(options.link).length > 0 ||\n toSpecArray(options.file).length > 0 ||\n toSpecArray(options.test).length > 0 ||\n toSpecArray(options.doc).length > 0;\n if (stepTitles.length > 1 && hasPerStepDetailOptions) {\n // Per-step detail flags target exactly one step; silently attaching them to\n // the first (or all) of several seeded steps would be unpredictable.\n throw new PmCliError(\n \"pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually\",\n EXIT_CODE.USAGE,\n {\n code: \"ambiguous_option_combination\",\n examples: [\n 'pm plan create --title \"Execution plan\" --step \"Read the code\" --step \"Write the fix\"',\n 'pm plan update-step <plan-id> plan-step-001 --step-body \"Inspect retry path\"',\n ],\n },\n );\n }\n let initialSteps: PlanStep[] = [];\n if (stepTitles.length === 1) {\n const status = asStepStatus(options.stepStatus, \"pending\");\n const linkedItems = buildLinkInputs(options, \"depends_on\");\n const files = toSpecArray(options.file).map(parseStepFile);\n const tests = toSpecArray(options.test).map(parseStepTest);\n const docs = toSpecArray(options.doc).map(parseStepDoc);\n const now = nowIso();\n initialSteps = [{\n id: \"plan-step-001\",\n order: 1,\n title: stepTitles[0],\n body: options.stepBody?.trim() || undefined,\n status,\n owner: options.stepOwner?.trim() || undefined,\n evidence: options.stepEvidence?.trim() || undefined,\n blocked_reason: status === \"blocked\" ? options.stepBlockedReason?.trim() || \"\" : undefined,\n linked_items: linkedItems.length > 0 ? linkedItems : undefined,\n files: files.length > 0 ? files : undefined,\n tests: tests.length > 0 ? tests : undefined,\n docs: docs.length > 0 ? docs : undefined,\n created_at: now,\n updated_at: now,\n completed_at: status === \"completed\" ? now : undefined,\n }];\n } else if (stepTitles.length > 1) {\n const now = nowIso();\n initialSteps = stepTitles.map((stepTitle, index) => ({\n id: `${STEP_ID_PREFIX}${String(index + 1).padStart(3, \"0\")}`,\n order: index + 1,\n title: stepTitle,\n status: \"pending\" as const,\n created_at: now,\n updated_at: now,\n }));\n }\n if (initialSteps.length > 0) {\n initialStep = initialSteps[0];\n const stepped = await mutateItem({\n pmRoot: ctx.pmRoot,\n settings: ctx.settings,\n id: createResult.item.id,\n op: \"plan_create_initial_step\",\n author: resolveAuthor(options.author, ctx.settings.author_default),\n message:\n initialSteps.length === 1\n ? `plan create initial step \"${initialSteps[0].title}\"`\n : `plan create ${initialSteps.length} initial steps`,\n mutate(doc) {\n ensurePlanItem(doc.metadata);\n doc.metadata.plan_steps = initialSteps;\n if (initialValidation) {\n doc.metadata.plan_validation = [...(doc.metadata.plan_validation ?? []), initialValidation];\n }\n return { changedFields: initialValidation ? [\"plan_steps\", \"plan_validation\"] : [\"plan_steps\"] };\n },\n });\n finalMetadata = stepped.item as unknown as ItemMetadata;\n } else if (initialValidation) {\n const validated = await mutateItem({\n pmRoot: ctx.pmRoot,\n settings: ctx.settings,\n id: createResult.item.id,\n op: \"plan_create_initial_validation\",\n author: resolveAuthor(options.author, ctx.settings.author_default),\n message: \"plan create initial validation\",\n mutate(doc) {\n ensurePlanItem(doc.metadata);\n doc.metadata.plan_validation = [...(doc.metadata.plan_validation ?? []), initialValidation];\n return { changedFields: [\"plan_validation\"] };\n },\n });\n finalMetadata = validated.item as unknown as ItemMetadata;\n } else if (hasPerStepDetailOptions) {\n throw new PmCliError(\"pm plan create step options require --step-title (or a single --step)\", EXIT_CODE.USAGE, {\n code: \"missing_required_option\",\n examples: ['pm plan create --title \"Execution plan\" --step-title \"Read the code\"'],\n });\n }\n if (options.claim) {\n const claimed = await mutateItem({\n pmRoot: ctx.pmRoot,\n settings: ctx.settings,\n id: createResult.item.id,\n op: \"claim\",\n author: resolveAuthor(options.author, ctx.settings.author_default),\n message: \"plan claim by author\",\n mutate(doc) {\n doc.metadata.assignee = resolveAuthor(options.author, ctx.settings.author_default);\n return { changedFields: [\"assignee\"] };\n },\n });\n finalMetadata = claimed.item as unknown as ItemMetadata;\n }\n\n const plan = projectPlan(finalMetadata, \"brief\");\n return {\n action: \"create\",\n plan,\n step: initialStep,\n next_actions: nextActionsFor(createResult.item.id, plan),\n warnings: [...createResult.warnings],\n generated_at: nowIso(),\n };\n}\n\nasync function planShow(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const depth = asDepth(options.depth);\n const fields = parsePlanFields(options.fields);\n const { document, itemId } = await readPlanItem(ctx, id);\n const fullPlan = projectPlan(document.metadata, fields === null ? depth : \"deep\");\n const plan = fields === null ? fullPlan : projectPlanForFields(fullPlan, fields);\n return {\n action: \"show\",\n plan,\n next_actions: nextActionsFor(itemId, fullPlan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\ninterface MutateStepArgs {\n id: string;\n options: PlanCommandOptions;\n ctx: PlanWriteContext;\n op: string;\n message: string;\n mutator(steps: PlanStep[], doc: ItemDocument): { changedSteps: string[]; current?: PlanStep; resultStep?: PlanStep };\n}\n\nasync function mutatePlanSteps(args: MutateStepArgs): Promise<{ document: ItemDocument; resultStep?: PlanStep; itemId: string }> {\n const author = resolveAuthor(args.options.author, args.ctx.settings.author_default);\n let resultStep: PlanStep | undefined;\n const result = await mutateItem({\n pmRoot: args.ctx.pmRoot,\n settings: args.ctx.settings,\n id: args.id,\n op: args.op,\n author,\n message: args.options.message ?? args.message,\n force: args.options.force,\n mutate(doc) {\n ensurePlanItem(doc.metadata);\n const steps = (doc.metadata.plan_steps ?? []).slice();\n const before = JSON.stringify(steps);\n const outcome = args.mutator(steps, doc);\n resultStep = outcome.resultStep;\n const sorted = steps\n .slice()\n .sort((left, right) => left.order - right.order)\n .map((step, index) => ({ ...step, order: index + 1 }));\n doc.metadata.plan_steps = sorted;\n const after = JSON.stringify(sorted);\n const changedFields = before === after ? [] : [\"plan_steps\"];\n if (changedFields.length === 0 && outcome.changedSteps.length === 0) {\n return { changedFields: [] };\n }\n return { changedFields: changedFields.length > 0 ? changedFields : [\"plan_steps\"] };\n },\n });\n return {\n document: { metadata: result.item as unknown as ItemMetadata, body: result.body },\n resultStep,\n itemId: result.item.id,\n };\n}\n\nasync function planAddStep(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const title = options.stepTitle?.trim();\n if (!title) {\n throw new PmCliError(\"pm plan add-step requires --step-title\", EXIT_CODE.USAGE);\n }\n const status = asStepStatus(options.stepStatus, \"pending\");\n const allowMultipleActive = options.allowMultipleActive === true;\n\n const linkedItems = buildLinkInputs(options, \"depends_on\");\n\n const files = toSpecArray(options.file).map(parseStepFile);\n const tests = toSpecArray(options.test).map(parseStepTest);\n const docs = toSpecArray(options.doc).map(parseStepDoc);\n\n const { document, resultStep, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_add_step\",\n message: `plan add-step \"${title}\"`,\n mutator(steps) {\n const order = steps.length + 1;\n if (status === \"in_progress\" && !allowMultipleActive) {\n for (const step of steps) {\n if (step.status === \"in_progress\") {\n throw new PmCliError(\n `Plan already has step ${step.id} in_progress. Pass --allow-multiple-active or update that step first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n }\n }\n const now = nowIso();\n const step: PlanStep = {\n id: newStepId(steps),\n order,\n title,\n body: options.stepBody?.trim() || undefined,\n status,\n owner: options.stepOwner?.trim() || undefined,\n evidence: options.stepEvidence?.trim() || undefined,\n blocked_reason: status === \"blocked\" ? options.stepBlockedReason?.trim() || \"\" : undefined,\n linked_items: linkedItems.length > 0 ? linkedItems : undefined,\n files: files.length > 0 ? files : undefined,\n tests: tests.length > 0 ? tests : undefined,\n docs: docs.length > 0 ? docs : undefined,\n created_at: now,\n updated_at: now,\n completed_at: status === \"completed\" ? now : undefined,\n };\n steps.push(step);\n return { changedSteps: [step.id], resultStep: step };\n },\n });\n\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"add-step\",\n plan,\n step: resultStep,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nfunction buildLinkInputs(options: PlanCommandOptions, fallbackKind: PlanStepLinkKind): PlanStepLink[] {\n const dependsOn = toArray(options.dependsOn).map((id) => ({ id, kind: fallbackKind } as PlanStepLink));\n const related = toArray(options.related).map((id) => ({ id, kind: \"related\" } as PlanStepLink));\n const blocks = toArray(options.blocks).map((id) => ({ id, kind: \"blocks\" } as PlanStepLink));\n const blockedBy = toArray(options.blockedBy).map((id) => ({ id, kind: \"blocked_by\" } as PlanStepLink));\n const explicit = toArray(options.link);\n const explicitKind = asLinkKind(options.linkKind, fallbackKind);\n const note = options.linkNote?.trim();\n const explicitLinks = explicit.map((id) => {\n const link: PlanStepLink = { id, kind: explicitKind };\n if (note) link.note = note;\n return link;\n });\n return [...dependsOn, ...related, ...blocks, ...blockedBy, ...explicitLinks];\n}\n\nasync function planUpdateStep(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n args: { stepRef: string; finalStatus?: PlanStepStatus; op: string; allowMultipleActive?: boolean },\n): Promise<PlanCommandResult> {\n const { document, resultStep, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: args.op,\n message: options.message ?? `${args.op} ${args.stepRef}`,\n mutator(steps, doc) {\n const step = resolveStepRef(steps, args.stepRef);\n const now = nowIso();\n const desiredStatus = args.finalStatus ?? asStepStatus(options.stepStatus, step.status);\n if (desiredStatus === \"in_progress\" && step.status !== \"in_progress\" && !options.allowMultipleActive && !args.allowMultipleActive) {\n for (const other of steps) {\n if (other.id !== step.id && other.status === \"in_progress\") {\n throw new PmCliError(\n `Plan already has step ${other.id} in_progress. Pass --allow-multiple-active or update that step first.`,\n EXIT_CODE.CONFLICT,\n );\n }\n }\n }\n if (desiredStatus === \"blocked\" && !options.stepBlockedReason?.trim() && !step.blocked_reason) {\n throw new PmCliError(\n \"Blocking a step requires --step-blocked-reason or an already-recorded blocked_reason.\",\n EXIT_CODE.USAGE,\n );\n }\n if (options.stepTitle?.trim()) step.title = options.stepTitle.trim();\n if (options.stepBody !== undefined) step.body = options.stepBody.trim() || undefined;\n if (options.stepOwner !== undefined) step.owner = options.stepOwner.trim() || undefined;\n if (options.stepEvidence !== undefined) step.evidence = options.stepEvidence.trim() || undefined;\n if (options.stepBlockedReason !== undefined) step.blocked_reason = options.stepBlockedReason.trim() || undefined;\n if (options.stepReplacement !== undefined) step.superseded_by = options.stepReplacement.trim() || undefined;\n step.status = desiredStatus;\n step.updated_at = now;\n if (desiredStatus === \"completed\" && !step.completed_at) {\n step.completed_at = now;\n } else if (desiredStatus !== \"completed\") {\n step.completed_at = undefined;\n }\n doc.metadata.updated_at = now;\n return { changedSteps: [step.id], resultStep: step };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: args.op === \"plan_complete_step\" ? \"complete-step\" : args.op === \"plan_block_step\" ? \"block-step\" : \"update-step\",\n plan,\n step: resultStep,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planReorderStep(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n stepRef: string,\n newOrder: number,\n): Promise<PlanCommandResult> {\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_reorder_step\",\n message: options.message ?? `plan reorder-step ${stepRef} -> ${newOrder}`,\n mutator(steps) {\n const step = resolveStepRef(steps, stepRef);\n const filtered = steps.filter((entry) => entry.id !== step.id);\n const clamped = Math.max(1, Math.min(newOrder, filtered.length + 1));\n filtered.splice(clamped - 1, 0, step);\n filtered.forEach((entry, index) => {\n entry.order = index + 1;\n entry.updated_at = nowIso();\n });\n steps.length = 0;\n steps.push(...filtered);\n return { changedSteps: [step.id], resultStep: step };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"reorder-step\",\n plan,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planRemoveStep(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n stepRef: string,\n): Promise<PlanCommandResult> {\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_remove_step\",\n message: options.message ?? `plan remove-step ${stepRef}`,\n mutator(steps) {\n const step = resolveStepRef(steps, stepRef);\n const remaining = steps.filter((entry) => entry.id !== step.id);\n remaining.forEach((entry, index) => {\n entry.order = index + 1;\n });\n steps.length = 0;\n steps.push(...remaining);\n return { changedSteps: [step.id] };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"remove-step\",\n plan,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planLink(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n stepRef: string,\n): Promise<PlanCommandResult> {\n const newLinks = buildLinkInputs(options, asLinkKind(options.linkKind, \"related\"));\n if (newLinks.length === 0) {\n throw new PmCliError(\"pm plan link requires at least one --link/--related/--blocks/--blocked-by/--depends-on id\", EXIT_CODE.USAGE);\n }\n const promoteToItemDep = options.promoteToItemDep === true;\n const { document, itemId, resultStep } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_link_step\",\n message: options.message ?? `plan link ${stepRef}`,\n mutator(steps, doc) {\n const step = resolveStepRef(steps, stepRef);\n const existing = step.linked_items ?? [];\n const dedupKey = (link: PlanStepLink) => `${link.kind}:${link.id}`;\n const seen = new Set(existing.map(dedupKey));\n for (const link of newLinks) {\n const key = dedupKey(link);\n if (seen.has(key)) continue;\n existing.push(link);\n seen.add(key);\n }\n step.linked_items = existing;\n step.updated_at = nowIso();\n if (promoteToItemDep) {\n const deps = doc.metadata.dependencies ?? [];\n const depKey = (dep: { id: string; kind: string }) => `${dep.kind}:${dep.id}`;\n const seenDeps = new Set(deps.map(depKey));\n for (const link of newLinks) {\n const candidate = {\n id: link.id,\n kind: link.kind as DependencyKind,\n created_at: nowIso(),\n author: resolveAuthor(options.author, ctx.settings.author_default),\n };\n if (seenDeps.has(depKey(candidate))) continue;\n deps.push(candidate);\n seenDeps.add(depKey(candidate));\n }\n doc.metadata.dependencies = deps;\n }\n return { changedSteps: [step.id], resultStep: step };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"link\",\n plan,\n step: resultStep,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planUnlink(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n stepRef: string,\n): Promise<PlanCommandResult> {\n const removeIds = toArray(options.link);\n if (removeIds.length === 0) {\n throw new PmCliError(\"pm plan unlink requires --link <id> to remove\", EXIT_CODE.USAGE);\n }\n const { document, itemId, resultStep } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_unlink_step\",\n message: options.message ?? `plan unlink ${stepRef}`,\n mutator(steps) {\n const step = resolveStepRef(steps, stepRef);\n const filtered = (step.linked_items ?? []).filter((link) => !removeIds.includes(link.id));\n step.linked_items = filtered.length > 0 ? filtered : undefined;\n step.updated_at = nowIso();\n return { changedSteps: [step.id], resultStep: step };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"unlink\",\n plan,\n step: resultStep,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planAppendLog(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n kind: \"decision\" | \"discovery\" | \"validation\",\n): Promise<PlanCommandResult> {\n const logText = resolvePlanLogText(kind, options);\n if (!logText) {\n const canonical = `--${kind}-text`;\n const shorthand = `--${kind}`;\n throw new PmCliError(`pm plan ${kind} requires ${canonical}`, EXIT_CODE.USAGE, {\n code: \"missing_required_option\",\n examples: [\n `pm plan ${kind} <plan-id> ${canonical} \"...\"`,\n `pm plan ${kind} <plan-id> ${shorthand} \"...\"`,\n ],\n recovery: {\n suggested_retry: `pm plan ${kind} <plan-id> ${canonical} <value>`,\n },\n });\n }\n const author = resolveAuthor(options.author, ctx.settings.author_default);\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: `plan_append_${kind}`,\n message: options.message ?? `plan ${kind} append`,\n mutator(_steps, doc) {\n const now = nowIso();\n if (kind === \"decision\") {\n const list = doc.metadata.plan_decisions ?? [];\n list.push({\n ts: now,\n author,\n decision: logText,\n rationale: options.decisionRationale?.trim() || undefined,\n evidence: options.decisionEvidence?.trim() || undefined,\n });\n doc.metadata.plan_decisions = list;\n return { changedSteps: [] };\n }\n if (kind === \"discovery\") {\n const list = doc.metadata.plan_discoveries ?? [];\n list.push({ ts: now, author, text: logText });\n doc.metadata.plan_discoveries = list;\n return { changedSteps: [] };\n }\n const list = doc.metadata.plan_validation ?? [];\n list.push({\n text: logText,\n command: options.validationCommand?.trim() || undefined,\n expected: options.validationExpected?.trim() || undefined,\n });\n doc.metadata.plan_validation = list;\n return { changedSteps: [] };\n },\n });\n const plan = projectPlan(document.metadata, \"deep\");\n return {\n action: kind,\n plan,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planResume(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const text = options.resumeContext?.trim();\n if (!text) {\n throw new PmCliError(\"pm plan resume requires --resume-context <text>\", EXIT_CODE.USAGE);\n }\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_resume\",\n message: options.message ?? \"plan resume context update\",\n mutator(_steps, doc) {\n doc.metadata.plan_resume_context = text;\n return { changedSteps: [] };\n },\n });\n const plan = projectPlan(document.metadata, \"brief\");\n return {\n action: \"resume\",\n plan,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planApprove(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const mode = asPlanMode(options.mode ?? \"approved\", \"approved\");\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_approve\",\n message: options.message ?? `plan approve mode=${mode}`,\n mutator(_steps, doc) {\n doc.metadata.plan_mode = mode;\n return { changedSteps: [] };\n },\n });\n const plan = projectPlan(document.metadata, \"brief\");\n return {\n action: \"approve\",\n plan,\n next_actions: nextActionsFor(itemId, plan),\n warnings: [],\n generated_at: nowIso(),\n };\n}\n\nasync function planMaterialize(\n id: string,\n options: PlanCommandOptions,\n ctx: PlanWriteContext,\n): Promise<PlanCommandResult> {\n const stepRefs = toArray(options.steps);\n if (stepRefs.length === 0) {\n throw new PmCliError(\"pm plan materialize requires --steps <ids|orders|all>\", EXIT_CODE.USAGE);\n }\n const targetType = options.materializeType?.trim() || \"Task\";\n const typeRegistry = resolveItemTypeRegistry(ctx.settings, getActiveExtensionRegistrations());\n const resolvedTypeName = resolveTypeName(targetType, typeRegistry);\n if (!resolvedTypeName) {\n throw new PmCliError(`Invalid --materialize-type \"${targetType}\"`, EXIT_CODE.USAGE);\n }\n const parent = options.materializeParent?.trim() || id;\n const tags = options.materializeTags;\n\n const planRead = await readPlanItem(ctx, id);\n const steps = (planRead.document.metadata.plan_steps ?? []).slice();\n const { targets, skipped: materializeSkipped } = resolveMaterializeTargets(steps, stepRefs);\n if (targets.length === 0) {\n if (materializeSkipped.length > 0) {\n // PR #78 / Gemini medium follow-up: when every selected step was\n // already materialized or completed, return a successful no-op\n // result (exit 0) instead of throwing NOT_FOUND. This makes\n // `pm plan materialize --steps all` truly idempotent for CI/agent\n // workflows; the skip reasons + warnings still surface what was\n // intentionally not redone.\n const plan = projectPlan(planRead.document.metadata, \"standard\");\n return {\n action: \"materialize\",\n plan,\n materialized: [],\n materialize_skipped: materializeSkipped,\n next_actions: nextActionsFor(planRead.itemId, plan),\n warnings: materializeSkipped.map(\n (entry) =>\n `plan_materialize_skipped:${entry.from_step}:${entry.reason}${entry.existing_id ? `:${entry.existing_id}` : \"\"}`,\n ),\n generated_at: nowIso(),\n };\n }\n throw new PmCliError(\"No matching plan steps found for --steps\", EXIT_CODE.NOT_FOUND);\n }\n\n const materialized: { id: string; type: string; from_step: string }[] = [];\n for (const step of targets) {\n const deps = [\n `id=${parent},kind=parent`,\n `id=${planRead.itemId},kind=discovered_from`,\n ];\n for (const link of step.linked_items ?? []) {\n const realKind: DependencyKind =\n link.kind === \"blocked_by\" || link.kind === \"blocks\" || link.kind === \"related\" || link.kind === \"discovered_from\"\n ? link.kind\n : \"related\";\n deps.push(`id=${link.id},kind=${realKind}`);\n }\n const created = await runCreate(\n {\n title: step.title,\n description: step.body?.trim() || step.title,\n type: resolvedTypeName,\n parent,\n tags,\n author: options.author,\n message: options.message ?? `materialized from plan ${planRead.itemId} step ${step.id}`,\n dep: deps,\n },\n ctx.settings ? { ...({} as GlobalOptions), path: ctx.pmRoot } as GlobalOptions : ({} as GlobalOptions),\n );\n materialized.push({ id: created.item.id, type: resolvedTypeName, from_step: step.id });\n }\n\n const { document, itemId } = await mutatePlanSteps({\n id,\n options,\n ctx,\n op: \"plan_materialize\",\n message: options.message ?? `plan materialize ${stepRefs.join(\",\")}`,\n mutator(currentSteps, doc) {\n for (const target of targets) {\n const matched = materialized.find((entry) => entry.from_step === target.id);\n if (!matched) continue;\n const step = currentSteps.find((entry) => entry.id === target.id);\n if (!step) continue;\n const links = step.linked_items ?? [];\n links.push({ id: matched.id, kind: \"implements\", note: `materialized as ${matched.type}` });\n step.linked_items = links;\n step.updated_at = nowIso();\n }\n return { changedSteps: targets.map((entry) => entry.id) };\n },\n });\n const plan = projectPlan(document.metadata, \"standard\");\n return {\n action: \"materialize\",\n plan,\n materialized,\n ...(materializeSkipped.length > 0 ? { materialize_skipped: materializeSkipped } : {}),\n next_actions: nextActionsFor(itemId, plan),\n warnings: materializeSkipped.map(\n (entry) =>\n `plan_materialize_skipped:${entry.from_step}:${entry.reason}${entry.existing_id ? `:${entry.existing_id}` : \"\"}`,\n ),\n generated_at: nowIso(),\n };\n}\n\nexport interface PlanDispatchInput {\n subcommand: PlanSubcommand;\n id?: string;\n stepRef?: string;\n reorderTo?: number;\n options: PlanCommandOptions;\n global: GlobalOptions;\n}\n\nexport async function runPlan(input: PlanDispatchInput): Promise<PlanCommandResult> {\n const ctx = await loadContext(input.global);\n // pm-6mit: --step accumulates ordered step titles on create. For every other\n // subcommand a single --step value keeps its historical alias-of---step-title\n // behavior; multiple values would be ambiguous there (one step is targeted),\n // so they are rejected instead of silently dropping all but the last.\n if (input.subcommand !== \"create\") {\n const stepValues = toOrderedStepTitles(input.options.step);\n if (stepValues.length > 1) {\n throw new PmCliError(\n `pm plan ${input.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`,\n EXIT_CODE.USAGE,\n );\n }\n if (stepValues.length === 1 && !input.options.stepTitle?.trim()) {\n input = { ...input, options: { ...input.options, stepTitle: stepValues[0] } };\n }\n }\n switch (input.subcommand) {\n case \"create\":\n return planCreate(input.options, input.global, ctx);\n case \"show\":\n if (!input.id) throw new PmCliError(\"pm plan show requires a plan id\", EXIT_CODE.USAGE);\n return planShow(input.id, input.options, ctx);\n case \"add-step\":\n if (!input.id) throw new PmCliError(\"pm plan add-step requires a plan id\", EXIT_CODE.USAGE);\n return planAddStep(input.id, input.options, ctx);\n case \"update-step\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan update-step requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planUpdateStep(input.id, input.options, ctx, { stepRef: input.stepRef, op: \"plan_update_step\" });\n case \"complete-step\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan complete-step requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planUpdateStep(input.id, input.options, ctx, { stepRef: input.stepRef, finalStatus: \"completed\", op: \"plan_complete_step\" });\n case \"block-step\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan block-step requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planUpdateStep(input.id, input.options, ctx, { stepRef: input.stepRef, finalStatus: \"blocked\", op: \"plan_block_step\" });\n case \"reorder-step\":\n if (!input.id || !input.stepRef || input.reorderTo === undefined)\n throw new PmCliError(\"pm plan reorder-step requires <plan-id> <step> <new-order>\", EXIT_CODE.USAGE);\n return planReorderStep(input.id, input.options, ctx, input.stepRef, input.reorderTo);\n case \"remove-step\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan remove-step requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planRemoveStep(input.id, input.options, ctx, input.stepRef);\n case \"link\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan link requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planLink(input.id, input.options, ctx, input.stepRef);\n case \"unlink\":\n if (!input.id || !input.stepRef) throw new PmCliError(\"pm plan unlink requires <plan-id> <step>\", EXIT_CODE.USAGE);\n return planUnlink(input.id, input.options, ctx, input.stepRef);\n case \"decision\":\n if (!input.id) throw new PmCliError(\"pm plan decision requires a plan id\", EXIT_CODE.USAGE);\n return planAppendLog(input.id, input.options, ctx, \"decision\");\n case \"discovery\":\n if (!input.id) throw new PmCliError(\"pm plan discovery requires a plan id\", EXIT_CODE.USAGE);\n return planAppendLog(input.id, input.options, ctx, \"discovery\");\n case \"validation\":\n if (!input.id) throw new PmCliError(\"pm plan validation requires a plan id\", EXIT_CODE.USAGE);\n return planAppendLog(input.id, input.options, ctx, \"validation\");\n case \"resume\":\n if (!input.id) throw new PmCliError(\"pm plan resume requires a plan id\", EXIT_CODE.USAGE);\n return planResume(input.id, input.options, ctx);\n case \"approve\":\n if (!input.id) throw new PmCliError(\"pm plan approve requires a plan id\", EXIT_CODE.USAGE);\n return planApprove(input.id, input.options, ctx);\n case \"materialize\":\n if (!input.id) throw new PmCliError(\"pm plan materialize requires a plan id\", EXIT_CODE.USAGE);\n return planMaterialize(input.id, input.options, ctx);\n default:\n throw new PmCliError(`Unknown pm plan subcommand \"${input.subcommand}\"`, EXIT_CODE.USAGE);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCO,IAAM,mBAAmB;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAIK,IAAM,yBAAyB,CAAC,SAAS,YAAY,MAAM;AA2GlE,IAAM,iBAAiB;AACvB,IAAM,oBAA8B;AAEpC,SAAS,cAAc,WAA+B,UAAgB;AACpE,QAAM,WAAW,aAAa,QAAQ,IAAI,aAAa;AACvD,QAAM,UAAU,SAAS,KAAI;AAC7B,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAQA,SAAS,oBAAoB,OAAc;AACzC,QAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,UAAU,UAAa,UAAU,OAAO,CAAA,IAAK,CAAC,KAAK;AACjG,SAAO,OACJ,OAAO,CAAC,UAAU,UAAU,UAAa,UAAU,IAAI,EACvD,IAAI,CAAC,WAAW,OAAO,UAAU,WAAW,QAAQ,OAAO,KAAK,GAAG,KAAI,CAAE,EACzE,OAAO,CAAC,UAAU,MAAM,SAAS,CAAC;AACvC;AAEA,SAAS,QAAQ,OAAoC;AACnD,MAAI,MAAM,QAAQ,KAAK;AAAG,WAAO,MAAM,QAAQ,CAAC,UAA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JsonStream,
10
10
  printListJsonStream,
11
11
  resolveActivityStreamMode
12
- } from "./chunk-B65UUCGQ.js";
13
- import "./chunk-P2PSODAQ.js";
12
+ } from "./chunk-37CYVF73.js";
13
+ import "./chunk-35P4GT6E.js";
14
14
  import "./chunk-7UGSRQCL.js";
15
15
  import {
16
16
  printError,
@@ -235,4 +235,4 @@ function registerListQueryCommands(program, options) {
235
235
  export {
236
236
  registerListQueryCommands
237
237
  };
238
- //# sourceMappingURL=register-list-query-VHDXWEPP.js.map
238
+ //# sourceMappingURL=register-list-query-4UPMHONX.js.map
@@ -11,8 +11,8 @@ import {
11
11
  printActivityJsonStream,
12
12
  printListJsonStream,
13
13
  resolveActivityStreamMode
14
- } from "./chunk-IH4MBKK7.js";
15
- import "./chunk-FXRU333M.js";
14
+ } from "./chunk-XWMF3POR.js";
15
+ import "./chunk-UIG4TW2H.js";
16
16
  import "./chunk-XJDGS74Y.js";
17
17
  import {
18
18
  printError,
@@ -230,6 +230,6 @@ function registerListQueryCommands(program, options) {
230
230
  export {
231
231
  registerListQueryCommands
232
232
  };
233
- //# sourceMappingURL=register-list-query-NPE3ECJQ.js.map
233
+ //# sourceMappingURL=register-list-query-7VOW2C3W.js.map
234
234
 
235
235
  //# debugId=3c8f53c1-d9fa-599b-9b8b-83da76ea068e
@@ -6,11 +6,11 @@ import {
6
6
  invalidateSearchCachesForMutation,
7
7
  normalizeCreateOptions,
8
8
  normalizeUpdateOptions
9
- } from "./chunk-B65UUCGQ.js";
9
+ } from "./chunk-37CYVF73.js";
10
10
  import {
11
11
  CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS,
12
12
  UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS
13
- } from "./chunk-P2PSODAQ.js";
13
+ } from "./chunk-35P4GT6E.js";
14
14
  import "./chunk-7UGSRQCL.js";
15
15
  import {
16
16
  printError,
@@ -66,7 +66,7 @@ function isPureSnakeCaseAlias(canonicalFlagSpec, aliasFlagSpec) {
66
66
  !(function() {
67
67
  try {
68
68
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
69
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "f05f0b6a-38aa-501a-af20-476b9d77d383");
69
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "07f90455-c9f8-5cb9-86fe-be98e72908cb");
70
70
  } catch (e2) {
71
71
  }
72
72
  })();
@@ -155,7 +155,7 @@ function registerMutationCommands(program) {
155
155
  options.title = positionalTitle;
156
156
  }
157
157
  const normalized = normalizeCreateOptions(options, { requireType: false });
158
- const { runCreate } = await import("./create-JVXYHYH4.js");
158
+ const { runCreate } = await import("./create-VWLWS34Z.js");
159
159
  const result = await runCreate(normalized, globalOptions);
160
160
  await invalidateSearchCachesForMutation(globalOptions, result);
161
161
  printResult(result, globalOptions);
@@ -186,7 +186,7 @@ function registerMutationCommands(program) {
186
186
  updateCommand.action(async (id, options, command) => {
187
187
  const globalOptions = getGlobalOptions(command);
188
188
  const startedAt = Date.now();
189
- const { runUpdate } = await import("./update-2EVXOC7V.js");
189
+ const { runUpdate } = await import("./update-36JM7YZT.js");
190
190
  const result = await runUpdate(id, normalizeUpdateOptions(options), globalOptions);
191
191
  await invalidateSearchCachesForMutation(globalOptions, result);
192
192
  printResult(result, globalOptions);
@@ -226,7 +226,7 @@ function registerMutationCommands(program) {
226
226
  updateManyCommand.action(async (options, command) => {
227
227
  const globalOptions = getGlobalOptions(command);
228
228
  const startedAt = Date.now();
229
- const { runUpdateMany } = await import("./update-many-TUGU5YXQ.js");
229
+ const { runUpdateMany } = await import("./update-many-NTWZ5YT3.js");
230
230
  const result = await runUpdateMany({
231
231
  status: typeof options.filterStatus === "string" ? options.filterStatus : void 0,
232
232
  list: {
@@ -408,7 +408,7 @@ function registerMutationCommands(program) {
408
408
  printError(`profile:command=restore took_ms=${Date.now() - startedAt}`);
409
409
  }
410
410
  });
411
- const planCommand = program.command("plan").description("Agent-optimized Plan item workflow: create, manage steps, link dependencies, approve, and materialize.").argument("[subcommand]", "Plan subcommand: create|show|add-step|update-step|complete-step|block-step|reorder-step|remove-step|link|unlink|decision|discovery|validation|resume|approve|materialize").argument("[id]", "Plan id (required for non-create subcommands); for create this may be the positional title").argument("[stepRef]", "Step reference: stable id (plan-step-001) or order integer").argument("[reorderTo]", "New order integer for reorder-step").option("--title <value>", "Plan title").option("--description <value>", "Plan description").option("--scope <value>", "Short scope statement of the target change or investigation").option("--parent <value>", "Parent pm item id").option("--related <value>", "Related pm item ids (repeatable, csv-friendly)", collect).option("--blocks <value>", "Pm item ids this plan blocks (repeatable, csv-friendly)", collect).option("--blocked-by <value>", "Pm item ids that block this plan (repeatable, csv-friendly)", collect).option("--harness <value>", "Plan harness provenance: codex|claude-code|cursor|generic").option("--mode <value>", "Plan mode: draft|research|review|approved|executing|paused|completed|superseded").option("--resume-context <value>", "Compact context summary for a future stateless agent").option("--tags <value>", "Comma-separated tags").option("--priority <value>", "Priority 0-4").option("--body <value>", "Plan item body").option("--claim", "Claim the plan on create for the author").option("--from-search <value>", "Record the search query that led to plan creation").option("--step-title <value>", "Step title for add-step / update-step").option("--step <value>", "Alias for --step-title").option("--step-body <value>", "Step body text").option("--step-owner <value>", "Step owner").option("--step-status <value>", "Step status: pending|in_progress|completed|blocked|skipped|superseded").option("--step-evidence <value>", "Step evidence text (used by update-step/complete-step)").option("--step-blocked-reason <value>", "Step blocked reason (required when blocking)").option("--step-replacement <value>", "Replacement reference for a superseded step").option("--depends-on <value>", "Pm item ids the step depends on (repeatable, csv-friendly)", collect).option("--link <value>", "Pm item id to link (repeatable, csv-friendly)", collect).option("--link-kind <value>", "Link kind: related|blocks|blocked_by|depends_on|discovered_from|implements|verifies|supersedes").option("--link-note <value>", "Optional note for the link").option("--promote-to-item-dep", "Also add the linked id as a top-level item dependency when linking").option("--allow-multiple-active", "Allow multiple steps to be in_progress at once").option("--file <value>", "Step linked file path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--test <value>", "Step linked test command=<value>[,path=<value>,note=<text>] (repeatable)", collect).option("--doc <value>", "Step linked doc path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--decision-text <value>", "Decision log entry text").option("--decision <value>", "Alias for --decision-text").option("--decision-rationale <value>", "Decision log entry rationale").option("--decision-evidence <value>", "Decision log entry evidence").option("--discovery-text <value>", "Discovery log entry text").option("--discovery <value>", "Alias for --discovery-text").option("--validation-text <value>", "Validation log entry text").option("--validation <value>", "Alias for --validation-text").option("--validation-command <value>", "Validation log entry command").option("--validation-expected <value>", "Validation log entry expected outcome").option("--depth <value>", "Show depth: brief|standard|deep (default: brief)").option("--fields <value>", "Comma-separated field projection for show output").option("--steps <value>", "Comma-separated step ids/orders for materialize").option("--materialize-type <value>", "Item type for materialized steps (default: Task)").option("--materialize-parent <value>", "Parent item id for materialized children (default: the plan)").option("--materialize-tags <value>", "Comma-separated tags for materialized children").option("--author <value>", "Mutation author").option("--message <value>", "Mutation message").option("--force", "Force ownership override");
411
+ const planCommand = program.command("plan").description("Agent-optimized Plan item workflow: create, manage steps, link dependencies, approve, and materialize.").argument("[subcommand]", "Plan subcommand: create|show|add-step|update-step|complete-step|block-step|reorder-step|remove-step|link|unlink|decision|discovery|validation|resume|approve|materialize").argument("[id]", "Plan id (required for non-create subcommands); for create this may be the positional title").argument("[stepRef]", "Step reference: stable id (plan-step-001) or order integer").argument("[reorderTo]", "New order integer for reorder-step").option("--title <value>", "Plan title").option("--description <value>", "Plan description").option("--scope <value>", "Short scope statement of the target change or investigation").option("--parent <value>", "Parent pm item id").option("--related <value>", "Related pm item ids (repeatable, csv-friendly)", collect).option("--blocks <value>", "Pm item ids this plan blocks (repeatable, csv-friendly)", collect).option("--blocked-by <value>", "Pm item ids that block this plan (repeatable, csv-friendly)", collect).option("--harness <value>", "Plan harness provenance: codex|claude-code|cursor|generic").option("--mode <value>", "Plan mode: draft|research|review|approved|executing|paused|completed|superseded").option("--resume-context <value>", "Compact context summary for a future stateless agent").option("--tags <value>", "Comma-separated tags").option("--priority <value>", "Priority 0-4").option("--body <value>", "Plan item body").option("--claim", "Claim the plan on create for the author").option("--from-search <value>", "Record the search query that led to plan creation").option("--step-title <value>", "Step title for add-step / update-step").option("--step <value>", "Step title (repeatable on create: each --step appends an ordered step; elsewhere a single value aliases --step-title)", collect).option("--step-body <value>", "Step body text").option("--step-owner <value>", "Step owner").option("--step-status <value>", "Step status: pending|in_progress|completed|blocked|skipped|superseded").option("--step-evidence <value>", "Step evidence text (used by update-step/complete-step)").option("--step-blocked-reason <value>", "Step blocked reason (required when blocking)").option("--step-replacement <value>", "Replacement reference for a superseded step").option("--depends-on <value>", "Pm item ids the step depends on (repeatable, csv-friendly)", collect).option("--link <value>", "Pm item id to link (repeatable, csv-friendly)", collect).option("--link-kind <value>", "Link kind: related|blocks|blocked_by|depends_on|discovered_from|implements|verifies|supersedes").option("--link-note <value>", "Optional note for the link").option("--promote-to-item-dep", "Also add the linked id as a top-level item dependency when linking").option("--allow-multiple-active", "Allow multiple steps to be in_progress at once").option("--file <value>", "Step linked file path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--test <value>", "Step linked test command=<value>[,path=<value>,note=<text>] (repeatable)", collect).option("--doc <value>", "Step linked doc path=<value>[,scope=project|global,note=<text>] (repeatable)", collect).option("--decision-text <value>", "Decision log entry text").option("--decision <value>", "Alias for --decision-text").option("--decision-rationale <value>", "Decision log entry rationale").option("--decision-evidence <value>", "Decision log entry evidence").option("--discovery-text <value>", "Discovery log entry text").option("--discovery <value>", "Alias for --discovery-text").option("--validation-text <value>", "Validation log entry text").option("--validation <value>", "Alias for --validation-text").option("--validation-command <value>", "Validation log entry command").option("--validation-expected <value>", "Validation log entry expected outcome").option("--depth <value>", "Show depth: brief|standard|deep (default: brief)").option("--fields <value>", "Comma-separated field projection for show output").option("--steps <value>", "Comma-separated step ids/orders for materialize").option("--materialize-type <value>", "Item type for materialized steps (default: Task)").option("--materialize-parent <value>", "Parent item id for materialized children (default: the plan)").option("--materialize-tags <value>", "Comma-separated tags for materialized children").option("--author <value>", "Mutation author").option("--message <value>", "Mutation message").option("--force", "Force ownership override");
412
412
  for (const [flags, description] of [
413
413
  ["--resume_context <value>", "Alias for --resume-context"],
414
414
  ["--from_search <value>", "Alias for --from-search"],
@@ -445,7 +445,7 @@ function registerMutationCommands(program) {
445
445
  planCommand.action(async (subcommand, id, stepRef, reorderToken, options, command) => {
446
446
  const globalOptions = getGlobalOptions(command);
447
447
  const startedAt = Date.now();
448
- const { runPlan, PLAN_SUBCOMMANDS } = await import("./plan-FQLMJRLZ.js");
448
+ const { runPlan, PLAN_SUBCOMMANDS } = await import("./plan-7IVSICR6.js");
449
449
  const normalizedSubcommand = (subcommand ?? "").trim().toLowerCase();
450
450
  if (!normalizedSubcommand) {
451
451
  throw new PmCliError(`pm plan requires a subcommand. Allowed: ${PLAN_SUBCOMMANDS.join(", ")}`, EXIT_CODE.USAGE, {
@@ -466,7 +466,10 @@ function registerMutationCommands(program) {
466
466
  ["blocked_by", "blockedBy"],
467
467
  ["resume_context", "resumeContext"],
468
468
  ["from_search", "fromSearch"],
469
- ["step", "stepTitle"],
469
+ // pm-6mit: "step" is no longer folded into stepTitle here — it is a
470
+ // first-class repeatable option normalized inside runPlan (create
471
+ // accumulates ordered steps; other subcommands accept a single value
472
+ // as a stepTitle alias).
470
473
  ["step_title", "stepTitle"],
471
474
  ["step_body", "stepBody"],
472
475
  ["step_owner", "stepOwner"],
@@ -546,17 +549,28 @@ function registerMutationCommands(program) {
546
549
  printError(`profile:command=history-redact took_ms=${Date.now() - startedAt}`);
547
550
  }
548
551
  });
549
- program.command("history-repair").argument("<id>", "Item id").option("--dry-run", "Preview the re-anchor impact without writing the history file").option("--author <value>", "Mutation author").option("--message <value>", "Audit history message for the repair marker entry").option("--force", "Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker.").action(async (id, options, command) => {
552
+ program.command("history-repair").argument("[id]", "Item id (omit with --all)").option("--all", "Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run", "Preview the re-anchor impact without writing the history file").option("--author <value>", "Mutation author").option("--message <value>", "Audit history message for the repair marker entry").option("--force", "Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async (id, options, command) => {
550
553
  const globalOptions = getGlobalOptions(command);
551
554
  const startedAt = Date.now();
552
- const { runHistoryRepair } = await import("./history-repair-KVPFJKOS.js");
553
- const result = await runHistoryRepair(id, {
555
+ const { runHistoryRepair, runHistoryRepairAll, assertHistoryRepairTarget } = await import("./history-repair-OSQOKJ3E.js");
556
+ const all = options.all === true;
557
+ assertHistoryRepairTarget(id, all);
558
+ const repairOptions = {
554
559
  dryRun: options.dryRun === true,
555
560
  author: typeof options.author === "string" ? options.author : void 0,
556
561
  message: typeof options.message === "string" ? options.message : void 0,
557
562
  force: Boolean(options.force)
558
- }, globalOptions);
559
- printResult(result, globalOptions);
563
+ };
564
+ if (all) {
565
+ const result = await runHistoryRepairAll(repairOptions, globalOptions);
566
+ printResult(result, globalOptions);
567
+ if (result.totals.failed > 0) {
568
+ process.exitCode = EXIT_CODE.GENERIC_FAILURE;
569
+ }
570
+ } else {
571
+ const result = await runHistoryRepair(id, repairOptions, globalOptions);
572
+ printResult(result, globalOptions);
573
+ }
560
574
  if (globalOptions.profile) {
561
575
  printError(`profile:command=history-repair took_ms=${Date.now() - startedAt}`);
562
576
  }
@@ -747,19 +761,20 @@ function registerMutationCommands(program) {
747
761
  }
748
762
  });
749
763
  const filesCommand = program.command("files").description("Manage files linked to an item.");
750
- filesCommand.argument("<id>", "Item id").option("--add <value>", "Add linked file entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked file entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked file by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked file paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--list", "List linked files without mutating").option("--append-stable", "Preserve existing linked-file order and append new links without full-array resorting").option("--validate-paths", "Validate linked file paths for existence and file shape").option("--audit", "Audit linked file usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").action(async (id, options, command) => {
764
+ filesCommand.argument("<id>", "Item id").option("--add <value>", "Add linked file entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked file entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked file by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked file paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--note <value>", "Note attached to every link added by --add/--add-glob in this invocation (embedded note= wins)").option("--list", "List linked files without mutating").option("--append-stable", "Preserve existing linked-file order and append new links without full-array resorting").option("--validate-paths", "Validate linked file paths for existence and file shape").option("--audit", "Audit linked file usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").action(async (id, options, command) => {
751
765
  const globalOptions = getGlobalOptions(command);
752
766
  const startedAt = Date.now();
753
767
  const addValues = Array.isArray(options.add) ? options.add : [];
754
768
  const addGlobValues = Array.isArray(options.addGlob) ? options.addGlob : [];
755
769
  const removeValues = Array.isArray(options.remove) ? options.remove : [];
756
770
  const migrateValues = Array.isArray(options.migrate) ? options.migrate : [];
757
- const { runFiles } = await import("./files-GVMNVLCB.js");
771
+ const { runFiles } = await import("./files-FYP3MDPX.js");
758
772
  const result = await runFiles(id, {
759
773
  add: addValues,
760
774
  addGlob: addGlobValues,
761
775
  remove: removeValues,
762
776
  migrate: migrateValues,
777
+ note: typeof options.note === "string" ? options.note : void 0,
763
778
  list: Boolean(options.list),
764
779
  appendStable: Boolean(options.appendStable),
765
780
  validatePaths: Boolean(options.validatePaths),
@@ -779,14 +794,15 @@ function registerMutationCommands(program) {
779
794
  filesCommand.command("discover").argument("<id>", "Item id").option("--apply", "Add discovered missing files to the item").option("--note <value>", "Note to attach to discovered file links").option("--append-stable", "Preserve existing linked-file order and append discovered links without full-array resorting").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").description("Discover existing file paths referenced in item text and optionally link missing files.").action(async (id, options, command) => {
780
795
  const globalOptions = getGlobalOptions(command);
781
796
  const startedAt = Date.now();
782
- const { runFilesDiscover } = await import("./files-GVMNVLCB.js");
797
+ const mergedOptions = { ...command.optsWithGlobals(), ...options };
798
+ const { runFilesDiscover } = await import("./files-FYP3MDPX.js");
783
799
  const result = await runFilesDiscover(id, {
784
- apply: Boolean(options.apply),
785
- note: typeof options.note === "string" ? options.note : void 0,
786
- appendStable: Boolean(options.appendStable),
787
- author: typeof options.author === "string" ? options.author : void 0,
788
- message: typeof options.message === "string" ? options.message : void 0,
789
- force: Boolean(options.force)
800
+ apply: Boolean(mergedOptions.apply),
801
+ note: typeof mergedOptions.note === "string" ? mergedOptions.note : void 0,
802
+ appendStable: Boolean(mergedOptions.appendStable),
803
+ author: typeof mergedOptions.author === "string" ? mergedOptions.author : void 0,
804
+ message: typeof mergedOptions.message === "string" ? mergedOptions.message : void 0,
805
+ force: Boolean(mergedOptions.force)
790
806
  }, globalOptions);
791
807
  if (result.changed) {
792
808
  await invalidateSearchCachesForMutation(globalOptions, result);
@@ -796,19 +812,20 @@ function registerMutationCommands(program) {
796
812
  printError(`profile:command=files.discover took_ms=${Date.now() - startedAt}`);
797
813
  }
798
814
  });
799
- program.command("docs").argument("<id>", "Item id").option("--add <value>", "Add linked doc entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked doc entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked doc by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked doc paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--list", "List linked docs without mutating").option("--validate-paths", "Validate linked doc paths for existence and file shape").option("--audit", "Audit linked doc usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").description("Manage docs linked to an item.").action(async (id, options, command) => {
815
+ program.command("docs").argument("<id>", "Item id").option("--add <value>", "Add linked doc entry (CSV/markdown pairs or - for stdin)", collect).option("--add-glob <value>", "Add linked doc entries from a glob (plain glob or pattern=<glob>,scope=<scope>,note=<text>; repeatable)", collect).option("--remove <value>", "Remove linked doc by path (path=<value>, path:<value>, plain path, or - for stdin)", collect).option("--migrate <value>", "Migrate linked doc paths in-place (from=<prefix>,to=<prefix>; repeatable)", collect).option("--note <value>", "Note attached to every link added by --add/--add-glob in this invocation (embedded note= wins)").option("--list", "List linked docs without mutating").option("--validate-paths", "Validate linked doc paths for existence and file shape").option("--audit", "Audit linked doc usage across all items for this item's linked paths").option("--author <value>", "Mutation author").option("--message <value>", "History message").option("--force", "Force ownership override").description("Manage docs linked to an item.").action(async (id, options, command) => {
800
816
  const globalOptions = getGlobalOptions(command);
801
817
  const startedAt = Date.now();
802
818
  const addValues = Array.isArray(options.add) ? options.add : [];
803
819
  const addGlobValues = Array.isArray(options.addGlob) ? options.addGlob : [];
804
820
  const removeValues = Array.isArray(options.remove) ? options.remove : [];
805
821
  const migrateValues = Array.isArray(options.migrate) ? options.migrate : [];
806
- const { runDocs } = await import("./docs-MB53UJAJ.js");
822
+ const { runDocs } = await import("./docs-MXLGZUIT.js");
807
823
  const result = await runDocs(id, {
808
824
  add: addValues,
809
825
  addGlob: addGlobValues,
810
826
  remove: removeValues,
811
827
  migrate: migrateValues,
828
+ note: typeof options.note === "string" ? options.note : void 0,
812
829
  list: Boolean(options.list),
813
830
  validatePaths: Boolean(options.validatePaths),
814
831
  audit: Boolean(options.audit),
@@ -843,4 +860,4 @@ function registerMutationCommands(program) {
843
860
  export {
844
861
  registerMutationCommands
845
862
  };
846
- //# sourceMappingURL=register-mutation-EAYNLGOS.js.map
863
+ //# sourceMappingURL=register-mutation-FARSGYRD.js.map