substrate-ai 0.20.154 → 0.20.156

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,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { FileKvStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, buildPipelineStatusOutput, createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion } from "../health-BmBd4zyE.js";
2
+ import { FileKvStore, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, buildPipelineStatusOutput, createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion } from "../health-CoJWnndU.js";
3
3
  import { createLogger } from "../logger-KeHncl-f.js";
4
4
  import { createEventBus } from "../helpers-CElYrONe.js";
5
5
  import { AdapterRegistry, BudgetConfigSchema, CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, ConfigError, CostTrackerConfigSchema, DEFAULT_CONFIG, DoltClient, DoltNotInstalled, GlobalSettingsSchema, InMemoryDatabaseAdapter, IngestionServer, MonitorDatabaseImpl, OPERATIONAL_FINDING, PartialGlobalSettingsSchema, PartialProviderConfigSchema, ProvidersSchema, RoutingRecommender, STORY_METRICS, TelemetryConfigSchema, addTokenUsage, aggregateTokenUsageForRun, checkDoltInstalled, compareRunMetrics, createAmendmentRun, createConfigSystem, createDecision, createGitWorktreeManager, createPipelineRun, createStderrLogger, getActiveDecisions, getAllCostEntriesFiltered, getBaselineRunMetrics, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestCompletedRun, getLatestRun, getPipelineRunById, getPlanningCostTotal, getRetryableEscalations, getRunMetrics, getRunningPipelineRuns, getSessionCostSummary, getSessionCostSummaryFiltered, getStoryMetricsForRun, getTokenUsageSummary, incrementRunRestarts, initSchema, initWorkGraphSchema, initializeDolt, listRunMetrics, loadParentRunDecisions, supersedeDecision, swallowDebug, tagRunAsBaseline, updatePipelineRun } from "../dist-Dl3vBZil.js";
6
6
  import "../adapter-registry-DXLMTmfD.js";
