codesavant 2.3.0 → 3.4.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 (3) hide show
  1. package/README.md +928 -64
  2. package/dist/cli.js +22122 -15709
  3. package/package.json +22 -6
package/README.md CHANGED
@@ -1,104 +1,968 @@
1
1
  # CodeSavant
2
2
 
3
- AI-powered coding assistant CLI with multi-provider support. A feature-complete alternative to Claude Code CLI that works with multiple LLM providers.
3
+ > AI-powered coding assistant CLI that brings Claude, GPT-4, and other leading AI models directly to your terminal.
4
4
 
5
- ## Features
5
+ [![NPM Version](https://img.shields.io/npm/v/codesavant.svg)](https://www.npmjs.com/package/codesavant)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Powered by Bun](https://img.shields.io/badge/Powered%20by-Bun-black)](https://bun.sh)
6
8
 
7
- - **Multi-Provider Support**: Anthropic, OpenAI, Gemini, Bedrock, Groq, DeepSeek, Ollama
8
- - **Full Tool Suite**: Read, Write, Edit, Bash, Glob, Grep, LSP, MultiEdit, LS, NotebookRead
9
- - **MCP Integration**: Connect to Model Context Protocol servers
10
- - **Hooks System**: 40+ hook events for customization
11
- - **Session Management**: Resume previous conversations
12
- - **Plan Mode**: Read-only exploration mode
13
- - **Subagent System**: Spawn specialized agents for complex tasks
9
+ ---
14
10
 
15
- ## Installation
11
+ ## ✨ Features
12
+
13
+ - 🤖 **Multi-Provider Support** - Works with Anthropic Claude, OpenAI GPT-4, Groq, DeepSeek, Google Gemini, Ollama, and AWS Bedrock
14
+ - 🎯 **Interactive REPL** - Rich terminal interface with streaming responses and real-time tool execution
15
+ - 🔧 **20+ Built-in Tools** - File operations, web search, code analysis, task management
16
+ - 🎨 **Aurora Theme** - Beautiful, modern color scheme optimized for terminal readability
17
+ - 💾 **Session Management** - Save, resume, and checkpoint your conversations
18
+ - 🔌 **MCP Integration** - Model Context Protocol support for extensibility
19
+ - 🎭 **Craft Skills** - AI-powered workflows for TDD, debugging, planning, and code review
20
+ - 🚀 **Multiple Execution Modes** - Interactive, single-command, pipe mode, or resume sessions
21
+ - 🛡️ **Security First** - Permission system with SSRF protection and command validation
22
+ - 📊 **Context Management** - Automatic token tracking and conversation compression
23
+
24
+ ---
25
+
26
+ ## 📦 Installation
27
+
28
+ CodeSavant requires [Bun](https://bun.sh) runtime (v1.0.0+).
29
+
30
+ ### Install Bun
16
31
 
17
32
  ```bash
18
- # Using bun (recommended)
19
- bun add -g codesavant
33
+ # macOS, Linux, WSL
34
+ curl -fsSL https://bun.sh/install | bash
20
35
 
21
- # Using npm
36
+ # Or with npm
37
+ npm install -g bun
38
+ ```
39
+
40
+ ### Install CodeSavant
41
+
42
+ ```bash
43
+ # Global installation
44
+ bun install -g codesavant
45
+
46
+ # Or with npm
22
47
  npm install -g codesavant
23
48
  ```
24
49
 
25
- ## Requirements
50
+ ---
26
51
 
27
- - [Bun](https://bun.sh) >= 1.0.0
52
+ ## 🚀 Quick Start
28
53
 
29
- ## Usage
54
+ ### 1. Launch Interactive REPL
30
55
 
31
56
  ```bash
32
- # Interactive mode
33
57
  codesavant
58
+ ```
34
59
 
35
- # Single prompt
36
- codesavant "Explain this codebase"
60
+ On first run, you'll be prompted to configure your preferred AI provider:
37
61
 
38
- # Print mode (non-interactive)
39
- codesavant -p "List all TypeScript files"
62
+ ```
63
+ Welcome to CodeSavant!
64
+ No providers configured. Let's set one up.
65
+
66
+ Which provider would you like to configure?
67
+ 1. Anthropic (Claude)
68
+ 2. OpenAI (GPT-4)
69
+ 3. Groq (Fast inference)
70
+ 4. Ollama (Local models)
71
+ > 1
72
+
73
+ Enter your Anthropic API key: sk-ant-...
74
+ ✓ API key saved!
75
+ ```
76
+
77
+ ### 2. Start Chatting
40
78
 
41
- # Pipe mode
42
- echo "Summarize this file" | codesavant --pipe
79
+ ```
80
+ > Hello! I need help refactoring my TypeScript code.
81
+
82
+ │ I'd be happy to help you refactor your TypeScript code! Could you share
83
+ │ the code you'd like to refactor, along with any specific goals you have?
84
+
85
+ > Read src/utils/parser.ts and suggest improvements
43
86
 
44
- # Resume session
45
- codesavant -r <session-id>
87
+ [Tool: Read] ✓ Complete
88
+ file: src/utils/parser.ts
89
+
90
+ │ Based on the code, here are my suggestions for refactoring:
91
+ │ 1. Extract magic numbers into constants
92
+ │ 2. Add explicit return types
93
+ │ 3. Use more descriptive variable names...
94
+ ```
46
95
 
47
- # Plan mode (read-only)
96
+ ---
97
+
98
+ ## 📖 Usage
99
+
100
+ ### Command-Line Interface
101
+
102
+ ```bash
103
+ # Interactive REPL (default)
104
+ codesavant
105
+
106
+ # Single command execution
107
+ codesavant -p "explain this error"
108
+
109
+ # Pipe content as context
110
+ cat error.log | codesavant --pipe
111
+
112
+ # Resume a previous session
113
+ codesavant -r abc123
114
+
115
+ # Specify provider and model
116
+ codesavant --provider openai --model gpt-4o
117
+
118
+ # Plan mode (read-only tools)
48
119
  codesavant --plan
49
120
 
50
- # Specify provider
121
+ # YOLO mode (auto-approve all)
122
+ codesavant --yolo
123
+
124
+ # Strict mode (approve everything)
125
+ codesavant --strict
126
+ ```
127
+
128
+ ### CLI Options
129
+
130
+ | Option | Description | Example |
131
+ |--------|-------------|---------|
132
+ | `-p, --print <prompt>` | Execute prompt and exit | `codesavant -p "fix bug"` |
133
+ | `--pipe` | Read prompt from stdin | `cat file \| codesavant --pipe` |
134
+ | `-r, --resume <id>` | Resume previous session | `codesavant -r abc123` |
135
+ | `--provider <name>` | Set AI provider | `codesavant --provider anthropic` |
136
+ | `--model <name>` | Set model | `codesavant --model gpt-4o` |
137
+ | `--plan` | Read-only mode | `codesavant --plan` |
138
+ | `--yolo` | Auto-approve all tools | `codesavant --yolo` |
139
+ | `--strict` | Approve all tools manually | `codesavant --strict` |
140
+ | `--cwd <dir>` | Set working directory | `codesavant --cwd /project` |
141
+ | `-o, --output-format` | Output format (text/json/markdown) | `codesavant -o json` |
142
+ | `--version` | Show version | `codesavant --version` |
143
+ | `--help` | Show help | `codesavant --help` |
144
+
145
+ ---
146
+
147
+ ## 🎮 REPL Commands
148
+
149
+ Once in the interactive REPL, use these slash commands:
150
+
151
+ ### Session Management
152
+
153
+ ```bash
154
+ /session # Show current session info
155
+ /session list # List recent sessions
156
+ /resume [#|id] # Resume a session
157
+ /checkpoint [name] # Create checkpoint
158
+ /clear # Clear conversation
159
+ /exit # Exit REPL
160
+ ```
161
+
162
+ ### Configuration & Status
163
+
164
+ ```bash
165
+ /config # Show configuration
166
+ /status # Show session status
167
+ /provider # Display current provider
168
+ /model # Display current model
169
+ /permissions [mode] # Show/set permissions
170
+ /login # Show auth status
171
+ /doctor # Run health checks
172
+ ```
173
+
174
+ ### Context & Memory
175
+
176
+ ```bash
177
+ /memory # Show project memory
178
+ /context # Show context usage
179
+ /history [count] # Show recent messages
180
+ /cost # Show token usage
181
+ /compact # Compress conversation
182
+ ```
183
+
184
+ ### Features & Tools
185
+
186
+ ```bash
187
+ /help # Show all commands
188
+ /skills # List available skills
189
+ /tasks # Display task list
190
+ /mcp # Show MCP server status
191
+ /plan # Toggle plan mode
192
+ /rewind [args] # Revert file changes
193
+ ```
194
+
195
+ ---
196
+
197
+ ## 🤖 Supported AI Providers
198
+
199
+ ### Anthropic Claude
200
+
201
+ ```bash
202
+ # Set API key
203
+ export ANTHROPIC_API_KEY="sk-ant-..."
204
+
205
+ # Use Claude
206
+ codesavant --provider anthropic --model claude-sonnet-4-20250514
207
+ ```
208
+
209
+ **Models:**
210
+ - `claude-sonnet-4-20250514` (recommended)
211
+ - `claude-3-opus-20240229`
212
+ - `claude-3-sonnet-20240229`
213
+ - `claude-3-haiku-20240307`
214
+
215
+ ### OpenAI GPT-4
216
+
217
+ ```bash
218
+ # Set API key
219
+ export OPENAI_API_KEY="sk-..."
220
+
221
+ # Use GPT-4
51
222
  codesavant --provider openai --model gpt-4o
52
223
  ```
53
224
 
54
- ## Configuration
225
+ **Models:**
226
+ - `gpt-4o` (recommended)
227
+ - `gpt-4o-mini`
228
+ - `gpt-4-turbo`
229
+ - `gpt-4`
230
+ - `gpt-3.5-turbo`
231
+
232
+ ### Groq (Fast Inference)
233
+
234
+ ```bash
235
+ # Set API key
236
+ export GROQ_API_KEY="gsk_..."
237
+
238
+ # Use Groq
239
+ codesavant --provider groq --model llama-3.1-70b-versatile
240
+ ```
241
+
242
+ **Models:**
243
+ - `llama-3.1-70b-versatile`
244
+ - `llama-3.2-90b-vision-preview`
245
+ - `mixtral-8x7b-32768`
55
246
 
56
- Set your API key for the provider you want to use:
247
+ ### Google Gemini
57
248
 
58
249
  ```bash
59
- # Anthropic (default)
60
- export ANTHROPIC_API_KEY=your-key
250
+ # Set API key
251
+ export GOOGLE_API_KEY="AIza..."
252
+
253
+ # Use Gemini
254
+ codesavant --provider gemini --model gemini-2.0-flash-exp
255
+ ```
256
+
257
+ **Models:**
258
+ - `gemini-2.0-flash-exp`
259
+ - `gemini-1.5-pro`
260
+ - `gemini-1.5-flash`
61
261
 
62
- # OpenAI
63
- export OPENAI_API_KEY=your-key
262
+ ### DeepSeek
64
263
 
65
- # Gemini
66
- export GOOGLE_API_KEY=your-key
264
+ ```bash
265
+ # Set API key
266
+ export DEEPSEEK_API_KEY="sk-..."
67
267
 
68
- # AWS Bedrock
69
- export AWS_ACCESS_KEY_ID=your-key
70
- export AWS_SECRET_ACCESS_KEY=your-secret
71
- export AWS_REGION=us-east-1
268
+ # Use DeepSeek
269
+ codesavant --provider deepseek --model deepseek-chat
72
270
  ```
73
271
 
74
- ## Providers
272
+ **Models:**
273
+ - `deepseek-chat`
274
+ - `deepseek-coder`
275
+
276
+ ### Ollama (Local Models)
277
+
278
+ ```bash
279
+ # Start Ollama server
280
+ ollama serve
281
+
282
+ # Pull a model
283
+ ollama pull llama3.2
284
+
285
+ # Use Ollama
286
+ codesavant --provider ollama --model llama3.2
287
+ ```
288
+
289
+ **Models:** Any Ollama model (llama3.2, codellama, mistral, etc.)
290
+
291
+ ### AWS Bedrock
292
+
293
+ ```bash
294
+ # Configure AWS credentials
295
+ aws configure
296
+
297
+ # Use Bedrock
298
+ codesavant --provider bedrock --model anthropic.claude-3-sonnet-20240229-v1:0
299
+ ```
300
+
301
+ ---
302
+
303
+ ## 🎭 Craft Skills (AI Workflows)
304
+
305
+ Craft skills are specialized AI workflows for software engineering tasks.
306
+
307
+ ### Process Skills (Use First)
308
+
309
+ ```bash
310
+ # Brainstorm and explore requirements
311
+ /craft ideate <feature description>
312
+
313
+ # Debug systematically
314
+ /craft diagnose <bug description>
315
+ ```
316
+
317
+ **Example:**
318
+ ```
319
+ > /craft ideate user authentication system
320
+
321
+ │ I'm using the ideate skill to brainstorm the authentication system.
322
+
323
+ │ Let's explore the requirements. What authentication method do you prefer?
324
+ │ 1. JWT tokens (stateless)
325
+ │ 2. Session-based (server-side state)
326
+ │ 3. OAuth 2.0 (third-party)
327
+
328
+ > 1
329
+
330
+ │ Great choice! Let's design a JWT-based auth system...
331
+ ```
332
+
333
+ ### Implementation Skills (During Work)
334
+
335
+ ```bash
336
+ # Test-driven development
337
+ /craft proof <feature>
338
+
339
+ # Create implementation plan
340
+ /craft blueprint <feature>
341
+
342
+ # Execute plan step-by-step
343
+ /craft build <plan>
344
+
345
+ # Parallel subagent execution
346
+ /craft assembly-line <plan>
347
+
348
+ # Create isolated git worktree
349
+ /craft workspace <feature-name>
350
+ ```
351
+
352
+ **Example:**
353
+ ```
354
+ > /craft proof login endpoint
355
+
356
+ │ I'm using TDD workflow. Let me write failing tests first...
357
+
358
+ [Tool: Write] ✓ Complete
359
+ file: tests/auth/login.test.ts
360
+
361
+ │ Tests written. Running to verify they fail...
362
+
363
+ [Tool: Bash] ✓ Complete
364
+ command: bun test tests/auth/login.test.ts
365
+
366
+ │ ✗ 3 tests failing (expected). Now implementing minimal code to pass...
367
+ ```
368
+
369
+ ### Quality Skills (After Work)
370
+
371
+ ```bash
372
+ # Verify work with evidence
373
+ /craft inspect <claim>
374
+
375
+ # Code review checklist
376
+ /craft review
377
+
378
+ # Final deployment checks
379
+ /craft ship
380
+ ```
381
+
382
+ ---
383
+
384
+ ## 🔧 Built-in Tools
385
+
386
+ CodeSavant provides 20+ tools that AI can use to help you:
387
+
388
+ ### File Operations
389
+
390
+ | Tool | Description | Example Use |
391
+ |------|-------------|-------------|
392
+ | **Read** | Read file contents | "Read src/main.ts" |
393
+ | **Write** | Create/overwrite files | "Create a new config.json" |
394
+ | **Edit** | Modify existing files | "Update the port in server.ts to 3000" |
395
+ | **Glob** | Find files by pattern | "Find all .tsx files" |
396
+ | **Grep** | Search file contents | "Search for TODO comments" |
397
+
398
+ ### Code & Execution
399
+
400
+ | Tool | Description | Example Use |
401
+ |------|-------------|-------------|
402
+ | **Bash** | Execute shell commands | "Run the tests" |
403
+ | **LSP** | Code analysis | "Get diagnostics for this file" |
404
+ | **Notebook** | Jupyter notebook ops | "Read notebook cells" |
405
+
406
+ ### Web & Search
407
+
408
+ | Tool | Description | Example Use |
409
+ |------|-------------|-------------|
410
+ | **WebSearch** | Search the internet | "Search for React 18 docs" |
411
+ | **WebFetch** | Fetch & analyze pages | "Fetch and summarize this article" |
412
+
413
+ ### Task Management
414
+
415
+ | Tool | Description | Example Use |
416
+ |------|-------------|-------------|
417
+ | **TaskCreate** | Create structured tasks | Used by workflows |
418
+ | **TaskList** | List all tasks | "Show my tasks" |
419
+ | **TaskUpdate** | Update task status | Automatic during work |
420
+
421
+ ### AI Features
422
+
423
+ | Tool | Description | Example Use |
424
+ |------|-------------|-------------|
425
+ | **Task (Subagent)** | Spawn parallel agents | For complex multi-step work |
426
+ | **Skill** | Execute custom skills | Via /craft commands |
427
+ | **AskUser** | Interactive questions | AI asks for clarification |
428
+
429
+ ---
430
+
431
+ ## 📁 Configuration
432
+
433
+ ### Settings File
434
+
435
+ CodeSavant uses `.codesavant/settings.json`:
436
+
437
+ ```json
438
+ {
439
+ "providers": {
440
+ "anthropic": {
441
+ "apiKey": "sk-ant-..."
442
+ },
443
+ "openai": {
444
+ "apiKey": "sk-..."
445
+ }
446
+ },
447
+ "defaultProvider": "anthropic",
448
+ "defaultModel": "claude-sonnet-4-20250514",
449
+ "hooks": {
450
+ "session_start": "echo 'Session started!'",
451
+ "user_prompt_submit": "git status"
452
+ },
453
+ "permissions": {
454
+ "mode": "default"
455
+ }
456
+ }
457
+ ```
458
+
459
+ ### Project Memory (SAVANT.md)
460
+
461
+ Create `.codesavant/SAVANT.md` for project context:
462
+
463
+ ```markdown
464
+ # Project: MyApp
465
+
466
+ ## Architecture
467
+ - Next.js 14 app router
468
+ - PostgreSQL database
469
+ - tRPC API layer
470
+
471
+ ## Coding Standards
472
+ - Use TypeScript strict mode
473
+ - Prefer functional components
474
+ - Write tests for all features
475
+ ```
476
+
477
+ AI will read this automatically for project context.
478
+
479
+ ### Custom Skills
480
+
481
+ Create custom skills in `.codesavant/skills/`:
482
+
483
+ ```markdown
484
+ ---
485
+ name: deploy
486
+ category: implementation
487
+ description: Deploy to production
488
+ ---
489
+
490
+ # Deploy Skill
491
+
492
+ Follow these steps to deploy:
493
+
494
+ 1. Run tests: `bun test`
495
+ 2. Build: `bun run build`
496
+ 3. Deploy: `vercel deploy --prod`
497
+ ```
498
+
499
+ ---
500
+
501
+ ## 🎨 Aurora Theme
502
+
503
+ CodeSavant features a modern "Aurora" color scheme:
504
+
505
+ - **Electric Blue** - Assistant messages, primary UI
506
+ - **Aqua** - User input, selections
507
+ - **Emerald** - Success states, completions
508
+ - **Amber** - Warnings, processing
509
+ - **Crimson** - Errors, failures
510
+ - **Violet** - Keywords, special states
511
+
512
+ Colors are optimized for terminal readability on both light and dark backgrounds.
513
+
514
+ ---
515
+
516
+ ## 💡 Examples
517
+
518
+ ### Example 1: Code Review
519
+
520
+ ```bash
521
+ codesavant
522
+
523
+ > Review the changes in src/auth.ts and suggest improvements
524
+
525
+ [Tool: Read] ✓ Complete
526
+ file: src/auth.ts
527
+
528
+ │ I've reviewed the authentication code. Here are my findings:
529
+
530
+ │ **Security Issues:**
531
+ │ 1. Line 23: Password stored in plaintext - should use bcrypt
532
+ │ 2. Line 45: JWT secret hardcoded - move to environment variable
533
+
534
+ │ **Code Quality:**
535
+ │ 1. Consider extracting validation logic into separate function
536
+ │ 2. Add error handling for database connection failures
537
+
538
+ │ Would you like me to fix these issues?
539
+
540
+ > Yes, fix the security issues
541
+
542
+ [Tool: Edit] ✓ Complete
543
+ file: src/auth.ts
544
+
545
+ │ I've updated the code to:
546
+ │ - Hash passwords with bcrypt
547
+ │ - Load JWT secret from environment variable
548
+ │ - Add proper error handling
549
+
550
+ │ Changes made to src/auth.ts (lines 23-50)
551
+ ```
552
+
553
+ ### Example 2: TDD Workflow
554
+
555
+ ```bash
556
+ codesavant
557
+
558
+ > /craft proof user registration endpoint
559
+
560
+ │ Starting TDD workflow. Writing failing tests first...
561
+
562
+ [Tool: Write] ✓ Complete
563
+ file: tests/api/register.test.ts
564
+
565
+ │ Test cases written:
566
+ │ 1. Should register new user with valid data
567
+ │ 2. Should reject duplicate email
568
+ │ 3. Should validate password strength
569
+ │ 4. Should return JWT token on success
570
+
571
+ │ Running tests...
572
+
573
+ [Tool: Bash] ✓ Complete
574
+ command: bun test tests/api/register.test.ts
575
+
576
+ │ ✗ All 4 tests failing (expected)
577
+
578
+ │ Now implementing minimal code to pass tests...
579
+
580
+ [Tool: Write] ✓ Complete
581
+ file: src/api/register.ts
582
+
583
+ [Tool: Bash] ✓ Complete
584
+ command: bun test tests/api/register.test.ts
585
+
586
+ │ ✓ All 4 tests passing!
587
+
588
+ │ Implementation complete. Ready to commit?
589
+
590
+ > Yes
591
+
592
+ [Tool: Bash] ✓ Complete
593
+ command: git add . && git commit -m "feat: add user registration endpoint"
594
+ ```
595
+
596
+ ### Example 3: Debugging
597
+
598
+ ```bash
599
+ codesavant
600
+
601
+ > My app crashes with "Cannot read property 'name' of undefined"
602
+
603
+ │ Let's debug this systematically. Can you share the error stack trace
604
+ │ or the file where the error occurs?
605
+
606
+ > Read src/components/UserProfile.tsx
607
+
608
+ [Tool: Read] ✓ Complete
609
+ file: src/components/UserProfile.tsx
610
+
611
+ │ Found the issue at line 15:
612
+
613
+ │ ```typescript
614
+ │ const userName = user.name; // user might be undefined
615
+ │ ```
616
+
617
+ │ The problem is accessing `user.name` without checking if `user` exists first.
618
+
619
+ │ Root cause: The component renders before the user data is loaded.
620
+
621
+ │ Fix: Add a loading check:
622
+
623
+ │ ```typescript
624
+ │ if (!user) return <Loading />;
625
+ │ const userName = user.name;
626
+ │ ```
627
+
628
+ │ Should I apply this fix?
629
+
630
+ > Yes
631
+
632
+ [Tool: Edit] ✓ Complete
633
+ file: src/components/UserProfile.tsx
634
+ ```
635
+
636
+ ### Example 4: Pipe Mode
637
+
638
+ ```bash
639
+ # Analyze an error log
640
+ cat error.log | codesavant --pipe -p "analyze this error and suggest a fix"
641
+
642
+ # Review a diff
643
+ git diff | codesavant --pipe -p "review these changes"
644
+
645
+ # Explain code
646
+ cat complex-algorithm.ts | codesavant --pipe -p "explain this algorithm step by step"
647
+ ```
648
+
649
+ ### Example 5: Session Management
650
+
651
+ ```bash
652
+ # Start working on a feature
653
+ codesavant
654
+
655
+ > I need to add OAuth authentication
656
+
657
+ │ Let's plan the OAuth implementation...
658
+ │ [Long conversation with code changes]
659
+
660
+ > /checkpoint oauth-implementation
661
+
662
+ │ ✓ Checkpoint created: oauth-implementation
663
+
664
+ > /exit
665
+
666
+ # Later, resume the session
667
+ codesavant -r
668
+
669
+ > /resume
670
+
671
+ │ Recent sessions:
672
+ │ 1. [2h ago] OAuth authentication (15 messages)
673
+ │ 2. [1d ago] Bug fix in parser (8 messages)
674
+
675
+ │ Which session? (1-2)
676
+
677
+ > 1
678
+
679
+ │ Resuming session...
680
+ │ [Previous conversation restored]
681
+
682
+ > Continue with the OAuth implementation
683
+ ```
684
+
685
+ ---
686
+
687
+ ## 🔐 Security
688
+
689
+ CodeSavant includes comprehensive security features:
690
+
691
+ ### Permission Modes
692
+
693
+ - **Default** - Approve destructive operations interactively
694
+ - **Plan** (`--plan`) - Read-only, no file modifications
695
+ - **YOLO** (`--yolo`) - Auto-approve (use with caution!)
696
+ - **Strict** (`--strict`) - Approve all tools manually
697
+
698
+ ### Built-in Protections
699
+
700
+ - ✅ **SSRF Protection** - Blocks private IPs, localhost in WebFetch
701
+ - ✅ **Path Validation** - Prevents traversal attacks in file operations
702
+ - ✅ **Command Safety** - Array-based command spawning (no shell injection)
703
+ - ✅ **Secrets Handling** - API keys from environment/config only
704
+ - ✅ **Tool Risk Assessment** - High-risk tools require approval
705
+
706
+ ### Best Practices
707
+
708
+ ```bash
709
+ # Use plan mode for exploratory analysis
710
+ codesavant --plan
711
+
712
+ # Review changes before committing
713
+ codesavant # (default mode prompts for destructive ops)
714
+
715
+ # Avoid YOLO mode in production environments
716
+ codesavant --yolo # ⚠️ Use only in safe environments
717
+ ```
718
+
719
+ ---
720
+
721
+ ## 🚀 Advanced Features
722
+
723
+ ### Hooks System
724
+
725
+ Execute commands at key lifecycle events:
726
+
727
+ ```json
728
+ {
729
+ "hooks": {
730
+ "session_start": "git pull origin main",
731
+ "user_prompt_submit": "git status",
732
+ "session_end": "git stash"
733
+ }
734
+ }
735
+ ```
736
+
737
+ ### MCP Server Integration
738
+
739
+ Connect external tools via Model Context Protocol:
740
+
741
+ ```json
742
+ {
743
+ "mcpServers": {
744
+ "github": {
745
+ "command": "npx",
746
+ "args": ["-y", "@modelcontextprotocol/server-github"],
747
+ "env": {
748
+ "GITHUB_TOKEN": "ghp_..."
749
+ }
750
+ }
751
+ }
752
+ }
753
+ ```
754
+
755
+ ### Background Tasks
756
+
757
+ Run long operations in the background:
758
+
759
+ ```bash
760
+ > /bg npm run build
761
+
762
+ │ Task started in background (ID: bg_abc123)
763
+ │ You can continue working...
764
+
765
+ > /tasks
766
+
767
+ │ Active Tasks:
768
+ │ ● bg_abc123: npm run build (Running, 45s)
769
+ ```
770
+
771
+ ### File Change Tracking
772
+
773
+ Revert changes from previous operations:
774
+
775
+ ```bash
776
+ > /rewind
777
+
778
+ │ Recent file changes:
779
+ │ 1. src/config.ts (2 min ago)
780
+ │ 2. src/auth.ts (5 min ago)
781
+
782
+ │ Revert which file? (1-2, or 'all')
783
+
784
+ > 1
785
+
786
+ [Tool: Bash] ✓ Complete
787
+ command: git restore src/config.ts
788
+
789
+ │ ✓ Reverted src/config.ts
790
+ ```
791
+
792
+ ---
793
+
794
+ ## 📊 Context Management
795
+
796
+ CodeSavant automatically manages context window:
797
+
798
+ ```bash
799
+ > /context
800
+
801
+ │ Context Usage:
802
+ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45,230 / 200,000 tokens (23%)
803
+
804
+ │ Breakdown:
805
+ │ - System: 2,450 tokens (5%)
806
+ │ - User: 18,920 tokens (42%)
807
+ │ - Assistant: 20,860 tokens (46%)
808
+ │ - Tools: 3,000 tokens (7%)
809
+
810
+ │ Status: ✓ Healthy
811
+ ```
812
+
813
+ When approaching limits, use `/compact` to compress:
814
+
815
+ ```bash
816
+ > /compact
817
+
818
+ │ Compressing conversation history...
819
+
820
+ │ Before: 45,230 tokens (23%)
821
+ │ After: 22,100 tokens (11%)
822
+
823
+ │ ✓ Compressed 50% of conversation
824
+ │ ✓ Key information preserved
825
+ ```
826
+
827
+ ---
828
+
829
+ ## 🐛 Troubleshooting
830
+
831
+ ### Provider Not Working
832
+
833
+ ```bash
834
+ # Check authentication
835
+ codesavant
836
+ > /login
837
+
838
+ # Run diagnostics
839
+ > /doctor
840
+
841
+ │ Running health checks...
842
+ │ ✓ Provider: anthropic (authenticated)
843
+ │ ✓ Storage: ~/.codesavant/ (writable)
844
+ │ ✓ Working directory: /project (writable)
845
+ │ ✓ All systems operational
846
+ ```
847
+
848
+ ### Session Not Saving
849
+
850
+ ```bash
851
+ # Check permissions
852
+ ls -la ~/.codesavant/
853
+
854
+ # Should see:
855
+ # drwxr-xr-x sessions/
856
+ # -rw-r--r-- settings.json
857
+
858
+ # Fix permissions if needed
859
+ chmod 755 ~/.codesavant
860
+ chmod 644 ~/.codesavant/settings.json
861
+ ```
862
+
863
+ ### API Rate Limits
864
+
865
+ ```bash
866
+ # Check cost/usage
867
+ > /cost
868
+
869
+ │ Token Usage (This Session):
870
+ │ - Input: 12,450 tokens
871
+ │ - Output: 8,920 tokens
872
+ │ - Total: 21,370 tokens
873
+
874
+ │ Estimated Cost: $0.32
875
+ ```
876
+
877
+ ---
878
+
879
+ ## 🤝 Contributing
880
+
881
+ We welcome contributions! CodeSavant is open source under the MIT license.
882
+
883
+ ### Development Setup
884
+
885
+ ```bash
886
+ # Clone repository
887
+ git clone https://github.com/vaggarwal039/codesavant.git
888
+ cd codesavant
889
+
890
+ # Install dependencies
891
+ bun install
892
+
893
+ # Run in development
894
+ bun run src/cli.ts
895
+
896
+ # Run tests
897
+ bun test
898
+
899
+ # Build for production
900
+ bun run build
901
+ ```
902
+
903
+ ### Project Structure
904
+
905
+ ```
906
+ codesavant/
907
+ ├── src/
908
+ │ ├── cli.ts # CLI entry point
909
+ │ ├── repl-ink.tsx # Interactive REPL
910
+ │ ├── agent.ts # AI agent orchestration
911
+ │ ├── providers/ # AI provider implementations
912
+ │ ├── tools/ # Built-in tools
913
+ │ ├── skills/ # Craft skills
914
+ │ ├── components/ # UI components
915
+ │ └── ...
916
+ ├── tests/ # Test suite (4,500+ tests)
917
+ ├── docs/ # Documentation
918
+ └── package.json
919
+ ```
920
+
921
+ ---
922
+
923
+ ## 📄 License
924
+
925
+ MIT License - see [LICENSE](LICENSE) file for details.
926
+
927
+ ---
928
+
929
+ ## 🙏 Acknowledgments
930
+
931
+ Built with:
932
+ - [Bun](https://bun.sh) - Fast JavaScript runtime
933
+ - [Ink](https://github.com/vadimdemedes/ink) - React for CLIs
934
+ - [Commander.js](https://github.com/tj/commander.js) - CLI framework
935
+ - [Chalk](https://github.com/chalk/chalk) - Terminal styling
936
+
937
+ Powered by:
938
+ - [Anthropic Claude](https://anthropic.com)
939
+ - [OpenAI GPT-4](https://openai.com)
940
+ - [Google Gemini](https://deepmind.google/technologies/gemini/)
941
+ - [Groq](https://groq.com)
942
+ - [DeepSeek](https://deepseek.com)
943
+
944
+ ---
945
+
946
+ ## 📞 Support
947
+
948
+ - **Issues**: [GitHub Issues](https://github.com/vaggarwal039/codesavant/issues)
949
+ - **Discussions**: [GitHub Discussions](https://github.com/vaggarwal039/codesavant/discussions)
950
+ - **Email**: vishal.a.aggarwal@pwc.com
75
951
 
76
- | Provider | Models | Auth |
77
- |----------|--------|------|
78
- | Anthropic | claude-3-opus, claude-3-sonnet, claude-3-haiku | ANTHROPIC_API_KEY |
79
- | OpenAI | gpt-4o, gpt-4-turbo, gpt-3.5-turbo | OPENAI_API_KEY |
80
- | Gemini | gemini-1.5-pro, gemini-1.5-flash | GOOGLE_API_KEY |
81
- | Bedrock | claude-3, llama-3 | AWS credentials |
82
- | Groq | llama-3, mixtral | GROQ_API_KEY |
83
- | DeepSeek | deepseek-chat, deepseek-coder | DEEPSEEK_API_KEY |
84
- | Ollama | Any local model | Local server |
952
+ ---
85
953
 
86
- ## Tools
954
+ ## 🗺️ Roadmap
87
955
 
88
- CodeSavant includes a comprehensive set of tools:
956
+ Coming soon:
957
+ - [ ] Web dashboard for session management
958
+ - [ ] VS Code extension
959
+ - [ ] Custom theme editor
960
+ - [ ] Team collaboration features
961
+ - [ ] Cloud session sync
962
+ - [ ] More AI providers (Cohere, Mistral, etc.)
89
963
 
90
- - **Read**: Read file contents
91
- - **Write**: Create/overwrite files
92
- - **Edit**: Make targeted edits to files
93
- - **MultiEdit**: Batch edit multiple files atomically
94
- - **Bash**: Execute shell commands
95
- - **Glob**: Find files by pattern
96
- - **Grep**: Search file contents
97
- - **LS**: List directory contents
98
- - **LSP**: Language server integration
99
- - **NotebookRead**: Read Jupyter notebooks
100
- - **Task**: Spawn subagents for complex tasks
964
+ ---
101
965
 
102
- ## License
966
+ **Made with ❤️ by Vishal Aggarwal**
103
967
 
104
- MIT
968
+ **Star ⭐ this repo if you find it useful!**