codehere 0.1.0 → 0.2.0

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.

Potentially problematic release.


This version of codehere might be problematic. Click here for more details.

Files changed (603) hide show
  1. package/README.md +51 -25
  2. package/dist/agents/base.d.ts +107 -0
  3. package/dist/agents/base.d.ts.map +1 -0
  4. package/dist/agents/base.js +101 -0
  5. package/dist/agents/base.js.map +1 -0
  6. package/dist/agents/orchestrator-model-driven.d.ts +41 -0
  7. package/dist/agents/orchestrator-model-driven.d.ts.map +1 -0
  8. package/dist/agents/orchestrator-model-driven.js +141 -0
  9. package/dist/agents/orchestrator-model-driven.js.map +1 -0
  10. package/dist/agents/react-orchestrator-agent.d.ts +15 -0
  11. package/dist/agents/react-orchestrator-agent.d.ts.map +1 -0
  12. package/dist/agents/react-orchestrator-agent.js +54 -0
  13. package/dist/agents/react-orchestrator-agent.js.map +1 -0
  14. package/dist/application/agents/execution-agent.d.ts +68 -0
  15. package/dist/application/agents/execution-agent.d.ts.map +1 -0
  16. package/dist/application/agents/execution-agent.js +299 -0
  17. package/dist/application/agents/execution-agent.js.map +1 -0
  18. package/dist/application/agents/multi-agent-orchestrator.d.ts +64 -0
  19. package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -0
  20. package/dist/application/agents/multi-agent-orchestrator.js +209 -0
  21. package/dist/application/agents/multi-agent-orchestrator.js.map +1 -0
  22. package/dist/application/agents/planning-agent.d.ts +61 -0
  23. package/dist/application/agents/planning-agent.d.ts.map +1 -0
  24. package/dist/application/agents/planning-agent.js +357 -0
  25. package/dist/application/agents/planning-agent.js.map +1 -0
  26. package/dist/application/agents/validation-agent.d.ts +64 -0
  27. package/dist/application/agents/validation-agent.d.ts.map +1 -0
  28. package/dist/application/agents/validation-agent.js +182 -0
  29. package/dist/application/agents/validation-agent.js.map +1 -0
  30. package/dist/application/architectures/plan-and-act.d.ts +94 -0
  31. package/dist/application/architectures/plan-and-act.d.ts.map +1 -0
  32. package/dist/application/architectures/plan-and-act.js +242 -0
  33. package/dist/application/architectures/plan-and-act.js.map +1 -0
  34. package/dist/application/index.d.ts +12 -0
  35. package/dist/application/index.d.ts.map +1 -0
  36. package/dist/application/index.js +12 -0
  37. package/dist/application/index.js.map +1 -0
  38. package/dist/application/services/agent-factory.d.ts +9 -0
  39. package/dist/application/services/agent-factory.d.ts.map +1 -0
  40. package/dist/application/services/agent-factory.js +28 -0
  41. package/dist/application/services/agent-factory.js.map +1 -0
  42. package/dist/application/services/dependency-container.d.ts +140 -0
  43. package/dist/application/services/dependency-container.d.ts.map +1 -0
  44. package/dist/application/services/dependency-container.js +402 -0
  45. package/dist/application/services/dependency-container.js.map +1 -0
  46. package/dist/application/services/git-context-service.d.ts +30 -0
  47. package/dist/application/services/git-context-service.d.ts.map +1 -0
  48. package/dist/application/services/git-context-service.js +83 -0
  49. package/dist/application/services/git-context-service.js.map +1 -0
  50. package/dist/application/services/intelligent-router.d.ts +74 -0
  51. package/dist/application/services/intelligent-router.d.ts.map +1 -0
  52. package/dist/application/services/intelligent-router.js +711 -0
  53. package/dist/application/services/intelligent-router.js.map +1 -0
  54. package/dist/application/services/tool-executor-service.d.ts +14 -0
  55. package/dist/application/services/tool-executor-service.d.ts.map +1 -0
  56. package/dist/application/services/tool-executor-service.js +94 -0
  57. package/dist/application/services/tool-executor-service.js.map +1 -0
  58. package/dist/application/use-cases/ask-question-use-case.d.ts +36 -0
  59. package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -0
  60. package/dist/application/use-cases/ask-question-use-case.js +150 -0
  61. package/dist/application/use-cases/ask-question-use-case.js.map +1 -0
  62. package/dist/application/use-cases/edit-file-use-case.d.ts +76 -0
  63. package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -0
  64. package/dist/application/use-cases/edit-file-use-case.js +685 -0
  65. package/dist/application/use-cases/edit-file-use-case.js.map +1 -0
  66. package/dist/application/use-cases/explain-file-use-case.d.ts +21 -0
  67. package/dist/application/use-cases/explain-file-use-case.d.ts.map +1 -0
  68. package/dist/application/use-cases/explain-file-use-case.js +50 -0
  69. package/dist/application/use-cases/explain-file-use-case.js.map +1 -0
  70. package/dist/application/use-cases/index-codebase-use-case.d.ts +46 -0
  71. package/dist/application/use-cases/index-codebase-use-case.d.ts.map +1 -0
  72. package/dist/application/use-cases/index-codebase-use-case.js +113 -0
  73. package/dist/application/use-cases/index-codebase-use-case.js.map +1 -0
  74. package/dist/application/use-cases/planning-use-case.d.ts +46 -0
  75. package/dist/application/use-cases/planning-use-case.d.ts.map +1 -0
  76. package/dist/application/use-cases/planning-use-case.js +267 -0
  77. package/dist/application/use-cases/planning-use-case.js.map +1 -0
  78. package/dist/application/use-cases/react-orchestration-use-case.d.ts +51 -0
  79. package/dist/application/use-cases/react-orchestration-use-case.d.ts.map +1 -0
  80. package/dist/application/use-cases/react-orchestration-use-case.js +325 -0
  81. package/dist/application/use-cases/react-orchestration-use-case.js.map +1 -0
  82. package/dist/application/use-cases/reflexion-use-case.d.ts +24 -0
  83. package/dist/application/use-cases/reflexion-use-case.d.ts.map +1 -0
  84. package/dist/application/use-cases/reflexion-use-case.js +30 -0
  85. package/dist/application/use-cases/reflexion-use-case.js.map +1 -0
  86. package/dist/application/workflows/deterministic-workflows.d.ts +61 -0
  87. package/dist/application/workflows/deterministic-workflows.d.ts.map +1 -0
  88. package/dist/application/workflows/deterministic-workflows.js +189 -0
  89. package/dist/application/workflows/deterministic-workflows.js.map +1 -0
  90. package/dist/cache.d.ts.map +1 -1
  91. package/dist/cache.js +1 -3
  92. package/dist/cache.js.map +1 -1
  93. package/dist/chat.js +10 -10
  94. package/dist/chat.js.map +1 -1
  95. package/dist/docs.d.ts.map +1 -1
  96. package/dist/docs.js +1 -2
  97. package/dist/docs.js.map +1 -1
  98. package/dist/domain/entities/code-chunk.d.ts +26 -0
  99. package/dist/domain/entities/code-chunk.d.ts.map +1 -0
  100. package/dist/domain/entities/code-chunk.js +6 -0
  101. package/dist/domain/entities/code-chunk.js.map +1 -0
  102. package/dist/domain/entities/decision.d.ts +37 -0
  103. package/dist/domain/entities/decision.d.ts.map +1 -0
  104. package/dist/domain/entities/decision.js +9 -0
  105. package/dist/domain/entities/decision.js.map +1 -0
  106. package/dist/domain/entities/edit.d.ts +35 -0
  107. package/dist/domain/entities/edit.d.ts.map +1 -0
  108. package/dist/domain/entities/edit.js +6 -0
  109. package/dist/domain/entities/edit.js.map +1 -0
  110. package/dist/domain/entities/knowledge-node.d.ts +83 -0
  111. package/dist/domain/entities/knowledge-node.d.ts.map +1 -0
  112. package/dist/domain/entities/knowledge-node.js +9 -0
  113. package/dist/domain/entities/knowledge-node.js.map +1 -0
  114. package/dist/domain/entities/knowledge-preservation.d.ts +42 -0
  115. package/dist/domain/entities/knowledge-preservation.d.ts.map +1 -0
  116. package/dist/domain/entities/knowledge-preservation.js +10 -0
  117. package/dist/domain/entities/knowledge-preservation.js.map +1 -0
  118. package/dist/domain/entities/memory.d.ts +36 -0
  119. package/dist/domain/entities/memory.d.ts.map +1 -0
  120. package/dist/domain/entities/memory.js +6 -0
  121. package/dist/domain/entities/memory.js.map +1 -0
  122. package/dist/domain/entities/pattern.d.ts +49 -0
  123. package/dist/domain/entities/pattern.d.ts.map +1 -0
  124. package/dist/domain/entities/pattern.js +7 -0
  125. package/dist/domain/entities/pattern.js.map +1 -0
  126. package/dist/domain/entities/plan.d.ts +42 -0
  127. package/dist/domain/entities/plan.d.ts.map +1 -0
  128. package/dist/domain/entities/plan.js +6 -0
  129. package/dist/domain/entities/plan.js.map +1 -0
  130. package/dist/domain/entities/query.d.ts +17 -0
  131. package/dist/domain/entities/query.d.ts.map +1 -0
  132. package/dist/domain/entities/query.js +6 -0
  133. package/dist/domain/entities/query.js.map +1 -0
  134. package/dist/domain/index.d.ts +16 -0
  135. package/dist/domain/index.d.ts.map +1 -0
  136. package/dist/domain/index.js +19 -0
  137. package/dist/domain/index.js.map +1 -0
  138. package/dist/domain/interfaces/ai-service.interface.d.ts +62 -0
  139. package/dist/domain/interfaces/ai-service.interface.d.ts.map +1 -0
  140. package/dist/domain/interfaces/ai-service.interface.js +6 -0
  141. package/dist/domain/interfaces/ai-service.interface.js.map +1 -0
  142. package/dist/domain/interfaces/code-analyzer.interface.d.ts +38 -0
  143. package/dist/domain/interfaces/code-analyzer.interface.d.ts.map +1 -0
  144. package/dist/domain/interfaces/code-analyzer.interface.js +6 -0
  145. package/dist/domain/interfaces/code-analyzer.interface.js.map +1 -0
  146. package/dist/domain/interfaces/decision-repository.interface.d.ts +51 -0
  147. package/dist/domain/interfaces/decision-repository.interface.d.ts.map +1 -0
  148. package/dist/domain/interfaces/decision-repository.interface.js +9 -0
  149. package/dist/domain/interfaces/decision-repository.interface.js.map +1 -0
  150. package/dist/domain/interfaces/embedding-repository.interface.d.ts +28 -0
  151. package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -0
  152. package/dist/domain/interfaces/embedding-repository.interface.js +6 -0
  153. package/dist/domain/interfaces/embedding-repository.interface.js.map +1 -0
  154. package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts +91 -0
  155. package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts.map +1 -0
  156. package/dist/domain/interfaces/knowledge-graph-repository.interface.js +9 -0
  157. package/dist/domain/interfaces/knowledge-graph-repository.interface.js.map +1 -0
  158. package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts +50 -0
  159. package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts.map +1 -0
  160. package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +8 -0
  161. package/dist/domain/interfaces/knowledge-preservation-repository.interface.js.map +1 -0
  162. package/dist/domain/interfaces/memory-repository.interface.d.ts +49 -0
  163. package/dist/domain/interfaces/memory-repository.interface.d.ts.map +1 -0
  164. package/dist/domain/interfaces/memory-repository.interface.js +6 -0
  165. package/dist/domain/interfaces/memory-repository.interface.js.map +1 -0
  166. package/dist/domain/interfaces/pattern-repository.interface.d.ts +48 -0
  167. package/dist/domain/interfaces/pattern-repository.interface.d.ts.map +1 -0
  168. package/dist/domain/interfaces/pattern-repository.interface.js +6 -0
  169. package/dist/domain/interfaces/pattern-repository.interface.js.map +1 -0
  170. package/dist/domain/interfaces/verification-service.interface.d.ts +20 -0
  171. package/dist/domain/interfaces/verification-service.interface.d.ts.map +1 -0
  172. package/dist/domain/interfaces/verification-service.interface.js +6 -0
  173. package/dist/domain/interfaces/verification-service.interface.js.map +1 -0
  174. package/dist/domain/services/codebase-detector.d.ts +18 -0
  175. package/dist/domain/services/codebase-detector.d.ts.map +1 -0
  176. package/dist/domain/services/codebase-detector.js +91 -0
  177. package/dist/domain/services/codebase-detector.js.map +1 -0
  178. package/dist/domain/services/cross-team-pattern-sharing.d.ts +65 -0
  179. package/dist/domain/services/cross-team-pattern-sharing.d.ts.map +1 -0
  180. package/dist/domain/services/cross-team-pattern-sharing.js +125 -0
  181. package/dist/domain/services/cross-team-pattern-sharing.js.map +1 -0
  182. package/dist/domain/services/decision-recorder.d.ts +76 -0
  183. package/dist/domain/services/decision-recorder.d.ts.map +1 -0
  184. package/dist/domain/services/decision-recorder.js +223 -0
  185. package/dist/domain/services/decision-recorder.js.map +1 -0
  186. package/dist/domain/services/decision-retriever.d.ts +75 -0
  187. package/dist/domain/services/decision-retriever.d.ts.map +1 -0
  188. package/dist/domain/services/decision-retriever.js +133 -0
  189. package/dist/domain/services/decision-retriever.js.map +1 -0
  190. package/dist/domain/services/graded-memory-activation.d.ts +37 -0
  191. package/dist/domain/services/graded-memory-activation.d.ts.map +1 -0
  192. package/dist/domain/services/graded-memory-activation.js +69 -0
  193. package/dist/domain/services/graded-memory-activation.js.map +1 -0
  194. package/dist/domain/services/knowledge-access.d.ts +63 -0
  195. package/dist/domain/services/knowledge-access.d.ts.map +1 -0
  196. package/dist/domain/services/knowledge-access.js +132 -0
  197. package/dist/domain/services/knowledge-access.js.map +1 -0
  198. package/dist/domain/services/knowledge-extractor.d.ts +54 -0
  199. package/dist/domain/services/knowledge-extractor.d.ts.map +1 -0
  200. package/dist/domain/services/knowledge-extractor.js +247 -0
  201. package/dist/domain/services/knowledge-extractor.js.map +1 -0
  202. package/dist/domain/services/knowledge-graph-builder.d.ts +70 -0
  203. package/dist/domain/services/knowledge-graph-builder.d.ts.map +1 -0
  204. package/dist/domain/services/knowledge-graph-builder.js +268 -0
  205. package/dist/domain/services/knowledge-graph-builder.js.map +1 -0
  206. package/dist/domain/services/knowledge-graph-query.d.ts +69 -0
  207. package/dist/domain/services/knowledge-graph-query.d.ts.map +1 -0
  208. package/dist/domain/services/knowledge-graph-query.js +187 -0
  209. package/dist/domain/services/knowledge-graph-query.js.map +1 -0
  210. package/dist/domain/services/memory-retriever.d.ts +30 -0
  211. package/dist/domain/services/memory-retriever.d.ts.map +1 -0
  212. package/dist/domain/services/memory-retriever.js +82 -0
  213. package/dist/domain/services/memory-retriever.js.map +1 -0
  214. package/dist/domain/services/memory-synthesizer.d.ts +57 -0
  215. package/dist/domain/services/memory-synthesizer.d.ts.map +1 -0
  216. package/dist/domain/services/memory-synthesizer.js +91 -0
  217. package/dist/domain/services/memory-synthesizer.js.map +1 -0
  218. package/dist/domain/services/pattern-extractor.d.ts +108 -0
  219. package/dist/domain/services/pattern-extractor.d.ts.map +1 -0
  220. package/dist/domain/services/pattern-extractor.js +442 -0
  221. package/dist/domain/services/pattern-extractor.js.map +1 -0
  222. package/dist/domain/services/query-intent-classifier.d.ts +16 -0
  223. package/dist/domain/services/query-intent-classifier.d.ts.map +1 -0
  224. package/dist/domain/services/query-intent-classifier.js +140 -0
  225. package/dist/domain/services/query-intent-classifier.js.map +1 -0
  226. package/dist/domain/services/react-loop.d.ts +44 -0
  227. package/dist/domain/services/react-loop.d.ts.map +1 -0
  228. package/dist/domain/services/react-loop.js +110 -0
  229. package/dist/domain/services/react-loop.js.map +1 -0
  230. package/dist/edit.d.ts +0 -12
  231. package/dist/edit.d.ts.map +1 -1
  232. package/dist/edit.js +76 -351
  233. package/dist/edit.js.map +1 -1
  234. package/dist/embed.d.ts +0 -4
  235. package/dist/embed.d.ts.map +1 -1
  236. package/dist/embed.js +100 -174
  237. package/dist/embed.js.map +1 -1
  238. package/dist/error-handler.d.ts +1 -0
  239. package/dist/error-handler.d.ts.map +1 -1
  240. package/dist/error-handler.js +46 -3
  241. package/dist/error-handler.js.map +1 -1
  242. package/dist/index.js +228 -231
  243. package/dist/index.js.map +1 -1
  244. package/dist/infrastructure/ai/cohere-ai-service.d.ts +54 -0
  245. package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -0
  246. package/dist/infrastructure/ai/cohere-ai-service.js +547 -0
  247. package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -0
  248. package/dist/infrastructure/ai/command-r-evaluation.d.ts +42 -0
  249. package/dist/infrastructure/ai/command-r-evaluation.d.ts.map +1 -0
  250. package/dist/infrastructure/ai/command-r-evaluation.js +206 -0
  251. package/dist/infrastructure/ai/command-r-evaluation.js.map +1 -0
  252. package/dist/infrastructure/ai/model-config.d.ts +47 -0
  253. package/dist/infrastructure/ai/model-config.d.ts.map +1 -0
  254. package/dist/infrastructure/ai/model-config.js +84 -0
  255. package/dist/infrastructure/ai/model-config.js.map +1 -0
  256. package/dist/infrastructure/cache/embedding-cache.d.ts +46 -0
  257. package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -0
  258. package/dist/infrastructure/cache/embedding-cache.js +104 -0
  259. package/dist/infrastructure/cache/embedding-cache.js.map +1 -0
  260. package/dist/infrastructure/chunking/ast-code-chunker.d.ts +12 -0
  261. package/dist/infrastructure/chunking/ast-code-chunker.d.ts.map +1 -0
  262. package/dist/infrastructure/chunking/ast-code-chunker.js +19 -0
  263. package/dist/infrastructure/chunking/ast-code-chunker.js.map +1 -0
  264. package/dist/infrastructure/chunking/code-aware-chunker.d.ts +63 -0
  265. package/dist/infrastructure/chunking/code-aware-chunker.d.ts.map +1 -0
  266. package/dist/infrastructure/chunking/code-aware-chunker.js +397 -0
  267. package/dist/infrastructure/chunking/code-aware-chunker.js.map +1 -0
  268. package/dist/infrastructure/config/config-manager.d.ts +79 -0
  269. package/dist/infrastructure/config/config-manager.d.ts.map +1 -0
  270. package/dist/infrastructure/config/config-manager.js +162 -0
  271. package/dist/infrastructure/config/config-manager.js.map +1 -0
  272. package/dist/infrastructure/cost/cost-tracker.d.ts +90 -0
  273. package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -0
  274. package/dist/infrastructure/cost/cost-tracker.js +353 -0
  275. package/dist/infrastructure/cost/cost-tracker.js.map +1 -0
  276. package/dist/infrastructure/file-scanner/file-scanner.d.ts +31 -0
  277. package/dist/infrastructure/file-scanner/file-scanner.d.ts.map +1 -0
  278. package/dist/infrastructure/file-scanner/file-scanner.js +106 -0
  279. package/dist/infrastructure/file-scanner/file-scanner.js.map +1 -0
  280. package/dist/infrastructure/governance/nist-ai-rmf.d.ts +107 -0
  281. package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -0
  282. package/dist/infrastructure/governance/nist-ai-rmf.js +294 -0
  283. package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -0
  284. package/dist/infrastructure/governance/policy-as-code.d.ts +90 -0
  285. package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -0
  286. package/dist/infrastructure/governance/policy-as-code.js +244 -0
  287. package/dist/infrastructure/governance/policy-as-code.js.map +1 -0
  288. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +138 -0
  289. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -0
  290. package/dist/infrastructure/governance/prompt-to-code-lineage.js +241 -0
  291. package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -0
  292. package/dist/infrastructure/index.d.ts +7 -0
  293. package/dist/infrastructure/index.d.ts.map +1 -0
  294. package/dist/infrastructure/index.js +7 -0
  295. package/dist/infrastructure/index.js.map +1 -0
  296. package/dist/infrastructure/observability/execution-tracer.d.ts +105 -0
  297. package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -0
  298. package/dist/infrastructure/observability/execution-tracer.js +190 -0
  299. package/dist/infrastructure/observability/execution-tracer.js.map +1 -0
  300. package/dist/infrastructure/observability/prompt-versioner.d.ts +67 -0
  301. package/dist/infrastructure/observability/prompt-versioner.d.ts.map +1 -0
  302. package/dist/infrastructure/observability/prompt-versioner.js +145 -0
  303. package/dist/infrastructure/observability/prompt-versioner.js.map +1 -0
  304. package/dist/infrastructure/protocols/a2a-metadata.d.ts +278 -0
  305. package/dist/infrastructure/protocols/a2a-metadata.d.ts.map +1 -0
  306. package/dist/infrastructure/protocols/a2a-metadata.js +137 -0
  307. package/dist/infrastructure/protocols/a2a-metadata.js.map +1 -0
  308. package/dist/infrastructure/protocols/a2a-protocol.d.ts +132 -0
  309. package/dist/infrastructure/protocols/a2a-protocol.d.ts.map +1 -0
  310. package/dist/infrastructure/protocols/a2a-protocol.js +314 -0
  311. package/dist/infrastructure/protocols/a2a-protocol.js.map +1 -0
  312. package/dist/infrastructure/protocols/mcp-oauth.d.ts +91 -0
  313. package/dist/infrastructure/protocols/mcp-oauth.d.ts.map +1 -0
  314. package/dist/infrastructure/protocols/mcp-oauth.js +184 -0
  315. package/dist/infrastructure/protocols/mcp-oauth.js.map +1 -0
  316. package/dist/infrastructure/protocols/mcp-server.d.ts +126 -0
  317. package/dist/infrastructure/protocols/mcp-server.d.ts.map +1 -0
  318. package/dist/infrastructure/protocols/mcp-server.js +333 -0
  319. package/dist/infrastructure/protocols/mcp-server.js.map +1 -0
  320. package/dist/infrastructure/protocols/streaming-handler.d.ts +57 -0
  321. package/dist/infrastructure/protocols/streaming-handler.d.ts.map +1 -0
  322. package/dist/infrastructure/protocols/streaming-handler.js +103 -0
  323. package/dist/infrastructure/protocols/streaming-handler.js.map +1 -0
  324. package/dist/infrastructure/security/ai-sast-scanner.d.ts +55 -0
  325. package/dist/infrastructure/security/ai-sast-scanner.d.ts.map +1 -0
  326. package/dist/infrastructure/security/ai-sast-scanner.js +163 -0
  327. package/dist/infrastructure/security/ai-sast-scanner.js.map +1 -0
  328. package/dist/infrastructure/security/docker-sandbox.d.ts +57 -0
  329. package/dist/infrastructure/security/docker-sandbox.d.ts.map +1 -0
  330. package/dist/infrastructure/security/docker-sandbox.js +178 -0
  331. package/dist/infrastructure/security/docker-sandbox.js.map +1 -0
  332. package/dist/infrastructure/security/enhanced-security-gate.d.ts +51 -0
  333. package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -0
  334. package/dist/infrastructure/security/enhanced-security-gate.js +92 -0
  335. package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -0
  336. package/dist/infrastructure/security/input-validator.d.ts +33 -0
  337. package/dist/infrastructure/security/input-validator.d.ts.map +1 -0
  338. package/dist/infrastructure/security/input-validator.js +152 -0
  339. package/dist/infrastructure/security/input-validator.js.map +1 -0
  340. package/dist/infrastructure/security/license-scanner.d.ts +55 -0
  341. package/dist/infrastructure/security/license-scanner.d.ts.map +1 -0
  342. package/dist/infrastructure/security/license-scanner.js +167 -0
  343. package/dist/infrastructure/security/license-scanner.js.map +1 -0
  344. package/dist/infrastructure/security/provider-bias-detector.d.ts +53 -0
  345. package/dist/infrastructure/security/provider-bias-detector.d.ts.map +1 -0
  346. package/dist/infrastructure/security/provider-bias-detector.js +164 -0
  347. package/dist/infrastructure/security/provider-bias-detector.js.map +1 -0
  348. package/dist/infrastructure/security/sandbox-executor.d.ts +34 -0
  349. package/dist/infrastructure/security/sandbox-executor.d.ts.map +1 -0
  350. package/dist/infrastructure/security/sandbox-executor.js +64 -0
  351. package/dist/infrastructure/security/sandbox-executor.js.map +1 -0
  352. package/dist/infrastructure/storage/memory-stream-service.d.ts +47 -0
  353. package/dist/infrastructure/storage/memory-stream-service.d.ts.map +1 -0
  354. package/dist/infrastructure/storage/memory-stream-service.js +204 -0
  355. package/dist/infrastructure/storage/memory-stream-service.js.map +1 -0
  356. package/dist/infrastructure/storage/sqlite-decision-repository.d.ts +29 -0
  357. package/dist/infrastructure/storage/sqlite-decision-repository.d.ts.map +1 -0
  358. package/dist/infrastructure/storage/sqlite-decision-repository.js +232 -0
  359. package/dist/infrastructure/storage/sqlite-decision-repository.js.map +1 -0
  360. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +24 -0
  361. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -0
  362. package/dist/infrastructure/storage/sqlite-embedding-repository.js +162 -0
  363. package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -0
  364. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts +41 -0
  365. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +1 -0
  366. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +417 -0
  367. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +1 -0
  368. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts +29 -0
  369. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +1 -0
  370. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +230 -0
  371. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +1 -0
  372. package/dist/infrastructure/storage/sqlite-memory-repository.d.ts +40 -0
  373. package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +1 -0
  374. package/dist/infrastructure/storage/sqlite-memory-repository.js +229 -0
  375. package/dist/infrastructure/storage/sqlite-memory-repository.js.map +1 -0
  376. package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts +25 -0
  377. package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +1 -0
  378. package/dist/infrastructure/storage/sqlite-pattern-repository.js +249 -0
  379. package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +1 -0
  380. package/dist/infrastructure/ux/appropriate-friction.d.ts +77 -0
  381. package/dist/infrastructure/ux/appropriate-friction.d.ts.map +1 -0
  382. package/dist/infrastructure/ux/appropriate-friction.js +213 -0
  383. package/dist/infrastructure/ux/appropriate-friction.js.map +1 -0
  384. package/dist/infrastructure/ux/bi-directional-learning.d.ts +109 -0
  385. package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -0
  386. package/dist/infrastructure/ux/bi-directional-learning.js +200 -0
  387. package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -0
  388. package/dist/infrastructure/ux/expectation-management.d.ts +65 -0
  389. package/dist/infrastructure/ux/expectation-management.d.ts.map +1 -0
  390. package/dist/infrastructure/ux/expectation-management.js +193 -0
  391. package/dist/infrastructure/ux/expectation-management.js.map +1 -0
  392. package/dist/infrastructure/ux/hitl-validation.d.ts +104 -0
  393. package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -0
  394. package/dist/infrastructure/ux/hitl-validation.js +211 -0
  395. package/dist/infrastructure/ux/hitl-validation.js.map +1 -0
  396. package/dist/infrastructure/ux/progressive-disclosure.d.ts +84 -0
  397. package/dist/infrastructure/ux/progressive-disclosure.d.ts.map +1 -0
  398. package/dist/infrastructure/ux/progressive-disclosure.js +235 -0
  399. package/dist/infrastructure/ux/progressive-disclosure.js.map +1 -0
  400. package/dist/infrastructure/ux/team-standards.d.ts +94 -0
  401. package/dist/infrastructure/ux/team-standards.d.ts.map +1 -0
  402. package/dist/infrastructure/ux/team-standards.js +196 -0
  403. package/dist/infrastructure/ux/team-standards.js.map +1 -0
  404. package/dist/infrastructure/verification/verification-service.d.ts +12 -0
  405. package/dist/infrastructure/verification/verification-service.d.ts.map +1 -0
  406. package/dist/infrastructure/verification/verification-service.js +47 -0
  407. package/dist/infrastructure/verification/verification-service.js.map +1 -0
  408. package/dist/infrastructure/xai/attention-visualizer.d.ts +73 -0
  409. package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -0
  410. package/dist/infrastructure/xai/attention-visualizer.js +174 -0
  411. package/dist/infrastructure/xai/attention-visualizer.js.map +1 -0
  412. package/dist/infrastructure/xai/cot-visualizer.d.ts +105 -0
  413. package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -0
  414. package/dist/infrastructure/xai/cot-visualizer.js +239 -0
  415. package/dist/infrastructure/xai/cot-visualizer.js.map +1 -0
  416. package/dist/infrastructure/xai/decision-tree-log.d.ts +104 -0
  417. package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -0
  418. package/dist/infrastructure/xai/decision-tree-log.js +216 -0
  419. package/dist/infrastructure/xai/decision-tree-log.js.map +1 -0
  420. package/dist/infrastructure/xai/interactive-xai.d.ts +106 -0
  421. package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -0
  422. package/dist/infrastructure/xai/interactive-xai.js +262 -0
  423. package/dist/infrastructure/xai/interactive-xai.js.map +1 -0
  424. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +80 -0
  425. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -0
  426. package/dist/infrastructure/xai/uncertainty-quantifier.js +201 -0
  427. package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -0
  428. package/dist/intelligent-retrieval.d.ts.map +1 -1
  429. package/dist/intelligent-retrieval.js +8 -1
  430. package/dist/intelligent-retrieval.js.map +1 -1
  431. package/dist/intent/classifier.d.ts +6 -0
  432. package/dist/intent/classifier.d.ts.map +1 -0
  433. package/dist/intent/classifier.js +2 -0
  434. package/dist/intent/classifier.js.map +1 -0
  435. package/dist/intent/context.d.ts +4 -0
  436. package/dist/intent/context.d.ts.map +1 -0
  437. package/dist/intent/context.js +2 -0
  438. package/dist/intent/context.js.map +1 -0
  439. package/dist/iterative-refinement.d.ts.map +1 -1
  440. package/dist/iterative-refinement.js +20 -3
  441. package/dist/iterative-refinement.js.map +1 -1
  442. package/dist/learning.d.ts.map +1 -1
  443. package/dist/learning.js +1 -2
  444. package/dist/learning.js.map +1 -1
  445. package/dist/monitoring.d.ts.map +1 -1
  446. package/dist/monitoring.js +1 -2
  447. package/dist/monitoring.js.map +1 -1
  448. package/dist/parallel-processor.d.ts +3 -2
  449. package/dist/parallel-processor.d.ts.map +1 -1
  450. package/dist/parallel-processor.js +183 -56
  451. package/dist/parallel-processor.js.map +1 -1
  452. package/dist/presentation/cli/commands/ask-command.d.ts +8 -0
  453. package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -0
  454. package/dist/presentation/cli/commands/ask-command.js +133 -0
  455. package/dist/presentation/cli/commands/ask-command.js.map +1 -0
  456. package/dist/presentation/cli/commands/config-command.d.ts +9 -0
  457. package/dist/presentation/cli/commands/config-command.d.ts.map +1 -0
  458. package/dist/presentation/cli/commands/config-command.js +123 -0
  459. package/dist/presentation/cli/commands/config-command.js.map +1 -0
  460. package/dist/presentation/cli/commands/cost-command.d.ts +8 -0
  461. package/dist/presentation/cli/commands/cost-command.d.ts.map +1 -0
  462. package/dist/presentation/cli/commands/cost-command.js +191 -0
  463. package/dist/presentation/cli/commands/cost-command.js.map +1 -0
  464. package/dist/presentation/cli/commands/decision-command.d.ts +12 -0
  465. package/dist/presentation/cli/commands/decision-command.d.ts.map +1 -0
  466. package/dist/presentation/cli/commands/decision-command.js +207 -0
  467. package/dist/presentation/cli/commands/decision-command.js.map +1 -0
  468. package/dist/presentation/cli/commands/help-command.d.ts +9 -0
  469. package/dist/presentation/cli/commands/help-command.d.ts.map +1 -0
  470. package/dist/presentation/cli/commands/help-command.js +281 -0
  471. package/dist/presentation/cli/commands/help-command.js.map +1 -0
  472. package/dist/presentation/cli/commands/knowledge-command.d.ts +13 -0
  473. package/dist/presentation/cli/commands/knowledge-command.d.ts.map +1 -0
  474. package/dist/presentation/cli/commands/knowledge-command.js +129 -0
  475. package/dist/presentation/cli/commands/knowledge-command.js.map +1 -0
  476. package/dist/presentation/cli/commands/learning-dashboard-command.d.ts +8 -0
  477. package/dist/presentation/cli/commands/learning-dashboard-command.d.ts.map +1 -0
  478. package/dist/presentation/cli/commands/learning-dashboard-command.js +183 -0
  479. package/dist/presentation/cli/commands/learning-dashboard-command.js.map +1 -0
  480. package/dist/presentation/cli/commands/orchestrate-command.d.ts +8 -0
  481. package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -0
  482. package/dist/presentation/cli/commands/orchestrate-command.js +112 -0
  483. package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -0
  484. package/dist/presentation/cli/commands/plan-command.d.ts +8 -0
  485. package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -0
  486. package/dist/presentation/cli/commands/plan-command.js +114 -0
  487. package/dist/presentation/cli/commands/plan-command.js.map +1 -0
  488. package/dist/presentation/cli/commands/react-command.d.ts +8 -0
  489. package/dist/presentation/cli/commands/react-command.d.ts.map +1 -0
  490. package/dist/presentation/cli/commands/react-command.js +99 -0
  491. package/dist/presentation/cli/commands/react-command.js.map +1 -0
  492. package/dist/presentation/cli/commands/setup-command.d.ts +10 -0
  493. package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -0
  494. package/dist/presentation/cli/commands/setup-command.js +231 -0
  495. package/dist/presentation/cli/commands/setup-command.js.map +1 -0
  496. package/dist/presentation/cli/commands/smart-command.d.ts +6 -0
  497. package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -0
  498. package/dist/presentation/cli/commands/smart-command.js +212 -0
  499. package/dist/presentation/cli/commands/smart-command.js.map +1 -0
  500. package/dist/presentation/cli/commands/trace-command.d.ts +8 -0
  501. package/dist/presentation/cli/commands/trace-command.d.ts.map +1 -0
  502. package/dist/presentation/cli/commands/trace-command.js +125 -0
  503. package/dist/presentation/cli/commands/trace-command.js.map +1 -0
  504. package/dist/presentation/cli/commands/undo-command.d.ts +8 -0
  505. package/dist/presentation/cli/commands/undo-command.d.ts.map +1 -0
  506. package/dist/presentation/cli/commands/undo-command.js +141 -0
  507. package/dist/presentation/cli/commands/undo-command.js.map +1 -0
  508. package/dist/presentation/cli/error-display.d.ts +23 -0
  509. package/dist/presentation/cli/error-display.d.ts.map +1 -0
  510. package/dist/presentation/cli/error-display.js +122 -0
  511. package/dist/presentation/cli/error-display.js.map +1 -0
  512. package/dist/refactor.d.ts.map +1 -1
  513. package/dist/refactor.js +2 -4
  514. package/dist/refactor.js.map +1 -1
  515. package/dist/search.d.ts.map +1 -1
  516. package/dist/search.js +2 -63
  517. package/dist/search.js.map +1 -1
  518. package/dist/session.d.ts.map +1 -1
  519. package/dist/session.js +52 -3
  520. package/dist/session.js.map +1 -1
  521. package/dist/testgen.d.ts.map +1 -1
  522. package/dist/testgen.js +1 -2
  523. package/dist/testgen.js.map +1 -1
  524. package/dist/tools/bash.d.ts +53 -0
  525. package/dist/tools/bash.d.ts.map +1 -0
  526. package/dist/tools/bash.js +213 -0
  527. package/dist/tools/bash.js.map +1 -0
  528. package/dist/tools/edit.d.ts +48 -0
  529. package/dist/tools/edit.d.ts.map +1 -0
  530. package/dist/tools/edit.js +235 -0
  531. package/dist/tools/edit.js.map +1 -0
  532. package/dist/tools/executor.d.ts +29 -0
  533. package/dist/tools/executor.d.ts.map +1 -0
  534. package/dist/tools/executor.js +153 -0
  535. package/dist/tools/executor.js.map +1 -0
  536. package/dist/tools/git-tool.d.ts +87 -0
  537. package/dist/tools/git-tool.d.ts.map +1 -0
  538. package/dist/tools/git-tool.js +292 -0
  539. package/dist/tools/git-tool.js.map +1 -0
  540. package/dist/tools/parser.d.ts +33 -0
  541. package/dist/tools/parser.d.ts.map +1 -0
  542. package/dist/tools/parser.js +158 -0
  543. package/dist/tools/parser.js.map +1 -0
  544. package/dist/tools/registry.d.ts +74 -0
  545. package/dist/tools/registry.d.ts.map +1 -0
  546. package/dist/tools/registry.js +302 -0
  547. package/dist/tools/registry.js.map +1 -0
  548. package/dist/tools/search.d.ts +41 -0
  549. package/dist/tools/search.d.ts.map +1 -0
  550. package/dist/tools/search.js +100 -0
  551. package/dist/tools/search.js.map +1 -0
  552. package/dist/ui.d.ts.map +1 -1
  553. package/dist/ui.js +4 -2
  554. package/dist/ui.js.map +1 -1
  555. package/dist/utils/check-api-status.d.ts +12 -0
  556. package/dist/utils/check-api-status.d.ts.map +1 -0
  557. package/dist/utils/check-api-status.js +82 -0
  558. package/dist/utils/check-api-status.js.map +1 -0
  559. package/dist/utils/diff-parser.d.ts +22 -0
  560. package/dist/utils/diff-parser.d.ts.map +1 -0
  561. package/dist/utils/diff-parser.js +160 -0
  562. package/dist/utils/diff-parser.js.map +1 -0
  563. package/dist/utils/logger.d.ts +34 -0
  564. package/dist/utils/logger.d.ts.map +1 -0
  565. package/dist/utils/logger.js +56 -0
  566. package/dist/utils/logger.js.map +1 -0
  567. package/dist/utils/version.d.ts +21 -0
  568. package/dist/utils/version.d.ts.map +1 -0
  569. package/dist/utils/version.js +52 -0
  570. package/dist/utils/version.js.map +1 -0
  571. package/dist/verification/backup.d.ts +30 -0
  572. package/dist/verification/backup.d.ts.map +1 -0
  573. package/dist/verification/backup.js +238 -0
  574. package/dist/verification/backup.js.map +1 -0
  575. package/dist/verification/compiler.d.ts +20 -0
  576. package/dist/verification/compiler.d.ts.map +1 -0
  577. package/dist/verification/compiler.js +228 -0
  578. package/dist/verification/compiler.js.map +1 -0
  579. package/dist/verification/index.d.ts +59 -0
  580. package/dist/verification/index.d.ts.map +1 -0
  581. package/dist/verification/index.js +273 -0
  582. package/dist/verification/index.js.map +1 -0
  583. package/dist/verification/test-runner.d.ts +27 -0
  584. package/dist/verification/test-runner.d.ts.map +1 -0
  585. package/dist/verification/test-runner.js +379 -0
  586. package/dist/verification/test-runner.js.map +1 -0
  587. package/package.json +39 -14
  588. package/ARCHITECTURE.md +0 -240
  589. package/CHANGELOG.md +0 -44
  590. package/CONTRIBUTING.md +0 -171
  591. package/dist/benchmark.d.ts +0 -39
  592. package/dist/benchmark.d.ts.map +0 -1
  593. package/dist/benchmark.js +0 -195
  594. package/dist/benchmark.js.map +0 -1
  595. package/dist/scaffold.d.ts +0 -14
  596. package/dist/scaffold.d.ts.map +0 -1
  597. package/dist/scaffold.js +0 -85
  598. package/dist/scaffold.js.map +0 -1
  599. package/templates/next-page/app/layout.tsx +0 -19
  600. package/templates/next-page/app/page.tsx +0 -10
  601. package/templates/next-page/package.json +0 -22
  602. package/templates/node-api/index.js +0 -57
  603. package/templates/node-api/package.json +0 -13
