@codemieai/code 0.0.1

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 (159) hide show
  1. package/.claude/agents/README.md +298 -0
  2. package/.claude/agents/release-manager.md +857 -0
  3. package/CLAUDE.md +856 -0
  4. package/LICENSE +201 -0
  5. package/README.md +917 -0
  6. package/bin/codemie-code.js +23 -0
  7. package/bin/codemie.js +8 -0
  8. package/dist/agents/adapters/aider.d.ts +12 -0
  9. package/dist/agents/adapters/aider.d.ts.map +1 -0
  10. package/dist/agents/adapters/aider.js +80 -0
  11. package/dist/agents/adapters/aider.js.map +1 -0
  12. package/dist/agents/adapters/claude-code.d.ts +12 -0
  13. package/dist/agents/adapters/claude-code.d.ts.map +1 -0
  14. package/dist/agents/adapters/claude-code.js +98 -0
  15. package/dist/agents/adapters/claude-code.js.map +1 -0
  16. package/dist/agents/adapters/codemie-code.d.ts +12 -0
  17. package/dist/agents/adapters/codemie-code.d.ts.map +1 -0
  18. package/dist/agents/adapters/codemie-code.js +42 -0
  19. package/dist/agents/adapters/codemie-code.js.map +1 -0
  20. package/dist/agents/adapters/codex.d.ts +12 -0
  21. package/dist/agents/adapters/codex.d.ts.map +1 -0
  22. package/dist/agents/adapters/codex.js +80 -0
  23. package/dist/agents/adapters/codex.js.map +1 -0
  24. package/dist/agents/registry.d.ts +18 -0
  25. package/dist/agents/registry.d.ts.map +1 -0
  26. package/dist/agents/registry.js +35 -0
  27. package/dist/agents/registry.js.map +1 -0
  28. package/dist/cli/cli.d.ts +4 -0
  29. package/dist/cli/cli.d.ts.map +1 -0
  30. package/dist/cli/cli.js +107 -0
  31. package/dist/cli/cli.js.map +1 -0
  32. package/dist/cli/commands/doctor.d.ts +3 -0
  33. package/dist/cli/commands/doctor.d.ts.map +1 -0
  34. package/dist/cli/commands/doctor.js +128 -0
  35. package/dist/cli/commands/doctor.js.map +1 -0
  36. package/dist/cli/commands/install.d.ts +3 -0
  37. package/dist/cli/commands/install.d.ts.map +1 -0
  38. package/dist/cli/commands/install.js +76 -0
  39. package/dist/cli/commands/install.js.map +1 -0
  40. package/dist/cli/commands/list.d.ts +3 -0
  41. package/dist/cli/commands/list.d.ts.map +1 -0
  42. package/dist/cli/commands/list.js +50 -0
  43. package/dist/cli/commands/list.js.map +1 -0
  44. package/dist/cli/commands/mcp.d.ts +3 -0
  45. package/dist/cli/commands/mcp.d.ts.map +1 -0
  46. package/dist/cli/commands/mcp.js +459 -0
  47. package/dist/cli/commands/mcp.js.map +1 -0
  48. package/dist/cli/commands/run.d.ts +3 -0
  49. package/dist/cli/commands/run.d.ts.map +1 -0
  50. package/dist/cli/commands/run.js +41 -0
  51. package/dist/cli/commands/run.js.map +1 -0
  52. package/dist/cli/commands/uninstall.d.ts +3 -0
  53. package/dist/cli/commands/uninstall.d.ts.map +1 -0
  54. package/dist/cli/commands/uninstall.js +71 -0
  55. package/dist/cli/commands/uninstall.js.map +1 -0
  56. package/dist/cli/commands/version.d.ts +3 -0
  57. package/dist/cli/commands/version.d.ts.map +1 -0
  58. package/dist/cli/commands/version.js +28 -0
  59. package/dist/cli/commands/version.js.map +1 -0
  60. package/dist/cli/index.d.ts +3 -0
  61. package/dist/cli/index.d.ts.map +1 -0
  62. package/dist/cli/index.js +50 -0
  63. package/dist/cli/index.js.map +1 -0
  64. package/dist/code/agent-events.d.ts +39 -0
  65. package/dist/code/agent-events.d.ts.map +1 -0
  66. package/dist/code/agent-events.js +4 -0
  67. package/dist/code/agent-events.js.map +1 -0
  68. package/dist/code/agent.d.ts +19 -0
  69. package/dist/code/agent.d.ts.map +1 -0
  70. package/dist/code/agent.js +144 -0
  71. package/dist/code/agent.js.map +1 -0
  72. package/dist/code/config.d.ts +13 -0
  73. package/dist/code/config.d.ts.map +1 -0
  74. package/dist/code/config.js +41 -0
  75. package/dist/code/config.js.map +1 -0
  76. package/dist/code/index.d.ts +19 -0
  77. package/dist/code/index.d.ts.map +1 -0
  78. package/dist/code/index.js +400 -0
  79. package/dist/code/index.js.map +1 -0
  80. package/dist/code/prompts.d.ts +2 -0
  81. package/dist/code/prompts.d.ts.map +1 -0
  82. package/dist/code/prompts.js +45 -0
  83. package/dist/code/prompts.js.map +1 -0
  84. package/dist/code/tools/command.d.ts +8 -0
  85. package/dist/code/tools/command.d.ts.map +1 -0
  86. package/dist/code/tools/command.js +83 -0
  87. package/dist/code/tools/command.js.map +1 -0
  88. package/dist/code/tools/diff-utils.d.ts +2 -0
  89. package/dist/code/tools/diff-utils.d.ts.map +1 -0
  90. package/dist/code/tools/diff-utils.js +45 -0
  91. package/dist/code/tools/diff-utils.js.map +1 -0
  92. package/dist/code/tools/filesystem.d.ts +11 -0
  93. package/dist/code/tools/filesystem.d.ts.map +1 -0
  94. package/dist/code/tools/filesystem.js +442 -0
  95. package/dist/code/tools/filesystem.js.map +1 -0
  96. package/dist/code/tools/git.d.ts +7 -0
  97. package/dist/code/tools/git.d.ts.map +1 -0
  98. package/dist/code/tools/git.js +111 -0
  99. package/dist/code/tools/git.js.map +1 -0
  100. package/dist/code/tools/mcp.d.ts +13 -0
  101. package/dist/code/tools/mcp.d.ts.map +1 -0
  102. package/dist/code/tools/mcp.js +230 -0
  103. package/dist/code/tools/mcp.js.map +1 -0
  104. package/dist/data/tips.json +118 -0
  105. package/dist/env/manager.d.ts +14 -0
  106. package/dist/env/manager.d.ts.map +1 -0
  107. package/dist/env/manager.js +99 -0
  108. package/dist/env/manager.js.map +1 -0
  109. package/dist/index.d.ts +14 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +47 -0
  112. package/dist/index.js.map +1 -0
  113. package/dist/ui/terminal-ui.d.ts +73 -0
  114. package/dist/ui/terminal-ui.d.ts.map +1 -0
  115. package/dist/ui/terminal-ui.js +900 -0
  116. package/dist/ui/terminal-ui.js.map +1 -0
  117. package/dist/utils/async-tips.d.ts +64 -0
  118. package/dist/utils/async-tips.d.ts.map +1 -0
  119. package/dist/utils/async-tips.js +242 -0
  120. package/dist/utils/async-tips.js.map +1 -0
  121. package/dist/utils/env-mapper.d.ts +40 -0
  122. package/dist/utils/env-mapper.d.ts.map +1 -0
  123. package/dist/utils/env-mapper.js +122 -0
  124. package/dist/utils/env-mapper.js.map +1 -0
  125. package/dist/utils/errors.d.ts +25 -0
  126. package/dist/utils/errors.d.ts.map +1 -0
  127. package/dist/utils/errors.js +58 -0
  128. package/dist/utils/errors.js.map +1 -0
  129. package/dist/utils/exec.d.ts +12 -0
  130. package/dist/utils/exec.d.ts.map +1 -0
  131. package/dist/utils/exec.js +49 -0
  132. package/dist/utils/exec.js.map +1 -0
  133. package/dist/utils/logger.d.ts +19 -0
  134. package/dist/utils/logger.d.ts.map +1 -0
  135. package/dist/utils/logger.js +53 -0
  136. package/dist/utils/logger.js.map +1 -0
  137. package/dist/utils/tips.d.ts +35 -0
  138. package/dist/utils/tips.d.ts.map +1 -0
  139. package/dist/utils/tips.js +132 -0
  140. package/dist/utils/tips.js.map +1 -0
  141. package/docs/USER_GUIDE.md +573 -0
  142. package/eslint.config.mjs +43 -0
  143. package/package.json +66 -0
  144. package/tests/agent-direct.test.mjs +45 -0
  145. package/tests/agent-output.test.mjs +64 -0
  146. package/tests/codemie-code.test.mjs +42 -0
  147. package/tests/context7-only.test.mjs +42 -0
  148. package/tests/conversation-flow.test.mjs +63 -0
  149. package/tests/interactive-simulation.test.mjs +60 -0
  150. package/tests/live-output.test.mjs +53 -0
  151. package/tests/mcp-context7.test.mjs +105 -0
  152. package/tests/mcp-e2e.test.mjs +109 -0
  153. package/tests/mcp-time-server.test.mjs +58 -0
  154. package/tests/streaming.test.mjs +57 -0
  155. package/tests/test-helpers.mjs +94 -0
  156. package/tests/text-wrapping.test.mjs +33 -0
  157. package/tests/tool-count.test.mjs +81 -0
  158. package/tests/ui-format.test.mjs +39 -0
  159. package/tests/ui-state.test.mjs +72 -0
