substrate-ai 0.20.37 → 0.20.39

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.
package/dist/cli/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
- import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDING_COUNTS, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts } from "../health-BAcRfZ4s.js";
2
+ import { FileStateStore, RunManifest, SUBSTRATE_OWNED_SETTINGS_KEYS, SupervisorLock, VALID_PHASES, WorkGraphRepository, ZERO_FINDING_COUNTS, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, parseRuntimeProbes, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts } from "../health-R9GiVIiQ.js";
3
3
  import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
- import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-BnMsd9hC.js";
5
+ import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, InMemoryDatabaseAdapter, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createDoltClient, createPipelineRun, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-VcMmfo2w.js";
6
6
  import "../adapter-registry-DXLMTmfD.js";
7
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-YBY2vrF4.js";
8
- import "../errors-DSGhhrgv.js";
7
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GitClient, GrammarLoader, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, validateStopAfterFromConflict } from "../run-Dm70k8bR.js";
8
+ import "../errors-CogpxBUg.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
11
11
  import "../version-manager-impl-BmOWu8ml.js";
12
- import { registerUpgradeCommand } from "../upgrade-D3NuTkSL.js";
12
+ import { registerUpgradeCommand } from "../upgrade-CF4__LCr.js";
13
13
  import { Command } from "commander";
14
14
  import { fileURLToPath } from "url";
15
15
  import { dirname, join, resolve } from "path";
16
16
  import { access, mkdir, readFile, writeFile } from "fs/promises";
17
17
  import yaml from "js-yaml";
18
- import { existsSync, readFileSync } from "node:fs";
18
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
19
19
  import { execFile, spawn } from "node:child_process";
20
20
  import * as path$3 from "node:path";
21
21
  import * as path$2 from "node:path";
22
22
  import * as path$1 from "node:path";
23
- import { basename as basename$1, join as join$1 } from "node:path";
23
+ import { basename as basename$1, join as join$1, resolve as resolve$1 } from "node:path";
24
24
  import { randomUUID } from "node:crypto";
25
25
  import { z } from "zod";
26
26
  import * as fs from "node:fs/promises";