package/dist/testgen.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Test Generation System
3
3
  * Generate comprehensive tests for code
4
4
  */
5
- import { readFileSync, existsSync, writeFileSync } from 'fs';
5
+ import { readFileSync, existsSync, writeFileSync, mkdirSync } from 'fs';
6
6
  import { join, dirname, basename } from 'path';
7
7
  import { chatWithContext } from './chat.js';
8
8
  import { getEnhancedContext } from './context.js';
@@ -105,7 +105,6 @@ export function saveTests(filepath, testContent) {
105
105
  const fullPath = join(process.cwd(), filepath);
106
106
  const dir = dirname(fullPath);
107
107
  if (!existsSync(dir)) {
108
- const { mkdirSync } = require('fs');
109
108
  mkdirSync(dir, { recursive: true });
110
109
  }
111
110
  writeFileSync(fullPath, testContent, 'utf-8');
@@ -1 +1 @@
1
- {"version":3,"file":"testgen.js","sourceRoot":"","sources":["../src/testgen.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,UAGlD,EAAE;IACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;IAE/C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAA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,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;;;;;;;;;;gCAUF,CAAC;IAE/B,MAAM,cAAc,GAAmB,CAAC;YACtC,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,WAAW;YACpB,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAC3E,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Bash Tool
3
+ * Execute shell commands safely with detailed descriptions for the model
4
+ * Following Claude Code approach: detailed tool descriptions, error-proofing
5
+ *
6
+ * SECURITY: Uses Docker sandbox when available for isolated execution
7
+ */
8
+ export interface BashOptions {
9
+ /** Working directory (will be resolved to absolute path) */
10
+ cwd?: string;
11
+ /** Timeout in milliseconds (default: 30000 = 30s) */
12
+ timeout?: number;
13
+ /** Maximum output size in bytes (default: 1MB) */
14
+ maxOutputSize?: number;
15
+ /** Environment variables */
16
+ env?: Record<string, string>;
17
+ }
18
+ export interface BashResult {
19
+ /** Exit code (0 = success) */
20
+ exitCode: number;
21
+ /** Standard output */
22
+ stdout: string;
23
+ /** Standard error */
24
+ stderr: string;
25
+ /** Command that was executed */
26
+ command: string;
27
+ /** Execution time in milliseconds */
28
+ duration: number;
29
+ /** Whether command succeeded */
30
+ success: boolean;
31
+ /** Whether command was executed in sandbox */
32
+ sandboxed?: boolean;
33
+ /** Sandbox status message */
34
+ sandboxStatus?: string;
35
+ }
36
+ /**
37
+ * Execute a bash command safely
38
+ *
39
+ * SECURITY & ERROR-PROOFING:
40
+ * - All paths are resolved to absolute paths
41
+ * - Commands are executed in Docker sandbox when available (MANDATORY for production)
42
+ * - Falls back to direct execution with warning if sandbox unavailable
43
+ * - Timeout protection prevents hanging
44
+ * - Output size limits prevent memory issues
45
+ * - Command injection attempts are logged
46
+ */
47
+ export declare function executeBash(command: string, options?: BashOptions): Promise<BashResult>;
48
+ /**
49
+ * Tool description for the model
50
+ * This is critical - the model needs to understand how to use this tool
51
+ */
52
+ export declare const BASH_TOOL_DESCRIPTION = "\nBash Tool - Execute shell commands\n\nDESCRIPTION:\nExecute bash/shell commands in a controlled environment. All paths are automatically resolved to absolute paths.\n\nAVAILABLE COMMANDS:\n- Any valid bash/shell command\n- Commands run in the project directory by default\n- Working directory can be specified\n\nIMPORTANT CONSTRAINTS:\n1. **Absolute Paths Required**: Always use absolute paths or paths relative to the working directory\n2. **No Internet Access**: Commands run in isolated environment (no network access)\n3. **Available Packages**: Standard Unix utilities (ls, cat, grep, find, etc.)\n4. **Timeout**: Commands timeout after 30 seconds (configurable)\n5. **Output Limit**: Maximum 1MB output (configurable)\n\nESCAPING:\n- Use single quotes for strings: 'string with spaces'\n- Escape special characters: Use backslash before $, backtick, or double quote\n- For complex commands, consider breaking into multiple steps\n\nBACKGROUND PROCESSES:\n- Background processes (&) are NOT supported\n- Use sequential commands instead\n\nPATH HANDLING:\n- All paths are resolved to absolute paths automatically\n- Use resolve() or absolute paths to avoid relative path issues\n- Example: /Users/username/project/file.txt (absolute)\n- Example: ./file.txt (relative to cwd)\n\nERROR HANDLING:\n- Exit code 0 = success\n- Exit code != 0 = failure\n- Check stderr for error messages\n- Timeout errors are reported in stderr\n\nEXAMPLES:\n- executeBash('ls -la', { cwd: '/path/to/dir' })\n- executeBash('grep -r \"pattern\" .', { cwd: '/path/to/project' })\n- executeBash('cat /absolute/path/to/file.txt')\n- executeBash('find . -name \"*.ts\" -type f', { cwd: '/path/to/project' })\n\nSECURITY NOTES:\n- Commands execute in Docker sandbox when available (MANDATORY for production)\n- Falls back to direct execution with warning if Docker unavailable\n- Potentially dangerous commands are logged but not blocked\n- Use with caution for destructive operations\n- Always verify paths before executing\n\nSANDBOX STATUS:\n- Check result.sandboxed to see if command ran in sandbox\n- Check result.sandboxStatus for sandbox availability information\n- Production deployments should always have Docker available\n";
53
+ //# sourceMappingURL=bash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,UAAU,CAAC,CAiIrB;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yqEAwDjC,CAAC"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * Bash Tool
3
+ * Execute shell commands safely with detailed descriptions for the model
4
+ * Following Claude Code approach: detailed tool descriptions, error-proofing
5
+ *
6
+ * SECURITY: Uses Docker sandbox when available for isolated execution
7
+ */
8
+ import { exec } from 'child_process';
9
+ import { promisify } from 'util';
10
+ import { resolve } from 'path';
11
+ import { existsSync } from 'fs';
12
+ import { SandboxExecutor } from '../infrastructure/security/sandbox-executor.js';
13
+ const execAsync = promisify(exec);
14
+ // Singleton sandbox executor instance
15
+ let sandboxExecutor = null;
16
+ /**
17
+ * Get or create sandbox executor instance
18
+ */
19
+ function getSandboxExecutor() {
20
+ if (!sandboxExecutor) {
21
+ sandboxExecutor = new SandboxExecutor();
22
+ }
23
+ return sandboxExecutor;
24
+ }
25
+ /**
26
+ * Execute a bash command safely
27
+ *
28
+ * SECURITY & ERROR-PROOFING:
29
+ * - All paths are resolved to absolute paths
30
+ * - Commands are executed in Docker sandbox when available (MANDATORY for production)
31
+ * - Falls back to direct execution with warning if sandbox unavailable
32
+ * - Timeout protection prevents hanging
33
+ * - Output size limits prevent memory issues
34
+ * - Command injection attempts are logged
35
+ */
36
+ export async function executeBash(command, options = {}) {
37
+ const startTime = Date.now();
38
+ // Resolve working directory to absolute path
39
+ const cwd = options.cwd
40
+ ? resolve(options.cwd)
41
+ : process.cwd();
42
+ // Verify directory exists
43
+ if (!existsSync(cwd)) {
44
+ throw new Error(`Working directory does not exist: ${cwd}`);
45
+ }
46
+ // Security: Log suspicious patterns (but don't block - let model decide)
47
+ const suspiciousPatterns = [
48
+ /rm\s+-rf\s+\//, // Dangerous rm -rf /
49
+ /format\s+c:/i, // Windows format
50
+ /mkfs/, // Filesystem creation
51
+ /dd\s+if=/, // Disk operations
52
+ ];
53
+ for (const pattern of suspiciousPatterns) {
54
+ if (pattern.test(command)) {
55
+ console.warn(`⚠️ Warning: Potentially dangerous command detected: ${command}`);
56
+ }
57
+ }
58
+ // Try to use sandbox first (MANDATORY for production security)
59
+ const sandbox = getSandboxExecutor();
60
+ const sandboxAvailable = await sandbox.isAvailable();
61
+ if (sandboxAvailable) {
62
+ try {
63
+ // Execute in sandbox
64
+ const sandboxOptions = {
65
+ timeout: options.timeout || 30000,
66
+ memoryLimit: '512m',
67
+ cpuLimit: '0.5',
68
+ networkAccess: false, // No network access by default
69
+ };
70
+ const sandboxResult = await sandbox.executeBash(command, sandboxOptions);
71
+ const duration = Date.now() - startTime;
72
+ return {
73
+ exitCode: sandboxResult.exitCode || (sandboxResult.success ? 0 : 1),
74
+ stdout: sandboxResult.output || '',
75
+ stderr: sandboxResult.error || '',
76
+ command,
77
+ duration,
78
+ success: sandboxResult.success,
79
+ sandboxed: true,
80
+ sandboxStatus: 'Executed in Docker sandbox (secure)',
81
+ };
82
+ }
83
+ catch (sandboxError) {
84
+ // If sandbox execution fails, fall through to direct execution with warning
85
+ console.warn(`⚠️ Sandbox execution failed, falling back to direct execution: ${sandboxError.message}`);
86
+ }
87
+ }
88
+ else {
89
+ // Sandbox not available - use direct execution with warning
90
+ console.warn(`⚠️ WARNING: Docker sandbox not available. Executing command directly (less secure).`);
91
+ console.warn(`⚠️ For production use, please install Docker to enable secure sandbox execution.`);
92
+ }
93
+ // Fallback: Direct execution (with security warning)
94
+ const timeout = options.timeout || 30000; // 30 seconds
95
+ const maxOutputSize = options.maxOutputSize || 1024 * 1024; // 1MB
96
+ // Merge environment variables
97
+ const env = {
98
+ ...process.env,
99
+ ...options.env,
100
+ };
101
+ try {
102
+ // Execute command with timeout
103
+ const { stdout, stderr } = await Promise.race([
104
+ execAsync(command, {
105
+ cwd,
106
+ env,
107
+ maxBuffer: maxOutputSize,
108
+ }),
109
+ new Promise((_, reject) => {
110
+ setTimeout(() => {
111
+ reject(new Error(`Command timed out after ${timeout}ms`));
112
+ }, timeout);
113
+ }),
114
+ ]);
115
+ const duration = Date.now() - startTime;
116
+ // Check output size
117
+ const totalSize = (stdout?.length || 0) + (stderr?.length || 0);
118
+ if (totalSize > maxOutputSize) {
119
+ console.warn(`⚠️ Warning: Command output exceeds ${maxOutputSize} bytes, truncated`);
120
+ }
121
+ return {
122
+ exitCode: 0,
123
+ stdout: stdout || '',
124
+ stderr: stderr || '',
125
+ command,
126
+ duration,
127
+ success: true,
128
+ sandboxed: false,
129
+ sandboxStatus: sandboxAvailable
130
+ ? 'Sandbox available but execution failed, used direct execution'
131
+ : 'Docker sandbox not available, used direct execution (less secure)',
132
+ };
133
+ }
134
+ catch (error) {
135
+ const duration = Date.now() - startTime;
136
+ // Extract exit code from error
137
+ const exitCode = error.code || (error.signal ? 128 : 1);
138
+ return {
139
+ exitCode,
140
+ stdout: error.stdout || '',
141
+ stderr: error.stderr || error.message || '',
142
+ command,
143
+ duration,
144
+ success: exitCode === 0,
145
+ sandboxed: false,
146
+ sandboxStatus: sandboxAvailable
147
+ ? 'Sandbox available but execution failed, used direct execution'
148
+ : 'Docker sandbox not available, used direct execution (less secure)',
149
+ };
150
+ }
151
+ }
152
+ /**
153
+ * Tool description for the model
154
+ * This is critical - the model needs to understand how to use this tool
155
+ */
156
+ export const BASH_TOOL_DESCRIPTION = `
157
+ Bash Tool - Execute shell commands
158
+
159
+ DESCRIPTION:
160
+ Execute bash/shell commands in a controlled environment. All paths are automatically resolved to absolute paths.
161
+
162
+ AVAILABLE COMMANDS:
163
+ - Any valid bash/shell command
164
+ - Commands run in the project directory by default
165
+ - Working directory can be specified
166
+
167
+ IMPORTANT CONSTRAINTS:
168
+ 1. **Absolute Paths Required**: Always use absolute paths or paths relative to the working directory
169
+ 2. **No Internet Access**: Commands run in isolated environment (no network access)
170
+ 3. **Available Packages**: Standard Unix utilities (ls, cat, grep, find, etc.)
171
+ 4. **Timeout**: Commands timeout after 30 seconds (configurable)
172
+ 5. **Output Limit**: Maximum 1MB output (configurable)
173
+
174
+ ESCAPING:
175
+ - Use single quotes for strings: 'string with spaces'
176
+ - Escape special characters: Use backslash before $, backtick, or double quote
177
+ - For complex commands, consider breaking into multiple steps
178
+
179
+ BACKGROUND PROCESSES:
180
+ - Background processes (&) are NOT supported
181
+ - Use sequential commands instead
182
+
183
+ PATH HANDLING:
184
+ - All paths are resolved to absolute paths automatically
185
+ - Use resolve() or absolute paths to avoid relative path issues
186
+ - Example: /Users/username/project/file.txt (absolute)
187
+ - Example: ./file.txt (relative to cwd)
188
+
189
+ ERROR HANDLING:
190
+ - Exit code 0 = success
191
+ - Exit code != 0 = failure
192
+ - Check stderr for error messages
193
+ - Timeout errors are reported in stderr
194
+
195
+ EXAMPLES:
196
+ - executeBash('ls -la', { cwd: '/path/to/dir' })
197
+ - executeBash('grep -r "pattern" .', { cwd: '/path/to/project' })
198
+ - executeBash('cat /absolute/path/to/file.txt')
199
+ - executeBash('find . -name "*.ts" -type f', { cwd: '/path/to/project' })
200
+
201
+ SECURITY NOTES:
202
+ - Commands execute in Docker sandbox when available (MANDATORY for production)
203
+ - Falls back to direct execution with warning if Docker unavailable
204
+ - Potentially dangerous commands are logged but not blocked
205
+ - Use with caution for destructive operations
206
+ - Always verify paths before executing
207
+
208
+ SANDBOX STATUS:
209
+ - Check result.sandboxed to see if command ran in sandbox
210
+ - Check result.sandboxStatus for sandbox availability information
211
+ - Production deployments should always have Docker available
212
+ `;
213
+ //# sourceMappingURL=bash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bash.js","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAEjF,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAElC,sCAAsC;AACtC,IAAI,eAAe,GAA2B,IAAI,CAAC;AAEnD;;GAEG;AACH,SAAS,kBAAkB;IACzB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAgCD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAe,EACf,UAAuB,EAAE;IAEzB,MAAM,SAAS,GAAG,IA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7B,CAAC,CAAC,+DAA+D;gBACjE,CAAC,CAAC,mEAAmE;SACxE,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDpC,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Edit Tool
3
+ * String replacement-based file editing (like Claude Code)
4
+ * Requires exact matches for safety
5
+ */
6
+ export interface EditOptions {
7
+ /** Working directory (will be resolved to absolute path) */
8
+ cwd?: string;
9
+ /** Create file if it doesn't exist */
10
+ createIfNotExists?: boolean;
11
+ }
12
+ export interface EditResult {
13
+ /** Whether operation succeeded */
14
+ success: boolean;
15
+ /** File path (absolute) */
16
+ filepath: string;
17
+ /** Operation performed */
18
+ operation: 'view' | 'create' | 'str_replace' | 'undo';
19
+ /** Error message if failed */
20
+ error?: string;
21
+ /** File content (for view operations) */
22
+ content?: string;
23
+ /** Number of replacements made */
24
+ replacements?: number;
25
+ }
26
+ /**
27
+ * View file content
28
+ */
29
+ export declare function viewFile(filepath: string, options?: EditOptions): EditResult;
30
+ /**
31
+ * Create a new file
32
+ */
33
+ export declare function createFile(filepath: string, content: string, options?: EditOptions): EditResult;
34
+ /**
35
+ * String replacement (exact match required)
36
+ * CRITICAL: Must match exactly, or error if multiple matches
37
+ */
38
+ export declare function strReplace(filepath: string, oldString: string, newString: string, options?: EditOptions): EditResult;
39
+ /**
40
+ * Undo last edit
41
+ */
42
+ export declare function undoEdit(filepath: string, options?: EditOptions): EditResult;
43
+ /**
44
+ * Tool description for the model
45
+ * This is critical - the model needs to understand how to use this tool
46
+ */
47
+ export declare const EDIT_TOOL_DESCRIPTION = "\nEdit Tool - String replacement-based file editing\n\nDESCRIPTION:\nEdit files using string replacement. Requires exact matches for safety.\n\nAVAILABLE OPERATIONS:\n1. **view(filepath)**: View file content\n2. **create(filepath, content)**: Create new file\n3. **str_replace(filepath, oldString, newString)**: Replace string in file\n4. **undo(filepath)**: Undo last edit\n\nCRITICAL RULES:\n1. **Exact Match Required**: oldString must match EXACTLY in the file\n2. **Unique Match Required**: If multiple matches found, provide more context\n3. **Absolute Paths**: All paths are resolved to absolute paths automatically\n4. **Context for Uniqueness**: Include surrounding lines if needed to make match unique\n\nSTRING REPLACEMENT:\n- oldString must appear EXACTLY ONCE in the file\n- If 0 matches: Error - string not found\n- If 2+ matches: Error - provide more context\n- Include surrounding code/whitespace to ensure uniqueness\n\nEXAMPLES:\n- str_replace('/path/to/file.ts', 'function old()', 'function new()')\n- str_replace('/path/to/file.ts', 'const x = 1;\\n', 'const x = 2;\\n')\n- Include context: str_replace('/path/to/file.ts', ' // Comment\\n function old()', ' // Comment\\n function new()')\n\nPATH HANDLING:\n- All paths are resolved to absolute paths\n- Use absolute paths or paths relative to cwd\n- Example: '/Users/username/project/file.ts' (absolute)\n- Example: './file.ts' (relative to cwd)\n\nUNDO:\n- undo() restores file to previous state\n- Only one level of undo (last edit)\n- Undo stack is in-memory (lost on restart)\n\nERROR HANDLING:\n- Check success field in result\n- Check error field for error message\n- Common errors:\n - File not found\n - String not found (0 matches)\n - Multiple matches (need more context)\n\nSECURITY:\n- All paths are validated\n- No file system traversal beyond project directory\n- Exact match requirement prevents accidental replacements\n";
48
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,WAAW;IAC1B,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;IACtD,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,UAAU,CA4BhF;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,WAAgB,GACxB,UAAU,CA6CZ;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,WAAgB,GACxB,UAAU,CA+DZ;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,UAAU,CA8BhF;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,83DAoDjC,CAAC"}
@@ -0,0 +1,235 @@
1
+ /**
2
+ * Edit Tool
3
+ * String replacement-based file editing (like Claude Code)
4
+ * Requires exact matches for safety
5
+ */
6
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
7
+ import { resolve, dirname } from 'path';
8
+ // Undo stack (simple in-memory, could be persisted later)
9
+ const undoStack = new Map();
10
+ /**
11
+ * View file content
12
+ */
13
+ export function viewFile(filepath, options = {}) {
14
+ const absPath = resolve(options.cwd || process.cwd(), filepath);
15
+ if (!existsSync(absPath)) {
16
+ return {
17
+ success: false,
18
+ filepath: absPath,
19
+ operation: 'view',
20
+ error: `File not found: ${absPath}`,
21
+ };
22
+ }
23
+ try {
24
+ const content = readFileSync(absPath, 'utf-8');
25
+ return {
26
+ success: true,
27
+ filepath: absPath,
28
+ operation: 'view',
29
+ content,
30
+ };
31
+ }
32
+ catch (error) {
33
+ return {
34
+ success: false,
35
+ filepath: absPath,
36
+ operation: 'view',
37
+ error: error instanceof Error ? error.message : String(error),
38
+ };
39
+ }
40
+ }
41
+ /**
42
+ * Create a new file
43
+ */
44
+ export function createFile(filepath, content, options = {}) {
45
+ const absPath = resolve(options.cwd || process.cwd(), filepath);
46
+ // Check if file exists
47
+ if (existsSync(absPath) && !options.createIfNotExists) {
48
+ return {
49
+ success: false,
50
+ filepath: absPath,
51
+ operation: 'create',
52
+ error: `File already exists: ${absPath}`,
53
+ };
54
+ }
55
+ try {
56
+ // Ensure directory exists
57
+ const dir = dirname(absPath);
58
+ if (!existsSync(dir)) {
59
+ mkdirSync(dir, { recursive: true });
60
+ }
61
+ // Save to undo stack
62
+ if (existsSync(absPath)) {
63
+ const oldContent = readFileSync(absPath, 'utf-8');
64
+ if (!undoStack.has(absPath)) {
65
+ undoStack.set(absPath, []);
66
+ }
67
+ undoStack.get(absPath).push(oldContent);
68
+ }
69
+ // Write file
70
+ writeFileSync(absPath, content, 'utf-8');
71
+ return {
72
+ success: true,
73
+ filepath: absPath,
74
+ operation: 'create',
75
+ };
76
+ }
77
+ catch (error) {
78
+ return {
79
+ success: false,
80
+ filepath: absPath,
81
+ operation: 'create',
82
+ error: error instanceof Error ? error.message : String(error),
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * String replacement (exact match required)
88
+ * CRITICAL: Must match exactly, or error if multiple matches
89
+ */
90
+ export function strReplace(filepath, oldString, newString, options = {}) {
91
+ const absPath = resolve(options.cwd || process.cwd(), filepath);
92
+ if (!existsSync(absPath)) {
93
+ return {
94
+ success: false,
95
+ filepath: absPath,
96
+ operation: 'str_replace',
97
+ error: `File not found: ${absPath}`,
98
+ };
99
+ }
100
+ try {
101
+ // Read file
102
+ const content = readFileSync(absPath, 'utf-8');
103
+ // Save to undo stack
104
+ if (!undoStack.has(absPath)) {
105
+ undoStack.set(absPath, []);
106
+ }
107
+ undoStack.get(absPath).push(content);
108
+ // Count matches
109
+ const matches = content.split(oldString).length - 1;
110
+ if (matches === 0) {
111
+ return {
112
+ success: false,
113
+ filepath: absPath,
114
+ operation: 'str_replace',
115
+ error: `String not found in file. Exact match required.`,
116
+ };
117
+ }
118
+ if (matches > 1) {
119
+ return {
120
+ success: false,
121
+ filepath: absPath,
122
+ operation: 'str_replace',
123
+ error: `Multiple matches found (${matches}). Provide more context to make the match unique.`,
124
+ };
125
+ }
126
+ // Perform replacement
127
+ const newContent = content.replace(oldString, newString);
128
+ // Write file
129
+ writeFileSync(absPath, newContent, 'utf-8');
130
+ return {
131
+ success: true,
132
+ filepath: absPath,
133
+ operation: 'str_replace',
134
+ replacements: 1,
135
+ };
136
+ }
137
+ catch (error) {
138
+ return {
139
+ success: false,
140
+ filepath: absPath,
141
+ operation: 'str_replace',
142
+ error: error instanceof Error ? error.message : String(error),
143
+ };
144
+ }
145
+ }
146
+ /**
147
+ * Undo last edit
148
+ */
149
+ export function undoEdit(filepath, options = {}) {
150
+ const absPath = resolve(options.cwd || process.cwd(), filepath);
151
+ const stack = undoStack.get(absPath);
152
+ if (!stack || stack.length === 0) {
153
+ return {
154
+ success: false,
155
+ filepath: absPath,
156
+ operation: 'undo',
157
+ error: 'No undo history available',
158
+ };
159
+ }
160
+ try {
161
+ const previousContent = stack.pop();
162
+ writeFileSync(absPath, previousContent, 'utf-8');
163
+ return {
164
+ success: true,
165
+ filepath: absPath,
166
+ operation: 'undo',
167
+ };
168
+ }
169
+ catch (error) {
170
+ return {
171
+ success: false,
172
+ filepath: absPath,
173
+ operation: 'undo',
174
+ error: error instanceof Error ? error.message : String(error),
175
+ };
176
+ }
177
+ }
178
+ /**
179
+ * Tool description for the model
180
+ * This is critical - the model needs to understand how to use this tool
181
+ */
182
+ export const EDIT_TOOL_DESCRIPTION = `
183
+ Edit Tool - String replacement-based file editing
184
+
185
+ DESCRIPTION:
186
+ Edit files using string replacement. Requires exact matches for safety.
187
+
188
+ AVAILABLE OPERATIONS:
189
+ 1. **view(filepath)**: View file content
190
+ 2. **create(filepath, content)**: Create new file
191
+ 3. **str_replace(filepath, oldString, newString)**: Replace string in file
192
+ 4. **undo(filepath)**: Undo last edit
193
+
194
+ CRITICAL RULES:
195
+ 1. **Exact Match Required**: oldString must match EXACTLY in the file
196
+ 2. **Unique Match Required**: If multiple matches found, provide more context
197
+ 3. **Absolute Paths**: All paths are resolved to absolute paths automatically
198
+ 4. **Context for Uniqueness**: Include surrounding lines if needed to make match unique
199
+
200
+ STRING REPLACEMENT:
201
+ - oldString must appear EXACTLY ONCE in the file
202
+ - If 0 matches: Error - string not found
203
+ - If 2+ matches: Error - provide more context
204
+ - Include surrounding code/whitespace to ensure uniqueness
205
+
206
+ EXAMPLES:
207
+ - str_replace('/path/to/file.ts', 'function old()', 'function new()')
208
+ - str_replace('/path/to/file.ts', 'const x = 1;\\n', 'const x = 2;\\n')
209
+ - Include context: str_replace('/path/to/file.ts', ' // Comment\\n function old()', ' // Comment\\n function new()')
210
+
211
+ PATH HANDLING:
212
+ - All paths are resolved to absolute paths
213
+ - Use absolute paths or paths relative to cwd
214
+ - Example: '/Users/username/project/file.ts' (absolute)
215
+ - Example: './file.ts' (relative to cwd)
216
+
217
+ UNDO:
218
+ - undo() restores file to previous state
219
+ - Only one level of undo (last edit)
220
+ - Undo stack is in-memory (lost on restart)
221
+
222
+ ERROR HANDLING:
223
+ - Check success field in result
224
+ - Check error field for error message
225
+ - Common errors:
226
+ - File not found
227
+ - String not found (0 matches)
228
+ - Multiple matches (need more context)
229
+
230
+ SECURITY:
231
+ - All paths are validated
232
+ - No file system traversal beyond project directory
233
+ - Exact match requirement prevents accidental replacements
234
+ `;
235
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EA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;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,OAAO;YACjB,SAAS,EAAE,MAAM;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDpC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Tool Executor
3
+ * Execute tools with error handling and result formatting
4
+ */
5
+ import type { ToolCall } from './parser.js';
6
+ export interface ToolExecutionResult {
7
+ /** Whether execution succeeded */
8
+ success: boolean;
9
+ /** Tool name */
10
+ tool: string;
11
+ /** Execution result */
12
+ result?: any;
13
+ /** Error message if failed */
14
+ error?: string;
15
+ /** Execution time in milliseconds */
16
+ duration?: number;
17
+ }
18
+ export declare class ToolExecutor {
19
+ /**
20
+ * Execute a single tool call
21
+ */
22
+ execute(call: ToolCall): Promise<ToolExecutionResult>;
23
+ /**
24
+ * Execute multiple tool calls in sequence
25
+ * Stops on first error
26
+ */
27
+ executeAll(calls: ToolCall[]): Promise<ToolExecutionResult[]>;
28
+ }
29
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/tools/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IAClC,kCAAkC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,YAAY;IACvB;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwG3D;;;OAGG;IACG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;CAcpE"}