@lousy-agents/mcp 5.23.9 → 5.23.11

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.
Files changed (2) hide show
  1. package/dist/mcp-server.js +943 -362
  2. package/package.json +1 -1
@@ -6559,7 +6559,7 @@ function escapeJsonPtr(str) {
6559
6559
 
6560
6560
 
6561
6561
  },
6562
- 7693(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6562
+ 7698(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6563
6563
  // NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
6564
6564
  var constructs_namespaceObject = {};
6565
6565
  __webpack_require__.r(constructs_namespaceObject);
@@ -28656,7 +28656,7 @@ const external_node_async_hooks_namespaceObject = __rspack_createRequire_require
28656
28656
 
28657
28657
  const file_observation_active = new external_node_async_hooks_namespaceObject.AsyncLocalStorage();
28658
28658
  function recordFileObservationFailure(error, kind) {
28659
- const failures = file_observation_active.getStore();
28659
+ const failures = file_observation_active.getStore()?.failures;
28660
28660
  if (!failures)
28661
28661
  return;
28662
28662
  let kinds = failures.get(error);
@@ -28665,13 +28665,17 @@ function recordFileObservationFailure(error, kind) {
28665
28665
  kinds.add(kind);
28666
28666
  }
28667
28667
  function isFileObservationFailure(error, kind) {
28668
- return file_observation_active.getStore()?.get(error)?.has(kind) === true;
28668
+ return file_observation_active.getStore()?.failures.get(error)?.has(kind) === true;
28669
+ }
28670
+ async function observedFilePublicationPending(filePath, identity) {
28671
+ return await file_observation_active.getStore()?.publicationPending?.(filePath, identity) ?? false;
28669
28672
  }
28670
28673
  // Each Root observation owns its receipts, including nested and concurrent reads.
28671
- function fileObservation() {
28674
+ function fileObservation(options = {}) {
28672
28675
  const failures = new Map();
28676
+ const context = { failures, ...options };
28673
28677
  return {
28674
- run(operation) { return file_observation_active.run(failures, operation); },
28678
+ run(operation) { return file_observation_active.run(context, operation); },
28675
28679
  has(error, kind) { return failures.get(error)?.has(kind) === true; },
28676
28680
  };
28677
28681
  }
@@ -30950,17 +30954,19 @@ function cleanupSidecarStages(target, assertCurrent, native, onlyStage) {
30950
30954
  }
30951
30955
  // Readers reject the linked record and retry. Authorized cleanup may handle
30952
30956
  // the one matching stage; recognition streams past the opportunistic budget.
30953
- function sidecar_lock_staging_sidecarPublicationPending(target, onStage) {
30957
+ function sidecar_lock_staging_sidecarPublicationPending(target, onStage, options = {}) {
30954
30958
  let entries;
30955
30959
  let callbackFailure;
30956
30960
  try {
30957
30961
  const current = external_node_fs_.lstatSync(target, { bigint: true, throwIfNoEntry: false });
30958
30962
  if (!current)
30959
- return true;
30963
+ return !options.requireStage;
30964
+ if (options.identity && !sameFileIdentityForCleanup(current, options.identity))
30965
+ return false;
30960
30966
  if (!current.isFile() || current.isSymbolicLink())
30961
30967
  return false;
30962
30968
  if (current.nlink === 1n)
30963
- return true;
30969
+ return !options.requireStage;
30964
30970
  if (current.nlink !== 2n)
30965
30971
  return false;
30966
30972
  const prefix = stagingPrefix(target);
@@ -30984,7 +30990,7 @@ function sidecar_lock_staging_sidecarPublicationPending(target, onStage) {
30984
30990
  }
30985
30991
  }
30986
30992
  const after = external_node_fs_.lstatSync(target, { bigint: true, throwIfNoEntry: false });
30987
- return !after || !sameFileIdentityForCleanup(after, current) || after.nlink === 1n;
30993
+ return !options.requireStage && (!after || !sameFileIdentityForCleanup(after, current) || after.nlink === 1n);
30988
30994
  }
30989
30995
  catch {
30990
30996
  if (callbackFailure)
@@ -31513,6 +31519,236 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
31513
31519
  }
31514
31520
  }
31515
31521
 
31522
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/test-hooks.js
31523
+
31524
+ let test_hooks_fsSafeTestHooks;
31525
+ function allowFsSafeTestHooks() {
31526
+ return false || process.env.VITEST === "true";
31527
+ }
31528
+ function getFsSafeTestHooks() {
31529
+ return test_hooks_fsSafeTestHooks;
31530
+ }
31531
+ function __setFsSafeTestHooksForTest(hooks) {
31532
+ if (hooks && !allowFsSafeTestHooks()) {
31533
+ throw new Error("__setFsSafeTestHooksForTest is only available in tests");
31534
+ }
31535
+ test_hooks_fsSafeTestHooks = hooks;
31536
+ }
31537
+
31538
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/timing.js
31539
+ const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
31540
+ function scheduleTimeout(callback, ms) {
31541
+ let timer;
31542
+ if (Number.isFinite(ms) && ms > MAX_TIMER_DELAY_MS) {
31543
+ const startedAt = performance.now();
31544
+ const tick = () => {
31545
+ const remaining = ms - (performance.now() - startedAt);
31546
+ if (remaining <= 0)
31547
+ callback();
31548
+ else
31549
+ timer = setTimeout(tick, Math.min(remaining, MAX_TIMER_DELAY_MS));
31550
+ };
31551
+ // Node clamps overflowing delays to 1 ms. Rearm bounded timers against a
31552
+ // monotonic clock so clock changes and event-loop stalls cannot shorten them.
31553
+ timer = setTimeout(tick, MAX_TIMER_DELAY_MS);
31554
+ }
31555
+ else {
31556
+ timer = setTimeout(callback, ms);
31557
+ }
31558
+ return () => clearTimeout(timer);
31559
+ }
31560
+ function sleep(ms) {
31561
+ return new Promise((resolve) => { scheduleTimeout(resolve, ms); });
31562
+ }
31563
+ function sleepSync(ms) {
31564
+ if (ms <= 0) {
31565
+ return;
31566
+ }
31567
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
31568
+ }
31569
+ async function withTimeout(promise, timeoutMs, labelOrOptions = {
31570
+ message: "timeout",
31571
+ }) {
31572
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
31573
+ return await promise;
31574
+ }
31575
+ const options = typeof labelOrOptions === "string" ? { label: labelOrOptions } : labelOrOptions;
31576
+ const createError = options.createError ??
31577
+ (() => new Error(options.message ?? `${options.label ?? "operation"} timed out after ${timeoutMs}ms`));
31578
+ let cancelTimeout;
31579
+ try {
31580
+ return await Promise.race([
31581
+ promise,
31582
+ new Promise((_, reject) => {
31583
+ cancelTimeout = scheduleTimeout(() => {
31584
+ try {
31585
+ reject(createError());
31586
+ }
31587
+ catch (error) {
31588
+ reject(error);
31589
+ }
31590
+ }, timeoutMs);
31591
+ }),
31592
+ ]);
31593
+ }
31594
+ finally {
31595
+ cancelTimeout?.();
31596
+ }
31597
+ }
31598
+
31599
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-recovery.js
31600
+
31601
+
31602
+
31603
+
31604
+
31605
+
31606
+
31607
+
31608
+ const non9pDevices = new Set();
31609
+ /** Other platforms keep their existing path even when the option is enabled. */
31610
+ function shouldPrepareDrvfsRecovery(enabled, dev) {
31611
+ if (enabled !== true)
31612
+ return false;
31613
+ // Synthetic mount evidence must not inherit observations from the real host.
31614
+ if (getFsSafeTestHooks()?.drvfsMountObservation)
31615
+ return true;
31616
+ if (process.platform !== "linux")
31617
+ return false;
31618
+ if (dev === undefined)
31619
+ return true;
31620
+ // Linux 9p allocates anonymous devices (major zero), never block devices.
31621
+ if (((dev >> 8n) & 0xfffn) !== 0n || ((dev >> 32n) & 0xfffff000n) !== 0n)
31622
+ return false;
31623
+ return !non9pDevices.has(dev);
31624
+ }
31625
+ /** Negative evidence only: a stale/reused device number can only disable recovery. */
31626
+ function mayPrepareDrvfsRecoveryAtFd(parentFd, dev) {
31627
+ if (!shouldPrepareDrvfsRecovery(true, dev))
31628
+ return false;
31629
+ if (getFsSafeTestHooks()?.drvfsMountObservation)
31630
+ return true;
31631
+ try {
31632
+ if (native_getNativeBinding()?.is9pFilesystem?.(parentFd) === false) {
31633
+ non9pDevices.add(dev);
31634
+ return false;
31635
+ }
31636
+ }
31637
+ catch { /* Unavailable evidence preserves full recovery-time verification. */ }
31638
+ return true;
31639
+ }
31640
+ /** No sampling or positive cache: the retained directory's exact mount owns admission. */
31641
+ function admitsDrvfsRenameRecoveryAtFd(parentFd) {
31642
+ try {
31643
+ const hook = getFsSafeTestHooks()?.drvfsMountObservation;
31644
+ if (!hook && process.platform !== "linux")
31645
+ return false;
31646
+ if (!Number.isInteger(parentFd) || parentFd < 0)
31647
+ return false;
31648
+ const observation = hook ? hook(parentFd) : (() => {
31649
+ if (external_node_fs_.statfsSync("/proc/self/fd", { bigint: true }).type !== 0x9fa0n)
31650
+ return undefined;
31651
+ // statfs follows this kernel-owned descriptor alias to the retained parent.
31652
+ return {
31653
+ magic: external_node_fs_.statfsSync(`/proc/self/fd/${parentFd}`, { bigint: true }).type,
31654
+ fdinfo: external_node_fs_.readFileSync(`/proc/self/fdinfo/${parentFd}`, "utf8"),
31655
+ mountinfo: external_node_fs_.readFileSync("/proc/self/mountinfo", "utf8"),
31656
+ };
31657
+ })();
31658
+ if (!observation || observation.magic !== 0x01021997n)
31659
+ return false;
31660
+ const ids = [...observation.fdinfo.matchAll(/^mnt_id:\s*(\d+)\s*$/gm)];
31661
+ if (ids.length !== 1)
31662
+ return false;
31663
+ const entries = observation.mountinfo.split("\n").filter(line => line.split(" ")[0] === ids[0][1]);
31664
+ if (entries.length !== 1)
31665
+ return false;
31666
+ const [before, after, extra] = entries[0].split(" - ");
31667
+ if (!before || !after || extra !== undefined || before.split(" ").length < 6)
31668
+ return false;
31669
+ const fields = after.split(" ");
31670
+ return fields.length === 3 && fields[0] === "9p" &&
31671
+ fields[2].split(",").some(option => option === "aname=drvfs" || option.startsWith("aname=drvfs;"));
31672
+ }
31673
+ catch {
31674
+ return false;
31675
+ }
31676
+ }
31677
+ /** Exact metadata is necessary but cannot exclude inode reuse after the final close. */
31678
+ function assertRecoveredPublication(actual, expected) {
31679
+ if (!actual.isFile() || actual.isSymbolicLink() || actual.nlink !== 1n ||
31680
+ actual.dev !== expected.dev || actual.ino !== expected.ino || actual.size !== expected.size ||
31681
+ actual.mode !== expected.mode || actual.uid !== expected.uid || actual.gid !== expected.gid) {
31682
+ throw new errors_FsSafeError("path-mismatch", "published file changed during DrvFS recovery");
31683
+ }
31684
+ }
31685
+ async function recoverAfterHiddenRename(params) {
31686
+ if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
31687
+ throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
31688
+ }
31689
+ await params.closeWriter();
31690
+ for (let attempt = 0;; attempt++) {
31691
+ let recovered;
31692
+ try {
31693
+ recovered = await params.reopen();
31694
+ }
31695
+ catch (error) {
31696
+ if (!hasErrorCode(error, "ENOENT") || attempt === 4)
31697
+ throw error;
31698
+ await sleep(20);
31699
+ continue;
31700
+ }
31701
+ try {
31702
+ await params.retain?.(recovered);
31703
+ }
31704
+ catch (error) {
31705
+ await params.dispose?.(recovered).catch(() => undefined);
31706
+ throw error;
31707
+ }
31708
+ return recovered;
31709
+ }
31710
+ }
31711
+ function recoverAfterHiddenRenameSync(params) {
31712
+ if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
31713
+ throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
31714
+ }
31715
+ params.closeWriter();
31716
+ for (let attempt = 0;; attempt++) {
31717
+ try {
31718
+ return params.reopen();
31719
+ }
31720
+ catch (error) {
31721
+ if (!hasErrorCode(error, "ENOENT") || attempt === 4)
31722
+ throw error;
31723
+ sleepSync(20);
31724
+ }
31725
+ }
31726
+ }
31727
+ function assertRecoveredFile(fd, expected, content) {
31728
+ assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
31729
+ if (content && !bounded_read_readFileDescriptorBoundedSync(fd, content.byteLength).equals(content)) {
31730
+ throw new errors_FsSafeError("path-mismatch", "published content changed during DrvFS recovery");
31731
+ }
31732
+ assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
31733
+ }
31734
+ function reopenRecoveredNativeFile(binding, parentFd, basename, expected, content) {
31735
+ if (!binding.openBeneath || !binding.closeOwnedFd || !binding.stagedFileMatches) {
31736
+ throw new errors_FsSafeError("helper-unavailable", "native DrvFS recovery requires descriptor-relative verification");
31737
+ }
31738
+ const fd = binding.openBeneath(parentFd, basename, nativeOpenFlags(external_node_fs_.constants.O_RDONLY | external_node_fs_.constants.O_NONBLOCK)).fd;
31739
+ try {
31740
+ assertRecoveredFile(fd, expected, content);
31741
+ if (!binding.stagedFileMatches(parentFd, basename, fd)) {
31742
+ throw new errors_FsSafeError("path-mismatch", "published name changed during DrvFS recovery");
31743
+ }
31744
+ return fd;
31745
+ }
31746
+ catch (error) {
31747
+ binding.closeOwnedFd(fd);
31748
+ throw error;
31749
+ }
31750
+ }
31751
+
31516
31752
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-boundary.js
31517
31753
 
31518
31754
 
@@ -31891,67 +32127,6 @@ function recursiveMkdirPath(directory) {
31891
32127
  return needsAbsolutePath ? absolutePathWithRawSegments(directory) : directory;
31892
32128
  }
31893
32129
 
31894
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/timing.js
31895
- const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
31896
- function scheduleTimeout(callback, ms) {
31897
- let timer;
31898
- if (Number.isFinite(ms) && ms > MAX_TIMER_DELAY_MS) {
31899
- const startedAt = performance.now();
31900
- const tick = () => {
31901
- const remaining = ms - (performance.now() - startedAt);
31902
- if (remaining <= 0)
31903
- callback();
31904
- else
31905
- timer = setTimeout(tick, Math.min(remaining, MAX_TIMER_DELAY_MS));
31906
- };
31907
- // Node clamps overflowing delays to 1 ms. Rearm bounded timers against a
31908
- // monotonic clock so clock changes and event-loop stalls cannot shorten them.
31909
- timer = setTimeout(tick, MAX_TIMER_DELAY_MS);
31910
- }
31911
- else {
31912
- timer = setTimeout(callback, ms);
31913
- }
31914
- return () => clearTimeout(timer);
31915
- }
31916
- function sleep(ms) {
31917
- return new Promise((resolve) => { scheduleTimeout(resolve, ms); });
31918
- }
31919
- function sleepSync(ms) {
31920
- if (ms <= 0) {
31921
- return;
31922
- }
31923
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
31924
- }
31925
- async function withTimeout(promise, timeoutMs, labelOrOptions = {
31926
- message: "timeout",
31927
- }) {
31928
- if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
31929
- return await promise;
31930
- }
31931
- const options = typeof labelOrOptions === "string" ? { label: labelOrOptions } : labelOrOptions;
31932
- const createError = options.createError ??
31933
- (() => new Error(options.message ?? `${options.label ?? "operation"} timed out after ${timeoutMs}ms`));
31934
- let cancelTimeout;
31935
- try {
31936
- return await Promise.race([
31937
- promise,
31938
- new Promise((_, reject) => {
31939
- cancelTimeout = scheduleTimeout(() => {
31940
- try {
31941
- reject(createError());
31942
- }
31943
- catch (error) {
31944
- reject(error);
31945
- }
31946
- }, timeoutMs);
31947
- }),
31948
- ]);
31949
- }
31950
- finally {
31951
- cancelTimeout?.();
31952
- }
31953
- }
31954
-
31955
32130
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/exclusive-create.js
31956
32131
 