7
- import { RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-Dan3I0ea.js";
8
- import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-CNzfjk92.js";
7
+ import { RunManifest, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, parseRuntimeProbes, readCurrentRunId, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck } from "../manifest-read-DFpujDzP.js";
8
+ import { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR, GitClient, GrammarLoader, Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runSolutioningPhase, unescape, validateStopAfterFromConflict } from "../run-hO_G3pBQ.js";
9
9
  import "../errors-Dyyei2ah.js";
10
10
  import "../routing-DFxoKHDt.js";
11
11
  import { WorkGraphRepository } from "../work-graph-repository-DZyJv5pV.js";
12
12
  import "../decisions-CzSIEeGP.js";
13
13
  import "../decision-router-BAPpON_C.js";
14
- import "../interactive-prompt-Cj0Od5XZ.js";
14
+ import "../interactive-prompt-BuoVYIgS.js";
15
15
  import "../recovery-engine-BKGBeBnW.js";
16
16
  import "../version-manager-impl-qFBiO4Eh.js";
17
17
  import { registerUpgradeCommand } from "../upgrade-DGqUA_5f.js";
@@ -7126,7 +7126,7 @@ async function runStatusAction(options) {
7126
7126
  logger$15.debug({ err }, "Work graph query failed, continuing without work graph data");
7127
7127
  }
7128
7128
  if (run === void 0) {
7129
- const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-BwXD8UBv.js");
7129
+ const { inspectProcessTree: inspectProcessTree$1 } = await import("../health-D_taFoP2.js");
7130
7130
  const substrateDirPath = join(projectRoot, ".substrate");
7131
7131
  const processInfo = inspectProcessTree$1({
7132
7132
  projectRoot,
@@ -8655,7 +8655,7 @@ async function runSupervisorAction(options, deps = {}) {
8655
8655
  await initSchema(expAdapter);
8656
8656
  const { runRunAction: runPipeline } = await import(
8657
8657
  /* @vite-ignore */
8658
- "../run-6x92Moln.js"
8658
+ "../run-DJ7P6y4z.js"
8659
8659
  );
8660
8660
  const runStoryFn = async (opts) => {
8661
8661
  const exitCode = await runPipeline({
@@ -1,6 +1,6 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
2
  import { DoltClient, DoltQueryError, createDatabaseAdapter$1 as createDatabaseAdapter, getLatestRun, getPipelineRunById, initSchema } from "./dist-Dl3vBZil.js";
3
- import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-Dan3I0ea.js";
3
+ import { resolveMainRepoRoot, resolveRunManifest } from "./manifest-read-DFpujDzP.js";
4
4
  import { createRequire } from "module";
5
5
  import { dirname, join } from "path";
6
6
  import { existsSync, readFileSync } from "node:fs";
@@ -1000,4 +1000,4 @@ function registerHealthCommand(program, _version = "0.0.0", projectRoot = proces
1000
1000
 
1001
1001
  //#endregion
1002
1002
  export { BMAD_BASELINE_TOKENS_FULL, DEFAULT_STALL_THRESHOLD_SECONDS, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, SUBSTRATE_OWNED_SETTINGS_KEYS, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter$1 as createDatabaseAdapter, createDoltOperatorReader, findPackageRoot, formatOutput, formatPipelineStatusHuman, formatPipelineSummary, formatTokenTelemetry, getAllDescendantPids, getAutoHealthData, getSubstrateDefaultSettings, inspectProcessTree, isOrchestratorProcessLine, parseDbTimestampAsUtc, registerHealthCommand, resolveBmadMethodSrcPath, resolveBmadMethodVersion, runHealthAction, validateStoryKey };
1003
- //# sourceMappingURL=health-BmBd4zyE.js.map
1003
+ //# sourceMappingURL=health-CoJWnndU.js.map
@@ -1,7 +1,7 @@
1
- import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-BmBd4zyE.js";
1
+ import { DEFAULT_STALL_THRESHOLD_SECONDS, getAllDescendantPids, getAutoHealthData, inspectProcessTree, isOrchestratorProcessLine, registerHealthCommand, runHealthAction } from "./health-CoJWnndU.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./dist-Dl3vBZil.js";
4
- import "./manifest-read-Dan3I0ea.js";
4
+ import "./manifest-read-DFpujDzP.js";
5
5
  import "./work-graph-repository-DZyJv5pV.js";
6
6
  import "./decisions-CzSIEeGP.js";
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "./logger-KeHncl-f.js";
2
- import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-Dan3I0ea.js";
2
+ import { readCurrentRunId, resolveMainRepoRoot } from "./manifest-read-DFpujDzP.js";
3
3
  import { join } from "node:path";
4
4
  import { mkdir, readFile, writeFile } from "node:fs/promises";
5
5
  import * as readline from "node:readline";
@@ -180,4 +180,4 @@ async function runInteractivePrompt(decisionContext) {
180
180
 
181
181
  //#endregion
182
182
  export { runInteractivePrompt };
183
- //# sourceMappingURL=interactive-prompt-Cj0Od5XZ.js.map
183
+ //# sourceMappingURL=interactive-prompt-BuoVYIgS.js.map
@@ -2244,10 +2244,10 @@ function detectTestCommand(workingDir) {
2244
2244
  * do not mask their own exit code, so this is a tampering signal, not a style
2245
2245
  * nit. Note: cannot catch arbitrary in-language masking (e.g. `python -c
2246
2246
  * "...sys.exit(0)"`) — the trusted-profile read is the primary defense; this is
2247
- * belt-and-braces for the shell-wrapper class and the --no-worktree path.
2247
+ * belt-and-braces for common shell-wrapper masks; NOT a complete parser.
2248
2248
  */
2249
2249
  function detectsExitCodeLaundering(command) {
2250
- return /(\|\||;)\s*(true|:|exit\s+0)(\s|;|$)/.test(command);
2250
+ return /(\|\||;)\s*(true|:|exit\s+0|return\s+0|exec\s+true)(?!\w)/.test(command) || /\{\s*(exit\s+0|true|:)\s*;?\s*\}/.test(command);
2251
2251
  }
2252
2252
  var TestSuiteCheck = class {
2253
2253
  name = "test-suite";
@@ -2415,11 +2415,35 @@ const LANGUAGE_EXTENSIONS = {
2415
2415
  ".mjs",
2416
2416
  ".cjs"
2417
2417
  ],
2418
- python: [".py"],
2418
+ python: [".py", ".pyi"],
2419
2419
  go: [".go"],
2420
2420
  rust: [".rs"],
2421
2421
  java: [".java"],
2422
- kotlin: [".kt", ".kts"]
2422
+ kotlin: [".kt", ".kts"],
2423
+ ruby: [".rb", ".rake"],
2424
+ php: [".php"],
2425
+ csharp: [".cs"],
2426
+ cpp: [
2427
+ ".cpp",
2428
+ ".cc",
2429
+ ".cxx",
2430
+ ".hpp",
2431
+ ".hh",
2432
+ ".h",
2433
+ ".hxx"
2434
+ ],
2435
+ c: [".c", ".h"],
2436
+ swift: [".swift"],
2437
+ scala: [".scala", ".sc"],
2438
+ elixir: [".ex", ".exs"],
2439
+ clojure: [
2440
+ ".clj",
2441
+ ".cljs",
2442
+ ".cljc"
2443
+ ],
2444
+ perl: [".pl", ".pm"],
2445
+ lua: [".lua"],
2446
+ dart: [".dart"]
2423
2447
  };
2424
2448
  /** JS-family toolchain manifests whose appearance flips build detection. */
2425
2449
  const JS_TOOLCHAIN_MANIFESTS = [
@@ -2436,7 +2460,18 @@ const JS_TOOLCHAIN_MANIFESTS = [
2436
2460
  const ALWAYS_DENY_SEGMENTS = [
2437
2461
  "node_modules",
2438
2462
  ".venv",
2439
- "__pycache__"
2463
+ "venv",
2464
+ "__pycache__",
2465
+ ".gradle",
2466
+ ".tox",
2467
+ ".mypy_cache",
2468
+ ".pytest_cache",
2469
+ ".ruff_cache",
2470
+ ".next",
2471
+ ".nuxt",
2472
+ ".svelte-kit",
2473
+ "coverage",
2474
+ ".turbo"
2440
2475
  ];
2441
2476
  /**
2442
2477
  * Collect every `language: <x>` declaration in the profile (single-project
@@ -2477,7 +2512,21 @@ function classifyContamination(changedFiles, allowedLanguages) {
2477
2512
  droppings.push(file);
2478
2513
  continue;
2479
2514
  }
2480
- if (!allowJs && segments.includes("dist")) {
2515
+ if (segments.some((seg) => seg.endsWith(".egg-info"))) {
2516
+ droppings.push(file);
2517
+ continue;
2518
+ }
2519
+ if (!allowJs && segments.some((seg) => seg === "dist" || seg === "build" || seg === "out")) {
2520
+ droppings.push(file);
2521
+ continue;
2522
+ }
2523
+ const allowGoVendor = allowedLanguages.includes("go");
2524
+ const allowJvmTarget = allowedLanguages.some((l) => l === "rust" || l === "java" || l === "kotlin" || l === "scala");
2525
+ if (!allowGoVendor && segments.includes("vendor")) {
2526
+ droppings.push(file);
2527
+ continue;
2528
+ }
2529
+ if (!allowJvmTarget && segments.includes("target")) {
2481
2530
  droppings.push(file);
2482
2531
  continue;
2483
2532
  }
@@ -2568,6 +2617,8 @@ function isTestPath(file) {
2568
2617
  if (/(^|\/)(__tests__|tests?)\//.test(norm)) return true;
2569
2618
  if (/\.(test|spec)\.[a-z]+$/.test(base)) return true;
2570
2619
  if (/^test_.*\.py$/.test(base) || /_test\.(py|go)$/.test(base)) return true;
2620
+ if (base === "conftest.py") return true;
2621
+ if (/(^|\/)(fixtures|factories|testsupport|test-support|test_support|__mocks__|__fixtures__)\//.test(norm)) return true;
2571
2622
  return false;
2572
2623
  }
2573
2624
  var TestMutationCheck = class {
@@ -6331,4 +6382,4 @@ async function resolveRunManifest(dbRoot, runId) {
6331
6382
 
6332
6383
  //#endregion
6333
6384
  export { FindingsInjector, RunManifest, RuntimeProbeListSchema, SupervisorLock, ZERO_FINDINGS_BY_AUTHOR, ZERO_FINDING_COUNTS, ZERO_PROBE_AUTHOR_METRICS, aggregateProbeAuthorMetrics, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, parseRuntimeProbes, readCurrentRunId, renderFindings, resolveGraphPath, resolveMainRepoRoot, resolveRunManifest, rollupFindingCounts, rollupFindingsByAuthor, rollupProbeAuthorByClass, rollupProbeAuthorMetrics, runAcTraceabilityCheck, runStaleVerificationRecovery };
6334
- //# sourceMappingURL=manifest-read-Dan3I0ea.js.map
6385
+ //# sourceMappingURL=manifest-read-DFpujDzP.js.map
@@ -1,6 +1,6 @@
1
1
  import "../../logger-KeHncl-f.js";
2
2
  import "../../dist-Dl3vBZil.js";
3
- import "../../manifest-read-Dan3I0ea.js";
4
- import { runInteractivePrompt } from "../../interactive-prompt-Cj0Od5XZ.js";
3
+ import "../../manifest-read-DFpujDzP.js";
4
+ import { runInteractivePrompt } from "../../interactive-prompt-BuoVYIgS.js";
5
5
 
6
6
  export { runInteractivePrompt };
@@ -1,14 +1,14 @@
1
- import "./health-BmBd4zyE.js";
1
+ import "./health-CoJWnndU.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
4
  import "./dist-Dl3vBZil.js";
5
- import "./manifest-read-Dan3I0ea.js";
6
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-CNzfjk92.js";
5
+ import "./manifest-read-DFpujDzP.js";
6
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, runRunAction, wireNdjsonEmitter } from "./run-hO_G3pBQ.js";
7
7
  import "./routing-DFxoKHDt.js";
8
8
  import "./work-graph-repository-DZyJv5pV.js";
9
9
  import "./decisions-CzSIEeGP.js";
10
10
  import "./decision-router-BAPpON_C.js";
11
- import "./interactive-prompt-Cj0Od5XZ.js";
11
+ import "./interactive-prompt-BuoVYIgS.js";
12
12
  import "./recovery-engine-BKGBeBnW.js";
13
13
 
14
14
  export { runRunAction };
@@ -1,11 +1,11 @@
1
- import { BMAD_BASELINE_TOKENS_FULL, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, validateStoryKey } from "./health-BmBd4zyE.js";
1
+ import { BMAD_BASELINE_TOKENS_FULL, FileKvStore, STOP_AFTER_VALID_PHASES, STORY_KEY_PATTERN, VALID_PHASES, __commonJS, __require, __toESM, buildPipelineStatusOutput, createDatabaseAdapter, formatOutput, formatPipelineSummary, formatTokenTelemetry, inspectProcessTree, parseDbTimestampAsUtc, validateStoryKey } from "./health-CoJWnndU.js";
2
2
  import { createLogger } from "./logger-KeHncl-f.js";
3
3
  import { TypedEventBusImpl, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-CElYrONe.js";
4
4
  import { ADVISORY_NOTES, BRANCH_PREFIX, CLAUDE_AUTH_FAILURE_HINT, CODEX_SANDBOX_BLOCK_HINT, 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, classifyVersionGap, createConfigSystem, createDatabaseAdapter$1, createDecision, createGitWorktreeManager, createPipelineRun, createRequirement, detectClaudeAuthFailure, detectCodexSandboxBlock, detectInterfaceChanges, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunMetrics, getRunningPipelineRuns, getStoryMetricsForRun, getTokenUsageSummary, initSchema, listRequirements, loadModelRoutingConfig, registerArtifact, swallowDebug, updatePipelineRun, updatePipelineRunConfig, upsertDecision, writeRunMetrics, writeStoryMetrics } from "./dist-Dl3vBZil.js";
5
- import { FindingsInjector, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, parseRuntimeProbes, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery } from "./manifest-read-Dan3I0ea.js";
5
+ import { FindingsInjector, RunManifest, RuntimeProbeListSchema, applyConfigToGraph, createDefaultVerificationPipeline, createGraphOrchestrator, createSdlcCodeReviewHandler, createSdlcCreateStoryHandler, createSdlcDevStoryHandler, createSdlcPhaseHandler, detectsEventDrivenAC, detectsStateIntegratingAC, extractTargetFilesFromStoryContent, parseRuntimeProbes, renderFindings, resolveGraphPath, resolveMainRepoRoot, runAcTraceabilityCheck, runStaleVerificationRecovery } from "./manifest-read-DFpujDzP.js";
6
6
  import { WorkGraphRepository, detectCycles } from "./work-graph-repository-DZyJv5pV.js";
7
7
  import { deriveExitCode, routeDecision } from "./decision-router-BAPpON_C.js";
8
- import { runInteractivePrompt } from "./interactive-prompt-Cj0Od5XZ.js";
8
+ import { runInteractivePrompt } from "./interactive-prompt-BuoVYIgS.js";
9
9
  import { runRecoveryEngine } from "./recovery-engine-BKGBeBnW.js";
10
10
  import { basename, dirname, extname, join } from "path";
11
11
  import { access, readFile, readdir, stat } from "fs/promises";
@@ -5340,7 +5340,7 @@ function checkGitModifiedTrackedFiles(workingDir = process.cwd(), baselineSha) {
5340
5340
  return [];
5341
5341
  }
5342
5342
  const diffs = ["git diff --name-only HEAD", "git diff --cached --name-only"];
5343
- if (baselineSha !== void 0 && baselineSha.length > 0) diffs.push(`git diff --name-only --diff-filter=MD ${baselineSha}..HEAD`);
5343
+ if (baselineSha !== void 0 && baselineSha.length > 0) diffs.push(`git diff --name-only --diff-filter=MDR ${baselineSha}..HEAD`);
5344
5344
  for (const args of diffs) try {
5345
5345
  execSync(args, {
5346
5346
  cwd: workingDir,
@@ -6901,8 +6901,12 @@ async function commitDevStoryOutput(storyKey, storyTitle, filesModified, working
6901
6901
  const COMMIT_DENY_SEGMENTS = [
6902
6902
  "node_modules",
6903
6903
  ".venv",
6904
+ "venv",
6904
6905
  "__pycache__",
6905
- ".substrate-worktrees"
6906
+ ".substrate-worktrees",
6907
+ ".mypy_cache",
6908
+ ".pytest_cache",
6909
+ ".ruff_cache"
6906
6910
  ];
6907
6911
  const insideWorktree = [];
6908
6912
  for (const p of filesModified) {
@@ -6931,7 +6935,7 @@ async function commitDevStoryOutput(storyKey, storyTitle, filesModified, working
6931
6935
  reason: "no-files-inside-worktree"
6932
6936
  };
6933
6937
  try {
6934
- execSync(`git add ${insideWorktree.map((p) => JSON.stringify(p)).join(" ")}`, {
6938
+ execFileSync("git", ["add", ...insideWorktree], {
6935
6939
  cwd: workingDir,
6936
6940
  stdio: [
6937
6941
  "ignore",
@@ -6970,7 +6974,11 @@ async function commitDevStoryOutput(storyKey, storyTitle, filesModified, working
6970
6974
  const title = storyTitle ?? "implementation";
6971
6975
  const message = `feat(story-${storyKey}): ${title}`;
6972
6976
  try {
6973
- execSync(`git commit -m ${JSON.stringify(message)}`, {
6977
+ execFileSync("git", [
6978
+ "commit",
6979
+ "-m",
6980
+ message
6981
+ ], {
6974
6982
  cwd: workingDir,
6975
6983
  stdio: [
6976
6984
  "ignore",
@@ -7074,7 +7082,12 @@ async function checkpointStoryWorktree(storyKey, reason, workingDir) {
7074
7082
  const cleanReason = (reason.split("\n")[0] ?? "checkpoint").split("").filter((ch) => ch.charCodeAt(0) >= 32).join("").slice(0, 100);
7075
7083
  const message = `wip(story-${storyKey}): ${cleanReason}`;
7076
7084
  try {
7077
- execSync(`git commit --no-verify -m ${JSON.stringify(message)}`, {
7085
+ execFileSync("git", [
7086
+ "commit",
7087
+ "--no-verify",
7088
+ "-m",
7089
+ message
7090
+ ], {
7078
7091
  cwd: workingDir,
7079
7092
  stdio: [
7080
7093
  "ignore",
@@ -14219,7 +14232,20 @@ function createImplementationOrchestrator(deps) {
14219
14232
  }
14220
14233
  if (effectiveProjectRoot !== void 0 && effectiveProjectRoot !== projectRoot) {
14221
14234
  const resolvedStoryFile = isAbsolute(createResult.story_file) ? createResult.story_file : resolve$1(effectiveProjectRoot, createResult.story_file);
14222
- const relToWorktree = relative(effectiveProjectRoot, resolvedStoryFile);
14235
+ const canonicalize = (p) => {
14236
+ let cur = p;
14237
+ for (let i = 0; i < 64; i++) try {
14238
+ return join$1(realpathSync(cur), relative(cur, p));
14239
+ } catch {
14240
+ const parent = dirname$1(cur);
14241
+ if (parent === cur) break;
14242
+ cur = parent;
14243
+ }
14244
+ return p;
14245
+ };
14246
+ const realWorktree = canonicalize(effectiveProjectRoot);
14247
+ const realStoryFile = canonicalize(resolvedStoryFile);
14248
+ const relToWorktree = relative(realWorktree, realStoryFile);
14223
14249
  const outsideWorktree = relToWorktree.startsWith("..") || isAbsolute(relToWorktree);
14224
14250
  if (outsideWorktree) {
14225
14251
  const errMsg = `create-story wrote its artifact OUTSIDE the story worktree: ${createResult.story_file} (resolved: ${resolvedStoryFile}) (worktree: ${effectiveProjectRoot}). The agent escaped its working directory — this is the parent/home-directory write-leak class (field finding #15). The stray file was NOT adopted; inspect and remove it.`;
@@ -15267,6 +15293,72 @@ function createImplementationOrchestrator(deps) {
15267
15293
  }
15268
15294
  if (devStoryWasSuccess && gitDiffFiles !== void 0 && gitDiffFiles.length > 0) {
15269
15295
  const implClassification = classifyImplementationDiff(gitDiffFiles);
15296
+ let implAddedLines;
15297
+ if (implClassification.hasImplementation && baselineHeadSha) {
15298
+ const numstatCwd = effectiveProjectRoot ?? process.cwd();
15299
+ try {
15300
+ execSync("git add -N -A", {
15301
+ cwd: numstatCwd,
15302
+ timeout: 5e3,
15303
+ stdio: [
15304
+ "ignore",
15305
+ "pipe",
15306
+ "pipe"
15307
+ ]
15308
+ });
15309
+ const numstat = execSync("git diff -w --numstat HEAD", {
15310
+ cwd: numstatCwd,
15311
+ encoding: "utf-8",
15312
+ timeout: 5e3,
15313
+ stdio: [
15314
+ "ignore",
15315
+ "pipe",
15316
+ "pipe"
15317
+ ]
15318
+ });
15319
+ try {
15320
+ execSync("git reset -q", {
15321
+ cwd: numstatCwd,
15322
+ timeout: 5e3,
15323
+ stdio: [
15324
+ "ignore",
15325
+ "pipe",
15326
+ "pipe"
15327
+ ]
15328
+ });
15329
+ } catch {}
15330
+ const isArtifactPath = (f$1) => {
15331
+ const n$1 = f$1.replace(/\\/g, "/").replace(/^\.\//, "");
15332
+ return n$1.startsWith("_bmad-output/") || n$1.startsWith(".substrate/");
15333
+ };
15334
+ const implRows = numstat.split("\n").map((line) => line.split(" ")).filter((cols) => cols.length === 3 && cols[0] !== "-" && !isArtifactPath(cols[2]));
15335
+ implAddedLines = implRows.length > 0 ? implRows.reduce((sum, cols) => sum + (Number.parseInt(cols[0], 10) || 0), 0) : void 0;
15336
+ } catch {
15337
+ implAddedLines = void 0;
15338
+ }
15339
+ }
15340
+ if (implClassification.hasImplementation && implAddedLines === 0) {
15341
+ logger$27.warn({
15342
+ storyKey,
15343
+ changed: gitDiffFiles.slice(0, 10)
15344
+ }, "dev-story reported success but its implementation files added zero non-whitespace lines (empty stub / whitespace-only / pure deletion) — escalating no-implementation");
15345
+ endPhase(storyKey, "dev-story", devStoryModel);
15346
+ updateStory(storyKey, {
15347
+ phase: "ESCALATED",
15348
+ error: "no-implementation",
15349
+ completedAt: new Date().toISOString()
15350
+ });
15351
+ await writeStoryMetricsBestEffort(storyKey, "escalated", 0);
15352
+ await emitEscalation({
15353
+ storyKey,
15354
+ lastVerdict: "no-implementation",
15355
+ reviewCycles: 0,
15356
+ issues: [`dev-story reported COMPLETE and touched non-artifact files, but added ZERO non-whitespace lines to any of them (${gitDiffFiles.slice(0, 10).join(", ")}) — the "implementation" is an empty stub, a whitespace-only edit, or a pure deletion.`],
15357
+ escalationReason: "no-implementation"
15358
+ });
15359
+ await persistState();
15360
+ return;
15361
+ }
15270
15362
  if (!implClassification.hasImplementation) {
15271
15363
  logger$27.warn({
15272
15364
  storyKey,
@@ -15756,7 +15848,7 @@ function createImplementationOrchestrator(deps) {
15756
15848
  outputTokenCount: devOutputTokenCount,
15757
15849
  sourceEpicContent,
15758
15850
  ...effectiveProjectRoot !== void 0 ? { changedFiles: recaptureChangedFiles(effectiveProjectRoot) } : {},
15759
- ...modifiedTrackedFiles !== void 0 ? { modifiedTrackedFiles } : {},
15851
+ ...effectiveProjectRoot !== void 0 ? { modifiedTrackedFiles: checkGitModifiedTrackedFiles(effectiveProjectRoot, baselineHeadSha) } : {},
15760
15852
  runId: config.pipelineRunId
15761
15853
  });
15762
15854
  const retryVerifSummary = await verificationPipeline.run(retryVerifContext, "A");
@@ -16194,7 +16286,12 @@ function createImplementationOrchestrator(deps) {
16194
16286
  if (finalizationMode === "branch" || finalizationMode === "pr") {
16195
16287
  let prUrl;
16196
16288
  if (finalizationMode === "pr") try {
16197
- execSync(`git push -u origin ${branchName}`, {
16289
+ execFileSync("git", [
16290
+ "push",
16291
+ "-u",
16292
+ "origin",
16293
+ branchName
16294
+ ], {
16198
16295
  cwd: projectRoot,
16199
16296
  stdio: [
16200
16297
  "ignore",
@@ -16204,7 +16301,16 @@ function createImplementationOrchestrator(deps) {
16204
16301
  timeout: 6e4
16205
16302
  });
16206
16303
  const shortSha = (storyDeliverableSha ?? "").slice(0, 10);
16207
- const ghOutput = execSync(`gh pr create --head ${branchName} --title ${JSON.stringify(`story ${storyKey}: ${_capturedStoryTitle ?? "implementation"}`)} --body ${JSON.stringify(`Substrate story ${storyKey} (commit ${shortSha}). Verified by the Tier-A pipeline; see the run manifest for the full verification record.`)}`, {
16304
+ const ghOutput = execFileSync("gh", [
16305
+ "pr",
16306
+ "create",
16307
+ "--head",
16308
+ branchName,
16309
+ "--title",
16310
+ `story ${storyKey}: ${_capturedStoryTitle ?? "implementation"}`,
16311
+ "--body",
16312
+ `Substrate story ${storyKey} (commit ${shortSha}). Verified by the Tier-A pipeline; see the run manifest for the full verification record.`
16313
+ ], {
16208
16314
  cwd: projectRoot,
16209
16315
  encoding: "utf-8",
16210
16316
  stdio: [
@@ -16546,6 +16652,26 @@ function createImplementationOrchestrator(deps) {
16546
16652
  continue;
16547
16653
  }
16548
16654
  if (isPhantomReview && timeoutRetried) {
16655
+ const phantomAuthSignature = detectClaudeAuthFailure(reviewResult.error ?? "");
16656
+ if (phantomAuthSignature !== null) {
16657
+ endPhase(storyKey, "code-review");
16658
+ updateStory(storyKey, {
16659
+ phase: "ESCALATED",
16660
+ error: "auth-failure",
16661
+ completedAt: new Date().toISOString()
16662
+ });
16663
+ await writeStoryMetricsBestEffort(storyKey, "escalated", reviewCycles + 1);
16664
+ await emitEscalation({
16665
+ storyKey,
16666
+ lastVerdict: "auth-failure",
16667
+ reviewCycles: reviewCycles + 1,
16668
+ issues: [reviewResult.error ?? "", CLAUDE_AUTH_FAILURE_HINT],
16669
+ escalationReason: "auth-failure"
16670
+ });
16671
+ await triggerAuthFailureHalt(storyKey, phantomAuthSignature);
16672
+ await persistState();
16673
+ return;
16674
+ }
16549
16675
  const isStoryFileMissing = (reviewResult.error ?? "").includes("story-file-missing");
16550
16676
  const escalationReason = isStoryFileMissing ? "story-file-missing" : "consecutive-review-timeouts";
16551
16677
  logger$27.warn({
@@ -16625,6 +16751,25 @@ function createImplementationOrchestrator(deps) {
16625
16751
  } catch (err) {
16626
16752
  const errMsg = err instanceof Error ? err.message : String(err);
16627
16753
  endPhase(storyKey, "code-review");
16754
+ const reviewAuthSignature = detectClaudeAuthFailure(errMsg);
16755
+ if (reviewAuthSignature !== null) {
16756
+ updateStory(storyKey, {
16757
+ phase: "ESCALATED",
16758
+ error: "auth-failure",
16759
+ completedAt: new Date().toISOString()
16760
+ });
16761
+ await writeStoryMetricsBestEffort(storyKey, "failed", reviewCycles);
16762
+ await emitEscalation({
16763
+ storyKey,
16764
+ lastVerdict: "auth-failure",
16765
+ reviewCycles,
16766
+ issues: [errMsg, CLAUDE_AUTH_FAILURE_HINT],
16767
+ escalationReason: "auth-failure"
16768
+ });
16769
+ await triggerAuthFailureHalt(storyKey, reviewAuthSignature);
16770
+ await persistState();
16771
+ return;
16772
+ }
16628
16773
  updateStory(storyKey, {
16629
16774
  phase: "ESCALATED",
16630
16775
  error: errMsg,
@@ -16850,6 +16995,10 @@ function createImplementationOrchestrator(deps) {
16850
16995
  storyKey
16851
16996
  });
16852
16997
  const fixResult = await handle.result;
16998
+ {
16999
+ const fixFiles = fixResult.parsed?.files_modified;
17000
+ if (Array.isArray(fixFiles)) devFilesModified = Array.from(new Set([...devFilesModified, ...fixFiles.filter((f$1) => typeof f$1 === "string")]));
17001
+ }
16853
17002
  eventBus.emit("orchestrator:story-phase-complete", {
16854
17003
  storyKey,
16855
17004
  phase: "IN_MINOR_FIX",
@@ -17057,6 +17206,10 @@ function createImplementationOrchestrator(deps) {
17057
17206
  });
17058
17207
  const fixResult = await handle.result;
17059
17208
  endPhase(storyKey, "fix");
17209
+ {
17210
+ const fixFiles = fixResult.parsed?.files_modified;
17211
+ if (Array.isArray(fixFiles)) devFilesModified = Array.from(new Set([...devFilesModified, ...fixFiles.filter((f$1) => typeof f$1 === "string")]));
17212
+ }
17060
17213
  eventBus.emit("orchestrator:story-phase-complete", {
17061
17214
  storyKey,
17062
17215
  phase: taskType === "minor-fixes" ? "IN_MINOR_FIX" : "IN_MAJOR_FIX",
@@ -47934,4 +48087,4 @@ function registerRunCommand(program, version = "0.0.0", projectRoot = process.cw
47934
48087
 
47935
48088
  //#endregion
47936
48089
  export { AdapterTelemetryPersistence, AppError, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, EpicIngester, GLOBSTAR$1 as GLOBSTAR, GitClient, GrammarLoader, Minimatch$1 as Minimatch, Minipass, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SymbolParser, createContextCompiler, createDispatcher, createEventEmitter, createImplementationOrchestrator, createPackLoader, createPhaseOrchestrator, createStopAfterGate, createTelemetryAdvisor, escape$1 as escape, formatPhaseCompletionSummary, getFactoryRunSummaries, getScenarioResultsForRun, getTwinRunsForRun, listGraphRuns, normalizeGraphSummaryToStatus, registerExportCommand, registerFactoryCommand, registerRunCommand, registerScenariosCommand, resolveMaxReviewCycles, resolveProbeAuthorStateIntegrating, resolveStoryKeys, runAnalysisPhase, runPlanningPhase, runProbeAuthor, runRunAction, runSolutioningPhase, unescape$1 as unescape, validateStopAfterFromConflict, wireNdjsonEmitter };
47937
- //# sourceMappingURL=run-CNzfjk92.js.map
48090
+ //# sourceMappingURL=run-hO_G3pBQ.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.20.154",
3
+ "version": "0.20.156",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",