oh-my-claude-sisyphus 1.0.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/LICENSE +21 -0
- package/README.md +416 -0
- package/dist/agents/definitions.d.ts +48 -0
- package/dist/agents/definitions.d.ts.map +1 -0
- package/dist/agents/definitions.js +271 -0
- package/dist/agents/definitions.js.map +1 -0
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +5 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +280 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +5 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +49 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +329 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/features/continuation-enforcement.d.ts +34 -0
- package/dist/features/continuation-enforcement.d.ts.map +1 -0
- package/dist/features/continuation-enforcement.js +142 -0
- package/dist/features/continuation-enforcement.js.map +1 -0
- package/dist/features/index.d.ts +6 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +6 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/magic-keywords.d.ts +22 -0
- package/dist/features/magic-keywords.d.ts.map +1 -0
- package/dist/features/magic-keywords.js +189 -0
- package/dist/features/magic-keywords.js.map +1 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/servers.d.ts +77 -0
- package/dist/mcp/servers.d.ts.map +1 -0
- package/dist/mcp/servers.js +122 -0
- package/dist/mcp/servers.js.map +1 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/types.d.ts +133 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tools/ast-tools.d.ts +63 -0
- package/dist/tools/ast-tools.d.ts.map +1 -0
- package/dist/tools/ast-tools.js +349 -0
- package/dist/tools/ast-tools.js.map +1 -0
- package/dist/tools/index.d.ts +52 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +120 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/lsp/client.d.ts +201 -0
- package/dist/tools/lsp/client.d.ts.map +1 -0
- package/dist/tools/lsp/client.js +454 -0
- package/dist/tools/lsp/client.js.map +1 -0
- package/dist/tools/lsp/index.d.ts +9 -0
- package/dist/tools/lsp/index.d.ts.map +1 -0
- package/dist/tools/lsp/index.js +7 -0
- package/dist/tools/lsp/index.js.map +1 -0
- package/dist/tools/lsp/servers.d.ts +37 -0
- package/dist/tools/lsp/servers.d.ts.map +1 -0
- package/dist/tools/lsp/servers.js +148 -0
- package/dist/tools/lsp/servers.js.map +1 -0
- package/dist/tools/lsp/utils.d.ts +58 -0
- package/dist/tools/lsp/utils.d.ts.map +1 -0
- package/dist/tools/lsp/utils.js +236 -0
- package/dist/tools/lsp/utils.js.map +1 -0
- package/dist/tools/lsp-tools.d.ts +151 -0
- package/dist/tools/lsp-tools.d.ts.map +1 -0
- package/dist/tools/lsp-tools.js +358 -0
- package/dist/tools/lsp-tools.js.map +1 -0
- package/package.json +75 -0
- package/scripts/install.sh +765 -0
- package/scripts/uninstall.sh +47 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST Tools using ast-grep
|
|
3
|
+
*
|
|
4
|
+
* Provides AST-aware code search and transformation:
|
|
5
|
+
* - Pattern matching with meta-variables ($VAR, $$$)
|
|
6
|
+
* - Code replacement while preserving structure
|
|
7
|
+
* - Support for 25+ programming languages
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { readFileSync, readdirSync, statSync, writeFileSync } from 'fs';
|
|
11
|
+
import { join, extname, resolve } from 'path';
|
|
12
|
+
// Dynamic import for @ast-grep/napi (ESM module)
|
|
13
|
+
let sgModule = null;
|
|
14
|
+
async function getSgModule() {
|
|
15
|
+
if (!sgModule) {
|
|
16
|
+
sgModule = await import('@ast-grep/napi');
|
|
17
|
+
}
|
|
18
|
+
return sgModule;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Supported languages for AST analysis
|
|
22
|
+
* Maps to ast-grep language identifiers
|
|
23
|
+
*/
|
|
24
|
+
export const SUPPORTED_LANGUAGES = [
|
|
25
|
+
'javascript', 'typescript', 'tsx', 'python', 'ruby', 'go', 'rust',
|
|
26
|
+
'java', 'kotlin', 'swift', 'c', 'cpp', 'csharp',
|
|
27
|
+
'html', 'css', 'json', 'yaml'
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* Map file extensions to ast-grep language identifiers
|
|
31
|
+
*/
|
|
32
|
+
const EXT_TO_LANG = {
|
|
33
|
+
'.js': 'javascript',
|
|
34
|
+
'.mjs': 'javascript',
|
|
35
|
+
'.cjs': 'javascript',
|
|
36
|
+
'.jsx': 'javascript',
|
|
37
|
+
'.ts': 'typescript',
|
|
38
|
+
'.mts': 'typescript',
|
|
39
|
+
'.cts': 'typescript',
|
|
40
|
+
'.tsx': 'tsx',
|
|
41
|
+
'.py': 'python',
|
|
42
|
+
'.rb': 'ruby',
|
|
43
|
+
'.go': 'go',
|
|
44
|
+
'.rs': 'rust',
|
|
45
|
+
'.java': 'java',
|
|
46
|
+
'.kt': 'kotlin',
|
|
47
|
+
'.kts': 'kotlin',
|
|
48
|
+
'.swift': 'swift',
|
|
49
|
+
'.c': 'c',
|
|
50
|
+
'.h': 'c',
|
|
51
|
+
'.cpp': 'cpp',
|
|
52
|
+
'.cc': 'cpp',
|
|
53
|
+
'.cxx': 'cpp',
|
|
54
|
+
'.hpp': 'cpp',
|
|
55
|
+
'.cs': 'csharp',
|
|
56
|
+
'.html': 'html',
|
|
57
|
+
'.htm': 'html',
|
|
58
|
+
'.css': 'css',
|
|
59
|
+
'.json': 'json',
|
|
60
|
+
'.yaml': 'yaml',
|
|
61
|
+
'.yml': 'yaml'
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Get files matching the language in a directory
|
|
65
|
+
*/
|
|
66
|
+
function getFilesForLanguage(dirPath, language, maxFiles = 1000) {
|
|
67
|
+
const files = [];
|
|
68
|
+
const extensions = Object.entries(EXT_TO_LANG)
|
|
69
|
+
.filter(([_, lang]) => lang === language)
|
|
70
|
+
.map(([ext]) => ext);
|
|
71
|
+
function walk(dir) {
|
|
72
|
+
if (files.length >= maxFiles)
|
|
73
|
+
return;
|
|
74
|
+
try {
|
|
75
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
76
|
+
for (const entry of entries) {
|
|
77
|
+
if (files.length >= maxFiles)
|
|
78
|
+
return;
|
|
79
|
+
const fullPath = join(dir, entry.name);
|
|
80
|
+
// Skip common non-source directories
|
|
81
|
+
if (entry.isDirectory()) {
|
|
82
|
+
if (!['node_modules', '.git', 'dist', 'build', '__pycache__', '.venv', 'venv'].includes(entry.name)) {
|
|
83
|
+
walk(fullPath);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else if (entry.isFile()) {
|
|
87
|
+
const ext = extname(entry.name).toLowerCase();
|
|
88
|
+
if (extensions.includes(ext)) {
|
|
89
|
+
files.push(fullPath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Ignore permission errors
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const resolvedPath = resolve(dirPath);
|
|
99
|
+
const stat = statSync(resolvedPath);
|
|
100
|
+
if (stat.isFile()) {
|
|
101
|
+
return [resolvedPath];
|
|
102
|
+
}
|
|
103
|
+
walk(resolvedPath);
|
|
104
|
+
return files;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Format a match result for display
|
|
108
|
+
*/
|
|
109
|
+
function formatMatch(filePath, matchText, startLine, endLine, context, fileContent) {
|
|
110
|
+
const lines = fileContent.split('\n');
|
|
111
|
+
const contextStart = Math.max(0, startLine - context - 1);
|
|
112
|
+
const contextEnd = Math.min(lines.length, endLine + context);
|
|
113
|
+
const contextLines = lines.slice(contextStart, contextEnd);
|
|
114
|
+
const numberedLines = contextLines.map((line, i) => {
|
|
115
|
+
const lineNum = contextStart + i + 1;
|
|
116
|
+
const isMatch = lineNum >= startLine && lineNum <= endLine;
|
|
117
|
+
const prefix = isMatch ? '>' : ' ';
|
|
118
|
+
return `${prefix} ${lineNum.toString().padStart(4)}: ${line}`;
|
|
119
|
+
});
|
|
120
|
+
return `${filePath}:${startLine}\n${numberedLines.join('\n')}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* AST Grep Search Tool - Find code patterns using AST matching
|
|
124
|
+
*/
|
|
125
|
+
export const astGrepSearchTool = {
|
|
126
|
+
name: 'ast_grep_search',
|
|
127
|
+
description: `Search for code patterns using AST matching. More precise than text search.
|
|
128
|
+
|
|
129
|
+
Use meta-variables in patterns:
|
|
130
|
+
- $NAME - matches any single AST node (identifier, expression, etc.)
|
|
131
|
+
- $$$ARGS - matches multiple nodes (for function arguments, list items, etc.)
|
|
132
|
+
|
|
133
|
+
Examples:
|
|
134
|
+
- "function $NAME($$$ARGS)" - find all function declarations
|
|
135
|
+
- "console.log($MSG)" - find all console.log calls
|
|
136
|
+
- "if ($COND) { $$$BODY }" - find all if statements
|
|
137
|
+
- "$X === null" - find null equality checks
|
|
138
|
+
- "import $$$IMPORTS from '$MODULE'" - find imports
|
|
139
|
+
|
|
140
|
+
Note: Patterns must be valid AST nodes for the language.`,
|
|
141
|
+
schema: {
|
|
142
|
+
pattern: z.string().describe('AST pattern with meta-variables ($VAR, $$$VARS)'),
|
|
143
|
+
language: z.enum(SUPPORTED_LANGUAGES).describe('Programming language'),
|
|
144
|
+
path: z.string().optional().describe('Directory or file to search (default: current directory)'),
|
|
145
|
+
context: z.number().int().min(0).max(10).optional().describe('Lines of context around matches (default: 2)'),
|
|
146
|
+
maxResults: z.number().int().min(1).max(100).optional().describe('Maximum results to return (default: 20)')
|
|
147
|
+
},
|
|
148
|
+
handler: async (args) => {
|
|
149
|
+
const { pattern, language, path = '.', context = 2, maxResults = 20 } = args;
|
|
150
|
+
try {
|
|
151
|
+
const sg = await getSgModule();
|
|
152
|
+
const files = getFilesForLanguage(path, language);
|
|
153
|
+
if (files.length === 0) {
|
|
154
|
+
return {
|
|
155
|
+
content: [{
|
|
156
|
+
type: 'text',
|
|
157
|
+
text: `No ${language} files found in ${path}`
|
|
158
|
+
}]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const results = [];
|
|
162
|
+
let totalMatches = 0;
|
|
163
|
+
for (const filePath of files) {
|
|
164
|
+
if (totalMatches >= maxResults)
|
|
165
|
+
break;
|
|
166
|
+
try {
|
|
167
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
168
|
+
const root = sg.parse(language, content).root();
|
|
169
|
+
const matches = root.findAll(pattern);
|
|
170
|
+
for (const match of matches) {
|
|
171
|
+
if (totalMatches >= maxResults)
|
|
172
|
+
break;
|
|
173
|
+
const range = match.range();
|
|
174
|
+
const startLine = range.start.line + 1;
|
|
175
|
+
const endLine = range.end.line + 1;
|
|
176
|
+
results.push(formatMatch(filePath, match.text(), startLine, endLine, context, content));
|
|
177
|
+
totalMatches++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// Skip files that fail to parse
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (results.length === 0) {
|
|
185
|
+
return {
|
|
186
|
+
content: [{
|
|
187
|
+
type: 'text',
|
|
188
|
+
text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}\n\nTip: Ensure the pattern is a valid AST node. For example:\n- Use "function $NAME" not just "$NAME"\n- Use "console.log($X)" not "console.log"`
|
|
189
|
+
}]
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const header = `Found ${totalMatches} match(es) in ${files.length} file(s)\nPattern: ${pattern}\n\n`;
|
|
193
|
+
return {
|
|
194
|
+
content: [{
|
|
195
|
+
type: 'text',
|
|
196
|
+
text: header + results.join('\n\n---\n\n')
|
|
197
|
+
}]
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
return {
|
|
202
|
+
content: [{
|
|
203
|
+
type: 'text',
|
|
204
|
+
text: `Error in AST search: ${error instanceof Error ? error.message : String(error)}\n\nCommon issues:\n- Pattern must be a complete AST node\n- Language must match file type\n- Check that @ast-grep/napi is installed`
|
|
205
|
+
}]
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* AST Grep Replace Tool - Replace code patterns using AST matching
|
|
212
|
+
*/
|
|
213
|
+
export const astGrepReplaceTool = {
|
|
214
|
+
name: 'ast_grep_replace',
|
|
215
|
+
description: `Replace code patterns using AST matching. Preserves matched content via meta-variables.
|
|
216
|
+
|
|
217
|
+
Use meta-variables in both pattern and replacement:
|
|
218
|
+
- $NAME in pattern captures a node, use $NAME in replacement to insert it
|
|
219
|
+
- $$$ARGS captures multiple nodes
|
|
220
|
+
|
|
221
|
+
Examples:
|
|
222
|
+
- Pattern: "console.log($MSG)" → Replacement: "logger.info($MSG)"
|
|
223
|
+
- Pattern: "var $NAME = $VALUE" → Replacement: "const $NAME = $VALUE"
|
|
224
|
+
- Pattern: "$OBJ.forEach(($ITEM) => { $$$BODY })" → Replacement: "for (const $ITEM of $OBJ) { $$$BODY }"
|
|
225
|
+
|
|
226
|
+
IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to apply.`,
|
|
227
|
+
schema: {
|
|
228
|
+
pattern: z.string().describe('Pattern to match'),
|
|
229
|
+
replacement: z.string().describe('Replacement pattern (use same meta-variables)'),
|
|
230
|
+
language: z.enum(SUPPORTED_LANGUAGES).describe('Programming language'),
|
|
231
|
+
path: z.string().optional().describe('Directory or file to search (default: current directory)'),
|
|
232
|
+
dryRun: z.boolean().optional().describe('Preview only, don\'t apply changes (default: true)')
|
|
233
|
+
},
|
|
234
|
+
handler: async (args) => {
|
|
235
|
+
const { pattern, replacement, language, path = '.', dryRun = true } = args;
|
|
236
|
+
try {
|
|
237
|
+
const sg = await getSgModule();
|
|
238
|
+
const files = getFilesForLanguage(path, language);
|
|
239
|
+
if (files.length === 0) {
|
|
240
|
+
return {
|
|
241
|
+
content: [{
|
|
242
|
+
type: 'text',
|
|
243
|
+
text: `No ${language} files found in ${path}`
|
|
244
|
+
}]
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
const changes = [];
|
|
248
|
+
let totalReplacements = 0;
|
|
249
|
+
for (const filePath of files) {
|
|
250
|
+
try {
|
|
251
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
252
|
+
const root = sg.parse(language, content).root();
|
|
253
|
+
const matches = root.findAll(pattern);
|
|
254
|
+
if (matches.length === 0)
|
|
255
|
+
continue;
|
|
256
|
+
// Collect all edits for this file
|
|
257
|
+
const edits = [];
|
|
258
|
+
for (const match of matches) {
|
|
259
|
+
const range = match.range();
|
|
260
|
+
const startOffset = range.start.index;
|
|
261
|
+
const endOffset = range.end.index;
|
|
262
|
+
// Build replacement by substituting meta-variables
|
|
263
|
+
let finalReplacement = replacement;
|
|
264
|
+
// Get all captured meta-variables
|
|
265
|
+
// ast-grep captures are accessed via match.getMatch() or by variable name
|
|
266
|
+
// For simplicity, we'll use a basic approach here
|
|
267
|
+
const matchedText = match.text();
|
|
268
|
+
// Try to get named captures
|
|
269
|
+
try {
|
|
270
|
+
// Replace meta-variables in the replacement string
|
|
271
|
+
const metaVars = replacement.match(/\$\$?\$?[A-Z_][A-Z0-9_]*/g) || [];
|
|
272
|
+
for (const metaVar of metaVars) {
|
|
273
|
+
const varName = metaVar.replace(/^\$+/, '');
|
|
274
|
+
const captured = match.getMatch(varName);
|
|
275
|
+
if (captured) {
|
|
276
|
+
finalReplacement = finalReplacement.replace(metaVar, captured.text());
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// If meta-variable extraction fails, use pattern as-is
|
|
282
|
+
}
|
|
283
|
+
edits.push({
|
|
284
|
+
start: startOffset,
|
|
285
|
+
end: endOffset,
|
|
286
|
+
replacement: finalReplacement,
|
|
287
|
+
line: range.start.line + 1,
|
|
288
|
+
before: matchedText
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
// Sort edits in reverse order to apply from end to start
|
|
292
|
+
edits.sort((a, b) => b.start - a.start);
|
|
293
|
+
let newContent = content;
|
|
294
|
+
for (const edit of edits) {
|
|
295
|
+
const before = newContent.slice(edit.start, edit.end);
|
|
296
|
+
newContent = newContent.slice(0, edit.start) + edit.replacement + newContent.slice(edit.end);
|
|
297
|
+
changes.push({
|
|
298
|
+
file: filePath,
|
|
299
|
+
before,
|
|
300
|
+
after: edit.replacement,
|
|
301
|
+
line: edit.line
|
|
302
|
+
});
|
|
303
|
+
totalReplacements++;
|
|
304
|
+
}
|
|
305
|
+
if (!dryRun && edits.length > 0) {
|
|
306
|
+
writeFileSync(filePath, newContent, 'utf-8');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
// Skip files that fail to parse
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (changes.length === 0) {
|
|
314
|
+
return {
|
|
315
|
+
content: [{
|
|
316
|
+
type: 'text',
|
|
317
|
+
text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}`
|
|
318
|
+
}]
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const mode = dryRun ? 'DRY RUN (no changes applied)' : 'CHANGES APPLIED';
|
|
322
|
+
const header = `${mode}\n\nFound ${totalReplacements} replacement(s) in ${files.length} file(s)\nPattern: ${pattern}\nReplacement: ${replacement}\n\n`;
|
|
323
|
+
const changeList = changes.slice(0, 50).map(c => `${c.file}:${c.line}\n - ${c.before}\n + ${c.after}`).join('\n\n');
|
|
324
|
+
const footer = changes.length > 50 ? `\n\n... and ${changes.length - 50} more changes` : '';
|
|
325
|
+
return {
|
|
326
|
+
content: [{
|
|
327
|
+
type: 'text',
|
|
328
|
+
text: header + changeList + footer + (dryRun ? '\n\nTo apply changes, run with dryRun: false' : '')
|
|
329
|
+
}]
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
return {
|
|
334
|
+
content: [{
|
|
335
|
+
type: 'text',
|
|
336
|
+
text: `Error in AST replace: ${error instanceof Error ? error.message : String(error)}`
|
|
337
|
+
}]
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Get all AST tool definitions
|
|
344
|
+
*/
|
|
345
|
+
export const astTools = [
|
|
346
|
+
astGrepSearchTool,
|
|
347
|
+
astGrepReplaceTool
|
|
348
|
+
];
|
|
349
|
+
//# sourceMappingURL=ast-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-tools.js","sourceRoot":"","sources":["../../src/tools/ast-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,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C,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAC9C,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,KAAK,EAAE,CACvD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEf,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,eAAe,OAAO,CAAC,MAAM,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;YAE5F,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,EAAE,CAAC;qBACpG,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;qBACxF,CAAC;aACH,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,iBAAiB;IACjB,kBAAkB;CACnB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry and MCP Server Creation
|
|
3
|
+
*
|
|
4
|
+
* This module exports all custom tools and provides helpers
|
|
5
|
+
* for creating MCP servers with the Claude Agent SDK.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export { lspTools } from './lsp-tools.js';
|
|
9
|
+
export { astTools } from './ast-tools.js';
|
|
10
|
+
/**
|
|
11
|
+
* Generic tool definition type
|
|
12
|
+
*/
|
|
13
|
+
export interface GenericToolDefinition {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
schema: z.ZodRawShape;
|
|
17
|
+
handler: (args: unknown) => Promise<{
|
|
18
|
+
content: Array<{
|
|
19
|
+
type: 'text';
|
|
20
|
+
text: string;
|
|
21
|
+
}>;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* All custom tools available in the system
|
|
26
|
+
*/
|
|
27
|
+
export declare const allCustomTools: GenericToolDefinition[];
|
|
28
|
+
/**
|
|
29
|
+
* Get tools by category
|
|
30
|
+
*/
|
|
31
|
+
export declare function getToolsByCategory(category: 'lsp' | 'ast' | 'all'): GenericToolDefinition[];
|
|
32
|
+
/**
|
|
33
|
+
* Create a Zod schema object from a tool's schema definition
|
|
34
|
+
*/
|
|
35
|
+
export declare function createZodSchema<T extends z.ZodRawShape>(schema: T): z.ZodObject<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Format for creating tools compatible with Claude Agent SDK
|
|
38
|
+
*/
|
|
39
|
+
export interface SdkToolFormat {
|
|
40
|
+
name: string;
|
|
41
|
+
description: string;
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: 'object';
|
|
44
|
+
properties: Record<string, unknown>;
|
|
45
|
+
required: string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert our tool definitions to SDK format
|
|
50
|
+
*/
|
|
51
|
+
export declare function toSdkToolFormat(tool: GenericToolDefinition): SdkToolFormat;
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACzF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,qBAAqB,EAGjD,CAAC;AAEF;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,qBAAqB,EAAE,CAS3F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAElF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,qBAAqB,GAAG,aAAa,CAS1E"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry and MCP Server Creation
|
|
3
|
+
*
|
|
4
|
+
* This module exports all custom tools and provides helpers
|
|
5
|
+
* for creating MCP servers with the Claude Agent SDK.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { lspTools } from './lsp-tools.js';
|
|
9
|
+
import { astTools } from './ast-tools.js';
|
|
10
|
+
export { lspTools } from './lsp-tools.js';
|
|
11
|
+
export { astTools } from './ast-tools.js';
|
|
12
|
+
/**
|
|
13
|
+
* All custom tools available in the system
|
|
14
|
+
*/
|
|
15
|
+
export const allCustomTools = [
|
|
16
|
+
...lspTools,
|
|
17
|
+
...astTools
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Get tools by category
|
|
21
|
+
*/
|
|
22
|
+
export function getToolsByCategory(category) {
|
|
23
|
+
switch (category) {
|
|
24
|
+
case 'lsp':
|
|
25
|
+
return lspTools;
|
|
26
|
+
case 'ast':
|
|
27
|
+
return astTools;
|
|
28
|
+
case 'all':
|
|
29
|
+
return allCustomTools;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create a Zod schema object from a tool's schema definition
|
|
34
|
+
*/
|
|
35
|
+
export function createZodSchema(schema) {
|
|
36
|
+
return z.object(schema);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Convert our tool definitions to SDK format
|
|
40
|
+
*/
|
|
41
|
+
export function toSdkToolFormat(tool) {
|
|
42
|
+
const zodSchema = z.object(tool.schema);
|
|
43
|
+
const jsonSchema = zodToJsonSchema(zodSchema);
|
|
44
|
+
return {
|
|
45
|
+
name: tool.name,
|
|
46
|
+
description: tool.description,
|
|
47
|
+
inputSchema: jsonSchema
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Simple Zod to JSON Schema converter for tool definitions
|
|
52
|
+
*/
|
|
53
|
+
function zodToJsonSchema(schema) {
|
|
54
|
+
const shape = schema.shape;
|
|
55
|
+
const properties = {};
|
|
56
|
+
const required = [];
|
|
57
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
58
|
+
const zodType = value;
|
|
59
|
+
properties[key] = zodTypeToJsonSchema(zodType);
|
|
60
|
+
// Check if the field is required (not optional)
|
|
61
|
+
if (!zodType.isOptional()) {
|
|
62
|
+
required.push(key);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties,
|
|
68
|
+
required
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert individual Zod types to JSON Schema
|
|
73
|
+
*/
|
|
74
|
+
function zodTypeToJsonSchema(zodType) {
|
|
75
|
+
const result = {};
|
|
76
|
+
// Handle optional wrapper
|
|
77
|
+
if (zodType instanceof z.ZodOptional) {
|
|
78
|
+
return zodTypeToJsonSchema(zodType._def.innerType);
|
|
79
|
+
}
|
|
80
|
+
// Handle default wrapper
|
|
81
|
+
if (zodType instanceof z.ZodDefault) {
|
|
82
|
+
const inner = zodTypeToJsonSchema(zodType._def.innerType);
|
|
83
|
+
inner.default = zodType._def.defaultValue();
|
|
84
|
+
return inner;
|
|
85
|
+
}
|
|
86
|
+
// Get description if available
|
|
87
|
+
const description = zodType._def.description;
|
|
88
|
+
if (description) {
|
|
89
|
+
result.description = description;
|
|
90
|
+
}
|
|
91
|
+
// Handle basic types
|
|
92
|
+
if (zodType instanceof z.ZodString) {
|
|
93
|
+
result.type = 'string';
|
|
94
|
+
}
|
|
95
|
+
else if (zodType instanceof z.ZodNumber) {
|
|
96
|
+
result.type = zodType._def.checks?.some((c) => c.kind === 'int')
|
|
97
|
+
? 'integer'
|
|
98
|
+
: 'number';
|
|
99
|
+
}
|
|
100
|
+
else if (zodType instanceof z.ZodBoolean) {
|
|
101
|
+
result.type = 'boolean';
|
|
102
|
+
}
|
|
103
|
+
else if (zodType instanceof z.ZodArray) {
|
|
104
|
+
result.type = 'array';
|
|
105
|
+
result.items = zodTypeToJsonSchema(zodType._def.type);
|
|
106
|
+
}
|
|
107
|
+
else if (zodType instanceof z.ZodEnum) {
|
|
108
|
+
result.type = 'string';
|
|
109
|
+
result.enum = zodType._def.values;
|
|
110
|
+
}
|
|
111
|
+
else if (zodType instanceof z.ZodObject) {
|
|
112
|
+
return zodToJsonSchema(zodType);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// Fallback for unknown types
|
|
116
|
+
result.type = 'string';
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY1C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA4B;IACrD,GAAG,QAA8C;IACjD,GAAG,QAA8C;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAA+B;IAChE,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,KAAK;YACR,OAAO,QAA8C,CAAC;QACxD,KAAK,KAAK;YACR,OAAO,QAA8C,CAAC;QACxD,KAAK,KAAK;YACR,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAA0B,MAAS;IAChE,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAeD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAA2B;IACzD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,CA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