Learnings from OpenCode, Claude Code, and other coding agents. Estimated: 8 sprints × 2 weeks = 16 weeks total.
Duration: 2 weeks Priority: 🔴 CRITICAL
- Add
--modeflag:plan(read-only analysis) |build(full PR flow) planmode: phân tích + báo cáo, KHÔNG generate code hoặc tạo PRbuildmode: full pipeline như hiện tại- Config:
pipeline.default_mode: "build" - TUI:
Tabđể switch giữa plan/build
- Replace
sandbox.enabledvới granularpermissionsconfig:pipeline: permissions: file_read: "allow" # always allow reading files file_edit: { "src/**": "allow", "**/config.*": "ask", "**/*.lock": "deny" } file_create: { "tests/**": "allow", "**": "ask" } file_delete: "deny" shell_command: { "cargo test": "allow", "cargo build": "allow", "*": "ask" } pr_create: "ask" # ask before creating PR pr_push: "allow" # auto-push after ask
- Permission actions:
"allow"|"ask"|"deny" - Pattern matching: glob patterns (
**,*,?) - Wildcard:
"*"matches everything - Interactive prompt: khi
ask→ hỏi user yes/no/skip/all - Non-interactive: khi không có terminal →
ask→deny
- Track file diffs trước/sau khi generate code
- Store in
file_snapshotstable:repo,path,before,after,timestamp - Support
contribai undo— rollback last generated changes - Config:
pipeline.snapshot: true(default)
Acceptance Criteria:
- ✅
contribai analyze --mode planruns analysis only - ✅
contribai run --mode buildruns full pipeline - ✅ Permission rules enforced — denied actions blocked
- ✅
contribai undoreverts last code changes - ✅ 15+ tests for permission matching
Duration: 2 weeks Priority: 🔴 CRITICAL
- Add
llm.small_modelconfig — cheap model cho lightweight tasks:llm: model: "gemini/gemini-3-pro" # primary model small_model: "gemini/gemini-3-flash" # cheap model for light tasks
- Route automatically:
- PR title generation → small model
- Commit message generation → small model
- Context compaction/summarization → small model
- Code analysis → primary model
- Code generation → primary model
- Fallback: nếu
small_modelkhông set → dùngmodel
- Khi context window vượt threshold (default: 80%), tự động compress:
- Summarize old messages thành 1-2 paragraph
- Keep recent messages + system prompt intact
- Use
small_modelfor summarization
- Config:
pipeline: compaction: auto: true threshold: 0.8 # 80% of max context reserved_tokens: 4096 # reserve for response prune: true # prune old tool results
- Compaction strategy:
- Summarize tool outputs → 1 line each
- Merge consecutive assistant messages
- Keep file contents only if still referenced
- Real-time context tracking:
used_tokens / max_tokens - Display budget trong TUI:
[████████░░░░░░] 62% - Auto-compaction trigger khi vượt threshold
- Manual compaction:
contribai compact-context
Acceptance Criteria:
- ✅ Small model used for PR titles, commit messages
- ✅ Context auto-compacts at 80% threshold
- ✅ TUI shows context budget bar
- ✅ 10+ tests for compaction logic
- ✅ Cost savings: ~30% fewer tokens on average run
Duration: 2 weeks Priority: 🟡 HIGH
- User định nghĩa custom workflows trong config:
commands: fix-security: description: "Fix security issues only" analyzers: [security] contribution_types: [security_fix] risk_tolerance: high approve: true docs-only: description: "Improve documentation" analyzers: [docs] contribution_types: [docs_improve] skip_non_docs: true test-gen: description: "Generate tests for uncovered files" analyzers: [testing] contribution_types: [testing] max_files_per_pr: 5
- CLI:
contribai cmd fix-security→ chạy custom workflow - TUI:
/fix-securityshortcut
- Chạy nhiều pipeline sessions song song:
contribai session new --name hunt-python # Session 1 contribai session new --name hunt-go # Session 2 contribai session list # Xem tất cả sessions contribai session attach hunt-python # Attach vào session contribai session kill hunt-go # Kill session
- Mỗi session có: riêng memory context, riêng circuit breaker state
- Session storage:
~/.contribai/sessions/<id>.json - Share session:
contribai session export <id>→ JSON file
- Fork session từ checkpoint:
contribai session fork <id> --from-step analysis
- Useful để thử nghiệm different strategies trên cùng repo
Acceptance Criteria:
- ✅ Custom commands chạy đúng config
- ✅ Multiple sessions chạy song song
- ✅ Session list/attach/kill/for/export/import
- ✅ 15+ tests for session management
Duration: 2 weeks Priority: 🟡 HIGH
- Support GitHub Copilot token as LLM provider:
llm: provider: "copilot" # Auto-detects from gh copilot token
- Flow:
gh auth login→ GitHub token- Exchange for Copilot token via
https://api.github.com/copilot_internal/v2/token - Use Copilot token để call
gpt-4o,claude-sonnet-4,gemini-2.5-proqua Copilot API
- Benefits: User đã có Copilot subscription → không cần API key riêng
- Support ChatGPT Plus/Pro account sharing:
llm: provider: "chatgpt" access_token: "" # From chat.openai.com/api/auth/session
- Flow: Extract
access_tokentừ browser localStorage hoặcchatgptCLI - Model mapping:
gpt-4o,gpt-4.1,o3,o4-mini
contribai logincải tiến: detect tất cả available auth sources:🔐 Authentication Status ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GitHub: ✅ Token set (via gh CLI) LLM Providers: Gemini: ❌ GEMINI_API_KEY not set OpenAI: ❌ OPENAI_API_KEY not set Copilot: ✅ Token detected (via gh copilot) ChatGPT: ❌ Not configured Vertex AI: ✅ gcloud configured (project-xxx) Ollama: ⚪ Running locally (localhost:11434)- Auto-prioritize: Copilot > Vertex AI > API keys > Ollama
- Interactive switch:
contribai login→ chọn provider → auto-config
- Auto-refresh expiring tokens:
- Copilot token: refresh trước khi expire (5-min TTL)
- Vertex AI token: gcloud token (55-min TTL, đã có)
- ChatGPT token: manual refresh (no auto-refresh)
- Warning khi token sắp expire:
⚠️ Copilot token expires in 2 minutes - Graceful fallback: khi token expire → try next available provider
- Configure fallback chain:
llm: primary: "copilot/gpt-4o" fallback: - "vertex/gemini-3-pro" - "openai/gpt-4o" - "ollama/llama-3.3-70b"
- Auto-fallback khi: rate limit, API error, token expired
- Log:
⚠️ Copilot rate limited → falling back to Vertex AI
Acceptance Criteria:
- ✅
contribai logindetects all available auth sources - ✅ Copilot auth works (token exchange + API calls)
- ✅ Token auto-refresh for Copilot + Vertex AI
- ✅ Provider fallback chain works
- ✅ 10+ tests for auth flows
Duration: 2 weeks Priority: 🟡 HIGH
- ContribAI kết nối external MCP servers như tools:
mcp: github-copilot: type: remote url: https://api.githubcopilot.com/mcp headers: Authorization: "Bearer $COPILOT_TOKEN" local-tools: type: local command: ["npx", "-y", "@modelcontextprotocol/server-tools"] custom-api: type: remote url: https://my-mcp-server.com/mcp oauth: clientId: "contribai" clientSecret: "$MCP_SECRET" scope: "tools:execute"
- MCP tools available trong pipeline như built-in tools
- Auto-discover tools từ MCP server capabilities
- Replace sandbox AST parse với LSP diagnostics:
- Start LSP server cho repo language (TypeScript → tsserver, Python → pyright)
- Send generated code qua LSP
- Parse diagnostics: errors → reject, warnings → warn, none → accept
- Config:
sandbox: mode: "lsp" # lsp | ast | docker | local | off lsp_timeout: 10 # seconds to wait for diagnostics accept_warnings: false # reject if warnings present
- Fallback: nếu LSP không available → AST parse
- Tự động phát hiện LSP server từ repo:
package.jsoncótypescript→ dùngtypescript-language-serverrequirements.txtcópyright→ dùngpyrightCargo.toml→ dùngrust-analyzer
- Download + install LSP nếu chưa có (cache trong
~/.contribai/lsp/)
Acceptance Criteria:
- ✅ MCP remote client connects + discovers tools
- ✅ LSP validation catches errors in generated code
- ✅ LSP auto-discovers server from repo structure
- ✅ Fallback to AST when LSP unavailable
- ✅ 10+ tests for MCP + LSP
Duration: 2 weeks Priority: 🟡 HIGH
- Chạy pipeline như standalone server:
contribai serve --port 9876
- Server exposes JSON-RPC API:
run— trigger pipeline runanalyze— analyze specific repostatus— get pipeline statussessions/list— list active sessionssessions/create— create new sessioncache/stats— LLM cache stats
- CLI kết nối remote server:
contribai run --server http://remote-host:9876 contribai analyze --server http://remote-host:9876 <url>
- Auth: API key hoặc mTLS cho remote connections
- TUI:
contribai tui --server http://remote-host:9876
- REST API compatible với external clients
- WebSocket streaming cho real-time progress
- Session sync giữa clients (start on CLI, monitor on mobile)
GET /health— server health checkGET /metrics— Prometheus metrics (đã có từ Sprint 7)GET /api/sessions— active sessionsGET /api/stats— pipeline statistics
Acceptance Criteria:
- ✅
contribai servestarts pipeline server - ✅ Remote client can trigger runs
- ✅ TUI connects to remote server
- ✅ Health + metrics endpoints work
- ✅ 10+ tests for server/client
Duration: 2 weeks Priority: 🟢 MEDIUM
- Full keybind configuration:
tui: keybinds: agent_cycle: "tab" model_list: "m" session_new: "n" input_submit: "return" input_newline: "shift+return" leader: "ctrl+x"
- Vim-like keybinds:
hjkl,ctrl+d/u,gg/G - Leader key system:
ctrl+x→r= run,a= analyze
- Real-time context usage bar trong TUI
- Show: tokens used, tokens remaining, cost estimate
- Color-coded: green (<60%), yellow (60-80%), red (>80%)
Tabđể switch giữaplanvàbuildmode- Visual indicator:
[PLAN]vs[BUILD] - Different prompt templates cho mỗi mode
- Expandable tool execution details trong TUI
- Show: tool name, input, output, duration, status
- Filter: show only failed tools, or all
contribai session export <id>→ JSON file- Shareable format cho debugging/review
- Import:
contribai session import session.json
Acceptance Criteria:
- ✅ Keybinds configurable
- ✅ Context budget bar trong TUI
- ✅ Agent switching via Tab
- ✅ Tool details panel
- ✅ Session export/import
Duration: 2 weeks Priority: 🟢 MEDIUM
- Export traces to Jaeger, Zipkin, OTLP:
experimental: openTelemetry: enabled: true endpoint: "http://localhost:4318" serviceName: "contribai"
- Trace: pipeline run, LLM calls, file fetches, PR creation
- Span attributes: repo, model, tokens, duration, cost
- Log format: JSON lines với correlation IDs
- Fields:
timestamp,level,message,trace_id,span_id,repo,model - Config:
log: level: "info" format: "json" output: "stderr" file: "~/.contribai/logs/pipeline.log"
- Pre-built Grafana dashboard JSON:
- Pipeline runs over time
- LLM token usage + cost
- PR merge rate by repo
- Cache hit rate
- Circuit breaker state timeline
- Error rate by type
- Configurable alerts:
alerts: circuit_breaker_open: true # notify when circuit opens pr_rejected_rate: 0.5 # alert if >50% PRs rejected daily_cost_usd: 10 # alert if daily cost > $10 token_budget_exceeded: true # alert if context budget exceeded
Acceptance Criteria:
- ✅ OpenTelemetry traces exported
- ✅ Structured JSON logging
- ✅ Grafana dashboard JSON included
- ✅ Alert rules configurable
- ✅ 5+ tests for observability
Duration: 2 weeks Priority: 🟢 MEDIUM
- Extensible plugin architecture:
plugin: - name: "custom-analyzer" path: "./plugins/analyzer.py" - name: "slack-notifier" npm: "@contribai/slack-notifier"
- Plugin hooks:
on_analysis_complete,on_pr_created,on_pr_merged,on_error - Plugin SDK: Python + TypeScript
- Enterprise config:
enterprise: url: "https://contribai.mycompany.com" sso: "saml" allowed_providers: ["copilot", "vertex"] max_daily_cost_usd: 50
- SSO integration: SAML, OIDC
- Audit logging: all actions logged to enterprise server
- i18n for CLI messages:
- English (default)
- Vietnamese
- Japanese
- Chinese (Simplified)
- TUI labels translated
cargo clippy -- -D warnings— 0 warningscargo audit— 0 advisories- All tests pass: target 600+ tests
- Release binaries for all 4 platforms
- Update all docs: README, ARCHITECTURE, RUNBOOK
Acceptance Criteria:
- ✅ Plugin system works (load + execute hooks)
- ✅ Enterprise mode with SSO
- ✅ CLI messages in 4 languages
- ✅ 600+ tests, 0 clippy warnings, 0 audit advisories
- ✅ Release v6.0.0 with all platforms
| Sprint | Focus | Key Deliverables |
|---|---|---|
| 8 | Agent Modes + Permissions | Plan/Build modes, Rule-based permissions, File snapshots |
| 9 | Small Model + Compaction | Small model routing, Auto context compaction, Budget display |
| 10 | Custom Commands + Sessions | User-defined commands, Multi-session, Session forking |
| 11 | Auth Ecosystem | Copilot auth, ChatGPT auth, Auto-detection, Fallback chain |
| 12 | MCP Remote + LSP | MCP remote client, LSP validation, Auto LSP discovery |
| 13 | Client/Server | Pipeline server, Remote client, Mobile-ready API |
| 14 | TUI Polish | Configurable keybinds, Context budget, Agent switching |
| 15 | Observability | OpenTelemetry, JSON logging, Grafana dashboard, Alerts |
| 16 | Polish + Release | Plugin system, Enterprise mode, i18n, v6.0.0 release |
- Tests: 575 → 600+
- Version: 5.17.1 → 6.0.0
- LLM Providers: 5 → 9+ (thêm Copilot, ChatGPT, fallback chain)
- CLI Commands: 40 → 55+
- Features từ OpenCode: 11/11 implemented