claudeRuleScan.ts ×3

Frontier kind: Code frontier

unlabeled · c_05772da43167

228 tests · 18609 LOC · 67 files · introduces 0 tests · 48 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges48 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1831 ranges18609 lines · 67 files · Browse complete extent
All tests (intent)
228 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 48 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/customizations/scan/claudeRuleScan.ts 48 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- claudeRuleScan.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { URI } from '../../../../../../base/common/uri.js';
7 > import { basename } from '../../../../../../base/common/resources.js';
8 > import { IFileService } from '../../../../../files/common/files.js';
9 > import { parseRuleFile, pathExists, type IParsedRule } from '../../../../../agentPlugins/common/pluginParsers.js';
10 > import { CustomizationType } from '../../../../common/state/protocol/channels-session/state.js';
11 > import { customizationId, type RuleCustomization } from '../../../../common/state/sessionState.js';
12 >
13 > /**
14 > * The CLAUDE.md memory files a session loads as always-on rules. The
15 > * documented primary locations only — user `~/.claude/CLAUDE.md`, project
16 > * `./CLAUDE.md` / `./.claude/CLAUDE.md`, and the personal `./CLAUDE.local.md`.
17 > * (Managed-policy OS-level CLAUDE.md and the ancestor-directory walk are
18 > * intentionally out of scope.)
19 > *
20 > * Exported so the change-watcher can reuse the exact same list and never
21 > * drift from what {@link scanClaudeRules} actually reads.
22 > */
23 > export function claudeMemoryFiles(workingDirectory: URI | undefined, userHome: URI): URI[] {
24 const files = [URI.joinPath(userHome, '.claude', 'CLAUDE.md')];
25 if (workingDirectory) {
32 return files;
33 }
35 > /**
36 > * Recursively collects `*.md` files under `dir` (sorted by path). Follows
37 > * symlinked subdirectories — `.claude/rules` supports them — with a
38 > * visited-set guard plus a hard depth cap so circular symlinks terminate.
39 > * (The visited-set alone is insufficient: a symlink cycle like
40 > * `rules/a -> rules` produces an ever-deeper, never-repeating path, so the
41 > * depth cap is the real termination guarantee.)
42 > */
43 > const MAX_RULE_SCAN_DEPTH = 32;
44 >
45 async function readMarkdownFilesRecursive(dir: URI, fileService: IFileService, seen = new Set<string>(), depth = 0): Promise<URI[]> {
46 const key = dir.toString();
70 return files.sort((a, b) => a.path.localeCompare(b.path));
71 }
73 > /**
74 > * Scans a session's Claude "memory" rules — the {@link CustomizationType.Rule}
75 > * tier — from both forms:
76 > * - CLAUDE.md instruction files ({@link claudeMemoryFiles}): always-on,
77 > * no path scoping.
78 > * - `.claude/rules/**\/*.md` (project + user, recursive): path-scoped when
79 > * a `paths` frontmatter glob is present (parsed via {@link parseRuleFile}),
80 > * otherwise always-on.
81 > *
82 > * Each rule carries its real source-file `uri` so the workbench can open it
83 > * for editing. Rules are additive (not deduped by name) — the SDK has no
84 > * rule concept, so they are never filtered post-materialize.
85 > */
86 export async function scanClaudeRules(
87 workingDirectory: URI | undefined,