@orkestrel/scaffold 0.0.117 → 0.0.119

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.
@@ -1245,6 +1245,35 @@ export declare function catalogToLayers(entries: readonly CatalogEntry[]): Reado
1245
1245
  */
1246
1246
  export declare function cloneValue(value: unknown): JSONValue | undefined;
1247
1247
 
1248
+ /**
1249
+ * Collects the near names and equal contracts other owners claim beside each name a candidate adds.
1250
+ *
1251
+ * @param candidate - The candidate owner's contract.
1252
+ * @param published - The names the candidate owner's published guide claims; empty when none.
1253
+ * @param contracts - Every owner's contract; the candidate owner's own entry is skipped.
1254
+ * @returns One advisory per added name, peer, and class, sorted by added name, peer owner, and peer
1255
+ * name, with a spelling class before `signature`.
1256
+ *
1257
+ * @remarks
1258
+ * An added name is one `candidate` claims and `published` does not. A spelling class comes from
1259
+ * `inferSurfaceSimilarity`; `signature` holds when both names carry equal cells that
1260
+ * `matchesSurfaceStructure` accepts. A name equal to the added name is a collision, not an
1261
+ * advisory.
1262
+ *
1263
+ * @example
1264
+ * ```ts
1265
+ * import { collectSurfaceAdvisories } from '@orkestrel/scaffold'
1266
+ *
1267
+ * const advisories = collectSurfaceAdvisories(
1268
+ * { owner: 'alpha', names: ['Routes'], signatures: new Map() },
1269
+ * [],
1270
+ * [{ owner: 'router', names: ['Route'], signatures: new Map() }],
1271
+ * )
1272
+ * advisories[0]?.similarity // 'plural'
1273
+ * ```
1274
+ */
1275
+ export declare function collectSurfaceAdvisories(candidate: SurfaceContract, published: readonly string[], contracts: readonly SurfaceContract[]): readonly SurfaceAdvisory[];
1276
+
1248
1277
  /**
1249
1278
  * Collects bare names claimed by distinct owners in sorted order.
1250
1279
  *
@@ -2258,6 +2287,25 @@ export declare class Compiler implements CompilerInterface {
2258
2287
  */
2259
2288
  export declare function inferGroup(path: string): Group;
2260
2289
 
2290
+ /**
2291
+ * Infers how two different names resemble each other by spelling.
2292
+ *
2293
+ * @returns The first class that holds, or `undefined` when none does or the names are equal.
2294
+ *
2295
+ * @remarks
2296
+ * Reads, in order, a case-fold twin, a singular or plural form (`s`, `es`, or `y` to `ies`), and
2297
+ * one insertion, deletion, or substitution of a code unit when both names hold at least
2298
+ * `SURFACE_EDIT_LENGTH` characters. Never returns `signature`, which compares cells.
2299
+ *
2300
+ * @example
2301
+ * ```ts
2302
+ * import { inferSurfaceSimilarity } from '@orkestrel/scaffold'
2303
+ *
2304
+ * inferSurfaceSimilarity('Route', 'Routes') // 'plural'
2305
+ * ```
2306
+ */
2307
+ export declare function inferSurfaceSimilarity(name: string, other: string): SurfaceSimilarity | undefined;
2308
+
2261
2309
  /**
2262
2310
  * Inserts dependencies a package manifest does not declare into the section each one names.
2263
2311
  *
@@ -3082,6 +3130,21 @@ export declare class Compiler implements CompilerInterface {
3082
3130
  */
3083
3131
  export declare function matchesEngines(engines: string): boolean;
3084
3132
 
3133
+ /**
3134
+ * Checks whether an error is the `TARGET` refusal a surface reader raises for a guide its parser
3135
+ * refuses, which carries the parser's code in its context.
3136
+ *
3137
+ * @returns True if the error is that refusal; false otherwise.
3138
+ *
3139
+ * @example
3140
+ * ```ts
3141
+ * import { matchesGuideRefusal, ScaffoldError } from '@orkestrel/scaffold'
3142
+ *
3143
+ * matchesGuideRefusal(new ScaffoldError('TARGET', 'Refused', { code: 'header' })) // true
3144
+ * ```
3145
+ */
3146
+ export declare function matchesGuideRefusal(error: unknown): boolean;
3147
+
3085
3148
  /**
3086
3149
  * Tests whether a path instructs or wires an agent rather than the toolchain.
3087
3150
  *
@@ -3174,6 +3237,26 @@ export declare class Compiler implements CompilerInterface {
3174
3237
  */
3175
3238
  export declare function matchesRange(range: string, latest: string): boolean;
3176
3239
 
3240
+ /**
3241
+ * Checks whether a guide `Signature` cell spells a structure rather than a literal or a type name.
3242
+ *
3243
+ * @returns True if the cell is one code span that opens with a member list holding at least one
3244
+ * member, its array and union forms included; false otherwise.
3245
+ *
3246
+ * @remarks
3247
+ * A literal (`2000`, `" "`, `'live' | 'floor'`), a bare primitive (`string`), a type reference
3248
+ * (`RegExp`, `Guard<string>`, `readonly string[]`), a function type, an empty member list, and
3249
+ * prose are no structure: two names sharing one of those share a type, not a contract.
3250
+ *
3251
+ * @example
3252
+ * ```ts
3253
+ * import { matchesSurfaceStructure } from '@orkestrel/scaffold'
3254
+ *
3255
+ * matchesSurfaceStructure('`{ owner, names }`') // true
3256
+ * ```
3257
+ */
3258
+ export declare function matchesSurfaceStructure(signature: string): boolean;
3259
+
3177
3260
  /** Caps the bytes accepted for one artifact. */
