@codemieai/code 0.0.2 → 0.0.4

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 (360) hide show
  1. package/README.md +357 -719
  2. package/bin/codemie-claude.js +145 -0
  3. package/bin/codemie-code.js +128 -15
  4. package/bin/codemie-codex.js +137 -0
  5. package/bin/codemie.js +1 -1
  6. package/dist/agents/adapters/claude-code.d.ts +7 -2
  7. package/dist/agents/adapters/claude-code.d.ts.map +1 -1
  8. package/dist/agents/adapters/claude-code.js +94 -58
  9. package/dist/agents/adapters/claude-code.js.map +1 -1
  10. package/dist/agents/adapters/codemie-code.d.ts +11 -2
  11. package/dist/agents/adapters/codemie-code.d.ts.map +1 -1
  12. package/dist/agents/adapters/codemie-code.js +93 -25
  13. package/dist/agents/adapters/codemie-code.js.map +1 -1
  14. package/dist/agents/adapters/codex.d.ts +7 -2
  15. package/dist/agents/adapters/codex.d.ts.map +1 -1
  16. package/dist/agents/adapters/codex.js +104 -39
  17. package/dist/agents/adapters/codex.js.map +1 -1
  18. package/dist/agents/codemie-code/agent.d.ts +89 -0
  19. package/dist/agents/codemie-code/agent.d.ts.map +1 -0
  20. package/dist/agents/codemie-code/agent.js +689 -0
  21. package/dist/agents/codemie-code/agent.js.map +1 -0
  22. package/dist/agents/codemie-code/config.d.ts +40 -0
  23. package/dist/agents/codemie-code/config.d.ts.map +1 -0
  24. package/dist/agents/codemie-code/config.js +278 -0
  25. package/dist/agents/codemie-code/config.js.map +1 -0
  26. package/dist/agents/codemie-code/filters.d.ts +91 -0
  27. package/dist/agents/codemie-code/filters.d.ts.map +1 -0
  28. package/dist/agents/codemie-code/filters.js +328 -0
  29. package/dist/agents/codemie-code/filters.js.map +1 -0
  30. package/dist/agents/codemie-code/index.d.ts +92 -0
  31. package/dist/agents/codemie-code/index.d.ts.map +1 -0
  32. package/dist/agents/codemie-code/index.js +327 -0
  33. package/dist/agents/codemie-code/index.js.map +1 -0
  34. package/dist/agents/codemie-code/modes/contextAwarePlanning.d.ts +87 -0
  35. package/dist/agents/codemie-code/modes/contextAwarePlanning.d.ts.map +1 -0
  36. package/dist/agents/codemie-code/modes/contextAwarePlanning.js +957 -0
  37. package/dist/agents/codemie-code/modes/contextAwarePlanning.js.map +1 -0
  38. package/dist/agents/codemie-code/modes/planMode.d.ts +116 -0
  39. package/dist/agents/codemie-code/modes/planMode.d.ts.map +1 -0
  40. package/dist/agents/codemie-code/modes/planMode.js +537 -0
  41. package/dist/agents/codemie-code/modes/planMode.js.map +1 -0
  42. package/dist/agents/codemie-code/prompts.d.ts +40 -0
  43. package/dist/agents/codemie-code/prompts.d.ts.map +1 -0
  44. package/dist/agents/codemie-code/prompts.js +160 -0
  45. package/dist/agents/codemie-code/prompts.js.map +1 -0
  46. package/dist/agents/codemie-code/storage/todoStorage.d.ts +78 -0
  47. package/dist/agents/codemie-code/storage/todoStorage.d.ts.map +1 -0
  48. package/dist/agents/codemie-code/storage/todoStorage.js +225 -0
  49. package/dist/agents/codemie-code/storage/todoStorage.js.map +1 -0
  50. package/dist/agents/codemie-code/tokenUtils.d.ts +108 -0
  51. package/dist/agents/codemie-code/tokenUtils.d.ts.map +1 -0
  52. package/dist/agents/codemie-code/tokenUtils.js +220 -0
  53. package/dist/agents/codemie-code/tokenUtils.js.map +1 -0
  54. package/dist/agents/codemie-code/toolMetadata.d.ts +15 -0
  55. package/dist/agents/codemie-code/toolMetadata.d.ts.map +1 -0
  56. package/dist/agents/codemie-code/toolMetadata.js +315 -0
  57. package/dist/agents/codemie-code/toolMetadata.js.map +1 -0
  58. package/dist/agents/codemie-code/tools/index.d.ts +45 -0
  59. package/dist/agents/codemie-code/tools/index.d.ts.map +1 -0
  60. package/dist/agents/codemie-code/tools/index.js +407 -0
  61. package/dist/agents/codemie-code/tools/index.js.map +1 -0
  62. package/dist/agents/codemie-code/tools/planning.d.ts +53 -0
  63. package/dist/agents/codemie-code/tools/planning.d.ts.map +1 -0
  64. package/dist/agents/codemie-code/tools/planning.js +224 -0
  65. package/dist/agents/codemie-code/tools/planning.js.map +1 -0
  66. package/dist/agents/codemie-code/types.d.ts +418 -0
  67. package/dist/agents/codemie-code/types.d.ts.map +1 -0
  68. package/dist/agents/codemie-code/types.js +35 -0
  69. package/dist/agents/codemie-code/types.js.map +1 -0
  70. package/dist/agents/codemie-code/ui/progressTracker.d.ts +125 -0
  71. package/dist/agents/codemie-code/ui/progressTracker.d.ts.map +1 -0
  72. package/dist/agents/codemie-code/ui/progressTracker.js +343 -0
  73. package/dist/agents/codemie-code/ui/progressTracker.js.map +1 -0
  74. package/dist/agents/codemie-code/ui/todoPanel.d.ts +112 -0
  75. package/dist/agents/codemie-code/ui/todoPanel.d.ts.map +1 -0
  76. package/dist/agents/codemie-code/ui/todoPanel.js +318 -0
  77. package/dist/agents/codemie-code/ui/todoPanel.js.map +1 -0
  78. package/dist/agents/codemie-code/ui.d.ts +179 -0
  79. package/dist/agents/codemie-code/ui.d.ts.map +1 -0
  80. package/dist/agents/codemie-code/ui.js +1408 -0
  81. package/dist/agents/codemie-code/ui.js.map +1 -0
  82. package/dist/agents/codemie-code/utils/progressionEnforcer.d.ts +87 -0
  83. package/dist/agents/codemie-code/utils/progressionEnforcer.d.ts.map +1 -0
  84. package/dist/agents/codemie-code/utils/progressionEnforcer.js +293 -0
  85. package/dist/agents/codemie-code/utils/progressionEnforcer.js.map +1 -0
  86. package/dist/agents/codemie-code/utils/todoParser.d.ts +41 -0
  87. package/dist/agents/codemie-code/utils/todoParser.d.ts.map +1 -0
  88. package/dist/agents/codemie-code/utils/todoParser.js +305 -0
  89. package/dist/agents/codemie-code/utils/todoParser.js.map +1 -0
  90. package/dist/agents/codemie-code/utils/todoValidator.d.ts +65 -0
  91. package/dist/agents/codemie-code/utils/todoValidator.d.ts.map +1 -0
  92. package/dist/agents/codemie-code/utils/todoValidator.js +249 -0
  93. package/dist/agents/codemie-code/utils/todoValidator.js.map +1 -0
  94. package/dist/agents/codemie-code/validators/planValidator.d.ts +94 -0
  95. package/dist/agents/codemie-code/validators/planValidator.d.ts.map +1 -0
  96. package/dist/agents/codemie-code/validators/planValidator.js +281 -0
  97. package/dist/agents/codemie-code/validators/planValidator.js.map +1 -0
  98. package/dist/agents/registry.d.ts +1 -1
  99. package/dist/agents/registry.d.ts.map +1 -1
  100. package/dist/agents/registry.js +11 -15
  101. package/dist/agents/registry.js.map +1 -1
  102. package/dist/cli/commands/auth.d.ts +3 -0
  103. package/dist/cli/commands/auth.d.ts.map +1 -0
  104. package/dist/cli/commands/auth.js +170 -0
  105. package/dist/cli/commands/auth.js.map +1 -0
  106. package/dist/cli/commands/config.d.ts +3 -0
  107. package/dist/cli/commands/config.d.ts.map +1 -0
  108. package/dist/cli/commands/config.js +350 -0
  109. package/dist/cli/commands/config.js.map +1 -0
  110. package/dist/cli/commands/doctor.d.ts.map +1 -1
  111. package/dist/cli/commands/doctor.js +308 -71
  112. package/dist/cli/commands/doctor.js.map +1 -1
  113. package/dist/cli/commands/env.d.ts +3 -0
  114. package/dist/cli/commands/env.d.ts.map +1 -0
  115. package/dist/cli/commands/env.js +19 -0
  116. package/dist/cli/commands/env.js.map +1 -0
  117. package/dist/cli/commands/install.d.ts.map +1 -1
  118. package/dist/cli/commands/install.js +28 -33
  119. package/dist/cli/commands/install.js.map +1 -1
  120. package/dist/cli/commands/list.js +18 -24
  121. package/dist/cli/commands/list.js.map +1 -1
  122. package/dist/cli/commands/run.d.ts.map +1 -1
  123. package/dist/cli/commands/run.js +297 -31
  124. package/dist/cli/commands/run.js.map +1 -1
  125. package/dist/cli/commands/setup.d.ts +3 -0
  126. package/dist/cli/commands/setup.d.ts.map +1 -0
  127. package/dist/cli/commands/setup.js +523 -0
  128. package/dist/cli/commands/setup.js.map +1 -0
  129. package/dist/cli/commands/tools.d.ts +6 -0
  130. package/dist/cli/commands/tools.d.ts.map +1 -0
  131. package/dist/cli/commands/tools.js +244 -0
  132. package/dist/cli/commands/tools.js.map +1 -0
  133. package/dist/cli/commands/uninstall.js +24 -30
  134. package/dist/cli/commands/uninstall.js.map +1 -1
  135. package/dist/cli/commands/version.d.ts.map +1 -1
  136. package/dist/cli/commands/version.js +11 -16
  137. package/dist/cli/commands/version.js.map +1 -1
  138. package/dist/cli/commands/workflow.d.ts +6 -0
  139. package/dist/cli/commands/workflow.d.ts.map +1 -0
  140. package/dist/cli/commands/workflow.js +424 -0
  141. package/dist/cli/commands/workflow.js.map +1 -0
  142. package/dist/cli/index.js +85 -35
  143. package/dist/cli/index.js.map +1 -1
  144. package/dist/clients/adapters/github.d.ts +17 -0
  145. package/dist/clients/adapters/github.d.ts.map +1 -0
  146. package/dist/clients/adapters/github.js +150 -0
  147. package/dist/clients/adapters/github.js.map +1 -0
  148. package/dist/clients/adapters/gitlab.d.ts +17 -0
  149. package/dist/clients/adapters/gitlab.d.ts.map +1 -0
  150. package/dist/clients/adapters/gitlab.js +147 -0
  151. package/dist/clients/adapters/gitlab.js.map +1 -0
  152. package/dist/clients/registry.d.ts +20 -0
  153. package/dist/clients/registry.d.ts.map +1 -0
  154. package/dist/clients/registry.js +27 -0
  155. package/dist/clients/registry.js.map +1 -0
  156. package/dist/env/manager.js +9 -46
  157. package/dist/env/manager.js.map +1 -1
  158. package/dist/index.d.ts +6 -13
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +6 -43
  161. package/dist/index.js.map +1 -1
  162. package/dist/tools/detector.d.ts +33 -0
  163. package/dist/tools/detector.d.ts.map +1 -0
  164. package/dist/tools/detector.js +145 -0
  165. package/dist/tools/detector.js.map +1 -0
  166. package/dist/tools/index.d.ts +8 -0
  167. package/dist/tools/index.d.ts.map +1 -0
  168. package/dist/tools/index.js +8 -0
  169. package/dist/tools/index.js.map +1 -0
  170. package/dist/tools/manager.d.ts +21 -0
  171. package/dist/tools/manager.d.ts.map +1 -0
  172. package/dist/tools/manager.js +104 -0
  173. package/dist/tools/manager.js.map +1 -0
  174. package/dist/tools/registry.d.ts +8 -0
  175. package/dist/tools/registry.d.ts.map +1 -0
  176. package/dist/tools/registry.js +36 -0
  177. package/dist/tools/registry.js.map +1 -0
  178. package/dist/tools/types.d.ts +41 -0
  179. package/dist/tools/types.d.ts.map +1 -0
  180. package/dist/tools/types.js +5 -0
  181. package/dist/tools/types.js.map +1 -0
  182. package/dist/types/sso.d.ts +42 -0
  183. package/dist/types/sso.d.ts.map +1 -0
  184. package/dist/types/sso.js +2 -0
  185. package/dist/types/sso.js.map +1 -0
  186. package/dist/utils/agent-compatibility.d.ts +32 -0
  187. package/dist/utils/agent-compatibility.d.ts.map +1 -0
  188. package/dist/utils/agent-compatibility.js +140 -0
  189. package/dist/utils/agent-compatibility.js.map +1 -0
  190. package/dist/utils/async-tips.d.ts.map +1 -1
  191. package/dist/utils/async-tips.js +16 -55
  192. package/dist/utils/async-tips.js.map +1 -1
  193. package/dist/utils/clipboard.d.ts +16 -0
  194. package/dist/utils/clipboard.d.ts.map +1 -0
  195. package/dist/utils/clipboard.js +179 -0
  196. package/dist/utils/clipboard.js.map +1 -0
  197. package/dist/utils/codemie-integration-validator.d.ts +17 -0
  198. package/dist/utils/codemie-integration-validator.d.ts.map +1 -0
  199. package/dist/utils/codemie-integration-validator.js +105 -0
  200. package/dist/utils/codemie-integration-validator.js.map +1 -0
  201. package/dist/utils/codemie-model-fetcher.d.ts +11 -0
  202. package/dist/utils/codemie-model-fetcher.d.ts.map +1 -0
  203. package/dist/utils/codemie-model-fetcher.js +242 -0
  204. package/dist/utils/codemie-model-fetcher.js.map +1 -0
  205. package/dist/utils/config-loader.d.ts +118 -0
  206. package/dist/utils/config-loader.d.ts.map +1 -0
  207. package/dist/utils/config-loader.js +397 -0
  208. package/dist/utils/config-loader.js.map +1 -0
  209. package/dist/utils/credential-store.d.ts +16 -0
  210. package/dist/utils/credential-store.d.ts.map +1 -0
  211. package/dist/utils/credential-store.js +109 -0
  212. package/dist/utils/credential-store.js.map +1 -0
  213. package/dist/utils/dirname.d.ts +7 -0
  214. package/dist/utils/dirname.d.ts.map +1 -0
  215. package/dist/utils/dirname.js +11 -0
  216. package/dist/utils/dirname.js.map +1 -0
  217. package/dist/utils/errors.js +7 -17
  218. package/dist/utils/errors.js.map +1 -1
  219. package/dist/utils/exec.js +3 -6
  220. package/dist/utils/exec.js.map +1 -1
  221. package/dist/utils/first-time.d.ts +34 -0
  222. package/dist/utils/first-time.d.ts.map +1 -0
  223. package/dist/utils/first-time.js +226 -0
  224. package/dist/utils/first-time.js.map +1 -0
  225. package/dist/utils/health-checker.d.ts +20 -0
  226. package/dist/utils/health-checker.d.ts.map +1 -0
  227. package/dist/utils/health-checker.js +172 -0
  228. package/dist/utils/health-checker.js.map +1 -0
  229. package/dist/utils/logger.js +12 -18
  230. package/dist/utils/logger.js.map +1 -1
  231. package/dist/utils/model-fetcher.d.ts +21 -0
  232. package/dist/utils/model-fetcher.d.ts.map +1 -0
  233. package/dist/utils/model-fetcher.js +150 -0
  234. package/dist/utils/model-fetcher.js.map +1 -0
  235. package/dist/utils/sso-auth.d.ts +15 -0
  236. package/dist/utils/sso-auth.d.ts.map +1 -0
  237. package/dist/utils/sso-auth.js +207 -0
  238. package/dist/utils/sso-auth.js.map +1 -0
  239. package/dist/utils/sso-gateway.d.ts +47 -0
  240. package/dist/utils/sso-gateway.d.ts.map +1 -0
  241. package/dist/utils/sso-gateway.js +298 -0
  242. package/dist/utils/sso-gateway.js.map +1 -0
  243. package/dist/utils/tips.d.ts.map +1 -1
  244. package/dist/utils/tips.js +13 -52
  245. package/dist/utils/tips.js.map +1 -1
  246. package/dist/workflows/detector.d.ts +37 -0
  247. package/dist/workflows/detector.d.ts.map +1 -0
  248. package/dist/workflows/detector.js +160 -0
  249. package/dist/workflows/detector.js.map +1 -0
  250. package/dist/workflows/index.d.ts +8 -0
  251. package/dist/workflows/index.d.ts.map +1 -0
  252. package/dist/workflows/index.js +8 -0
  253. package/dist/workflows/index.js.map +1 -0
  254. package/dist/workflows/installer.d.ts +24 -0
  255. package/dist/workflows/installer.d.ts.map +1 -0
  256. package/dist/workflows/installer.js +105 -0
  257. package/dist/workflows/installer.js.map +1 -0
  258. package/dist/workflows/registry.d.ts +29 -0
  259. package/dist/workflows/registry.d.ts.map +1 -0
  260. package/dist/workflows/registry.js +54 -0
  261. package/dist/workflows/registry.js.map +1 -0
  262. package/dist/workflows/templates/github/metadata.d.ts +6 -0
  263. package/dist/workflows/templates/github/metadata.d.ts.map +1 -0
  264. package/dist/workflows/templates/github/metadata.js +111 -0
  265. package/dist/workflows/templates/github/metadata.js.map +1 -0
  266. package/dist/workflows/templates/gitlab/metadata.d.ts +6 -0
  267. package/dist/workflows/templates/gitlab/metadata.d.ts.map +1 -0
  268. package/dist/workflows/templates/gitlab/metadata.js +14 -0
  269. package/dist/workflows/templates/gitlab/metadata.js.map +1 -0
  270. package/dist/workflows/types.d.ts +71 -0
  271. package/dist/workflows/types.d.ts.map +1 -0
  272. package/dist/workflows/types.js +5 -0
  273. package/dist/workflows/types.js.map +1 -0
  274. package/package.json +32 -25
  275. package/src/workflows/templates/github/code-ci.yml +529 -0
  276. package/src/workflows/templates/github/inline-fix.yml +665 -0
  277. package/src/workflows/templates/github/pr-review.yml +677 -0
  278. package/.claude/agents/README.md +0 -298
  279. package/.claude/agents/release-manager.md +0 -857
  280. package/.codemie/guides/git-workflow.md +0 -493
  281. package/CLAUDE.md +0 -855
  282. package/dist/agents/adapters/aider.d.ts +0 -12
  283. package/dist/agents/adapters/aider.d.ts.map +0 -1
  284. package/dist/agents/adapters/aider.js +0 -80
  285. package/dist/agents/adapters/aider.js.map +0 -1
  286. package/dist/cli/cli.d.ts +0 -4
  287. package/dist/cli/cli.d.ts.map +0 -1
  288. package/dist/cli/cli.js +0 -107
  289. package/dist/cli/cli.js.map +0 -1
  290. package/dist/cli/commands/mcp.d.ts +0 -3
  291. package/dist/cli/commands/mcp.d.ts.map +0 -1
  292. package/dist/cli/commands/mcp.js +0 -459
  293. package/dist/cli/commands/mcp.js.map +0 -1
  294. package/dist/code/agent-events.d.ts +0 -39
  295. package/dist/code/agent-events.d.ts.map +0 -1
  296. package/dist/code/agent-events.js +0 -4
  297. package/dist/code/agent-events.js.map +0 -1
  298. package/dist/code/agent.d.ts +0 -19
  299. package/dist/code/agent.d.ts.map +0 -1
  300. package/dist/code/agent.js +0 -144
  301. package/dist/code/agent.js.map +0 -1
  302. package/dist/code/config.d.ts +0 -13
  303. package/dist/code/config.d.ts.map +0 -1
  304. package/dist/code/config.js +0 -41
  305. package/dist/code/config.js.map +0 -1
  306. package/dist/code/index.d.ts +0 -19
  307. package/dist/code/index.d.ts.map +0 -1
  308. package/dist/code/index.js +0 -400
  309. package/dist/code/index.js.map +0 -1
  310. package/dist/code/prompts.d.ts +0 -2
  311. package/dist/code/prompts.d.ts.map +0 -1
  312. package/dist/code/prompts.js +0 -45
  313. package/dist/code/prompts.js.map +0 -1
  314. package/dist/code/tools/command.d.ts +0 -8
  315. package/dist/code/tools/command.d.ts.map +0 -1
  316. package/dist/code/tools/command.js +0 -83
  317. package/dist/code/tools/command.js.map +0 -1
  318. package/dist/code/tools/diff-utils.d.ts +0 -2
  319. package/dist/code/tools/diff-utils.d.ts.map +0 -1
  320. package/dist/code/tools/diff-utils.js +0 -45
  321. package/dist/code/tools/diff-utils.js.map +0 -1
  322. package/dist/code/tools/filesystem.d.ts +0 -11
  323. package/dist/code/tools/filesystem.d.ts.map +0 -1
  324. package/dist/code/tools/filesystem.js +0 -442
  325. package/dist/code/tools/filesystem.js.map +0 -1
  326. package/dist/code/tools/git.d.ts +0 -7
  327. package/dist/code/tools/git.d.ts.map +0 -1
  328. package/dist/code/tools/git.js +0 -111
  329. package/dist/code/tools/git.js.map +0 -1
  330. package/dist/code/tools/mcp.d.ts +0 -13
  331. package/dist/code/tools/mcp.d.ts.map +0 -1
  332. package/dist/code/tools/mcp.js +0 -230
  333. package/dist/code/tools/mcp.js.map +0 -1
  334. package/dist/data/tips.json +0 -118
  335. package/dist/ui/terminal-ui.d.ts +0 -73
  336. package/dist/ui/terminal-ui.d.ts.map +0 -1
  337. package/dist/ui/terminal-ui.js +0 -900
  338. package/dist/ui/terminal-ui.js.map +0 -1
  339. package/dist/utils/env-mapper.d.ts +0 -40
  340. package/dist/utils/env-mapper.d.ts.map +0 -1
  341. package/dist/utils/env-mapper.js +0 -122
  342. package/dist/utils/env-mapper.js.map +0 -1
  343. package/docs/USER_GUIDE.md +0 -573
  344. package/eslint.config.mjs +0 -43
  345. package/tests/agent-direct.test.mjs +0 -45
  346. package/tests/agent-output.test.mjs +0 -64
  347. package/tests/codemie-code.test.mjs +0 -42
  348. package/tests/context7-only.test.mjs +0 -42
  349. package/tests/conversation-flow.test.mjs +0 -63
  350. package/tests/interactive-simulation.test.mjs +0 -60
  351. package/tests/live-output.test.mjs +0 -53
  352. package/tests/mcp-context7.test.mjs +0 -105
  353. package/tests/mcp-e2e.test.mjs +0 -109
  354. package/tests/mcp-time-server.test.mjs +0 -58
  355. package/tests/streaming.test.mjs +0 -57
  356. package/tests/test-helpers.mjs +0 -94
  357. package/tests/text-wrapping.test.mjs +0 -33
  358. package/tests/tool-count.test.mjs +0 -81
  359. package/tests/ui-format.test.mjs +0 -39
  360. package/tests/ui-state.test.mjs +0 -72
