@stan-chen/simple-cli 0.2.3 → 0.2.4

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.
Files changed (136) hide show
  1. package/README.md +62 -63
  2. package/dist/anyllm.py +62 -0
  3. package/dist/builtins.d.ts +726 -0
  4. package/dist/builtins.js +481 -0
  5. package/dist/cli.d.ts +0 -4
  6. package/dist/cli.js +34 -493
  7. package/dist/engine.d.ts +33 -0
  8. package/dist/engine.js +138 -0
  9. package/dist/learnings.d.ts +15 -0
  10. package/dist/learnings.js +54 -0
  11. package/dist/llm.d.ts +18 -0
  12. package/dist/llm.js +66 -0
  13. package/dist/mcp.d.ts +132 -0
  14. package/dist/mcp.js +43 -0
  15. package/dist/skills.d.ts +5 -16
  16. package/dist/skills.js +91 -253
  17. package/dist/tui.d.ts +1 -0
  18. package/dist/tui.js +10 -0
  19. package/package.json +10 -6
  20. package/dist/claw/jit.d.ts +0 -5
  21. package/dist/claw/jit.js +0 -138
  22. package/dist/claw/management.d.ts +0 -3
  23. package/dist/claw/management.js +0 -107
  24. package/dist/commands/add.d.ts +0 -9
  25. package/dist/commands/add.js +0 -50
  26. package/dist/commands/git/commit.d.ts +0 -12
  27. package/dist/commands/git/commit.js +0 -98
  28. package/dist/commands/git/status.d.ts +0 -6
  29. package/dist/commands/git/status.js +0 -42
  30. package/dist/commands/index.d.ts +0 -16
  31. package/dist/commands/index.js +0 -377
  32. package/dist/commands/mcp/status.d.ts +0 -6
  33. package/dist/commands/mcp/status.js +0 -31
  34. package/dist/commands/swarm.d.ts +0 -36
  35. package/dist/commands/swarm.js +0 -236
  36. package/dist/commands.d.ts +0 -32
  37. package/dist/commands.js +0 -427
  38. package/dist/context.d.ts +0 -116
  39. package/dist/context.js +0 -337
  40. package/dist/index.d.ts +0 -6
  41. package/dist/index.js +0 -109
  42. package/dist/lib/agent.d.ts +0 -99
  43. package/dist/lib/agent.js +0 -313
  44. package/dist/lib/editor.d.ts +0 -74
  45. package/dist/lib/editor.js +0 -441
  46. package/dist/lib/git.d.ts +0 -164
  47. package/dist/lib/git.js +0 -356
  48. package/dist/lib/shim.d.ts +0 -4
  49. package/dist/lib/shim.js +0 -30
  50. package/dist/lib/ui.d.ts +0 -159
  51. package/dist/lib/ui.js +0 -277
  52. package/dist/mcp/client.d.ts +0 -22
  53. package/dist/mcp/client.js +0 -81
  54. package/dist/mcp/manager.d.ts +0 -186
  55. package/dist/mcp/manager.js +0 -446
  56. package/dist/prompts/provider.d.ts +0 -22
  57. package/dist/prompts/provider.js +0 -79
  58. package/dist/providers/index.d.ts +0 -31
  59. package/dist/providers/index.js +0 -93
  60. package/dist/providers/multi.d.ts +0 -12
  61. package/dist/providers/multi.js +0 -28
  62. package/dist/registry.d.ts +0 -29
  63. package/dist/registry.js +0 -443
  64. package/dist/repoMap.d.ts +0 -5
  65. package/dist/repoMap.js +0 -79
  66. package/dist/router.d.ts +0 -41
  67. package/dist/router.js +0 -118
  68. package/dist/swarm/coordinator.d.ts +0 -86
  69. package/dist/swarm/coordinator.js +0 -257
  70. package/dist/swarm/index.d.ts +0 -28
  71. package/dist/swarm/index.js +0 -29
  72. package/dist/swarm/task.d.ts +0 -104
  73. package/dist/swarm/task.js +0 -221
  74. package/dist/swarm/types.d.ts +0 -132
  75. package/dist/swarm/types.js +0 -37
  76. package/dist/swarm/worker.d.ts +0 -109
  77. package/dist/swarm/worker.js +0 -369
  78. package/dist/tools/analyzeFile.d.ts +0 -16
  79. package/dist/tools/analyzeFile.js +0 -43
  80. package/dist/tools/analyze_file.d.ts +0 -16
  81. package/dist/tools/analyze_file.js +0 -43
  82. package/dist/tools/clawBrain.d.ts +0 -23
  83. package/dist/tools/clawBrain.js +0 -136
  84. package/dist/tools/claw_brain.d.ts +0 -23
  85. package/dist/tools/claw_brain.js +0 -139
  86. package/dist/tools/deleteFile.d.ts +0 -19
  87. package/dist/tools/deleteFile.js +0 -36
  88. package/dist/tools/delete_file.d.ts +0 -19
  89. package/dist/tools/delete_file.js +0 -36
  90. package/dist/tools/fileOps.d.ts +0 -22
  91. package/dist/tools/fileOps.js +0 -43
  92. package/dist/tools/file_ops.d.ts +0 -22
  93. package/dist/tools/file_ops.js +0 -43
  94. package/dist/tools/git.d.ts +0 -40
  95. package/dist/tools/git.js +0 -236
  96. package/dist/tools/glob.d.ts +0 -34
  97. package/dist/tools/glob.js +0 -165
  98. package/dist/tools/grep.d.ts +0 -53
  99. package/dist/tools/grep.js +0 -296
  100. package/dist/tools/linter.d.ts +0 -35
  101. package/dist/tools/linter.js +0 -407
  102. package/dist/tools/listDir.d.ts +0 -29
  103. package/dist/tools/listDir.js +0 -50
  104. package/dist/tools/list_dir.d.ts +0 -29
  105. package/dist/tools/list_dir.js +0 -50
  106. package/dist/tools/memory.d.ts +0 -34
  107. package/dist/tools/memory.js +0 -215
  108. package/dist/tools/organizer.d.ts +0 -1
  109. package/dist/tools/organizer.js +0 -65
  110. package/dist/tools/readFiles.d.ts +0 -25
  111. package/dist/tools/readFiles.js +0 -31
  112. package/dist/tools/read_files.d.ts +0 -25
  113. package/dist/tools/read_files.js +0 -31
  114. package/dist/tools/reloadTools.d.ts +0 -11
  115. package/dist/tools/reloadTools.js +0 -22
  116. package/dist/tools/reload_tools.d.ts +0 -11
  117. package/dist/tools/reload_tools.js +0 -22
  118. package/dist/tools/runCommand.d.ts +0 -32
  119. package/dist/tools/runCommand.js +0 -79
  120. package/dist/tools/run_command.d.ts +0 -32
  121. package/dist/tools/run_command.js +0 -103
  122. package/dist/tools/scheduler.d.ts +0 -25
  123. package/dist/tools/scheduler.js +0 -65
  124. package/dist/tools/scraper.d.ts +0 -31
  125. package/dist/tools/scraper.js +0 -211
  126. package/dist/tools/writeFiles.d.ts +0 -63
  127. package/dist/tools/writeFiles.js +0 -87
  128. package/dist/tools/write_files.d.ts +0 -84
  129. package/dist/tools/write_files.js +0 -91
  130. package/dist/tools/write_to_file.d.ts +0 -15
  131. package/dist/tools/write_to_file.js +0 -21
  132. package/dist/ui/server.d.ts +0 -5
  133. package/dist/ui/server.js +0 -74
  134. package/dist/watcher.d.ts +0 -35
  135. package/dist/watcher.js +0 -164
  136. /package/{docs/assets → assets}/logo.jpeg +0 -0
