Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions CODI.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ grep("saveSession", "src/") // Finds all references to saveSession
get_context_status() // Checks current context usage
```

This project's architecture anticipates intelligent tool use and context management.

**Codi** is your AI coding wingman for the terminal - a CLI tool that supports multiple AI providers (Claude, OpenAI, Ollama, Ollama Cloud, RunPod). It enables developers to work with AI models through a conversational interface while giving the AI access to filesystem tools.
**Codi** is your AI coding wingman for the terminal - a CLI tool that supports multiple AI providers (Claude, OpenAI, Ollama, Ollama Cloud, RunPod). It enables developers to work with AI models through a conversational interface while giving the AI access to filesystem tools, and this project's architecture anticipates intelligent tool use and context management.

## Quick Reference

Expand All @@ -60,11 +58,6 @@ pnpm test:watch # Watch mode
# Interactive mode (default)
ANTHROPIC_API_KEY=... pnpm dev

# Non-interactive mode (single prompt and exit)
codi -P "explain this code" -f json # JSON output
codi --prompt "fix the bug" --quiet # Suppress spinners
codi -P "write tests" -y # Auto-approve all tools

# Testing with different providers
ANTHROPIC_API_KEY=... pnpm dev
OPENAI_API_KEY=... pnpm dev -- --provider openai
Expand Down Expand Up @@ -853,7 +846,7 @@ export default {

### Lower Priority / Nice to Have

#### 9. Interactive File Selection
#### 12. Interactive File Selection
**What**: Fuzzy file finder for commands.

**Implementation**:
Expand All @@ -863,7 +856,7 @@ export default {

**Dependencies**: `inquirer` or `prompts` package

#### 10. Parallel Tool Execution
#### 13. Parallel Tool Execution
**What**: Execute independent tools concurrently.

**Implementation**:
Expand All @@ -874,7 +867,7 @@ export default {
**Files to modify**:
- Modify: `src/agent.ts` (parallel execution logic)

#### 16. Web Search Tool - IMPLEMENTED
#### 14. Web Search Tool - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -907,7 +900,7 @@ Search results for: "TypeScript 5.0 features"
- `src/tools/web-search.ts` - Web search tool implementation
- `tests/web-search.test.ts` - Unit tests

#### 17. Multi-Model Orchestration - IMPLEMENTED
#### 15. Multi-Model Orchestration - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -956,7 +949,7 @@ codi --summarize-provider anthropic --summarize-model claude-3-5-haiku-latest
- `src/agent.ts` - `getSummaryProvider()` method
- `tests/multi-model.test.ts` - Unit tests

#### 18. Model Map (Multi-Model Orchestration) - COMPLETE
#### 16. Model Map (Multi-Model Orchestration) - COMPLETE

**Status**: Complete (Phases 1-3 + Model Roles)

Expand Down Expand Up @@ -1100,7 +1093,7 @@ pipelines:
- [ ] Config hot-reload support (watch file changes)
- [ ] Cost tracking per model/pipeline

#### 19. Multi-Agent Orchestration - IMPLEMENTED
#### 17. Multi-Agent Orchestration - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -1186,7 +1179,7 @@ codi
- ✅ Ollama (glm-4.7:cloud, qwen3-coder:480b-cloud)
- ✅ OpenAI

#### 20. Symbol Index - IMPLEMENTED
#### 18. Symbol Index - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -1216,15 +1209,15 @@ codi
- [ ] Symbol rename/refactor support
- [ ] Call graph tracking

#### 15. Code Snippets Library
#### 19. Code Snippets Library
**What**: Save and reuse code snippets.

**Implementation**:
- Store snippets in `~/.codi/snippets/`
- Add `/snippet save <name>` and `/snippet use <name>` commands
- Support tags and search

#### 16. Multi-file Refactoring
#### 20. Multi-file Refactoring
**What**: Coordinated changes across multiple files.

**Implementation**:
Expand All @@ -1233,7 +1226,7 @@ codi
- Generate coordinated edit plan
- Apply changes atomically (all or nothing)

#### 12. Test Runner Integration - IMPLEMENTED
#### 21. Test Runner Integration - IMPLEMENTED

**Status**: Complete

Expand All @@ -1254,7 +1247,7 @@ codi
- `src/tools/run-tests.ts` - Test runner tool implementation
- `tests/run-tests.test.ts` - Comprehensive test coverage

#### 13. Context Optimization - IMPLEMENTED
#### 22. Context Optimization - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -1284,7 +1277,7 @@ codi
- `-c, --compress` - Enable context compression (entity normalization) at startup
- Automatic compaction happens regardless of flag when needed

#### 14. RAG System (Embeddings) - IMPLEMENTED
#### 23. RAG System (Embeddings) - IMPLEMENTED

**Status**: Complete

Expand All @@ -1311,7 +1304,7 @@ codi
- OpenAI API key (for embeddings)
- Automatic fallback if unavailable

#### 15. Debug UI - IMPLEMENTED
#### 24. Debug UI - IMPLEMENTED

**Status**: Complete

Expand Down Expand Up @@ -1364,15 +1357,22 @@ For maximum impact with reasonable effort:
4. ~~**Diff Preview** - Safety improvement~~ DONE
5. ~~**Undo System** - Safety net for file changes~~ DONE
6. ~~**Cost Tracking** - API usage and cost monitoring~~ DONE
7. ~~**Test Runner** - Automated test execution~~ DONE
8. ~~**Context Optimization** - Smart compaction and deduplication~~ DONE
9. ~~**RAG System** - Semantic code search~~ DONE
10. ~~**Debug UI** - Spinners and graduated verbosity~~ DONE
7. ~~**Plugin System** - Third-party extensions (DISABLED)~~ DONE
8. ~~**Vision Support** - Image analysis capabilities~~ DONE
9. ~~**Interactive File Selection** - Fuzzy file finder (LOWER PRIORITY)~~ PLANNED
10. ~~**Parallel Tool Execution** - Concurrent operations (LOWER PRIORITY)~~ PLANNED
11. ~~**Web Search** - Search web via DuckDuckGo~~ DONE
12. ~~**Multi-Model Orchestration** - Use cheaper models for summarization~~ DONE
13. ~~**Model Map** - Docker-compose style multi-model config~~ DONE (Phases 1-3 complete)
14. ~~**Multi-Agent Orchestration** - Parallel agents with IPC permission bubbling~~ DONE
15. ~~**Security Model Validation** - AI-powered security analysis for bash commands~~ DONE
15. ~~**Symbol Index** - Code navigation enhancements~~ DONE
16. ~~**Code Snippets Library** - Code reuse system (LOWER PRIORITY)~~ PLANNED
17. ~~**Multi-file Refactoring** - Coordinated changes (LOWER PRIORITY)~~ PLANNED
18. ~~**Test Runner** - Automated test execution~~ DONE
19. ~~**Context Optimization** - Smart compaction and deduplication~~ DONE
20. ~~**RAG System** - Semantic code search~~ DONE
21. ~~**Debug UI** - Spinners and graduated verbosity~~ DONE
22. ~~**Security Model Validation** - AI-powered security analysis for bash commands~~ DONE

## Security Guidelines

Expand Down Expand Up @@ -1476,8 +1476,6 @@ See `workflow-status-roadmap.md` for detailed roadmap:

**Status**: ✅ **Production Ready** - Workflow execution fully functional

Previous versions had a vulnerability where chained commands like `!echo "?" | pnpm dev --quiet` only required permission for the first command (`echo`) but would silently execute subsequent commands (`pnpm`). This has been fixed by requiring explicit permission for ALL commands in a chain.

### AI-Powered Security Model Validation

Codi supports optional AI-powered security analysis for bash commands using a local Ollama model. When enabled, commands are analyzed for security risks before user confirmation.
Expand Down
58 changes: 56 additions & 2 deletions src/commands/compact-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const compactCommand: Command = {
name: 'compact',
aliases: ['summarize', 'compress', 'compression'],
description: 'Manage context size through summarization and compression',
usage: '/compact [summarize|compress|status|memory] [options]',
usage: '/compact [summarize|compress|status|memory|debug] [options]',
taskType: 'fast',
execute: async (args: string, context: CommandContext): Promise<string | null> => {
if (!context.agent) {
Expand All @@ -28,6 +28,60 @@ export const compactCommand: Command = {
const subcommand = parts[0] || 'status';
const subArgs = parts.slice(1).join(' ');

// /compact debug - Show detailed context debugging info
if (subcommand === 'debug') {
try {
const info = context.agent.getContextInfo();
const messages = context.agent.getMessages();

// Validate we have a messages array
if (!messages || !Array.isArray(messages)) {
return 'CONTEXT_DEBUG_ERROR:Invalid messages data';
}

// Build detailed debug output
const debugInfo = {
context: {
tokens: info.tokens,
messageTokens: info.messageTokens,
systemPromptTokens: info.systemPromptTokens,
toolDefinitionTokens: info.toolDefinitionTokens,
messages: info.messages,
userMessages: info.userMessages,
assistantMessages: info.assistantMessages,
toolResultMessages: info.toolResultMessages,
},
limits: {
maxTokens: info.maxTokens,
contextWindow: info.contextWindow,
effectiveLimit: info.effectiveLimit,
outputReserve: info.outputReserve,
safetyBuffer: info.safetyBuffer,
tierName: info.tierName,
},
state: {
hasSummary: info.hasSummary,
compressionEnabled: info.compressionEnabled,
compressionStats: info.compression,
workingSetFiles: info.workingSetFiles,
},
messagePreviews: messages.map((msg, index) => ({
index,
role: msg.role,
contentPreview: typeof msg.content === 'string'
? msg.content.slice(0, 200) + (msg.content.length > 200 ? '...' : '')
: `[complex content: ${msg.content.length} blocks]`,
contentLength: typeof msg.content === 'string' ? msg.content.length : (msg.content?.length || 0),
})),
conversationSummary: info.hasSummary ? '[summary exists - use /compact status for token info]' : null,
};

return `CONTEXT_DEBUG:${JSON.stringify(debugInfo, null, 2)}`;
} catch (error) {
return `CONTEXT_DEBUG_ERROR:${error instanceof Error ? error.message : 'Unknown error occurred'}`;
}
}

// /compact memory - Show memory usage
if (subcommand === 'memory') {
const monitor = getMemoryMonitor();
Expand Down Expand Up @@ -146,7 +200,7 @@ export const compactCommand: Command = {
return `COMPRESS_STATS:${JSON.stringify(output)}`;
}

return `COMPACT_ERROR:Unknown subcommand "${subcommand}". Use: status, summarize, compress`;
return `COMPACT_ERROR:Unknown subcommand "${subcommand}". Use: status, summarize, compress, memory, debug`;
},
};

Expand Down