package/README.md ADDED
@@ -0,0 +1,917 @@
1
+ # CodeMie Code
2
+
3
+ > AI coding assistant and CLI wrapper for managing multiple AI coding agents
4
+
5
+ CodeMie Code is a unified npm package that provides both a built-in AI coding assistant and a CLI wrapper for managing multiple AI coding agents (Claude Code, Aider, Codex, etc.).
6
+
7
+ ## ✨ Features
8
+
9
+ - 🤖 **Built-in AI Assistant** - Ready-to-use coding assistant powered by any AI provider
10
+ - 🔧 **CLI Wrapper** - Manage and run multiple AI coding agents from one interface
11
+ - 🛠️ **Complete Toolset** - 15 tools including filesystem operations, git commands, and code execution
12
+ - 🔌 **MCP Support** - Model Context Protocol integration for extensible tool support
13
+ - 🔒 **Security First** - Path validation, symlink protection, and command sanitization
14
+ - 📝 **Diff-based Editing** - Smart file editing with indentation preservation
15
+ - 🌐 **Provider Agnostic** - Works with any AI provider (OpenAI, Anthropic, Azure, etc.)
16
+ - 🎯 **Project-aware** - Operates within allowed directories with ignore patterns
17
+ - 🚀 **Zero Configuration** - Works with environment variables only
18
+
19
+ ---
20
+
21
+ ## 📦 Installation
22
+
23
+ ### From npm (when published)
24
+
25
+ ```bash
26
+ npm install -g @codemieai/code
27
+ ```
28
+
29
+ ### From Source (Development)
30
+
31
+ ```bash
32
+ # Clone the repository
33
+ git clone https://github.com/codemie-ai/codemie-code.git
34
+ cd codemie-code
35
+
36
+ # Install dependencies
37
+ npm install
38
+
39
+ # Build the project
40
+ npm run build
41
+
42
+ # Link globally for testing
43
+ npm link
44
+ ```
45
+
46
+ ### Verify Installation
47
+
48
+ ```bash
49
+ # Check if commands are available
50
+ codemie --help
51
+ codemie-code --help
52
+
53
+ # Run health check
54
+ codemie doctor
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🚀 Quick Start
60
+
61
+ ### 1. Set Up Environment Variables
62
+
63
+ CodeMie Code requires AI provider credentials:
64
+
65
+ ```bash
66
+ export CODEMIE_BASE_URL="https://your-ai-proxy.com"
67
+ export CODEMIE_AUTH_TOKEN="your-auth-token"
68
+ export CODEMIE_MODEL="claude-4-5-sonnet"
69
+ ```
70
+
71
+ **Add to your shell profile** for persistence:
72
+
73
+ ```bash
74
+ # Add to ~/.bashrc or ~/.zshrc
75
+ echo 'export CODEMIE_BASE_URL="https://your-ai-proxy.com"' >> ~/.bashrc
76
+ echo 'export CODEMIE_AUTH_TOKEN="your-auth-token"' >> ~/.bashrc
77
+ echo 'export CODEMIE_MODEL="claude-4-5-sonnet"' >> ~/.bashrc
78
+
79
+ # Reload shell
80
+ source ~/.bashrc
81
+ ```
82
+
83
+ ### 2. Test Connection
84
+
85
+ ```bash
86
+ codemie-code test
87
+ ```
88
+
89
+ **Expected output:**
90
+ ```
91
+ ✓ Configuration loaded
92
+ ✓ Testing connection...
93
+ ✓ Connection successful
94
+ ✓ Model: claude-4-5-sonnet
95
+ ```
96
+
97
+ ### 3. Start the Assistant
98
+
99
+ ```bash
100
+ # In current directory
101
+ codemie-code
102
+
103
+ # In specific directory
104
+ codemie-code /path/to/your/project
105
+
106
+ # Execute one-off task
107
+ codemie-code exec "Add error handling to api.ts"
108
+ ```
109
+
110
+ ### 4. Interact with the Assistant
111
+
112
+ ```
113
+ ╔═══════════════════════════════════════╗
114
+ ║ CodeMie Code Assistant ║
115
+ ╚═══════════════════════════════════════╝
116
+
117
+ Working directory: /your/project
118
+ Model: claude-4-5-sonnet
119
+
120
+ Type "exit" to quit, "clear" to clear history
121
+
122
+ You: List all TypeScript files in this project
123
+ You: Show git status and recent commits
124
+ You: Create a new file called utils.ts with helper functions
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 📚 Configuration
130
+
131
+ ### Required Environment Variables
132
+
133
+ | Variable | Description | Example |
134
+ |----------|-------------|---------|
135
+ | `CODEMIE_BASE_URL` | AI provider base URL | `https://your-ai-proxy.com` |
136
+ | `CODEMIE_AUTH_TOKEN` | Authentication token | `your-token-here` |
137
+ | `CODEMIE_MODEL` | Model to use | `claude-4-5-sonnet` |
138
+
139
+ ### Optional Configuration
140
+
141
+ #### Runtime Configuration
142
+
143
+ ```bash
144
+ # Enable debug logging
145
+ export CODEMIE_DEBUG="true"
146
+
147
+ # Timeout for AI requests (seconds)
148
+ export CODEMIE_TIMEOUT="300"
149
+
150
+ # Load specific MCP servers
151
+ export CODEMIE_MCP_SERVERS="time,context7"
152
+ ```
153
+
154
+ #### MCP Configuration
155
+
156
+ Configure MCP (Model Context Protocol) servers in `~/.codemie/config.json`:
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "context7": {
162
+ "command": "npx",
163
+ "args": ["-y", "@upstash/context7-mcp"]
164
+ },
165
+ "time": {
166
+ "command": "uvx",
167
+ "args": ["mcp-server-time"]
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ Or use environment variable to specify which servers to load:
174
+
175
+ ```bash
176
+ # Load specific MCP servers
177
+ export CODEMIE_MCP_SERVERS="context7,time"
178
+ codemie-code
179
+
180
+ # Or with CLI flag
181
+ codemie-code --mcp-servers context7,time
182
+ ```
183
+
184
+ When no `--mcp-servers` flag is provided, all servers configured in `~/.codemie/config.json` are loaded automatically.
185
+
186
+ ### Configuration Methods
187
+
188
+ #### Method 1: Shell Environment (Recommended)
189
+
190
+ ```bash
191
+ # Add to ~/.bashrc or ~/.zshrc
192
+ export CODEMIE_BASE_URL="https://your-ai-proxy.com"
193
+ export CODEMIE_AUTH_TOKEN="your-token"
194
+ export CODEMIE_MODEL="claude-4-5-sonnet"
195
+
196
+ # Reload shell
197
+ source ~/.bashrc # or ~/.zshrc
198
+ ```
199
+
200
+ #### Method 2: Project .env File
201
+
202
+ ```bash
203
+ # Create .env in your project
204
+ cat > .env << EOF
205
+ CODEMIE_BASE_URL=https://your-ai-proxy.com
206
+ CODEMIE_AUTH_TOKEN=your-token
207
+ CODEMIE_MODEL=claude-4-5-sonnet
208
+ EOF
209
+
210
+ # Load and run
211
+ set -a; source .env; set +a
212
+ codemie-code
213
+ ```
214
+
215
+ #### Method 3: Inline
216
+
217
+ ```bash
218
+ CODEMIE_BASE_URL="https://your-ai-proxy.com" \
219
+ CODEMIE_AUTH_TOKEN="your-token" \
220
+ CODEMIE_MODEL="claude-4-5-sonnet" \
221
+ codemie-code
222
+ ```
223
+
224
+ ### Advanced: Provider-Specific Configuration
225
+
226
+ For advanced scenarios, you can use provider-specific environment variables. These act as fallbacks if generic `CODEMIE_*` variables are not set:
227
+
228
+ **For Anthropic Claude:**
229
+ ```bash
230
+ export ANTHROPIC_BASE_URL="https://api.anthropic.com"
231
+ export ANTHROPIC_AUTH_TOKEN="your-anthropic-token"
232
+ export ANTHROPIC_MODEL="claude-4-5-sonnet"
233
+ ```
234
+
235
+ **For OpenAI GPT:**
236
+ ```bash
237
+ export OPENAI_BASE_URL="https://api.openai.com/v1"
238
+ export OPENAI_API_KEY="your-openai-key"
239
+ export OPENAI_MODEL="gpt-4"
240
+ ```
241
+
242
+ **Configuration Priority:**
243
+ 1. `CODEMIE_*` (generic - checked first)
244
+ 2. `ANTHROPIC_*` or `OPENAI_*` (provider-specific - fallback)
245
+
246
+ ---
247
+
248
+ ## 🎯 Usage
249
+
250
+ ### CodeMie Code Assistant
251
+
252
+ The built-in AI assistant with filesystem, git, and command execution tools.
253
+
254
+ ```bash
255
+ # Interactive mode (default)
256
+ codemie-code
257
+ codemie-code /path/to/project
258
+
259
+ # Execute one-off task
260
+ codemie-code exec "Add error handling to api.ts"
261
+
262
+ # Execute with custom directory
263
+ codemie-code exec "Run tests" -d /path/to/project
264
+
265
+ # Test connection
266
+ codemie-code test
267
+
268
+ # With MCP servers
269
+ codemie-code --mcp-servers time,context7
270
+
271
+ # With specific model
272
+ CODEMIE_MODEL="claude-opus" codemie-code
273
+ ```
274
+
275
+ #### Interactive Commands
276
+
277
+ Once inside the assistant:
278
+
279
+ - **exit** - Exit the assistant
280
+ - **clear** - Clear conversation history
281
+ - Any coding question or task
282
+
283
+ #### Example Prompts
284
+
285
+ ```
286
+ You: Show me the project structure
287
+ You: Read the package.json file
288
+ You: List all TypeScript files
289
+ You: Show git status and recent commits
290
+ You: Create a new file called utils.ts with helper functions
291
+ You: Search for files containing "authentication"
292
+ You: Edit README.md to add a new section
293
+ You: Run npm test and show me the results
294
+ ```
295
+
296
+ ### MCP Server Management
297
+
298
+ Extend capabilities with Model Context Protocol servers.
299
+
300
+ ```bash
301
+ # List available servers
302
+ codemie-code mcp list
303
+
304
+ # List with detailed configuration
305
+ codemie-code mcp list -v
306
+
307
+ # Add new server
308
+ codemie-code mcp add <name> <command-or-url> [options]
309
+
310
+ # Test server configuration
311
+ codemie-code mcp test <server-name>
312
+
313
+ # Remove server
314
+ codemie-code mcp remove <server-name>
315
+
316
+ # Preview which servers will load
317
+ codemie-code mcp servers
318
+ codemie-code mcp servers --servers time,context7
319
+ ```
320
+
321
+ #### Popular MCP Servers
322
+
323
+ **Time Server** - Query times in any timezone:
324
+ ```bash
325
+ codemie-code mcp add time uvx -a "mcp-server-time"
326
+ codemie-code --mcp-servers time
327
+
328
+ # Then ask: "What time is it in Hong Kong?"
329
+ ```
330
+
331
+ **Context7** - Access up-to-date library documentation:
332
+ ```bash
333
+ codemie-code mcp add context7 npx -a "-y" "@upstash/context7-mcp"
334
+ codemie-code --mcp-servers context7
335
+
336
+ # Then ask: "Show me LangChain documentation for chains"
337
+ ```
338
+
339
+ ### CLI Wrapper (codemie)
340
+
341
+ Manage multiple AI coding agents from one interface.
342
+
343
+ #### List Available Agents
344
+
345
+ ```bash
346
+ codemie list # List all agents
347
+ codemie list --installed # List only installed agents
348
+ ```
349
+
350
+ #### Install Agents
351
+
352
+ ```bash
353
+ codemie install claude-code # Install Anthropic Claude Code
354
+ codemie install aider # Install Aider
355
+ codemie install codex # Install OpenAI Codex
356
+ ```
357
+
358
+ #### Run Agents
359
+
360
+ ```bash
361
+ # Run built-in CodeMie Code
362
+ codemie run codemie-code
363
+
364
+ # Run other agents
365
+ codemie run claude-code
366
+ codemie run aider
367
+ codemie run codex
368
+
369
+ # With custom model
370
+ codemie run codemie-code --model claude-opus
371
+
372
+ # Pass additional arguments
373
+ codemie run aider --no-auto-commits
374
+ ```
375
+
376
+ #### Uninstall Agents
377
+
378
+ ```bash
379
+ codemie uninstall claude-code
380
+ codemie uninstall aider
381
+ ```
382
+
383
+ #### Health Check
384
+
385
+ ```bash
386
+ codemie doctor
387
+ ```
388
+
389
+ Checks:
390
+ - ✅ Node.js version (>= 24.0.0)
391
+ - ✅ npm installation
392
+ - ✅ git availability
393
+ - ✅ Environment variables configuration
394
+ - ✅ Installed agents
395
+
396
+ #### Version Information
397
+
398
+ ```bash
399
+ codemie version
400
+ codemie-code --version
401
+ ```
402
+
403
+ ---
404
+
405
+ ## 🛠️ Available Tools
406
+
407
+ CodeMie Code assistant comes with 15 built-in tools, plus extensible MCP tools:
408
+
409
+ ### Filesystem Tools (10 tools)
410
+
411
+ | Tool | Description |
412
+ |------|-------------|
413
+ | `read_file` | Read contents of a file |
414
+ | `read_multiple_files` | Read multiple files at once |
415
+ | `write_file` | Write/create a file with content |
416
+ | `edit_file` | Edit file with diff-based updates |
417
+ | `create_directory` | Create directories recursively |
418
+ | `list_directory` | List files and directories |
419
+ | `project_tree` | Generate visual project structure tree |
420
+ | `move_file` | Move or rename files |
421
+ | `search_files` | Search files by name or content |
422
+ | `list_allowed_directories` | Show accessible directories |
423
+
424
+ ### Git Tools (4 tools)
425
+
426
+ | Tool | Description |
427
+ |------|-------------|
428
+ | `git_status` | Get repository status |
429
+ | `git_diff` | Show git diff for changes |
430
+ | `git_log` | Show commit history |
431
+ | `git_command` | Execute any git command |
432
+
433
+ ### Command Execution (1 tool)
434
+
435
+ | Tool | Description |
436
+ |------|-------------|
437
+ | `execute_command` | Execute shell commands (with security checks) |
438
+
439
+ ### MCP Tools (Extensible)
440
+
441
+ MCP (Model Context Protocol) enables dynamic tool loading from external servers:
442
+
443
+ | Server | Tools | Description |
444
+ |--------|-------|-------------|
445
+ | `context7` | `resolve-library-id`, `get-library-docs` | Access up-to-date library documentation |
446
+ | `time` | `get-current-time` | Query times in any timezone |
447
+ | Custom | Varies | Add your own MCP servers |
448
+
449
+ Configure MCP servers in `~/.codemie/config.json` to extend available tools.
450
+
451
+ ### Tool Features
452
+
453
+ - **Path Validation**: All operations restricted to allowed directories
454
+ - **Symlink Protection**: Prevents escaping allowed directories
455
+ - **Ignore Patterns**: Automatically excludes node_modules, .git, etc.
456
+ - **Indentation Preservation**: Smart editing maintains code formatting
457
+ - **Unified Diffs**: Shows clear before/after changes
458
+ - **Command Sanitization**: Blocks dangerous commands (rm -rf /, sudo, etc.)
459
+
460
+ ---
461
+
462
+ ## 🔒 Security Features
463
+
464
+ CodeMie Code implements multiple security layers:
465
+
466
+ ### Filesystem Security
467
+
468
+ ✅ **Path Validation**
469
+ - All paths validated against allowed directories
470
+ - No directory traversal attacks (../)
471
+ - Absolute path resolution
472
+
473
+ ✅ **Symlink Protection**
474
+ - Symlinks resolved and validated
475
+ - Target paths must be within allowed directories
476
+
477
+ ✅ **Ignore Patterns**
478
+ - Automatically excludes sensitive directories
479
+ - Default: `node_modules`, `.git`, `__pycache__`, `.venv`, `dist`, `build`
480
+
481
+ ### Command Security
482
+
483
+ The `execute_command` tool blocks dangerous patterns:
484
+
485
+ ```typescript
486
+ 🚫 rm -rf / // Recursive delete on root
487
+ 🚫 mkfs // Filesystem formatting
488
+ 🚫 dd if= // Disk operations
489
+ 🚫 wget ... | sh // Download and execute
490
+ 🚫 curl ... | sh // Download and execute
491
+ 🚫 sudo // Privilege escalation
492
+ 🚫 chmod 777 // Unsafe permissions
493
+ 🚫 > /etc/ // Writing to system config
494
+ 🚫 > /dev/ // Writing to devices
495
+ 🚫 :(){ :|:& };: // Fork bomb
496
+ ```
497
+
498
+ ### Security Best Practices
499
+
500
+ 1. **Set Allowed Directories**: Only the working directory is accessible
501
+ 2. **Review Changes**: Always review diffs before applying
502
+ 3. **Use Version Control**: Work in git repositories
503
+ 4. **Test in Isolation**: Test in separate environments first
504
+
505
+ ---
506
+
507
+ ## 🎨 Usage Examples
508
+
509
+ ### Example 1: Code Review
510
+
511
+ ```bash
512
+ codemie-code
513
+
514
+ You: Read src/utils/helper.ts and review the code
515
+ Assistant: [Reads file, provides detailed review with suggestions]
516
+
517
+ You: Create a test file for this module
518
+ Assistant: [Creates tests/utils/helper.test.ts with test cases]
519
+ ```
520
+
521
+ ### Example 2: Refactoring
522
+
523
+ ```bash
524
+ You: Show me all files in src/components
525
+ Assistant: [Lists component files]
526
+
527
+ You: Read Button.tsx and refactor it to use hooks
528
+ Assistant: [Shows diff with proposed changes]
529
+
530
+ You: Apply those changes
531
+ Assistant: [Applies edits and shows confirmation]
532
+ ```
533
+
534
+ ### Example 3: Git Workflow
535
+
536
+ ```bash
537
+ You: Show me the current git status
538
+ Assistant: [Shows modified, staged, and untracked files]
539
+
540
+ You: Show diff for src/app.ts
541
+ Assistant: [Displays git diff]
542
+
543
+ You: Show the last 5 commits
544
+ Assistant: [Shows commit history]
545
+ ```
546
+
547
+ ### Example 4: Project Setup
548
+
549
+ ```bash
550
+ You: Create a new directory called "api"
551
+ Assistant: [Creates directory]
552
+
553
+ You: Create index.ts in api/ with a basic Express setup
554
+ Assistant: [Creates file with boilerplate code]
555
+
556
+ You: Create a README.md in api/ documenting the API
557
+ Assistant: [Creates documentation]
558
+ ```
559
+
560
+ ### Example 5: Search and Replace
561
+
562
+ ```bash
563
+ You: Search for all files containing "TODO"
564
+ Assistant: [Lists files with TODO comments]
565
+
566
+ You: Read components/Header.tsx
567
+ Assistant: [Shows file content]
568
+
569
+ You: Replace the TODO with an implementation
570
+ Assistant: [Shows diff and applies changes]
571
+ ```
572
+
573
+ ---
574
+
575
+ ## 🐛 Troubleshooting
576
+
577
+ ### Common Issues
578
+
579
+ #### "Base URL not configured"
580
+
581
+ **Solution:**
582
+ ```bash
583
+ export CODEMIE_BASE_URL="https://your-ai-proxy.com"
584
+ export CODEMIE_AUTH_TOKEN="your-token"
585
+ export CODEMIE_MODEL="claude-4-5-sonnet"
586
+ ```
587
+
588
+ #### "Connection test failed"
589
+
590
+ **Possible causes:**
591
+ 1. Invalid CODEMIE_AUTH_TOKEN
592
+ 2. CODEMIE_BASE_URL not accessible
593
+ 3. Network/VPN issues
594
+
595
+ **Solution:**
596
+ ```bash
597
+ # Verify URL is accessible
598
+ curl -I $CODEMIE_BASE_URL
599
+
600
+ # Check environment variables
601
+ echo $CODEMIE_BASE_URL
602
+ echo $CODEMIE_AUTH_TOKEN
603
+ echo $CODEMIE_MODEL
604
+
605
+ # Run doctor
606
+ codemie doctor
607
+
608
+ # Try test again
609
+ codemie-code test
610
+ ```
611
+
612
+ #### "Command not found: codemie"
613
+
614
+ **Solution:**
615
+ ```bash
616
+ # Re-install globally
617
+ npm install -g @codemieai/code
618
+
619
+ # Or re-link the package (from source)
620
+ cd /path/to/codemie-code
621
+ npm link
622
+
623
+ # Verify
624
+ which codemie
625
+ which codemie-code
626
+ ```
627
+
628
+ #### "Path outside allowed directories"
629
+
630
+ **Solution:**
631
+ CodeMie Code only operates within the working directory for security.
632
+
633
+ ```bash
634
+ # Start in the correct directory
635
+ cd /path/to/your/project
636
+ codemie-code
637
+
638
+ # Or specify the directory
639
+ codemie-code /path/to/your/project
640
+ ```
641
+
642
+ #### Environment Variables Not Loaded
643
+
644
+ ```bash
645
+ # Verify variables are set
646
+ env | grep CODEMIE_
647
+
648
+ # If empty, reload shell profile
649
+ source ~/.bashrc # or ~/.zshrc
650
+
651
+ # Or export again
652
+ export CODEMIE_BASE_URL="..."
653
+ export CODEMIE_AUTH_TOKEN="..."
654
+ export CODEMIE_MODEL="..."
655
+ ```
656
+
657
+ ### Debug Mode
658
+
659
+ Enable debug logging to diagnose issues:
660
+
661
+ ```bash
662
+ export CODEMIE_DEBUG="true"
663
+ codemie-code
664
+ ```
665
+
666
+ Debug mode shows:
667
+ - Tool initialization details
668
+ - AI request/response info
669
+ - File operation details
670
+ - Error stack traces
671
+
672
+ ### Clean Installation
673
+
674
+ If you encounter persistent issues:
675
+
676
+ ```bash
677
+ # Clean build
678
+ rm -rf dist/ node_modules/
679
+ npm install
680
+ npm run build
681
+
682
+ # Re-link
683
+ npm link
684
+ ```
685
+
686
+ ---
687
+
688
+ ## 📊 Architecture
689
+
690
+ ### Package Structure
691
+
692
+ ```
693
+ codemie-code/
694
+ ├── bin/
695
+ │ ├── codemie-code.js # AI assistant entry point
696
+ │ └── codemie.js # CLI wrapper entry point
697
+
698
+ ├── src/
699
+ │ ├── code/ # CodeMie Code Assistant
700
+ │ │ ├── index.ts # Main assistant class
701
+ │ │ ├── agent.ts # LangChain ReAct agent
702
+ │ │ ├── agent-events.ts # Event system for streaming
703
+ │ │ ├── config.ts # Configuration loader
704
+ │ │ ├── prompts.ts # System prompts
705
+ │ │ └── tools/ # Tool implementations
706
+ │ │ ├── filesystem.ts # 10 filesystem tools
707
+ │ │ ├── git.ts # 4 git tools
708
+ │ │ ├── command.ts # Command execution
709
+ │ │ ├── mcp.ts # MCP integration
710
+ │ │ └── diff-utils.ts # Diff utilities
711
+ │ │
712
+ │ ├── cli/ # CLI Wrapper
713
+ │ │ └── commands/ # CLI commands
714
+ │ │ ├── list.ts
715
+ │ │ ├── install.ts
716
+ │ │ ├── run.ts
717
+ │ │ ├── doctor.ts
718
+ │ │ ├── uninstall.ts
719
+ │ │ ├── version.ts
720
+ │ │ └── mcp.ts
721
+ │ │
722
+ │ ├── agents/ # Agent System
723
+ │ │ ├── registry.ts # Agent registry
724
+ │ │ └── adapters/ # Agent adapters
725
+ │ │ ├── codemie-code.ts
726
+ │ │ ├── claude-code.ts
727
+ │ │ ├── codex.ts
728
+ │ │ └── aider.ts
729
+ │ │
730
+ │ ├── env/ # Environment Management
731
+ │ │ └── manager.ts
732
+ │ │
733
+ │ ├── ui/ # UI Layer
734
+ │ │ └── terminal-ui.ts # Interactive terminal
735
+ │ │
736
+ │ └── utils/ # Utilities
737
+ │ ├── env-mapper.ts # Environment variable mapping
738
+ │ ├── exec.ts # Process execution
739
+ │ ├── logger.ts # Logging
740
+ │ ├── errors.ts # Error classes
741
+ │ └── tips.ts # Loading tips
742
+
743
+ ├── tests/ # Test files
744
+ │ └── integration/ # Integration tests
745
+
746
+ ├── dist/ # Build output (TypeScript compilation)
747
+ ├── mcp/ # MCP server configurations
748
+ │ └── servers.json
749
+ ├── package.json # Dependencies and scripts
750
+ ├── tsconfig.json # TypeScript configuration
751
+ ├── eslint.config.mjs # ESLint configuration
752
+ └── README.md # Package documentation
753
+ ```
754
+
755
+ ### Technology Stack
756
+
757
+ - **Language**: TypeScript (ES2022, NodeNext modules)
758
+ - **Runtime**: Node.js >= 24.0.0 (LTS Krypton)
759
+ - **Package Manager**: npm
760
+ - **LLM Framework**: LangChain 1.x (`@langchain/core`, `@langchain/langgraph`, `@langchain/openai`)
761
+ - **LLM Provider**: Any OpenAI-compatible API
762
+ - **CLI Framework**: Commander.js
763
+ - **Schema Validation**: Zod
764
+ - **Diff Generation**: diff package
765
+ - **UI**: Chalk, Inquirer, Ora
766
+ - **Testing**: Jest with ts-jest
767
+ - **Linting**: ESLint with TypeScript support
768
+
769
+ ---
770
+
771
+ ## 🔄 Roadmap
772
+
773
+ ### Current Status (v1.0.0)
774
+
775
+ ✅ **Implemented**:
776
+ - Built-in AI coding assistant
777
+ - CLI wrapper for multiple agents
778
+ - 10 filesystem tools with security
779
+ - 4 git operation tools
780
+ - 1 command execution tool
781
+ - MCP (Model Context Protocol) integration
782
+ - Diff-based file editing
783
+ - Agent management (install/uninstall/run)
784
+ - Health check and diagnostics
785
+ - Interactive terminal UI with cancellation support
786
+ - One-off task execution with `exec` command
787
+
788
+ ### Planned Features (v1.1.0+)
789
+
790
+ - 🎨 Custom themes and output formats
791
+ - 📦 Enhanced plugin system for custom tools
792
+ - 🌐 Multi-language support
793
+ - 📊 Usage analytics and insights
794
+ - 🔌 VS Code extension integration
795
+ - 🤖 More agent adapters (Cursor, Copilot, etc.)
796
+ - 🔍 Advanced MCP server discovery and management
797
+
798
+ ---
799
+
800
+ ## 🤝 Contributing
801
+
802
+ Contributions are welcome! Please:
803
+
804
+ 1. Fork the repository
805
+ 2. Create a feature branch
806
+ 3. Make your changes
807
+ 4. Add tests if applicable
808
+ 5. Submit a pull request
809
+
810
+ ### Development Setup
811
+
812
+ ```bash
813
+ # Clone repository
814
+ git clone https://github.com/codemie-ai/codemie-code.git
815
+ cd codemie-code
816
+
817
+ # Install dependencies
818
+ npm install
819
+
820
+ # Build
821
+ npm run build
822
+
823
+ # Watch mode (for development)
824
+ npm run dev
825
+
826
+ # Test locally
827
+ npm link
828
+ codemie doctor
829
+ ```
830
+
831
+ ### Running Tests
832
+
833
+ ```bash
834
+ # Run all tests
835
+ npm test
836
+
837
+ # Run with coverage
838
+ npm run test:coverage
839
+
840
+ # Run specific test
841
+ npm test -- path/to/test
842
+
843
+ # Manual integration tests
844
+ node tests/test-streaming.js
845
+ node tests/test-agent-direct.js
846
+ ```
847
+
848
+ ---
849
+
850
+ ## 📄 License
851
+
852
+ MIT License - see LICENSE file for details
853
+
854
+ ---
855
+
856
+ ## 🙏 Acknowledgments
857
+
858
+ - Built with [LangChain](https://js.langchain.com/)
859
+ - Inspired by [Aider](https://github.com/paul-gauthier/aider) and [Claude Code](https://claude.com/code)
860
+ - CLI framework by [Commander.js](https://github.com/tj/commander.js)
861
+ - MCP specification by [Anthropic](https://github.com/modelcontextprotocol/specification)
862
+
863
+ ---
864
+
865
+ ## 📞 Support
866
+
867
+ For issues, questions, or contributions:
868
+ - 🐛 Report bugs via [GitHub Issues](https://github.com/codemie-ai/codemie-code/issues)
869
+ - 💬 Ask questions in [Discussions](https://github.com/codemie-ai/codemie-code/discussions)
870
+ - 📖 Read the full [User Guide](docs/USER_GUIDE.md)
871
+
872
+ ---
873
+
874
+ ## Quick Reference
875
+
876
+ ### Essential Commands
877
+
878
+ ```bash
879
+ # Setup
880
+ export CODEMIE_BASE_URL="https://your-ai-proxy.com"
881
+ export CODEMIE_AUTH_TOKEN="your-token"
882
+ export CODEMIE_MODEL="claude-4-5-sonnet"
883
+
884
+ # Verify
885
+ codemie doctor
886
+ codemie-code test
887
+
888
+ # Start coding
889
+ codemie-code
890
+ codemie-code /path/to/project
891
+ codemie-code exec "task description"
892
+
893
+ # MCP
894
+ codemie-code mcp list
895
+ codemie-code --mcp-servers time,context7
896
+
897
+ # CLI Wrapper
898
+ codemie list
899
+ codemie install claude-code
900
+ codemie run claude-code
901
+ ```
902
+
903
+ ### Common Tasks
904
+
905
+ | What you want | Command |
906
+ |---------------|---------|
907
+ | Start interactive coding | `codemie-code` |
908
+ | Execute single task | `codemie-code exec "task"` |
909
+ | Test connection | `codemie-code test` |
910
+ | Check system health | `codemie doctor` |
911
+ | List MCP servers | `codemie-code mcp list` |
912
+ | Install agent | `codemie install <agent>` |
913
+ | Show versions | `codemie version` |
914
+
915
+ ---
916
+
917
+ **Made with ❤️ by the CodeMie Team**