@skillcap/gdh 0.22.0 → 0.24.0

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 (150) hide show
  1. package/INSTALL-BUNDLE.json +1 -1
  2. package/RELEASE-SPAN-UPDATE-CONTRACTS.json +129 -0
  3. package/node_modules/@gdh/adapters/dist/authoring-hook-render.d.ts.map +1 -1
  4. package/node_modules/@gdh/adapters/dist/authoring-hook-render.js +9 -2
  5. package/node_modules/@gdh/adapters/dist/authoring-hook-render.js.map +1 -1
  6. package/node_modules/@gdh/adapters/dist/claude-statusline-render.d.ts.map +1 -1
  7. package/node_modules/@gdh/adapters/dist/claude-statusline-render.js +2 -1
  8. package/node_modules/@gdh/adapters/dist/claude-statusline-render.js.map +1 -1
  9. package/node_modules/@gdh/adapters/dist/claude-update-hook-render.d.ts.map +1 -1
  10. package/node_modules/@gdh/adapters/dist/claude-update-hook-render.js +2 -1
  11. package/node_modules/@gdh/adapters/dist/claude-update-hook-render.js.map +1 -1
  12. package/node_modules/@gdh/adapters/dist/claude-update-worker-render.d.ts.map +1 -1
  13. package/node_modules/@gdh/adapters/dist/claude-update-worker-render.js +2 -1
  14. package/node_modules/@gdh/adapters/dist/claude-update-worker-render.js.map +1 -1
  15. package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.d.ts +71 -0
  16. package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.d.ts.map +1 -0
  17. package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.js +89 -0
  18. package/node_modules/@gdh/adapters/dist/deferred-actions-advisory.js.map +1 -0
  19. package/node_modules/@gdh/adapters/dist/durable-backup.d.ts +209 -0
  20. package/node_modules/@gdh/adapters/dist/durable-backup.d.ts.map +1 -0
  21. package/node_modules/@gdh/adapters/dist/durable-backup.js +346 -0
  22. package/node_modules/@gdh/adapters/dist/durable-backup.js.map +1 -0
  23. package/node_modules/@gdh/adapters/dist/index.d.ts +10 -1
  24. package/node_modules/@gdh/adapters/dist/index.d.ts.map +1 -1
  25. package/node_modules/@gdh/adapters/dist/index.js +24 -2
  26. package/node_modules/@gdh/adapters/dist/index.js.map +1 -1
  27. package/node_modules/@gdh/adapters/dist/inventory-sweep.d.ts +53 -0
  28. package/node_modules/@gdh/adapters/dist/inventory-sweep.d.ts.map +1 -0
  29. package/node_modules/@gdh/adapters/dist/inventory-sweep.js +98 -0
  30. package/node_modules/@gdh/adapters/dist/inventory-sweep.js.map +1 -0
  31. package/node_modules/@gdh/adapters/dist/process-orchestration.d.ts +223 -0
  32. package/node_modules/@gdh/adapters/dist/process-orchestration.d.ts.map +1 -0
  33. package/node_modules/@gdh/adapters/dist/process-orchestration.js +368 -0
  34. package/node_modules/@gdh/adapters/dist/process-orchestration.js.map +1 -0
  35. package/node_modules/@gdh/adapters/dist/self-update-mechanics.d.ts +157 -14
  36. package/node_modules/@gdh/adapters/dist/self-update-mechanics.d.ts.map +1 -1
  37. package/node_modules/@gdh/adapters/dist/self-update-mechanics.js +570 -89
  38. package/node_modules/@gdh/adapters/dist/self-update-mechanics.js.map +1 -1
  39. package/node_modules/@gdh/adapters/dist/skill-rendering.d.ts.map +1 -1
  40. package/node_modules/@gdh/adapters/dist/skill-rendering.js +25 -0
  41. package/node_modules/@gdh/adapters/dist/skill-rendering.js.map +1 -1
  42. package/node_modules/@gdh/adapters/package.json +8 -8
  43. package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.d.ts +112 -0
  44. package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.d.ts.map +1 -0
  45. package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.js +264 -0
  46. package/node_modules/@gdh/authoring/dist/diagnostics-broker-contract.js.map +1 -0
  47. package/node_modules/@gdh/authoring/dist/diagnostics-broker.d.ts +92 -0
  48. package/node_modules/@gdh/authoring/dist/diagnostics-broker.d.ts.map +1 -0
  49. package/node_modules/@gdh/authoring/dist/diagnostics-broker.js +532 -0
  50. package/node_modules/@gdh/authoring/dist/diagnostics-broker.js.map +1 -0
  51. package/node_modules/@gdh/authoring/dist/index.d.ts +1 -0
  52. package/node_modules/@gdh/authoring/dist/index.d.ts.map +1 -1
  53. package/node_modules/@gdh/authoring/dist/index.js +1 -0
  54. package/node_modules/@gdh/authoring/dist/index.js.map +1 -1
  55. package/node_modules/@gdh/authoring/dist/lsp-client.d.ts +16 -0
  56. package/node_modules/@gdh/authoring/dist/lsp-client.d.ts.map +1 -1
  57. package/node_modules/@gdh/authoring/dist/lsp-client.js +24 -0
  58. package/node_modules/@gdh/authoring/dist/lsp-client.js.map +1 -1
  59. package/node_modules/@gdh/authoring/dist/lsp.d.ts.map +1 -1
  60. package/node_modules/@gdh/authoring/dist/lsp.js +123 -2
  61. package/node_modules/@gdh/authoring/dist/lsp.js.map +1 -1
  62. package/node_modules/@gdh/authoring/package.json +2 -2
  63. package/node_modules/@gdh/cli/dist/index.d.ts +9 -0
  64. package/node_modules/@gdh/cli/dist/index.d.ts.map +1 -1
  65. package/node_modules/@gdh/cli/dist/index.js +423 -5
  66. package/node_modules/@gdh/cli/dist/index.js.map +1 -1
  67. package/node_modules/@gdh/cli/dist/migrate.d.ts +152 -1
  68. package/node_modules/@gdh/cli/dist/migrate.d.ts.map +1 -1
  69. package/node_modules/@gdh/cli/dist/migrate.js +295 -9
  70. package/node_modules/@gdh/cli/dist/migrate.js.map +1 -1
  71. package/node_modules/@gdh/cli/dist/self-update.d.ts +14 -0
  72. package/node_modules/@gdh/cli/dist/self-update.d.ts.map +1 -1
  73. package/node_modules/@gdh/cli/dist/self-update.js +197 -15
  74. package/node_modules/@gdh/cli/dist/self-update.js.map +1 -1
  75. package/node_modules/@gdh/cli/package.json +10 -10
  76. package/node_modules/@gdh/core/dist/index.d.ts +209 -6
  77. package/node_modules/@gdh/core/dist/index.d.ts.map +1 -1
  78. package/node_modules/@gdh/core/dist/index.js +28 -5
  79. package/node_modules/@gdh/core/dist/index.js.map +1 -1
  80. package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.d.ts +3 -0
  81. package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.d.ts.map +1 -0
  82. package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.js +247 -0
  83. package/node_modules/@gdh/core/dist/migrations/entries/s2c2_to_s2c3_rules_schema_v2_to_v3.js.map +1 -0
  84. package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.d.ts +3 -0
  85. package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.d.ts.map +1 -0
  86. package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.js +152 -0
  87. package/node_modules/@gdh/core/dist/migrations/entries/s3c8_to_s3c9_register_runtime_bridge_autoload.js.map +1 -0
  88. package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.d.ts +3 -0
  89. package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.d.ts.map +1 -0
  90. package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.js +67 -0
  91. package/node_modules/@gdh/core/dist/migrations/envelopes/envelope-output-validator.js.map +1 -0
  92. package/node_modules/@gdh/core/dist/migrations/envelopes/index.d.ts +37 -0
  93. package/node_modules/@gdh/core/dist/migrations/envelopes/index.d.ts.map +1 -0
  94. package/node_modules/@gdh/core/dist/migrations/envelopes/index.js +60 -0
  95. package/node_modules/@gdh/core/dist/migrations/envelopes/index.js.map +1 -0
  96. package/node_modules/@gdh/core/dist/migrations/envelopes/types.d.ts +121 -0
  97. package/node_modules/@gdh/core/dist/migrations/envelopes/types.d.ts.map +1 -0
  98. package/node_modules/@gdh/core/dist/migrations/envelopes/types.js +2 -0
  99. package/node_modules/@gdh/core/dist/migrations/envelopes/types.js.map +1 -0
  100. package/node_modules/@gdh/core/dist/migrations/golden-harness.d.ts +40 -0
  101. package/node_modules/@gdh/core/dist/migrations/golden-harness.d.ts.map +1 -0
  102. package/node_modules/@gdh/core/dist/migrations/golden-harness.js +71 -0
  103. package/node_modules/@gdh/core/dist/migrations/golden-harness.js.map +1 -0
  104. package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.d.ts +322 -0
  105. package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.d.ts.map +1 -0
  106. package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.js +384 -0
  107. package/node_modules/@gdh/core/dist/migrations/managed-surface-classes.js.map +1 -0
  108. package/node_modules/@gdh/core/dist/migrations/probes.d.ts +58 -0
  109. package/node_modules/@gdh/core/dist/migrations/probes.d.ts.map +1 -0
  110. package/node_modules/@gdh/core/dist/migrations/probes.js +112 -0
  111. package/node_modules/@gdh/core/dist/migrations/probes.js.map +1 -0
  112. package/node_modules/@gdh/core/dist/migrations/registry.d.ts +205 -0
  113. package/node_modules/@gdh/core/dist/migrations/registry.d.ts.map +1 -0
  114. package/node_modules/@gdh/core/dist/migrations/registry.js +214 -0
  115. package/node_modules/@gdh/core/dist/migrations/registry.js.map +1 -0
  116. package/node_modules/@gdh/core/dist/state/atomic-write.d.ts +19 -0
  117. package/node_modules/@gdh/core/dist/state/atomic-write.d.ts.map +1 -0
  118. package/node_modules/@gdh/core/dist/state/atomic-write.js +34 -0
  119. package/node_modules/@gdh/core/dist/state/atomic-write.js.map +1 -0
  120. package/node_modules/@gdh/core/dist/state/migration-state.d.ts +135 -0
  121. package/node_modules/@gdh/core/dist/state/migration-state.d.ts.map +1 -0
  122. package/node_modules/@gdh/core/dist/state/migration-state.js +186 -0
  123. package/node_modules/@gdh/core/dist/state/migration-state.js.map +1 -0
  124. package/node_modules/@gdh/core/dist/state/processes-snapshot.d.ts +72 -0
  125. package/node_modules/@gdh/core/dist/state/processes-snapshot.d.ts.map +1 -0
  126. package/node_modules/@gdh/core/dist/state/processes-snapshot.js +113 -0
  127. package/node_modules/@gdh/core/dist/state/processes-snapshot.js.map +1 -0
  128. package/node_modules/@gdh/core/dist/state/render-inventory.d.ts +54 -0
  129. package/node_modules/@gdh/core/dist/state/render-inventory.d.ts.map +1 -0
  130. package/node_modules/@gdh/core/dist/state/render-inventory.js +77 -0
  131. package/node_modules/@gdh/core/dist/state/render-inventory.js.map +1 -0
  132. package/node_modules/@gdh/core/package.json +1 -1
  133. package/node_modules/@gdh/docs/dist/agent-contract.d.ts.map +1 -1
  134. package/node_modules/@gdh/docs/dist/agent-contract.js +2 -1
  135. package/node_modules/@gdh/docs/dist/agent-contract.js.map +1 -1
  136. package/node_modules/@gdh/docs/dist/guidance.d.ts.map +1 -1
  137. package/node_modules/@gdh/docs/dist/guidance.js +14 -7
  138. package/node_modules/@gdh/docs/dist/guidance.js.map +1 -1
  139. package/node_modules/@gdh/docs/package.json +2 -2
  140. package/node_modules/@gdh/mcp/dist/index.d.ts.map +1 -1
  141. package/node_modules/@gdh/mcp/dist/index.js +77 -1
  142. package/node_modules/@gdh/mcp/dist/index.js.map +1 -1
  143. package/node_modules/@gdh/mcp/package.json +8 -8
  144. package/node_modules/@gdh/observability/package.json +2 -2
  145. package/node_modules/@gdh/runtime/dist/bridge-surface.js +63 -2
  146. package/node_modules/@gdh/runtime/dist/bridge-surface.js.map +1 -1
  147. package/node_modules/@gdh/runtime/package.json +2 -2
  148. package/node_modules/@gdh/scan/package.json +3 -3
  149. package/node_modules/@gdh/verify/package.json +7 -7
  150. package/package.json +11 -11
