erosolar-cli 1.7.55 → 1.7.57

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 (273) hide show
  1. package/dist/shell/unifiedInputProcessor.d.ts +15 -12
  2. package/dist/shell/unifiedInputProcessor.d.ts.map +1 -1
  3. package/dist/shell/unifiedInputProcessor.js +45 -72
  4. package/dist/shell/unifiedInputProcessor.js.map +1 -1
  5. package/package.json +4 -4
  6. package/dist/active-stack-security.d.ts +0 -110
  7. package/dist/active-stack-security.js +0 -313
  8. package/dist/active-stack-security.js.map +0 -1
  9. package/dist/advanced-targeting.d.ts +0 -113
  10. package/dist/advanced-targeting.js +0 -252
  11. package/dist/advanced-targeting.js.map +0 -1
  12. package/dist/bin/adapters/node/index.js +0 -33
  13. package/dist/bin/adapters/types.js +0 -1
  14. package/dist/bin/alpha-zero/agentWrapper.js +0 -165
  15. package/dist/bin/alpha-zero/codeEvaluator.js +0 -272
  16. package/dist/bin/alpha-zero/competitiveRunner.js +0 -219
  17. package/dist/bin/alpha-zero/index.js +0 -98
  18. package/dist/bin/alpha-zero/introspection.js +0 -298
  19. package/dist/bin/alpha-zero/metricsTracker.js +0 -207
  20. package/dist/bin/alpha-zero/security/core.js +0 -269
  21. package/dist/bin/alpha-zero/security/google.js +0 -308
  22. package/dist/bin/alpha-zero/security/googleLoader.js +0 -40
  23. package/dist/bin/alpha-zero/security/index.js +0 -31
  24. package/dist/bin/alpha-zero/security/simulation.js +0 -274
  25. package/dist/bin/alpha-zero/selfModification.js +0 -231
  26. package/dist/bin/alpha-zero/types.js +0 -30
  27. package/dist/bin/bin/erosolar-optimized.js +0 -205
  28. package/dist/bin/capabilities/agentSpawningCapability.js +0 -116
  29. package/dist/bin/capabilities/bashCapability.js +0 -22
  30. package/dist/bin/capabilities/cloudCapability.js +0 -36
  31. package/dist/bin/capabilities/codeAnalysisCapability.js +0 -22
  32. package/dist/bin/capabilities/codeQualityCapability.js +0 -23
  33. package/dist/bin/capabilities/dependencySecurityCapability.js +0 -22
  34. package/dist/bin/capabilities/devCapability.js +0 -22
  35. package/dist/bin/capabilities/editCapability.js +0 -28
  36. package/dist/bin/capabilities/emailCapability.js +0 -20
  37. package/dist/bin/capabilities/enhancedGitCapability.js +0 -221
  38. package/dist/bin/capabilities/filesystemCapability.js +0 -22
  39. package/dist/bin/capabilities/globCapability.js +0 -28
  40. package/dist/bin/capabilities/interactionCapability.js +0 -20
  41. package/dist/bin/capabilities/learnCapability.js +0 -22
  42. package/dist/bin/capabilities/mcpCapability.js +0 -20
  43. package/dist/bin/capabilities/notebookCapability.js +0 -28
  44. package/dist/bin/capabilities/planningCapability.js +0 -27
  45. package/dist/bin/capabilities/refactoringCapability.js +0 -23
  46. package/dist/bin/capabilities/repoChecksCapability.js +0 -22
  47. package/dist/bin/capabilities/searchCapability.js +0 -22
  48. package/dist/bin/capabilities/skillCapability.js +0 -76
  49. package/dist/bin/capabilities/taskManagementCapability.js +0 -20
  50. package/dist/bin/capabilities/testingCapability.js +0 -23
  51. package/dist/bin/capabilities/toolManifest.js +0 -159
  52. package/dist/bin/capabilities/toolRegistry.js +0 -114
  53. package/dist/bin/capabilities/webCapability.js +0 -20
  54. package/dist/bin/config.js +0 -139
  55. package/dist/bin/contracts/v1/agent.js +0 -7
  56. package/dist/bin/contracts/v1/agentProfileManifest.js +0 -8
  57. package/dist/bin/contracts/v1/agentRules.js +0 -9
  58. package/dist/bin/contracts/v1/toolAccess.js +0 -8
  59. package/dist/bin/erosolar-optimized.d.ts +0 -12
  60. package/dist/bin/erosolar-optimized.d.ts.map +0 -1
  61. package/dist/bin/erosolar-optimized.js +0 -239
  62. package/dist/bin/erosolar-optimized.js.map +0 -1
  63. package/dist/bin/headless/headlessApp.js +0 -172
  64. package/dist/bin/mcp/config.js +0 -202
  65. package/dist/bin/mcp/stdioClient.js +0 -172
  66. package/dist/bin/mcp/toolBridge.js +0 -104
  67. package/dist/bin/mcp/types.js +0 -1
  68. package/dist/bin/plugins/index.js +0 -113
  69. package/dist/bin/plugins/providers/anthropic/index.js +0 -25
  70. package/dist/bin/plugins/providers/deepseek/index.js +0 -24
  71. package/dist/bin/plugins/providers/google/index.js +0 -26
  72. package/dist/bin/plugins/providers/index.js +0 -19
  73. package/dist/bin/plugins/providers/ollama/index.js +0 -59
  74. package/dist/bin/plugins/providers/openai/index.js +0 -26
  75. package/dist/bin/plugins/providers/xai/index.js +0 -24
  76. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +0 -8
  77. package/dist/bin/plugins/tools/bash/localBashPlugin.js +0 -13
  78. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +0 -13
  79. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +0 -13
  80. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -13
  81. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +0 -13
  82. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +0 -11
  83. package/dist/bin/plugins/tools/development/devPlugin.js +0 -13
  84. package/dist/bin/plugins/tools/edit/editPlugin.js +0 -14
  85. package/dist/bin/plugins/tools/email/emailPlugin.js +0 -11
  86. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +0 -8
  87. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +0 -13
  88. package/dist/bin/plugins/tools/glob/globPlugin.js +0 -14
  89. package/dist/bin/plugins/tools/index.js +0 -2
  90. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +0 -11
  91. package/dist/bin/plugins/tools/learn/learnPlugin.js +0 -13
  92. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +0 -8
  93. package/dist/bin/plugins/tools/nodeDefaults.js +0 -56
  94. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +0 -14
  95. package/dist/bin/plugins/tools/planning/planningPlugin.js +0 -14
  96. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +0 -11
  97. package/dist/bin/plugins/tools/registry.js +0 -57
  98. package/dist/bin/plugins/tools/search/localSearchPlugin.js +0 -13
  99. package/dist/bin/plugins/tools/skills/skillPlugin.js +0 -8
  100. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +0 -11
  101. package/dist/bin/plugins/tools/testing/testingPlugin.js +0 -11
  102. package/dist/bin/plugins/tools/web/webPlugin.js +0 -11
  103. package/dist/bin/providers/anthropicProvider.js +0 -329
  104. package/dist/bin/providers/googleProvider.js +0 -203
  105. package/dist/bin/providers/openaiChatCompletionsProvider.js +0 -208
  106. package/dist/bin/providers/openaiResponsesProvider.js +0 -249
  107. package/dist/bin/providers/providerFactory.js +0 -24
  108. package/dist/bin/runtime/agentController.js +0 -321
  109. package/dist/bin/runtime/agentHost.js +0 -153
  110. package/dist/bin/runtime/agentSession.js +0 -195
  111. package/dist/bin/runtime/node.js +0 -10
  112. package/dist/bin/runtime/universal.js +0 -28
  113. package/dist/bin/skills/skillRepository.js +0 -236
  114. package/dist/bin/skills/types.js +0 -1
  115. package/dist/bin/subagents/taskRunner.js +0 -269
  116. package/dist/bin/tools/backgroundBashTools.js +0 -211
  117. package/dist/bin/tools/bashTools.js +0 -159
  118. package/dist/bin/tools/cloudTools.js +0 -864
  119. package/dist/bin/tools/codeAnalysisTools.js +0 -641
  120. package/dist/bin/tools/codeQualityTools.js +0 -294
  121. package/dist/bin/tools/dependencyTools.js +0 -282
  122. package/dist/bin/tools/devTools.js +0 -238
  123. package/dist/bin/tools/diffUtils.js +0 -137
  124. package/dist/bin/tools/editTools.js +0 -134
  125. package/dist/bin/tools/emailTools.js +0 -448
  126. package/dist/bin/tools/fileTools.js +0 -282
  127. package/dist/bin/tools/globTools.js +0 -173
  128. package/dist/bin/tools/grepTools.js +0 -332
  129. package/dist/bin/tools/interactionTools.js +0 -170
  130. package/dist/bin/tools/learnTools.js +0 -1818
  131. package/dist/bin/tools/notebookEditTools.js +0 -196
  132. package/dist/bin/tools/planningTools.js +0 -46
  133. package/dist/bin/tools/refactoringTools.js +0 -293
  134. package/dist/bin/tools/repoChecksTools.js +0 -160
  135. package/dist/bin/tools/searchTools.js +0 -206
  136. package/dist/bin/tools/skillTools.js +0 -177
  137. package/dist/bin/tools/taskManagementTools.js +0 -156
  138. package/dist/bin/tools/testingTools.js +0 -232
  139. package/dist/bin/tools/webTools.js +0 -480
  140. package/dist/bin/workspace.js +0 -106
  141. package/dist/bin/workspace.validator.js +0 -213
  142. package/dist/capabilities/offensiveSecurityCapability.d.ts +0 -26
  143. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +0 -1
  144. package/dist/capabilities/offensiveSecurityCapability.js +0 -58
  145. package/dist/capabilities/offensiveSecurityCapability.js.map +0 -1
  146. package/dist/capabilities/realSecurityCapability.d.ts +0 -26
  147. package/dist/capabilities/realSecurityCapability.d.ts.map +0 -1
  148. package/dist/capabilities/realSecurityCapability.js +0 -53
  149. package/dist/capabilities/realSecurityCapability.js.map +0 -1
  150. package/dist/capabilities/securityCapability.d.ts +0 -32
  151. package/dist/capabilities/securityCapability.d.ts.map +0 -1
  152. package/dist/capabilities/securityCapability.js +0 -57
  153. package/dist/capabilities/securityCapability.js.map +0 -1
  154. package/dist/capabilities/ultimateSecurityCapability.d.ts +0 -42
  155. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +0 -1
  156. package/dist/capabilities/ultimateSecurityCapability.js +0 -96
  157. package/dist/capabilities/ultimateSecurityCapability.js.map +0 -1
  158. package/dist/core/designThoughtCheck.d.ts +0 -196
  159. package/dist/core/designThoughtCheck.d.ts.map +0 -1
  160. package/dist/core/designThoughtCheck.js +0 -287
  161. package/dist/core/designThoughtCheck.js.map +0 -1
  162. package/dist/core/designThoughtCheckEngine.d.ts +0 -58
  163. package/dist/core/designThoughtCheckEngine.d.ts.map +0 -1
  164. package/dist/core/designThoughtCheckEngine.js +0 -358
  165. package/dist/core/designThoughtCheckEngine.js.map +0 -1
  166. package/dist/core/designThoughtCheckIntegration.d.ts +0 -103
  167. package/dist/core/designThoughtCheckIntegration.d.ts.map +0 -1
  168. package/dist/core/designThoughtCheckIntegration.js +0 -207
  169. package/dist/core/designThoughtCheckIntegration.js.map +0 -1
  170. package/dist/core/intelligenceTools.d.ts +0 -19
  171. package/dist/core/intelligenceTools.d.ts.map +0 -1
  172. package/dist/core/intelligenceTools.js +0 -453
  173. package/dist/core/intelligenceTools.js.map +0 -1
  174. package/dist/core/operationalTools.d.ts +0 -19
  175. package/dist/core/operationalTools.d.ts.map +0 -1
  176. package/dist/core/operationalTools.js +0 -467
  177. package/dist/core/operationalTools.js.map +0 -1
  178. package/dist/offensive/core/offensive-engine.d.ts +0 -171
  179. package/dist/offensive/core/offensive-engine.d.ts.map +0 -1
  180. package/dist/offensive/core/offensive-engine.js +0 -345
  181. package/dist/offensive/core/offensive-engine.js.map +0 -1
  182. package/dist/offensive/core/offensive-integration.d.ts +0 -129
  183. package/dist/offensive/core/offensive-integration.d.ts.map +0 -1
  184. package/dist/offensive/core/offensive-integration.js +0 -364
  185. package/dist/offensive/core/offensive-integration.js.map +0 -1
  186. package/dist/offensive/core/offensive-tools.d.ts +0 -55
  187. package/dist/offensive/core/offensive-tools.d.ts.map +0 -1
  188. package/dist/offensive/core/offensive-tools.js +0 -438
  189. package/dist/offensive/core/offensive-tools.js.map +0 -1
  190. package/dist/offensive/offensive-cli.d.ts +0 -48
  191. package/dist/offensive/offensive-cli.d.ts.map +0 -1
  192. package/dist/offensive/offensive-cli.js +0 -233
  193. package/dist/offensive/offensive-cli.js.map +0 -1
  194. package/dist/security/apt-simulation-cli.d.ts +0 -57
  195. package/dist/security/apt-simulation-cli.d.ts.map +0 -1
  196. package/dist/security/apt-simulation-cli.js +0 -278
  197. package/dist/security/apt-simulation-cli.js.map +0 -1
  198. package/dist/security/apt-simulation-engine-complete.d.ts +0 -97
  199. package/dist/security/apt-simulation-engine-complete.d.ts.map +0 -1
  200. package/dist/security/apt-simulation-engine-complete.js +0 -441
  201. package/dist/security/apt-simulation-engine-complete.js.map +0 -1
  202. package/dist/security/apt-simulation-engine.d.ts +0 -97
  203. package/dist/security/apt-simulation-engine.d.ts.map +0 -1
  204. package/dist/security/apt-simulation-engine.js +0 -441
  205. package/dist/security/apt-simulation-engine.js.map +0 -1
  206. package/dist/security/authorization.d.ts +0 -45
  207. package/dist/security/authorization.d.ts.map +0 -1
  208. package/dist/security/authorization.js +0 -128
  209. package/dist/security/authorization.js.map +0 -1
  210. package/dist/security/comprehensive-security-research.d.ts +0 -84
  211. package/dist/security/comprehensive-security-research.d.ts.map +0 -1
  212. package/dist/security/comprehensive-security-research.js +0 -211
  213. package/dist/security/comprehensive-security-research.js.map +0 -1
  214. package/dist/security/offensive/exploitationEngine.d.ts +0 -54
  215. package/dist/security/offensive/exploitationEngine.d.ts.map +0 -1
  216. package/dist/security/offensive/exploitationEngine.js +0 -263
  217. package/dist/security/offensive/exploitationEngine.js.map +0 -1
  218. package/dist/security/real/networkExploitation.d.ts +0 -92
  219. package/dist/security/real/networkExploitation.d.ts.map +0 -1
  220. package/dist/security/real/networkExploitation.js +0 -316
  221. package/dist/security/real/networkExploitation.js.map +0 -1
  222. package/dist/security/real/persistenceImplementation.d.ts +0 -62
  223. package/dist/security/real/persistenceImplementation.d.ts.map +0 -1
  224. package/dist/security/real/persistenceImplementation.js +0 -323
  225. package/dist/security/real/persistenceImplementation.js.map +0 -1
  226. package/dist/security/real/vulnerabilityScanner.d.ts +0 -73
  227. package/dist/security/real/vulnerabilityScanner.d.ts.map +0 -1
  228. package/dist/security/real/vulnerabilityScanner.js +0 -341
  229. package/dist/security/real/vulnerabilityScanner.js.map +0 -1
  230. package/dist/shell/capturePastePatch.d.ts +0 -9
  231. package/dist/shell/capturePastePatch.d.ts.map +0 -1
  232. package/dist/shell/capturePastePatch.js +0 -98
  233. package/dist/shell/capturePastePatch.js.map +0 -1
  234. package/dist/shell/enhancedInteractiveShell.d.ts +0 -90
  235. package/dist/shell/enhancedInteractiveShell.d.ts.map +0 -1
  236. package/dist/shell/enhancedInteractiveShell.js +0 -248
  237. package/dist/shell/enhancedInteractiveShell.js.map +0 -1
  238. package/dist/shell/inputProcessor.d.ts +0 -56
  239. package/dist/shell/inputProcessor.d.ts.map +0 -1
  240. package/dist/shell/inputProcessor.js +0 -172
  241. package/dist/shell/inputProcessor.js.map +0 -1
  242. package/dist/shell/interactiveShell-patch.d.ts +0 -27
  243. package/dist/shell/interactiveShell-patch.d.ts.map +0 -1
  244. package/dist/shell/interactiveShell-patch.js +0 -38
  245. package/dist/shell/interactiveShell-patch.js.map +0 -1
  246. package/dist/shell/interactiveShell-robust.d.ts +0 -26
  247. package/dist/shell/interactiveShell-robust.d.ts.map +0 -1
  248. package/dist/shell/interactiveShell-robust.js +0 -34
  249. package/dist/shell/interactiveShell-robust.js.map +0 -1
  250. package/dist/shell/multiLinePasteManager.d.ts +0 -106
  251. package/dist/shell/multiLinePasteManager.d.ts.map +0 -1
  252. package/dist/shell/multiLinePasteManager.js +0 -308
  253. package/dist/shell/multiLinePasteManager.js.map +0 -1
  254. package/dist/shell/processInputBlockPatch.d.ts +0 -8
  255. package/dist/shell/processInputBlockPatch.d.ts.map +0 -1
  256. package/dist/shell/processInputBlockPatch.js +0 -133
  257. package/dist/shell/processInputBlockPatch.js.map +0 -1
  258. package/dist/tools/enhancedSecurityTools.d.ts +0 -19
  259. package/dist/tools/enhancedSecurityTools.d.ts.map +0 -1
  260. package/dist/tools/enhancedSecurityTools.js +0 -215
  261. package/dist/tools/enhancedSecurityTools.js.map +0 -1
  262. package/dist/tools/offensiveSecurityTools.d.ts +0 -16
  263. package/dist/tools/offensiveSecurityTools.d.ts.map +0 -1
  264. package/dist/tools/offensiveSecurityTools.js +0 -285
  265. package/dist/tools/offensiveSecurityTools.js.map +0 -1
  266. package/dist/tools/realSecurityTools.d.ts +0 -18
  267. package/dist/tools/realSecurityTools.d.ts.map +0 -1
  268. package/dist/tools/realSecurityTools.js +0 -468
  269. package/dist/tools/realSecurityTools.js.map +0 -1
  270. package/dist/tools/securityTools.d.ts +0 -20
  271. package/dist/tools/securityTools.d.ts.map +0 -1
  272. package/dist/tools/securityTools.js +0 -449
  273. package/dist/tools/securityTools.js.map +0 -1
