Add CLI Init Command with AI-Powered Config Generation#28
Merged
Conversation
- Add CLI with init command for automatic config generation - Use Anthropic Claude API to generate config from project analysis - Support JS and JSON output formats - Integrate ConfigService into MCP service (resources, tools, prompts) - Add console utilities and comprehensive tests Enables to auto-generate codingbuddy.config.js close #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add CLI Init Command with AI-Powered Config Generation
📋 Summary
Implements the
codingbuddy initCLI command that automatically generatescodingbuddy.config.jsfrom project analysis using AI. This provides a simple, one-command solution for developers to configure CodingBuddy for their projects.Closes #22
🎯 Problem
Manual Configuration Barrier
Even with project analysis capabilities (TICKET-003), developers still need to:
This creates friction and reduces adoption. Developers want a single command that does everything.
Missing Developer Interface
The previous PRs built the infrastructure:
But there was no way for developers to actually use it. They needed a CLI command.
✨ Solution
CLI Init Command
A complete CLI implementation that:
AnalyzerService1. CLI Entry Point (
cli.ts)Features:
init,help,version)--format,--force,--api-key)Commands:
codingbuddy init [path]- Initialize configurationcodingbuddy --help- Show usagecodingbuddy --version- Show versionOptions:
--format <js|json>- Output format (default: js)--force, -f- Overwrite existing config--api-key <key>- Anthropic API key (or useANTHROPIC_API_KEYenv)2. Init Command (
init.command.ts)Features:
AnalyzerServiceConfigGeneratorConfigWriterInitResultwith success statusKey Functions:
runInit(options): Main init command executiongetApiKey(options): Get API key from options or environment3. Config Generator (
config.generator.ts)Features:
claude-sonnet-4-20250514Key Functions:
ConfigGenerator.generate(analysis): Generate config from analysisextractJsonFromResponse(response): Extract JSON from AI responseparseJsonResponse(response): Parse and validate JSON responseAI Prompt:
4. Config Writer (
config.writer.ts)Features:
Key Functions:
writeConfig(projectRoot, config, options): Write config filefindExistingConfig(projectRoot): Find existing configformatConfigAsJs(config): Format as JS moduleformatConfigAsJson(config): Format as JSONOutput Formats:
JavaScript (
codingbuddy.config.js):JSON (
codingbuddy.config.json):{ "projectName": "my-app", "language": "ko", "techStack": { "frontend": ["React", "TypeScript"] } }5. Prompt Builder (
prompt.builder.ts)Features:
Key Functions:
buildSystemPrompt(): Build system promptbuildAnalysisPrompt(analysis): Format analysis as user prompt6. Console Utilities (
utils/console.ts)Features:
Key Functions:
log.info/success/warn/error(message): Colored loggingspinner.start/succeed/fail/stop(message): Spinner controlformatConfig(config): Format config for display7. MCP Service Integration (
mcp.service.ts)Features:
ConfigServiceinto MCP serviceconfig://projectresourceget_project_configtoolactivate_agentpromptparse_moderesponseNew Resources:
config://project- Project configuration as JSON resourceNew Tools:
get_project_config- Get project configurationEnhanced Prompts:
activate_agent- Now includes project context (tech stack, architecture, conventions)parse_mode- Now includes language setting from config🧪 Testing
Test Coverage
Total: 70+ tests, all passing ✅
Test Scenarios
CLI:
Init Command:
Config Generator:
Config Writer:
MCP Service:
🎯 Benefits
1. Low Barrier to Entry
Single command (
npx codingbuddy init) to get started. No manual configuration needed.2. Intelligent Configuration
AI understands project characteristics and generates appropriate settings based on actual project state.
3. Transparency
Clear progress indication and error messages. Users can see what's happening at each step.
4. Customization
Generated config can be manually edited after generation. Users have full control.
5. MCP Integration
Config is automatically used by MCP server to improve AI responses with project context.
📖 Usage Example
🔗 Related Documentation
📝 Design Decisions
Why Anthropic Claude API?
Why Two Output Formats?
Why Separate Modules?
Why Console Utilities?
Why MCP Integration?
✅ Acceptance Criteria
npx codingbuddy initcommand works