@@ -5,7 +5,7 @@ import os from "node:os";
5
5
  import path from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { buildGdhStatusResult, CLAUDE_CHECK_SKILL_RELATIVE_PATH, CLAUDE_CHECK_UPDATE_HOOK_RELATIVE_PATH, CLAUDE_MIGRATE_SKILL_RELATIVE_PATH, CLAUDE_ONBOARD_SKILL_RELATIVE_PATH, CLAUDE_PREPARE_SKILL_RELATIVE_PATH, CLAUDE_SCAN_SKILL_RELATIVE_PATH, CLAUDE_STATUS_SKILL_RELATIVE_PATH, CODEX_CHECK_SKILL_RELATIVE_PATH, CODEX_MIGRATE_SKILL_RELATIVE_PATH, CODEX_ONBOARD_SKILL_RELATIVE_PATH, CODEX_PREPARE_SKILL_RELATIVE_PATH, CODEX_SCAN_SKILL_RELATIVE_PATH, CODEX_STATUS_SKILL_RELATIVE_PATH, CURSOR_CHECK_SKILL_RELATIVE_PATH, CURSOR_MIGRATE_SKILL_RELATIVE_PATH, CURSOR_ONBOARD_SKILL_RELATIVE_PATH, CURSOR_PREPARE_SKILL_RELATIVE_PATH, CURSOR_SCAN_SKILL_RELATIVE_PATH, CURSOR_STATUS_SKILL_RELATIVE_PATH, createGsdSnapshot, getSupportedAgentAdaptersStatus, installSupportedAgentAdapters, } from "@gdh/adapters";
