atabey 0.0.5 → 0.0.7

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 (388) hide show
  1. package/ATABEY.md +4 -4
  2. package/README.md +35 -33
  3. package/bin/cli.js +2 -2
  4. package/bin/validate-agent-army.js +6 -6
  5. package/dist/framework-mcp/src/constants.js +1 -1
  6. package/dist/framework-mcp/src/constants.js.map +1 -1
  7. package/dist/framework-mcp/src/index.d.ts +1 -0
  8. package/dist/framework-mcp/src/index.js +30 -5
  9. package/dist/framework-mcp/src/index.js.map +1 -1
  10. package/dist/framework-mcp/src/resources/index.d.ts +10 -0
  11. package/dist/framework-mcp/src/resources/index.js +59 -0
  12. package/dist/framework-mcp/src/resources/index.js.map +1 -0
  13. package/dist/framework-mcp/src/tools/control_plane/locking.js +3 -3
  14. package/dist/framework-mcp/src/tools/control_plane/locking.js.map +1 -1
  15. package/dist/framework-mcp/src/tools/control_plane/registry.js +3 -2
  16. package/dist/framework-mcp/src/tools/control_plane/registry.js.map +1 -1
  17. package/dist/framework-mcp/src/tools/definitions.js +33 -1
  18. package/dist/framework-mcp/src/tools/definitions.js.map +1 -1
  19. package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.d.ts +1 -1
  20. package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js +8 -3
  21. package/dist/framework-mcp/src/tools/file_system/batch_surgical_edit.js.map +1 -1
  22. package/dist/framework-mcp/src/tools/file_system/patch_file.d.ts +1 -1
  23. package/dist/framework-mcp/src/tools/file_system/patch_file.js +8 -3
  24. package/dist/framework-mcp/src/tools/file_system/patch_file.js.map +1 -1
  25. package/dist/framework-mcp/src/tools/file_system/read_file.js +3 -3
  26. package/dist/framework-mcp/src/tools/file_system/read_file.js.map +1 -1
  27. package/dist/framework-mcp/src/tools/file_system/replace_text.d.ts +1 -1
  28. package/dist/framework-mcp/src/tools/file_system/replace_text.js +8 -3
  29. package/dist/framework-mcp/src/tools/file_system/replace_text.js.map +1 -1
  30. package/dist/framework-mcp/src/tools/file_system/write_file.d.ts +1 -1
  31. package/dist/framework-mcp/src/tools/file_system/write_file.js +10 -5
  32. package/dist/framework-mcp/src/tools/file_system/write_file.js.map +1 -1
  33. package/dist/framework-mcp/src/tools/framework/audit_deps.js +2 -2
  34. package/dist/framework-mcp/src/tools/framework/audit_deps.js.map +1 -1
  35. package/dist/framework-mcp/src/tools/framework/run_tests.js +2 -2
  36. package/dist/framework-mcp/src/tools/framework/run_tests.js.map +1 -1
  37. package/dist/framework-mcp/src/tools/framework/submit_plan.d.ts +10 -0
  38. package/dist/framework-mcp/src/tools/framework/submit_plan.js +14 -0
  39. package/dist/framework-mcp/src/tools/framework/submit_plan.js.map +1 -0
  40. package/dist/framework-mcp/src/tools/framework/update_memory.js +1 -1
  41. package/dist/framework-mcp/src/tools/framework/update_memory.js.map +1 -1
  42. package/dist/framework-mcp/src/tools/index.js +2 -0
  43. package/dist/framework-mcp/src/tools/index.js.map +1 -1
  44. package/dist/framework-mcp/src/tools/memory/get_insights.js +1 -1
  45. package/dist/framework-mcp/src/tools/memory/get_insights.js.map +1 -1
  46. package/dist/framework-mcp/src/tools/messaging/log_action.js +1 -1
  47. package/dist/framework-mcp/src/tools/messaging/log_action.js.map +1 -1
  48. package/dist/framework-mcp/src/tools/messaging/send_message.js +5 -5
  49. package/dist/framework-mcp/src/tools/messaging/send_message.js.map +1 -1
  50. package/dist/framework-mcp/src/tools/observability/check_ports.js +1 -1
  51. package/dist/framework-mcp/src/tools/observability/check_ports.js.map +1 -1
  52. package/dist/framework-mcp/src/tools/quality/check_lint.js +2 -2
  53. package/dist/framework-mcp/src/tools/quality/check_lint.js.map +1 -1
  54. package/dist/framework-mcp/src/tools/search/get_gaps.js +1 -1
  55. package/dist/framework-mcp/src/tools/search/get_gaps.js.map +1 -1
  56. package/dist/framework-mcp/src/tools/search/grep_search.js +3 -3
  57. package/dist/framework-mcp/src/tools/search/grep_search.js.map +1 -1
  58. package/dist/framework-mcp/src/tools/types.d.ts +1 -0
  59. package/dist/framework-mcp/src/utils/compliance.d.ts +6 -0
  60. package/dist/framework-mcp/src/utils/compliance.js +158 -5
  61. package/dist/framework-mcp/src/utils/compliance.js.map +1 -1
  62. package/dist/framework-mcp/src/utils/permissions.d.ts +12 -0
  63. package/dist/framework-mcp/src/utils/permissions.js +72 -0
  64. package/dist/framework-mcp/src/utils/permissions.js.map +1 -0
  65. package/dist/framework-mcp/tests/tools/file_system/compliance-risk.test.js +84 -0
  66. package/dist/framework-mcp/tests/tools/file_system/compliance-risk.test.js.map +1 -0
  67. package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js +31 -31
  68. package/dist/framework-mcp/tests/tools/file_system/file_system_tools.test.js.map +1 -1
  69. package/dist/framework-mcp/tests/tools/file_system/permissions.test.d.ts +1 -0
  70. package/dist/framework-mcp/tests/tools/file_system/permissions.test.js +92 -0
  71. package/dist/framework-mcp/tests/tools/file_system/permissions.test.js.map +1 -0
  72. package/dist/framework-mcp/tests/tools/messaging/send_message.test.js +5 -5
  73. package/dist/framework-mcp/tests/tools/messaging/send_message.test.js.map +1 -1
  74. package/dist/src/cli/adapters/core.js +1 -1
  75. package/dist/src/cli/adapters/core.js.map +1 -1
  76. package/dist/src/cli/adapters/scaffold.js +2 -2
  77. package/dist/src/cli/adapters/scaffold.js.map +1 -1
  78. package/dist/src/cli/commands/check.js +5 -3
  79. package/dist/src/cli/commands/check.js.map +1 -1
  80. package/dist/src/cli/commands/compliance.js +2 -2
  81. package/dist/src/cli/commands/compliance.js.map +1 -1
  82. package/dist/src/cli/commands/contract.js +2 -2
  83. package/dist/src/cli/commands/contract.js.map +1 -1
  84. package/dist/src/cli/commands/dashboard.d.ts +5 -0
  85. package/dist/src/cli/commands/dashboard.js +124 -0
  86. package/dist/src/cli/commands/dashboard.js.map +1 -0
  87. package/dist/src/cli/commands/explorer.js +3 -3
  88. package/dist/src/cli/commands/explorer.js.map +1 -1
  89. package/dist/src/cli/commands/git.js +3 -3
  90. package/dist/src/cli/commands/git.js.map +1 -1
  91. package/dist/src/cli/commands/init/create-agent.d.ts +4 -0
  92. package/dist/src/cli/commands/init/create-agent.js +59 -0
  93. package/dist/src/cli/commands/init/create-agent.js.map +1 -0
  94. package/dist/src/cli/commands/init/scaffold-core.d.ts +1 -0
  95. package/dist/src/cli/commands/init/scaffold-core.js +11 -7
  96. package/dist/src/cli/commands/init/scaffold-core.js.map +1 -1
  97. package/dist/src/cli/commands/init/scaffold-docs.d.ts +1 -0
  98. package/dist/src/cli/commands/init/scaffold-docs.js +4 -6
  99. package/dist/src/cli/commands/init/scaffold-docs.js.map +1 -1
  100. package/dist/src/cli/commands/init/scaffold-ops.js +4 -4
  101. package/dist/src/cli/commands/init/scaffold-ops.js.map +1 -1
  102. package/dist/src/cli/commands/init/scaffold-standards.js +10 -8
  103. package/dist/src/cli/commands/init/scaffold-standards.js.map +1 -1
  104. package/dist/src/cli/commands/init.js +26 -10
  105. package/dist/src/cli/commands/init.js.map +1 -1
  106. package/dist/src/cli/commands/knowledge.js +3 -3
  107. package/dist/src/cli/commands/knowledge.js.map +1 -1
  108. package/dist/src/cli/commands/lint.js +2 -2
  109. package/dist/src/cli/commands/lint.js.map +1 -1
  110. package/dist/src/cli/commands/log.js +6 -28
  111. package/dist/src/cli/commands/log.js.map +1 -1
  112. package/dist/src/cli/commands/orchestrate.d.ts +10 -17
  113. package/dist/src/cli/commands/orchestrate.js +92 -341
  114. package/dist/src/cli/commands/orchestrate.js.map +1 -1
  115. package/dist/src/cli/commands/plan.d.ts +5 -0
  116. package/dist/src/cli/commands/plan.js +80 -59
  117. package/dist/src/cli/commands/plan.js.map +1 -1
  118. package/dist/src/cli/commands/script.js +3 -3
  119. package/dist/src/cli/commands/script.js.map +1 -1
  120. package/dist/src/cli/commands/security.js +2 -2
  121. package/dist/src/cli/commands/security.js.map +1 -1
  122. package/dist/src/cli/commands/status.js +65 -8
  123. package/dist/src/cli/commands/status.js.map +1 -1
  124. package/dist/src/cli/commands/trace.d.ts +4 -0
  125. package/dist/src/cli/commands/trace.js +83 -2
  126. package/dist/src/cli/commands/trace.js.map +1 -1
  127. package/dist/src/cli/index.js +68 -18
  128. package/dist/src/cli/index.js.map +1 -1
  129. package/dist/src/cli/shims.js +14 -14
  130. package/dist/src/cli/utils/claude.js +1 -1
  131. package/dist/src/cli/utils/claude.js.map +1 -1
  132. package/dist/src/cli/utils/compliance.js +7 -1
  133. package/dist/src/cli/utils/compliance.js.map +1 -1
  134. package/dist/src/cli/utils/fs.js +1 -1
  135. package/dist/src/cli/utils/fs.js.map +1 -1
  136. package/dist/src/cli/utils/i18n.d.ts +1 -0
  137. package/dist/src/cli/utils/i18n.js +2 -0
  138. package/dist/src/cli/utils/i18n.js.map +1 -1
  139. package/dist/src/cli/utils/memory.d.ts +12 -3
  140. package/dist/src/cli/utils/memory.js +39 -31
  141. package/dist/src/cli/utils/memory.js.map +1 -1
  142. package/dist/src/cli/utils/pkg.js +2 -2
  143. package/dist/src/cli/utils/pkg.js.map +1 -1
  144. package/dist/src/cli/utils/schemas.d.ts +8 -8
  145. package/dist/src/cli/utils/ui.js +4 -4
  146. package/dist/src/cli/utils/ui.js.map +1 -1
  147. package/dist/src/contracts/tasks.d.ts +2 -2
  148. package/dist/src/dashboard/vite.config.d.ts +2 -0
  149. package/dist/src/dashboard/vite.config.js +16 -0
  150. package/dist/src/dashboard/vite.config.js.map +1 -0
  151. package/dist/src/modules/adapters/definitions.js +10 -10
  152. package/dist/src/modules/adapters/definitions.js.map +1 -1
  153. package/dist/src/modules/adapters/shared.js +4 -4
  154. package/dist/src/modules/adapters/shared.js.map +1 -1
  155. package/dist/src/modules/agents/definitions.d.ts +19 -0
  156. package/dist/src/modules/agents/definitions.js +74 -21
  157. package/dist/src/modules/agents/definitions.js.map +1 -1
  158. package/dist/src/modules/agents/registry/backend.js +8 -0
  159. package/dist/src/modules/agents/registry/backend.js.map +1 -1
  160. package/dist/src/modules/agents/registry/database.js +7 -0
  161. package/dist/src/modules/agents/registry/database.js.map +1 -1
  162. package/dist/src/modules/agents/registry/devops.js +6 -0
  163. package/dist/src/modules/agents/registry/devops.js.map +1 -1
  164. package/dist/src/modules/agents/registry/frontend.js +8 -0
  165. package/dist/src/modules/agents/registry/frontend.js.map +1 -1
  166. package/dist/src/modules/agents/registry/security.js +6 -0
  167. package/dist/src/modules/agents/registry/security.js.map +1 -1
  168. package/dist/src/modules/agents/types.d.ts +2 -0
  169. package/dist/src/modules/engines/evaluation-engine.d.ts +11 -0
  170. package/dist/src/modules/engines/evaluation-engine.js +103 -0
  171. package/dist/src/modules/engines/evaluation-engine.js.map +1 -0
  172. package/dist/src/modules/engines/health-engine.d.ts +16 -0
  173. package/dist/src/modules/engines/health-engine.js +50 -0
  174. package/dist/src/modules/engines/health-engine.js.map +1 -0
  175. package/dist/src/modules/engines/planning-engine.d.ts +25 -0
  176. package/dist/src/modules/engines/planning-engine.js +79 -0
  177. package/dist/src/modules/engines/planning-engine.js.map +1 -0
  178. package/dist/src/modules/engines/risk-engine.d.ts +18 -0
  179. package/dist/src/modules/engines/risk-engine.js +106 -0
  180. package/dist/src/modules/engines/risk-engine.js.map +1 -0
  181. package/dist/src/modules/engines/routing-engine.d.ts +11 -0
  182. package/dist/src/modules/engines/routing-engine.js +74 -0
  183. package/dist/src/modules/engines/routing-engine.js.map +1 -0
  184. package/dist/src/modules/engines/types.d.ts +47 -0
  185. package/dist/src/modules/engines/types.js +2 -0
  186. package/dist/src/modules/engines/types.js.map +1 -0
  187. package/dist/src/shared/constants.d.ts +5 -2
  188. package/dist/src/shared/constants.js +4 -1
  189. package/dist/src/shared/constants.js.map +1 -1
  190. package/dist/src/shared/fs.d.ts +1 -0
  191. package/dist/src/shared/fs.js +4 -0
  192. package/dist/src/shared/fs.js.map +1 -1
  193. package/dist/src/shared/storage.d.ts +60 -0
  194. package/dist/src/shared/storage.js +208 -0
  195. package/dist/src/shared/storage.js.map +1 -0
  196. package/dist/tests/agent-memory-v2.test.d.ts +1 -0
  197. package/dist/tests/agent-memory-v2.test.js +68 -0
  198. package/dist/tests/agent-memory-v2.test.js.map +1 -0
  199. package/dist/tests/agents-definitions.test.js +42 -0
  200. package/dist/tests/agents-definitions.test.js.map +1 -1
  201. package/dist/tests/integration/hermes_locking.test.js +7 -10
  202. package/dist/tests/integration/hermes_locking.test.js.map +1 -1
  203. package/dist/tests/orchestrate.test.js +5 -1
  204. package/dist/tests/orchestrate.test.js.map +1 -1
  205. package/dist/tests/orchestrator-dependencies.test.d.ts +1 -0
  206. package/dist/tests/orchestrator-dependencies.test.js +52 -0
  207. package/dist/tests/orchestrator-dependencies.test.js.map +1 -0
  208. package/dist/tests/plan.test.d.ts +1 -0
  209. package/dist/tests/plan.test.js +63 -0
  210. package/dist/tests/plan.test.js.map +1 -0
  211. package/dist/tests/planning-engine.test.d.ts +1 -0
  212. package/dist/tests/planning-engine.test.js +50 -0
  213. package/dist/tests/planning-engine.test.js.map +1 -0
  214. package/dist/tests/status-cost.test.d.ts +1 -0
  215. package/dist/tests/status-cost.test.js +54 -0
  216. package/dist/tests/status-cost.test.js.map +1 -0
  217. package/dist/tests/status.test.js +8 -7
  218. package/dist/tests/status.test.js.map +1 -1
  219. package/dist/tests/trace-replay.test.d.ts +1 -0
  220. package/dist/tests/trace-replay.test.js +65 -0
  221. package/dist/tests/trace-replay.test.js.map +1 -0
  222. package/dist/tests/trace.test.js +14 -7
  223. package/dist/tests/trace.test.js.map +1 -1
  224. package/dist/ui/assets/index-Bkt7APzu.css +1 -0
  225. package/dist/ui/assets/index-CeX-06mI.js +49 -0
  226. package/dist/ui/index.html +14 -0
  227. package/package.json +5 -4
  228. package/templates/prompts/contract-design-recipe.md +1 -1
  229. package/templates/prompts/db-management-recipe.md +3 -3
  230. package/templates/prompts/deployment-recipe.md +3 -3
  231. package/templates/prompts/performance-optimization-recipe.md +3 -3
  232. package/templates/prompts/pull-request-template.md +2 -2
  233. package/templates/prompts/security-audit-recipe.md +3 -3
  234. package/templates/standards/crud-governance.md +1 -1
  235. package/templates/standards/deployment-standards.md +1 -1
  236. package/templates/standards/governance-standards.md +1 -1
  237. package/templates/standards/llm-governance.md +1 -1
  238. package/templates/standards/nextjs-standards.md +13 -0
  239. package/templates/standards/observability-standards.md +1 -1
  240. package/templates/standards/security-audit-standards.md +1 -1
  241. package/templates/standards/security-standards.md +1 -1
  242. package/templates/standards/testing-standards.md +1 -1
  243. package/templates/standards/vite-standards.md +13 -0
  244. package/framework-mcp/dist/constants.js +0 -64
  245. package/framework-mcp/dist/index.js +0 -119
  246. package/framework-mcp/dist/tools/control_plane/locking.js +0 -82
  247. package/framework-mcp/dist/tools/control_plane/registry.js +0 -34
  248. package/framework-mcp/dist/tools/definitions.js +0 -290
  249. package/framework-mcp/dist/tools/file_system/batch_surgical_edit.js +0 -59
  250. package/framework-mcp/dist/tools/file_system/patch_file.js +0 -29
  251. package/framework-mcp/dist/tools/file_system/read_file.js +0 -51
  252. package/framework-mcp/dist/tools/file_system/replace_text.js +0 -45
  253. package/framework-mcp/dist/tools/file_system/write_file.js +0 -38
  254. package/framework-mcp/dist/tools/framework/audit_deps.js +0 -41
  255. package/framework-mcp/dist/tools/framework/get_status.js +0 -5
  256. package/framework-mcp/dist/tools/framework/orchestrate.js +0 -5
  257. package/framework-mcp/dist/tools/framework/run_tests.js +0 -27
  258. package/framework-mcp/dist/tools/framework/update_contract_hash.js +0 -5
  259. package/framework-mcp/dist/tools/framework/update_memory.js +0 -8
  260. package/framework-mcp/dist/tools/index.js +0 -60
  261. package/framework-mcp/dist/tools/memory/get_insights.js +0 -34
  262. package/framework-mcp/dist/tools/memory/read_memory.js +0 -28
  263. package/framework-mcp/dist/tools/messaging/log_action.js +0 -22
  264. package/framework-mcp/dist/tools/messaging/send_message.js +0 -94
  265. package/framework-mcp/dist/tools/observability/check_ports.js +0 -26
  266. package/framework-mcp/dist/tools/observability/get_health.js +0 -19
  267. package/framework-mcp/dist/tools/quality/check_lint.js +0 -30
  268. package/framework-mcp/dist/tools/search/get_gaps.js +0 -48
  269. package/framework-mcp/dist/tools/search/get_map.js +0 -43
  270. package/framework-mcp/dist/tools/search/grep_search.js +0 -75
  271. package/framework-mcp/dist/tools/search/list_dir.js +0 -28
  272. package/framework-mcp/dist/tools/shell/run_command.js +0 -56
  273. package/framework-mcp/dist/utils/cli.js +0 -59
  274. package/framework-mcp/dist/utils/compliance.js +0 -78
  275. package/framework-mcp/dist/utils/fs.js +0 -44
  276. package/framework-mcp/dist/utils/metrics.js +0 -56
  277. package/framework-mcp/dist/utils/security.js +0 -60
  278. package/framework-mcp/package-lock.json +0 -1191
  279. package/framework-mcp/package.json +0 -26
  280. package/framework-mcp/src/constants.ts +0 -78
  281. package/framework-mcp/src/declarations.d.ts +0 -17
  282. package/framework-mcp/src/index.ts +0 -144
  283. package/framework-mcp/src/tools/control_plane/locking.ts +0 -89
  284. package/framework-mcp/src/tools/control_plane/registry.ts +0 -38
  285. package/framework-mcp/src/tools/definitions.ts +0 -292
  286. package/framework-mcp/src/tools/file_system/batch_surgical_edit.ts +0 -79
  287. package/framework-mcp/src/tools/file_system/patch_file.ts +0 -39
  288. package/framework-mcp/src/tools/file_system/read_file.ts +0 -58
  289. package/framework-mcp/src/tools/file_system/replace_text.ts +0 -54
  290. package/framework-mcp/src/tools/file_system/write_file.ts +0 -45
  291. package/framework-mcp/src/tools/framework/audit_deps.ts +0 -49
  292. package/framework-mcp/src/tools/framework/get_status.ts +0 -7
  293. package/framework-mcp/src/tools/framework/orchestrate.ts +0 -7
  294. package/framework-mcp/src/tools/framework/run_tests.ts +0 -30
  295. package/framework-mcp/src/tools/framework/update_contract_hash.ts +0 -7
  296. package/framework-mcp/src/tools/framework/update_memory.ts +0 -10
  297. package/framework-mcp/src/tools/index.ts +0 -64
  298. package/framework-mcp/src/tools/memory/get_insights.ts +0 -41
  299. package/framework-mcp/src/tools/memory/read_memory.ts +0 -31
  300. package/framework-mcp/src/tools/messaging/log_action.ts +0 -28
  301. package/framework-mcp/src/tools/messaging/send_message.ts +0 -97
  302. package/framework-mcp/src/tools/observability/check_ports.ts +0 -30
  303. package/framework-mcp/src/tools/observability/get_health.ts +0 -24
  304. package/framework-mcp/src/tools/quality/check_lint.ts +0 -36
  305. package/framework-mcp/src/tools/search/get_gaps.ts +0 -54
  306. package/framework-mcp/src/tools/search/get_map.ts +0 -48
  307. package/framework-mcp/src/tools/search/grep_search.ts +0 -75
  308. package/framework-mcp/src/tools/search/list_dir.ts +0 -34
  309. package/framework-mcp/src/tools/shell/run_command.ts +0 -66
  310. package/framework-mcp/src/tools/types.ts +0 -89
  311. package/framework-mcp/src/utils/cli.ts +0 -53
  312. package/framework-mcp/src/utils/compliance.ts +0 -95
  313. package/framework-mcp/src/utils/fs.ts +0 -45
  314. package/framework-mcp/src/utils/metrics.ts +0 -73
  315. package/framework-mcp/src/utils/security.ts +0 -66
  316. package/framework-mcp/tests/tools/file_system/file_system_tools.test.ts +0 -212
  317. package/framework-mcp/tests/tools/messaging/send_message.test.ts +0 -136
  318. package/framework-mcp/tests/tools/quality/check_lint.test.ts +0 -46
  319. package/framework-mcp/tests/tools/shell/run_command.test.ts +0 -55
  320. package/framework-mcp/tsconfig.json +0 -14
  321. package/src/cli/adapters/core.ts +0 -91
  322. package/src/cli/adapters/index.ts +0 -5
  323. package/src/cli/adapters/paths.ts +0 -135
  324. package/src/cli/adapters/scaffold.ts +0 -95
  325. package/src/cli/adapters/utils.ts +0 -87
  326. package/src/cli/commands/approve.ts +0 -73
  327. package/src/cli/commands/check.ts +0 -188
  328. package/src/cli/commands/compliance.ts +0 -55
  329. package/src/cli/commands/contract.ts +0 -68
  330. package/src/cli/commands/explorer.ts +0 -45
  331. package/src/cli/commands/git.ts +0 -39
  332. package/src/cli/commands/init/scaffold-core.ts +0 -136
  333. package/src/cli/commands/init/scaffold-docs.ts +0 -44
  334. package/src/cli/commands/init/scaffold-ops.ts +0 -83
  335. package/src/cli/commands/init/scaffold-standards.ts +0 -67
  336. package/src/cli/commands/init.ts +0 -193
  337. package/src/cli/commands/knowledge.ts +0 -44
  338. package/src/cli/commands/lint.ts +0 -23
  339. package/src/cli/commands/log.ts +0 -37
  340. package/src/cli/commands/memory.ts +0 -6
  341. package/src/cli/commands/orchestrate.ts +0 -450
  342. package/src/cli/commands/plan.ts +0 -113
  343. package/src/cli/commands/script.ts +0 -20
  344. package/src/cli/commands/security.ts +0 -38
  345. package/src/cli/commands/status.ts +0 -44
  346. package/src/cli/commands/trace.ts +0 -31
  347. package/src/cli/index.ts +0 -322
  348. package/src/cli/shims.ts +0 -66
  349. package/src/cli/utils/claude.ts +0 -63
  350. package/src/cli/utils/compliance.ts +0 -191
  351. package/src/cli/utils/config-schema.ts +0 -48
  352. package/src/cli/utils/fs.ts +0 -170
  353. package/src/cli/utils/i18n.ts +0 -44
  354. package/src/cli/utils/memory.ts +0 -303
  355. package/src/cli/utils/pkg.ts +0 -317
  356. package/src/cli/utils/schemas.ts +0 -22
  357. package/src/cli/utils/string.ts +0 -55
  358. package/src/cli/utils/time.ts +0 -27
  359. package/src/cli/utils/ui.ts +0 -66
  360. package/src/contracts/index.ts +0 -1
  361. package/src/contracts/tasks.ts +0 -26
  362. package/src/modules/adapters/definitions.ts +0 -171
  363. package/src/modules/adapters/registry.ts +0 -27
  364. package/src/modules/adapters/shared.ts +0 -120
  365. package/src/modules/adapters/types.ts +0 -16
  366. package/src/modules/agents/definitions.ts +0 -460
  367. package/src/modules/agents/registry/analyst.ts +0 -44
  368. package/src/modules/agents/registry/architect.ts +0 -47
  369. package/src/modules/agents/registry/backend.ts +0 -46
  370. package/src/modules/agents/registry/database.ts +0 -43
  371. package/src/modules/agents/registry/devops.ts +0 -44
  372. package/src/modules/agents/registry/explorer.ts +0 -41
  373. package/src/modules/agents/registry/frontend.ts +0 -48
  374. package/src/modules/agents/registry/git.ts +0 -41
  375. package/src/modules/agents/registry/manager.ts +0 -58
  376. package/src/modules/agents/registry/mobile.ts +0 -44
  377. package/src/modules/agents/registry/native.ts +0 -44
  378. package/src/modules/agents/registry/quality.ts +0 -46
  379. package/src/modules/agents/registry/security.ts +0 -42
  380. package/src/modules/agents/types.ts +0 -37
  381. package/src/modules/skills/definitions.ts +0 -71
  382. package/src/schema/agent-lifecycle-schema.json +0 -59
  383. package/src/shared/constants.ts +0 -218
  384. package/src/shared/errors.ts +0 -75
  385. package/src/shared/fs.ts +0 -50
  386. package/src/shared/logger.ts +0 -139
  387. package/src/shared/types.ts +0 -20
  388. /package/{framework-mcp/dist/tools/types.js → dist/framework-mcp/tests/tools/file_system/compliance-risk.test.d.ts} +0 -0
