substrate-ai 0.5.2 → 0.5.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,12 +1,12 @@
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, 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-CxoTrYdA.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, 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-D7a-qzk9.js";
3
3
  import { createLogger } from "../logger-D2fS2ccL.js";
4
4
  import { AdapterRegistry } from "../adapter-registry-BkUvZSKJ.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";
8
8
  import { addTokenUsage, createDecision, createPipelineRun, getDecisionsByCategory, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getTokenUsageSummary, listRequirements, updatePipelineRun } from "../decisions-C6MF2Cax.js";
9
- import { ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, aggregateTokenUsageForRun, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline } from "../operational-CidppHy-.js";
9
+ import { ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, aggregateTokenUsageForRun, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline } from "../operational-BRpT8MYF.js";
10
10
  import { abortMerge, createWorktree, getConflictingFiles, getMergedFiles, getOrphanedWorktrees, performMerge, removeBranch, removeWorktree, simulateMerge, verifyGitVersion } from "../git-utils-C-fdrHF_.js";
11
11
  import "../version-manager-impl-DTlmGvHb.js";
12
12
  import { registerUpgradeCommand } from "../upgrade-C8_VcI8B.js";
@@ -2909,7 +2909,7 @@ async function runSupervisorAction(options, deps = {}) {
2909
2909
  try {
2910
2910
  const { createExperimenter } = await import(
2911
2911
  /* @vite-ignore */
2912
- "../experimenter-CoR0k66d.js"
2912
+ "../experimenter-CjfzjmwY.js"
2913
2913
  );
2914
2914
  const { getLatestRun: getLatest } = await import(
2915
2915
  /* @vite-ignore */
@@ -2923,7 +2923,7 @@ async function runSupervisorAction(options, deps = {}) {
2923
2923
  await initSchema(expAdapter);
2924
2924
  const { runRunAction: runPipeline } = await import(
2925
2925
  /* @vite-ignore */
2926
- "../run-BSs4Dn0j.js"
2926
+ "../run-DE9y1W6N.js"
2927
2927
  );
2928
2928
  const runStoryFn = async (opts) => {
2929
2929
  const exitCode = await runPipeline({
@@ -7880,23 +7880,19 @@ function registerRoutingCommand(program) {
7880
7880
  /**
7881
7881
  * Work-graph schema DDL constants.
7882
7882
  *
7883
- * Story 31-1 placeholder defines the `stories`, `story_dependencies`, and
7884
- * `ready_stories` DDL used by the EpicIngester and downstream consumers.
7885
- *
7886
- * NOTE: This file is a minimal placeholder created by story 31-2 because story
7887
- * 31-1 (schema creation) had not yet run. If story 31-1 produces a richer
7888
- * schema, merge carefully and remove this note.
7883
+ * Aligned with the authoritative schema in src/modules/state/schema.sql.
7884
+ * Table names use `wg_stories` and `story_dependencies`.
7889
7885
  */
7890
7886
  const CREATE_STORIES_TABLE = `
7891
- CREATE TABLE IF NOT EXISTS stories (
7892
- story_key VARCHAR(50) NOT NULL,
7893
- epic_num INT NOT NULL,
7894
- story_num INT NOT NULL,
7895
- title VARCHAR(500) NOT NULL,
7896
- priority VARCHAR(10) NOT NULL,
7897
- size VARCHAR(50) NOT NULL,
7898
- sprint INT NOT NULL,
7899
- status VARCHAR(50) NOT NULL DEFAULT 'planned',
7887
+ CREATE TABLE IF NOT EXISTS wg_stories (
7888
+ story_key VARCHAR(20) NOT NULL,
7889
+ epic VARCHAR(20) NOT NULL,
7890
+ title VARCHAR(255),
7891
+ status VARCHAR(30) NOT NULL DEFAULT 'planned',
7892
+ spec_path VARCHAR(500),
7893
+ created_at DATETIME,
7894
+ updated_at DATETIME,
7895
+ completed_at DATETIME,
7900
7896
  PRIMARY KEY (story_key)
7901
7897
  )
7902
7898
  `.trim();
@@ -7906,31 +7902,33 @@ CREATE TABLE IF NOT EXISTS story_dependencies (
7906
7902
  depends_on VARCHAR(50) NOT NULL,
7907
7903
  dependency_type VARCHAR(50) NOT NULL DEFAULT 'blocks',
7908
7904
  source VARCHAR(50) NOT NULL DEFAULT 'explicit',
7905
+ created_at DATETIME,
7909
7906
  PRIMARY KEY (story_key, depends_on)
7910
7907
  )
7911
7908
  `.trim();
7912
7909
  const CREATE_READY_STORIES_VIEW = `
7913
7910
  CREATE VIEW IF NOT EXISTS ready_stories AS
7914
7911
  SELECT s.*
7915
- FROM stories s
7916
- WHERE s.status = 'planned'
7912
+ FROM wg_stories s
7913
+ WHERE s.status IN ('planned', 'ready')
7917
7914
  AND NOT EXISTS (
7918
7915
  SELECT 1 FROM story_dependencies sd
7919
- JOIN stories blocking ON sd.depends_on = blocking.story_key
7916
+ JOIN wg_stories blocking ON sd.depends_on = blocking.story_key
7920
7917
  WHERE sd.story_key = s.story_key
7921
- AND blocking.status != 'done'
7918
+ AND sd.dependency_type = 'blocks'
7919
+ AND blocking.status <> 'complete'
7922
7920
  )
7923
7921
  `.trim();
7924
7922
 
7925
7923
  //#endregion
7926
7924
  //#region src/modules/work-graph/epic-parser.ts
7927
- /** Regex for sprint header lines: `**Sprint 1 —` (em dash or hyphen) */
7928
- const SPRINT_HEADER_RE = /^\*\*Sprint\s+(\d+)\s*[—–-]/i;
7925
+ /** Regex for sprint header lines: `**Sprint 1 —` or `Sprint 1 —` (with or without bold markers) */
7926
+ const SPRINT_HEADER_RE = /^(?:\*\*)?Sprint\s+(\d+)\s*[—–-]/i;
7929
7927
  /**
7930
7928
  * Regex for story lines: `- 31-2: Epic doc ingestion (P0, Medium)`
7931
7929
  * Captures: epicNum, storyNum, title, priority, size
7932
7930
  */
7933
- const STORY_LINE_RE = /^-\s+(\d+)-(\d+):\s+(.+?)\s+\((P\d+),\s+([\w-]+)\)\s*$/;
7931
+ const STORY_LINE_RE = /^(?:-\s+)?(\d+)-(\d+):\s+(.+?)\s+\((P\d+),\s+([\w-]+)\)\s*$/;
7934
7932
  /** Regex to find the story map section heading */
7935
7933
  const STORY_MAP_HEADING_RE = /^#{1,6}\s+.*Story\s+Map/im;
7936
7934
  /** Regex to find the dependency chain line */
@@ -7953,6 +7951,7 @@ var EpicParser = class {
7953
7951
  let currentSprint = 0;
7954
7952
  for (const rawLine of afterHeading.split("\n")) {
7955
7953
  const line = rawLine.trim();
7954
+ if (line.startsWith("```")) continue;
7956
7955
  const sprintMatch = SPRINT_HEADER_RE.exec(line);
7957
7956
  if (sprintMatch) {
7958
7957
  currentSprint = parseInt(sprintMatch[1], 10);
@@ -8043,24 +8042,21 @@ var EpicIngester = class {
8043
8042
  return this.adapter.transaction(async (tx) => {
8044
8043
  let storiesUpserted = 0;
8045
8044
  for (const story of stories) {
8046
- const existing = await tx.query("SELECT status FROM stories WHERE story_key = ?", [story.story_key]);
8047
- if (existing.length > 0) await tx.query("UPDATE stories SET title = ?, priority = ?, size = ?, sprint = ? WHERE story_key = ?", [
8045
+ const existing = await tx.query("SELECT status FROM wg_stories WHERE story_key = ?", [story.story_key]);
8046
+ if (existing.length > 0) await tx.query("UPDATE wg_stories SET title = ?, updated_at = ? WHERE story_key = ?", [
8048
8047
  story.title,
8049
- story.priority,
8050
- story.size,
8051
- story.sprint,
8048
+ new Date().toISOString(),
8052
8049
  story.story_key
8053
8050
  ]);
8054
8051
  else {
8055
- await tx.query("INSERT INTO stories (story_key, epic_num, story_num, title, priority, size, sprint, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [
8052
+ const now = new Date().toISOString();
8053
+ await tx.query("INSERT INTO wg_stories (story_key, epic, title, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?)", [
8056
8054
  story.story_key,
8057
- story.epic_num,
8058
- story.story_num,
8055
+ String(story.epic_num),
8059
8056
  story.title,
8060
- story.priority,
8061
- story.size,
8062
- story.sprint,
8063
- "planned"
8057
+ "planned",
8058
+ now,
8059
+ now
8064
8060
  ]);
8065
8061
  storiesUpserted++;
8066
8062
  }
@@ -1,6 +1,6 @@
1
1
  import "./logger-D2fS2ccL.js";
2
2
  import { createDecision } from "./decisions-C6MF2Cax.js";
3
- import { EXPERIMENT_RESULT, getRunMetrics, getStoryMetricsForRun } from "./operational-CidppHy-.js";
3
+ import { EXPERIMENT_RESULT, getRunMetrics, getStoryMetricsForRun } from "./operational-BRpT8MYF.js";
4
4
  import { spawnGit } from "./git-utils-C-fdrHF_.js";
5
5
  import { spawn } from "node:child_process";
6
6
  import { join } from "node:path";
@@ -500,4 +500,4 @@ function createExperimenter(config, deps) {
500
500
 
501
501
  //#endregion
502
502
  export { createExperimenter };
503
- //# sourceMappingURL=experimenter-CoR0k66d.js.map
503
+ //# sourceMappingURL=experimenter-CjfzjmwY.js.map
@@ -186,7 +186,7 @@ async function aggregateTokenUsageForStory(adapter, runId, storyKey) {
186
186
  FROM token_usage
187
187
  WHERE pipeline_run_id = ?
188
188
  AND metadata IS NOT NULL
189
- AND json_extract(metadata, '$.storyKey') = ?`, [runId, storyKey]);
189
+ AND metadata LIKE ?`, [runId, `%"storyKey":"${storyKey}"%`]);
190
190
  return rows[0] ?? {
191
191
  input: 0,
192
192
  output: 0,
@@ -371,4 +371,4 @@ const ADVISORY_NOTES = "advisory-notes";
371
371
 
372
372
  //#endregion
373
373
  export { ADVISORY_NOTES, ESCALATION_DIAGNOSIS, EXPERIMENT_RESULT, OPERATIONAL_FINDING, STORY_METRICS, STORY_OUTCOME, TEST_EXPANSION_FINDING, TEST_PLAN, aggregateTokenUsageForRun, aggregateTokenUsageForStory, compareRunMetrics, getBaselineRunMetrics, getRunMetrics, getStoryMetricsForRun, incrementRunRestarts, listRunMetrics, tagRunAsBaseline, writeRunMetrics, writeStoryMetrics };
374
- //# sourceMappingURL=operational-CidppHy-.js.map
374
+ //# sourceMappingURL=operational-BRpT8MYF.js.map
@@ -3,7 +3,7 @@ import { CURRENT_CONFIG_FORMAT_VERSION, PartialSubstrateConfigSchema, SUPPORTED_
3
3
  import { ConfigError, ConfigIncompatibleFormatError, createEventBus, createTuiApp, isTuiCapable, printNonTtyWarning, sleep } from "./helpers-BihqWgVe.js";
4
4
  import { RoutingRecommender, RoutingResolver, RoutingTelemetry, RoutingTokenAccumulator, RoutingTuner, loadModelRoutingConfig } from "./routing-BUE9pIxW.js";
5
5
  import { addTokenUsage, createDecision, createPipelineRun, createRequirement, getArtifactByTypeForRun, getArtifactsByRun, getDecisionsByCategory, getDecisionsByPhase, getDecisionsByPhaseForRun, getLatestRun, getPipelineRunById, getRunningPipelineRuns, getTokenUsageSummary, registerArtifact, updatePipelineRun, updatePipelineRunConfig, upsertDecision } from "./decisions-C6MF2Cax.js";
6
- import { ADVISORY_NOTES, ESCALATION_DIAGNOSIS, OPERATIONAL_FINDING, STORY_METRICS, STORY_OUTCOME, TEST_EXPANSION_FINDING, TEST_PLAN, aggregateTokenUsageForRun, aggregateTokenUsageForStory, getStoryMetricsForRun, writeRunMetrics, writeStoryMetrics } from "./operational-CidppHy-.js";
6
+ import { ADVISORY_NOTES, ESCALATION_DIAGNOSIS, OPERATIONAL_FINDING, STORY_METRICS, STORY_OUTCOME, TEST_EXPANSION_FINDING, TEST_PLAN, aggregateTokenUsageForRun, aggregateTokenUsageForStory, getStoryMetricsForRun, writeRunMetrics, writeStoryMetrics } from "./operational-BRpT8MYF.js";
7
7
  import { createRequire } from "module";
8
8
  import { dirname, join, resolve } from "path";
9
9
  import { access, mkdir, readFile, readdir, stat, writeFile } from "fs/promises";
@@ -22121,4 +22121,4 @@ function registerRunCommand(program, _version = "0.0.0", projectRoot = process.c
22121
22121
 
22122
22122
  //#endregion
22123
22123
  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, 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 };
22124
- //# sourceMappingURL=run-CxoTrYdA.js.map
22124
+ //# sourceMappingURL=run-D7a-qzk9.js.map
@@ -1,9 +1,9 @@
1
- import { registerRunCommand, runRunAction } from "./run-CxoTrYdA.js";
1
+ import { registerRunCommand, runRunAction } from "./run-D7a-qzk9.js";
2
2
  import "./logger-D2fS2ccL.js";
3
3
  import "./config-migrator-DtZW1maj.js";
4
4
  import "./helpers-BihqWgVe.js";
5
5
  import "./routing-BUE9pIxW.js";
6
6
  import "./decisions-C6MF2Cax.js";
7
- import "./operational-CidppHy-.js";
7
+ import "./operational-BRpT8MYF.js";
8
8
 
9
9
  export { runRunAction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "substrate-ai",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Substrate — multi-agent orchestration daemon for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "MIT",