@codemieai/code 0.0.1 → 0.0.3

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