@lousy-agents/cli 5.23.10 → 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.
- package/api/copilot-with-fastify/.devcontainer/devcontainer.json +1 -1
- package/api/copilot-with-fastify/package-lock.json +40 -72
- package/api/copilot-with-fastify/package.json +4 -4
- package/cli/copilot-with-citty/.devcontainer/devcontainer.json +1 -1
- package/cli/copilot-with-citty/package.json +2 -2
- package/dist/index.js +975 -366
- package/package.json +1 -1
- package/ui/copilot-with-react/.devcontainer/devcontainer.json +1 -1
- package/ui/copilot-with-react/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -3053,7 +3053,7 @@ exports.basename = (path, { windows } = {}) => {
|
|
|
3053
3053
|
|
|
3054
3054
|
|
|
3055
3055
|
},
|
|
3056
|
-
|
|
3056
|
+
5219(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3057
3057
|
// NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
|
|
3058
3058
|
var constructs_namespaceObject = {};
|
|
3059
3059
|
__webpack_require__.r(constructs_namespaceObject);
|
|
@@ -47417,41 +47417,6 @@ const RUN_LEVEL_RULE_IDS = new Set([
|
|
|
47417
47417
|
return ruleId !== undefined && RUN_LEVEL_RULE_IDS.has(ruleId);
|
|
47418
47418
|
}
|
|
47419
47419
|
|
|
47420
|
-
;// CONCATENATED MODULE: ../core/src/entities/discovery-limit-message.ts
|
|
47421
|
-
/**
|
|
47422
|
-
* The one wording for a directory walk that stopped at a limit, shared by lint
|
|
47423
|
-
* (instruction/discovery-limit-reached) and doctor (discovery-limit-reached)
|
|
47424
|
-
* so the two cannot describe the same limits differently. Each caller says
|
|
47425
|
-
* what it was looking for and what the user should take from the gap.
|
|
47426
|
-
*/ /** 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 }) {
|
|
47427
|
-
const sentences = [];
|
|
47428
|
-
if (reached.maxDirectories !== undefined) {
|
|
47429
|
-
sentences.push(`${subject} stopped after listing ${reached.maxDirectories} directories, so ${missing} in the remaining directories ${consequence}.`);
|
|
47430
|
-
}
|
|
47431
|
-
if (reached.maxDepth !== undefined) {
|
|
47432
|
-
sentences.push(`${subject} did not go more than ${reached.maxDepth} directories deep, so ${missing} in deeper directories ${consequence}.`);
|
|
47433
|
-
}
|
|
47434
|
-
if (reached.maxEntries !== undefined) {
|
|
47435
|
-
sentences.push(`${subject} stopped after examining ${reached.maxEntries} directory entries, so ${missing} in the remaining entries ${consequence}.`);
|
|
47436
|
-
}
|
|
47437
|
-
return sentences;
|
|
47438
|
-
}
|
|
47439
|
-
/** How many paths a message names before it counts the rest. */ const NAMED_PATHS = 5;
|
|
47440
|
-
/**
|
|
47441
|
-
* The first few paths joined with commas, and a count of the rest, so a
|
|
47442
|
-
* message about a fan-out stays readable: "a, b, c, d, e, and 3 more".
|
|
47443
|
-
*/ function listPaths(paths) {
|
|
47444
|
-
const listed = paths.slice(0, NAMED_PATHS).join(", ");
|
|
47445
|
-
const unlisted = paths.length - NAMED_PATHS;
|
|
47446
|
-
return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;
|
|
47447
|
-
}
|
|
47448
|
-
/**
|
|
47449
|
-
* The message for instruction file discovery skipping symbolic links that
|
|
47450
|
-
* point outside the repository, so their targets were not analyzed.
|
|
47451
|
-
*/ function describeSkippedSymlinks(paths) {
|
|
47452
|
-
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.`;
|
|
47453
|
-
}
|
|
47454
|
-
|
|
47455
47420
|
;// CONCATENATED MODULE: ../core/src/entities/agentic-location-catalog.ts
|
|
47456
47421
|
/**
|
|
47457
47422
|
* Canonical catalog of agentic construct locations shared by lint and doctor.
|
|
@@ -47695,6 +47660,41 @@ function isNestedInstructionFilename(fileName) {
|
|
|
47695
47660
|
return NESTED_INSTRUCTION_FILENAMES.has(fileName);
|
|
47696
47661
|
}
|
|
47697
47662
|
|
|
47663
|
+
;// CONCATENATED MODULE: ../core/src/entities/discovery-limit-message.ts
|
|
47664
|
+
/**
|
|
47665
|
+
* The one wording for a directory walk that stopped at a limit, shared by lint
|
|
47666
|
+
* (instruction/discovery-limit-reached) and doctor (discovery-limit-reached)
|
|
47667
|
+
* so the two cannot describe the same limits differently. Each caller says
|
|
47668
|
+
* what it was looking for and what the user should take from the gap.
|
|
47669
|
+
*/ /** 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 }) {
|
|
47670
|
+
const sentences = [];
|
|
47671
|
+
if (reached.maxDirectories !== undefined) {
|
|
47672
|
+
sentences.push(`${subject} stopped after listing ${reached.maxDirectories} directories, so ${missing} in the remaining directories ${consequence}.`);
|
|
47673
|
+
}
|
|
47674
|
+
if (reached.maxDepth !== undefined) {
|
|
47675
|
+
sentences.push(`${subject} did not go more than ${reached.maxDepth} directories deep, so ${missing} in deeper directories ${consequence}.`);
|
|
47676
|
+
}
|
|
47677
|
+
if (reached.maxEntries !== undefined) {
|
|
47678
|
+
sentences.push(`${subject} stopped after examining ${reached.maxEntries} directory entries, so ${missing} in the remaining entries ${consequence}.`);
|
|
47679
|
+
}
|
|
47680
|
+
return sentences;
|
|
47681
|
+
}
|
|
47682
|
+
/** How many paths a message names before it counts the rest. */ const NAMED_PATHS = 5;
|
|
47683
|
+
/**
|
|
47684
|
+
* The first few paths joined with commas, and a count of the rest, so a
|
|
47685
|
+
* message about a fan-out stays readable: "a, b, c, d, e, and 3 more".
|
|
47686
|
+
*/ function listPaths(paths) {
|
|
47687
|
+
const listed = paths.slice(0, NAMED_PATHS).join(", ");
|
|
47688
|
+
const unlisted = paths.length - NAMED_PATHS;
|
|
47689
|
+
return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;
|
|
47690
|
+
}
|
|
47691
|
+
/**
|
|
47692
|
+
* The message for instruction file discovery skipping symbolic links that
|
|
47693
|
+
* point outside the repository, so their targets were not analyzed.
|
|
47694
|
+
*/ function describeSkippedSymlinks(paths) {
|
|
47695
|
+
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.`;
|
|
47696
|
+
}
|
|
47697
|
+
|
|
47698
47698
|
;// CONCATENATED MODULE: ../core/src/lib/agentic-location-matchers.ts
|
|
47699
47699
|
/**
|
|
47700
47700
|
* Pure path→construct matching helpers over the agentic location catalog.
|
|
@@ -47820,6 +47820,72 @@ function hookConfigPaths(catalog = agentic_location_catalog_AGENTIC_LOCATION_CAT
|
|
|
47820
47820
|
function instructionDiscoveryEntries(catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
|
|
47821
47821
|
return catalog.filter((entry)=>entry.instructionFormat != null);
|
|
47822
47822
|
}
|
|
47823
|
+
/**
|
|
47824
|
+
* Format for a `CLAUDE.md`, `AGENTS.md`, `AGENTS.MD`, or `agents.md` that the
|
|
47825
|
+
* catalog's exact paths and suffix walks do not already load.
|
|
47826
|
+
*
|
|
47827
|
+
* A directory that loads every markdown file keeps the file (`null` here).
|
|
47828
|
+
* A suffix-restricted directory such as `.github/instructions` does not load
|
|
47829
|
+
* these names, so they stay Claude or shared instructions.
|
|
47830
|
+
*/ function formatForAdditionalInstructionFile(path, catalog = agentic_location_catalog_AGENTIC_LOCATION_CATALOG) {
|
|
47831
|
+
const normalized = normalizeRepoRelativePath(path);
|
|
47832
|
+
if (normalized === "") {
|
|
47833
|
+
return null;
|
|
47834
|
+
}
|
|
47835
|
+
const slash = normalized.lastIndexOf("/");
|
|
47836
|
+
const fileName = slash === -1 ? normalized : normalized.slice(slash + 1);
|
|
47837
|
+
if (!isNestedInstructionFilename(fileName)) {
|
|
47838
|
+
return null;
|
|
47839
|
+
}
|
|
47840
|
+
const best = bestMatchingEntry(normalized, catalog);
|
|
47841
|
+
if (best?.matchKind === "exact") {
|
|
47842
|
+
return null;
|
|
47843
|
+
}
|
|
47844
|
+
if (best?.matchKind === "directory-prefix" && best.fileSuffix === undefined) {
|
|
47845
|
+
return null;
|
|
47846
|
+
}
|
|
47847
|
+
return fileName === "CLAUDE.md" ? "claude-md" : "agents-md";
|
|
47848
|
+
}
|
|
47849
|
+
|
|
47850
|
+
;// CONCATENATED MODULE: ../core/src/lib/agentic-discovery-skips.ts
|
|
47851
|
+
/**
|
|
47852
|
+
* Directories lint and doctor both leave out of discovery.
|
|
47853
|
+
* Pure path rules. No filesystem I/O.
|
|
47854
|
+
*/ const BUILD_OUTPUT_DIRECTORY_NAMES = [
|
|
47855
|
+
"dist"
|
|
47856
|
+
];
|
|
47857
|
+
const NAMED_SKIP_DIRECTORIES = new Set([
|
|
47858
|
+
"node_modules",
|
|
47859
|
+
".git",
|
|
47860
|
+
...BUILD_OUTPUT_DIRECTORY_NAMES
|
|
47861
|
+
]);
|
|
47862
|
+
/**
|
|
47863
|
+
* True when `relativePath` is a fixture directory met below the scan root.
|
|
47864
|
+
* The root itself is not passed here. When the relative path has no parent
|
|
47865
|
+
* segment, `rootDirectoryName` is that parent, so a scan started in a
|
|
47866
|
+
* directory named `tests` still skips its `fixtures` child.
|
|
47867
|
+
*
|
|
47868
|
+
* `tests/fixtures` is the parent and child, not every directory named
|
|
47869
|
+
* `fixtures`, so `src/fixtures` stays in the scan. `__fixtures__` and
|
|
47870
|
+
* `testdata` are names at any depth.
|
|
47871
|
+
*/ function isFixtureDirectory(relativePath, rootDirectoryName) {
|
|
47872
|
+
const segments = relativePath.split("/");
|
|
47873
|
+
const name = segments[segments.length - 1] ?? "";
|
|
47874
|
+
if (name === "__fixtures__" || name === "testdata") {
|
|
47875
|
+
return true;
|
|
47876
|
+
}
|
|
47877
|
+
const parent = segments.length >= 2 ? segments[segments.length - 2] : rootDirectoryName;
|
|
47878
|
+
return parent === "tests" && name === "fixtures";
|
|
47879
|
+
}
|
|
47880
|
+
/**
|
|
47881
|
+
* True when a discovered directory should not be entered. Callers that use
|
|
47882
|
+
* `walkRepository` pass `isFixtureDirectory` as `skipDirectory` and add
|
|
47883
|
+
* `BUILD_OUTPUT_DIRECTORY_NAMES` to `skipDirectoryNames` instead.
|
|
47884
|
+
*/ function isSkippedDiscoveryDirectory(relativePath, rootDirectoryName) {
|
|
47885
|
+
const segments = relativePath.split("/");
|
|
47886
|
+
const name = segments[segments.length - 1] ?? "";
|
|
47887
|
+
return NAMED_SKIP_DIRECTORIES.has(name) || isFixtureDirectory(relativePath, rootDirectoryName);
|
|
47888
|
+
}
|
|
47823
47889
|
|
|
47824
47890
|
;// CONCATENATED MODULE: ../core/src/gateways/real-path-within-root.ts
|
|
47825
47891
|
/**
|
|
@@ -47987,6 +48053,7 @@ function resolveSettings(options) {
|
|
|
47987
48053
|
includeFile: options.includeFile,
|
|
47988
48054
|
includeSubdirectories: options.includeSubdirectories ?? true,
|
|
47989
48055
|
revisit: options.revisit ?? "once-per-real-directory",
|
|
48056
|
+
symbolicLinks: options.symbolicLinks ?? "follow-within-root",
|
|
47990
48057
|
maxDepth: options.maxDepth ?? DEFAULT_MAX_WALK_DEPTH,
|
|
47991
48058
|
maxDirectories: options.maxDirectories ?? DEFAULT_MAX_WALK_DIRECTORIES,
|
|
47992
48059
|
maxEntries: options.maxEntries ?? DEFAULT_MAX_WALK_ENTRIES,
|
|
@@ -48005,6 +48072,13 @@ function resolveSettings(options) {
|
|
|
48005
48072
|
/** Joins a repository-relative directory and an entry without a leading "/". */ function joinRelative(directory, name) {
|
|
48006
48073
|
return directory === "" ? name : `${directory}/${name}`;
|
|
48007
48074
|
}
|
|
48075
|
+
async function repository_walk_isSymbolicLink(absolutePath) {
|
|
48076
|
+
try {
|
|
48077
|
+
return (await (0,promises_.lstat)(absolutePath)).isSymbolicLink();
|
|
48078
|
+
} catch {
|
|
48079
|
+
return false;
|
|
48080
|
+
}
|
|
48081
|
+
}
|
|
48008
48082
|
function segmentsOf(relativePath) {
|
|
48009
48083
|
return relativePath.split("/").filter((segment)=>segment !== "");
|
|
48010
48084
|
}
|
|
@@ -48020,6 +48094,7 @@ function segmentsOf(relativePath) {
|
|
|
48020
48094
|
listedDirectories = 0;
|
|
48021
48095
|
limitReached = false;
|
|
48022
48096
|
depthLimitReached = false;
|
|
48097
|
+
depthLimitedDirectories = [];
|
|
48023
48098
|
entriesExamined = 0;
|
|
48024
48099
|
entryLimitReached = false;
|
|
48025
48100
|
skippedOutsideRoot = [];
|
|
@@ -48034,6 +48109,7 @@ function segmentsOf(relativePath) {
|
|
|
48034
48109
|
files: this.files,
|
|
48035
48110
|
directoryLimitReached: this.limitReached,
|
|
48036
48111
|
depthLimitReached: this.depthLimitReached,
|
|
48112
|
+
depthLimitedDirectories: this.depthLimitedDirectories,
|
|
48037
48113
|
entryLimitReached: this.entryLimitReached,
|
|
48038
48114
|
skippedOutsideRoot: this.skippedOutsideRoot,
|
|
48039
48115
|
limits: {
|
|
@@ -48082,6 +48158,9 @@ function segmentsOf(relativePath) {
|
|
|
48082
48158
|
}
|
|
48083
48159
|
}
|
|
48084
48160
|
async walkEntry(directoryReal, entryRelativePath, name, depth, ancestors) {
|
|
48161
|
+
if (this.settings.symbolicLinks === "skip" && await repository_walk_isSymbolicLink((0,external_node_path_.join)(directoryReal, name))) {
|
|
48162
|
+
return;
|
|
48163
|
+
}
|
|
48085
48164
|
const entry = await inspectPathWithinRoot(this.rootReal, (0,external_node_path_.join)(directoryReal, name));
|
|
48086
48165
|
if (entry.status === "outside-root") {
|
|
48087
48166
|
if (this.wouldHaveCollected(entry.kind, entryRelativePath, name, depth)) {
|
|
@@ -48100,6 +48179,7 @@ function segmentsOf(relativePath) {
|
|
|
48100
48179
|
await this.walkDirectory(entryRelativePath, depth + 1, ancestors);
|
|
48101
48180
|
} else if (this.isTooDeep(entryRelativePath, name, depth) && !this.isRevisit(entry.real, ancestors)) {
|
|
48102
48181
|
this.depthLimitReached = true;
|
|
48182
|
+
this.depthLimitedDirectories.push(entryRelativePath);
|
|
48103
48183
|
}
|
|
48104
48184
|
}
|
|
48105
48185
|
wouldHaveCollected(kind, relativePath, name, depth) {
|
|
@@ -48144,6 +48224,7 @@ function segmentsOf(relativePath) {
|
|
|
48144
48224
|
files: [],
|
|
48145
48225
|
directoryLimitReached: false,
|
|
48146
48226
|
depthLimitReached: false,
|
|
48227
|
+
depthLimitedDirectories: [],
|
|
48147
48228
|
entryLimitReached: false,
|
|
48148
48229
|
skippedOutsideRoot: [],
|
|
48149
48230
|
limits: {
|
|
@@ -48156,6 +48237,307 @@ function segmentsOf(relativePath) {
|
|
|
48156
48237
|
return new RepositoryWalk(targetDir, rootReal, settings).run();
|
|
48157
48238
|
}
|
|
48158
48239
|
|
|
48240
|
+
;// CONCATENATED MODULE: ../core/src/gateways/agentic-artifact-discovery.ts
|
|
48241
|
+
/**
|
|
48242
|
+
* Instruction discovery shared by lint and doctor.
|
|
48243
|
+
*
|
|
48244
|
+
* Each directory-prefix instruction location is walked from that location, so
|
|
48245
|
+
* depth 10 is counted from the catalog root. The walk keeps every logical
|
|
48246
|
+
* path (`refuse-ancestors`). Lint collapses those paths to one per real file.
|
|
48247
|
+
*/
|
|
48248
|
+
|
|
48249
|
+
|
|
48250
|
+
|
|
48251
|
+
|
|
48252
|
+
|
|
48253
|
+
|
|
48254
|
+
|
|
48255
|
+
|
|
48256
|
+
|
|
48257
|
+
/** Directories below an agent or subagent catalog root that are still listed. */ const AGENT_CATALOG_DEPTH = 32;
|
|
48258
|
+
/** One skill directory below a skill root. `root/<name>/SKILL.md` is depth 1. */ const SKILL_CATALOG_DEPTH = 1;
|
|
48259
|
+
async function discoverInstructionLocations(targetDir, options) {
|
|
48260
|
+
const walks = [];
|
|
48261
|
+
for (const entry of instructionDiscoveryEntries()){
|
|
48262
|
+
if (entry.instructionFormat == null || entry.matchKind !== "directory-prefix") {
|
|
48263
|
+
continue;
|
|
48264
|
+
}
|
|
48265
|
+
walks.push({
|
|
48266
|
+
role: "catalog",
|
|
48267
|
+
format: entry.instructionFormat,
|
|
48268
|
+
walked: await walkRepository(targetDir, instructionWalkOptions(entry, options))
|
|
48269
|
+
});
|
|
48270
|
+
}
|
|
48271
|
+
if (options.includeNestedWalk !== false) {
|
|
48272
|
+
walks.push({
|
|
48273
|
+
role: "nested",
|
|
48274
|
+
format: null,
|
|
48275
|
+
walked: await walkRepository(targetDir, {
|
|
48276
|
+
...instructionWalkOptions({
|
|
48277
|
+
path: "",
|
|
48278
|
+
matchKind: "directory-prefix",
|
|
48279
|
+
includeSubdirectories: true,
|
|
48280
|
+
fileSuffix: undefined
|
|
48281
|
+
}, options),
|
|
48282
|
+
startRelativePath: "",
|
|
48283
|
+
includeFile: (name)=>isNestedInstructionFilename(name),
|
|
48284
|
+
includeSubdirectories: true
|
|
48285
|
+
})
|
|
48286
|
+
});
|
|
48287
|
+
}
|
|
48288
|
+
return walks;
|
|
48289
|
+
}
|
|
48290
|
+
/**
|
|
48291
|
+
* One logical path per real file. Paths are the same file when their
|
|
48292
|
+
* symlink-free real paths match, so symbolic-link aliases collapse while two
|
|
48293
|
+
* hard links to one inode stay separate files. The path kept is the full
|
|
48294
|
+
* relative path that sorts first by UTF-16 code unit. That is not the directory a
|
|
48295
|
+
* name-ordered walk meets first: `b-extra/file` sorts before `b/file`
|
|
48296
|
+
* because `-` comes before `/`.
|
|
48297
|
+
*
|
|
48298
|
+
* When `preferred` is given, a path it accepts wins over one it rejects, and
|
|
48299
|
+
* code-unit order only breaks a tie between equals. The result is in
|
|
48300
|
+
* code-unit order of the kept paths either way.
|
|
48301
|
+
*/ function collapseToFirstRealFile(files, preferred = ()=>false) {
|
|
48302
|
+
const sorted = [
|
|
48303
|
+
...files
|
|
48304
|
+
].sort((left, right)=>Number(preferred(right)) - Number(preferred(left)) || compareCodeUnits(left.relativePath, right.relativePath));
|
|
48305
|
+
const seen = new Set();
|
|
48306
|
+
const kept = [];
|
|
48307
|
+
for (const file of sorted){
|
|
48308
|
+
if (seen.has(file.real)) {
|
|
48309
|
+
continue;
|
|
48310
|
+
}
|
|
48311
|
+
seen.add(file.real);
|
|
48312
|
+
kept.push(file);
|
|
48313
|
+
}
|
|
48314
|
+
return kept.sort((left, right)=>compareCodeUnits(left.relativePath, right.relativePath));
|
|
48315
|
+
}
|
|
48316
|
+
/**
|
|
48317
|
+
* Markdown files under the agent catalog roots, to {@link AGENT_CATALOG_DEPTH}
|
|
48318
|
+
* from each root. Symlinks are followed when they stay inside the repository;
|
|
48319
|
+
* lint drops those paths afterwards.
|
|
48320
|
+
*/ async function discoverAgentFiles(targetDir, options) {
|
|
48321
|
+
return discoverMarkdownUnderRoots(targetDir, agentDirectoryRoots(), AGENT_CATALOG_DEPTH, options);
|
|
48322
|
+
}
|
|
48323
|
+
/** Markdown files under the subagent catalog roots, to the agent depth. */ async function discoverSubagentFiles(targetDir, options) {
|
|
48324
|
+
return discoverMarkdownUnderRoots(targetDir, subagentDirectoryRoots(), AGENT_CATALOG_DEPTH, options);
|
|
48325
|
+
}
|
|
48326
|
+
/**
|
|
48327
|
+
* `SKILL.md` files one directory below a skill root. A `SKILL.md` in the root
|
|
48328
|
+
* itself, or nested further, is not a skill file. The walk stops at that
|
|
48329
|
+
* depth by definition, so meeting a skill's own subdirectory, such as
|
|
48330
|
+
* `references/` or `scripts/`, is not a depth limit: nothing below it could
|
|
48331
|
+
* be a skill file.
|
|
48332
|
+
*/ async function discoverSkillFiles(targetDir, options) {
|
|
48333
|
+
const walked = await discoverMarkdownUnderRoots(targetDir, skillDirectoryRoots(), SKILL_CATALOG_DEPTH, options, (name)=>name === "SKILL.md");
|
|
48334
|
+
return {
|
|
48335
|
+
...walked,
|
|
48336
|
+
depthLimitReached: false,
|
|
48337
|
+
files: walked.files.filter((file)=>skillDirectoryRoots().some((root)=>isSkillFileUnderRoot(root, file.relativePath)))
|
|
48338
|
+
};
|
|
48339
|
+
}
|
|
48340
|
+
/**
|
|
48341
|
+
* Reports a directory, entry, or depth cap from a construct walk. The depth
|
|
48342
|
+
* number is that walk's own cap, not the repository root's depth of 10.
|
|
48343
|
+
*/ function reportConstructLimits(walk, onDiagnostic, wording) {
|
|
48344
|
+
if (onDiagnostic === undefined) {
|
|
48345
|
+
return;
|
|
48346
|
+
}
|
|
48347
|
+
const sentences = describeDiscoveryLimits({
|
|
48348
|
+
...walk.directoryLimitReached ? {
|
|
48349
|
+
maxDirectories: walk.limits.maxDirectories
|
|
48350
|
+
} : {},
|
|
48351
|
+
...walk.depthLimitReached ? {
|
|
48352
|
+
maxDepth: walk.limits.maxDepth
|
|
48353
|
+
} : {},
|
|
48354
|
+
...walk.entryLimitReached ? {
|
|
48355
|
+
maxEntries: walk.limits.maxEntries
|
|
48356
|
+
} : {}
|
|
48357
|
+
}, wording);
|
|
48358
|
+
if (sentences.length > 0) {
|
|
48359
|
+
onDiagnostic({
|
|
48360
|
+
ruleId: DISCOVERY_LIMIT_REACHED_RULE_ID,
|
|
48361
|
+
message: sentences.join(" ")
|
|
48362
|
+
});
|
|
48363
|
+
}
|
|
48364
|
+
}
|
|
48365
|
+
function isSkillFileUnderRoot(root, relativePath) {
|
|
48366
|
+
const rootSegments = root.split("/").filter((segment)=>segment !== "");
|
|
48367
|
+
const segments = relativePath.split("/").filter((segment)=>segment !== "");
|
|
48368
|
+
return segments.length === rootSegments.length + 2 && segments.at(-1) === "SKILL.md" && rootSegments.every((segment, index)=>segments[index] === segment);
|
|
48369
|
+
}
|
|
48370
|
+
/**
|
|
48371
|
+
* Drops a path that is a symbolic link or sits under one. Skills, agents,
|
|
48372
|
+
* subagents, and hooks keep this filter; the shared walk itself follows
|
|
48373
|
+
* in-repo links so doctor can inventory them.
|
|
48374
|
+
*/ async function omitSymlinkedPaths(targetDir, files) {
|
|
48375
|
+
const kept = [];
|
|
48376
|
+
for (const file of files){
|
|
48377
|
+
if (!await containsSymbolicLink(targetDir, file.relativePath)) {
|
|
48378
|
+
kept.push(file);
|
|
48379
|
+
}
|
|
48380
|
+
}
|
|
48381
|
+
return kept;
|
|
48382
|
+
}
|
|
48383
|
+
/**
|
|
48384
|
+
* Catalog paths that exist as regular files and are not symbolic links.
|
|
48385
|
+
* Hooks and MCP configs use this, then apply their own content checks.
|
|
48386
|
+
*/ async function discoverExactRegularFiles(targetDir, relativePaths) {
|
|
48387
|
+
const rootReal = await (0,promises_.realpath)((0,external_node_path_.resolve)(targetDir)).catch(()=>null);
|
|
48388
|
+
if (rootReal === null) {
|
|
48389
|
+
return [];
|
|
48390
|
+
}
|
|
48391
|
+
const found = [];
|
|
48392
|
+
for (const relativePath of relativePaths){
|
|
48393
|
+
if (relativePath.split("/").some((segment)=>segment === "..")) {
|
|
48394
|
+
continue;
|
|
48395
|
+
}
|
|
48396
|
+
if (await isRegularFileInsideRoot(targetDir, rootReal, relativePath)) {
|
|
48397
|
+
found.push(relativePath);
|
|
48398
|
+
}
|
|
48399
|
+
}
|
|
48400
|
+
return found;
|
|
48401
|
+
}
|
|
48402
|
+
async function isRegularFileInsideRoot(targetDir, rootReal, relativePath) {
|
|
48403
|
+
if (await containsSymbolicLink(targetDir, relativePath)) {
|
|
48404
|
+
return false;
|
|
48405
|
+
}
|
|
48406
|
+
try {
|
|
48407
|
+
const real = await (0,promises_.realpath)((0,external_node_path_.join)(targetDir, ...relativePath.split("/")));
|
|
48408
|
+
const fromRoot = (0,external_node_path_.relative)(rootReal, real);
|
|
48409
|
+
if (fromRoot.startsWith("..") || fromRoot.startsWith("/") || fromRoot === "") {
|
|
48410
|
+
return false;
|
|
48411
|
+
}
|
|
48412
|
+
const stat = await (0,promises_.lstat)(real);
|
|
48413
|
+
return stat.isFile();
|
|
48414
|
+
} catch {
|
|
48415
|
+
return false;
|
|
48416
|
+
}
|
|
48417
|
+
}
|
|
48418
|
+
function isMissingDirectoryError(error) {
|
|
48419
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
48420
|
+
}
|
|
48421
|
+
/** Lists a directory, treating only one that is gone as empty. */ function emptyWhenMissing(list) {
|
|
48422
|
+
return async (rootReal, path)=>{
|
|
48423
|
+
try {
|
|
48424
|
+
return await list(rootReal, path);
|
|
48425
|
+
} catch (error) {
|
|
48426
|
+
if (isMissingDirectoryError(error)) {
|
|
48427
|
+
return [];
|
|
48428
|
+
}
|
|
48429
|
+
throw error;
|
|
48430
|
+
}
|
|
48431
|
+
};
|
|
48432
|
+
}
|
|
48433
|
+
function hasDoubleDot(name) {
|
|
48434
|
+
return name.includes("..");
|
|
48435
|
+
}
|
|
48436
|
+
function lintWalkOptions(includeFile, skipDirectory, list) {
|
|
48437
|
+
return {
|
|
48438
|
+
includeFile: (name)=>!hasDoubleDot(name) && includeFile(name),
|
|
48439
|
+
skipDirectory: (relativePath)=>hasDoubleDot(relativePath.split("/").at(-1) ?? "") || skipDirectory(relativePath),
|
|
48440
|
+
symbolicLinks: "skip",
|
|
48441
|
+
listDirectory: emptyWhenMissing(list)
|
|
48442
|
+
};
|
|
48443
|
+
}
|
|
48444
|
+
async function discoverMarkdownUnderRoots(targetDir, roots, maxDepth, options, includeFile = (name)=>name.endsWith(".md")) {
|
|
48445
|
+
const files = [];
|
|
48446
|
+
const skippedOutsideRoot = [];
|
|
48447
|
+
let directoryLimitReached = false;
|
|
48448
|
+
let entryLimitReached = false;
|
|
48449
|
+
let depthLimitReached = false;
|
|
48450
|
+
let limits = {
|
|
48451
|
+
maxDirectories: options.maxDirectories ?? (/* inlined export .DEFAULT_MAX_WALK_DIRECTORIES */10000),
|
|
48452
|
+
maxDepth,
|
|
48453
|
+
maxEntries: options.maxEntries ?? (/* inlined export .DEFAULT_MAX_WALK_ENTRIES */200000)
|
|
48454
|
+
};
|
|
48455
|
+
for (const root of roots){
|
|
48456
|
+
if (await isLintSkippedRoot(targetDir, root, options)) {
|
|
48457
|
+
continue;
|
|
48458
|
+
}
|
|
48459
|
+
const walked = await walkRepository(targetDir, constructWalkOptions(root, maxDepth, options, includeFile));
|
|
48460
|
+
files.push(...walked.files);
|
|
48461
|
+
directoryLimitReached = directoryLimitReached || walked.directoryLimitReached;
|
|
48462
|
+
entryLimitReached = entryLimitReached || walked.entryLimitReached;
|
|
48463
|
+
depthLimitReached = depthLimitReached || walked.depthLimitReached;
|
|
48464
|
+
limits = walked.limits;
|
|
48465
|
+
for (const path of walked.skippedOutsideRoot){
|
|
48466
|
+
if (!skippedOutsideRoot.includes(path)) {
|
|
48467
|
+
skippedOutsideRoot.push(path);
|
|
48468
|
+
}
|
|
48469
|
+
}
|
|
48470
|
+
}
|
|
48471
|
+
return {
|
|
48472
|
+
files,
|
|
48473
|
+
directoryLimitReached,
|
|
48474
|
+
entryLimitReached,
|
|
48475
|
+
depthLimitReached,
|
|
48476
|
+
skippedOutsideRoot,
|
|
48477
|
+
limits
|
|
48478
|
+
};
|
|
48479
|
+
}
|
|
48480
|
+
/** A lint walk lists nothing below a catalog root that is itself a link. */ async function isLintSkippedRoot(targetDir, root, options) {
|
|
48481
|
+
return options.purpose === "lint" && await containsSymbolicLink(targetDir, root);
|
|
48482
|
+
}
|
|
48483
|
+
function constructWalkOptions(root, maxDepth, options, includeFile) {
|
|
48484
|
+
const base = instructionWalkOptions({
|
|
48485
|
+
path: root,
|
|
48486
|
+
matchKind: "directory-prefix",
|
|
48487
|
+
includeSubdirectories: true,
|
|
48488
|
+
fileSuffix: undefined
|
|
48489
|
+
}, {
|
|
48490
|
+
...options,
|
|
48491
|
+
maxDepth
|
|
48492
|
+
});
|
|
48493
|
+
const purposeOptions = options.purpose === "lint" ? lintWalkOptions(includeFile, base.skipDirectory ?? (()=>false), options.listDirectory ?? file_system_utils_listDirectoryWithinRoot) : {
|
|
48494
|
+
includeFile,
|
|
48495
|
+
...options.listDirectory === undefined ? {} : {
|
|
48496
|
+
listDirectory: options.listDirectory
|
|
48497
|
+
}
|
|
48498
|
+
};
|
|
48499
|
+
return {
|
|
48500
|
+
...base,
|
|
48501
|
+
includeSubdirectories: true,
|
|
48502
|
+
maxDepth,
|
|
48503
|
+
...purposeOptions
|
|
48504
|
+
};
|
|
48505
|
+
}
|
|
48506
|
+
async function containsSymbolicLink(targetDir, relativePath) {
|
|
48507
|
+
const segments = relativePath.split("/").filter((segment)=>segment !== "");
|
|
48508
|
+
const walked = [];
|
|
48509
|
+
for (const segment of segments){
|
|
48510
|
+
walked.push(segment);
|
|
48511
|
+
try {
|
|
48512
|
+
const stat = await (0,promises_.lstat)((0,external_node_path_.join)(targetDir, ...walked));
|
|
48513
|
+
if (stat.isSymbolicLink()) {
|
|
48514
|
+
return true;
|
|
48515
|
+
}
|
|
48516
|
+
} catch {
|
|
48517
|
+
return false;
|
|
48518
|
+
}
|
|
48519
|
+
}
|
|
48520
|
+
return false;
|
|
48521
|
+
}
|
|
48522
|
+
function instructionWalkOptions(entry, options) {
|
|
48523
|
+
return {
|
|
48524
|
+
startRelativePath: entry.path,
|
|
48525
|
+
includeFile: (name)=>name.endsWith(entry.fileSuffix ?? ".md"),
|
|
48526
|
+
includeSubdirectories: entry.includeSubdirectories === true,
|
|
48527
|
+
revisit: "refuse-ancestors",
|
|
48528
|
+
maxDepth: options.maxDepth ?? (/* inlined export .DEFAULT_MAX_WALK_DEPTH */10),
|
|
48529
|
+
maxDirectories: options.maxDirectories ?? (/* inlined export .DEFAULT_MAX_WALK_DIRECTORIES */10000),
|
|
48530
|
+
skipDirectoryNames: [
|
|
48531
|
+
...DEFAULT_SKIPPED_DIRECTORY_NAMES,
|
|
48532
|
+
...BUILD_OUTPUT_DIRECTORY_NAMES
|
|
48533
|
+
],
|
|
48534
|
+
skipDirectory: (relativePath)=>isFixtureDirectory(relativePath, options.rootDirectoryName),
|
|
48535
|
+
...options.maxEntries === undefined ? {} : {
|
|
48536
|
+
maxEntries: options.maxEntries
|
|
48537
|
+
}
|
|
48538
|
+
};
|
|
48539
|
+
}
|
|
48540
|
+
|
|
48159
48541
|
;// CONCATENATED MODULE: ../core/src/gateways/instruction-file-discovery-gateway.ts
|
|
48160
48542
|
/**
|
|
48161
48543
|
* Gateway for discovering instruction files across multiple formats.
|
|
@@ -48167,6 +48549,8 @@ function segmentsOf(relativePath) {
|
|
|
48167
48549
|
|
|
48168
48550
|
|
|
48169
48551
|
|
|
48552
|
+
|
|
48553
|
+
|
|
48170
48554
|
/**
|
|
48171
48555
|
* File system implementation of the instruction file discovery gateway.
|
|
48172
48556
|
*
|
|
@@ -48196,34 +48580,77 @@ function segmentsOf(relativePath) {
|
|
|
48196
48580
|
rootReal
|
|
48197
48581
|
};
|
|
48198
48582
|
const findings = new DiscoveryFindings();
|
|
48583
|
+
const rootDirectoryName = (0,external_node_path_.basename)((0,external_node_path_.resolve)(targetDir));
|
|
48584
|
+
const locations = await discoverInstructionLocations(targetDir, {
|
|
48585
|
+
rootDirectoryName,
|
|
48586
|
+
maxDirectories: this.maxDirectories,
|
|
48587
|
+
...this.maxEntries === undefined ? {} : {
|
|
48588
|
+
maxEntries: this.maxEntries
|
|
48589
|
+
}
|
|
48590
|
+
});
|
|
48591
|
+
const catalogWalks = locations.filter((location)=>location.role === "catalog");
|
|
48592
|
+
let catalogIndex = 0;
|
|
48593
|
+
const seen = new Set();
|
|
48594
|
+
const exactFiles = [];
|
|
48199
48595
|
for (const entry of instructionDiscoveryEntries()){
|
|
48200
48596
|
const format = entry.instructionFormat;
|
|
48201
48597
|
if (format == null) {
|
|
48202
48598
|
continue;
|
|
48203
48599
|
}
|
|
48204
48600
|
if (entry.matchKind === "exact") {
|
|
48205
|
-
|
|
48601
|
+
const exact = await discoverExactFile(root, entry.path, format);
|
|
48602
|
+
findings.addExact(exact);
|
|
48603
|
+
if (exact.real !== undefined) {
|
|
48604
|
+
seen.add(entry.path);
|
|
48605
|
+
exactFiles.push(await instruction_file_discovery_gateway_exactFileIdentity(entry.path, exact.real));
|
|
48606
|
+
}
|
|
48607
|
+
continue;
|
|
48608
|
+
}
|
|
48609
|
+
const walked = catalogWalks[catalogIndex]?.walked;
|
|
48610
|
+
catalogIndex += 1;
|
|
48611
|
+
if (walked === undefined) {
|
|
48206
48612
|
continue;
|
|
48207
48613
|
}
|
|
48208
|
-
|
|
48614
|
+
const files = collapseToFirstRealFile(walked.files);
|
|
48615
|
+
findings.addWalk({
|
|
48616
|
+
...walked,
|
|
48617
|
+
files
|
|
48618
|
+
}, (file)=>toDiscoveredFile(root, file.relativePath, {
|
|
48209
48619
|
kind: "file",
|
|
48210
48620
|
real: file.real
|
|
48211
48621
|
}, format));
|
|
48622
|
+
for (const file of files){
|
|
48623
|
+
seen.add(file.relativePath);
|
|
48624
|
+
}
|
|
48625
|
+
}
|
|
48626
|
+
const nested = locations.find((location)=>location.role === "nested");
|
|
48627
|
+
if (nested !== undefined) {
|
|
48628
|
+
this.recordNestedInstructionFiles(root, seen, exactFiles, findings, nested.walked);
|
|
48212
48629
|
}
|
|
48213
48630
|
findings.report(onDiagnostic);
|
|
48214
48631
|
return findings.files;
|
|
48215
48632
|
}
|
|
48216
|
-
|
|
48217
|
-
|
|
48218
|
-
|
|
48219
|
-
|
|
48220
|
-
|
|
48221
|
-
revisit: "once-per-real-directory",
|
|
48222
|
-
maxDirectories: this.maxDirectories,
|
|
48223
|
-
...this.maxEntries === undefined ? {} : {
|
|
48224
|
-
maxEntries: this.maxEntries
|
|
48633
|
+
recordNestedInstructionFiles(root, seen, exactFiles, findings, additional) {
|
|
48634
|
+
const walkedPaths = new Set(additional.files.map((file)=>file.relativePath));
|
|
48635
|
+
const candidates = additional.files.filter((file)=>{
|
|
48636
|
+
if (seen.has(file.relativePath) || isExactFileAlias(file, exactFiles, walkedPaths)) {
|
|
48637
|
+
return false;
|
|
48225
48638
|
}
|
|
48226
|
-
|
|
48639
|
+
return formatForAdditionalInstructionFile(file.relativePath) !== null;
|
|
48640
|
+
});
|
|
48641
|
+
const files = collapseToFirstRealFile(candidates, (file)=>isAtItsRealPath(root, file));
|
|
48642
|
+
findings.addWalk({
|
|
48643
|
+
...additional,
|
|
48644
|
+
files,
|
|
48645
|
+
skippedOutsideRoot: additional.skippedOutsideRoot.filter(isAnalyzableNestedInstructionLinkPath),
|
|
48646
|
+
depthLimitReached: false
|
|
48647
|
+
}, (file)=>toDiscoveredFile(root, file.relativePath, {
|
|
48648
|
+
kind: "file",
|
|
48649
|
+
real: file.real
|
|
48650
|
+
}, formatForAdditionalInstructionFile(file.relativePath) ?? "agents-md"));
|
|
48651
|
+
if (additional.depthLimitedDirectories.some(isNestedFilenameAnalyzedBelow)) {
|
|
48652
|
+
findings.noteNestedFilenameDepth(additional.limits.maxDepth);
|
|
48653
|
+
}
|
|
48227
48654
|
}
|
|
48228
48655
|
}
|
|
48229
48656
|
/**
|
|
@@ -48234,6 +48661,7 @@ function segmentsOf(relativePath) {
|
|
|
48234
48661
|
skippedOutsideRoot = [];
|
|
48235
48662
|
directoryLimitReached = false;
|
|
48236
48663
|
depthLimitReached = false;
|
|
48664
|
+
nestedFilenameDepth;
|
|
48237
48665
|
entryLimitReached = false;
|
|
48238
48666
|
limits;
|
|
48239
48667
|
addExact(exact) {
|
|
@@ -48241,13 +48669,17 @@ function segmentsOf(relativePath) {
|
|
|
48241
48669
|
this.skippedOutsideRoot.push(...exact.skippedOutsideRoot);
|
|
48242
48670
|
}
|
|
48243
48671
|
addWalk(walked, toDiscovered) {
|
|
48244
|
-
this.
|
|
48245
|
-
|
|
48246
|
-
|
|
48247
|
-
|
|
48248
|
-
|
|
48672
|
+
this.recordLimits(walked);
|
|
48673
|
+
for (const path of walked.skippedOutsideRoot){
|
|
48674
|
+
if (!this.skippedOutsideRoot.includes(path)) {
|
|
48675
|
+
this.skippedOutsideRoot.push(path);
|
|
48676
|
+
}
|
|
48677
|
+
}
|
|
48249
48678
|
this.files.push(...walked.files.map(toDiscovered));
|
|
48250
48679
|
}
|
|
48680
|
+
noteNestedFilenameDepth(maxDepth) {
|
|
48681
|
+
this.nestedFilenameDepth = maxDepth;
|
|
48682
|
+
}
|
|
48251
48683
|
report(onDiagnostic) {
|
|
48252
48684
|
const reasons = this.describeLimits();
|
|
48253
48685
|
if (reasons.length > 0) {
|
|
@@ -48263,11 +48695,39 @@ function segmentsOf(relativePath) {
|
|
|
48263
48695
|
});
|
|
48264
48696
|
}
|
|
48265
48697
|
}
|
|
48698
|
+
recordLimits(walked) {
|
|
48699
|
+
if (this.limits === undefined) {
|
|
48700
|
+
this.limits = {
|
|
48701
|
+
...walked.limits
|
|
48702
|
+
};
|
|
48703
|
+
}
|
|
48704
|
+
if (walked.directoryLimitReached) {
|
|
48705
|
+
this.directoryLimitReached = true;
|
|
48706
|
+
this.limits = {
|
|
48707
|
+
...this.limits,
|
|
48708
|
+
maxDirectories: walked.limits.maxDirectories
|
|
48709
|
+
};
|
|
48710
|
+
}
|
|
48711
|
+
if (walked.depthLimitReached) {
|
|
48712
|
+
this.depthLimitReached = true;
|
|
48713
|
+
this.limits = {
|
|
48714
|
+
...this.limits,
|
|
48715
|
+
maxDepth: walked.limits.maxDepth
|
|
48716
|
+
};
|
|
48717
|
+
}
|
|
48718
|
+
if (walked.entryLimitReached) {
|
|
48719
|
+
this.entryLimitReached = true;
|
|
48720
|
+
this.limits = {
|
|
48721
|
+
...this.limits,
|
|
48722
|
+
maxEntries: walked.limits.maxEntries
|
|
48723
|
+
};
|
|
48724
|
+
}
|
|
48725
|
+
}
|
|
48266
48726
|
describeLimits() {
|
|
48267
48727
|
if (this.limits === undefined) {
|
|
48268
48728
|
return [];
|
|
48269
48729
|
}
|
|
48270
|
-
|
|
48730
|
+
const sentences = describeDiscoveryLimits({
|
|
48271
48731
|
...this.directoryLimitReached ? {
|
|
48272
48732
|
maxDirectories: this.limits.maxDirectories
|
|
48273
48733
|
} : {},
|
|
@@ -48278,6 +48738,12 @@ function segmentsOf(relativePath) {
|
|
|
48278
48738
|
maxEntries: this.limits.maxEntries
|
|
48279
48739
|
} : {}
|
|
48280
48740
|
}, DISCOVERY_WORDING);
|
|
48741
|
+
if (this.nestedFilenameDepth !== undefined) {
|
|
48742
|
+
sentences.push(...describeDiscoveryLimits({
|
|
48743
|
+
maxDepth: this.nestedFilenameDepth
|
|
48744
|
+
}, NESTED_FILENAME_DEPTH_WORDING));
|
|
48745
|
+
}
|
|
48746
|
+
return sentences;
|
|
48281
48747
|
}
|
|
48282
48748
|
}
|
|
48283
48749
|
const DISCOVERY_WORDING = {
|
|
@@ -48285,6 +48751,62 @@ const DISCOVERY_WORDING = {
|
|
|
48285
48751
|
missing: "instruction files",
|
|
48286
48752
|
consequence: "were not analyzed"
|
|
48287
48753
|
};
|
|
48754
|
+
const NESTED_FILENAME_DEPTH_WORDING = {
|
|
48755
|
+
subject: "Instruction file discovery",
|
|
48756
|
+
missing: "CLAUDE.md, AGENTS.md, AGENTS.MD, and agents.md files",
|
|
48757
|
+
consequence: "may not have been analyzed"
|
|
48758
|
+
};
|
|
48759
|
+
/**
|
|
48760
|
+
* True when the walked path is the file's own location rather than a path
|
|
48761
|
+
* that reaches it through a symbolic link, so a file also visible through a
|
|
48762
|
+
* catalog-owned link is reported where it lives.
|
|
48763
|
+
*/ function isAtItsRealPath(root, file) {
|
|
48764
|
+
return file.real === (0,external_node_path_.join)(root.rootReal, ...file.relativePath.split("/"));
|
|
48765
|
+
}
|
|
48766
|
+
/**
|
|
48767
|
+
* True for a skipped link the nested walk would have analyzed: a nested
|
|
48768
|
+
* instruction filename at the root, or one no other catalog entry owns. A
|
|
48769
|
+
* link such as `.claude/skills/a/AGENTS.md` is owned by its skill directory,
|
|
48770
|
+
* so lint would not analyze it as an instruction even inside the repository.
|
|
48771
|
+
*/ function isAnalyzableNestedInstructionLinkPath(relativePath) {
|
|
48772
|
+
const slash = relativePath.lastIndexOf("/");
|
|
48773
|
+
if (slash === -1) {
|
|
48774
|
+
return isNestedInstructionFilename(relativePath);
|
|
48775
|
+
}
|
|
48776
|
+
return formatForAdditionalInstructionFile(relativePath) !== null;
|
|
48777
|
+
}
|
|
48778
|
+
async function instruction_file_discovery_gateway_exactFileIdentity(path, real) {
|
|
48779
|
+
const stats = await (0,promises_.stat)(real).catch(()=>null);
|
|
48780
|
+
return {
|
|
48781
|
+
path,
|
|
48782
|
+
real,
|
|
48783
|
+
identity: stats === null ? null : identityKey(stats)
|
|
48784
|
+
};
|
|
48785
|
+
}
|
|
48786
|
+
function identityKey(identity) {
|
|
48787
|
+
return `${identity.dev}:${identity.ino}`;
|
|
48788
|
+
}
|
|
48789
|
+
/**
|
|
48790
|
+
* True when a nested-walk file is an exact catalog file already discovered
|
|
48791
|
+
* under another name: the same real path (a symbolic link to it or from it),
|
|
48792
|
+
* or the same inode under a name that differs only in case, as a
|
|
48793
|
+
* case-insensitive file system reports `agents.md` for `AGENTS.md`. That
|
|
48794
|
+
* second form is one directory entry only when the walk did not also list the
|
|
48795
|
+
* catalog name: two entries listed by their own names are two files, even
|
|
48796
|
+
* when they are hard links to one inode.
|
|
48797
|
+
*/ function isExactFileAlias(file, exactFiles, walkedPaths) {
|
|
48798
|
+
const walkedIdentity = identityKey(file.identity);
|
|
48799
|
+
return exactFiles.some((exact)=>exact.real === file.real || exact.identity === walkedIdentity && exact.path.toLowerCase() === file.relativePath.toLowerCase() && !walkedPaths.has(exact.path));
|
|
48800
|
+
}
|
|
48801
|
+
/**
|
|
48802
|
+
* True when a directory the nested walk did not enter could hold a
|
|
48803
|
+
* CLAUDE.md or AGENTS.md that lint would analyze, so the depth limit may have
|
|
48804
|
+
* hidden one. Under a skill, hook, or agent directory those names belong to
|
|
48805
|
+
* the construct that owns the directory and are never analyzed as
|
|
48806
|
+
* instructions; under `.github/instructions` they are.
|
|
48807
|
+
*/ function isNestedFilenameAnalyzedBelow(directory) {
|
|
48808
|
+
return formatForAdditionalInstructionFile(`${directory}/CLAUDE.md`) !== null;
|
|
48809
|
+
}
|
|
48288
48810
|
/**
|
|
48289
48811
|
* Discovers one exact-path instruction file, or nothing when it is missing
|
|
48290
48812
|
* or resolves outside the root, in which case a link out of the repository is
|
|
@@ -48296,6 +48818,7 @@ const DISCOVERY_WORDING = {
|
|
|
48296
48818
|
files: [
|
|
48297
48819
|
toDiscoveredFile(root, relativePosixPath, inspected, format)
|
|
48298
48820
|
],
|
|
48821
|
+
real: inspected.real,
|
|
48299
48822
|
skippedOutsideRoot: []
|
|
48300
48823
|
};
|
|
48301
48824
|
}
|
|
@@ -48745,7 +49268,6 @@ const PackageJsonSchema = schemas_object({
|
|
|
48745
49268
|
|
|
48746
49269
|
|
|
48747
49270
|
/** Maximum skill file size: 1 MB */ const MAX_SKILL_FILE_BYTES = 1_048_576;
|
|
48748
|
-
/** Catalog skill roots converted to OS-native relative paths. */ const SKILL_DIRECTORIES = skillDirectoryRoots().map((root)=>(0,external_node_path_.join)(...root.split("/")));
|
|
48749
49271
|
/** Maximum lock file size: 256 KB */ const MAX_LOCK_FILE_BYTES = 262_144;
|
|
48750
49272
|
/** Relative path to the skills lock file. */ const SKILLS_LOCK_PATH = "skills-lock.json";
|
|
48751
49273
|
/** Zod schema for skills-lock.json structure */ const SkillsLockSchema = schemas_object({
|
|
@@ -48776,59 +49298,40 @@ const PackageJsonSchema = schemas_object({
|
|
|
48776
49298
|
/**
|
|
48777
49299
|
* File system implementation of the skill lint gateway.
|
|
48778
49300
|
*/ class FileSystemSkillLintGateway {
|
|
48779
|
-
|
|
48780
|
-
|
|
48781
|
-
|
|
48782
|
-
|
|
48783
|
-
|
|
48784
|
-
|
|
49301
|
+
limits;
|
|
49302
|
+
constructor(limits = {}){
|
|
49303
|
+
this.limits = limits;
|
|
49304
|
+
}
|
|
49305
|
+
async discoverSkills(targetDir, onDiagnostic) {
|
|
49306
|
+
const walk = await discoverSkillFiles(targetDir, {
|
|
49307
|
+
rootDirectoryName: (0,external_node_path_.basename)((0,external_node_path_.resolve)(targetDir)),
|
|
49308
|
+
purpose: "lint",
|
|
49309
|
+
...this.limits
|
|
49310
|
+
});
|
|
49311
|
+
reportConstructLimits(walk, onDiagnostic, {
|
|
49312
|
+
subject: "Skill discovery",
|
|
49313
|
+
missing: "skill files",
|
|
49314
|
+
consequence: "were not analyzed"
|
|
49315
|
+
});
|
|
49316
|
+
const found = await omitSymlinkedPaths(targetDir, walk.files);
|
|
49317
|
+
const skills = found.flatMap((file)=>{
|
|
49318
|
+
const skillName = file.relativePath.split("/").at(-2) ?? "";
|
|
49319
|
+
if (skillName.includes("..") || skillName.includes("/") || skillName.includes("\\")) {
|
|
49320
|
+
return [];
|
|
49321
|
+
}
|
|
49322
|
+
return [
|
|
49323
|
+
{
|
|
49324
|
+
filePath: (0,external_node_path_.join)(targetDir, ...file.relativePath.split("/")),
|
|
49325
|
+
skillName
|
|
49326
|
+
}
|
|
49327
|
+
];
|
|
49328
|
+
});
|
|
48785
49329
|
const lockedNames = await readLockedSkillNames(targetDir);
|
|
48786
49330
|
if (lockedNames.size === 0) {
|
|
48787
49331
|
return skills;
|
|
48788
49332
|
}
|
|
48789
49333
|
return skills.filter((skill)=>!lockedNames.has(skill.skillName));
|
|
48790
49334
|
}
|
|
48791
|
-
async discoverSkillsInDir(targetDir, skillsDir) {
|
|
48792
|
-
try {
|
|
48793
|
-
if (!await file_system_utils_pathExistsWithinRoot(targetDir, skillsDir)) {
|
|
48794
|
-
return [];
|
|
48795
|
-
}
|
|
48796
|
-
} catch {
|
|
48797
|
-
return [];
|
|
48798
|
-
}
|
|
48799
|
-
let entries;
|
|
48800
|
-
try {
|
|
48801
|
-
entries = await file_system_utils_listDirectoryWithinRoot(targetDir, skillsDir);
|
|
48802
|
-
} catch (error) {
|
|
48803
|
-
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
48804
|
-
return [];
|
|
48805
|
-
}
|
|
48806
|
-
throw error;
|
|
48807
|
-
}
|
|
48808
|
-
const skills = [];
|
|
48809
|
-
for (const entry of entries){
|
|
48810
|
-
if (!entry.isDirectory()) {
|
|
48811
|
-
continue;
|
|
48812
|
-
}
|
|
48813
|
-
if (entry.name.includes("..") || entry.name.includes("/") || entry.name.includes("\\")) {
|
|
48814
|
-
continue;
|
|
48815
|
-
}
|
|
48816
|
-
const skillRelativePath = (0,external_node_path_.join)(skillsDir, entry.name, "SKILL.md");
|
|
48817
|
-
let hasSkillFile = false;
|
|
48818
|
-
try {
|
|
48819
|
-
hasSkillFile = await file_system_utils_pathExistsWithinRoot(targetDir, skillRelativePath);
|
|
48820
|
-
} catch {
|
|
48821
|
-
hasSkillFile = false;
|
|
48822
|
-
}
|
|
48823
|
-
if (hasSkillFile) {
|
|
48824
|
-
skills.push({
|
|
48825
|
-
filePath: (0,external_node_path_.join)(targetDir, skillRelativePath),
|
|
48826
|
-
skillName: entry.name
|
|
48827
|
-
});
|
|
48828
|
-
}
|
|
48829
|
-
}
|
|
48830
|
-
return skills;
|
|
48831
|
-
}
|
|
48832
49335
|
async readSkillFileContent(filePath) {
|
|
48833
49336
|
return readFileNoFollow(filePath, MAX_SKILL_FILE_BYTES);
|
|
48834
49337
|
}
|
|
@@ -53132,6 +53635,28 @@ function mcpServerRecords(servers) {
|
|
|
53132
53635
|
}));
|
|
53133
53636
|
}
|
|
53134
53637
|
|
|
53638
|
+
;// CONCATENATED MODULE: ../core/src/entities/mcp-config-schema.ts
|
|
53639
|
+
/**
|
|
53640
|
+
* Baseline shape of an MCP server configuration file. Shared by doctor and
|
|
53641
|
+
* lint so the two cannot disagree on what a valid config is.
|
|
53642
|
+
*/
|
|
53643
|
+
/**
|
|
53644
|
+
* Zod schema for a single MCP server declaration.
|
|
53645
|
+
* Baseline shape only: an object whose optional `type`/`transport` fields,
|
|
53646
|
+
* when present, must be non-empty strings. Unknown fields are preserved.
|
|
53647
|
+
*/ const McpServerEntrySchema = schemas_object({
|
|
53648
|
+
type: schemas_string().min(1, "type must not be empty").optional(),
|
|
53649
|
+
transport: schemas_string().min(1, "transport must not be empty").optional()
|
|
53650
|
+
}).passthrough();
|
|
53651
|
+
/**
|
|
53652
|
+
* Zod schema for the MCP config file shape: `mcpServers` (Claude Code's
|
|
53653
|
+
* `.mcp.json` convention) and `servers` (VS Code's `.vscode/mcp.json`
|
|
53654
|
+
* convention), each a map of server name to a server declaration.
|
|
53655
|
+
*/ const McpConfigSchema = schemas_object({
|
|
53656
|
+
mcpServers: schemas_record(schemas_string(), McpServerEntrySchema).optional(),
|
|
53657
|
+
servers: schemas_record(schemas_string(), McpServerEntrySchema).optional()
|
|
53658
|
+
}).passthrough();
|
|
53659
|
+
|
|
53135
53660
|
;// CONCATENATED MODULE: ../core/src/entities/mcp-config-source.ts
|
|
53136
53661
|
/**
|
|
53137
53662
|
* Canonical list of MCP server configuration file locations.
|
|
@@ -53158,10 +53683,6 @@ function mcpServerRecords(servers) {
|
|
|
53158
53683
|
|
|
53159
53684
|
|
|
53160
53685
|
const MAX_MCP_CONFIG_BYTES = 1_048_576;
|
|
53161
|
-
const McpServerEntrySchema = schemas_object({
|
|
53162
|
-
type: schemas_string().optional(),
|
|
53163
|
-
transport: schemas_string().optional()
|
|
53164
|
-
}).passthrough();
|
|
53165
53686
|
/**
|
|
53166
53687
|
* Property names that must never be used as MCP server names: assigning
|
|
53167
53688
|
* them via a plain object key (as zod's `record()` does when reconstructing
|
|
@@ -53193,55 +53714,107 @@ function hasReservedServerName(parsed) {
|
|
|
53193
53714
|
}
|
|
53194
53715
|
return false;
|
|
53195
53716
|
}
|
|
53196
|
-
|
|
53197
|
-
|
|
53198
|
-
|
|
53199
|
-
|
|
53200
|
-
|
|
53201
|
-
|
|
53202
|
-
|
|
53203
|
-
|
|
53717
|
+
const mcp_config_MISSING_ERROR_CODES = new Set([
|
|
53718
|
+
"not-found",
|
|
53719
|
+
"ENOENT",
|
|
53720
|
+
"ENOTDIR"
|
|
53721
|
+
]);
|
|
53722
|
+
function codeOf(value) {
|
|
53723
|
+
if (typeof value !== "object" || value === null || !("code" in value)) {
|
|
53724
|
+
return undefined;
|
|
53725
|
+
}
|
|
53726
|
+
return typeof value.code === "string" ? value.code : undefined;
|
|
53727
|
+
}
|
|
53728
|
+
/**
|
|
53729
|
+
* Classifies a read failure. Only a genuinely missing file (or a missing
|
|
53730
|
+
* parent directory) is silent: `undefined`. Anything else means something
|
|
53731
|
+
* is at the path that doctor could not inventory, so it is a defect. The
|
|
53732
|
+
* reason is chosen from the error's codes only, never its message, which
|
|
53733
|
+
* carries absolute paths.
|
|
53734
|
+
*/ function unreadableReason(error) {
|
|
53735
|
+
const code = codeOf(error);
|
|
53736
|
+
if (code !== undefined && mcp_config_MISSING_ERROR_CODES.has(code)) {
|
|
53737
|
+
return undefined;
|
|
53738
|
+
}
|
|
53739
|
+
const causeCode = error instanceof Error ? codeOf(error.cause) : undefined;
|
|
53740
|
+
if (causeCode === "symlink") {
|
|
53741
|
+
return "symlink";
|
|
53742
|
+
}
|
|
53743
|
+
if (causeCode === "too-large") {
|
|
53744
|
+
return "too-large";
|
|
53745
|
+
}
|
|
53746
|
+
return "unreadable";
|
|
53747
|
+
}
|
|
53748
|
+
function mcp_config_defect(source, reason) {
|
|
53749
|
+
return {
|
|
53750
|
+
records: [],
|
|
53751
|
+
defects: [
|
|
53752
|
+
{
|
|
53753
|
+
path: source.relPath,
|
|
53754
|
+
reason
|
|
53755
|
+
}
|
|
53756
|
+
]
|
|
53757
|
+
};
|
|
53758
|
+
}
|
|
53204
53759
|
async function readMcpServersFromSource(repoRoot, source) {
|
|
53205
53760
|
let content;
|
|
53206
53761
|
try {
|
|
53207
53762
|
content = await file_system_utils_readTextWithinRoot(repoRoot, source.relPath, MAX_MCP_CONFIG_BYTES);
|
|
53208
|
-
} catch
|
|
53209
|
-
|
|
53763
|
+
} catch (error) {
|
|
53764
|
+
const reason = unreadableReason(error);
|
|
53765
|
+
return reason === undefined ? {
|
|
53766
|
+
records: [],
|
|
53767
|
+
defects: []
|
|
53768
|
+
} : mcp_config_defect(source, reason);
|
|
53210
53769
|
}
|
|
53211
53770
|
let raw;
|
|
53212
53771
|
try {
|
|
53213
53772
|
raw = JSON.parse(content);
|
|
53214
53773
|
} catch {
|
|
53215
|
-
return
|
|
53774
|
+
return mcp_config_defect(source, "invalid-json");
|
|
53216
53775
|
}
|
|
53217
53776
|
if (hasReservedServerName(raw)) {
|
|
53218
|
-
return
|
|
53777
|
+
return mcp_config_defect(source, "reserved-name");
|
|
53219
53778
|
}
|
|
53220
53779
|
const result = McpConfigSchema.safeParse(raw);
|
|
53221
53780
|
if (!result.success) {
|
|
53222
|
-
return
|
|
53781
|
+
return mcp_config_defect(source, "invalid-schema");
|
|
53223
53782
|
}
|
|
53224
53783
|
const servers = {
|
|
53225
53784
|
...result.data.mcpServers ?? {},
|
|
53226
53785
|
...result.data.servers ?? {}
|
|
53227
53786
|
};
|
|
53228
|
-
return
|
|
53229
|
-
|
|
53230
|
-
|
|
53231
|
-
|
|
53232
|
-
|
|
53233
|
-
|
|
53234
|
-
|
|
53235
|
-
|
|
53236
|
-
|
|
53237
|
-
|
|
53787
|
+
return {
|
|
53788
|
+
records: Object.entries(servers).map(([serverName, entry])=>({
|
|
53789
|
+
serverName,
|
|
53790
|
+
harness: source.harnessHint,
|
|
53791
|
+
path: source.relPath,
|
|
53792
|
+
...entry.transport !== undefined ? {
|
|
53793
|
+
transport: entry.transport
|
|
53794
|
+
} : entry.type !== undefined ? {
|
|
53795
|
+
transport: entry.type
|
|
53796
|
+
} : {}
|
|
53797
|
+
})),
|
|
53798
|
+
defects: []
|
|
53799
|
+
};
|
|
53238
53800
|
}
|
|
53239
|
-
async function
|
|
53801
|
+
async function inspectMcpConfigs(repoRoot) {
|
|
53240
53802
|
const records = [];
|
|
53803
|
+
const defects = [];
|
|
53241
53804
|
for (const source of MCP_CONFIG_SOURCES){
|
|
53242
|
-
|
|
53805
|
+
const read = await readMcpServersFromSource(repoRoot, source);
|
|
53806
|
+
records.push(...read.records);
|
|
53807
|
+
defects.push(...read.defects);
|
|
53243
53808
|
}
|
|
53244
|
-
return
|
|
53809
|
+
return {
|
|
53810
|
+
records,
|
|
53811
|
+
defects
|
|
53812
|
+
};
|
|
53813
|
+
}
|
|
53814
|
+
async function enumerateMcpServers(repoRoot) {
|
|
53815
|
+
return [
|
|
53816
|
+
...(await inspectMcpConfigs(repoRoot)).records
|
|
53817
|
+
];
|
|
53245
53818
|
}
|
|
53246
53819
|
|
|
53247
53820
|
;// CONCATENATED MODULE: ../core/src/gateways/import-target-classifier.ts
|
|
@@ -53412,6 +53985,8 @@ async function enumerateMcpServers(repoRoot) {
|
|
|
53412
53985
|
|
|
53413
53986
|
|
|
53414
53987
|
|
|
53988
|
+
|
|
53989
|
+
|
|
53415
53990
|
const SCANNABLE_EXTENSIONS = new Set([
|
|
53416
53991
|
".md",
|
|
53417
53992
|
".mdc",
|
|
@@ -53424,34 +53999,20 @@ const SCANNABLE_EXTENSIONS = new Set([
|
|
|
53424
53999
|
const SCANNABLE_EXTENSIONLESS = new Set([
|
|
53425
54000
|
".cursorrules"
|
|
53426
54001
|
]);
|
|
53427
|
-
/** Doctor also skips build output, which the shared walk does not. */ const DOCTOR_SKIPPED_DIRECTORY_NAMES = [
|
|
54002
|
+
/** Doctor also skips build output, which the shared walk's default list does not. */ const DOCTOR_SKIPPED_DIRECTORY_NAMES = [
|
|
53428
54003
|
...DEFAULT_SKIPPED_DIRECTORY_NAMES,
|
|
53429
|
-
|
|
54004
|
+
...BUILD_OUTPUT_DIRECTORY_NAMES
|
|
53430
54005
|
];
|
|
53431
|
-
/**
|
|
53432
|
-
* True when `relativePath` is a fixture directory the walk met below the
|
|
53433
|
-
* scan root. The root itself is not passed here. When the relative path has
|
|
53434
|
-
* no parent segment, `rootDirectoryName` is that parent, so a scan started
|
|
53435
|
-
* in a directory named `tests` still skips its `fixtures` child.
|
|
53436
|
-
*
|
|
53437
|
-
* `tests/fixtures` is the parent and child, not every directory named
|
|
53438
|
-
* `fixtures`, so `src/fixtures` stays in the scan. `__fixtures__` and
|
|
53439
|
-
* `testdata` are names at any depth.
|
|
53440
|
-
*/ function isFixtureDirectory(relativePath, rootDirectoryName) {
|
|
53441
|
-
const segments = relativePath.split("/");
|
|
53442
|
-
const name = segments[segments.length - 1];
|
|
53443
|
-
if (name === "__fixtures__" || name === "testdata") {
|
|
53444
|
-
return true;
|
|
53445
|
-
}
|
|
53446
|
-
const parent = segments.length >= 2 ? segments[segments.length - 2] : rootDirectoryName;
|
|
53447
|
-
return parent === "tests" && name === "fixtures";
|
|
53448
|
-
}
|
|
53449
54006
|
function isScannableFile(name) {
|
|
53450
54007
|
if (SCANNABLE_EXTENSIONLESS.has(name)) return true;
|
|
53451
54008
|
const dot = name.lastIndexOf(".");
|
|
53452
54009
|
if (dot === -1) return false;
|
|
53453
54010
|
return SCANNABLE_EXTENSIONS.has(name.slice(dot).toLowerCase());
|
|
53454
54011
|
}
|
|
54012
|
+
function parentSegmentCount(relativePath) {
|
|
54013
|
+
const segments = relativePath.split("/").filter((segment)=>segment !== "");
|
|
54014
|
+
return Math.max(0, segments.length - 1);
|
|
54015
|
+
}
|
|
53455
54016
|
function toSourceFile(repoRoot, rootReal, file) {
|
|
53456
54017
|
return {
|
|
53457
54018
|
absPath: (0,external_node_path_.resolve)(repoRoot, file.relativePath),
|
|
@@ -53461,6 +54022,19 @@ function toSourceFile(repoRoot, rootReal, file) {
|
|
|
53461
54022
|
identity: file.identity
|
|
53462
54023
|
};
|
|
53463
54024
|
}
|
|
54025
|
+
/**
|
|
54026
|
+
* Adds the links a catalog walk skipped, leaving out a path already listed
|
|
54027
|
+
* and a path below one already listed. A catalog walk that starts below a
|
|
54028
|
+
* link out of the repository reports its own start directory, which is not
|
|
54029
|
+
* a link; the link itself is already in the list.
|
|
54030
|
+
*/ function appendSkippedLinks(skipped, additions) {
|
|
54031
|
+
for (const path of additions){
|
|
54032
|
+
const covered = skipped.some((listed)=>path === listed || path.startsWith(`${listed}/`));
|
|
54033
|
+
if (!covered) {
|
|
54034
|
+
skipped.push(path);
|
|
54035
|
+
}
|
|
54036
|
+
}
|
|
54037
|
+
}
|
|
53464
54038
|
/**
|
|
53465
54039
|
* Scans a repository into an inventory using the shared walk.
|
|
53466
54040
|
*
|
|
@@ -53486,7 +54060,55 @@ function toSourceFile(repoRoot, rootReal, file) {
|
|
|
53486
54060
|
maxEntries: options.maxEntries
|
|
53487
54061
|
}
|
|
53488
54062
|
});
|
|
53489
|
-
const
|
|
54063
|
+
const instructionWalks = await discoverInstructionLocations(absRoot, {
|
|
54064
|
+
rootDirectoryName: (0,external_node_path_.basename)(absRoot),
|
|
54065
|
+
maxDirectories,
|
|
54066
|
+
includeNestedWalk: false,
|
|
54067
|
+
...options.maxEntries === undefined ? {} : {
|
|
54068
|
+
maxEntries: options.maxEntries
|
|
54069
|
+
}
|
|
54070
|
+
});
|
|
54071
|
+
const knownPaths = new Set(walked.files.map((file)=>file.relativePath));
|
|
54072
|
+
const catalogLimits = {
|
|
54073
|
+
rootDirectoryName: (0,external_node_path_.basename)(absRoot),
|
|
54074
|
+
maxDirectories,
|
|
54075
|
+
...options.maxEntries === undefined ? {} : {
|
|
54076
|
+
maxEntries: options.maxEntries
|
|
54077
|
+
}
|
|
54078
|
+
};
|
|
54079
|
+
const agentWalk = await discoverAgentFiles(absRoot, catalogLimits);
|
|
54080
|
+
const subagentWalk = await discoverSubagentFiles(absRoot, catalogLimits);
|
|
54081
|
+
const deepConstructFiles = [
|
|
54082
|
+
...agentWalk.files,
|
|
54083
|
+
...subagentWalk.files
|
|
54084
|
+
];
|
|
54085
|
+
const beyondRootDepth = [
|
|
54086
|
+
...instructionWalks.filter((location)=>location.role === "catalog").flatMap((location)=>location.walked.files),
|
|
54087
|
+
...deepConstructFiles
|
|
54088
|
+
].filter((file)=>!knownPaths.has(file.relativePath) && parentSegmentCount(file.relativePath) > (/* inlined export .DEFAULT_MAX_WALK_DEPTH */10));
|
|
54089
|
+
// Files the root walk cannot reach are appended after its list, in the
|
|
54090
|
+
// catalog walk's order. They are not interleaved into that walk's order.
|
|
54091
|
+
const files = [
|
|
54092
|
+
...walked.files,
|
|
54093
|
+
...beyondRootDepth
|
|
54094
|
+
].map((file)=>toSourceFile(absRoot, rootReal, file));
|
|
54095
|
+
const catalogWalks = instructionWalks.filter((location)=>location.role === "catalog");
|
|
54096
|
+
const depthLimitReached = walked.depthLimitReached || catalogWalks.some((location)=>location.walked.depthLimitReached);
|
|
54097
|
+
const constructWalks = [
|
|
54098
|
+
agentWalk,
|
|
54099
|
+
subagentWalk
|
|
54100
|
+
];
|
|
54101
|
+
const directoryLimitReached = walked.directoryLimitReached || catalogWalks.some((location)=>location.walked.directoryLimitReached) || constructWalks.some((walk)=>walk.directoryLimitReached);
|
|
54102
|
+
const entryLimitReached = walked.entryLimitReached || catalogWalks.some((location)=>location.walked.entryLimitReached) || constructWalks.some((walk)=>walk.entryLimitReached);
|
|
54103
|
+
const skippedOutsideRoot = [
|
|
54104
|
+
...walked.skippedOutsideRoot
|
|
54105
|
+
];
|
|
54106
|
+
for (const location of catalogWalks){
|
|
54107
|
+
appendSkippedLinks(skippedOutsideRoot, location.walked.skippedOutsideRoot);
|
|
54108
|
+
}
|
|
54109
|
+
for (const walk of constructWalks){
|
|
54110
|
+
appendSkippedLinks(skippedOutsideRoot, walk.skippedOutsideRoot);
|
|
54111
|
+
}
|
|
53490
54112
|
const edgeContext = {
|
|
53491
54113
|
repoRoot: absRoot,
|
|
53492
54114
|
rootReal,
|
|
@@ -53496,29 +54118,32 @@ function toSourceFile(repoRoot, rootReal, file) {
|
|
|
53496
54118
|
})
|
|
53497
54119
|
};
|
|
53498
54120
|
const { records: fileRecords, filesOverImportLimit, unreadFiles } = await buildFileInventory(files, edgeContext, options.readContent);
|
|
53499
|
-
const
|
|
54121
|
+
const mcpConfigs = await inspectMcpConfigs(absRoot);
|
|
53500
54122
|
return {
|
|
53501
54123
|
records: [
|
|
53502
54124
|
...markReferencedRecords(fileRecords),
|
|
53503
|
-
...mcpServerRecords(
|
|
54125
|
+
...mcpServerRecords(mcpConfigs.records)
|
|
53504
54126
|
],
|
|
53505
|
-
...
|
|
54127
|
+
...mcpConfigs.defects.length > 0 ? {
|
|
54128
|
+
mcpConfigDefects: mcpConfigs.defects
|
|
54129
|
+
} : {},
|
|
54130
|
+
...directoryLimitReached ? {
|
|
53506
54131
|
directoryLimit: {
|
|
53507
54132
|
maxDirectories: walked.limits.maxDirectories
|
|
53508
54133
|
}
|
|
53509
54134
|
} : {},
|
|
53510
|
-
...
|
|
54135
|
+
...depthLimitReached ? {
|
|
53511
54136
|
depthLimit: {
|
|
53512
54137
|
maxDepth: walked.limits.maxDepth
|
|
53513
54138
|
}
|
|
53514
54139
|
} : {},
|
|
53515
|
-
...
|
|
54140
|
+
...entryLimitReached ? {
|
|
53516
54141
|
entryLimit: {
|
|
53517
54142
|
maxEntries: walked.limits.maxEntries
|
|
53518
54143
|
}
|
|
53519
54144
|
} : {},
|
|
53520
|
-
...
|
|
53521
|
-
skippedOutsideRoot
|
|
54145
|
+
...skippedOutsideRoot.length > 0 ? {
|
|
54146
|
+
skippedOutsideRoot
|
|
53522
54147
|
} : {},
|
|
53523
54148
|
...filesOverImportLimit.length > 0 ? {
|
|
53524
54149
|
importLimit: {
|
|
@@ -54350,6 +54975,36 @@ function evaluate(criteria, ctx) {
|
|
|
54350
54975
|
return findings;
|
|
54351
54976
|
}
|
|
54352
54977
|
|
|
54978
|
+
;// CONCATENATED MODULE: ../doctor/src/use-cases/mcp-config-finding.ts
|
|
54979
|
+
/**
|
|
54980
|
+
* Constant, content-free text per cause. Never built from the file's content
|
|
54981
|
+
* or an absolute path, so a finding cannot leak either.
|
|
54982
|
+
*/ const REASON_TEXT = {
|
|
54983
|
+
"invalid-json": "is not valid JSON",
|
|
54984
|
+
"invalid-schema": "does not match the MCP config schema",
|
|
54985
|
+
"reserved-name": "declares a reserved server name (__proto__, constructor, or prototype)",
|
|
54986
|
+
"too-large": "is larger than the 1 MiB size limit",
|
|
54987
|
+
symlink: "is a symbolic link, which doctor does not follow",
|
|
54988
|
+
unreadable: "exists but could not be read as a regular file"
|
|
54989
|
+
};
|
|
54990
|
+
/**
|
|
54991
|
+
* One high defect per malformed MCP config. The target is the repo-relative
|
|
54992
|
+
* path, so a longer path does not satisfy a shorter one. A missing file is
|
|
54993
|
+
* not a defect, and no server record is invented for a file that did not parse.
|
|
54994
|
+
*/ function mcpConfigFindings(defects) {
|
|
54995
|
+
return defects.map((defect)=>({
|
|
54996
|
+
id: `malformed-mcp-config:${defect.path}`,
|
|
54997
|
+
criterionId: "malformed-mcp-config",
|
|
54998
|
+
targetId: defect.path,
|
|
54999
|
+
severity: "high",
|
|
55000
|
+
category: "malformed-reference",
|
|
55001
|
+
classification: "defect",
|
|
55002
|
+
intentGated: false,
|
|
55003
|
+
assumedIntent: false,
|
|
55004
|
+
description: `The MCP config at ${defect.path} is malformed: it ${REASON_TEXT[defect.reason]}.`
|
|
55005
|
+
}));
|
|
55006
|
+
}
|
|
55007
|
+
|
|
54353
55008
|
;// CONCATENATED MODULE: ../doctor/src/use-cases/scan-notice-findings.ts
|
|
54354
55009
|
|
|
54355
55010
|
|
|
@@ -54393,6 +55048,7 @@ function evaluate(criteria, ctx) {
|
|
|
54393
55048
|
|
|
54394
55049
|
|
|
54395
55050
|
|
|
55051
|
+
|
|
54396
55052
|
async function loadIntent(repoPath, records, classification, ports) {
|
|
54397
55053
|
const loaded = await ports.readIntent(repoPath);
|
|
54398
55054
|
if (loaded.report.status !== "absent" || !ports.elicitIntent) {
|
|
@@ -54419,7 +55075,7 @@ async function loadIntent(repoPath, records, classification, ports) {
|
|
|
54419
55075
|
this.scanWarnings = scanWarnings;
|
|
54420
55076
|
}
|
|
54421
55077
|
}
|
|
54422
|
-
async function completeRun(input, ports, base) {
|
|
55078
|
+
async function completeRun(input, ports, base, mcpConfigDefects) {
|
|
54423
55079
|
const { records, classification } = base;
|
|
54424
55080
|
const snapshotRef = await ports.loadSnapshotRef(input.repoPath);
|
|
54425
55081
|
const withSnapshot = {
|
|
@@ -54428,25 +55084,29 @@ async function completeRun(input, ports, base) {
|
|
|
54428
55084
|
snapshotRef
|
|
54429
55085
|
} : {}
|
|
54430
55086
|
};
|
|
55087
|
+
const configFindings = mcpConfigFindings(mcpConfigDefects);
|
|
54431
55088
|
if (input.summaryOnly) {
|
|
54432
55089
|
return {
|
|
54433
55090
|
kind: "summary",
|
|
54434
55091
|
...withSnapshot
|
|
54435
55092
|
};
|
|
54436
55093
|
}
|
|
54437
|
-
if (classification.archetype === "none") {
|
|
55094
|
+
if (classification.archetype === "none" && configFindings.length === 0) {
|
|
54438
55095
|
return {
|
|
54439
55096
|
kind: "no-constructs",
|
|
54440
55097
|
...withSnapshot
|
|
54441
55098
|
};
|
|
54442
55099
|
}
|
|
54443
55100
|
const loaded = await loadIntent(input.repoPath, records, classification, ports);
|
|
54444
|
-
const findings =
|
|
54445
|
-
|
|
54446
|
-
|
|
54447
|
-
|
|
54448
|
-
|
|
54449
|
-
|
|
55101
|
+
const findings = [
|
|
55102
|
+
...evaluate(CRITERIA, {
|
|
55103
|
+
records,
|
|
55104
|
+
classification,
|
|
55105
|
+
intent: loaded.intent,
|
|
55106
|
+
intentLoadStatus: loaded.report.status
|
|
55107
|
+
}),
|
|
55108
|
+
...configFindings
|
|
55109
|
+
];
|
|
54450
55110
|
return {
|
|
54451
55111
|
kind: "evaluated",
|
|
54452
55112
|
...withSnapshot,
|
|
@@ -54467,7 +55127,7 @@ async function runDoctor(input, ports) {
|
|
|
54467
55127
|
]
|
|
54468
55128
|
};
|
|
54469
55129
|
try {
|
|
54470
|
-
return await completeRun(input, ports, base);
|
|
55130
|
+
return await completeRun(input, ports, base, scan.mcpConfigDefects ?? []);
|
|
54471
55131
|
} catch (error) {
|
|
54472
55132
|
throw new DoctorRunFailure(error, base.scanWarnings);
|
|
54473
55133
|
}
|
|
@@ -56101,82 +56761,6 @@ function diagnosticLines(output) {
|
|
|
56101
56761
|
}
|
|
56102
56762
|
}
|
|
56103
56763
|
|
|
56104
|
-
;// CONCATENATED MODULE: ../core/src/gateways/markdown-file-discovery.ts
|
|
56105
|
-
/**
|
|
56106
|
-
* Shared recursive markdown-file discovery for lint gateways that scan a
|
|
56107
|
-
* catalog root directory for `.md` files (agents, subagents). Guards
|
|
56108
|
-
* against path traversal and symlink escapes, and caps recursion depth to
|
|
56109
|
-
* avoid stack exhaustion on pathologically deep directory trees.
|
|
56110
|
-
*/
|
|
56111
|
-
|
|
56112
|
-
/** Maximum subdirectory nesting the walk will descend into. */ const MAX_WALK_DEPTH = 32;
|
|
56113
|
-
function markdown_file_discovery_isUnsafeEntryName(name) {
|
|
56114
|
-
return name.includes("..") || name.includes("/") || name.includes("\\");
|
|
56115
|
-
}
|
|
56116
|
-
function isWithinResolvedRoot(resolvedRootDir, absoluteEntryPath) {
|
|
56117
|
-
const resolvedPath = (0,external_node_path_.resolve)(absoluteEntryPath);
|
|
56118
|
-
const rel = (0,external_node_path_.relative)(resolvedRootDir, resolvedPath);
|
|
56119
|
-
return !rel.startsWith("..") && !rel.startsWith(external_node_path_.sep);
|
|
56120
|
-
}
|
|
56121
|
-
async function rootExists(targetDir, rootDir) {
|
|
56122
|
-
try {
|
|
56123
|
-
return await file_system_utils_pathExistsWithinRoot(targetDir, rootDir);
|
|
56124
|
-
} catch {
|
|
56125
|
-
return false;
|
|
56126
|
-
}
|
|
56127
|
-
}
|
|
56128
|
-
function isDiscoverableMarkdownFile(entry, name) {
|
|
56129
|
-
return entry.isFile() && name.endsWith(".md");
|
|
56130
|
-
}
|
|
56131
|
-
async function collectEntryFiles(targetDir, resolvedRootDir, dir, depth, entry, deriveName) {
|
|
56132
|
-
const name = entry.name;
|
|
56133
|
-
if (markdown_file_discovery_isUnsafeEntryName(name)) {
|
|
56134
|
-
return [];
|
|
56135
|
-
}
|
|
56136
|
-
const entryPath = (0,external_node_path_.join)(dir, name);
|
|
56137
|
-
const absoluteEntryPath = (0,external_node_path_.join)(targetDir, entryPath);
|
|
56138
|
-
if (!isWithinResolvedRoot(resolvedRootDir, absoluteEntryPath)) {
|
|
56139
|
-
return [];
|
|
56140
|
-
}
|
|
56141
|
-
if (entry.isSymbolicLink()) {
|
|
56142
|
-
return [];
|
|
56143
|
-
}
|
|
56144
|
-
if (entry.isDirectory()) {
|
|
56145
|
-
return walkMarkdownFiles(targetDir, resolvedRootDir, entryPath, depth + 1, deriveName);
|
|
56146
|
-
}
|
|
56147
|
-
if (!isDiscoverableMarkdownFile(entry, name)) {
|
|
56148
|
-
return [];
|
|
56149
|
-
}
|
|
56150
|
-
return [
|
|
56151
|
-
{
|
|
56152
|
-
filePath: absoluteEntryPath,
|
|
56153
|
-
name: deriveName(name)
|
|
56154
|
-
}
|
|
56155
|
-
];
|
|
56156
|
-
}
|
|
56157
|
-
async function walkMarkdownFiles(targetDir, resolvedRootDir, dir, depth, deriveName) {
|
|
56158
|
-
if (depth > MAX_WALK_DEPTH) {
|
|
56159
|
-
return [];
|
|
56160
|
-
}
|
|
56161
|
-
const entries = await file_system_utils_listDirectoryWithinRoot(targetDir, dir);
|
|
56162
|
-
const discovered = [];
|
|
56163
|
-
for (const entry of entries){
|
|
56164
|
-
const files = await collectEntryFiles(targetDir, resolvedRootDir, dir, depth, entry, deriveName);
|
|
56165
|
-
discovered.push(...files);
|
|
56166
|
-
}
|
|
56167
|
-
return discovered;
|
|
56168
|
-
}
|
|
56169
|
-
/**
|
|
56170
|
-
* Recursively discovers `.md` files under `rootDir` (relative to
|
|
56171
|
-
* `targetDir`). `deriveName` maps a filename to the construct name callers
|
|
56172
|
-
* use to identify the file (e.g. stripping `.md` or `.agent.md`).
|
|
56173
|
-
*/ async function discoverMarkdownFiles(targetDir, rootDir, deriveName) {
|
|
56174
|
-
if (!await rootExists(targetDir, rootDir)) {
|
|
56175
|
-
return [];
|
|
56176
|
-
}
|
|
56177
|
-
return walkMarkdownFiles(targetDir, (0,external_node_path_.resolve)(targetDir, rootDir), rootDir, 0, deriveName);
|
|
56178
|
-
}
|
|
56179
|
-
|
|
56180
56764
|
;// CONCATENATED MODULE: ../core/src/gateways/agent-lint-gateway.ts
|
|
56181
56765
|
/**
|
|
56182
56766
|
* Gateway for agent lint file system operations.
|
|
@@ -56185,26 +56769,33 @@ async function walkMarkdownFiles(targetDir, resolvedRootDir, dir, depth, deriveN
|
|
|
56185
56769
|
|
|
56186
56770
|
|
|
56187
56771
|
|
|
56188
|
-
|
|
56189
56772
|
/** Maximum agent file size: 1 MB */ const MAX_AGENT_FILE_BYTES = 1_048_576;
|
|
56190
|
-
/** Catalog agent roots converted to OS-native relative paths. */ const AGENT_DIRECTORIES = agentDirectoryRoots().map((root)=>(0,external_node_path_.join)(...root.split("/")));
|
|
56191
56773
|
/**
|
|
56192
56774
|
* File system implementation of the agent lint gateway.
|
|
56193
56775
|
*/ class FileSystemAgentLintGateway {
|
|
56194
|
-
|
|
56195
|
-
|
|
56196
|
-
|
|
56197
|
-
const discovered = await this.discoverAgentsInDir(targetDir, agentsDir);
|
|
56198
|
-
agents.push(...discovered);
|
|
56199
|
-
}
|
|
56200
|
-
return agents;
|
|
56776
|
+
limits;
|
|
56777
|
+
constructor(limits = {}){
|
|
56778
|
+
this.limits = limits;
|
|
56201
56779
|
}
|
|
56202
|
-
async
|
|
56203
|
-
const
|
|
56204
|
-
|
|
56205
|
-
|
|
56206
|
-
|
|
56207
|
-
|
|
56780
|
+
async discoverAgents(targetDir, onDiagnostic) {
|
|
56781
|
+
const walk = await discoverAgentFiles(targetDir, {
|
|
56782
|
+
rootDirectoryName: (0,external_node_path_.basename)((0,external_node_path_.resolve)(targetDir)),
|
|
56783
|
+
purpose: "lint",
|
|
56784
|
+
...this.limits
|
|
56785
|
+
});
|
|
56786
|
+
reportConstructLimits(walk, onDiagnostic, {
|
|
56787
|
+
subject: "Agent discovery",
|
|
56788
|
+
missing: "agent files",
|
|
56789
|
+
consequence: "were not analyzed"
|
|
56790
|
+
});
|
|
56791
|
+
const found = collapseToFirstRealFile(await omitSymlinkedPaths(targetDir, walk.files));
|
|
56792
|
+
return found.map((file)=>{
|
|
56793
|
+
const name = file.relativePath.split("/").at(-1) ?? "";
|
|
56794
|
+
return {
|
|
56795
|
+
filePath: (0,external_node_path_.join)(targetDir, ...file.relativePath.split("/")),
|
|
56796
|
+
agentName: name.endsWith(".agent.md") ? (0,external_node_path_.basename)(name, ".agent.md") : (0,external_node_path_.basename)(name, ".md")
|
|
56797
|
+
};
|
|
56798
|
+
});
|
|
56208
56799
|
}
|
|
56209
56800
|
async readAgentFileContent(filePath) {
|
|
56210
56801
|
return readFileNoFollow(filePath, MAX_AGENT_FILE_BYTES);
|
|
@@ -56372,11 +56963,13 @@ function collectResolvedImports(repoRoot, edges) {
|
|
|
56372
56963
|
*/
|
|
56373
56964
|
|
|
56374
56965
|
|
|
56966
|
+
|
|
56375
56967
|
/** Maximum hook config file size: 1 MB */ const MAX_CONFIG_FILE_BYTES = 1_048_576;
|
|
56376
56968
|
/** Matches the Copilot hook key `"preToolUse":` to detect hook section presence */ const COPILOT_HOOK_PATTERN = /"preToolUse"\s*:/;
|
|
56377
56969
|
/** Matches the Claude hook key `"hooks":` to detect hook section presence */ const CLAUDE_HOOK_PATTERN = /"hooks"\s*:/;
|
|
56378
56970
|
/** Catalog hook config paths converted to OS-native relative paths. */ const HOOK_CONFIG_PATHS = hookConfigPaths().map((entry)=>({
|
|
56379
56971
|
relativePath: (0,external_node_path_.join)(...entry.relativePath.split("/")),
|
|
56972
|
+
posixPath: entry.relativePath,
|
|
56380
56973
|
platform: entry.platform
|
|
56381
56974
|
}));
|
|
56382
56975
|
/**
|
|
@@ -56396,38 +56989,64 @@ function collectResolvedImports(repoRoot, edges) {
|
|
|
56396
56989
|
const hooks = parsed.hooks;
|
|
56397
56990
|
return hooks !== null && typeof hooks === "object" && !Array.isArray(hooks);
|
|
56398
56991
|
}
|
|
56992
|
+
/** Error messages that mean a hook config path must be left out, not fail the run. */ const UNSAFE_PATH_MESSAGE_PREFIXES = [
|
|
56993
|
+
"Resolved path is outside target directory:",
|
|
56994
|
+
"Path contains symbolic link:"
|
|
56995
|
+
];
|
|
56996
|
+
function isMissingPathError(error) {
|
|
56997
|
+
return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
|
|
56998
|
+
}
|
|
56999
|
+
function isUnsafePathError(error) {
|
|
57000
|
+
return error instanceof Error && UNSAFE_PATH_MESSAGE_PREFIXES.some((prefix)=>error.message.startsWith(prefix));
|
|
57001
|
+
}
|
|
57002
|
+
function isRejectedFileError(error) {
|
|
57003
|
+
return error instanceof Error && (error.message.startsWith("Symlinks are not allowed") || error.message.includes("exceeds size limit"));
|
|
57004
|
+
}
|
|
57005
|
+
/**
|
|
57006
|
+
* Resolves a catalog hook config path inside the target directory.
|
|
57007
|
+
* Returns undefined when the path is missing, leaves the directory, or
|
|
57008
|
+
* crosses a symbolic link. Any other failure is rethrown.
|
|
57009
|
+
*/ async function resolveHookConfigPath(targetDir, relativePath) {
|
|
57010
|
+
try {
|
|
57011
|
+
return await file_system_utils_resolveSafePath(targetDir, relativePath);
|
|
57012
|
+
} catch (error) {
|
|
57013
|
+
if (isMissingPathError(error) || isUnsafePathError(error)) {
|
|
57014
|
+
return undefined;
|
|
57015
|
+
}
|
|
57016
|
+
throw error;
|
|
57017
|
+
}
|
|
57018
|
+
}
|
|
57019
|
+
/**
|
|
57020
|
+
* Reads a hook config file without following symbolic links.
|
|
57021
|
+
* Returns undefined when the file is missing, is a symlink, or is too large.
|
|
57022
|
+
* Any other failure is rethrown.
|
|
57023
|
+
*/ async function readHookConfigContent(safePath) {
|
|
57024
|
+
try {
|
|
57025
|
+
return await readFileNoFollow(safePath, MAX_CONFIG_FILE_BYTES);
|
|
57026
|
+
} catch (error) {
|
|
57027
|
+
if (isMissingPathError(error) || isRejectedFileError(error)) {
|
|
57028
|
+
return undefined;
|
|
57029
|
+
}
|
|
57030
|
+
throw error;
|
|
57031
|
+
}
|
|
57032
|
+
}
|
|
56399
57033
|
/**
|
|
56400
57034
|
* File system implementation of the hook config lint gateway.
|
|
56401
57035
|
*/ class FileSystemHookConfigGateway {
|
|
56402
57036
|
async discoverHookFiles(targetDir) {
|
|
56403
57037
|
const discovered = [];
|
|
57038
|
+
const present = new Set(await discoverExactRegularFiles(targetDir, HOOK_CONFIG_PATHS.map((config)=>config.posixPath)));
|
|
56404
57039
|
for (const config of HOOK_CONFIG_PATHS){
|
|
56405
|
-
|
|
56406
|
-
|
|
56407
|
-
safePath = await file_system_utils_resolveSafePath(targetDir, config.relativePath);
|
|
56408
|
-
} catch (error) {
|
|
56409
|
-
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
|
56410
|
-
continue;
|
|
56411
|
-
}
|
|
56412
|
-
if (error instanceof Error && (error.message.startsWith("Resolved path is outside target directory:") || error.message.startsWith("Path contains symbolic link:"))) {
|
|
56413
|
-
continue;
|
|
56414
|
-
}
|
|
56415
|
-
throw error;
|
|
57040
|
+
if (!present.has(config.posixPath)) {
|
|
57041
|
+
continue;
|
|
56416
57042
|
}
|
|
56417
|
-
|
|
56418
|
-
|
|
56419
|
-
|
|
56420
|
-
}
|
|
56421
|
-
|
|
56422
|
-
|
|
56423
|
-
|
|
56424
|
-
if (error instanceof Error && error.message.startsWith("Symlinks are not allowed")) {
|
|
56425
|
-
continue;
|
|
56426
|
-
}
|
|
56427
|
-
if (error instanceof Error && error.message.includes("exceeds size limit")) {
|
|
56428
|
-
continue;
|
|
56429
|
-
}
|
|
56430
|
-
throw error;
|
|
57043
|
+
const safePath = await resolveHookConfigPath(targetDir, config.relativePath);
|
|
57044
|
+
if (safePath === undefined) {
|
|
57045
|
+
continue;
|
|
57046
|
+
}
|
|
57047
|
+
const content = await readHookConfigContent(safePath);
|
|
57048
|
+
if (content === undefined) {
|
|
57049
|
+
continue;
|
|
56431
57050
|
}
|
|
56432
57051
|
if (this.mayContainHookSection(content, config.platform)) {
|
|
56433
57052
|
discovered.push({
|
|
@@ -77980,57 +78599,19 @@ const HEADING_PATTERN_DESCRIPTIONS = new Map(Object.entries(HEADING_PATTERN_DESC
|
|
|
77980
78599
|
*/
|
|
77981
78600
|
|
|
77982
78601
|
|
|
78602
|
+
|
|
77983
78603
|
/** Maximum MCP config file size: 1 MB */ const MAX_MCP_CONFIG_FILE_BYTES = 1_048_576;
|
|
77984
|
-
/** Catalog MCP config paths converted to OS-native relative paths. */ const MCP_CONFIG_RELATIVE_PATHS = MCP_CONFIG_SOURCES.map((source)=>(0,external_node_path_.join)(...source.relPath.split("/")));
|
|
77985
|
-
const SKIPPABLE_PATH_ERROR_PREFIXES = [
|
|
77986
|
-
"Resolved path is outside target directory:",
|
|
77987
|
-
"Path contains symbolic link:"
|
|
77988
|
-
];
|
|
77989
|
-
function isSkippablePathError(error) {
|
|
77990
|
-
if (!(error instanceof Error)) {
|
|
77991
|
-
return false;
|
|
77992
|
-
}
|
|
77993
|
-
return SKIPPABLE_PATH_ERROR_PREFIXES.some((prefix)=>error.message.startsWith(prefix));
|
|
77994
|
-
}
|
|
77995
|
-
async function pathExistsSafely(targetDir, relativePath) {
|
|
77996
|
-
try {
|
|
77997
|
-
return await file_system_utils_pathExistsWithinRoot(targetDir, relativePath);
|
|
77998
|
-
} catch {
|
|
77999
|
-
return false;
|
|
78000
|
-
}
|
|
78001
|
-
}
|
|
78002
|
-
async function resolveConfigPathOrNull(targetDir, relativePath) {
|
|
78003
|
-
try {
|
|
78004
|
-
return await file_system_utils_resolveSafePath(targetDir, relativePath);
|
|
78005
|
-
} catch (error) {
|
|
78006
|
-
if (isSkippablePathError(error)) {
|
|
78007
|
-
return null;
|
|
78008
|
-
}
|
|
78009
|
-
throw error;
|
|
78010
|
-
}
|
|
78011
|
-
}
|
|
78012
|
-
/**
|
|
78013
|
-
* Resolves a config path within the target directory, returning null when the
|
|
78014
|
-
* path is missing or escapes the root via traversal/symlink.
|
|
78015
|
-
*/ async function tryResolveConfigPath(targetDir, relativePath) {
|
|
78016
|
-
if (!await pathExistsSafely(targetDir, relativePath)) {
|
|
78017
|
-
return null;
|
|
78018
|
-
}
|
|
78019
|
-
return resolveConfigPathOrNull(targetDir, relativePath);
|
|
78020
|
-
}
|
|
78021
78604
|
/**
|
|
78022
78605
|
* File system implementation of the MCP server lint gateway.
|
|
78023
78606
|
*/ class FileSystemMcpServersLintGateway {
|
|
78024
78607
|
async discoverMcpConfigFiles(targetDir) {
|
|
78025
78608
|
const discovered = [];
|
|
78026
|
-
|
|
78027
|
-
|
|
78028
|
-
|
|
78029
|
-
continue;
|
|
78030
|
-
}
|
|
78609
|
+
const posixPaths = MCP_CONFIG_SOURCES.map((source)=>source.relPath);
|
|
78610
|
+
const present = await discoverExactRegularFiles(targetDir, posixPaths);
|
|
78611
|
+
for (const relativePath of present){
|
|
78031
78612
|
discovered.push({
|
|
78032
|
-
filePath:
|
|
78033
|
-
relativePath
|
|
78613
|
+
filePath: (0,external_node_path_.join)(targetDir, ...relativePath.split("/")),
|
|
78614
|
+
relativePath: (0,external_node_path_.join)(...relativePath.split("/"))
|
|
78034
78615
|
});
|
|
78035
78616
|
}
|
|
78036
78617
|
return discovered;
|
|
@@ -78053,26 +78634,33 @@ async function resolveConfigPathOrNull(targetDir, relativePath) {
|
|
|
78053
78634
|
|
|
78054
78635
|
|
|
78055
78636
|
|
|
78056
|
-
|
|
78057
78637
|
/** Maximum subagent file size: 1 MB */ const MAX_SUBAGENT_FILE_BYTES = 1_048_576;
|
|
78058
|
-
/** Catalog subagent roots converted to OS-native relative paths. */ const SUBAGENT_DIRECTORIES = subagentDirectoryRoots().map((root)=>(0,external_node_path_.join)(...root.split("/")));
|
|
78059
78638
|
/**
|
|
78060
78639
|
* File system implementation of the subagent lint gateway.
|
|
78061
78640
|
*/ class FileSystemSubagentLintGateway {
|
|
78062
|
-
|
|
78063
|
-
|
|
78064
|
-
|
|
78065
|
-
const discovered = await this.discoverSubagentsInDir(targetDir, subagentsDir);
|
|
78066
|
-
subagents.push(...discovered);
|
|
78067
|
-
}
|
|
78068
|
-
return subagents;
|
|
78641
|
+
limits;
|
|
78642
|
+
constructor(limits = {}){
|
|
78643
|
+
this.limits = limits;
|
|
78069
78644
|
}
|
|
78070
|
-
async
|
|
78071
|
-
const
|
|
78072
|
-
|
|
78073
|
-
|
|
78074
|
-
|
|
78075
|
-
|
|
78645
|
+
async discoverSubagents(targetDir, onDiagnostic) {
|
|
78646
|
+
const walk = await discoverSubagentFiles(targetDir, {
|
|
78647
|
+
rootDirectoryName: (0,external_node_path_.basename)((0,external_node_path_.resolve)(targetDir)),
|
|
78648
|
+
purpose: "lint",
|
|
78649
|
+
...this.limits
|
|
78650
|
+
});
|
|
78651
|
+
reportConstructLimits(walk, onDiagnostic, {
|
|
78652
|
+
subject: "Subagent discovery",
|
|
78653
|
+
missing: "subagent files",
|
|
78654
|
+
consequence: "were not analyzed"
|
|
78655
|
+
});
|
|
78656
|
+
const found = collapseToFirstRealFile(await omitSymlinkedPaths(targetDir, walk.files));
|
|
78657
|
+
return found.map((file)=>{
|
|
78658
|
+
const name = file.relativePath.split("/").at(-1) ?? "";
|
|
78659
|
+
return {
|
|
78660
|
+
filePath: (0,external_node_path_.join)(targetDir, ...file.relativePath.split("/")),
|
|
78661
|
+
subagentName: (0,external_node_path_.basename)(name, ".md")
|
|
78662
|
+
};
|
|
78663
|
+
});
|
|
78076
78664
|
}
|
|
78077
78665
|
async readSubagentFileContent(filePath) {
|
|
78078
78666
|
return readFileNoFollow(filePath, MAX_SUBAGENT_FILE_BYTES);
|
|
@@ -78262,7 +78850,12 @@ async function resolveConfigPathOrNull(targetDir, relativePath) {
|
|
|
78262
78850
|
if (!input.targetDir) {
|
|
78263
78851
|
throw new Error("Target directory is required");
|
|
78264
78852
|
}
|
|
78265
|
-
const
|
|
78853
|
+
const discoveryDiagnostics = [];
|
|
78854
|
+
const agents = await this.gateway.discoverAgents(input.targetDir, (diagnostic)=>discoveryDiagnostics.push({
|
|
78855
|
+
filePath: input.targetDir,
|
|
78856
|
+
ruleId: diagnostic.ruleId,
|
|
78857
|
+
message: diagnostic.message
|
|
78858
|
+
}));
|
|
78266
78859
|
const results = [];
|
|
78267
78860
|
for (const agent of agents){
|
|
78268
78861
|
const content = await this.gateway.readAgentFileContent(agent.filePath);
|
|
@@ -78275,7 +78868,10 @@ async function resolveConfigPathOrNull(targetDir, relativePath) {
|
|
|
78275
78868
|
results,
|
|
78276
78869
|
totalAgents: agents.length,
|
|
78277
78870
|
totalErrors,
|
|
78278
|
-
totalWarnings
|
|
78871
|
+
totalWarnings: totalWarnings + discoveryDiagnostics.length,
|
|
78872
|
+
...discoveryDiagnostics.length > 0 ? {
|
|
78873
|
+
discoveryDiagnostics
|
|
78874
|
+
} : {}
|
|
78279
78875
|
};
|
|
78280
78876
|
}
|
|
78281
78877
|
lintAgent(agent, content) {
|
|
@@ -78758,6 +79354,7 @@ const INVALID_JSON_MESSAGE_PREFIX = "Invalid JSON in hook configuration file";
|
|
|
78758
79354
|
* Code's `.vscode/mcp.json` convention) is a map of server name to a
|
|
78759
79355
|
* server declaration.
|
|
78760
79356
|
*/
|
|
79357
|
+
|
|
78761
79358
|
const lint_mcp_servers_INVALID_JSON_MESSAGE_PREFIX = "Invalid JSON in MCP server configuration file";
|
|
78762
79359
|
/**
|
|
78763
79360
|
* Property names that must never be used as MCP server names: assigning
|
|
@@ -78775,20 +79372,6 @@ const lint_mcp_servers_SERVER_MAP_FIELDS = [
|
|
|
78775
79372
|
"mcpServers",
|
|
78776
79373
|
"servers"
|
|
78777
79374
|
];
|
|
78778
|
-
/**
|
|
78779
|
-
* Zod schema for a single MCP server declaration.
|
|
78780
|
-
* Baseline shape only: an object whose optional `type`/`transport` fields,
|
|
78781
|
-
* when present, must be non-empty strings. Unknown fields are preserved.
|
|
78782
|
-
*/ const lint_mcp_servers_McpServerEntrySchema = schemas_object({
|
|
78783
|
-
type: schemas_string().min(1, "type must not be empty").optional(),
|
|
78784
|
-
transport: schemas_string().min(1, "transport must not be empty").optional()
|
|
78785
|
-
}).passthrough();
|
|
78786
|
-
/**
|
|
78787
|
-
* Zod schema for the MCP config file shape.
|
|
78788
|
-
*/ const lint_mcp_servers_McpConfigSchema = schemas_object({
|
|
78789
|
-
mcpServers: schemas_record(schemas_string(), lint_mcp_servers_McpServerEntrySchema).optional(),
|
|
78790
|
-
servers: schemas_record(schemas_string(), lint_mcp_servers_McpServerEntrySchema).optional()
|
|
78791
|
-
}).passthrough();
|
|
78792
79375
|
function lint_mcp_servers_isPlainObject(value) {
|
|
78793
79376
|
return typeof value === "object" && value !== null;
|
|
78794
79377
|
}
|
|
@@ -78899,7 +79482,7 @@ function countBySeverity(results, severity) {
|
|
|
78899
79482
|
if (reservedNameDiagnostics.length > 0) {
|
|
78900
79483
|
return invalidConfigResult(file.filePath, reservedNameDiagnostics);
|
|
78901
79484
|
}
|
|
78902
|
-
const result =
|
|
79485
|
+
const result = McpConfigSchema.safeParse(parsed);
|
|
78903
79486
|
if (!result.success) {
|
|
78904
79487
|
return invalidConfigResult(file.filePath, zodIssuesToDiagnostics(result.error.issues));
|
|
78905
79488
|
}
|
|
@@ -78946,7 +79529,12 @@ class LintSkillFrontmatterUseCase {
|
|
|
78946
79529
|
if (!input.targetDir) {
|
|
78947
79530
|
throw new Error("Target directory is required");
|
|
78948
79531
|
}
|
|
78949
|
-
const
|
|
79532
|
+
const discoveryDiagnostics = [];
|
|
79533
|
+
const skills = await this.gateway.discoverSkills(input.targetDir, (diagnostic)=>discoveryDiagnostics.push({
|
|
79534
|
+
filePath: input.targetDir,
|
|
79535
|
+
ruleId: diagnostic.ruleId,
|
|
79536
|
+
message: diagnostic.message
|
|
79537
|
+
}));
|
|
78950
79538
|
const results = [];
|
|
78951
79539
|
for (const skill of skills){
|
|
78952
79540
|
const content = await this.gateway.readSkillFileContent(skill.filePath);
|
|
@@ -78959,7 +79547,10 @@ class LintSkillFrontmatterUseCase {
|
|
|
78959
79547
|
results,
|
|
78960
79548
|
totalSkills: skills.length,
|
|
78961
79549
|
totalErrors,
|
|
78962
|
-
totalWarnings
|
|
79550
|
+
totalWarnings: totalWarnings + discoveryDiagnostics.length,
|
|
79551
|
+
...discoveryDiagnostics.length > 0 ? {
|
|
79552
|
+
discoveryDiagnostics
|
|
79553
|
+
} : {}
|
|
78963
79554
|
};
|
|
78964
79555
|
}
|
|
78965
79556
|
lintSkill(skill, content) {
|
|
@@ -79097,7 +79688,12 @@ function hasFrontmatterDelimiters(content) {
|
|
|
79097
79688
|
if (!input.targetDir) {
|
|
79098
79689
|
throw new Error("Target directory is required");
|
|
79099
79690
|
}
|
|
79100
|
-
const
|
|
79691
|
+
const discoveryDiagnostics = [];
|
|
79692
|
+
const subagents = await this.gateway.discoverSubagents(input.targetDir, (diagnostic)=>discoveryDiagnostics.push({
|
|
79693
|
+
filePath: input.targetDir,
|
|
79694
|
+
ruleId: diagnostic.ruleId,
|
|
79695
|
+
message: diagnostic.message
|
|
79696
|
+
}));
|
|
79101
79697
|
const results = [];
|
|
79102
79698
|
for (const subagent of subagents){
|
|
79103
79699
|
const content = await this.gateway.readSubagentFileContent(subagent.filePath);
|
|
@@ -79110,7 +79706,10 @@ function hasFrontmatterDelimiters(content) {
|
|
|
79110
79706
|
results,
|
|
79111
79707
|
totalSubagents: subagents.length,
|
|
79112
79708
|
totalErrors,
|
|
79113
|
-
totalWarnings
|
|
79709
|
+
totalWarnings: totalWarnings + discoveryDiagnostics.length,
|
|
79710
|
+
...discoveryDiagnostics.length > 0 ? {
|
|
79711
|
+
discoveryDiagnostics
|
|
79712
|
+
} : {}
|
|
79114
79713
|
};
|
|
79115
79714
|
}
|
|
79116
79715
|
lintSubagent(subagent, content) {
|
|
@@ -79382,6 +79981,16 @@ const LintOptionsSchema = schemas_object({
|
|
|
79382
79981
|
});
|
|
79383
79982
|
}
|
|
79384
79983
|
}
|
|
79984
|
+
for (const report of output.discoveryDiagnostics ?? []){
|
|
79985
|
+
diagnostics.push({
|
|
79986
|
+
filePath: report.filePath,
|
|
79987
|
+
line: 1,
|
|
79988
|
+
severity: "warning",
|
|
79989
|
+
message: report.message,
|
|
79990
|
+
ruleId: report.ruleId,
|
|
79991
|
+
target
|
|
79992
|
+
});
|
|
79993
|
+
}
|
|
79385
79994
|
return {
|
|
79386
79995
|
diagnostics,
|
|
79387
79996
|
target,
|
|
@@ -88948,4 +89557,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
88948
89557
|
// module factories are used so entry inlining is disabled
|
|
88949
89558
|
// startup
|
|
88950
89559
|
// Load entry module and return exports
|
|
88951
|
-
var __webpack_exports__ = __webpack_require__(
|
|
89560
|
+
var __webpack_exports__ = __webpack_require__(5219);
|