@@ -1,238 +0,0 @@
1
- import { exec } from 'node:child_process';
2
- import { existsSync, readFileSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { promisify } from 'node:util';
5
- const execAsync = promisify(exec);
6
- export function createDevTools(workingDir) {
7
- return [
8
- {
9
- name: 'run_tests',
10
- description: 'Execute test suite using npm test or other test runners',
11
- parameters: {
12
- type: 'object',
13
- properties: {
14
- testPattern: {
15
- type: 'string',
16
- description: 'Optional test pattern or file to run specific tests',
17
- },
18
- timeout: {
19
- type: 'number',
20
- description: 'Timeout in milliseconds (default: 60000)',
21
- },
22
- },
23
- additionalProperties: false,
24
- },
25
- handler: async (args) => {
26
- const testPatternArg = args['testPattern'];
27
- const testPattern = typeof testPatternArg === 'string' && testPatternArg.trim() ? testPatternArg.trim() : undefined;
28
- const timeoutArg = args['timeout'];
29
- const timeout = typeof timeoutArg === 'number' && Number.isFinite(timeoutArg) && timeoutArg > 0 ? timeoutArg : 60000;
30
- try {
31
- // Check if package.json exists
32
- const packageJsonPath = join(workingDir, 'package.json');
33
- if (!existsSync(packageJsonPath)) {
34
- return 'Error: package.json not found. Cannot run tests.';
35
- }
36
- // Build test command
37
- let command = 'npm test';
38
- if (testPattern) {
39
- // Try to detect test runner and build appropriate command
40
- const packageInfo = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
41
- const scripts = packageInfo.scripts || {};
42
- const testScript = scripts['test'] ?? '';
43
- if (testScript.includes('jest')) {
44
- command = `npx jest ${testPattern}`;
45
- }
46
- else if (testScript.includes('vitest')) {
47
- command = `npx vitest run ${testPattern}`;
48
- }
49
- else if (testScript.includes('mocha')) {
50
- command = `npx mocha ${testPattern}`;
51
- }
52
- else {
53
- // Fallback to npm test with pattern
54
- command = `npm test -- ${testPattern}`;
55
- }
56
- }
57
- const { stdout, stderr } = await execAsync(command, {
58
- cwd: workingDir,
59
- timeout,
60
- maxBuffer: 1024 * 1024 * 10, // 10MB
61
- });
62
- let result = `Test command: ${command}\n\n`;
63
- if (stdout)
64
- result += `stdout:\n${stdout}\n`;
65
- if (stderr)
66
- result += `stderr:\n${stderr}\n`;
67
- return result || 'Tests completed (no output)';
68
- }
69
- catch (error) {
70
- if (error.killed) {
71
- return `Error: Test command timed out after ${timeout}ms`;
72
- }
73
- return `Error running tests: ${error.message}\nstderr: ${error.stderr || 'none'}`;
74
- }
75
- },
76
- },
77
- {
78
- name: 'install_dependencies',
79
- description: 'Install project dependencies using npm, yarn, or pnpm',
80
- parameters: {
81
- type: 'object',
82
- properties: {
83
- packageManager: {
84
- type: 'string',
85
- enum: ['npm', 'yarn', 'pnpm'],
86
- description: 'Package manager to use (default: npm)',
87
- },
88
- production: {
89
- type: 'boolean',
90
- description: 'Install only production dependencies',
91
- },
92
- },
93
- additionalProperties: false,
94
- },
95
- handler: async (args) => {
96
- const packageManager = typeof args['packageManager'] === 'string' ? args['packageManager'] : 'npm';
97
- const production = args['production'] === true;
98
- try {
99
- let command;
100
- if (packageManager === 'npm') {
101
- command = production ? 'npm ci --production' : 'npm ci';
102
- }
103
- else if (packageManager === 'yarn') {
104
- command = production ? 'yarn install --production' : 'yarn install';
105
- }
106
- else if (packageManager === 'pnpm') {
107
- command = production ? 'pnpm install --prod' : 'pnpm install';
108
- }
109
- else {
110
- return `Error: Unsupported package manager: ${packageManager}`;
111
- }
112
- const { stdout, stderr } = await execAsync(command, {
113
- cwd: workingDir,
114
- timeout: 300000, // 5 minutes
115
- maxBuffer: 1024 * 1024 * 10,
116
- });
117
- let result = `Dependency installation command: ${command}\n\n`;
118
- if (stdout)
119
- result += `stdout:\n${stdout}\n`;
120
- if (stderr)
121
- result += `stderr:\n${stderr}\n`;
122
- return result || 'Dependencies installed successfully (no output)';
123
- }
124
- catch (error) {
125
- if (error.killed) {
126
- return 'Error: Dependency installation timed out';
127
- }
128
- return `Error installing dependencies: ${error.message}\nstderr: ${error.stderr || 'none'}`;
129
- }
130
- },
131
- },
132
- {
133
- name: 'check_package_info',
134
- description: 'Get information about project dependencies and scripts from package.json',
135
- parameters: {
136
- type: 'object',
137
- properties: {
138
- detail: {
139
- type: 'string',
140
- enum: ['basic', 'dependencies', 'scripts', 'full'],
141
- description: 'Level of detail to include',
142
- },
143
- },
144
- additionalProperties: false,
145
- },
146
- handler: async (args) => {
147
- const detailArg = args['detail'];
148
- const detail = typeof detailArg === 'string' && detailArg.trim() ? detailArg : 'basic';
149
- try {
150
- const packageJsonPath = join(workingDir, 'package.json');
151
- if (!existsSync(packageJsonPath)) {
152
- return 'Error: package.json not found';
153
- }
154
- const packageInfo = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
155
- const output = [];
156
- output.push(`# Package Info: ${packageInfo.name || 'Unnamed'} v${packageInfo.version || 'Unknown'}`);
157
- output.push('');
158
- if (detail === 'basic' || detail === 'full') {
159
- output.push('## Basic Info');
160
- output.push(`- Name: ${packageInfo.name || 'Not specified'}`);
161
- output.push(`- Version: ${packageInfo.version || 'Not specified'}`);
162
- output.push('');
163
- }
164
- if ((detail === 'scripts' || detail === 'full') && packageInfo.scripts) {
165
- output.push('## Scripts');
166
- Object.entries(packageInfo.scripts).forEach(([name, script]) => {
167
- output.push(`- ${name}: ${script}`);
168
- });
169
- output.push('');
170
- }
171
- if ((detail === 'dependencies' || detail === 'full') && packageInfo.dependencies) {
172
- output.push('## Dependencies');
173
- Object.entries(packageInfo.dependencies).forEach(([name, version]) => {
174
- output.push(`- ${name}: ${version}`);
175
- });
176
- output.push('');
177
- }
178
- if ((detail === 'dependencies' || detail === 'full') && packageInfo.devDependencies) {
179
- output.push('## Dev Dependencies');
180
- Object.entries(packageInfo.devDependencies).forEach(([name, version]) => {
181
- output.push(`- ${name}: ${version}`);
182
- });
183
- output.push('');
184
- }
185
- return output.join('\n');
186
- }
187
- catch (error) {
188
- return `Error reading package.json: ${error instanceof Error ? error.message : String(error)}`;
189
- }
190
- },
191
- },
192
- {
193
- name: 'run_build',
194
- description: 'Execute build process using npm run build or other build commands',
195
- parameters: {
196
- type: 'object',
197
- properties: {
198
- buildCommand: {
199
- type: 'string',
200
- description: 'Custom build command (defaults to npm run build)',
201
- },
202
- timeout: {
203
- type: 'number',
204
- description: 'Timeout in milliseconds (default: 300000)',
205
- },
206
- },
207
- additionalProperties: false,
208
- },
209
- handler: async (args) => {
210
- const buildCommandArg = args['buildCommand'];
211
- const buildCommand = typeof buildCommandArg === 'string' && buildCommandArg.trim()
212
- ? buildCommandArg
213
- : 'npm run build';
214
- const timeoutArg = args['timeout'];
215
- const timeout = typeof timeoutArg === 'number' && Number.isFinite(timeoutArg) && timeoutArg > 0 ? timeoutArg : 300000; // 5 minutes
216
- try {
217
- const { stdout, stderr } = await execAsync(buildCommand, {
218
- cwd: workingDir,
219
- timeout,
220
- maxBuffer: 1024 * 1024 * 10,
221
- });
222
- let result = `Build command: ${buildCommand}\n\n`;
223
- if (stdout)
224
- result += `stdout:\n${stdout}\n`;
225
- if (stderr)
226
- result += `stderr:\n${stderr}\n`;
227
- return result || 'Build completed (no output)';
228
- }
229
- catch (error) {
230
- if (error.killed) {
231
- return `Error: Build command timed out after ${timeout}ms`;
232
- }
233
- return `Error running build: ${error.message}\nstderr: ${error.stderr || 'none'}`;
234
- }
235
- },
236
- },
237
- ];
238
- }
@@ -1,137 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { join } from 'node:path';
5
- export function buildDiffSegments(previous, next) {
6
- const before = normalizeNewlines(previous);
7
- const after = normalizeNewlines(next);
8
- if (before === after) {
9
- return [];
10
- }
11
- const gitSegments = tryBuildWithGit(before, after);
12
- if (gitSegments) {
13
- return gitSegments;
14
- }
15
- return buildNaiveDiff(before, after);
16
- }
17
- export function formatDiffLines(diff) {
18
- if (!diff.length) {
19
- return [];
20
- }
21
- const width = Math.max(1, ...diff.map((entry) => Math.max(1, entry.lineNumber).toString().length));
22
- return diff.map((entry) => {
23
- const prefix = entry.type === 'added' ? '+' : '-';
24
- const lineNumber = Math.max(1, entry.lineNumber);
25
- const body = entry.content.length > 0 ? entry.content : '[empty line]';
26
- const paddedNumber = lineNumber.toString().padStart(width, ' ');
27
- return `${prefix} L${paddedNumber} | ${body}`;
28
- });
29
- }
30
- function tryBuildWithGit(before, after) {
31
- let tempDir = null;
32
- try {
33
- tempDir = mkdtempSync(join(tmpdir(), 'erosolar-diff-'));
34
- const originalPath = join(tempDir, 'before.txt');
35
- const updatedPath = join(tempDir, 'after.txt');
36
- writeFileSync(originalPath, before, 'utf8');
37
- writeFileSync(updatedPath, after, 'utf8');
38
- const result = spawnSync('git', ['--no-pager', 'diff', '--no-index', '--unified=0', '--color=never', '--', originalPath, updatedPath], { encoding: 'utf8' });
39
- if (result.error) {
40
- const code = result.error.code;
41
- if (code === 'ENOENT') {
42
- return null;
43
- }
44
- return null;
45
- }
46
- if (typeof result.status === 'number' && result.status > 1) {
47
- return null;
48
- }
49
- return parseUnifiedDiff(result.stdout);
50
- }
51
- catch {
52
- return null;
53
- }
54
- finally {
55
- if (tempDir) {
56
- rmSync(tempDir, { recursive: true, force: true });
57
- }
58
- }
59
- }
60
- function parseUnifiedDiff(output) {
61
- if (!output.trim()) {
62
- return [];
63
- }
64
- const lines = output.split('\n');
65
- const segments = [];
66
- let oldLine = 0;
67
- let newLine = 0;
68
- for (const rawLine of lines) {
69
- const line = rawLine.replace(/\r$/, '');
70
- if (!line) {
71
- continue;
72
- }
73
- if (line.startsWith('@@')) {
74
- const match = /@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line);
75
- if (match?.[1] && match?.[2]) {
76
- oldLine = parseInt(match[1], 10);
77
- newLine = parseInt(match[2], 10);
78
- }
79
- continue;
80
- }
81
- if (line.startsWith('+++') || line.startsWith('---') || line.startsWith('diff ') || line.startsWith('index ')) {
82
- continue;
83
- }
84
- if (line.startsWith('Binary ')) {
85
- continue;
86
- }
87
- if (line.startsWith('\\')) {
88
- continue;
89
- }
90
- if (line.startsWith('+')) {
91
- segments.push({ type: 'added', lineNumber: newLine, content: line.slice(1) });
92
- newLine += 1;
93
- continue;
94
- }
95
- if (line.startsWith('-')) {
96
- segments.push({ type: 'removed', lineNumber: oldLine, content: line.slice(1) });
97
- oldLine += 1;
98
- continue;
99
- }
100
- if (line.startsWith(' ')) {
101
- oldLine += 1;
102
- newLine += 1;
103
- continue;
104
- }
105
- }
106
- return segments;
107
- }
108
- function buildNaiveDiff(before, after) {
109
- const a = splitLines(before);
110
- const b = splitLines(after);
111
- const max = Math.max(a.length, b.length);
112
- const segments = [];
113
- for (let index = 0; index < max; index += 1) {
114
- const left = a[index];
115
- const right = b[index];
116
- if (left === right) {
117
- continue;
118
- }
119
- if (typeof left === 'string') {
120
- segments.push({ type: 'removed', lineNumber: index + 1, content: left });
121
- }
122
- if (typeof right === 'string') {
123
- segments.push({ type: 'added', lineNumber: index + 1, content: right });
124
- }
125
- }
126
- return segments;
127
- }
128
- function normalizeNewlines(value) {
129
- return value.replace(/\r\n/g, '\n');
130
- }
131
- function splitLines(value) {
132
- if (!value) {
133
- return [];
134
- }
135
- const normalized = normalizeNewlines(value);
136
- return normalized.split('\n');
137
- }
@@ -1,134 +0,0 @@
1
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
2
- import { join, relative } from 'node:path';
3
- import { buildError } from '../core/errors.js';
4
- import { buildDiffSegments, formatDiffLines } from './diffUtils.js';
5
- /**
6
- * Creates the Edit tool for surgical file modifications using exact string replacement.
7
- *
8
- * This tool performs string-based edits without requiring full file rewrites,
9
- * making it ideal for targeted changes while preserving exact formatting and indentation.
10
- *
11
- * Features:
12
- * - Exact string matching (preserves indentation)
13
- * - Replace all occurrences or enforce uniqueness
14
- * - Unified diff preview
15
- * - Validation before writing
16
- *
17
- * @param workingDir - The working directory for resolving relative paths
18
- * @returns Array containing the Edit tool definition
19
- */
20
- export function createEditTools(workingDir) {
21
- return [
22
- {
23
- name: 'Edit',
24
- description: 'Performs exact string replacements in files. Use for surgical edits when you know the exact text to replace. The edit will FAIL if old_string is not unique unless replace_all is true.',
25
- parameters: {
26
- type: 'object',
27
- properties: {
28
- file_path: {
29
- type: 'string',
30
- description: 'The absolute path to the file to modify',
31
- },
32
- old_string: {
33
- type: 'string',
34
- description: 'The exact text to replace (must match precisely including indentation and whitespace)',
35
- },
36
- new_string: {
37
- type: 'string',
38
- description: 'The text to replace it with (must be different from old_string)',
39
- },
40
- replace_all: {
41
- type: 'boolean',
42
- description: 'Replace all occurrences of old_string (default false). When false, the edit fails if old_string appears multiple times.',
43
- },
44
- },
45
- required: ['file_path', 'old_string', 'new_string'],
46
- additionalProperties: false,
47
- },
48
- handler: async (args) => {
49
- const pathArg = args['file_path'];
50
- const oldString = args['old_string'];
51
- const newString = args['new_string'];
52
- const replaceAll = args['replace_all'] === true;
53
- // Validate inputs
54
- if (typeof pathArg !== 'string' || !pathArg.trim()) {
55
- return 'Error: file_path must be a non-empty string.';
56
- }
57
- if (typeof oldString !== 'string') {
58
- return 'Error: old_string must be a string.';
59
- }
60
- if (typeof newString !== 'string') {
61
- return 'Error: new_string must be a string.';
62
- }
63
- if (oldString === newString) {
64
- return 'Error: old_string and new_string must be different.';
65
- }
66
- try {
67
- const filePath = resolveFilePath(workingDir, pathArg);
68
- // Check file exists
69
- if (!existsSync(filePath)) {
70
- return `Error: File not found: ${filePath}`;
71
- }
72
- // Read current content
73
- const currentContent = readFileSync(filePath, 'utf-8');
74
- // Check if old_string exists in file
75
- if (!currentContent.includes(oldString)) {
76
- return `Error: old_string not found in file. The exact text must match including all whitespace and indentation.\n\nFile: ${filePath}\nSearching for: ${JSON.stringify(oldString.substring(0, 100))}...`;
77
- }
78
- // Count occurrences
79
- const occurrences = countOccurrences(currentContent, oldString);
80
- if (!replaceAll && occurrences > 1) {
81
- return `Error: old_string appears ${occurrences} times in the file. Either:\n1. Provide a larger unique string that includes more context\n2. Set replace_all: true to replace all ${occurrences} occurrences\n\nFile: ${filePath}`;
82
- }
83
- // Perform replacement
84
- const newContent = replaceAll
85
- ? currentContent.split(oldString).join(newString)
86
- : currentContent.replace(oldString, newString);
87
- // Generate diff
88
- const diffSegments = buildDiffSegments(currentContent, newContent);
89
- // Write file
90
- writeFileSync(filePath, newContent, 'utf-8');
91
- // Build summary
92
- const relativePath = relative(workingDir, filePath);
93
- const displayPath = relativePath && !relativePath.startsWith('..') ? relativePath : filePath;
94
- const addedLines = diffSegments.filter(s => s.type === 'added').length;
95
- const removedLines = diffSegments.filter(s => s.type === 'removed').length;
96
- const occurrencesText = replaceAll ? ` (${occurrences} occurrence${occurrences > 1 ? 's' : ''})` : '';
97
- const diffLines = formatDiffLines(diffSegments);
98
- const diffBlock = diffLines.length > 0
99
- ? ['```diff', ...diffLines, '```'].join('\n')
100
- : '(No visual diff - whitespace or formatting changes only)';
101
- return [
102
- `✓ Edited ${displayPath}${occurrencesText}`,
103
- `Lines changed: +${addedLines} / -${removedLines}`,
104
- '',
105
- 'Diff preview:',
106
- diffBlock,
107
- ].join('\n');
108
- }
109
- catch (error) {
110
- return buildError('editing file', error, {
111
- file_path: pathArg,
112
- old_string_length: typeof oldString === 'string' ? oldString.length : 0,
113
- new_string_length: typeof newString === 'string' ? newString.length : 0,
114
- });
115
- }
116
- },
117
- },
118
- ];
119
- }
120
- function resolveFilePath(workingDir, path) {
121
- const normalized = path.trim();
122
- return normalized.startsWith('/') ? normalized : join(workingDir, normalized);
123
- }
124
- function countOccurrences(text, search) {
125
- if (!search)
126
- return 0;
127
- let count = 0;
128
- let position = 0;
129
- while ((position = text.indexOf(search, position)) !== -1) {
130
- count++;
131
- position += search.length;
132
- }
133
- return count;
134
- }