@orkestrel/scaffold 0.0.46 → 0.0.47
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/bin/main.js +179 -44
- package/dist/bin/main.js.map +1 -1
- package/dist/host/AGENTS.md +1 -0
- package/dist/host/agents/orchestration.md +3 -1
- package/dist/host/claude/agents/codex.md +4 -4
- package/dist/host/claude/agents/orkestrel.md +4 -4
- package/dist/host/claude/rules/documentation.md +2 -1
- package/dist/host/claude/rules/quality.md +3 -0
- package/dist/host/claude/rules/tests.md +19 -0
- package/dist/host/claude/rules/workspace.md +28 -21
- package/dist/host/claude/settings.json +781 -2
- package/dist/host/configs/policy.ts +167 -10
- package/dist/host/dotfiles/oxlintrc.json +9 -0
- package/dist/host/guides/scaffold.md +143 -44
- package/dist/host/scripts/codex.sh +0 -0
- package/dist/host/scripts/cursor.sh +0 -0
- package/dist/host/scripts/deps.sh +0 -0
- package/dist/host/scripts/ollama.sh +0 -0
- package/dist/host/tests/config.test.ts +126 -11
- package/dist/host/tests/policy.test.ts +7 -0
- package/dist/host/tests/setupPolicy.ts +222 -8
- package/dist/src/core/index.cjs +420 -24
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +102 -9
- package/dist/src/core/index.d.ts +102 -9
- package/dist/src/core/index.js +416 -25
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +41 -49
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +9 -8
- package/dist/src/server/index.d.ts +9 -8
- package/dist/src/server/index.js +42 -50
- package/dist/src/server/index.js.map +1 -1
- package/package.json +8 -6
|
@@ -908,7 +908,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
908
908
|
*/
|
|
909
909
|
catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
|
|
910
910
|
/**
|
|
911
|
-
* Rewrite the
|
|
911
|
+
* Rewrite the declared dependency ranges the caller names in the target's manifest.
|
|
912
912
|
*
|
|
913
913
|
* @param dependencies - The names and ranges the manifest must declare.
|
|
914
914
|
* @param target - The directory to write into.
|
|
@@ -1062,7 +1062,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
|
|
1064
1064
|
/**
|
|
1065
|
-
* Rewrite the
|
|
1065
|
+
* Rewrite the declared dependency ranges the caller names in the target's manifest.
|
|
1066
1066
|
*
|
|
1067
1067
|
* @param dependencies - The names and ranges the manifest must declare.
|
|
1068
1068
|
* @param target - The directory to write into.
|
|
@@ -1630,7 +1630,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1630
1630
|
/** The upstream reader's observation channel. */
|
|
1631
1631
|
get emitter(): EmitterInterface<UpstreamEventMap>;
|
|
1632
1632
|
/**
|
|
1633
|
-
* Look up the
|
|
1633
|
+
* Look up the newest release each declared range admits.
|
|
1634
1634
|
*
|
|
1635
1635
|
* @param dependencies - The declared dependencies to look up.
|
|
1636
1636
|
* @returns One release verdict per dependency, in input order.
|
|
@@ -1639,10 +1639,11 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1639
1639
|
* torn down before or during the call.
|
|
1640
1640
|
*
|
|
1641
1641
|
* @remarks
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1642
|
+
* The reader selects across the packument's stable version map before any
|
|
1643
|
+
* collection bound can truncate it. It falls back to `dist-tags.latest` only
|
|
1644
|
+
* when that version satisfies the declared range. `*` requests the newest
|
|
1645
|
+
* stable version outright. The verdict's `major` field carries the stable
|
|
1646
|
+
* major from the latest tag when that tag can be read.
|
|
1646
1647
|
*
|
|
1647
1648
|
* @example
|
|
1648
1649
|
* ```ts
|
|
@@ -1760,7 +1761,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1760
1761
|
export declare interface UpstreamInterface {
|
|
1761
1762
|
readonly emitter: EmitterInterface<UpstreamEventMap>;
|
|
1762
1763
|
/**
|
|
1763
|
-
* Look up the
|
|
1764
|
+
* Look up the newest release each declared range admits.
|
|
1764
1765
|
*
|
|
1765
1766
|
* @param dependencies - The declared dependencies to look up.
|
|
1766
1767
|
* @returns One release verdict per dependency, in input order.
|
|
@@ -908,7 +908,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
908
908
|
*/
|
|
909
909
|
catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
|
|
910
910
|
/**
|
|
911
|
-
* Rewrite the
|
|
911
|
+
* Rewrite the declared dependency ranges the caller names in the target's manifest.
|
|
912
912
|
*
|
|
913
913
|
* @param dependencies - The names and ranges the manifest must declare.
|
|
914
914
|
* @param target - The directory to write into.
|
|
@@ -1062,7 +1062,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1062
1062
|
*/
|
|
1063
1063
|
catalog(entries: readonly CatalogEntry[], target: string): MaterializeResult;
|
|
1064
1064
|
/**
|
|
1065
|
-
* Rewrite the
|
|
1065
|
+
* Rewrite the declared dependency ranges the caller names in the target's manifest.
|
|
1066
1066
|
*
|
|
1067
1067
|
* @param dependencies - The names and ranges the manifest must declare.
|
|
1068
1068
|
* @param target - The directory to write into.
|
|
@@ -1630,7 +1630,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1630
1630
|
/** The upstream reader's observation channel. */
|
|
1631
1631
|
get emitter(): EmitterInterface<UpstreamEventMap>;
|
|
1632
1632
|
/**
|
|
1633
|
-
* Look up the
|
|
1633
|
+
* Look up the newest release each declared range admits.
|
|
1634
1634
|
*
|
|
1635
1635
|
* @param dependencies - The declared dependencies to look up.
|
|
1636
1636
|
* @returns One release verdict per dependency, in input order.
|
|
@@ -1639,10 +1639,11 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1639
1639
|
* torn down before or during the call.
|
|
1640
1640
|
*
|
|
1641
1641
|
* @remarks
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1642
|
+
* The reader selects across the packument's stable version map before any
|
|
1643
|
+
* collection bound can truncate it. It falls back to `dist-tags.latest` only
|
|
1644
|
+
* when that version satisfies the declared range. `*` requests the newest
|
|
1645
|
+
* stable version outright. The verdict's `major` field carries the stable
|
|
1646
|
+
* major from the latest tag when that tag can be read.
|
|
1646
1647
|
*
|
|
1647
1648
|
* @example
|
|
1648
1649
|
* ```ts
|
|
@@ -1760,7 +1761,7 @@ export declare class Materializer implements MaterializerInterface {
|
|
|
1760
1761
|
export declare interface UpstreamInterface {
|
|
1761
1762
|
readonly emitter: EmitterInterface<UpstreamEventMap>;
|
|
1762
1763
|
/**
|
|
1763
|
-
* Look up the
|
|
1764
|
+
* Look up the newest release each declared range admits.
|
|
1764
1765
|
*
|
|
1765
1766
|
* @param dependencies - The declared dependencies to look up.
|
|
1766
1767
|
* @returns One release verdict per dependency, in input order.
|
package/dist/src/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { andOf, arrayOf, attempt, boundsOf, holds, isArray, isBoolean, isError, isFunction, isInteger, isRecord, isString, parseJSON, parseJSONAs, parseStringField, recordOf, stringOf } from "@orkestrel/contract";
|
|
2
|
-
import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, ScaffoldError, WORKSPACE_OWNED_PATHS, bytesToHex, catalogToLayers, cloneValue, computeBytes, contentToHex, inferGroup, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, nameToGuide, planToFindings } from "../core/index.js";
|
|
2
|
+
import { CATALOG_AGENT_PATH, CONTROL_CHARACTER_PATTERN, EXECUTABLE_PATHS, HOST_PATHS, MAX_ARTIFACT_BYTES, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_REGISTRY_BYTES, MAX_TOTAL_ARTIFACT_BYTES, MAX_TOTAL_REGISTRY_BYTES, ScaffoldError, WORKSPACE_OWNED_PATHS, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, contentToHex, extractRangeMajor, extractVersion, inferGroup, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isMirror, isPath, isPlan, isSnapshot, matchesDriftReachability, matchesRange, nameToGuide, planToFindings, replaceManifestRanges } from "../core/index.js";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { chmodSync, closeSync, constants, copyFileSync, fstatSync, linkSync, lstatSync, mkdirSync, openSync, opendirSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, join, parse, relative, resolve, sep } from "node:path";
|
|
@@ -2425,7 +2425,7 @@ var Materializer = class Materializer {
|
|
|
2425
2425
|
return this.#rewrite(directory, CATALOG_AGENT_PATH, MAX_ARTIFACT_BYTES, this.#recatalog(accepted));
|
|
2426
2426
|
}
|
|
2427
2427
|
/**
|
|
2428
|
-
* Rewrite the
|
|
2428
|
+
* Rewrite the declared dependency ranges the caller names in the target's manifest.
|
|
2429
2429
|
*
|
|
2430
2430
|
* @param dependencies - The names and ranges the manifest must declare.
|
|
2431
2431
|
* @param target - The directory to write into.
|
|
@@ -2924,45 +2924,12 @@ var Materializer = class Materializer {
|
|
|
2924
2924
|
}
|
|
2925
2925
|
#redeclare(dependencies) {
|
|
2926
2926
|
return (text) => {
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
let index = manifest.indexOf(key);
|
|
2932
|
-
let declared = false;
|
|
2933
|
-
while (index >= 0) {
|
|
2934
|
-
const span = this.#span(manifest, index + key.length);
|
|
2935
|
-
if (span === void 0) {
|
|
2936
|
-
index = manifest.indexOf(key, index + key.length);
|
|
2937
|
-
continue;
|
|
2938
|
-
}
|
|
2939
|
-
manifest = manifest.slice(0, span[0]) + range + manifest.slice(span[1]);
|
|
2940
|
-
declared = true;
|
|
2941
|
-
index = manifest.indexOf(key, span[0] + range.length);
|
|
2942
|
-
}
|
|
2943
|
-
if (!declared) throw this.#error("INVALID", `The manifest does not declare ${dependency.name}, so its range cannot be rewritten.`, { name: dependency.name });
|
|
2944
|
-
}
|
|
2945
|
-
return manifest;
|
|
2927
|
+
const manifest = replaceManifestRanges(text, dependencies);
|
|
2928
|
+
if (manifest !== void 0) return manifest;
|
|
2929
|
+
const missing = dependencies.find((dependency) => !text.includes(JSON.stringify(dependency.name)));
|
|
2930
|
+
throw this.#error("INVALID", `The manifest does not declare ${missing?.name ?? "a requested package"}, so its range cannot be rewritten.`, missing === void 0 ? void 0 : { name: missing.name });
|
|
2946
2931
|
};
|
|
2947
2932
|
}
|
|
2948
|
-
#span(text, from) {
|
|
2949
|
-
let index = from;
|
|
2950
|
-
while (index < text.length && /\s/u.test(text.charAt(index))) index += 1;
|
|
2951
|
-
if (text.charAt(index) !== ":") return void 0;
|
|
2952
|
-
index += 1;
|
|
2953
|
-
while (index < text.length && /\s/u.test(text.charAt(index))) index += 1;
|
|
2954
|
-
if (text.charAt(index) !== "\"") return void 0;
|
|
2955
|
-
const start = index;
|
|
2956
|
-
index += 1;
|
|
2957
|
-
while (index < text.length) {
|
|
2958
|
-
if (text.charAt(index) === "\\") {
|
|
2959
|
-
index += 2;
|
|
2960
|
-
continue;
|
|
2961
|
-
}
|
|
2962
|
-
if (text.charAt(index) === "\"") return [start, index + 1];
|
|
2963
|
-
index += 1;
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
2933
|
#finish(result) {
|
|
2967
2934
|
this.#emitter.emit("finish", result);
|
|
2968
2935
|
return result;
|
|
@@ -3027,7 +2994,6 @@ var Upstream = class Upstream {
|
|
|
3027
2994
|
static #defaultTimeout = 1e4;
|
|
3028
2995
|
static #defaultConcurrency = 6;
|
|
3029
2996
|
static #defaultRetries = 0;
|
|
3030
|
-
static #defaultBudget = 16777216;
|
|
3031
2997
|
static #scope = "orkestrel";
|
|
3032
2998
|
static #unreadable = "the answer carries no readable latest version";
|
|
3033
2999
|
static #packument = "application/vnd.npm.install-v1+json";
|
|
@@ -3075,15 +3041,15 @@ var Upstream = class Upstream {
|
|
|
3075
3041
|
this.#registryTimeout = options?.registry?.timeout ?? Upstream.#defaultTimeout;
|
|
3076
3042
|
this.#concurrency = options?.concurrency ?? Upstream.#defaultConcurrency;
|
|
3077
3043
|
this.#retries = options?.retries ?? Upstream.#defaultRetries;
|
|
3078
|
-
this.#limit = options?.limit ??
|
|
3079
|
-
this.#budget = options?.budget ??
|
|
3044
|
+
this.#limit = options?.limit ?? MAX_REGISTRY_BYTES;
|
|
3045
|
+
this.#budget = options?.budget ?? MAX_TOTAL_REGISTRY_BYTES;
|
|
3080
3046
|
}
|
|
3081
3047
|
/** The upstream reader's observation channel. */
|
|
3082
3048
|
get emitter() {
|
|
3083
3049
|
return this.#emitter;
|
|
3084
3050
|
}
|
|
3085
3051
|
/**
|
|
3086
|
-
* Look up the
|
|
3052
|
+
* Look up the newest release each declared range admits.
|
|
3087
3053
|
*
|
|
3088
3054
|
* @param dependencies - The declared dependencies to look up.
|
|
3089
3055
|
* @returns One release verdict per dependency, in input order.
|
|
@@ -3092,10 +3058,11 @@ var Upstream = class Upstream {
|
|
|
3092
3058
|
* torn down before or during the call.
|
|
3093
3059
|
*
|
|
3094
3060
|
* @remarks
|
|
3095
|
-
*
|
|
3096
|
-
*
|
|
3097
|
-
*
|
|
3098
|
-
*
|
|
3061
|
+
* The reader selects across the packument's stable version map before any
|
|
3062
|
+
* collection bound can truncate it. It falls back to `dist-tags.latest` only
|
|
3063
|
+
* when that version satisfies the declared range. `*` requests the newest
|
|
3064
|
+
* stable version outright. The verdict's `major` field carries the stable
|
|
3065
|
+
* major from the latest tag when that tag can be read.
|
|
3099
3066
|
*
|
|
3100
3067
|
* @example
|
|
3101
3068
|
* ```ts
|
|
@@ -3224,17 +3191,21 @@ var Upstream = class Upstream {
|
|
|
3224
3191
|
}
|
|
3225
3192
|
async #release(dependency, allowance) {
|
|
3226
3193
|
const outcome = await this.#read(this.#registryURL(dependency.name), this.#registryTimeout, allowance, Upstream.#packument);
|
|
3227
|
-
const latest = outcome.lookup === "found" ? this.#
|
|
3194
|
+
const latest = outcome.lookup === "found" ? this.#releaseVersion(outcome.content, dependency.range) : void 0;
|
|
3195
|
+
const tagged = outcome.lookup === "found" ? this.#latest(outcome.content) : void 0;
|
|
3196
|
+
const major = tagged === void 0 ? void 0 : extractVersion(tagged)?.[0];
|
|
3228
3197
|
const release = latest === void 0 ? {
|
|
3229
3198
|
name: dependency.name,
|
|
3230
3199
|
range: dependency.range,
|
|
3231
3200
|
lookup: outcome.lookup === "missing" ? "missing" : "failed",
|
|
3232
|
-
note: outcome.lookup === "found" ? Upstream.#unreadable : outcome.note
|
|
3201
|
+
note: outcome.lookup === "found" ? Upstream.#unreadable : outcome.note,
|
|
3202
|
+
...major === void 0 ? {} : { major }
|
|
3233
3203
|
} : {
|
|
3234
3204
|
name: dependency.name,
|
|
3235
3205
|
range: dependency.range,
|
|
3236
3206
|
lookup: "found",
|
|
3237
|
-
latest
|
|
3207
|
+
latest,
|
|
3208
|
+
...major === void 0 ? {} : { major }
|
|
3238
3209
|
};
|
|
3239
3210
|
this.#emitter.emit("release", release);
|
|
3240
3211
|
return release;
|
|
@@ -3319,6 +3290,27 @@ var Upstream = class Upstream {
|
|
|
3319
3290
|
if (latest === void 0 || latest.length === 0 || latest.length > MAX_RANGE_LENGTH) return;
|
|
3320
3291
|
return CONTROL_CHARACTER_PATTERN.test(latest) ? void 0 : latest;
|
|
3321
3292
|
}
|
|
3293
|
+
#releaseVersion(content, range) {
|
|
3294
|
+
const parsed = parseJSON(content);
|
|
3295
|
+
if (!isRecord(parsed)) return void 0;
|
|
3296
|
+
const versions = parsed.versions;
|
|
3297
|
+
let selected;
|
|
3298
|
+
if (isRecord(versions)) for (const version of Object.keys(versions)) {
|
|
3299
|
+
if (!this.#admits(range, version)) continue;
|
|
3300
|
+
if (selected === void 0 || compareVersions(version, selected) > 0) selected = version;
|
|
3301
|
+
}
|
|
3302
|
+
if (selected !== void 0) return selected;
|
|
3303
|
+
const latest = this.#latest(content);
|
|
3304
|
+
return latest !== void 0 && this.#admits(range, latest) ? latest : void 0;
|
|
3305
|
+
}
|
|
3306
|
+
#admits(range, version) {
|
|
3307
|
+
const extracted = extractVersion(version);
|
|
3308
|
+
if (extracted === void 0) return false;
|
|
3309
|
+
if (range === "*") return true;
|
|
3310
|
+
const major = extractRangeMajor(range);
|
|
3311
|
+
if (major !== void 0 && range === `^${String(major)}`) return extracted[0] === major;
|
|
3312
|
+
return matchesRange(range, version);
|
|
3313
|
+
}
|
|
3322
3314
|
#registryURL(name) {
|
|
3323
3315
|
return `${this.#registryBase}/${encodeURIComponent(name).replaceAll("%40", "@")}`;
|
|
3324
3316
|
}
|