@side-quest/kit 0.1.0 → 0.2.0
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/CHANGELOG.md +20 -0
- package/README.md +54 -352
- package/dist/cli.d.ts +14 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +156 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -2509
- package/dist/index.js.map +1 -0
- package/dist/lib/ast/index.d.ts +11 -0
- package/dist/lib/ast/index.d.ts.map +1 -0
- package/dist/lib/ast/index.js +15 -0
- package/dist/lib/ast/index.js.map +1 -0
- package/dist/lib/ast/languages.d.ts +55 -0
- package/dist/lib/ast/languages.d.ts.map +1 -0
- package/dist/lib/ast/languages.js +146 -0
- package/dist/lib/ast/languages.js.map +1 -0
- package/dist/lib/ast/pattern.d.ts +84 -0
- package/dist/lib/ast/pattern.d.ts.map +1 -0
- package/dist/lib/ast/pattern.js +268 -0
- package/dist/lib/ast/pattern.js.map +1 -0
- package/dist/lib/ast/searcher.d.ts +89 -0
- package/dist/lib/ast/searcher.d.ts.map +1 -0
- package/dist/lib/ast/searcher.js +316 -0
- package/dist/lib/ast/searcher.js.map +1 -0
- package/dist/lib/ast/types.d.ts +93 -0
- package/dist/lib/ast/types.d.ts.map +1 -0
- package/dist/lib/ast/types.js +23 -0
- package/dist/lib/ast/types.js.map +1 -0
- package/dist/lib/commands/callers.d.ts +20 -0
- package/dist/lib/commands/callers.d.ts.map +1 -0
- package/dist/lib/commands/callers.js +162 -0
- package/dist/lib/commands/callers.js.map +1 -0
- package/dist/lib/commands/find.d.ts +15 -0
- package/dist/lib/commands/find.d.ts.map +1 -0
- package/dist/lib/commands/find.js +113 -0
- package/dist/lib/commands/find.js.map +1 -0
- package/dist/lib/commands/overview.d.ts +6 -0
- package/dist/lib/commands/overview.d.ts.map +1 -0
- package/dist/lib/commands/overview.js +52 -0
- package/dist/lib/commands/overview.js.map +1 -0
- package/dist/lib/commands/prime.d.ts +16 -0
- package/dist/lib/commands/prime.d.ts.map +1 -0
- package/dist/lib/commands/prime.js +168 -0
- package/dist/lib/commands/prime.js.map +1 -0
- package/dist/lib/commands/search.d.ts +20 -0
- package/dist/lib/commands/search.d.ts.map +1 -0
- package/dist/lib/commands/search.js +111 -0
- package/dist/lib/commands/search.js.map +1 -0
- package/dist/lib/errors.d.ts +80 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +189 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/formatters/output.d.ts +5 -0
- package/dist/lib/formatters/output.d.ts.map +1 -0
- package/dist/lib/formatters/output.js +5 -0
- package/dist/lib/formatters/output.js.map +1 -0
- package/dist/lib/formatters.d.ts +29 -0
- package/dist/lib/formatters.d.ts.map +1 -0
- package/dist/lib/formatters.js +141 -0
- package/dist/lib/formatters.js.map +1 -0
- package/dist/lib/index-tools.d.ts +108 -0
- package/dist/lib/index-tools.d.ts.map +1 -0
- package/dist/lib/index-tools.js +311 -0
- package/dist/lib/index-tools.js.map +1 -0
- package/dist/lib/index.d.ts +21 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +42 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/kit-wrapper.d.ts +70 -0
- package/dist/lib/kit-wrapper.d.ts.map +1 -0
- package/dist/lib/kit-wrapper.js +462 -0
- package/dist/lib/kit-wrapper.js.map +1 -0
- package/dist/lib/logger.d.ts +28 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/logger.js +39 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/types.d.ts +179 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +48 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils/args.d.ts +40 -0
- package/dist/lib/utils/args.d.ts.map +1 -0
- package/dist/lib/utils/args.js +58 -0
- package/dist/lib/utils/args.js.map +1 -0
- package/dist/lib/utils/git.d.ts +23 -0
- package/dist/lib/utils/git.d.ts.map +1 -0
- package/dist/lib/utils/git.js +50 -0
- package/dist/lib/utils/git.js.map +1 -0
- package/dist/lib/utils/index-parser.d.ts +155 -0
- package/dist/lib/utils/index-parser.d.ts.map +1 -0
- package/dist/lib/utils/index-parser.js +252 -0
- package/dist/lib/utils/index-parser.js.map +1 -0
- package/dist/lib/validators.d.ts +138 -0
- package/dist/lib/validators.d.ts.map +1 -0
- package/dist/lib/validators.js +302 -0
- package/dist/lib/validators.js.map +1 -0
- package/dist/mcp/index.d.ts +19 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +769 -0
- package/dist/mcp/index.js.map +1 -0
- package/package.json +5 -2
- package/src/cli.ts +170 -0
- package/src/lib/ast/index.ts +32 -0
- package/src/lib/ast/languages.ts +172 -0
- package/src/lib/ast/pattern.ts +299 -0
- package/src/lib/ast/searcher.ts +381 -0
- package/src/lib/ast/types.ts +99 -0
- package/src/lib/commands/callers.ts +226 -0
- package/src/lib/commands/find.ts +159 -0
- package/src/lib/commands/overview.ts +73 -0
- package/src/lib/commands/prime.ts +271 -0
- package/src/lib/commands/search.ts +146 -0
- package/src/lib/errors.ts +221 -0
- package/src/lib/formatters/output.ts +9 -0
- package/src/lib/formatters.ts +189 -0
- package/src/lib/index-tools.ts +471 -0
- package/src/lib/index.ts +122 -0
- package/src/lib/kit-wrapper.ts +675 -0
- package/src/lib/logger.ts +57 -0
- package/src/lib/types.ts +228 -0
- package/src/lib/utils/args.ts +72 -0
- package/src/lib/utils/git.ts +65 -0
- package/src/lib/utils/index-parser.ts +350 -0
- package/src/lib/validators.ts +437 -0
- package/src/mcp/index.ts +144 -79
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callers command - Find who calls a function
|
|
3
|
+
*
|
|
4
|
+
* Uses kit grep to find all call sites of a function, filtering out the
|
|
5
|
+
* definition itself to show only actual usage locations.
|
|
6
|
+
*/
|
|
7
|
+
import { color, OutputFormat } from '../formatters/output';
|
|
8
|
+
import { executeKitGrep } from '../kit-wrapper';
|
|
9
|
+
import { findSymbol, loadProjectIndex } from '../utils/index-parser';
|
|
10
|
+
/**
|
|
11
|
+
* Format callers result as markdown
|
|
12
|
+
*
|
|
13
|
+
* @param result - Callers result to format
|
|
14
|
+
* @returns Formatted markdown string
|
|
15
|
+
*/
|
|
16
|
+
function formatMarkdown(result) {
|
|
17
|
+
const { functionName, definitionFile, definitionLine, callSites, count } = result;
|
|
18
|
+
if (count === 0) {
|
|
19
|
+
return color('yellow', `\n⚠️ No call sites found for function: ${functionName}\n`);
|
|
20
|
+
}
|
|
21
|
+
let output = color('cyan', `\n📞 Found ${count} call site(s) for: `);
|
|
22
|
+
output += color('blue', functionName);
|
|
23
|
+
output += '\n\n';
|
|
24
|
+
// Show definition location if available
|
|
25
|
+
if (definitionFile && definitionLine) {
|
|
26
|
+
output += color('dim', `Definition: ${definitionFile}:${definitionLine}\n\n`);
|
|
27
|
+
}
|
|
28
|
+
// Group by file
|
|
29
|
+
const byFile = new Map();
|
|
30
|
+
for (const callSite of callSites) {
|
|
31
|
+
if (!byFile.has(callSite.file)) {
|
|
32
|
+
byFile.set(callSite.file, []);
|
|
33
|
+
}
|
|
34
|
+
byFile.get(callSite.file)?.push(callSite);
|
|
35
|
+
}
|
|
36
|
+
// Output each file
|
|
37
|
+
for (const [file, sites] of byFile.entries()) {
|
|
38
|
+
output += color('dim', `${file}:\n`);
|
|
39
|
+
for (const site of sites) {
|
|
40
|
+
output += ` ${color('dim', `L${site.line}:`)} ${site.context.trim()}\n`;
|
|
41
|
+
}
|
|
42
|
+
output += '\n';
|
|
43
|
+
}
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format callers result as JSON
|
|
48
|
+
*
|
|
49
|
+
* @param result - Callers result to format
|
|
50
|
+
* @returns JSON string
|
|
51
|
+
*/
|
|
52
|
+
function formatJSON(result) {
|
|
53
|
+
return JSON.stringify(result, null, 2);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Execute callers command
|
|
57
|
+
*
|
|
58
|
+
* Finds all locations where a function is called by:
|
|
59
|
+
* 1. Looking up the function definition in PROJECT_INDEX.json
|
|
60
|
+
* 2. Using kit grep to find all occurrences
|
|
61
|
+
* 3. Filtering out the definition line to show only call sites
|
|
62
|
+
*
|
|
63
|
+
* @param functionName - Name of the function to find callers for
|
|
64
|
+
* @param format - Output format (markdown or JSON)
|
|
65
|
+
*/
|
|
66
|
+
export async function executeCallers(functionName, format) {
|
|
67
|
+
try {
|
|
68
|
+
// Find the function definition in the index
|
|
69
|
+
let definitionFile;
|
|
70
|
+
let definitionLine;
|
|
71
|
+
try {
|
|
72
|
+
const index = await loadProjectIndex();
|
|
73
|
+
const definitions = findSymbol(index, functionName);
|
|
74
|
+
// Use the first definition found (functions should be unique)
|
|
75
|
+
const firstDef = definitions[0];
|
|
76
|
+
if (firstDef) {
|
|
77
|
+
definitionFile = firstDef.file;
|
|
78
|
+
definitionLine = firstDef.symbol.start_line;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Index not available - we'll proceed without filtering the definition
|
|
83
|
+
}
|
|
84
|
+
// Use kit grep to find all occurrences
|
|
85
|
+
const grepResult = executeKitGrep({
|
|
86
|
+
pattern: functionName,
|
|
87
|
+
caseSensitive: true,
|
|
88
|
+
maxResults: 500,
|
|
89
|
+
});
|
|
90
|
+
// Handle errors
|
|
91
|
+
if ('error' in grepResult) {
|
|
92
|
+
if (format === OutputFormat.JSON) {
|
|
93
|
+
console.error(JSON.stringify({
|
|
94
|
+
error: grepResult.error,
|
|
95
|
+
functionName,
|
|
96
|
+
isError: true,
|
|
97
|
+
}, null, 2));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.error(color('red', '\n❌ Error:'), grepResult.error, '\n');
|
|
101
|
+
}
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
// Filter matches to exclude the definition line
|
|
105
|
+
let matches = grepResult.matches;
|
|
106
|
+
if (definitionFile && definitionLine) {
|
|
107
|
+
matches = matches.filter((match) => !(match.file === definitionFile && match.line === definitionLine));
|
|
108
|
+
}
|
|
109
|
+
// Filter out matches that look like definitions rather than calls
|
|
110
|
+
// Heuristics:
|
|
111
|
+
// - Lines starting with "function ", "const ", "let ", "var ", "export function"
|
|
112
|
+
// - Lines with "= function" or "= (" (function assignments)
|
|
113
|
+
// - Lines with "export async function" (exported async functions)
|
|
114
|
+
matches = matches.filter((match) => {
|
|
115
|
+
const trimmed = match.content.trim();
|
|
116
|
+
const definitionPatterns = [
|
|
117
|
+
/^function\s+/, // function declarations
|
|
118
|
+
/^export\s+(async\s+)?function\s+/, // exported functions (sync or async)
|
|
119
|
+
/^(const|let|var)\s+\w+\s*=\s*function/, // function expressions
|
|
120
|
+
/^(const|let|var)\s+\w+\s*=\s*\(/, // arrow functions
|
|
121
|
+
/^(const|let|var)\s+\w+\s*=\s*async\s*\(/, // async arrow functions
|
|
122
|
+
/^async\s+function\s+/, // async function declarations
|
|
123
|
+
];
|
|
124
|
+
return !definitionPatterns.some((pattern) => pattern.test(trimmed));
|
|
125
|
+
});
|
|
126
|
+
// Convert to call sites
|
|
127
|
+
const callSites = matches.map((match) => ({
|
|
128
|
+
file: match.file,
|
|
129
|
+
line: match.line || 0,
|
|
130
|
+
context: match.content,
|
|
131
|
+
}));
|
|
132
|
+
// Build result
|
|
133
|
+
const result = {
|
|
134
|
+
functionName,
|
|
135
|
+
definitionFile,
|
|
136
|
+
definitionLine,
|
|
137
|
+
callSites,
|
|
138
|
+
count: callSites.length,
|
|
139
|
+
};
|
|
140
|
+
// Output results
|
|
141
|
+
if (format === OutputFormat.JSON) {
|
|
142
|
+
console.log(formatJSON(result));
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(formatMarkdown(result));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (format === OutputFormat.JSON) {
|
|
150
|
+
console.error(JSON.stringify({
|
|
151
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
152
|
+
functionName,
|
|
153
|
+
isError: true,
|
|
154
|
+
}, null, 2));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
console.error(color('red', '\n❌ Error:'), error instanceof Error ? error.message : error, '\n');
|
|
158
|
+
}
|
|
159
|
+
process.exit(1);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=callers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callers.js","sourceRoot":"","sources":["../../../src/lib/commands/callers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAsBpE;;;;;GAKG;AACH,SAAS,cAAc,CAAC,MAAqB;IAC5C,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,EAAE,GACvE,MAAM,CAAA;IAEP,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CACX,QAAQ,EACR,2CAA2C,YAAY,IAAI,CAC3D,CAAA;IACF,CAAC;IAED,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,KAAK,qBAAqB,CAAC,CAAA;IACpE,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACrC,MAAM,IAAI,MAAM,CAAA;IAEhB,wCAAwC;IACxC,IAAI,cAAc,IAAI,cAAc,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACd,KAAK,EACL,eAAe,cAAc,IAAI,cA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EAAE,CAAC;QAChB,IAAI,MAAM,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CACZ,IAAI,CAAC,SAAS,CACb;gBACC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;gBAC/D,YAAY;gBACZ,OAAO,EAAE,IAAI;aACb,EACD,IAAI,EACJ,CAAC,CACD,CACD,CAAA;QACF,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,KAAK,CACZ,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,EAC1B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAC9C,IAAI,CACJ,CAAA;QACF,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find command - Locate symbol definitions by name
|
|
3
|
+
*
|
|
4
|
+
* Searches PROJECT_INDEX.json for symbol definitions with exact or fuzzy matching.
|
|
5
|
+
* Supports dual output formats (markdown table or JSON).
|
|
6
|
+
*/
|
|
7
|
+
import { OutputFormat } from '../formatters/output';
|
|
8
|
+
/**
|
|
9
|
+
* Execute find command
|
|
10
|
+
*
|
|
11
|
+
* @param symbol - Symbol name to search for
|
|
12
|
+
* @param format - Output format (markdown or JSON)
|
|
13
|
+
*/
|
|
14
|
+
export declare function executeFind(symbol: string, format: OutputFormat): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/find.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAwF1D;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAsDf"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find command - Locate symbol definitions by name
|
|
3
|
+
*
|
|
4
|
+
* Searches PROJECT_INDEX.json for symbol definitions with exact or fuzzy matching.
|
|
5
|
+
* Supports dual output formats (markdown table or JSON).
|
|
6
|
+
*/
|
|
7
|
+
import { color, OutputFormat } from '../formatters/output';
|
|
8
|
+
import { findSymbol, findSymbolFuzzy, loadProjectIndex, } from '../utils/index-parser';
|
|
9
|
+
/**
|
|
10
|
+
* Format symbol results as markdown table
|
|
11
|
+
*/
|
|
12
|
+
function formatMarkdown(results, query) {
|
|
13
|
+
if (results.length === 0) {
|
|
14
|
+
return color('yellow', `\n⚠️ No symbols found matching: ${query}\n`);
|
|
15
|
+
}
|
|
16
|
+
let output = color('cyan', `\n📍 Found ${results.length} symbol(s)\n\n`);
|
|
17
|
+
// Group by file
|
|
18
|
+
const byFile = new Map();
|
|
19
|
+
for (const { file, symbol } of results) {
|
|
20
|
+
if (!byFile.has(file)) {
|
|
21
|
+
byFile.set(file, []);
|
|
22
|
+
}
|
|
23
|
+
byFile.get(file)?.push(symbol);
|
|
24
|
+
}
|
|
25
|
+
// Output each file
|
|
26
|
+
for (const [file, symbols] of byFile.entries()) {
|
|
27
|
+
output += color('dim', `${file}:\n`);
|
|
28
|
+
for (const symbol of symbols) {
|
|
29
|
+
const typeColor = getTypeColor(symbol.type);
|
|
30
|
+
output += ` ${color('dim', '•')} ${color(typeColor, symbol.type.padEnd(10))} ${color('blue', symbol.name)} ${color('dim', `(line ${symbol.start_line}`)}\n`;
|
|
31
|
+
}
|
|
32
|
+
output += '\n';
|
|
33
|
+
}
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get color for symbol type
|
|
38
|
+
*/
|
|
39
|
+
function getTypeColor(type) {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'function':
|
|
42
|
+
return 'blue';
|
|
43
|
+
case 'class':
|
|
44
|
+
return 'green';
|
|
45
|
+
case 'interface':
|
|
46
|
+
case 'type':
|
|
47
|
+
return 'magenta';
|
|
48
|
+
case 'constant':
|
|
49
|
+
return 'cyan';
|
|
50
|
+
default:
|
|
51
|
+
return 'yellow';
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Format symbol results as JSON
|
|
56
|
+
*/
|
|
57
|
+
function formatJSON(results, query) {
|
|
58
|
+
return JSON.stringify({
|
|
59
|
+
query,
|
|
60
|
+
count: results.length,
|
|
61
|
+
results: results.map(({ file, symbol }) => ({
|
|
62
|
+
file,
|
|
63
|
+
name: symbol.name,
|
|
64
|
+
type: symbol.type,
|
|
65
|
+
line: symbol.start_line,
|
|
66
|
+
code: symbol.code,
|
|
67
|
+
})),
|
|
68
|
+
}, null, 2);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Execute find command
|
|
72
|
+
*
|
|
73
|
+
* @param symbol - Symbol name to search for
|
|
74
|
+
* @param format - Output format (markdown or JSON)
|
|
75
|
+
*/
|
|
76
|
+
export async function executeFind(symbol, format) {
|
|
77
|
+
try {
|
|
78
|
+
const index = await loadProjectIndex();
|
|
79
|
+
// Try exact match first
|
|
80
|
+
let results = findSymbol(index, symbol);
|
|
81
|
+
// If no exact match, try fuzzy search
|
|
82
|
+
if (results.length === 0) {
|
|
83
|
+
const fuzzyResults = findSymbolFuzzy(index, symbol);
|
|
84
|
+
if (fuzzyResults.length > 0 && format === OutputFormat.MARKDOWN) {
|
|
85
|
+
console.log(color('yellow', `\n⚠️ No exact match for "${symbol}". Showing fuzzy matches:\n`));
|
|
86
|
+
}
|
|
87
|
+
results = fuzzyResults.map(({ file, symbol: sym }) => ({
|
|
88
|
+
file,
|
|
89
|
+
symbol: sym,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
// Output results
|
|
93
|
+
if (format === OutputFormat.JSON) {
|
|
94
|
+
console.log(formatJSON(results, symbol));
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
console.log(formatMarkdown(results, symbol));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (format === OutputFormat.JSON) {
|
|
102
|
+
console.error(JSON.stringify({
|
|
103
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
104
|
+
isError: true,
|
|
105
|
+
}, null, 2));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.error(color('red', '\n❌ Error:'), error instanceof Error ? error.message : error);
|
|
109
|
+
}
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../../src/lib/commands/find.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EACN,UAAU,EACV,eAAe,EAEf,gBAAgB,GAChB,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AACH,SAAS,cAAc,CACtB,OAAqD,EACrD,KAAa;IAEb,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,QAAQ,EAAE,oCAAoC,KAAK,IAAI,CAAC,CAAA;IACtE,CAAC;IAED,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,OAAO,CAAC,MAAM,gBAAgB,CAAC,CAAA;IAExE,gBAAgB;IAChB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC/C,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAA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AAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;QACzC,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;QAC7C,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,MAAM,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CACZ,IAAI,CAAC,SAAS,CACb;gBACC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;gBAC/D,OAAO,EAAE,IAAI;aACb,EACD,IAAI,EACJ,CAAC,CACD,CACD,CAAA;QACF,CAAC;aAAM,CAAC;YACP,OAAO,CAAC,KAAK,CACZ,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,EAC1B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAC9C,CAAA;QACF,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overview.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/overview.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAS,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAO1D,wBAAsB,eAAe,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CA0Df"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overview command - List all symbols in a file
|
|
3
|
+
*/
|
|
4
|
+
import { color, OutputFormat } from '../formatters/output';
|
|
5
|
+
import { getFileSymbols, loadProjectIndex, } from '../utils/index-parser';
|
|
6
|
+
export async function executeOverview(file, format) {
|
|
7
|
+
try {
|
|
8
|
+
const index = await loadProjectIndex();
|
|
9
|
+
const symbols = getFileSymbols(index, file);
|
|
10
|
+
if (symbols.length === 0) {
|
|
11
|
+
if (format === OutputFormat.JSON) {
|
|
12
|
+
console.log(JSON.stringify({ file, symbols: [] }, null, 2));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.log(color('yellow', `\n⚠️ No symbols found in: ${file}\n`));
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (format === OutputFormat.JSON) {
|
|
20
|
+
console.log(JSON.stringify({ file, count: symbols.length, symbols }, null, 2));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Group by type
|
|
24
|
+
const grouped = symbols.reduce((acc, sym) => {
|
|
25
|
+
if (!acc[sym.type])
|
|
26
|
+
acc[sym.type] = [];
|
|
27
|
+
acc[sym.type]?.push(sym);
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
console.log(color('cyan', `\n📄 ${file}\n`));
|
|
31
|
+
console.log(color('dim', `Total symbols: ${symbols.length}\n`));
|
|
32
|
+
for (const [type, syms] of Object.entries(grouped)) {
|
|
33
|
+
console.log(color('magenta', `${type}s:`));
|
|
34
|
+
for (const sym of syms) {
|
|
35
|
+
console.log(` ${color('dim', '•')} ${color('blue', sym.name)} ${color('dim', `(line ${sym.start_line})`)}`);
|
|
36
|
+
}
|
|
37
|
+
console.log('');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error(format === OutputFormat.JSON
|
|
43
|
+
? JSON.stringify({
|
|
44
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
45
|
+
isError: true,
|
|
46
|
+
}, null, 2)
|
|
47
|
+
: color('red', '\n❌ Error:') +
|
|
48
|
+
` ${error instanceof Error ? error.message : error}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
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I;aACb,EACD,IAAI,EACJ,CAAC,CACD;YACF,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC;gBAC1B,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CACvD,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prime command - Generate or refresh PROJECT_INDEX.json
|
|
3
|
+
*
|
|
4
|
+
* Migrated from prime-reporter.ts to integrate with kit-index CLI.
|
|
5
|
+
* Supports dual output formats (markdown with colors, or JSON).
|
|
6
|
+
*/
|
|
7
|
+
import { OutputFormat } from '../formatters/output';
|
|
8
|
+
/**
|
|
9
|
+
* Execute prime command
|
|
10
|
+
*
|
|
11
|
+
* @param force - Force regenerate even if index is fresh
|
|
12
|
+
* @param format - Output format (markdown or JSON)
|
|
13
|
+
* @param customPath - Optional custom path to index (defaults to git root or CWD)
|
|
14
|
+
*/
|
|
15
|
+
export declare function executePrime(force: boolean, format: OutputFormat, customPath?: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=prime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prime.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/prime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAS,YAAY,EAAE,MAAM,sBAAsB,CAAA;AA0L1D;;;;;;GAMG;AACH,wBAAsB,YAAY,CACjC,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,YAAY,EACpB,UAAU,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CA4Df"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prime command - Generate or refresh PROJECT_INDEX.json
|
|
3
|
+
*
|
|
4
|
+
* Migrated from prime-reporter.ts to integrate with kit-index CLI.
|
|
5
|
+
* Supports dual output formats (markdown with colors, or JSON).
|
|
6
|
+
*/
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { getFileAgeHours, getFileSizeMB } from '@side-quest/core/fs';
|
|
9
|
+
import { ensureCommandAvailable, spawnWithTimeout, } from '@side-quest/core/spawn';
|
|
10
|
+
import { color, OutputFormat } from '../formatters/output';
|
|
11
|
+
import { getTargetDir, INDEX_FILE, MAX_AGE_HOURS } from '../utils/git.js';
|
|
12
|
+
/**
|
|
13
|
+
* Parse index stats from PROJECT_INDEX.json
|
|
14
|
+
*/
|
|
15
|
+
async function parseIndexStats(indexPath) {
|
|
16
|
+
const file = Bun.file(indexPath);
|
|
17
|
+
const json = (await file.json());
|
|
18
|
+
const symbolCount = Object.values(json.symbols).reduce((sum, arr) => sum + arr.length, 0);
|
|
19
|
+
return {
|
|
20
|
+
files: json.files.length,
|
|
21
|
+
symbols: symbolCount,
|
|
22
|
+
hasTree: json.file_tree !== undefined,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate the index using kit CLI
|
|
27
|
+
*/
|
|
28
|
+
async function generateIndex(targetDir, indexPath) {
|
|
29
|
+
const kitCmd = ensureCommandAvailable('kit');
|
|
30
|
+
const startTime = Date.now();
|
|
31
|
+
const result = await spawnWithTimeout([kitCmd, 'index', targetDir, '-o', indexPath], 60_000);
|
|
32
|
+
if (result.timedOut) {
|
|
33
|
+
throw new Error('kit index timed out');
|
|
34
|
+
}
|
|
35
|
+
if (result.exitCode !== 0) {
|
|
36
|
+
throw new Error(`kit index failed: ${result.stderr}`);
|
|
37
|
+
}
|
|
38
|
+
const durationSec = (Date.now() - startTime) / 1000;
|
|
39
|
+
return { durationSec };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Report existing index (markdown format)
|
|
43
|
+
*/
|
|
44
|
+
async function reportExistingMarkdown(ageHours, indexPath, targetDir) {
|
|
45
|
+
const stats = await parseIndexStats(indexPath);
|
|
46
|
+
const size = getFileSizeMB(indexPath);
|
|
47
|
+
console.log(color('cyan', '\n📊 PROJECT_INDEX.json exists\n'));
|
|
48
|
+
console.log(color('dim', `Location: ${targetDir}`));
|
|
49
|
+
console.log(color('dim', `Age: ${ageHours.toFixed(1)} hours`));
|
|
50
|
+
console.log(color('dim', `Files: ${stats.files}`));
|
|
51
|
+
console.log(color('dim', `Symbols: ${stats.symbols}`));
|
|
52
|
+
console.log(color('dim', `Size: ${size} MB`));
|
|
53
|
+
console.log(color('yellow', '\n⚠️ Index is less than 24 hours old. Use --force to regenerate.'));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Report existing index (JSON format)
|
|
57
|
+
*/
|
|
58
|
+
async function reportExistingJSON(ageHours, indexPath, targetDir) {
|
|
59
|
+
const stats = await parseIndexStats(indexPath);
|
|
60
|
+
const sizeMB = getFileSizeMB(indexPath);
|
|
61
|
+
console.log(JSON.stringify({
|
|
62
|
+
status: 'exists',
|
|
63
|
+
location: targetDir,
|
|
64
|
+
ageHours: Number.parseFloat(ageHours.toFixed(1)),
|
|
65
|
+
files: stats.files,
|
|
66
|
+
symbols: stats.symbols,
|
|
67
|
+
size: `${sizeMB} MB`,
|
|
68
|
+
message: 'Index is less than 24 hours old. Use --force to regenerate.',
|
|
69
|
+
}, null, 2));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Report successful generation (markdown format)
|
|
73
|
+
*/
|
|
74
|
+
async function reportSuccessMarkdown(durationSec, indexPath, targetDir) {
|
|
75
|
+
const stats = await parseIndexStats(indexPath);
|
|
76
|
+
const sizeMB = getFileSizeMB(indexPath);
|
|
77
|
+
console.log(color('green', '\n✅ PROJECT_INDEX.json generated successfully\n'));
|
|
78
|
+
console.log(color('cyan', 'Stats:'));
|
|
79
|
+
console.log(` ${color('dim', '•')} Location: ${color('blue', targetDir)}`);
|
|
80
|
+
console.log(` ${color('dim', '•')} Files indexed: ${color('blue', stats.files.toString())}`);
|
|
81
|
+
console.log(` ${color('dim', '•')} Symbols extracted: ${color('blue', stats.symbols.toString())}`);
|
|
82
|
+
console.log(` ${color('dim', '•')} Index size: ${color('blue', `${sizeMB} MB`)}`);
|
|
83
|
+
console.log(` ${color('dim', '•')} Time taken: ${color('blue', `${durationSec.toFixed(1)}s`)}`);
|
|
84
|
+
console.log(color('cyan', '\nYou can now use:'));
|
|
85
|
+
console.log(` ${color('dim', '•')} ${color('magenta', 'bun run src/cli.ts find <symbol>')} - Find symbol definitions`);
|
|
86
|
+
console.log(` ${color('dim', '•')} ${color('magenta', 'bun run src/cli.ts callers <fn>')} - Find who calls a function`);
|
|
87
|
+
console.log(` ${color('dim', '•')} ${color('magenta', 'bun run src/cli.ts overview <file>')} - Get file symbol summary`);
|
|
88
|
+
console.log(` ${color('dim', '•')} ${color('magenta', 'bun run src/cli.ts stats')} - Codebase overview`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Report successful generation (JSON format)
|
|
92
|
+
*/
|
|
93
|
+
async function reportSuccessJSON(durationSec, indexPath, targetDir) {
|
|
94
|
+
const stats = await parseIndexStats(indexPath);
|
|
95
|
+
const sizeMB = getFileSizeMB(indexPath);
|
|
96
|
+
console.log(JSON.stringify({
|
|
97
|
+
success: true,
|
|
98
|
+
location: targetDir,
|
|
99
|
+
stats: {
|
|
100
|
+
files: stats.files,
|
|
101
|
+
symbols: stats.symbols,
|
|
102
|
+
hasTree: stats.hasTree,
|
|
103
|
+
size: `${sizeMB} MB`,
|
|
104
|
+
durationSec: Number.parseFloat(durationSec.toFixed(1)),
|
|
105
|
+
},
|
|
106
|
+
}, null, 2));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Execute prime command
|
|
110
|
+
*
|
|
111
|
+
* @param force - Force regenerate even if index is fresh
|
|
112
|
+
* @param format - Output format (markdown or JSON)
|
|
113
|
+
* @param customPath - Optional custom path to index (defaults to git root or CWD)
|
|
114
|
+
*/
|
|
115
|
+
export async function executePrime(force, format, customPath) {
|
|
116
|
+
try {
|
|
117
|
+
// Determine target directory and index path
|
|
118
|
+
const targetDir = await getTargetDir(customPath);
|
|
119
|
+
const indexPath = join(targetDir, INDEX_FILE);
|
|
120
|
+
const ageHours = getFileAgeHours(indexPath);
|
|
121
|
+
// Check if index exists and is fresh
|
|
122
|
+
if (ageHours !== null && ageHours <= MAX_AGE_HOURS && !force) {
|
|
123
|
+
if (format === OutputFormat.JSON) {
|
|
124
|
+
await reportExistingJSON(ageHours, indexPath, targetDir);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
await reportExistingMarkdown(ageHours, indexPath, targetDir);
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// Generate progress indicator (markdown only)
|
|
132
|
+
if (format === OutputFormat.MARKDOWN) {
|
|
133
|
+
console.log(color('blue', '▶ Generating index...'));
|
|
134
|
+
}
|
|
135
|
+
// Generate new index
|
|
136
|
+
const { durationSec } = await generateIndex(targetDir, indexPath);
|
|
137
|
+
// Report success
|
|
138
|
+
if (format === OutputFormat.JSON) {
|
|
139
|
+
await reportSuccessJSON(durationSec, indexPath, targetDir);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
await reportSuccessMarkdown(durationSec, indexPath, targetDir);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
if (format === OutputFormat.JSON) {
|
|
147
|
+
console.error(JSON.stringify({
|
|
148
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
149
|
+
isError: true,
|
|
150
|
+
}, null, 2));
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.error(color('red', '\n❌ Error:'), error);
|
|
154
|
+
// Check if kit is installed
|
|
155
|
+
try {
|
|
156
|
+
ensureCommandAvailable('kit');
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
console.error(color('yellow', '\n💡 Kit CLI not found. Install with:'));
|
|
160
|
+
console.error(color('dim', ' uv tool install cased-kit'));
|
|
161
|
+
console.error(color('dim', ' # or'));
|
|
162
|
+
console.error(color('dim', ' pipx install cased-kit'));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=prime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prime.js","sourceRoot":"","sources":["../../../src/lib/commands/prime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EACN,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAQzE;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAI9B,CAAA;IAED,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CACrD,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,EAC9B,CAAC,CACD,CAAA;IAED,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;QACxB,OAAO,EAAE,WAAW;QACpB,OAAO,EAAE,IAAI,CAAC,SAAS,KAAK,SAAS;KACrC,CAAA;AACF,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa,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;YAAC,MAAM,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,uCAAuC,CAAC,CAAC,CAAA;gBACvE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC,CAAA;gBAC1D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;gBACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC,CAAA;YACxD,CAAC;QACF,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic search command - Natural language code search
|
|
3
|
+
*
|
|
4
|
+
* Uses kit semantic search to find code by meaning rather than exact text.
|
|
5
|
+
* Gracefully falls back to grep if ML dependencies unavailable.
|
|
6
|
+
*/
|
|
7
|
+
import { OutputFormat } from '../formatters/output';
|
|
8
|
+
import type { SemanticOptions } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* Execute semantic search command
|
|
11
|
+
*
|
|
12
|
+
* Performs natural language search over codebase using vector embeddings.
|
|
13
|
+
* Shows warning with install instructions if semantic unavailable.
|
|
14
|
+
*
|
|
15
|
+
* @param query - Natural language search query
|
|
16
|
+
* @param options - Search options (path, topK, chunkBy, buildIndex)
|
|
17
|
+
* @param format - Output format (markdown or JSON)
|
|
18
|
+
*/
|
|
19
|
+
export declare function executeSearch(query: string, options: Omit<SemanticOptions, 'query'>, format: OutputFormat): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/search.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,KAAK,EAAiB,eAAe,EAAkB,MAAM,UAAU,CAAA;AAE9E;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,EACvC,MAAM,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAuEf"}
|