erosolar-cli 1.7.55 → 1.7.56

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/package.json +1 -1
  2. package/dist/active-stack-security.d.ts +0 -110
  3. package/dist/active-stack-security.js +0 -313
  4. package/dist/active-stack-security.js.map +0 -1
  5. package/dist/advanced-targeting.d.ts +0 -113
  6. package/dist/advanced-targeting.js +0 -252
  7. package/dist/advanced-targeting.js.map +0 -1
  8. package/dist/bin/adapters/node/index.js +0 -33
  9. package/dist/bin/adapters/types.js +0 -1
  10. package/dist/bin/alpha-zero/agentWrapper.js +0 -165
  11. package/dist/bin/alpha-zero/codeEvaluator.js +0 -272
  12. package/dist/bin/alpha-zero/competitiveRunner.js +0 -219
  13. package/dist/bin/alpha-zero/index.js +0 -98
  14. package/dist/bin/alpha-zero/introspection.js +0 -298
  15. package/dist/bin/alpha-zero/metricsTracker.js +0 -207
  16. package/dist/bin/alpha-zero/security/core.js +0 -269
  17. package/dist/bin/alpha-zero/security/google.js +0 -308
  18. package/dist/bin/alpha-zero/security/googleLoader.js +0 -40
  19. package/dist/bin/alpha-zero/security/index.js +0 -31
  20. package/dist/bin/alpha-zero/security/simulation.js +0 -274
  21. package/dist/bin/alpha-zero/selfModification.js +0 -231
  22. package/dist/bin/alpha-zero/types.js +0 -30
  23. package/dist/bin/bin/erosolar-optimized.js +0 -205
  24. package/dist/bin/capabilities/agentSpawningCapability.js +0 -116
  25. package/dist/bin/capabilities/bashCapability.js +0 -22
  26. package/dist/bin/capabilities/cloudCapability.js +0 -36
  27. package/dist/bin/capabilities/codeAnalysisCapability.js +0 -22
  28. package/dist/bin/capabilities/codeQualityCapability.js +0 -23
  29. package/dist/bin/capabilities/dependencySecurityCapability.js +0 -22
  30. package/dist/bin/capabilities/devCapability.js +0 -22
  31. package/dist/bin/capabilities/editCapability.js +0 -28
  32. package/dist/bin/capabilities/emailCapability.js +0 -20
  33. package/dist/bin/capabilities/enhancedGitCapability.js +0 -221
  34. package/dist/bin/capabilities/filesystemCapability.js +0 -22
  35. package/dist/bin/capabilities/globCapability.js +0 -28
  36. package/dist/bin/capabilities/interactionCapability.js +0 -20
  37. package/dist/bin/capabilities/learnCapability.js +0 -22
  38. package/dist/bin/capabilities/mcpCapability.js +0 -20
  39. package/dist/bin/capabilities/notebookCapability.js +0 -28
  40. package/dist/bin/capabilities/planningCapability.js +0 -27
  41. package/dist/bin/capabilities/refactoringCapability.js +0 -23
  42. package/dist/bin/capabilities/repoChecksCapability.js +0 -22
  43. package/dist/bin/capabilities/searchCapability.js +0 -22
  44. package/dist/bin/capabilities/skillCapability.js +0 -76
  45. package/dist/bin/capabilities/taskManagementCapability.js +0 -20
  46. package/dist/bin/capabilities/testingCapability.js +0 -23
  47. package/dist/bin/capabilities/toolManifest.js +0 -159
  48. package/dist/bin/capabilities/toolRegistry.js +0 -114
  49. package/dist/bin/capabilities/webCapability.js +0 -20
  50. package/dist/bin/config.js +0 -139
  51. package/dist/bin/contracts/v1/agent.js +0 -7
  52. package/dist/bin/contracts/v1/agentProfileManifest.js +0 -8
  53. package/dist/bin/contracts/v1/agentRules.js +0 -9
  54. package/dist/bin/contracts/v1/toolAccess.js +0 -8
  55. package/dist/bin/erosolar-optimized.d.ts +0 -12
  56. package/dist/bin/erosolar-optimized.d.ts.map +0 -1
  57. package/dist/bin/erosolar-optimized.js +0 -239
  58. package/dist/bin/erosolar-optimized.js.map +0 -1
  59. package/dist/bin/headless/headlessApp.js +0 -172
  60. package/dist/bin/mcp/config.js +0 -202
  61. package/dist/bin/mcp/stdioClient.js +0 -172
  62. package/dist/bin/mcp/toolBridge.js +0 -104
  63. package/dist/bin/mcp/types.js +0 -1
  64. package/dist/bin/plugins/index.js +0 -113
  65. package/dist/bin/plugins/providers/anthropic/index.js +0 -25
  66. package/dist/bin/plugins/providers/deepseek/index.js +0 -24
  67. package/dist/bin/plugins/providers/google/index.js +0 -26
  68. package/dist/bin/plugins/providers/index.js +0 -19
  69. package/dist/bin/plugins/providers/ollama/index.js +0 -59
  70. package/dist/bin/plugins/providers/openai/index.js +0 -26
  71. package/dist/bin/plugins/providers/xai/index.js +0 -24
  72. package/dist/bin/plugins/tools/agentSpawning/agentSpawningPlugin.js +0 -8
  73. package/dist/bin/plugins/tools/bash/localBashPlugin.js +0 -13
  74. package/dist/bin/plugins/tools/checks/localRepoChecksPlugin.js +0 -13
  75. package/dist/bin/plugins/tools/cloud/cloudPlugin.js +0 -13
  76. package/dist/bin/plugins/tools/codeAnalysis/codeAnalysisPlugin.js +0 -13
  77. package/dist/bin/plugins/tools/codeQuality/codeQualityPlugin.js +0 -13
  78. package/dist/bin/plugins/tools/dependency/dependencyPlugin.js +0 -11
  79. package/dist/bin/plugins/tools/development/devPlugin.js +0 -13
  80. package/dist/bin/plugins/tools/edit/editPlugin.js +0 -14
  81. package/dist/bin/plugins/tools/email/emailPlugin.js +0 -11
  82. package/dist/bin/plugins/tools/enhancedGit/enhancedGitPlugin.js +0 -8
  83. package/dist/bin/plugins/tools/filesystem/localFilesystemPlugin.js +0 -13
  84. package/dist/bin/plugins/tools/glob/globPlugin.js +0 -14
  85. package/dist/bin/plugins/tools/index.js +0 -2
  86. package/dist/bin/plugins/tools/interaction/interactionPlugin.js +0 -11
  87. package/dist/bin/plugins/tools/learn/learnPlugin.js +0 -13
  88. package/dist/bin/plugins/tools/mcp/mcpPlugin.js +0 -8
  89. package/dist/bin/plugins/tools/nodeDefaults.js +0 -56
  90. package/dist/bin/plugins/tools/notebook/notebookPlugin.js +0 -14
  91. package/dist/bin/plugins/tools/planning/planningPlugin.js +0 -14
  92. package/dist/bin/plugins/tools/refactoring/refactoringPlugin.js +0 -11
  93. package/dist/bin/plugins/tools/registry.js +0 -57
  94. package/dist/bin/plugins/tools/search/localSearchPlugin.js +0 -13
  95. package/dist/bin/plugins/tools/skills/skillPlugin.js +0 -8
  96. package/dist/bin/plugins/tools/taskManagement/taskManagementPlugin.js +0 -11
  97. package/dist/bin/plugins/tools/testing/testingPlugin.js +0 -11
  98. package/dist/bin/plugins/tools/web/webPlugin.js +0 -11
  99. package/dist/bin/providers/anthropicProvider.js +0 -329
  100. package/dist/bin/providers/googleProvider.js +0 -203
  101. package/dist/bin/providers/openaiChatCompletionsProvider.js +0 -208
  102. package/dist/bin/providers/openaiResponsesProvider.js +0 -249
  103. package/dist/bin/providers/providerFactory.js +0 -24
  104. package/dist/bin/runtime/agentController.js +0 -321
  105. package/dist/bin/runtime/agentHost.js +0 -153
  106. package/dist/bin/runtime/agentSession.js +0 -195
  107. package/dist/bin/runtime/node.js +0 -10
  108. package/dist/bin/runtime/universal.js +0 -28
  109. package/dist/bin/skills/skillRepository.js +0 -236
  110. package/dist/bin/skills/types.js +0 -1
  111. package/dist/bin/subagents/taskRunner.js +0 -269
  112. package/dist/bin/tools/backgroundBashTools.js +0 -211
  113. package/dist/bin/tools/bashTools.js +0 -159
  114. package/dist/bin/tools/cloudTools.js +0 -864
  115. package/dist/bin/tools/codeAnalysisTools.js +0 -641
  116. package/dist/bin/tools/codeQualityTools.js +0 -294
  117. package/dist/bin/tools/dependencyTools.js +0 -282
  118. package/dist/bin/tools/devTools.js +0 -238
  119. package/dist/bin/tools/diffUtils.js +0 -137
  120. package/dist/bin/tools/editTools.js +0 -134
  121. package/dist/bin/tools/emailTools.js +0 -448
  122. package/dist/bin/tools/fileTools.js +0 -282
  123. package/dist/bin/tools/globTools.js +0 -173
  124. package/dist/bin/tools/grepTools.js +0 -332
  125. package/dist/bin/tools/interactionTools.js +0 -170
  126. package/dist/bin/tools/learnTools.js +0 -1818
  127. package/dist/bin/tools/notebookEditTools.js +0 -196
  128. package/dist/bin/tools/planningTools.js +0 -46
  129. package/dist/bin/tools/refactoringTools.js +0 -293
  130. package/dist/bin/tools/repoChecksTools.js +0 -160
  131. package/dist/bin/tools/searchTools.js +0 -206
  132. package/dist/bin/tools/skillTools.js +0 -177
  133. package/dist/bin/tools/taskManagementTools.js +0 -156
  134. package/dist/bin/tools/testingTools.js +0 -232
  135. package/dist/bin/tools/webTools.js +0 -480
  136. package/dist/bin/workspace.js +0 -106
  137. package/dist/bin/workspace.validator.js +0 -213
  138. package/dist/capabilities/offensiveSecurityCapability.d.ts +0 -26
  139. package/dist/capabilities/offensiveSecurityCapability.d.ts.map +0 -1
  140. package/dist/capabilities/offensiveSecurityCapability.js +0 -58
  141. package/dist/capabilities/offensiveSecurityCapability.js.map +0 -1
  142. package/dist/capabilities/realSecurityCapability.d.ts +0 -26
  143. package/dist/capabilities/realSecurityCapability.d.ts.map +0 -1
  144. package/dist/capabilities/realSecurityCapability.js +0 -53
  145. package/dist/capabilities/realSecurityCapability.js.map +0 -1
  146. package/dist/capabilities/securityCapability.d.ts +0 -32
  147. package/dist/capabilities/securityCapability.d.ts.map +0 -1
  148. package/dist/capabilities/securityCapability.js +0 -57
  149. package/dist/capabilities/securityCapability.js.map +0 -1
  150. package/dist/capabilities/ultimateSecurityCapability.d.ts +0 -42
  151. package/dist/capabilities/ultimateSecurityCapability.d.ts.map +0 -1
  152. package/dist/capabilities/ultimateSecurityCapability.js +0 -96
  153. package/dist/capabilities/ultimateSecurityCapability.js.map +0 -1
  154. package/dist/core/designThoughtCheck.d.ts +0 -196
  155. package/dist/core/designThoughtCheck.d.ts.map +0 -1
  156. package/dist/core/designThoughtCheck.js +0 -287
  157. package/dist/core/designThoughtCheck.js.map +0 -1
  158. package/dist/core/designThoughtCheckEngine.d.ts +0 -58
  159. package/dist/core/designThoughtCheckEngine.d.ts.map +0 -1
  160. package/dist/core/designThoughtCheckEngine.js +0 -358
  161. package/dist/core/designThoughtCheckEngine.js.map +0 -1
  162. package/dist/core/designThoughtCheckIntegration.d.ts +0 -103
  163. package/dist/core/designThoughtCheckIntegration.d.ts.map +0 -1
  164. package/dist/core/designThoughtCheckIntegration.js +0 -207
  165. package/dist/core/designThoughtCheckIntegration.js.map +0 -1
  166. package/dist/core/intelligenceTools.d.ts +0 -19
  167. package/dist/core/intelligenceTools.d.ts.map +0 -1
  168. package/dist/core/intelligenceTools.js +0 -453
  169. package/dist/core/intelligenceTools.js.map +0 -1
  170. package/dist/core/operationalTools.d.ts +0 -19
  171. package/dist/core/operationalTools.d.ts.map +0 -1
  172. package/dist/core/operationalTools.js +0 -467
  173. package/dist/core/operationalTools.js.map +0 -1
  174. package/dist/offensive/core/offensive-engine.d.ts +0 -171
  175. package/dist/offensive/core/offensive-engine.d.ts.map +0 -1
  176. package/dist/offensive/core/offensive-engine.js +0 -345
  177. package/dist/offensive/core/offensive-engine.js.map +0 -1
  178. package/dist/offensive/core/offensive-integration.d.ts +0 -129
  179. package/dist/offensive/core/offensive-integration.d.ts.map +0 -1
  180. package/dist/offensive/core/offensive-integration.js +0 -364
  181. package/dist/offensive/core/offensive-integration.js.map +0 -1
  182. package/dist/offensive/core/offensive-tools.d.ts +0 -55
  183. package/dist/offensive/core/offensive-tools.d.ts.map +0 -1
  184. package/dist/offensive/core/offensive-tools.js +0 -438
  185. package/dist/offensive/core/offensive-tools.js.map +0 -1
  186. package/dist/offensive/offensive-cli.d.ts +0 -48
  187. package/dist/offensive/offensive-cli.d.ts.map +0 -1
  188. package/dist/offensive/offensive-cli.js +0 -233
  189. package/dist/offensive/offensive-cli.js.map +0 -1
  190. package/dist/security/apt-simulation-cli.d.ts +0 -57
  191. package/dist/security/apt-simulation-cli.d.ts.map +0 -1
  192. package/dist/security/apt-simulation-cli.js +0 -278
  193. package/dist/security/apt-simulation-cli.js.map +0 -1
  194. package/dist/security/apt-simulation-engine-complete.d.ts +0 -97
  195. package/dist/security/apt-simulation-engine-complete.d.ts.map +0 -1
  196. package/dist/security/apt-simulation-engine-complete.js +0 -441
  197. package/dist/security/apt-simulation-engine-complete.js.map +0 -1
  198. package/dist/security/apt-simulation-engine.d.ts +0 -97
  199. package/dist/security/apt-simulation-engine.d.ts.map +0 -1
  200. package/dist/security/apt-simulation-engine.js +0 -441
  201. package/dist/security/apt-simulation-engine.js.map +0 -1
  202. package/dist/security/authorization.d.ts +0 -45
  203. package/dist/security/authorization.d.ts.map +0 -1
  204. package/dist/security/authorization.js +0 -128
  205. package/dist/security/authorization.js.map +0 -1
  206. package/dist/security/comprehensive-security-research.d.ts +0 -84
  207. package/dist/security/comprehensive-security-research.d.ts.map +0 -1
  208. package/dist/security/comprehensive-security-research.js +0 -211
  209. package/dist/security/comprehensive-security-research.js.map +0 -1
  210. package/dist/security/offensive/exploitationEngine.d.ts +0 -54
  211. package/dist/security/offensive/exploitationEngine.d.ts.map +0 -1
  212. package/dist/security/offensive/exploitationEngine.js +0 -263
  213. package/dist/security/offensive/exploitationEngine.js.map +0 -1
  214. package/dist/security/real/networkExploitation.d.ts +0 -92
  215. package/dist/security/real/networkExploitation.d.ts.map +0 -1
  216. package/dist/security/real/networkExploitation.js +0 -316
  217. package/dist/security/real/networkExploitation.js.map +0 -1
  218. package/dist/security/real/persistenceImplementation.d.ts +0 -62
  219. package/dist/security/real/persistenceImplementation.d.ts.map +0 -1
  220. package/dist/security/real/persistenceImplementation.js +0 -323
  221. package/dist/security/real/persistenceImplementation.js.map +0 -1
  222. package/dist/security/real/vulnerabilityScanner.d.ts +0 -73
  223. package/dist/security/real/vulnerabilityScanner.d.ts.map +0 -1
  224. package/dist/security/real/vulnerabilityScanner.js +0 -341
  225. package/dist/security/real/vulnerabilityScanner.js.map +0 -1
  226. package/dist/shell/capturePastePatch.d.ts +0 -9
  227. package/dist/shell/capturePastePatch.d.ts.map +0 -1
  228. package/dist/shell/capturePastePatch.js +0 -98
  229. package/dist/shell/capturePastePatch.js.map +0 -1
  230. package/dist/shell/enhancedInteractiveShell.d.ts +0 -90
  231. package/dist/shell/enhancedInteractiveShell.d.ts.map +0 -1
  232. package/dist/shell/enhancedInteractiveShell.js +0 -248
  233. package/dist/shell/enhancedInteractiveShell.js.map +0 -1
  234. package/dist/shell/inputProcessor.d.ts +0 -56
  235. package/dist/shell/inputProcessor.d.ts.map +0 -1
  236. package/dist/shell/inputProcessor.js +0 -172
  237. package/dist/shell/inputProcessor.js.map +0 -1
  238. package/dist/shell/interactiveShell-patch.d.ts +0 -27
  239. package/dist/shell/interactiveShell-patch.d.ts.map +0 -1
  240. package/dist/shell/interactiveShell-patch.js +0 -38
  241. package/dist/shell/interactiveShell-patch.js.map +0 -1
  242. package/dist/shell/interactiveShell-robust.d.ts +0 -26
  243. package/dist/shell/interactiveShell-robust.d.ts.map +0 -1
  244. package/dist/shell/interactiveShell-robust.js +0 -34
  245. package/dist/shell/interactiveShell-robust.js.map +0 -1
  246. package/dist/shell/multiLinePasteManager.d.ts +0 -106
  247. package/dist/shell/multiLinePasteManager.d.ts.map +0 -1
  248. package/dist/shell/multiLinePasteManager.js +0 -308
  249. package/dist/shell/multiLinePasteManager.js.map +0 -1
  250. package/dist/shell/processInputBlockPatch.d.ts +0 -8
  251. package/dist/shell/processInputBlockPatch.d.ts.map +0 -1
  252. package/dist/shell/processInputBlockPatch.js +0 -133
  253. package/dist/shell/processInputBlockPatch.js.map +0 -1
  254. package/dist/shell/unifiedInputProcessor.d.ts +0 -23
  255. package/dist/shell/unifiedInputProcessor.d.ts.map +0 -1
  256. package/dist/shell/unifiedInputProcessor.js +0 -92
  257. package/dist/shell/unifiedInputProcessor.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,196 +0,0 @@