31957
32132
 
@@ -32243,6 +32418,7 @@ class AtomicFile {
32243
32418
 
32244
32419
 
32245
32420
 
32421
+
32246
32422
  function replace_file_descriptor_parentCloseFailure(primary, closeError) {
32247
32423
  return primary ? new AggregateError([primary.error, closeError], "Atomic parent preparation and close failed") : closeError;
32248
32424
  }
@@ -32305,6 +32481,8 @@ async function pinDirectoryForMode(params) {
32305
32481
  ignoreChmodError: params.ignoreChmodError,
32306
32482
  });
32307
32483
  await owner.verify();
32484
+ if (params.allowDrvfsRenameRecovery)
32485
+ mayPrepareDrvfsRecoveryAtFd(handle.fd, expected.dev);
32308
32486
  return owner;
32309
32487
  }
32310
32488
  catch (error) {
@@ -32351,6 +32529,8 @@ function* applyDirectoryMode(io, params) {
32351
32529
  let primary;
32352
32530
  try {
32353
32531
  inspectAtomicIdentity(io, () => file.statExact(), expected, false, admit);
32532
+ if (params.allowDrvfsRenameRecovery)
32533
+ mayPrepareDrvfsRecoveryAtFd(file.fd, expected.dev);
32354
32534
  if (params.mode !== "preserve") {
32355
32535
  params.mutation?.assert();
32356
32536
  file.chmod(params.mode & 0o7777);
@@ -32576,146 +32756,6 @@ function __cleanupRegisteredTempPathForTest(tempPath) {
32576
32756
  }
32577
32757
  }
32578
32758
 
32579
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/test-hooks.js
32580
-
32581
- let test_hooks_fsSafeTestHooks;
32582
- function allowFsSafeTestHooks() {
32583
- return false || process.env.VITEST === "true";
32584
- }
32585
- function getFsSafeTestHooks() {
32586
- return test_hooks_fsSafeTestHooks;
32587
- }
32588
- function __setFsSafeTestHooksForTest(hooks) {
32589
- if (hooks && !allowFsSafeTestHooks()) {
32590
- throw new Error("__setFsSafeTestHooksForTest is only available in tests");
32591
- }
32592
- test_hooks_fsSafeTestHooks = hooks;
32593
- }
32594
-
32595
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-recovery.js
32596
-
32597
-
32598
-
32599
-
32600
-
32601
-
32602
-
32603
- /** Other platforms keep their existing path even when the option is enabled. */
32604
- function shouldPrepareDrvfsRecovery(enabled) {
32605
- return enabled === true && (process.platform === "linux" || getFsSafeTestHooks()?.drvfsMountObservation !== undefined);
32606
- }
32607
- /** No sampling or positive cache: the retained directory's exact mount owns admission. */
32608
- function admitsDrvfsRenameRecoveryAtFd(parentFd) {
32609
- try {
32610
- const hook = getFsSafeTestHooks()?.drvfsMountObservation;
32611
- if (!hook && process.platform !== "linux")
32612
- return false;
32613
- if (!Number.isInteger(parentFd) || parentFd < 0)
32614
- return false;
32615
- const observation = hook ? hook(parentFd) : (() => {
32616
- if (external_node_fs_.statfsSync("/proc/self/fd", { bigint: true }).type !== 0x9fa0n)
32617
- return undefined;
32618
- // statfs follows this kernel-owned descriptor alias to the retained parent.
32619
- return {
32620
- magic: external_node_fs_.statfsSync(`/proc/self/fd/${parentFd}`, { bigint: true }).type,
32621
- fdinfo: external_node_fs_.readFileSync(`/proc/self/fdinfo/${parentFd}`, "utf8"),
32622
- mountinfo: external_node_fs_.readFileSync("/proc/self/mountinfo", "utf8"),
32623
- };
32624
- })();
32625
- if (!observation || observation.magic !== 0x01021997n)
32626
- return false;
32627
- const ids = [...observation.fdinfo.matchAll(/^mnt_id:\s*(\d+)\s*$/gm)];
32628
- if (ids.length !== 1)
32629
- return false;
32630
- const entries = observation.mountinfo.split("\n").filter(line => line.split(" ")[0] === ids[0][1]);
32631
- if (entries.length !== 1)
32632
- return false;
32633
- const [before, after, extra] = entries[0].split(" - ");
32634
- if (!before || !after || extra !== undefined || before.split(" ").length < 6)
32635
- return false;
32636
- const fields = after.split(" ");
32637
- return fields.length === 3 && fields[0] === "9p" &&
32638
- fields[2].split(",").some(option => option === "aname=drvfs" || option.startsWith("aname=drvfs;"));
32639
- }
32640
- catch {
32641
- return false;
32642
- }
32643
- }
32644
- /** Exact metadata is necessary but cannot exclude inode reuse after the final close. */
32645
- function assertRecoveredPublication(actual, expected) {
32646
- if (!actual.isFile() || actual.isSymbolicLink() || actual.nlink !== 1n ||
32647
- actual.dev !== expected.dev || actual.ino !== expected.ino || actual.size !== expected.size ||
32648
- actual.mode !== expected.mode || actual.uid !== expected.uid || actual.gid !== expected.gid) {
32649
- throw new errors_FsSafeError("path-mismatch", "published file changed during DrvFS recovery");
32650
- }
32651
- }
32652
- async function recoverAfterHiddenRename(params) {
32653
- if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
32654
- throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
32655
- }
32656
- await params.closeWriter();
32657
- for (let attempt = 0;; attempt++) {
32658
- let recovered;
32659
- try {
32660
- recovered = await params.reopen();
32661
- }
32662
- catch (error) {
32663
- if (!hasErrorCode(error, "ENOENT") || attempt === 4)
32664
- throw error;
32665
- await sleep(20);
32666
- continue;
32667
- }
32668
- try {
32669
- await params.retain?.(recovered);
32670
- }
32671
- catch (error) {
32672
- await params.dispose?.(recovered).catch(() => undefined);
32673
- throw error;
32674
- }
32675
- return recovered;
32676
- }
32677
- }
32678
- function recoverAfterHiddenRenameSync(params) {
32679
- if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
32680
- throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
32681
- }
32682
- params.closeWriter();
32683
- for (let attempt = 0;; attempt++) {
32684
- try {
32685
- return params.reopen();
32686
- }
32687
- catch (error) {
32688
- if (!hasErrorCode(error, "ENOENT") || attempt === 4)
32689
- throw error;
32690
- sleepSync(20);
32691
- }
32692
- }
32693
- }
32694
- function assertRecoveredFile(fd, expected, content) {
32695
- assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
32696
- if (content && !bounded_read_readFileDescriptorBoundedSync(fd, content.byteLength).equals(content)) {
32697
- throw new errors_FsSafeError("path-mismatch", "published content changed during DrvFS recovery");
32698
- }
32699
- assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
32700
- }
32701
- function reopenRecoveredNativeFile(binding, parentFd, basename, expected, content) {
32702
- if (!binding.openBeneath || !binding.closeOwnedFd || !binding.stagedFileMatches) {
32703
- throw new errors_FsSafeError("helper-unavailable", "native DrvFS recovery requires descriptor-relative verification");
32704
- }
32705
- const fd = binding.openBeneath(parentFd, basename, nativeOpenFlags(external_node_fs_.constants.O_RDONLY | external_node_fs_.constants.O_NONBLOCK)).fd;
32706
- try {
32707
- assertRecoveredFile(fd, expected, content);
32708
- if (!binding.stagedFileMatches(parentFd, basename, fd)) {
32709
- throw new errors_FsSafeError("path-mismatch", "published name changed during DrvFS recovery");
32710
- }
32711
- return fd;
32712
- }
32713
- catch (error) {
32714
- binding.closeOwnedFd(fd);
32715
- throw error;
32716
- }
32717
- }
32718
-
32719
32759
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
32720
32760
 
32721
32761
 
@@ -33308,8 +33348,11 @@ function staged_directory_openStagedDirectory(directory) {
33308
33348
 
33309
33349
 
33310
33350
 
33351
+
33311
33352
  /** Retained only for an explicitly enabled operation; no new default-path I/O. */
33312
- function retainDrvfsParent(directory) {
33353
+ function retainDrvfsParent(directory, dev, filesystemChecked = false) {
33354
+ if (!shouldPrepareDrvfsRecovery(true, dev))
33355
+ return undefined;
33313
33356
  let parent;
33314
33357
  try {
33315
33358
  // Resolve through the filesystem first: lexical normalization of link/..
@@ -33323,6 +33366,11 @@ function retainDrvfsParent(directory) {
33323
33366
  assertStagedDirectoryCurrent(retained.receipt);
33324
33367
  };
33325
33368
  assertCurrent();
33369
+ if (!filesystemChecked && !mayPrepareDrvfsRecoveryAtFd(retained.fd, retained.receipt.identity.dev)) {
33370
+ parent = undefined;
33371
+ external_node_fs_.closeSync(retained.fd);
33372
+ return undefined;
33373
+ }
33326
33374
  return { fd: retained.fd, assertCurrent, close() { external_node_fs_.closeSync(retained.fd); } };
33327
33375
  }
33328
33376
  catch {
@@ -33442,10 +33490,10 @@ class AtomicTempOwner {
33442
33490
  throw new Error("Atomic temp owner has no descriptor");
33443
33491
  return this.resource.fd;
33444
33492
  }
33445
- *prepareRecovery(content, directory = external_node_path_.dirname(this.pathname)) {
33493
+ *prepareRecovery(content, directory = external_node_path_.dirname(this.pathname), filesystemChecked = false) {
33446
33494
  if (!shouldPrepareDrvfsRecovery(true))
33447
33495
  return;
33448
- this.recoveryParent = retainDrvfsParent(directory);
33496
+ this.recoveryParent = retainDrvfsParent(directory, this.identity.dev, filesystemChecked);
33449
33497
  if (!this.recoveryParent)
33450
33498
  return;
33451
33499
  const observed = this.resource.statExact();
@@ -35798,11 +35846,11 @@ function fileLockSyncRootReceiptStillCurrent(pathAuthority, receipt) {
35798
35846
 
35799
35847
 
35800
35848
 
35801
- async function rootSidecarPublicationPending(lockRoot, relative, cleanAbandoned = false) {
35849
+ async function rootSidecarPublicationPending(lockRoot, relative, options = {}) {
35802
35850
  const resolved = await lockRoot.resolve(relative);
35803
35851
  const parent = external_node_path_.dirname(resolved);
35804
35852
  const identity = await directory_guard_inspectDirectoryIdentity(parent);
35805
- if (cleanAbandoned) {
35853
+ if (options.cleanAbandoned) {
35806
35854
  const admitted = admitFileLockSyncRootPath(captureFileLockSyncRootAuthority(lockRoot), resolved);
35807
35855
  const receipt = observeDirectory(external_node_path_.dirname(admitted.path));
35808
35856
  cleanupSidecarStages(admitted.path, candidate => {
@@ -35813,7 +35861,7 @@ async function rootSidecarPublicationPending(lockRoot, relative, cleanAbandoned
35813
35861
  assertFileLockSyncRootMutationAllowed(candidate, admitted.authority.denyMutations);
35814
35862
  });
35815
35863
  }
35816
- const pending = sidecar_lock_staging_sidecarPublicationPending(resolved);
35864
+ const pending = sidecar_lock_staging_sidecarPublicationPending(resolved, undefined, options);
35817
35865
  await directory_guard_inspectDirectoryIdentity(parent, identity);
35818
35866
  return pending && await lockRoot.resolve(relative) === resolved;
35819
35867
  }
@@ -35845,7 +35893,10 @@ async function openSidecarRoot(lockRoot, relative, discardObservation, onOpenFai
35845
35893
  break;
35846
35894
  }
35847
35895
  }
35848
- const observation = fileObservation();
35896
+ const observation = fileObservation({
35897
+ publicationPending: async (candidate, identity) => discardObservation === "changed" && candidate === resolved &&
35898
+ await rootSidecarPublicationPending(lockRoot, relative, { requireStage: true, identity }),
35899
+ });
35849
35900
  try {
35850
35901
  const opened = await observation.run(() => lockRoot.open(relative));
35851
35902
  if (opened.realPath !== expectedRealPath) {
@@ -35866,13 +35917,19 @@ async function openSidecarRoot(lockRoot, relative, discardObservation, onOpenFai
35866
35917
  return null;
35867
35918
  const discardable = observation.has(error, `unlinked:${resolved}`) ||
35868
35919
  (discardObservation === "changed" && observation.has(error, `changed:${resolved}`));
35869
- if (!discardObservation || (!missing && (!completeParents || !discardable)))
35920
+ const linkedChange = discardObservation === "changed" && observation.has(error, `linked-change:${resolved}`);
35921
+ if (!discardObservation || (!missing && (!completeParents || (!discardable && !linkedChange))))
35870
35922
  throw error;
35871
35923
  try {
35924
+ // Linked-change receipts already proved a matching stage while the exact
35925
+ // descriptor was open; retained ancestry and the current path still fence it.
35872
35926
  const probe = fileObservation();
35873
35927
  try {
35874
35928
  const current = await probe.run(() => lockRoot.stat(relative));
35875
- if (!current.isFile || current.isSymbolicLink || current.nlink !== 1)
35929
+ // A successor can still hold its matching publication-stage link.
35930
+ // Discard only the old read; retained ancestry is revalidated below.
35931
+ if (!current.isFile || current.isSymbolicLink || (current.nlink !== 1 &&
35932
+ !(current.nlink === 2 && await rootSidecarPublicationPending(lockRoot, relative))))
35876
35933
  throw error;
35877
35934
  }
35878
35935
  catch (probeError) {
@@ -43524,6 +43581,7 @@ class NativeStagedFile {
43524
43581
  #recoveryIdentity;
43525
43582
  #recoveryContent;
43526
43583
  #recovered = false;
43584
+ #prepareRecovery;
43527
43585
  #publicationTask;
43528
43586
  #rejectFinalSymlink = false;
43529
43587
  #unsupportedNoReplace;
@@ -43537,6 +43595,8 @@ class NativeStagedFile {
43537
43595
  this.#assertBeforeMutation = owner.assertBeforeMutation;
43538
43596
  this.#private = owner.permissionPolicy === "private-creation";
43539
43597
  this.#verifyMode = owner.permissionPolicy !== undefined;
43598
+ this.#prepareRecovery = shouldPrepareDrvfsRecovery(owner.allowDrvfsRenameRecovery, owner.directory.identity.dev) &&
43599
+ mayPrepareDrvfsRecoveryAtFd(owner.parentFd, owner.directory.identity.dev);
43540
43600
  }
43541
43601
  // The supplied closer owns parentFd even on construction or preparation failure.
43542
43602
  static async create(owner, input, maxBytes) {
@@ -43553,7 +43613,7 @@ class NativeStagedFile {
43553
43613
  }
43554
43614
  throw error;
43555
43615
  }
43556
- if (shouldPrepareDrvfsRecovery(owner.allowDrvfsRenameRecovery) && input.kind === "buffer") {
43616
+ if (staged.#prepareRecovery && input.kind === "buffer") {
43557
43617
  staged.#recoveryContent = typeof input.data === "string" ? Buffer.from(input.data, input.encoding) : Buffer.from(input.data);
43558
43618
  }
43559
43619
  await staged.#prepare(input, maxBytes);
@@ -43791,7 +43851,7 @@ class NativeStagedFile {
43791
43851
  this.#assertCurrent();
43792
43852
  assertFinalSymlinkRejected(external_node_path_.join(this.#owner.directory.realPath, basename), this.#rejectFinalSymlink);
43793
43853
  }
43794
- if (shouldPrepareDrvfsRecovery(this.#owner.allowDrvfsRenameRecovery)) {
43854
+ if (this.#prepareRecovery) {
43795
43855
  // Apply restrictive modes before exposing the name or releasing its last fd.
43796
43856
  if ((this.#owner.mode & 0o600) !== 0o600)
43797
43857
  external_node_fs_.fchmodSync(this.#file(), this.#owner.mode);
@@ -44391,10 +44451,11 @@ async function handleStaleSidecarAdmission(params) {
44391
44451
  throw error;
44392
44452
  }
44393
44453
  // An incomplete owner can still be writing; age is not liveness evidence.
44394
- if (!snapshot || (!params.parserState.parser && snapshot.payload === null) || isIncompleteSidecarLockRecord(snapshot.raw)) {
44454
+ if (!snapshot) {
44395
44455
  await params.waitForRetry();
44396
44456
  return;
44397
44457
  }
44458
+ const incomplete = (!params.parserState.parser && snapshot.payload === null) || isIncompleteSidecarLockRecord(snapshot.raw);
44398
44459
  const staleOptions = params.staleOptionsState;
44399
44460
  try {
44400
44461
  if (!staleOptions.shouldReclaimObserved) {
@@ -44430,7 +44491,7 @@ async function handleStaleSidecarAdmission(params) {
44430
44491
  assertUnheld();
44431
44492
  try {
44432
44493
  if (!shouldReclaim)
44433
- return defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
44494
+ return !incomplete && defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
44434
44495
  return await Reflect.apply(shouldReclaim, undefined, [{
44435
44496
  lockPath,
44436
44497
  normalizedTargetPath,
@@ -44476,6 +44537,9 @@ async function handleStaleSidecarAdmission(params) {
44476
44537
  await params.waitForRetry();
44477
44538
  return;
44478
44539
  }
44540
+ // Policy may diagnose an incomplete record, but can never authorize its removal.
44541
+ if (incomplete)
44542
+ throw sidecarLockStale(lockPath, normalizedTargetPath);
44479
44543
  if ((staleOptions.staleRecovery ?? "fail-closed") === "remove-if-unchanged") {
44480
44544
  const acquiredGuard = await admission.run(() => tryAcquireSidecarReclaimGuard(params.reclaimGuards, params.reclaimGuardPath, params.lockRoot));
44481
44545
  if (acquiredGuard)
@@ -45184,7 +45248,7 @@ async function acquireSidecarLock(options, context) {
45184
45248
  catch (error) {
45185
45249
  let cause = error;
45186
45250
  for (let depth = 0; depth < 4 && cause && typeof cause === "object"; depth++) {
45187
- if (observation.has(cause, "hardlink") && await rootSidecarPublicationPending(lockRoot, relativeLockPath, true)) {
45251
+ if (observation.has(cause, "hardlink") && await rootSidecarPublicationPending(lockRoot, relativeLockPath, { cleanAbandoned: true })) {
45188
45252
  exclusiveCreateConflict = true;
45189
45253
  throw Object.assign(new Error("sidecar publication in progress"), { code: "EEXIST" });
45190
45254
  }
@@ -46104,7 +46168,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
46104
46168
  ((params.mode & 0o400) !== 0 ||
46105
46169
  (process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
46106
46170
  if (shouldPrepareDrvfsRecovery(params.allowDrvfsRenameRecovery)) {
46107
- recoveryParent = retainDrvfsParent(parentPath);
46171
+ recoveryParent = retainDrvfsParent(parentPath, parentGuard.stat.dev);
46108
46172
  if (recoveryParent)
46109
46173
  recoveryIdentity = external_node_fs_.fstatSync(handle.fd, { bigint: true });
46110
46174
  if (recoveryParent && params.input.kind === "buffer")
@@ -46691,16 +46755,26 @@ function openedPathResolutionError(error = new errors_FsSafeError("path-mismatch
46691
46755
  }
46692
46756
  async function recordPreOpenFileChange(error, handle, filePath, before, opened) {
46693
46757
  if (!isFileObservationFailure(error, "identity") || !before?.isFile() || !opened?.isFile() ||
46694
- ![0n, 1n].includes(before.nlink) || ![0n, 1n].includes(opened.nlink))
46758
+ ![0n, 1n].includes(before.nlink) || ![0n, 1n, 2n].includes(opened.nlink))
46695
46759
  return;
46696
46760
  try {
46697
46761
  await strict_file_identity_inspectFileIdentity(async () => before);
46698
- const current = await strict_file_identity_inspectFileIdentity(() => process.platform === "win32"
46762
+ // A fresh exact descriptor distinguishes a completed handoff from a
46763
+ // still-linked generation that needs separate publication proof.
46764
+ const inspectCurrent = () => strict_file_identity_inspectFileIdentity(() => process.platform === "win32"
46699
46765
  ? external_node_fs_.fstatSync(handle.fd, { bigint: true }) : handle.stat({ bigint: true }), opened);
46700
- if (current.isFile() && [0n, 1n].includes(current.nlink) &&
46701
- (before.dev !== current.dev || before.ino !== current.ino)) {
46766
+ let current = await inspectCurrent();
46767
+ let publication = false;
46768
+ if (current.isFile() && current.nlink === 2n) {
46769
+ publication = await observedFilePublicationPending(filePath, current);
46770
+ current = await inspectCurrent();
46771
+ }
46772
+ if (current.isFile() && (before.dev !== current.dev || before.ino !== current.ino)) {
46702
46773
  // A stale pathname sample is not proof that its former inode was unlinked.
46703
- recordFileObservationFailure(error, `changed:${filePath}`);
46774
+ if ([0n, 1n].includes(current.nlink))
46775
+ recordFileObservationFailure(error, `changed:${filePath}`);
46776
+ else if (current.nlink === 2n && publication)
46777
+ recordFileObservationFailure(error, `linked-change:${filePath}`);
46704
46778
  }
46705
46779
  }
46706
46780
  catch {
@@ -46806,7 +46880,7 @@ async function openLocalFileDescriptor(filePath, options) {
46806
46880
  : await strict_file_identity_inspectFileIdentity(async () => inspect(await handle.stat({ bigint: true })), expected);
46807
46881
  }
46808
46882
  catch (error) {
46809
- if (openedIdentity && [0n, 1n].includes(openedIdentity.nlink)) {
46883
+ if (openedIdentity && [0n, 1n, 2n].includes(openedIdentity.nlink)) {
46810
46884
  await recordPreOpenFileChange(error, handle, filePath, preOpenStat, openedIdentity);
46811
46885
  }
46812
46886
  throw error;
@@ -50938,8 +51012,12 @@ async function commitPinnedWriteInRoot(root, pinned, params, input) {
50938
51012
  });
50939
51013
  }
50940
51014
  catch (error) {
50941
- if (error instanceof SidecarFallbackWriteError)
50942
- throw error.failure;
51015
+ if (error instanceof SidecarFallbackWriteError) {
51016
+ // Windows keeps its historical direct-write error identity.
51017
+ if (process.platform === "win32")
51018
+ throw error.failure;
51019
+ error = error.failure;
51020
+ }
50943
51021
  if (verifyingPublication)
50944
51022
  throw error;
50945
51023
  const errorCode = error?.code;
@@ -55247,7 +55325,7 @@ const BYTES_PER_MIB = 1_048_576;
55247
55325
  * Lint rule registry entity.
55248
55326
  * Defines all known lint rule IDs with their default severities, organized by target.
55249
55327
  */ /** Valid severity values for rule configuration */ /** Reported when an instruction file could not be read or parsed. */ const INSTRUCTION_PARSE_ERROR_RULE_ID = "instruction/parse-error";
55250
- /** Reported when instruction discovery stopped at one of its limits. */ const DISCOVERY_LIMIT_REACHED_RULE_ID = "instruction/discovery-limit-reached";
55328
+ /** Reported when instruction discovery stopped at one of its limits. */ const lint_rules_DISCOVERY_LIMIT_REACHED_RULE_ID = "instruction/discovery-limit-reached";
55251
55329
  /** Reported when instruction discovery skipped symbolic links that lead outside the repository. */ const DISCOVERY_SYMLINK_SKIPPED_RULE_ID = "instruction/discovery-symlink-skipped";
55252
55330
  /** Default severity levels for all known lint rules */ const DEFAULT_LINT_RULES = (/* unused pure expression or super */ null && ({
55253
55331
  agents: {
@@ -55300,7 +55378,7 @@ const BYTES_PER_MIB = 1_048_576;
55300
55378
  "instruction/import-cycle": "warn",
55301
55379
  "instruction/import-depth-exceeded": "warn",
55302
55380
  "instruction/import-size-exceeded": "warn",
55303
- [DISCOVERY_LIMIT_REACHED_RULE_ID]: "warn",
55381
+ [lint_rules_DISCOVERY_LIMIT_REACHED_RULE_ID]: "warn",
55304
55382
  [DISCOVERY_SYMLINK_SKIPPED_RULE_ID]: "warn"
55305
55383
  },
55306
55384
  skills: {
@@ -55316,7 +55394,7 @@ const BYTES_PER_MIB = 1_048_576;
55316
55394
  }
55317
55395
  }));
55318
55396
  const RUN_LEVEL_RULE_IDS = new Set([
55319
- DISCOVERY_LIMIT_REACHED_RULE_ID,
55397
+ lint_rules_DISCOVERY_LIMIT_REACHED_RULE_ID,
55320
55398
  DISCOVERY_SYMLINK_SKIPPED_RULE_ID
55321
55399
  ]);
55322
55400
  /**
@@ -55329,41 +55407,6 @@ const RUN_LEVEL_RULE_IDS = new Set([
55329
55407
  return ruleId !== undefined && RUN_LEVEL_RULE_IDS.has(ruleId);
55330
55408
  }
55331
55409
 
55332
- ;// CONCATENATED MODULE: ../core/src/entities/discovery-limit-message.ts
55333
- /**
55334
- * The one wording for a directory walk that stopped at a limit, shared by lint
55335
- * (instruction/discovery-limit-reached) and doctor (discovery-limit-reached)
55336
- * so the two cannot describe the same limits differently. Each caller says
55337
- * what it was looking for and what the user should take from the gap.
55338
- */ /** The limits a walk reached; a limit it did not reach is left out. */ /** One sentence for each limit that was reached: directories, depth, entries. */ function describeDiscoveryLimits(reached, { subject, missing, consequence }) {
55339
- const sentences = [];
55340
- if (reached.maxDirectories !== undefined) {
55341
- sentences.push(`${subject} stopped after listing ${reached.maxDirectories} directories, so ${missing} in the remaining directories ${consequence}.`);
55342
- }
55343
- if (reached.maxDepth !== undefined) {
55344
- sentences.push(`${subject} did not go more than ${reached.maxDepth} directories deep, so ${missing} in deeper directories ${consequence}.`);
55345
- }
55346
- if (reached.maxEntries !== undefined) {
55347
- sentences.push(`${subject} stopped after examining ${reached.maxEntries} directory entries, so ${missing} in the remaining entries ${consequence}.`);
55348
- }
55349
- return sentences;
55350
- }
55351
- /** How many paths a message names before it counts the rest. */ const NAMED_PATHS = 5;
55352
- /**
55353
- * The first few paths joined with commas, and a count of the rest, so a
55354
- * message about a fan-out stays readable: "a, b, c, d, e, and 3 more".
55355
- */ function listPaths(paths) {
55356
- const listed = paths.slice(0, NAMED_PATHS).join(", ");
55357
- const unlisted = paths.length - NAMED_PATHS;
55358
- return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;
55359
- }
55360
- /**
55361
- * The message for instruction file discovery skipping symbolic links that
55362
- * point outside the repository, so their targets were not analyzed.
55363
- */ function describeSkippedSymlinks(paths) {
55364
- return `Instruction file discovery skipped ${paths.length} symbolic link(s) that point outside the repository, so their targets were not analyzed: ${listPaths(paths)}. Replace a link with a file inside the repository to have it analyzed.`;
55365
- }
55366
-
55367
55410
  ;// CONCATENATED MODULE: ../core/src/entities/agentic-location-catalog.ts
55368
55411
  /**
55369
55412
  * Canonical catalog of agentic construct locations shared by lint and doctor.
@@ -55607,6 +55650,41 @@ function agentic_location_catalog_isNestedInstructionFilename(fileName) {
55607
55650
  return NESTED_INSTRUCTION_FILENAMES.has(fileName);
55608
55651
  }
55609
55652
 
55653
+ ;// CONCATENATED MODULE: ../core/src/entities/discovery-limit-message.ts
55654
+ /**
55655
+ * The one wording for a directory walk that stopped at a limit, shared by lint
55656
+ * (instruction/discovery-limit-reached) and doctor (discovery-limit-reached)
55657
+ * so the two cannot describe the same limits differently. Each caller says
55658
+ * what it was looking for and what the user should take from the gap.
55659
+ */ /** The limits a walk reached; a limit it did not reach is left out. */ /** One sentence for each limit that was reached: directories, depth, entries. */ function discovery_limit_message_describeDiscoveryLimits(reached, { subject, missing, consequence }) {
55660
+ const sentences = [];
55661
+ if (reached.maxDirectories !== undefined) {
55662
+ sentences.push(`${subject} stopped after listing ${reached.maxDirectories} directories, so ${missing} in the remaining directories ${consequence}.`);
55663
+ }
55664
+ if (reached.maxDepth !== undefined) {
55665
+ sentences.push(`${subject} did not go more than ${reached.maxDepth} directories deep, so ${missing} in deeper directories ${consequence}.`);
55666
+ }
55667
+ if (reached.maxEntries !== undefined) {
55668
+ sentences.push(`${subject} stopped after examining ${reached.maxEntries} directory entries, so ${missing} in the remaining entries ${consequence}.`);
55669
+ }
55670
+ return sentences;
55671
+ }
55672
+ /** How many paths a message names before it counts the rest. */ const NAMED_PATHS = 5;
55673
+ /**
55674
+ * The first few paths joined with commas, and a count of the rest, so a
55675
+ * message about a fan-out stays readable: "a, b, c, d, e, and 3 more".
55676
+ */ function listPaths(paths) {
55677
+ const listed = paths.slice(0, NAMED_PATHS).join(", ");
55678
+ const unlisted = paths.length - NAMED_PATHS;
55679
+ return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;
55680
+ }
55681
+ /**
55682
+ * The message for instruction file discovery skipping symbolic links that
55683
+ * point outside the repository, so their targets were not analyzed.
55684
+ */ function describeSkippedSymlinks(paths) {
55685
+ return `Instruction file discovery skipped ${paths.length} symbolic link(s) that point outside the repository, so their targets were not analyzed: ${listPaths(paths)}. Replace a link with a file inside the repository to have it analyzed.`;
55686
+ }
55687
+
55610
55688
  ;// CONCATENATED MODULE: ../core/src/lib/agentic-location-matchers.ts
55611
55689
  /**
55612
55690
  * Pure path→construct matching helpers over the agentic location catalog.
@@ -55649,7 +55727,7 @@ function matchesLocationEntry(path, entry) {
55649
55727
  }
55650
55728
  return normalized === entry.path || normalized.startsWith(`${entry.path}/`) && (entry.fileSuffix === undefined || normalized.endsWith(entry.fileSuffix));
55651
55729
  }
55652
- function entriesMatchingPath(path, catalog = AGENTIC_LOCATION_CATALOG) {
55730
+ function entriesMatchingPath(path, catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55653
55731
  return catalog.filter((entry)=>matchesLocationEntry(path, entry));
55654
55732
  }
55655
55733
  /**
@@ -55672,7 +55750,7 @@ function specificityScore(entry) {
55672
55750
  const kindBonus = entry.matchKind === "exact" ? 1_000_000 : 0;
55673
55751
  return kindBonus + entry.path.length;
55674
55752
  }
55675
- function bestMatchingEntry(path, catalog = AGENTIC_LOCATION_CATALOG) {
55753
+ function bestMatchingEntry(path, catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55676
55754
  const matches = entriesMatchingPath(path, catalog);
55677
55755
  if (matches.length === 0) {
55678
55756
  return null;
@@ -55708,16 +55786,16 @@ function constructTypesForPath(path, catalog = AGENTIC_LOCATION_CATALOG) {
55708
55786
  ...secondary
55709
55787
  ];
55710
55788
  }
55711
- function lintTargetEntries(target, catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55789
+ function lintTargetEntries(target, catalog = AGENTIC_LOCATION_CATALOG) {
55712
55790
  return catalog.filter((entry)=>entry.lintTarget === target);
55713
55791
  }
55714
- function skillDirectoryRoots(catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55792
+ function agentic_location_matchers_skillDirectoryRoots(catalog = AGENTIC_LOCATION_CATALOG) {
55715
55793
  return lintTargetEntries("skills", catalog).filter((entry)=>entry.matchKind === "directory-prefix").map((entry)=>entry.path);
55716
55794
  }
55717
- function agentDirectoryRoots(catalog = AGENTIC_LOCATION_CATALOG) {
55795
+ function agentic_location_matchers_agentDirectoryRoots(catalog = AGENTIC_LOCATION_CATALOG) {
55718
55796
  return lintTargetEntries("agents", catalog).filter((entry)=>entry.matchKind === "directory-prefix").map((entry)=>entry.path);
55719
55797
  }
55720
- function subagentDirectoryRoots(catalog = AGENTIC_LOCATION_CATALOG) {
55798
+ function agentic_location_matchers_subagentDirectoryRoots(catalog = AGENTIC_LOCATION_CATALOG) {
55721
55799
  return lintTargetEntries("subagents", catalog).filter((entry)=>entry.matchKind === "directory-prefix").map((entry)=>entry.path);
55722
55800
  }
55723
55801
  function isHookConfigEntry(entry) {
@@ -55732,6 +55810,86 @@ function hookConfigPaths(catalog = AGENTIC_LOCATION_CATALOG) {
55732
55810
  function instructionDiscoveryEntries(catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55733
55811
  return catalog.filter((entry)=>entry.instructionFormat != null);
55734
55812
  }
55813
+ /**
55814
+ * Format for a `CLAUDE.md`, `AGENTS.md`, `AGENTS.MD`, or `agents.md` that the
55815
+ * catalog's exact paths and suffix walks do not already load.
55816
+ *
55817
+ * A directory that loads every markdown file keeps the file (`null` here).
55818
+ * A suffix-restricted directory such as `.github/instructions` does not load
55819
+ * these names, so they stay Claude or shared instructions.
55820
+ */ function formatForAdditionalInstructionFile(path, catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
55821
+ const normalized = normalizeRepoRelativePath(path);
55822
+ if (normalized === "") {
55823
+ return null;
55824
+ }
55825
+ const slash = normalized.lastIndexOf("/");
55826
+ const fileName = slash === -1 ? normalized : normalized.slice(slash + 1);
55827
+ if (!agentic_location_catalog_isNestedInstructionFilename(fileName)) {
55828
+ return null;
55829
+ }
55830
+ const best = bestMatchingEntry(normalized, catalog);
55831
+ if (best?.matchKind === "exact") {
55832
+ return null;
55833
+ }
55834
+ if (best?.matchKind === "directory-prefix" && best.fileSuffix === undefined) {
55835
+ return null;
55836
+ }
55837
+ return fileName === "CLAUDE.md" ? "claude-md" : "agents-md";
55838
+ }
55839
+
55840
+ ;// CONCATENATED MODULE: ../core/src/entities/code-unit-order.ts
55841
+ /**
55842
+ * Orders strings by UTF-16 code unit.
55843
+ *
55844
+ * Unlike `localeCompare`, the result does not depend on the machine's locale
55845
+ * or ICU data, so anything sorted with it (directory entries, inventory
55846
+ * paths) comes out in the same order on every machine and in CI.
55847
+ */ function compareCodeUnits(a, b) {
55848
+ if (a < b) {
55849
+ return -1;
55850
+ }
55851
+ return a > b ? 1 : 0;
55852
+ }
55853
+
55854
+ ;// CONCATENATED MODULE: ../core/src/lib/agentic-discovery-skips.ts
55855
+ /**
55856
+ * Directories lint and doctor both leave out of discovery.
55857
+ * Pure path rules. No filesystem I/O.
55858
+ */ const BUILD_OUTPUT_DIRECTORY_NAMES = [
55859
+ "dist"
55860
+ ];
55861
+ const NAMED_SKIP_DIRECTORIES = new Set([
55862
+ "node_modules",
55863
+ ".git",
55864
+ ...BUILD_OUTPUT_DIRECTORY_NAMES
55865
+ ]);
55866
+ /**
55867
+ * True when `relativePath` is a fixture directory met below the scan root.
55868
+ * The root itself is not passed here. When the relative path has no parent
55869
+ * segment, `rootDirectoryName` is that parent, so a scan started in a
55870
+ * directory named `tests` still skips its `fixtures` child.
55871
+ *
55872
+ * `tests/fixtures` is the parent and child, not every directory named
55873
+ * `fixtures`, so `src/fixtures` stays in the scan. `__fixtures__` and
55874
+ * `testdata` are names at any depth.
55875
+ */ function isFixtureDirectory(relativePath, rootDirectoryName) {
55876
+ const segments = relativePath.split("/");
55877
+ const name = segments[segments.length - 1] ?? "";
55878
+ if (name === "__fixtures__" || name === "testdata") {
55879
+ return true;
55880
+ }
55881
+ const parent = segments.length >= 2 ? segments[segments.length - 2] : rootDirectoryName;
55882
+ return parent === "tests" && name === "fixtures";
55883
+ }
55884
+ /**
55885
+ * True when a discovered directory should not be entered. Callers that use
55886
+ * `walkRepository` pass `isFixtureDirectory` as `skipDirectory` and add
55887
+ * `BUILD_OUTPUT_DIRECTORY_NAMES` to `skipDirectoryNames` instead.
55888
+ */ function isSkippedDiscoveryDirectory(relativePath, rootDirectoryName) {
55889
+ const segments = relativePath.split("/");
55890
+ const name = segments[segments.length - 1] ?? "";
55891
+ return NAMED_SKIP_DIRECTORIES.has(name) || isFixtureDirectory(relativePath, rootDirectoryName);
55892
+ }
55735
55893
 
55736
55894
  ;// CONCATENATED MODULE: ../core/src/gateways/real-path-within-root.ts
55737
55895
  /**
@@ -55855,20 +56013,6 @@ async function kindOutsideRoot(real, fs) {
55855
56013
  } : null;
55856
56014
  }
55857
56015
 
55858
- ;// CONCATENATED MODULE: ../core/src/entities/code-unit-order.ts
55859
- /**
55860
- * Orders strings by UTF-16 code unit.
55861
- *
55862
- * Unlike `localeCompare`, the result does not depend on the machine's locale
55863
- * or ICU data, so anything sorted with it (directory entries, inventory
55864
- * paths) comes out in the same order on every machine and in CI.
55865
- */ function compareCodeUnits(a, b) {
55866
- if (a < b) {
55867
- return -1;
55868
- }
55869
- return a > b ? 1 : 0;
55870
- }
55871
-
55872
56016
  ;// CONCATENATED MODULE: ../core/src/gateways/repository-walk.ts
55873
56017
  /**
55874
56018
  * The shared, bounded walk over a repository tree, used by instruction
@@ -55895,7 +56039,7 @@ async function kindOutsideRoot(real, fs) {
55895
56039
  * Directory entries examined before the walk stops. The directory cap counts
55896
56040
  * listings, not the entries in them, and a fan-out of directory aliases lists
55897
56041
  * a wide directory many times over, so this bounds the work itself.
55898
- */ const DEFAULT_MAX_WALK_ENTRIES = 200_000;
56042
+ */ const repository_walk_DEFAULT_MAX_WALK_ENTRIES = 200_000;
55899
56043
  const DEFAULT_SKIPPED_DIRECTORY_NAMES = [
55900
56044
  "node_modules",
55901
56045
  ".git"
@@ -55913,9 +56057,10 @@ function resolveSettings(options) {
55913
56057
  includeFile: options.includeFile,
55914
56058
  includeSubdirectories: options.includeSubdirectories ?? true,
55915
56059
  revisit: options.revisit ?? "once-per-real-directory",
56060
+ symbolicLinks: options.symbolicLinks ?? "follow-within-root",
55916
56061
  maxDepth: options.maxDepth ?? DEFAULT_MAX_WALK_DEPTH,
55917
56062
  maxDirectories: options.maxDirectories ?? DEFAULT_MAX_WALK_DIRECTORIES,
55918
- maxEntries: options.maxEntries ?? DEFAULT_MAX_WALK_ENTRIES,
56063
+ maxEntries: options.maxEntries ?? repository_walk_DEFAULT_MAX_WALK_ENTRIES,
55919
56064
  skipDirectoryNames: new Set(options.skipDirectoryNames ?? DEFAULT_SKIPPED_DIRECTORY_NAMES),
55920
56065
  skipDirectory: options.skipDirectory ?? (()=>false),
55921
56066
  listDirectory: options.listDirectory ?? listWithinRoot
@@ -55931,6 +56076,13 @@ function resolveSettings(options) {
55931
56076
  /** Joins a repository-relative directory and an entry without a leading "/". */ function joinRelative(directory, name) {
55932
56077
  return directory === "" ? name : `${directory}/${name}`;
55933
56078
  }
56079
+ async function repository_walk_isSymbolicLink(absolutePath) {
56080
+ try {
56081
+ return (await (0,promises_.lstat)(absolutePath)).isSymbolicLink();
56082
+ } catch {
56083
+ return false;
56084
+ }
56085
+ }
55934
56086
  function segmentsOf(relativePath) {
55935
56087
  return relativePath.split("/").filter((segment)=>segment !== "");
55936
56088
  }
@@ -55946,6 +56098,7 @@ function segmentsOf(relativePath) {
55946
56098
  listedDirectories = 0;
55947
56099
  limitReached = false;
55948
56100
  depthLimitReached = false;
56101
+ depthLimitedDirectories = [];
55949
56102
  entriesExamined = 0;
55950
56103
  entryLimitReached = false;
55951
56104
  skippedOutsideRoot = [];
@@ -55960,6 +56113,7 @@ function segmentsOf(relativePath) {
55960
56113
  files: this.files,
55961
56114
  directoryLimitReached: this.limitReached,
55962
56115
  depthLimitReached: this.depthLimitReached,
56116
+ depthLimitedDirectories: this.depthLimitedDirectories,
55963
56117
  entryLimitReached: this.entryLimitReached,
55964
56118
  skippedOutsideRoot: this.skippedOutsideRoot,
55965
56119
  limits: {
@@ -56008,6 +56162,9 @@ function segmentsOf(relativePath) {
56008
56162
  }
56009
56163
  }
56010
56164
  async walkEntry(directoryReal, entryRelativePath, name, depth, ancestors) {
56165
+ if (this.settings.symbolicLinks === "skip" && await repository_walk_isSymbolicLink((0,external_node_path_.join)(directoryReal, name))) {
56166
+ return;
56167
+ }
56011
56168
  const entry = await inspectPathWithinRoot(this.rootReal, (0,external_node_path_.join)(directoryReal, name));
56012
56169
  if (entry.status === "outside-root") {
56013
56170
  if (this.wouldHaveCollected(entry.kind, entryRelativePath, name, depth)) {
@@ -56026,6 +56183,7 @@ function segmentsOf(relativePath) {
56026
56183
  await this.walkDirectory(entryRelativePath, depth + 1, ancestors);
56027
56184
  } else if (this.isTooDeep(entryRelativePath, name, depth) && !this.isRevisit(entry.real, ancestors)) {
56028
56185
  this.depthLimitReached = true;
56186
+ this.depthLimitedDirectories.push(entryRelativePath);
56029
56187
  }
56030
56188
  }
56031
56189
  wouldHaveCollected(kind, relativePath, name, depth) {
@@ -56062,7 +56220,7 @@ function segmentsOf(relativePath) {
56062
56220
  * directory reached through several aliases is counted each time it is
56063
56221
  * listed. When the cap is hit the walk stops listing, keeps what it found and
56064
56222
  * reports directoryLimitReached; it never throws for it.
56065
- */ async function walkRepository(targetDir, options) {
56223
+ */ async function repository_walk_walkRepository(targetDir, options) {
56066
56224
  const rootReal = await (0,promises_.realpath)((0,external_node_path_.resolve)(targetDir)).catch(()=>null);
56067
56225
  const settings = resolveSettings(options);
56068
56226
  if (rootReal === null) {
@@ -56070,6 +56228,7 @@ function segmentsOf(relativePath) {
56070
56228
  files: [],
56071
56229
  directoryLimitReached: false,
56072
56230
  depthLimitReached: false,
56231
+ depthLimitedDirectories: [],
56073
56232
  entryLimitReached: false,
56074
56233
  skippedOutsideRoot: [],
56075
56234
  limits: {
@@ -56082,6 +56241,307 @@ function segmentsOf(relativePath) {
56082
56241
  return new RepositoryWalk(targetDir, rootReal, settings).run();
56083
56242
  }
56084
56243
 
56244
+ ;// CONCATENATED MODULE: ../core/src/gateways/agentic-artifact-discovery.ts
56245
+ /**
56246
+ * Instruction discovery shared by lint and doctor.
56247
+ *
56248
+ * Each directory-prefix instruction location is walked from that location, so
56249
+ * depth 10 is counted from the catalog root. The walk keeps every logical
56250
+ * path (`refuse-ancestors`). Lint collapses those paths to one per real file.
56251
+ */
56252
+
56253
+
56254
+
56255
+
56256
+
56257
+
56258
+
56259
+
56260
+
56261
+ /** Directories below an agent or subagent catalog root that are still listed. */ const AGENT_CATALOG_DEPTH = 32;
56262
+ /** One skill directory below a skill root. `root/<name>/SKILL.md` is depth 1. */ const SKILL_CATALOG_DEPTH = 1;
56263
+ async function discoverInstructionLocations(targetDir, options) {
56264
+ const walks = [];
56265
+ for (const entry of instructionDiscoveryEntries()){
56266
+ if (entry.instructionFormat == null || entry.matchKind !== "directory-prefix") {
56267
+ continue;
56268
+ }
56269
+ walks.push({
56270
+ role: "catalog",
56271
+ format: entry.instructionFormat,
56272
+ walked: await repository_walk_walkRepository(targetDir, instructionWalkOptions(entry, options))
56273
+ });
56274
+ }
56275
+ if (options.includeNestedWalk !== false) {
56276
+ walks.push({
56277
+ role: "nested",
56278
+ format: null,
56279
+ walked: await repository_walk_walkRepository(targetDir, {
56280
+ ...instructionWalkOptions({
56281
+ path: "",
56282
+ matchKind: "directory-prefix",
56283
+ includeSubdirectories: true,
56284
+ fileSuffix: undefined
56285
+ }, options),
56286
+ startRelativePath: "",
56287
+ includeFile: (name)=>agentic_location_catalog_isNestedInstructionFilename(name),
56288
+ includeSubdirectories: true
56289
+ })
56290
+ });
56291
+ }
56292
+ return walks;
56293
+ }
56294
+ /**
56295
+ * One logical path per real file. Paths are the same file when their
56296
+ * symlink-free real paths match, so symbolic-link aliases collapse while two
56297
+ * hard links to one inode stay separate files. The path kept is the full
56298
+ * relative path that sorts first by UTF-16 code unit. That is not the directory a
56299
+ * name-ordered walk meets first: `b-extra/file` sorts before `b/file`
56300
+ * because `-` comes before `/`.
56301
+ *
56302
+ * When `preferred` is given, a path it accepts wins over one it rejects, and
56303
+ * code-unit order only breaks a tie between equals. The result is in
56304
+ * code-unit order of the kept paths either way.
56305
+ */ function collapseToFirstRealFile(files, preferred = ()=>false) {
56306
+ const sorted = [
56307
+ ...files
56308
+ ].sort((left, right)=>Number(preferred(right)) - Number(preferred(left)) || compareCodeUnits(left.relativePath, right.relativePath));
56309
+ const seen = new Set();
56310
+ const kept = [];
56311
+ for (const file of sorted){
56312
+ if (seen.has(file.real)) {
56313
+ continue;
56314
+ }
56315
+ seen.add(file.real);
56316
+ kept.push(file);
56317
+ }
56318
+ return kept.sort((left, right)=>compareCodeUnits(left.relativePath, right.relativePath));
56319
+ }
56320
+ /**
56321
+ * Markdown files under the agent catalog roots, to {@link AGENT_CATALOG_DEPTH}
56322
+ * from each root. Symlinks are followed when they stay inside the repository;
56323
+ * lint drops those paths afterwards.
56324
+ */ async function discoverAgentFiles(targetDir, options) {
56325
+ return discoverMarkdownUnderRoots(targetDir, agentDirectoryRoots(), AGENT_CATALOG_DEPTH, options);
56326
+ }
56327
+ /** Markdown files under the subagent catalog roots, to the agent depth. */ async function discoverSubagentFiles(targetDir, options) {
56328
+ return discoverMarkdownUnderRoots(targetDir, subagentDirectoryRoots(), AGENT_CATALOG_DEPTH, options);
56329
+ }
56330
+ /**
56331
+ * `SKILL.md` files one directory below a skill root. A `SKILL.md` in the root
56332
+ * itself, or nested further, is not a skill file. The walk stops at that
56333
+ * depth by definition, so meeting a skill's own subdirectory, such as
56334
+ * `references/` or `scripts/`, is not a depth limit: nothing below it could
56335
+ * be a skill file.
56336
+ */ async function agentic_artifact_discovery_discoverSkillFiles(targetDir, options) {
56337
+ const walked = await discoverMarkdownUnderRoots(targetDir, skillDirectoryRoots(), SKILL_CATALOG_DEPTH, options, (name)=>name === "SKILL.md");
56338
+ return {
56339
+ ...walked,
56340
+ depthLimitReached: false,
56341
+ files: walked.files.filter((file)=>skillDirectoryRoots().some((root)=>isSkillFileUnderRoot(root, file.relativePath)))
56342
+ };
56343
+ }
56344
+ /**
56345
+ * Reports a directory, entry, or depth cap from a construct walk. The depth
56346
+ * number is that walk's own cap, not the repository root's depth of 10.
56347
+ */ function agentic_artifact_discovery_reportConstructLimits(walk, onDiagnostic, wording) {
56348
+ if (onDiagnostic === undefined) {
56349
+ return;
56350
+ }
56351
+ const sentences = describeDiscoveryLimits({
56352
+ ...walk.directoryLimitReached ? {
56353
+ maxDirectories: walk.limits.maxDirectories
56354
+ } : {},
56355
+ ...walk.depthLimitReached ? {
56356
+ maxDepth: walk.limits.maxDepth
56357
+ } : {},
56358
+ ...walk.entryLimitReached ? {
56359
+ maxEntries: walk.limits.maxEntries
56360
+ } : {}
56361
+ }, wording);
56362
+ if (sentences.length > 0) {
56363
+ onDiagnostic({
56364
+ ruleId: DISCOVERY_LIMIT_REACHED_RULE_ID,
56365
+ message: sentences.join(" ")
56366
+ });
56367
+ }
56368
+ }
56369
+ function isSkillFileUnderRoot(root, relativePath) {
56370
+ const rootSegments = root.split("/").filter((segment)=>segment !== "");
56371
+ const segments = relativePath.split("/").filter((segment)=>segment !== "");
56372
+ return segments.length === rootSegments.length + 2 && segments.at(-1) === "SKILL.md" && rootSegments.every((segment, index)=>segments[index] === segment);
56373
+ }
56374
+ /**
56375
+ * Drops a path that is a symbolic link or sits under one. Skills, agents,
56376
+ * subagents, and hooks keep this filter; the shared walk itself follows
56377
+ * in-repo links so doctor can inventory them.
56378
+ */ async function agentic_artifact_discovery_omitSymlinkedPaths(targetDir, files) {
56379
+ const kept = [];
56380
+ for (const file of files){
56381
+ if (!await containsSymbolicLink(targetDir, file.relativePath)) {
56382
+ kept.push(file);
56383
+ }
56384
+ }
56385
+ return kept;
56386
+ }
56387
+ /**
56388
+ * Catalog paths that exist as regular files and are not symbolic links.
56389
+ * Hooks and MCP configs use this, then apply their own content checks.
56390
+ */ async function discoverExactRegularFiles(targetDir, relativePaths) {
56391
+ const rootReal = await realpath(resolve(targetDir)).catch(()=>null);
56392
+ if (rootReal === null) {
56393
+ return [];
56394
+ }
56395
+ const found = [];
56396
+ for (const relativePath of relativePaths){
56397
+ if (relativePath.split("/").some((segment)=>segment === "..")) {
56398
+ continue;
56399
+ }
56400
+ if (await isRegularFileInsideRoot(targetDir, rootReal, relativePath)) {
56401
+ found.push(relativePath);
56402
+ }
56403
+ }
56404
+ return found;
56405
+ }
56406
+ async function isRegularFileInsideRoot(targetDir, rootReal, relativePath) {
56407
+ if (await containsSymbolicLink(targetDir, relativePath)) {
56408
+ return false;
56409
+ }
56410
+ try {
56411
+ const real = await realpath(join(targetDir, ...relativePath.split("/")));
56412
+ const fromRoot = relative(rootReal, real);
56413
+ if (fromRoot.startsWith("..") || fromRoot.startsWith("/") || fromRoot === "") {
56414
+ return false;
56415
+ }
56416
+ const stat = await lstat(real);
56417
+ return stat.isFile();
56418
+ } catch {
56419
+ return false;
56420
+ }
56421
+ }
56422
+ function isMissingDirectoryError(error) {
56423
+ return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
56424
+ }
56425
+ /** Lists a directory, treating only one that is gone as empty. */ function emptyWhenMissing(list) {
56426
+ return async (rootReal, path)=>{
56427
+ try {
56428
+ return await list(rootReal, path);
56429
+ } catch (error) {
56430
+ if (isMissingDirectoryError(error)) {
56431
+ return [];
56432
+ }
56433
+ throw error;
56434
+ }
56435
+ };
56436
+ }
56437
+ function hasDoubleDot(name) {
56438
+ return name.includes("..");
56439
+ }
56440
+ function lintWalkOptions(includeFile, skipDirectory, list) {
56441
+ return {
56442
+ includeFile: (name)=>!hasDoubleDot(name) && includeFile(name),
56443
+ skipDirectory: (relativePath)=>hasDoubleDot(relativePath.split("/").at(-1) ?? "") || skipDirectory(relativePath),
56444
+ symbolicLinks: "skip",
56445
+ listDirectory: emptyWhenMissing(list)
56446
+ };
56447
+ }
56448
+ async function discoverMarkdownUnderRoots(targetDir, roots, maxDepth, options, includeFile = (name)=>name.endsWith(".md")) {
56449
+ const files = [];
56450
+ const skippedOutsideRoot = [];
56451
+ let directoryLimitReached = false;
56452
+ let entryLimitReached = false;
56453
+ let depthLimitReached = false;
56454
+ let limits = {
56455
+ maxDirectories: options.maxDirectories ?? (/* inlined export .DEFAULT_MAX_WALK_DIRECTORIES */10000),
56456
+ maxDepth,
56457
+ maxEntries: options.maxEntries ?? DEFAULT_MAX_WALK_ENTRIES
56458
+ };
56459
+ for (const root of roots){
56460
+ if (await isLintSkippedRoot(targetDir, root, options)) {
56461
+ continue;
56462
+ }
56463
+ const walked = await walkRepository(targetDir, constructWalkOptions(root, maxDepth, options, includeFile));
56464
+ files.push(...walked.files);
56465
+ directoryLimitReached = directoryLimitReached || walked.directoryLimitReached;
56466
+ entryLimitReached = entryLimitReached || walked.entryLimitReached;
56467
+ depthLimitReached = depthLimitReached || walked.depthLimitReached;
56468
+ limits = walked.limits;
56469
+ for (const path of walked.skippedOutsideRoot){
56470
+ if (!skippedOutsideRoot.includes(path)) {
56471
+ skippedOutsideRoot.push(path);
56472
+ }
56473
+ }
56474
+ }
56475
+ return {
56476
+ files,
56477
+ directoryLimitReached,
56478
+ entryLimitReached,
56479
+ depthLimitReached,
56480
+ skippedOutsideRoot,
56481
+ limits
56482
+ };
56483
+ }
56484
+ /** A lint walk lists nothing below a catalog root that is itself a link. */ async function isLintSkippedRoot(targetDir, root, options) {
56485
+ return options.purpose === "lint" && await containsSymbolicLink(targetDir, root);
56486
+ }
56487
+ function constructWalkOptions(root, maxDepth, options, includeFile) {
56488
+ const base = instructionWalkOptions({
56489
+ path: root,
56490
+ matchKind: "directory-prefix",
56491
+ includeSubdirectories: true,
56492
+ fileSuffix: undefined
56493
+ }, {
56494
+ ...options,
56495
+ maxDepth
56496
+ });
56497
+ const purposeOptions = options.purpose === "lint" ? lintWalkOptions(includeFile, base.skipDirectory ?? (()=>false), options.listDirectory ?? listDirectoryWithinRoot) : {
56498
+ includeFile,
56499
+ ...options.listDirectory === undefined ? {} : {
56500
+ listDirectory: options.listDirectory
56501
+ }
56502
+ };
56503
+ return {
56504
+ ...base,
56505
+ includeSubdirectories: true,
56506
+ maxDepth,
56507
+ ...purposeOptions
56508
+ };
56509
+ }
56510
+ async function containsSymbolicLink(targetDir, relativePath) {
56511
+ const segments = relativePath.split("/").filter((segment)=>segment !== "");
56512
+ const walked = [];
56513
+ for (const segment of segments){
56514
+ walked.push(segment);
56515
+ try {
56516
+ const stat = await lstat(join(targetDir, ...walked));
56517
+ if (stat.isSymbolicLink()) {
56518
+ return true;
56519
+ }
56520
+ } catch {
56521
+ return false;
56522
+ }
56523
+ }
56524
+ return false;
56525
+ }
56526
+ function instructionWalkOptions(entry, options) {
56527
+ return {
56528
+ startRelativePath: entry.path,
56529
+ includeFile: (name)=>name.endsWith(entry.fileSuffix ?? ".md"),
56530
+ includeSubdirectories: entry.includeSubdirectories === true,
56531
+ revisit: "refuse-ancestors",
56532
+ maxDepth: options.maxDepth ?? (/* inlined export .DEFAULT_MAX_WALK_DEPTH */10),
56533
+ maxDirectories: options.maxDirectories ?? (/* inlined export .DEFAULT_MAX_WALK_DIRECTORIES */10000),
56534
+ skipDirectoryNames: [
56535
+ ...DEFAULT_SKIPPED_DIRECTORY_NAMES,
56536
+ ...BUILD_OUTPUT_DIRECTORY_NAMES
56537
+ ],
56538
+ skipDirectory: (relativePath)=>isFixtureDirectory(relativePath, options.rootDirectoryName),
56539
+ ...options.maxEntries === undefined ? {} : {
56540
+ maxEntries: options.maxEntries
56541
+ }
56542
+ };
56543
+ }
56544
+
56085
56545
  ;// CONCATENATED MODULE: ../core/src/gateways/instruction-file-discovery-gateway.ts
56086
56546
  /**
56087
56547
  * Gateway for discovering instruction files across multiple formats.
@@ -56093,6 +56553,8 @@ function segmentsOf(relativePath) {
56093
56553
 
56094
56554
 
56095
56555
 
56556
+
56557
+
56096
56558
  /**
56097
56559
  * File system implementation of the instruction file discovery gateway.
56098
56560
  *
@@ -56122,34 +56584,77 @@ function segmentsOf(relativePath) {
56122
56584
  rootReal
56123
56585
  };
56124
56586
  const findings = new DiscoveryFindings();
56587
+ const rootDirectoryName = (0,external_node_path_.basename)((0,external_node_path_.resolve)(targetDir));
56588
+ const locations = await discoverInstructionLocations(targetDir, {
56589
+ rootDirectoryName,
56590
+ maxDirectories: this.maxDirectories,
56591
+ ...this.maxEntries === undefined ? {} : {
56592
+ maxEntries: this.maxEntries
56593
+ }
56594
+ });
56595
+ const catalogWalks = locations.filter((location)=>location.role === "catalog");
56596
+ let catalogIndex = 0;
56597
+ const seen = new Set();
56598
+ const exactFiles = [];
56125
56599
  for (const entry of instructionDiscoveryEntries()){
56126
56600
  const format = entry.instructionFormat;
56127
56601
  if (format == null) {
56128
56602
  continue;
56129
56603
  }
56130
56604
  if (entry.matchKind === "exact") {
56131
- findings.addExact(await discoverExactFile(root, entry.path, format));
56605
+ const exact = await discoverExactFile(root, entry.path, format);
56606
+ findings.addExact(exact);
56607
+ if (exact.real !== undefined) {
56608
+ seen.add(entry.path);
56609
+ exactFiles.push(await instruction_file_discovery_gateway_exactFileIdentity(entry.path, exact.real));
56610
+ }
56611
+ continue;
56612
+ }
56613
+ const walked = catalogWalks[catalogIndex]?.walked;
56614
+ catalogIndex += 1;
56615
+ if (walked === undefined) {
56132
56616
  continue;
56133
56617
  }
56134
- findings.addWalk(await walkRepository(targetDir, this.walkOptions(entry)), (file)=>toDiscoveredFile(root, file.relativePath, {
56618
+ const files = collapseToFirstRealFile(walked.files);
56619
+ findings.addWalk({
56620
+ ...walked,
56621
+ files
56622
+ }, (file)=>toDiscoveredFile(root, file.relativePath, {
56135
56623
  kind: "file",
56136
56624
  real: file.real
56137
56625
  }, format));
56626
+ for (const file of files){
56627
+ seen.add(file.relativePath);
56628
+ }
56629
+ }
56630
+ const nested = locations.find((location)=>location.role === "nested");
56631
+ if (nested !== undefined) {
56632
+ this.recordNestedInstructionFiles(root, seen, exactFiles, findings, nested.walked);
56138
56633
  }
56139
56634
  findings.report(onDiagnostic);
56140
56635
  return findings.files;
56141
56636
  }
56142
- walkOptions(entry) {
56143
- return {
56144
- startRelativePath: entry.path,
56145
- includeFile: (name)=>name.endsWith(entry.fileSuffix ?? ".md"),
56146
- includeSubdirectories: entry.includeSubdirectories === true,
56147
- revisit: "once-per-real-directory",
56148
- maxDirectories: this.maxDirectories,
56149
- ...this.maxEntries === undefined ? {} : {
56150
- maxEntries: this.maxEntries
56637
+ recordNestedInstructionFiles(root, seen, exactFiles, findings, additional) {
56638
+ const walkedPaths = new Set(additional.files.map((file)=>file.relativePath));
56639
+ const candidates = additional.files.filter((file)=>{
56640
+ if (seen.has(file.relativePath) || isExactFileAlias(file, exactFiles, walkedPaths)) {
56641
+ return false;
56151
56642
  }
56152
- };
56643
+ return formatForAdditionalInstructionFile(file.relativePath) !== null;
56644
+ });
56645
+ const files = collapseToFirstRealFile(candidates, (file)=>isAtItsRealPath(root, file));
56646
+ findings.addWalk({
56647
+ ...additional,
56648
+ files,
56649
+ skippedOutsideRoot: additional.skippedOutsideRoot.filter(isAnalyzableNestedInstructionLinkPath),
56650
+ depthLimitReached: false
56651
+ }, (file)=>toDiscoveredFile(root, file.relativePath, {
56652
+ kind: "file",
56653
+ real: file.real
56654
+ }, formatForAdditionalInstructionFile(file.relativePath) ?? "agents-md"));
56655
+ if (additional.depthLimitedDirectories.some(isNestedFilenameAnalyzedBelow)) {
56656
+ findings.noteNestedFilenameDepth(additional.limits.maxDepth);
56657
+ }
56153
56658
  }
56154
56659
  }
56155
56660
  /**
@@ -56160,6 +56665,7 @@ function segmentsOf(relativePath) {
56160
56665
  skippedOutsideRoot = [];
56161
56666
  directoryLimitReached = false;
56162
56667
  depthLimitReached = false;
56668
+ nestedFilenameDepth;
56163
56669
  entryLimitReached = false;
56164
56670
  limits;
56165
56671
  addExact(exact) {
@@ -56167,18 +56673,22 @@ function segmentsOf(relativePath) {
56167
56673
  this.skippedOutsideRoot.push(...exact.skippedOutsideRoot);
56168
56674
  }
56169
56675
  addWalk(walked, toDiscovered) {
56170
- this.limits = walked.limits;
56171
- this.directoryLimitReached ||= walked.directoryLimitReached;
56172
- this.depthLimitReached ||= walked.depthLimitReached;
56173
- this.entryLimitReached ||= walked.entryLimitReached;
56174
- this.skippedOutsideRoot.push(...walked.skippedOutsideRoot);
56676
+ this.recordLimits(walked);
56677
+ for (const path of walked.skippedOutsideRoot){
56678
+ if (!this.skippedOutsideRoot.includes(path)) {
56679
+ this.skippedOutsideRoot.push(path);
56680
+ }
56681
+ }
56175
56682
  this.files.push(...walked.files.map(toDiscovered));
56176
56683
  }
56684
+ noteNestedFilenameDepth(maxDepth) {
56685
+ this.nestedFilenameDepth = maxDepth;
56686
+ }
56177
56687
  report(onDiagnostic) {
56178
56688
  const reasons = this.describeLimits();
56179
56689
  if (reasons.length > 0) {
56180
56690
  onDiagnostic?.({
56181
- ruleId: DISCOVERY_LIMIT_REACHED_RULE_ID,
56691
+ ruleId: lint_rules_DISCOVERY_LIMIT_REACHED_RULE_ID,
56182
56692
  message: reasons.join(" ")
56183
56693
  });
56184
56694
  }
@@ -56189,11 +56699,39 @@ function segmentsOf(relativePath) {
56189
56699
  });
56190
56700
  }
56191
56701
  }
56702
+ recordLimits(walked) {
56703
+ if (this.limits === undefined) {
56704
+ this.limits = {
56705
+ ...walked.limits
56706
+ };
56707
+ }
56708
+ if (walked.directoryLimitReached) {
56709
+ this.directoryLimitReached = true;
56710
+ this.limits = {
56711
+ ...this.limits,
56712
+ maxDirectories: walked.limits.maxDirectories
56713
+ };
56714
+ }
56715
+ if (walked.depthLimitReached) {
56716
+ this.depthLimitReached = true;
56717
+ this.limits = {
56718
+ ...this.limits,
56719
+ maxDepth: walked.limits.maxDepth
56720
+ };
56721
+ }
56722
+ if (walked.entryLimitReached) {
56723
+ this.entryLimitReached = true;
56724
+ this.limits = {
56725
+ ...this.limits,
56726
+ maxEntries: walked.limits.maxEntries
56727
+ };
56728
+ }
56729
+ }
56192
56730
  describeLimits() {
56193
56731
  if (this.limits === undefined) {
56194
56732
  return [];
56195
56733
  }
56196
- return describeDiscoveryLimits({
56734
+ const sentences = discovery_limit_message_describeDiscoveryLimits({
56197
56735
  ...this.directoryLimitReached ? {
56198
56736
  maxDirectories: this.limits.maxDirectories
56199
56737
  } : {},
@@ -56204,6 +56742,12 @@ function segmentsOf(relativePath) {
56204
56742
  maxEntries: this.limits.maxEntries
56205
56743
  } : {}
56206
56744
  }, DISCOVERY_WORDING);
56745
+ if (this.nestedFilenameDepth !== undefined) {
56746
+ sentences.push(...discovery_limit_message_describeDiscoveryLimits({
56747
+ maxDepth: this.nestedFilenameDepth
56748
+ }, NESTED_FILENAME_DEPTH_WORDING));
56749
+ }
56750
+ return sentences;
56207
56751
  }
56208
56752
  }
56209
56753
  const DISCOVERY_WORDING = {
@@ -56211,6 +56755,62 @@ const DISCOVERY_WORDING = {
56211
56755
  missing: "instruction files",
56212
56756
  consequence: "were not analyzed"
56213
56757
  };
56758
+ const NESTED_FILENAME_DEPTH_WORDING = {
56759
+ subject: "Instruction file discovery",
56760
+ missing: "CLAUDE.md, AGENTS.md, AGENTS.MD, and agents.md files",
56761
+ consequence: "may not have been analyzed"
56762
+ };
56763
+ /**
56764
+ * True when the walked path is the file's own location rather than a path
56765
+ * that reaches it through a symbolic link, so a file also visible through a
56766
+ * catalog-owned link is reported where it lives.
56767
+ */ function isAtItsRealPath(root, file) {
56768
+ return file.real === (0,external_node_path_.join)(root.rootReal, ...file.relativePath.split("/"));
56769
+ }
56770
+ /**
56771
+ * True for a skipped link the nested walk would have analyzed: a nested
56772
+ * instruction filename at the root, or one no other catalog entry owns. A
56773
+ * link such as `.claude/skills/a/AGENTS.md` is owned by its skill directory,
56774
+ * so lint would not analyze it as an instruction even inside the repository.
56775
+ */ function isAnalyzableNestedInstructionLinkPath(relativePath) {
56776
+ const slash = relativePath.lastIndexOf("/");
56777
+ if (slash === -1) {
56778
+ return agentic_location_catalog_isNestedInstructionFilename(relativePath);
56779
+ }
56780
+ return formatForAdditionalInstructionFile(relativePath) !== null;
56781
+ }
56782
+ async function instruction_file_discovery_gateway_exactFileIdentity(path, real) {
56783
+ const stats = await (0,promises_.stat)(real).catch(()=>null);
56784
+ return {
56785
+ path,
56786
+ real,
56787
+ identity: stats === null ? null : identityKey(stats)
56788
+ };
56789
+ }
56790
+ function identityKey(identity) {
56791
+ return `${identity.dev}:${identity.ino}`;
56792
+ }
56793
+ /**
56794
+ * True when a nested-walk file is an exact catalog file already discovered
56795
+ * under another name: the same real path (a symbolic link to it or from it),
56796
+ * or the same inode under a name that differs only in case, as a
56797
+ * case-insensitive file system reports `agents.md` for `AGENTS.md`. That
56798
+ * second form is one directory entry only when the walk did not also list the
56799
+ * catalog name: two entries listed by their own names are two files, even
56800
+ * when they are hard links to one inode.
56801
+ */ function isExactFileAlias(file, exactFiles, walkedPaths) {
56802
+ const walkedIdentity = identityKey(file.identity);
56803
+ return exactFiles.some((exact)=>exact.real === file.real || exact.identity === walkedIdentity && exact.path.toLowerCase() === file.relativePath.toLowerCase() && !walkedPaths.has(exact.path));
56804
+ }
56805
+ /**
56806
+ * True when a directory the nested walk did not enter could hold a
56807
+ * CLAUDE.md or AGENTS.md that lint would analyze, so the depth limit may have
56808
+ * hidden one. Under a skill, hook, or agent directory those names belong to
56809
+ * the construct that owns the directory and are never analyzed as
56810
+ * instructions; under `.github/instructions` they are.
56811
+ */ function isNestedFilenameAnalyzedBelow(directory) {
56812
+ return formatForAdditionalInstructionFile(`${directory}/CLAUDE.md`) !== null;
56813
+ }
56214
56814
  /**
56215
56815
  * Discovers one exact-path instruction file, or nothing when it is missing
56216
56816
  * or resolves outside the root, in which case a link out of the repository is
@@ -56222,6 +56822,7 @@ const DISCOVERY_WORDING = {
56222
56822
  files: [
56223
56823
  toDiscoveredFile(root, relativePosixPath, inspected, format)
56224
56824
  ],
56825
+ real: inspected.real,
56225
56826
  skippedOutsideRoot: []
56226
56827
  };
56227
56828
  }
@@ -58459,7 +59060,6 @@ const PackageJsonSchema = schemas_object({
58459
59060
 
58460
59061
 
58461
59062
  /** Maximum skill file size: 1 MB */ const MAX_SKILL_FILE_BYTES = 1_048_576;
58462
- /** Catalog skill roots converted to OS-native relative paths. */ const SKILL_DIRECTORIES = skillDirectoryRoots().map((root)=>(0,external_node_path_.join)(...root.split("/")));
58463
59063
  /** Maximum lock file size: 256 KB */ const MAX_LOCK_FILE_BYTES = 262_144;
58464
59064
  /** Relative path to the skills lock file. */ const SKILLS_LOCK_PATH = "skills-lock.json";
58465
59065
  /** Zod schema for skills-lock.json structure */ const SkillsLockSchema = schemas_object({
@@ -58490,59 +59090,40 @@ const PackageJsonSchema = schemas_object({
58490
59090
  /**
58491
59091
  * File system implementation of the skill lint gateway.
58492
59092
  */ class FileSystemSkillLintGateway {
58493
- async discoverSkills(targetDir) {
58494
- const skills = [];
58495
- for (const relativeDir of SKILL_DIRECTORIES){
58496
- const discovered = await this.discoverSkillsInDir(targetDir, relativeDir);
58497
- skills.push(...discovered);
58498
- }
59093
+ limits;
59094
+ constructor(limits = {}){
59095
+ this.limits = limits;
59096
+ }
59097
+ async discoverSkills(targetDir, onDiagnostic) {
59098
+ const walk = await discoverSkillFiles(targetDir, {
59099
+ rootDirectoryName: basename(resolve(targetDir)),
59100
+ purpose: "lint",
59101
+ ...this.limits
59102
+ });
59103
+ reportConstructLimits(walk, onDiagnostic, {
59104
+ subject: "Skill discovery",
59105
+ missing: "skill files",
59106
+ consequence: "were not analyzed"
59107
+ });
59108
+ const found = await omitSymlinkedPaths(targetDir, walk.files);
59109
+ const skills = found.flatMap((file)=>{
59110
+ const skillName = file.relativePath.split("/").at(-2) ?? "";
59111
+ if (skillName.includes("..") || skillName.includes("/") || skillName.includes("\\")) {
59112
+ return [];
59113
+ }
59114
+ return [
59115
+ {
59116
+ filePath: join(targetDir, ...file.relativePath.split("/")),
59117
+ skillName
59118
+ }
59119
+ ];
59120
+ });
58499
59121
  const lockedNames = await readLockedSkillNames(targetDir);
58500
59122
  if (lockedNames.size === 0) {
58501
59123
  return skills;
58502
59124
  }
58503
59125
  return skills.filter((skill)=>!lockedNames.has(skill.skillName));
58504
59126
  }
58505
- async discoverSkillsInDir(targetDir, skillsDir) {
58506
- try {
58507
- if (!await pathExistsWithinRoot(targetDir, skillsDir)) {
58508
- return [];
58509
- }
58510
- } catch {
58511
- return [];
58512
- }
58513
- let entries;
58514
- try {
58515
- entries = await listDirectoryWithinRoot(targetDir, skillsDir);
58516
- } catch (error) {
58517
- if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
58518
- return [];
58519
- }
58520
- throw error;
58521
- }
58522
- const skills = [];
58523
- for (const entry of entries){
58524
- if (!entry.isDirectory()) {
58525
- continue;
58526
- }
58527
- if (entry.name.includes("..") || entry.name.includes("/") || entry.name.includes("\\")) {
58528
- continue;
58529
- }
58530
- const skillRelativePath = join(skillsDir, entry.name, "SKILL.md");
58531
- let hasSkillFile = false;
58532
- try {
58533
- hasSkillFile = await pathExistsWithinRoot(targetDir, skillRelativePath);
58534
- } catch {
58535
- hasSkillFile = false;
58536
- }
58537
- if (hasSkillFile) {
58538
- skills.push({
58539
- filePath: join(targetDir, skillRelativePath),
58540
- skillName: entry.name
58541
- });
58542
- }
58543
- }
58544
- return skills;
58545
- }
58546
59127
  async readSkillFileContent(filePath) {
58547
59128
  return readFileNoFollow(filePath, MAX_SKILL_FILE_BYTES);
58548
59129
  }
@@ -94599,4 +95180,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
94599
95180
  // module factories are used so entry inlining is disabled
94600
95181
  // startup
94601
95182
  // Load entry module and return exports
94602
- var __webpack_exports__ = __webpack_require__(7693);
95183
+ var __webpack_exports__ = __webpack_require__(7698);