8
- import { checkManagedLsp, doctorManagedLsp, getManagedLspStatus, hasCompleteOnboardingSurface, inspectCacheState, pruneCacheState, pruneManagedLsp, readProjectConfig, readWorktreeState, resolveAuthoringStatus, resolveEffectiveTargetPath, resolvePinnedVersion, resolveProjectRoot, resolveTargetGodotDocsVersion, restartManagedLsp, runAuthoringCheck, runImportRefresh, runTargetPrepare, runWarmup, stopManagedLsp, } from "@gdh/authoring";
8
+ import { checkManagedLsp, doctorAuthoringDiagnostics, doctorManagedLsp, getAuthoringDiagnosticsStatus, getCurrentAuthoringDiagnostics, getManagedLspStatus, hasCompleteOnboardingSurface, inspectCacheState, pruneCacheState, pruneAuthoringDiagnostics, pruneManagedLsp, readProjectConfig, readWorktreeState, refreshAuthoringDiagnostics, resolveAuthoringStatus, resolveEffectiveTargetPath, resolvePinnedVersion, resolveProjectRoot, resolveTargetGodotDocsVersion, restartManagedLsp, runAuthoringCheck, runImportRefresh, runTargetPrepare, runWarmup, stopManagedLsp, } from "@gdh/authoring";
9
9
  import { definePackageBoundary, GDH_AUTHORING_DOGFOOD_VERSION, GDH_AUTHORING_SLICE_REPORT_VERSION, GDH_PRODUCT_NAME, resolveCurrentGdhInstall, resolveGdhProductMetadata, } from "@gdh/core";
