substrate-ai 0.19.43 → 0.19.45

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
@@ -4,7 +4,7 @@ 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, 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-sNh9XQ6V.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-kiI4y78c.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-BekA_Ns3.js";
8
8
  import "../errors-RupuC-ES.js";
9
9
  import "../routing-CcBOCuC9.js";
10
10
  import "../decisions-C0pz9Clx.js";
@@ -4833,7 +4833,7 @@ async function runSupervisorAction(options, deps = {}) {
4833
4833
  await initSchema(expAdapter);
4834
4834
  const { runRunAction: runPipeline } = await import(
4835
4835
  /* @vite-ignore */
4836
- "../run-BzRTI2mg.js"
4836
+ "../run-D4Ivv2xD.js"
4837
4837
  );
4838
4838
  const runStoryFn = async (opts) => {
4839
4839
  const exitCode = await runPipeline({
@@ -4709,7 +4709,7 @@ const DEFAULT_TIMEOUTS = {
4709
4709
  "create-story": 6e5,
4710
4710
  "dev-story": 18e5,
4711
4711
  "code-review": 9e5,
4712
- "minor-fixes": 3e5,
4712
+ "minor-fixes": 6e5,
4713
4713
  "major-rework": 9e5,
4714
4714
  "readiness-check": 6e5,
4715
4715
  "elicitation": 9e5,
@@ -18478,16 +18478,129 @@ async function loadEscalationDiagnoses(adapter, runId) {
18478
18478
  }
18479
18479
  return results;
18480
18480
  }
18481
+ async function buildRunReportFromManifest(runId, runsDir, adapter, opts) {
18482
+ try {
18483
+ const manifest = RunManifest.open(runId, runsDir);
18484
+ const data = await manifest.read();
18485
+ if (!data?.per_story_state || Object.keys(data.per_story_state).length === 0) {
18486
+ logger$2.warn({ runId }, "RunManifest has no per_story_state — cannot build RunReport");
18487
+ return null;
18488
+ }
18489
+ const MANIFEST_RESULT_MAP = {
18490
+ "complete": "SHIP_IT",
18491
+ "escalated": "ESCALATED",
18492
+ "failed": "FAILED",
18493
+ "verification-failed": "FAILED",
18494
+ "gated": "FAILED"
18495
+ };
18496
+ const stories = [];
18497
+ let totalInputTokens = 0;
18498
+ let totalOutputTokens = 0;
18499
+ let totalCostUsd = 0;
18500
+ let totalReviewCycles = 0;
18501
+ let totalDispatches = 0;
18502
+ let storiesSucceeded = 0;
18503
+ let storiesFailed = 0;
18504
+ let storiesEscalated = 0;
18505
+ const storyKeys = Object.keys(data.per_story_state);
18506
+ const escalationDiagnoses = await loadEscalationDiagnoses(adapter, runId);
18507
+ for (const [storyKey, state] of Object.entries(data.per_story_state)) {
18508
+ const result = MANIFEST_RESULT_MAP[state.status] ?? state.status.toUpperCase();
18509
+ let wallClockSeconds$1 = 0;
18510
+ if (state.started_at && state.completed_at) wallClockSeconds$1 = Math.round((new Date(state.completed_at).getTime() - new Date(state.started_at).getTime()) / 1e3);
18511
+ const costUsd = state.cost_usd ?? 0;
18512
+ const reviewCycles = state.review_cycles ?? 0;
18513
+ const dispatches = state.dispatches ?? 0;
18514
+ totalCostUsd += costUsd;
18515
+ totalReviewCycles += reviewCycles;
18516
+ totalDispatches += dispatches;
18517
+ if (result === "SHIP_IT" || result === "LGTM_WITH_NOTES" || result === "NEEDS_MINOR_FIXES") storiesSucceeded++;
18518
+ else if (result === "ESCALATED") storiesEscalated++;
18519
+ else storiesFailed++;
18520
+ const vr = state.verification_result ? {
18521
+ status: state.verification_result.status ?? "pass",
18522
+ checks: (state.verification_result.checks ?? []).map((c) => ({
18523
+ checkName: c.checkName,
18524
+ status: c.status,
18525
+ ...c.details !== void 0 && { details: c.details },
18526
+ ...c.duration_ms !== void 0 && { durationMs: c.duration_ms }
18527
+ }))
18528
+ } : void 0;
18529
+ const escalation = escalationDiagnoses[storyKey];
18530
+ stories.push({
18531
+ storyKey,
18532
+ result,
18533
+ wallClockSeconds: wallClockSeconds$1,
18534
+ ...state.started_at && { startedAt: state.started_at },
18535
+ ...state.completed_at && { completedAt: state.completed_at },
18536
+ inputTokens: 0,
18537
+ outputTokens: 0,
18538
+ costUsd,
18539
+ reviewCycles,
18540
+ dispatches,
18541
+ ...escalation !== void 0 && {
18542
+ escalationReason: escalation.reason,
18543
+ ...escalation.issues.length > 0 && { escalationIssues: escalation.issues }
18544
+ },
18545
+ ...vr !== void 0 && {
18546
+ verificationStatus: vr.status,
18547
+ verificationChecks: vr.checks
18548
+ }
18549
+ });
18550
+ }
18551
+ const escalationFindings = Object.values(escalationDiagnoses).map((d) => d.finding);
18552
+ let wallClockSeconds = 0;
18553
+ if (data.created_at && data.updated_at) wallClockSeconds = Math.round((new Date(data.updated_at).getTime() - new Date(data.created_at).getTime()) / 1e3);
18554
+ const rawStatus = data.run_status ?? "completed";
18555
+ const status = rawStatus === "completed" ? "completed" : rawStatus === "failed" ? "failed" : "partial";
18556
+ const projectId = opts.projectId ?? (opts.projectRoot ? basename$1(opts.projectRoot) : "unknown");
18557
+ logger$2.info({
18558
+ runId,
18559
+ storyCount: stories.length
18560
+ }, "Built RunReport from manifest fallback");
18561
+ return {
18562
+ runId,
18563
+ projectId,
18564
+ substrateVersion: opts.substrateVersion ?? getSubstrateVersion(),
18565
+ timestamp: data.updated_at ?? new Date().toISOString(),
18566
+ ...data.created_at && { startedAt: data.created_at },
18567
+ ...data.updated_at && { completedAt: data.updated_at },
18568
+ status,
18569
+ wallClockSeconds,
18570
+ totalInputTokens,
18571
+ totalOutputTokens,
18572
+ totalCostUsd,
18573
+ storiesAttempted: stories.length,
18574
+ storiesSucceeded,
18575
+ storiesFailed,
18576
+ storiesEscalated,
18577
+ totalReviewCycles,
18578
+ totalDispatches,
18579
+ restarts: data.restart_count ?? 0,
18580
+ stories,
18581
+ ...escalationFindings.length > 0 && { escalationFindings },
18582
+ agentBackend: opts.agentBackend ?? "claude-code",
18583
+ engineType: opts.engineType ?? "linear",
18584
+ concurrency: opts.concurrency ?? 3
18585
+ };
18586
+ } catch (err) {
18587
+ logger$2.warn({
18588
+ runId,
18589
+ err
18590
+ }, "Failed to build RunReport from manifest fallback");
18591
+ return null;
18592
+ }
18593
+ }
18481
18594
  async function buildRunReport(adapter, runId, opts) {
18482
18595
  const runMetrics = await getRunMetrics(adapter, runId);
18596
+ const storyMetrics = runMetrics ? await getStoryMetricsForRun(adapter, runId) : [];
18597
+ const dbDir = opts.projectRoot ? join$1(opts.projectRoot, ".substrate") : ".substrate";
18598
+ const runsDir = join$1(dbDir, "runs");
18483
18599
  if (!runMetrics) {
18484
- logger$2.warn({ runId }, "No run_metrics foundcannot build RunReport");
18485
- return null;
18600
+ logger$2.warn({ runId }, "No run_metrics in Dolt falling back to RunManifest");
18601
+ return buildRunReportFromManifest(runId, runsDir, adapter, opts);
18486
18602
  }
18487
- const storyMetrics = await getStoryMetricsForRun(adapter, runId);
18488
18603
  const storyKeys = storyMetrics.map((s$1) => s$1.story_key);
18489
- const dbDir = opts.projectRoot ? join$1(opts.projectRoot, ".substrate") : ".substrate";
18490
- const runsDir = join$1(dbDir, "runs");
18491
18604
  const verificationResults = await loadVerificationResults(runId, runsDir);
18492
18605
  const efficiencyScores = await loadEfficiencyScores(adapter, storyKeys);
18493
18606
  const contractVerification = await loadContractVerification(adapter, runId);
@@ -18539,11 +18652,13 @@ async function buildRunReport(adapter, runId, opts) {
18539
18652
  phaseDurations = JSON.parse(s$1.phase_durations_json);
18540
18653
  } catch {}
18541
18654
  const vr = verificationResults[s$1.story_key];
18542
- const qualityScore = efficiencyScores[s$1.story_key];
18655
+ const rawQualityScore = efficiencyScores[s$1.story_key];
18543
18656
  const escalation = escalationDiagnoses[s$1.story_key];
18657
+ const normalizedStoryResult = normalizeResult(s$1.result);
18658
+ const qualityScore = rawQualityScore !== void 0 ? normalizedStoryResult === "ESCALATED" || normalizedStoryResult === "FAILED" ? Math.min(rawQualityScore, 40) : rawQualityScore : void 0;
18544
18659
  return {
18545
18660
  storyKey: s$1.story_key,
18546
- result: normalizeResult(s$1.result),
18661
+ result: normalizedStoryResult,
18547
18662
  wallClockSeconds: s$1.wall_clock_seconds,
18548
18663
  ...s$1.started_at && { startedAt: s$1.started_at },
18549
18664
  ...s$1.completed_at && { completedAt: s$1.completed_at },
@@ -42794,4 +42909,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
42794
42909
 
42795
42910
  //#endregion
42796
42911
  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, wireNdjsonEmitter };
42797
- //# sourceMappingURL=run-kiI4y78c.js.map
42912
+ //# sourceMappingURL=run-BekA_Ns3.js.map
@@ -2,7 +2,7 @@ import "./health-BbsWlD8o.js";
2
2
  import "./logger-KeHncl-f.js";
3
3
  import "./helpers-CElYrONe.js";
4
4
  import "./dist-sNh9XQ6V.js";
5
- import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction, wireNdjsonEmitter } from "./run-kiI4y78c.js";
5
+ import { normalizeGraphSummaryToStatus, registerRunCommand, resolveMaxReviewCycles, runRunAction, wireNdjsonEmitter } from "./run-BekA_Ns3.js";
6
6
  import "./routing-CcBOCuC9.js";
7
7
  import "./decisions-C0pz9Clx.js";
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.19.43",
3
+ "version": "0.19.45",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",