@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.
package/dist/bin/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { align, renderTable, strip, stripControls, width } from "@orkestrel/console";
3
3
  import { attempt, isArray, isDefined, isError, isInstance, isRecord, isString, parseJSON } from "@orkestrel/contract";
4
- import { AXES, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFORMANCE_TEST_PATH, Compiler, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, FRAMEWORKS, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, JOURNEY_CONFIG_PATH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, RESERVED_SHEET_NAMES, SERVICE_SETUP_PATH, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, STYLES_ENTRY_PATH, ScaffoldError, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TREE_TEST_PATH, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToFaces, blueprintToManifestOverrides, blueprintToProjects, blueprintToScripts, blueprintToSheets, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, collectSurfaceCollisions, compareSurfaceCollisions, compareVersions, createBlueprint, extractRangeMajor, extractVersion, isFloorPath, isScaffoldError, isSheetName, iterateAnswers, manifestToDependencies, manifestToName, nameToGuide, parseExtension, replaceManifestOverrides, replaceManifestScripts, replacePlanRanges } from "../src/core/index.js";
4
+ import { AXES, BIN_ENTRY_PATH, CATALOG_AGENT_PATH, CONFORMANCE_TEST_PATH, Compiler, DEPENDENCY_NAME_PATTERN, ENVIRONMENTS, FRAMEWORKS, GLOBAL_SETUP_PATH, GROUPS, GUIDES_TEST_PATH, HOST_PATHS, INTEGRATION_TEST_PATH, JOURNEY_CONFIG_PATH, MAX_MANIFEST_BYTES, MAX_PATH_LENGTH, MAX_RANGE_LENGTH, RESERVED_SHEET_NAMES, SERVICE_SETUP_PATH, SHEET_ENTRY_NAME, SHOWCASE_CONFIG_PATH, SHOWCASE_DEV_DEPENDENCIES, SHOWCASE_PAGES_PATH, SKILLS_CONFIG_PATH, STYLES_ENTRY_PATH, ScaffoldError, THEMES_BARREL_PATH, THEMES_ENTRY_PATH, TREE_TEST_PATH, blueprintToConfigArtifacts, blueprintToDevDependencies, blueprintToFaces, blueprintToManifestOverrides, blueprintToProjects, blueprintToScripts, blueprintToSheets, blueprintToTestArtifacts, blueprintToToolchainHolds, blueprintToWritableScripts, collectSurfaceAdvisories, collectSurfaceCollisions, compareSurfaceCollisions, compareVersions, createBlueprint, extractRangeMajor, extractVersion, isFloorPath, isScaffoldError, isSheetName, iterateAnswers, manifestToDependencies, manifestToName, matchesGuideRefusal, nameToGuide, parseExtension, replaceManifestOverrides, replaceManifestScripts, replacePlanRanges } from "../src/core/index.js";
5
5
  import { MAX_INVENTORY_PATHS, Materializer, Upstream, filesToHost, isExactCaseFile, isPhysicalDirectory, isWorktree, listFiles, readFileText, readHostFloor, readHostManifest, readSnapshot, readSurfaceCandidate, readSurfaceFile, readSurfaceGuide, readSurfaceRecord, resolveContainedPath } from "../src/server/index.js";
6
6
  import { join, normalize, resolve } from "node:path";
7
7
  import { createSession } from "@orkestrel/process/server";
@@ -10,7 +10,7 @@ import { readdirSync } from "node:fs";
10
10
  import { parseArgs } from "node:util";