3178
3261
  export declare const MAX_ARTIFACT_BYTES = 5242880;
3179
3262
 
@@ -4171,8 +4254,37 @@ export declare class Compiler implements CompilerInterface {
4171
4254
  /** Names the surface an extension extends. */
4172
4255
  export declare type Surface = 'browser' | 'styles';
4173
4256
 
4174
- /** Represents a candidate checkout's claim with each name two or more of its environments export. */
4175
- export declare interface SurfaceCandidate extends SurfaceClaim {
4257
+ /** Sets the shortest name length at which a one-edit neighbor counts as a near name. */
4258
+ export declare const SURFACE_EDIT_LENGTH = 6;
4259
+
4260
+ /**
4261
+ * Lists the declared transfers of bare names to their ruled keepers, frozen.
4262
+ *
4263
+ * @remarks
4264
+ * `stageHost` admits each keeper into its name's recorded owner set and refuses a transfer
4265
+ * whose keeper alone claims the name. `.claude/rules/names.md` § Fleet name ownership rule 5
4266
+ * governs when a transfer is declared and removed.
4267
+ */
4268
+ export declare const SURFACE_TRANSFERS: readonly SurfaceTransfer[];
4269
+
4270
+ /**
4271
+ * Reports a name a candidate adds beside a near name or an equal contract another owner claims.
4272
+ *
4273
+ * @remarks
4274
+ * `name` and `owner` are the candidate's; `peer` is the other owner's claimed name.
4275
+ */
4276
+ export declare interface SurfaceAdvisory {
4277
+ readonly name: string;
4278
+ readonly owner: string;
4279
+ readonly peer: {
4280
+ readonly name: string;
4281
+ readonly owner: string;
4282
+ };
4283
+ readonly similarity: SurfaceSimilarity;
4284
+ }
4285
+
4286
+ /** Represents a candidate checkout's contract with each name two or more of its environments export. */
4287
+ export declare interface SurfaceCandidate extends SurfaceContract {
4176
4288
  readonly conflicts: readonly SurfaceConflict[];
4177
4289
  }
4178
4290
 
@@ -4195,6 +4307,16 @@ export declare class Compiler implements CompilerInterface {
4195
4307
  readonly environments: readonly string[];
4196
4308
  }
4197
4309
 
4310
+ /**
4311
+ * Represents one owner's claim with the guide `Signature` cell of each name a Surface row documents.
4312
+ *
4313
+ * @remarks
4314
+ * `signatures` maps a claimed name to its cell; a name only a barrel claims has no entry.
4315
+ */
4316
+ export declare interface SurfaceContract extends SurfaceClaim {
4317
+ readonly signatures: ReadonlyMap<string, string>;
4318
+ }
4319
+
4198
4320
  /** Reports a collision's standing against the recorded owner set. */
4199
4321
  export declare interface SurfaceFinding extends SurfaceCollision {
4200
4322
  readonly standing: 'error' | 'recorded' | 'closed';
@@ -4203,6 +4325,28 @@ export declare class Compiler implements CompilerInterface {
4203
4325
  /** Lists the surfaces an extension may extend, frozen. */
4204
4326
  export declare const SURFACES: readonly Surface[];
4205
4327
 
4328
+ /**
4329
+ * Names how an added name resembles a name another owner claims.
4330
+ *
4331
+ * @remarks
4332
+ * `case` is a case-fold twin, `plural` a singular or plural form, `edit` a name one insertion,
4333
+ * deletion, or substitution away, and `signature` a different name with an equal structure cell.
4334
+ */
4335
+ export declare type SurfaceSimilarity = 'case' | 'plural' | 'edit' | 'signature';
4336
+
4337
+ /**
4338
+ * Represents a declared transfer of one bare name to the package a roadmap item rules keeps it.
4339
+ *
4340
+ * @remarks
4341
+ * `keeper` is the owner admitted into the name's recorded owner set, and `item` is the
4342
+ * `ROADMAP.md` item that rules the transfer.
4343
+ */
4344
+ export declare interface SurfaceTransfer {
4345
+ readonly name: string;
4346
+ readonly keeper: string;
4347
+ readonly item: number;
4348
+ }
4349
+
4206
4350
  /** Sets the columns one tab occupies when the formatter measures a line, matching `tabWidth`. */
4207
4351
  export declare const TAB_WIDTH = 2;
4208
4352
 
@@ -1245,6 +1245,35 @@ export declare function catalogToLayers(entries: readonly CatalogEntry[]): Reado
1245
1245
  */
1246
1246
  export declare function cloneValue(value: unknown): JSONValue | undefined;
1247
1247
 
1248
+ /**
1249
+ * Collects the near names and equal contracts other owners claim beside each name a candidate adds.
1250
+ *
1251
+ * @param candidate - The candidate owner's contract.
1252
+ * @param published - The names the candidate owner's published guide claims; empty when none.
1253
+ * @param contracts - Every owner's contract; the candidate owner's own entry is skipped.
1254
+ * @returns One advisory per added name, peer, and class, sorted by added name, peer owner, and peer
1255
+ * name, with a spelling class before `signature`.
1256
+ *
1257
+ * @remarks
1258
+ * An added name is one `candidate` claims and `published` does not. A spelling class comes from
1259
+ * `inferSurfaceSimilarity`; `signature` holds when both names carry equal cells that
1260
+ * `matchesSurfaceStructure` accepts. A name equal to the added name is a collision, not an
1261
+ * advisory.
1262
+ *
1263
+ * @example
1264
+ * ```ts
1265
+ * import { collectSurfaceAdvisories } from '@orkestrel/scaffold'
1266
+ *
1267
+ * const advisories = collectSurfaceAdvisories(
1268
+ * { owner: 'alpha', names: ['Routes'], signatures: new Map() },
1269
+ * [],
1270
+ * [{ owner: 'router', names: ['Route'], signatures: new Map() }],
1271
+ * )
1272
+ * advisories[0]?.similarity // 'plural'
1273
+ * ```
1274
+ */
1275
+ export declare function collectSurfaceAdvisories(candidate: SurfaceContract, published: readonly string[], contracts: readonly SurfaceContract[]): readonly SurfaceAdvisory[];
1276
+
1248
1277
  /**
1249
1278
  * Collects bare names claimed by distinct owners in sorted order.
1250
1279
  *
@@ -2258,6 +2287,25 @@ export declare class Compiler implements CompilerInterface {
2258
2287
  */
2259
2288
  export declare function inferGroup(path: string): Group;
2260
2289
 
2290
+ /**
2291
+ * Infers how two different names resemble each other by spelling.
2292
+ *
2293
+ * @returns The first class that holds, or `undefined` when none does or the names are equal.
2294
+ *
2295
+ * @remarks
2296
+ * Reads, in order, a case-fold twin, a singular or plural form (`s`, `es`, or `y` to `ies`), and
2297
+ * one insertion, deletion, or substitution of a code unit when both names hold at least
2298
+ * `SURFACE_EDIT_LENGTH` characters. Never returns `signature`, which compares cells.
2299
+ *
2300
+ * @example
2301
+ * ```ts
2302
+ * import { inferSurfaceSimilarity } from '@orkestrel/scaffold'
2303
+ *
2304
+ * inferSurfaceSimilarity('Route', 'Routes') // 'plural'
2305
+ * ```
2306
+ */
2307
+ export declare function inferSurfaceSimilarity(name: string, other: string): SurfaceSimilarity | undefined;
2308
+
2261
2309
  /**
2262
2310
  * Inserts dependencies a package manifest does not declare into the section each one names.
2263
2311
  *
@@ -3082,6 +3130,21 @@ export declare class Compiler implements CompilerInterface {
3082
3130
  */
3083
3131
  export declare function matchesEngines(engines: string): boolean;
3084
3132
 
3133
+ /**
3134
+ * Checks whether an error is the `TARGET` refusal a surface reader raises for a guide its parser
3135
+ * refuses, which carries the parser's code in its context.
3136
+ *
3137
+ * @returns True if the error is that refusal; false otherwise.
3138
+ *
3139
+ * @example
3140
+ * ```ts
3141
+ * import { matchesGuideRefusal, ScaffoldError } from '@orkestrel/scaffold'
3142
+ *
3143
+ * matchesGuideRefusal(new ScaffoldError('TARGET', 'Refused', { code: 'header' })) // true
3144
+ * ```
3145
+ */
3146
+ export declare function matchesGuideRefusal(error: unknown): boolean;
3147
+
3085
3148
  /**
3086
3149
  * Tests whether a path instructs or wires an agent rather than the toolchain.
3087
3150
  *
@@ -3174,6 +3237,26 @@ export declare class Compiler implements CompilerInterface {
3174
3237
  */
3175
3238
  export declare function matchesRange(range: string, latest: string): boolean;
3176
3239
 
3240
+ /**
3241
+ * Checks whether a guide `Signature` cell spells a structure rather than a literal or a type name.
3242
+ *
3243
+ * @returns True if the cell is one code span that opens with a member list holding at least one
3244
+ * member, its array and union forms included; false otherwise.
3245
+ *
3246
+ * @remarks
3247
+ * A literal (`2000`, `" "`, `'live' | 'floor'`), a bare primitive (`string`), a type reference
3248
+ * (`RegExp`, `Guard<string>`, `readonly string[]`), a function type, an empty member list, and
3249
+ * prose are no structure: two names sharing one of those share a type, not a contract.
3250
+ *
3251
+ * @example
3252
+ * ```ts
3253
+ * import { matchesSurfaceStructure } from '@orkestrel/scaffold'
3254
+ *
3255
+ * matchesSurfaceStructure('`{ owner, names }`') // true
3256
+ * ```
3257
+ */
3258
+ export declare function matchesSurfaceStructure(signature: string): boolean;
3259
+
3177
3260
  /** Caps the bytes accepted for one artifact. */
3178
3261
  export declare const MAX_ARTIFACT_BYTES = 5242880;
3179
3262
 
@@ -4171,8 +4254,37 @@ export declare class Compiler implements CompilerInterface {
4171
4254
  /** Names the surface an extension extends. */
4172
4255
  export declare type Surface = 'browser' | 'styles';
4173
4256
 
4174
- /** Represents a candidate checkout's claim with each name two or more of its environments export. */
4175
- export declare interface SurfaceCandidate extends SurfaceClaim {
4257
+ /** Sets the shortest name length at which a one-edit neighbor counts as a near name. */
4258
+ export declare const SURFACE_EDIT_LENGTH = 6;
4259
+
4260
+ /**
4261
+ * Lists the declared transfers of bare names to their ruled keepers, frozen.
4262
+ *
4263
+ * @remarks
4264
+ * `stageHost` admits each keeper into its name's recorded owner set and refuses a transfer
4265
+ * whose keeper alone claims the name. `.claude/rules/names.md` § Fleet name ownership rule 5
4266
+ * governs when a transfer is declared and removed.
4267
+ */
4268
+ export declare const SURFACE_TRANSFERS: readonly SurfaceTransfer[];
4269
+
4270
+ /**
4271
+ * Reports a name a candidate adds beside a near name or an equal contract another owner claims.
4272
+ *
4273
+ * @remarks
4274
+ * `name` and `owner` are the candidate's; `peer` is the other owner's claimed name.
4275
+ */
4276
+ export declare interface SurfaceAdvisory {
4277
+ readonly name: string;
4278
+ readonly owner: string;
4279
+ readonly peer: {
4280
+ readonly name: string;
4281
+ readonly owner: string;
4282
+ };
4283
+ readonly similarity: SurfaceSimilarity;
4284
+ }
4285
+
4286
+ /** Represents a candidate checkout's contract with each name two or more of its environments export. */
4287
+ export declare interface SurfaceCandidate extends SurfaceContract {
4176
4288
  readonly conflicts: readonly SurfaceConflict[];
4177
4289
  }
4178
4290
 
@@ -4195,6 +4307,16 @@ export declare class Compiler implements CompilerInterface {
4195
4307
  readonly environments: readonly string[];
4196
4308
  }
4197
4309
 
4310
+ /**
4311
+ * Represents one owner's claim with the guide `Signature` cell of each name a Surface row documents.
4312
+ *
4313
+ * @remarks
4314
+ * `signatures` maps a claimed name to its cell; a name only a barrel claims has no entry.
4315
+ */
4316
+ export declare interface SurfaceContract extends SurfaceClaim {
4317
+ readonly signatures: ReadonlyMap<string, string>;
4318
+ }
4319
+
4198
4320
  /** Reports a collision's standing against the recorded owner set. */
4199
4321
  export declare interface SurfaceFinding extends SurfaceCollision {
4200
4322
  readonly standing: 'error' | 'recorded' | 'closed';
@@ -4203,6 +4325,28 @@ export declare class Compiler implements CompilerInterface {
4203
4325
  /** Lists the surfaces an extension may extend, frozen. */
4204
4326
  export declare const SURFACES: readonly Surface[];
4205
4327
 
4328
+ /**
4329
+ * Names how an added name resembles a name another owner claims.
4330
+ *
4331
+ * @remarks
4332
+ * `case` is a case-fold twin, `plural` a singular or plural form, `edit` a name one insertion,
4333
+ * deletion, or substitution away, and `signature` a different name with an equal structure cell.
4334
+ */
4335
+ export declare type SurfaceSimilarity = 'case' | 'plural' | 'edit' | 'signature';
4336
+
4337
+ /**
4338
+ * Represents a declared transfer of one bare name to the package a roadmap item rules keeps it.
4339
+ *
4340
+ * @remarks
4341
+ * `keeper` is the owner admitted into the name's recorded owner set, and `item` is the
4342
+ * `ROADMAP.md` item that rules the transfer.
4343
+ */
4344
+ export declare interface SurfaceTransfer {
4345
+ readonly name: string;
4346
+ readonly keeper: string;
4347
+ readonly item: number;
4348
+ }
4349
+
4206
4350
  /** Sets the columns one tab occupies when the formatter measures a line, matching `tabWidth`. */
4207
4351
  export declare const TAB_WIDTH = 2;
4208
4352
 
@@ -3,7 +3,7 @@ import { fillTemplate } from "@orkestrel/template";
3
3
  import { Emitter } from "@orkestrel/emitter";
4
4
  var package_default = {
5
5
  name: "@orkestrel/scaffold",
6
- version: "0.0.117",
6
+ version: "0.0.119",
7
7
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
8
8
  keywords: [
9
9
  "audit",
@@ -363,6 +363,69 @@ var SEED_GUIDE_PATHS = Object.freeze(["guides/guide.md", "guides/scaffold.md"]);
363
363
  /** Names the repository-relative path where the committed vendored-file inventory is served. */
364
364
  var HOST_INVENTORY_PATH = "host.json";
365
365
  /**
366
+ * Lists the declared transfers of bare names to their ruled keepers, frozen.
367
+ *
368
+ * @remarks
369
+ * `stageHost` admits each keeper into its name's recorded owner set and refuses a transfer
370
+ * whose keeper alone claims the name. `.claude/rules/names.md` § Fleet name ownership rule 5
371
+ * governs when a transfer is declared and removed.
372
+ */
373
+ var SURFACE_TRANSFERS = Object.freeze([
374
+ ...["BOM"].map((name) => ({
375
+ name,
376
+ keeper: "codec",
377
+ item: 80
378
+ })),
379
+ ...[
380
+ "CHOICE_LIMIT",
381
+ "NAME_LIMIT",
382
+ "NODE_LIMIT",
383
+ "STRING_LIMIT",
384
+ "TEXT_LIMIT",
385
+ "errorToMessage",
386
+ "escapeRegExp",
387
+ "failure",
388
+ "isFailure",
389
+ "isSuccess",
390
+ "success"
391
+ ].map((name) => ({
392
+ name,
393
+ keeper: "contract",
394
+ item: 79
395
+ })),
396
+ ...[
397
+ "JSONRPCError",
398
+ "JSONRPCErrorResponse",
399
+ "JSONRPCId",
400
+ "JSONRPCInvocation",
401
+ "JSONRPCMessage",
402
+ "JSONRPCNotification",
403
+ "JSONRPCRequest",
404
+ "JSONRPCResponse",
405
+ "JSONRPCResultResponse",
406
+ "JSONRPC_INTERNAL_ERROR",
407
+ "JSONRPC_INVALID_PARAMS",
408
+ "JSONRPC_INVALID_REQUEST",
409
+ "JSONRPC_METHOD_NOT_FOUND",
410
+ "JSONRPC_PARSE_ERROR",
411
+ "buildJSONRPCError",
412
+ "buildJSONRPCResult",
413
+ "isJSONRPCError",
414
+ "isJSONRPCErrorResponse",
415
+ "isJSONRPCId",
416
+ "isJSONRPCInvocation",
417
+ "isJSONRPCMessage",
418
+ "isJSONRPCNotification",
419
+ "isJSONRPCRequest",
420
+ "isJSONRPCResponse",
421
+ "isJSONRPCResultResponse"
422
+ ].map((name) => ({
423
+ name,
424
+ keeper: "jsonrpc",
425
+ item: 81
426
+ }))
427
+ ].map((transfer) => Object.freeze(transfer)));
428
+ /**
366
429
  * Lists the vendored paths whose present bytes belong to each workspace, frozen.
367
430
  *
368
431
  * @remarks
@@ -599,6 +662,8 @@ var MAX_RANGE_LENGTH = 2048;
599
662
  var MAX_SCRIPT_LENGTH = 4096;
600
663
  /** Caps the length of one path, matching the longest a supported filesystem accepts. */
601
664
  var MAX_PATH_LENGTH = 32767;
665
+ /** Sets the shortest name length at which a one-edit neighbor counts as a near name. */
666
+ var SURFACE_EDIT_LENGTH = 6;
602
667
  /** Caps the items accepted in one public collection. */
603
668
  var MAX_COLLECTION_ITEMS = 1e3;
604
669
  /** Caps the columns one emitted line may occupy, matching `printWidth` in `.oxfmtrc.json`. */
@@ -5591,6 +5656,122 @@ function collectSurfaceConflicts(owner, exports) {
5591
5656
  });
5592
5657
  }
5593
5658
  /**
5659
+ * Infers how two different names resemble each other by spelling.
5660
+ *
5661
+ * @returns The first class that holds, or `undefined` when none does or the names are equal.
5662
+ *
5663
+ * @remarks
5664
+ * Reads, in order, a case-fold twin, a singular or plural form (`s`, `es`, or `y` to `ies`), and
5665
+ * one insertion, deletion, or substitution of a code unit when both names hold at least
5666
+ * `SURFACE_EDIT_LENGTH` characters. Never returns `signature`, which compares cells.
5667
+ *
5668
+ * @example
5669
+ * ```ts
5670
+ * import { inferSurfaceSimilarity } from '@orkestrel/scaffold'
5671
+ *
5672
+ * inferSurfaceSimilarity('Route', 'Routes') // 'plural'
5673
+ * ```
5674
+ */
5675
+ function inferSurfaceSimilarity(name, other) {
5676
+ const [short, long] = name.length <= other.length ? [name, other] : [other, name];
5677
+ if (name === other) return void 0;
5678
+ if (name.toLowerCase() === other.toLowerCase()) return "case";
5679
+ if (long === `${short}s` || long === `${short}es` || short.endsWith("y") && long === `${short.slice(0, -1)}ies`) return "plural";
5680
+ if (short.length < 6 || long.length - short.length > 1) return void 0;
5681
+ const found = short.split("").findIndex((character, position) => character !== long[position]);
5682
+ const index = found === -1 ? short.length : found;
5683
+ const rest = long.length === short.length ? short.slice(index + 1) : short.slice(index);
5684
+ return long.slice(index + 1) === rest ? "edit" : void 0;
5685
+ }
5686
+ /**
5687
+ * Checks whether an error is the `TARGET` refusal a surface reader raises for a guide its parser
5688
+ * refuses, which carries the parser's code in its context.
5689
+ *
5690
+ * @returns True if the error is that refusal; false otherwise.
5691
+ *
5692
+ * @example
5693
+ * ```ts
5694
+ * import { matchesGuideRefusal, ScaffoldError } from '@orkestrel/scaffold'
5695
+ *
5696
+ * matchesGuideRefusal(new ScaffoldError('TARGET', 'Refused', { code: 'header' })) // true
5697
+ * ```
5698
+ */
5699
+ function matchesGuideRefusal(error) {
5700
+ return isScaffoldError(error) && error.code === "TARGET" && isRecord(error.context) && isString(error.context.code);
5701
+ }
5702
+ /**
5703
+ * Checks whether a guide `Signature` cell spells a structure rather than a literal or a type name.
5704
+ *
5705
+ * @returns True if the cell is one code span that opens with a member list holding at least one
5706
+ * member, its array and union forms included; false otherwise.
5707
+ *
5708
+ * @remarks
5709
+ * A literal (`2000`, `" "`, `'live' | 'floor'`), a bare primitive (`string`), a type reference
5710
+ * (`RegExp`, `Guard<string>`, `readonly string[]`), a function type, an empty member list, and
5711
+ * prose are no structure: two names sharing one of those share a type, not a contract.
5712
+ *
5713
+ * @example
5714
+ * ```ts
5715
+ * import { matchesSurfaceStructure } from '@orkestrel/scaffold'
5716
+ *
5717
+ * matchesSurfaceStructure('`{ owner, names }`') // true
5718
+ * ```
5719
+ */
5720
+ function matchesSurfaceStructure(signature) {
5721
+ const code = /^`([^`]+)`$/u.exec(signature)?.[1]?.trim();
5722
+ return code !== void 0 && code.startsWith("{") && !/^\{\s*\}$/u.test(code);
5723
+ }
5724
+ /**
5725
+ * Collects the near names and equal contracts other owners claim beside each name a candidate adds.
5726
+ *
5727
+ * @param candidate - The candidate owner's contract.
5728
+ * @param published - The names the candidate owner's published guide claims; empty when none.
5729
+ * @param contracts - Every owner's contract; the candidate owner's own entry is skipped.
5730
+ * @returns One advisory per added name, peer, and class, sorted by added name, peer owner, and peer
5731
+ * name, with a spelling class before `signature`.
5732
+ *
5733
+ * @remarks
5734
+ * An added name is one `candidate` claims and `published` does not. A spelling class comes from
5735
+ * `inferSurfaceSimilarity`; `signature` holds when both names carry equal cells that
5736
+ * `matchesSurfaceStructure` accepts. A name equal to the added name is a collision, not an
5737
+ * advisory.
5738
+ *
5739
+ * @example
5740
+ * ```ts
5741
+ * import { collectSurfaceAdvisories } from '@orkestrel/scaffold'
5742
+ *
5743
+ * const advisories = collectSurfaceAdvisories(
5744
+ * { owner: 'alpha', names: ['Routes'], signatures: new Map() },
5745
+ * [],
5746
+ * [{ owner: 'router', names: ['Route'], signatures: new Map() }],
5747
+ * )
5748
+ * advisories[0]?.similarity // 'plural'
5749
+ * ```
5750
+ */
5751
+ function collectSurfaceAdvisories(candidate, published, contracts) {
5752
+ const known = new Set(published);
5753
+ const peers = contracts.filter(({ owner }) => owner !== candidate.owner).flatMap(({ owner, names, signatures }) => [...new Set(names)].map((name) => ({
5754
+ name,
5755
+ owner,
5756
+ signature: signatures.get(name)
5757
+ }))).sort((left, right) => compareValues(left.owner, right.owner) || compareValues(left.name, right.name));
5758
+ return [...new Set(candidate.names)].filter((name) => !known.has(name)).sort(compareValues).flatMap((name) => {
5759
+ const signature = candidate.signatures.get(name);
5760
+ const structure = signature !== void 0 && matchesSurfaceStructure(signature);
5761
+ return peers.flatMap((peer) => {
5762
+ return [inferSurfaceSimilarity(name, peer.name), structure && peer.name !== name && peer.signature === signature ? "signature" : void 0].flatMap((similarity) => similarity === void 0 ? [] : [{
5763
+ name,
5764
+ owner: candidate.owner,
5765
+ peer: {
5766
+ name: peer.name,
5767
+ owner: peer.owner
5768
+ },
5769
+ similarity
5770
+ }]);
5771
+ });
5772
+ });
5773
+ }
5774
+ /**
5594
5775
  * Encodes bytes as exact lowercase hexadecimal text.
5595
5776
  *
5596
5777
  * @param bytes - The bytes to encode.
@@ -9707,6 +9888,6 @@ var Compiler = class {
9707
9888
  return error;
9708
9889
  }
9709
9890
  };
9710
- export { APP_BROWSER_DEV_DEPENDENCIES, APP_DEV_DEPENDENCIES, APP_MATRIX, APP_SERVER_DEV_DEPENDENCIES, ARTIFACT_TEMPLATES, AXES, BASE_DEV_DEPENDENCIES, BIN_CONFIGS, BIN_ENTRY_PATH, BIN_OUTPUT_PATH, BROWSE_DEV_DEPENDENCIES, BROWSE_UPSTREAM, CANON_PATHS, CAPTURE_DEV_DEPENDENCIES, CAPTURE_UPSTREAM, CATALOG_AGENT_PATH, CATALOG_END_MARKER, CATALOG_START_MARKER, CONFIG_TEMPLATES, CONFORMANCE_TEST_PATH, CONTROL_CHARACTER_PATTERN, Compiler, DECLARATION_DEV_DEPENDENCIES, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, DISTRIBUTION_SETUP_PATH, DISTRIBUTION_TEST_PATH, ENGINES_PATTERN, ENVIRONMENTS, EXECUTABLE_PATHS, EXTRA_RANGE_PATTERN, FLOOR_RANGE_PATTERN, FOREIGN_NAME_PATTERN, FRAMEWORKS, FRAMEWORK_MATRIX, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HEX_PATTERN, HOST_INVENTORY_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, INVALID_PATH_CHARACTER_PATTERN, JOURNEY_CONFIG_PATH, MANIFEST_PATH, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_AUDIT_FINDINGS, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_NAME_LENGTH, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_REGISTRY_BYTES, MAX_SCRIPT_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, MAX_TOTAL_REGISTRY_BYTES, MINIMUM_NODE_VERSION, MINIMUM_NPM_VERSION, NAME_PATTERN, ORCHESTRATION_PATH_NAMES, ORCHESTRATION_PATH_PREFIXES, ORKESTREL_RANGE_PATTERN, PRINT_WIDTH, REFERENCE_PATHS, RELEASE_PROOF_COMMAND, RESERVED_SHEET_NAMES, SEED_GUIDE_PATHS, SERVICE_SCRIPT_PATH, SERVICE_SETUP_PATH, SERVICE_TEST_INCLUDE, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_OVERRIDES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, SOURCE_BROWSER_DEV_DEPENDENCIES, SRC_MATRIX, STUDIES_TEST_INCLUDE, STYLES_DEV_DEPENDENCIES, STYLES_ENTRY_PATH, SURFACES, ScaffoldError, TAB_WIDTH, TARGET_SKILL_NAMES, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TOOLCHAIN_HOLDS, TREE_TEST_PATH, VERSION_PATTERN, WORKSPACE_DEV_ENGINES, WORKSPACE_OWNED_PATHS, applyOverrides, artifactToFinding, artifactToHex, artifactsToQuestions, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToDocumentArtifacts, blueprintToExports, blueprintToFaces, blueprintToGuideArtifacts, blueprintToHostArtifacts, blueprintToMachinery, blueprintToManifest, blueprintToManifestOverrides, blueprintToOptimizedDependencies, blueprintToOrchestrationArtifacts, blueprintToProjects, blueprintToQuestions, blueprintToRootTsconfig, blueprintToRootVite, blueprintToScripts, blueprintToSheets, blueprintToSourceArtifacts, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, bytesToHex, catalogToLayers, cloneValue, collectSurfaceCollisions, collectSurfaceConflicts, compareSurfaceCollisions, compareVersions, computeBytes, computeHash, computeTotal, contentToHex, createBlueprint, dependenciesToQuestions, extractRangeMajor, extractVersion, inferDrift, inferGroup, insertManifestDependencies, insertManifestSection, isArtifact, isAudit, isBlueprint, isBrowserExtension, isCanonPath, isCatalogEntry, isCollection, isCompilerHooks, isCompilerOptions, isContent, isDeferredPath, isDependency, isDependencyName, isEnvironment, isExtension, isFinding, isFloorPath, isGroup, isGroups, isHex, isManifestScript, isMirror, isOverride, isPath, isPlan, isQuestion, isRetainedPath, isScaffoldError, isSheetName, isSnapshot, isStylesExtension, isSurface, iterateAnswers, manifestToDependencies, manifestToName, matchesDriftReachability, matchesEngines, matchesOrchestrationPath, matchesPrintWidth, matchesRange, nameToGuide, overridesToQuestions, parseBlueprint, parseCompilerOptions, parseExtension, parseGroups, parseSnapshot, pathToCondition, planToFindings, planToHash, planToSummary, renderSkillPointer, replaceManifestOverride, replaceManifestOverrides, replaceManifestRanges, replaceManifestScripts, replacePlanRanges, scanManifestTokens, selectGroups, selectHostPaths, serializeTypeScriptString, srcToEntry, srcToExports, srcToRoot };
9891
+ export { APP_BROWSER_DEV_DEPENDENCIES, APP_DEV_DEPENDENCIES, APP_MATRIX, APP_SERVER_DEV_DEPENDENCIES, ARTIFACT_TEMPLATES, AXES, BASE_DEV_DEPENDENCIES, BIN_CONFIGS, BIN_ENTRY_PATH, BIN_OUTPUT_PATH, BROWSE_DEV_DEPENDENCIES, BROWSE_UPSTREAM, CANON_PATHS, CAPTURE_DEV_DEPENDENCIES, CAPTURE_UPSTREAM, CATALOG_AGENT_PATH, CATALOG_END_MARKER, CATALOG_START_MARKER, CONFIG_TEMPLATES, CONFORMANCE_TEST_PATH, CONTROL_CHARACTER_PATTERN, Compiler, DECLARATION_DEV_DEPENDENCIES, DEFAULT_ENGINES, DEFAULT_VERSION, DEPENDENCY_NAME_PATTERN, DISTRIBUTION_SETUP_PATH, DISTRIBUTION_TEST_PATH, ENGINES_PATTERN, ENVIRONMENTS, EXECUTABLE_PATHS, EXTRA_RANGE_PATTERN, FLOOR_RANGE_PATTERN, FOREIGN_NAME_PATTERN, FRAMEWORKS, FRAMEWORK_MATRIX, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HEX_PATTERN, HOST_INVENTORY_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, INVALID_PATH_CHARACTER_PATTERN, JOURNEY_CONFIG_PATH, MANIFEST_PATH, MAX_ARTIFACT_BYTES, MAX_ARTIFACT_HEX_LENGTH, MAX_AUDIT_FINDINGS, MAX_COLLECTION_ITEMS, MAX_DEPENDENCY_NAME_LENGTH, MAX_MANIFEST_BYTES, MAX_NAME_LENGTH, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, MAX_REGISTRY_BYTES, MAX_SCRIPT_LENGTH, MAX_TOTAL_ARTIFACT_BYTES, MAX_TOTAL_REGISTRY_BYTES, MINIMUM_NODE_VERSION, MINIMUM_NPM_VERSION, NAME_PATTERN, ORCHESTRATION_PATH_NAMES, ORCHESTRATION_PATH_PREFIXES, ORKESTREL_RANGE_PATTERN, PRINT_WIDTH, REFERENCE_PATHS, RELEASE_PROOF_COMMAND, RESERVED_SHEET_NAMES, SEED_GUIDE_PATHS, SERVICE_SCRIPT_PATH, SERVICE_SETUP_PATH, SERVICE_TEST_INCLUDE, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_OVERRIDES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, SOURCE_BROWSER_DEV_DEPENDENCIES, SRC_MATRIX, STUDIES_TEST_INCLUDE, STYLES_DEV_DEPENDENCIES, STYLES_ENTRY_PATH, SURFACES, SURFACE_EDIT_LENGTH, SURFACE_TRANSFERS, ScaffoldError, TAB_WIDTH, TARGET_SKILL_NAMES, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TOOLCHAIN_HOLDS, TREE_TEST_PATH, VERSION_PATTERN, WORKSPACE_DEV_ENGINES, WORKSPACE_OWNED_PATHS, applyOverrides, artifactToFinding, artifactToHex, artifactsToQuestions, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToDocumentArtifacts, blueprintToExports, blueprintToFaces, blueprintToGuideArtifacts, blueprintToHostArtifacts, blueprintToMachinery, blueprintToManifest, blueprintToManifestOverrides, blueprintToOptimizedDependencies, blueprintToOrchestrationArtifacts, blueprintToProjects, blueprintToQuestions, blueprintToRootTsconfig, blueprintToRootVite, blueprintToScripts, blueprintToSheets, blueprintToSourceArtifacts, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, bytesToHex, catalogToLayers, cloneValue, collectSurfaceAdvisories, collectSurfaceCollisions, collectSurfaceConflicts, compareSurfaceCollisions, compareVersions, computeBytes, computeHash, computeTotal, contentToHex, createBlueprint, dependenciesToQuestions, extractRangeMajor, extractVersion, inferDrift, inferGroup, inferSurfaceSimilarity, insertManifestDependencies, insertManifestSection, isArtifact, isAudit, isBlueprint, isBrowserExtension, isCanonPath, isCatalogEntry, isCollection, isCompilerHooks, isCompilerOptions, isContent, isDeferredPath, isDependency, isDependencyName, isEnvironment, isExtension, isFinding, isFloorPath, isGroup, isGroups, isHex, isManifestScript, isMirror, isOverride, isPath, isPlan, isQuestion, isRetainedPath, isScaffoldError, isSheetName, isSnapshot, isStylesExtension, isSurface, iterateAnswers, manifestToDependencies, manifestToName, matchesDriftReachability, matchesEngines, matchesGuideRefusal, matchesOrchestrationPath, matchesPrintWidth, matchesRange, matchesSurfaceStructure, nameToGuide, overridesToQuestions, parseBlueprint, parseCompilerOptions, parseExtension, parseGroups, parseSnapshot, pathToCondition, planToFindings, planToHash, planToSummary, renderSkillPointer, replaceManifestOverride, replaceManifestOverrides, replaceManifestRanges, replaceManifestScripts, replacePlanRanges, scanManifestTokens, selectGroups, selectHostPaths, serializeTypeScriptString, srcToEntry, srcToExports, srcToRoot };
9711
9892
 
9712
9893
  //# sourceMappingURL=index.js.map