@radicaltools/cli 0.3.2 → 0.3.4
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/README.md +4 -5
- package/dist/index.js +78 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -588,11 +588,10 @@ world, seed, path and length that replay it, the steps and what differs.
|
|
|
588
588
|
`--no-known` lets the fuzz files' known failures filter nothing, `--no-shrink`
|
|
589
589
|
reports the first failure as found.
|
|
590
590
|
|
|
591
|
-
A fuzz file is written with the engine,
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
scenario or a fitness function can name in its Metrics.
|
|
591
|
+
A fuzz file is written with the engine,
|
|
592
|
+
[`@radicaltools/crucible`](https://www.npmjs.com/package/@radicaltools/crucible). It reports
|
|
593
|
+
a test case per world and one per world and rule (`on the bookstore model: undoRestores
|
|
594
|
+
holds`), which `radical verify` can bind to a scenario or a fitness function.
|
|
596
595
|
|
|
597
596
|
Exit status: 0 every file passed, 1 one failed, 2 radical fuzz could not run.
|
|
598
597
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// <define:__RADICAL_BUILD__>
|
|
4
|
-
var define_RADICAL_BUILD_default = { version: "0.3.
|
|
4
|
+
var define_RADICAL_BUILD_default = { version: "0.3.4", commit: "1a00a35", date: "2026-11-06", release: true };
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
7
|
import { spawn as spawn8 } from "child_process";
|
|
@@ -3461,7 +3461,12 @@ function parseRepositoryFile(text3, file = REPOSITORY_FILE) {
|
|
|
3461
3461
|
};
|
|
3462
3462
|
const tests = settings("tests", ["include", "exclude"]);
|
|
3463
3463
|
const ci = settings("ci", ["artifacts"]);
|
|
3464
|
+
const model = raw?.model;
|
|
3465
|
+
if (model !== void 0 && (typeof model?.repo !== "string" || !model.repo || model.ref !== void 0 && typeof model.ref !== "string")) {
|
|
3466
|
+
throw new Error(`${file}: "model" needs "repo" (the address of the model's repository), and "ref" is a branch or tag`);
|
|
3467
|
+
}
|
|
3464
3468
|
return {
|
|
3469
|
+
...model ? { model: { repo: model.repo, ...model.ref ? { ref: model.ref } : {} } } : {},
|
|
3465
3470
|
...tests ? { tests } : {},
|
|
3466
3471
|
...ci ? { ci } : {},
|
|
3467
3472
|
implements: list("implements").map((e2, i) => {
|
|
@@ -3487,6 +3492,7 @@ ${lines.join(",\n")}
|
|
|
3487
3492
|
` : ""}]`;
|
|
3488
3493
|
const inline = (v) => `{ ${Object.entries(v).map(([k, list]) => `${JSON.stringify(k)}: [${list.map((x) => JSON.stringify(x)).join(", ")}]`).join(", ")} }`;
|
|
3489
3494
|
const settings = [
|
|
3495
|
+
...file.model ? [` "model": { ${Object.entries(file.model).map(([k, v]) => `${JSON.stringify(k)}: ${JSON.stringify(v)}`).join(", ")} }`] : [],
|
|
3490
3496
|
...file.tests ? [` "tests": ${inline(file.tests)}`] : [],
|
|
3491
3497
|
...file.ci ? [` "ci": ${inline(file.ci)}`] : []
|
|
3492
3498
|
];
|
|
@@ -3511,6 +3517,43 @@ function builtIn(mapped, id, parentOf) {
|
|
|
3511
3517
|
function elementPaths(mapped, id, parentOf) {
|
|
3512
3518
|
return builtIn(mapped, id, parentOf)?.paths ?? [];
|
|
3513
3519
|
}
|
|
3520
|
+
var OTHER_REPOSITORIES = "other repositories";
|
|
3521
|
+
function repositoryPartIds(data, mapped) {
|
|
3522
|
+
const parent = new Map(data.nodes.map((n) => [n.id, n.parentId]));
|
|
3523
|
+
const under = (id, roots) => {
|
|
3524
|
+
for (let at = id; at; at = parent.get(at)) if (roots.has(at)) return true;
|
|
3525
|
+
return false;
|
|
3526
|
+
};
|
|
3527
|
+
const from = (type, targets) => data.relations.filter((r) => r.relationType === type && targets.has(r.targetId)).map((r) => r.sourceId);
|
|
3528
|
+
const to2 = (type, sources) => data.relations.filter((r) => r.relationType === type && sources.has(r.sourceId)).map((r) => r.targetId);
|
|
3529
|
+
const elements = new Set(data.nodes.filter((n) => builtIn(mapped, n.id, (id) => parent.get(id))).map((n) => n.id));
|
|
3530
|
+
const requirements = new Set(to2("satisfies", elements));
|
|
3531
|
+
for (let size = -1; size !== requirements.size; ) {
|
|
3532
|
+
size = requirements.size;
|
|
3533
|
+
for (const id of to2("derives", requirements)) requirements.add(id);
|
|
3534
|
+
}
|
|
3535
|
+
const realised = new Set(to2("realises", elements));
|
|
3536
|
+
const machines = /* @__PURE__ */ new Set([...to2("implements", elements), ...from("lifecycle-of", realised)]);
|
|
3537
|
+
const entities = [...realised, ...to2("lifecycle-of", machines)];
|
|
3538
|
+
const behaviour = data.nodes.filter((n) => under(n.id, machines)).map((n) => n.id);
|
|
3539
|
+
const adrs = new Set(from("constrains", elements));
|
|
3540
|
+
return /* @__PURE__ */ new Set([
|
|
3541
|
+
...elements,
|
|
3542
|
+
...requirements,
|
|
3543
|
+
...entities,
|
|
3544
|
+
...behaviour,
|
|
3545
|
+
...from("verifies", /* @__PURE__ */ new Set([...requirements, ...machines])),
|
|
3546
|
+
...adrs,
|
|
3547
|
+
...from("implements", adrs)
|
|
3548
|
+
]);
|
|
3549
|
+
}
|
|
3550
|
+
function repositoryPart(data, mapped) {
|
|
3551
|
+
const here = repositoryPartIds(data, mapped);
|
|
3552
|
+
return {
|
|
3553
|
+
nodes: data.nodes.map((n) => here.has(n.id) || n.origin ? n : { ...n, origin: OTHER_REPOSITORIES }),
|
|
3554
|
+
relations: data.relations.map((r) => here.has(r.sourceId) && here.has(r.targetId) || r.origin ? r : { ...r, origin: OTHER_REPOSITORIES })
|
|
3555
|
+
};
|
|
3556
|
+
}
|
|
3514
3557
|
|
|
3515
3558
|
// ../../packages/node-files/src/repositoryLayout.ts
|
|
3516
3559
|
var RADICAL_DIR = ".radical";
|
|
@@ -3535,7 +3578,8 @@ async function upwards(from) {
|
|
|
3535
3578
|
const dirs = [];
|
|
3536
3579
|
for (let dir = resolve(from); ; dir = dirname2(dir)) {
|
|
3537
3580
|
dirs.push(dir);
|
|
3538
|
-
|
|
3581
|
+
const checkout = basename(dir) === "model" && basename(dirname2(dir)) === RADICAL_DIR;
|
|
3582
|
+
if (!checkout && await exists(join(dir, ".git")) || dirname2(dir) === dir) return dirs;
|
|
3539
3583
|
}
|
|
3540
3584
|
}
|
|
3541
3585
|
async function repositoryRoot(from) {
|
|
@@ -6524,6 +6568,7 @@ function settingsInModel(config) {
|
|
|
6524
6568
|
function checkData(data, options, config) {
|
|
6525
6569
|
const found = [];
|
|
6526
6570
|
data = { ...data, nodes: withBoundTests(data.nodes, options.repository?.verifies) };
|
|
6571
|
+
if (options.repository?.model) data = { ...data, ...repositoryPart(data, options.repository.implements) };
|
|
6527
6572
|
const nodes = byId(data.nodes);
|
|
6528
6573
|
const relations = byId(data.relations);
|
|
6529
6574
|
staleReferences(data.views ?? [], data.sequences ?? [], data.presentations ?? [], nodes, relations, data.snapshots ?? []).forEach((finding) => found.push({ rule: STALE_REFERENCE, ...finding }));
|
|
@@ -6692,6 +6737,7 @@ function parseDeps(text3) {
|
|
|
6692
6737
|
});
|
|
6693
6738
|
return { name, dependencies: deps };
|
|
6694
6739
|
}
|
|
6740
|
+
var folderInRepository = (path) => path.replace(/^\.(?:\/|$)|\/$/g, "");
|
|
6695
6741
|
var LATEST = "latest";
|
|
6696
6742
|
var originFor = (name, commit) => `${name}@${commit.slice(0, 7)}`;
|
|
6697
6743
|
function composeFederation(own, deps) {
|
|
@@ -11974,6 +12020,14 @@ import { join as join10 } from "path";
|
|
|
11974
12020
|
import { promisify as promisify2 } from "util";
|
|
11975
12021
|
|
|
11976
12022
|
// ../../packages/common/src/modelChanges.ts
|
|
12023
|
+
function onlyPart(report, ids) {
|
|
12024
|
+
const element = (list) => list.filter((e2) => ids.has(e2.id));
|
|
12025
|
+
const relation = (list) => list.filter((r) => ids.has(r.source.id) || ids.has(r.target.id));
|
|
12026
|
+
return {
|
|
12027
|
+
elements: { added: element(report.elements.added), removed: element(report.elements.removed), changed: element(report.elements.changed) },
|
|
12028
|
+
relations: { added: relation(report.relations.added), removed: relation(report.relations.removed), changed: relation(report.relations.changed) }
|
|
12029
|
+
};
|
|
12030
|
+
}
|
|
11977
12031
|
var NOT_MODEL = /* @__PURE__ */ new Set(["id", "x", "y", "width", "height", "collapsed"]);
|
|
11978
12032
|
var SHOWN = /* @__PURE__ */ new Set(["type", "label", "parentId", "sourceId", "targetId", "relationType"]);
|
|
11979
12033
|
var present = (value) => modelValue(value) !== null;
|
|
@@ -12218,8 +12272,12 @@ async function modelChangesSince(folder, current, since, options = {}) {
|
|
|
12218
12272
|
}
|
|
12219
12273
|
const before = { nodes: byId2(old.nodes), relations: byId2(old.relations) };
|
|
12220
12274
|
const after = { nodes: byId2(current.nodes), relations: byId2(current.relations) };
|
|
12221
|
-
|
|
12275
|
+
let report = modelChangeReport(before, after);
|
|
12222
12276
|
const mapping = await readRepositoryMapping(folder).catch(() => null);
|
|
12277
|
+
if (options.part) {
|
|
12278
|
+
if (!mapping) throw new Error("--part needs the repository's .radical/radical.json");
|
|
12279
|
+
report = onlyPart(report, /* @__PURE__ */ new Set([...repositoryPartIds(old, mapping.implements), ...repositoryPartIds(current, mapping.implements)]));
|
|
12280
|
+
}
|
|
12223
12281
|
if (mapping) {
|
|
12224
12282
|
for (const change of [...report.elements.added, ...report.elements.changed, ...report.elements.removed]) {
|
|
12225
12283
|
if (change.type === "scenario" || change.type === "fitness-fn") change.tests = testsBoundTo(mapping.verifies, change.id);
|
|
@@ -12282,7 +12340,7 @@ async function fetchRef(dir, dep) {
|
|
|
12282
12340
|
return git3(dir, ["rev-parse", "FETCH_HEAD^{commit}"]);
|
|
12283
12341
|
}
|
|
12284
12342
|
async function modelFilesAt(dir, commit, path) {
|
|
12285
|
-
const folder = path
|
|
12343
|
+
const folder = folderInRepository(path);
|
|
12286
12344
|
const tree = folder ? `${commit}:${folder}` : `${commit}^{tree}`;
|
|
12287
12345
|
const listing = await gitOk2(dir, ["ls-tree", "-r", "-z", tree]);
|
|
12288
12346
|
if (listing === null) return {};
|
|
@@ -12400,7 +12458,7 @@ async function fetchAll(root, deps) {
|
|
|
12400
12458
|
}
|
|
12401
12459
|
async function locationOf(dep, home) {
|
|
12402
12460
|
const address = repoAddress(dep.repo, home);
|
|
12403
|
-
const folder = dep.path
|
|
12461
|
+
const folder = folderInRepository(dep.path) || ".";
|
|
12404
12462
|
if (!isAddress(address)) return `file:${await realpath3(join12(address, folder)).catch(() => resolve9(address, folder))}`;
|
|
12405
12463
|
return `${addressKey(address)}#${folder}`;
|
|
12406
12464
|
}
|
|
@@ -12634,6 +12692,8 @@ var CHECK_USAGE = `Usage: radical check [folder] [options]
|
|
|
12634
12692
|
|
|
12635
12693
|
Checks a Radical Markdown model folder: its files, its metamodel, and that it
|
|
12636
12694
|
is complete (requirements have scenarios, accepted ADRs fitness functions, \u2026).
|
|
12695
|
+
In a repository whose .radical/radical.json names a model in a repository of
|
|
12696
|
+
its own ("model": { "repo": \u2026 }), it judges that repository's part of the model.
|
|
12637
12697
|
|
|
12638
12698
|
folder the model folder (default: the working directory)
|
|
12639
12699
|
--config <file> rule settings (default: check.json in the model folder,
|
|
@@ -12772,6 +12832,7 @@ ${CHECK_USAGE}`);
|
|
|
12772
12832
|
const mapping = await readRepositoryMapping(root);
|
|
12773
12833
|
repository = mapping && {
|
|
12774
12834
|
file: relative5(io2.cwd, mapping.file),
|
|
12835
|
+
...mapping.model ? { model: mapping.model } : {},
|
|
12775
12836
|
implements: mapping.implements.map((entry) => ({ ...entry, missing: entry.paths.filter((path) => !existsSync2(resolve10(mapping.root, path))) })),
|
|
12776
12837
|
verifies: mapping.verifies,
|
|
12777
12838
|
...mapping.tests ? { tests: mapping.tests } : {},
|
|
@@ -12905,6 +12966,7 @@ ${CHECK_USAGE}`);
|
|
|
12905
12966
|
}
|
|
12906
12967
|
if (values.evidence && result.evidence) await writeBeside(resolve10(io2.cwd, values.evidence), JSON.stringify(result.evidence, null, 2) + "\n");
|
|
12907
12968
|
const options = { folder, verbose: values.verbose };
|
|
12969
|
+
if (repository?.model && values.format !== "json" && !values.quiet) io2.out(`Judged this repository's part of the model of ${repository.model.repo}.`);
|
|
12908
12970
|
if (federation && values.format !== "json" && !values.quiet) {
|
|
12909
12971
|
io2.out(`Checked with ${describeDeps(federation.fetched) || "no other model"} (${DEPS_FILE}).`);
|
|
12910
12972
|
for (const note of federation.notes) io2.out(`Note: ${note}`);
|
|
@@ -12965,6 +13027,10 @@ folding are left out. The MCP server's get_changes tool gives the same list.
|
|
|
12965
13027
|
--since <ref> the git branch, tag or commit to compare with (default:
|
|
12966
13028
|
the merge base with the default branch, origin/main)
|
|
12967
13029
|
--format <format> text (default) or json
|
|
13030
|
+
--part only the repository's part of the model, by its
|
|
13031
|
+
.radical/radical.json, as it is now and as it was at the
|
|
13032
|
+
base: what the repository has left to build when the base
|
|
13033
|
+
is the commit its code has reached
|
|
12968
13034
|
--save-base also save the model at the base to .state/base.json in
|
|
12969
13035
|
the folder, for Studio to show the changes (radical hooks
|
|
12970
13036
|
install keeps it fresh)
|
|
@@ -12981,6 +13047,7 @@ async function diffCommand(args, io2) {
|
|
|
12981
13047
|
since: { type: "string" },
|
|
12982
13048
|
format: { type: "string", default: "text" },
|
|
12983
13049
|
"save-base": { type: "boolean", default: false },
|
|
13050
|
+
part: { type: "boolean", default: false },
|
|
12984
13051
|
quiet: { type: "boolean", default: false },
|
|
12985
13052
|
help: { type: "boolean", short: "h", default: false }
|
|
12986
13053
|
}
|
|
@@ -13005,7 +13072,7 @@ ${DIFF_USAGE}`);
|
|
|
13005
13072
|
const root = await realpath5(resolve11(io2.cwd, folder));
|
|
13006
13073
|
if (!(await stat8(root)).isDirectory()) throw new Error("not a directory");
|
|
13007
13074
|
const data = deserializeFromMdFolder(await new MdFolderSession(diskFolderStorage(root), { writeCache: false }).readAll()).data;
|
|
13008
|
-
const changes = await modelChangesSince(root, data, values.since, { saveBase: values["save-base"] });
|
|
13075
|
+
const changes = await modelChangesSince(root, data, values.since, { saveBase: values["save-base"], part: values.part });
|
|
13009
13076
|
if (values.quiet && values["save-base"]) return 0;
|
|
13010
13077
|
if (values["save-base"]) io2.err(`Saved the base (${changes.base.commit.slice(0, 7)}) to ${folder}/.state/base.json.`);
|
|
13011
13078
|
io2.out(values.format === "json" ? JSON.stringify({ base: changes.base, ...changes.report }, null, 2) : changes.text);
|
|
@@ -15798,8 +15865,11 @@ ${SENSE_USAGE}`);
|
|
|
15798
15865
|
const own = deserializeFromMdFolder(files).data;
|
|
15799
15866
|
const federation = await composeFolder(folder);
|
|
15800
15867
|
const others = federation ? federationOthers(files, federation.fetched) : null;
|
|
15801
|
-
|
|
15802
|
-
|
|
15868
|
+
const mapping = await readRepositoryMapping(folder);
|
|
15869
|
+
const whole = { nodes: [...own.nodes, ...others?.nodes ?? []], relations: [...own.relations, ...others?.relations ?? []] };
|
|
15870
|
+
const part = mapping?.model ? repositoryPart(whole, mapping.implements) : whole;
|
|
15871
|
+
nodes = part.nodes;
|
|
15872
|
+
model = sensorModel(part, federation?.deps.name || basename5(folder), mapping?.implements ?? []);
|
|
15803
15873
|
sensors = await repositorySensors(folder);
|
|
15804
15874
|
} catch (error) {
|
|
15805
15875
|
io2.err(`Cannot read the model folder ${named}: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radicaltools/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Connect coding agents to Radical Markdown architecture models, check, diff and export them, and fuzz a project against them, from the command line.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://radical.tools",
|