substrate-ai 0.3.2 → 0.3.4

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,3 @@
1
+ import { AdapterRegistry } from "./adapter-registry-DHl0W-YB.js";
2
+
3
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltNotInstalled, FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, TelemetryPersistence, VALID_PHASES, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDispatcher, createDoltClient, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initializeDolt, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runMigrations, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-Fzhz3-mv.js";
2
+ import { DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltNotInstalled, FileStateStore, SUBSTRATE_OWNED_SETTINGS_KEYS, TelemetryPersistence, VALID_PHASES, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDispatcher, createDoltClient, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initializeDolt, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runMigrations, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-8ygA8hgY.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
4
  import { AdapterRegistry } from "../adapter-registry-DHl0W-YB.js";
5
- import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-CQmBdKeG.js";
6
- import { ConfigError, createEventBus } from "../helpers-RL22dYtn.js";
7
- import { addTokenUsage, createDecision, createPipelineRun, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestRun, getTokenUsageSummary, listRequirements, updatePipelineRun } from "../decisions-Dq4cAA2L.js";
8
- import { ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, aggregateTokenUsageForRun, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline } from "../operational-Bovj4fS-.js";
9
- import { abortMerge, createWorktree, getConflictingFiles, getMergedFiles, getOrphanedWorktrees, performMerge, removeBranch, removeWorktree, simulateMerge, verifyGitVersion } from "../git-utils-CtmrZrHS.js";
10
- import "../version-manager-impl-33JYXsqa.js";
11
- import { registerUpgradeCommand } from "../upgrade-DO307rFf.js";
5
+ import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
6
+ import { ConfigError, createEventBus } from "../helpers-BihqWgVe.js";
7
+ import { addTokenUsage, createDecision, createPipelineRun, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestRun, getTokenUsageSummary, listRequirements, updatePipelineRun } from "../decisions-CdpiJIm5.js";
8
+ import { ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, aggregateTokenUsageForRun, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline } from "../operational-DisxqtjC.js";
9
+ import { abortMerge, createWorktree, getConflictingFiles, getMergedFiles, getOrphanedWorktrees, performMerge, removeBranch, removeWorktree, simulateMerge, verifyGitVersion } from "../git-utils-UbKLSGsD.js";
10
+ import "../version-manager-impl-zsJjBhak.js";
11
+ import { registerUpgradeCommand } from "../upgrade-DTzeenA-.js";
12
12
  import { Command } from "commander";
13
13
  import { fileURLToPath } from "url";
14
14
  import { dirname, join, resolve } from "path";
@@ -2278,6 +2278,20 @@ function defaultSupervisorDeps() {
2278
2278
  }
2279
2279
  },
2280
2280
  getAllDescendants: (rootPids) => getAllDescendantPids(rootPids),