1
- import { readFileSync, writeFileSync, existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { buildError } from '../core/errors.js';
4
- /**
5
- * Creates the NotebookEdit tool for editing Jupyter .ipynb files
6
- *
7
- * This tool allows surgical editing of Jupyter notebook cells, supporting:
8
- * - Replacing cell content
9
- * - Inserting new cells
10
- * - Deleting cells
11
- * - Both code and markdown cells
12
- *
13
- * @param workingDir - The working directory for resolving paths
14
- * @returns Array containing the NotebookEdit tool definition
15
- */
16
- export function createNotebookEditTools(workingDir) {
17
- return [
18
- {
19
- name: 'NotebookEdit',
20
- description: 'Completely replaces or modifies cells in a Jupyter notebook (.ipynb file). Use edit_mode=replace (default) to replace a cell, edit_mode=insert to add a new cell, or edit_mode=delete to remove a cell.',
21
- parameters: {
22
- type: 'object',
23
- properties: {
24
- notebook_path: {
25
- type: 'string',
26
- description: 'The absolute path to the Jupyter notebook file to edit (must be .ipynb file)',
27
- },
28
- cell_id: {
29
- type: 'string',
30
- description: 'The ID of the cell to edit. When inserting a new cell, the new cell will be inserted after the cell with this ID, or at the beginning if not specified.',
31
- },
32
- new_source: {
33
- type: 'string',
34
- description: 'The new source for the cell (code or markdown content)',
35
- },
36
- cell_type: {
37
- type: 'string',
38
- description: 'The type of the cell (code or markdown). If not specified, defaults to current cell type. Required when using edit_mode=insert.',
39
- },
40
- edit_mode: {
41
- type: 'string',
42
- description: 'The type of edit to make: "replace" (default), "insert", or "delete"',
43
- },
44
- },
45
- required: ['notebook_path', 'new_source'],
46
- additionalProperties: false,
47
- },
48
- handler: async (args) => {
49
- const notebookPath = args['notebook_path'];
50
- const cellId = args['cell_id'];
51
- const newSource = args['new_source'];
52
- const cellType = args['cell_type'];
53
- const editMode = args['edit_mode'] || 'replace';
54
- // Validate inputs
55
- if (typeof notebookPath !== 'string' || !notebookPath.trim()) {
56
- return 'Error: notebook_path must be a non-empty string.';
57
- }
58
- if (!notebookPath.endsWith('.ipynb')) {
59
- return 'Error: notebook_path must be a .ipynb file.';
60
- }
61
- if (typeof newSource !== 'string') {
62
- return 'Error: new_source must be a string.';
63
- }
64
- if (editMode !== 'replace' && editMode !== 'insert' && editMode !== 'delete') {
65
- return 'Error: edit_mode must be "replace", "insert", or "delete".';
66
- }
67
- if (editMode === 'insert' && !cellType) {
68
- return 'Error: cell_type is required when edit_mode=insert.';
69
- }
70
- if (cellType && cellType !== 'code' && cellType !== 'markdown') {
71
- return 'Error: cell_type must be "code" or "markdown".';
72
- }
73
- try {
74
- const filePath = resolveFilePath(workingDir, notebookPath);
75
- // Check file exists
76
- if (!existsSync(filePath)) {
77
- return `Error: Notebook file not found: ${filePath}`;
78
- }
79
- // Read and parse notebook
80
- const content = readFileSync(filePath, 'utf-8');
81
- let notebook;
82
- try {
83
- notebook = JSON.parse(content);
84
- }
85
- catch (parseError) {
86
- return `Error: Failed to parse notebook JSON: ${parseError}`;
87
- }
88
- // Validate notebook structure
89
- if (!notebook.cells || !Array.isArray(notebook.cells)) {
90
- return 'Error: Invalid notebook structure - missing cells array.';
91
- }
92
- // Perform the edit
93
- let resultMessage;
94
- switch (editMode) {
95
- case 'insert':
96
- resultMessage = insertCell(notebook, cellId, newSource, cellType);
97
- break;
98
- case 'delete':
99
- resultMessage = deleteCell(notebook, cellId);
100
- break;
101
- case 'replace':
102
- default:
103
- resultMessage = replaceCell(notebook, cellId, newSource, cellType);
104
- break;
105
- }
106
- // Write back to file
107
- const updatedContent = JSON.stringify(notebook, null, 2);
108
- writeFileSync(filePath, updatedContent, 'utf-8');
109
- return `✓ Notebook edited: ${filePath}\n${resultMessage}`;
110
- }
111
- catch (error) {
112
- return buildError('editing notebook', error, {
113
- notebook_path: notebookPath,
114
- edit_mode: editMode,
115
- });
116
- }
117
- },
118
- },
119
- ];
120
- }
121
- function resolveFilePath(workingDir, path) {
122
- const normalized = path.trim();
123
- return normalized.startsWith('/') ? normalized : join(workingDir, normalized);
124
- }
125
- function replaceCell(notebook, cellId, newSource, cellType) {
126
- let cellIndex;
127
- if (cellId) {
128
- // Find cell by ID
129
- cellIndex = notebook.cells.findIndex(c => c.id === cellId);
130
- if (cellIndex === -1) {
131
- throw new Error(`Cell with id "${cellId}" not found.`);
132
- }
133
- }
134
- else {
135
- // Default to first cell
136
- if (notebook.cells.length === 0) {
137
- throw new Error('Notebook has no cells. Use edit_mode=insert to add a cell.');
138
- }
139
- cellIndex = 0;
140
- }
141
- const cell = notebook.cells[cellIndex];
142
- const oldType = cell.cell_type;
143
- const newType = cellType || oldType;
144
- // Update cell
145
- cell.cell_type = newType;
146
- cell.source = newSource.split('\n');
147
- // If changing from code to markdown, remove code-specific fields
148
- if (oldType === 'code' && newType === 'markdown') {
149
- delete cell.execution_count;
150
- delete cell.outputs;
151
- }
152
- // If changing from markdown to code, add code-specific fields
153
- if (oldType === 'markdown' && newType === 'code') {
154
- cell.execution_count = null;
155
- cell.outputs = [];
156
- }
157
- return `Replaced cell ${cellIndex} (${oldType} → ${newType})`;
158
- }
159
- function insertCell(notebook, afterCellId, newSource, cellType) {
160
- let insertIndex = 0;
161
- if (afterCellId) {
162
- const afterIndex = notebook.cells.findIndex(c => c.id === afterCellId);
163
- if (afterIndex === -1) {
164
- throw new Error(`Cell with id "${afterCellId}" not found.`);
165
- }
166
- insertIndex = afterIndex + 1;
167
- }
168
- const newCell = {
169
- cell_type: cellType,
170
- id: generateCellId(),
171
- metadata: {},
172
- source: newSource.split('\n'),
173
- };
174
- if (cellType === 'code') {
175
- newCell.execution_count = null;
176
- newCell.outputs = [];
177
- }
178
- notebook.cells.splice(insertIndex, 0, newCell);
179
- return `Inserted new ${cellType} cell at position ${insertIndex}`;
180
- }
181
- function deleteCell(notebook, cellId) {
182
- if (!cellId) {
183
- throw new Error('cell_id is required when edit_mode=delete.');
184
- }
185
- const cellIndex = notebook.cells.findIndex(c => c.id === cellId);
186
- if (cellIndex === -1) {
187
- throw new Error(`Cell with id "${cellId}" not found.`);
188
- }
189
- const cellType = notebook.cells[cellIndex].cell_type;
190
- notebook.cells.splice(cellIndex, 1);
191
- return `Deleted ${cellType} cell at position ${cellIndex}`;
192
- }
193
- function generateCellId() {
194
- // Generate a random cell ID (simplified version)
195
- return Math.random().toString(36).substring(2, 10);
196
- }
@@ -1,46 +0,0 @@
1
- /**
2
- * Creates planning workflow tools
3
- *
4
- * Tools:
5
- * - ExitPlanMode: Signal completion of planning phase
6
- *
7
- * These tools help structure agent workflows with explicit planning phases.
8
- */
9
- export function createPlanningTools() {
10
- return [
11
- {
12
- name: 'ExitPlanMode',
13
- description: 'Use this tool when you are in plan mode and have finished presenting your plan and are ready to code. This will prompt the user to exit plan mode. IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you are gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.',
14
- parameters: {
15
- type: 'object',
16
- properties: {
17
- plan: {
18
- type: 'string',
19
- description: 'The plan you came up with, that you want to run by the user for approval. Supports markdown. The plan should be pretty concise.',
20
- },
21
- },
22
- required: ['plan'],
23
- additionalProperties: false,
24
- },
25
- handler: async (args) => {
26
- const plan = args['plan'];
27
- if (typeof plan !== 'string' || !plan.trim()) {
28
- return 'Error: plan must be a non-empty string.';
29
- }
30
- // Format the plan output
31
- const formattedPlan = [
32
- '='.repeat(70),
33
- 'PLAN READY FOR APPROVAL',
34
- '='.repeat(70),
35
- '',
36
- plan.trim(),
37
- '',
38
- '='.repeat(70),
39
- 'Ready to proceed? If you approve this plan, I will begin implementation.',
40
- '='.repeat(70),
41
- ].join('\n');
42
- return formattedPlan;
43
- },
44
- },
45
- ];
46
- }
@@ -1,293 +0,0 @@
1
- import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
2
- import { basename, join, relative } from 'node:path';
3
- import { performAdvancedAstAnalysis } from './codeAnalysisTools.js';
4
- const SOURCE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
5
- const IGNORED_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build', '.next', '.turbo']);
6
- export function createRefactoringTools(workingDir) {
7
- return [
8
- {
9
- name: 'detect_refactoring_hotspots',
10
- description: 'Scan a file or directory for large/complex functions that merit refactoring.',
11
- parameters: {
12
- type: 'object',
13
- properties: {
14
- path: {
15
- type: 'string',
16
- description: 'File or directory to inspect (relative to workspace).',
17
- },
18
- maxResults: {
19
- type: 'number',
20
- description: 'Limit the number of hotspots returned (default: 10).',
21
- },
22
- },
23
- required: ['path'],
24
- additionalProperties: false,
25
- },
26
- handler: async (args) => {
27
- try {
28
- const targetPath = resolveFilePath(workingDir, args['path']);
29
- if (!existsSync(targetPath)) {
30
- return `Error: Path not found: ${targetPath}`;
31
- }
32
- const files = collectSourceFiles(targetPath);
33
- if (files.length === 0) {
34
- return `No source files (.ts/.tsx/.js/.jsx) discovered under ${targetPath}.`;
35
- }
36
- const hotspots = [];
37
- for (const file of files) {
38
- const content = readFileSync(file, 'utf-8');
39
- const ast = performAdvancedAstAnalysis(content, file);
40
- for (const symbol of ast.symbols) {
41
- if (symbol.kind === 'class') {
42
- continue;
43
- }
44
- const reasons = [];
45
- if (symbol.statementCount > 40) {
46
- reasons.push(`long body (${symbol.statementCount} statements)`);
47
- }
48
- if (symbol.cyclomaticComplexity > 12) {
49
- reasons.push(`complex (CC ${symbol.cyclomaticComplexity})`);
50
- }
51
- const span = symbol.endLine - symbol.startLine + 1;
52
- if (span > 120) {
53
- reasons.push(`spans ${span} lines`);
54
- }
55
- if (reasons.length > 0) {
56
- hotspots.push({
57
- file,
58
- symbol,
59
- reasons,
60
- score: symbol.cyclomaticComplexity * 2 + symbol.statementCount,
61
- });
62
- }
63
- }
64
- }
65
- if (hotspots.length === 0) {
66
- return 'No refactoring hotspots detected.';
67
- }
68
- const maxResultsArg = args['maxResults'];
69
- const limit = typeof maxResultsArg === 'number' && Number.isFinite(maxResultsArg) && maxResultsArg > 0
70
- ? Math.floor(maxResultsArg)
71
- : 10;
72
- hotspots.sort((a, b) => b.score - a.score);
73
- const selection = hotspots.slice(0, limit);
74
- const output = [];
75
- output.push(`# Refactoring hotspots (${selection.length}/${hotspots.length})`);
76
- output.push('');
77
- selection.forEach((record, index) => {
78
- const relPath = relative(workingDir, record.file);
79
- const span = record.symbol.endLine - record.symbol.startLine + 1;
80
- output.push(`${index + 1}. ${record.symbol.name} in ${relPath} (lines ${record.symbol.startLine}-${record.symbol.endLine})`);
81
- output.push(` - Severity score: ${record.score}`);
82
- output.push(` - Reasons: ${record.reasons.join(', ')}`);
83
- output.push(` - Statements: ${record.symbol.statementCount}, CC: ${record.symbol.cyclomaticComplexity}, span ${span} lines`);
84
- });
85
- return output.join('\n');
86
- }
87
- catch (error) {
88
- return `Error detecting hotspots: ${error instanceof Error ? error.message : String(error)}`;
89
- }
90
- },
91
- },
92
- {
93
- name: 'generate_refactor_plan',
94
- description: 'Create a structured refactor plan for the most complex symbol in a file (or a specific symbol).',
95
- parameters: {
96
- type: 'object',
97
- properties: {
98
- path: {
99
- type: 'string',
100
- description: 'File to analyze.',
101
- },
102
- symbol: {
103
- type: 'string',
104
- description: 'Optional symbol to target (defaults to the most complex function).',
105
- },
106
- },
107
- required: ['path'],
108
- additionalProperties: false,
109
- },
110
- handler: async (args) => {
111
- try {
112
- const filePath = resolveFilePath(workingDir, args['path']);
113
- if (!existsSync(filePath)) {
114
- return `Error: File not found: ${filePath}`;
115
- }
116
- const content = readFileSync(filePath, 'utf-8');
117
- const ast = performAdvancedAstAnalysis(content, filePath);
118
- if (ast.symbols.length === 0) {
119
- return `No analyzable symbols found in ${filePath}.`;
120
- }
121
- const targetSymbol = selectTargetSymbol(ast.symbols, args['symbol']);
122
- if (!targetSymbol) {
123
- return `Symbol "${String(args['symbol'])}" not found in ${filePath}.`;
124
- }
125
- const callOutputs = ast.callGraph.filter((edge) => edge.from === targetSymbol.name || edge.to === targetSymbol.name);
126
- const relPath = relative(workingDir, filePath);
127
- const plan = [];
128
- plan.push(`# Refactor plan for ${targetSymbol.name}`);
129
- plan.push(`File: ${relPath}`);
130
- plan.push('');
131
- plan.push('## Current metrics');
132
- plan.push(`- Statements: ${targetSymbol.statementCount}`);
133
- plan.push(`- Cyclomatic complexity: ${targetSymbol.cyclomaticComplexity}`);
134
- plan.push(`- Span: lines ${targetSymbol.startLine}-${targetSymbol.endLine}`);
135
- plan.push('');
136
- plan.push('## Recommended steps');
137
- plan.push('- Break the function into cohesive helpers grouped by responsibility.');
138
- if (targetSymbol.statementCount > 60) {
139
- plan.push('- Extract the initialization / setup logic into a dedicated helper.');
140
- }
141
- if (targetSymbol.cyclomaticComplexity > 14) {
142
- plan.push('- Replace deeply nested branching with guard clauses or strategy objects.');
143
- }
144
- plan.push('- Introduce descriptive interfaces/types to clarify inputs and return values.');
145
- plan.push('- Write focused unit tests for each new helper and for the refactored entry point.');
146
- plan.push('');
147
- plan.push('## Dependency considerations');
148
- if (callOutputs.length === 0) {
149
- plan.push('This symbol does not interact with other tracked functions inside the file.');
150
- }
151
- else {
152
- plan.push('Calls & referenced symbols:');
153
- callOutputs.forEach((edge) => {
154
- if (edge.from === targetSymbol.name) {
155
- plan.push(`- Calls ${edge.to} (${edge.count} time${edge.count === 1 ? '' : 's'})`);
156
- }
157
- else {
158
- plan.push(`- Invoked by ${edge.from} (${edge.count} call${edge.count === 1 ? '' : 's'})`);
159
- }
160
- });
161
- }
162
- return plan.join('\n');
163
- }
164
- catch (error) {
165
- return `Error generating refactor plan: ${error instanceof Error ? error.message : String(error)}`;
166
- }
167
- },
168
- },
169
- {
170
- name: 'analyze_refactor_impact',
171
- description: 'Summarize inbound/outbound calls for a symbol to estimate refactor blast radius.',
172
- parameters: {
173
- type: 'object',
174
- properties: {
175
- path: {
176
- type: 'string',
177
- description: 'File containing the symbol.',
178
- },
179
- symbol: {
180
- type: 'string',
181
- description: 'Symbol name to inspect. Defaults to the most connected symbol.',
182
- },
183
- },
184
- required: ['path'],
185
- additionalProperties: false,
186
- },
187
- handler: async (args) => {
188
- try {
189
- const filePath = resolveFilePath(workingDir, args['path']);
190
- if (!existsSync(filePath)) {
191
- return `Error: File not found: ${filePath}`;
192
- }
193
- const content = readFileSync(filePath, 'utf-8');
194
- const ast = performAdvancedAstAnalysis(content, filePath);
195
- if (ast.symbols.length === 0) {
196
- return `No analyzable symbols found in ${filePath}.`;
197
- }
198
- const fallbackSymbol = ast.symbols[0]?.name ?? '';
199
- const symbolArg = args['symbol'];
200
- const symbolName = typeof symbolArg === 'string' && symbolArg.trim()
201
- ? symbolArg.trim()
202
- : findMostConnectedSymbol(ast) ?? fallbackSymbol;
203
- const incoming = ast.callGraph.filter((edge) => edge.to === symbolName);
204
- const outgoing = ast.callGraph.filter((edge) => edge.from === symbolName);
205
- const summary = [];
206
- summary.push(`# Refactor impact for ${symbolName}`);
207
- summary.push('');
208
- summary.push('## Incoming references');
209
- if (incoming.length === 0) {
210
- summary.push('No recorded inbound calls inside this file.');
211
- }
212
- else {
213
- incoming.forEach((edge) => {
214
- summary.push(`- ${edge.from} (${edge.count} call${edge.count === 1 ? '' : 's'})`);
215
- });
216
- }
217
- summary.push('');
218
- summary.push('## Outgoing calls');
219
- if (outgoing.length === 0) {
220
- summary.push('No outbound calls recorded.');
221
- }
222
- else {
223
- outgoing.forEach((edge) => {
224
- summary.push(`- ${edge.to} (${edge.count} call${edge.count === 1 ? '' : 's'})`);
225
- });
226
- }
227
- return summary.join('\n');
228
- }
229
- catch (error) {
230
- return `Error analyzing refactor impact: ${error instanceof Error ? error.message : String(error)}`;
231
- }
232
- },
233
- },
234
- ];
235
- }
236
- function resolveFilePath(workingDir, path) {
237
- if (typeof path !== 'string' || !path.trim()) {
238
- throw new Error('Path must be a non-empty string.');
239
- }
240
- const value = path.trim();
241
- return value.startsWith('/') ? value : join(workingDir, value);
242
- }
243
- function collectSourceFiles(targetPath) {
244
- const stats = statSync(targetPath);
245
- if (stats.isDirectory()) {
246
- const directoryName = basename(targetPath);
247
- if (IGNORED_DIRECTORIES.has(directoryName)) {
248
- return [];
249
- }
250
- const entries = readdirSync(targetPath);
251
- const files = [];
252
- for (const entry of entries) {
253
- files.push(...collectSourceFiles(join(targetPath, entry)));
254
- }
255
- return files;
256
- }
257
- if (!stats.isFile()) {
258
- return [];
259
- }
260
- if (SOURCE_EXTENSIONS.some((ext) => targetPath.endsWith(ext))) {
261
- return [targetPath];
262
- }
263
- return [];
264
- }
265
- function selectTargetSymbol(symbols, requestedSymbol) {
266
- if (typeof requestedSymbol === 'string' && requestedSymbol.trim()) {
267
- const match = symbols.find((symbol) => symbol.name === requestedSymbol.trim());
268
- if (match) {
269
- return match;
270
- }
271
- return null;
272
- }
273
- const sorted = [...symbols]
274
- .filter((symbol) => symbol.kind !== 'class')
275
- .sort((a, b) => b.cyclomaticComplexity - a.cyclomaticComplexity);
276
- return sorted[0] ?? null;
277
- }
278
- function findMostConnectedSymbol(ast) {
279
- const connectionWeights = new Map();
280
- for (const edge of ast.callGraph) {
281
- connectionWeights.set(edge.from, (connectionWeights.get(edge.from) ?? 0) + edge.count);
282
- connectionWeights.set(edge.to, (connectionWeights.get(edge.to) ?? 0) + edge.count);
283
- }
284
- let bestSymbol = null;
285
- let bestScore = -1;
286
- for (const [symbol, weight] of connectionWeights.entries()) {
287
- if (weight > bestScore) {
288
- bestSymbol = symbol;
289
- bestScore = weight;
290
- }
291
- }
292
- return bestSymbol;
293
- }