@@ -333,12 +333,12 @@ var GitWorktreeManagerImpl = class {
333
333
  _onTaskReady;
334
334
  _onTaskComplete;
335
335
  _onTaskFailed;
336
- constructor(eventBus, projectRoot, baseDirectory = DEFAULT_WORKTREE_BASE, db = null, logger$16) {
336
+ constructor(eventBus, projectRoot, baseDirectory = DEFAULT_WORKTREE_BASE, db = null, logger$17) {
337
337
  this._eventBus = eventBus;
338
338
  this._projectRoot = projectRoot;
339
339
  this._baseDirectory = baseDirectory;
340
340
  this._db = db;
341
- this._logger = logger$16 ?? console;
341
+ this._logger = logger$17 ?? console;
342
342
  this._onTaskReady = ({ taskId }) => {
343
343
  this._handleTaskReady(taskId).catch((err) => {
344
344
  this._logger.error({
@@ -642,14 +642,14 @@ var RecommendationEngine = class {
642
642
  _filters;
643
643
  _historyDays;
644
644
  _logger;
645
- constructor(monitorDb, config = {}, logger$16) {
645
+ constructor(monitorDb, config = {}, logger$17) {
646
646
  this._monitorDb = monitorDb;
647
647
  this._filters = {
648
648
  threshold_percentage: config.recommendation_threshold_percentage ?? 5,
649
649
  min_sample_size: config.min_sample_size ?? 10
650
650
  };
651
651
  this._historyDays = config.recommendation_history_days ?? 90;
652
- this._logger = logger$16 ?? console;
652
+ this._logger = logger$17 ?? console;
653
653
  }
654
654
  generateRecommendations() {
655
655
  const sinceDate = new Date(Date.now() - this._historyDays * 24 * 60 * 60 * 1e3).toISOString();
@@ -1739,7 +1739,7 @@ function buildStackAwareDevNotes(profile) {
1739
1739
 
1740
1740
  //#endregion
1741
1741
  //#region src/cli/commands/init.ts
1742
- const logger$15 = createLogger("init");
1742
+ const logger$16 = createLogger("init");
1743
1743
  const __dirname = dirname(new URL(import.meta.url).pathname);
1744
1744
  const SCAFFOLD_VERSION_REGEX = /<!-- substrate:version=([\d.]+) -->/;
1745
1745
  /**
@@ -1780,7 +1780,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1780
1780
  const version = resolveBmadMethodVersion();
1781
1781
  if (force && bmadExists) process.stderr.write(`Warning: Replacing existing _bmad/ framework with bmad-method@${version}\n`);
1782
1782
  process.stdout.write(`Scaffolding BMAD framework from bmad-method@${version}\n`);
1783
- logger$15.info({
1783
+ logger$16.info({
1784
1784
  version,
1785
1785
  dest: bmadDest
1786
1786
  }, "Scaffolding BMAD framework");
@@ -1790,7 +1790,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1790
1790
  const destDir = join(bmadDest, dir);
1791
1791
  mkdirSync$1(destDir, { recursive: true });
1792
1792
  cpSync(srcDir, destDir, { recursive: true });
1793
- logger$15.info({
1793
+ logger$16.info({
1794
1794
  dir,
1795
1795
  dest: destDir
1796
1796
  }, "Scaffolded BMAD framework directory");
@@ -1809,7 +1809,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1809
1809
  "document_output_language: English"
1810
1810
  ].join("\n") + "\n";
1811
1811
  await writeFile(configFile, configStub, "utf8");
1812
- logger$15.info({ configFile }, "Generated _bmad/_config/config.yaml stub");
1812
+ logger$16.info({ configFile }, "Generated _bmad/_config/config.yaml stub");
1813
1813
  }
1814
1814
  }
1815
1815
  const CLAUDE_MD_START_MARKER = "<!-- substrate:start -->";
@@ -1824,7 +1824,7 @@ async function scaffoldClaudeMd(projectRoot, profile) {
1824
1824
  try {
1825
1825
  sectionContent = await readFile(templatePath, "utf8");
1826
1826
  } catch {
1827
- logger$15.warn({ templatePath }, "CLAUDE.md substrate section template not found; skipping");
1827
+ logger$16.warn({ templatePath }, "CLAUDE.md substrate section template not found; skipping");
1828
1828
  return;
1829
1829
  }
1830
1830
  const substrateVersion = readSubstrateVersion(pkgRoot);
@@ -1860,7 +1860,7 @@ async function scaffoldClaudeMd(projectRoot, profile) {
1860
1860
  else newContent = updatedExisting;
1861
1861
  }
1862
1862
  await writeFile(claudeMdPath, newContent, "utf8");
1863
- logger$15.info({ claudeMdPath }, "Wrote substrate section to CLAUDE.md");
1863
+ logger$16.info({ claudeMdPath }, "Wrote substrate section to CLAUDE.md");
1864
1864
  }
1865
1865
  async function scaffoldAgentsMd(projectRoot, profile) {
1866
1866
  const agentsMdPath = join(projectRoot, "AGENTS.md");
@@ -1872,7 +1872,7 @@ async function scaffoldAgentsMd(projectRoot, profile) {
1872
1872
  try {
1873
1873
  sectionContent = await readFile(templatePath, "utf8");
1874
1874
  } catch {
1875
- logger$15.warn({ templatePath }, "AGENTS.md substrate section template not found; skipping");
1875
+ logger$16.warn({ templatePath }, "AGENTS.md substrate section template not found; skipping");
1876
1876
  return;
1877
1877
  }
1878
1878
  const substrateVersion = readSubstrateVersion(pkgRoot);
@@ -1893,7 +1893,7 @@ async function scaffoldAgentsMd(projectRoot, profile) {
1893
1893
  newContent = existingContent + separator + sectionContent;
1894
1894
  }
1895
1895
  await writeFile(agentsMdPath, newContent, "utf8");
1896
- logger$15.info({ agentsMdPath }, "Wrote substrate section to AGENTS.md");
1896
+ logger$16.info({ agentsMdPath }, "Wrote substrate section to AGENTS.md");
1897
1897
  }
1898
1898
  async function scaffoldGeminiMd(projectRoot, profile) {
1899
1899
  const geminiMdPath = join(projectRoot, "GEMINI.md");
@@ -1905,7 +1905,7 @@ async function scaffoldGeminiMd(projectRoot, profile) {
1905
1905
  try {
1906
1906
  sectionContent = await readFile(templatePath, "utf8");
1907
1907
  } catch {
1908
- logger$15.warn({ templatePath }, "GEMINI.md substrate section template not found; skipping");
1908
+ logger$16.warn({ templatePath }, "GEMINI.md substrate section template not found; skipping");
1909
1909
  return;
1910
1910
  }
1911
1911
  const substrateVersion = readSubstrateVersion(pkgRoot);
@@ -1926,7 +1926,7 @@ async function scaffoldGeminiMd(projectRoot, profile) {
1926
1926
  newContent = existingContent + separator + sectionContent;
1927
1927
  }
1928
1928
  await writeFile(geminiMdPath, newContent, "utf8");
1929
- logger$15.info({ geminiMdPath }, "Wrote substrate section to GEMINI.md");
1929
+ logger$16.info({ geminiMdPath }, "Wrote substrate section to GEMINI.md");
1930
1930
  }
1931
1931
  async function scaffoldStatuslineScript(projectRoot) {
1932
1932
  const pkgRoot = findPackageRoot(__dirname);
@@ -1937,7 +1937,7 @@ async function scaffoldStatuslineScript(projectRoot) {
1937
1937
  try {
1938
1938
  content = await readFile(templatePath, "utf8");
1939
1939
  } catch {
1940
- logger$15.warn({ templatePath }, "statusline.sh template not found; skipping");
1940
+ logger$16.warn({ templatePath }, "statusline.sh template not found; skipping");
1941
1941
  return;
1942
1942
  }
1943
1943
  const claudeDir = join(projectRoot, ".claude");
@@ -1945,7 +1945,7 @@ async function scaffoldStatuslineScript(projectRoot) {
1945
1945
  mkdirSync$1(claudeDir, { recursive: true });
1946
1946
  await writeFile(statuslinePath, content, "utf8");
1947
1947
  chmodSync(statuslinePath, 493);
1948
- logger$15.info({ statuslinePath }, "Wrote .claude/statusline.sh");
1948
+ logger$16.info({ statuslinePath }, "Wrote .claude/statusline.sh");
1949
1949
  }
1950
1950
  async function scaffoldClaudeSettings(projectRoot) {
1951
1951
  const claudeDir = join(projectRoot, ".claude");
@@ -1961,7 +1961,7 @@ async function scaffoldClaudeSettings(projectRoot) {
1961
1961
  if (!merged["$schema"]) merged["$schema"] = "https://json.schemastore.org/claude-code-settings.json";
1962
1962
  mkdirSync$1(claudeDir, { recursive: true });
1963
1963
  await writeFile(settingsPath, JSON.stringify(merged, null, 2) + "\n", "utf8");
1964
- logger$15.info({ settingsPath }, "Wrote substrate settings to .claude/settings.json");
1964
+ logger$16.info({ settingsPath }, "Wrote substrate settings to .claude/settings.json");
1965
1965
  }
1966
1966
  function resolveBmadMethodInstallerLibPath(fromDir = __dirname) {
1967
1967
  try {
@@ -2033,7 +2033,7 @@ async function compileBmadAgents(bmadDir) {
2033
2033
  writeFileSync$1(mdPath, result.xml, "utf-8");
2034
2034
  compiled++;
2035
2035
  } catch (compileErr) {
2036
- logger$15.debug({
2036
+ logger$16.debug({
2037
2037
  err: compileErr,
2038
2038
  file
2039
2039
  }, "Failed to compile agent YAML");
@@ -2180,9 +2180,9 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2180
2180
  const _require = createRequire(join(__dirname, "synthetic.js"));
2181
2181
  try {
2182
2182
  const compiledCount = await compileBmadAgents(bmadDir);
2183
- if (compiledCount > 0) logger$15.info({ compiledCount }, "Compiled agent YAML files to MD");
2183
+ if (compiledCount > 0) logger$16.info({ compiledCount }, "Compiled agent YAML files to MD");
2184
2184
  } catch (compileErr) {
2185
- logger$15.warn({ err: compileErr }, "Agent compilation failed; agent commands may be incomplete");
2185
+ logger$16.warn({ err: compileErr }, "Agent compilation failed; agent commands may be incomplete");
2186
2186
  }
2187
2187
  const resolveExport = (mod, name) => {
2188
2188
  if (typeof mod[name] === "function") return mod[name];
@@ -2196,7 +2196,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2196
2196
  const manifestGenPath = join(installerLibPath, "core", "manifest-generator.js");
2197
2197
  const pathUtilsPath = join(installerLibPath, "ide", "shared", "path-utils.js");
2198
2198
  if (!existsSync$1(agentGenPath)) {
2199
- logger$15.info("bmad-method generators not available (requires bmad-method with agent/workflow/task-tool generators)");
2199
+ logger$16.info("bmad-method generators not available (requires bmad-method with agent/workflow/task-tool generators)");
2200
2200
  return;
2201
2201
  }
2202
2202
  const agentMod = _require(agentGenPath);
@@ -2206,11 +2206,11 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2206
2206
  if (existsSync$1(workflowGenPath)) {
2207
2207
  const workflowMod = _require(workflowGenPath);
2208
2208
  WorkflowCommandGenerator = resolveExport(workflowMod, "WorkflowCommandGenerator");
2209
- } else logger$15.info("bmad-method workflow-command-generator not available; will try skill-based installation");
2209
+ } else logger$16.info("bmad-method workflow-command-generator not available; will try skill-based installation");
2210
2210
  if (existsSync$1(taskToolGenPath)) {
2211
2211
  const taskToolMod = _require(taskToolGenPath);
2212
2212
  TaskToolCommandGenerator = resolveExport(taskToolMod, "TaskToolCommandGenerator");
2213
- } else logger$15.info("bmad-method task-tool-command-generator not available; will try skill-based installation");
2213
+ } else logger$16.info("bmad-method task-tool-command-generator not available; will try skill-based installation");
2214
2214
  let ManifestGenerator = null;
2215
2215
  if (existsSync$1(manifestGenPath)) {
2216
2216
  const manifestMod = _require(manifestGenPath);
@@ -2242,7 +2242,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2242
2242
  const manifestGen = new ManifestGenerator();
2243
2243
  await manifestGen.generateManifests(bmadDir, allModules, [], { ides: ["claude-code"] });
2244
2244
  } catch (manifestErr) {
2245
- logger$15.warn({ err: manifestErr }, "ManifestGenerator failed; workflow/task commands may be incomplete");
2245
+ logger$16.warn({ err: manifestErr }, "ManifestGenerator failed; workflow/task commands may be incomplete");
2246
2246
  }
2247
2247
  const commandsDir = join(projectRoot, ".claude", "commands");
2248
2248
  mkdirSync$1(commandsDir, { recursive: true });
@@ -2270,7 +2270,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2270
2270
  const total = agentCount + workflowCount + taskToolCount + skillCount;
2271
2271
  if (outputFormat !== "json") if (skillCount > 0) process.stdout.write(`Generated ${String(total)} Claude Code commands (${String(agentCount)} agents, ${String(skillCount)} skills)\n`);
2272
2272
  else process.stdout.write(`Generated ${String(total)} Claude Code commands (${String(agentCount)} agents, ${String(workflowCount)} workflows, ${String(taskToolCount)} tasks/tools)\n`);
2273
- logger$15.info({
2273
+ logger$16.info({
2274
2274
  agentCount,
2275
2275
  workflowCount,
2276
2276
  taskToolCount,
@@ -2281,7 +2281,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2281
2281
  } catch (err) {
2282
2282
  const msg = err instanceof Error ? err.message : String(err);
2283
2283
  if (outputFormat !== "json") process.stderr.write(`Warning: .claude/commands/ generation failed: ${msg}\n`);
2284
- logger$15.warn({ err }, "scaffoldClaudeCommands failed; init continues");
2284
+ logger$16.warn({ err }, "scaffoldClaudeCommands failed; init continues");
2285
2285
  }
2286
2286
  }
2287
2287
  /**
@@ -2310,7 +2310,7 @@ function syncCommandsAsPrompts(commandsDir, promptsDir, ownershipPrefixes, nameP
2310
2310
  unlinkSync$1(join(promptsDir, entry.name));
2311
2311
  }
2312
2312
  } catch (err) {
2313
- logger$15.debug({
2313
+ logger$16.debug({
2314
2314
  err,
2315
2315
  promptsDir
2316
2316
  }, "Failed to prune stale prompts");
@@ -2352,7 +2352,7 @@ function syncSkillsToTarget(srcSkillsDir, destSkillsDir, ownershipPrefixes, name
2352
2352
  });
2353
2353
  }
2354
2354
  } catch (err) {
2355
- logger$15.debug({
2355
+ logger$16.debug({
2356
2356
  err,
2357
2357
  destSkillsDir
2358
2358
  }, "Failed to prune stale skills");
@@ -2395,16 +2395,16 @@ function scaffoldCodexProject(projectRoot, outputFormat) {
2395
2395
  const skillCount = syncSkillsToTarget(claudeSkillsDir, codexSkillsDir, PROJECT_OWNERSHIP_PREFIXES, "");
2396
2396
  const total = promptCount + skillCount;
2397
2397
  if (outputFormat !== "json" && total > 0) process.stdout.write(`Generated ${String(total)} Codex artifacts (${String(promptCount)} prompts, ${String(skillCount)} skills)\n`);
2398
- if (total > 0) logger$15.info({
2398
+ if (total > 0) logger$16.info({
2399
2399
  promptCount,
2400
2400
  skillCount,
2401
2401
  codexDir
2402
2402
  }, "Generated .codex/");
2403
- else logger$15.debug({ codexDir }, "No Codex artifacts generated; source Claude content not found");
2403
+ else logger$16.debug({ codexDir }, "No Codex artifacts generated; source Claude content not found");
2404
2404
  } catch (err) {
2405
2405
  const msg = err instanceof Error ? err.message : String(err);
2406
2406
  if (outputFormat !== "json") process.stderr.write(`Warning: .codex/ generation failed: ${msg}\n`);
2407
- logger$15.warn({ err }, "scaffoldCodexProject failed; init continues");
2407
+ logger$16.warn({ err }, "scaffoldCodexProject failed; init continues");
2408
2408
  }
2409
2409
  }
2410
2410
  /**
@@ -2430,16 +2430,16 @@ function scaffoldCodexUser(projectRoot, homeDir, outputFormat) {
2430
2430
  const skillCount = syncSkillsToTarget(claudeSkillsDir, userSkillsDir, ["substrate-"], "substrate-");
2431
2431
  const total = promptCount + skillCount;
2432
2432
  if (outputFormat !== "json" && total > 0) process.stdout.write(`Installed ${String(total)} Codex artifacts to ${userCodexDir} (${String(promptCount)} prompts, ${String(skillCount)} skills)\n`);
2433
- if (total > 0) logger$15.info({
2433
+ if (total > 0) logger$16.info({
2434
2434
  promptCount,
2435
2435
  skillCount,
2436
2436
  userCodexDir
2437
2437
  }, "Installed user-scope Codex content");
2438
- else logger$15.debug({ userCodexDir }, "No user-scope Codex content installed; source Claude content not found");
2438
+ else logger$16.debug({ userCodexDir }, "No user-scope Codex content installed; source Claude content not found");
2439
2439
  } catch (err) {
2440
2440
  const msg = err instanceof Error ? err.message : String(err);
2441
2441
  if (outputFormat !== "json") process.stderr.write(`Warning: user-scope Codex install failed: ${msg}\n`);
2442
- logger$15.warn({ err }, "scaffoldCodexUser failed; init continues");
2442
+ logger$16.warn({ err }, "scaffoldCodexUser failed; init continues");
2443
2443
  }
2444
2444
  }
2445
2445
  const PROVIDER_DEFAULTS = DEFAULT_CONFIG.providers;
@@ -2559,7 +2559,7 @@ async function runInitAction(options) {
2559
2559
  discoveryReport = await registry.discoverAndRegister();
2560
2560
  } catch (err) {
2561
2561
  const message = err instanceof Error ? err.message : String(err);
2562
- logger$15.error({ err }, "Adapter discovery failed");
2562
+ logger$16.error({ err }, "Adapter discovery failed");
2563
2563
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, `Adapter discovery failed: ${message}`) + "\n");
2564
2564
  else process.stderr.write(` Error: adapter discovery failed — ${message}\n`);
2565
2565
  return INIT_EXIT_ERROR;
@@ -2602,7 +2602,7 @@ async function runInitAction(options) {
2602
2602
  try {
2603
2603
  detectedProfile = await detectProjectProfile(dbRoot);
2604
2604
  } catch (err) {
2605
- logger$15.warn({ err }, "Project profile detection failed; skipping");
2605
+ logger$16.warn({ err }, "Project profile detection failed; skipping");
2606
2606
  }
2607
2607
  if (detectedProfile === null) {
2608
2608
  if (outputFormat !== "json") process.stdout.write(" No project stack detected. Create .substrate/project-profile.yaml manually to enable polyglot support.\n");
@@ -2636,12 +2636,12 @@ async function runInitAction(options) {
2636
2636
  return INIT_EXIT_ERROR;
2637
2637
  }
2638
2638
  if (force && existsSync$1(localManifest)) {
2639
- logger$15.info({ pack: packName }, "Replacing existing pack with bundled version");
2639
+ logger$16.info({ pack: packName }, "Replacing existing pack with bundled version");
2640
2640
  process.stderr.write(`Warning: Replacing existing pack '${packName}' with bundled version\n`);
2641
2641
  }
2642
2642
  mkdirSync$1(dirname(packPath), { recursive: true });
2643
2643
  cpSync(bundledPackPath, packPath, { recursive: true });
2644
- logger$15.info({
2644
+ logger$16.info({
2645
2645
  pack: packName,
2646
2646
  dest: packPath
2647
2647
  }, "Scaffolded methodology pack");
@@ -2693,10 +2693,10 @@ async function runInitAction(options) {
2693
2693
  if (missing.length > 0) {
2694
2694
  const block = "\n# Substrate runtime files\n" + missing.join("\n") + "\n";
2695
2695
  appendFileSync(gitignorePath, block);
2696
- logger$15.info({ entries: missing }, "Added substrate runtime files to .gitignore");
2696
+ logger$16.info({ entries: missing }, "Added substrate runtime files to .gitignore");
2697
2697
  }
2698
2698
  } catch (err) {
2699
- logger$15.debug({ err }, "Could not update .gitignore (non-fatal)");
2699
+ logger$16.debug({ err }, "Could not update .gitignore (non-fatal)");
2700
2700
  }
2701
2701
  const doltMode = options.doltMode ?? "auto";
2702
2702
  let doltInitialized = false;
@@ -2713,7 +2713,7 @@ async function runInitAction(options) {
2713
2713
  process.stderr.write(`${err.message}\n`);
2714
2714
  return INIT_EXIT_ERROR;
2715
2715
  }
2716
- logger$15.debug("Dolt not installed, skipping auto-init");
2716
+ logger$16.debug("Dolt not installed, skipping auto-init");
2717
2717
  } else {
2718
2718
  const msg = err instanceof Error ? err.message : String(err);
2719
2719
  if (doltMode === "force") {
@@ -2723,7 +2723,7 @@ async function runInitAction(options) {
2723
2723
  process.stderr.write(`⚠ Dolt state store initialization failed: ${msg}\n Pipeline metrics, cost tracking, and health monitoring will not persist.\n Fix the issue and re-run: substrate init --dolt\n`);
2724
2724
  }
2725
2725
  }
2726
- else logger$15.debug("Dolt step was skipped (--no-dolt)");
2726
+ else logger$16.debug("Dolt step was skipped (--no-dolt)");
2727
2727
  const successMsg = `Pack '${packName}' and database initialized successfully at ${dbPath}`;
2728
2728
  if (outputFormat === "json") process.stdout.write(formatOutput({
2729
2729
  pack: packName,
@@ -2761,7 +2761,7 @@ async function runInitAction(options) {
2761
2761
  const msg = err instanceof Error ? err.message : String(err);
2762
2762
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
2763
2763
  else process.stderr.write(`Error: ${msg}\n`);
2764
- logger$15.error({ err }, "init failed");
2764
+ logger$16.error({ err }, "init failed");
2765
2765
  return INIT_EXIT_ERROR;
2766
2766
  }
2767
2767
  }
@@ -2785,7 +2785,7 @@ function registerInitCommand(program, _version, registry) {
2785
2785
 
2786
2786
  //#endregion
2787
2787
  //#region src/cli/commands/config.ts
2788
- const logger$14 = createLogger("config-cmd");
2788
+ const logger$15 = createLogger("config-cmd");
2789
2789
  const CONFIG_EXIT_SUCCESS = 0;
2790
2790
  const CONFIG_EXIT_ERROR = 1;
2791
2791
  const CONFIG_EXIT_INVALID = 2;
@@ -2811,7 +2811,7 @@ async function runConfigShow(opts = {}) {
2811
2811
  return CONFIG_EXIT_INVALID;
2812
2812
  }
2813
2813
  const message = err instanceof Error ? err.message : String(err);
2814
- logger$14.error({ err }, "Failed to load configuration");
2814
+ logger$15.error({ err }, "Failed to load configuration");
2815
2815
  process.stderr.write(` Error loading configuration: ${message}\n`);
2816
2816
  return CONFIG_EXIT_ERROR;
2817
2817
  }
@@ -2885,7 +2885,7 @@ async function runConfigExport(opts = {}) {
2885
2885
  return CONFIG_EXIT_INVALID;
2886
2886
  }
2887
2887
  const message = err instanceof Error ? err.message : String(err);
2888
- logger$14.error({ err }, "Failed to load configuration");
2888
+ logger$15.error({ err }, "Failed to load configuration");
2889
2889
  process.stderr.write(`Error loading configuration: ${message}\n`);
2890
2890
  return CONFIG_EXIT_ERROR;
2891
2891
  }
@@ -3039,7 +3039,7 @@ function registerConfigCommand(program, _version) {
3039
3039
 
3040
3040
  //#endregion
3041
3041
  //#region src/cli/commands/resume.ts
3042
- const logger$13 = createLogger("resume-cmd");
3042
+ const logger$14 = createLogger("resume-cmd");
3043
3043
  /**
3044
3044
  * Map internal orchestrator phase names to pipeline event protocol phase names.
3045
3045
  */
@@ -3131,15 +3131,15 @@ async function runResumeAction(options) {
3131
3131
  const manifestStories = manifestData.cli_flags["stories"] ?? manifestData.story_scope;
3132
3132
  if (Array.isArray(manifestStories) && manifestStories.length > 0) {
3133
3133
  scopedStories = manifestStories;
3134
- logger$13.debug({
3134
+ logger$14.debug({
3135
3135
  runId,
3136
3136
  stories: scopedStories
3137
3137
  }, "resume scope loaded from manifest");
3138
3138
  }
3139
3139
  } catch {
3140
- logger$13.debug({ runId }, "manifest read failed in resume — using legacy config_json scope");
3140
+ logger$14.debug({ runId }, "manifest read failed in resume — using legacy config_json scope");
3141
3141
  }
3142
- else logger$13.debug({ runId }, "Run manifest not found for scope preservation — using legacy config_json scope");
3142
+ else logger$14.debug({ runId }, "Run manifest not found for scope preservation — using legacy config_json scope");
3143
3143
  }
3144
3144
  return runFullPipelineFromPhase({
3145
3145
  packName,
@@ -3162,7 +3162,7 @@ async function runResumeAction(options) {
3162
3162
  const msg = err instanceof Error ? err.message : String(err);
3163
3163
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
3164
3164
  else process.stderr.write(`Error: ${msg}\n`);
3165
- logger$13.error({ err }, "auto resume failed");
3165
+ logger$14.error({ err }, "auto resume failed");
3166
3166
  return 1;
3167
3167
  } finally {
3168
3168
  try {
@@ -3411,11 +3411,11 @@ async function runFullPipelineFromPhase(options) {
3411
3411
  output_tokens: output,
3412
3412
  cost_usd: costUsd
3413
3413
  }).catch((err) => {
3414
- logger$13.warn({ err }, "Failed to record token usage");
3414
+ logger$14.warn({ err }, "Failed to record token usage");
3415
3415
  });
3416
3416
  }
3417
3417
  } catch (err) {
3418
- logger$13.warn({ err }, "Failed to record token usage");
3418
+ logger$14.warn({ err }, "Failed to record token usage");
3419
3419
  }
3420
3420
  });
3421
3421
  const storyKeys = await resolveStoryKeys(adapter, projectRoot, {
@@ -3484,7 +3484,7 @@ async function runFullPipelineFromPhase(options) {
3484
3484
  const msg = err instanceof Error ? err.message : String(err);
3485
3485
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
3486
3486
  else process.stderr.write(`Error: ${msg}\n`);
3487
- logger$13.error({ err }, "pipeline from phase failed");
3487
+ logger$14.error({ err }, "pipeline from phase failed");
3488
3488
  return 1;
3489
3489
  } finally {
3490
3490
  try {
@@ -3513,7 +3513,7 @@ function registerResumeCommand(program, _version = "0.0.0", projectRoot = proces
3513
3513
 
3514
3514
  //#endregion
3515
3515
  //#region src/cli/commands/status.ts
3516
- const logger$12 = createLogger("status-cmd");
3516
+ const logger$13 = createLogger("status-cmd");
3517
3517
  /**
3518
3518
  * Map a manifest per-story status string to the appropriate WorkGraphCounts bucket.
3519
3519
  * Unknown strings are treated as `inProgress` (safe default).
@@ -3625,9 +3625,9 @@ async function runStatusAction(options) {
3625
3625
  const manifestData = await resolvedManifest.read();
3626
3626
  manifestPerStoryState = manifestData.per_story_state;
3627
3627
  workGraph = buildWorkGraphFromManifest(manifestData.per_story_state);
3628
- logger$12.debug({ runId: run?.id }, "status: workGraph built from manifest per_story_state");
3628
+ logger$13.debug({ runId: run?.id }, "status: workGraph built from manifest per_story_state");
3629
3629
  } catch {
3630
- logger$12.debug({ runId: run?.id }, "status: manifest read failed — falling back to wg_stories");
3630
+ logger$13.debug({ runId: run?.id }, "status: manifest read failed — falling back to wg_stories");
3631
3631
  }
3632
3632
  if (workGraph === void 0) try {
3633
3633
  const wgRepo = new WorkGraphRepository(adapter);
@@ -3664,10 +3664,10 @@ async function runStatusAction(options) {
3664
3664
  };
3665
3665
  }
3666
3666
  } catch (err) {
3667
- logger$12.debug({ err }, "Work graph query failed, continuing without work graph data");
3667
+ logger$13.debug({ err }, "Work graph query failed, continuing without work graph data");
3668
3668
  }
3669
3669
  if (run === void 0) {
3670
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-DvAr7miW.js");
3670
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-C-ZrHJwL.js");
3671
3671
  const substrateDirPath = join(projectRoot, ".substrate");
3672
3672
  const processInfo = inspectProcessTree$1({
3673
3673
  projectRoot,
@@ -3697,7 +3697,7 @@ async function runStatusAction(options) {
3697
3697
  if (stateStore) try {
3698
3698
  storeStories = await stateStore.queryStories({});
3699
3699
  } catch (err) {
3700
- logger$12.debug({ err }, "StateStore query failed, continuing without store data");
3700
+ logger$13.debug({ err }, "StateStore query failed, continuing without store data");
3701
3701
  }
3702
3702
  if (outputFormat === "json") {
3703
3703
  const statusOutput = buildPipelineStatusOutput(run, tokenSummary, decisionsCount, storiesCount);
@@ -3825,7 +3825,7 @@ async function runStatusAction(options) {
3825
3825
  const msg = err instanceof Error ? err.message : String(err);
3826
3826
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
3827
3827
  else process.stderr.write(`Error: ${msg}\n`);
3828
- logger$12.error({ err }, "status action failed");
3828
+ logger$13.error({ err }, "status action failed");
3829
3829
  return 1;
3830
3830
  } finally {
3831
3831
  try {
@@ -4172,7 +4172,7 @@ Analyze thoroughly and return ONLY the JSON array with no additional text.`;
4172
4172
 
4173
4173
  //#endregion
4174
4174
  //#region src/cli/commands/amend.ts
4175
- const logger$11 = createLogger("amend-cmd");
4175
+ const logger$12 = createLogger("amend-cmd");
4176
4176
  /**
4177
4177
  * Detect and apply supersessions after a phase completes in an amendment run.
4178
4178
  *
@@ -4203,7 +4203,7 @@ async function runPostPhaseSupersessionDetection(adapter, amendmentRunId, curren
4203
4203
  });
4204
4204
  } catch (err) {
4205
4205
  const msg = err instanceof Error ? err.message : String(err);
4206
- logger$11.warn({
4206
+ logger$12.warn({
4207
4207
  err,
4208
4208
  originalId: parentMatch.id,
4209
4209
  supersedingId: newDec.id
@@ -4340,7 +4340,7 @@ async function runAmendAction(options) {
4340
4340
  for (let i = startIdx; i < phaseOrder.length; i++) {
4341
4341
  const currentPhase = phaseOrder[i];
4342
4342
  const amendmentContext = handler.loadContextForPhase(currentPhase);
4343
- logger$11.info({
4343
+ logger$12.info({
4344
4344
  phase: currentPhase,
4345
4345
  amendmentContextLen: amendmentContext.length
4346
4346
  }, "Amendment context loaded for phase");
@@ -4461,7 +4461,7 @@ async function runAmendAction(options) {
4461
4461
  } catch (err) {
4462
4462
  const msg = err instanceof Error ? err.message : String(err);
4463
4463
  process.stderr.write(`Error: ${msg}\n`);
4464
- logger$11.error({ err }, "amend failed");
4464
+ logger$12.error({ err }, "amend failed");
4465
4465
  return 1;
4466
4466
  } finally {
4467
4467
  try {
@@ -4617,7 +4617,7 @@ function defaultSupervisorDeps() {
4617
4617
  if (cached === null) {
4618
4618
  const { AdapterRegistry: AR } = await import(
4619
4619
  /* @vite-ignore */
4620
- "../adapter-registry-Cu2eLuau.js"
4620
+ "../adapter-registry-CcahKCG1.js"
4621
4621
  );
4622
4622
  cached = new AR();
4623
4623
  await cached.discoverAndRegister();
@@ -5184,11 +5184,11 @@ async function runSupervisorAction(options, deps = {}) {
5184
5184
  try {
5185
5185
  const { createExperimenter } = await import(
5186
5186
  /* @vite-ignore */
5187
- "../experimenter-CN8PhRbv.js"
5187
+ "../experimenter-2KGF4bLj.js"
5188
5188
  );
5189
5189
  const { getLatestRun: getLatest } = await import(
5190
5190
  /* @vite-ignore */
5191
- "../decisions-DlPFWRDm.js"
5191
+ "../decisions-UFV5YFaW.js"
5192
5192
  );
5193
5193
  const expAdapter = createDatabaseAdapter({
5194
5194
  backend: "auto",
@@ -5198,7 +5198,7 @@ async function runSupervisorAction(options, deps = {}) {
5198
5198
  await initSchema(expAdapter);
5199
5199
  const { runRunAction: runPipeline } = await import(
5200
5200
  /* @vite-ignore */
5201
- "../run-__o2iU0w.js"
5201
+ "../run-CL1C4M2f.js"
5202
5202
  );
5203
5203
  const runStoryFn = async (opts) => {
5204
5204
  const exitCode = await runPipeline({
@@ -5448,7 +5448,7 @@ function registerSupervisorCommand(program, _version = "0.0.0", projectRoot = pr
5448
5448
 
5449
5449
  //#endregion
5450
5450
  //#region src/cli/commands/metrics.ts
5451
- const logger$10 = createLogger("metrics-cmd");
5451
+ const logger$11 = createLogger("metrics-cmd");
5452
5452
  async function openTelemetryAdapter(basePath) {
5453
5453
  try {
5454
5454
  const adapter = createDatabaseAdapter({
@@ -5730,7 +5730,7 @@ async function runMetricsAction(options) {
5730
5730
  const routingConfigPath = join(dbDir, "routing.yml");
5731
5731
  let routingConfig = null;
5732
5732
  if (existsSync$1(routingConfigPath)) try {
5733
- const { loadModelRoutingConfig } = await import("../routing-sauIk945.js");
5733
+ const { loadModelRoutingConfig } = await import("../routing-BNGNSI0w.js");
5734
5734
  routingConfig = loadModelRoutingConfig(routingConfigPath);
5735
5735
  } catch {}
5736
5736
  if (routingConfig === null) routingConfig = {
@@ -5814,7 +5814,7 @@ async function runMetricsAction(options) {
5814
5814
  }
5815
5815
  }
5816
5816
  } catch (err) {
5817
- logger$10.debug({ err }, "getScenarioResultsForRun failed");
5817
+ logger$11.debug({ err }, "getScenarioResultsForRun failed");
5818
5818
  }
5819
5819
  if (rows.length === 0) {
5820
5820
  const msg = `No factory run found with id: ${run}`;
@@ -5850,7 +5850,7 @@ async function runMetricsAction(options) {
5850
5850
  }
5851
5851
  }
5852
5852
  } catch (err) {
5853
- logger$10.debug({ err }, "getTwinRunsForRun failed — twin_runs table may not exist yet");
5853
+ logger$11.debug({ err }, "getTwinRunsForRun failed — twin_runs table may not exist yet");
5854
5854
  }
5855
5855
  }
5856
5856
  return 0;
@@ -5860,7 +5860,7 @@ async function runMetricsAction(options) {
5860
5860
  try {
5861
5861
  factoryRuns$1 = await getFactoryRunSummaries(adapter, limit);
5862
5862
  } catch (err) {
5863
- logger$10.debug({ err }, "getFactoryRunSummaries failed in factory-only mode");
5863
+ logger$11.debug({ err }, "getFactoryRunSummaries failed in factory-only mode");
5864
5864
  }
5865
5865
  if (outputFormat === "json") process.stdout.write(formatOutput({ graph_runs: factoryRuns$1 }, "json", true) + "\n");
5866
5866
  else if (factoryRuns$1.length === 0) process.stdout.write("No factory runs recorded yet.\n");
@@ -5921,7 +5921,7 @@ async function runMetricsAction(options) {
5921
5921
  doltMetrics = await stateStore.queryMetrics(doltFilter);
5922
5922
  await stateStore.close();
5923
5923
  } catch (doltErr) {
5924
- logger$10.warn({ err: doltErr }, "StateStore query failed — falling back to SQLite metrics only");
5924
+ logger$11.warn({ err: doltErr }, "StateStore query failed — falling back to SQLite metrics only");
5925
5925
  }
5926
5926
  const storyMetricDecisions = await getDecisionsByCategory(adapter, STORY_METRICS);
5927
5927
  const storyMetrics = storyMetricDecisions.map((d) => {
@@ -5977,7 +5977,7 @@ async function runMetricsAction(options) {
5977
5977
  try {
5978
5978
  factoryRuns = await getFactoryRunSummaries(adapter, limit);
5979
5979
  } catch (err) {
5980
- logger$10.debug({ err }, "getFactoryRunSummaries failed — table may not exist in older databases");
5980
+ logger$11.debug({ err }, "getFactoryRunSummaries failed — table may not exist in older databases");
5981
5981
  }
5982
5982
  if (outputFormat === "json") {
5983
5983
  const runsWithBreakdown = runs.map((run$1) => ({
@@ -6091,7 +6091,7 @@ async function runMetricsAction(options) {
6091
6091
  const msg = err instanceof Error ? err.message : String(err);
6092
6092
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
6093
6093
  else process.stderr.write(`Error: ${msg}\n`);
6094
- logger$10.error({ err }, "metrics action failed");
6094
+ logger$11.error({ err }, "metrics action failed");
6095
6095
  return 1;
6096
6096
  } finally {
6097
6097
  try {
@@ -6291,7 +6291,7 @@ function registerMigrateCommand(program) {
6291
6291
  function getLatestSessionId(_adapter) {
6292
6292
  return null;
6293
6293
  }
6294
- const logger$9 = createLogger("cost-cmd");
6294
+ const logger$10 = createLogger("cost-cmd");
6295
6295
  const COST_EXIT_SUCCESS = 0;
6296
6296
  const COST_EXIT_ERROR = 1;
6297
6297
  /**
@@ -6535,7 +6535,7 @@ async function runCostAction(options) {
6535
6535
  } catch (err) {
6536
6536
  const message = err instanceof Error ? err.message : String(err);
6537
6537
  process.stderr.write(`Error: ${message}\n`);
6538
- logger$9.error({ err }, "runCostAction failed");
6538
+ logger$10.error({ err }, "runCostAction failed");
6539
6539
  return COST_EXIT_ERROR;
6540
6540
  } finally {
6541
6541
  if (adapter !== null) try {
@@ -6569,7 +6569,7 @@ function registerCostCommand(program, version = "0.0.0", projectRoot = process.c
6569
6569
 
6570
6570
  //#endregion
6571
6571
  //#region src/cli/commands/monitor.ts
6572
- const logger$8 = createLogger("monitor-cmd");
6572
+ const logger$9 = createLogger("monitor-cmd");
6573
6573
  const MONITOR_EXIT_SUCCESS = 0;
6574
6574
  const MONITOR_EXIT_ERROR = 1;
6575
6575
  /**
@@ -6772,7 +6772,7 @@ async function runMonitorReportAction(options) {
6772
6772
  } catch (err) {
6773
6773
  const message = err instanceof Error ? err.message : String(err);
6774
6774
  process.stderr.write(`Error: ${message}\n`);
6775
- logger$8.error({ err }, "runMonitorReportAction failed");
6775
+ logger$9.error({ err }, "runMonitorReportAction failed");
6776
6776
  return MONITOR_EXIT_ERROR;
6777
6777
  } finally {
6778
6778
  if (monitorDb !== null) try {
@@ -6834,7 +6834,7 @@ async function runMonitorStatusAction(options) {
6834
6834
  } catch (err) {
6835
6835
  const message = err instanceof Error ? err.message : String(err);
6836
6836
  process.stderr.write(`Error: ${message}\n`);
6837
- logger$8.error({ err }, "runMonitorStatusAction failed");
6837
+ logger$9.error({ err }, "runMonitorStatusAction failed");
6838
6838
  return MONITOR_EXIT_ERROR;
6839
6839
  } finally {
6840
6840
  if (monitorDb !== null) try {
@@ -6869,7 +6869,7 @@ async function runMonitorResetAction(options) {
6869
6869
  } catch (err) {
6870
6870
  const message = err instanceof Error ? err.message : String(err);
6871
6871
  process.stderr.write(`Error: ${message}\n`);
6872
- logger$8.error({ err }, "runMonitorResetAction failed");
6872
+ logger$9.error({ err }, "runMonitorResetAction failed");
6873
6873
  return MONITOR_EXIT_ERROR;
6874
6874
  } finally {
6875
6875
  if (monitorDb !== null) try {
@@ -6917,7 +6917,7 @@ async function runMonitorRecommendationsAction(options) {
6917
6917
  } catch (err) {
6918
6918
  const message = err instanceof Error ? err.message : String(err);
6919
6919
  process.stderr.write(`Error: ${message}\n`);
6920
- logger$8.error({ err }, "runMonitorRecommendationsAction failed");
6920
+ logger$9.error({ err }, "runMonitorRecommendationsAction failed");
6921
6921
  return MONITOR_EXIT_ERROR;
6922
6922
  } finally {
6923
6923
  if (monitorDb !== null) try {
@@ -6995,7 +6995,7 @@ function registerMonitorCommand(program, version = "0.0.0", projectRoot = proces
6995
6995
 
6996
6996
  //#endregion
6997
6997
  //#region src/cli/commands/merge.ts
6998
- const logger$7 = createLogger("merge-cmd");
6998
+ const logger$8 = createLogger("merge-cmd");
6999
6999
  const MERGE_EXIT_SUCCESS = 0;
7000
7000
  const MERGE_EXIT_CONFLICT = 1;
7001
7001
  const MERGE_EXIT_ERROR = 2;
@@ -7033,7 +7033,7 @@ async function mergeTask(taskId, targetBranch, projectRoot) {
7033
7033
  projectRoot
7034
7034
  });
7035
7035
  try {
7036
- logger$7.info({
7036
+ logger$8.info({
7037
7037
  taskId,
7038
7038
  targetBranch
7039
7039
  }, "Running conflict detection...");
@@ -7055,7 +7055,7 @@ async function mergeTask(taskId, targetBranch, projectRoot) {
7055
7055
  } catch (err) {
7056
7056
  const message = err instanceof Error ? err.message : String(err);
7057
7057
  console.error(`Error merging task "${taskId}": ${message}`);
7058
- logger$7.error({
7058
+ logger$8.error({
7059
7059
  taskId,
7060
7060
  err
7061
7061
  }, "merge --task failed");
@@ -7109,7 +7109,7 @@ async function mergeAll(targetBranch, projectRoot, taskIds) {
7109
7109
  error: message
7110
7110
  });
7111
7111
  console.log(` Error for task "${taskId}": ${message}`);
7112
- logger$7.error({
7112
+ logger$8.error({
7113
7113
  taskId,
7114
7114
  err
7115
7115
  }, "merge --all: task failed");
@@ -7162,7 +7162,7 @@ function registerMergeCommand(program, projectRoot = process.cwd()) {
7162
7162
 
7163
7163
  //#endregion
7164
7164
  //#region src/cli/commands/worktrees.ts
7165
- const logger$6 = createLogger("worktrees-cmd");
7165
+ const logger$7 = createLogger("worktrees-cmd");
7166
7166
  const WORKTREES_EXIT_SUCCESS = 0;
7167
7167
  const WORKTREES_EXIT_ERROR = 1;
7168
7168
  /** Valid task statuses for filtering */
@@ -7289,7 +7289,7 @@ async function listWorktreesAction(options) {
7289
7289
  try {
7290
7290
  worktreeInfos = await manager.listWorktrees();
7291
7291
  } catch (err) {
7292
- logger$6.error({ err }, "Failed to list worktrees");
7292
+ logger$7.error({ err }, "Failed to list worktrees");
7293
7293
  const message = err instanceof Error ? err.message : String(err);
7294
7294
  process.stderr.write(`Error listing worktrees: ${message}\n`);
7295
7295
  return WORKTREES_EXIT_ERROR;
@@ -7316,7 +7316,7 @@ async function listWorktreesAction(options) {
7316
7316
  } catch (err) {
7317
7317
  const message = err instanceof Error ? err.message : String(err);
7318
7318
  process.stderr.write(`Error: ${message}\n`);
7319
- logger$6.error({ err }, "listWorktreesAction failed");
7319
+ logger$7.error({ err }, "listWorktreesAction failed");
7320
7320
  return WORKTREES_EXIT_ERROR;
7321
7321
  }
7322
7322
  }
@@ -7357,7 +7357,7 @@ function registerWorktreesCommand(program, version = "0.0.0", projectRoot = proc
7357
7357
 
7358
7358
  //#endregion
7359
7359
  //#region src/cli/commands/brainstorm.ts
7360
- const logger$5 = createLogger("brainstorm-cmd");
7360
+ const logger$6 = createLogger("brainstorm-cmd");
7361
7361
  /**
7362
7362
  * Detect whether the project has existing planning artifacts that indicate
7363
7363
  * this is an amendment session (vs. a brand-new project brainstorm).
@@ -7403,13 +7403,13 @@ async function loadAmendmentContextDocuments(projectRoot) {
7403
7403
  try {
7404
7404
  brief = await readFile(briefPath, "utf-8");
7405
7405
  } catch {
7406
- logger$5.warn({ briefPath }, "product-brief.md not found — continuing without brief context");
7406
+ logger$6.warn({ briefPath }, "product-brief.md not found — continuing without brief context");
7407
7407
  process.stderr.write(`Warning: product-brief.md not found at ${briefPath}\n`);
7408
7408
  }
7409
7409
  try {
7410
7410
  prd = await readFile(prdPath, "utf-8");
7411
7411
  } catch {
7412
- logger$5.warn({ prdPath }, "requirements.md not found — continuing without PRD context");
7412
+ logger$6.warn({ prdPath }, "requirements.md not found — continuing without PRD context");
7413
7413
  process.stderr.write(`Warning: requirements.md not found at ${prdPath}\n`);
7414
7414
  }
7415
7415
  return {
@@ -7618,7 +7618,7 @@ async function dispatchToPersonas(userPrompt, context, llmDispatch) {
7618
7618
  }
7619
7619
  ];
7620
7620
  const defaultDispatch = async (prompt, personaName) => {
7621
- logger$5.debug({
7621
+ logger$6.debug({
7622
7622
  personaName,
7623
7623
  promptLength: prompt.length
7624
7624
  }, "Dispatching to persona (stub mode)");
@@ -7635,7 +7635,7 @@ async function dispatchToPersonas(userPrompt, context, llmDispatch) {
7635
7635
  };
7636
7636
  } catch (err) {
7637
7637
  const msg = err instanceof Error ? err.message : String(err);
7638
- logger$5.error({
7638
+ logger$6.error({
7639
7639
  err,
7640
7640
  personaName: persona.name
7641
7641
  }, "Persona dispatch failed");
@@ -7787,7 +7787,7 @@ async function runBrainstormSession(options, llmDispatch, rlInterface) {
7787
7787
  }
7788
7788
  });
7789
7789
  rl.on("error", (err) => {
7790
- logger$5.error({ err }, "readline error");
7790
+ logger$6.error({ err }, "readline error");
7791
7791
  if (!sessionEnded) endSession(false);
7792
7792
  });
7793
7793
  });
@@ -7828,7 +7828,7 @@ function registerBrainstormCommand(program, _version = "0.0.0", projectRoot = pr
7828
7828
 
7829
7829
  //#endregion
7830
7830
  //#region src/cli/commands/retry-escalated.ts
7831
- const logger$4 = createLogger("retry-escalated-cmd");
7831
+ const logger$5 = createLogger("retry-escalated-cmd");
7832
7832
  async function runRetryEscalatedAction(options) {
7833
7833
  const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry, agent: agentId, events: eventsFlag } = options;
7834
7834
  const dbRoot = await resolveMainRepoRoot(projectRoot);
@@ -7869,7 +7869,7 @@ async function runRetryEscalatedAction(options) {
7869
7869
  process.stdout.write(`[INFO] ${storyKey}: Context ceiling set to ${contextCeiling} tokens due to prior context spike pattern.\n`);
7870
7870
  }
7871
7871
  } catch (err) {
7872
- logger$4.warn({
7872
+ logger$5.warn({
7873
7873
  err,
7874
7874
  storyKey
7875
7875
  }, "Failed to read efficiency profile — skipping gate");
@@ -8023,11 +8023,11 @@ async function runRetryEscalatedAction(options) {
8023
8023
  output_tokens: output,
8024
8024
  cost_usd: costUsd
8025
8025
  }).catch((err) => {
8026
- logger$4.warn({ err }, "Failed to record token usage");
8026
+ logger$5.warn({ err }, "Failed to record token usage");
8027
8027
  });
8028
8028
  }
8029
8029
  } catch (err) {
8030
- logger$4.warn({ err }, "Failed to record token usage");
8030
+ logger$5.warn({ err }, "Failed to record token usage");
8031
8031
  }
8032
8032
  });
8033
8033
  if (outputFormat === "human") {
@@ -8056,7 +8056,7 @@ async function runRetryEscalatedAction(options) {
8056
8056
  const msg = err instanceof Error ? err.message : String(err);
8057
8057
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
8058
8058
  else process.stderr.write(`Error: ${msg}\n`);
8059
- logger$4.error({ err }, "retry-escalated failed");
8059
+ logger$5.error({ err }, "retry-escalated failed");
8060
8060
  return 1;
8061
8061
  } finally {
8062
8062
  try {
@@ -8089,7 +8089,7 @@ function registerRetryEscalatedCommand(program, _version = "0.0.0", projectRoot
8089
8089
 
8090
8090
  //#endregion
8091
8091
  //#region src/cli/commands/cancel.ts
8092
- const logger$3 = createLogger("cancel-cmd");
8092
+ const logger$4 = createLogger("cancel-cmd");
8093
8093
  async function runCancelAction(options) {
8094
8094
  const { outputFormat, projectRoot, force } = options;
8095
8095
  const dbRoot = await resolveMainRepoRoot(projectRoot);
@@ -8128,7 +8128,7 @@ async function runCancelAction(options) {
8128
8128
  }
8129
8129
  } catch (err) {
8130
8130
  const msg = err instanceof Error ? err.message : String(err);
8131
- logger$3.warn({
8131
+ logger$4.warn({
8132
8132
  pid,
8133
8133
  err: msg
8134
8134
  }, "Failed to kill orchestrator");
@@ -8158,7 +8158,7 @@ async function runCancelAction(options) {
8158
8158
  await adapter.close();
8159
8159
  }
8160
8160
  } catch (err) {
8161
- logger$3.warn({ err }, "Could not update pipeline run status (non-fatal)");
8161
+ logger$4.warn({ err }, "Could not update pipeline run status (non-fatal)");
8162
8162
  }
8163
8163
  if (outputFormat === "json") process.stdout.write(formatOutput({
8164
8164
  cancelled: true,
@@ -8510,6 +8510,129 @@ function emitDiff(diff, ctx) {
8510
8510
  process.stdout.write("\n");
8511
8511
  }
8512
8512
 
8513
+ //#endregion
8514
+ //#region src/cli/commands/probe-author.ts
8515
+ const logger$3 = createLogger("cli:probe-author");
8516
+ /**
8517
+ * A minimum-viable logger that routes everything to stderr. Used by the
8518
+ * subcommand to keep stdout reserved for the JSON result payload.
8519
+ * Pino's default pino()-without-destination writes to stdout; we need
8520
+ * the inverse here.
8521
+ */
8522
+ function makeStderrLogger() {
8523
+ const emit = (level, args) => {
8524
+ const payload = args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ");
8525
+ process.stderr.write(`[${level}] ${payload}\n`);
8526
+ };
8527
+ return {
8528
+ debug: (...args) => emit("debug", args),
8529
+ info: (...args) => emit("info", args),
8530
+ warn: (...args) => emit("warn", args),
8531
+ error: (...args) => emit("error", args)
8532
+ };
8533
+ }
8534
+ function registerProbeAuthorCommand(program, _version, projectRoot, registry) {
8535
+ const probeAuthor = program.command("probe-author").description("probe-author phase utilities (Story 60-14)");
8536
+ probeAuthor.command("dispatch").description("Dispatch the probe-author phase against a single story file. Reads the story artifact + epic content, calls the probe-author agent, outputs the authored probes as JSON. Powers the A/B validation harness eval (scripts/eval-probe-author.mjs) and serves as a manual operator inspection tool.").requiredOption("--story-file <path>", "Path to the story artifact (.md). Receives the appended ## Runtime Probes section.").option("--epic-file <path>", "Path to source epic content (default: same as --story-file)").option("--story-key <key>", "Story key for telemetry / event payloads", "probe-author-cli").option("--agent <id>", "Agent backend (default: claude-code)", "claude-code").option("--pack <name>", "Methodology pack name (default: bmad)", "bmad").option("--output-format <format>", "Output format: json (default; print authored probes as JSON to stdout) or append (leave story-file with appended Runtime Probes section)", "json").option("--working-dir <path>", "Working directory for the dispatcher (default: --story-file directory)").option("--bypass-gates", "Skip the event-driven AC + idempotency gates inside runProbeAuthor. Use ONLY for operator invocations / A/B eval-harness runs that need to test authoring quality across non-event-driven AC. Production pipelines should never set this — the gates are load-bearing for the orchestrator path.", false).action(async (opts) => {
8537
+ const exitCode = await runProbeAuthorDispatch(opts, projectRoot, registry);
8538
+ process.exitCode = exitCode;
8539
+ });
8540
+ }
8541
+ /**
8542
+ * Core entry point for `substrate probe-author dispatch`. Returns the
8543
+ * exit code (0 on probe-author success, 1 on failure or skip).
8544
+ */
8545
+ async function runProbeAuthorDispatch(opts, projectRoot, registry) {
8546
+ const storyFilePath = resolve$1(opts.storyFile);
8547
+ const epicFilePath = opts.epicFile !== void 0 ? resolve$1(opts.epicFile) : storyFilePath;
8548
+ let epicContent;
8549
+ try {
8550
+ epicContent = readFileSync(epicFilePath, "utf-8");
8551
+ } catch (err) {
8552
+ const msg = err instanceof Error ? err.message : String(err);
8553
+ process.stderr.write(`probe-author: failed to read epic file ${epicFilePath}: ${msg}\n`);
8554
+ return 1;
8555
+ }
8556
+ let originalStoryContent;
8557
+ try {
8558
+ originalStoryContent = readFileSync(storyFilePath, "utf-8");
8559
+ } catch (err) {
8560
+ const msg = err instanceof Error ? err.message : String(err);
8561
+ process.stderr.write(`probe-author: failed to read story file ${storyFilePath}: ${msg}\n`);
8562
+ return 1;
8563
+ }
8564
+ const eventBus = createEventBus();
8565
+ const adapter = new InMemoryDatabaseAdapter();
8566
+ const packLoader = createPackLoader();
8567
+ const packPath = `${projectRoot}/packs/${opts.pack}`;
8568
+ let pack;
8569
+ try {
8570
+ pack = await packLoader.load(packPath);
8571
+ } catch (err) {
8572
+ const msg = err instanceof Error ? err.message : String(err);
8573
+ process.stderr.write(`probe-author: failed to load methodology pack '${opts.pack}' from ${packPath}: ${msg}\n`);
8574
+ return 1;
8575
+ }
8576
+ const contextCompiler = createContextCompiler({ db: adapter });
8577
+ const stderrLogger = makeStderrLogger();
8578
+ const dispatcher = createDispatcher({
8579
+ eventBus,
8580
+ adapterRegistry: registry,
8581
+ logger: stderrLogger
8582
+ });
8583
+ const workingDir = opts.workingDir !== void 0 ? resolve$1(opts.workingDir) : resolve$1(storyFilePath, "..");
8584
+ logger$3.info({
8585
+ storyKey: opts.storyKey,
8586
+ storyFile: storyFilePath,
8587
+ epicFile: epicFilePath,
8588
+ agent: opts.agent,
8589
+ pack: opts.pack
8590
+ }, "probe-author dispatch starting");
8591
+ const result = await runProbeAuthor({
8592
+ db: adapter,
8593
+ pack,
8594
+ contextCompiler,
8595
+ dispatcher,
8596
+ projectRoot: workingDir,
8597
+ agentId: opts.agent
8598
+ }, {
8599
+ storyKey: opts.storyKey,
8600
+ storyFilePath,
8601
+ pipelineRunId: `probe-author-cli-${Date.now()}`,
8602
+ sourceAcContent: epicContent,
8603
+ epicContent,
8604
+ ...opts.bypassGates === true ? { bypassGates: true } : {}
8605
+ });
8606
+ let postDispatchContent = originalStoryContent;
8607
+ try {
8608
+ postDispatchContent = readFileSync(storyFilePath, "utf-8");
8609
+ } catch {}
8610
+ const parseResult = parseRuntimeProbes(postDispatchContent);
8611
+ const probes = parseResult.kind === "parsed" ? parseResult.probes : [];
8612
+ if (opts.outputFormat === "json") {
8613
+ if (postDispatchContent !== originalStoryContent) try {
8614
+ writeFileSync(storyFilePath, originalStoryContent, "utf-8");
8615
+ } catch (err) {
8616
+ const msg = err instanceof Error ? err.message : String(err);
8617
+ process.stderr.write(`probe-author: warning — failed to restore story file: ${msg}\n`);
8618
+ }
8619
+ process.stdout.write(JSON.stringify({
8620
+ success: result.result === "success",
8621
+ result: result.result,
8622
+ error: result.error,
8623
+ probesAuthoredCount: result.probesAuthoredCount,
8624
+ probes,
8625
+ tokenUsage: result.tokenUsage,
8626
+ durationMs: result.durationMs
8627
+ }, null, 2) + "\n");
8628
+ } else if (opts.outputFormat === "append") process.stderr.write(`probe-author: ${result.result} — ${result.probesAuthoredCount} probe(s) authored. Story file at ${storyFilePath}\n`);
8629
+ else {
8630
+ process.stderr.write(`probe-author: invalid --output-format '${opts.outputFormat}'. Valid: json | append\n`);
8631
+ return 1;
8632
+ }
8633
+ return result.result === "success" ? 0 : 1;
8634
+ }
8635
+
8513
8636
  //#endregion
8514
8637
  //#region src/cli/commands/history.ts
8515
8638
  function registerHistoryCommand(program) {
@@ -9114,6 +9237,7 @@ async function createProgram() {
9114
9237
  registerHistoryCommand(program);
9115
9238
  registerMigrateCommand(program);
9116
9239
  registerProbesCommand(program);
9240
+ registerProbeAuthorCommand(program, version, process.cwd(), registry);
9117
9241
  registerRepoMapCommand(program);
9118
9242
  registerRoutingCommand(program);
9119
9243
  registerCostCommand(program, version);
@@ -9132,8 +9256,8 @@ async function createProgram() {
9132
9256
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
9133
9257
  function checkForUpdatesInBackground(currentVersion) {
9134
9258
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
9135
- import("../upgrade-BXfinu5K.js").then(async () => {
9136
- const { createVersionManager } = await import("../version-manager-impl-ChzfLw90.js");
9259
+ import("../upgrade-Csv0GRft.js").then(async () => {
9260
+ const { createVersionManager } = await import("../version-manager-impl-C-mrgne3.js");
9137
9261
  const vm = createVersionManager();
9138
9262
  const result = await vm.checkForUpdates();
9139
9263
  if (result.updateAvailable) {