2281
+ getRegistry: (() => {
2282
+ let cached = null;
2283
+ return async () => {
2284
+ if (cached === null) {
2285
+ const { AdapterRegistry: AR } = await import(
2286
+ /* @vite-ignore */
2287
+ "../adapter-registry-eyyVr21J.js"
2288
+ );
2289
+ cached = new AR();
2290
+ await cached.discoverAndRegister();
2291
+ }
2292
+ return cached;
2293
+ };
2294
+ })(),
2281
2295
  writeStallFindings: async (opts) => {
2282
2296
  try {
2283
2297
  const dbRoot = await resolveMainRepoRoot(opts.projectRoot);
@@ -2422,7 +2436,7 @@ function buildTerminalSummary(storyDetails) {
2422
2436
  */
2423
2437
  async function handleStallRecovery(health, state, config, deps, io) {
2424
2438
  const { stallThreshold, maxRestarts, pack, outputFormat } = config;
2425
- const { killPid, resumePipeline, sleep, incrementRestarts, getAllDescendants, writeStallFindings } = deps;
2439
+ const { killPid, resumePipeline, sleep, incrementRestarts, getAllDescendants, writeStallFindings, getRegistry } = deps;
2426
2440
  const { emitEvent, log } = io;
2427
2441
  const { projectRoot } = state;
2428
2442
  if (health.staleness_seconds < stallThreshold) return null;
@@ -2491,12 +2505,14 @@ async function handleStallRecovery(health, state, config, deps, io) {
2491
2505
  });
2492
2506
  log(`Supervisor: Restarting pipeline (attempt ${newRestartCount}/${maxRestarts})`);
2493
2507
  try {
2508
+ const registry = await getRegistry();
2494
2509
  await resumePipeline({
2495
2510
  runId: health.run_id ?? void 0,
2496
2511
  outputFormat,
2497
2512
  projectRoot,
2498
2513
  concurrency: 3,
2499
- pack
2514
+ pack,
2515
+ registry
2500
2516
  });
2501
2517
  if (writeStallFindings) await writeStallFindings({
2502
2518
  runId: health.run_id,
@@ -2554,6 +2570,7 @@ async function runSupervisorAction(options, deps = {}) {
2554
2570
  runId,
2555
2571
  restartCount: 0
2556
2572
  };
2573
+ let maxRestartsExhausted = false;
2557
2574
  const startTime = Date.now();
2558
2575
  function emitEvent(event) {
2559
2576
  if (outputFormat === "json") {
@@ -2650,11 +2667,11 @@ async function runSupervisorAction(options, deps = {}) {
2650
2667
  try {
2651
2668
  const { createExperimenter } = await import(
2652
2669
  /* @vite-ignore */
2653
- "../experimenter-Br1-vzYv.js"
2670
+ "../experimenter-jto3orYl.js"
2654
2671
  );
2655
2672
  const { getLatestRun: getLatest } = await import(
2656
2673
  /* @vite-ignore */
2657
- "../decisions-DxgMpQpz.js"
2674
+ "../decisions-CbysnTi5.js"
2658
2675
  );
2659
2676
  const dbPath = join(projectRoot, ".substrate", "substrate.db");
2660
2677
  const expDbWrapper = new DatabaseWrapper(dbPath);
@@ -2664,7 +2681,7 @@ async function runSupervisorAction(options, deps = {}) {
2664
2681
  const expDb = expDbWrapper.db;
2665
2682
  const { runRunAction: runPipeline } = await import(
2666
2683
  /* @vite-ignore */
2667
- "../run-BJ5z_b2J.js"
2684
+ "../run-Dul2DU3D.js"
2668
2685
  );
2669
2686
  const runStoryFn = async (opts) => {
2670
2687
  const exitCode = await runPipeline({
@@ -2729,6 +2746,7 @@ async function runSupervisorAction(options, deps = {}) {
2729
2746
  }
2730
2747
  return summary.failed.length > 0 || summary.escalated.length > 0 ? 1 : 0;
2731
2748
  }
2749
+ if (maxRestartsExhausted) return 2;
2732
2750
  const stallResult = await handleStallRecovery(health, state, {
2733
2751
  stallThreshold,
2734
2752
  maxRestarts,
@@ -2740,15 +2758,14 @@ async function runSupervisorAction(options, deps = {}) {
2740
2758
  sleep: resolvedDeps.sleep,
2741
2759
  incrementRestarts: resolvedDeps.incrementRestarts,
2742
2760
  getAllDescendants: resolvedDeps.getAllDescendants,
2743
- writeStallFindings: resolvedDeps.writeStallFindings
2761
+ writeStallFindings: resolvedDeps.writeStallFindings,
2762
+ getRegistry: resolvedDeps.getRegistry
2744
2763
  }, {
2745
2764
  emitEvent,
2746
2765
  log
2747
2766
  });
2748
- if (stallResult !== null) {
2749
- if (stallResult.maxRestartsExceeded) return 2;
2750
- state = stallResult.state;
2751
- }
2767
+ if (stallResult !== null) if (stallResult.maxRestartsExceeded) maxRestartsExhausted = true;
2768
+ else state = stallResult.state;
2752
2769
  await sleep(pollInterval * 1e3);
2753
2770
  }
2754
2771
  }
@@ -2778,6 +2795,7 @@ async function runMultiProjectSupervisor(options, deps = {}) {
2778
2795
  }]));
2779
2796
  const doneProjects = new Set();
2780
2797
  const projectExitCodes = new Map();
2798
+ const maxRestartsExhaustedProjects = new Set();
2781
2799
  const startTime = Date.now();
2782
2800
  function emitEvent(event) {
2783
2801
  if (outputFormat === "json") {
@@ -2834,6 +2852,11 @@ async function runMultiProjectSupervisor(options, deps = {}) {
2834
2852
  projectExitCodes.set(projectRoot, summary.failed.length > 0 || summary.escalated.length > 0 ? 1 : 0);
2835
2853
  continue;
2836
2854
  }
2855
+ if (maxRestartsExhaustedProjects.has(projectRoot)) {
2856
+ doneProjects.add(projectRoot);
2857
+ projectExitCodes.set(projectRoot, 2);
2858
+ continue;
2859
+ }
2837
2860
  const stallResult = await handleStallRecovery(health, state, {
2838
2861
  stallThreshold,
2839
2862
  maxRestarts,
@@ -2846,10 +2869,8 @@ async function runMultiProjectSupervisor(options, deps = {}) {
2846
2869
  }),
2847
2870
  log: (msg) => log(`[${projectRoot}] ${msg}`)
2848
2871
  });
2849
- if (stallResult !== null) if (stallResult.maxRestartsExceeded) {
2850
- doneProjects.add(projectRoot);
2851
- projectExitCodes.set(projectRoot, 2);
2852
- } else states.set(projectRoot, stallResult.state);
2872
+ if (stallResult !== null) if (stallResult.maxRestartsExceeded) maxRestartsExhaustedProjects.add(projectRoot);
2873
+ else states.set(projectRoot, stallResult.state);
2853
2874
  }
2854
2875
  if (doneProjects.size >= projects.length) {
2855
2876
  const elapsedSeconds = Math.round((Date.now() - startTime) / 1e3);
@@ -3025,7 +3046,6 @@ async function runMetricsAction(options) {
3025
3046
  }
3026
3047
  try {
3027
3048
  const telemetryPersistence = new TelemetryPersistence(sqliteDb);
3028
- telemetryPersistence.initSchema();
3029
3049
  if (efficiency === true) {
3030
3050
  const scores = await telemetryPersistence.getEfficiencyScores(20);
3031
3051
  if (outputFormat === "json") process.stdout.write(formatOutput({ efficiency: rowsToEfficiencyScore(scores) }, "json", true) + "\n");
@@ -7452,8 +7472,8 @@ async function createProgram() {
7452
7472
  /** Fire-and-forget startup version check (story 8.3, AC3/AC5) */
7453
7473
  function checkForUpdatesInBackground(currentVersion) {
7454
7474
  if (process.env.SUBSTRATE_NO_UPDATE_CHECK === "1") return;
7455
- import("../upgrade-Ex1ukwsm.js").then(async () => {
7456
- const { createVersionManager } = await import("../version-manager-impl-Dk3S31y6.js");
7475
+ import("../upgrade-BlJKjr6I.js").then(async () => {
7476
+ const { createVersionManager } = await import("../version-manager-impl-BsHqAeGT.js");
7457
7477
  const vm = createVersionManager();
7458
7478
  const result = await vm.checkForUpdates();
7459
7479
  if (result.updateAvailable) {
@@ -247,4 +247,4 @@ const defaultConfigMigrator = new ConfigMigrator();
247
247
 
248
248
  //#endregion
249
249
  export { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema, SUPPORTED_CONFIG_FORMAT_VERSIONS, SUPPORTED_TASK_GRAPH_VERSIONS, SubstrateConfigSchema, defaultConfigMigrator };
250
- //# sourceMappingURL=config-migrator-CQmBdKeG.js.map
250
+ //# sourceMappingURL=config-migrator-DtZW1maj.js.map
@@ -1,3 +1,3 @@
1
- import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./decisions-Dq4cAA2L.js";
1
+ import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./decisions-CdpiJIm5.js";
2
2
 
3
3
  export { getLatestRun };
@@ -369,4 +369,4 @@ function getTokenUsageSummary(db, runId) {
369
369
 
370
370
  //#endregion
371
371
  export { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, listRequirements, registerArtifact, updateDecision, updatePipelineRun, updatePipelineRunConfig, upsertDecision };
372
- //# sourceMappingURL=decisions-Dq4cAA2L.js.map
372
+ //# sourceMappingURL=decisions-CdpiJIm5.js.map
@@ -1,7 +1,7 @@
1
1
  import "./logger-D2fS2ccL.js";
2
- import { createDecision } from "./decisions-Dq4cAA2L.js";
3
- import { EXPERIMENT_RESULT, getRunMetrics, getStoryMetricsForRun } from "./operational-Bovj4fS-.js";
4
- import { spawnGit } from "./git-utils-CtmrZrHS.js";
2
+ import { createDecision } from "./decisions-CdpiJIm5.js";
3
+ import { EXPERIMENT_RESULT, getRunMetrics, getStoryMetricsForRun } from "./operational-DisxqtjC.js";
4
+ import { spawnGit } from "./git-utils-UbKLSGsD.js";
5
5
  import { spawn } from "node:child_process";
6
6
  import { join } from "node:path";
7
7
  import { mkdir, readFile, writeFile } from "node:fs/promises";
@@ -500,4 +500,4 @@ function createExperimenter(config, deps) {
500
500
 
501
501
  //#endregion
502
502
  export { createExperimenter };
503
- //# sourceMappingURL=experimenter-Br1-vzYv.js.map
503
+ //# sourceMappingURL=experimenter-jto3orYl.js.map
@@ -362,4 +362,4 @@ async function getMergedFiles(cwd) {
362
362
 
363
363
  //#endregion
364
364
  export { abortMerge, createWorktree, getConflictingFiles, getMergedFiles, getOrphanedWorktrees, performMerge, removeBranch, removeWorktree, simulateMerge, spawnGit, verifyGitVersion };
365
- //# sourceMappingURL=git-utils-CtmrZrHS.js.map
365
+ //# sourceMappingURL=git-utils-UbKLSGsD.js.map
@@ -917,4 +917,4 @@ async function withRetry(fn, maxRetries = 3, baseDelayMs = 100) {
917
917
 
918
918
  //#endregion
919
919
  export { AdtError, BudgetExceededError, ConfigError, ConfigIncompatibleFormatError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError, assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry };
920
- //# sourceMappingURL=helpers-RL22dYtn.js.map
920
+ //# sourceMappingURL=helpers-BihqWgVe.js.map
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { childLogger, createLogger, logger } from "./logger-D2fS2ccL.js";
2
2
  import { AdapterRegistry, ClaudeCodeAdapter, CodexCLIAdapter, GeminiCLIAdapter } from "./adapter-registry-DHl0W-YB.js";
3
- import { AdtError, BudgetExceededError, ConfigError, ConfigIncompatibleFormatError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError, assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry } from "./helpers-RL22dYtn.js";
3
+ import { AdtError, BudgetExceededError, ConfigError, ConfigIncompatibleFormatError, GitError, RecoveryError, TaskConfigError, TaskGraphCycleError, TaskGraphError, TaskGraphIncompatibleFormatError, WorkerError, WorkerNotFoundError, assertDefined, createEventBus, createTuiApp, deepClone, formatDuration, generateId, isPlainObject, isTuiCapable, printNonTtyWarning, sleep, withRetry } from "./helpers-BihqWgVe.js";
4
4
 
5
5
  //#region src/core/di.ts
6
6
  /**
@@ -356,4 +356,4 @@ const ADVISORY_NOTES = "advisory-notes";
356
356
 
357
357
  //#endregion
358
358
  export { ADVISORY_NOTES, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, STORY_OUTCOME, TEST_EXPANSION_FINDING, TEST_PLAN, aggregateTokenUsageForRun, aggregateTokenUsageForStory, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline, writeRunMetrics, writeStoryMetrics };
359
- //# sourceMappingURL=operational-Bovj4fS-.js.map
359
+ //# sourceMappingURL=operational-DisxqtjC.js.map