@srobroek/pi-speckit-beads 3.2.1 → 3.2.2
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/CHANGELOG.md +2 -0
- package/extensions/speckit-beads.js +284 -90
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
## speckit-beads [3.2.2](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v3.2.1...speckit-beads--v3.2.2) (2026-12-05)
|
|
2
|
+
|
|
1
3
|
## speckit-beads [3.2.1](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v3.2.0...speckit-beads--v3.2.1) (2026-12-05)
|
|
2
4
|
|
|
3
5
|
## speckit-beads [3.2.0](https://github.com/srobroek/harness-plugins/compare/speckit-beads--v3.1.0...speckit-beads--v3.2.0) (2026-12-05)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Generated by scripts/build.ts. Do not edit.
|
|
3
3
|
// plugins/speckit-beads/pi-src/speckit-beads.ts
|
|
4
4
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5
|
-
import { join as
|
|
5
|
+
import { join as join10 } from "path";
|
|
6
6
|
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
7
7
|
|
|
8
8
|
// lib/src/external-directories.ts
|
|
@@ -1214,9 +1214,197 @@ The index was not synced for these paths: ${synced.reason}`}`,
|
|
|
1214
1214
|
}
|
|
1215
1215
|
|
|
1216
1216
|
// plugins/speckit-beads/opencode/src/setup.ts
|
|
1217
|
-
import { appendFileSync,
|
|
1218
|
-
import { dirname as dirname3, isAbsolute as
|
|
1217
|
+
import { appendFileSync, existsSync as existsSync3, lstatSync as lstatSync3, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
1218
|
+
import { dirname as dirname3, isAbsolute as isAbsolute3, join as join5, relative as relative2, resolve as resolve4, sep } from "path";
|
|
1219
1219
|
import { fileURLToPath } from "url";
|
|
1220
|
+
|
|
1221
|
+
// lib/src/formulas.ts
|
|
1222
|
+
import { accessSync, constants as constants2, copyFileSync, lstatSync as lstatSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, statSync as statSync2 } from "fs";
|
|
1223
|
+
import { isAbsolute as isAbsolute2, join as join4, resolve as resolve3 } from "path";
|
|
1224
|
+
function describeFormulaFailure(failure) {
|
|
1225
|
+
const paths = failure.paths.join(", ");
|
|
1226
|
+
switch (failure.kind) {
|
|
1227
|
+
case "symlinked-directory":
|
|
1228
|
+
return `refusing symlinked path: ${paths}`;
|
|
1229
|
+
case "no-workspace":
|
|
1230
|
+
return `not a beads workspace: ${paths} has no .beads/ (run bd init there first)`;
|
|
1231
|
+
case "destination-not-directory":
|
|
1232
|
+
return `formula destination is not a directory: ${paths}`;
|
|
1233
|
+
case "source-symlink":
|
|
1234
|
+
case "source-missing":
|
|
1235
|
+
return `shipped formula missing or unsafe: ${paths}`;
|
|
1236
|
+
case "source-unreadable":
|
|
1237
|
+
return `shipped formula unreadable (${failure.code}): ${paths}`;
|
|
1238
|
+
case "destination-symlink":
|
|
1239
|
+
case "destination-not-file":
|
|
1240
|
+
case "destinations-unsafe":
|
|
1241
|
+
return `refusing non-file formula destination: ${paths}`;
|
|
1242
|
+
case "divergent":
|
|
1243
|
+
return `refusing to overwrite divergent formulas (pass force=true to replace them): ${paths}`;
|
|
1244
|
+
case "destination-unreadable":
|
|
1245
|
+
return `cannot read formula destination (${failure.code}): ${paths}`;
|
|
1246
|
+
case "destination-unwritable":
|
|
1247
|
+
return `cannot write formula destination (${failure.code}): ${paths}${failure.copied.length > 0 ? `; already copied: ${failure.copied.join(", ")}` : ""}`;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
function errorCode(error) {
|
|
1251
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : "UNKNOWN";
|
|
1252
|
+
}
|
|
1253
|
+
function probe(path) {
|
|
1254
|
+
try {
|
|
1255
|
+
return { stat: lstatSync2(path, { throwIfNoEntry: false }) };
|
|
1256
|
+
} catch (error) {
|
|
1257
|
+
return { code: errorCode(error) };
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function isNonDirectory(path) {
|
|
1261
|
+
try {
|
|
1262
|
+
return !statSync2(path).isDirectory();
|
|
1263
|
+
} catch {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
function installFormulas(options) {
|
|
1268
|
+
const { workspace, cwd, sourceDir, force = false, requireWorkspace = true, sourcePreflight = [], refusals = "unsafe-first" } = options;
|
|
1269
|
+
const repo = isAbsolute2(workspace) ? workspace : resolve3(cwd, workspace);
|
|
1270
|
+
const beads = join4(repo, ".beads");
|
|
1271
|
+
const destination = join4(beads, "formulas");
|
|
1272
|
+
const fail = (failure) => ({
|
|
1273
|
+
ok: false,
|
|
1274
|
+
text: describeFormulaFailure(failure),
|
|
1275
|
+
copied: failure.kind === "destination-unwritable" ? failure.copied : [],
|
|
1276
|
+
unchanged: [],
|
|
1277
|
+
destination,
|
|
1278
|
+
failure
|
|
1279
|
+
});
|
|
1280
|
+
const beadsProbe = probe(beads);
|
|
1281
|
+
const rootIsFile = "code" in beadsProbe && beadsProbe.code === "ENOTDIR" && isNonDirectory(repo);
|
|
1282
|
+
if ("code" in beadsProbe && !rootIsFile)
|
|
1283
|
+
return fail({ kind: "destination-unreadable", paths: [beads], code: beadsProbe.code });
|
|
1284
|
+
const beadsStat = "stat" in beadsProbe ? beadsProbe.stat : undefined;
|
|
1285
|
+
if (beadsStat?.isSymbolicLink())
|
|
1286
|
+
return fail({ kind: "symlinked-directory", paths: [beads] });
|
|
1287
|
+
const formulasProbe = beadsStat?.isDirectory() ? probe(destination) : { stat: undefined };
|
|
1288
|
+
if ("code" in formulasProbe)
|
|
1289
|
+
return fail({ kind: "destination-unreadable", paths: [destination], code: formulasProbe.code });
|
|
1290
|
+
const destStat = formulasProbe.stat;
|
|
1291
|
+
if (destStat?.isSymbolicLink())
|
|
1292
|
+
return fail({ kind: "symlinked-directory", paths: [destination] });
|
|
1293
|
+
if (requireWorkspace && !beadsStat?.isDirectory())
|
|
1294
|
+
return fail({ kind: "no-workspace", paths: [repo] });
|
|
1295
|
+
if (rootIsFile)
|
|
1296
|
+
return fail({ kind: "destination-not-directory", paths: [destination] });
|
|
1297
|
+
if (beadsStat && !beadsStat.isDirectory())
|
|
1298
|
+
return fail({ kind: "destination-not-directory", paths: [destination] });
|
|
1299
|
+
if (destStat && !destStat.isDirectory() && refusals !== "first")
|
|
1300
|
+
return fail({ kind: "destination-not-directory", paths: [destination] });
|
|
1301
|
+
const sourceOf = (name) => join4(sourceDir, `${name}.formula.toml`);
|
|
1302
|
+
const sourceRefusal = (name) => {
|
|
1303
|
+
const src = sourceOf(name);
|
|
1304
|
+
const found = probe(src);
|
|
1305
|
+
if ("code" in found)
|
|
1306
|
+
return { kind: "source-unreadable", paths: [src], code: found.code };
|
|
1307
|
+
if (!found.stat)
|
|
1308
|
+
return { kind: "source-missing", paths: [src] };
|
|
1309
|
+
if (found.stat.isSymbolicLink())
|
|
1310
|
+
return { kind: "source-symlink", paths: [src] };
|
|
1311
|
+
return found.stat.isFile() ? undefined : { kind: "source-missing", paths: [src] };
|
|
1312
|
+
};
|
|
1313
|
+
for (const name of sourcePreflight) {
|
|
1314
|
+
const refusal = sourceRefusal(name);
|
|
1315
|
+
if (refusal)
|
|
1316
|
+
return fail(refusal);
|
|
1317
|
+
}
|
|
1318
|
+
let names;
|
|
1319
|
+
try {
|
|
1320
|
+
names = typeof options.names === "function" ? options.names() : options.names;
|
|
1321
|
+
} catch (error) {
|
|
1322
|
+
return fail({ kind: "source-unreadable", paths: [sourceDir], code: errorCode(error) });
|
|
1323
|
+
}
|
|
1324
|
+
const copies = [];
|
|
1325
|
+
const unchanged = [];
|
|
1326
|
+
const divergent = [];
|
|
1327
|
+
const unsafe = [];
|
|
1328
|
+
for (const name of names) {
|
|
1329
|
+
const src = sourceOf(name);
|
|
1330
|
+
const dest = join4(destination, `${name}.formula.toml`);
|
|
1331
|
+
if (refusals === "first") {
|
|
1332
|
+
const sourceProbe = probe(src);
|
|
1333
|
+
if ("code" in sourceProbe)
|
|
1334
|
+
return fail({ kind: "source-unreadable", paths: [src], code: sourceProbe.code });
|
|
1335
|
+
if (sourceProbe.stat?.isSymbolicLink())
|
|
1336
|
+
return fail({ kind: "source-symlink", paths: [src] });
|
|
1337
|
+
const destProbe = probe(dest);
|
|
1338
|
+
if ("code" in destProbe)
|
|
1339
|
+
return fail({ kind: "destination-unreadable", paths: [dest], code: destProbe.code });
|
|
1340
|
+
if (destProbe.stat?.isSymbolicLink())
|
|
1341
|
+
return fail({ kind: "destination-symlink", paths: [dest] });
|
|
1342
|
+
}
|
|
1343
|
+
const refusal = sourceRefusal(name);
|
|
1344
|
+
if (refusal)
|
|
1345
|
+
return fail(refusal);
|
|
1346
|
+
const found = probe(dest);
|
|
1347
|
+
if ("code" in found)
|
|
1348
|
+
return fail({ kind: "destination-unreadable", paths: [dest], code: found.code });
|
|
1349
|
+
const st = found.stat;
|
|
1350
|
+
const reason = st?.isSymbolicLink() ? "destination-symlink" : st && !st.isFile() ? "destination-not-file" : undefined;
|
|
1351
|
+
if (reason !== undefined) {
|
|
1352
|
+
if (refusals !== "collect")
|
|
1353
|
+
return fail({ kind: reason, paths: [dest] });
|
|
1354
|
+
unsafe.push({ reason, path: dest });
|
|
1355
|
+
continue;
|
|
1356
|
+
}
|
|
1357
|
+
if (st) {
|
|
1358
|
+
let shipped;
|
|
1359
|
+
try {
|
|
1360
|
+
shipped = readFileSync3(src);
|
|
1361
|
+
} catch (error) {
|
|
1362
|
+
return fail({ kind: "source-unreadable", paths: [src], code: errorCode(error) });
|
|
1363
|
+
}
|
|
1364
|
+
let installed;
|
|
1365
|
+
try {
|
|
1366
|
+
installed = readFileSync3(dest);
|
|
1367
|
+
} catch (error) {
|
|
1368
|
+
return fail({ kind: "destination-unreadable", paths: [dest], code: errorCode(error) });
|
|
1369
|
+
}
|
|
1370
|
+
if (shipped.equals(installed)) {
|
|
1371
|
+
unchanged.push(name);
|
|
1372
|
+
continue;
|
|
1373
|
+
}
|
|
1374
|
+
if (refusals === "first" && !force)
|
|
1375
|
+
return fail({ kind: "divergent", paths: [dest] });
|
|
1376
|
+
divergent.push(dest);
|
|
1377
|
+
}
|
|
1378
|
+
copies.push({ src, dest, name });
|
|
1379
|
+
}
|
|
1380
|
+
if (unsafe.length > 0)
|
|
1381
|
+
return fail({ kind: "destinations-unsafe", paths: unsafe.map(({ path }) => path), reasons: unsafe.map(({ reason }) => reason) });
|
|
1382
|
+
if (divergent.length > 0 && !force)
|
|
1383
|
+
return fail({ kind: "divergent", paths: divergent });
|
|
1384
|
+
for (const { src } of copies) {
|
|
1385
|
+
try {
|
|
1386
|
+
accessSync(src, constants2.R_OK);
|
|
1387
|
+
} catch (error) {
|
|
1388
|
+
return fail({ kind: "source-unreadable", paths: [src], code: errorCode(error) });
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
const copied = [];
|
|
1392
|
+
let writing = destination;
|
|
1393
|
+
try {
|
|
1394
|
+
mkdirSync2(destination, { recursive: true });
|
|
1395
|
+
for (const { src, dest, name } of copies) {
|
|
1396
|
+
writing = dest;
|
|
1397
|
+
copyFileSync(src, dest);
|
|
1398
|
+
copied.push(name);
|
|
1399
|
+
}
|
|
1400
|
+
} catch (error) {
|
|
1401
|
+
return fail({ kind: "destination-unwritable", paths: [writing], code: errorCode(error), copied });
|
|
1402
|
+
}
|
|
1403
|
+
const text = copied.length > 0 ? `copied ${copied.join(", ")} into ${destination}` : `every formula already in ${destination}`;
|
|
1404
|
+
return { ok: true, text, copied, unchanged, destination };
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
// plugins/speckit-beads/opencode/src/setup.ts
|
|
1220
1408
|
var PHASE_TIMEOUT_MS = 60000;
|
|
1221
1409
|
var STOPPED = "stopped by the tool call; rerun to resume, finished phases are skipped";
|
|
1222
1410
|
var isStopped = (signal) => signal?.aborted === true;
|
|
@@ -1290,7 +1478,7 @@ var testPluginRoot = null;
|
|
|
1290
1478
|
function pluginRoot() {
|
|
1291
1479
|
if (testPluginRoot)
|
|
1292
1480
|
return testPluginRoot;
|
|
1293
|
-
return
|
|
1481
|
+
return join5(dirname3(fileURLToPath(import.meta.url)), "..");
|
|
1294
1482
|
}
|
|
1295
1483
|
function parseSpecifyMajorMinor(versionOut) {
|
|
1296
1484
|
const m = versionOut.match(/(\d+)\.(\d+)/);
|
|
@@ -1305,9 +1493,9 @@ function specifyVersionOk(versionOut) {
|
|
|
1305
1493
|
return v.major > 0 || v.major === 0 && v.minor >= 12;
|
|
1306
1494
|
}
|
|
1307
1495
|
function ensureGitignore(repo) {
|
|
1308
|
-
safePath(
|
|
1309
|
-
const gi =
|
|
1310
|
-
const existing = existsSync3(gi) ?
|
|
1496
|
+
safePath(join5(repo, ".gitignore"), repo);
|
|
1497
|
+
const gi = join5(repo, ".gitignore");
|
|
1498
|
+
const existing = existsSync3(gi) ? readFileSync4(gi, "utf8") : "";
|
|
1311
1499
|
if (existing.split(`
|
|
1312
1500
|
`).some((l) => l.trim() === GITIGNORE_ENTRY)) {
|
|
1313
1501
|
return "gitignore already has spec-status.md";
|
|
@@ -1324,54 +1512,60 @@ function ensureGitignore(repo) {
|
|
|
1324
1512
|
return "appended specs/**/spec-status.md to .gitignore";
|
|
1325
1513
|
}
|
|
1326
1514
|
function safePath(path, base) {
|
|
1327
|
-
const root =
|
|
1328
|
-
const rel = relative2(root,
|
|
1329
|
-
if (rel.startsWith("..") ||
|
|
1515
|
+
const root = resolve4(base);
|
|
1516
|
+
const rel = relative2(root, resolve4(path));
|
|
1517
|
+
if (rel.startsWith("..") || isAbsolute3(rel))
|
|
1330
1518
|
throw new Error(`path escapes ${root}: ${path}`);
|
|
1331
1519
|
let current = root;
|
|
1332
1520
|
for (const part of rel.split(sep === "\\" ? /[\\/]/ : "/").filter(Boolean)) {
|
|
1333
|
-
current =
|
|
1334
|
-
const st =
|
|
1521
|
+
current = join5(current, part);
|
|
1522
|
+
const st = lstatSync3(current, { throwIfNoEntry: false });
|
|
1335
1523
|
if (st?.isSymbolicLink())
|
|
1336
1524
|
throw new Error(`unsafe symlink: ${current}`);
|
|
1337
1525
|
}
|
|
1338
1526
|
}
|
|
1339
|
-
function
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1527
|
+
function installRefusal(failure) {
|
|
1528
|
+
const paths = failure.paths.join(", ");
|
|
1529
|
+
switch (failure.kind) {
|
|
1530
|
+
case "symlinked-directory":
|
|
1531
|
+
case "source-symlink":
|
|
1532
|
+
case "destination-symlink":
|
|
1533
|
+
return `unsafe symlink: ${paths}`;
|
|
1534
|
+
case "source-missing":
|
|
1535
|
+
return `required formula missing or unsafe: ${paths}`;
|
|
1536
|
+
case "source-unreadable":
|
|
1537
|
+
return `required formula missing or unsafe: ${paths} (${failure.code})`;
|
|
1538
|
+
case "destination-not-directory":
|
|
1539
|
+
return `formula destination is not a directory: ${paths}`;
|
|
1540
|
+
case "destination-unreadable":
|
|
1541
|
+
return `cannot read formula destination (${failure.code}): ${paths}`;
|
|
1542
|
+
case "destination-unwritable":
|
|
1543
|
+
return `cannot write formula destination (${failure.code}): ${paths}${failure.copied.length > 0 ? `; already copied: ${failure.copied.join(", ")}` : ""}`;
|
|
1544
|
+
case "no-workspace":
|
|
1545
|
+
case "destination-not-file":
|
|
1546
|
+
case "destinations-unsafe":
|
|
1547
|
+
case "divergent":
|
|
1548
|
+
return `refusing divergent formula destination: ${paths}`;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
function installFormulas2(repo, srcDir) {
|
|
1552
|
+
const result = installFormulas({ workspace: repo, cwd: process.cwd(), names: FORMULAS, sourceDir: srcDir, requireWorkspace: false, refusals: "first" });
|
|
1553
|
+
if (result.failure !== undefined)
|
|
1554
|
+
throw new Error(installRefusal(result.failure));
|
|
1555
|
+
return result.copied.map((name) => `copied ${name}`);
|
|
1362
1556
|
}
|
|
1363
1557
|
function storyFormulaNote(repo) {
|
|
1364
|
-
if (
|
|
1558
|
+
if (lstatSync3(join5(repo, ".beads", "formulas", "beads-feature.formula.toml"), { throwIfNoEntry: false })?.isFile())
|
|
1365
1559
|
return;
|
|
1366
1560
|
return "beads-feature is not installed; run the beads plugin's beads_formulas tool to split user stories into features";
|
|
1367
1561
|
}
|
|
1368
1562
|
function installedExtensions(repo) {
|
|
1369
|
-
const registry =
|
|
1563
|
+
const registry = join5(repo, ".specify", "extensions", ".registry");
|
|
1370
1564
|
safePath(registry, repo);
|
|
1371
1565
|
if (!existsSync3(registry))
|
|
1372
1566
|
return new Set;
|
|
1373
1567
|
try {
|
|
1374
|
-
const data = JSON.parse(
|
|
1568
|
+
const data = JSON.parse(readFileSync4(registry, "utf8"));
|
|
1375
1569
|
const extensions = data !== null && typeof data === "object" && "extensions" in data ? data.extensions : undefined;
|
|
1376
1570
|
if (extensions === null || typeof extensions !== "object" || Array.isArray(extensions))
|
|
1377
1571
|
return new Set;
|
|
@@ -1381,11 +1575,11 @@ function installedExtensions(repo) {
|
|
|
1381
1575
|
}
|
|
1382
1576
|
}
|
|
1383
1577
|
function communityCatalogState(repo) {
|
|
1384
|
-
const config =
|
|
1578
|
+
const config = join5(repo, ".specify", "extension-catalogs.yml");
|
|
1385
1579
|
safePath(config, repo);
|
|
1386
1580
|
if (!existsSync3(config))
|
|
1387
1581
|
return "absent";
|
|
1388
|
-
const parsed = Bun.YAML.parse(
|
|
1582
|
+
const parsed = Bun.YAML.parse(readFileSync4(config, "utf8"));
|
|
1389
1583
|
const catalogs = parsed !== null && typeof parsed === "object" && "catalogs" in parsed && Array.isArray(parsed.catalogs) ? parsed.catalogs : [];
|
|
1390
1584
|
let conflict = false;
|
|
1391
1585
|
for (const entry of catalogs) {
|
|
@@ -1406,7 +1600,7 @@ function output(result) {
|
|
|
1406
1600
|
`) || `exit ${result.exitCode}`;
|
|
1407
1601
|
}
|
|
1408
1602
|
async function runSetup(params, cwd, signal) {
|
|
1409
|
-
const repo =
|
|
1603
|
+
const repo = resolve4(cwd, params.workspace ?? ".");
|
|
1410
1604
|
const phases = [];
|
|
1411
1605
|
const record = (phase, status, detail) => phases.push({ phase, status, detail });
|
|
1412
1606
|
const finish = () => ({
|
|
@@ -1424,9 +1618,9 @@ async function runSetup(params, cwd, signal) {
|
|
|
1424
1618
|
return finish();
|
|
1425
1619
|
};
|
|
1426
1620
|
try {
|
|
1427
|
-
safePath(
|
|
1428
|
-
safePath(
|
|
1429
|
-
safePath(
|
|
1621
|
+
safePath(join5(repo, ".specify"), repo);
|
|
1622
|
+
safePath(join5(repo, ".beads"), repo);
|
|
1623
|
+
safePath(join5(repo, ".gitignore"), repo);
|
|
1430
1624
|
if (params.skipSpecify)
|
|
1431
1625
|
record("specify", "skipped", "skipSpecify: specify CLI steps omitted");
|
|
1432
1626
|
else {
|
|
@@ -1441,7 +1635,7 @@ ${ver.stderr}`))
|
|
|
1441
1635
|
return fail(`specify-cli >= 0.12.0 required. Got: ${ver.stdout || ver.stderr}`);
|
|
1442
1636
|
record(current, "done", ver.stdout.trim());
|
|
1443
1637
|
current = "specify init";
|
|
1444
|
-
if (existsSync3(
|
|
1638
|
+
if (existsSync3(join5(repo, ".specify")) && !params.force)
|
|
1445
1639
|
record(current, "skipped", ".specify already present (pass force=true to re-scaffold)");
|
|
1446
1640
|
else {
|
|
1447
1641
|
const init = await run([
|
|
@@ -1511,7 +1705,7 @@ ${ver.stderr}`))
|
|
|
1511
1705
|
record(current, "done", "bd init --skip-hooks");
|
|
1512
1706
|
}
|
|
1513
1707
|
current = "formulas";
|
|
1514
|
-
const copied =
|
|
1708
|
+
const copied = installFormulas2(repo, join5(pluginRoot(), "formulas"));
|
|
1515
1709
|
const story = storyFormulaNote(repo);
|
|
1516
1710
|
const formulas = copied.length ? copied.join(", ") : "every formula already present";
|
|
1517
1711
|
record(current, copied.length ? "done" : "skipped", story ? `${formulas}; ${story}` : formulas);
|
|
@@ -1542,9 +1736,9 @@ function defineMode(spec) {
|
|
|
1542
1736
|
|
|
1543
1737
|
// plugins/speckit-beads/opencode/src/workflow.ts
|
|
1544
1738
|
import { existsSync as existsSync4 } from "fs";
|
|
1545
|
-
import { isAbsolute as
|
|
1739
|
+
import { isAbsolute as isAbsolute4, join as join6, relative as relative3, sep as sep2 } from "path";
|
|
1546
1740
|
function usesSpeckit(directory) {
|
|
1547
|
-
return existsSync4(
|
|
1741
|
+
return existsSync4(join6(directory, ".specify"));
|
|
1548
1742
|
}
|
|
1549
1743
|
function speckitWorkspace(directory, projectRoot, detect = usesSpeckit) {
|
|
1550
1744
|
if (detect(directory))
|
|
@@ -1552,7 +1746,7 @@ function speckitWorkspace(directory, projectRoot, detect = usesSpeckit) {
|
|
|
1552
1746
|
if (projectRoot === undefined || projectRoot === directory)
|
|
1553
1747
|
return;
|
|
1554
1748
|
const path = relative3(projectRoot, directory);
|
|
1555
|
-
const inside = path !== "" && path !== ".." && !path.startsWith(`..${sep2}`) && !
|
|
1749
|
+
const inside = path !== "" && path !== ".." && !path.startsWith(`..${sep2}`) && !isAbsolute4(path);
|
|
1556
1750
|
return inside && detect(projectRoot) ? projectRoot : undefined;
|
|
1557
1751
|
}
|
|
1558
1752
|
|
|
@@ -1692,7 +1886,7 @@ ${refusal}
|
|
|
1692
1886
|
}
|
|
1693
1887
|
|
|
1694
1888
|
// plugins/speckit-beads/opencode/src/tasks-guard.ts
|
|
1695
|
-
import { dirname as dirname4, isAbsolute as
|
|
1889
|
+
import { dirname as dirname4, isAbsolute as isAbsolute5, resolve as resolve5 } from "path";
|
|
1696
1890
|
|
|
1697
1891
|
// lib/src/tool-targets.ts
|
|
1698
1892
|
var WRITE_TOOLS = new Set(["edit", "write", "patch"]);
|
|
@@ -1859,7 +2053,7 @@ function repoOf(path) {
|
|
|
1859
2053
|
}
|
|
1860
2054
|
function tasksTargets(tool, input, directory) {
|
|
1861
2055
|
if (WRITE_TOOLS.has(tool)) {
|
|
1862
|
-
const hits = writeTargets(tool, input).filter(isTasksMd).map((path) =>
|
|
2056
|
+
const hits = writeTargets(tool, input).filter(isTasksMd).map((path) => isAbsolute5(path) ? path : resolve5(directory, path));
|
|
1863
2057
|
return hits.length > 0 ? [...new Set(hits.map(repoOf))] : undefined;
|
|
1864
2058
|
}
|
|
1865
2059
|
if (!isShellTool(tool))
|
|
@@ -1884,7 +2078,7 @@ async function decideToolCall(tool, input, directory, probe, reason = DENY_REASO
|
|
|
1884
2078
|
}
|
|
1885
2079
|
|
|
1886
2080
|
// plugins/speckit-beads/opencode/src/tools.ts
|
|
1887
|
-
import { isAbsolute as
|
|
2081
|
+
import { isAbsolute as isAbsolute9, resolve as resolve9 } from "path";
|
|
1888
2082
|
|
|
1889
2083
|
// plugins/speckit-beads/opencode/src/spec-start.ts
|
|
1890
2084
|
var APPROVAL_QUESTION = "Require routine human approval checkpoints for this spec/run? Yes or no.";
|
|
@@ -2235,7 +2429,7 @@ async function startSpec(input, command) {
|
|
|
2235
2429
|
import { spawn } from "child_process";
|
|
2236
2430
|
import { randomUUID } from "crypto";
|
|
2237
2431
|
import { realpathSync as realpathSync4 } from "fs";
|
|
2238
|
-
import { join as
|
|
2432
|
+
import { join as join9 } from "path";
|
|
2239
2433
|
|
|
2240
2434
|
// lib/src/bd-embedded-write-lock.ts
|
|
2241
2435
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
@@ -2243,13 +2437,13 @@ import {
|
|
|
2243
2437
|
closeSync as closeSync3,
|
|
2244
2438
|
existsSync as existsSync5,
|
|
2245
2439
|
openSync as openSync3,
|
|
2246
|
-
readFileSync as
|
|
2247
|
-
statSync as
|
|
2440
|
+
readFileSync as readFileSync5,
|
|
2441
|
+
statSync as statSync5,
|
|
2248
2442
|
unlinkSync,
|
|
2249
2443
|
writeSync
|
|
2250
2444
|
} from "fs";
|
|
2251
2445
|
import { hostname } from "os";
|
|
2252
|
-
import { basename as basename4, dirname as dirname6, isAbsolute as
|
|
2446
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute8, join as join8, resolve as resolve8 } from "path";
|
|
2253
2447
|
|
|
2254
2448
|
// lib/src/backoff.ts
|
|
2255
2449
|
var POLL_MS = 20;
|
|
@@ -2303,18 +2497,18 @@ function flagEnabled(tokens, names) {
|
|
|
2303
2497
|
var TRUTHY = { "": true, "1": true, t: true, T: true, TRUE: true, true: true, True: true };
|
|
2304
2498
|
|
|
2305
2499
|
// lib/src/beads-ledger.ts
|
|
2306
|
-
import { realpathSync as realpathSync2, statSync as
|
|
2307
|
-
import { isAbsolute as
|
|
2500
|
+
import { realpathSync as realpathSync2, statSync as statSync3 } from "fs";
|
|
2501
|
+
import { isAbsolute as isAbsolute6, join as join7, resolve as resolve6 } from "path";
|
|
2308
2502
|
|
|
2309
2503
|
// lib/src/bounded-read.ts
|
|
2310
|
-
import { closeSync as closeSync2, constants as
|
|
2504
|
+
import { closeSync as closeSync2, constants as constants3, fstatSync as fstatSync2, lstatSync as lstatSync4, openSync as openSync2, readSync } from "fs";
|
|
2311
2505
|
var MAX_LEDGER_FILE_BYTES = 64 * 1024;
|
|
2312
2506
|
function readBoundedBytes(path, maxBytes) {
|
|
2313
2507
|
let fd;
|
|
2314
2508
|
try {
|
|
2315
|
-
if (!
|
|
2509
|
+
if (!lstatSync4(path).isFile())
|
|
2316
2510
|
return { kind: "unreadable", reason: "not-regular" };
|
|
2317
|
-
fd = openSync2(path,
|
|
2511
|
+
fd = openSync2(path, constants3.O_RDONLY | constants3.O_NOFOLLOW | constants3.O_NONBLOCK);
|
|
2318
2512
|
const info = fstatSync2(fd);
|
|
2319
2513
|
if (!info.isFile())
|
|
2320
2514
|
return { kind: "unreadable", reason: "not-regular" };
|
|
@@ -2349,7 +2543,7 @@ function readBounded(path, maxBytes = MAX_LEDGER_FILE_BYTES) {
|
|
|
2349
2543
|
// lib/src/beads-ledger.ts
|
|
2350
2544
|
function isDirectory2(path) {
|
|
2351
2545
|
try {
|
|
2352
|
-
return
|
|
2546
|
+
return statSync3(path).isDirectory();
|
|
2353
2547
|
} catch {
|
|
2354
2548
|
return false;
|
|
2355
2549
|
}
|
|
@@ -2358,14 +2552,14 @@ function canonicalPath(path) {
|
|
|
2358
2552
|
try {
|
|
2359
2553
|
return realpathSync2(path);
|
|
2360
2554
|
} catch {
|
|
2361
|
-
return
|
|
2555
|
+
return resolve6(path);
|
|
2362
2556
|
}
|
|
2363
2557
|
}
|
|
2364
2558
|
|
|
2365
2559
|
// lib/src/beads-store.ts
|
|
2366
2560
|
import { spawnSync } from "child_process";
|
|
2367
|
-
import { lstatSync as
|
|
2368
|
-
import { basename as basename3, dirname as dirname5, isAbsolute as
|
|
2561
|
+
import { lstatSync as lstatSync5, realpathSync as realpathSync3, statSync as statSync4 } from "fs";
|
|
2562
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute7, resolve as resolve7 } from "path";
|
|
2369
2563
|
function repoIdentity(cwd) {
|
|
2370
2564
|
if (cwd.includes("\x00"))
|
|
2371
2565
|
return;
|
|
@@ -2384,7 +2578,7 @@ function repoIdentity(cwd) {
|
|
|
2384
2578
|
}
|
|
2385
2579
|
const out = String(result.stdout ?? "").trim();
|
|
2386
2580
|
try {
|
|
2387
|
-
return realpathSync3(
|
|
2581
|
+
return realpathSync3(isAbsolute7(out) ? out : resolve7(cwd, out));
|
|
2388
2582
|
} catch {
|
|
2389
2583
|
return;
|
|
2390
2584
|
}
|
|
@@ -2398,7 +2592,7 @@ function repositoryState(cwd) {
|
|
|
2398
2592
|
}
|
|
2399
2593
|
for (;; ) {
|
|
2400
2594
|
try {
|
|
2401
|
-
|
|
2595
|
+
lstatSync5(resolve7(current, ".git"));
|
|
2402
2596
|
return "present";
|
|
2403
2597
|
} catch (error) {
|
|
2404
2598
|
if (!(error instanceof Error) || !("code" in error) || error.code !== "ENOENT")
|
|
@@ -2411,19 +2605,19 @@ function repositoryState(cwd) {
|
|
|
2411
2605
|
}
|
|
2412
2606
|
}
|
|
2413
2607
|
function sessionPinCandidates(cwd) {
|
|
2414
|
-
const local =
|
|
2608
|
+
const local = resolve7(cwd, ".beads");
|
|
2415
2609
|
const common = repoIdentity(cwd);
|
|
2416
2610
|
if (common === undefined)
|
|
2417
2611
|
return [];
|
|
2418
2612
|
if (common !== cwd && common.endsWith("/.git")) {
|
|
2419
|
-
const primaryRoot =
|
|
2613
|
+
const primaryRoot = resolve7(common, "..");
|
|
2420
2614
|
try {
|
|
2421
2615
|
if (realpathSync3(cwd) === primaryRoot)
|
|
2422
2616
|
return [local];
|
|
2423
2617
|
} catch {
|
|
2424
2618
|
return [];
|
|
2425
2619
|
}
|
|
2426
|
-
return [
|
|
2620
|
+
return [resolve7(primaryRoot, ".beads"), local];
|
|
2427
2621
|
}
|
|
2428
2622
|
return [local];
|
|
2429
2623
|
}
|
|
@@ -2434,13 +2628,13 @@ function sessionPinFor(cwd) {
|
|
|
2434
2628
|
return existingStore(sessionPinCandidates(cwd));
|
|
2435
2629
|
}
|
|
2436
2630
|
function storeFromBeadsDb(value, cwd) {
|
|
2437
|
-
const path =
|
|
2631
|
+
const path = resolve7(cwd, value);
|
|
2438
2632
|
return basename3(path) === ".beads" ? path : dirname5(path);
|
|
2439
2633
|
}
|
|
2440
2634
|
function ambientStore(cwd, env, walkUp = sessionPinFor) {
|
|
2441
2635
|
const dir = env.BEADS_DIR;
|
|
2442
2636
|
if (dir !== undefined && dir !== "")
|
|
2443
|
-
return
|
|
2637
|
+
return resolve7(cwd, dir);
|
|
2444
2638
|
const found = walkUp(cwd);
|
|
2445
2639
|
if (found !== undefined)
|
|
2446
2640
|
return found;
|
|
@@ -2481,7 +2675,7 @@ function processStartIdentity(pid) {
|
|
|
2481
2675
|
return identityForTests(pid);
|
|
2482
2676
|
try {
|
|
2483
2677
|
if (process.platform === "linux") {
|
|
2484
|
-
const stat =
|
|
2678
|
+
const stat = readFileSync5(`/proc/${pid}/stat`, "utf8");
|
|
2485
2679
|
const identity = parseLinuxStatStartIdentity(stat);
|
|
2486
2680
|
if (identity !== undefined)
|
|
2487
2681
|
return identity;
|
|
@@ -2539,25 +2733,25 @@ function selectedStoreFor(globals, cwd, env) {
|
|
|
2539
2733
|
const target = absolute(db, base);
|
|
2540
2734
|
if (!existsSync5(target))
|
|
2541
2735
|
return;
|
|
2542
|
-
return isDirectory2(target) ? target :
|
|
2736
|
+
return isDirectory2(target) ? target : join8(target, "..");
|
|
2543
2737
|
}
|
|
2544
2738
|
if (directory !== undefined)
|
|
2545
2739
|
return sessionPinFor(base);
|
|
2546
2740
|
return ambientStore(cwd, env);
|
|
2547
2741
|
}
|
|
2548
2742
|
function absolute(path, cwd) {
|
|
2549
|
-
return
|
|
2743
|
+
return isAbsolute8(path) ? path : resolve8(cwd, path);
|
|
2550
2744
|
}
|
|
2551
2745
|
function canonicalStore(store) {
|
|
2552
2746
|
return store === undefined ? undefined : canonicalPath(store);
|
|
2553
2747
|
}
|
|
2554
2748
|
function embedded(store) {
|
|
2555
2749
|
for (const file of ["metadata.json", "config.yaml"]) {
|
|
2556
|
-
const read = readBounded(
|
|
2750
|
+
const read = readBounded(join8(store, file));
|
|
2557
2751
|
if (read.kind === "unreadable" || read.kind === "text" && read.text !== "")
|
|
2558
2752
|
return true;
|
|
2559
2753
|
}
|
|
2560
|
-
return isDirectory2(
|
|
2754
|
+
return isDirectory2(join8(store, "embeddeddolt"));
|
|
2561
2755
|
}
|
|
2562
2756
|
function embeddedStoreFor(cwd, env = process.env) {
|
|
2563
2757
|
const store = storeFor([], cwd, env);
|
|
@@ -2607,7 +2801,7 @@ var MIGRATE_SKIPS_STORE_INIT = new Set([
|
|
|
2607
2801
|
var LIST_PREFIXES = new Set(["then", "else", "do"]);
|
|
2608
2802
|
function ageOf(path) {
|
|
2609
2803
|
try {
|
|
2610
|
-
return Date.now() -
|
|
2804
|
+
return Date.now() - statSync5(path).mtimeMs;
|
|
2611
2805
|
} catch {
|
|
2612
2806
|
return 0;
|
|
2613
2807
|
}
|
|
@@ -2726,7 +2920,7 @@ function wakeHead(lock) {
|
|
|
2726
2920
|
registry().queues.get(lock)?.[0]?.wake?.();
|
|
2727
2921
|
}
|
|
2728
2922
|
async function hold(store, owner, waitMs = WAIT_MS, signal) {
|
|
2729
|
-
const lock =
|
|
2923
|
+
const lock = join8(store, LOCK_NAME);
|
|
2730
2924
|
const { owned, queues } = registry();
|
|
2731
2925
|
const deadline = Date.now() + waitMs;
|
|
2732
2926
|
let attempt = 0;
|
|
@@ -2772,7 +2966,7 @@ async function hold(store, owner, waitMs = WAIT_MS, signal) {
|
|
|
2772
2966
|
reason: `Beads embedded write lock could not be taken at ${lock} (${code ?? "unknown error"}). The write was refused rather than risk a second writer on the embedded Dolt journal.`
|
|
2773
2967
|
};
|
|
2774
2968
|
}
|
|
2775
|
-
const steal =
|
|
2969
|
+
const steal = join8(store, STEAL_NAME);
|
|
2776
2970
|
const unsafe = unsafeRecord(lock) ? lock : unsafeRecord(steal) ? steal : undefined;
|
|
2777
2971
|
if (unsafe !== undefined) {
|
|
2778
2972
|
return {
|
|
@@ -2817,7 +3011,7 @@ async function hold(store, owner, waitMs = WAIT_MS, signal) {
|
|
|
2817
3011
|
}
|
|
2818
3012
|
}
|
|
2819
3013
|
function withOwnership(storeLock, token, change) {
|
|
2820
|
-
const steal =
|
|
3014
|
+
const steal = join8(dirname6(storeLock), STEAL_NAME);
|
|
2821
3015
|
let fd;
|
|
2822
3016
|
try {
|
|
2823
3017
|
fd = openSync3(steal, "wx");
|
|
@@ -2839,7 +3033,7 @@ function withOwnership(storeLock, token, change) {
|
|
|
2839
3033
|
}
|
|
2840
3034
|
}
|
|
2841
3035
|
function release(store, owner) {
|
|
2842
|
-
const lock =
|
|
3036
|
+
const lock = join8(store, LOCK_NAME);
|
|
2843
3037
|
const owned = registry().owned;
|
|
2844
3038
|
const held = owned.get(lock);
|
|
2845
3039
|
if (held === undefined)
|
|
@@ -2933,7 +3127,7 @@ async function runSpecStart(options, signal, commandMs = COMMAND_MS, module = BE
|
|
|
2933
3127
|
const cwd = realpathSync4(options.workspace);
|
|
2934
3128
|
const env = {
|
|
2935
3129
|
...process.env,
|
|
2936
|
-
BEADS_DIR: realpathSync4(
|
|
3130
|
+
BEADS_DIR: realpathSync4(join9(cwd, ".beads")),
|
|
2937
3131
|
GIT_TERMINAL_PROMPT: "0",
|
|
2938
3132
|
SSH_ASKPASS: "/usr/bin/false",
|
|
2939
3133
|
SSH_ASKPASS_REQUIRE: "force",
|
|
@@ -3102,14 +3296,14 @@ var START_INPUT = {
|
|
|
3102
3296
|
};
|
|
3103
3297
|
var START_DESCRIPTION = `Start or resume a spec workflow, with an explicit routine approval choice from the user before pouring.
|
|
3104
3298
|
` + "Persists and reads back the answer, reuses it on resume, and requires separate consent to migrate an existing gated run. Nests a new run under the spec's feature epic and titles it <spec> (<profile>); moving an existing unparented run needs the user's yes to REPARENT_REQUIRED. Refuses an epic that blocks on a step of the run, and warns when the epic's open blocks edges would hide the run from bd ready. Holds the Beads store's write lock for the whole start. Returns CHOICE_REQUIRED, MIGRATION_REQUIRED or REPARENT_REQUIRED with a question to ask the user, READY when the run can advance, or INCOMPLETE (store-lock wait ran out, a bd command passed its bound, or cancellation) with the step reached and whether a pour was issued; inspect the run before retrying. Reviews, tests and safety confirmations remain required.";
|
|
3105
|
-
var within = (base, path) => path === undefined ? base :
|
|
3299
|
+
var within = (base, path) => path === undefined ? base : isAbsolute9(path) ? path : resolve9(base, path);
|
|
3106
3300
|
var record = (input) => input !== null && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
3107
3301
|
function toolDirectory(input, session, speckitWorkspace) {
|
|
3108
3302
|
return record(input).workspace === undefined ? speckitWorkspace(session) ?? session : session;
|
|
3109
3303
|
}
|
|
3110
3304
|
function setupTarget(input, directory) {
|
|
3111
3305
|
const workspace = record(input).workspace;
|
|
3112
|
-
return typeof workspace === "string" && workspace !== "" ?
|
|
3306
|
+
return typeof workspace === "string" && workspace !== "" ? resolve9(directory, workspace) : directory;
|
|
3113
3307
|
}
|
|
3114
3308
|
var SETUP_KEYS = new Set(Object.keys(setupInput("").properties));
|
|
3115
3309
|
function readSetupParams(input) {
|
|
@@ -3212,7 +3406,7 @@ async function executeStart(input, directory, signal, lock = BEADS_LOCK) {
|
|
|
3212
3406
|
|
|
3213
3407
|
// plugins/speckit-beads/pi-src/ready-watch.ts
|
|
3214
3408
|
import { execFile } from "child_process";
|
|
3215
|
-
import { resolve as
|
|
3409
|
+
import { resolve as resolve10 } from "path";
|
|
3216
3410
|
import { promisify } from "util";
|
|
3217
3411
|
|
|
3218
3412
|
// lib/src/beads-pin.ts
|
|
@@ -3294,7 +3488,7 @@ async function watchLedger(cwd, env = process.env) {
|
|
|
3294
3488
|
const store = pinnedEnvironment(cwd, env).BEADS_DIR;
|
|
3295
3489
|
if (store === undefined || store === "")
|
|
3296
3490
|
throw new Error("No Beads ledger resolves for this checkout");
|
|
3297
|
-
return
|
|
3491
|
+
return resolve10(cwd, store);
|
|
3298
3492
|
}
|
|
3299
3493
|
function watchEnv(ledger, base = process.env) {
|
|
3300
3494
|
const env = {
|
|
@@ -3399,7 +3593,7 @@ function createReadyWatch(scope, options) {
|
|
|
3399
3593
|
|
|
3400
3594
|
// plugins/speckit-beads/pi-src/routes.ts
|
|
3401
3595
|
import { homedir as homedir2 } from "os";
|
|
3402
|
-
import { isAbsolute as
|
|
3596
|
+
import { isAbsolute as isAbsolute10, resolve as resolve11 } from "path";
|
|
3403
3597
|
var WORKFLOW_SECTION = "speckit_workflow";
|
|
3404
3598
|
var MESSAGE_TYPE = "speckit-beads";
|
|
3405
3599
|
function guardReason(settingsPath) {
|
|
@@ -3431,7 +3625,7 @@ User input: ${command.args}` };
|
|
|
3431
3625
|
function toolPath(path, cwd) {
|
|
3432
3626
|
const plain = path.startsWith("@") ? path.slice(1) : path;
|
|
3433
3627
|
const expanded = plain === "~" ? homedir2() : plain.startsWith("~/") ? `${homedir2()}${plain.slice(1)}` : plain;
|
|
3434
|
-
return
|
|
3628
|
+
return isAbsolute10(expanded) ? expanded : resolve11(cwd, expanded);
|
|
3435
3629
|
}
|
|
3436
3630
|
function readCommand(path) {
|
|
3437
3631
|
const normal = path.replaceAll("\\", "/");
|
|
@@ -3467,7 +3661,7 @@ function notify(ctx, message) {
|
|
|
3467
3661
|
`);
|
|
3468
3662
|
}
|
|
3469
3663
|
function setupSpeckitPi(pi, deps = {}) {
|
|
3470
|
-
const settingsPath = deps.settingsPath ??
|
|
3664
|
+
const settingsPath = deps.settingsPath ?? join10(getAgentDir(), PI_SETTINGS_FILE);
|
|
3471
3665
|
const loaded = loadPiPluginSettings(settingsPath, "speckit-beads", "the defaults apply");
|
|
3472
3666
|
const options = parseOptions(loaded.options, PI_INTEGRATION);
|
|
3473
3667
|
const probe = deps.probe ?? ((directory) => beadsActive(directory));
|
package/package.json
CHANGED