substrate-ai 0.4.1 → 0.4.3

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 { DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, 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-cqQmW8wL.js";
2
+ import { DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, 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-AHblPlOJ.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
4
  import { AdapterRegistry } from "../adapter-registry-rSOJ9Kvz.js";
5
5
  import { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema } from "../config-migrator-DtZW1maj.js";
@@ -622,7 +622,8 @@ async function runInitAction(options) {
622
622
  config_format_version: CURRENT_CONFIG_FORMAT_VERSION,
623
623
  task_graph_version: CURRENT_TASK_GRAPH_VERSION,
624
624
  global: DEFAULT_CONFIG.global,
625
- providers: configProviders
625
+ providers: configProviders,
626
+ telemetry: DEFAULT_CONFIG.telemetry
626
627
  };
627
628
  const routingPolicy = structuredClone(DEFAULT_ROUTING_POLICY);
628
629
  await mkdir(substrateDir, { recursive: true });
@@ -2708,7 +2709,7 @@ async function runSupervisorAction(options, deps = {}) {
2708
2709
  const expDb = expDbWrapper.db;
2709
2710
  const { runRunAction: runPipeline } = await import(
2710
2711
  /* @vite-ignore */
2711
- "../run-CQJP37ZC.js"
2712
+ "../run-C_mCMW99.js"
2712
2713
  );
2713
2714
  const runStoryFn = async (opts) => {
2714
2715
  const exitCode = await runPipeline({
@@ -110,6 +110,10 @@ const DEFAULT_CONFIG = {
110
110
  claude: DEFAULT_CLAUDE_PROVIDER,
111
111
  codex: DEFAULT_CODEX_PROVIDER,
112
112
  gemini: DEFAULT_GEMINI_PROVIDER
113
+ },
114
+ telemetry: {
115
+ enabled: true,
116
+ port: 4318
113
117
  }
114
118
  };
115
119
 
@@ -21081,4 +21085,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
21081
21085
 
21082
21086
  //#endregion
21083
21087
  export { DEFAULT_CONFIG, DEFAULT_ROUTING_POLICY, DatabaseWrapper, DoltClient, DoltNotInstalled, DoltRepoMapMetaRepository, DoltSymbolRepository, 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 };
21084
- //# sourceMappingURL=run-cqQmW8wL.js.map
21088
+ //# sourceMappingURL=run-AHblPlOJ.js.map
@@ -1,4 +1,4 @@
1
- import { registerRunCommand, runRunAction } from "./run-cqQmW8wL.js";
1
+ import { registerRunCommand, runRunAction } from "./run-AHblPlOJ.js";
2
2
  import "./logger-D2fS2ccL.js";
3
3
  import "./config-migrator-DtZW1maj.js";
4
4
  import "./helpers-BihqWgVe.js";
@@ -0,0 +1,236 @@
1
+ -- Substrate State Schema v1
2
+ -- Dolt-compatible DDL: composite natural business-key primary keys,
3
+ -- DATETIME columns to avoid timezone-dependent merge conflicts.
4
+
5
+ -- ---------------------------------------------------------------------------
6
+ -- stories
7
+ -- ---------------------------------------------------------------------------
8
+ CREATE TABLE IF NOT EXISTS stories (
9
+ story_key VARCHAR(100) NOT NULL,
10
+ sprint VARCHAR(50),
11
+ status VARCHAR(30) NOT NULL DEFAULT 'PENDING',
12
+ phase VARCHAR(30) NOT NULL DEFAULT 'PENDING',
13
+ ac_results JSON,
14
+ error_message TEXT,
15
+ created_at DATETIME,
16
+ updated_at DATETIME,
17
+ completed_at DATETIME,
18
+ PRIMARY KEY (story_key)
19
+ );
20
+
21
+ -- ---------------------------------------------------------------------------
22
+ -- contracts
23
+ -- ---------------------------------------------------------------------------
24
+ CREATE TABLE IF NOT EXISTS contracts (
25
+ story_key VARCHAR(100) NOT NULL,
26
+ name VARCHAR(200) NOT NULL,
27
+ direction VARCHAR(20) NOT NULL,
28
+ schema_path VARCHAR(500),
29
+ transport VARCHAR(200),
30
+ recorded_at DATETIME,
31
+ PRIMARY KEY (story_key, name, direction)
32
+ );
33
+
34
+ -- ---------------------------------------------------------------------------
35
+ -- metrics
36
+ -- ---------------------------------------------------------------------------
37
+ CREATE TABLE IF NOT EXISTS metrics (
38
+ story_key VARCHAR(100) NOT NULL,
39
+ task_type VARCHAR(100) NOT NULL,
40
+ recorded_at DATETIME NOT NULL,
41
+ model VARCHAR(100),
42
+ tokens_in BIGINT NOT NULL DEFAULT 0,
43
+ tokens_out BIGINT NOT NULL DEFAULT 0,
44
+ cache_read_tokens BIGINT NOT NULL DEFAULT 0,
45
+ cost_usd DECIMAL(10,6) NOT NULL DEFAULT 0,
46
+ wall_clock_ms BIGINT NOT NULL DEFAULT 0,
47
+ review_cycles INT NOT NULL DEFAULT 0,
48
+ stall_count INT NOT NULL DEFAULT 0,
49
+ result VARCHAR(30),
50
+ PRIMARY KEY (story_key, task_type, recorded_at)
51
+ );
52
+
53
+ -- ---------------------------------------------------------------------------
54
+ -- dispatch_log
55
+ -- ---------------------------------------------------------------------------
56
+ CREATE TABLE IF NOT EXISTS dispatch_log (
57
+ story_key VARCHAR(100) NOT NULL,
58
+ dispatched_at DATETIME NOT NULL,
59
+ branch VARCHAR(200),
60
+ worker_id VARCHAR(100),
61
+ result VARCHAR(30),
62
+ PRIMARY KEY (story_key, dispatched_at)
63
+ );
64
+
65
+ -- ---------------------------------------------------------------------------
66
+ -- build_results
67
+ -- ---------------------------------------------------------------------------
68
+ CREATE TABLE IF NOT EXISTS build_results (
69
+ story_key VARCHAR(100) NOT NULL,
70
+ timestamp DATETIME NOT NULL,
71
+ command VARCHAR(500),
72
+ exit_code INT,
73
+ stdout_hash VARCHAR(64),
74
+ PRIMARY KEY (story_key, timestamp)
75
+ );
76
+
77
+ -- ---------------------------------------------------------------------------
78
+ -- review_verdicts
79
+ -- ---------------------------------------------------------------------------
80
+ CREATE TABLE IF NOT EXISTS review_verdicts (
81
+ story_key VARCHAR(100) NOT NULL,
82
+ timestamp DATETIME NOT NULL,
83
+ verdict VARCHAR(30),
84
+ issues_count INT NOT NULL DEFAULT 0,
85
+ notes TEXT,
86
+ PRIMARY KEY (story_key, timestamp)
87
+ );
88
+
89
+ -- ---------------------------------------------------------------------------
90
+ -- _schema_version
91
+ -- ---------------------------------------------------------------------------
92
+ CREATE TABLE IF NOT EXISTS _schema_version (
93
+ version INT NOT NULL,
94
+ applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
95
+ description VARCHAR(500),
96
+ PRIMARY KEY (version)
97
+ );
98
+
99
+ -- Seed schema version (idempotent via INSERT IGNORE)
100
+ INSERT IGNORE INTO _schema_version (version, description) VALUES (1, 'Initial substrate state schema');
101
+
102
+ -- ---------------------------------------------------------------------------
103
+ -- turn_analysis (story 27-4)
104
+ -- ---------------------------------------------------------------------------
105
+ CREATE TABLE IF NOT EXISTS turn_analysis (
106
+ story_key VARCHAR(64) NOT NULL,
107
+ span_id VARCHAR(128) NOT NULL,
108
+ turn_number INTEGER NOT NULL,
109
+ name VARCHAR(255) NOT NULL DEFAULT '',
110
+ timestamp BIGINT NOT NULL DEFAULT 0,
111
+ source VARCHAR(32) NOT NULL DEFAULT '',
112
+ model VARCHAR(64),
113
+ input_tokens INTEGER NOT NULL DEFAULT 0,
114
+ output_tokens INTEGER NOT NULL DEFAULT 0,
115
+ cache_read_tokens INTEGER NOT NULL DEFAULT 0,
116
+ fresh_tokens INTEGER NOT NULL DEFAULT 0,
117
+ cache_hit_rate DOUBLE NOT NULL DEFAULT 0,
118
+ cost_usd DOUBLE NOT NULL DEFAULT 0,
119
+ duration_ms INTEGER NOT NULL DEFAULT 0,
120
+ context_size INTEGER NOT NULL DEFAULT 0,
121
+ context_delta INTEGER NOT NULL DEFAULT 0,
122
+ tool_name VARCHAR(128),
123
+ is_context_spike BOOLEAN NOT NULL DEFAULT 0,
124
+ child_spans_json TEXT NOT NULL DEFAULT '[]',
125
+ PRIMARY KEY (story_key, span_id)
126
+ );
127
+
128
+ CREATE INDEX IF NOT EXISTS idx_turn_analysis_story ON turn_analysis (story_key, turn_number);
129
+
130
+ INSERT IGNORE INTO _schema_version (version, description) VALUES (2, 'Add turn_analysis table (Epic 27-4)');
131
+
132
+ -- ---------------------------------------------------------------------------
133
+ -- efficiency_scores
134
+ -- ---------------------------------------------------------------------------
135
+ CREATE TABLE IF NOT EXISTS efficiency_scores (
136
+ story_key VARCHAR(64) NOT NULL,
137
+ timestamp BIGINT NOT NULL,
138
+ composite_score INTEGER NOT NULL DEFAULT 0,
139
+ cache_hit_sub_score DOUBLE NOT NULL DEFAULT 0,
140
+ io_ratio_sub_score DOUBLE NOT NULL DEFAULT 0,
141
+ context_management_sub_score DOUBLE NOT NULL DEFAULT 0,
142
+ avg_cache_hit_rate DOUBLE NOT NULL DEFAULT 0,
143
+ avg_io_ratio DOUBLE NOT NULL DEFAULT 0,
144
+ context_spike_count INTEGER NOT NULL DEFAULT 0,
145
+ total_turns INTEGER NOT NULL DEFAULT 0,
146
+ per_model_json TEXT NOT NULL DEFAULT '[]',
147
+ per_source_json TEXT NOT NULL DEFAULT '[]',
148
+ PRIMARY KEY (story_key, timestamp)
149
+ );
150
+
151
+ CREATE INDEX IF NOT EXISTS idx_efficiency_story ON efficiency_scores (story_key, timestamp DESC);
152
+
153
+ -- ---------------------------------------------------------------------------
154
+ -- recommendations (story 27-7)
155
+ -- ---------------------------------------------------------------------------
156
+ CREATE TABLE IF NOT EXISTS recommendations (
157
+ id VARCHAR(16) NOT NULL,
158
+ story_key VARCHAR(64) NOT NULL,
159
+ sprint_id VARCHAR(64),
160
+ rule_id VARCHAR(64) NOT NULL,
161
+ severity VARCHAR(16) NOT NULL,
162
+ title TEXT NOT NULL,
163
+ description TEXT NOT NULL,
164
+ potential_savings_tokens INTEGER,
165
+ potential_savings_usd DOUBLE,
166
+ action_target TEXT,
167
+ generated_at VARCHAR(32) NOT NULL,
168
+ PRIMARY KEY (id)
169
+ );
170
+ CREATE INDEX IF NOT EXISTS idx_recommendations_story ON recommendations (story_key, severity);
171
+
172
+ -- ---------------------------------------------------------------------------
173
+ -- category_stats (story 27-5)
174
+ -- ---------------------------------------------------------------------------
175
+ CREATE TABLE IF NOT EXISTS category_stats (
176
+ story_key VARCHAR(100) NOT NULL,
177
+ category VARCHAR(30) NOT NULL,
178
+ total_tokens BIGINT NOT NULL DEFAULT 0,
179
+ percentage DECIMAL(6,3) NOT NULL DEFAULT 0,
180
+ event_count INTEGER NOT NULL DEFAULT 0,
181
+ avg_tokens_per_event DECIMAL(12,2) NOT NULL DEFAULT 0,
182
+ trend VARCHAR(10) NOT NULL DEFAULT 'stable',
183
+ PRIMARY KEY (story_key, category)
184
+ );
185
+
186
+ CREATE INDEX IF NOT EXISTS idx_category_stats_story ON category_stats (story_key, total_tokens);
187
+
188
+ -- ---------------------------------------------------------------------------
189
+ -- consumer_stats (story 27-5)
190
+ -- ---------------------------------------------------------------------------
191
+ CREATE TABLE IF NOT EXISTS consumer_stats (
192
+ story_key VARCHAR(100) NOT NULL,
193
+ consumer_key VARCHAR(300) NOT NULL,
194
+ category VARCHAR(30) NOT NULL,
195
+ total_tokens BIGINT NOT NULL DEFAULT 0,
196
+ percentage DECIMAL(6,3) NOT NULL DEFAULT 0,
197
+ event_count INTEGER NOT NULL DEFAULT 0,
198
+ top_invocations_json TEXT,
199
+ PRIMARY KEY (story_key, consumer_key)
200
+ );
201
+
202
+ CREATE INDEX IF NOT EXISTS idx_consumer_stats_story ON consumer_stats (story_key, total_tokens);
203
+
204
+ INSERT IGNORE INTO _schema_version (version, description) VALUES (3, 'Add category_stats and consumer_stats tables (Epic 27-5)');
205
+ INSERT IGNORE INTO _schema_version (version, description) VALUES (4, 'Add recommendations table (Epic 27-7)');
206
+
207
+ -- ---------------------------------------------------------------------------
208
+ -- repo_map_symbols (story 28-2 / Epic 28)
209
+ -- ---------------------------------------------------------------------------
210
+ CREATE TABLE IF NOT EXISTS repo_map_symbols (
211
+ id BIGINT AUTO_INCREMENT NOT NULL,
212
+ file_path VARCHAR(1000) NOT NULL,
213
+ symbol_name VARCHAR(500) NOT NULL,
214
+ symbol_kind VARCHAR(20) NOT NULL,
215
+ signature TEXT,
216
+ line_number INT NOT NULL DEFAULT 0,
217
+ exported TINYINT(1) NOT NULL DEFAULT 0,
218
+ file_hash VARCHAR(64) NOT NULL,
219
+ PRIMARY KEY (id)
220
+ );
221
+
222
+ CREATE INDEX IF NOT EXISTS idx_repo_map_symbols_file ON repo_map_symbols (file_path);
223
+ CREATE INDEX IF NOT EXISTS idx_repo_map_symbols_kind ON repo_map_symbols (symbol_kind);
224
+
225
+ -- ---------------------------------------------------------------------------
226
+ -- repo_map_meta (story 28-2 / Epic 28)
227
+ -- ---------------------------------------------------------------------------
228
+ CREATE TABLE IF NOT EXISTS repo_map_meta (
229
+ id INT NOT NULL DEFAULT 1,
230
+ commit_sha VARCHAR(64),
231
+ updated_at DATETIME,
232
+ file_count INT NOT NULL DEFAULT 0,
233
+ PRIMARY KEY (id)
234
+ );
235
+
236
+ INSERT IGNORE INTO _schema_version (version, description) VALUES (5, 'Add repo_map_symbols and repo_map_meta tables (Epic 28-2)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,6 +38,7 @@
38
38
  "dist/**/*.js",
39
39
  "dist/**/*.d.ts",
40
40
  "dist/**/*.json",
41
+ "dist/**/*.sql",
41
42
  "dist/cli/templates",
42
43
  "packs",
43
44
  "README.md"