@wairon/cli 5.1.1-dev.52 → 5.1.1-dev.54

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/index.js CHANGED
@@ -1233,7 +1233,7 @@ var init_defaults = __esm({
1233
1233
  copilot: ".github/prompts",
1234
1234
  codex: ".codex/agents"
1235
1235
  };
1236
- WAIRON_VERSION = "5.1.1-dev.52";
1236
+ WAIRON_VERSION = "5.1.1-dev.54";
1237
1237
  GITHUB_REPO = "SYW-Apps/Waffle-AIron";
1238
1238
  ARCHITECT_AGENT_ID = "agent-architect";
1239
1239
  ARCHITECT_TEMPLATE_ID = "architect";
@@ -17994,92 +17994,6 @@ var init_surfaces = __esm({
17994
17994
  }
17995
17995
  });
17996
17996
 
17997
- // src/core/approval.ts
17998
- function digest(content) {
17999
- const normalized = content.replace(/\r\n/g, "\n");
18000
- return crypto4.createHash("sha256").update(normalized, "utf8").digest("hex");
18001
- }
18002
- function currentSpecDigests(root = getProjectRoot()) {
18003
- const mountDirs = loadSubsystemSpecs().filter((s) => s.projectPath && !s.id.includes("::")).map((s) => `${path15.resolve(root, s.projectPath).split(path15.sep).join("/")}/`);
18004
- const out = {};
18005
- for (const [abs, content] of snapshotSpecFiles()) {
18006
- const normalized = path15.resolve(abs).split(path15.sep).join("/");
18007
- if (mountDirs.some((dir) => normalized.startsWith(dir))) continue;
18008
- out[path15.relative(root, abs).split(path15.sep).join("/")] = digest(content);
18009
- }
18010
- return out;
18011
- }
18012
- function captureApprovedSpecs(root = getProjectRoot(), scope) {
18013
- const current2 = currentSpecDigests(root);
18014
- if (!scope) return current2;
18015
- const previous = readLockRecord()?.specs ?? {};
18016
- const specs = { ...previous };
18017
- for (const rel2 of Object.keys(previous)) {
18018
- if (scope.paths.has(rel2) && current2[rel2] === void 0) delete specs[rel2];
18019
- }
18020
- for (const rel2 of scope.paths) {
18021
- if (current2[rel2] !== void 0) specs[rel2] = current2[rel2];
18022
- }
18023
- return specs;
18024
- }
18025
- function diffAgainstApproval(root = getProjectRoot()) {
18026
- const approved = approvedSpecs(root);
18027
- if (!approved) return null;
18028
- const current2 = currentSpecDigests(root);
18029
- const added = [];
18030
- const changed = [];
18031
- const removed = [];
18032
- const unchangedPaths = [];
18033
- for (const [rel2, d] of Object.entries(current2)) {
18034
- const before = approved[rel2];
18035
- if (before === void 0) added.push(rel2);
18036
- else if (before !== d) changed.push(rel2);
18037
- else unchangedPaths.push(rel2);
18038
- }
18039
- for (const rel2 of Object.keys(approved)) {
18040
- if (current2[rel2] === void 0) removed.push(rel2);
18041
- }
18042
- return {
18043
- added: added.sort(),
18044
- changed: changed.sort(),
18045
- removed: removed.sort(),
18046
- unchangedPaths: unchangedPaths.sort()
18047
- };
18048
- }
18049
- function approvedSpecs(root) {
18050
- return approvalRecord(root)?.specs ?? null;
18051
- }
18052
- function approvalRecord(root = getProjectRoot()) {
18053
- return readLockRecordAt(root);
18054
- }
18055
- function settledSpecPaths(root = getProjectRoot()) {
18056
- const diff = diffAgainstApproval(root);
18057
- return diff ? new Set(diff.unchangedPaths) : null;
18058
- }
18059
- function pinOf(stateId) {
18060
- return `${stateId.algorithm}:${stateId.digest}`;
18061
- }
18062
- function currentChildPins(mounts, root = getProjectRoot()) {
18063
- const pins = {};
18064
- for (const mount of mounts) {
18065
- if (!mount.projectPath || mount.id.includes("::")) continue;
18066
- const child = readLockRecordAt(path15.resolve(root, mount.projectPath));
18067
- if (child) pins[mount.id] = pinOf(child.stateId);
18068
- }
18069
- return pins;
18070
- }
18071
- var crypto4, path15;
18072
- var init_approval = __esm({
18073
- "src/core/approval.ts"() {
18074
- "use strict";
18075
- crypto4 = __toESM(require("crypto"));
18076
- path15 = __toESM(require("path"));
18077
- init_fs();
18078
- init_specs2();
18079
- init_lockfile();
18080
- }
18081
- });
18082
-
18083
17997
  // src/core/validation.ts
