codesavant 3.4.0 → 4.0.0
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/README.md +826 -0
- package/dist/cli.js +60649 -31377
- package/package.json +31 -6
- package/scripts/postinstall.cjs +103 -0
package/README.md
ADDED
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
# CodeSavant
|
|
2
|
+
|
|
3
|
+
> AI-powered autonomous coding agent CLI that brings Claude, GPT-4, and other leading AI models directly to your terminal. Features autonomous workflows, a skill marketplace, self-improving brain, and design intelligence.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/codesavant)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://bun.sh)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What's New in v4.0
|
|
12
|
+
|
|
13
|
+
- **Autonomous /craft Cycle** - End-to-end feature building: research, question, plan, build, verify -- all orchestrated automatically
|
|
14
|
+
- **Skill Marketplace** - Browse, install, and publish reusable AI skills with version management and hash verification
|
|
15
|
+
- **Self-Improving Brain** - Cross-session learning that detects patterns, captures failures, and optimizes over time
|
|
16
|
+
- **Design Intelligence Foundation** - Frontend detection, design token vocabulary, and DesignBrief schemas for style-aware code generation
|
|
17
|
+
- **360+ Test Files** - Comprehensive test coverage across unit, integration, e2e, performance, and security suites
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- **Multi-Provider Support** - Works with Anthropic Claude, OpenAI GPT-4, Groq, DeepSeek, Google Gemini, Ollama, and AWS Bedrock
|
|
24
|
+
- **Interactive REPL** - Rich terminal interface with streaming responses and real-time tool execution
|
|
25
|
+
- **20+ Built-in Tools** - File operations, web search, code analysis, task management
|
|
26
|
+
- **Autonomous Agent** - Self-directed research, questioning, planning, and building via /craft
|
|
27
|
+
- **Skill Marketplace** - Browse, install, and publish community skills
|
|
28
|
+
- **Self-Improving Brain** - Pattern detection, failure capture, and cross-session learning
|
|
29
|
+
- **Design Intelligence** - Frontend detection, style vocabulary, and design token resolution
|
|
30
|
+
- **Craft Skills** - AI-powered workflows for TDD, debugging, planning, and code review
|
|
31
|
+
- **Session Management** - Save, resume, and checkpoint your conversations
|
|
32
|
+
- **MCP Integration** - Model Context Protocol support for extensibility
|
|
33
|
+
- **Security First** - Permission system with SSRF protection and command validation
|
|
34
|
+
- **Context Management** - Automatic token tracking and conversation compression
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
CodeSavant requires [Bun](https://bun.sh) runtime (v1.0.0+).
|
|
41
|
+
|
|
42
|
+
### Install Bun
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# macOS, Linux, WSL
|
|
46
|
+
curl -fsSL https://bun.sh/install | bash
|
|
47
|
+
|
|
48
|
+
# Or with npm
|
|
49
|
+
npm install -g bun
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Install CodeSavant
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Global installation
|
|
56
|
+
bun install -g codesavant
|
|
57
|
+
|
|
58
|
+
# Or with npm
|
|
59
|
+
npm install -g codesavant
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
### 1. Launch Interactive REPL
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
codesavant
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
On first run, you'll be prompted to configure your preferred AI provider:
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Welcome to CodeSavant!
|
|
76
|
+
No providers configured. Let's set one up.
|
|
77
|
+
|
|
78
|
+
Which provider would you like to configure?
|
|
79
|
+
1. Anthropic (Claude)
|
|
80
|
+
2. OpenAI (GPT-4)
|
|
81
|
+
3. Groq (Fast inference)
|
|
82
|
+
4. Ollama (Local models)
|
|
83
|
+
> 1
|
|
84
|
+
|
|
85
|
+
Enter your Anthropic API key: sk-ant-...
|
|
86
|
+
✓ API key saved!
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 2. Start Chatting
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
> Hello! I need help refactoring my TypeScript code.
|
|
93
|
+
|
|
94
|
+
│ I'd be happy to help you refactor your TypeScript code! Could you share
|
|
95
|
+
│ the code you'd like to refactor, along with any specific goals you have?
|
|
96
|
+
|
|
97
|
+
> Read src/utils/parser.ts and suggest improvements
|
|
98
|
+
|
|
99
|
+
[Tool: Read] ✓ Complete
|
|
100
|
+
file: src/utils/parser.ts
|
|
101
|
+
|
|
102
|
+
│ Based on the code, here are my suggestions for refactoring:
|
|
103
|
+
│ 1. Extract magic numbers into constants
|
|
104
|
+
│ 2. Add explicit return types
|
|
105
|
+
│ 3. Use more descriptive variable names...
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Usage
|
|
111
|
+
|
|
112
|
+
### Command-Line Interface
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Interactive REPL (default)
|
|
116
|
+
codesavant
|
|
117
|
+
|
|
118
|
+
# Single command execution
|
|
119
|
+
codesavant -p "explain this error"
|
|
120
|
+
|
|
121
|
+
# Pipe content as context
|
|
122
|
+
cat error.log | codesavant --pipe
|
|
123
|
+
|
|
124
|
+
# Resume a previous session
|
|
125
|
+
codesavant -r abc123
|
|
126
|
+
|
|
127
|
+
# Specify provider and model
|
|
128
|
+
codesavant --provider openai --model gpt-4o
|
|
129
|
+
|
|
130
|
+
# Plan mode (read-only tools)
|
|
131
|
+
codesavant --plan
|
|
132
|
+
|
|
133
|
+
# YOLO mode (auto-approve all)
|
|
134
|
+
codesavant --yolo
|
|
135
|
+
|
|
136
|
+
# Strict mode (approve everything)
|
|
137
|
+
codesavant --strict
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### CLI Options
|
|
141
|
+
|
|
142
|
+
| Option | Description | Example |
|
|
143
|
+
|--------|-------------|---------|
|
|
144
|
+
| `-p, --print <prompt>` | Execute prompt and exit | `codesavant -p "fix bug"` |
|
|
145
|
+
| `--pipe` | Read prompt from stdin | `cat file \| codesavant --pipe` |
|
|
146
|
+
| `-r, --resume <id>` | Resume previous session | `codesavant -r abc123` |
|
|
147
|
+
| `--provider <name>` | Set AI provider | `codesavant --provider anthropic` |
|
|
148
|
+
| `--model <name>` | Set model | `codesavant --model gpt-4o` |
|
|
149
|
+
| `--plan` | Read-only mode | `codesavant --plan` |
|
|
150
|
+
| `--yolo` | Auto-approve all tools | `codesavant --yolo` |
|
|
151
|
+
| `--strict` | Approve all tools manually | `codesavant --strict` |
|
|
152
|
+
| `--cwd <dir>` | Set working directory | `codesavant --cwd /project` |
|
|
153
|
+
| `-o, --output-format` | Output format (text/json/markdown) | `codesavant -o json` |
|
|
154
|
+
| `--version` | Show version | `codesavant --version` |
|
|
155
|
+
| `--help` | Show help | `codesavant --help` |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## REPL Commands
|
|
160
|
+
|
|
161
|
+
Once in the interactive REPL, use these slash commands:
|
|
162
|
+
|
|
163
|
+
### Session Management
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
/session # Show current session info
|
|
167
|
+
/session list # List recent sessions
|
|
168
|
+
/resume [#|id] # Resume a session
|
|
169
|
+
/checkpoint [name] # Create checkpoint
|
|
170
|
+
/clear # Clear conversation
|
|
171
|
+
/exit # Exit REPL
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Configuration & Status
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
/config # Show configuration
|
|
178
|
+
/status # Show session status
|
|
179
|
+
/provider # Display current provider
|
|
180
|
+
/model # Display current model
|
|
181
|
+
/permissions [mode] # Show/set permissions
|
|
182
|
+
/login # Show auth status
|
|
183
|
+
/doctor # Run health checks
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Context & Memory
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
/memory # Show project memory
|
|
190
|
+
/context # Show context usage
|
|
191
|
+
/history [count] # Show recent messages
|
|
192
|
+
/cost # Show token usage
|
|
193
|
+
/compact # Compress conversation
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Features & Tools
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
/help # Show all commands
|
|
200
|
+
/skills # List available skills
|
|
201
|
+
/tasks # Display task list
|
|
202
|
+
/mcp # Show MCP server status
|
|
203
|
+
/plan # Toggle plan mode
|
|
204
|
+
/rewind [args] # Revert file changes
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Supported AI Providers
|
|
210
|
+
|
|
211
|
+
### Anthropic Claude
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Set API key
|
|
215
|
+
export ANTHROPIC_API_KEY="sk-ant-..."
|
|
216
|
+
|
|
217
|
+
# Use Claude
|
|
218
|
+
codesavant --provider anthropic --model claude-sonnet-4-20250514
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Models:**
|
|
222
|
+
- `claude-sonnet-4-20250514` (recommended)
|
|
223
|
+
- `claude-3-opus-20240229`
|
|
224
|
+
- `claude-3-sonnet-20240229`
|
|
225
|
+
- `claude-3-haiku-20240307`
|
|
226
|
+
|
|
227
|
+
### OpenAI GPT-4
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Set API key
|
|
231
|
+
export OPENAI_API_KEY="sk-..."
|
|
232
|
+
|
|
233
|
+
# Use GPT-4
|
|
234
|
+
codesavant --provider openai --model gpt-4o
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Models:**
|
|
238
|
+
- `gpt-4o` (recommended)
|
|
239
|
+
- `gpt-4o-mini`
|
|
240
|
+
- `gpt-4-turbo`
|
|
241
|
+
- `gpt-4`
|
|
242
|
+
- `gpt-3.5-turbo`
|
|
243
|
+
|
|
244
|
+
### Groq (Fast Inference)
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Set API key
|
|
248
|
+
export GROQ_API_KEY="gsk_..."
|
|
249
|
+
|
|
250
|
+
# Use Groq
|
|
251
|
+
codesavant --provider groq --model llama-3.1-70b-versatile
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Models:**
|
|
255
|
+
- `llama-3.1-70b-versatile`
|
|
256
|
+
- `llama-3.2-90b-vision-preview`
|
|
257
|
+
- `mixtral-8x7b-32768`
|
|
258
|
+
|
|
259
|
+
### Google Gemini
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Set API key
|
|
263
|
+
export GOOGLE_API_KEY="AIza..."
|
|
264
|
+
|
|
265
|
+
# Use Gemini
|
|
266
|
+
codesavant --provider gemini --model gemini-2.0-flash-exp
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Models:**
|
|
270
|
+
- `gemini-2.0-flash-exp`
|
|
271
|
+
- `gemini-1.5-pro`
|
|
272
|
+
- `gemini-1.5-flash`
|
|
273
|
+
|
|
274
|
+
### DeepSeek
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Set API key
|
|
278
|
+
export DEEPSEEK_API_KEY="sk-..."
|
|
279
|
+
|
|
280
|
+
# Use DeepSeek
|
|
281
|
+
codesavant --provider deepseek --model deepseek-chat
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Models:**
|
|
285
|
+
- `deepseek-chat`
|
|
286
|
+
- `deepseek-coder`
|
|
287
|
+
|
|
288
|
+
### Ollama (Local Models)
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# Start Ollama server
|
|
292
|
+
ollama serve
|
|
293
|
+
|
|
294
|
+
# Pull a model
|
|
295
|
+
ollama pull llama3.2
|
|
296
|
+
|
|
297
|
+
# Use Ollama
|
|
298
|
+
codesavant --provider ollama --model llama3.2
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Models:** Any Ollama model (llama3.2, codellama, mistral, etc.)
|
|
302
|
+
|
|
303
|
+
### AWS Bedrock
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Configure AWS credentials
|
|
307
|
+
aws configure
|
|
308
|
+
|
|
309
|
+
# Use Bedrock
|
|
310
|
+
codesavant --provider bedrock --model anthropic.claude-3-sonnet-20240229-v1:0
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## Autonomous /craft Workflows
|
|
316
|
+
|
|
317
|
+
The `/craft` command provides fully autonomous AI workflows that research, plan, build, and verify features end-to-end.
|
|
318
|
+
|
|
319
|
+
### Process Skills (Use First)
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# Brainstorm and explore requirements
|
|
323
|
+
/craft ideate <feature description>
|
|
324
|
+
|
|
325
|
+
# Debug systematically
|
|
326
|
+
/craft diagnose <bug description>
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Implementation Skills (During Work)
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
# Test-driven development
|
|
333
|
+
/craft proof <feature>
|
|
334
|
+
|
|
335
|
+
# Create implementation plan
|
|
336
|
+
/craft blueprint <feature>
|
|
337
|
+
|
|
338
|
+
# Execute plan step-by-step
|
|
339
|
+
/craft build <plan>
|
|
340
|
+
|
|
341
|
+
# Parallel subagent execution
|
|
342
|
+
/craft assembly-line <plan>
|
|
343
|
+
|
|
344
|
+
# Create isolated git worktree
|
|
345
|
+
/craft workspace <feature-name>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Quality Skills (After Work)
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# Verify work with evidence
|
|
352
|
+
/craft inspect <claim>
|
|
353
|
+
|
|
354
|
+
# Code review checklist
|
|
355
|
+
/craft review
|
|
356
|
+
|
|
357
|
+
# Final deployment checks
|
|
358
|
+
/craft ship
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Full Autonomous Cycle
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Fully autonomous: research → question → plan → build → verify
|
|
365
|
+
/craft <feature description>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
The craft orchestrator spawns research agents in parallel, asks targeted questions, builds a development roadmap, executes plans with atomic commits, and verifies output quality -- all autonomously.
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Skill Marketplace
|
|
373
|
+
|
|
374
|
+
Browse and install community-created skills, or publish your own.
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
# Browse available skills
|
|
378
|
+
/skills marketplace
|
|
379
|
+
|
|
380
|
+
# Install a skill
|
|
381
|
+
/skills install <skill-name>
|
|
382
|
+
|
|
383
|
+
# Publish your skill
|
|
384
|
+
/skills publish <skill-path>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Skills are verified with SHA-256 hash integrity checks, support semantic versioning, and handle slug collisions gracefully.
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Self-Improving Brain
|
|
392
|
+
|
|
393
|
+
CodeSavant learns across sessions:
|
|
394
|
+
|
|
395
|
+
- **Pattern Detection** - Identifies recurring coding patterns and preferences
|
|
396
|
+
- **Failure Capture** - Records what went wrong and how it was fixed
|
|
397
|
+
- **Optimization** - Detects opportunities to improve workflows
|
|
398
|
+
- **Memory Resolution** - Three-tier priority system (project > user > global)
|
|
399
|
+
|
|
400
|
+
The brain operates transparently -- it writes insights after sessions and reads them before the next one, getting better over time without manual configuration.
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Design Intelligence
|
|
405
|
+
|
|
406
|
+
CodeSavant automatically detects frontend work and applies design-aware context:
|
|
407
|
+
|
|
408
|
+
- **Frontend Detection** - Identifies frontend tasks from file extensions (.tsx, .jsx, .css, .vue, .svelte), import patterns, and intent keywords
|
|
409
|
+
- **Style Vocabulary** - 50+ design buzzwords (minimal, bold, cinematic, etc.) mapped to concrete design tokens
|
|
410
|
+
- **Design Brief Schema** - Structured, validated design preferences with opinionated defaults
|
|
411
|
+
- **Token Resolution** - Translates style buzzwords into actionable token hints (border-radius, spacing, contrast, etc.)
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## Built-in Tools
|
|
416
|
+
|
|
417
|
+
CodeSavant provides 20+ tools that AI can use to help you:
|
|
418
|
+
|
|
419
|
+
### File Operations
|
|
420
|
+
|
|
421
|
+
| Tool | Description | Example Use |
|
|
422
|
+
|------|-------------|-------------|
|
|
423
|
+
| **Read** | Read file contents | "Read src/main.ts" |
|
|
424
|
+
| **Write** | Create/overwrite files | "Create a new config.json" |
|
|
425
|
+
| **Edit** | Modify existing files | "Update the port in server.ts to 3000" |
|
|
426
|
+
| **Glob** | Find files by pattern | "Find all .tsx files" |
|
|
427
|
+
| **Grep** | Search file contents | "Search for TODO comments" |
|
|
428
|
+
|
|
429
|
+
### Code & Execution
|
|
430
|
+
|
|
431
|
+
| Tool | Description | Example Use |
|
|
432
|
+
|------|-------------|-------------|
|
|
433
|
+
| **Bash** | Execute shell commands | "Run the tests" |
|
|
434
|
+
| **LSP** | Code analysis | "Get diagnostics for this file" |
|
|
435
|
+
| **Notebook** | Jupyter notebook ops | "Read notebook cells" |
|
|
436
|
+
|
|
437
|
+
### Web & Search
|
|
438
|
+
|
|
439
|
+
| Tool | Description | Example Use |
|
|
440
|
+
|------|-------------|-------------|
|
|
441
|
+
| **WebSearch** | Search the internet | "Search for React 18 docs" |
|
|
442
|
+
| **WebFetch** | Fetch & analyze pages | "Fetch and summarize this article" |
|
|
443
|
+
|
|
444
|
+
### Task Management
|
|
445
|
+
|
|
446
|
+
| Tool | Description | Example Use |
|
|
447
|
+
|------|-------------|-------------|
|
|
448
|
+
| **TaskCreate** | Create structured tasks | Used by workflows |
|
|
449
|
+
| **TaskList** | List all tasks | "Show my tasks" |
|
|
450
|
+
| **TaskUpdate** | Update task status | Automatic during work |
|
|
451
|
+
|
|
452
|
+
### AI Features
|
|
453
|
+
|
|
454
|
+
| Tool | Description | Example Use |
|
|
455
|
+
|------|-------------|-------------|
|
|
456
|
+
| **Task (Subagent)** | Spawn parallel agents | For complex multi-step work |
|
|
457
|
+
| **Skill** | Execute custom skills | Via /craft commands |
|
|
458
|
+
| **AskUser** | Interactive questions | AI asks for clarification |
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Configuration
|
|
463
|
+
|
|
464
|
+
### Settings File
|
|
465
|
+
|
|
466
|
+
CodeSavant uses `.codesavant/settings.json`:
|
|
467
|
+
|
|
468
|
+
```json
|
|
469
|
+
{
|
|
470
|
+
"providers": {
|
|
471
|
+
"anthropic": {
|
|
472
|
+
"apiKey": "sk-ant-..."
|
|
473
|
+
},
|
|
474
|
+
"openai": {
|
|
475
|
+
"apiKey": "sk-..."
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
"defaultProvider": "anthropic",
|
|
479
|
+
"defaultModel": "claude-sonnet-4-20250514",
|
|
480
|
+
"hooks": {
|
|
481
|
+
"session_start": "echo 'Session started!'",
|
|
482
|
+
"user_prompt_submit": "git status"
|
|
483
|
+
},
|
|
484
|
+
"permissions": {
|
|
485
|
+
"mode": "default"
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Project Memory (SAVANT.md)
|
|
491
|
+
|
|
492
|
+
Create `.codesavant/SAVANT.md` for project context:
|
|
493
|
+
|
|
494
|
+
```markdown
|
|
495
|
+
# Project: MyApp
|
|
496
|
+
|
|
497
|
+
## Architecture
|
|
498
|
+
- Next.js 14 app router
|
|
499
|
+
- PostgreSQL database
|
|
500
|
+
- tRPC API layer
|
|
501
|
+
|
|
502
|
+
## Coding Standards
|
|
503
|
+
- Use TypeScript strict mode
|
|
504
|
+
- Prefer functional components
|
|
505
|
+
- Write tests for all features
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
AI will read this automatically for project context.
|
|
509
|
+
|
|
510
|
+
### Custom Skills
|
|
511
|
+
|
|
512
|
+
Create custom skills in `.codesavant/skills/`:
|
|
513
|
+
|
|
514
|
+
```markdown
|
|
515
|
+
---
|
|
516
|
+
name: deploy
|
|
517
|
+
category: implementation
|
|
518
|
+
description: Deploy to production
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
# Deploy Skill
|
|
522
|
+
|
|
523
|
+
Follow these steps to deploy:
|
|
524
|
+
|
|
525
|
+
1. Run tests: `bun test`
|
|
526
|
+
2. Build: `bun run build`
|
|
527
|
+
3. Deploy: `vercel deploy --prod`
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
## Security
|
|
533
|
+
|
|
534
|
+
CodeSavant includes comprehensive security features:
|
|
535
|
+
|
|
536
|
+
### Permission Modes
|
|
537
|
+
|
|
538
|
+
- **Default** - Approve destructive operations interactively
|
|
539
|
+
- **Plan** (`--plan`) - Read-only, no file modifications
|
|
540
|
+
- **YOLO** (`--yolo`) - Auto-approve (use with caution!)
|
|
541
|
+
- **Strict** (`--strict`) - Approve all tools manually
|
|
542
|
+
|
|
543
|
+
### Built-in Protections
|
|
544
|
+
|
|
545
|
+
- **SSRF Protection** - Blocks private IPs, localhost in WebFetch
|
|
546
|
+
- **Path Validation** - Prevents traversal attacks in file operations
|
|
547
|
+
- **Command Safety** - Array-based command spawning (no shell injection)
|
|
548
|
+
- **Secrets Handling** - API keys from environment/config only
|
|
549
|
+
- **Tool Risk Assessment** - High-risk tools require approval
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## Advanced Features
|
|
554
|
+
|
|
555
|
+
### Hooks System
|
|
556
|
+
|
|
557
|
+
Execute commands at key lifecycle events:
|
|
558
|
+
|
|
559
|
+
```json
|
|
560
|
+
{
|
|
561
|
+
"hooks": {
|
|
562
|
+
"session_start": "git pull origin main",
|
|
563
|
+
"user_prompt_submit": "git status",
|
|
564
|
+
"session_end": "git stash"
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
### MCP Server Integration
|
|
570
|
+
|
|
571
|
+
Connect external tools via Model Context Protocol:
|
|
572
|
+
|
|
573
|
+
```json
|
|
574
|
+
{
|
|
575
|
+
"mcpServers": {
|
|
576
|
+
"github": {
|
|
577
|
+
"command": "npx",
|
|
578
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
579
|
+
"env": {
|
|
580
|
+
"GITHUB_TOKEN": "ghp_..."
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### Background Tasks
|
|
588
|
+
|
|
589
|
+
Run long operations in the background:
|
|
590
|
+
|
|
591
|
+
```bash
|
|
592
|
+
> /bg npm run build
|
|
593
|
+
|
|
594
|
+
│ Task started in background (ID: bg_abc123)
|
|
595
|
+
│ You can continue working...
|
|
596
|
+
|
|
597
|
+
> /tasks
|
|
598
|
+
|
|
599
|
+
│ Active Tasks:
|
|
600
|
+
│ ● bg_abc123: npm run build (Running, 45s)
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
### File Change Tracking
|
|
604
|
+
|
|
605
|
+
Revert changes from previous operations:
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
> /rewind
|
|
609
|
+
|
|
610
|
+
│ Recent file changes:
|
|
611
|
+
│ 1. src/config.ts (2 min ago)
|
|
612
|
+
│ 2. src/auth.ts (5 min ago)
|
|
613
|
+
│
|
|
614
|
+
│ Revert which file? (1-2, or 'all')
|
|
615
|
+
|
|
616
|
+
> 1
|
|
617
|
+
|
|
618
|
+
[Tool: Bash] ✓ Complete
|
|
619
|
+
command: git restore src/config.ts
|
|
620
|
+
|
|
621
|
+
│ ✓ Reverted src/config.ts
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## Examples
|
|
627
|
+
|
|
628
|
+
### Example 1: Autonomous Feature Building
|
|
629
|
+
|
|
630
|
+
```bash
|
|
631
|
+
codesavant
|
|
632
|
+
|
|
633
|
+
> /craft user authentication with JWT
|
|
634
|
+
|
|
635
|
+
│ Starting autonomous craft cycle...
|
|
636
|
+
│
|
|
637
|
+
│ [Research] Spawning 4 parallel research agents...
|
|
638
|
+
│ ✓ Stack research complete
|
|
639
|
+
│ ✓ Architecture research complete
|
|
640
|
+
│ ✓ Security research complete
|
|
641
|
+
│ ✓ Patterns research complete
|
|
642
|
+
│
|
|
643
|
+
│ [Questioning] I have 2 questions before building:
|
|
644
|
+
│ 1. Do you want refresh token rotation?
|
|
645
|
+
│ 2. Session storage: Redis or in-memory?
|
|
646
|
+
│
|
|
647
|
+
> Yes to refresh tokens, use Redis
|
|
648
|
+
|
|
649
|
+
│ [Planning] Creating development roadmap...
|
|
650
|
+
│ [Building] Executing 3 plans with atomic commits...
|
|
651
|
+
│ [Verifying] Running quality checks...
|
|
652
|
+
│
|
|
653
|
+
│ ✓ Feature complete: 12 files, 8 commits, all tests passing
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
### Example 2: TDD Workflow
|
|
657
|
+
|
|
658
|
+
```bash
|
|
659
|
+
codesavant
|
|
660
|
+
|
|
661
|
+
> /craft proof login endpoint
|
|
662
|
+
|
|
663
|
+
│ Starting TDD workflow. Writing failing tests first...
|
|
664
|
+
|
|
665
|
+
[Tool: Write] ✓ Complete
|
|
666
|
+
file: tests/api/login.test.ts
|
|
667
|
+
|
|
668
|
+
│ ✗ 4 tests failing (expected). Now implementing minimal code to pass...
|
|
669
|
+
|
|
670
|
+
[Tool: Write] ✓ Complete
|
|
671
|
+
file: src/api/login.ts
|
|
672
|
+
|
|
673
|
+
│ ✓ All 4 tests passing!
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
### Example 3: Pipe Mode
|
|
677
|
+
|
|
678
|
+
```bash
|
|
679
|
+
# Analyze an error log
|
|
680
|
+
cat error.log | codesavant --pipe -p "analyze this error and suggest a fix"
|
|
681
|
+
|
|
682
|
+
# Review a diff
|
|
683
|
+
git diff | codesavant --pipe -p "review these changes"
|
|
684
|
+
|
|
685
|
+
# Explain code
|
|
686
|
+
cat complex-algorithm.ts | codesavant --pipe -p "explain this algorithm step by step"
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
### Example 4: Session Management
|
|
690
|
+
|
|
691
|
+
```bash
|
|
692
|
+
# Start working on a feature
|
|
693
|
+
codesavant
|
|
694
|
+
|
|
695
|
+
> I need to add OAuth authentication
|
|
696
|
+
|
|
697
|
+
│ Let's plan the OAuth implementation...
|
|
698
|
+
│ [Long conversation with code changes]
|
|
699
|
+
|
|
700
|
+
> /checkpoint oauth-implementation
|
|
701
|
+
|
|
702
|
+
│ ✓ Checkpoint created: oauth-implementation
|
|
703
|
+
|
|
704
|
+
> /exit
|
|
705
|
+
|
|
706
|
+
# Later, resume the session
|
|
707
|
+
codesavant -r
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
---
|
|
711
|
+
|
|
712
|
+
## Troubleshooting
|
|
713
|
+
|
|
714
|
+
### Provider Not Working
|
|
715
|
+
|
|
716
|
+
```bash
|
|
717
|
+
# Check authentication
|
|
718
|
+
codesavant
|
|
719
|
+
> /login
|
|
720
|
+
|
|
721
|
+
# Run diagnostics
|
|
722
|
+
> /doctor
|
|
723
|
+
|
|
724
|
+
│ Running health checks...
|
|
725
|
+
│ ✓ Provider: anthropic (authenticated)
|
|
726
|
+
│ ✓ Storage: ~/.codesavant/ (writable)
|
|
727
|
+
│ ✓ Working directory: /project (writable)
|
|
728
|
+
│ ✓ All systems operational
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### API Rate Limits
|
|
732
|
+
|
|
733
|
+
```bash
|
|
734
|
+
> /cost
|
|
735
|
+
|
|
736
|
+
│ Token Usage (This Session):
|
|
737
|
+
│ - Input: 12,450 tokens
|
|
738
|
+
│ - Output: 8,920 tokens
|
|
739
|
+
│ - Total: 21,370 tokens
|
|
740
|
+
│
|
|
741
|
+
│ Estimated Cost: $0.32
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
## Contributing
|
|
747
|
+
|
|
748
|
+
We welcome contributions! CodeSavant is open source under the MIT license.
|
|
749
|
+
|
|
750
|
+
### Development Setup
|
|
751
|
+
|
|
752
|
+
```bash
|
|
753
|
+
# Clone repository
|
|
754
|
+
git clone https://github.com/vaggarwal039/codesavant.git
|
|
755
|
+
cd codesavant
|
|
756
|
+
|
|
757
|
+
# Install dependencies
|
|
758
|
+
bun install
|
|
759
|
+
|
|
760
|
+
# Run in development
|
|
761
|
+
bun run src/cli.ts
|
|
762
|
+
|
|
763
|
+
# Run tests
|
|
764
|
+
bun test
|
|
765
|
+
|
|
766
|
+
# Build for production
|
|
767
|
+
bun run build
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
### Project Structure
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
codesavant/
|
|
774
|
+
├── src/
|
|
775
|
+
│ ├── cli.ts # CLI entry point
|
|
776
|
+
│ ├── repl-ink.tsx # Interactive REPL
|
|
777
|
+
│ ├── agent.ts # AI agent orchestration
|
|
778
|
+
│ ├── providers/ # AI provider implementations
|
|
779
|
+
│ ├── tools/ # Built-in tools
|
|
780
|
+
│ ├── skills/ # Unified skill system
|
|
781
|
+
│ ├── craft/ # Craft skill engine
|
|
782
|
+
│ ├── craft-orchestrator/ # Autonomous build cycle
|
|
783
|
+
│ ├── marketplace/ # Skill marketplace
|
|
784
|
+
│ ├── brain/ # Self-improving brain
|
|
785
|
+
│ ├── design/ # Design intelligence
|
|
786
|
+
│ ├── components/ # UI components
|
|
787
|
+
│ └── ...
|
|
788
|
+
├── tests/ # Test suite (360+ test files)
|
|
789
|
+
├── docs/ # Documentation
|
|
790
|
+
└── package.json
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
---
|
|
794
|
+
|
|
795
|
+
## License
|
|
796
|
+
|
|
797
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
798
|
+
|
|
799
|
+
---
|
|
800
|
+
|
|
801
|
+
## Acknowledgments
|
|
802
|
+
|
|
803
|
+
Built with:
|
|
804
|
+
- [Bun](https://bun.sh) - Fast JavaScript runtime
|
|
805
|
+
- [Ink](https://github.com/vadimdemedes/ink) - React for CLIs
|
|
806
|
+
- [Commander.js](https://github.com/tj/commander.js) - CLI framework
|
|
807
|
+
- [Chalk](https://github.com/chalk/chalk) - Terminal styling
|
|
808
|
+
- [Zod](https://zod.dev) - TypeScript schema validation
|
|
809
|
+
|
|
810
|
+
Powered by:
|
|
811
|
+
- [Anthropic Claude](https://anthropic.com)
|
|
812
|
+
- [OpenAI GPT-4](https://openai.com)
|
|
813
|
+
- [Google Gemini](https://deepmind.google/technologies/gemini/)
|
|
814
|
+
- [Groq](https://groq.com)
|
|
815
|
+
- [DeepSeek](https://deepseek.com)
|
|
816
|
+
|
|
817
|
+
---
|
|
818
|
+
|
|
819
|
+
## Support
|
|
820
|
+
|
|
821
|
+
- **Issues**: [GitHub Issues](https://github.com/vaggarwal039/codesavant/issues)
|
|
822
|
+
- **Discussions**: [GitHub Discussions](https://github.com/vaggarwal039/codesavant/discussions)
|
|
823
|
+
|
|
824
|
+
---
|
|
825
|
+
|
|
826
|
+
**Made with care by [Vishal Aggarwal](https://github.com/vaggarwal039)**
|