erosolar-cli 1.7.211 → 1.7.213

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 (40) hide show
  1. package/dist/capabilities/buildCapability.d.ts +24 -0
  2. package/dist/capabilities/buildCapability.d.ts.map +1 -0
  3. package/dist/capabilities/buildCapability.js +25 -0
  4. package/dist/capabilities/buildCapability.js.map +1 -0
  5. package/dist/capabilities/index.d.ts +1 -0
  6. package/dist/capabilities/index.d.ts.map +1 -1
  7. package/dist/capabilities/index.js +1 -0
  8. package/dist/capabilities/index.js.map +1 -1
  9. package/dist/core/aiErrorFixer.d.ts +70 -0
  10. package/dist/core/aiErrorFixer.d.ts.map +1 -0
  11. package/dist/core/aiErrorFixer.js +402 -0
  12. package/dist/core/aiErrorFixer.js.map +1 -0
  13. package/dist/plugins/tools/build/buildPlugin.d.ts +9 -0
  14. package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -0
  15. package/dist/plugins/tools/build/buildPlugin.js +20 -0
  16. package/dist/plugins/tools/build/buildPlugin.js.map +1 -0
  17. package/dist/plugins/tools/nodeDefaults.d.ts.map +1 -1
  18. package/dist/plugins/tools/nodeDefaults.js +2 -0
  19. package/dist/plugins/tools/nodeDefaults.js.map +1 -1
  20. package/dist/shell/interactiveShell.d.ts.map +1 -1
  21. package/dist/shell/interactiveShell.js +22 -5
  22. package/dist/shell/interactiveShell.js.map +1 -1
  23. package/dist/shell/terminalInput.d.ts +4 -1
  24. package/dist/shell/terminalInput.d.ts.map +1 -1
  25. package/dist/shell/terminalInput.js +19 -9
  26. package/dist/shell/terminalInput.js.map +1 -1
  27. package/dist/shell/updateManager.d.ts.map +1 -1
  28. package/dist/shell/updateManager.js +3 -102
  29. package/dist/shell/updateManager.js.map +1 -1
  30. package/dist/tools/bashTools.d.ts.map +1 -1
  31. package/dist/tools/bashTools.js +25 -1
  32. package/dist/tools/bashTools.js.map +1 -1
  33. package/dist/tools/buildTools.d.ts +9 -0
  34. package/dist/tools/buildTools.d.ts.map +1 -0
  35. package/dist/tools/buildTools.js +344 -0
  36. package/dist/tools/buildTools.js.map +1 -0
  37. package/dist/tools/devTools.d.ts.map +1 -1
  38. package/dist/tools/devTools.js +0 -180
  39. package/dist/tools/devTools.js.map +1 -1
  40. package/package.json +1 -1
