Skip to content

Commit 5cb8c0a

Browse files
committed
feat(codebase): add ignored property to CodebaseTreeNode and update parameter names in codebaseGetOverview
1 parent f18f2e7 commit 5cb8c0a

2 files changed

Lines changed: 22 additions & 27 deletions

File tree

src/client-pipe.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export interface CodebaseTreeNode {
233233
children?: CodebaseTreeNode[];
234234
symbols?: CodebaseSymbolNode[];
235235
lineCount?: number;
236+
ignored?: boolean;
236237
}
237238

238239
export interface CodebaseOverviewResult {
@@ -388,16 +389,16 @@ export interface CodebaseTraceSymbolResult {
388389
*/
389390
export async function codebaseGetOverview(
390391
rootDir: string,
391-
folderPath: string,
392+
dir: string,
392393
recursive: boolean,
393-
fileTypes: string | string[],
394394
symbols: boolean,
395395
timeout?: number,
396396
metadata?: boolean,
397+
toolScope?: string,
397398
): Promise<CodebaseOverviewResult> {
398399
const result = await sendClientRequest(
399400
'codebase.getOverview',
400-
{rootDir, folderPath, recursive, fileTypes, symbols, metadata},
401+
{rootDir, dir, recursive, symbols, metadata, toolScope},
401402
timeout ?? 30_000,
402403
);
403404
assertResult<CodebaseOverviewResult>(result, 'codebase.getOverview');

src/tools/codebase/codebase-map.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ function formatTree(
9999
const indent = INDENT.repeat(depth);
100100

101101
for (const node of nodes) {
102+
if (node.ignored) {
103+
const suffix = node.type === 'directory' ? `${node.name}/` : node.name;
104+
output += `${indent}[Ignored] ${suffix}\n`;
105+
continue;
106+
}
107+
102108
if (node.type === 'directory') {
103109
const willRecurse = !!node.children?.length
104110
&& (opts.maxFolderDepth === undefined || depth < opts.maxFolderDepth);
@@ -194,19 +200,16 @@ export const map = defineTool({
194200
description: 'Get a structural map of the codebase at any granularity — folders, files, or symbols.\n\n' +
195201
'Returns a tree with folders ending in `/`, files with extensions, and symbols as `kind name`.\n\n' +
196202
'**Parameters:**\n' +
197-
'- `folderPath` — Folder to map (relative or absolute). Defaults to workspace root.\n' +
203+
'- `dir` — Folder to map (relative or absolute). Defaults to workspace root.\n' +
198204
'- `recursive` — Include subdirectories recursively. Default: false (immediate children only).\n' +
199-
'- `fileTypes` — Which files to include: `"*"` (all), `"none"` (folders only), or array of extensions.\n' +
200205
'- `symbols` — Include symbol skeleton (name + kind, hierarchically nested). Default: false.\n' +
201206
'- `metadata` — Show counts per file/folder. Key: F=files, D=directories, L=lines, S=symbols. Example: `[5F|3D]` = 5 files, 3 dirs. `[61L|25S]` = 61 lines, 25 symbols. Default: false.\n\n' +
202207
'**EXAMPLES:**\n' +
203208
'- Shallow view of root: `{}`\n' +
204209
'- Full project tree: `{ recursive: true }`\n' +
205-
'- Only TypeScript files: `{ fileTypes: [".ts"], recursive: true }`\n' +
206-
'- Folder structure only: `{ fileTypes: "none", recursive: true }`\n' +
207-
'- Specific folder with symbols: `{ folderPath: "src", recursive: true, symbols: true }`\n' +
210+
'- Specific folder with symbols: `{ dir: "src", recursive: true, symbols: true }`\n' +
208211
'- Tree with metadata: `{ recursive: true, metadata: true }`\n' +
209-
'- Only CSS files in a subfolder: `{ folderPath: "src/styles", fileTypes: [".css", ".scss"] }`',
212+
'- Only a subfolder: `{ dir: "src/styles", recursive: true }`',
210213
annotations: {
211214
title: 'Codebase Map',
212215
category: ToolCategory.CODEBASE_ANALYSIS,
@@ -217,19 +220,12 @@ export const map = defineTool({
217220
conditions: ['client-pipe', 'codebase-sequential'],
218221
},
219222
schema: {
220-
folderPath: zod.string().optional()
223+
dir: zod.string().optional()
221224
.describe('Folder to map. Relative to workspace root or absolute. Defaults to workspace root.'),
222225

223226
recursive: zod.boolean().optional()
224227
.describe('Include subdirectories recursively. Default: false (immediate children only).'),
225228

226-
fileTypes: zod.union([
227-
zod.literal('*'),
228-
zod.literal('none'),
229-
zod.array(zod.string()),
230-
]).optional()
231-
.describe('"*" = all files (default), "none" = folders only, or array of extensions like [".ts", ".md"].'),
232-
233229
symbols: zod.boolean().optional()
234230
.describe('Include symbol skeleton (name + kind, hierarchically nested). Default: false.'),
235231

@@ -241,12 +237,10 @@ export const map = defineTool({
241237
response.setSkipLedger();
242238

243239
const rootDir = getClientWorkspace();
244-
const folderPath = params.folderPath ?? rootDir;
240+
const dir = params.dir ?? rootDir;
245241
const recursive = params.recursive ?? false;
246-
const fileTypes = params.fileTypes ?? '*';
247242
const symbols = params.symbols ?? false;
248243
const metadata = params.metadata ?? false;
249-
const isNone = fileTypes === 'none';
250244

251245
// Dynamic timeout based on request scope
252246
const dynamicTimeout =
@@ -256,15 +250,15 @@ export const map = defineTool({
256250

257251
const overviewResult = await codebaseGetOverview(
258252
rootDir,
259-
folderPath,
253+
dir,
260254
recursive,
261-
fileTypes,
262255
symbols,
263256
dynamicTimeout,
264257
metadata,
258+
'codebase_map',
265259
);
266260

267-
if (overviewResult.summary.totalFiles === 0 && !isNone) {
261+
if (overviewResult.summary.totalFiles === 0) {
268262
const ignoreContext = readIgnoreContext(overviewResult.projectRoot);
269263
response.appendResponseLine('No files found. Check scope patterns or .devtoolsignore.\n');
270264
if (ignoreContext.activePatterns.length > 0) {
@@ -286,7 +280,7 @@ export const map = defineTool({
286280

287281
// Quick check: does the full output fit without any compression?
288282
const fullOutput = formatTree(tree, {
289-
showFiles: !isNone,
283+
showFiles: true,
290284
showSymbols: symbols,
291285
metadata: metadata,
292286
});
@@ -313,7 +307,7 @@ export const map = defineTool({
313307
if (fd === 0) {
314308
response.appendResponseLine(
315309
'Error: the folder structure at the root level alone exceeds the output limit. ' +
316-
'Try targeting a specific subfolder with the folderPath parameter.\n',
310+
'Try targeting a specific subfolder with the dir parameter.\n',
317311
);
318312
return;
319313
}
@@ -327,7 +321,7 @@ export const map = defineTool({
327321

328322
// Phase 2: Files — expand per folder depth level
329323
let fileLimit = -1;
330-
if (!compressionLabel && !isNone) {
324+
if (!compressionLabel) {
331325
for (let fd = 0; fd <= folderLimit; fd++) {
332326
const candidate = formatTree(tree, {
333327
showFiles: true, showSymbols: false, metadata: metaMode,
@@ -427,7 +421,7 @@ export const map = defineTool({
427421
if (compressionLabel) {
428422
response.appendResponseLine(
429423
`Output compressed: ${compressionLabel}. ` +
430-
'Use folderPath to target a specific subfolder, or file_read for full file details.\n',
424+
'Use dir to target a specific subfolder, or file_read for full file details.\n',
431425
);
432426
}
433427

0 commit comments

Comments
 (0)