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,332 +0,0 @@
1
- import { readFileSync, readdirSync, statSync } from 'node:fs';
2
- import { join, relative, extname } from 'node:path';
3
- import { buildError } from '../core/errors.js';
4
- /**
5
- * Creates the Grep tool - a powerful search tool built on ripgrep patterns
6
- *
7
- * Features:
8
- * - Full regex syntax support
9
- * - Multiple output modes (content, files_with_matches, count)
10
- * - Context lines (-A, -B, -C)
11
- * - Case insensitivity
12
- * - Type filtering (js, ts, py, etc.)
13
- * - Glob pattern filtering
14
- * - Multiline matching
15
- * - Head/offset limiting
16
- *
17
- * @param workingDir - The working directory for searching
18
- * @returns Array containing the Grep tool definition
19
- */
20
- export function createGrepTools(workingDir) {
21
- return [
22
- {
23
- name: 'Grep',
24
- description: 'A powerful search tool built on ripgrep patterns. Supports full regex syntax, multiple output modes, and context lines. Use for searching file contents.',
25
- parameters: {
26
- type: 'object',
27
- properties: {
28
- pattern: {
29
- type: 'string',
30
- description: 'The regular expression pattern to search for in file contents',
31
- },
32
- path: {
33
- type: 'string',
34
- description: 'File or directory to search in (defaults to current working directory)',
35
- },
36
- output_mode: {
37
- type: 'string',
38
- description: 'Output mode: "content" shows matching lines, "files_with_matches" shows file paths (default), "count" shows match counts',
39
- },
40
- '-i': {
41
- type: 'boolean',
42
- description: 'Case insensitive search',
43
- },
44
- '-n': {
45
- type: 'boolean',
46
- description: 'Show line numbers in output (requires output_mode: "content"). Defaults to true.',
47
- },
48
- '-A': {
49
- type: 'number',
50
- description: 'Number of lines to show after each match (requires output_mode: "content")',
51
- },
52
- '-B': {
53
- type: 'number',
54
- description: 'Number of lines to show before each match (requires output_mode: "content")',
55
- },
56
- '-C': {
57
- type: 'number',
58
- description: 'Number of lines to show before and after each match (requires output_mode: "content")',
59
- },
60
- glob: {
61
- type: 'string',
62
- description: 'Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}")',
63
- },
64
- type: {
65
- type: 'string',
66
- description: 'File type to search (e.g. "js", "py", "rust", "go"). More efficient than glob for standard file types.',
67
- },
68
- multiline: {
69
- type: 'boolean',
70
- description: 'Enable multiline mode where . matches newlines and patterns can span lines. Default: false.',
71
- },
72
- head_limit: {
73
- type: 'number',
74
- description: 'Limit output to first N entries. Defaults: content=20, files=30, count=50. Always use low values to prevent context overflow.',
75
- },
76
- offset: {
77
- type: 'number',
78
- description: 'Skip first N lines/entries before applying head_limit. Defaults to 0.',
79
- },
80
- },
81
- required: ['pattern'],
82
- additionalProperties: false,
83
- },
84
- handler: async (args) => {
85
- const pattern = args['pattern'];
86
- const pathArg = args['path'];
87
- const outputMode = args['output_mode'] || 'files_with_matches';
88
- const caseInsensitive = args['-i'] === true;
89
- const showLineNumbers = args['-n'] !== false; // Default true
90
- const afterContext = typeof args['-A'] === 'number' ? args['-A'] : 0;
91
- const beforeContext = typeof args['-B'] === 'number' ? args['-B'] : 0;
92
- const contextLines = typeof args['-C'] === 'number' ? args['-C'] : 0;
93
- const globPattern = args['glob'];
94
- const fileType = args['type'];
95
- const multiline = args['multiline'] === true;
96
- // CRITICAL: Much lower defaults based on output mode
97
- const defaultLimit = outputMode === 'content' ? 20 : (outputMode === 'count' ? 50 : 30);
98
- const headLimit = typeof args['head_limit'] === 'number' ? args['head_limit'] : defaultLimit;
99
- const offset = typeof args['offset'] === 'number' ? args['offset'] : 0;
100
- // Validate pattern
101
- if (typeof pattern !== 'string' || !pattern.trim()) {
102
- return 'Error: pattern must be a non-empty string.';
103
- }
104
- // Validate output_mode
105
- if (outputMode !== 'content' && outputMode !== 'files_with_matches' && outputMode !== 'count') {
106
- return 'Error: output_mode must be "content", "files_with_matches", or "count".';
107
- }
108
- try {
109
- const searchPath = pathArg && typeof pathArg === 'string'
110
- ? resolveFilePath(workingDir, pathArg)
111
- : workingDir;
112
- // Create regex with appropriate flags
113
- const flags = caseInsensitive ? 'gi' : 'g';
114
- const dotallFlags = multiline ? (caseInsensitive ? 'gis' : 'gs') : flags;
115
- const regex = new RegExp(pattern, dotallFlags);
116
- // Perform search
117
- const matches = searchFiles(searchPath, regex, {
118
- globPattern: typeof globPattern === 'string' ? globPattern : undefined,
119
- fileType: typeof fileType === 'string' ? fileType : undefined,
120
- multiline,
121
- });
122
- // Apply offset and head_limit
123
- const totalMatches = matches.length;
124
- const filteredMatches = applyOffsetAndLimit(matches, offset, headLimit);
125
- const truncated = totalMatches > filteredMatches.length;
126
- // Format output based on mode
127
- let result;
128
- switch (outputMode) {
129
- case 'content':
130
- result = formatContentOutput(filteredMatches, {
131
- showLineNumbers,
132
- beforeContext: contextLines || beforeContext,
133
- afterContext: contextLines || afterContext,
134
- searchPath,
135
- });
136
- break;
137
- case 'count':
138
- result = formatCountOutput(filteredMatches, searchPath);
139
- break;
140
- case 'files_with_matches':
141
- default:
142
- result = formatFilesOutput(filteredMatches, searchPath);
143
- break;
144
- }
145
- // Add truncation notice
146
- if (truncated) {
147
- result += `\n\n... [${totalMatches - filteredMatches.length} more matches truncated. Use head_limit parameter to see more]`;
148
- }
149
- return result;
150
- }
151
- catch (error) {
152
- return buildError('grep search', error, {
153
- pattern: String(pattern),
154
- path: pathArg ? String(pathArg) : undefined,
155
- output_mode: String(outputMode),
156
- });
157
- }
158
- },
159
- },
160
- ];
161
- }
162
- function resolveFilePath(workingDir, path) {
163
- const normalized = path.trim();
164
- return normalized.startsWith('/') ? normalized : join(workingDir, normalized);
165
- }
166
- function searchFiles(searchPath, regex, options) {
167
- const results = [];
168
- const ignoredDirs = new Set([
169
- '.git', 'node_modules', 'dist', '.next', 'build', 'coverage',
170
- '.turbo', '.cache', '__pycache__', '.pytest_cache', '.venv', 'venv',
171
- ]);
172
- function search(currentPath) {
173
- try {
174
- const stat = statSync(currentPath);
175
- if (stat.isDirectory()) {
176
- const entries = readdirSync(currentPath);
177
- for (const entry of entries) {
178
- if (ignoredDirs.has(entry))
179
- continue;
180
- search(join(currentPath, entry));
181
- }
182
- }
183
- else if (stat.isFile()) {
184
- // Filter by file type or glob
185
- if (options.fileType && !matchesFileType(currentPath, options.fileType)) {
186
- return;
187
- }
188
- if (options.globPattern && !matchesGlob(currentPath, options.globPattern)) {
189
- return;
190
- }
191
- // Skip binary files
192
- if (isBinaryFile(currentPath)) {
193
- return;
194
- }
195
- // Read and search file
196
- const content = readFileSync(currentPath, 'utf-8');
197
- if (options.multiline) {
198
- // Multiline mode: search entire content
199
- const matches = content.match(regex);
200
- if (matches) {
201
- for (const match of matches) {
202
- results.push({
203
- file: currentPath,
204
- line: 1, // In multiline, line numbers are approximate
205
- content: match,
206
- match,
207
- });
208
- }
209
- }
210
- }
211
- else {
212
- // Line-by-line mode
213
- const lines = content.split('\n');
214
- lines.forEach((line, index) => {
215
- const matches = line.match(regex);
216
- if (matches) {
217
- results.push({
218
- file: currentPath,
219
- line: index + 1,
220
- content: line,
221
- match: matches[0],
222
- });
223
- }
224
- });
225
- }
226
- }
227
- }
228
- catch (error) {
229
- // Silently ignore permission errors
230
- }
231
- }
232
- search(searchPath);
233
- return results;
234
- }
235
- function applyOffsetAndLimit(matches, offset, headLimit) {
236
- let result = matches;
237
- if (offset > 0) {
238
- result = result.slice(offset);
239
- }
240
- if (headLimit !== undefined && headLimit > 0) {
241
- result = result.slice(0, headLimit);
242
- }
243
- return result;
244
- }
245
- function formatContentOutput(matches, options) {
246
- if (matches.length === 0) {
247
- return 'No matches found.';
248
- }
249
- const lines = [];
250
- for (const match of matches) {
251
- const relPath = relative(options.searchPath, match.file);
252
- const displayPath = relPath && !relPath.startsWith('..') ? relPath : match.file;
253
- if (options.showLineNumbers) {
254
- lines.push(`${displayPath}:${match.line}:${match.content}`);
255
- }
256
- else {
257
- lines.push(`${displayPath}:${match.content}`);
258
- }
259
- }
260
- return lines.join('\n');
261
- }
262
- function formatFilesOutput(matches, searchPath) {
263
- if (matches.length === 0) {
264
- return 'No matches found.';
265
- }
266
- // Get unique file paths
267
- const uniqueFiles = [...new Set(matches.map(m => m.file))];
268
- const relativePaths = uniqueFiles.map(file => {
269
- const rel = relative(searchPath, file);
270
- return rel && !rel.startsWith('..') ? rel : file;
271
- });
272
- return relativePaths.join('\n');
273
- }
274
- function formatCountOutput(matches, searchPath) {
275
- if (matches.length === 0) {
276
- return 'No matches found.';
277
- }
278
- // Count matches per file
279
- const counts = new Map();
280
- for (const match of matches) {
281
- counts.set(match.file, (counts.get(match.file) || 0) + 1);
282
- }
283
- const lines = [];
284
- for (const [file, count] of counts) {
285
- const relPath = relative(searchPath, file);
286
- const displayPath = relPath && !relPath.startsWith('..') ? relPath : file;
287
- lines.push(`${count}:${displayPath}`);
288
- }
289
- return lines.join('\n');
290
- }
291
- function matchesFileType(filePath, fileType) {
292
- const ext = extname(filePath).toLowerCase();
293
- const typeMap = {
294
- js: ['.js', '.jsx', '.mjs', '.cjs'],
295
- ts: ['.ts', '.tsx'],
296
- py: ['.py'],
297
- rust: ['.rs'],
298
- go: ['.go'],
299
- java: ['.java'],
300
- cpp: ['.cpp', '.cc', '.cxx', '.hpp', '.h'],
301
- c: ['.c', '.h'],
302
- ruby: ['.rb'],
303
- php: ['.php'],
304
- html: ['.html', '.htm'],
305
- css: ['.css', '.scss', '.sass'],
306
- json: ['.json'],
307
- yaml: ['.yaml', '.yml'],
308
- md: ['.md', '.markdown'],
309
- };
310
- const extensions = typeMap[fileType.toLowerCase()];
311
- return extensions ? extensions.includes(ext) : false;
312
- }
313
- function matchesGlob(filePath, globPattern) {
314
- const pattern = globPattern
315
- .replace(/\./g, '\\.')
316
- .replace(/\*\*/g, '.*')
317
- .replace(/\*/g, '[^/]*')
318
- .replace(/\?/g, '.');
319
- const regex = new RegExp(pattern + '$');
320
- return regex.test(filePath);
321
- }
322
- function isBinaryFile(filePath) {
323
- const ext = extname(filePath).toLowerCase();
324
- const binaryExts = new Set([
325
- '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.ico', '.svg',
326
- '.pdf', '.zip', '.tar', '.gz', '.7z', '.rar',
327
- '.exe', '.dll', '.so', '.dylib', '.bin',
328
- '.mp3', '.mp4', '.avi', '.mov', '.flv',
329
- '.woff', '.woff2', '.ttf', '.eot',
330
- ]);
331
- return binaryExts.has(ext);
332
- }
@@ -1,170 +0,0 @@
1
- import * as readline from 'node:readline';
2
- export function createInteractionTools() {
3
- return [
4
- {
5
- name: 'AskUserQuestion',
6
- description: `Use this tool when you need to ask the user questions during execution. This allows you to:
7
- 1. Gather user preferences or requirements
8
- 2. Clarify ambiguous instructions
9
- 3. Get decisions on implementation choices as you work
10
- 4. Offer choices to the user about what direction to take
11
-
12
- Usage notes:
13
- - Users will always be able to select "Other" to provide custom text input
14
- - Use multiSelect: true to allow multiple answers to be selected for a question`,
15
- parameters: {
16
- type: 'object',
17
- properties: {
18
- questions: {
19
- description: 'Questions to ask the user (1-4 questions)',
20
- type: 'array',
21
- items: {
22
- type: 'object',
23
- properties: {
24
- question: {
25
- type: 'string',
26
- description: 'The complete question to ask the user. Should be clear, specific, and end with a question mark. Example: "Which library should we use for date formatting?" If multiSelect is true, phrase it accordingly, e.g. "Which features do you want to enable?"',
27
- },
28
- header: {
29
- type: 'string',
30
- description: 'Very short label displayed as a chip/tag (max 12 chars). Examples: "Auth method", "Library", "Approach".',
31
- },
32
- options: {
33
- type: 'array',
34
- description: 'The available choices for this question. Must have 2-4 options. Each option should be a distinct, mutually exclusive choice (unless multiSelect is enabled). There should be no "Other" option, that will be provided automatically.',
35
- items: {
36
- type: 'object',
37
- properties: {
38
- label: {
39
- type: 'string',
40
- description: 'The display text for this option that the user will see and select. Should be concise (1-5 words) and clearly describe the choice.',
41
- },
42
- description: {
43
- type: 'string',
44
- description: 'Explanation of what this option means or what will happen if chosen. Useful for providing context about trade-offs or implications.',
45
- },
46
- },
47
- required: ['label', 'description'],
48
- additionalProperties: false,
49
- },
50
- },
51
- multiSelect: {
52
- type: 'boolean',
53
- description: 'Set to true to allow the user to select multiple options instead of just one. Use when choices are not mutually exclusive.',
54
- },
55
- },
56
- required: ['question', 'header', 'options', 'multiSelect'],
57
- additionalProperties: false,
58
- },
59
- },
60
- answers: {
61
- type: 'object',
62
- description: 'User answers collected by the permission component',
63
- },
64
- },
65
- required: ['questions'],
66
- },
67
- handler: async (args) => {
68
- const questions = args['questions'];
69
- const answers = args['answers'];
70
- if (!questions || !Array.isArray(questions)) {
71
- return 'Error: questions parameter is required and must be an array.';
72
- }
73
- if (answers) {
74
- // Answers were already provided (e.g., by an interactive UI layer)
75
- let output = 'šŸ“‹ User Responses:\n\n';
76
- for (const [key, value] of Object.entries(answers)) {
77
- output += `${key}: ${value}\n`;
78
- }
79
- return output;
80
- }
81
- // Interactive mode - ask questions via terminal
82
- const rl = readline.createInterface({
83
- input: process.stdin,
84
- output: process.stdout,
85
- });
86
- const userAnswers = {};
87
- try {
88
- for (let i = 0; i < questions.length; i++) {
89
- const q = questions[i];
90
- if (!q)
91
- continue;
92
- console.log(`\n[${q.header}] ${q.question}`);
93
- console.log('');
94
- q.options.forEach((opt, idx) => {
95
- console.log(` ${idx + 1}. ${opt.label}`);
96
- console.log(` ${opt.description}`);
97
- });
98
- console.log(` ${q.options.length + 1}. Other (custom input)`);
99
- console.log('');
100
- const answer = await new Promise((resolve) => {
101
- rl.question(q.multiSelect
102
- ? `Select options (comma-separated numbers, e.g., "1,3"): `
103
- : `Select an option (1-${q.options.length + 1}): `, (input) => {
104
- resolve(input.trim());
105
- });
106
- });
107
- if (q.multiSelect) {
108
- // Handle multi-select
109
- const selections = answer
110
- .split(',')
111
- .map((s) => s.trim())
112
- .filter((s) => s.length > 0);
113
- const selectedOptions = [];
114
- for (const sel of selections) {
115
- const idx = parseInt(sel, 10);
116
- if (idx >= 1 && idx <= q.options.length) {
117
- const option = q.options[idx - 1];
118
- if (option) {
119
- selectedOptions.push(option.label);
120
- }
121
- }
122
- else if (idx === q.options.length + 1) {
123
- const customAnswer = await new Promise((resolve) => {
124
- rl.question('Enter custom value: ', (input) => {
125
- resolve(input.trim());
126
- });
127
- });
128
- selectedOptions.push(customAnswer);
129
- }
130
- }
131
- userAnswers[q.header] = selectedOptions.join(', ');
132
- }
133
- else {
134
- // Handle single select
135
- const idx = parseInt(answer, 10);
136
- if (idx >= 1 && idx <= q.options.length) {
137
- const option = q.options[idx - 1];
138
- if (option) {
139
- userAnswers[q.header] = option.label;
140
- }
141
- else {
142
- userAnswers[q.header] = 'Invalid selection';
143
- }
144
- }
145
- else if (idx === q.options.length + 1) {
146
- const customAnswer = await new Promise((resolve) => {
147
- rl.question('Enter custom value: ', (input) => {
148
- resolve(input.trim());
149
- });
150
- });
151
- userAnswers[q.header] = customAnswer;
152
- }
153
- else {
154
- userAnswers[q.header] = 'Invalid selection';
155
- }
156
- }
157
- }
158
- let output = '\nšŸ“‹ User Responses:\n\n';
159
- for (const [key, value] of Object.entries(userAnswers)) {
160
- output += `${key}: ${value}\n`;
161
- }
162
- return output;
163
- }
164
- finally {
165
- rl.close();
166
- }
167
- },
168
- },
169
- ];
170
- }