18084
17998
  function loadProjectConfig2() {
18085
17999
  return loadProjectConfig();
@@ -18361,13 +18275,13 @@ function validateSddTree(rulesOrOptions, projectType = "backend") {
18361
18275
  function resolveThroughParent(boundRoot, treatAllAsComplete, childRules) {
18362
18276
  const reach = getRequestParentReach();
18363
18277
  if (reach && !reach.parentReach) return null;
18364
- const ceiling = reach?.topRoot ? path16.resolve(reach.topRoot) : void 0;
18278
+ const ceiling = reach?.topRoot ? path15.resolve(reach.topRoot) : void 0;
18365
18279
  const chain = [];
18366
- let top = path16.resolve(boundRoot);
18280
+ let top = path15.resolve(boundRoot);
18367
18281
  while (top !== ceiling) {
18368
18282
  const hop = findChainingParent(top, ceiling);
18369
18283
  if (!hop) break;
18370
- const next = path16.resolve(hop.parentRoot);
18284
+ const next = path15.resolve(hop.parentRoot);
18371
18285
  if (ceiling && !isWithinOrEqual(ceiling, next)) break;
18372
18286
  chain.unshift(hop.subsystemId);
18373
18287
  top = next;
@@ -18414,8 +18328,8 @@ function isIdChar(ch) {
18414
18328
  return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9" || ch === "_" || ch === "-" || ch === "." || ch === ":";
18415
18329
  }
18416
18330
  function isWithinOrEqual(dir, target) {
18417
- const rel2 = path16.relative(dir, target);
18418
- return rel2 === "" || !rel2.startsWith("..") && !path16.isAbsolute(rel2);
18331
+ const rel2 = path15.relative(dir, target);
18332
+ return rel2 === "" || !rel2.startsWith("..") && !path15.isAbsolute(rel2);
18419
18333
  }
18420
18334
  function dedupeIssues(list) {
18421
18335
  const seen = /* @__PURE__ */ new Set();
@@ -18436,7 +18350,7 @@ function settledStatusBearing(loaded) {
18436
18350
  if (!settled || settled.size === 0) return [];
18437
18351
  const root = getProjectRoot();
18438
18352
  const index = scanAllSpecs();
18439
- const rel2 = (abs) => path16.relative(root, abs).split(path16.sep).join("/");
18353
+ const rel2 = (abs) => path15.relative(root, abs).split(path15.sep).join("/");
18440
18354
  const out = [];
18441
18355
  const take = (specs, paths) => {
18442
18356
  for (const spec of specs) {
@@ -18466,7 +18380,7 @@ function computeGateStateId() {
18466
18380
  registerBuiltinRules();
18467
18381
  return computeGateIdentity(content, extensions, ruleSequence(), inputs, gate);
18468
18382
  }
18469
- var path16, RESOLUTION_FAILURE_CODES, SEVERITY_RANK;
18383
+ var path15, RESOLUTION_FAILURE_CODES, SEVERITY_RANK;
18470
18384
  var init_validation = __esm({
18471
18385
  "src/core/validation.ts"() {
18472
18386
  "use strict";
@@ -18482,8 +18396,8 @@ var init_validation = __esm({
18482
18396
  init_source_analysis();
18483
18397
  init_specs2();
18484
18398
  init_fs();
18485
- path16 = __toESM(require("path"));
18486
- init_approval();
18399
+ path15 = __toESM(require("path"));
18400
+ init_core();
18487
18401
  RESOLUTION_FAILURE_CODES = /* @__PURE__ */ new Set([
18488
18402
  "UNDEFINED_TYPE_REFERENCE",
18489
18403
  "INVALID_DEPENDENCY_REFERENCE",
@@ -19125,42 +19039,42 @@ function rebaseReference(ref, mount, direction, isMoved = () => false) {
19125
19039
  return relativizeId(travels ? qualifyId(left, to, NO_ROOT_SUBSYSTEMS) : target, to);
19126
19040
  }
19127
19041
  function isWithin(dir, file) {
19128
- const d = path17.resolve(dir);
19129
- const f = path17.resolve(file);
19130
- return f === d || f.startsWith(d + path17.sep);
19042
+ const d = path16.resolve(dir);
19043
+ const f = path16.resolve(file);
19044
+ return f === d || f.startsWith(d + path16.sep);
19131
19045
  }
19132
19046
  function canonicalPath(target) {
19133
- let existing = path17.resolve(target);
19047
+ let existing = path16.resolve(target);
19134
19048
  const rest = [];
19135
19049
  for (; ; ) {
19136
19050
  try {
19137
19051
  fs12.lstatSync(existing);
19138
19052
  break;
19139
19053
  } catch {
19140
- const up = path17.dirname(existing);
19141
- if (up === existing) return path17.resolve(target);
19142
- rest.unshift(path17.basename(existing));
19054
+ const up = path16.dirname(existing);
19055
+ if (up === existing) return path16.resolve(target);
19056
+ rest.unshift(path16.basename(existing));
19143
19057
  existing = up;
19144
19058
  }
19145
19059
  }
19146
19060
  try {
19147
- return path17.join(fs12.realpathSync.native(existing), ...rest);
19061
+ return path16.join(fs12.realpathSync.native(existing), ...rest);
19148
19062
  } catch {
19149
19063
  return null;
19150
19064
  }
19151
19065
  }
19152
19066
  function chainDirKey(dir) {
19153
- return canonicalPath(dir) ?? path17.resolve(dir);
19067
+ return canonicalPath(dir) ?? path16.resolve(dir);
19154
19068
  }
19155
19069
  function projectPathEscapesRoot(projectRoot, projectPath, resolvedChildDir) {
19156
- if (path17.isAbsolute(projectPath) || !isWithin(projectRoot, resolvedChildDir)) return true;
19070
+ if (path16.isAbsolute(projectPath) || !isWithin(projectRoot, resolvedChildDir)) return true;
19157
19071
  const root = canonicalPath(projectRoot);
19158
19072
  const child = canonicalPath(resolvedChildDir);
19159
19073
  return root === null || child === null || !isWithin(root, child);
19160
19074
  }
19161
19075
  function assertContainedProjectPath(projectRoot, projectPath) {
19162
- const root = path17.resolve(projectRoot);
19163
- const resolved = path17.resolve(root, projectPath);
19076
+ const root = path16.resolve(projectRoot);
19077
+ const resolved = path16.resolve(root, projectPath);
19164
19078
  if (projectPathEscapesRoot(root, projectPath, resolved)) {
19165
19079
  throw new Error(
19166
19080
  `projectPath "${projectPath}" must resolve within the project root "${root}", but resolves to "${resolved}"; absolute, ../-escaping and link-escaping paths are rejected so a chained subproject is always contained by its parent.`
@@ -19171,12 +19085,12 @@ function assertContainedProjectPath(projectRoot, projectPath) {
19171
19085
  function findChainingParent(childRoot, ceiling) {
19172
19086
  let childResolved;
19173
19087
  try {
19174
- childResolved = path17.resolve(childRoot);
19088
+ childResolved = path16.resolve(childRoot);
19175
19089
  } catch {
19176
19090
  return null;
19177
19091
  }
19178
- const bound2 = ceiling ? path17.resolve(ceiling) : void 0;
19179
- let dir = path17.dirname(childResolved);
19092
+ const bound2 = ceiling ? path16.resolve(ceiling) : void 0;
19093
+ let dir = path16.dirname(childResolved);
19180
19094
  for (let hops = 0; hops < 32; hops++) {
19181
19095
  if (bound2 && !isWithin(bound2, dir)) break;
19182
19096
  const specsDir = aiPathsAt(dir).specsDir();
@@ -19192,7 +19106,7 @@ function findChainingParent(childRoot, ceiling) {
19192
19106
  const projectPath = raw.projectPath;
19193
19107
  if (typeof projectPath === "string" && projectPath.trim() !== "") {
19194
19108
  try {
19195
- const mountDir = path17.resolve(dir, projectPath);
19109
+ const mountDir = path16.resolve(dir, projectPath);
19196
19110
  if (mountDir === childResolved && !projectPathEscapesRoot(dir, projectPath, mountDir)) {
19197
19111
  const id = raw.id;
19198
19112
  return { parentRoot: dir, subsystemId: typeof id === "string" ? id : "?" };
@@ -19203,14 +19117,14 @@ function findChainingParent(childRoot, ceiling) {
19203
19117
  }
19204
19118
  }
19205
19119
  }
19206
- const up = path17.dirname(dir);
19120
+ const up = path16.dirname(dir);
19207
19121
  if (up === dir) break;
19208
19122
  dir = up;
19209
19123
  }
19210
19124
  return null;
19211
19125
  }
19212
19126
  function inspectChainedRoots(rootDir = getProjectRoot()) {
19213
- const root = path17.resolve(rootDir);
19127
+ const root = path16.resolve(rootDir);
19214
19128
  const inspection = { roots: [], skipped: [] };
19215
19129
  const listed = /* @__PURE__ */ new Set();
19216
19130
  const walk2 = (projectDir, prefix, ancestors, depth) => {
@@ -19229,7 +19143,7 @@ function inspectChainedRoots(rootDir = getProjectRoot()) {
19229
19143
  const localId = typeof id === "string" ? id : "?";
19230
19144
  let childDir;
19231
19145
  try {
19232
- childDir = path17.resolve(projectDir, projectPath);
19146
+ childDir = path16.resolve(projectDir, projectPath);
19233
19147
  } catch {
19234
19148
  continue;
19235
19149
  }
@@ -19246,7 +19160,7 @@ function inspectChainedRoots(rootDir = getProjectRoot()) {
19246
19160
  const key = chainDirKey(childDir);
19247
19161
  if (listed.has(key)) continue;
19248
19162
  listed.add(key);
19249
- inspection.roots.push(path17.relative(root, childDir).split(path17.sep).join("/"));
19163
+ inspection.roots.push(path16.relative(root, childDir).split(path16.sep).join("/"));
19250
19164
  walk2(childDir, prefix ? `${prefix}::${localId}` : localId, /* @__PURE__ */ new Set([...ancestors, key]), depth + 1);
19251
19165
  }
19252
19166
  };
@@ -19332,9 +19246,9 @@ function stripNamespaceFromImplementation(spec, prefix) {
19332
19246
  }
19333
19247
  function childRelativeFilePaths(spec, authoringRoot, childRoot) {
19334
19248
  const reexpress = (p) => {
19335
- if (path17.isAbsolute(p)) return p;
19336
- const rel2 = path17.relative(childRoot, path17.resolve(authoringRoot, p));
19337
- const inside = rel2 !== "" && rel2 !== ".." && !rel2.startsWith(`..${path17.sep}`) && !path17.isAbsolute(rel2);
19249
+ if (path16.isAbsolute(p)) return p;
19250
+ const rel2 = path16.relative(childRoot, path16.resolve(authoringRoot, p));
19251
+ const inside = rel2 !== "" && rel2 !== ".." && !rel2.startsWith(`..${path16.sep}`) && !path16.isAbsolute(rel2);
19338
19252
  return inside ? rel2.replace(/\\/g, "/") : p;
19339
19253
  };
19340
19254
  return {
@@ -19369,9 +19283,9 @@ function findOwner(id, components) {
19369
19283
  }) ?? null;
19370
19284
  }
19371
19285
  function moveComponentFolder(fromDir, toDir) {
19372
- if (path17.normalize(fromDir) === path17.normalize(toDir)) return false;
19286
+ if (path16.normalize(fromDir) === path16.normalize(toDir)) return false;
19373
19287
  if (!fs12.existsSync(fromDir) || fs12.existsSync(toDir)) return false;
19374
- ensureDir(path17.dirname(toDir));
19288
+ ensureDir(path16.dirname(toDir));
19375
19289
  fs12.renameSync(fromDir, toDir);
19376
19290
  return true;
19377
19291
  }
@@ -19787,7 +19701,7 @@ function refusedMoveSummary(from, to, methods, refusals, alternatives) {
19787
19701
  return `Refused: moving ${namedMethods(methods)} from "${from}" to "${to}" is refused by ${refusals.join(", ")}. Nothing was written. ` + (cheapest ? `The cheapest legal home is "${cheapest.component}" (${cheapest.newDependencies.length} new dependenc${cheapest.newDependencies.length === 1 ? "y" : "ies"}, ${cheapest.dependencyCount} of ${cheapest.dependencyLimit}).` : `No component of this subsystem can take them as they stand \u2014 ${alternatives.length} were weighed.`);
19788
19702
  }
19789
19703
  function workspaceFor(rootDir) {
19790
- const key = path17.resolve(rootDir);
19704
+ const key = path16.resolve(rootDir);
19791
19705
  let ws = workspaces.get(key);
19792
19706
  if (!ws) {
19793
19707
  ws = new SpecWorkspace(key);
@@ -19917,13 +19831,13 @@ function snapshotInputKey(snapshot) {
19917
19831
  return canonicalize(content);
19918
19832
  }
19919
19833
  function consumedSurfaceInputsAt(rootDir) {
19920
- const dir = path17.join(rootDir, ".wai", "surfaces");
19834
+ const dir = path16.join(rootDir, ".wai", "surfaces");
19921
19835
  if (!pathExists(dir)) return [];
19922
19836
  const keys = [];
19923
19837
  for (const file of fs12.readdirSync(dir)) {
19924
19838
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
19925
19839
  try {
19926
- keys.push(snapshotInputKey(SurfaceSnapshotSchema.parse(readYamlFile(path17.join(dir, file)))));
19840
+ keys.push(snapshotInputKey(SurfaceSnapshotSchema.parse(readYamlFile(path16.join(dir, file)))));
19927
19841
  } catch {
19928
19842
  }
19929
19843
  }
@@ -19931,7 +19845,7 @@ function consumedSurfaceInputsAt(rootDir) {
19931
19845
  }
19932
19846
  function consumedContractInputs() {
19933
19847
  const root = getProjectRoot();
19934
- const roots = [root, ...listChainedRoots(root).map((rel2) => path17.join(root, rel2))];
19848
+ const roots = [root, ...listChainedRoots(root).map((rel2) => path16.join(root, rel2))];
19935
19849
  return roots.flatMap(consumedSurfaceInputsAt);
19936
19850
  }
19937
19851
  function readLockState(current2) {
@@ -19967,7 +19881,7 @@ function markSelectionsBundled(bundled) {
19967
19881
  projectConfigRepository.markSelectionsBundled(bundled);
19968
19882
  }
19969
19883
  function computeStateIdAt(root) {
19970
- const resolved = path17.resolve(root);
19884
+ const resolved = path16.resolve(root);
19971
19885
  return runWithProjectRoot(resolved, () => {
19972
19886
  workspaceFor(resolved).invalidate();
19973
19887
  const system = loadSystemSpec();
@@ -20017,12 +19931,12 @@ function updateSpec(kind, id, delta, hooks, dryRun) {
20017
19931
  function moveMethods(from, to, methods, hooks, dryRun) {
20018
19932
  return current().moveMethods(from, to, methods, hooks, dryRun);
20019
19933
  }
20020
- var fs12, path17, NO_ROOT_SUBSYSTEMS, SIGNATURE_TTL_MS, COMPONENT_AUTH_SOURCE, DELTA_VERBS, JUMP_LABEL_TWINS, LABEL_TWIN_CONTAINERS, SpecWorkspace, DEFAULT_DEPENDENCY_LIMIT, PROSE_FIELDS, workspaces;
19934
+ var fs12, path16, NO_ROOT_SUBSYSTEMS, SIGNATURE_TTL_MS, COMPONENT_AUTH_SOURCE, DELTA_VERBS, JUMP_LABEL_TWINS, LABEL_TWIN_CONTAINERS, SpecWorkspace, DEFAULT_DEPENDENCY_LIMIT, PROSE_FIELDS, workspaces;
20021
19935
  var init_specs2 = __esm({
20022
19936
  "src/core/specs.ts"() {
20023
19937
  "use strict";
20024
19938
  fs12 = __toESM(require("fs"));
20025
- path17 = __toESM(require("path"));
19939
+ path16 = __toESM(require("path"));
20026
19940
  init_loader();
20027
19941
  init_project_config();
20028
19942
  init_fs();
@@ -20057,7 +19971,7 @@ var init_specs2 = __esm({
20057
19971
  this.rootSubsystems = /* @__PURE__ */ new Set();
20058
19972
  this.scanVisitedSpecDirs = [];
20059
19973
  this.loaderIssues = [];
20060
- this.rootDir = path17.resolve(rootDir);
19974
+ this.rootDir = path16.resolve(rootDir);
20061
19975
  this.paths = aiPathsAt(this.rootDir);
20062
19976
  }
20063
19977
  invalidate() {
@@ -20100,8 +20014,8 @@ var init_specs2 = __esm({
20100
20014
  * qualifies the spec itself — so scoping a validate to a mount keeps it.
20101
20015
  */
20102
20016
  loaderIssueSpecId(file, rawId, namespacePrefix) {
20103
- const stem = path17.basename(file, ".yaml");
20104
- const local = rawId ?? (stem.startsWith(".") ? path17.basename(path17.dirname(file)) : stem);
20017
+ const stem = path16.basename(file, ".yaml");
20018
+ const local = rawId ?? (stem.startsWith(".") ? path16.basename(path16.dirname(file)) : stem);
20105
20019
  return namespacePrefix ? qualifyId(local, namespacePrefix, this.rootSubsystems) : local;
20106
20020
  }
20107
20021
  scanSpecsForProject(projectDir, namespacePrefix, visitedDirs, maxDepth, currentDepth) {
@@ -20111,10 +20025,10 @@ var init_specs2 = __esm({
20111
20025
  this.scanVisitedSpecDirs.push(specsDir);
20112
20026
  if (!pathExists(specsDir)) return index;
20113
20027
  const files = listSpecFiles(specsDir);
20114
- const systemYaml = path17.normalize(projectPaths.specsSystem());
20028
+ const systemYaml = path16.normalize(projectPaths.specsSystem());
20115
20029
  const localSubprojects = [];
20116
20030
  for (const file of files) {
20117
- const normFile = path17.normalize(file);
20031
+ const normFile = path16.normalize(file);
20118
20032
  if (normFile === systemYaml) continue;
20119
20033
  let detectedType = "spec";
20120
20034
  let rawId;
@@ -20158,7 +20072,7 @@ var init_specs2 = __esm({
20158
20072
  } else if ("contract" in raw) {
20159
20073
  detectedType = "implementation";
20160
20074
  const parsed = ImplementationSpecSchema.parse(raw);
20161
- const normalizeSourcePath = (p) => path17.relative(projectDir, path17.resolve(projectDir, p)).replace(/\\/g, "/");
20075
+ const normalizeSourcePath = (p) => path16.relative(projectDir, path16.resolve(projectDir, p)).replace(/\\/g, "/");
20162
20076
  if (parsed.sourcePath) parsed.sourcePath = normalizeSourcePath(parsed.sourcePath);
20163
20077
  for (const method of parsed.methods) {
20164
20078
  if (method.sourcePath) method.sourcePath = normalizeSourcePath(method.sourcePath);
@@ -20284,7 +20198,7 @@ var init_specs2 = __esm({
20284
20198
  }
20285
20199
  if (currentDepth < maxDepth) {
20286
20200
  for (const subproj of localSubprojects) {
20287
- const childDir = path17.resolve(projectDir, subproj.projectPath);
20201
+ const childDir = path16.resolve(projectDir, subproj.projectPath);
20288
20202
  const mountId = namespacePrefix ? qualifyDeclaredId(subproj.subsystemId, namespacePrefix, true) : subproj.subsystemId;
20289
20203
  if (projectPathEscapesRoot(projectDir, subproj.projectPath, childDir)) {
20290
20204
  this.loaderIssues.push({
@@ -20347,7 +20261,7 @@ var init_specs2 = __esm({
20347
20261
  const index = this.scanAll();
20348
20262
  const sub = index.subsystems.find((s) => s.id === currentPrefix);
20349
20263
  if (sub && sub.projectPath) {
20350
- const nextDir = path17.resolve(currentDir, sub.projectPath);
20264
+ const nextDir = path16.resolve(currentDir, sub.projectPath);
20351
20265
  if (projectPathEscapesRoot(currentDir, sub.projectPath, nextDir)) {
20352
20266
  this.loaderIssues.push({
20353
20267
  severity: "error",
@@ -20399,9 +20313,9 @@ var init_specs2 = __esm({
20399
20313
  return index.paths.subsystem[matches[0]];
20400
20314
  }
20401
20315
  if (pathExists(this.paths.specsSubsystemsDir()) && listFiles(this.paths.specsSubsystemsDir(), ".yaml").length > 0) {
20402
- return path17.join(this.paths.specsSubsystemsDir(), `${id}.yaml`);
20316
+ return path16.join(this.paths.specsSubsystemsDir(), `${id}.yaml`);
20403
20317
  }
20404
- return path17.join(this.paths.specsDir(), id, ".index.yaml");
20318
+ return path16.join(this.paths.specsDir(), id, ".index.yaml");
20405
20319
  }
20406
20320
  getComponentPath(id, subsystemId) {
20407
20321
  const index = this.scanAll();
@@ -20421,21 +20335,21 @@ var init_specs2 = __esm({
20421
20335
  if (owner) {
20422
20336
  const ownerPath = index.paths.component[owner.id];
20423
20337
  if (ownerPath && ownerPath.endsWith(".index.yaml")) {
20424
- return path17.join(path17.dirname(ownerPath), id, ".index.yaml");
20338
+ return path16.join(path16.dirname(ownerPath), id, ".index.yaml");
20425
20339
  }
20426
20340
  }
20427
20341
  if (subsystemId) {
20428
20342
  const subPath = this.getSubsystemPath(subsystemId);
20429
- const subDir = path17.dirname(subPath);
20343
+ const subDir = path16.dirname(subPath);
20430
20344
  if (subPath.endsWith(".index.yaml")) {
20431
- return path17.join(subDir, id, ".index.yaml");
20345
+ return path16.join(subDir, id, ".index.yaml");
20432
20346
  }
20433
20347
  }
20434
20348
  if (pathExists(this.paths.specsComponentsDir()) && listFiles(this.paths.specsComponentsDir(), ".yaml").length > 0) {
20435
- return path17.join(this.paths.specsComponentsDir(), `${id}.yaml`);
20349
+ return path16.join(this.paths.specsComponentsDir(), `${id}.yaml`);
20436
20350
  }
20437
20351
  const targetSubsystem = subsystemId || "default";
20438
- return path17.join(this.paths.specsDir(), targetSubsystem, id, ".index.yaml");
20352
+ return path16.join(this.paths.specsDir(), targetSubsystem, id, ".index.yaml");
20439
20353
  }
20440
20354
  getInterfacePath(id, componentId) {
20441
20355
  const index = this.scanAll();
@@ -20461,16 +20375,16 @@ var init_specs2 = __esm({
20461
20375
  }
20462
20376
  if (componentId) {
20463
20377
  const compPath = this.getComponentPath(componentId);
20464
- const compDir = path17.dirname(compPath);
20378
+ const compDir = path16.dirname(compPath);
20465
20379
  if (compPath.endsWith(".index.yaml")) {
20466
- return path17.join(compDir, ".interface.yaml");
20380
+ return path16.join(compDir, ".interface.yaml");
20467
20381
  }
20468
20382
  }
20469
20383
  if (pathExists(this.paths.specsInterfacesDir()) && listFiles(this.paths.specsInterfacesDir(), ".yaml").length > 0) {
20470
- return path17.join(this.paths.specsInterfacesDir(), `${id}.yaml`);
20384
+ return path16.join(this.paths.specsInterfacesDir(), `${id}.yaml`);
20471
20385
  }
20472
20386
  const targetComponent = componentId || "default";
20473
- return path17.join(this.paths.specsDir(), "default", targetComponent, ".interface.yaml");
20387
+ return path16.join(this.paths.specsDir(), "default", targetComponent, ".interface.yaml");
20474
20388
  }
20475
20389
  getImplementationPath(id, contractId) {
20476
20390
  const index = this.scanAll();
@@ -20496,16 +20410,16 @@ var init_specs2 = __esm({
20496
20410
  }
20497
20411
  if (contractId) {
20498
20412
  const intfPath = this.getInterfacePath(contractId);
20499
- const intfDir = path17.dirname(intfPath);
20413
+ const intfDir = path16.dirname(intfPath);
20500
20414
  if (intfPath.endsWith(".interface.yaml")) {
20501
- return path17.join(intfDir, ".implementation.yaml");
20415
+ return path16.join(intfDir, ".implementation.yaml");
20502
20416
  }
20503
20417
  }
20504
20418
  if (pathExists(this.paths.specsImplementationsDir()) && listFiles(this.paths.specsImplementationsDir(), ".yaml").length > 0) {
20505
- return path17.join(this.paths.specsImplementationsDir(), `${id}.yaml`);
20419
+ return path16.join(this.paths.specsImplementationsDir(), `${id}.yaml`);
20506
20420
  }
20507
20421
  const targetContract = contractId ? contractId.replace(/^i/, "") : "default";
20508
- return path17.join(this.paths.specsDir(), "default", targetContract, ".implementation.yaml");
20422
+ return path16.join(this.paths.specsDir(), "default", targetContract, ".implementation.yaml");
20509
20423
  }
20510
20424
  getTypePath(id, subsystemId, group) {
20511
20425
  const index = this.scanAll();
@@ -20536,7 +20450,7 @@ var init_specs2 = __esm({
20536
20450
  const groupPath = index.paths.group[targetGroup] || index.paths.group[plainGroup];
20537
20451
  if (groupPath) {
20538
20452
  const localId2 = id.split("::").pop();
20539
- return path17.join(path17.dirname(groupPath), `${localId2}.yaml`);
20453
+ return path16.join(path16.dirname(groupPath), `${localId2}.yaml`);
20540
20454
  }
20541
20455
  }
20542
20456
  let localId = id;
@@ -20549,12 +20463,12 @@ var init_specs2 = __esm({
20549
20463
  }
20550
20464
  if (subsystemId) {
20551
20465
  const subPath = this.getSubsystemPath(subsystemId);
20552
- const subDir = path17.dirname(subPath);
20466
+ const subDir = path16.dirname(subPath);
20553
20467
  if (subPath.endsWith(".index.yaml")) {
20554
- return path17.join(subDir, "types", `${localId}.yaml`);
20468
+ return path16.join(subDir, "types", `${localId}.yaml`);
20555
20469
  }
20556
20470
  }
20557
- return path17.join(this.paths.specsTypesDir(), `${localId}.yaml`);
20471
+ return path16.join(this.paths.specsTypesDir(), `${localId}.yaml`);
20558
20472
  }
20559
20473
  getGroupPath(id, subsystemId) {
20560
20474
  const index = this.scanAll();
@@ -20588,12 +20502,12 @@ var init_specs2 = __esm({
20588
20502
  }
20589
20503
  if (subsystemId) {
20590
20504
  const subPath = this.getSubsystemPath(subsystemId);
20591
- const subDir = path17.dirname(subPath);
20505
+ const subDir = path16.dirname(subPath);
20592
20506
  if (subPath.endsWith(".index.yaml")) {
20593
- return path17.join(subDir, "types", localId, ".index.yaml");
20507
+ return path16.join(subDir, "types", localId, ".index.yaml");
20594
20508
  }
20595
20509
  }
20596
- return path17.join(this.paths.specsTypesDir(), localId, ".index.yaml");
20510
+ return path16.join(this.paths.specsTypesDir(), localId, ".index.yaml");
20597
20511
  }
20598
20512
  // -------------------------------------------------------------------------
20599
20513
  // Level 0: System
@@ -20616,7 +20530,7 @@ var init_specs2 = __esm({
20616
20530
  }
20617
20531
  saveSystemSpec(spec) {
20618
20532
  const p = this.paths.specsSystem();
20619
- ensureDir(path17.dirname(p));
20533
+ ensureDir(path16.dirname(p));
20620
20534
  writeSpecFile(p, parseOrThrow(SystemSpecSchema, spec, "system", spec.name));
20621
20535
  invalidateSpecCache();
20622
20536
  }
@@ -20738,7 +20652,7 @@ var init_specs2 = __esm({
20738
20652
  }
20739
20653
  saveSubsystemSpec(spec, opts) {
20740
20654
  const p = this.getSubsystemPath(spec.id);
20741
- ensureDir(path17.dirname(p));
20655
+ ensureDir(path16.dirname(p));
20742
20656
  const { prefix } = splitNamespace(spec.id);
20743
20657
  if (!prefix && spec.projectPath && spec.projectPath.trim() !== "") {
20744
20658
  assertContainedProjectPath(this.rootDir, spec.projectPath);
@@ -20805,7 +20719,7 @@ var init_specs2 = __esm({
20805
20719
  saveComponentSpec(spec, opts) {
20806
20720
  const notices = [];
20807
20721
  const p = this.getComponentPath(spec.id, spec.subsystem);
20808
- ensureDir(path17.dirname(p));
20722
+ ensureDir(path16.dirname(p));
20809
20723
  const specToWrite = this.prepareComponentForWrite(spec);
20810
20724
  const existing = this.loadComponentSpec(spec.id);
20811
20725
  if (existing) {
@@ -20822,7 +20736,7 @@ var init_specs2 = __esm({
20822
20736
  const subsystemChanged = existing && existing.subsystem !== spec.subsystem && splitNamespace(existing.subsystem).localId !== splitNamespace(spec.subsystem).localId;
20823
20737
  if (subsystemChanged && !p.endsWith(".index.yaml")) {
20824
20738
  notices.push(
20825
- `component "${spec.id}" already exists at ${path17.relative(this.rootDir, p)} \u2014 the flat layout re-saves in place and never relocates the file. The subsystem field is now "${spec.subsystem}" (was "${existing.subsystem}").`
20739
+ `component "${spec.id}" already exists at ${path16.relative(this.rootDir, p)} \u2014 the flat layout re-saves in place and never relocates the file. The subsystem field is now "${spec.subsystem}" (was "${existing.subsystem}").`
20826
20740
  );
20827
20741
  }
20828
20742
  specToWrite.updatedAt = opts?.preserveUpdatedAt && existing?.updatedAt ? existing.updatedAt : (/* @__PURE__ */ new Date()).toISOString();
@@ -20846,12 +20760,12 @@ var init_specs2 = __esm({
20846
20760
  if (owner) {
20847
20761
  const ownerPath = index.paths.component[owner.id];
20848
20762
  if (ownerPath && ownerPath.endsWith(".index.yaml")) {
20849
- const ownerSubDir = path17.dirname(this.getSubsystemPath(owner.subsystem));
20850
- return path17.join(ownerSubDir, owner.id, comp.id);
20763
+ const ownerSubDir = path16.dirname(this.getSubsystemPath(owner.subsystem));
20764
+ return path16.join(ownerSubDir, owner.id, comp.id);
20851
20765
  }
20852
20766
  }
20853
- const subDir = path17.dirname(this.getSubsystemPath(comp.subsystem));
20854
- return path17.join(subDir, comp.id);
20767
+ const subDir = path16.dirname(this.getSubsystemPath(comp.subsystem));
20768
+ return path16.join(subDir, comp.id);
20855
20769
  }
20856
20770
  /**
20857
20771
  * Move component folders so the physical tree mirrors ownership: each owned
@@ -20867,7 +20781,7 @@ var init_specs2 = __esm({
20867
20781
  if (!currentPath) continue;
20868
20782
  const desiredDir = this.desiredComponentDir(comp, index);
20869
20783
  if (!desiredDir) continue;
20870
- if (moveComponentFolder(path17.dirname(currentPath), desiredDir)) moved.push(comp.id);
20784
+ if (moveComponentFolder(path16.dirname(currentPath), desiredDir)) moved.push(comp.id);
20871
20785
  }
20872
20786
  if (moved.length) invalidateSpecCache();
20873
20787
  return moved;
@@ -20923,7 +20837,7 @@ var init_specs2 = __esm({
20923
20837
  if (!occupantId) return;
20924
20838
  if (occupantId === id || splitNamespace(occupantId).localId === splitNamespace(id).localId) return;
20925
20839
  throw new Error(
20926
- `Cannot write ${kind} "${id}": ${parentLabel} is already ${kind === "interface" ? "served by" : "implemented by"} "${occupantId}" at ${path17.relative(this.rootDir, p)}, and both ids resolve to that one file. Re-author "${occupantId}" instead, or delete it first if you meant to replace it.`
20840
+ `Cannot write ${kind} "${id}": ${parentLabel} is already ${kind === "interface" ? "served by" : "implemented by"} "${occupantId}" at ${path16.relative(this.rootDir, p)}, and both ids resolve to that one file. Re-author "${occupantId}" instead, or delete it first if you meant to replace it.`
20927
20841
  );
20928
20842
  }
20929
20843
  /** Returns non-fatal placement notices (see saveTypeSpec) — empty when there is nothing to clarify. */
@@ -20931,12 +20845,12 @@ var init_specs2 = __esm({
20931
20845
  const notices = [];
20932
20846
  const p = this.getInterfacePath(spec.id, spec.component);
20933
20847
  this.assertPathHoldsNoOtherSpec(p, spec.id, "interface", `component "${spec.component}"`);
20934
- ensureDir(path17.dirname(p));
20848
+ ensureDir(path16.dirname(p));
20935
20849
  const specToWrite = this.prepareInterfaceForWrite(spec);
20936
20850
  const existing = this.loadInterfaceSpec(spec.id);
20937
20851
  if (existing && existing.component !== spec.component && splitNamespace(existing.component).localId !== splitNamespace(spec.component).localId) {
20938
20852
  notices.push(
20939
- `interface "${spec.id}" already exists at ${path17.relative(this.rootDir, p)} \u2014 re-saving updates the component binding field in place (now "${spec.component}", was "${existing.component}") and never moves the file.`
20853
+ `interface "${spec.id}" already exists at ${path16.relative(this.rootDir, p)} \u2014 re-saving updates the component binding field in place (now "${spec.component}", was "${existing.component}") and never moves the file.`
20940
20854
  );
20941
20855
  }
20942
20856
  if (existing) {
@@ -20993,12 +20907,12 @@ var init_specs2 = __esm({
20993
20907
  const notices = [];
20994
20908
  const p = this.getImplementationPath(spec.id, spec.contract);
20995
20909
  this.assertPathHoldsNoOtherSpec(p, spec.id, "implementation", `contract "${spec.contract}"`);
20996
- ensureDir(path17.dirname(p));
20910
+ ensureDir(path16.dirname(p));
20997
20911
  const specToWrite = this.prepareImplementationForWrite(spec);
20998
20912
  const existing = this.loadImplementationSpec(spec.id);
20999
20913
  if (existing && existing.contract !== spec.contract && splitNamespace(existing.contract).localId !== splitNamespace(spec.contract).localId) {
21000
20914
  notices.push(
21001
- `implementation "${spec.id}" already exists at ${path17.relative(this.rootDir, p)} \u2014 re-saving updates the contract binding field in place (now "${spec.contract}", was "${existing.contract}") and never moves the file.`
20915
+ `implementation "${spec.id}" already exists at ${path16.relative(this.rootDir, p)} \u2014 re-saving updates the contract binding field in place (now "${spec.contract}", was "${existing.contract}") and never moves the file.`
21002
20916
  );
21003
20917
  }
21004
20918
  if (existing) {
@@ -21039,11 +20953,11 @@ var init_specs2 = __esm({
21039
20953
  const existing = this.loadTypeSpec(spec.id);
21040
20954
  const group = spec.group || (existing ? existing.group : void 0);
21041
20955
  const p = this.getTypePath(spec.id, spec.subsystem, group);
21042
- ensureDir(path17.dirname(p));
20956
+ ensureDir(path16.dirname(p));
21043
20957
  const subsystemChanged = existing && (existing.subsystem ?? "") !== (spec.subsystem ?? "") && splitNamespace(existing.subsystem ?? "").localId !== splitNamespace(spec.subsystem ?? "").localId;
21044
20958
  if (subsystemChanged) {
21045
20959
  notices.push(
21046
- `type "${spec.id}" already exists at ${path17.relative(this.rootDir, p)} \u2014 re-saving updates fields in place and never relocates the file. The subsystem field is now "${spec.subsystem ?? "(none)"}" (was "${existing.subsystem ?? "(none)"}").`
20960
+ `type "${spec.id}" already exists at ${path16.relative(this.rootDir, p)} \u2014 re-saving updates fields in place and never relocates the file. The subsystem field is now "${spec.subsystem ?? "(none)"}" (was "${existing.subsystem ?? "(none)"}").`
21047
20961
  );
21048
20962
  }
21049
20963
  if (spec.subsystem && (!existing || subsystemChanged) && !this.getSubsystemPath(spec.subsystem).endsWith(".index.yaml")) {
@@ -21081,7 +20995,7 @@ var init_specs2 = __esm({
21081
20995
  }
21082
20996
  saveGroupSpec(spec, opts) {
21083
20997
  const p = this.getGroupPath(spec.id);
21084
- ensureDir(path17.dirname(p));
20998
+ ensureDir(path16.dirname(p));
21085
20999
  const specToWrite = this.prepareGroupForWrite(spec);
21086
21000
  const existing = this.loadGroupSpec(spec.id);
21087
21001
  if (existing) {
@@ -21159,7 +21073,7 @@ var init_specs2 = __esm({
21159
21073
  };
21160
21074
  const out = /* @__PURE__ */ new Set();
21161
21075
  const add = (p) => {
21162
- if (p) out.add(path17.resolve(p));
21076
+ if (p) out.add(path16.resolve(p));
21163
21077
  };
21164
21078
  for (const s of this.loadSubsystemSpecs()) {
21165
21079
  if (!scopeSubsystem || s.id === scopeSubsystem || s.id.startsWith(`${scopeSubsystem}::`)) {
@@ -21230,11 +21144,11 @@ var init_specs2 = __esm({
21230
21144
  const files = /* @__PURE__ */ new Set();
21231
21145
  const sysPath = this.paths.specsSystem();
21232
21146
  if (pathExists(sysPath)) {
21233
- files.add(path17.resolve(sysPath));
21147
+ files.add(path16.resolve(sysPath));
21234
21148
  }
21235
21149
  for (const group of Object.values(index.paths)) {
21236
21150
  for (const file of Object.values(group)) {
21237
- files.add(path17.resolve(file));
21151
+ files.add(path16.resolve(file));
21238
21152
  }
21239
21153
  }
21240
21154
  for (const file of files) {
@@ -21253,20 +21167,20 @@ var init_specs2 = __esm({
21253
21167
  const files = listSpecFiles(specsDir);
21254
21168
  const legacy = [];
21255
21169
  for (const f of files) {
21256
- const base = path17.basename(f);
21257
- const dir = path17.dirname(f);
21170
+ const base = path16.basename(f);
21171
+ const dir = path16.dirname(f);
21258
21172
  if (base === "system.yaml") {
21259
- legacy.push({ path: f, expected: path17.join(dir, ".index.yaml") });
21173
+ legacy.push({ path: f, expected: path16.join(dir, ".index.yaml") });
21260
21174
  } else if (base === "subsystem.yaml") {
21261
- legacy.push({ path: f, expected: path17.join(dir, ".index.yaml") });
21175
+ legacy.push({ path: f, expected: path16.join(dir, ".index.yaml") });
21262
21176
  } else if (base === "component.yaml") {
21263
- legacy.push({ path: f, expected: path17.join(dir, ".index.yaml") });
21177
+ legacy.push({ path: f, expected: path16.join(dir, ".index.yaml") });
21264
21178
  } else if (base === "group.yaml") {
21265
- legacy.push({ path: f, expected: path17.join(dir, ".index.yaml") });
21179
+ legacy.push({ path: f, expected: path16.join(dir, ".index.yaml") });
21266
21180
  } else if (base === "interface.yaml") {
21267
- legacy.push({ path: f, expected: path17.join(dir, ".interface.yaml") });
21181
+ legacy.push({ path: f, expected: path16.join(dir, ".interface.yaml") });
21268
21182
  } else if (base === "implementation.yaml") {
21269
- legacy.push({ path: f, expected: path17.join(dir, ".implementation.yaml") });
21183
+ legacy.push({ path: f, expected: path16.join(dir, ".implementation.yaml") });
21270
21184
  }
21271
21185
  }
21272
21186
  return legacy;
@@ -22278,7 +22192,7 @@ __export(agent_resolver_exports, {
22278
22192
  });
22279
22193
  function listFilesRecursiveSafe(dirPath, ext) {
22280
22194
  if (!fs13.existsSync(dirPath)) return [];
22281
- const nameLower = path18.basename(dirPath).toLowerCase();
22195
+ const nameLower = path17.basename(dirPath).toLowerCase();
22282
22196
  const IGNORED_DIRS = /* @__PURE__ */ new Set([
22283
22197
  "node_modules",
22284
22198
  "target",
@@ -22296,7 +22210,7 @@ function listFilesRecursiveSafe(dirPath, ext) {
22296
22210
  const entries = fs13.readdirSync(dirPath, { withFileTypes: true });
22297
22211
  const files = [];
22298
22212
  for (const entry of entries) {
22299
- const fullPath = path18.join(dirPath, entry.name);
22213
+ const fullPath = path17.join(dirPath, entry.name);
22300
22214
  if (entry.isDirectory()) {
22301
22215
  files.push(...listFilesRecursiveSafe(fullPath, ext));
22302
22216
  } else if (entry.isFile() && entry.name.endsWith(ext)) {
@@ -22309,8 +22223,8 @@ function getProjectFiles(projectDir) {
22309
22223
  let files = projectFilesCache.get(projectDir);
22310
22224
  if (!files) {
22311
22225
  files = [];
22312
- const srcDir = path18.join(projectDir, "src");
22313
- const legacySrcDir = path18.join(projectDir, "legacy-src");
22226
+ const srcDir = path17.join(projectDir, "src");
22227
+ const legacySrcDir = path17.join(projectDir, "legacy-src");
22314
22228
  let searchDir = projectDir;
22315
22229
  if (pathExists(srcDir)) {
22316
22230
  searchDir = srcDir;
@@ -22325,7 +22239,7 @@ function getProjectFiles(projectDir) {
22325
22239
  files.push(...listFilesRecursiveSafe(searchDir, ext));
22326
22240
  }
22327
22241
  const rootDir = getProjectRoot();
22328
- files = files.map((f) => path18.relative(rootDir, f).replace(/\\/g, "/"));
22242
+ files = files.map((f) => path17.relative(rootDir, f).replace(/\\/g, "/"));
22329
22243
  projectFilesCache.set(projectDir, files);
22330
22244
  }
22331
22245
  return files;
@@ -22350,8 +22264,8 @@ function inferSourcePathForComponent(comp, subsystems) {
22350
22264
  let bestFile = null;
22351
22265
  let bestScore = -1;
22352
22266
  for (const f of files) {
22353
- const ext = path18.extname(f);
22354
- const base = path18.basename(f, ext).toLowerCase();
22267
+ const ext = path17.extname(f);
22268
+ const base = path17.basename(f, ext).toLowerCase();
22355
22269
  if (candidates.has(base)) {
22356
22270
  let score = 0;
22357
22271
  const normalizedPath = f.toLowerCase();
@@ -22448,7 +22362,7 @@ function resolveAgentTopology() {
22448
22362
  });
22449
22363
  for (const sub of subsystems) {
22450
22364
  if (sub.projectPath) {
22451
- const mountSpecPath = path18.relative(getProjectRoot(), getSubsystemPath(sub.id)).replace(/\\/g, "/");
22365
+ const mountSpecPath = path17.relative(getProjectRoot(), getSubsystemPath(sub.id)).replace(/\\/g, "/");
22452
22366
  agents.push({
22453
22367
  id: `${sub.id}-owner`,
22454
22368
  name: `${sub.name} (chained subproject)`,
@@ -22470,9 +22384,9 @@ function resolveAgentTopology() {
22470
22384
  }
22471
22385
  const subComponents = components.filter((c) => c.subsystem === sub.id);
22472
22386
  const ownedPaths = [];
22473
- ownedPaths.push(path18.relative(getProjectRoot(), getSubsystemPath(sub.id)).replace(/\\/g, "/"));
22387
+ ownedPaths.push(path17.relative(getProjectRoot(), getSubsystemPath(sub.id)).replace(/\\/g, "/"));
22474
22388
  for (const c of subComponents) {
22475
- ownedPaths.push(path18.relative(getProjectRoot(), getComponentPath(c.id, sub.id)).replace(/\\/g, "/"));
22389
+ ownedPaths.push(path17.relative(getProjectRoot(), getComponentPath(c.id, sub.id)).replace(/\\/g, "/"));
22476
22390
  }
22477
22391
  if (!config.rules.generateComponentImplementers) {
22478
22392
  for (const comp of subComponents) {
@@ -22548,10 +22462,10 @@ function resolveAgentTopology() {
22548
22462
  }
22549
22463
  const dependencies = comp.dependsOn.map((depId) => `${depId}-implementer`);
22550
22464
  const readPaths = [
22551
- path18.relative(getProjectRoot(), AI_PATHS.specsSystem()).replace(/\\/g, "/"),
22552
- path18.relative(getProjectRoot(), getComponentPath(comp.id, comp.subsystem)).replace(/\\/g, "/"),
22553
- ...compInterfaces.map((i) => path18.relative(getProjectRoot(), getInterfacePath(i.id, comp.id)).replace(/\\/g, "/")),
22554
- ...compImpls.map((impl) => path18.relative(getProjectRoot(), getImplementationPath(impl.id, impl.contract)).replace(/\\/g, "/"))
22465
+ path17.relative(getProjectRoot(), AI_PATHS.specsSystem()).replace(/\\/g, "/"),
22466
+ path17.relative(getProjectRoot(), getComponentPath(comp.id, comp.subsystem)).replace(/\\/g, "/"),
22467
+ ...compInterfaces.map((i) => path17.relative(getProjectRoot(), getInterfacePath(i.id, comp.id)).replace(/\\/g, "/")),
22468
+ ...compImpls.map((impl) => path17.relative(getProjectRoot(), getImplementationPath(impl.id, impl.contract)).replace(/\\/g, "/"))
22555
22469
  ];
22556
22470
  agents.push({
22557
22471
  id: `${comp.id}-implementer`,
@@ -22640,11 +22554,11 @@ ${guidance.trim()}
22640
22554
  budget
22641
22555
  };
22642
22556
  }
22643
- var path18, fs13, projectFilesCache, UnknownAgentError;
22557
+ var path17, fs13, projectFilesCache, UnknownAgentError;
22644
22558
  var init_agent_resolver = __esm({
22645
22559
  "src/core/agent_resolver.ts"() {
22646
22560
  "use strict";
22647
- path18 = __toESM(require("path"));
22561
+ path17 = __toESM(require("path"));
22648
22562
  fs13 = __toESM(require("fs"));
22649
22563
  init_loader();
22650
22564
  init_project_config();
@@ -22668,12 +22582,12 @@ var init_agent_resolver = __esm({
22668
22582
 
22669
22583
  // src/config/loader.ts
22670
22584
  function aiPathsAt(rootDir) {
22671
- const resolvedRoot = path19.resolve(rootDir);
22585
+ const resolvedRoot = path18.resolve(rootDir);
22672
22586
  const aiDirAt2 = (...segments) => {
22673
- const waiPath = path19.join(resolvedRoot, ".wai");
22674
- const waironPath = path19.join(resolvedRoot, ".wairon");
22587
+ const waiPath = path18.join(resolvedRoot, ".wai");
22588
+ const waironPath = path18.join(resolvedRoot, ".wairon");
22675
22589
  const base = !fs14.existsSync(waiPath) && fs14.existsSync(waironPath) ? waironPath : waiPath;
22676
- return path19.join(base, ...segments);
22590
+ return path18.join(base, ...segments);
22677
22591
  };
22678
22592
  const specsDir = () => projectConfigRepositoryAt(resolvedRoot).specsDir();
22679
22593
  return {
@@ -22690,12 +22604,12 @@ function aiPathsAt(rootDir) {
22690
22604
  contextDomainsMd: () => aiDirAt2("context", "domains.md"),
22691
22605
  contextWaironGuideMd: () => aiDirAt2("context", "wairon-guide.md"),
22692
22606
  specsDir,
22693
- specsSystem: () => path19.join(specsDir(), ".index.yaml"),
22694
- specsSubsystemsDir: () => path19.join(specsDir(), "subsystems"),
22695
- specsComponentsDir: () => path19.join(specsDir(), "components"),
22696
- specsInterfacesDir: () => path19.join(specsDir(), "interfaces"),
22697
- specsImplementationsDir: () => path19.join(specsDir(), "implementations"),
22698
- specsTypesDir: () => path19.join(specsDir(), "types")
22607
+ specsSystem: () => path18.join(specsDir(), ".index.yaml"),
22608
+ specsSubsystemsDir: () => path18.join(specsDir(), "subsystems"),
22609
+ specsComponentsDir: () => path18.join(specsDir(), "components"),
22610
+ specsInterfacesDir: () => path18.join(specsDir(), "interfaces"),
22611
+ specsImplementationsDir: () => path18.join(specsDir(), "implementations"),
22612
+ specsTypesDir: () => path18.join(specsDir(), "types")
22699
22613
  };
22700
22614
  }
22701
22615
  function isProjectInitialized() {
@@ -22726,12 +22640,12 @@ function loadTopologyConfig() {
22726
22640
  function saveTopologyConfig(config) {
22727
22641
  writeYamlFile(AI_PATHS.topologyConfig(), config);
22728
22642
  }
22729
- var fs14, path19, AI_PATHS;
22643
+ var fs14, path18, AI_PATHS;
22730
22644
  var init_loader = __esm({
22731
22645
  "src/config/loader.ts"() {
22732
22646
  "use strict";
22733
22647
  fs14 = __toESM(require("fs"));
22734
- path19 = __toESM(require("path"));
22648
+ path18 = __toESM(require("path"));
22735
22649
  init_fs();
22736
22650
  init_yaml();
22737
22651
  init_errors();
@@ -22772,7 +22686,7 @@ __export(domains_exports, {
22772
22686
  resolveDomains: () => resolveDomains
22773
22687
  });
22774
22688
  function rel(p) {
22775
- return path20.relative(process.cwd(), p).replace(/\\/g, "/");
22689
+ return path19.relative(process.cwd(), p).replace(/\\/g, "/");
22776
22690
  }
22777
22691
  function deriveSubsystemDomains() {
22778
22692
  const subsystems = loadSubsystemSpecs();
@@ -22822,11 +22736,11 @@ function removeFreeStandingDomain(id) {
22822
22736
  config.domains.splice(idx, 1);
22823
22737
  saveTopologyConfig(config);
22824
22738
  }
22825
- var path20;
22739
+ var path19;
22826
22740
  var init_domains = __esm({
22827
22741
  "src/core/domains.ts"() {
22828
22742
  "use strict";
22829
- path20 = __toESM(require("path"));
22743
+ path19 = __toESM(require("path"));
22830
22744
  init_loader();
22831
22745
  init_specs2();
22832
22746
  init_errors();
@@ -22903,7 +22817,7 @@ function ensureProjectInitialized(fallbackName) {
22903
22817
  function walkChainedSubprojects(projectRoot, onChild) {
22904
22818
  const visited = /* @__PURE__ */ new Set();
22905
22819
  const walk2 = (dir) => {
22906
- const resolved = path21.resolve(dir);
22820
+ const resolved = path20.resolve(dir);
22907
22821
  if (visited.has(resolved)) return;
22908
22822
  visited.add(resolved);
22909
22823
  const specsDir = aiPathsAt(dir).specsDir();
@@ -22925,7 +22839,7 @@ function walkChainedSubprojects(projectRoot, onChild) {
22925
22839
  continue;
22926
22840
  }
22927
22841
  const id = raw.id;
22928
- onChild(childDir, typeof id === "string" ? id : path21.basename(childDir));
22842
+ onChild(childDir, typeof id === "string" ? id : path20.basename(childDir));
22929
22843
  walk2(childDir);
22930
22844
  }
22931
22845
  };
@@ -22952,7 +22866,7 @@ function listDirectChainedSubprojects(projectRoot) {
22952
22866
  continue;
22953
22867
  }
22954
22868
  const id = raw.id;
22955
- out.push({ dir, subsystemId: typeof id === "string" ? id : path21.basename(dir) });
22869
+ out.push({ dir, subsystemId: typeof id === "string" ? id : path20.basename(dir) });
22956
22870
  }
22957
22871
  return out;
22958
22872
  }
@@ -23012,7 +22926,7 @@ function moveSubsystemProject(subsystemId, newProjectPath) {
23012
22926
  if (fs15.existsSync(newDir)) {
23013
22927
  throw new WaironError(`Target directory already exists: ${newDir}`);
23014
22928
  }
23015
- ensureDir(path21.dirname(newDir));
22929
+ ensureDir(path20.dirname(newDir));
23016
22930
  fs15.renameSync(oldDir, newDir);
23017
22931
  }
23018
22932
  saveSubsystemSpec({ ...sub, projectPath: nextPath, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
@@ -23022,9 +22936,9 @@ function toPosixPath(p) {
23022
22936
  return p.replace(/\\/g, "/");
23023
22937
  }
23024
22938
  function isWithinDir(dir, file) {
23025
- const d = path21.resolve(dir);
23026
- const f = path21.resolve(file);
23027
- return f === d || f.startsWith(d + path21.sep);
22939
+ const d = path20.resolve(dir);
22940
+ const f = path20.resolve(file);
22941
+ return f === d || f.startsWith(d + path20.sep);
23028
22942
  }
23029
22943
  function externalizeSubsystem(subsystemId, projectPath) {
23030
22944
  if (subsystemId.includes("::")) {
@@ -23036,13 +22950,13 @@ function externalizeSubsystem(subsystemId, projectPath) {
23036
22950
  }
23037
22951
  const parentRoot = getProjectRoot();
23038
22952
  const parentSpecsDir = aiPathsAt(parentRoot).specsDir();
23039
- const fooDir = path21.join(parentSpecsDir, subsystemId);
22953
+ const fooDir = path20.join(parentSpecsDir, subsystemId);
23040
22954
  if (!fs15.existsSync(fooDir)) {
23041
22955
  throw new WaironError(`subsystem specs directory not found: ${fooDir}`);
23042
22956
  }
23043
22957
  const relPath = toPosixPath(projectPath);
23044
22958
  const childDir = assertContainedProjectPath(parentRoot, relPath);
23045
- const childFooDir = path21.join(childDir, ".wai", "specs", subsystemId);
22959
+ const childFooDir = path20.join(childDir, ".wai", "specs", subsystemId);
23046
22960
  if (fs15.existsSync(childFooDir)) {
23047
22961
  throw new WaironError(`target already contains a "${subsystemId}" subsystem: ${childFooDir}`);
23048
22962
  }
@@ -23055,18 +22969,18 @@ function externalizeSubsystem(subsystemId, projectPath) {
23055
22969
  runWithProjectRoot(childDir, () => {
23056
22970
  const now = (/* @__PURE__ */ new Date()).toISOString();
23057
22971
  projectConfigRepository.create(defaultProjectConfig(childSystemName, now));
23058
- ensureDir(path21.join(childDir, ".wai", "specs"));
22972
+ ensureDir(path20.join(childDir, ".wai", "specs"));
23059
22973
  saveSystemSpec(bootstrapSystemSpec(childSystemName, now));
23060
22974
  });
23061
- ensureDir(path21.dirname(childFooDir));
22975
+ ensureDir(path20.dirname(childFooDir));
23062
22976
  fs15.renameSync(fooDir, childFooDir);
23063
22977
  rebaseImplementationPaths(childFooDir, parentRoot, childDir);
23064
- patchSubsystemIndex(path21.join(childFooDir, ".index.yaml"), (s) => {
22978
+ patchSubsystemIndex(path20.join(childFooDir, ".index.yaml"), (s) => {
23065
22979
  s.parentSystem = childSystemName;
23066
22980
  delete s.projectPath;
23067
22981
  });
23068
22982
  ensureDir(fooDir);
23069
- writeYamlFile(path21.join(fooDir, ".index.yaml"), {
22983
+ writeYamlFile(path20.join(fooDir, ".index.yaml"), {
23070
22984
  id: subsystemId,
23071
22985
  name: foo.name,
23072
22986
  description: foo.description,
@@ -23093,8 +23007,8 @@ function internalizeSubsystem(subsystemId) {
23093
23007
  const parentRoot = getProjectRoot();
23094
23008
  const parentSpecsDir = aiPathsAt(parentRoot).specsDir();
23095
23009
  const childDir = assertContainedProjectPath(parentRoot, foo.projectPath);
23096
- const childWai = path21.join(childDir, ".wai");
23097
- const childFooDir = path21.join(childDir, ".wai", "specs", subsystemId);
23010
+ const childWai = path20.join(childDir, ".wai");
23011
+ const childFooDir = path20.join(childDir, ".wai", "specs", subsystemId);
23098
23012
  if (!fs15.existsSync(childFooDir)) {
23099
23013
  throw new WaironError(`external subproject missing subsystem "${subsystemId}": ${childFooDir}`);
23100
23014
  }
@@ -23108,12 +23022,12 @@ function internalizeSubsystem(subsystemId) {
23108
23022
  false
23109
23023
  );
23110
23024
  const parentSystemName = loadSystemSpec()?.name ?? foo.parentSystem;
23111
- const fooDir = path21.join(parentSpecsDir, subsystemId);
23025
+ const fooDir = path20.join(parentSpecsDir, subsystemId);
23112
23026
  fs15.rmSync(fooDir, { recursive: true, force: true });
23113
- ensureDir(path21.dirname(fooDir));
23027
+ ensureDir(path20.dirname(fooDir));
23114
23028
  fs15.renameSync(childFooDir, fooDir);
23115
23029
  rebaseImplementationPaths(fooDir, childDir, parentRoot);
23116
- patchSubsystemIndex(path21.join(fooDir, ".index.yaml"), (s) => {
23030
+ patchSubsystemIndex(path20.join(fooDir, ".index.yaml"), (s) => {
23117
23031
  s.parentSystem = parentSystemName;
23118
23032
  delete s.projectPath;
23119
23033
  });
@@ -23195,8 +23109,8 @@ function rebaseImplementationPaths(specsDir, fromRoot, toRoot) {
23195
23109
  let changed = false;
23196
23110
  const rebase = (holder, key) => {
23197
23111
  const p = holder[key];
23198
- if (typeof p !== "string" || p === "" || path21.isAbsolute(p)) return;
23199
- const next = toPosixPath(path21.relative(toRoot, path21.resolve(fromRoot, p)));
23112
+ if (typeof p !== "string" || p === "" || path20.isAbsolute(p)) return;
23113
+ const next = toPosixPath(path20.relative(toRoot, path20.resolve(fromRoot, p)));
23200
23114
  if (next !== p) {
23201
23115
  holder[key] = next;
23202
23116
  changed = true;
@@ -23273,7 +23187,7 @@ function moveRenamedSpecs(componentId, newId, component, movingInterface, moving
23273
23187
  if (movedInterface) saveInterfaceSpec({ ...movedInterface, id: interfaceId, component: newId });
23274
23188
  if (movedImplementation) {
23275
23189
  const oldFile = getImplementationPath(movedImplementation.id);
23276
- if (path21.resolve(getImplementationPath(implementationId, movedImplementation.contract)) === path21.resolve(oldFile)) {
23190
+ if (path20.resolve(getImplementationPath(implementationId, movedImplementation.contract)) === path20.resolve(oldFile)) {
23277
23191
  fs15.unlinkSync(oldFile);
23278
23192
  }
23279
23193
  saveImplementationSpec({ ...movedImplementation, id: implementationId });
@@ -23291,8 +23205,8 @@ function removeSpecFile2(file, id) {
23291
23205
  return;
23292
23206
  }
23293
23207
  fs15.unlinkSync(file);
23294
- const specsRoot = path21.resolve(aiPathsAt(getProjectRoot()).specsDir());
23295
- for (let dir = path21.dirname(path21.resolve(file)); dir !== specsRoot && isWithinDir(specsRoot, dir); dir = path21.dirname(dir)) {
23208
+ const specsRoot = path20.resolve(aiPathsAt(getProjectRoot()).specsDir());
23209
+ for (let dir = path20.dirname(path20.resolve(file)); dir !== specsRoot && isWithinDir(specsRoot, dir); dir = path20.dirname(dir)) {
23296
23210
  if (fs15.readdirSync(dir).length > 0) break;
23297
23211
  fs15.rmdirSync(dir);
23298
23212
  }
@@ -23391,12 +23305,12 @@ function collectMentions(specsDir, methodName, moved) {
23391
23305
  function identifierPattern(methodName) {
23392
23306
  return new RegExp(`(?<![A-Za-z0-9_])${methodName}(?![A-Za-z0-9_])`);
23393
23307
  }
23394
- var fs15, path21, METHOD_NAME, PROSE_FIELDS2;
23308
+ var fs15, path20, METHOD_NAME, PROSE_FIELDS2;
23395
23309
  var init_provision = __esm({
23396
23310
  "src/core/provision.ts"() {
23397
23311
  "use strict";
23398
23312
  fs15 = __toESM(require("fs"));
23399
- path21 = __toESM(require("path"));
23313
+ path20 = __toESM(require("path"));
23400
23314
  init_specs2();
23401
23315
  init_loader();
23402
23316
  init_project_config();
@@ -23583,16 +23497,16 @@ function readFrontmatter(raw, fallbackName) {
23583
23497
  return { name: field("name") || fallbackName, description: field("description") };
23584
23498
  }
23585
23499
  function builtinSkillsDir() {
23586
- return path22.resolve(__dirname, "..", "templates", "skills");
23500
+ return path21.resolve(__dirname, "..", "templates", "skills");
23587
23501
  }
23588
23502
  function skillTemplatePath(name) {
23589
- return path22.join(builtinSkillsDir(), `${name}.md`);
23503
+ return path21.join(builtinSkillsDir(), `${name}.md`);
23590
23504
  }
23591
23505
  function skillDestPath(type, destDir, name) {
23592
23506
  if (type === "claude" || type === "codex" || type === "gemini" || type === "agy") {
23593
- return path22.join(destDir, name, "SKILL.md");
23507
+ return path21.join(destDir, name, "SKILL.md");
23594
23508
  }
23595
- return path22.join(destDir, `${name}.md`);
23509
+ return path21.join(destDir, `${name}.md`);
23596
23510
  }
23597
23511
  function skillsDirForTarget(type) {
23598
23512
  switch (type) {
@@ -23630,7 +23544,7 @@ function exportSddSkills(targetTypes) {
23630
23544
  if (!fs16.existsSync(skillTemplatePath(name))) continue;
23631
23545
  const content = composeBuiltinSkill(name, packSkills.filter((s) => s.targets.includes(type)));
23632
23546
  const destPath = skillDestPath(type, destDir, name);
23633
- ensureDir(path22.dirname(destPath));
23547
+ ensureDir(path21.dirname(destPath));
23634
23548
  fs16.writeFileSync(destPath, content, "utf-8");
23635
23549
  fileCount++;
23636
23550
  }
@@ -23641,7 +23555,7 @@ function exportSddSkills(targetTypes) {
23641
23555
  const id = packSkillId(skill);
23642
23556
  const content = fs16.readFileSync(skill.sourcePath, "utf-8");
23643
23557
  const destPath = skillDestPath(type, destDir, id);
23644
- ensureDir(path22.dirname(destPath));
23558
+ ensureDir(path21.dirname(destPath));
23645
23559
  fs16.writeFileSync(destPath, content, "utf-8");
23646
23560
  fileCount++;
23647
23561
  }
@@ -23718,11 +23632,11 @@ function readResource(resourceId) {
23718
23632
  if (!known) throw new SkillResourceNotFoundError(resourceId);
23719
23633
  return readSkillResource(resourceId);
23720
23634
  }
23721
- var path22, fs16, SKILL_NAMES, SKILL_RESOURCE_SCHEME, RESOURCE_SKILL_IDS, SkillResourceNotFoundError;
23635
+ var path21, fs16, SKILL_NAMES, SKILL_RESOURCE_SCHEME, RESOURCE_SKILL_IDS, SkillResourceNotFoundError;
23722
23636
  var init_skills = __esm({
23723
23637
  "src/core/skills.ts"() {
23724
23638
  "use strict";
23725
- path22 = __toESM(require("path"));
23639
+ path21 = __toESM(require("path"));
23726
23640
  fs16 = __toESM(require("fs"));
23727
23641
  init_fs();
23728
23642
  init_defaults();
@@ -27296,39 +27210,39 @@ function hasAuthoredSpecs(root) {
27296
27210
  if (!pathExists(specsDir)) {
27297
27211
  return false;
27298
27212
  }
27299
- const systemIndex = path23.resolve(paths.specsSystem());
27213
+ const systemIndex = path22.resolve(paths.specsSystem());
27300
27214
  for (const file of listFilesRecursive(specsDir, ".yaml")) {
27301
- if (path23.resolve(file) !== systemIndex) {
27215
+ if (path22.resolve(file) !== systemIndex) {
27302
27216
  return true;
27303
27217
  }
27304
27218
  }
27305
27219
  return false;
27306
27220
  }
27307
27221
  function createStagingDir(destDir) {
27308
- const root = path23.resolve(destDir);
27222
+ const root = path22.resolve(destDir);
27309
27223
  fs17.mkdirSync(root, { recursive: true });
27310
- const stagingDir = fs17.mkdtempSync(path23.join(root, STAGING_PREFIX));
27224
+ const stagingDir = fs17.mkdtempSync(path22.join(root, STAGING_PREFIX));
27311
27225
  return stagingDir;
27312
27226
  }
27313
27227
  function commitStagedTree(stagingDir, destDir, roots, backupExisting) {
27314
- const root = path23.resolve(destDir);
27315
- const backupDir = path23.join(root, BACKUP_DIR, timestampSlug());
27228
+ const root = path22.resolve(destDir);
27229
+ const backupDir = path22.join(root, BACKUP_DIR, timestampSlug());
27316
27230
  let backedUp = false;
27317
27231
  for (const rootRel of roots) {
27318
27232
  const relative9 = rootRel === "." ? "" : rootRel;
27319
- const stagedSpecDir = path23.join(stagingDir, relative9, ".wai");
27233
+ const stagedSpecDir = path22.join(stagingDir, relative9, ".wai");
27320
27234
  if (!fs17.existsSync(stagedSpecDir)) continue;
27321
- const liveSpecDir = liveSpecDirFor(path23.join(root, relative9));
27235
+ const liveSpecDir = liveSpecDirFor(path22.join(root, relative9));
27322
27236
  if (backupExisting && liveSpecDir && fs17.existsSync(liveSpecDir)) {
27323
- const backupTarget = path23.join(backupDir, relative9, path23.basename(liveSpecDir));
27324
- fs17.mkdirSync(path23.dirname(backupTarget), { recursive: true });
27237
+ const backupTarget = path22.join(backupDir, relative9, path22.basename(liveSpecDir));
27238
+ fs17.mkdirSync(path22.dirname(backupTarget), { recursive: true });
27325
27239
  fs17.renameSync(liveSpecDir, backupTarget);
27326
27240
  backedUp = true;
27327
27241
  } else if (liveSpecDir && fs17.existsSync(liveSpecDir)) {
27328
27242
  fs17.rmSync(liveSpecDir, { recursive: true, force: true });
27329
27243
  }
27330
- const target = path23.join(root, relative9, ".wai");
27331
- fs17.mkdirSync(path23.dirname(target), { recursive: true });
27244
+ const target = path22.join(root, relative9, ".wai");
27245
+ fs17.mkdirSync(path22.dirname(target), { recursive: true });
27332
27246
  if (fs17.existsSync(target)) fs17.rmSync(target, { recursive: true, force: true });
27333
27247
  fs17.renameSync(stagedSpecDir, target);
27334
27248
  }
@@ -27353,7 +27267,7 @@ function exportSpecTree(includeDerived, allowPartial) {
27353
27267
  const skipped = [...inspection.skipped];
27354
27268
  const roots = [{ relativePath: ".", waiDir: aiPathsAt(root).root() }];
27355
27269
  for (const rel2 of inspection.roots) {
27356
- const waiDir = aiPathsAt(path23.resolve(root, rel2)).root();
27270
+ const waiDir = aiPathsAt(path22.resolve(root, rel2)).root();
27357
27271
  if (pathExists(waiDir)) {
27358
27272
  roots.push({ relativePath: rel2, waiDir });
27359
27273
  } else {
@@ -27384,7 +27298,7 @@ function importSpecTree(archive, options) {
27384
27298
  if (!info.compatible) {
27385
27299
  throw new Error("incompatible .waitree archive (format or minimum wairon version)");
27386
27300
  }
27387
- const destDir = path23.resolve(options.destDir ?? getProjectRoot());
27301
+ const destDir = path22.resolve(options.destDir ?? getProjectRoot());
27388
27302
  const occupied = hasSpecTree(destDir);
27389
27303
  const authored = hasAuthoredSpecs(destDir);
27390
27304
  if (authored && options.replaceExisting !== true) {
@@ -27415,21 +27329,21 @@ function importSpecTree(archive, options) {
27415
27329
  return result;
27416
27330
  }
27417
27331
  function liveSpecDirFor(rootDir) {
27418
- const modern = path23.join(rootDir, ".wai");
27332
+ const modern = path22.join(rootDir, ".wai");
27419
27333
  if (fs17.existsSync(modern)) return modern;
27420
- const legacy = path23.join(rootDir, ".wairon");
27334
+ const legacy = path22.join(rootDir, ".wairon");
27421
27335
  if (fs17.existsSync(legacy)) return legacy;
27422
27336
  return null;
27423
27337
  }
27424
27338
  function timestampSlug() {
27425
27339
  return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
27426
27340
  }
27427
- var fs17, path23, sdkPortal, STAGING_PREFIX, BACKUP_DIR;
27341
+ var fs17, path22, sdkPortal, STAGING_PREFIX, BACKUP_DIR;
27428
27342
  var init_treetransfer = __esm({
27429
27343
  "src/core/treetransfer.ts"() {
27430
27344
  "use strict";
27431
27345
  fs17 = __toESM(require("fs"));
27432
- path23 = __toESM(require("path"));
27346
+ path22 = __toESM(require("path"));
27433
27347
  sdkPortal = __toESM(require_dist());
27434
27348
  init_loader();
27435
27349
  init_fs();
@@ -27587,6 +27501,106 @@ var init_narrative_repair = __esm({
27587
27501
  }
27588
27502
  });
27589
27503
 
27504
+ // src/core/approval.ts
27505
+ function diffSize(d) {
27506
+ return d.added.length + d.changed.length + d.removed.length;
27507
+ }
27508
+ function digest(content) {
27509
+ const normalized = content.replace(/\r\n/g, "\n");
27510
+ return crypto4.createHash("sha256").update(normalized, "utf8").digest("hex");
27511
+ }
27512
+ function currentSpecDigests(root = getProjectRoot()) {
27513
+ const mountDirs = loadSubsystemSpecs().filter((s) => s.projectPath && !s.id.includes("::")).map((s) => `${path23.resolve(root, s.projectPath).split(path23.sep).join("/")}/`);
27514
+ const out = {};
27515
+ for (const [abs, content] of snapshotSpecFiles()) {
27516
+ const normalized = path23.resolve(abs).split(path23.sep).join("/");
27517
+ if (mountDirs.some((dir) => normalized.startsWith(dir))) continue;
27518
+ out[path23.relative(root, abs).split(path23.sep).join("/")] = digest(content);
27519
+ }
27520
+ return out;
27521
+ }
27522
+ function captureApprovedSpecs(root = getProjectRoot(), scope) {
27523
+ const current2 = currentSpecDigests(root);
27524
+ if (!scope) return current2;
27525
+ const previous = readLockRecord()?.specs ?? {};
27526
+ const specs = { ...previous };
27527
+ for (const rel2 of Object.keys(previous)) {
27528
+ if (scope.paths.has(rel2) && current2[rel2] === void 0) delete specs[rel2];
27529
+ }
27530
+ for (const rel2 of scope.paths) {
27531
+ if (current2[rel2] !== void 0) specs[rel2] = current2[rel2];
27532
+ }
27533
+ return specs;
27534
+ }
27535
+ function diffAgainstApproval(root = getProjectRoot()) {
27536
+ const approved = approvedSpecs(root);
27537
+ if (!approved) return null;
27538
+ const current2 = currentSpecDigests(root);
27539
+ const added = [];
27540
+ const changed = [];
27541
+ const removed = [];
27542
+ const unchangedPaths = [];
27543
+ for (const [rel2, d] of Object.entries(current2)) {
27544
+ const before = approved[rel2];
27545
+ if (before === void 0) added.push(rel2);
27546
+ else if (before !== d) changed.push(rel2);
27547
+ else unchangedPaths.push(rel2);
27548
+ }
27549
+ for (const rel2 of Object.keys(approved)) {
27550
+ if (current2[rel2] === void 0) removed.push(rel2);
27551
+ }
27552
+ return {
27553
+ added: added.sort(),
27554
+ changed: changed.sort(),
27555
+ removed: removed.sort(),
27556
+ unchangedPaths: unchangedPaths.sort()
27557
+ };
27558
+ }
27559
+ function approvedSpecs(root) {
27560
+ return approvalRecord(root)?.specs ?? null;
27561
+ }
27562
+ function approvalRecord(root = getProjectRoot()) {
27563
+ return readLockRecordAt(root);
27564
+ }
27565
+ function settledSpecPaths(root = getProjectRoot()) {
27566
+ const diff = diffAgainstApproval(root);
27567
+ return diff ? new Set(diff.unchangedPaths) : null;
27568
+ }
27569
+ function pinOf(stateId) {
27570
+ return `${stateId.algorithm}:${stateId.digest}`;
27571
+ }
27572
+ function currentChildPins(mounts, root = getProjectRoot()) {
27573
+ const pins = {};
27574
+ for (const mount of mounts) {
27575
+ if (!mount.projectPath || mount.id.includes("::")) continue;
27576
+ const child = readLockRecordAt(path23.resolve(root, mount.projectPath));
27577
+ if (child) pins[mount.id] = pinOf(child.stateId);
27578
+ }
27579
+ return pins;
27580
+ }
27581
+ function movedChildren(mounts, root = getProjectRoot()) {
27582
+ const pinned = approvalRecord(root)?.children;
27583
+ if (!pinned) return [];
27584
+ const now = currentChildPins(mounts, root);
27585
+ const moved = [];
27586
+ for (const [id, was] of Object.entries(pinned)) {
27587
+ const current2 = now[id] ?? null;
27588
+ if (current2 !== was) moved.push({ id, pinned: was, now: current2 });
27589
+ }
27590
+ return moved;
27591
+ }
27592
+ var crypto4, path23;
27593
+ var init_approval = __esm({
27594
+ "src/core/approval.ts"() {
27595
+ "use strict";
27596
+ crypto4 = __toESM(require("crypto"));
27597
+ path23 = __toESM(require("path"));
27598
+ init_fs();
27599
+ init_specs2();
27600
+ init_lockfile();
27601
+ }
27602
+ });
27603
+
27590
27604
  // src/core/approver.ts
27591
27605
  function gitConfig(key) {
27592
27606
  try {
@@ -27877,6 +27891,7 @@ __export(src_exports, {
27877
27891
  diagnoseProjectPacks: () => diagnoseProjectPacks,
27878
27892
  diagramSetIndex: () => diagramSetIndex,
27879
27893
  diffAgainstApproval: () => diffAgainstApproval,
27894
+ diffSize: () => diffSize,
27880
27895
  discardStagingDir: () => discardStagingDir,
27881
27896
  discoverPacks: () => discoverPacks,
27882
27897
  dryRunSerializeSpecs: () => dryRunSerializeSpecs,
@@ -28001,6 +28016,7 @@ __export(src_exports, {
28001
28016
  methodTypeRefs: () => methodTypeRefs,
28002
28017
  moveMethods: () => moveMethods,
28003
28018
  moveSubsystemProject: () => moveSubsystemProject,
28019
+ movedChildren: () => movedChildren,
28004
28020
  narrativeStepForeignFields: () => narrativeStepForeignFields,
28005
28021
  normalizeApprover: () => normalizeApprover,
28006
28022
  normalizeComponentLayout: () => normalizeComponentLayout,
@@ -28078,6 +28094,7 @@ __export(src_exports, {
28078
28094
  setLogLevel: () => setLogLevel,
28079
28095
  setProjectRoot: () => setProjectRoot,
28080
28096
  setProjectType: () => setProjectType,
28097
+ settledSpecPaths: () => settledSpecPaths,
28081
28098
  skillExtendErrors: () => skillExtendErrors,
28082
28099
  skillsDirForTarget: () => skillsDirForTarget,
28083
28100
  snapshotSpecFiles: () => snapshotSpecFiles,
@@ -28622,6 +28639,7 @@ function loadProjectConfig4() {
28622
28639
  diagnoseProjectPacks,
28623
28640
  diagramSetIndex,
28624
28641
  diffAgainstApproval,
28642
+ diffSize,
28625
28643
  discardStagingDir,
28626
28644
  discoverPacks,
28627
28645
  dryRunSerializeSpecs,
@@ -28746,6 +28764,7 @@ function loadProjectConfig4() {
28746
28764
  methodTypeRefs,
28747
28765
  moveMethods,
28748
28766
  moveSubsystemProject,
28767
+ movedChildren,
28749
28768
  narrativeStepForeignFields,
28750
28769
  normalizeApprover,
28751
28770
  normalizeComponentLayout,
@@ -28823,6 +28842,7 @@ function loadProjectConfig4() {
28823
28842
  setLogLevel,
28824
28843
  setProjectRoot,
28825
28844
  setProjectType,
28845
+ settledSpecPaths,
28826
28846
  skillExtendErrors,
28827
28847
  skillsDirForTarget,
28828
28848
  snapshotSpecFiles,