@orkestrel/scaffold 0.0.84 → 0.0.86

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.
@@ -550,7 +550,8 @@ export declare const isManifestEntry: Guard<ManifestEntry>;
550
550
  * @remarks
551
551
  * The whole closed record a manifest-writing method accepts, so a caller
552
552
  * naming a region the writer does not carry is refused before any byte moves.
553
- * Each region is bounded by the same collection law its own list guard applies.
553
+ * Each region is bounded by the same collection law its own list guard applies,
554
+ * and `additions` is the one region a caller may omit.
554
555
  *
555
556
  * @example
556
557
  * ```ts
@@ -558,6 +559,11 @@ export declare const isManifestEntry: Guard<ManifestEntry>;
558
559
  *
559
560
  * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
560
561
  * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
562
+ * isManifestRegionSet({
563
+ * pins: { runtime: [], development: [] },
564
+ * scripts: [],
565
+ * additions: { runtime: [], development: [{ name: 'typescript', range: '^6.0.3' }] },
566
+ * }) // true
561
567
  * ```
562
568
  */
563
569
  export declare const isManifestRegionSet: Guard<ManifestRegionSet>;
@@ -1239,11 +1245,13 @@ export declare class Materializer implements MaterializerInterface {
1239
1245
  /**
1240
1246
  * Rewrites the manifest regions the caller names in the target's manifest.
1241
1247
  *
1242
- * @param regions - The dependency ranges and script values the manifest must declare.
1248
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
1243
1249
  * @param target - The directory to write into.
1244
1250
  * @returns The manifest path, written when a named region moved and skipped otherwise.
1245
1251
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
1246
- * exact shape or names a package the manifest does not declare, `TARGET` when
1252
+ * exact shape, names a range the manifest does not declare, or names an
1253
+ * addition the manifest already declares or whose section is not an object
1254
+ * of version strings, `TARGET` when
1247
1255
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
1248
1256
  * committed, and `DESTROYED` after teardown.
1249
1257
  *
@@ -1251,7 +1259,10 @@ export declare class Materializer implements MaterializerInterface {
1251
1259
  * No other part of the manifest is read back out or rewritten. The method
1252
1260
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
1253
1261
  * range already declared in its named writable section is rewritten, so an
1254
- * undeclared name is refused instead of inserted.
1262
+ * undeclared pin is refused instead of inserted. An undeclared package enters
1263
+ * the manifest only through `additions`, which inserts it into the section its
1264
+ * list names in key order, creating that section when the manifest lacks it,
1265
+ * before the ranges are rewritten.
1255
1266
  *
1256
1267
  * The regions refuse differently because their targets differ. A range
1257
1268
  * the manifest does not declare is the caller's mistake and throws. A script
@@ -1417,7 +1428,7 @@ export declare class Materializer implements MaterializerInterface {
1417
1428
  /**
1418
1429
  * Rewrites the manifest regions the caller names in the target's manifest.
1419
1430
  *
1420
- * @param regions - The dependency ranges and script values the manifest must declare.
1431
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
1421
1432
  * @param target - The directory to write into.
1422
1433
  * @returns The manifest path, written when a named region moved and skipped otherwise.
1423
1434
  *
@@ -1425,7 +1436,9 @@ export declare class Materializer implements MaterializerInterface {
1425
1436
  * No other part of the manifest is read back out or rewritten. The method
1426
1437
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. A
1427
1438
  * script region naming a value the manifest does not accept is skipped
1428
- * without a byte moving, and the range region is written regardless.
1439
+ * without a byte moving, and the range region is written regardless. An
1440
+ * addition is inserted into the section its list names, which is created when
1441
+ * the manifest lacks it, and one the manifest already declares is refused.
1429
1442
  */
1430
1443
  declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1431
1444
  /**
@@ -550,7 +550,8 @@ export declare const isManifestEntry: Guard<ManifestEntry>;
550
550
  * @remarks
551
551
  * The whole closed record a manifest-writing method accepts, so a caller
552
552
  * naming a region the writer does not carry is refused before any byte moves.
553
- * Each region is bounded by the same collection law its own list guard applies.
553
+ * Each region is bounded by the same collection law its own list guard applies,
554
+ * and `additions` is the one region a caller may omit.
554
555
  *
555
556
  * @example
556
557
  * ```ts
@@ -558,6 +559,11 @@ export declare const isManifestEntry: Guard<ManifestEntry>;
558
559
  *
559
560
  * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
560
561
  * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
562
+ * isManifestRegionSet({
563
+ * pins: { runtime: [], development: [] },
564
+ * scripts: [],
565
+ * additions: { runtime: [], development: [{ name: 'typescript', range: '^6.0.3' }] },
566
+ * }) // true
561
567
  * ```
562
568
  */
563
569
  export declare const isManifestRegionSet: Guard<ManifestRegionSet>;
@@ -1239,11 +1245,13 @@ export declare class Materializer implements MaterializerInterface {
1239
1245
  /**
1240
1246
  * Rewrites the manifest regions the caller names in the target's manifest.
1241
1247
  *
1242
- * @param regions - The dependency ranges and script values the manifest must declare.
1248
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
1243
1249
  * @param target - The directory to write into.
1244
1250
  * @returns The manifest path, written when a named region moved and skipped otherwise.
1245
1251
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
1246
- * exact shape or names a package the manifest does not declare, `TARGET` when
1252
+ * exact shape, names a range the manifest does not declare, or names an
1253
+ * addition the manifest already declares or whose section is not an object
1254
+ * of version strings, `TARGET` when
1247
1255
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
1248
1256
  * committed, and `DESTROYED` after teardown.
1249
1257
  *
@@ -1251,7 +1259,10 @@ export declare class Materializer implements MaterializerInterface {
1251
1259
  * No other part of the manifest is read back out or rewritten. The method
1252
1260
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
1253
1261
  * range already declared in its named writable section is rewritten, so an
1254
- * undeclared name is refused instead of inserted.
1262
+ * undeclared pin is refused instead of inserted. An undeclared package enters
1263
+ * the manifest only through `additions`, which inserts it into the section its
1264
+ * list names in key order, creating that section when the manifest lacks it,
1265
+ * before the ranges are rewritten.
1255
1266
  *
1256
1267
  * The regions refuse differently because their targets differ. A range
1257
1268
  * the manifest does not declare is the caller's mistake and throws. A script
@@ -1417,7 +1428,7 @@ export declare class Materializer implements MaterializerInterface {
1417
1428
  /**
1418
1429
  * Rewrites the manifest regions the caller names in the target's manifest.
1419
1430
  *
1420
- * @param regions - The dependency ranges and script values the manifest must declare.
1431
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
1421
1432
  * @param target - The directory to write into.
1422
1433
  * @returns The manifest path, written when a named region moved and skipped otherwise.
1423
1434
  *
@@ -1425,7 +1436,9 @@ export declare class Materializer implements MaterializerInterface {
1425
1436
  * No other part of the manifest is read back out or rewritten. The method
1426
1437
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. A
1427
1438
  * script region naming a value the manifest does not accept is skipped
1428
- * without a byte moving, and the range region is written regardless.
1439
+ * without a byte moving, and the range region is written regardless. An
1440
+ * addition is inserted into the section its list names, which is created when
1441
+ * the manifest lacks it, and one the manifest already declares is refused.
1429
1442
  */
1430
1443
  declare(regions: ManifestRegionSet, target: string): MaterializeResult;
1431
1444
  /**
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { andOf, arrayOf, attempt, boundsOf, compareValues, holds, isArray, isBoolean, isError, isFunction, isInteger, isNumber, isRecord, isString, parseJSON, parseJSONAs, parseStringField, recordOf, stringOf, unionOf, whereOf } from "@orkestrel/contract";
3
- import { CANON_PATHS, CATALOG_AGENT_PATH, CATALOG_CLOSING_MARKER, CATALOG_OPENING_MARKER, CONTROL_CHARACTER_PATTERN, DEPENDENCY_NAME_PATTERN, EXECUTABLE_PATHS, HOST_INVENTORY_PATH, 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, REFERENCE_PATHS, ScaffoldError, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, contentToHex, extractRangeMajor, extractVersion, inferGroup, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isFloorPath, isHex, isManifestScript, isMirror, isPath, isPlan, isRetainedPath, isSnapshot, matchesDriftReachability, matchesRange, nameToGuide, planToFindings, renderSkillPointer, replaceManifestRanges, replaceManifestScripts } from "../core/index.js";
3
+ import { CANON_PATHS, CATALOG_AGENT_PATH, CATALOG_CLOSING_MARKER, CATALOG_OPENING_MARKER, CONTROL_CHARACTER_PATTERN, DEPENDENCY_NAME_PATTERN, EXECUTABLE_PATHS, HOST_INVENTORY_PATH, 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, REFERENCE_PATHS, ScaffoldError, bytesToHex, catalogToLayers, cloneValue, compareVersions, computeBytes, contentToHex, extractRangeMajor, extractVersion, inferGroup, insertManifestDependencies, isAudit, isCatalogEntry, isCollection, isDependency, isDependencyName, isFloorPath, isHex, isManifestScript, isMirror, isPath, isPlan, isRetainedPath, isSnapshot, matchesDriftReachability, matchesRange, nameToGuide, planToFindings, renderSkillPointer, replaceManifestRanges, replaceManifestScripts } from "../core/index.js";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
5
  import { chmodSync, closeSync, constants, copyFileSync, fstatSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, opendirSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
6
6
  import { tmpdir } from "node:os";
@@ -2144,7 +2144,8 @@ var isDependencies = andOf(isCollection, arrayOf(isDependency));
2144
2144
  * @remarks
2145
2145
  * The whole closed record a manifest-writing method accepts, so a caller
2146
2146
  * naming a region the writer does not carry is refused before any byte moves.
2147
- * Each region is bounded by the same collection law its own list guard applies.
2147
+ * Each region is bounded by the same collection law its own list guard applies,
2148
+ * and `additions` is the one region a caller may omit.
2148
2149
  *
2149
2150
  * @example
2150
2151
  * ```ts
@@ -2152,6 +2153,11 @@ var isDependencies = andOf(isCollection, arrayOf(isDependency));
2152
2153
  *
2153
2154
  * isManifestRegionSet({ pins: { runtime: [], development: [] }, scripts: [] }) // true
2154
2155
  * isManifestRegionSet({ pins: { runtime: [], development: [] } }) // false
2156
+ * isManifestRegionSet({
2157
+ * pins: { runtime: [], development: [] },
2158
+ * scripts: [],
2159
+ * additions: { runtime: [], development: [{ name: 'typescript', range: '^6.0.3' }] },
2160
+ * }) // true
2155
2161
  * ```
2156
2162
  */
2157
2163
  var isManifestRegionSet = recordOf({
@@ -2159,8 +2165,12 @@ var isManifestRegionSet = recordOf({
2159
2165
  runtime: isDependencies,
2160
2166
  development: isDependencies
2161
2167
  }),
2162
- scripts: andOf(isCollection, arrayOf(isManifestScript))
2163
- });
2168
+ scripts: andOf(isCollection, arrayOf(isManifestScript)),
2169
+ additions: recordOf({
2170
+ runtime: isDependencies,
2171
+ development: isDependencies
2172
+ })
2173
+ }, ["additions"]);
2164
2174
  /** Narrows a value to a bounded list of fetched guide mirrors. */
