substrate-ai 0.5.7 → 0.5.8
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-
|
|
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-CCjGNBpI.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";
|
|
@@ -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-
|
|
2972
|
+
"../run-CqpGVKg6.js"
|
|
2973
2973
|
);
|
|
2974
2974
|
const runStoryFn = async (opts) => {
|
|
2975
2975
|
const exitCode = await runPipeline({
|
|
@@ -6276,7 +6276,7 @@ const DEFAULT_TIMEOUTS = {
|
|
|
6276
6276
|
"planning": 3e5,
|
|
6277
6277
|
"architecture": 3e5,
|
|
6278
6278
|
"story-generation": 3e5,
|
|
6279
|
-
"create-story":
|
|
6279
|
+
"create-story": 6e5,
|
|
6280
6280
|
"dev-story": 18e5,
|
|
6281
6281
|
"code-review": 9e5,
|
|
6282
6282
|
"minor-fixes": 6e5,
|
|
@@ -6310,7 +6310,7 @@ const DEFAULT_MAX_TURNS = {
|
|
|
6310
6310
|
"dev-story": 75,
|
|
6311
6311
|
"major-rework": 50,
|
|
6312
6312
|
"code-review": 25,
|
|
6313
|
-
"create-story":
|
|
6313
|
+
"create-story": 30,
|
|
6314
6314
|
"minor-fixes": 25,
|
|
6315
6315
|
"analysis-vision": 8,
|
|
6316
6316
|
"analysis-scope": 10,
|
|
@@ -13038,32 +13038,42 @@ var IngestionServer = class {
|
|
|
13038
13038
|
};
|
|
13039
13039
|
}
|
|
13040
13040
|
/**
|
|
13041
|
-
*
|
|
13042
|
-
*
|
|
13041
|
+
* Substrate resource attributes extracted from an OTLP payload.
|
|
13042
|
+
* These are set by ClaudeCodeAdapter via OTEL_RESOURCE_ATTRIBUTES env var.
|
|
13043
13043
|
*/
|
|
13044
|
-
|
|
13045
|
-
if (!body || typeof body !== "object") return
|
|
13044
|
+
_extractSubstrateAttributes(body) {
|
|
13045
|
+
if (!body || typeof body !== "object") return {};
|
|
13046
13046
|
const payload = body;
|
|
13047
13047
|
const extractFromResources = (resources) => {
|
|
13048
|
-
|
|
13048
|
+
const result = {};
|
|
13049
|
+
if (!Array.isArray(resources)) return result;
|
|
13049
13050
|
for (const entry of resources) {
|
|
13050
13051
|
if (!entry || typeof entry !== "object") continue;
|
|
13051
13052
|
const resource = entry.resource;
|
|
13052
13053
|
if (!resource || typeof resource !== "object") continue;
|
|
13053
|
-
const attrs = resource.attributes;
|
|
13054
|
-
if (!Array.isArray(attrs)) continue;
|
|
13055
|
-
for (const attr of attrs) {
|
|
13054
|
+
const attrs$1 = resource.attributes;
|
|
13055
|
+
if (!Array.isArray(attrs$1)) continue;
|
|
13056
|
+
for (const attr of attrs$1) {
|
|
13056
13057
|
if (!attr || typeof attr !== "object") continue;
|
|
13057
13058
|
const a = attr;
|
|
13058
|
-
|
|
13059
|
+
const key = a.key;
|
|
13060
|
+
if (key !== void 0 && key.startsWith("substrate.")) {
|
|
13059
13061
|
const val = a.value;
|
|
13060
|
-
if (val && typeof val.stringValue === "string")
|
|
13062
|
+
if (val && typeof val.stringValue === "string") result[key] = val.stringValue;
|
|
13061
13063
|
}
|
|
13062
13064
|
}
|
|
13063
13065
|
}
|
|
13064
|
-
return
|
|
13066
|
+
return result;
|
|
13067
|
+
};
|
|
13068
|
+
const attrs = {
|
|
13069
|
+
...extractFromResources(payload.resourceSpans),
|
|
13070
|
+
...extractFromResources(payload.resourceLogs)
|
|
13071
|
+
};
|
|
13072
|
+
return {
|
|
13073
|
+
storyKey: attrs["substrate.story_key"],
|
|
13074
|
+
taskType: attrs["substrate.task_type"],
|
|
13075
|
+
dispatchId: attrs["substrate.dispatch_id"]
|
|
13065
13076
|
};
|
|
13066
|
-
return extractFromResources(payload.resourceSpans) ?? extractFromResources(payload.resourceLogs);
|
|
13067
13077
|
}
|
|
13068
13078
|
_handleRequest(req, res) {
|
|
13069
13079
|
if (req.url === "/health" && req.method === "GET") {
|
|
@@ -13087,12 +13097,19 @@ var IngestionServer = class {
|
|
|
13087
13097
|
if (this._buffer !== void 0) try {
|
|
13088
13098
|
const body = JSON.parse(bodyStr);
|
|
13089
13099
|
const source = detectSource(body);
|
|
13090
|
-
const storyKey = this.
|
|
13091
|
-
|
|
13100
|
+
const { storyKey, taskType, dispatchId } = this._extractSubstrateAttributes(body);
|
|
13101
|
+
let dispatchContext;
|
|
13102
|
+
if (taskType !== void 0 && dispatchId !== void 0) dispatchContext = {
|
|
13103
|
+
taskType,
|
|
13104
|
+
phase: taskType,
|
|
13105
|
+
dispatchId
|
|
13106
|
+
};
|
|
13107
|
+
else if (storyKey !== void 0) dispatchContext = this._activeDispatches.get(storyKey);
|
|
13092
13108
|
const payload = {
|
|
13093
13109
|
body,
|
|
13094
13110
|
source,
|
|
13095
13111
|
receivedAt: Date.now(),
|
|
13112
|
+
storyKey,
|
|
13096
13113
|
...dispatchContext !== void 0 && { dispatchContext }
|
|
13097
13114
|
};
|
|
13098
13115
|
this._buffer.push(payload);
|
|
@@ -13723,7 +13740,7 @@ var ConsumerAnalyzer = class {
|
|
|
13723
13740
|
|
|
13724
13741
|
//#endregion
|
|
13725
13742
|
//#region src/modules/telemetry/recommender.ts
|
|
13726
|
-
var Recommender = class {
|
|
13743
|
+
var Recommender = class Recommender {
|
|
13727
13744
|
_logger;
|
|
13728
13745
|
constructor(logger$27) {
|
|
13729
13746
|
this._logger = logger$27;
|
|
@@ -13781,8 +13798,21 @@ var Recommender = class {
|
|
|
13781
13798
|
return spans.reduce((sum, s) => sum + s.inputTokens + s.outputTokens, 0);
|
|
13782
13799
|
}
|
|
13783
13800
|
/**
|
|
13784
|
-
*
|
|
13785
|
-
*
|
|
13801
|
+
* Minimum absolute token count for a consumer to be flagged.
|
|
13802
|
+
* Below this, the consumer is too small to be actionable regardless of percentage.
|
|
13803
|
+
*/
|
|
13804
|
+
static MIN_SIGNIFICANT_TOKENS = 1e4;
|
|
13805
|
+
/**
|
|
13806
|
+
* Identify top 3 token consumers (by inputTokens + outputTokens) where pct >5%
|
|
13807
|
+
* AND absolute tokens exceed MIN_SIGNIFICANT_TOKENS.
|
|
13808
|
+
*
|
|
13809
|
+
* Filters out model-only consumers (empty toolName, format "model|") since those
|
|
13810
|
+
* just indicate which model ran — not an actionable optimization target.
|
|
13811
|
+
*
|
|
13812
|
+
* Severity factors both percentage share and absolute magnitude:
|
|
13813
|
+
* - percentage-based tier via _assignSeverity()
|
|
13814
|
+
* - capped at 'warning' when absolute tokens < 50,000
|
|
13815
|
+
* - capped at 'info' when absolute tokens < 20,000
|
|
13786
13816
|
*/
|
|
13787
13817
|
_runBiggestConsumers(ctx) {
|
|
13788
13818
|
const { consumers, storyKey, sprintId, generatedAt } = ctx;
|
|
@@ -13791,11 +13821,18 @@ var Recommender = class {
|
|
|
13791
13821
|
if (grandTotal === 0) return [];
|
|
13792
13822
|
const sorted = [...consumers].sort((a, b) => b.totalTokens - a.totalTokens);
|
|
13793
13823
|
const top3 = sorted.slice(0, 3).filter((c) => {
|
|
13794
|
-
|
|
13824
|
+
if (c.percentage <= 5) return false;
|
|
13825
|
+
if (c.totalTokens < Recommender.MIN_SIGNIFICANT_TOKENS) return false;
|
|
13826
|
+
if (c.consumerKey.endsWith("|") && !c.consumerKey.includes("|", 0)) return false;
|
|
13827
|
+
const parts = c.consumerKey.split("|");
|
|
13828
|
+
if (parts.length === 2 && parts[1] === "") return false;
|
|
13829
|
+
return true;
|
|
13795
13830
|
});
|
|
13796
13831
|
return top3.map((consumer, index) => {
|
|
13797
13832
|
const pct = consumer.percentage;
|
|
13798
|
-
|
|
13833
|
+
let severity = this._assignSeverity(pct);
|
|
13834
|
+
if (consumer.totalTokens < 2e4 && severity !== "info") severity = "info";
|
|
13835
|
+
else if (consumer.totalTokens < 5e4 && severity === "critical") severity = "warning";
|
|
13799
13836
|
const actionTarget = consumer.consumerKey;
|
|
13800
13837
|
const id = this._makeId("biggest_consumers", storyKey, actionTarget, index);
|
|
13801
13838
|
return {
|
|
@@ -22642,4 +22679,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
|
|
|
22642
22679
|
|
|
22643
22680
|
//#endregion
|
|
22644
22681
|
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 };
|
|
22645
|
-
//# sourceMappingURL=run-
|
|
22682
|
+
//# sourceMappingURL=run-CCjGNBpI.js.map
|