substrate-ai 0.6.6 → 0.6.7

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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-BiREqhp_.js";
2
+ import { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runSolutioningPhase, validateStopAfterFromConflict } from "../run-Dmq9AYGt.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
4
  import { AdapterRegistry } from "../adapter-registry-D2zdMwVu.js";
5
5
  import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
@@ -3486,7 +3486,7 @@ async function runSupervisorAction(options, deps = {}) {
3486
3486
  await initSchema(expAdapter);
3487
3487
  const { runRunAction: runPipeline } = await import(
3488
3488
  /* @vite-ignore */
3489
- "../run-DZpZt2zm.js"
3489
+ "../run-BhgHYRk6.js"
3490
3490
  );
3491
3491
  const runStoryFn = async (opts) => {
3492
3492
  const exitCode = await runPipeline({
@@ -1,4 +1,4 @@
1
- import { registerRunCommand, runRunAction } from "./run-BiREqhp_.js";
1
+ import { registerRunCommand, runRunAction } from "./run-Dmq9AYGt.js";
2
2
  import "./logger-D2fS2ccL.js";
3
3
  import "./config-migrator-DtZW1maj.js";
4
4
  import "./helpers-BihqWgVe.js";
@@ -9379,6 +9379,29 @@ async function getGitDiffForFiles(files, workingDirectory = process.cwd()) {
9379
9379
  ], workingDirectory, "git-diff-files");
9380
9380
  }
9381
9381
  /**
9382
+ * Capture the file-level stat summary scoped to specific files.
9383
+ *
9384
+ * Runs `git diff --stat HEAD -- file1.ts file2.ts ...` to produce a condensed
9385
+ * stat summary limited to only the specified file paths. Used as a fallback
9386
+ * when the scoped full diff exceeds the token budget — ensures the stat-only
9387
+ * summary also stays scoped to the story's files rather than showing all
9388
+ * uncommitted changes in the repo.
9389
+ *
9390
+ * @param files - List of file paths to scope the stat summary to
9391
+ * @param workingDirectory - Directory to run git in (defaults to process.cwd())
9392
+ * @returns The scoped stat summary string, or '' on error/empty
9393
+ */
9394
+ async function getGitDiffStatForFiles(files, workingDirectory = process.cwd()) {
9395
+ if (files.length === 0) return "";
9396
+ return runGitCommand([
9397
+ "diff",
9398
+ "--stat",
9399
+ "HEAD",
9400
+ "--",
9401
+ ...files
9402
+ ], workingDirectory, "git-diff-stat-files");
9403
+ }
9404
+ /**
9382
9405
  * Get all changed file paths from the working tree via `git status --porcelain`.
9383
9406
  *
9384
9407
  * Includes all status codes (M, A, R, D, ??) so that newly created untracked
@@ -10366,8 +10389,8 @@ async function runCodeReview(deps, params) {
10366
10389
  estimatedTotal: scopedTotal,
10367
10390
  ceiling: TOKEN_CEILING,
10368
10391
  fileCount: filesModified.length
10369
- }, "Scoped diff exceeds token ceiling — falling back to stat-only summary");
10370
- gitDiffContent = await getGitDiffStatSummary(cwd);
10392
+ }, "Scoped diff exceeds token ceiling — falling back to scoped stat-only summary");
10393
+ gitDiffContent = await getGitDiffStatForFiles(filesModified, cwd);
10371
10394
  }
10372
10395
  } else {
10373
10396
  const changedFiles = await getGitChangedFiles(cwd);
@@ -10917,7 +10940,7 @@ async function runTestExpansion(deps, params) {
10917
10940
  ceiling: TOKEN_CEILING,
10918
10941
  fileCount: filesModified.length
10919
10942
  }, "Scoped diff exceeds token ceiling — falling back to stat-only summary");
10920
- gitDiffContent = await getGitDiffStatSummary(cwd);
10943
+ gitDiffContent = await getGitDiffStatForFiles(filesModified, cwd);
10921
10944
  }
10922
10945
  } catch (err) {
10923
10946
  logger$13.warn({ error: err instanceof Error ? err.message : String(err) }, "Failed to get git diff — proceeding with empty diff");
@@ -17164,30 +17187,79 @@ function createImplementationOrchestrator(deps) {
17164
17187
  } else if (buildVerifyResult.status === "failed" || buildVerifyResult.status === "timeout") {
17165
17188
  const truncatedOutput = (buildVerifyResult.output ?? "").slice(0, 2e3);
17166
17189
  const reason = buildVerifyResult.reason ?? "build-verification-failed";
17167
- eventBus.emit("story:build-verification-failed", {
17168
- storyKey,
17169
- exitCode: buildVerifyResult.exitCode ?? 1,
17170
- output: truncatedOutput
17171
- });
17172
- logger$27.warn({
17173
- storyKey,
17174
- reason,
17175
- exitCode: buildVerifyResult.exitCode
17176
- }, "Build verification failedescalating story");
17177
- updateStory(storyKey, {
17178
- phase: "ESCALATED",
17179
- error: reason,
17180
- completedAt: new Date().toISOString()
17181
- });
17182
- await writeStoryMetricsBestEffort(storyKey, "escalated", 0);
17183
- await emitEscalation({
17184
- storyKey,
17185
- lastVerdict: reason,
17186
- reviewCycles: 0,
17187
- issues: [truncatedOutput]
17188
- });
17189
- await persistState();
17190
- return;
17190
+ let retryPassed = false;
17191
+ const fullOutput = buildVerifyResult.output ?? "";
17192
+ const missingPkgMatch = fullOutput.match(/Cannot find (?:module|package) ['"]([^'"]+)['"]/) ?? fullOutput.match(/ERR_MODULE_NOT_FOUND[^]*?['"]([^'"]+)['"]/);
17193
+ if (missingPkgMatch && buildVerifyResult.status !== "timeout") {
17194
+ const missingPkg = missingPkgMatch[1].replace(/^(@[^/]+\/[^/]+)\/.*$/, "$1").replace(/^([^@][^/]*)\/.*$/, "$1");
17195
+ const resolvedRoot = projectRoot ?? process.cwd();
17196
+ logger$27.warn({
17197
+ storyKey,
17198
+ missingPkg
17199
+ }, "Build-fix retry: detected missing npm package attempting npm install");
17200
+ try {
17201
+ execSync(`npm install ${missingPkg}`, {
17202
+ cwd: resolvedRoot,
17203
+ timeout: 6e4,
17204
+ encoding: "utf-8",
17205
+ stdio: "pipe"
17206
+ });
17207
+ logger$27.warn({
17208
+ storyKey,
17209
+ missingPkg
17210
+ }, "Build-fix retry: npm install succeeded — retrying build verification");
17211
+ const retryResult = runBuildVerification({
17212
+ verifyCommand: pack.manifest.verifyCommand,
17213
+ verifyTimeoutMs: pack.manifest.verifyTimeoutMs,
17214
+ projectRoot: resolvedRoot
17215
+ });
17216
+ if (retryResult.status === "passed") {
17217
+ retryPassed = true;
17218
+ eventBus.emit("story:build-verification-passed", { storyKey });
17219
+ logger$27.warn({
17220
+ storyKey,
17221
+ missingPkg
17222
+ }, "Build-fix retry: build verification passed after installing missing package");
17223
+ } else logger$27.warn({
17224
+ storyKey,
17225
+ missingPkg,
17226
+ retryStatus: retryResult.status
17227
+ }, "Build-fix retry: build still fails after installing missing package — escalating");
17228
+ } catch (installErr) {
17229
+ const installMsg = installErr instanceof Error ? installErr.message : String(installErr);
17230
+ logger$27.warn({
17231
+ storyKey,
17232
+ missingPkg,
17233
+ error: installMsg
17234
+ }, "Build-fix retry: npm install failed — escalating");
17235
+ }
17236
+ }
17237
+ if (!retryPassed) {
17238
+ eventBus.emit("story:build-verification-failed", {
17239
+ storyKey,
17240
+ exitCode: buildVerifyResult.exitCode ?? 1,
17241
+ output: truncatedOutput
17242
+ });
17243
+ logger$27.warn({
17244
+ storyKey,
17245
+ reason,
17246
+ exitCode: buildVerifyResult.exitCode
17247
+ }, "Build verification failed — escalating story");
17248
+ updateStory(storyKey, {
17249
+ phase: "ESCALATED",
17250
+ error: reason,
17251
+ completedAt: new Date().toISOString()
17252
+ });
17253
+ await writeStoryMetricsBestEffort(storyKey, "escalated", 0);
17254
+ await emitEscalation({
17255
+ storyKey,
17256
+ lastVerdict: reason,
17257
+ reviewCycles: 0,
17258
+ issues: [truncatedOutput]
17259
+ });
17260
+ await persistState();
17261
+ return;
17262
+ }
17191
17263
  }
17192
17264
  }
17193
17265
  try {
@@ -18069,6 +18141,11 @@ function createImplementationOrchestrator(deps) {
18069
18141
  batchCount: batches.length,
18070
18142
  maxConcurrency: config.maxConcurrency
18071
18143
  }, "Orchestrator starting");
18144
+ logger$27.info({
18145
+ storyCount: storyKeys.length,
18146
+ conflictGroups: batches.length,
18147
+ maxConcurrency: config.maxConcurrency
18148
+ }, `Story dispatch plan: ${storyKeys.length} stories in ${batches.length} conflict groups (max concurrency: ${config.maxConcurrency})`);
18072
18149
  if (config.skipPreflight !== true) {
18073
18150
  const preflightStart = Date.now();
18074
18151
  const preFlightResult = runBuildVerification({
@@ -23182,6 +23259,19 @@ async function runRunAction(options) {
23182
23259
  });
23183
23260
  }
23184
23261
  const ingestionServer = telemetryEnabled ? new IngestionServer({ port: telemetryPort }) : void 0;
23262
+ if (ingestionServer !== void 0) {
23263
+ process.on("exit", () => {
23264
+ ingestionServer.stop();
23265
+ });
23266
+ process.on("SIGINT", () => {
23267
+ ingestionServer.stop();
23268
+ process.exit(130);
23269
+ });
23270
+ process.on("SIGTERM", () => {
23271
+ ingestionServer.stop();
23272
+ process.exit(143);
23273
+ });
23274
+ }
23185
23275
  if (telemetryPersistence !== void 0) {
23186
23276
  const routingTelemetry = new RoutingTelemetry(telemetryPersistence, logger);
23187
23277
  eventBus.on("routing:model-selected", (payload) => {
@@ -23542,6 +23632,19 @@ async function runFullPipeline(options) {
23542
23632
  }
23543
23633
  } else if (currentPhase === "implementation") {
23544
23634
  const fpIngestionServer = fullTelemetryEnabled ? new IngestionServer({ port: fullTelemetryPort ?? 4318 }) : void 0;
23635
+ if (fpIngestionServer !== void 0) {
23636
+ process.on("exit", () => {
23637
+ fpIngestionServer.stop();
23638
+ });
23639
+ process.on("SIGINT", () => {
23640
+ fpIngestionServer.stop();
23641
+ process.exit(130);
23642
+ });
23643
+ process.on("SIGTERM", () => {
23644
+ fpIngestionServer.stop();
23645
+ process.exit(143);
23646
+ });
23647
+ }
23545
23648
  const fpTelemetryPersistence = fullTelemetryEnabled ? new AdapterTelemetryPersistence(adapter) : void 0;
23546
23649
  const orchestrator = createImplementationOrchestrator({
23547
23650
  db: adapter,
@@ -23705,4 +23808,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
23705
23808
 
23706
23809
  //#endregion
23707
23810
  export { AdapterTelemetryPersistence, AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, VALID_PHASES, WorkGraphRepository, buildPipelineStatusOutput, checkDoltInstalled, createConfigSystem, createContextCompiler, createDatabaseAdapter, createDispatcher, createDoltClient, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStateStore, createStopAfterGate, createTelemetryAdvisor, detectCycles, findPackageRoot, formatOutput, formatPhaseCompletionSummary, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, initSchema, initializeDolt, isSyncAdapter, parseDbTimestampAsUtc, registerHealthCommand, registerRunCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, resolveMainRepoRoot, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
23708
- //# sourceMappingURL=run-BiREqhp_.js.map
23811
+ //# sourceMappingURL=run-Dmq9AYGt.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",