woopcode 0.1.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/CONTRIBUTING.md +329 -0
- package/LICENSE +21 -0
- package/README.md +582 -0
- package/cli.ts +17 -0
- package/commands/agent.tsx +139 -0
- package/commands/agentController.ts +138 -0
- package/commands/models.ts +21 -0
- package/commands/providers/index.ts +12 -0
- package/commands/providers/listProviders.ts +28 -0
- package/commands/providers/login.ts +28 -0
- package/commands/providers/logout.ts +33 -0
- package/commands/providers/setProvider.ts +34 -0
- package/config/authProvider.ts +54 -0
- package/config/client.ts +163 -0
- package/config/config.ts +118 -0
- package/config/conversation.json +1 -0
- package/config/models.json +50 -0
- package/config/paths.ts +96 -0
- package/config/providers.json +21 -0
- package/config/runtime.ts +130 -0
- package/config/systemPrompt.ts +54 -0
- package/config/types.ts +88 -0
- package/onboarding/FLOW.md +291 -0
- package/onboarding/index.ts +56 -0
- package/onboarding/providers.ts +47 -0
- package/onboarding/setupWizard.tsx +193 -0
- package/onboarding/test-reset.ts +55 -0
- package/package.json +86 -0
- package/tools/createFile.ts +24 -0
- package/tools/editFile.ts +85 -0
- package/tools/findFiles.ts +94 -0
- package/tools/grep.ts +68 -0
- package/tools/index.ts +26 -0
- package/tools/listFiles.ts +49 -0
- package/tools/readFile.ts +53 -0
- package/tools/runTests.ts +29 -0
- package/tools/terminal.ts +37 -0
- package/tools/writeFile.ts +75 -0
- package/tui/package.json +0 -0
- package/tui/src/app.tsx +60 -0
- package/tui/src/components/ApprovalFooter.tsx +29 -0
- package/tui/src/components/AsciiLogo.tsx +78 -0
- package/tui/src/components/BootScreen.tsx +76 -0
- package/tui/src/components/CapabilityRow.tsx +17 -0
- package/tui/src/components/CodeBlock.tsx +70 -0
- package/tui/src/components/DiffPreview.tsx +46 -0
- package/tui/src/components/DiffViewer.tsx +36 -0
- package/tui/src/components/HomeFooter.tsx +11 -0
- package/tui/src/components/HomeScreen.tsx +71 -0
- package/tui/src/components/InlineCode.tsx +13 -0
- package/tui/src/components/LogoReveal.tsx +158 -0
- package/tui/src/components/Markdown.tsx +280 -0
- package/tui/src/components/MessageRenderer.tsx +84 -0
- package/tui/src/components/PromptCard.tsx +52 -0
- package/tui/src/components/StreamingCursor.tsx +13 -0
- package/tui/src/components/ThinkingIndicator.tsx +14 -0
- package/tui/src/components/ToolStatus.tsx +26 -0
- package/tui/src/header.tsx +25 -0
- package/tui/src/hooks/useBootAnimation.ts +67 -0
- package/tui/src/hooks/useLogoAnimation.ts +114 -0
- package/tui/src/index.ts +5 -0
- package/tui/src/prompt.tsx +66 -0
- package/tui/src/statusBar.tsx +83 -0
- package/tui/src/store/ui-store.ts +234 -0
- package/tui/src/store/useUIStore.ts +9 -0
- package/tui/src/timeline.tsx +96 -0
- package/tui/src/types.ts +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# Woopcode
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/woopcode)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
**An autonomous AI coding assistant built for the terminal.**
|
|
7
|
+
|
|
8
|
+
Woopcode combines a streaming agent runtime, extensible tool system, and provider abstraction to help developers read, modify, and execute code directly from the command line. It operates within your project directory, with full access to your repository context.
|
|
9
|
+
|
|
10
|
+
Built with [Bun](https://bun.sh) and React [Ink](https://github.com/vadimdemedes/ink) for a fast, modern terminal experience.
|
|
11
|
+
|
|
12
|
+
<!-- Demo GIF: Terminal recording showing interactive agent session -->
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why Woopcode?
|
|
17
|
+
|
|
18
|
+
Most AI coding tools either run in your editor or operate as web services. Woopcode is different:
|
|
19
|
+
|
|
20
|
+
- **Terminal-native**: Full keyboard-driven workflow with no context switching
|
|
21
|
+
- **Streaming runtime**: See agent reasoning and tool execution in real-time
|
|
22
|
+
- **Approval-based editing**: Review all file changes as unified diffs before applying
|
|
23
|
+
- **Repository-aware**: Automatically loads project context (package.json, README, file tree)
|
|
24
|
+
- **Provider-agnostic**: Swap between AI providers without changing your workflow
|
|
25
|
+
- **Extensible**: Add custom tools and providers through a clean TypeScript API
|
|
26
|
+
|
|
27
|
+
Woopcode is designed for developers who want the power of AI assistance without leaving their terminal.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
### AI Runtime
|
|
34
|
+
|
|
35
|
+
- **Streaming responses** - Text streams character-by-character as the model generates
|
|
36
|
+
- **Tool execution** - Agent autonomously calls tools to inspect and modify your codebase
|
|
37
|
+
- **Conversation persistence** - Session history saved locally in JSON format
|
|
38
|
+
- **Cancellation support** - Interrupt agent execution at any time with Ctrl+C
|
|
39
|
+
- **Loop detection** - Prevents infinite tool call cycles
|
|
40
|
+
- **Iteration limits** - Configurable max iterations (default: 10) and turn window (default: 8)
|
|
41
|
+
|
|
42
|
+
### Built-in Tools
|
|
43
|
+
|
|
44
|
+
The agent has access to 9 filesystem and execution tools:
|
|
45
|
+
|
|
46
|
+
| Tool | Description |
|
|
47
|
+
|------|-------------|
|
|
48
|
+
| `list_files` | Recursively list repository structure |
|
|
49
|
+
| `find_files` | Find files by name or pattern |
|
|
50
|
+
| `read_file` | Read file contents |
|
|
51
|
+
| `grep` | Search file contents with regex |
|
|
52
|
+
| `create_file` | Create new files |
|
|
53
|
+
| `write_file` | Overwrite existing files |
|
|
54
|
+
| `edit_file` | Replace specific text within files |
|
|
55
|
+
| `run_terminal` | Execute shell commands |
|
|
56
|
+
| `run_tests` | Run project test suite |
|
|
57
|
+
|
|
58
|
+
All file-modifying tools (`write_file`, `edit_file`) trigger an approval workflow with diff preview.
|
|
59
|
+
|
|
60
|
+
### Interactive TUI
|
|
61
|
+
|
|
62
|
+
- **React-based interface** - Smooth rendering with Ink
|
|
63
|
+
- **Syntax highlighting** - Code blocks and markdown formatting
|
|
64
|
+
- **Diff preview** - Unified diff view for all file edits
|
|
65
|
+
- **Real-time status** - Current agent action displayed at all times
|
|
66
|
+
- **Keyboard shortcuts** - Navigate and approve changes without touching the mouse
|
|
67
|
+
|
|
68
|
+
### Provider Support
|
|
69
|
+
|
|
70
|
+
| Provider | Status | Models |
|
|
71
|
+
|----------|--------|--------|
|
|
72
|
+
| Google Gemini | ✅ Supported | gemini-3.5-flash-lite |
|
|
73
|
+
| OpenAI | 🚧 Planned | - |
|
|
74
|
+
| Anthropic | 🚧 Planned | - |
|
|
75
|
+
| Groq | 🚧 Planned | - |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
### Using Bun (Recommended)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Run without installing
|
|
85
|
+
bunx woopcode
|
|
86
|
+
|
|
87
|
+
# Install globally
|
|
88
|
+
bun add -g woopcode
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Using npm/npx
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Run without installing
|
|
95
|
+
npx woopcode
|
|
96
|
+
|
|
97
|
+
# Install globally
|
|
98
|
+
npm install -g woopcode
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### From Source
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Clone repository
|
|
105
|
+
git clone https://github.com/mangit955/woop-code.git
|
|
106
|
+
cd woop-code
|
|
107
|
+
|
|
108
|
+
# Install dependencies
|
|
109
|
+
bun install
|
|
110
|
+
|
|
111
|
+
# Run locally
|
|
112
|
+
bun cli.ts
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
### First-Time Setup
|
|
120
|
+
|
|
121
|
+
When you run Woopcode for the first time, it launches an interactive onboarding wizard:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
woopcode
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The wizard guides you through:
|
|
128
|
+
1. Selecting an AI provider (currently Google Gemini)
|
|
129
|
+
2. Obtaining an API key
|
|
130
|
+
3. Validating and saving your configuration
|
|
131
|
+
|
|
132
|
+
### Basic Usage
|
|
133
|
+
|
|
134
|
+
Once configured, Woopcode operates in your current directory:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cd ~/my-project
|
|
138
|
+
woopcode
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The agent automatically loads repository context and enters an interactive session.
|
|
142
|
+
|
|
143
|
+
### Example Prompts
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
> Explain the architecture of this repository
|
|
147
|
+
|
|
148
|
+
> Create a README documenting the key modules
|
|
149
|
+
|
|
150
|
+
> Refactor the authentication logic to use async/await
|
|
151
|
+
|
|
152
|
+
> Find all TODO comments in the codebase
|
|
153
|
+
|
|
154
|
+
> Generate unit tests for the runtime module
|
|
155
|
+
|
|
156
|
+
> Review recent git changes and suggest improvements
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Provider Management
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# List available providers
|
|
163
|
+
woopcode providers list
|
|
164
|
+
|
|
165
|
+
# Login to a provider
|
|
166
|
+
woopcode providers login -p google -a YOUR_API_KEY
|
|
167
|
+
|
|
168
|
+
# Change active provider
|
|
169
|
+
woopcode providers set -p google
|
|
170
|
+
|
|
171
|
+
# Logout
|
|
172
|
+
woopcode providers logout
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Architecture
|
|
178
|
+
|
|
179
|
+
Woopcode is organized into distinct layers, each with a clear responsibility:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
┌─────────────────────────────────────────┐
|
|
183
|
+
│ User / CLI │ Interactive terminal interface
|
|
184
|
+
└──────────────┬──────────────────────────┘
|
|
185
|
+
│
|
|
186
|
+
┌──────────────▼──────────────────────────┐
|
|
187
|
+
│ Agent Controller │ Manages conversation, handles UI updates
|
|
188
|
+
└──────────────┬──────────────────────────┘
|
|
189
|
+
│
|
|
190
|
+
┌──────────────▼──────────────────────────┐
|
|
191
|
+
│ Agent Runtime │ Streaming loop, iteration control, tool orchestration
|
|
192
|
+
└──────────────┬──────────────────────────┘
|
|
193
|
+
│
|
|
194
|
+
┌──────┴──────┐
|
|
195
|
+
│ │
|
|
196
|
+
┌───────▼────┐ ┌─────▼──────┐
|
|
197
|
+
│ Provider │ │ Tool │
|
|
198
|
+
│ Client │ │ Registry │ Provider abstraction and tool system
|
|
199
|
+
└───────┬────┘ └─────┬──────┘
|
|
200
|
+
│ │
|
|
201
|
+
┌───────▼─────────────▼────────┐
|
|
202
|
+
│ Filesystem / Network / LLM │ External systems
|
|
203
|
+
└──────────────────────────────┘
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Core Components
|
|
207
|
+
|
|
208
|
+
#### Runtime (`config/runtime.ts`)
|
|
209
|
+
|
|
210
|
+
The agent runtime implements a streaming request-response loop:
|
|
211
|
+
|
|
212
|
+
1. **Message Construction** - Recent conversation turns (default: 8) + repository context sent to provider
|
|
213
|
+
2. **Stream Processing** - Text and tool calls streamed from the LLM
|
|
214
|
+
3. **Tool Execution** - Tool calls intercepted and executed locally
|
|
215
|
+
4. **Result Injection** - Tool outputs appended to conversation
|
|
216
|
+
5. **Iteration** - Loop continues until agent responds with text or hits iteration limit (default: 10)
|
|
217
|
+
|
|
218
|
+
Key safety features:
|
|
219
|
+
- Tool loop detection (same tool + arguments cannot be called twice)
|
|
220
|
+
- Iteration limits prevent infinite loops
|
|
221
|
+
- Cancellation support via AbortSignal
|
|
222
|
+
- Tool result truncation (max 4000 characters)
|
|
223
|
+
|
|
224
|
+
#### Provider Abstraction (`config/client.ts`)
|
|
225
|
+
|
|
226
|
+
Providers implement a single interface:
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
interface ProviderClient {
|
|
230
|
+
stream(
|
|
231
|
+
messages: Message[],
|
|
232
|
+
repoContext: string,
|
|
233
|
+
signal?: AbortSignal
|
|
234
|
+
): AsyncGenerator<StreamEvent>;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
This abstraction allows swapping LLM providers without changing runtime logic.
|
|
239
|
+
|
|
240
|
+
#### Tool System (`tools/`)
|
|
241
|
+
|
|
242
|
+
Tools follow a consistent interface:
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
interface Tool {
|
|
246
|
+
name: string;
|
|
247
|
+
description: string;
|
|
248
|
+
parameters: ToolParameter[];
|
|
249
|
+
execute(args: Record<string, unknown>): Promise<string>;
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Example tool implementation (`tools/editFile.ts`):
|
|
254
|
+
|
|
255
|
+
```typescript
|
|
256
|
+
export const editFileTool: Tool = {
|
|
257
|
+
name: "edit_file",
|
|
258
|
+
description: "Replace text inside an existing file.",
|
|
259
|
+
|
|
260
|
+
parameters: [
|
|
261
|
+
{ name: "path", description: "File path", required: true },
|
|
262
|
+
{ name: "oldText", description: "Text to replace", required: true },
|
|
263
|
+
{ name: "newText", description: "Replacement text", required: true }
|
|
264
|
+
],
|
|
265
|
+
|
|
266
|
+
async execute(args) {
|
|
267
|
+
const path = args.path as string;
|
|
268
|
+
const oldText = args.oldText as string;
|
|
269
|
+
const newText = args.newText as string;
|
|
270
|
+
|
|
271
|
+
const content = await Bun.file(path).text();
|
|
272
|
+
const updated = content.replace(oldText, newText);
|
|
273
|
+
|
|
274
|
+
// Generate diff and request approval
|
|
275
|
+
const diff = createTwoFilesPatch(path, path, content, updated);
|
|
276
|
+
const approved = await store.setPendingEdit({ path, diff, ... });
|
|
277
|
+
|
|
278
|
+
if (!approved) return `Edit rejected for ${path}`;
|
|
279
|
+
|
|
280
|
+
await Bun.write(path, updated);
|
|
281
|
+
return `Edited ${path}`;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### Configuration (`config/`)
|
|
287
|
+
|
|
288
|
+
Configuration is stored in the user's home directory:
|
|
289
|
+
|
|
290
|
+
**Location:**
|
|
291
|
+
- **macOS/Linux**: `~/.config/woopcode/`
|
|
292
|
+
- **Windows**: `%LOCALAPPDATA%\woopcode\`
|
|
293
|
+
|
|
294
|
+
**Files:**
|
|
295
|
+
- `providers.json` - Provider settings and API keys
|
|
296
|
+
- `conversation.json` - Persistent conversation history
|
|
297
|
+
|
|
298
|
+
Configuration is automatically created on first run.
|
|
299
|
+
|
|
300
|
+
#### TUI (`tui/src/`)
|
|
301
|
+
|
|
302
|
+
Built with React and Ink, the terminal UI includes:
|
|
303
|
+
|
|
304
|
+
- `App` - Main application component with input handling
|
|
305
|
+
- `HomeScreen` - Initial screen with prompt examples and capabilities
|
|
306
|
+
- `DiffPreview` - Unified diff viewer for file edits
|
|
307
|
+
- `CodeBlock` - Syntax-highlighted code rendering
|
|
308
|
+
- `BootScreen` - Animated startup sequence
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Repository Structure
|
|
313
|
+
|
|
314
|
+
```
|
|
315
|
+
woopcode/
|
|
316
|
+
├── cli.ts # CLI entry point
|
|
317
|
+
├── commands/
|
|
318
|
+
│ ├── agent.tsx # Interactive agent command
|
|
319
|
+
│ ├── agentController.ts # Agent lifecycle management
|
|
320
|
+
│ ├── models.ts # Model listing command
|
|
321
|
+
│ └── providers/ # Provider management commands
|
|
322
|
+
├── config/
|
|
323
|
+
│ ├── runtime.ts # Agent loop implementation
|
|
324
|
+
│ ├── client.ts # Provider client factory
|
|
325
|
+
│ ├── authProvider.ts # Provider authentication
|
|
326
|
+
│ ├── systemPrompt.ts # Agent system prompt
|
|
327
|
+
│ ├── types.ts # Core type definitions
|
|
328
|
+
│ └── *.json # Configuration storage
|
|
329
|
+
├── tools/
|
|
330
|
+
│ ├── index.ts # Tool registry
|
|
331
|
+
│ ├── readFile.ts # Read file tool
|
|
332
|
+
│ ├── editFile.ts # Edit file tool
|
|
333
|
+
│ ├── writeFile.ts # Write file tool
|
|
334
|
+
│ ├── createFile.ts # Create file tool
|
|
335
|
+
│ ├── listFiles.ts # List files tool
|
|
336
|
+
│ ├── findFiles.ts # Find files tool
|
|
337
|
+
│ ├── grep.ts # Grep tool
|
|
338
|
+
│ ├── terminal.ts # Terminal execution tool
|
|
339
|
+
│ └── runTests.ts # Test runner tool
|
|
340
|
+
├── tui/
|
|
341
|
+
│ └── src/
|
|
342
|
+
│ ├── app.tsx # Main TUI component
|
|
343
|
+
│ ├── components/ # React components
|
|
344
|
+
│ └── store/ # State management
|
|
345
|
+
├── onboarding/
|
|
346
|
+
│ ├── index.ts # First-run setup wizard
|
|
347
|
+
│ ├── setupWizard.tsx # Interactive onboarding UI
|
|
348
|
+
│ └── providers.ts # Provider registry
|
|
349
|
+
└── packages/
|
|
350
|
+
└── tests/ # Comprehensive test suite
|
|
351
|
+
├── bench/ # Benchmarks
|
|
352
|
+
├── contracts/ # Contract tests
|
|
353
|
+
├── e2e/ # End-to-end tests
|
|
354
|
+
├── goldens/ # Golden file tests
|
|
355
|
+
├── property/ # Property-based tests
|
|
356
|
+
├── performance/ # Performance tests
|
|
357
|
+
└── runtime/ # Runtime tests
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## Testing
|
|
363
|
+
|
|
364
|
+
Woopcode includes a comprehensive test suite with multiple testing strategies:
|
|
365
|
+
|
|
366
|
+
### Test Categories
|
|
367
|
+
|
|
368
|
+
| Type | Count | Purpose |
|
|
369
|
+
|------|-------|---------|
|
|
370
|
+
| **Unit Tests** | ~10 | Component and function-level testing |
|
|
371
|
+
| **Integration Tests** | ~4 | Tool and provider integration |
|
|
372
|
+
| **Property Tests** | ~5 | Fuzz testing with fast-check |
|
|
373
|
+
| **Golden Tests** | ~4 | Snapshot testing for runtime behavior |
|
|
374
|
+
| **E2E Tests** | ~2 | Full agent session testing |
|
|
375
|
+
| **Benchmarks** | ~3 | Performance regression tracking |
|
|
376
|
+
|
|
377
|
+
### Running Tests
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# Run all tests
|
|
381
|
+
bun test
|
|
382
|
+
|
|
383
|
+
# Run specific test file
|
|
384
|
+
bun test packages/tests/runtime/agentLoop.test.ts
|
|
385
|
+
|
|
386
|
+
# Run benchmarks
|
|
387
|
+
bun run-benchmarks.ts
|
|
388
|
+
|
|
389
|
+
# Run with coverage (using Stryker)
|
|
390
|
+
bunx stryker run
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Test Philosophy
|
|
394
|
+
|
|
395
|
+
- **Contract tests** ensure tools and providers conform to interfaces
|
|
396
|
+
- **Property tests** verify invariants hold across random inputs
|
|
397
|
+
- **Golden tests** detect unintended changes in agent behavior
|
|
398
|
+
- **Robustness tests** verify error handling and edge cases
|
|
399
|
+
- **Performance tests** catch regressions in streaming and tool execution
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Extending Woopcode
|
|
404
|
+
|
|
405
|
+
### Adding a New Tool
|
|
406
|
+
|
|
407
|
+
1. Create a new file in `tools/`:
|
|
408
|
+
|
|
409
|
+
```typescript
|
|
410
|
+
// tools/myTool.ts
|
|
411
|
+
import type { Tool } from "../config/types";
|
|
412
|
+
|
|
413
|
+
export const myTool: Tool = {
|
|
414
|
+
name: "my_tool",
|
|
415
|
+
description: "Description for the AI",
|
|
416
|
+
|
|
417
|
+
parameters: [
|
|
418
|
+
{ name: "input", description: "Input parameter", required: true }
|
|
419
|
+
],
|
|
420
|
+
|
|
421
|
+
async execute(args) {
|
|
422
|
+
// Implementation
|
|
423
|
+
return "Result string";
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
2. Register in `tools/index.ts`:
|
|
429
|
+
|
|
430
|
+
```typescript
|
|
431
|
+
import { myTool } from "./myTool";
|
|
432
|
+
|
|
433
|
+
export const toolRegistry: Tool[] = [
|
|
434
|
+
// ... existing tools
|
|
435
|
+
myTool
|
|
436
|
+
];
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Adding a New Provider
|
|
440
|
+
|
|
441
|
+
1. Implement provider authentication in `config/authProvider.ts`:
|
|
442
|
+
|
|
443
|
+
```typescript
|
|
444
|
+
async function verifyMyProvider(apiKey: string): Promise<boolean> {
|
|
445
|
+
// Validation logic
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
2. Implement client in `config/client.ts`:
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
export function myProviderClient(apiKey: string): ProviderClient {
|
|
453
|
+
return {
|
|
454
|
+
async *stream(messages, repoContext, signal) {
|
|
455
|
+
// Streaming implementation
|
|
456
|
+
yield { type: "text", content: "..." };
|
|
457
|
+
yield { type: "tool_call", id: "...", name: "...", arguments: {} };
|
|
458
|
+
yield { type: "done" };
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
3. Add to provider registry in `onboarding/providers.ts`:
|
|
465
|
+
|
|
466
|
+
```typescript
|
|
467
|
+
{
|
|
468
|
+
id: "myprovider",
|
|
469
|
+
name: "My Provider",
|
|
470
|
+
enabled: true,
|
|
471
|
+
keyUrl: "https://myprovider.com/api-keys",
|
|
472
|
+
description: "Provider description"
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## Development
|
|
479
|
+
|
|
480
|
+
### Prerequisites
|
|
481
|
+
|
|
482
|
+
- [Bun](https://bun.sh) v1.0.0 or higher
|
|
483
|
+
- TypeScript 5.0+
|
|
484
|
+
|
|
485
|
+
### Commands
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
# Install dependencies
|
|
489
|
+
bun install
|
|
490
|
+
|
|
491
|
+
# Run locally
|
|
492
|
+
bun cli.ts
|
|
493
|
+
|
|
494
|
+
# Run with arguments
|
|
495
|
+
bun cli.ts --prompt "Explain this repository"
|
|
496
|
+
|
|
497
|
+
# Type checking
|
|
498
|
+
bunx tsc --noEmit
|
|
499
|
+
|
|
500
|
+
# Run tests
|
|
501
|
+
bun test
|
|
502
|
+
|
|
503
|
+
# Run specific test
|
|
504
|
+
bun test packages/tests/runtime/agentLoop.test.ts
|
|
505
|
+
|
|
506
|
+
# Run benchmarks
|
|
507
|
+
bun run-benchmarks.ts
|
|
508
|
+
|
|
509
|
+
# Format code
|
|
510
|
+
bun run format # (if configured)
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Project Standards
|
|
514
|
+
|
|
515
|
+
- **TypeScript** - Strict mode enabled
|
|
516
|
+
- **Testing** - Aim for >80% coverage on core runtime logic
|
|
517
|
+
- **Bun APIs** - Prefer `Bun.file`, `Bun.$`, `Bun.write` over Node.js equivalents
|
|
518
|
+
- **No dependencies on Node.js** - Use Bun-native APIs throughout
|
|
519
|
+
|
|
520
|
+
---
|
|
521
|
+
|
|
522
|
+
## Roadmap
|
|
523
|
+
|
|
524
|
+
Current status and planned features:
|
|
525
|
+
|
|
526
|
+
- [x] Streaming agent runtime
|
|
527
|
+
- [x] Tool execution system
|
|
528
|
+
- [x] Provider abstraction layer
|
|
529
|
+
- [x] Interactive TUI with Ink
|
|
530
|
+
- [x] Diff preview and approval workflow
|
|
531
|
+
- [x] Google Gemini provider
|
|
532
|
+
- [x] First-run onboarding wizard
|
|
533
|
+
- [x] Comprehensive test suite
|
|
534
|
+
- [ ] OpenAI provider support
|
|
535
|
+
- [ ] Anthropic Claude provider support
|
|
536
|
+
- [ ] Plugin system for third-party tools
|
|
537
|
+
- [ ] Session history improvements (search, replay)
|
|
538
|
+
- [ ] Multi-file editing workflow
|
|
539
|
+
- [ ] Configurable system prompts
|
|
540
|
+
- [ ] Remote provider support (API keys stored securely)
|
|
541
|
+
|
|
542
|
+
---
|
|
543
|
+
|
|
544
|
+
## Contributing
|
|
545
|
+
|
|
546
|
+
Contributions are welcome! Here's how to get started:
|
|
547
|
+
|
|
548
|
+
1. Fork the repository
|
|
549
|
+
2. Create a feature branch (`git checkout -b feature/my-feature`)
|
|
550
|
+
3. Make your changes
|
|
551
|
+
4. Add tests for new functionality
|
|
552
|
+
5. Run the test suite (`bun test`)
|
|
553
|
+
6. Commit your changes (`git commit -m 'Add my feature'`)
|
|
554
|
+
7. Push to your branch (`git push origin feature/my-feature`)
|
|
555
|
+
8. Open a Pull Request
|
|
556
|
+
|
|
557
|
+
### Guidelines
|
|
558
|
+
|
|
559
|
+
- Follow existing code style and conventions
|
|
560
|
+
- Add tests for new features
|
|
561
|
+
- Update documentation as needed
|
|
562
|
+
- Keep commits focused and atomic
|
|
563
|
+
- Write clear commit messages
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## License
|
|
568
|
+
|
|
569
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
570
|
+
|
|
571
|
+
---
|
|
572
|
+
|
|
573
|
+
## Credits
|
|
574
|
+
|
|
575
|
+
Built with:
|
|
576
|
+
- [Bun](https://bun.sh) - Fast JavaScript runtime
|
|
577
|
+
- [Ink](https://github.com/vadimdemedes/ink) - React for CLIs
|
|
578
|
+
- [Google Gemini](https://ai.google.dev/) - AI provider
|
|
579
|
+
- [Commander.js](https://github.com/tj/commander.js) - CLI framework
|
|
580
|
+
- [diff](https://github.com/kpdecker/jsdiff) - Unified diff generation
|
|
581
|
+
|
|
582
|
+
Inspired by [Aider](https://github.com/paul-gauthier/aider), [Claude Code](https://www.anthropic.com/), and [Cursor](https://cursor.sh).
|
package/cli.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { modelsCommand } from "./commands/models";
|
|
4
|
+
import { agentCommand, runAgent } from "./commands/agent";
|
|
5
|
+
import { providerCommand } from "./commands/providers";
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name("woopcode")
|
|
9
|
+
.description("Coding agent cli")
|
|
10
|
+
.version("0.1.0")
|
|
11
|
+
.option("-p, --prompt <prompt>", "prompt", "")
|
|
12
|
+
.action(runAgent)
|
|
13
|
+
.addCommand(modelsCommand)
|
|
14
|
+
.addCommand(agentCommand)
|
|
15
|
+
.addCommand(providerCommand);
|
|
16
|
+
|
|
17
|
+
program.parse();
|