@orkestrel/scaffold 0.0.16 → 0.0.18
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 +13 -3
- package/dist/bin/scaffold.js +67 -31
- package/dist/bin/scaffold.js.map +1 -1
- package/dist/host/claude/agents/orkestrel.md +14 -14
- package/dist/host/guides/src/scaffold.md +55 -18
- package/dist/host/tests/setupPolicy.ts +4 -3
- package/dist/src/core/index.cjs +196 -62
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +3 -3
- package/dist/src/core/index.d.ts +3 -3
- package/dist/src/core/index.js +196 -62
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +51 -33
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +10 -6
- package/dist/src/server/index.d.ts +10 -6
- package/dist/src/server/index.js +49 -31
- package/dist/src/server/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -957,16 +957,16 @@ function packageShortName(name) {
|
|
|
957
957
|
return name.startsWith("@orkestrel/") ? name.slice(11) : name;
|
|
958
958
|
}
|
|
959
959
|
/**
|
|
960
|
-
* Read bounded physical local guide mirrors for
|
|
960
|
+
* Read bounded physical local guide mirrors for package names.
|
|
961
961
|
*
|
|
962
962
|
* @param target - The package root.
|
|
963
|
-
* @param
|
|
964
|
-
* @returns Existing guide content keyed by
|
|
963
|
+
* @param names - The package names whose mirrors are eligible.
|
|
964
|
+
* @returns Existing guide content keyed by package name.
|
|
965
965
|
*/
|
|
966
|
-
function readGuideReferences(target,
|
|
966
|
+
function readGuideReferences(target, names) {
|
|
967
967
|
const current = {};
|
|
968
|
-
for (const
|
|
969
|
-
const path = `guides/src/${packageShortName(
|
|
968
|
+
for (const name of names) {
|
|
969
|
+
const path = `guides/src/${packageShortName(name)}.md`;
|
|
970
970
|
const full = resolvePhysicalPath(target, path, "TARGET", "target");
|
|
971
971
|
const status = (0, _orkestrel_contract.attempt)(() => (0, node_fs.lstatSync)(full));
|
|
972
972
|
if (!status.success) {
|
|
@@ -977,7 +977,7 @@ function readGuideReferences(target, dependencies) {
|
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
979
|
if (!status.value.isFile() || status.value.isSymbolicLink() || status.value.nlink !== 1) throw new _src_core.ScaffoldError("TARGET", `Local guide is not a physical file at ${path}`, { path });
|
|
980
|
-
current[
|
|
980
|
+
current[name] = readFileText(target, path, "TARGET", "target");
|
|
981
981
|
}
|
|
982
982
|
return Object.freeze(current);
|
|
983
983
|
}
|
|
@@ -1022,11 +1022,11 @@ function syncReportOf(target, guides, versions) {
|
|
|
1022
1022
|
* ```
|
|
1023
1023
|
*/
|
|
1024
1024
|
function hostRoot() {
|
|
1025
|
-
let dir = (0, node_path.dirname)((0, node_url.fileURLToPath)(
|
|
1025
|
+
let dir = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
1026
1026
|
for (;;) {
|
|
1027
1027
|
if ((0, node_fs.existsSync)((0, node_path.join)(dir, "package.json"))) return (0, node_path.join)(dir, "dist", "host");
|
|
1028
1028
|
const parent = (0, node_path.dirname)(dir);
|
|
1029
|
-
if (parent === dir) throw new _src_core.ScaffoldError("TARGET", "No package root found above the module location", { module:
|
|
1029
|
+
if (parent === dir) throw new _src_core.ScaffoldError("TARGET", "No package root found above the module location", { module: require("url").pathToFileURL(__filename).href });
|
|
1030
1030
|
dir = parent;
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
@@ -3516,8 +3516,10 @@ var Materializer = class {
|
|
|
3516
3516
|
* map, a fetched guide byte-equal to its entry verdicts `current`, anything
|
|
3517
3517
|
* differing or absent from the map verdicts `behind`; WITHOUT the map, every
|
|
3518
3518
|
* successful fetch verdicts `behind` (no reference means it needs syncing).
|
|
3519
|
-
* `pull` builds that map itself from the TARGET's
|
|
3520
|
-
*
|
|
3519
|
+
* `pull` builds that map itself from the TARGET's declared dependency mirrors;
|
|
3520
|
+
* `mirror` builds it from the registry's exact organization package list,
|
|
3521
|
+
* excluding the target's own guide and issuing no registry version reads. Both
|
|
3522
|
+
* verdicts are target-relative; `write` commits only the
|
|
3521
3523
|
* `behind` guides (never `current`, `missing`, or `failed`, which carries no
|
|
3522
3524
|
* trustworthy content) under the same realpath-anchored containment law
|
|
3523
3525
|
* `Materializer` enforces. After `destroy()` every method throws `DESTROYED`;
|
|
@@ -3575,29 +3577,30 @@ var Sync = class Sync {
|
|
|
3575
3577
|
}
|
|
3576
3578
|
async guides(deps, current) {
|
|
3577
3579
|
this.#ensureAlive();
|
|
3578
|
-
|
|
3580
|
+
const parsed = parseSyncDependencies(deps, false);
|
|
3581
|
+
return this.#guides(parsed.map((dependency) => dependency.name), current, Float64Array.of(this.#budget));
|
|
3579
3582
|
}
|
|
3580
3583
|
async versions(deps) {
|
|
3581
3584
|
this.#ensureAlive();
|
|
3582
3585
|
return this.#versions(deps, Float64Array.of(this.#budget));
|
|
3583
3586
|
}
|
|
3584
|
-
#guides(
|
|
3585
|
-
const parsed =
|
|
3587
|
+
#guides(names, current, allowance) {
|
|
3588
|
+
const parsed = parseSyncNames(names);
|
|
3586
3589
|
if (parsed.length > this.#items) throw new _src_core.ScaffoldError("INVALID", "Sync dependency count exceeds its item limit", {
|
|
3587
3590
|
items: parsed.length,
|
|
3588
3591
|
limit: this.#items
|
|
3589
3592
|
});
|
|
3590
|
-
const reference = parseSyncCurrent(current, parsed
|
|
3591
|
-
return Sync.#runPool(parsed, this.#concurrency, async (
|
|
3592
|
-
const short = packageShortName(
|
|
3593
|
+
const reference = parseSyncCurrent(current, parsed, this.#budget);
|
|
3594
|
+
return Sync.#runPool(parsed, this.#concurrency, async (name) => {
|
|
3595
|
+
const short = packageShortName(name);
|
|
3593
3596
|
const url = this.#guideUrl(short);
|
|
3594
3597
|
const outcome = await Sync.#fetchText(url, this.#guidesTimeout, this.#retries, this.#limit, allowance, this.#controller.signal);
|
|
3595
|
-
const guide = Sync.#toGuideSync(
|
|
3598
|
+
const guide = Sync.#toGuideSync(name, short, outcome, reference);
|
|
3596
3599
|
if (outcome.kind === "failed") this.#emitter.emit("error", outcome.error);
|
|
3597
|
-
this.#emitter.emit("guide",
|
|
3600
|
+
this.#emitter.emit("guide", name);
|
|
3598
3601
|
if (this.#strict && (guide.freshness === "missing" || guide.freshness === "failed")) throw new _src_core.ScaffoldError("FETCH", `Failed to fetch guide at ${url}`, {
|
|
3599
3602
|
url,
|
|
3600
|
-
name
|
|
3603
|
+
name
|
|
3601
3604
|
});
|
|
3602
3605
|
return guide;
|
|
3603
3606
|
});
|
|
@@ -3661,16 +3664,9 @@ var Sync = class Sync {
|
|
|
3661
3664
|
*/
|
|
3662
3665
|
async catalog() {
|
|
3663
3666
|
this.#ensureAlive();
|
|
3664
|
-
const orgUrl = this.#orgUrl();
|
|
3665
3667
|
const allowance = Float64Array.of(this.#budget);
|
|
3666
|
-
const
|
|
3667
|
-
|
|
3668
|
-
if (names.length > this.#items) throw new _src_core.ScaffoldError("FETCH", `Package list at ${orgUrl} exceeds the item limit`, {
|
|
3669
|
-
url: orgUrl,
|
|
3670
|
-
items: names.length,
|
|
3671
|
-
limit: this.#items
|
|
3672
|
-
});
|
|
3673
|
-
return [...await Sync.#runPool(names, this.#concurrency, async (name) => {
|
|
3668
|
+
const names = await this.#packages(allowance);
|
|
3669
|
+
return await Sync.#runPool(names, this.#concurrency, async (name) => {
|
|
3674
3670
|
const packumentOutcome = await Sync.#fetchText(this.#registryUrl(name), this.#registryTimeout, this.#retries, this.#limit, allowance, this.#controller.signal);
|
|
3675
3671
|
const packument = Sync.#toPackument(packumentOutcome);
|
|
3676
3672
|
const short = packageShortName(name);
|
|
@@ -3686,7 +3682,7 @@ var Sync = class Sync {
|
|
|
3686
3682
|
version: packument.version,
|
|
3687
3683
|
description
|
|
3688
3684
|
};
|
|
3689
|
-
})
|
|
3685
|
+
});
|
|
3690
3686
|
}
|
|
3691
3687
|
async pull(target, dependencies) {
|
|
3692
3688
|
this.#ensureAlive();
|
|
@@ -3695,10 +3691,21 @@ var Sync = class Sync {
|
|
|
3695
3691
|
const deps = dependencies === void 0 ? declared : parseSyncDependencies(dependencies, false);
|
|
3696
3692
|
if (dependencies !== void 0 && deps.some((dependency) => !declared.some((candidate) => candidate.name === dependency.name && candidate.range === dependency.range))) throw new _src_core.ScaffoldError("INVALID", "Sync pull selection is not declared by the target");
|
|
3697
3693
|
const name = (0, _src_core.manifestToName)(manifest);
|
|
3698
|
-
const
|
|
3699
|
-
const current = readGuideReferences(target,
|
|
3694
|
+
const guideNames = deps.map((dependency) => dependency.name).filter((dependency) => dependency !== name);
|
|
3695
|
+
const current = readGuideReferences(target, guideNames);
|
|
3700
3696
|
const allowance = Float64Array.of(this.#budget);
|
|
3701
|
-
const report = syncReportOf(target, await this.#guides(
|
|
3697
|
+
const report = syncReportOf(target, await this.#guides(guideNames, current, allowance), await this.#versions(deps, allowance));
|
|
3698
|
+
this.#emitter.emit("done", report);
|
|
3699
|
+
return report;
|
|
3700
|
+
}
|
|
3701
|
+
async mirror(target) {
|
|
3702
|
+
this.#ensureAlive();
|
|
3703
|
+
const manifest = readManifest(target);
|
|
3704
|
+
const name = (0, _src_core.manifestToName)(manifest);
|
|
3705
|
+
const allowance = Float64Array.of(this.#budget);
|
|
3706
|
+
const names = (await this.#packages(allowance)).filter((candidate) => candidate !== name);
|
|
3707
|
+
const current = readGuideReferences(target, names);
|
|
3708
|
+
const report = syncReportOf(target, await this.#guides(names, current, allowance), []);
|
|
3702
3709
|
this.#emitter.emit("done", report);
|
|
3703
3710
|
return report;
|
|
3704
3711
|
}
|
|
@@ -3791,6 +3798,17 @@ var Sync = class Sync {
|
|
|
3791
3798
|
#orgUrl() {
|
|
3792
3799
|
return `${this.#registryBase}/-/org/orkestrel/package`;
|
|
3793
3800
|
}
|
|
3801
|
+
async #packages(allowance) {
|
|
3802
|
+
const url = this.#orgUrl();
|
|
3803
|
+
const outcome = await Sync.#fetchText(url, this.#registryTimeout, this.#retries, this.#limit, allowance, this.#controller.signal);
|
|
3804
|
+
const names = Sync.#toOrgPackages(outcome, url);
|
|
3805
|
+
if (names.length > this.#items) throw new _src_core.ScaffoldError("FETCH", `Package list at ${url} exceeds the item limit`, {
|
|
3806
|
+
url,
|
|
3807
|
+
items: names.length,
|
|
3808
|
+
limit: this.#items
|
|
3809
|
+
});
|
|
3810
|
+
return [...names].sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
3811
|
+
}
|
|
3794
3812
|
static async #runPool(items, concurrency, worker) {
|
|
3795
3813
|
const results = new Array(items.length);
|
|
3796
3814
|
const state = {
|