package/CLAUDE.md DELETED
@@ -1,855 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Critical First Step: ALWAYS Read Documentation
6
-
7
- **MANDATORY**: Before writing ANY code, you MUST:
8
- 1. Read the `README.md` file - this is your PRIMARY source of truth
9
- 2. Review this CLAUDE.md for architectural patterns and conventions
10
- 3. Study reference implementations mentioned in this guide
11
-
12
- ## Common Commands
13
-
14
- ```bash
15
- # Installation & Setup
16
- npm install # Install dependencies
17
- npm link # Link globally for local testing
18
-
19
- # Building
20
- npm run build # Compile TypeScript and copy assets (to dist/)
21
- npm run dev # Watch mode for development
22
-
23
- # Testing
24
- npm test # Run all tests (Node.js native test runner)
25
- npm run test:watch # Run tests in watch mode
26
-
27
- # Run individual test files
28
- node --test tests/agent-direct.test.mjs
29
- node --test tests/streaming.test.mjs
30
-
31
- # Code Quality
32
- npm run lint # Check code style with ESLint
33
- npm run lint:fix # Fix linting issues automatically
34
-
35
- # Development Workflow
36
- npm run build && npm link # Build and link for testing
37
- codemie doctor # Verify installation and configuration
38
-
39
- # Release & Publishing
40
- git tag -a v0.0.1 -m "Release version 0.0.1" # Create release tag
41
- git push origin v0.0.1 # Push tag to trigger publish
42
- ```
43
-
44
- ## Core Principles
45
-
46
- **ALWAYS follow these fundamental principles:**
47
-
48
- ### KISS (Keep It Simple, Stupid)
49
- - Write simple, straightforward code that's easy to understand
50
- - Avoid over-engineering and unnecessary complexity
51
- - Remove redundant code, scripts, and configuration
52
- - If something can be done in fewer lines/steps, do it
53
- - Question every piece of complexity - is it truly needed?
54
-
55
- ### DRY (Don't Repeat Yourself)
56
- - Never duplicate code, logic, or configuration
57
- - Extract common patterns into reusable functions/utilities
58
- - Reuse existing utilities from `src/utils/` before creating new ones
59
- - If you find yourself copying code, refactor it into a shared function
60
- - One source of truth for each piece of knowledge
61
-
62
- **Remember:** Simple, clean code is better than clever, complex code.
63
-
64
- ## Specialized Agents
65
-
66
- This project uses specialized subagents for complex, multi-step workflows. These agents have dedicated system prompts stored in `.claude/agents/` that can be updated independently.
67
-
68
- ### Release Manager Agent
69
-
70
- **Location:** `.claude/agents/release-manager.md`
71
-
72
- **Purpose:** Automate the complete release process from change analysis to npm publication.
73
-
74
- **Trigger Phrases:**
75
- - "Release version X.X.X"
76
- - "Create a new release"
77
- - "Release a patch/minor/major version"
78
- - "Use release manager to..."
79
- - "Prepare a release"
80
-
81
- **What it does:**
82
- 1. Runs pre-flight checks (clean working directory, correct branch)
83
- 2. Analyzes git history since last release tag
84
- 3. Categorizes commits using conventional commits
85
- 4. Generates structured release notes (Keep a Changelog format)
86
- 5. Updates package.json and package-lock.json version
87
- 6. Creates git commit for version bump
88
- 7. Creates and pushes annotated git tag
89
- 8. Creates GitHub release with generated notes
90
- 9. Triggers npm publish workflow via GitHub Actions
91
- 10. Reports completion status and provides verification links
92
-
93
- **Example Usage:**
94
- ```
95
- You: "Release version 0.0.2"
96
-
97
- Claude:
98
- 1. Checks git status and current branch
99
- 2. Analyzes 12 commits since v0.0.1
100
- 3. Generates release notes with categorized changes
101
- 4. Shows preview and asks for confirmation
102
- 5. Updates package.json to 0.0.2
103
- 6. Creates commit "chore: bump version to 0.0.2"
104
- 7. Creates tag v0.0.2 and pushes
105
- 8. Creates GitHub Release
106
- 9. Reports: "✅ Released v0.0.2, npm publish workflow triggered"
107
- ```
108
-
109
- **Customization:**
110
- Edit `.claude/agents/release-manager.md` to modify:
111
- - Release notes format
112
- - Commit categorization rules
113
- - Version bump strategies
114
- - Error handling behavior
115
- - Pre-flight check requirements
116
-
117
- ### Creating Additional Agents
118
-
119
- To create your own specialized agent:
120
-
121
- 1. **Create the agent file**: `.claude/agents/{role}-{function}.md`
122
- - Example: `code-reviewer.md`, `test-generator.md`, `security-auditor.md`
123
-
124
- 2. **Define the system prompt**: Include role, capabilities, workflow, error handling, and examples
125
-
126
- 3. **Document trigger phrases**: Add them to this CLAUDE.md section
127
-
128
- 4. **Update agents README**: Add documentation to `.claude/agents/README.md`
129
-
130
- **Naming convention:** `{role}-{function}.md`
131
- - ✅ `release-manager.md`, `code-reviewer.md`, `test-generator.md`
132
- - ❌ `release.md`, `agent1.md`, `helper.md`
133
-
134
- **See:** `.claude/agents/README.md` for detailed agent creation guide and best practices.
135
-
136
- ## Critical Policies
137
-
138
- ### Testing & Documentation Policy
139
-
140
- **IMPORTANT - Do NOT write tests, documentation, or summaries unless explicitly requested:**
141
- - Do NOT write tests unless user explicitly says: "Write tests", "Create unit tests", etc.
142
- - Do NOT run tests unless user explicitly says: "Run the tests", "Execute test suite", etc.
143
- - Do NOT generate documentation unless user explicitly says: "Write documentation", "Create docs", etc.
144
- - Do NOT write summaries unless user explicitly says: "Summarize", "Write a summary", etc.
145
- - Do NOT run compilation checks unless explicitly requested
146
- - Do NOT proactively create README files or documentation files
147
-
148
- ### Node Modules Policy
149
-
150
- **IMPORTANT:**
151
- - NEVER modify files inside `node_modules/`
152
- - All source code lives in `src/`
153
- - All tests live in `tests/`
154
- - Build output goes to `dist/`
155
-
156
- ### Utilities Policy
157
-
158
- **Before implementing new utility functions:**
159
- 1. Check if similar functionality exists in `src/utils/` directory
160
- 2. Always reuse existing utilities (logger, exec, errors, tips, etc.)
161
- 3. If implementing new shared utilities, get user approval first
162
-
163
- ### Git Workflow Policy
164
-
165
- **CRITICAL - Read the complete Git Workflow Policy:**
166
-
167
- 📖 **See:** `.codemie/guides/git-workflow.md` for comprehensive git workflow guidelines
168
-
169
- **Key Requirements:**
170
- - ❌ **NEVER commit directly to `main` branch**
171
- - ✅ **ALWAYS create a feature branch** for any changes
172
- - ✅ **ALL changes go through Pull Request review**
173
- - ✅ Use conventional commit format: `type: description`
174
- - ✅ Follow branch naming: `feature/`, `fix/`, `docs/`, `refactor/`, `chore/`
175
-
176
- **Quick Reference:**
177
- ```bash
178
- # Standard workflow
179
- git checkout main && git pull origin main
180
- git checkout -b feature/your-feature-name
181
- # Make changes...
182
- git add .
183
- git commit -m "feat: add something" -m "Co-authored-by: CodeMie AI <codemie.ai@gmail.com>"
184
- git push -u origin feature/your-feature-name
185
- # Create PR via GitHub UI or: gh pr create
186
- ```
187
-
188
- **Important:** Always add CodeMie AI co-author to commits for proper attribution
189
-
190
- For detailed information on:
191
- - Branch naming conventions
192
- - Commit message guidelines
193
- - PR creation and review process
194
- - Merge conflict resolution
195
- - Emergency hotfixes
196
- - Git commands reference
197
-
198
- 👉 **Read:** `.codemie/guides/git-workflow.md`
199
-
200
- ### Release & Publishing Policy
201
-
202
- **IMPORTANT - How to publish to npm registry:**
203
-
204
- The project uses GitHub Actions to automatically publish to npm when a release is created. The workflow is defined in `.github/workflows/publish.yml`.
205
-
206
- **Step-by-step release process:**
207
-
208
- 1. **Ensure you're on the main branch** (after merging your feature branch):
209
- ```bash
210
- git checkout main
211
- git pull origin main
212
- ```
213
-
214
- 2. **Create an annotated git tag** with the version number:
215
- ```bash
216
- # Match the version in package.json (e.g., 0.0.1)
217
- git tag -a v0.0.1 -m "Release version 0.0.1"
218
- ```
219
-
220
- 3. **Push the tag to GitHub**:
221
- ```bash
222
- git push origin v0.0.1
223
- ```
224
-
225
- 4. **Create a GitHub Release** (two options):
226
-
227
- **Option A - GitHub UI (recommended):**
228
- - Go to GitHub repository → Releases → "Draft a new release"
229
- - Select the tag you just pushed (`v0.0.1`)
230
- - Add release title (e.g., `v0.0.1` or `Release 0.0.1`)
231
- - Add release notes describing changes
232
- - Click "Publish release"
233
-
234
- **Option B - Manual workflow trigger:**
235
- - Go to Actions → "Publish to NPM" workflow
236
- - Click "Run workflow"
237
- - Select the `main` branch
238
- - Click "Run workflow"
239
-
240
- 5. **The workflow will automatically**:
241
- - Checkout code
242
- - Install dependencies
243
- - Run CI checks (`npm run ci` - includes lint, build, and tests)
244
- - Publish to npm with `npm publish --access public`
245
- - Authenticate using the `NPM_TOKEN` secret
246
-
247
- **Prerequisites:**
248
- - `NPM_TOKEN` must be configured in GitHub repository secrets
249
- - Version in `package.json` must match the tag version (without the `v` prefix)
250
- - All CI checks must pass (linting, build, tests)
251
-
252
- **Version bumping:**
253
- ```bash
254
- # Update version in package.json
255
- npm version patch # 0.0.1 → 0.0.2
256
- npm version minor # 0.0.1 → 0.1.0
257
- npm version major # 0.0.1 → 1.0.0
258
-
259
- # This creates a commit and tag automatically
260
- # Then push both:
261
- git push origin main --tags
262
- ```
263
-
264
- **Verifying the publish:**
265
- ```bash
266
- # Check on npm registry
267
- npm view @codemieai/code
268
-
269
- # Install and test locally
270
- npm install -g @codemieai/code@latest
271
- codemie doctor
272
- ```
273
-
274
- ## Reference Implementations
275
-
276
- Study these excellent examples before implementing new code:
277
- - **AI Assistant** (`src/code/`) - Complete ReAct agent implementation with streaming
278
- - **Tool System** (`src/code/tools/`) - Filesystem, Git, Command, and MCP tools
279
- - **UI Layer** (`src/ui/terminal-ui.ts`) - Interactive terminal with cancellation support
280
- - **Agent System** (`src/agents/`) - Agent registry and adapters pattern
281
-
282
- ## Communication Style
283
-
284
- When responding:
285
- 1. Confirm your understanding of the request
286
- 2. Reference which patterns you're following from existing code
287
- 3. Outline your implementation approach
288
- 4. Present complete, working code
289
- 5. Explain key design decisions
290
- 6. Highlight any assumptions requiring user input
291
-
292
- ## Self-Verification Before Delivery
293
-
294
- - [ ] README.md and CLAUDE.md have been read and understood
295
- - [ ] Reference implementations reviewed for similar patterns
296
- - [ ] Code follows TypeScript best practices and project conventions
297
- - [ ] No tests written (unless explicitly requested)
298
- - [ ] No tests executed (unless explicitly requested)
299
- - [ ] Code is production-ready and follows DRY/KISS principles
300
-
301
- ## Escalation Scenarios
302
-
303
- Seek user guidance when:
304
- - Documentation is missing, unclear, or contradictory
305
- - New dependencies are required
306
- - Breaking changes are necessary
307
- - Multiple valid approaches exist
308
- - Reference implementations don't cover the use case
309
- - Security or architectural concerns arise
310
-
311
- ## Project Overview
312
-
313
- **CodeMie Code** is a unified npm package that provides:
314
- - A built-in AI coding assistant powered by LiteLLM (via LangChain)
315
- - A CLI wrapper for managing multiple AI coding agents (Claude Code, Aider, Codex)
316
-
317
- The project uses TypeScript with a ReAct agent pattern via LangGraph for autonomous tool execution.
318
-
319
- ## Quick Architecture Overview
320
-
321
- ### Core Components
322
-
323
- - **AI Assistant** (`src/code/`): Main assistant class, agent, configuration, prompts
324
- - **Tool System** (`src/code/tools/`): Filesystem, Git, Command execution, MCP integration
325
- - **CLI Wrapper** (`src/cli/commands/`): Commands for managing external agents
326
- - **Agent System** (`src/agents/`): Registry and adapters for different AI agents
327
- - **UI Layer** (`src/ui/`): Interactive terminal with streaming and cancellation
328
- - **Environment** (`src/env/`, `src/utils/`): Config management and utilities
329
-
330
- ### Entry Points
331
- - `bin/codemie-code.js` - Starts the AI assistant
332
- - `bin/codemie.js` - CLI wrapper for agent management
333
-
334
- ### Key Design Patterns
335
-
336
- #### ReAct Agent Pattern
337
- Uses LangGraph's `createReactAgent`:
338
- 1. **Reasoning** - LLM thinks about what to do
339
- 2. **Acting** - Calls tools based on reasoning
340
- 3. **Observing** - Receives tool results
341
- 4. Loops until task is complete
342
-
343
- #### Streaming Architecture
344
- Agent supports streaming via `chatStream()`:
345
- - `thinking_start/end` - Agent is reasoning
346
- - `tool_call_start` - Tool invocation begins
347
- - `tool_call_result` - Tool returns result
348
- - `content_chunk` - Partial response content
349
- - `complete/cancelled/error` - Terminal states
350
-
351
- #### Security Model
352
- All filesystem/command operations validate:
353
- - Paths must be within `allowedDirectories`
354
- - Symlinks are resolved and validated
355
- - Dangerous command patterns are blocked
356
- - Ignore patterns exclude sensitive dirs
357
-
358
- ## Project Structure
359
-
360
- ```
361
- codemie-code/
362
- ├── bin/
363
- │ ├── codemie-code.js # AI assistant entry point
364
- │ └── codemie.js # CLI wrapper entry point
365
-
366
- ├── src/
367
- │ ├── code/ # CodeMie Code Assistant
368
- │ │ ├── index.ts # Main assistant class
369
- │ │ ├── agent.ts # LangChain ReAct agent
370
- │ │ ├── agent-events.ts # Event system for streaming
371
- │ │ ├── config.ts # Configuration loader
372
- │ │ ├── prompts.ts # System prompts
373
- │ │ └── tools/ # Tool implementations
374
- │ │ ├── filesystem.ts # 8 filesystem tools
375
- │ │ ├── git.ts # 4 git tools
376
- │ │ ├── command.ts # Command execution
377
- │ │ ├── mcp.ts # MCP integration
378
- │ │ └── diff-utils.ts # Diff utilities
379
- │ │
380
- │ ├── cli/ # CLI Wrapper
381
- │ │ └── commands/ # CLI commands
382
- │ │ ├── list.ts
383
- │ │ ├── install.ts
384
- │ │ ├── run.ts
385
- │ │ ├── doctor.ts
386
- │ │ ├── uninstall.ts
387
- │ │ └── version.ts
388
- │ │
389
- │ ├── agents/ # Agent System
390
- │ │ ├── registry.ts # Agent registry
391
- │ │ └── adapters/ # Agent adapters
392
- │ │ ├── codemie-code.ts
393
- │ │ ├── claude-code.ts
394
- │ │ ├── codex.ts
395
- │ │ └── aider.ts
396
- │ │
397
- │ ├── env/ # Environment Management
398
- │ │ └── manager.ts
399
- │ │
400
- │ ├── ui/ # UI Layer
401
- │ │ └── terminal-ui.ts # Interactive terminal
402
- │ │
403
- │ └── utils/ # Utilities
404
- │ ├── env-mapper.ts # Environment variable mapping
405
- │ ├── exec.ts # Process execution
406
- │ ├── logger.ts # Logging
407
- │ ├── errors.ts # Error classes
408
- │ └── tips.ts # Loading tips
409
-
410
- ├── tests/ # Test files
411
- │ ├── test-*.js # Manual integration tests
412
- │ └── integration/ # Additional test scenarios
413
-
414
- ├── dist/ # Build output (TypeScript compilation)
415
- ├── mcp/ # MCP server configurations
416
- │ └── servers.json
417
- ├── package.json # Dependencies and scripts
418
- ├── tsconfig.json # TypeScript configuration
419
- ├── eslint.config.mjs # ESLint configuration
420
- └── README.md # Package documentation
421
- ```
422
-
423
- ## Technology Stack
424
-
425
- - **Language**: TypeScript (ES2022, NodeNext modules)
426
- - **Runtime**: Node.js >= 24.0.0 (LTS Krypton)
427
- - **Package Manager**: npm
428
- - **LLM Framework**: LangChain 1.x (`@langchain/core`, `@langchain/langgraph`, `@langchain/openai`)
429
- - **LLM Provider**: LiteLLM (OpenAI-compatible proxy)
430
- - **CLI Framework**: Commander.js
431
- - **Schema Validation**: Zod
432
- - **Diff Generation**: diff package
433
- - **UI**: Chalk, Inquirer, Ora
434
- - **Testing**: Jest with ts-jest
435
- - **Linting**: ESLint with TypeScript support
436
-
437
- ## Configuration & Environment
438
-
439
- ### Environment Variable Priority
440
- The config loader (`src/utils/env-mapper.ts`) checks in order:
441
- 1. `ANTHROPIC_*` - For Claude models
442
- 2. `OPENAI_*` - For GPT models
443
- 3. `AI_*` - Generic provider-agnostic
444
- 4. `LITELLM_*` - Legacy format (still supported)
445
-
446
- ### Required Environment Variables
447
-
448
- ```bash
449
- # Provider-specific (choose one set)
450
-
451
- # For Anthropic Claude models
452
- ANTHROPIC_BASE_URL=https://litellm-proxy.example.com
453
- ANTHROPIC_AUTH_TOKEN=your-token
454
- ANTHROPIC_MODEL=claude-4-5-sonnet
455
-
456
- # OR for OpenAI models
457
- OPENAI_BASE_URL=https://api.openai.com/v1
458
- OPENAI_API_KEY=your-token
459
- OPENAI_MODEL=gpt-4
460
-
461
- # OR generic provider-agnostic
462
- AI_BASE_URL=https://litellm-proxy.example.com
463
- AI_AUTH_TOKEN=your-token
464
- AI_MODEL=claude-4-5-sonnet
465
- ```
466
-
467
- ### Optional Environment Variables
468
-
469
- ```bash
470
- CODEMIE_DEBUG=true # Enable debug logging
471
- CODEMIE_MODEL=claude-opus # Override model
472
- CODEMIE_MCP_SERVERS=filesystem,cli-mcp-server # Load specific MCP servers
473
- AI_TIMEOUT=300 # Request timeout in seconds
474
- ```
475
-
476
- ### MCP Configuration
477
- MCP servers are defined in:
478
- 1. `mcp/servers.json` - Default server configurations
479
- 2. `~/.codemie/config.json` - User-specific MCP config
480
-
481
- MCP integration is handled by `src/code/tools/mcp.ts` which dynamically loads tools from configured servers.
482
-
483
- ## Development Guidelines
484
-
485
- ### File Naming Conventions
486
-
487
- - **Modules**: kebab-case (e.g., `terminal-ui.ts`, `agent-events.ts`)
488
- - **Classes**: PascalCase (e.g., `CodeMieCode`, `CodeMieAgent`)
489
- - **Functions**: camelCase (e.g., `loadConfig`, `getTools`)
490
- - **Constants**: UPPER_SNAKE_CASE (e.g., `SYSTEM_PROMPT`)
491
- - **Tests**: `test-*.js` or `*.test.ts`
492
-
493
- ### Code Style
494
-
495
- - **Formatter**: TypeScript default (2 spaces)
496
- - **Line Length**: No strict limit, but keep reasonable
497
- - **Quotes**: Single quotes preferred
498
- - **Semicolons**: Required
499
- - **Imports**: Organized (standard library, third-party, local)
500
- - **Type Hints**: Use TypeScript types throughout
501
- - **Async/Await**: Preferred over promises/callbacks
502
-
503
- ### Import Organization
504
-
505
- ```typescript
506
- // Third-party imports
507
- import { ChatOpenAI } from '@langchain/openai';
508
- import { StructuredTool } from '@langchain/core/tools';
509
- import chalk from 'chalk';
510
-
511
- // Local imports
512
- import { CodeMieConfig } from './config';
513
- import { logger } from '../utils/logger';
514
- import { FilesystemTools } from './tools/filesystem';
515
- ```
516
-
517
- ## Tool Development
518
-
519
- ### Adding New Filesystem Tools
520
-
521
- Extend `FilesystemTools` class in `src/code/tools/filesystem.ts`:
522
- 1. Create tool using `new StructuredTool()` with Zod schema
523
- 2. Add validation via `validatePath()` or `validateInAllowedDirectory()`
524
- 3. Push to tools array in constructor
525
- 4. Handle errors with try-catch, return error messages
526
-
527
- Example:
528
- ```typescript
529
- const myNewTool = new StructuredTool({
530
- name: "my_new_tool",
531
- description: "Description of what this tool does",
532
- schema: z.object({
533
- path: z.string().describe("File path"),
534
- content: z.string().describe("File content")
535
- }),
536
- func: async ({ path, content }) => {
537
- try {
538
- const fullPath = this.validatePath(path);
539
- // Tool implementation
540
- return "Success message";
541
- } catch (error: any) {
542
- return `Error: ${error.message}`;
543
- }
544
- }
545
- });
546
- ```
547
-
548
- ### Adding New Git Tools
549
-
550
- Extend `GitTools` class in `src/code/tools/git.ts` following the same pattern.
551
-
552
- ### Diff-Based Editing
553
-
554
- The `edit_file` tool uses `diff` package to generate unified diffs:
555
- - Preserves indentation (tabs vs spaces)
556
- - Shows clear before/after changes
557
- - Validates file exists before editing
558
-
559
- ## Agent Adapters
560
-
561
- To add a new agent adapter (e.g., for Cursor or Copilot):
562
-
563
- 1. Create `src/agents/adapters/my-agent.ts` implementing `AgentAdapter` interface
564
- 2. Register in `src/agents/registry.ts`
565
- 3. Implement required methods:
566
- - `install()` - Install the agent
567
- - `uninstall()` - Uninstall the agent
568
- - `isInstalled()` - Check if installed
569
- - `run(args)` - Run the agent
570
- - `getVersion()` - Get version info
571
-
572
- Example:
573
- ```typescript
574
- export class MyAgentAdapter implements AgentAdapter {
575
- name = 'my-agent';
576
- displayName = 'My Agent';
577
- description = 'Description of my agent';
578
-
579
- async install(): Promise<void> { /* ... */ }
580
- async uninstall(): Promise<void> { /* ... */ }
581
- async isInstalled(): Promise<boolean> { /* ... */ }
582
- async run(args: string[]): Promise<void> { /* ... */ }
583
- async getVersion(): Promise<string | null> { /* ... */ }
584
- }
585
- ```
586
-
587
- ## Error Handling
588
-
589
- ### Standard Error Pattern
590
-
591
- ```typescript
592
- try {
593
- // Operation
594
- const result = await performOperation();
595
- return result;
596
- } catch (error: any) {
597
- // Log error for debugging
598
- logger.error('Operation failed:', error);
599
-
600
- // Return user-friendly error message
601
- throw new Error(`Operation failed: ${error.message}`);
602
- }
603
- ```
604
-
605
- ### Custom Error Classes
606
-
607
- Located in `src/utils/errors.ts`:
608
- - `ConfigurationError` - Configuration issues
609
- - Use standard `Error` for most cases
610
-
611
- ## Testing Approach
612
-
613
- ### Test Framework & Structure
614
-
615
- - Uses **Node.js native test runner** (`node:test`)
616
- - All test files are located in `tests/` directory
617
- - Test files use `.mjs` extension (ES modules)
618
- - Tests are built using `describe()`, `it()`, `before()`, and `after()` from `node:test`
619
-
620
- ### Test Categories
621
-
622
- 1. **Agent Tests** - Test LLM agent functionality (requires base URL configuration)
623
- - `agent-direct.test.mjs` - Direct agent tool calling
624
- - `agent-output.test.mjs` - Agent output format
625
- - `streaming.test.mjs` - Streaming functionality
626
- - `conversation-flow.test.mjs` - Multiple question handling
627
-
628
- 2. **Integration Tests** - Test `codemie-code` (AI assistant) (requires base URL configuration)
629
- - `codemie-code.test.mjs` - CodeMieCode tool calling
630
- - `tool-count.test.mjs` - Tool loading verification
631
- - `interactive-simulation.test.mjs` - Interactive conversation simulation
632
- - `ui-state.test.mjs` - UI state management
633
- - `live-output.test.mjs` - Live output format
634
-
635
- 3. **MCP Tests** - Test MCP server integration with AI assistant (requires base URL configuration)
636
- - `mcp-context7.test.mjs` - Context7 MCP server
637
- - `mcp-time-server.test.mjs` - Time MCP server
638
- - `mcp-e2e.test.mjs` - End-to-end MCP integration
639
- - `context7-only.test.mjs` - Context7 server only
640
-
641
- 4. **UI/Format Tests** - Test formatting and UI logic (does NOT require base URL)
642
- - `ui-format.test.mjs` - UI formatting
643
- - `text-wrapping.test.mjs` - Text wrapping logic
644
-
645
- 5. **CLI Wrapper Tests** - Test `codemie` CLI commands (does NOT require base URL)
646
- - Currently no tests exist for CLI commands (`codemie doctor`, `codemie list`, etc.)
647
- - These commands don't interact with LLM, so they don't need base URL configuration
648
-
649
- ### Test Helpers
650
-
651
- The `tests/test-helpers.mjs` file provides utilities for managing test preconditions:
652
-
653
- **Key Functions:**
654
-
655
- ```javascript
656
- // Check if base URL is configured
657
- isBaseUrlConfigured()
658
-
659
- // Skip test if base URL is not configured (with warning)
660
- skipIfNoBaseUrl(testContext, customMessage?)
661
-
662
- // Get list of missing environment variables
663
- getMissingEnvVars()
664
-
665
- // Check if all required environment variables are configured
666
- isFullyConfigured()
667
-
668
- // Print configuration status for debugging
669
- printConfigStatus()
670
- ```
671
-
672
- **Usage Example:**
673
-
674
- ```javascript
675
- import { describe, it, before } from 'node:test';
676
- import { skipIfNoBaseUrl } from './test-helpers.mjs';
677
-
678
- describe('My Test Suite', () => {
679
- before(() => {
680
- if (skipIfNoBaseUrl()) return;
681
- // ... setup code
682
- });
683
-
684
- it('should do something', () => {
685
- if (skipIfNoBaseUrl()) return;
686
- // ... test code
687
- });
688
- });
689
- ```
690
-
691
- ### Environment Variable Requirements
692
-
693
- Tests that interact with LLM agents require one of:
694
- - `CODEMIE_BASE_URL`
695
- - `ANTHROPIC_BASE_URL`
696
- - `OPENAI_BASE_URL`
697
-
698
- If these are not set, tests will be **skipped with a warning** instead of failing.
699
-
700
- ### Running Tests
701
-
702
- ```bash
703
- # Run all tests
704
- npm test
705
-
706
- # Run tests in watch mode
707
- npm run test:watch
708
-
709
- # Run specific test file
710
- node --test tests/agent-direct.test.mjs
711
-
712
- # Run tests without base URL (will skip LLM tests)
713
- unset CODEMIE_BASE_URL ANTHROPIC_BASE_URL OPENAI_BASE_URL
714
- npm test
715
-
716
- # Run tests with debug output
717
- CODEMIE_DEBUG=true npm test
718
- ```
719
-
720
- ### Writing New Tests
721
-
722
- **For tests requiring LLM interaction:**
723
-
724
- 1. Import test helpers: `import { skipIfNoBaseUrl } from './test-helpers.mjs'`
725
- 2. Add skip checks to `before()` hooks: `before(() => { if (skipIfNoBaseUrl()) return; ... })`
726
- 3. Add skip checks to each test: `it('test name', () => { if (skipIfNoBaseUrl()) return; ... })`
727
-
728
- **For tests NOT requiring LLM interaction:**
729
-
730
- 1. No need to import or use test helpers
731
- 2. Tests will run regardless of environment configuration
732
-
733
- ### Test Best Practices
734
-
735
- - **Always build before testing**: Run `npm run build` to ensure dist/ is up to date
736
- - **Use descriptive test names**: Clearly state what is being tested
737
- - **Clean up resources**: Use `after()` hooks to dispose of resources (agents, MCP tools, etc.)
738
- - **Test isolation**: Each test should be independent and not rely on state from other tests
739
- - **Mock external dependencies**: When possible, avoid hitting real external services
740
- - **Handle async properly**: Use `async/await` for asynchronous operations
741
-
742
- ## Debugging
743
-
744
- Enable debug mode to see detailed execution:
745
-
746
- ```bash
747
- export CODEMIE_DEBUG=true
748
- codemie-code
749
- ```
750
-
751
- This shows:
752
- - Tool initialization counts
753
- - LLM request/response details
754
- - File operation details
755
- - Error stack traces
756
-
757
- ## Important Notes
758
-
759
- ### Module System
760
- - Uses ES modules (`"module": "NodeNext"`)
761
- - Import paths use `.js` extensions even for `.ts` files
762
- - Example: `import { logger } from '../utils/logger.js'`
763
-
764
- ### TypeScript Configuration
765
- - Strict mode enabled
766
- - Declaration maps for debugging
767
- - Output to `dist/` directory
768
- - Source maps enabled
769
-
770
- ### LangChain Version
771
- - Uses LangChain 1.x ecosystem
772
- - `@langchain/core` for base types
773
- - `@langchain/langgraph` for agent creation
774
- - `@langchain/openai` for ChatOpenAI model
775
-
776
- ### Not a Git Repository
777
- - This directory is NOT initialized as a git repository
778
- - It's a package within a larger monorepo structure
779
-
780
- ## Build Process
781
-
782
- The build process (`npm run build`):
783
- 1. Compiles TypeScript from `src/` to `dist/`
784
- 2. Copies `src/data/tips.json` to `dist/data/`
785
- 3. Generates declaration files (`.d.ts`)
786
- 4. Generates source maps
787
-
788
- ## Common Patterns & Utilities
789
-
790
- ### Configuration Loading
791
- See `src/code/config.ts` and `src/utils/env-mapper.ts` for how configuration is loaded with fallbacks.
792
-
793
- ### Logging
794
- Use the shared logger from `src/utils/logger.ts`:
795
- ```typescript
796
- import { logger } from '../utils/logger';
797
-
798
- logger.info('Information message');
799
- logger.success('Success message');
800
- logger.error('Error message');
801
- logger.debug('Debug message'); // Only shown when CODEMIE_DEBUG=true
802
- ```
803
-
804
- ### Process Execution
805
- Use utilities from `src/utils/exec.ts` for running commands.
806
-
807
- ### Tips System
808
- Loading tips are displayed during initialization from `src/data/tips.json`.
809
-
810
- ## Best Practices
811
-
812
- 1. **Modular Design**: Each component should have clear separation of concerns
813
- 2. **Error Handling**: Always handle errors gracefully with user-friendly messages
814
- 3. **Security**: Validate all paths and commands before execution
815
- 4. **Reusability**: Utilize shared utilities from `src/utils/`
816
- 5. **Documentation**: Provide comprehensive JSDoc comments for all public methods
817
- 6. **TypeScript**: Use proper types throughout, avoid `any` when possible
818
- 7. **Testing**: Write tests for new functionality when requested
819
- 8. **Async/Await**: Handle async operations properly with try-catch
820
-
821
- ## Troubleshooting
822
-
823
- ### Issue: Command not found after installation
824
- **Solution**: Re-link the package
825
- ```bash
826
- npm link
827
- which codemie
828
- which codemie-code
829
- ```
830
-
831
- ### Issue: TypeScript compilation errors
832
- **Solution**: Clean build
833
- ```bash
834
- rm -rf dist/
835
- npm run build
836
- ```
837
-
838
- ### Issue: Import errors
839
- **Solution**: Check import paths use `.js` extensions and are correct
840
-
841
- ### Issue: Environment variables not loaded
842
- **Solution**: Check variable names match the priority order and verify with:
843
- ```bash
844
- echo $ANTHROPIC_BASE_URL
845
- echo $AI_BASE_URL
846
- codemie doctor
847
- ```
848
-
849
- ## Support
850
-
851
- For questions or issues:
852
- - Review existing implementations in `src/`
853
- - Check test examples in `tests/`
854
- - Consult utilities in `src/utils/`
855
- - Read comprehensive `README.md`