@@ -1,407 +0,0 @@
1
- /**
2
- * Linter Tool - Checks code for syntax errors
3
- * Based on Aider's linter.py
4
- */
5
- import { z } from 'zod';
6
- import { execSync, spawnSync } from 'child_process';
7
- import { readFileSync, existsSync } from 'fs';
8
- import { extname, basename } from 'path';
9
- import { platform } from 'os';
10
- // Input schema
11
- export const inputSchema = z.object({
12
- path: z.string().describe('Path to file to lint'),
13
- fix: z.boolean().optional().default(false).describe('Attempt to auto-fix issues'),
14
- });
15
- // Language detection based on file extension
16
- const LANGUAGE_MAP = {
17
- '.py': 'python',
18
- '.js': 'javascript',
19
- '.jsx': 'javascript',
20
- '.ts': 'typescript',
21
- '.tsx': 'typescript',
22
- '.rb': 'ruby',
23
- '.go': 'go',
24
- '.rs': 'rust',
25
- '.java': 'java',
26
- '.c': 'c',
27
- '.cpp': 'cpp',
28
- '.h': 'c',
29
- '.hpp': 'cpp',
30
- '.cs': 'csharp',
31
- '.php': 'php',
32
- '.swift': 'swift',
33
- '.kt': 'kotlin',
34
- '.scala': 'scala',
35
- '.sh': 'shell',
36
- '.bash': 'shell',
37
- '.zsh': 'shell',
38
- };
39
- // Detect language from file
40
- function detectLanguage(filePath) {
41
- const ext = extname(filePath).toLowerCase();
42
- return LANGUAGE_MAP[ext] || null;
43
- }
44
- // Detect if a binary exists in PATH
45
- function detectBinary(bin) {
46
- try {
47
- const isWin = platform() === 'win32';
48
- const cmd = isWin ? 'where' : 'which';
49
- execSync(`${cmd} ${bin}`, { stdio: 'ignore' });
50
- return true;
51
- }
52
- catch {
53
- return false;
54
- }
55
- }
56
- // Get correct python binary
57
- function getPythonBinary() {
58
- if (detectBinary('python3'))
59
- return 'python3';
60
- if (detectBinary('python'))
61
- return 'python';
62
- return null;
63
- }
64
- // Platform agnostic /dev/null
65
- function getNullDevice() {
66
- return platform() === 'win32' ? 'NUL' : '/dev/null';
67
- }
68
- // Parse error output for line numbers
69
- function parseErrors(output, filePath) {
70
- const errors = [];
71
- const fileName = basename(filePath);
72
- const escapedFileName = fileName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
73
- const escapedFilePath = filePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
74
- // Common patterns for error messages: file:line:col: message
75
- // groups: [lineIndex, columnIndex (or -1), messageIndex (or -1)]
76
- const patterns = [
77
- // Python/flake8/eslint style: file.py:10:5: E501 line too long
78
- { regex: new RegExp(`(?:${escapedFileName}|${escapedFilePath}):(\\d+)(?::(\\d+))?:\\s*(.+)`, 'gm'), groups: [1, 2, 3] },
79
- // TypeScript/tsc style: file.ts(10,5): error TS1234: message
80
- { regex: new RegExp(`(?:${escapedFileName}|${escapedFilePath})\\((\\d+),(\\d+)\\):\\s*(\\w+)\\s+(.+)`, 'gm'), groups: [1, 2, 4] },
81
- // Python py_compile style: File "file.py", line 10
82
- { regex: /File\s+"[^"]+",\s+line\s+(\d+)/gim, groups: [1, -1, -1] },
83
- // Generic line number: line 10: message
84
- { regex: /line\s+(\d+):\s*(.+)/gim, groups: [1, -1, 2] },
85
- ];
86
- // Also capture standalone error messages like "SyntaxError: ..."
87
- const syntaxErrorMatch = output.match(/(SyntaxError|IndentationError|TabError):\s*(.+)/i);
88
- const syntaxErrorMessage = syntaxErrorMatch ? `${syntaxErrorMatch[1]}: ${syntaxErrorMatch[2]}` : null;
89
- for (const { regex, groups } of patterns) {
90
- let match;
91
- while ((match = regex.exec(output)) !== null) {
92
- const [lineIdx, colIdx, msgIdx] = groups;
93
- const line = parseInt(match[lineIdx], 10);
94
- const column = colIdx >= 0 && match[colIdx] ? parseInt(match[colIdx], 10) : undefined;
95
- let message = msgIdx >= 0 && match[msgIdx] ? match[msgIdx].trim() : '';
96
- // Use syntax error message if we found one and this pattern doesn't have a message
97
- if (!message && syntaxErrorMessage) {
98
- message = syntaxErrorMessage;
99
- }
100
- if (line > 0) {
101
- errors.push({
102
- line,
103
- column,
104
- message: message || 'Syntax error',
105
- severity: 'error',
106
- });
107
- }
108
- }
109
- }
110
- // Deduplicate errors by line number
111
- const seen = new Set();
112
- return errors.filter(e => {
113
- if (seen.has(e.line))
114
- return false;
115
- seen.add(e.line);
116
- return true;
117
- });
118
- }
119
- // Python syntax check using compile
120
- function lintPython(filePath, code) {
121
- const errors = [];
122
- let output = '';
123
- const pythonBin = getPythonBinary();
124
- if (!pythonBin) {
125
- return {
126
- file: filePath,
127
- language: 'python',
128
- errors: [],
129
- warnings: [],
130
- passed: true, // skipped
131
- output: 'Python binary not found, skipping lint.',
132
- };
133
- }
134
- // Try Python syntax check
135
- try {
136
- const result = spawnSync(pythonBin, ['-m', 'py_compile', filePath], {
137
- encoding: 'utf-8',
138
- timeout: 10000,
139
- });
140
- if (result.status !== 0) {
141
- output = result.stderr || result.stdout || '';
142
- errors.push(...parseErrors(output, filePath));
143
- }
144
- }
145
- catch {
146
- // Fall back to basic syntax check
147
- try {
148
- execSync(`${pythonBin} -c "compile(open('${filePath}').read(), '${filePath}', 'exec')"`, {
149
- encoding: 'utf-8',
150
- timeout: 10000,
151
- });
152
- }
153
- catch (e) {
154
- if (e instanceof Error) {
155
- output = e.message;
156
- errors.push(...parseErrors(output, filePath));
157
- }
158
- }
159
- }
160
- // Try flake8 for additional checks
161
- try {
162
- const result = spawnSync(pythonBin, ['-m', 'flake8', '--select=E9,F821,F823,F831,F406,F407,F701,F702,F704,F706', filePath], {
163
- encoding: 'utf-8',
164
- timeout: 10000,
165
- });
166
- if (result.stdout) {
167
- output += '\n' + result.stdout;
168
- errors.push(...parseErrors(result.stdout, filePath));
169
- }
170
- }
171
- catch {
172
- // flake8 not available, skip
173
- }
174
- return {
175
- file: filePath,
176
- language: 'python',
177
- errors: errors.filter(e => e.severity === 'error'),
178
- warnings: errors.filter(e => e.severity === 'warning'),
179
- passed: errors.filter(e => e.severity === 'error').length === 0,
180
- output: output.trim(),
181
- };
182
- }
183
- // JavaScript/TypeScript linting
184
- function lintJavaScript(filePath, code, isTypeScript) {
185
- const errors = [];
186
- let output = '';
187
- const language = isTypeScript ? 'typescript' : 'javascript';
188
- // Basic syntax check using Node.js
189
- try {
190
- if (isTypeScript) {
191
- // Try tsc for TypeScript
192
- const result = spawnSync('npx', ['tsc', '--noEmit', '--skipLibCheck', filePath], {
193
- encoding: 'utf-8',
194
- timeout: 30000,
195
- shell: platform() === 'win32' // Required for npx on Windows
196
- });
197
- if (result.status !== 0) {
198
- output = (result.stdout || '') + (result.stderr || '');
199
- errors.push(...parseErrors(output, filePath));
200
- }
201
- }
202
- else {
203
- // Use Node's vm module for JavaScript syntax check
204
- const result = spawnSync('node', ['--check', filePath], {
205
- encoding: 'utf-8',
206
- timeout: 10000,
207
- });
208
- if (result.status !== 0) {
209
- output = result.stderr || '';
210
- errors.push(...parseErrors(output, filePath));
211
- }
212
- }
213
- }
214
- catch (e) {
215
- if (e instanceof Error) {
216
- output = e.message;
217
- }
218
- }
219
- // Try ESLint
220
- try {
221
- const result = spawnSync('npx', ['eslint', '--format', 'compact', filePath], {
222
- encoding: 'utf-8',
223
- timeout: 30000,
224
- shell: platform() === 'win32'
225
- });
226
- if (result.stdout) {
227
- output += '\n' + result.stdout;
228
- errors.push(...parseErrors(result.stdout, filePath));
229
- }
230
- }
231
- catch {
232
- // ESLint not available
233
- }
234
- return {
235
- file: filePath,
236
- language,
237
- errors: errors.filter(e => e.severity === 'error'),
238
- warnings: errors.filter(e => e.severity === 'warning'),
239
- passed: errors.filter(e => e.severity === 'error').length === 0,
240
- output: output.trim(),
241
- };
242
- }
243
- // Go linting
244
- function lintGo(filePath) {
245
- if (!detectBinary('go')) {
246
- return {
247
- file: filePath, language: 'go', errors: [], warnings: [], passed: true, output: 'Go not found'
248
- };
249
- }
250
- const errors = [];
251
- let output = '';
252
- try {
253
- const result = spawnSync('go', ['vet', filePath], {
254
- encoding: 'utf-8',
255
- timeout: 30000,
256
- });
257
- output = result.stderr + result.stdout;
258
- if (result.status !== 0) {
259
- errors.push(...parseErrors(output, filePath));
260
- }
261
- }
262
- catch (e) {
263
- if (e instanceof Error) {
264
- output = e.message;
265
- }
266
- }
267
- return {
268
- file: filePath,
269
- language: 'go',
270
- errors: errors.filter(e => e.severity === 'error'),
271
- warnings: errors.filter(e => e.severity === 'warning'),
272
- passed: errors.filter(e => e.severity === 'error').length === 0,
273
- output: output.trim(),
274
- };
275
- }
276
- // Rust linting
277
- function lintRust(filePath) {
278
- if (!detectBinary('rustc')) {
279
- return {
280
- file: filePath, language: 'rust', errors: [], warnings: [], passed: true, output: 'Rustc not found'
281
- };
282
- }
283
- const errors = [];
284
- let output = '';
285
- try {
286
- const result = spawnSync('rustc', ['--emit=metadata', '-o', getNullDevice(), filePath], {
287
- encoding: 'utf-8',
288
- timeout: 30000,
289
- });
290
- output = result.stderr + result.stdout;
291
- if (result.status !== 0) {
292
- errors.push(...parseErrors(output, filePath));
293
- }
294
- }
295
- catch (e) {
296
- if (e instanceof Error) {
297
- output = e.message;
298
- }
299
- }
300
- return {
301
- file: filePath,
302
- language: 'rust',
303
- errors: errors.filter(e => e.severity === 'error'),
304
- warnings: errors.filter(e => e.severity === 'warning'),
305
- passed: errors.filter(e => e.severity === 'error').length === 0,
306
- output: output.trim(),
307
- };
308
- }
309
- // Generic shell linting
310
- function lintShell(filePath) {
311
- const errors = [];
312
- let output = '';
313
- // Try shellcheck first (cross platform)
314
- if (detectBinary('shellcheck')) {
315
- try {
316
- const result = spawnSync('shellcheck', ['-f', 'gcc', filePath], {
317
- encoding: 'utf-8',
318
- timeout: 10000,
319
- });
320
- if (result.stdout) {
321
- output += '\n' + result.stdout;
322
- errors.push(...parseErrors(result.stdout, filePath));
323
- }
324
- }
325
- catch {
326
- // shellcheck error
327
- }
328
- }
329
- else if (detectBinary('bash')) {
330
- // Fallback to bash -n, works on Windows if Git Bash / WSL is in path, or Linux/Mac
331
- try {
332
- const result = spawnSync('bash', ['-n', filePath], {
333
- encoding: 'utf-8',
334
- timeout: 10000,
335
- });
336
- output = result.stderr + result.stdout;
337
- if (result.status !== 0) {
338
- errors.push(...parseErrors(output, filePath));
339
- }
340
- }
341
- catch (e) {
342
- if (e instanceof Error) {
343
- output = e.message;
344
- }
345
- }
346
- }
347
- else {
348
- return {
349
- file: filePath, language: 'shell', errors: [], warnings: [], passed: true, output: 'No shell linter found (bash/shellcheck missing)'
350
- };
351
- }
352
- return {
353
- file: filePath,
354
- language: 'shell',
355
- errors: errors.filter(e => e.severity === 'error'),
356
- warnings: errors.filter(e => e.severity === 'warning'),
357
- passed: errors.filter(e => e.severity === 'error').length === 0,
358
- output: output.trim(),
359
- };
360
- }
361
- // Execute linting
362
- export async function execute(input) {
363
- const { path: filePath } = inputSchema.parse(input);
364
- if (!existsSync(filePath)) {
365
- return {
366
- file: filePath,
367
- language: 'unknown',
368
- errors: [{ line: 0, message: 'File not found', severity: 'error' }],
369
- warnings: [],
370
- passed: false,
371
- output: 'File not found',
372
- };
373
- }
374
- const language = detectLanguage(filePath);
375
- const code = readFileSync(filePath, 'utf-8');
376
- switch (language) {
377
- case 'python':
378
- return lintPython(filePath, code);
379
- case 'javascript':
380
- return lintJavaScript(filePath, code, false);
381
- case 'typescript':
382
- return lintJavaScript(filePath, code, true);
383
- case 'go':
384
- return lintGo(filePath);
385
- case 'rust':
386
- return lintRust(filePath);
387
- case 'shell':
388
- return lintShell(filePath);
389
- default:
390
- return {
391
- file: filePath,
392
- language: language || 'unknown',
393
- errors: [],
394
- warnings: [],
395
- passed: true,
396
- output: `No linter available for ${language || 'unknown language'}`,
397
- };
398
- }
399
- }
400
- // Tool definition
401
- export const tool = {
402
- name: 'lint',
403
- description: 'Check a source file for syntax errors and code quality issues. Supports Python, JavaScript, TypeScript, Go, Rust, and shell scripts.',
404
- inputSchema,
405
- permission: 'read',
406
- execute: async (args) => execute(args),
407
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Tool: listDir
3
- * List the contents of a directory (files and subdirectories)
4
- */
5
- import { z } from 'zod';
6
- export declare const name = "listDir";
7
- export declare const description = "List the contents of a directory, showing file sizes and directory indicators";
8
- export declare const permission: "read";
9
- export declare const schema: z.ZodObject<{
10
- path: z.ZodOptional<z.ZodString>;
11
- recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
12
- depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
13
- }, "strip", z.ZodTypeAny, {
14
- recursive: boolean;
15
- depth: number;
16
- path?: string | undefined;
17
- }, {
18
- recursive?: boolean | undefined;
19
- path?: string | undefined;
20
- depth?: number | undefined;
21
- }>;
22
- interface EntryInfo {
23
- name: string;
24
- isDir: boolean;
25
- size?: number;
26
- childrenCount?: number;
27
- }
28
- export declare const execute: (args: Record<string, unknown>) => Promise<EntryInfo[]>;
29
- export {};
@@ -1,50 +0,0 @@
1
- /**
2
- * Tool: listDir
3
- * List the contents of a directory (files and subdirectories)
4
- */
5
- import { readdir, stat } from 'fs/promises';
6
- import { join } from 'path';
7
- import { z } from 'zod';
8
- export const name = 'listDir';
9
- export const description = 'List the contents of a directory, showing file sizes and directory indicators';
10
- export const permission = 'read';
11
- export const schema = z.object({
12
- path: z.string().optional().describe('Directory path to list (default: current directory)'),
13
- recursive: z.boolean().optional().default(false).describe('Whether to list recursively'),
14
- depth: z.number().optional().default(1).describe('Max depth for recursive listing')
15
- });
16
- export const execute = async (args) => {
17
- const parsed = schema.parse(args);
18
- const rootPath = parsed.path || process.cwd();
19
- try {
20
- const entries = await readdir(rootPath, { withFileTypes: true });
21
- const result = [];
22
- for (const entry of entries) {
23
- // Basic ignores
24
- if (['node_modules', '.git', 'dist', 'build'].includes(entry.name))
25
- continue;
26
- const fullPath = join(rootPath, entry.name);
27
- const isDir = entry.isDirectory();
28
- let entryInfo = {
29
- name: entry.name,
30
- isDir
31
- };
32
- if (!isDir) {
33
- try {
34
- const s = await stat(fullPath);
35
- entryInfo.size = s.size;
36
- }
37
- catch { }
38
- }
39
- else if (parsed.recursive && (parsed.depth || 0) > 0) {
40
- // We don't actually do recursion here to keep it simple and flat
41
- // but it's a placeholder for future if needed.
42
- }
43
- result.push(entryInfo);
44
- }
45
- return result;
46
- }
47
- catch (error) {
48
- throw new Error(`Failed to list directory ${rootPath}: ${error instanceof Error ? error.message : error}`);
49
- }
50
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Tool: listDir
3
- * List the contents of a directory (files and subdirectories)
4
- */
5
- import { z } from 'zod';
6
- export declare const name = "list_dir";
7
- export declare const description = "List the contents of a directory, showing file sizes and directory indicators";
8
- export declare const permission: "read";
9
- export declare const schema: z.ZodObject<{
10
- path: z.ZodOptional<z.ZodString>;
11
- recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
12
- depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
13
- }, "strip", z.ZodTypeAny, {
14
- recursive: boolean;
15
- depth: number;
16
- path?: string | undefined;
17
- }, {
18
- recursive?: boolean | undefined;
19
- path?: string | undefined;
20
- depth?: number | undefined;
21
- }>;
22
- interface EntryInfo {
23
- name: string;
24
- isDir: boolean;
25
- size?: number;
26
- childrenCount?: number;
27
- }
28
- export declare const execute: (args: Record<string, unknown>) => Promise<EntryInfo[]>;
29
- export {};
@@ -1,50 +0,0 @@
1
- /**
2
- * Tool: listDir
3
- * List the contents of a directory (files and subdirectories)
4
- */
5
- import { readdir, stat } from 'fs/promises';
6
- import { join } from 'path';
7
- import { z } from 'zod';
8
- export const name = 'list_dir';
9
- export const description = 'List the contents of a directory, showing file sizes and directory indicators';
10
- export const permission = 'read';
11
- export const schema = z.object({
12
- path: z.string().optional().describe('Directory path to list (default: current directory)'),
13
- recursive: z.boolean().optional().default(false).describe('Whether to list recursively'),
14
- depth: z.number().optional().default(1).describe('Max depth for recursive listing')
15
- });
16
- export const execute = async (args) => {
17
- const parsed = schema.parse(args);
18
- const rootPath = parsed.path || process.cwd();
19
- try {
20
- const entries = await readdir(rootPath, { withFileTypes: true });
21
- const result = [];
22
- for (const entry of entries) {
23
- // Basic ignores
24
- if (['node_modules', '.git', 'dist', 'build'].includes(entry.name))
25
- continue;
26
- const fullPath = join(rootPath, entry.name);
27
- const isDir = entry.isDirectory();
28
- let entryInfo = {
29
- name: entry.name,
30
- isDir
31
- };
32
- if (!isDir) {
33
- try {
34
- const s = await stat(fullPath);
35
- entryInfo.size = s.size;
36
- }
37
- catch { }
38
- }
39
- else if (parsed.recursive && (parsed.depth || 0) > 0) {
40
- // We don't actually do recursion here to keep it simple and flat
41
- // but it's a placeholder for future if needed.
42
- }
43
- result.push(entryInfo);
44
- }
45
- return result;
46
- }
47
- catch (error) {
48
- throw new Error(`Failed to list directory ${rootPath}: ${error instanceof Error ? error.message : error}`);
49
- }
50
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * Memory Tool - Persistent context and memory management
3
- * Based on GeminiCLI's memoryTool.ts
4
- */
5
- import { z } from 'zod';
6
- import type { Tool } from '../registry.js';
7
- export declare const inputSchema: z.ZodObject<{
8
- operation: z.ZodEnum<["get", "set", "delete", "list", "search", "clear"]>;
9
- key: z.ZodOptional<z.ZodString>;
10
- value: z.ZodOptional<z.ZodString>;
11
- query: z.ZodOptional<z.ZodString>;
12
- namespace: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
- }, "strip", z.ZodTypeAny, {
14
- operation: "search" | "list" | "set" | "clear" | "get" | "delete";
15
- namespace: string;
16
- value?: string | undefined;
17
- key?: string | undefined;
18
- query?: string | undefined;
19
- }, {
20
- operation: "search" | "list" | "set" | "clear" | "get" | "delete";
21
- value?: string | undefined;
22
- key?: string | undefined;
23
- query?: string | undefined;
24
- namespace?: string | undefined;
25
- }>;
26
- type MemoryInput = z.infer<typeof inputSchema>;
27
- export declare function execute(input: MemoryInput): Promise<{
28
- operation: string;
29
- success: boolean;
30
- data?: unknown;
31
- error?: string;
32
- }>;
33
- export declare const tool: Tool;
34
- export {};