substrate-ai 0.4.9 → 0.4.11

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 { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, 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-Dx7bxebF.js";
2
+ import { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, 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-B_08vO01.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
4
  import { AdapterRegistry } from "../adapter-registry-Cd-7lG5v.js";
5
5
  import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
@@ -2709,7 +2709,7 @@ async function runSupervisorAction(options, deps = {}) {
2709
2709
  const expDb = expDbWrapper.db;
2710
2710
  const { runRunAction: runPipeline } = await import(
2711
2711
  /* @vite-ignore */
2712
- "../run-c8_Yj6xH.js"
2712
+ "../run-DbCq_Ynr.js"
2713
2713
  );
2714
2714
  const runStoryFn = async (opts) => {
2715
2715
  const exitCode = await runPipeline({
@@ -12568,11 +12568,15 @@ var EfficiencyScorer = class {
12568
12568
  return sum / turns.length;
12569
12569
  }
12570
12570
  /**
12571
- * Average I/O ratio: inputTokens / max(outputTokens, 1) per turn.
12571
+ * Average I/O ratio: totalInput / max(outputTokens, 1) per turn.
12572
+ * Total input = inputTokens (fresh) + cacheReadTokens (cached).
12572
12573
  */
12573
12574
  _computeAvgIoRatio(turns) {
12574
12575
  if (turns.length === 0) return 0;
12575
- const sum = turns.reduce((acc, t) => acc + t.inputTokens / Math.max(t.outputTokens, 1), 0);
12576
+ const sum = turns.reduce((acc, t) => {
12577
+ const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
12578
+ return acc + totalInput / Math.max(t.outputTokens, 1);
12579
+ }, 0);
12576
12580
  return sum / turns.length;
12577
12581
  }
12578
12582
  /**
@@ -12590,7 +12594,10 @@ var EfficiencyScorer = class {
12590
12594
  const result = [];
12591
12595
  for (const [model, groupTurns] of groups) {
12592
12596
  const cacheHitRate = groupTurns.reduce((acc, t) => acc + t.cacheHitRate, 0) / groupTurns.length;
12593
- const avgIoRatio = groupTurns.reduce((acc, t) => acc + t.inputTokens / Math.max(t.outputTokens, 1), 0) / groupTurns.length;
12597
+ const avgIoRatio = groupTurns.reduce((acc, t) => {
12598
+ const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
12599
+ return acc + totalInput / Math.max(t.outputTokens, 1);
12600
+ }, 0) / groupTurns.length;
12594
12601
  const totalCostUsd = groupTurns.reduce((acc, t) => acc + t.costUsd, 0);
12595
12602
  const totalOutputTokens = groupTurns.reduce((acc, t) => acc + t.outputTokens, 0);
12596
12603
  const costPer1KOutputTokens = totalCostUsd / Math.max(totalOutputTokens, 1) * 1e3;
@@ -12637,7 +12644,10 @@ var EfficiencyScorer = class {
12637
12644
  }
12638
12645
  _computeIoRatioSubScoreForGroup(turns) {
12639
12646
  if (turns.length === 0) return 0;
12640
- const avg = turns.reduce((acc, t) => acc + t.inputTokens / Math.max(t.outputTokens, 1), 0) / turns.length;
12647
+ const avg = turns.reduce((acc, t) => {
12648
+ const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
12649
+ return acc + totalInput / Math.max(t.outputTokens, 1);
12650
+ }, 0) / turns.length;
12641
12651
  return this._clamp(100 - (avg - 1) * 20, 0, 100);
12642
12652
  }
12643
12653
  _computeContextManagementSubScoreForGroup(turns) {
@@ -12668,7 +12678,9 @@ const EXACT_CATEGORY_MAP = new Map([
12668
12678
  ["list_files", "file_reads"],
12669
12679
  ["run_command", "tool_outputs"],
12670
12680
  ["memory_read", "system_prompts"],
12671
- ["web_fetch", "tool_outputs"]
12681
+ ["web_fetch", "tool_outputs"],
12682
+ ["api_request", "conversation_history"],
12683
+ ["tool_decision", "tool_outputs"]
12672
12684
  ]);
12673
12685
  const PREFIX_PATTERNS = [
12674
12686
  {
@@ -13481,9 +13493,10 @@ var LogTurnAnalyzer = class {
13481
13493
  let runningContext = 0;
13482
13494
  const turns = merged.map(({ representative: log$2, inputTokens, outputTokens, cacheReadTokens, costUsd }, idx) => {
13483
13495
  const prevContext = runningContext;
13484
- runningContext += inputTokens;
13485
- const freshTokens = inputTokens - cacheReadTokens;
13486
- const cacheHitRate = inputTokens > 0 ? cacheReadTokens / inputTokens : 0;
13496
+ runningContext += inputTokens + cacheReadTokens;
13497
+ const freshTokens = inputTokens;
13498
+ const totalInput = inputTokens + cacheReadTokens;
13499
+ const cacheHitRate = totalInput > 0 ? cacheReadTokens / totalInput : 0;
13487
13500
  return {
13488
13501
  spanId: log$2.spanId ?? log$2.logId,
13489
13502
  turnNumber: idx + 1,
@@ -14249,24 +14262,31 @@ var TelemetryPipeline = class {
14249
14262
  }
14250
14263
  /**
14251
14264
  * Log-only analysis path (AC3, AC6): processes turns from LogTurnAnalyzer
14252
- * through efficiency scoring and persistence.
14253
- *
14254
- * Categorizer and consumer analyzer remain span-only for now (story 27-16).
14265
+ * through efficiency scoring, category stats, and persistence.
14255
14266
  */
14256
14267
  async _processStoryFromTurns(storyKey, turns) {
14257
14268
  if (turns.length === 0) return;
14258
14269
  const efficiencyScore = this._efficiencyScorer.score(storyKey, turns);
14259
- await Promise.all([this._persistence.storeTurnAnalysis(storyKey, turns).catch((err) => logger$6.warn({
14260
- err,
14261
- storyKey
14262
- }, "Failed to store turn analysis")), this._persistence.storeEfficiencyScore(efficiencyScore).catch((err) => logger$6.warn({
14263
- err,
14264
- storyKey
14265
- }, "Failed to store efficiency score"))]);
14270
+ const categoryStats = this._categorizer.computeCategoryStatsFromTurns(turns);
14271
+ await Promise.all([
14272
+ this._persistence.storeTurnAnalysis(storyKey, turns).catch((err) => logger$6.warn({
14273
+ err,
14274
+ storyKey
14275
+ }, "Failed to store turn analysis")),
14276
+ this._persistence.storeEfficiencyScore(efficiencyScore).catch((err) => logger$6.warn({
14277
+ err,
14278
+ storyKey
14279
+ }, "Failed to store efficiency score")),
14280
+ categoryStats.length > 0 ? this._persistence.storeCategoryStats(storyKey, categoryStats).catch((err) => logger$6.warn({
14281
+ err,
14282
+ storyKey
14283
+ }, "Failed to store category stats")) : Promise.resolve()
14284
+ ]);
14266
14285
  logger$6.info({
14267
14286
  storyKey,
14268
14287
  turns: turns.length,
14269
- compositeScore: efficiencyScore.compositeScore
14288
+ compositeScore: efficiencyScore.compositeScore,
14289
+ categories: categoryStats.length
14270
14290
  }, "TelemetryPipeline: story analysis from turns complete");
14271
14291
  }
14272
14292
  };
@@ -21588,4 +21608,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
21588
21608
 
21589
21609
  //#endregion
21590
21610
  export { AppError, DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, ERR_REPO_MAP_STORAGE_WRITE, FileStateStore, GitClient, GrammarLoader, IngestionServer, RepoMapInjector, RepoMapModule, RepoMapQueryEngine, RepoMapStorage, SUBSTRATE_OWNED_SETTINGS_KEYS, SymbolParser, 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, runRunAction, runSolutioningPhase, validateStopAfterFromConflict };
21591
- //# sourceMappingURL=run-Dx7bxebF.js.map
21611
+ //# sourceMappingURL=run-B_08vO01.js.map
@@ -1,4 +1,4 @@
1
- import { registerRunCommand, runRunAction } from "./run-Dx7bxebF.js";
1
+ import { registerRunCommand, runRunAction } from "./run-B_08vO01.js";
2
2
  import "./logger-D2fS2ccL.js";
3
3
  import "./config-migrator-DtZW1maj.js";
4
4
  import "./helpers-BihqWgVe.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",