@@ -1,89 +0,0 @@
1
- export interface ToolDefinition {
2
- name: string;
3
- description: string;
4
- inputSchema: {
5
- type: "object";
6
- properties: Record<string, unknown>;
7
- required?: string[];
8
- };
9
- }
10
-
11
- // ─── File System ────────────────────────────────────────────────
12
- export interface ReadFileArgs { path: string; startLine?: number; endLine?: number; }
13
- export interface WriteFileArgs { path: string; content: string; }
14
- export interface ReplaceTextArgs { path: string; oldText: string; newText: string; allowMultiple?: boolean; }
15
- export interface PatchFileArgs { path: string; startLine: number; endLine: number; newContent: string; }
16
- export interface BatchSurgicalEditArgs {
17
- edits: Array<{ path: string; oldText: string; newText: string; allowMultiple?: boolean; }>;
18
- }
19
-
20
- // ─── Search & Discovery ──────────────────────────────────────────
21
- export interface ListDirArgs { path?: string; }
22
- export interface GrepSearchArgs { pattern: string; includePattern?: string; excludePattern?: string; }
23
- export interface GetProjectMapArgs { maxDepth?: number; includeFiles?: boolean; }
24
- export interface GetProjectGapsArgs { path?: string; }
25
-
26
- // ─── Messaging (Hermes) ─────────────────────────────────────────
27
- export interface SendAgentMessageArgs {
28
- from: string;
29
- to: string;
30
- category: "ACTION" | "DELEGATION" | "SUBTASK" | "REPLY" | "ALERT";
31
- content: string;
32
- traceId: string;
33
- parentId?: string;
34
- priority?: "HIGH" | "NORMAL" | "LOW";
35
- requiresApproval?: boolean;
36
- }
37
- export interface LogAgentActionArgs {
38
- agent: string;
39
- action: string;
40
- traceId: string;
41
- status: "SUCCESS" | "FAILURE";
42
- summary: string;
43
- findings?: string;
44
- }
45
-
46
- // ─── Control Plane ──────────────────────────────────────────────
47
- export interface AcquireLockArgs { resource: string; agent: string; ttl?: number; }
48
- export interface ReleaseLockArgs { resource: string; agent: string; }
49
- export interface RegisterAgentArgs { agent: string; role: string; capability?: number; }
50
-
51
- // ─── Observability & Utils ──────────────────────────────────────
52
- export interface StartDashboardArgs { port?: number; }
53
- export interface CheckActivePortsArgs { filter?: string; }
54
- export interface RunTestsArgs { command?: string; timeout?: number; }
55
- export interface UpdateProjectMemoryArgs { section: string; content: string; }
56
- export interface GetStatusArgs { timeout?: number; }
57
- export interface OrchestrateArgs { timeout?: number; }
58
- export interface UpdateContractHashArgs { timeout?: number; }
59
- export interface RunCommandArgs { command: string; }
60
-
61
- export type ToolArgs =
62
- | ReadFileArgs
63
- | WriteFileArgs
64
- | ReplaceTextArgs
65
- | PatchFileArgs
66
- | BatchSurgicalEditArgs
67
- | ListDirArgs
68
- | GrepSearchArgs
69
- | GetProjectMapArgs
70
- | GetProjectGapsArgs
71
- | SendAgentMessageArgs
72
- | LogAgentActionArgs
73
- | AcquireLockArgs
74
- | ReleaseLockArgs
75
- | RegisterAgentArgs
76
- | StartDashboardArgs
77
- | CheckActivePortsArgs
78
- | RunTestsArgs
79
- | UpdateProjectMemoryArgs
80
- | GetStatusArgs
81
- | OrchestrateArgs
82
- | UpdateContractHashArgs;
83
-
84
- export interface ToolResult {
85
- isError?: boolean;
86
- content: Array<{ type: "text"; text: string }>;
87
- }
88
-
89
- export type ToolHandler = (projectRoot: string, args: unknown) => ToolResult | Promise<ToolResult>;
@@ -1,53 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { execFileSync } from "child_process";
4
-
5
- /**
6
- * Executes a command safely and returns the output.
7
- */
8
- export function safeExec(cmd: string, args: string[], cwd: string, timeout = 30000): string {
9
- try {
10
- return execFileSync(cmd, args, { cwd, timeout, encoding: "utf8", stdio: "pipe" });
11
- } catch (err: unknown) {
12
- const error = err as { stdout?: Buffer | string; stderr?: Buffer | string; message?: string };
13
- return error.stdout?.toString() || error.stderr?.toString() || error.message || String(err);
14
- }
15
- }
16
-
17
- /**
18
- * Detects the backend language from the framework configuration.
19
- */
20
- export function getBackendLanguage(projectRoot: string): string {
21
- try {
22
- const configPath = path.join(projectRoot, ".atabey", "config.json");
23
- if (fs.existsSync(configPath)) {
24
- const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
25
- return config.backendLanguage || "Node.js (TypeScript)";
26
- }
27
- } catch {
28
- // Fallback to default
29
- }
30
- return "Node.js (TypeScript)";
31
- }
32
-
33
- /**
34
- * Returns the default lint command for the given language.
35
- */
36
- export function getDefaultLintCommand(language: string): string {
37
- if (language.includes("Go")) return "go fmt ./...";
38
- if (language.includes("Java")) return "./gradlew check"; // or mvn check
39
- if (language.includes("Python")) return "ruff check .";
40
- if (language.includes(".NET")) return "dotnet format";
41
- return "npm run lint";
42
- }
43
-
44
- /**
45
- * Returns the default test command for the given language.
46
- */
47
- export function getDefaultTestCommand(language: string): string {
48
- if (language.includes("Go")) return "go test ./...";
49
- if (language.includes("Java")) return "./gradlew test"; // or mvn test
50
- if (language.includes("Python")) return "pytest";
51
- if (language.includes(".NET")) return "dotnet test";
52
- return "npm test";
53
- }
@@ -1,95 +0,0 @@
1
- import ts from "typescript";
2
-
3
- /**
4
- * Enterprise Compliance Guardrail
5
- * Checks content against corporate standards using AST analysis before allowing file mutations.
6
- */
7
- export function verifyCorporateCompliance(content: string, filePath: string): void {
8
- // Skip compliance checks for non-source files or specific ignored files
9
- if (filePath.endsWith(".json") || filePath.endsWith(".md") || filePath.endsWith(".env.example")) {
10
- return;
11
- }
12
-
13
- const sourceFile = ts.createSourceFile(
14
- filePath,
15
- content,
16
- ts.ScriptTarget.Latest,
17
- true
18
- );
19
-
20
- const errors: string[] = [];
21
-
22
- /**
23
- * Recursive AST Visitor
24
- */
25
- function visit(node: ts.Node) {
26
- // 1. Zero Console Policy
27
- if (ts.isPropertyAccessExpression(node)) {
28
- const expression = node.expression;
29
- const name = node.name.text;
30
- if (ts.isIdentifier(expression) && expression.text === "console") {
31
- if (["log", "warn", "error"].includes(name)) {
32
- // Check if file is exempt
33
- if (!filePath.includes("logger.ts") && !filePath.includes("check.ts") && !filePath.includes("cli.ts")) {
34
- errors.push(`❌ Corporate Compliance Breach: 'console.${name}' usage is forbidden at line ${sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1}.`);
35
- }
36
- }
37
- }
38
- }
39
-
40
- // 2. No Explicit Any Policy
41
- if (ts.isTypeReferenceNode(node)) {
42
- if (ts.isIdentifier(node.typeName) && node.typeName.text === "any") {
43
- if (!filePath.includes("definitions.ts") && !filePath.includes("types.ts")) {
44
- errors.push(`❌ Corporate Compliance Breach: 'any' type is forbidden at line ${sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1}.`);
45
- }
46
- }
47
- }
48
-
49
- // 3. Zero UI Library Policy (No @chakra-ui, mui, @shadcn)
50
- if (ts.isImportDeclaration(node)) {
51
- const moduleSpecifier = node.moduleSpecifier;
52
- if (ts.isStringLiteral(moduleSpecifier)) {
53
- const forbiddenLibs = ["@chakra-ui", "mui", "@shadcn", "antd", "bootstrap"];
54
- const lib = forbiddenLibs.find(l => moduleSpecifier.text.includes(l));
55
- if (lib) {
56
- errors.push(`❌ Corporate Compliance Breach: External UI library '${lib}' usage is FORBIDDEN at line ${sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1}. Build atomic components manually instead.`);
57
- }
58
- }
59
- }
60
-
61
- // Handle 'any' as a keyword type (e.g., parameter: any)
62
- if (node.kind === ts.SyntaxKind.AnyKeyword) {
63
- if (!filePath.includes("definitions.ts") && !filePath.includes("types.ts")) {
64
- errors.push(`❌ Corporate Compliance Breach: 'any' keyword is forbidden at line ${sourceFile.getLineAndCharacterOfPosition(node.getStart()).line + 1}.`);
65
- }
66
- }
67
-
68
- ts.forEachChild(node, visit);
69
- }
70
-
71
- visit(sourceFile);
72
-
73
- // 3. Hardcoded Secrets & PII Guard
74
- const piiKeywords = [
75
- { regex: /API_KEY\s*=\s*['"][^'"]+['"]/i, msg: "Hardcoded API Key" },
76
- { regex: /SECRET\s*=\s*['"][^'"]+['"]/i, msg: "Hardcoded Secret" },
77
- { regex: /PASSWORD\s*=\s*['"][^'"]+['"]/i, msg: "Hardcoded Password" },
78
- { regex: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/, msg: "PII Detected: Email Address" },
79
- { regex: /\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/, msg: "PII Detected: Credit Card Pattern" }
80
- ];
81
-
82
- for (const { regex, msg } of piiKeywords) {
83
- if (regex.test(content)) {
84
- // Allow emails in specific files like README or package.json
85
- if (msg.includes("Email") && (filePath.endsWith("README.md") || filePath.endsWith("package.json") || filePath.includes("CONTRIBUTING"))) {
86
- continue;
87
- }
88
- errors.push(`❌ Corporate Compliance Breach: ${msg} detected.`);
89
- }
90
- }
91
-
92
- if (errors.length > 0) {
93
- throw new Error(errors.join("\n"));
94
- }
95
- }
@@ -1,45 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- /**
5
- * Ensures directory existence.
6
- */
7
- export function ensureDir(dirPath: string): void {
8
- if (!fs.existsSync(dirPath)) {
9
- fs.mkdirSync(dirPath, { recursive: true });
10
- }
11
- }
12
-
13
- /**
14
- * Atomically writes a text file.
15
- */
16
- export function writeTextFileAtomic(filePath: string, content: string): void {
17
- const dir = path.dirname(filePath);
18
- ensureDir(dir);
19
-
20
- const tempPath = `${filePath}.${Math.random().toString(36).slice(2, 9)}.tmp`;
21
- const finalContent = content.endsWith("\n") ? content : `${content}\n`;
22
-
23
- try {
24
- fs.writeFileSync(tempPath, finalContent, "utf8");
25
- fs.renameSync(tempPath, filePath);
26
- } catch (err) {
27
- if (fs.existsSync(tempPath)) {
28
- try { fs.unlinkSync(tempPath); } catch { /* ignore */ }
29
- }
30
- throw err;
31
- }
32
- }
33
-
34
- /**
35
- * Atomically appends to a file (if supported by OS) or simulates it.
36
- * Note: Real atomic append on POSIX is a single write() call with O_APPEND.
37
- * For simplicity and robustness across platforms, we use a simple append here
38
- * as the risk of corruption is lower than a full rewrite, but for logs
39
- * it's acceptable.
40
- */
41
- export function appendFileSafe(filePath: string, content: string): void {
42
- const dir = path.dirname(filePath);
43
- ensureDir(dir);
44
- fs.appendFileSync(filePath, content, "utf8");
45
- }
@@ -1,73 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { resolveFrameworkDir } from "./security.js";
4
- /**
5
- * Token and Metric Tracker for Agent Atabey.
6
- * Estimates token usage and logs operational costs.
7
- */
8
-
9
- interface MetricEntry {
10
- timestamp: string;
11
- agent: string;
12
- action: string;
13
- estimatedTokens: number;
14
- error?: string;
15
- }
16
-
17
- export const Metrics = {
18
- /**
19
- * Estimates tokens based on character count (rough heuristic: 1 token ~= 4 chars).
20
- */
21
- estimateTokens: (text: string): number => {
22
- return Math.ceil(text.length / 4);
23
- },
24
-
25
- /**
26
- * Logs the token usage and action to the observability metrics file.
27
- */
28
- logUsage: (projectRoot: string, agent: string, action: string, tokens: number) => {
29
- Metrics.saveMetric(projectRoot, {
30
- timestamp: new Date().toISOString(),
31
- agent,
32
- action,
33
- estimatedTokens: tokens
34
- });
35
- },
36
-
37
- /**
38
- * Logs an error occurrence to the observability metrics file.
39
- */
40
- logError: (projectRoot: string, agent: string, action: string, error: string) => {
41
- Metrics.saveMetric(projectRoot, {
42
- timestamp: new Date().toISOString(),
43
- agent,
44
- action: `ERROR: ${action}`,
45
- estimatedTokens: 0,
46
- error
47
- });
48
- },
49
-
50
- /**
51
- * Internal helper to save metric entries.
52
- */
53
- saveMetric: (projectRoot: string, entry: MetricEntry) => {
54
- const frameworkDir = resolveFrameworkDir(projectRoot);
55
- const metricsPath = path.join(projectRoot, frameworkDir, "observability/metrics.json");
56
- try {
57
- const metricsDir = path.dirname(metricsPath);
58
- if (!fs.existsSync(metricsDir)) fs.mkdirSync(metricsDir, { recursive: true });
59
-
60
- let currentMetrics: MetricEntry[] = [];
61
- if (fs.existsSync(metricsPath)) {
62
- currentMetrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
63
- }
64
-
65
- currentMetrics.push(entry);
66
-
67
- // Keep only last 100 entries to save space
68
- if (currentMetrics.length > 100) currentMetrics.shift();
69
-
70
- fs.writeFileSync(metricsPath, JSON.stringify(currentMetrics, null, 2));
71
- } catch { /* ignore: metrics should not block the main process */ }
72
- }
73
- };
@@ -1,66 +0,0 @@
1
- import path from "path";
2
- import fs from "fs";
3
- import { FRAMEWORK, MCP, UNIFIED_HUB_DIR } from "../constants.js"; // New import
4
- import os from "os"; // Need os.homedir()
5
-
6
- /**
7
- * Validates and resolves a user-provided path to prevent path traversal attacks.
8
- * Ensures the resolved path stays within the project root boundary.
9
- */
10
- export function safePath(projectRoot: string, userPath: string): string {
11
- const resolved = path.resolve(projectRoot, userPath);
12
- const normalizedRoot = path.resolve(projectRoot);
13
-
14
- if (!resolved.startsWith(normalizedRoot + path.sep) && resolved !== normalizedRoot) {
15
- throw new Error(`Access denied: path "${userPath}" escapes project root.`);
16
- }
17
-
18
- return resolved;
19
- }
20
-
21
- /**
22
- * Resolves the active framework directory.
23
- * Priority: ATABEY_TEST_DIR (env) -> package.json `atabey.frameworkDir` -> `.atabey` -> other adapter dirs -> global HOME.
24
- */
25
- export function resolveFrameworkDir(projectRoot: string): string {
26
- // For test environments, use the explicitly set test directory.
27
- const testDir = process.env[MCP.TEST_DIR_ENV];
28
- if (testDir) return testDir;
29
-
30
- // 1. Authoritative source: read from package.json if present
31
- try {
32
- const pkgPath = path.join(projectRoot, "package.json");
33
- if (fs.existsSync(pkgPath)) {
34
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as Record<string, unknown>;
35
- const atabeyConfig = pkg["atabey"] as Record<string, unknown> | undefined;
36
- if (atabeyConfig && typeof atabeyConfig["frameworkDir"] === "string") {
37
- // Ensure the path is relative if it's within the project, otherwise use as-is.
38
- const resolvedDir = path.resolve(projectRoot, atabeyConfig["frameworkDir"]);
39
- if (resolvedDir.startsWith(path.resolve(projectRoot))) {
40
- return path.relative(projectRoot, resolvedDir);
41
- }
42
- return atabeyConfig["frameworkDir"];
43
- }
44
- }
45
- } catch {
46
- // ignore — fall through to filesystem scan
47
- }
48
-
49
- // 2. Filesystem scan in projectRoot for common framework directories
50
- const localCandidates = [
51
- FRAMEWORK.CORE_DIR, // .atabey
52
- UNIFIED_HUB_DIR, // .agents
53
- // Add other adapter specific directories if needed, or remove if unified is strictly enforced
54
- ];
55
-
56
- for (const candidate of localCandidates) {
57
- const candidatePath = path.join(projectRoot, candidate);
58
- if (fs.existsSync(candidatePath)) {
59
- return candidate;
60
- }
61
- }
62
-
63
- // 3. Fallback to global home directory.
64
- const homeDir = os.homedir();
65
- return path.join(homeDir, FRAMEWORK.CORE_DIR);
66
- }
@@ -1,212 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
- import fs from "fs";
3
- import path from "path";
4
- import { handleReplaceText } from "../../../src/tools/file_system/replace_text.js";
5
- import { handlePatchFile } from "../../../src/tools/file_system/patch_file.js";
6
- import { handleReadFile } from "../../../src/tools/file_system/read_file.js";
7
- import { handleWriteFile } from "../../../src/tools/file_system/write_file.js";
8
- import { ToolArgs } from "../../../src/tools/types.js";
9
-
10
- import os from "os"; // Need to import os
11
-
12
- let TEST_DIR: string; // Declare as let
13
- let TEST_FILE: string;
14
- let MEMORY_DIR: string;
15
- let MEMORY_FILE: string;
16
-
17
- beforeEach(() => {
18
- TEST_DIR = fs.mkdtempSync(path.join(os.tmpdir(), "fs-tools-test-")); // Unique temp dir
19
- fs.mkdirSync(path.join(TEST_DIR, ".atabey"));
20
- TEST_FILE = path.join(TEST_DIR, "test_file.txt");
21
- MEMORY_DIR = path.join(TEST_DIR, ".atabey/memory");
22
- MEMORY_FILE = path.join(MEMORY_DIR, "PROJECT_MEMORY.md");
23
- });
24
-
25
- afterEach(() => {
26
- fs.rmSync(TEST_DIR, { recursive: true, force: true });
27
- });
28
-
29
- describe("File System Tools", () => {
30
-
31
- describe("handleReplaceText", () => {
32
- it("should replace a single occurrence of text", () => {
33
- fs.writeFileSync(TEST_FILE, "hello world", "utf8");
34
- const args: ToolArgs = {
35
- path: TEST_FILE,
36
- oldText: "world",
37
- newText: "there",
38
- };
39
- const result = handleReplaceText(TEST_DIR, args as any);
40
- expect(result.content[0].text).toContain("✅ Surgical edit successful in");
41
- expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there\n");
42
- });
43
-
44
- it("should throw an error if text is not found", () => {
45
- fs.writeFileSync(TEST_FILE, "hello world", "utf8");
46
- const args: ToolArgs = {
47
- path: TEST_FILE,
48
- oldText: "missing",
49
- newText: "found",
50
- };
51
- expect(() => handleReplaceText(TEST_DIR, args)).toThrowError("Text not found in file");
52
- });
53
-
54
- it("should throw an error for ambiguous replacement if allowMultiple is false", () => {
55
- fs.writeFileSync(TEST_FILE, "hello world world", "utf8");
56
- const args: ToolArgs = {
57
- path: TEST_FILE,
58
- oldText: "world",
59
- newText: "there",
60
- allowMultiple: false,
61
- };
62
- expect(() => handleReplaceText(TEST_DIR, args)).toThrowError("Ambiguous replacement");
63
- });
64
-
65
- it("should replace all occurrences of text if allowMultiple is true", () => {
66
- fs.writeFileSync(TEST_FILE, "hello world world", "utf8");
67
- const args: ToolArgs = {
68
- path: TEST_FILE,
69
- oldText: "world",
70
- newText: "there",
71
- allowMultiple: true,
72
- };
73
- const result = handleReplaceText(TEST_DIR, args as any);
74
- expect(result.content[0].text).toContain("✅ Surgical edit successful in");
75
- expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello there there\n");
76
- });
77
-
78
- it("should log usage to metrics.json upon replace", () => {
79
- fs.writeFileSync(TEST_FILE, "hello world", "utf8");
80
- const args: ToolArgs = {
81
- path: TEST_FILE,
82
- oldText: "world",
83
- newText: "there",
84
- };
85
- handleReplaceText(TEST_DIR, args);
86
- const metricsPath = path.join(TEST_DIR, ".atabey/observability/metrics.json");
87
- expect(fs.existsSync(metricsPath)).toBe(true);
88
- const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
89
- expect(metrics[0].action).toContain("replace_text");
90
- });
91
- });
92
-
93
- describe("handlePatchFile", () => {
94
- it("should replace lines in specified range", () => {
95
- fs.writeFileSync(TEST_FILE, "line1\nline2\nline3\nline4", "utf8");
96
- const args: ToolArgs = {
97
- path: TEST_FILE,
98
- startLine: 2,
99
- endLine: 3,
100
- newContent: "patched2\npatched3",
101
- };
102
- const result = handlePatchFile(TEST_DIR, args);
103
- expect(result.content[0].text).toContain("✅ File patched successfully");
104
- expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("line1\npatched2\npatched3\nline4");
105
- });
106
-
107
- it("should throw an error for invalid start line", () => {
108
- fs.writeFileSync(TEST_FILE, "line1\nline2", "utf8");
109
- const args: ToolArgs = {
110
- path: TEST_FILE,
111
- startLine: 5,
112
- endLine: 2,
113
- newContent: "error",
114
- };
115
- expect(() => handlePatchFile(TEST_DIR, args)).toThrowError("Invalid start line");
116
- });
117
-
118
- it("should throw an error for invalid end line", () => {
119
- fs.writeFileSync(TEST_FILE, "line1\nline2", "utf8");
120
- const args: ToolArgs = {
121
- path: TEST_FILE,
122
- startLine: 1,
123
- endLine: 5,
124
- newContent: "error",
125
- };
126
- expect(() => handlePatchFile(TEST_DIR, args)).toThrowError("Invalid end line");
127
- });
128
-
129
- it("should log usage to metrics.json upon patch", () => {
130
- fs.writeFileSync(TEST_FILE, "line1\nline2\nline3\nline4", "utf8");
131
- const args: ToolArgs = {
132
- path: TEST_FILE,
133
- startLine: 2,
134
- endLine: 3,
135
- newContent: "patched2\npatched3",
136
- };
137
- handlePatchFile(TEST_DIR, args as any);
138
- const metricsPath = path.join(TEST_DIR, ".atabey/observability/metrics.json");
139
- expect(fs.existsSync(metricsPath)).toBe(true);
140
- const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
141
- expect(metrics[0].action).toContain("patch_file");
142
- });
143
- });
144
-
145
- describe("handleReadFile", () => {
146
- it("should read full file content", () => {
147
- fs.writeFileSync(TEST_FILE, "hello world", "utf8");
148
- const args: ToolArgs = { path: TEST_FILE };
149
- const result = handleReadFile(TEST_DIR, args as any);
150
- expect(result.content[0].text).toBe("hello world");
151
- });
152
-
153
- it("should read sliced lines", () => {
154
- fs.writeFileSync(TEST_FILE, "line1\nline2\nline3\nline4", "utf8");
155
- const args: ToolArgs = {
156
- path: TEST_FILE,
157
- startLine: 2,
158
- endLine: 3
159
- };
160
- const result = handleReadFile(TEST_DIR, args as any);
161
- expect(result.content[0].text).toBe("line2\nline3");
162
- });
163
-
164
- it("should truncate long files", () => {
165
- const longContent = Array.from({ length: 1005 }, (_, i) => `line ${i + 1}`).join("\n");
166
- fs.writeFileSync(TEST_FILE, longContent, "utf8");
167
- const args: ToolArgs = { path: TEST_FILE };
168
- const result = handleReadFile(TEST_DIR, args as any);
169
- expect(result.content[0].text).toContain("TRUNCATED");
170
- expect(result.content[0].text).toContain("line 1000");
171
- expect(result.content[0].text).not.toContain("line 1001");
172
- });
173
- });
174
-
175
- describe("handleWriteFile", () => {
176
- it("should write new file and log usage", () => {
177
- const args: ToolArgs = {
178
- path: TEST_FILE,
179
- content: "hello world"
180
- };
181
- const result = handleWriteFile(TEST_DIR, args);
182
- expect(result.content[0].text).toContain("✅ File written:");
183
- expect(fs.readFileSync(TEST_FILE, "utf8")).toBe("hello world\n");
184
- });
185
-
186
- it("should write new file and log usage to metrics.json", () => {
187
- const args: ToolArgs = {
188
- path: TEST_FILE,
189
- content: "hello world"
190
- };
191
- handleWriteFile(TEST_DIR, args);
192
- const metricsPath = path.join(TEST_DIR, ".atabey/observability/metrics.json");
193
- expect(fs.existsSync(metricsPath)).toBe(true);
194
- const metrics = JSON.parse(fs.readFileSync(metricsPath, "utf8"));
195
- expect(metrics[0].action).toContain("write_file");
196
- expect(metrics[0].estimatedTokens).toBeGreaterThan(0);
197
- });
198
-
199
- it("should append update to PROJECT_MEMORY.md if it exists", () => {
200
- fs.mkdirSync(MEMORY_DIR, { recursive: true });
201
- fs.writeFileSync(MEMORY_FILE, "## CURRENT STATUS\n", "utf8");
202
- const args: ToolArgs = {
203
- path: TEST_FILE,
204
- content: "hello world"
205
- };
206
- handleWriteFile(TEST_DIR, args);
207
- const memoryContent = fs.readFileSync(MEMORY_FILE, "utf8");
208
- expect(memoryContent).toContain("Auto-Update");
209
- expect(memoryContent).toContain("wrote file");
210
- });
211
- });
212
- });