10
10
  import { fetchOfficialGodotDoc, getGuidanceStatus, resolveGuidanceQuery, searchOfficialGodotDocs, } from "@gdh/docs";
11
11
  import { createMcpManifest, invokeMcpTool, serveMcpOverStdio } from "@gdh/mcp";
@@ -13,11 +13,21 @@ import { inspectAuthoringEffectiveness, inspectAuthoringSessions, inspectGuidanc
13
13
  import { checkRuntimeRecipe, createRuntimeBridgeManager, serveRuntimeBridgeBroker, inspectRuntimeBridgeSurface, installRuntimeBridgeSurface, listRuntimeRecipes, removeRuntimeBridgeSurface, repairRuntimeBridgeSurface, runRuntimeRecipe, showRuntimeRecipe, } from "@gdh/runtime";
14
14
  import { applyRepairableOnboardingWrites, onboardGodotProject, persistInventoryForTarget, readInventoryCacheOrScan, scanGodotProjectInventory, } from "@gdh/scan";
15
15
  import { exerciseRuntimeCorpusEntry, inspectRuntimeCorpusStatus, inspectRuntimeVerificationBundleState, inspectRuntimeVerificationReadiness, listRuntimeScenarios, materializeRuntimeCorpusEntry, recordRuntimeCorpusValidation, runRuntimeVerificationScenario, showRuntimeScenario, } from "@gdh/verify";
16
- import { migrateProjectLifecycleSurface } from "./migrate.js";
16
+ import { clearEnvelope, clearMigrationBackups, migrateProjectLifecycleSurface, recordEnvelopeResult, } from "./migrate.js";
17
17
  import { runBridgeSessionCommand } from "./bridge-session.js";
18
18
  import { cleanupGdhMcpProcesses } from "./mcp-cleanup.js";
19
19
  import { presentPublicRuntimeTerms } from "./public-terms.js";
20
- import { runSelfUpdateCommand } from "./self-update.js";
20
+ import { runSelfUpdateCommand as runSelfUpdateCommandImpl } from "./self-update.js";
21
+ /**
22
+ * Re-export of `runSelfUpdateCommand` so the integration test in
23
+ * `packages/cli/src/self-update.integration.test.ts` (Plan 73-06) can drive
24
+ * the dispatcher directly without depending on the self-update module's
25
+ * surface evolving. The implementation lives in `./self-update.js`; this
26
+ * is a thin pass-through that preserves identical signature and behavior.
27
+ */
28
+ export async function runSelfUpdateCommand(args, io) {
29
+ return runSelfUpdateCommandImpl(args, io);
30
+ }
21
31
  import { executeSetupCommand, isSetupCanceledError, renderDurableTruthCollisionHint, renderSetupIntro, renderSetupOutro, renderSetupSummary, } from "./setup.js";
22
32
  import { emitUpdateBannerIfStale } from "./update-banner.js";
23
33
  export const cliPackage = definePackageBoundary({
@@ -124,6 +134,9 @@ export async function runCli(args, io = { stdout: process.stdout, stderr: proces
124
134
  if (command === "migrate") {
125
135
  return runMigrateCommand(rest, io);
126
136
  }
137
+ if (command === "migration") {
138
+ return runMigrationCommand(rest, io);
139
+ }
127
140
  if (command === "self-update") {
128
141
  return runSelfUpdateCommand(rest, io);
129
142
  }
@@ -507,16 +520,191 @@ async function runAuthoringCommand(args, io) {
507
520
  "Usage: gdh authoring <command> [target]",
508
521
  "",
509
522
  "Commands:",
510
- " check [target] Run the current authoring-check entrypoint and print a structured result.",
523
+ " check [target] Run the current authoring-check entrypoint and print a structured result.",
524
+ " diagnostics <command> Inspect current Godot authoring diagnostics snapshots.",
511
525
  ].join("\n") + "\n");
512
526
  return 0;
513
527
  }
514
528
  if (subcommand === "check") {
515
529
  return runAuthoringCheckCommand(rest, io);
516
530
  }
517
- io.stderr.write(`Unknown authoring command: ${subcommand}\n\nUsage: gdh authoring check [target]\n`);
531
+ if (subcommand === "diagnostics") {
532
+ return runAuthoringDiagnosticsCommand(rest, io);
533
+ }
534
+ io.stderr.write(`Unknown authoring command: ${subcommand}\n\nUsage: gdh authoring <check|diagnostics> [target]\n`);
535
+ return 1;
536
+ }
537
+ async function runAuthoringDiagnosticsCommand(args, io) {
538
+ const [subcommand, ...rest] = args;
539
+ if (!subcommand || subcommand === "--help" || subcommand === "help") {
540
+ io.stdout.write([
541
+ "Usage: gdh authoring diagnostics <command> [target]",
542
+ "",
543
+ "Inspect current Godot authoring diagnostics snapshots from the GDH diagnostics broker.",
544
+ "These commands report CURRENT diagnostics snapshots, not final validation evidence.",
545
+ "Use `gdh authoring check` for bounded validation evidence at task boundaries.",
546
+ "Use `gdh lsp status|doctor|restart|prune|stop` for LSP lifecycle management.",
547
+ "",
548
+ "Commands:",
549
+ " status [target] Print broker health and snapshot freshness.",
550
+ " current [target] Print current normalized diagnostics snapshot.",
551
+ " refresh [target] [--changed <p>…] Refresh diagnostics for changed files.",
552
+ " doctor [target] Explain stale, missing, or unavailable states.",
553
+ " prune [target] Remove stale broker metadata.",
554
+ ].join("\n") + "\n");
555
+ return 0;
556
+ }
557
+ if (subcommand === "status") {
558
+ return runAuthoringDiagnosticsSubcommand("status", rest, io);
559
+ }
560
+ if (subcommand === "current") {
561
+ return runAuthoringDiagnosticsSubcommand("current", rest, io);
562
+ }
563
+ if (subcommand === "refresh") {
564
+ return runAuthoringDiagnosticsRefreshCommand(rest, io);
565
+ }
566
+ if (subcommand === "doctor") {
567
+ return runAuthoringDiagnosticsSubcommand("doctor", rest, io);
568
+ }
569
+ if (subcommand === "prune") {
570
+ return runAuthoringDiagnosticsSubcommand("prune", rest, io);
571
+ }
572
+ io.stderr.write([
573
+ `Unknown authoring diagnostics command: ${subcommand}`,
574
+ "",
575
+ "Usage: gdh authoring diagnostics <status|current|refresh|doctor|prune> [target]",
576
+ ].join("\n") + "\n");
518
577
  return 1;
519
578
  }
579
+ async function runAuthoringDiagnosticsSubcommand(command, args, io) {
580
+ const helpText = {
581
+ status: [
582
+ "Usage: gdh authoring diagnostics status [target]",
583
+ "Usage: gdh authoring diagnostics status --target <path>",
584
+ "",
585
+ "Print diagnostics broker health, snapshot freshness, and scope summary as JSON.",
586
+ "Reports CURRENT broker state — not final validation evidence.",
587
+ "Use `gdh authoring check` for bounded validation evidence.",
588
+ ].join("\n"),
589
+ current: [
590
+ "Usage: gdh authoring diagnostics current [target]",
591
+ "Usage: gdh authoring diagnostics current --target <path>",
592
+ "",
593
+ "Print the current normalized diagnostics snapshot without triggering a refresh.",
594
+ "Reports CURRENT broker snapshot — not final validation evidence.",
595
+ "Use `gdh authoring diagnostics refresh` to update the snapshot after edits.",
596
+ ].join("\n"),
597
+ doctor: [
598
+ "Usage: gdh authoring diagnostics doctor [target]",
599
+ "Usage: gdh authoring diagnostics doctor --target <path>",
600
+ "",
601
+ "Explain stale, missing, incompatible, or unavailable diagnostics broker states.",
602
+ "Provides actionable recovery steps — does not recommend raw process killing.",
603
+ ].join("\n"),
604
+ prune: [
605
+ "Usage: gdh authoring diagnostics prune [target]",
606
+ "Usage: gdh authoring diagnostics prune --target <path>",
607
+ "",
608
+ "Remove stale diagnostics broker metadata under .gdh-state.",
609
+ "Only removes GDH-owned metadata — does not affect the managed LSP lifecycle.",
610
+ ].join("\n"),
611
+ };
612
+ if (args.includes("--help")) {
613
+ io.stdout.write(`${helpText[command]}\n`);
614
+ return 0;
615
+ }
616
+ const parsedTarget = parseSingleTargetPathArg(args, {
617
+ usage: `${helpText[command]}\n`,
618
+ allowTargetOption: true,
619
+ });
620
+ if (parsedTarget.error !== null) {
621
+ io.stderr.write(parsedTarget.error);
622
+ return 1;
623
+ }
624
+ const targetPath = parsedTarget.targetPath;
625
+ try {
626
+ const context = await buildAuthoringContext(targetPath);
627
+ const input = {
628
+ targetPath: context.targetPath,
629
+ status: context.status,
630
+ projectConfig: context.projectConfig,
631
+ };
632
+ if (command === "status") {
633
+ const result = await getAuthoringDiagnosticsStatus(input);
634
+ writeJsonResult(io, result);
635
+ }
636
+ else if (command === "current") {
637
+ const result = await getCurrentAuthoringDiagnostics(input);
638
+ writeJsonResult(io, result);
639
+ }
640
+ else if (command === "doctor") {
641
+ const result = await doctorAuthoringDiagnostics(input);
642
+ writeJsonResult(io, result);
643
+ }
644
+ else {
645
+ const result = await pruneAuthoringDiagnostics(input);
646
+ writeJsonResult(io, result);
647
+ }
648
+ return 0;
649
+ }
650
+ catch (error) {
651
+ io.stderr.write(`Failed to run authoring diagnostics ${command} for "${targetPath}": ${formatCliError(error)}\n`);
652
+ return 1;
653
+ }
654
+ }
655
+ async function runAuthoringDiagnosticsRefreshCommand(args, io) {
656
+ const usage = [
657
+ "Usage: gdh authoring diagnostics refresh [target] [--changed <path>...]",
658
+ "Usage: gdh authoring diagnostics refresh --target <path> [--changed <path>...]",
659
+ "",
660
+ "Open or refresh specified files through the managed LSP and persist the diagnostics snapshot.",
661
+ "Omitting --changed refreshes all project GDScript files.",
662
+ "Reports CURRENT broker snapshot after refresh — not final validation evidence.",
663
+ "Use `gdh authoring check --mode final` for bounded handoff evidence.",
664
+ ].join("\n");
665
+ if (args.includes("--help")) {
666
+ io.stdout.write(`${usage}\n`);
667
+ return 0;
668
+ }
669
+ // Collect --changed values (may be repeated)
670
+ const changedFiles = [];
671
+ const filteredArgs = [];
672
+ let i = 0;
673
+ while (i < args.length) {
674
+ if (args[i] === "--changed" && i + 1 < args.length) {
675
+ changedFiles.push(args[i + 1]);
676
+ i += 2;
677
+ }
678
+ else {
679
+ filteredArgs.push(args[i]);
680
+ i += 1;
681
+ }
682
+ }
683
+ const parsedTarget = parseSingleTargetPathArg(filteredArgs, {
684
+ usage: `${usage}\n`,
685
+ allowTargetOption: true,
686
+ });
687
+ if (parsedTarget.error !== null) {
688
+ io.stderr.write(parsedTarget.error);
689
+ return 1;
690
+ }
691
+ const targetPath = parsedTarget.targetPath;
692
+ try {
693
+ const context = await buildAuthoringContext(targetPath);
694
+ const result = await refreshAuthoringDiagnostics({
695
+ targetPath: context.targetPath,
696
+ status: context.status,
697
+ projectConfig: context.projectConfig,
698
+ ...(changedFiles.length > 0 && { changedFiles }),
699
+ });
700
+ writeJsonResult(io, result);
701
+ return 0;
702
+ }
703
+ catch (error) {
704
+ io.stderr.write(`Failed to refresh authoring diagnostics for "${targetPath}": ${formatCliError(error)}\n`);
705
+ return 1;
706
+ }
707
+ }
520
708
  async function runLspCommand(args, io) {
521
709
  const [subcommand, ...rest] = args;
522
710
  if (!subcommand || subcommand === "--help" || subcommand === "help") {
@@ -1791,6 +1979,235 @@ async function runMigrateCommand(args, io) {
1791
1979
  return 1;
1792
1980
  }
1793
1981
  }
1982
+ export async function runMigrationCommand(args, io) {
1983
+ const [subcommand, ...rest] = args;
1984
+ if (!subcommand || subcommand === "--help" || subcommand === "help") {
1985
+ io.stdout.write([
1986
+ "Usage: gdh migration <command>",
1987
+ "",
1988
+ "Commands:",
1989
+ " clear-backups [target] Remove .gdh-state/backup/ when all deferred-action probes are clean (idempotent).",
1990
+ " record-envelope-result <slug> --result-file <path> Record a Phase 73 envelope output_contract from a JSON file.",
1991
+ " record-envelope-result <slug> --result <inline-json> Record a Phase 73 envelope output_contract inline (JSON string).",
1992
+ " clear-envelope <slug> [target] Drop the recorded envelopes slot for <slug> from migration.json (testing/debug).",
1993
+ ].join("\n") + "\n");
1994
+ return 0;
1995
+ }
1996
+ if (subcommand === "clear-backups") {
1997
+ return runMigrationClearBackupsCommand(rest, io);
1998
+ }
1999
+ if (subcommand === "record-envelope-result") {
2000
+ return runMigrationRecordEnvelopeResultCommand(rest, io);
2001
+ }
2002
+ if (subcommand === "clear-envelope") {
2003
+ return runMigrationClearEnvelopeCommand(rest, io);
2004
+ }
2005
+ io.stderr.write([
2006
+ `Unknown migration command: ${subcommand}`,
2007
+ "",
2008
+ "Run `gdh migration --help` for the list of supported subcommands.",
2009
+ ].join("\n") + "\n");
2010
+ return 1;
2011
+ }
2012
+ async function runMigrationClearBackupsCommand(args, io) {
2013
+ if (args.includes("--help")) {
2014
+ io.stdout.write([
2015
+ "Usage: gdh migration clear-backups [target]",
2016
+ "",
2017
+ "Remove .gdh-state/backup/ when all deferred-action probes are clean.",
2018
+ "Exits 0 on cleared and noop, 1 on blocked_by_pending_probes.",
2019
+ ].join("\n") + "\n");
2020
+ return 0;
2021
+ }
2022
+ const unsupportedOptionsError = findUnsupportedOptionsError(args, {
2023
+ usage: "Usage: gdh migration clear-backups [target]\n",
2024
+ });
2025
+ if (unsupportedOptionsError !== null) {
2026
+ io.stderr.write(unsupportedOptionsError);
2027
+ return 1;
2028
+ }
2029
+ const { targetPath, error: targetPathError } = parseOptionalPositionalTargetPath(args, {
2030
+ usage: "Usage: gdh migration clear-backups [target]\n",
2031
+ });
2032
+ if (targetPathError !== null) {
2033
+ io.stderr.write(targetPathError);
2034
+ return 1;
2035
+ }
2036
+ try {
2037
+ const result = await clearMigrationBackups({ targetPath });
2038
+ writeJsonResult(io, result);
2039
+ return result.state === "blocked_by_pending_probes" ? 1 : 0;
2040
+ }
2041
+ catch (error) {
2042
+ io.stderr.write(`Failed to clear migration backups for "${targetPath}": ${formatCliError(error)}\n`);
2043
+ return 1;
2044
+ }
2045
+ }
2046
+ // ---------------------------------------------------------------------------
2047
+ // Phase 73 — gdh migration record-envelope-result (D-07 / D-13)
2048
+ // ---------------------------------------------------------------------------
2049
+ const RECORD_ENVELOPE_RESULT_USAGE = "Usage: gdh migration record-envelope-result <slug> [--result-file <path> | --result <json>] [--target <path>]\n";
2050
+ /**
2051
+ * Subcommand `"record-envelope-result"` for `gdh migration` (Phase 73 D-07).
2052
+ * Mutually-exclusive `--result-file` / `--result` gate; resolves `--target`
2053
+ * via {@link parseSingleTargetPathArg} after stripping the slug positional;
2054
+ * delegates validation and atomic write to {@link recordEnvelopeResult} in
2055
+ * `./migrate.js`. Exit 0 on `recorded`, exit 1 on `blocked`.
2056
+ */
2057
+ async function runMigrationRecordEnvelopeResultCommand(args, io) {
2058
+ if (args.includes("--help")) {
2059
+ io.stdout.write([
2060
+ "Usage: gdh migration record-envelope-result <slug> --result-file <path> [--target <path>]",
2061
+ "Usage: gdh migration record-envelope-result <slug> --result <inline-json> [--target <path>]",
2062
+ "",
2063
+ "Record a Phase 73 envelope output_contract block. Validates against the",
2064
+ "GdhMigrationEnvelopeOutput typed union (apply / abort / needs_clarification);",
2065
+ "appends to migration.json.envelopes[<slug>] and migration.json.envelopes[<slug>].attempts[].",
2066
+ 'Does NOT advance the chain — re-run `gdh self-update` after recording.',
2067
+ "",
2068
+ 'Exits 0 on { state: "recorded" }, 1 on { state: "blocked" }.',
2069
+ ].join("\n") + "\n");
2070
+ return 0;
2071
+ }
2072
+ const unsupportedOptionsError = findUnsupportedOptionsError(args, {
2073
+ usage: RECORD_ENVELOPE_RESULT_USAGE,
2074
+ optionsWithValues: ["--result-file", "--result", "--target"],
2075
+ });
2076
+ if (unsupportedOptionsError !== null) {
2077
+ io.stderr.write(unsupportedOptionsError);
2078
+ return 1;
2079
+ }
2080
+ // Walk argv and skip the value following each value-bearing flag so it is
2081
+ // not misinterpreted as a positional. Boolean flags would belong here too
2082
+ // if any were supported (none currently).
2083
+ const resolvedPositionals = [];
2084
+ for (let i = 0; i < args.length; i++) {
2085
+ const arg = args[i] ?? "";
2086
+ if (arg === "--result" || arg === "--result-file" || arg === "--target") {
2087
+ i++; // skip value
2088
+ continue;
2089
+ }
2090
+ if (arg.startsWith("--"))
2091
+ continue;
2092
+ resolvedPositionals.push(arg);
2093
+ }
2094
+ if (resolvedPositionals.length === 0) {
2095
+ io.stderr.write("Usage error: gdh migration record-envelope-result requires a <slug> positional argument.\n");
2096
+ return 1;
2097
+ }
2098
+ if (resolvedPositionals.length > 1) {
2099
+ io.stderr.write(`Usage error: gdh migration record-envelope-result accepts a single <slug>; received ${resolvedPositionals.length}.\n`);
2100
+ return 1;
2101
+ }
2102
+ const slug = resolvedPositionals[0];
2103
+ const resultFile = readSingleOptionValue(args, "--result-file");
2104
+ const resultInline = readSingleOptionValue(args, "--result");
2105
+ // Mutually exclusive: exactly one of the two MUST be present.
2106
+ if ((resultFile === null) === (resultInline === null)) {
2107
+ io.stderr.write("Usage error: provide exactly one of --result-file <path> or --result <inline-json>.\n");
2108
+ return 1;
2109
+ }
2110
+ // Use the canonical helper so --target resolution is symmetric with
2111
+ // runStatusCommand and the other migration dispatchers (no ad-hoc
2112
+ // path.resolve(targetExplicit) here). Strip the slug positional + the
2113
+ // value-bearing flags' values before delegating so the helper sees only
2114
+ // [--target <path>] (or nothing).
2115
+ const argsForTargetParse = [];
2116
+ for (let i = 0; i < args.length; i++) {
2117
+ const arg = args[i] ?? "";
2118
+ if (arg === "--target") {
2119
+ argsForTargetParse.push(arg);
2120
+ const next = args[i + 1];
2121
+ if (next !== undefined)
2122
+ argsForTargetParse.push(next);
2123
+ i++;
2124
+ continue;
2125
+ }
2126
+ if (arg === "--result" || arg === "--result-file") {
2127
+ i++; // skip value
2128
+ continue;
2129
+ }
2130
+ if (arg === slug)
2131
+ continue; // strip the consumed positional
2132
+ if (arg.startsWith("--"))
2133
+ continue; // strip help and other flags
2134
+ // Any leftover positional would have been caught above.
2135
+ }
2136
+ const { targetPath, error: targetError } = parseSingleTargetPathArg(argsForTargetParse, {
2137
+ usage: RECORD_ENVELOPE_RESULT_USAGE,
2138
+ allowTargetOption: true,
2139
+ });
2140
+ if (targetError !== null) {
2141
+ io.stderr.write(targetError);
2142
+ return 1;
2143
+ }
2144
+ try {
2145
+ const result = await recordEnvelopeResult({
2146
+ targetPath,
2147
+ envelopeRef: slug,
2148
+ resultSource: resultFile !== null
2149
+ ? { kind: "file", absolutePath: path.resolve(resultFile) }
2150
+ : { kind: "inline", json: resultInline },
2151
+ });
2152
+ writeJsonResult(io, result);
2153
+ return result.state === "blocked" ? 1 : 0;
2154
+ }
2155
+ catch (error) {
2156
+ io.stderr.write(`Failed to record envelope result for "${targetPath}": ${formatCliError(error)}\n`);
2157
+ return 1;
2158
+ }
2159
+ }
2160
+ // ---------------------------------------------------------------------------
2161
+ // Phase 73 — gdh migration clear-envelope (testing/debug)
2162
+ // ---------------------------------------------------------------------------
2163
+ /**
2164
+ * Subcommand `"clear-envelope"` for `gdh migration` (testing/debug companion).
2165
+ * Removes the per-slug slot from `migration.json.envelopes`; idempotent noop
2166
+ * on missing slot or missing migration state. Does NOT touch
2167
+ * `pending_envelope_resume` (mirrors D-13 isolation in
2168
+ * {@link recordEnvelopeResult}). Exit 0 always.
2169
+ */
2170
+ async function runMigrationClearEnvelopeCommand(args, io) {
2171
+ if (args.includes("--help")) {
2172
+ io.stdout.write([
2173
+ "Usage: gdh migration clear-envelope <slug> [target]",
2174
+ "",
2175
+ "Remove the recorded envelopes slot for <slug> from migration.json.",
2176
+ "Does NOT touch pending_envelope_resume. Idempotent.",
2177
+ "",
2178
+ "Exits 0 on cleared and noop.",
2179
+ ].join("\n") + "\n");
2180
+ return 0;
2181
+ }
2182
+ const unsupportedOptionsError = findUnsupportedOptionsError(args, {
2183
+ usage: "Usage: gdh migration clear-envelope <slug> [target]\n",
2184
+ });
2185
+ if (unsupportedOptionsError !== null) {
2186
+ io.stderr.write(unsupportedOptionsError);
2187
+ return 1;
2188
+ }
2189
+ const positional = args.filter((a) => !a.startsWith("--"));
2190
+ if (positional.length === 0) {
2191
+ io.stderr.write("Usage error: gdh migration clear-envelope requires a <slug> positional argument.\n");
2192
+ return 1;
2193
+ }
2194
+ if (positional.length > 2) {
2195
+ io.stderr.write("Usage error: gdh migration clear-envelope accepts at most <slug> and an optional [target].\n");
2196
+ return 1;
2197
+ }
2198
+ const slug = positional[0];
2199
+ const targetCandidate = positional[1] ?? null;
2200
+ const targetPath = targetCandidate !== null ? path.resolve(targetCandidate) : process.cwd();
2201
+ try {
2202
+ const result = await clearEnvelope({ targetPath, envelopeRef: slug });
2203
+ writeJsonResult(io, result);
2204
+ return 0;
2205
+ }
2206
+ catch (error) {
2207
+ io.stderr.write(`Failed to clear envelope "${slug}" for "${targetPath}": ${formatCliError(error)}\n`);
2208
+ return 1;
2209
+ }
2210
+ }
1794
2211
  async function runBridgeStatusCommand(args, io) {
1795
2212
  if (args.includes("--help")) {
1796
2213
  io.stdout.write([
@@ -3985,6 +4402,7 @@ function renderHelp() {
3985
4402
  " adapters install [target] [--dry-run] [--agent <name>] [--user] [--dev-repo <path>] [--integration-root <path>] Install or repair supported-agent reinforcement.",
3986
4403
  " adapters gsd snapshot [target] [--files <path>] Export a read-only GSD projection.",
3987
4404
  " authoring check [target] Run the current authoring-check entrypoint.",
4405
+ " authoring diagnostics <status|current|refresh|doctor|prune> [target] Inspect current Godot authoring diagnostics snapshots.",
3988
4406
  " lsp <status|check|stop|restart|prune|doctor> [target] Manage authoring.lsp lifecycle state.",
3989
4407
  " warmup [target] [--dry-run] Inspect or apply authoring worktree warmup.",
3990
4408
  " target prepare [target] [--source-target <path>] [--dry-run] Prepare target-local generated/import state.",