2165
2175
  var isMirrors = andOf(isCollection, arrayOf(isMirror));
2166
2176
  /** Narrows a value to a bounded list of fleet catalog rows. */
@@ -3152,11 +3162,13 @@ var Materializer = class {
3152
3162
  /**
3153
3163
  * Rewrites the manifest regions the caller names in the target's manifest.
3154
3164
  *
3155
- * @param regions - The dependency ranges and script values the manifest must declare.
3165
+ * @param regions - The dependency ranges, script values, and additions the manifest must declare.
3156
3166
  * @param target - The directory to write into.
3157
3167
  * @returns The manifest path, written when a named region moved and skipped otherwise.
3158
3168
  * @throws {@link ScaffoldError} coded `INVALID` when an argument is not the
3159
- * exact shape or names a package the manifest does not declare, `TARGET` when
3169
+ * exact shape, names a range the manifest does not declare, or names an
3170
+ * addition the manifest already declares or whose section is not an object
3171
+ * of version strings, `TARGET` when
3160
3172
  * the manifest is unreadable, `WRITE` when the write cannot be staged or
3161
3173
  * committed, and `DESTROYED` after teardown.
3162
3174
  *
@@ -3164,7 +3176,10 @@ var Materializer = class {
3164
3176
  * No other part of the manifest is read back out or rewritten. The method
3165
3177
  * never reads or writes `peerDependencies` or `peerDependenciesMeta`. Only a
3166
3178
  * range already declared in its named writable section is rewritten, so an
3167
- * undeclared name is refused instead of inserted.
3179
+ * undeclared pin is refused instead of inserted. An undeclared package enters
3180
+ * the manifest only through `additions`, which inserts it into the section its
3181
+ * list names in key order, creating that section when the manifest lacks it,
3182
+ * before the ranges are rewritten.
3168
3183
  *
3169
3184
  * The regions refuse differently because their targets differ. A range
3170
3185
  * the manifest does not declare is the caller's mistake and throws. A script
@@ -3768,7 +3783,16 @@ var Materializer = class {
3768
3783
  }
3769
3784
  #redeclare(regions) {
3770
3785
  return (text) => {
3771
- const manifest = replaceManifestRanges(text, regions.pins);
3786
+ const additions = regions.additions ?? {
3787
+ runtime: [],
3788
+ development: []
3789
+ };
3790
+ const declared = insertManifestDependencies(text, additions);
3791
+ if (declared === void 0) {
3792
+ const names = [...additions.runtime, ...additions.development].map(({ name }) => name);
3793
+ throw this.#error("INVALID", `The manifest cannot declare ${names.join(", ")}: it already declares one of them, or the section that receives them is not an object of version strings.`, { names: names.length });
3794
+ }
3795
+ const manifest = replaceManifestRanges(declared, regions.pins);
3772
3796
  if (manifest === void 0) {
3773
3797
  const missing = [...regions.pins.runtime, ...regions.pins.development].find((dependency) => !text.includes(JSON.stringify(dependency.name)));
3774
3798
  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 });