substrate-ai 0.19.20 → 0.19.22

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.
@@ -0,0 +1,4 @@
1
+ import { AdapterRegistry } from "./dist-DmhbWZ0f.js";
2
+ import "./adapter-registry-DXLMTmfD.js";
3
+
4
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import { FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot } from "../health-CkQncTB5.js";
2
+ import { FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, createDatabaseAdapter, createStateStore, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot } from "../health-DezAZoGb.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, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, tagRunAsBaseline, updatePipelineRun } from "../dist-CtFYOaeA.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-DmhbWZ0f.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-MGg8SzDA.js";
8
- import "../errors-CWSATPPa.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-DSj4ebow.js";
8
+ import "../errors-CrFWBvB4.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-UCMt4b7A.js";
12
+ import { registerUpgradeCommand } from "../upgrade-o__Q1Kdc.js";
13
13
  import { Command } from "commander";
14
14
  import { fileURLToPath } from "url";
15
15
  import { dirname, join, resolve } from "path";
@@ -332,12 +332,12 @@ var GitWorktreeManagerImpl = class {
332
332
  _onTaskReady;
333
333
  _onTaskComplete;
334
334
  _onTaskFailed;
335
- constructor(eventBus, projectRoot, baseDirectory = DEFAULT_WORKTREE_BASE, db = null, logger$15) {
335
+ constructor(eventBus, projectRoot, baseDirectory = DEFAULT_WORKTREE_BASE, db = null, logger$16) {
336
336
  this._eventBus = eventBus;
337
337
  this._projectRoot = projectRoot;
338
338
  this._baseDirectory = baseDirectory;
339
339
  this._db = db;
340
- this._logger = logger$15 ?? console;
340
+ this._logger = logger$16 ?? console;
341
341
  this._onTaskReady = ({ taskId }) => {
342
342
  this._handleTaskReady(taskId).catch((err) => {
343
343
  this._logger.error({
@@ -641,14 +641,14 @@ var RecommendationEngine = class {
641
641
  _filters;
642
642
  _historyDays;
643
643
  _logger;
644
- constructor(monitorDb, config = {}, logger$15) {
644
+ constructor(monitorDb, config = {}, logger$16) {
645
645
  this._monitorDb = monitorDb;
646
646
  this._filters = {
647
647
  threshold_percentage: config.recommendation_threshold_percentage ?? 5,
648
648
  min_sample_size: config.min_sample_size ?? 10
649
649
  };
650
650
  this._historyDays = config.recommendation_history_days ?? 90;
651
- this._logger = logger$15 ?? console;
651
+ this._logger = logger$16 ?? console;
652
652
  }
653
653
  generateRecommendations() {
654
654
  const sinceDate = new Date(Date.now() - this._historyDays * 24 * 60 * 60 * 1e3).toISOString();
@@ -1605,7 +1605,7 @@ function buildStackAwareDevNotes(profile) {
1605
1605
 
1606
1606
  //#endregion
1607
1607
  //#region src/cli/commands/init.ts
1608
- const logger$14 = createLogger("init");
1608
+ const logger$15 = createLogger("init");
1609
1609
  const __dirname = dirname(new URL(import.meta.url).pathname);
1610
1610
  const SCAFFOLD_VERSION_REGEX = /<!-- substrate:version=([\d.]+) -->/;
1611
1611
  /**
@@ -1646,7 +1646,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1646
1646
  const version = resolveBmadMethodVersion();
1647
1647
  if (force && bmadExists) process.stderr.write(`Warning: Replacing existing _bmad/ framework with bmad-method@${version}\n`);
1648
1648
  process.stdout.write(`Scaffolding BMAD framework from bmad-method@${version}\n`);
1649
- logger$14.info({
1649
+ logger$15.info({
1650
1650
  version,
1651
1651
  dest: bmadDest
1652
1652
  }, "Scaffolding BMAD framework");
@@ -1656,7 +1656,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1656
1656
  const destDir = join(bmadDest, dir);
1657
1657
  mkdirSync$1(destDir, { recursive: true });
1658
1658
  cpSync(srcDir, destDir, { recursive: true });
1659
- logger$14.info({
1659
+ logger$15.info({
1660
1660
  dir,
1661
1661
  dest: destDir
1662
1662
  }, "Scaffolded BMAD framework directory");
@@ -1675,7 +1675,7 @@ async function scaffoldBmadFramework(projectRoot, force, outputFormat) {
1675
1675
  "document_output_language: English"
1676
1676
  ].join("\n") + "\n";
1677
1677
  await writeFile(configFile, configStub, "utf8");
1678
- logger$14.info({ configFile }, "Generated _bmad/_config/config.yaml stub");
1678
+ logger$15.info({ configFile }, "Generated _bmad/_config/config.yaml stub");
1679
1679
  }
1680
1680
  }
1681
1681
  const CLAUDE_MD_START_MARKER = "<!-- substrate:start -->";
@@ -1690,7 +1690,7 @@ async function scaffoldClaudeMd(projectRoot, profile) {
1690
1690
  try {
1691
1691
  sectionContent = await readFile(templatePath, "utf8");
1692
1692
  } catch {
1693
- logger$14.warn({ templatePath }, "CLAUDE.md substrate section template not found; skipping");
1693
+ logger$15.warn({ templatePath }, "CLAUDE.md substrate section template not found; skipping");
1694
1694
  return;
1695
1695
  }
1696
1696
  const substrateVersion = readSubstrateVersion(pkgRoot);
@@ -1726,7 +1726,7 @@ async function scaffoldClaudeMd(projectRoot, profile) {
1726
1726
  else newContent = updatedExisting;
1727
1727
  }
1728
1728
  await writeFile(claudeMdPath, newContent, "utf8");
1729
- logger$14.info({ claudeMdPath }, "Wrote substrate section to CLAUDE.md");
1729
+ logger$15.info({ claudeMdPath }, "Wrote substrate section to CLAUDE.md");
1730
1730
  }
1731
1731
  async function scaffoldStatuslineScript(projectRoot) {
1732
1732
  const pkgRoot = findPackageRoot(__dirname);
@@ -1737,7 +1737,7 @@ async function scaffoldStatuslineScript(projectRoot) {
1737
1737
  try {
1738
1738
  content = await readFile(templatePath, "utf8");
1739
1739
  } catch {
1740
- logger$14.warn({ templatePath }, "statusline.sh template not found; skipping");
1740
+ logger$15.warn({ templatePath }, "statusline.sh template not found; skipping");
1741
1741
  return;
1742
1742
  }
1743
1743
  const claudeDir = join(projectRoot, ".claude");
@@ -1745,7 +1745,7 @@ async function scaffoldStatuslineScript(projectRoot) {
1745
1745
  mkdirSync$1(claudeDir, { recursive: true });
1746
1746
  await writeFile(statuslinePath, content, "utf8");
1747
1747
  chmodSync(statuslinePath, 493);
1748
- logger$14.info({ statuslinePath }, "Wrote .claude/statusline.sh");
1748
+ logger$15.info({ statuslinePath }, "Wrote .claude/statusline.sh");
1749
1749
  }
1750
1750
  async function scaffoldClaudeSettings(projectRoot) {
1751
1751
  const claudeDir = join(projectRoot, ".claude");
@@ -1761,7 +1761,7 @@ async function scaffoldClaudeSettings(projectRoot) {
1761
1761
  if (!merged["$schema"]) merged["$schema"] = "https://json.schemastore.org/claude-code-settings.json";
1762
1762
  mkdirSync$1(claudeDir, { recursive: true });
1763
1763
  await writeFile(settingsPath, JSON.stringify(merged, null, 2) + "\n", "utf8");
1764
- logger$14.info({ settingsPath }, "Wrote substrate settings to .claude/settings.json");
1764
+ logger$15.info({ settingsPath }, "Wrote substrate settings to .claude/settings.json");
1765
1765
  }
1766
1766
  function resolveBmadMethodInstallerLibPath(fromDir = __dirname) {
1767
1767
  try {
@@ -1833,7 +1833,7 @@ async function compileBmadAgents(bmadDir) {
1833
1833
  writeFileSync$1(mdPath, result.xml, "utf-8");
1834
1834
  compiled++;
1835
1835
  } catch (compileErr) {
1836
- logger$14.debug({
1836
+ logger$15.debug({
1837
1837
  err: compileErr,
1838
1838
  file
1839
1839
  }, "Failed to compile agent YAML");
@@ -1980,9 +1980,9 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
1980
1980
  const _require = createRequire(join(__dirname, "synthetic.js"));
1981
1981
  try {
1982
1982
  const compiledCount = await compileBmadAgents(bmadDir);
1983
- if (compiledCount > 0) logger$14.info({ compiledCount }, "Compiled agent YAML files to MD");
1983
+ if (compiledCount > 0) logger$15.info({ compiledCount }, "Compiled agent YAML files to MD");
1984
1984
  } catch (compileErr) {
1985
- logger$14.warn({ err: compileErr }, "Agent compilation failed; agent commands may be incomplete");
1985
+ logger$15.warn({ err: compileErr }, "Agent compilation failed; agent commands may be incomplete");
1986
1986
  }
1987
1987
  const resolveExport = (mod, name) => {
1988
1988
  if (typeof mod[name] === "function") return mod[name];
@@ -1996,7 +1996,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
1996
1996
  const manifestGenPath = join(installerLibPath, "core", "manifest-generator.js");
1997
1997
  const pathUtilsPath = join(installerLibPath, "ide", "shared", "path-utils.js");
1998
1998
  if (!existsSync$1(agentGenPath)) {
1999
- logger$14.info("bmad-method generators not available (requires bmad-method with agent/workflow/task-tool generators)");
1999
+ logger$15.info("bmad-method generators not available (requires bmad-method with agent/workflow/task-tool generators)");
2000
2000
  return;
2001
2001
  }
2002
2002
  const agentMod = _require(agentGenPath);
@@ -2006,11 +2006,11 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2006
2006
  if (existsSync$1(workflowGenPath)) {
2007
2007
  const workflowMod = _require(workflowGenPath);
2008
2008
  WorkflowCommandGenerator = resolveExport(workflowMod, "WorkflowCommandGenerator");
2009
- } else logger$14.info("bmad-method workflow-command-generator not available; will try skill-based installation");
2009
+ } else logger$15.info("bmad-method workflow-command-generator not available; will try skill-based installation");
2010
2010
  if (existsSync$1(taskToolGenPath)) {
2011
2011
  const taskToolMod = _require(taskToolGenPath);
2012
2012
  TaskToolCommandGenerator = resolveExport(taskToolMod, "TaskToolCommandGenerator");
2013
- } else logger$14.info("bmad-method task-tool-command-generator not available; will try skill-based installation");
2013
+ } else logger$15.info("bmad-method task-tool-command-generator not available; will try skill-based installation");
2014
2014
  let ManifestGenerator = null;
2015
2015
  if (existsSync$1(manifestGenPath)) {
2016
2016
  const manifestMod = _require(manifestGenPath);
@@ -2042,7 +2042,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2042
2042
  const manifestGen = new ManifestGenerator();
2043
2043
  await manifestGen.generateManifests(bmadDir, allModules, [], { ides: ["claude-code"] });
2044
2044
  } catch (manifestErr) {
2045
- logger$14.warn({ err: manifestErr }, "ManifestGenerator failed; workflow/task commands may be incomplete");
2045
+ logger$15.warn({ err: manifestErr }, "ManifestGenerator failed; workflow/task commands may be incomplete");
2046
2046
  }
2047
2047
  const commandsDir = join(projectRoot, ".claude", "commands");
2048
2048
  mkdirSync$1(commandsDir, { recursive: true });
@@ -2070,7 +2070,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2070
2070
  const total = agentCount + workflowCount + taskToolCount + skillCount;
2071
2071
  if (outputFormat !== "json") if (skillCount > 0) process.stdout.write(`Generated ${String(total)} Claude Code commands (${String(agentCount)} agents, ${String(skillCount)} skills)\n`);
2072
2072
  else process.stdout.write(`Generated ${String(total)} Claude Code commands (${String(agentCount)} agents, ${String(workflowCount)} workflows, ${String(taskToolCount)} tasks/tools)\n`);
2073
- logger$14.info({
2073
+ logger$15.info({
2074
2074
  agentCount,
2075
2075
  workflowCount,
2076
2076
  taskToolCount,
@@ -2081,7 +2081,7 @@ async function scaffoldClaudeCommands(projectRoot, outputFormat) {
2081
2081
  } catch (err) {
2082
2082
  const msg = err instanceof Error ? err.message : String(err);
2083
2083
  if (outputFormat !== "json") process.stderr.write(`Warning: .claude/commands/ generation failed: ${msg}\n`);
2084
- logger$14.warn({ err }, "scaffoldClaudeCommands failed; init continues");
2084
+ logger$15.warn({ err }, "scaffoldClaudeCommands failed; init continues");
2085
2085
  }
2086
2086
  }
2087
2087
  const PROVIDER_DEFAULTS = DEFAULT_CONFIG.providers;
@@ -2201,7 +2201,7 @@ async function runInitAction(options) {
2201
2201
  discoveryReport = await registry.discoverAndRegister();
2202
2202
  } catch (err) {
2203
2203
  const message = err instanceof Error ? err.message : String(err);
2204
- logger$14.error({ err }, "Adapter discovery failed");
2204
+ logger$15.error({ err }, "Adapter discovery failed");
2205
2205
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, `Adapter discovery failed: ${message}`) + "\n");
2206
2206
  else process.stderr.write(` Error: adapter discovery failed — ${message}\n`);
2207
2207
  return INIT_EXIT_ERROR;
@@ -2244,7 +2244,7 @@ async function runInitAction(options) {
2244
2244
  try {
2245
2245
  detectedProfile = await detectProjectProfile(dbRoot);
2246
2246
  } catch (err) {
2247
- logger$14.warn({ err }, "Project profile detection failed; skipping");
2247
+ logger$15.warn({ err }, "Project profile detection failed; skipping");
2248
2248
  }
2249
2249
  if (detectedProfile === null) {
2250
2250
  if (outputFormat !== "json") process.stdout.write(" No project stack detected. Create .substrate/project-profile.yaml manually to enable polyglot support.\n");
@@ -2278,12 +2278,12 @@ async function runInitAction(options) {
2278
2278
  return INIT_EXIT_ERROR;
2279
2279
  }
2280
2280
  if (force && existsSync$1(localManifest)) {
2281
- logger$14.info({ pack: packName }, "Replacing existing pack with bundled version");
2281
+ logger$15.info({ pack: packName }, "Replacing existing pack with bundled version");
2282
2282
  process.stderr.write(`Warning: Replacing existing pack '${packName}' with bundled version\n`);
2283
2283
  }
2284
2284
  mkdirSync$1(dirname(packPath), { recursive: true });
2285
2285
  cpSync(bundledPackPath, packPath, { recursive: true });
2286
- logger$14.info({
2286
+ logger$15.info({
2287
2287
  pack: packName,
2288
2288
  dest: packPath
2289
2289
  }, "Scaffolded methodology pack");
@@ -2314,7 +2314,10 @@ async function runInitAction(options) {
2314
2314
  const runtimeEntries = [
2315
2315
  ".substrate/orchestrator.pid",
2316
2316
  ".substrate/current-run-id",
2317
- ".substrate/scenarios/"
2317
+ ".substrate/scenarios/",
2318
+ ".substrate/state/",
2319
+ ".substrate/substrate.db",
2320
+ ".substrate/substrate.db-journal"
2318
2321
  ];
2319
2322
  try {
2320
2323
  const existing = existsSync$1(gitignorePath) ? readFileSync$1(gitignorePath, "utf-8") : "";
@@ -2322,10 +2325,10 @@ async function runInitAction(options) {
2322
2325
  if (missing.length > 0) {
2323
2326
  const block = "\n# Substrate runtime files\n" + missing.join("\n") + "\n";
2324
2327
  appendFileSync(gitignorePath, block);
2325
- logger$14.info({ entries: missing }, "Added substrate runtime files to .gitignore");
2328
+ logger$15.info({ entries: missing }, "Added substrate runtime files to .gitignore");
2326
2329
  }
2327
2330
  } catch (err) {
2328
- logger$14.debug({ err }, "Could not update .gitignore (non-fatal)");
2331
+ logger$15.debug({ err }, "Could not update .gitignore (non-fatal)");
2329
2332
  }
2330
2333
  const doltMode = options.doltMode ?? "auto";
2331
2334
  let doltInitialized = false;
@@ -2342,7 +2345,7 @@ async function runInitAction(options) {
2342
2345
  process.stderr.write(`${err.message}\n`);
2343
2346
  return INIT_EXIT_ERROR;
2344
2347
  }
2345
- logger$14.debug("Dolt not installed, skipping auto-init");
2348
+ logger$15.debug("Dolt not installed, skipping auto-init");
2346
2349
  } else {
2347
2350
  const msg = err instanceof Error ? err.message : String(err);
2348
2351
  if (doltMode === "force") {
@@ -2352,7 +2355,7 @@ async function runInitAction(options) {
2352
2355
  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`);
2353
2356
  }
2354
2357
  }
2355
- else logger$14.debug("Dolt step was skipped (--no-dolt)");
2358
+ else logger$15.debug("Dolt step was skipped (--no-dolt)");
2356
2359
  const successMsg = `Pack '${packName}' and database initialized successfully at ${dbPath}`;
2357
2360
  if (outputFormat === "json") process.stdout.write(formatOutput({
2358
2361
  pack: packName,
@@ -2386,7 +2389,7 @@ async function runInitAction(options) {
2386
2389
  const msg = err instanceof Error ? err.message : String(err);
2387
2390
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
2388
2391
  else process.stderr.write(`Error: ${msg}\n`);
2389
- logger$14.error({ err }, "init failed");
2392
+ logger$15.error({ err }, "init failed");
2390
2393
  return INIT_EXIT_ERROR;
2391
2394
  }
2392
2395
  }
@@ -2409,7 +2412,7 @@ function registerInitCommand(program, _version, registry) {
2409
2412
 
2410
2413
  //#endregion
2411
2414
  //#region src/cli/commands/config.ts
2412
- const logger$13 = createLogger("config-cmd");
2415
+ const logger$14 = createLogger("config-cmd");
2413
2416
  const CONFIG_EXIT_SUCCESS = 0;
2414
2417
  const CONFIG_EXIT_ERROR = 1;
2415
2418
  const CONFIG_EXIT_INVALID = 2;
@@ -2435,7 +2438,7 @@ async function runConfigShow(opts = {}) {
2435
2438
  return CONFIG_EXIT_INVALID;
2436
2439
  }
2437
2440
  const message = err instanceof Error ? err.message : String(err);
2438
- logger$13.error({ err }, "Failed to load configuration");
2441
+ logger$14.error({ err }, "Failed to load configuration");
2439
2442
  process.stderr.write(` Error loading configuration: ${message}\n`);
2440
2443
  return CONFIG_EXIT_ERROR;
2441
2444
  }
@@ -2509,7 +2512,7 @@ async function runConfigExport(opts = {}) {
2509
2512
  return CONFIG_EXIT_INVALID;
2510
2513
  }
2511
2514
  const message = err instanceof Error ? err.message : String(err);
2512
- logger$13.error({ err }, "Failed to load configuration");
2515
+ logger$14.error({ err }, "Failed to load configuration");
2513
2516
  process.stderr.write(`Error loading configuration: ${message}\n`);
2514
2517
  return CONFIG_EXIT_ERROR;
2515
2518
  }
@@ -2663,7 +2666,7 @@ function registerConfigCommand(program, _version) {
2663
2666
 
2664
2667
  //#endregion
2665
2668
  //#region src/cli/commands/resume.ts
2666
- const logger$12 = createLogger("resume-cmd");
2669
+ const logger$13 = createLogger("resume-cmd");
2667
2670
  /**
2668
2671
  * Map internal orchestrator phase names to pipeline event protocol phase names.
2669
2672
  */
@@ -2769,7 +2772,7 @@ async function runResumeAction(options) {
2769
2772
  const msg = err instanceof Error ? err.message : String(err);
2770
2773
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
2771
2774
  else process.stderr.write(`Error: ${msg}\n`);
2772
- logger$12.error({ err }, "auto resume failed");
2775
+ logger$13.error({ err }, "auto resume failed");
2773
2776
  return 1;
2774
2777
  } finally {
2775
2778
  try {
@@ -3018,11 +3021,11 @@ async function runFullPipelineFromPhase(options) {
3018
3021
  output_tokens: output,
3019
3022
  cost_usd: costUsd
3020
3023
  }).catch((err) => {
3021
- logger$12.warn({ err }, "Failed to record token usage");
3024
+ logger$13.warn({ err }, "Failed to record token usage");
3022
3025
  });
3023
3026
  }
3024
3027
  } catch (err) {
3025
- logger$12.warn({ err }, "Failed to record token usage");
3028
+ logger$13.warn({ err }, "Failed to record token usage");
3026
3029
  }
3027
3030
  });
3028
3031
  const storyKeys = await resolveStoryKeys(adapter, projectRoot, {
@@ -3091,7 +3094,7 @@ async function runFullPipelineFromPhase(options) {
3091
3094
  const msg = err instanceof Error ? err.message : String(err);
3092
3095
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
3093
3096
  else process.stderr.write(`Error: ${msg}\n`);
3094
- logger$12.error({ err }, "pipeline from phase failed");
3097
+ logger$13.error({ err }, "pipeline from phase failed");
3095
3098
  return 1;
3096
3099
  } finally {
3097
3100
  try {
@@ -3120,7 +3123,7 @@ function registerResumeCommand(program, _version = "0.0.0", projectRoot = proces
3120
3123
 
3121
3124
  //#endregion
3122
3125
  //#region src/cli/commands/status.ts
3123
- const logger$11 = createLogger("status-cmd");
3126
+ const logger$12 = createLogger("status-cmd");
3124
3127
  async function runStatusAction(options) {
3125
3128
  const { outputFormat, runId, projectRoot, stateStore, history } = options;
3126
3129
  if (history === true) {
@@ -3199,7 +3202,7 @@ async function runStatusAction(options) {
3199
3202
  };
3200
3203
  }
3201
3204
  } catch (err) {
3202
- logger$11.debug({ err }, "Work graph query failed, continuing without work graph data");
3205
+ logger$12.debug({ err }, "Work graph query failed, continuing without work graph data");
3203
3206
  }
3204
3207
  let run;
3205
3208
  if (runId !== void 0 && runId !== "") run = await getPipelineRunById(adapter, runId);
@@ -3215,9 +3218,9 @@ async function runStatusAction(options) {
3215
3218
  if (run === void 0) run = await getLatestRun(adapter);
3216
3219
  }
3217
3220
  if (run === void 0) {
3218
- const { inspectProcessTree } = await import("../health-DlKuVhQH.js");
3221
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-fmMNa5fo.js");
3219
3222
  const substrateDirPath = join(projectRoot, ".substrate");
3220
- const processInfo = inspectProcessTree({
3223
+ const processInfo = inspectProcessTree$1({
3221
3224
  projectRoot,
3222
3225
  substrateDirPath
3223
3226
  });
@@ -3245,7 +3248,7 @@ async function runStatusAction(options) {
3245
3248
  if (stateStore) try {
3246
3249
  storeStories = await stateStore.queryStories({});
3247
3250
  } catch (err) {
3248
- logger$11.debug({ err }, "StateStore query failed, continuing without store data");
3251
+ logger$12.debug({ err }, "StateStore query failed, continuing without store data");
3249
3252
  }
3250
3253
  if (outputFormat === "json") {
3251
3254
  const statusOutput = buildPipelineStatusOutput(run, tokenSummary, decisionsCount, storiesCount);
@@ -3368,7 +3371,7 @@ async function runStatusAction(options) {
3368
3371
  const msg = err instanceof Error ? err.message : String(err);
3369
3372
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
3370
3373
  else process.stderr.write(`Error: ${msg}\n`);
3371
- logger$11.error({ err }, "status action failed");
3374
+ logger$12.error({ err }, "status action failed");
3372
3375
  return 1;
3373
3376
  } finally {
3374
3377
  try {
@@ -3715,7 +3718,7 @@ Analyze thoroughly and return ONLY the JSON array with no additional text.`;
3715
3718
 
3716
3719
  //#endregion
3717
3720
  //#region src/cli/commands/amend.ts
3718
- const logger$10 = createLogger("amend-cmd");
3721
+ const logger$11 = createLogger("amend-cmd");
3719
3722
  /**
3720
3723
  * Detect and apply supersessions after a phase completes in an amendment run.
3721
3724
  *
@@ -3746,7 +3749,7 @@ async function runPostPhaseSupersessionDetection(adapter, amendmentRunId, curren
3746
3749
  });
3747
3750
  } catch (err) {
3748
3751
  const msg = err instanceof Error ? err.message : String(err);
3749
- logger$10.warn({
3752
+ logger$11.warn({
3750
3753
  err,
3751
3754
  originalId: parentMatch.id,
3752
3755
  supersedingId: newDec.id
@@ -3883,7 +3886,7 @@ async function runAmendAction(options) {
3883
3886
  for (let i = startIdx; i < phaseOrder.length; i++) {
3884
3887
  const currentPhase = phaseOrder[i];
3885
3888
  const amendmentContext = handler.loadContextForPhase(currentPhase);
3886
- logger$10.info({
3889
+ logger$11.info({
3887
3890
  phase: currentPhase,
3888
3891
  amendmentContextLen: amendmentContext.length
3889
3892
  }, "Amendment context loaded for phase");
@@ -4004,7 +4007,7 @@ async function runAmendAction(options) {
4004
4007
  } catch (err) {
4005
4008
  const msg = err instanceof Error ? err.message : String(err);
4006
4009
  process.stderr.write(`Error: ${msg}\n`);
4007
- logger$10.error({ err }, "amend failed");
4010
+ logger$11.error({ err }, "amend failed");
4008
4011
  return 1;
4009
4012
  } finally {
4010
4013
  try {
@@ -4102,7 +4105,7 @@ function defaultSupervisorDeps() {
4102
4105
  if (cached === null) {
4103
4106
  const { AdapterRegistry: AR } = await import(
4104
4107
  /* @vite-ignore */
4105
- "../adapter-registry-BDvUQgG3.js"
4108
+ "../adapter-registry-CHFfvph6.js"
4106
4109
  );
4107
4110
  cached = new AR();
4108
4111
  await cached.discoverAndRegister();
@@ -4544,11 +4547,11 @@ async function runSupervisorAction(options, deps = {}) {
4544
4547
  try {
4545
4548
  const { createExperimenter } = await import(
4546
4549
  /* @vite-ignore */
4547
- "../experimenter-ChKZzonq.js"
4550
+ "../experimenter-BzWRPx13.js"
4548
4551
  );
4549
4552
  const { getLatestRun: getLatest } = await import(
4550
4553
  /* @vite-ignore */
4551
- "../decisions-BEAzpqOy.js"
4554
+ "../decisions-B9fESQQz.js"
4552
4555
  );
4553
4556
  const expAdapter = createDatabaseAdapter({
4554
4557
  backend: "auto",
@@ -4558,7 +4561,7 @@ async function runSupervisorAction(options, deps = {}) {
4558
4561
  await initSchema(expAdapter);
4559
4562
  const { runRunAction: runPipeline } = await import(
4560
4563
  /* @vite-ignore */
4561
- "../run-DVwQH8Ea.js"
4564
+ "../run-Zkr2v7uB.js"
4562
4565
  );
4563
4566
  const runStoryFn = async (opts) => {
4564
4567
  const exitCode = await runPipeline({
@@ -4806,7 +4809,7 @@ function registerSupervisorCommand(program, _version = "0.0.0", projectRoot = pr
4806
4809
 
4807
4810
  //#endregion
4808
4811
  //#region src/cli/commands/metrics.ts
4809
- const logger$9 = createLogger("metrics-cmd");
4812
+ const logger$10 = createLogger("metrics-cmd");
4810
4813
  async function openTelemetryAdapter(basePath) {
4811
4814
  try {
4812
4815
  const adapter = createDatabaseAdapter({
@@ -5088,7 +5091,7 @@ async function runMetricsAction(options) {
5088
5091
  const routingConfigPath = join(dbDir, "routing.yml");
5089
5092
  let routingConfig = null;
5090
5093
  if (existsSync$1(routingConfigPath)) try {
5091
- const { loadModelRoutingConfig } = await import("../routing-DXoZWjBO.js");
5094
+ const { loadModelRoutingConfig } = await import("../routing-CLiOXDct.js");
5092
5095
  routingConfig = loadModelRoutingConfig(routingConfigPath);
5093
5096
  } catch {}
5094
5097
  if (routingConfig === null) routingConfig = {
@@ -5172,7 +5175,7 @@ async function runMetricsAction(options) {
5172
5175
  }
5173
5176
  }
5174
5177
  } catch (err) {
5175
- logger$9.debug({ err }, "getScenarioResultsForRun failed");
5178
+ logger$10.debug({ err }, "getScenarioResultsForRun failed");
5176
5179
  }
5177
5180
  if (rows.length === 0) {
5178
5181
  const msg = `No factory run found with id: ${run}`;
@@ -5208,7 +5211,7 @@ async function runMetricsAction(options) {
5208
5211
  }
5209
5212
  }
5210
5213
  } catch (err) {
5211
- logger$9.debug({ err }, "getTwinRunsForRun failed — twin_runs table may not exist yet");
5214
+ logger$10.debug({ err }, "getTwinRunsForRun failed — twin_runs table may not exist yet");
5212
5215
  }
5213
5216
  }
5214
5217
  return 0;
@@ -5218,7 +5221,7 @@ async function runMetricsAction(options) {
5218
5221
  try {
5219
5222
  factoryRuns$1 = await getFactoryRunSummaries(adapter, limit);
5220
5223
  } catch (err) {
5221
- logger$9.debug({ err }, "getFactoryRunSummaries failed in factory-only mode");
5224
+ logger$10.debug({ err }, "getFactoryRunSummaries failed in factory-only mode");
5222
5225
  }
5223
5226
  if (outputFormat === "json") process.stdout.write(formatOutput({ graph_runs: factoryRuns$1 }, "json", true) + "\n");
5224
5227
  else if (factoryRuns$1.length === 0) process.stdout.write("No factory runs recorded yet.\n");
@@ -5279,7 +5282,7 @@ async function runMetricsAction(options) {
5279
5282
  doltMetrics = await stateStore.queryMetrics(doltFilter);
5280
5283
  await stateStore.close();
5281
5284
  } catch (doltErr) {
5282
- logger$9.warn({ err: doltErr }, "StateStore query failed — falling back to SQLite metrics only");
5285
+ logger$10.warn({ err: doltErr }, "StateStore query failed — falling back to SQLite metrics only");
5283
5286
  }
5284
5287
  const storyMetricDecisions = await getDecisionsByCategory(adapter, STORY_METRICS);
5285
5288
  const storyMetrics = storyMetricDecisions.map((d) => {
@@ -5322,7 +5325,7 @@ async function runMetricsAction(options) {
5322
5325
  try {
5323
5326
  factoryRuns = await getFactoryRunSummaries(adapter, limit);
5324
5327
  } catch (err) {
5325
- logger$9.debug({ err }, "getFactoryRunSummaries failed — table may not exist in older databases");
5328
+ logger$10.debug({ err }, "getFactoryRunSummaries failed — table may not exist in older databases");
5326
5329
  }
5327
5330
  if (outputFormat === "json") {
5328
5331
  const runsWithBreakdown = runs.map((run$1) => ({
@@ -5431,7 +5434,7 @@ async function runMetricsAction(options) {
5431
5434
  const msg = err instanceof Error ? err.message : String(err);
5432
5435
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
5433
5436
  else process.stderr.write(`Error: ${msg}\n`);
5434
- logger$9.error({ err }, "metrics action failed");
5437
+ logger$10.error({ err }, "metrics action failed");
5435
5438
  return 1;
5436
5439
  } finally {
5437
5440
  try {
@@ -5631,7 +5634,7 @@ function registerMigrateCommand(program) {
5631
5634
  function getLatestSessionId(_adapter) {
5632
5635
  return null;
5633
5636
  }
5634
- const logger$8 = createLogger("cost-cmd");
5637
+ const logger$9 = createLogger("cost-cmd");
5635
5638
  const COST_EXIT_SUCCESS = 0;
5636
5639
  const COST_EXIT_ERROR = 1;
5637
5640
  /**
@@ -5875,7 +5878,7 @@ async function runCostAction(options) {
5875
5878
  } catch (err) {
5876
5879
  const message = err instanceof Error ? err.message : String(err);
5877
5880
  process.stderr.write(`Error: ${message}\n`);
5878
- logger$8.error({ err }, "runCostAction failed");
5881
+ logger$9.error({ err }, "runCostAction failed");
5879
5882
  return COST_EXIT_ERROR;
5880
5883
  } finally {
5881
5884
  if (adapter !== null) try {
@@ -5909,7 +5912,7 @@ function registerCostCommand(program, version = "0.0.0", projectRoot = process.c
5909
5912
 
5910
5913
  //#endregion
5911
5914
  //#region src/cli/commands/monitor.ts
5912
- const logger$7 = createLogger("monitor-cmd");
5915
+ const logger$8 = createLogger("monitor-cmd");
5913
5916
  const MONITOR_EXIT_SUCCESS = 0;
5914
5917
  const MONITOR_EXIT_ERROR = 1;
5915
5918
  /**
@@ -6112,7 +6115,7 @@ async function runMonitorReportAction(options) {
6112
6115
  } catch (err) {
6113
6116
  const message = err instanceof Error ? err.message : String(err);
6114
6117
  process.stderr.write(`Error: ${message}\n`);
6115
- logger$7.error({ err }, "runMonitorReportAction failed");
6118
+ logger$8.error({ err }, "runMonitorReportAction failed");
6116
6119
  return MONITOR_EXIT_ERROR;
6117
6120
  } finally {
6118
6121
  if (monitorDb !== null) try {
@@ -6174,7 +6177,7 @@ async function runMonitorStatusAction(options) {
6174
6177
  } catch (err) {
6175
6178
  const message = err instanceof Error ? err.message : String(err);
6176
6179
  process.stderr.write(`Error: ${message}\n`);
6177
- logger$7.error({ err }, "runMonitorStatusAction failed");
6180
+ logger$8.error({ err }, "runMonitorStatusAction failed");
6178
6181
  return MONITOR_EXIT_ERROR;
6179
6182
  } finally {
6180
6183
  if (monitorDb !== null) try {
@@ -6209,7 +6212,7 @@ async function runMonitorResetAction(options) {
6209
6212
  } catch (err) {
6210
6213
  const message = err instanceof Error ? err.message : String(err);
6211
6214
  process.stderr.write(`Error: ${message}\n`);
6212
- logger$7.error({ err }, "runMonitorResetAction failed");
6215
+ logger$8.error({ err }, "runMonitorResetAction failed");
6213
6216
  return MONITOR_EXIT_ERROR;
6214
6217
  } finally {
6215
6218
  if (monitorDb !== null) try {
@@ -6257,7 +6260,7 @@ async function runMonitorRecommendationsAction(options) {
6257
6260
  } catch (err) {
6258
6261
  const message = err instanceof Error ? err.message : String(err);
6259
6262
  process.stderr.write(`Error: ${message}\n`);
6260
- logger$7.error({ err }, "runMonitorRecommendationsAction failed");
6263
+ logger$8.error({ err }, "runMonitorRecommendationsAction failed");
6261
6264
  return MONITOR_EXIT_ERROR;
6262
6265
  } finally {
6263
6266
  if (monitorDb !== null) try {
@@ -6335,7 +6338,7 @@ function registerMonitorCommand(program, version = "0.0.0", projectRoot = proces
6335
6338
 
6336
6339
  //#endregion
6337
6340
  //#region src/cli/commands/merge.ts
6338
- const logger$6 = createLogger("merge-cmd");
6341
+ const logger$7 = createLogger("merge-cmd");
6339
6342
  const MERGE_EXIT_SUCCESS = 0;
6340
6343
  const MERGE_EXIT_CONFLICT = 1;
6341
6344
  const MERGE_EXIT_ERROR = 2;
@@ -6373,7 +6376,7 @@ async function mergeTask(taskId, targetBranch, projectRoot) {
6373
6376
  projectRoot
6374
6377
  });
6375
6378
  try {
6376
- logger$6.info({
6379
+ logger$7.info({
6377
6380
  taskId,
6378
6381
  targetBranch
6379
6382
  }, "Running conflict detection...");
@@ -6395,7 +6398,7 @@ async function mergeTask(taskId, targetBranch, projectRoot) {
6395
6398
  } catch (err) {
6396
6399
  const message = err instanceof Error ? err.message : String(err);
6397
6400
  console.error(`Error merging task "${taskId}": ${message}`);
6398
- logger$6.error({
6401
+ logger$7.error({
6399
6402
  taskId,
6400
6403
  err
6401
6404
  }, "merge --task failed");
@@ -6449,7 +6452,7 @@ async function mergeAll(targetBranch, projectRoot, taskIds) {
6449
6452
  error: message
6450
6453
  });
6451
6454
  console.log(` Error for task "${taskId}": ${message}`);
6452
- logger$6.error({
6455
+ logger$7.error({
6453
6456
  taskId,
6454
6457
  err
6455
6458
  }, "merge --all: task failed");
@@ -6502,7 +6505,7 @@ function registerMergeCommand(program, projectRoot = process.cwd()) {
6502
6505
 
6503
6506
  //#endregion
6504
6507
  //#region src/cli/commands/worktrees.ts
6505
- const logger$5 = createLogger("worktrees-cmd");
6508
+ const logger$6 = createLogger("worktrees-cmd");
6506
6509
  const WORKTREES_EXIT_SUCCESS = 0;
6507
6510
  const WORKTREES_EXIT_ERROR = 1;
6508
6511
  /** Valid task statuses for filtering */
@@ -6629,7 +6632,7 @@ async function listWorktreesAction(options) {
6629
6632
  try {
6630
6633
  worktreeInfos = await manager.listWorktrees();
6631
6634
  } catch (err) {
6632
- logger$5.error({ err }, "Failed to list worktrees");
6635
+ logger$6.error({ err }, "Failed to list worktrees");
6633
6636
  const message = err instanceof Error ? err.message : String(err);
6634
6637
  process.stderr.write(`Error listing worktrees: ${message}\n`);
6635
6638
  return WORKTREES_EXIT_ERROR;
@@ -6656,7 +6659,7 @@ async function listWorktreesAction(options) {
6656
6659
  } catch (err) {
6657
6660
  const message = err instanceof Error ? err.message : String(err);
6658
6661
  process.stderr.write(`Error: ${message}\n`);
6659
- logger$5.error({ err }, "listWorktreesAction failed");
6662
+ logger$6.error({ err }, "listWorktreesAction failed");
6660
6663
  return WORKTREES_EXIT_ERROR;
6661
6664
  }
6662
6665
  }
@@ -6697,7 +6700,7 @@ function registerWorktreesCommand(program, version = "0.0.0", projectRoot = proc
6697
6700
 
6698
6701
  //#endregion
6699
6702
  //#region src/cli/commands/brainstorm.ts
6700
- const logger$4 = createLogger("brainstorm-cmd");
6703
+ const logger$5 = createLogger("brainstorm-cmd");
6701
6704
  /**
6702
6705
  * Detect whether the project has existing planning artifacts that indicate
6703
6706
  * this is an amendment session (vs. a brand-new project brainstorm).
@@ -6743,13 +6746,13 @@ async function loadAmendmentContextDocuments(projectRoot) {
6743
6746
  try {
6744
6747
  brief = await readFile(briefPath, "utf-8");
6745
6748
  } catch {
6746
- logger$4.warn({ briefPath }, "product-brief.md not found — continuing without brief context");
6749
+ logger$5.warn({ briefPath }, "product-brief.md not found — continuing without brief context");
6747
6750
  process.stderr.write(`Warning: product-brief.md not found at ${briefPath}\n`);
6748
6751
  }
6749
6752
  try {
6750
6753
  prd = await readFile(prdPath, "utf-8");
6751
6754
  } catch {
6752
- logger$4.warn({ prdPath }, "requirements.md not found — continuing without PRD context");
6755
+ logger$5.warn({ prdPath }, "requirements.md not found — continuing without PRD context");
6753
6756
  process.stderr.write(`Warning: requirements.md not found at ${prdPath}\n`);
6754
6757
  }
6755
6758
  return {
@@ -6958,7 +6961,7 @@ async function dispatchToPersonas(userPrompt, context, llmDispatch) {
6958
6961
  }
6959
6962
  ];
6960
6963
  const defaultDispatch = async (prompt, personaName) => {
6961
- logger$4.debug({
6964
+ logger$5.debug({
6962
6965
  personaName,
6963
6966
  promptLength: prompt.length
6964
6967
  }, "Dispatching to persona (stub mode)");
@@ -6975,7 +6978,7 @@ async function dispatchToPersonas(userPrompt, context, llmDispatch) {
6975
6978
  };
6976
6979
  } catch (err) {
6977
6980
  const msg = err instanceof Error ? err.message : String(err);
6978
- logger$4.error({
6981
+ logger$5.error({
6979
6982
  err,
6980
6983
  personaName: persona.name
6981
6984
  }, "Persona dispatch failed");
@@ -7127,7 +7130,7 @@ async function runBrainstormSession(options, llmDispatch, rlInterface) {
7127
7130
  }
7128
7131
  });
7129
7132
  rl.on("error", (err) => {
7130
- logger$4.error({ err }, "readline error");
7133
+ logger$5.error({ err }, "readline error");
7131
7134
  if (!sessionEnded) endSession(false);
7132
7135
  });
7133
7136
  });
@@ -7168,7 +7171,7 @@ function registerBrainstormCommand(program, _version = "0.0.0", projectRoot = pr
7168
7171
 
7169
7172
  //#endregion
7170
7173
  //#region src/cli/commands/retry-escalated.ts
7171
- const logger$3 = createLogger("retry-escalated-cmd");
7174
+ const logger$4 = createLogger("retry-escalated-cmd");
7172
7175
  async function runRetryEscalatedAction(options) {
7173
7176
  const { runId, dryRun, force, outputFormat, projectRoot, concurrency, pack: packName, registry: injectedRegistry, agent: agentId, events: eventsFlag } = options;
7174
7177
  const dbRoot = await resolveMainRepoRoot(projectRoot);
@@ -7209,7 +7212,7 @@ async function runRetryEscalatedAction(options) {
7209
7212
  process.stdout.write(`[INFO] ${storyKey}: Context ceiling set to ${contextCeiling} tokens due to prior context spike pattern.\n`);
7210
7213
  }
7211
7214
  } catch (err) {
7212
- logger$3.warn({
7215
+ logger$4.warn({
7213
7216
  err,
7214
7217
  storyKey
7215
7218
  }, "Failed to read efficiency profile — skipping gate");
@@ -7363,11 +7366,11 @@ async function runRetryEscalatedAction(options) {
7363
7366
  output_tokens: output,
7364
7367
  cost_usd: costUsd
7365
7368
  }).catch((err) => {
7366
- logger$3.warn({ err }, "Failed to record token usage");
7369
+ logger$4.warn({ err }, "Failed to record token usage");
7367
7370
  });
7368
7371
  }
7369
7372
  } catch (err) {
7370
- logger$3.warn({ err }, "Failed to record token usage");
7373
+ logger$4.warn({ err }, "Failed to record token usage");
7371
7374
  }
7372
7375
  });
7373
7376
  if (outputFormat === "human") {
@@ -7396,7 +7399,7 @@ async function runRetryEscalatedAction(options) {
7396
7399
  const msg = err instanceof Error ? err.message : String(err);
7397
7400
  if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, msg) + "\n");
7398
7401
  else process.stderr.write(`Error: ${msg}\n`);
7399
- logger$3.error({ err }, "retry-escalated failed");
7402
+ logger$4.error({ err }, "retry-escalated failed");
7400
7403
  return 1;
7401
7404
  } finally {
7402
7405
  try {
@@ -7427,6 +7430,99 @@ function registerRetryEscalatedCommand(program, _version = "0.0.0", projectRoot
7427
7430
  });
7428
7431
  }
7429
7432
 
7433
+ //#endregion
7434
+ //#region src/cli/commands/cancel.ts
7435
+ const logger$3 = createLogger("cancel-cmd");
7436
+ async function runCancelAction(options) {
7437
+ const { outputFormat, projectRoot, force } = options;
7438
+ const dbRoot = await resolveMainRepoRoot(projectRoot);
7439
+ const substrateDirPath = join(dbRoot, ".substrate");
7440
+ const pidFilePath = join(substrateDirPath, "orchestrator.pid");
7441
+ const processInfo = inspectProcessTree({
7442
+ projectRoot,
7443
+ substrateDirPath
7444
+ });
7445
+ const pid = processInfo.orchestrator_pid;
7446
+ const zombies = processInfo.zombies ?? [];
7447
+ if (pid === null && zombies.length === 0) {
7448
+ if (outputFormat === "json") process.stdout.write(formatOutput({
7449
+ cancelled: false,
7450
+ reason: "no_running_pipeline"
7451
+ }, "json", true) + "\n");
7452
+ else process.stdout.write("No running pipeline found.\n");
7453
+ if (existsSync$1(pidFilePath)) try {
7454
+ unlinkSync(pidFilePath);
7455
+ if (outputFormat === "human") process.stdout.write("Cleaned up stale PID file.\n");
7456
+ } catch {}
7457
+ return 0;
7458
+ }
7459
+ const killed = [];
7460
+ if (pid !== null) try {
7461
+ for (const childPid of processInfo.child_pids) try {
7462
+ process.kill(childPid, "SIGTERM");
7463
+ killed.push(childPid);
7464
+ } catch {}
7465
+ process.kill(pid, force ? "SIGKILL" : "SIGTERM");
7466
+ killed.push(pid);
7467
+ if (outputFormat === "human") {
7468
+ process.stdout.write(`Killed orchestrator (PID ${pid})`);
7469
+ if (processInfo.child_pids.length > 0) process.stdout.write(` and ${processInfo.child_pids.length} child process(es)`);
7470
+ process.stdout.write("\n");
7471
+ }
7472
+ } catch (err) {
7473
+ const msg = err instanceof Error ? err.message : String(err);
7474
+ logger$3.warn({
7475
+ pid,
7476
+ err: msg
7477
+ }, "Failed to kill orchestrator");
7478
+ if (outputFormat === "human") process.stdout.write(`Warning: could not kill PID ${pid}: ${msg}\n`);
7479
+ }
7480
+ for (const zombiePid of zombies) try {
7481
+ process.kill(zombiePid, "SIGKILL");
7482
+ killed.push(zombiePid);
7483
+ } catch {}
7484
+ if (existsSync$1(pidFilePath)) try {
7485
+ unlinkSync(pidFilePath);
7486
+ } catch {}
7487
+ try {
7488
+ const adapter = createDatabaseAdapter({
7489
+ backend: "auto",
7490
+ basePath: dbRoot
7491
+ });
7492
+ try {
7493
+ await initSchema(adapter);
7494
+ const runningRuns = await getRunningPipelineRuns(adapter);
7495
+ for (const run of runningRuns) {
7496
+ await updatePipelineRun(adapter, run.id, { status: "cancelled" });
7497
+ if (outputFormat === "human") process.stdout.write(`Marked pipeline run ${run.id} as cancelled.\n`);
7498
+ }
7499
+ } finally {
7500
+ await adapter.close();
7501
+ }
7502
+ } catch (err) {
7503
+ logger$3.warn({ err }, "Could not update pipeline run status (non-fatal)");
7504
+ }
7505
+ if (outputFormat === "json") process.stdout.write(formatOutput({
7506
+ cancelled: true,
7507
+ killed_pids: killed,
7508
+ zombies_killed: zombies.length
7509
+ }, "json", true) + "\n");
7510
+ else if (killed.length === 0 && zombies.length > 0) process.stdout.write(`Killed ${zombies.length} zombie process(es).\n`);
7511
+ process.stdout.write("Pipeline cancelled. Run `substrate run` to start fresh.\n");
7512
+ return 0;
7513
+ }
7514
+ function registerCancelCommand(program, projectRoot = process.cwd()) {
7515
+ program.command("cancel").description("Cancel the running pipeline — kills orchestrator, cleans up state").option("--force", "Use SIGKILL instead of SIGTERM").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").action(async (opts) => {
7516
+ const outputFormat = opts.outputFormat === "json" ? "json" : "human";
7517
+ const exitCode = await runCancelAction({
7518
+ outputFormat,
7519
+ projectRoot: opts.projectRoot,
7520
+ force: opts.force
7521
+ });
7522
+ process.exitCode = exitCode;
7523
+ });
7524
+ }
7525
+
7430
7526
  //#endregion
7431
7527
  //#region src/cli/commands/contracts.ts
7432
7528
  function registerContractsCommand(program) {
@@ -8226,6 +8322,7 @@ async function createProgram() {
8226
8322
  registerSupervisorCommand(program, version);
8227
8323
  registerMetricsCommand(program, version);
8228
8324
  registerRetryEscalatedCommand(program, version, process.cwd(), registry);
8325
+ registerCancelCommand(program, process.cwd());
8229
8326
  registerContractsCommand(program);
8230
8327
  registerDiffCommand(program);
8231
8328
  registerHistoryCommand(program);
@@ -8248,8 +8345,8 @@ async function createProgram() {
8248
8345
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
8249
8346
  function checkForUpdatesInBackground(currentVersion) {
8250
8347
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
8251
- import("../upgrade-D_od33Mu.js").then(async () => {
8252
- const { createVersionManager } = await import("../version-manager-impl-DA5apVDT.js");
8348
+ import("../upgrade-BPh0o_3L.js").then(async () => {
8349
+ const { createVersionManager } = await import("../version-manager-impl-BO2Gvy5R.js");
8253
8350
  const vm = createVersionManager();
8254
8351
  const result = await vm.checkForUpdates();
8255
8352
  if (result.updateAvailable) {
@@ -1,4 +1,4 @@
1
- import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-CtFYOaeA.js";
1
+ import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./dist-DmhbWZ0f.js";
2
2
  import "./decisions-C0pz9Clx.js";
3
3
 
4
4
  export { getLatestRun };
@@ -516,12 +516,15 @@ const CHARS_PER_TOKEN$3 = 4;
516
516
  /**
517
517
  * Extract top-level field names from a Zod schema for prompt injection.
518
518
  * Returns field names with type hints (e.g., "result: <string>", "files_modified: <list>").
519
+ * Exported for testing.
519
520
  */
520
521
  function extractSchemaFields(schema) {
521
522
  let current = schema;
522
523
  let def = current?._def;
523
- while (def?.typeName === "ZodEffects" && def?.schema != null) {
524
- current = def.schema;
524
+ while (true) {
525
+ if (def?.typeName === "ZodEffects" && def?.schema != null) current = def.schema;
526
+ else if (def?.type === "pipe" && def?.in != null) current = def.in;
527
+ else break;
525
528
  def = current?._def;
526
529
  }
527
530
  const shape = current?.shape;
@@ -538,20 +541,26 @@ function extractSchemaFields(schema) {
538
541
  */
539
542
  function resolveZodTypeName(fieldDef) {
540
543
  const d = fieldDef;
541
- const typeName = d?._def?.typeName;
542
- if (typeName === "ZodOptional" || typeName === "ZodDefault") return d._def?.innerType != null ? resolveZodTypeName(d._def.innerType) : "<value>";
544
+ const typeName = d?._def?.typeName ?? d?._def?.type;
545
+ if (typeName === "ZodOptional" || typeName === "optional" || typeName === "ZodDefault" || typeName === "default") return d._def?.innerType != null ? resolveZodTypeName(d._def.innerType) : "<value>";
543
546
  if (typeName === "ZodEffects") return d._def?.schema != null ? resolveZodTypeName(d._def.schema) : "<value>";
544
- if (typeName === "ZodString") return "<string>";
545
- if (typeName === "ZodNumber") return "<number>";
546
- if (typeName === "ZodBoolean") return "<boolean>";
547
- if (typeName === "ZodEnum") {
547
+ if (typeName === "transform") return "<value>";
548
+ if (typeName === "pipe") return d._def?.out != null ? resolveZodTypeName(d._def.out) : "<value>";
549
+ if (typeName === "ZodString" || typeName === "string") return "<string>";
550
+ if (typeName === "ZodNumber" || typeName === "number") return "<number>";
551
+ if (typeName === "ZodBoolean" || typeName === "boolean") return "<boolean>";
552
+ if (typeName === "ZodEnum" || typeName === "enum") {
548
553
  const values = d._def?.values;
549
- return values != null ? values.join(" | ") : "<enum>";
554
+ const entries = d._def?.entries;
555
+ if (values != null) return values.join(" | ");
556
+ if (entries != null) return Object.keys(entries).join(" | ");
557
+ return "<enum>";
550
558
  }
551
- if (typeName === "ZodArray") return "<list>";
552
- if (typeName === "ZodObject") return "<object>";
559
+ if (typeName === "ZodArray" || typeName === "array") return "<list>";
560
+ if (typeName === "ZodObject" || typeName === "object") return "<object>";
553
561
  return "<value>";
554
562
  }
563
+ /** Exported for testing. */
555
564
  function buildYamlOutputSuffix(outputSchema) {
556
565
  const fields = outputSchema != null ? extractSchemaFields(outputSchema) : [];
557
566
  const fieldLines = fields.length > 0 ? fields.map((f) => ` ${f}`).join("\n") : " result: success\n # ... additional fields as specified in the task above";
@@ -10442,4 +10451,4 @@ async function callLLM(params) {
10442
10451
 
10443
10452
  //#endregion
10444
10453
  export { ADVISORY_NOTES, AdapterRegistry, AdtError, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, Categorizer, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, ConsumerAnalyzer, CostTrackerConfigSchema, DEFAULT_CONFIG, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, DoltNotInstalled, DoltQueryError, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, GeminiCLIAdapter, GlobalSettingsSchema, IngestionServer, LogTurnAnalyzer, ModelRoutingConfigSchema, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProviderPolicySchema, ProvidersSchema, Recommender, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TASK_TYPE_PHASE_MAP, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryConfigSchema, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, VersionManagerImpl, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, callLLM, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDatabaseAdapter as createDatabaseAdapter$1, createDecision, createDoltClient, createExperimenter, createPipelineRun, createRequirement, createVersionManager, detectInterfaceChanges, determineVerdict, getActiveDecisions, getAllCostEntriesFiltered, getArtifactByTypeForRun, getArtifactsByRun, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getModelTier, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initializeDolt, listRequirements, listRunMetrics, loadModelRoutingConfig, loadParentRunDecisions, registerArtifact, resolvePromptFile, supersedeDecision, tagRunAsBaseline, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics };
10445
- //# sourceMappingURL=dist-CtFYOaeA.js.map
10454
+ //# sourceMappingURL=dist-DmhbWZ0f.js.map
@@ -1,4 +1,4 @@
1
- import { AdtError } from "./dist-CtFYOaeA.js";
1
+ import { AdtError } from "./dist-DmhbWZ0f.js";
2
2
 
3
3
  //#region src/core/errors.ts
4
4
  /** Error thrown when task configuration is invalid */
@@ -71,4 +71,4 @@ var TaskGraphIncompatibleFormatError = class extends AdtError {
71
71
 
72
72
  //#endregion
73
73
  export { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError };
74
- //# sourceMappingURL=errors-CWSATPPa.js.map
74
+ //# sourceMappingURL=errors-CrFWBvB4.js.map
@@ -1,3 +1,3 @@
1
- import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-CtFYOaeA.js";
1
+ import { buildAuditLogEntry, buildBranchName, buildModificationDirective, buildPRBody, buildWorktreePath, createExperimenter, determineVerdict, resolvePromptFile } from "./dist-DmhbWZ0f.js";
2
2
 
3
3
  export { createExperimenter };
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-CtFYOaeA.js";
2
+ import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-DmhbWZ0f.js";
3
3
  import { createRequire } from "module";
4
4
  import { dirname, join } from "path";
5
5
  import { existsSync, readFileSync } from "node:fs";
@@ -1870,6 +1870,17 @@ async function runHealthAction(options) {
1870
1870
  process.stdout.write(`\n Summary: ${health.stories.active} active, ${health.stories.completed} completed, ${health.stories.escalated} escalated\n`);
1871
1871
  }
1872
1872
  }
1873
+ if (health.verdict === "STALLED") {
1874
+ process.stdout.write("\n Recommended Actions:\n");
1875
+ if (health.process.orchestrator_pid !== null) process.stdout.write(` 1. Kill stalled orchestrator: kill ${health.process.orchestrator_pid}\n`);
1876
+ if (health.process.zombies.length > 0) process.stdout.write(` ${health.process.orchestrator_pid !== null ? "2" : "1"}. Kill zombie processes: kill ${health.process.zombies.join(" ")}\n`);
1877
+ process.stdout.write(` ${health.process.orchestrator_pid !== null ? "3" : "2"}. Resume the run: substrate resume\n`);
1878
+ process.stdout.write(` ${health.process.orchestrator_pid !== null ? "4" : "3"}. Or start fresh: substrate run --events --stories <keys>\n`);
1879
+ } else if (health.verdict === "NO_PIPELINE_RUNNING" && health.stories.escalated > 0) {
1880
+ process.stdout.write("\n Recommended Actions:\n");
1881
+ process.stdout.write(" 1. Retry escalated stories: substrate retry-escalated\n");
1882
+ process.stdout.write(" 2. Or start a new run: substrate run --events\n");
1883
+ }
1873
1884
  if (health.dolt_state !== void 0) {
1874
1885
  const ds = health.dolt_state;
1875
1886
  const initStr = ds.initialized ? "yes" : "no";
@@ -1930,4 +1941,4 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
1930
1941
 
1931
1942
  //#endregion
1932
1943
  export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN$1 as STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createStateStore, detectCycles, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, runHealthAction, validateStoryKey };
1933
- //# sourceMappingURL=health-CkQncTB5.js.map
1944
+ //# sourceMappingURL=health-DezAZoGb.js.map
@@ -1,6 +1,6 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-CkQncTB5.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-DezAZoGb.js";
2
2
  import "./logger-KeHncl-f.js";
3
- import "./dist-CtFYOaeA.js";
3
+ import "./dist-DmhbWZ0f.js";
4
4
  import "./decisions-C0pz9Clx.js";
5
5
 
6
6
  export { inspectProcessTree };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { childLogger, createLogger, logger } from "./logger-KeHncl-f.js";
2
2
  import { assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry } from "./helpers-CElYrONe.js";
3
- import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-CtFYOaeA.js";
3
+ import { AdapterRegistry, AdtError, ClaudeCodeAdapter, CodexCLIAdapter, ConfigError, ConfigIncompatibleFormatError, GeminiCLIAdapter } from "./dist-DmhbWZ0f.js";
4
4
  import "./adapter-registry-DXLMTmfD.js";
5
- import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-CWSATPPa.js";
5
+ import { BudgetExceededError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError } from "./errors-CrFWBvB4.js";
6
6
 
7
7
  //#region src/core/di.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-CtFYOaeA.js";
1
+ import { ModelRoutingConfigSchema, ProviderPolicySchema, RoutingConfigError, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, TASK_TYPE_PHASE_MAP, getModelTier, loadModelRoutingConfig } from "./dist-DmhbWZ0f.js";
2
2
  import "./routing-CcBOCuC9.js";
3
3
 
4
4
  export { loadModelRoutingConfig };
@@ -1,7 +1,7 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, detectCycles, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveMainRepoRoot, validateStoryKey } from "./health-CkQncTB5.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, DoltMergeConflict, FileStateStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, WorkGraphRepository, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, detectCycles, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, resolveMainRepoRoot, validateStoryKey } from "./health-DezAZoGb.js";
2
2
  import { createLogger } from "./logger-KeHncl-f.js";
3
3
  import { TypedEventBusImpl, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-CElYrONe.js";
4
- import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-CtFYOaeA.js";
4
+ import { ADVISORY_NOTES, Categorizer, ConsumerAnalyzer, DEFAULT_GLOBAL_SETTINGS, DispatcherImpl, DoltClient, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, EfficiencyScorer, IngestionServer, LogTurnAnalyzer, OPERATIONAL_FINDING, Recommender, RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, STORY_METRICS, STORY_OUTCOME, SubstrateConfigSchema, TEST_EXPANSION_FINDING, TEST_PLAN, TelemetryNormalizer, TelemetryPipeline, TurnAnalyzer, addTokenUsage, aggregateTokenUsageForRun, aggregateTokenUsageForStory, callLLM, createConfigSystem, createDatabaseAdapter$1, createDecision, createPipelineRun, createRequirement, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-DmhbWZ0f.js";
5
5
  import { basename, dirname, extname, join } from "path";
6
6
  import { access, readFile, readdir, stat } from "fs/promises";
7
7
  import { EventEmitter } from "node:events";
@@ -10788,6 +10788,19 @@ function createImplementationOrchestrator(deps) {
10788
10788
  };
10789
10789
  }
10790
10790
  } catch {}
10791
+ const LOW_OUTPUT_TOKEN_THRESHOLD = 100;
10792
+ const unverified = tokenAgg.output < LOW_OUTPUT_TOKEN_THRESHOLD;
10793
+ if (unverified) {
10794
+ logger$22.warn({
10795
+ storyKey,
10796
+ outputTokens: tokenAgg.output,
10797
+ threshold: LOW_OUTPUT_TOKEN_THRESHOLD
10798
+ }, "Story completed with very low output tokens — marking as unverified");
10799
+ eventBus.emit("orchestrator:story-warn", {
10800
+ storyKey,
10801
+ msg: `Low output tokens (${tokenAgg.output} < ${LOW_OUTPUT_TOKEN_THRESHOLD}) — result may be unverified`
10802
+ });
10803
+ }
10791
10804
  eventBus.emit("story:metrics", {
10792
10805
  storyKey,
10793
10806
  wallClockMs,
@@ -10798,7 +10811,8 @@ function createImplementationOrchestrator(deps) {
10798
10811
  },
10799
10812
  reviewCycles,
10800
10813
  dispatches: _storyDispatches.get(storyKey) ?? 0,
10801
- ...diffStats !== void 0 ? { diffStats } : {}
10814
+ ...diffStats !== void 0 ? { diffStats } : {},
10815
+ ...unverified ? { unverified: true } : {}
10802
10816
  });
10803
10817
  } catch (emitErr) {
10804
10818
  logger$22.warn({
@@ -40317,6 +40331,7 @@ const logger = createLogger("run-cmd");
40317
40331
  * Resolve effective max review cycles by checking the adapter's default.
40318
40332
  * Uses Math.max so the adapter's recommendation is a floor, not an override.
40319
40333
  */
40334
+ /** Exported for testing. */
40320
40335
  function resolveMaxReviewCycles(cliValue, agentId, registry) {
40321
40336
  if (agentId == null || registry == null) return cliValue;
40322
40337
  const adapter = registry.get(agentId);
@@ -41818,5 +41833,5 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
41818
41833
  }
41819
41834
 
41820
41835
  //#endregion
41821
- export { 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, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
41822
- //# sourceMappingURL=run-MGg8SzDA.js.map
41836
+ export { 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, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveMaxReviewCycles, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
41837
+ //# sourceMappingURL=run-DSj4ebow.js.map
@@ -0,0 +1,9 @@
1
+ import "./health-DezAZoGb.js";
2
+ import "./logger-KeHncl-f.js";
3
+ import "./helpers-CElYrONe.js";
4
+ import "./dist-DmhbWZ0f.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction } from "./run-DSj4ebow.js";
6
+ import "./routing-CcBOCuC9.js";
7
+ import "./decisions-C0pz9Clx.js";
8
+
9
+ export { runRunAction };
@@ -1,5 +1,5 @@
1
- import "./dist-CtFYOaeA.js";
1
+ import "./dist-DmhbWZ0f.js";
2
2
  import "./version-manager-impl-BmOWu8ml.js";
3
- import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-UCMt4b7A.js";
3
+ import { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand } from "./upgrade-o__Q1Kdc.js";
4
4
 
5
5
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
@@ -1,4 +1,4 @@
1
- import { createVersionManager } from "./dist-CtFYOaeA.js";
1
+ import { createVersionManager } from "./dist-DmhbWZ0f.js";
2
2
  import { execSync, spawn } from "child_process";
3
3
  import * as readline from "readline";
4
4
 
@@ -123,4 +123,4 @@ function registerUpgradeCommand(program) {
123
123
 
124
124
  //#endregion
125
125
  export { isGlobalInstall, registerUpgradeCommand, runUpgradeCommand };
126
- //# sourceMappingURL=upgrade-UCMt4b7A.js.map
126
+ //# sourceMappingURL=upgrade-o__Q1Kdc.js.map
@@ -1,4 +1,4 @@
1
- import { VersionManagerImpl, createVersionManager } from "./dist-CtFYOaeA.js";
1
+ import { VersionManagerImpl, createVersionManager } from "./dist-DmhbWZ0f.js";
2
2
  import "./version-manager-impl-BmOWu8ml.js";
3
3
 
4
4
  export { createVersionManager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.19.20",
3
+ "version": "0.19.22",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- import { AdapterRegistry } from "./dist-CtFYOaeA.js";
2
- import "./adapter-registry-DXLMTmfD.js";
3
-
4
- export { AdapterRegistry };
@@ -1,9 +0,0 @@
1
- import "./health-CkQncTB5.js";
2
- import "./logger-KeHncl-f.js";
3
- import "./helpers-CElYrONe.js";
4
- import "./dist-CtFYOaeA.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, runRunAction } from "./run-MGg8SzDA.js";
6
- import "./routing-CcBOCuC9.js";
7
- import "./decisions-C0pz9Clx.js";
8
-
9
- export { runRunAction };