substrate-ai 0.5.4 → 0.5.6

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.
@@ -93,7 +93,11 @@ var ClaudeCodeAdapter = class {
93
93
  envEntries.OTEL_LOG_TOOL_DETAILS = "1";
94
94
  envEntries.OTEL_METRIC_EXPORT_INTERVAL = "10000";
95
95
  envEntries.OTEL_EXPORTER_OTLP_TIMEOUT = "5000";
96
- if (options.storyKey !== void 0) envEntries.OTEL_RESOURCE_ATTRIBUTES = `substrate.story_key=${options.storyKey}`;
96
+ const resourceAttrs = [];
97
+ if (options.storyKey !== void 0) resourceAttrs.push(`substrate.story_key=${options.storyKey}`);
98
+ if (options.taskType !== void 0) resourceAttrs.push(`substrate.task_type=${options.taskType}`);
99
+ if (options.dispatchId !== void 0) resourceAttrs.push(`substrate.dispatch_id=${options.dispatchId}`);
100
+ if (resourceAttrs.length > 0) envEntries.OTEL_RESOURCE_ATTRIBUTES = resourceAttrs.join(",");
97
101
  }
98
102
  return {
99
103
  binary: "claude",
@@ -833,4 +837,4 @@ var AdapterRegistry = class {
833
837
 
834
838
  //#endregion
835
839
  export { AdapterRegistry, ClaudeCodeAdapter, CodexCLIAdapter, GeminiCLIAdapter };
836
- //# sourceMappingURL=adapter-registry-CDNPbixE.js.map
840
+ //# sourceMappingURL=adapter-registry-D2zdMwVu.js.map
@@ -0,0 +1,4 @@
1
+ import "./logger-D2fS2ccL.js";
2
+ import { AdapterRegistry } from "./adapter-registry-D2zdMwVu.js";
3
+
4
+ export { AdapterRegistry };
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
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-BVqGAkUO.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-DwoihdAI.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
- import { AdapterRegistry } from "../adapter-registry-CDNPbixE.js";
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";
6
6
  import { ConfigError, createEventBus } from "../helpers-BihqWgVe.js";
7
7
  import { RoutingRecommender } from "../routing-BUE9pIxW.js";
@@ -2525,7 +2525,7 @@ function defaultSupervisorDeps() {
2525
2525
  if (cached === null) {
2526
2526
  const { AdapterRegistry: AR } = await import(
2527
2527
  /* @vite-ignore */
2528
- "../adapter-registry-B0XmM7pb.js"
2528
+ "../adapter-registry-WAyFydN5.js"
2529
2529
  );
2530
2530
  cached = new AR();
2531
2531
  await cached.discoverAndRegister();
@@ -2969,7 +2969,7 @@ async function runSupervisorAction(options, deps = {}) {
2969
2969
  await initSchema(expAdapter);
2970
2970
  const { runRunAction: runPipeline } = await import(
2971
2971
  /* @vite-ignore */
2972
- "../run-WMR5BAhL.js"
2972
+ "../run-H1Xn6_C4.js"
2973
2973
  );
2974
2974
  const runStoryFn = async (opts) => {
2975
2975
  const exitCode = await runPipeline({
package/dist/index.d.ts CHANGED
@@ -1527,6 +1527,10 @@ interface AdapterOptions {
1527
1527
  * Generated by TelemetryAdvisor.formatOptimizationDirectives().
1528
1528
  */
1529
1529
  optimizationDirectives?: string;
1530
+ /** Dispatch context: task type (create-story, dev-story, code-review, etc.) for OTLP attribution */
1531
+ taskType?: string;
1532
+ /** Dispatch context: unique dispatch ID for per-dispatch telemetry correlation */
1533
+ dispatchId?: string;
1530
1534
  }
1531
1535
  /**
1532
1536
  * Capabilities reported by an adapter for this CLI agent.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { childLogger, createLogger, logger } from "./logger-D2fS2ccL.js";
2
- import { AdapterRegistry, ClaudeCodeAdapter, CodexCLIAdapter, GeminiCLIAdapter } from "./adapter-registry-CDNPbixE.js";
2
+ import { AdapterRegistry, ClaudeCodeAdapter, CodexCLIAdapter, GeminiCLIAdapter } from "./adapter-registry-D2zdMwVu.js";
3
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
@@ -6776,7 +6776,9 @@ var DispatcherImpl = class {
6776
6776
  ...maxContextTokens !== void 0 ? { maxContextTokens } : {},
6777
6777
  ...otlpEndpoint !== void 0 ? { otlpEndpoint } : {},
6778
6778
  ...storyKey !== void 0 ? { storyKey } : {},
6779
- ...optimizationDirectives !== void 0 ? { optimizationDirectives } : {}
6779
+ ...optimizationDirectives !== void 0 ? { optimizationDirectives } : {},
6780
+ taskType,
6781
+ dispatchId: id
6780
6782
  });
6781
6783
  const timeoutMs = timeout ?? this._config.defaultTimeouts[taskType] ?? DEFAULT_TIMEOUTS[taskType] ?? 3e5;
6782
6784
  const env = { ...process.env };
@@ -13182,16 +13184,23 @@ var EfficiencyScorer = class {
13182
13184
  return this._clamp(avg * 100, 0, 100);
13183
13185
  }
13184
13186
  /**
13185
- * I/O ratio sub-score: lower ratio = better = higher score.
13186
- * Formula: clamp(100 - (avgIoRatio - 1) × 20, 0, 100)
13187
+ * I/O ratio sub-score: measures output productivity.
13187
13188
  *
13188
- * At avgIoRatio=1: score=80 (equal input/output tokens)
13189
- * At avgIoRatio=5: score=20
13190
- * At avgIoRatio≥6: clamped to 0
13189
+ * For code generation workloads, high context-to-output ratio is normal and
13190
+ * desirable (agent reads large cached context, produces substantial code).
13191
+ * The old formula penalized this. New formula uses output-to-fresh-input ratio:
13192
+ * - outputTokens / max(freshInputTokens, 1) per turn
13193
+ * - Ratio > 1 means productive (more output than fresh input) → score 100
13194
+ * - Ratio < 1 → scaled linearly: ratio * 100
13195
+ * - Averaged across turns
13191
13196
  */
13192
13197
  _computeIoRatioSubScore(turns) {
13193
- const avg = this._computeAvgIoRatio(turns);
13194
- return this._clamp(100 - (avg - 1) * 20, 0, 100);
13198
+ if (turns.length === 0) return 0;
13199
+ const avg = turns.reduce((acc, t) => {
13200
+ const freshInput = Math.max(t.inputTokens, 1);
13201
+ return acc + t.outputTokens / freshInput;
13202
+ }, 0) / turns.length;
13203
+ return this._clamp(avg >= 1 ? 100 : avg * 100, 0, 100);
13195
13204
  }
13196
13205
  /**
13197
13206
  * Context management sub-score: penalizes context spike frequency.
@@ -13287,10 +13296,10 @@ var EfficiencyScorer = class {
13287
13296
  _computeIoRatioSubScoreForGroup(turns) {
13288
13297
  if (turns.length === 0) return 0;
13289
13298
  const avg = turns.reduce((acc, t) => {
13290
- const totalInput = t.inputTokens + (t.cacheReadTokens ?? 0);
13291
- return acc + totalInput / Math.max(t.outputTokens, 1);
13299
+ const freshInput = Math.max(t.inputTokens, 1);
13300
+ return acc + t.outputTokens / freshInput;
13292
13301
  }, 0) / turns.length;
13293
- return this._clamp(100 - (avg - 1) * 20, 0, 100);
13302
+ return this._clamp(avg >= 1 ? 100 : avg * 100, 0, 100);
13294
13303
  }
13295
13304
  _computeContextManagementSubScoreForGroup(turns) {
13296
13305
  if (turns.length === 0) return 0;
@@ -15166,7 +15175,15 @@ var TelemetryAdvisor = class {
15166
15175
  */
15167
15176
  formatOptimizationDirectives(recommendations) {
15168
15177
  const MAX_CHARS$1 = 2e3;
15169
- const actionable = recommendations.filter((r) => r.severity === "critical" || r.severity === "warning");
15178
+ const AGENT_ACTIONABLE_RULES = new Set([
15179
+ "large_file_reads",
15180
+ "expensive_bash",
15181
+ "repeated_tool_calls",
15182
+ "context_growth_spike",
15183
+ "growing_categories",
15184
+ "cache_delta_regression"
15185
+ ]);
15186
+ const actionable = recommendations.filter((r) => (r.severity === "critical" || r.severity === "warning") && AGENT_ACTIONABLE_RULES.has(r.ruleId));
15170
15187
  if (actionable.length === 0) return "";
15171
15188
  const lines = actionable.map((r) => `OPTIMIZATION (${r.severity}): ${r.title}. ${r.description}`);
15172
15189
  const full = lines.join("\n");
@@ -17235,6 +17252,12 @@ async function resolveStoryKeys(db, projectRoot, opts) {
17235
17252
  const completedKeys = await getCompletedStoryKeys(db);
17236
17253
  filteredKeys = filteredKeys.filter((k) => !completedKeys.has(k));
17237
17254
  }
17255
+ const existingArtifacts = collectExistingStoryKeys(projectRoot);
17256
+ const alreadyDone = filteredKeys.filter((k) => existingArtifacts.has(k));
17257
+ if (alreadyDone.length > 0) {
17258
+ filteredKeys = filteredKeys.filter((k) => !existingArtifacts.has(k));
17259
+ for (const key of alreadyDone) db.query(`UPDATE wg_stories SET status = 'complete', completed_at = ? WHERE story_key = ? AND status <> 'complete'`, [new Date().toISOString(), key]).catch(() => {});
17260
+ }
17238
17261
  return sortStoryKeys([...new Set(filteredKeys)]);
17239
17262
  }
17240
17263
  try {
@@ -17262,6 +17285,10 @@ async function resolveStoryKeys(db, projectRoot, opts) {
17262
17285
  const completedKeys = await getCompletedStoryKeys(db);
17263
17286
  keys = keys.filter((k) => !completedKeys.has(k));
17264
17287
  }
17288
+ if (keys.length > 0) {
17289
+ const existingArtifacts = collectExistingStoryKeys(projectRoot);
17290
+ keys = keys.filter((k) => !existingArtifacts.has(k));
17291
+ }
17265
17292
  return sortStoryKeys([...new Set(keys)]);
17266
17293
  }
17267
17294
  /**
@@ -22615,4 +22642,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
22615
22642
 
22616
22643
  //#endregion
22617
22644
  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 };
22618
- //# sourceMappingURL=run-BVqGAkUO.js.map
22645
+ //# sourceMappingURL=run-DwoihdAI.js.map
@@ -1,4 +1,4 @@
1
- import { registerRunCommand, runRunAction } from "./run-BVqGAkUO.js";
1
+ import { registerRunCommand, runRunAction } from "./run-DwoihdAI.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.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,4 +0,0 @@
1
- import "./logger-D2fS2ccL.js";
2
- import { AdapterRegistry } from "./adapter-registry-CDNPbixE.js";
3
-
4
- export { AdapterRegistry };