substrate-ai 0.1.11 → 0.1.12
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 +48 -14
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from "url";
|
|
|
8
8
|
import { dirname, extname, isAbsolute, join, relative, resolve } from "path";
|
|
9
9
|
import { access, mkdir, readFile, readdir, stat, writeFile } from "fs/promises";
|
|
10
10
|
import { execFile } from "child_process";
|
|
11
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "fs";
|
|
11
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "fs";
|
|
12
12
|
import yaml, { dump, load } from "js-yaml";
|
|
13
13
|
import { z } from "zod";
|
|
14
14
|
import { fileURLToPath as fileURLToPath$1 } from "node:url";
|
|
@@ -323,9 +323,9 @@ const DEFAULT_CONFIG = {
|
|
|
323
323
|
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/cli/commands/templates.ts
|
|
326
|
-
const __filename = fileURLToPath$1(import.meta.url);
|
|
327
|
-
const __dirname = dirname$1(__filename);
|
|
328
|
-
const TEMPLATES_DIR = join$1(__dirname, "..", "templates");
|
|
326
|
+
const __filename$1 = fileURLToPath$1(import.meta.url);
|
|
327
|
+
const __dirname$1 = dirname$1(__filename$1);
|
|
328
|
+
const TEMPLATES_DIR = join$1(__dirname$1, "..", "templates");
|
|
329
329
|
/**
|
|
330
330
|
* Get the absolute path to a template YAML file.
|
|
331
331
|
*
|
|
@@ -12114,6 +12114,15 @@ Analyze thoroughly and return ONLY the JSON array with no additional text.`;
|
|
|
12114
12114
|
|
|
12115
12115
|
//#endregion
|
|
12116
12116
|
//#region src/cli/commands/auto.ts
|
|
12117
|
+
const __filename = fileURLToPath$1(import.meta.url);
|
|
12118
|
+
const __dirname = dirname(__filename);
|
|
12119
|
+
/**
|
|
12120
|
+
* Absolute path to the Substrate package root.
|
|
12121
|
+
*
|
|
12122
|
+
* In source: src/cli/commands/ → 3 levels up = repo root
|
|
12123
|
+
* Post-build: dist/cli/commands/ → 3 levels up = dist parent = package root
|
|
12124
|
+
*/
|
|
12125
|
+
const PACKAGE_ROOT = join(__dirname, "..", "..", "..");
|
|
12117
12126
|
const logger$3 = createLogger("auto-cmd");
|
|
12118
12127
|
/** BMAD baseline token total for full pipeline comparison (analysis+planning+solutioning+implementation) */
|
|
12119
12128
|
const BMAD_BASELINE_TOKENS_FULL = 56800;
|
|
@@ -12313,18 +12322,41 @@ function formatPipelineSummary(run, tokenSummary, decisionsCount, storiesCount,
|
|
|
12313
12322
|
return lines.join("\n");
|
|
12314
12323
|
}
|
|
12315
12324
|
async function runAutoInit(options) {
|
|
12316
|
-
const { pack: packName, projectRoot, outputFormat } = options;
|
|
12325
|
+
const { pack: packName, projectRoot, outputFormat, force = false } = options;
|
|
12317
12326
|
const packPath = join(projectRoot, "packs", packName);
|
|
12318
12327
|
const dbRoot = await resolveMainRepoRoot(projectRoot);
|
|
12319
12328
|
const dbDir = join(dbRoot, ".substrate");
|
|
12320
12329
|
const dbPath = join(dbDir, "substrate.db");
|
|
12321
12330
|
try {
|
|
12331
|
+
const localManifest = join(packPath, "manifest.yaml");
|
|
12332
|
+
let scaffolded = false;
|
|
12333
|
+
if (!existsSync(localManifest) || force) {
|
|
12334
|
+
const bundledPackPath = join(PACKAGE_ROOT, "packs", packName);
|
|
12335
|
+
if (!existsSync(join(bundledPackPath, "manifest.yaml"))) {
|
|
12336
|
+
const errorMsg = `Pack '${packName}' not found locally or in bundled packs. Try reinstalling Substrate.`;
|
|
12337
|
+
if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, errorMsg) + "\n");
|
|
12338
|
+
else process.stderr.write(`Error: ${errorMsg}\n`);
|
|
12339
|
+
return 1;
|
|
12340
|
+
}
|
|
12341
|
+
if (force && existsSync(localManifest)) {
|
|
12342
|
+
logger$3.info({ pack: packName }, "Replacing existing pack with bundled version");
|
|
12343
|
+
process.stderr.write(`Warning: Replacing existing pack '${packName}' with bundled version\n`);
|
|
12344
|
+
}
|
|
12345
|
+
mkdirSync(dirname(packPath), { recursive: true });
|
|
12346
|
+
cpSync(bundledPackPath, packPath, { recursive: true });
|
|
12347
|
+
logger$3.info({
|
|
12348
|
+
pack: packName,
|
|
12349
|
+
dest: packPath
|
|
12350
|
+
}, "Scaffolded methodology pack");
|
|
12351
|
+
process.stdout.write(`Scaffolding methodology pack '${packName}' into packs/${packName}/\n`);
|
|
12352
|
+
scaffolded = true;
|
|
12353
|
+
}
|
|
12322
12354
|
const packLoader = createPackLoader();
|
|
12323
12355
|
try {
|
|
12324
12356
|
await packLoader.load(packPath);
|
|
12325
12357
|
} catch (err) {
|
|
12326
12358
|
const msg = err instanceof Error ? err.message : String(err);
|
|
12327
|
-
const errorMsg = `Methodology pack '${packName}' not found.
|
|
12359
|
+
const errorMsg = `Methodology pack '${packName}' not found. Check that packs/${packName}/manifest.yaml exists or try reinstalling Substrate.\n${msg}`;
|
|
12328
12360
|
if (outputFormat === "json") process.stdout.write(formatOutput(null, "json", false, errorMsg) + "\n");
|
|
12329
12361
|
else process.stderr.write(`Error: ${errorMsg}\n`);
|
|
12330
12362
|
return 1;
|
|
@@ -12337,7 +12369,8 @@ async function runAutoInit(options) {
|
|
|
12337
12369
|
const successMsg = `Pack '${packName}' and database initialized successfully at ${dbPath}`;
|
|
12338
12370
|
if (outputFormat === "json") process.stdout.write(formatOutput({
|
|
12339
12371
|
pack: packName,
|
|
12340
|
-
dbPath
|
|
12372
|
+
dbPath,
|
|
12373
|
+
scaffolded
|
|
12341
12374
|
}, "json", true) + "\n");
|
|
12342
12375
|
else process.stdout.write(`${successMsg}\n`);
|
|
12343
12376
|
return 0;
|
|
@@ -13479,12 +13512,13 @@ async function runAmendCommand(options) {
|
|
|
13479
13512
|
*/
|
|
13480
13513
|
function registerAutoCommand(program, _version = "0.0.0", projectRoot = process.cwd()) {
|
|
13481
13514
|
const auto = program.command("auto").description("Autonomous implementation pipeline");
|
|
13482
|
-
auto.command("init").description("Initialize a methodology pack and decision store for autonomous pipeline").option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--output-format <format>", "Output format: human (default) or json", "human").action(async (opts) => {
|
|
13515
|
+
auto.command("init").description("Initialize a methodology pack and decision store for autonomous pipeline").option("--pack <name>", "Methodology pack name", "bmad").option("--project-root <path>", "Project root directory", projectRoot).option("--force", "Overwrite existing local pack with bundled version").option("--output-format <format>", "Output format: human (default) or json", "human").action(async (opts) => {
|
|
13483
13516
|
const outputFormat = opts.outputFormat === "json" ? "json" : "human";
|
|
13484
13517
|
const exitCode = await runAutoInit({
|
|
13485
13518
|
pack: opts.pack,
|
|
13486
13519
|
projectRoot: opts.projectRoot,
|
|
13487
|
-
outputFormat
|
|
13520
|
+
outputFormat,
|
|
13521
|
+
force: opts.force ?? false
|
|
13488
13522
|
});
|
|
13489
13523
|
process.exitCode = exitCode;
|
|
13490
13524
|
});
|
|
@@ -14566,12 +14600,12 @@ const logger = createLogger("cli");
|
|
|
14566
14600
|
/** Resolve the package.json path relative to this file */
|
|
14567
14601
|
async function getPackageVersion() {
|
|
14568
14602
|
try {
|
|
14569
|
-
const __filename$
|
|
14570
|
-
const __dirname$
|
|
14603
|
+
const __filename$2 = fileURLToPath(import.meta.url);
|
|
14604
|
+
const __dirname$2 = dirname(__filename$2);
|
|
14571
14605
|
const paths = [
|
|
14572
|
-
resolve(__dirname$
|
|
14573
|
-
resolve(__dirname$
|
|
14574
|
-
resolve(__dirname$
|
|
14606
|
+
resolve(__dirname$2, "../../package.json"),
|
|
14607
|
+
resolve(__dirname$2, "../package.json"),
|
|
14608
|
+
resolve(__dirname$2, "../../../package.json")
|
|
14575
14609
|
];
|
|
14576
14610
|
for (const pkgPath of paths) try {
|
|
14577
14611
|
const content = await readFile(pkgPath, "utf-8");
|