11
11
  var package_default = {
12
12
  name: "@orkestrel/scaffold",
13
- version: "0.0.117",
13
+ version: "0.0.119",
14
14
  description: "Scaffold workspaces with commands: new, audit, surface, repair, catalog, and overwrite.",
15
15
  keywords: [
16
16
  "audit",
@@ -1927,29 +1927,54 @@ var CLI = class {
1927
1927
  const candidates = [.../* @__PURE__ */ new Set([...command.checkouts.map((path) => resolve(path)), ...isExactCaseFile(join(target, "package.json")) ? [target] : []])].map((path) => readSurfaceCandidate(path));
1928
1928
  const names = membership?.entries?.map(({ name }) => name) ?? catalogToNames(floor);
1929
1929
  const owners = [.../* @__PURE__ */ new Set([...candidates.map(({ owner }) => owner), ...names.map((name) => name.replace(/^@orkestrel\//u, ""))])].sort();
1930
- const pending = owners.filter((owner) => !candidates.some((candidate) => candidate.owner === owner));
1931
- const mirrors = upstream === void 0 ? [] : await upstream.fetch(pending.map((owner) => `@orkestrel/${owner}`), {});
1932
- const claims = owners.map((owner) => {
1930
+ const mirrors = upstream === void 0 ? [] : await upstream.fetch(owners.map((owner) => `@orkestrel/${owner}`), {});
1931
+ const published = new Map(owners.map((owner) => {
1932
+ const tolerant = candidates.some((candidate) => candidate.owner === owner);
1933
+ const live = mirrors.find((mirror) => mirror.name === `@orkestrel/${owner}`);
1934
+ const read = live?.lookup === "found" ? attempt(() => readSurfaceGuide(live.content, owner, `live ${live.path}`)) : void 0;
1935
+ if (read?.success === true) return [owner, {
1936
+ ...read.value,
1937
+ source: "live"
1938
+ }];
1939
+ if (read !== void 0 && !(tolerant && matchesGuideRefusal(read.error))) throw read.error;
1940
+ const fallback = attempt(() => readSurfaceFile(floor, owner, "floor"));
1941
+ if (fallback.success) return [owner, fallback.value === void 0 ? void 0 : {
1942
+ ...fallback.value,
1943
+ source: "floor"
1944
+ }];
1945
+ if (!(tolerant && matchesGuideRefusal(fallback.error))) throw fallback.error;
1946
+ return [owner, void 0];
1947
+ }));
1948
+ const drafts = new Map(owners.flatMap((owner) => {
1933
1949
  const own = candidates.filter((candidate) => candidate.owner === owner);
1934
- if (own.length > 0) return {
1950
+ return own.length === 0 ? [] : [[owner, {
1935
1951
  owner,
1936
1952
  names: [...new Set(own.flatMap((candidate) => candidate.names))].sort(),
1953
+ signatures: new Map(own.flatMap((candidate) => [...candidate.signatures]))
1954
+ }]];
1955
+ }));
1956
+ const claims = owners.map((owner) => {
1957
+ const draft = drafts.get(owner);
1958
+ if (draft !== void 0) return {
1959
+ owner,
1960
+ names: draft.names,
1937
1961
  source: "candidate"
1938
1962
  };
1939
- const live = mirrors.find((mirror) => mirror.name === `@orkestrel/${owner}`);
1940
- if (live?.lookup === "found") return {
1941
- ...readSurfaceGuide(live.content, owner, `live ${live.path}`),
1942
- source: "live"
1943
- };
1944
- const fallback = readSurfaceFile(floor, owner, "floor");
1945
- return fallback === void 0 ? {
1963
+ const release = published.get(owner);
1964
+ return release === void 0 ? {
1946
1965
  owner,
1947
1966
  source: "unread"
1948
1967
  } : {
1949
- ...fallback,
1950
- source: "floor"
1968
+ owner,
1969
+ names: release.names,
1970
+ source: release.source
1951
1971
  };
1952
1972
  });
1973
+ const contracts = owners.flatMap((owner) => {
1974
+ const contract = drafts.get(owner) ?? published.get(owner);
1975
+ return contract === void 0 ? [] : [contract];
1976
+ });
1977
+ const advisories = [...drafts.values()].flatMap((draft) => collectSurfaceAdvisories(draft, published.get(draft.owner)?.names ?? [], contracts));
1953
1978
  const record = inventory?.lookup === "found" ? inventory.surface : isString(floor) ? readSurfaceRecord(floor) : floor.manifest.surface;
1954
1979
  const collisions = compareSurfaceCollisions(collectSurfaceCollisions(claims.flatMap((claim) => claim.source === "unread" ? [] : [claim])), record);
1955
1980
  const fell = claims.some(({ source }) => source === "floor" || source === "unread");
@@ -1963,6 +1988,7 @@ var CLI = class {
1963
1988
  owners: claims,
1964
1989
  collisions,
1965
1990
  conflicts,
1991
+ advisories,
1966
1992
  provenance
1967
1993
  };
1968
1994
  if (command.json === true) this.#report(result);
@@ -1975,6 +2001,7 @@ var CLI = class {
1975
2001
  if (inventory !== void 0 && inventory.lookup !== "found") this.#say(`Surface record fell to the floor inventory: ${inventory.note}.`);
1976
2002
  for (const collision of collisions.filter(({ standing }) => standing === "error")) this.#say(`Surface collision ${JSON.stringify(collision.name.slice(0, 512))}: ${collision.owners.map((owner) => JSON.stringify(owner.slice(0, 512))).join(", ")}. Rename the declaration outside its owning package or reuse the owner's export.`);
1977
2003
  for (const conflict of conflicts) this.#say(`Surface conflict ${JSON.stringify(conflict.name.slice(0, 512))}: ${JSON.stringify(conflict.owner.slice(0, 512))} exports it from ${conflict.environments.map((environment) => JSON.stringify(environment.slice(0, 512))).join(", ")}. Export it once from core, or give each environment's export a distinct name.`);
2004
+ for (const advisory of advisories) this.#say(`Surface advisory ${JSON.stringify(advisory.name.slice(0, 512))}: ${JSON.stringify(advisory.owner.slice(0, 512))} adds it beside ${JSON.stringify(advisory.peer.name.slice(0, 512))} from ${JSON.stringify(advisory.peer.owner.slice(0, 512))} (${advisory.similarity}). Rule it under fleet name ownership before the upload.`);
1978
2005
  this.#say(`${String(collisions.filter(({ standing }) => standing === "recorded").length)} recorded collisions, ${String(collisions.filter(({ standing }) => standing === "closed").length)} closed collisions.`);
1979
2006
  }
1980
2007
  return collisions.some(({ standing }) => standing === "error") || conflicts.length > 0 || claims.some(({ source }) => source === "unread") || upstream !== void 0 && (provenance.membership === "floor" || provenance.guides === "floor" || provenance.record === "floor") ? 1 : 0;