@codemieai/code 0.0.2 → 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.
- package/CLAUDE.md +130 -760
- package/README.md +283 -695
- package/bin/codemie-claude.js +122 -0
- package/bin/codemie-code.js +90 -15
- package/bin/codemie-codex.js +138 -0
- package/bin/codemie.js +1 -1
- package/config.example.json +10 -0
- package/dist/agents/adapters/claude-code.d.ts +2 -2
- package/dist/agents/adapters/claude-code.d.ts.map +1 -1
- package/dist/agents/adapters/claude-code.js +20 -42
- package/dist/agents/adapters/claude-code.js.map +1 -1
- package/dist/agents/adapters/codemie-code.d.ts +11 -2
- package/dist/agents/adapters/codemie-code.d.ts.map +1 -1
- package/dist/agents/adapters/codemie-code.js +93 -25
- package/dist/agents/adapters/codemie-code.js.map +1 -1
- package/dist/agents/adapters/codex.d.ts +2 -2
- package/dist/agents/adapters/codex.d.ts.map +1 -1
- package/dist/agents/adapters/codex.js +31 -24
- package/dist/agents/adapters/codex.js.map +1 -1
- package/dist/agents/codemie-code/agent.d.ts +89 -0
- package/dist/agents/codemie-code/agent.d.ts.map +1 -0
- package/dist/agents/codemie-code/agent.js +523 -0
- package/dist/agents/codemie-code/agent.js.map +1 -0
- package/dist/agents/codemie-code/config.d.ts +40 -0
- package/dist/agents/codemie-code/config.d.ts.map +1 -0
- package/dist/agents/codemie-code/config.js +276 -0
- package/dist/agents/codemie-code/config.js.map +1 -0
- package/dist/agents/codemie-code/filters.d.ts +91 -0
- package/dist/agents/codemie-code/filters.d.ts.map +1 -0
- package/dist/agents/codemie-code/filters.js +328 -0
- package/dist/agents/codemie-code/filters.js.map +1 -0
- package/dist/agents/codemie-code/index.d.ts +78 -0
- package/dist/agents/codemie-code/index.d.ts.map +1 -0
- package/dist/agents/codemie-code/index.js +259 -0
- package/dist/agents/codemie-code/index.js.map +1 -0
- package/dist/agents/codemie-code/prompts.d.ts +11 -0
- package/dist/agents/codemie-code/prompts.d.ts.map +1 -0
- package/dist/agents/codemie-code/prompts.js +31 -0
- package/dist/agents/codemie-code/prompts.js.map +1 -0
- package/dist/agents/codemie-code/streaming/events.d.ts +7 -0
- package/dist/agents/codemie-code/streaming/events.d.ts.map +1 -0
- package/dist/agents/codemie-code/streaming/events.js +7 -0
- package/dist/agents/codemie-code/streaming/events.js.map +1 -0
- package/dist/agents/codemie-code/streaming/formatter.d.ts +2 -0
- package/dist/agents/codemie-code/streaming/formatter.d.ts.map +1 -0
- package/dist/agents/codemie-code/streaming/formatter.js +2 -0
- package/dist/agents/codemie-code/streaming/formatter.js.map +1 -0
- package/dist/agents/codemie-code/streaming/ui.d.ts +2 -0
- package/dist/agents/codemie-code/streaming/ui.d.ts.map +1 -0
- package/dist/agents/codemie-code/streaming/ui.js +2 -0
- package/dist/agents/codemie-code/streaming/ui.js.map +1 -0
- package/dist/agents/codemie-code/tokenUtils.d.ts +108 -0
- package/dist/agents/codemie-code/tokenUtils.d.ts.map +1 -0
- package/dist/agents/codemie-code/tokenUtils.js +220 -0
- package/dist/agents/codemie-code/tokenUtils.js.map +1 -0
- package/dist/agents/codemie-code/toolMetadata.d.ts +15 -0
- package/dist/agents/codemie-code/toolMetadata.d.ts.map +1 -0
- package/dist/agents/codemie-code/toolMetadata.js +315 -0
- package/dist/agents/codemie-code/toolMetadata.js.map +1 -0
- package/dist/agents/codemie-code/tools/command.d.ts +2 -0
- package/dist/agents/codemie-code/tools/command.d.ts.map +1 -0
- package/dist/agents/codemie-code/tools/command.js +2 -0
- package/dist/agents/codemie-code/tools/command.js.map +1 -0
- package/dist/agents/codemie-code/tools/filesystem.d.ts +2 -0
- package/dist/agents/codemie-code/tools/filesystem.d.ts.map +1 -0
- package/dist/agents/codemie-code/tools/filesystem.js +2 -0
- package/dist/agents/codemie-code/tools/filesystem.js.map +1 -0
- package/dist/agents/codemie-code/tools/git.d.ts +2 -0
- package/dist/agents/codemie-code/tools/git.d.ts.map +1 -0
- package/dist/agents/codemie-code/tools/git.js +2 -0
- package/dist/agents/codemie-code/tools/git.js.map +1 -0
- package/dist/agents/codemie-code/tools/index.d.ts +19 -0
- package/dist/agents/codemie-code/tools/index.d.ts.map +1 -0
- package/dist/agents/codemie-code/tools/index.js +239 -0
- package/dist/agents/codemie-code/tools/index.js.map +1 -0
- package/dist/agents/codemie-code/tools/security.d.ts +2 -0
- package/dist/agents/codemie-code/tools/security.d.ts.map +1 -0
- package/dist/agents/codemie-code/tools/security.js +2 -0
- package/dist/agents/codemie-code/tools/security.js.map +1 -0
- package/dist/agents/codemie-code/types.d.ts +254 -0
- package/dist/agents/codemie-code/types.d.ts.map +1 -0
- package/dist/agents/codemie-code/types.js +35 -0
- package/dist/agents/codemie-code/types.js.map +1 -0
- package/dist/agents/codemie-code/ui.d.ts +83 -0
- package/dist/agents/codemie-code/ui.d.ts.map +1 -0
- package/dist/agents/codemie-code/ui.js +624 -0
- package/dist/agents/codemie-code/ui.js.map +1 -0
- package/dist/agents/registry.d.ts +1 -1
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +7 -13
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +323 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +113 -69
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/env.d.ts +3 -0
- package/dist/cli/commands/env.d.ts.map +1 -0
- package/dist/cli/commands/env.js +19 -0
- package/dist/cli/commands/env.js.map +1 -0
- package/dist/cli/commands/install.js +27 -33
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/list.js +18 -24
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/run.d.ts.map +1 -1
- package/dist/cli/commands/run.js +291 -31
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +3 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +357 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/uninstall.js +24 -30
- package/dist/cli/commands/uninstall.js.map +1 -1
- package/dist/cli/commands/version.d.ts.map +1 -1
- package/dist/cli/commands/version.js +11 -16
- package/dist/cli/commands/version.js.map +1 -1
- package/dist/cli/index.js +47 -31
- package/dist/cli/index.js.map +1 -1
- package/dist/env/manager.js +9 -46
- package/dist/env/manager.js.map +1 -1
- package/dist/index.d.ts +6 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -43
- package/dist/index.js.map +1 -1
- package/dist/utils/async-tips.d.ts.map +1 -1
- package/dist/utils/async-tips.js +16 -55
- package/dist/utils/async-tips.js.map +1 -1
- package/dist/utils/clipboard.d.ts +16 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +179 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/config-loader.d.ts +96 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +351 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/dirname.d.ts +7 -0
- package/dist/utils/dirname.d.ts.map +1 -0
- package/dist/utils/dirname.js +11 -0
- package/dist/utils/dirname.js.map +1 -0
- package/dist/utils/errors.js +7 -17
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/exec.js +3 -6
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/first-time.d.ts +34 -0
- package/dist/utils/first-time.d.ts.map +1 -0
- package/dist/utils/first-time.js +245 -0
- package/dist/utils/first-time.js.map +1 -0
- package/dist/utils/health-checker.d.ts +20 -0
- package/dist/utils/health-checker.d.ts.map +1 -0
- package/dist/utils/health-checker.js +168 -0
- package/dist/utils/health-checker.js.map +1 -0
- package/dist/utils/logger.js +12 -18
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/model-fetcher.d.ts +21 -0
- package/dist/utils/model-fetcher.d.ts.map +1 -0
- package/dist/utils/model-fetcher.js +137 -0
- package/dist/utils/model-fetcher.js.map +1 -0
- package/dist/utils/tips.d.ts.map +1 -1
- package/dist/utils/tips.js +13 -52
- package/dist/utils/tips.js.map +1 -1
- package/package.json +17 -23
- package/scripts/README.md +80 -0
- package/scripts/release.sh +156 -0
- package/dist/agents/adapters/aider.d.ts +0 -12
- package/dist/agents/adapters/aider.d.ts.map +0 -1
- package/dist/agents/adapters/aider.js +0 -80
- package/dist/agents/adapters/aider.js.map +0 -1
- package/dist/cli/cli.d.ts +0 -4
- package/dist/cli/cli.d.ts.map +0 -1
- package/dist/cli/cli.js +0 -107
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/commands/mcp.d.ts +0 -3
- package/dist/cli/commands/mcp.d.ts.map +0 -1
- package/dist/cli/commands/mcp.js +0 -459
- package/dist/cli/commands/mcp.js.map +0 -1
- package/dist/code/agent-events.d.ts +0 -39
- package/dist/code/agent-events.d.ts.map +0 -1
- package/dist/code/agent-events.js +0 -4
- package/dist/code/agent-events.js.map +0 -1
- package/dist/code/agent.d.ts +0 -19
- package/dist/code/agent.d.ts.map +0 -1
- package/dist/code/agent.js +0 -144
- package/dist/code/agent.js.map +0 -1
- package/dist/code/config.d.ts +0 -13
- package/dist/code/config.d.ts.map +0 -1
- package/dist/code/config.js +0 -41
- package/dist/code/config.js.map +0 -1
- package/dist/code/index.d.ts +0 -19
- package/dist/code/index.d.ts.map +0 -1
- package/dist/code/index.js +0 -400
- package/dist/code/index.js.map +0 -1
- package/dist/code/prompts.d.ts +0 -2
- package/dist/code/prompts.d.ts.map +0 -1
- package/dist/code/prompts.js +0 -45
- package/dist/code/prompts.js.map +0 -1
- package/dist/code/tools/command.d.ts +0 -8
- package/dist/code/tools/command.d.ts.map +0 -1
- package/dist/code/tools/command.js +0 -83
- package/dist/code/tools/command.js.map +0 -1
- package/dist/code/tools/diff-utils.d.ts +0 -2
- package/dist/code/tools/diff-utils.d.ts.map +0 -1
- package/dist/code/tools/diff-utils.js +0 -45
- package/dist/code/tools/diff-utils.js.map +0 -1
- package/dist/code/tools/filesystem.d.ts +0 -11
- package/dist/code/tools/filesystem.d.ts.map +0 -1
- package/dist/code/tools/filesystem.js +0 -442
- package/dist/code/tools/filesystem.js.map +0 -1
- package/dist/code/tools/git.d.ts +0 -7
- package/dist/code/tools/git.d.ts.map +0 -1
- package/dist/code/tools/git.js +0 -111
- package/dist/code/tools/git.js.map +0 -1
- package/dist/code/tools/mcp.d.ts +0 -13
- package/dist/code/tools/mcp.d.ts.map +0 -1
- package/dist/code/tools/mcp.js +0 -230
- package/dist/code/tools/mcp.js.map +0 -1
- package/dist/data/tips.json +0 -118
- package/dist/ui/terminal-ui.d.ts +0 -73
- package/dist/ui/terminal-ui.d.ts.map +0 -1
- package/dist/ui/terminal-ui.js +0 -900
- package/dist/ui/terminal-ui.js.map +0 -1
- package/dist/utils/env-mapper.d.ts +0 -40
- package/dist/utils/env-mapper.d.ts.map +0 -1
- package/dist/utils/env-mapper.js +0 -122
- package/dist/utils/env-mapper.js.map +0 -1
- package/docs/USER_GUIDE.md +0 -573
- package/tests/agent-direct.test.mjs +0 -45
- package/tests/agent-output.test.mjs +0 -64
- package/tests/codemie-code.test.mjs +0 -42
- package/tests/context7-only.test.mjs +0 -42
- package/tests/conversation-flow.test.mjs +0 -63
- package/tests/interactive-simulation.test.mjs +0 -60
- package/tests/live-output.test.mjs +0 -53
- package/tests/mcp-context7.test.mjs +0 -105
- package/tests/mcp-e2e.test.mjs +0 -109
- package/tests/mcp-time-server.test.mjs +0 -58
- package/tests/streaming.test.mjs +0 -57
- package/tests/test-helpers.mjs +0 -94
- package/tests/text-wrapping.test.mjs +0 -33
- package/tests/tool-count.test.mjs +0 -81
- package/tests/ui-format.test.mjs +0 -39
- 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
|
|
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,801 +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
|
|
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
|
-
**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
68
|
## Project Overview
|
|
312
69
|
|
|
313
|
-
**CodeMie
|
|
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)
|
|
70
|
+
**CodeMie** is a unified CLI wrapper for managing multiple AI coding agents, featuring:
|
|
316
71
|
|
|
317
|
-
|
|
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
|
|
318
76
|
|
|
319
|
-
##
|
|
77
|
+
## Architecture Overview
|
|
320
78
|
|
|
321
|
-
###
|
|
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
|
|
79
|
+
### High-Level Structure
|
|
359
80
|
|
|
360
81
|
```
|
|
361
82
|
codemie-code/
|
|
362
|
-
├── bin/
|
|
363
|
-
│ ├── codemie
|
|
364
|
-
│
|
|
365
|
-
│
|
|
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
|
|
366
88
|
├── src/
|
|
367
|
-
│ ├──
|
|
368
|
-
│
|
|
369
|
-
│
|
|
370
|
-
│
|
|
371
|
-
│
|
|
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';
|
|
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
|
|
515
94
|
```
|
|
516
95
|
|
|
517
|
-
|
|
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
|
-
```
|
|
96
|
+
### Core Components
|
|
547
97
|
|
|
548
|
-
|
|
98
|
+
#### 1. Agent System (`src/agents/`)
|
|
549
99
|
|
|
550
|
-
|
|
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
|
|
551
106
|
|
|
552
|
-
|
|
107
|
+
#### 2. CLI System (`src/cli/`)
|
|
553
108
|
|
|
554
|
-
|
|
555
|
-
-
|
|
556
|
-
-
|
|
557
|
-
-
|
|
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
|
|
558
116
|
|
|
559
|
-
|
|
117
|
+
#### 3. Configuration System (`src/env/`)
|
|
560
118
|
|
|
561
|
-
|
|
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
|
|
562
123
|
|
|
563
|
-
|
|
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
|
|
124
|
+
#### 4. Built-in Agent Architecture (`src/agents/codemie-code/`)
|
|
571
125
|
|
|
572
|
-
|
|
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
|
-
```
|
|
126
|
+
**Multi-layered architecture:**
|
|
586
127
|
|
|
587
|
-
|
|
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
|
|
588
138
|
|
|
589
|
-
###
|
|
139
|
+
### Key Architectural Patterns
|
|
590
140
|
|
|
141
|
+
#### Agent Adapter Pattern
|
|
142
|
+
All agents implement the `AgentAdapter` interface:
|
|
591
143
|
```typescript
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
throw new Error(`Operation failed: ${error.message}`);
|
|
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>;
|
|
602
153
|
}
|
|
603
154
|
```
|
|
604
155
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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`
|
|
156
|
+
#### Configuration Hierarchy
|
|
157
|
+
1. Environment variables (highest priority)
|
|
158
|
+
2. Global config file (`~/.codemie/config.json`)
|
|
159
|
+
3. Default values (lowest priority)
|
|
697
160
|
|
|
698
|
-
|
|
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
|
|
699
166
|
|
|
700
|
-
|
|
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
|
|
701
171
|
|
|
702
|
-
|
|
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
|
-
```
|
|
172
|
+
### Technology Stack
|
|
719
173
|
|
|
720
|
-
|
|
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)
|
|
721
181
|
|
|
722
|
-
|
|
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.
|
|
182
|
+
## Development Guidelines
|
|
792
183
|
|
|
793
|
-
###
|
|
794
|
-
Use the shared logger from `src/utils/logger.ts`:
|
|
795
|
-
```typescript
|
|
796
|
-
import { logger } from '../utils/logger';
|
|
184
|
+
### Working with Agent Shortcuts
|
|
797
185
|
|
|
798
|
-
|
|
799
|
-
logger.success('Success message');
|
|
800
|
-
logger.error('Error message');
|
|
801
|
-
logger.debug('Debug message'); // Only shown when CODEMIE_DEBUG=true
|
|
802
|
-
```
|
|
186
|
+
When modifying the direct agent shortcuts (`codemie-claude`, `codemie-codex`):
|
|
803
187
|
|
|
804
|
-
|
|
805
|
-
|
|
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
|
|
806
194
|
|
|
807
|
-
|
|
808
|
-
Loading tips are displayed during initialization from `src/data/tips.json`.
|
|
195
|
+
2. **Pass-through Architecture**: Use `allowUnknownOption()` and `passThroughOptions()` to forward all unrecognized options to the underlying agent
|
|
809
196
|
|
|
810
|
-
|
|
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
|
|
811
201
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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
|
|
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
|
|
820
206
|
|
|
821
|
-
|
|
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
|
-
```
|
|
207
|
+
### Adding New Agent Shortcuts
|
|
830
208
|
|
|
831
|
-
|
|
832
|
-
**Solution**: Clean build
|
|
833
|
-
```bash
|
|
834
|
-
rm -rf dist/
|
|
835
|
-
npm run build
|
|
836
|
-
```
|
|
209
|
+
To add a new direct agent shortcut (e.g., `codemie-newagent`):
|
|
837
210
|
|
|
838
|
-
|
|
839
|
-
|
|
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
|
|
840
216
|
|
|
841
|
-
###
|
|
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
|
-
```
|
|
217
|
+
### Built-in Agent Development
|
|
848
218
|
|
|
849
|
-
|
|
219
|
+
When working on the CodeMie Native agent (`src/agents/codemie-code/`):
|
|
850
220
|
|
|
851
|
-
|
|
852
|
-
-
|
|
853
|
-
-
|
|
854
|
-
-
|
|
855
|
-
-
|
|
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
|