@@ -0,0 +1,344 @@
1
+ /**
2
+ * Build and Test Tools with AI-Powered Error Analysis
3
+ *
4
+ * Provides run_build, run_tests, and check_package_info tools that automatically
5
+ * analyze errors and suggest fixes, following Claude Code's approach.
6
+ */
7
+ import { exec } from 'node:child_process';
8
+ import { existsSync, readFileSync } from 'node:fs';
9
+ import { join } from 'node:path';
10
+ import { promisify } from 'node:util';
11
+ import { createErrorFixer } from '../core/aiErrorFixer.js';
12
+ import { buildSandboxEnv } from './bashTools.js';
13
+ const execAsync = promisify(exec);
14
+ // ============================================================================
15
+ // Build Detection
16
+ // ============================================================================
17
+ function detectBuildCommand(workingDir) {
18
+ const packageJsonPath = join(workingDir, 'package.json');
19
+ if (existsSync(packageJsonPath)) {
20
+ try {
21
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
22
+ const scripts = packageJson.scripts ?? {};
23
+ if (scripts.build)
24
+ return 'npm run build';
25
+ if (scripts.compile)
26
+ return 'npm run compile';
27
+ if (scripts.tsc)
28
+ return 'npm run tsc';
29
+ if (existsSync(join(workingDir, 'tsconfig.json')))
30
+ return 'npx tsc';
31
+ return 'npm run build';
32
+ }
33
+ catch {
34
+ return 'npm run build';
35
+ }
36
+ }
37
+ if (existsSync(join(workingDir, 'Makefile')))
38
+ return 'make';
39
+ if (existsSync(join(workingDir, 'Cargo.toml')))
40
+ return 'cargo build';
41
+ if (existsSync(join(workingDir, 'pyproject.toml')))
42
+ return 'python -m build';
43
+ if (existsSync(join(workingDir, 'setup.py')))
44
+ return 'python setup.py build';
45
+ return null;
46
+ }
47
+ function detectTestCommand(workingDir) {
48
+ const packageJsonPath = join(workingDir, 'package.json');
49
+ if (existsSync(packageJsonPath)) {
50
+ try {
51
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
52
+ const scripts = packageJson.scripts ?? {};
53
+ if (scripts.test)
54
+ return 'npm test';
55
+ if (scripts['test:unit'])
56
+ return 'npm run test:unit';
57
+ if (scripts.jest)
58
+ return 'npm run jest';
59
+ if (scripts.vitest)
60
+ return 'npm run vitest';
61
+ return 'npm test';
62
+ }
63
+ catch {
64
+ return 'npm test';
65
+ }
66
+ }
67
+ if (existsSync(join(workingDir, 'pytest.ini')) || existsSync(join(workingDir, 'pyproject.toml'))) {
68
+ return 'pytest';
69
+ }
70
+ if (existsSync(join(workingDir, 'Cargo.toml')))
71
+ return 'cargo test';
72
+ return null;
73
+ }
74
+ // ============================================================================
75
+ // Result Formatting
76
+ // ============================================================================
77
+ function formatBuildSuccess(output, durationMs) {
78
+ const lines = ['✓ Build succeeded', '', `[Performance] took ${durationMs.toFixed(2)}ms`];
79
+ if (output.trim()) {
80
+ const truncated = output.length > 2000
81
+ ? output.slice(0, 2000) + `\n... [${output.length - 2000} more characters]`
82
+ : output;
83
+ lines.push('', truncated);
84
+ }
85
+ return lines.join('\n');
86
+ }
87
+ function formatBuildFailure(errors, _output, durationMs, fixer) {
88
+ const lines = [
89
+ '✗ Build failed',
90
+ '',
91
+ `[Performance] took ${durationMs.toFixed(2)}ms`,
92
+ '',
93
+ `═══ ERRORS DETECTED (${errors.length}) ═══`,
94
+ ];
95
+ for (let i = 0; i < Math.min(errors.length, 10); i++) {
96
+ const error = errors[i];
97
+ if (!error)
98
+ continue;
99
+ lines.push('');
100
+ lines.push(`${i + 1}. [${error.errorType}] ${error.message.slice(0, 200)}`);
101
+ const loc = error.locations[0];
102
+ if (loc) {
103
+ lines.push(` Location: ${loc.filePath}:${loc.lineNumber ?? '?'}`);
104
+ }
105
+ }
106
+ if (errors.length > 10) {
107
+ lines.push('');
108
+ lines.push(`... and ${errors.length - 10} more errors`);
109
+ }
110
+ if (errors.length > 0) {
111
+ const suggestions = fixer.getFixSuggestions(errors);
112
+ lines.push('');
113
+ lines.push(suggestions);
114
+ }
115
+ return lines.join('\n');
116
+ }
117
+ function formatTestSuccess(summary, _output, durationMs) {
118
+ const lines = ['✓ Tests passed', ` ${summary.passed} passed`];
119
+ if (summary.skipped > 0) {
120
+ lines.push(` ${summary.skipped} skipped`);
121
+ }
122
+ lines.push('');
123
+ lines.push(`[Performance] took ${durationMs.toFixed(2)}ms`);
124
+ return lines.join('\n');
125
+ }
126
+ function formatTestFailure(summary, errors, _output, durationMs, fixer) {
127
+ const lines = ['✗ Tests failed', ` ${summary.passed} passed, ${summary.failed} failed`];
128
+ if (summary.skipped > 0) {
129
+ lines.push(` ${summary.skipped} skipped`);
130
+ }
131
+ lines.push('');
132
+ lines.push(`[Performance] took ${durationMs.toFixed(2)}ms`);
133
+ if (errors.length > 0) {
134
+ lines.push('');
135
+ lines.push(`═══ FAILURES DETECTED (${errors.length}) ═══`);
136
+ for (let i = 0; i < Math.min(errors.length, 5); i++) {
137
+ const error = errors[i];
138
+ if (!error)
139
+ continue;
140
+ lines.push('');
141
+ lines.push(`${i + 1}. ${error.message.slice(0, 200)}`);
142
+ const loc = error.locations[0];
143
+ if (loc) {
144
+ lines.push(` Location: ${loc.filePath}:${loc.lineNumber ?? '?'}`);
145
+ }
146
+ }
147
+ }
148
+ const aiGuidance = fixer.formatForAI(errors);
149
+ if (aiGuidance) {
150
+ lines.push(aiGuidance);
151
+ }
152
+ return lines.join('\n');
153
+ }
154
+ // ============================================================================
155
+ // Tool Factory
156
+ // ============================================================================
157
+ export function createBuildTools(workingDir) {
158
+ const fixer = createErrorFixer({ workingDir });
159
+ return [
160
+ {
161
+ name: 'run_build',
162
+ description: 'Run the project build command with AI-powered error analysis. Auto-detects build system (npm, make, cargo, etc.) and provides intelligent error fixes when the build fails.',
163
+ parameters: {
164
+ type: 'object',
165
+ properties: {
166
+ command: {
167
+ type: 'string',
168
+ description: 'Build command to run. If not specified, auto-detects based on project type.',
169
+ },
170
+ timeout: {
171
+ type: 'number',
172
+ description: 'Timeout in milliseconds (default: 120000 = 2 minutes)',
173
+ },
174
+ },
175
+ additionalProperties: false,
176
+ },
177
+ handler: async (args) => {
178
+ const startTime = Date.now();
179
+ let buildCmd = args['command'];
180
+ if (!buildCmd) {
181
+ const detected = detectBuildCommand(workingDir);
182
+ if (!detected) {
183
+ return 'Error: Could not detect build system. Please specify a build command.';
184
+ }
185
+ buildCmd = detected;
186
+ }
187
+ const timeout = args['timeout'] ?? 120000;
188
+ try {
189
+ const env = await buildSandboxEnv(workingDir);
190
+ const { stdout, stderr } = await execAsync(buildCmd, {
191
+ cwd: workingDir,
192
+ timeout,
193
+ maxBuffer: 1024 * 1024 * 10,
194
+ env,
195
+ });
196
+ const durationMs = Date.now() - startTime;
197
+ const output = [stdout, stderr].filter(Boolean).join('\n');
198
+ return formatBuildSuccess(output, durationMs);
199
+ }
200
+ catch (error) {
201
+ const durationMs = Date.now() - startTime;
202
+ const output = [error.stdout, error.stderr, error.message].filter(Boolean).join('\n');
203
+ if (error.killed) {
204
+ return `Error: Build timed out after ${timeout}ms`;
205
+ }
206
+ const errors = fixer.analyzeOutput(output, buildCmd);
207
+ return formatBuildFailure(errors, output, durationMs, fixer);
208
+ }
209
+ },
210
+ },
211
+ {
212
+ name: 'run_tests',
213
+ description: 'Run project tests with AI-powered failure analysis. Auto-detects test framework and provides intelligent suggestions for fixing failing tests.',
214
+ parameters: {
215
+ type: 'object',
216
+ properties: {
217
+ command: {
218
+ type: 'string',
219
+ description: 'Test command to run. If not specified, auto-detects based on project type.',
220
+ },
221
+ timeout: {
222
+ type: 'number',
223
+ description: 'Timeout in milliseconds (default: 300000 = 5 minutes)',
224
+ },
225
+ },
226
+ additionalProperties: false,
227
+ },
228
+ handler: async (args) => {
229
+ const startTime = Date.now();
230
+ let testCmd = args['command'];
231
+ if (!testCmd) {
232
+ const detected = detectTestCommand(workingDir);
233
+ if (!detected) {
234
+ return 'Error: Could not detect test framework. Please specify a test command.';
235
+ }
236
+ testCmd = detected;
237
+ }
238
+ const timeout = args['timeout'] ?? 300000;
239
+ try {
240
+ const env = await buildSandboxEnv(workingDir);
241
+ const { stdout, stderr } = await execAsync(testCmd, {
242
+ cwd: workingDir,
243
+ timeout,
244
+ maxBuffer: 1024 * 1024 * 10,
245
+ env,
246
+ });
247
+ const durationMs = Date.now() - startTime;
248
+ const output = [stdout, stderr].filter(Boolean).join('\n');
249
+ const summary = fixer.parseTestSummary(output);
250
+ return formatTestSuccess(summary, output, durationMs);
251
+ }
252
+ catch (error) {
253
+ const durationMs = Date.now() - startTime;
254
+ const output = [error.stdout, error.stderr, error.message].filter(Boolean).join('\n');
255
+ if (error.killed) {
256
+ return `Error: Tests timed out after ${timeout}ms`;
257
+ }
258
+ const summary = fixer.parseTestSummary(output);
259
+ const errors = fixer.analyzeOutput(output, testCmd);
260
+ return formatTestFailure(summary, errors, output, durationMs, fixer);
261
+ }
262
+ },
263
+ },
264
+ {
265
+ name: 'check_package_info',
266
+ description: 'Get project information (name, version, scripts, dependencies). Useful for understanding what build/test commands are available.',
267
+ parameters: {
268
+ type: 'object',
269
+ properties: {
270
+ detail: {
271
+ type: 'string',
272
+ enum: ['basic', 'full'],
273
+ description: 'Detail level: "basic" shows name/version, "full" includes scripts and dependencies (default: basic)',
274
+ },
275
+ },
276
+ additionalProperties: false,
277
+ },
278
+ handler: async (args) => {
279
+ const detailLevel = args['detail'] ?? 'basic';
280
+ const infoParts = [];
281
+ const packageJsonPath = join(workingDir, 'package.json');
282
+ if (existsSync(packageJsonPath)) {
283
+ try {
284
+ const data = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
285
+ infoParts.push(`Node.js Project: ${data.name ?? 'unknown'}`);
286
+ infoParts.push(` Version: ${data.version ?? 'unknown'}`);
287
+ if (detailLevel === 'full') {
288
+ if (data.scripts) {
289
+ infoParts.push(' Scripts:');
290
+ for (const [name, cmd] of Object.entries(data.scripts)) {
291
+ infoParts.push(` ${name}: ${cmd}`);
292
+ }
293
+ }
294
+ if (data.dependencies) {
295
+ infoParts.push(` Dependencies: ${Object.keys(data.dependencies).length}`);
296
+ }
297
+ if (data.devDependencies) {
298
+ infoParts.push(` Dev Dependencies: ${Object.keys(data.devDependencies).length}`);
299
+ }
300
+ }
301
+ }
302
+ catch {
303
+ // Ignore parse errors
304
+ }
305
+ }
306
+ const cargoTomlPath = join(workingDir, 'Cargo.toml');
307
+ if (existsSync(cargoTomlPath)) {
308
+ try {
309
+ const content = readFileSync(cargoTomlPath, 'utf-8');
310
+ const nameMatch = content.match(/name\s*=\s*["']([^"']+)["']/);
311
+ const versionMatch = content.match(/version\s*=\s*["']([^"']+)["']/);
312
+ if (nameMatch)
313
+ infoParts.push(`Rust Project: ${nameMatch[1]}`);
314
+ if (versionMatch)
315
+ infoParts.push(` Version: ${versionMatch[1]}`);
316
+ }
317
+ catch {
318
+ // Ignore
319
+ }
320
+ }
321
+ const pyprojectPath = join(workingDir, 'pyproject.toml');
322
+ if (existsSync(pyprojectPath)) {
323
+ try {
324
+ const content = readFileSync(pyprojectPath, 'utf-8');
325
+ const nameMatch = content.match(/name\s*=\s*["']([^"']+)["']/);
326
+ const versionMatch = content.match(/version\s*=\s*["']([^"']+)["']/);
327
+ if (nameMatch)
328
+ infoParts.push(`Python Project: ${nameMatch[1]}`);
329
+ if (versionMatch)
330
+ infoParts.push(` Version: ${versionMatch[1]}`);
331
+ }
332
+ catch {
333
+ // Ignore
334
+ }
335
+ }
336
+ if (infoParts.length === 0) {
337
+ return 'Could not detect project type or no project manifest found.';
338
+ }
339
+ return infoParts.join('\n');
340
+ },
341
+ },
342
+ ];
343
+ }
344
+ //# sourceMappingURL=buildTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTools.js","sourceRoot":"","sources":["../../src/tools/buildTools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE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
1
- {"version":3,"file":"devTools.d.ts","sourceRoot":"","sources":["../../src/tools/devTools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAW7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAw3EnE"}
1
+ {"version":3,"file":"devTools.d.ts","sourceRoot":"","sources":["../../src/tools/devTools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAW7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAspEnE"}
@@ -6,81 +6,6 @@ import { verifiedSuccess, verifiedFailure, createCommandCheck, OutputPatterns, a
6
6
  const execAsync = promisify(exec);
7
7
  export function createDevTools(workingDir) {
8
8
  return [
9
- {
10
- name: 'run_tests',
11
- description: 'Execute test suite using npm test or other test runners',
12
- parameters: {
13
- type: 'object',
14
- properties: {
15
- testPattern: {
16
- type: 'string',
17
- description: 'Optional test pattern or file to run specific tests',
18
- },
19
- timeout: {
20
- type: 'number',
21
- description: 'Timeout in milliseconds (default: 60000)',
22
- },
23
- },
24
- additionalProperties: false,
25
- },
26
- handler: async (args) => {
27
- const testPatternArg = args['testPattern'];
28
- const testPattern = typeof testPatternArg === 'string' && testPatternArg.trim() ? testPatternArg.trim() : undefined;
29
- const timeoutArg = args['timeout'];
30
- const timeout = typeof timeoutArg === 'number' && Number.isFinite(timeoutArg) && timeoutArg > 0 ? timeoutArg : 300000; // 5 min default
31
- const startTime = Date.now();
32
- try {
33
- // Check if package.json exists
34
- const packageJsonPath = join(workingDir, 'package.json');
35
- if (!existsSync(packageJsonPath)) {
36
- return verifiedFailure('Cannot run tests', 'package.json not found in working directory', ['Initialize npm project with `npm init`', 'Navigate to correct directory'], [{ check: 'package.json exists', passed: false, details: 'File not found' }]);
37
- }
38
- // Build test command
39
- let command = 'npm test';
40
- if (testPattern) {
41
- // Try to detect test runner and build appropriate command
42
- const packageInfo = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
43
- const scripts = packageInfo.scripts || {};
44
- const testScript = scripts['test'] ?? '';
45
- if (testScript.includes('jest')) {
46
- command = `npx jest ${testPattern}`;
47
- }
48
- else if (testScript.includes('vitest')) {
49
- command = `npx vitest run ${testPattern}`;
50
- }
51
- else if (testScript.includes('mocha')) {
52
- command = `npx mocha ${testPattern}`;
53
- }
54
- else {
55
- // Fallback to npm test with pattern
56
- command = `npm test -- ${testPattern}`;
57
- }
58
- }
59
- const { stdout, stderr } = await execAsync(command, {
60
- cwd: workingDir,
61
- timeout,
62
- maxBuffer: 1024 * 1024 * 10, // 10MB
63
- });
64
- const durationMs = Date.now() - startTime;
65
- const combinedOutput = [stdout, stderr].filter(Boolean).join('\n');
66
- // Analyze for test failure patterns
67
- const analysis = analyzeOutput(combinedOutput, OutputPatterns.npm, 0);
68
- const commandCheck = createCommandCheck('Test execution', 0, combinedOutput);
69
- if (analysis.isFailure) {
70
- return verifiedFailure('Tests failed', `Command: ${command}\n\nOutput:\n${combinedOutput}`, ['Review failing tests', 'Fix test assertions or code'], [commandCheck], durationMs);
71
- }
72
- return verifiedSuccess('Tests passed', `Command: ${command}\n\nOutput:\n${combinedOutput || '(no output)'}`, [commandCheck], durationMs);
73
- }
74
- catch (error) {
75
- const durationMs = Date.now() - startTime;
76
- const combinedError = [error.stdout, error.stderr, error.message].filter(Boolean).join('\n');
77
- if (error.killed) {
78
- return verifiedFailure(`Tests timed out after ${timeout}ms`, `The test command was killed after exceeding the timeout.\nPartial output:\n${combinedError || '(none)'}`, ['Increase timeout if tests legitimately need more time', 'Check for infinite loops or hanging tests'], [{ check: 'Timeout', passed: false, details: `Exceeded ${timeout}ms` }], durationMs);
79
- }
80
- return verifiedFailure(`Tests failed with exit code ${error.code ?? 1}`, `Error output:\n${combinedError || '(none)'}`, ['Review test failures', 'Fix failing tests'], [createCommandCheck('Test execution', error.code ?? 1, combinedError)], durationMs);
81
- }
82
- },
83
- },
84
9
  {
85
10
  name: 'install_dependencies',
86
11
  description: 'Install project dependencies using npm, yarn, or pnpm',
@@ -145,111 +70,6 @@ export function createDevTools(workingDir) {
145
70
  }
146
71
  },
147
72
  },
148
- {
149
- name: 'check_package_info',
150
- description: 'Get information about project dependencies and scripts from package.json',
151
- parameters: {
152
- type: 'object',
153
- properties: {
154
- detail: {
155
- type: 'string',
156
- enum: ['basic', 'dependencies', 'scripts', 'full'],
157
- description: 'Level of detail to include',
158
- },
159
- },
160
- additionalProperties: false,
161
- },
162
- handler: async (args) => {
163
- const detailArg = args['detail'];
164
- const detail = typeof detailArg === 'string' && detailArg.trim() ? detailArg : 'basic';
165
- try {
166
- const packageJsonPath = join(workingDir, 'package.json');
167
- if (!existsSync(packageJsonPath)) {
168
- return 'Error: package.json not found';
169
- }
170
- const packageInfo = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
171
- const output = [];
172
- output.push(`# Package Info: ${packageInfo.name || 'Unnamed'} v${packageInfo.version || 'Unknown'}`);
173
- output.push('');
174
- if (detail === 'basic' || detail === 'full') {
175
- output.push('## Basic Info');
176
- output.push(`- Name: ${packageInfo.name || 'Not specified'}`);
177
- output.push(`- Version: ${packageInfo.version || 'Not specified'}`);
178
- output.push('');
179
- }
180
- if ((detail === 'scripts' || detail === 'full') && packageInfo.scripts) {
181
- output.push('## Scripts');
182
- Object.entries(packageInfo.scripts).forEach(([name, script]) => {
183
- output.push(`- ${name}: ${script}`);
184
- });
185
- output.push('');
186
- }
187
- if ((detail === 'dependencies' || detail === 'full') && packageInfo.dependencies) {
188
- output.push('## Dependencies');
189
- Object.entries(packageInfo.dependencies).forEach(([name, version]) => {
190
- output.push(`- ${name}: ${version}`);
191
- });
192
- output.push('');
193
- }
194
- if ((detail === 'dependencies' || detail === 'full') && packageInfo.devDependencies) {
195
- output.push('## Dev Dependencies');
196
- Object.entries(packageInfo.devDependencies).forEach(([name, version]) => {
197
- output.push(`- ${name}: ${version}`);
198
- });
199
- output.push('');
200
- }
201
- return output.join('\n');
202
- }
203
- catch (error) {
204
- return `Error reading package.json: ${error instanceof Error ? error.message : String(error)}`;
205
- }
206
- },
207
- },
208
- {
209
- name: 'run_build',
210
- description: 'Execute build process using npm run build or other build commands',
211
- parameters: {
212
- type: 'object',
213
- properties: {
214
- buildCommand: {
215
- type: 'string',
216
- description: 'Custom build command (defaults to npm run build)',
217
- },
218
- timeout: {
219
- type: 'number',
220
- description: 'Timeout in milliseconds (default: 300000)',
221
- },
222
- },
223
- additionalProperties: false,
224
- },
225
- handler: async (args) => {
226
- const buildCommandArg = args['buildCommand'];
227
- const buildCommand = typeof buildCommandArg === 'string' && buildCommandArg.trim()
228
- ? buildCommandArg
229
- : 'npm run build';
230
- const timeoutArg = args['timeout'];
231
- const timeout = typeof timeoutArg === 'number' && Number.isFinite(timeoutArg) && timeoutArg > 0 ? timeoutArg : 300000; // 5 minutes
232
- try {
233
- const { stdout, stderr } = await execAsync(buildCommand, {
234
- cwd: workingDir,
235
- timeout,
236
- maxBuffer: 1024 * 1024 * 10,
237
- });
238
- let result = `Build command: ${buildCommand}\n\n`;
239
- if (stdout)
240
- result += `stdout:\n${stdout}\n`;
241
- if (stderr)
242
- result += `stderr:\n${stderr}\n`;
243
- return result || 'Build completed (no output)';
244
- }
245
- catch (error) {
246
- if (error.killed) {
247
- return `Error: Build command timed out after ${timeout}ms`;
248
- }
249
- return `Error running build: ${error.message}\nstderr: ${error.stderr || 'none'}`;
250
- }
251
- },
252
- },
253
73
  {
254
74
  name: 'npm_publish',
255
75
  description: 'Publish package to npm registry. Handles the full workflow: check login, commit changes, bump version, build, and publish.',