token-pilot 0.12.0 → 0.14.1
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/.claude-plugin/hooks/hooks.json +9 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +30 -1
- package/README.md +28 -7
- package/dist/config/defaults.js +12 -0
- package/dist/core/architecture-fingerprint.d.ts +34 -0
- package/dist/core/architecture-fingerprint.js +127 -0
- package/dist/core/budget-planner.d.ts +21 -0
- package/dist/core/budget-planner.js +68 -0
- package/dist/core/confidence.d.ts +31 -0
- package/dist/core/confidence.js +99 -0
- package/dist/core/context-registry.d.ts +14 -0
- package/dist/core/context-registry.js +55 -0
- package/dist/core/decision-trace.d.ts +31 -0
- package/dist/core/decision-trace.js +45 -0
- package/dist/core/intent-classifier.d.ts +13 -0
- package/dist/core/intent-classifier.js +44 -0
- package/dist/core/policy-engine.d.ts +41 -0
- package/dist/core/policy-engine.js +76 -0
- package/dist/core/session-analytics.d.ts +8 -0
- package/dist/core/session-analytics.js +86 -7
- package/dist/core/session-cache.d.ts +74 -0
- package/dist/core/session-cache.js +162 -0
- package/dist/core/validation.d.ts +3 -0
- package/dist/core/validation.js +3 -0
- package/dist/git/file-watcher.d.ts +6 -0
- package/dist/git/file-watcher.js +18 -2
- package/dist/git/watcher.d.ts +3 -0
- package/dist/git/watcher.js +6 -0
- package/dist/handlers/code-audit.d.ts +7 -2
- package/dist/handlers/code-audit.js +19 -5
- package/dist/handlers/explore-area.d.ts +10 -0
- package/dist/handlers/explore-area.js +39 -13
- package/dist/handlers/find-unused.d.ts +3 -0
- package/dist/handlers/find-unused.js +3 -2
- package/dist/handlers/find-usages.d.ts +7 -0
- package/dist/handlers/find-usages.js +36 -5
- package/dist/handlers/module-info.d.ts +3 -0
- package/dist/handlers/module-info.js +22 -2
- package/dist/handlers/project-overview.d.ts +1 -1
- package/dist/handlers/project-overview.js +18 -2
- package/dist/handlers/read-for-edit.d.ts +3 -0
- package/dist/handlers/read-for-edit.js +185 -3
- package/dist/handlers/read-range.d.ts +1 -1
- package/dist/handlers/read-range.js +16 -1
- package/dist/handlers/read-symbol.d.ts +1 -1
- package/dist/handlers/read-symbol.js +26 -2
- package/dist/handlers/related-files.d.ts +11 -0
- package/dist/handlers/related-files.js +178 -42
- package/dist/handlers/smart-read-many.js +70 -16
- package/dist/handlers/smart-read.js +10 -1
- package/dist/handlers/test-summary.js +26 -3
- package/dist/hooks/installer.d.ts +12 -8
- package/dist/hooks/installer.js +24 -8
- package/dist/index.d.ts +16 -1
- package/dist/index.js +61 -55
- package/dist/server.js +395 -30
- package/dist/types.d.ts +12 -0
- package/package.json +5 -3
- package/start.sh +28 -27
- package/dist/handlers/class-hierarchy.d.ts +0 -11
- package/dist/handlers/class-hierarchy.js +0 -28
- package/dist/handlers/export-ast-index.d.ts +0 -22
- package/dist/handlers/export-ast-index.js +0 -175
- package/dist/handlers/find-implementations.d.ts +0 -11
- package/dist/handlers/find-implementations.js +0 -27
- package/dist/handlers/search-code.d.ts +0 -14
- package/dist/handlers/search-code.js +0 -32
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "token-pilot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Save 60-80% tokens when AI reads code — MCP server for token-efficient code navigation, AST-aware structural reading instead of dumping full files into context window",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
"CHANGELOG.md"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"prebuild": "
|
|
21
|
+
"prebuild": "node --input-type=module -e \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
|
|
22
22
|
"build": "tsc",
|
|
23
23
|
"dev": "tsc --watch",
|
|
24
24
|
"start": "node dist/index.js",
|
|
25
25
|
"test": "vitest run",
|
|
26
|
+
"test:coverage": "vitest run --coverage",
|
|
26
27
|
"test:watch": "vitest",
|
|
27
28
|
"lint": "tsc --noEmit",
|
|
28
|
-
"prepublishOnly": "npm run build && chmod
|
|
29
|
+
"prepublishOnly": "npm run build && node --input-type=module -e \"import { chmod } from 'node:fs/promises'; await chmod('dist/index.js', 0o755);\""
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
31
32
|
"token-savings",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"chokidar": "^4.0.3"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
65
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
64
66
|
"@types/node": "^22.0.0",
|
|
65
67
|
"typescript": "^5.7.0",
|
|
66
68
|
"vitest": "^3.0.0"
|
package/start.sh
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Token Pilot bootstrap script for Claude Code plugin system.
|
|
3
|
-
# Handles auto-install of dependencies and build on first run.
|
|
4
|
-
|
|
5
|
-
set -e
|
|
6
|
-
|
|
7
|
-
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
cd "$SCRIPT_DIR"
|
|
9
|
-
|
|
10
|
-
# 1. Install
|
|
11
|
-
if [ ! -
|
|
12
|
-
echo "[token-pilot] Installing dependencies..." >&2
|
|
13
|
-
npm install --production --no-audit --no-fund 2>&1 >&2
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
# 2. Build if dist/ is missing
|
|
17
|
-
if [ ! -f "dist/index.js" ]; then
|
|
18
|
-
echo "[token-pilot] Building..." >&2
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Token Pilot bootstrap script for Claude Code plugin system.
|
|
3
|
+
# Handles auto-install of dependencies and build on first run.
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
cd "$SCRIPT_DIR"
|
|
9
|
+
|
|
10
|
+
# 1. Install runtime dependencies when the package is incomplete.
|
|
11
|
+
if [ ! -f "node_modules/@modelcontextprotocol/sdk/package.json" ]; then
|
|
12
|
+
echo "[token-pilot] Installing runtime dependencies..." >&2
|
|
13
|
+
npm install --production --no-audit --no-fund 2>&1 >&2
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# 2. Build if dist/ is missing.
|
|
17
|
+
if [ ! -f "dist/index.js" ]; then
|
|
18
|
+
echo "[token-pilot] Building..." >&2
|
|
19
|
+
if [ ! -f "node_modules/typescript/bin/tsc" ]; then
|
|
20
|
+
npm install --no-audit --no-fund 2>&1 >&2
|
|
21
|
+
fi
|
|
22
|
+
npm run build 2>&1 >&2
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
# 3. Start the MCP server.
|
|
26
|
+
# Pass CLAUDE_PROJECT_DIR as project root if available, otherwise cwd.
|
|
27
|
+
PROJECT_ROOT="${CLAUDE_PROJECT_DIR:-$(pwd)}"
|
|
28
|
+
exec node "$SCRIPT_DIR/dist/index.js" "$PROJECT_ROOT"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AstIndexClient } from '../ast-index/client.js';
|
|
2
|
-
export interface ClassHierarchyArgs {
|
|
3
|
-
name: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function handleClassHierarchy(args: ClassHierarchyArgs, astIndex: AstIndexClient): Promise<{
|
|
6
|
-
content: Array<{
|
|
7
|
-
type: 'text';
|
|
8
|
-
text: string;
|
|
9
|
-
}>;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=class-hierarchy.d.ts.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export async function handleClassHierarchy(args, astIndex) {
|
|
2
|
-
const tree = await astIndex.hierarchy(args.name);
|
|
3
|
-
if (!tree) {
|
|
4
|
-
return {
|
|
5
|
-
content: [{
|
|
6
|
-
type: 'text',
|
|
7
|
-
text: `No hierarchy found for "${args.name}".`,
|
|
8
|
-
}],
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
const lines = [
|
|
12
|
-
`HIERARCHY: "${args.name}"`,
|
|
13
|
-
'',
|
|
14
|
-
];
|
|
15
|
-
formatNode(tree, lines, 0);
|
|
16
|
-
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
17
|
-
}
|
|
18
|
-
function formatNode(node, lines, depth) {
|
|
19
|
-
const indent = ' '.repeat(depth);
|
|
20
|
-
const loc = node.file ? ` (${node.file}:${node.line})` : '';
|
|
21
|
-
lines.push(`${indent}${node.kind} ${node.name}${loc}`);
|
|
22
|
-
if (node.children) {
|
|
23
|
-
for (const child of node.children) {
|
|
24
|
-
formatNode(child, lines, depth + 1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=class-hierarchy.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AstIndexClient } from '../ast-index/client.js';
|
|
2
|
-
import type { FileCache } from '../core/file-cache.js';
|
|
3
|
-
export interface ExportAstIndexArgs {
|
|
4
|
-
paths?: string[];
|
|
5
|
-
format?: 'markdown' | 'json';
|
|
6
|
-
all_indexed?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Export AST structural data in a format suitable for context-mode's BM25 index.
|
|
10
|
-
*
|
|
11
|
-
* Generates a markdown document with headings per file and symbols as sections,
|
|
12
|
-
* which context-mode can index via its `index` tool for cross-tool search.
|
|
13
|
-
*
|
|
14
|
-
* When all_indexed=true, exports all files known to ast-index (not just cached ones).
|
|
15
|
-
*/
|
|
16
|
-
export declare function handleExportAstIndex(args: ExportAstIndexArgs, astIndex: AstIndexClient, fileCache: FileCache): Promise<{
|
|
17
|
-
content: Array<{
|
|
18
|
-
type: 'text';
|
|
19
|
-
text: string;
|
|
20
|
-
}>;
|
|
21
|
-
}>;
|
|
22
|
-
//# sourceMappingURL=export-ast-index.d.ts.map
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Export AST structural data in a format suitable for context-mode's BM25 index.
|
|
3
|
-
*
|
|
4
|
-
* Generates a markdown document with headings per file and symbols as sections,
|
|
5
|
-
* which context-mode can index via its `index` tool for cross-tool search.
|
|
6
|
-
*
|
|
7
|
-
* When all_indexed=true, exports all files known to ast-index (not just cached ones).
|
|
8
|
-
*/
|
|
9
|
-
export async function handleExportAstIndex(args, astIndex, fileCache) {
|
|
10
|
-
const format = args.format ?? 'markdown';
|
|
11
|
-
// When all_indexed is requested, use ast-index to get all file outlines directly
|
|
12
|
-
if (args.all_indexed) {
|
|
13
|
-
return exportAllIndexed(astIndex, format, args.paths);
|
|
14
|
-
}
|
|
15
|
-
// Gather all cached files or specified subset
|
|
16
|
-
const cachedPaths = fileCache.cachedPaths();
|
|
17
|
-
const targetPaths = args.paths && args.paths.length > 0
|
|
18
|
-
? args.paths.filter(p => cachedPaths.includes(p))
|
|
19
|
-
: cachedPaths;
|
|
20
|
-
if (targetPaths.length === 0) {
|
|
21
|
-
return {
|
|
22
|
-
content: [{
|
|
23
|
-
type: 'text',
|
|
24
|
-
text: 'No cached files available.\nHINT: Use all_indexed=true to export all files from the ast-index, or use smart_read on files first to populate the cache.',
|
|
25
|
-
}],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (format === 'json') {
|
|
29
|
-
return exportJson(targetPaths, fileCache);
|
|
30
|
-
}
|
|
31
|
-
return exportMarkdown(targetPaths, fileCache);
|
|
32
|
-
}
|
|
33
|
-
function exportMarkdown(paths, fileCache) {
|
|
34
|
-
const sections = [
|
|
35
|
-
'# Token Pilot AST Index Export',
|
|
36
|
-
'',
|
|
37
|
-
`Exported ${paths.length} files. Index this content via context-mode for cross-tool search.`,
|
|
38
|
-
'',
|
|
39
|
-
];
|
|
40
|
-
for (const filePath of paths) {
|
|
41
|
-
const cached = fileCache.get(filePath);
|
|
42
|
-
if (!cached)
|
|
43
|
-
continue;
|
|
44
|
-
const { structure } = cached;
|
|
45
|
-
sections.push(`## ${structure.path}`);
|
|
46
|
-
sections.push('');
|
|
47
|
-
sections.push(`Language: ${structure.language} | Lines: ${structure.meta.lines}`);
|
|
48
|
-
sections.push('');
|
|
49
|
-
// Imports as a section
|
|
50
|
-
if (structure.imports.length > 0) {
|
|
51
|
-
sections.push('### Imports');
|
|
52
|
-
for (const imp of structure.imports) {
|
|
53
|
-
sections.push(`- \`${imp.specifiers.join(', ')}\` from \`${imp.source}\``);
|
|
54
|
-
}
|
|
55
|
-
sections.push('');
|
|
56
|
-
}
|
|
57
|
-
// Symbols as searchable sections
|
|
58
|
-
for (const sym of structure.symbols) {
|
|
59
|
-
formatSymbolMarkdown(sym, sections, 3);
|
|
60
|
-
}
|
|
61
|
-
sections.push('---');
|
|
62
|
-
sections.push('');
|
|
63
|
-
}
|
|
64
|
-
sections.push('');
|
|
65
|
-
sections.push('To index in context-mode, pass this content to the `index` tool with source: "token-pilot-ast".');
|
|
66
|
-
return { content: [{ type: 'text', text: sections.join('\n') }] };
|
|
67
|
-
}
|
|
68
|
-
function exportJson(paths, fileCache) {
|
|
69
|
-
const data = [];
|
|
70
|
-
for (const filePath of paths) {
|
|
71
|
-
const cached = fileCache.get(filePath);
|
|
72
|
-
if (!cached)
|
|
73
|
-
continue;
|
|
74
|
-
const symbols = flattenSymbols(cached.structure.symbols);
|
|
75
|
-
data.push({
|
|
76
|
-
path: cached.structure.path,
|
|
77
|
-
language: cached.structure.language,
|
|
78
|
-
lines: cached.structure.meta.lines,
|
|
79
|
-
symbols,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
83
|
-
}
|
|
84
|
-
function formatSymbolMarkdown(sym, sections, headingLevel) {
|
|
85
|
-
const heading = '#'.repeat(Math.min(headingLevel, 6));
|
|
86
|
-
sections.push(`${heading} ${sym.kind} \`${sym.name}\``);
|
|
87
|
-
sections.push('');
|
|
88
|
-
sections.push(`Signature: \`${sym.signature}\` (L${sym.location.startLine}-${sym.location.endLine})`);
|
|
89
|
-
if (sym.doc) {
|
|
90
|
-
sections.push('');
|
|
91
|
-
sections.push(sym.doc);
|
|
92
|
-
}
|
|
93
|
-
sections.push('');
|
|
94
|
-
for (const child of sym.children) {
|
|
95
|
-
formatSymbolMarkdown(child, sections, headingLevel + 1);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Export all files from ast-index directly (bypasses cache).
|
|
100
|
-
* Uses ast-index outline for each file to get structure.
|
|
101
|
-
*/
|
|
102
|
-
async function exportAllIndexed(astIndex, format, filterPaths) {
|
|
103
|
-
let allFiles = await astIndex.listFiles();
|
|
104
|
-
if (filterPaths && filterPaths.length > 0) {
|
|
105
|
-
allFiles = allFiles.filter(f => filterPaths.some(p => f.includes(p)));
|
|
106
|
-
}
|
|
107
|
-
if (allFiles.length === 0) {
|
|
108
|
-
return {
|
|
109
|
-
content: [{
|
|
110
|
-
type: 'text',
|
|
111
|
-
text: 'No files in ast-index. The index may not be built yet.',
|
|
112
|
-
}],
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
// For large projects, just export file list with symbol counts
|
|
116
|
-
// Getting full outlines for 1000+ files would be too slow
|
|
117
|
-
if (allFiles.length > 50) {
|
|
118
|
-
const sections = [
|
|
119
|
-
'# Token Pilot AST Index Export',
|
|
120
|
-
'',
|
|
121
|
-
`Total indexed files: ${allFiles.length}`,
|
|
122
|
-
'',
|
|
123
|
-
'## Indexed Files',
|
|
124
|
-
'',
|
|
125
|
-
];
|
|
126
|
-
for (const f of allFiles) {
|
|
127
|
-
sections.push(`- ${f}`);
|
|
128
|
-
}
|
|
129
|
-
sections.push('');
|
|
130
|
-
sections.push('HINT: Use export_ast_index(paths=["src/specific-dir/"]) to export outlines for a subset.');
|
|
131
|
-
return { content: [{ type: 'text', text: sections.join('\n') }] };
|
|
132
|
-
}
|
|
133
|
-
// For smaller sets, get full outlines
|
|
134
|
-
const sections = [
|
|
135
|
-
'# Token Pilot AST Index Export',
|
|
136
|
-
'',
|
|
137
|
-
`Exported ${allFiles.length} files from ast-index.`,
|
|
138
|
-
'',
|
|
139
|
-
];
|
|
140
|
-
for (const filePath of allFiles) {
|
|
141
|
-
const structure = await astIndex.outline(filePath);
|
|
142
|
-
if (!structure) {
|
|
143
|
-
sections.push(`## ${filePath}`);
|
|
144
|
-
sections.push('(no AST structure available)');
|
|
145
|
-
sections.push('');
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
sections.push(`## ${structure.path}`);
|
|
149
|
-
sections.push('');
|
|
150
|
-
sections.push(`Language: ${structure.language} | Lines: ${structure.meta.lines}`);
|
|
151
|
-
sections.push('');
|
|
152
|
-
for (const sym of structure.symbols) {
|
|
153
|
-
formatSymbolMarkdown(sym, sections, 3);
|
|
154
|
-
}
|
|
155
|
-
sections.push('---');
|
|
156
|
-
sections.push('');
|
|
157
|
-
}
|
|
158
|
-
return { content: [{ type: 'text', text: sections.join('\n') }] };
|
|
159
|
-
}
|
|
160
|
-
function flattenSymbols(symbols) {
|
|
161
|
-
const result = [];
|
|
162
|
-
for (const sym of symbols) {
|
|
163
|
-
result.push({
|
|
164
|
-
name: sym.name,
|
|
165
|
-
kind: sym.kind,
|
|
166
|
-
signature: sym.signature,
|
|
167
|
-
location: `L${sym.location.startLine}-${sym.location.endLine}`,
|
|
168
|
-
});
|
|
169
|
-
if (sym.children.length > 0) {
|
|
170
|
-
result.push(...flattenSymbols(sym.children));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return result;
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=export-ast-index.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AstIndexClient } from '../ast-index/client.js';
|
|
2
|
-
export interface FindImplementationsArgs {
|
|
3
|
-
name: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function handleFindImplementations(args: FindImplementationsArgs, astIndex: AstIndexClient): Promise<{
|
|
6
|
-
content: Array<{
|
|
7
|
-
type: 'text';
|
|
8
|
-
text: string;
|
|
9
|
-
}>;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=find-implementations.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export async function handleFindImplementations(args, astIndex) {
|
|
2
|
-
const results = await astIndex.implementations(args.name);
|
|
3
|
-
if (results.length === 0) {
|
|
4
|
-
const hints = [`No implementations found for "${args.name}".`];
|
|
5
|
-
if (!astIndex.isAvailable()) {
|
|
6
|
-
hints.push('WARNING: ast-index is not available. Install it: cargo install ast-index');
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
hints.push('TIP: Index may not cover this language/project. Run `ast-index build` in the project root.');
|
|
10
|
-
}
|
|
11
|
-
return { content: [{ type: 'text', text: hints.join('\n') }] };
|
|
12
|
-
}
|
|
13
|
-
const lines = [
|
|
14
|
-
`IMPLEMENTATIONS: "${args.name}" (${results.length} found)`,
|
|
15
|
-
'',
|
|
16
|
-
];
|
|
17
|
-
for (const impl of results) {
|
|
18
|
-
const methods = impl.methods?.length
|
|
19
|
-
? ` — methods: ${impl.methods.join(', ')}`
|
|
20
|
-
: '';
|
|
21
|
-
lines.push(` ${impl.kind} ${impl.name} (${impl.file}:${impl.line})${methods}`);
|
|
22
|
-
}
|
|
23
|
-
lines.push('');
|
|
24
|
-
lines.push('HINT: Use read_symbol() to inspect a specific implementation.');
|
|
25
|
-
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=find-implementations.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AstIndexClient } from '../ast-index/client.js';
|
|
2
|
-
export interface SearchCodeArgs {
|
|
3
|
-
query: string;
|
|
4
|
-
in_file?: string;
|
|
5
|
-
max_results?: number;
|
|
6
|
-
fuzzy?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function handleSearchCode(args: SearchCodeArgs, astIndex: AstIndexClient): Promise<{
|
|
9
|
-
content: Array<{
|
|
10
|
-
type: 'text';
|
|
11
|
-
text: string;
|
|
12
|
-
}>;
|
|
13
|
-
}>;
|
|
14
|
-
//# sourceMappingURL=search-code.d.ts.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export async function handleSearchCode(args, astIndex) {
|
|
2
|
-
const results = await astIndex.search(args.query, {
|
|
3
|
-
inFile: args.in_file,
|
|
4
|
-
maxResults: args.max_results ?? 20,
|
|
5
|
-
fuzzy: args.fuzzy,
|
|
6
|
-
});
|
|
7
|
-
if (results.length === 0) {
|
|
8
|
-
const hints = [`No results found for "${args.query}".`];
|
|
9
|
-
if (!args.fuzzy)
|
|
10
|
-
hints.push('TIP: Try fuzzy=true for broader matching.');
|
|
11
|
-
if (!astIndex.isAvailable()) {
|
|
12
|
-
hints.push('WARNING: ast-index is not available. Install it: cargo install ast-index');
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
hints.push('TIP: Index may not cover this language/project. Run `ast-index build` in the project root.');
|
|
16
|
-
hints.push('TIP: Check that the symbol exists and the index is up to date (project_overview shows index status).');
|
|
17
|
-
}
|
|
18
|
-
return { content: [{ type: 'text', text: hints.join('\n') }] };
|
|
19
|
-
}
|
|
20
|
-
const lines = [
|
|
21
|
-
`SEARCH: "${args.query}" (${results.length} results)`,
|
|
22
|
-
'',
|
|
23
|
-
];
|
|
24
|
-
for (const r of results) {
|
|
25
|
-
lines.push(` ${r.file}:${r.line}`);
|
|
26
|
-
lines.push(` ${r.text.trim()}`);
|
|
27
|
-
}
|
|
28
|
-
lines.push('');
|
|
29
|
-
lines.push('HINT: Use read_symbol() or read_range() to load specific results.');
|
|
30
|
-
return { content: [{ type: 'text', text: lines.join('\n') }] };
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=search-code.js.map
|