sparkecoder 0.1.3

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 ADDED
@@ -0,0 +1,353 @@
1
+ # Sparkecoder
2
+
3
+ A powerful coding agent CLI with HTTP API. Built with the [Vercel AI SDK](https://sdk.vercel.ai).
4
+
5
+ ## Features
6
+
7
+ - 🤖 **Multi-Agent Sessions** - Run multiple agents simultaneously with isolated contexts
8
+ - 🔄 **Streaming Responses** - Real-time SSE streaming following Vercel AI SDK data stream protocol
9
+ - 🔧 **Powerful Tools** - Bash execution, file operations, planning, and skill loading
10
+ - ✅ **Tool Approvals** - Configurable approval requirements for dangerous operations
11
+ - 📚 **Skills System** - Load specialized knowledge documents into context
12
+ - 💾 **SQLite Persistence** - Full session and message history storage
13
+ - 🌐 **HTTP API** - RESTful API with auto-generated OpenAPI specification via hono-openapi
14
+ - 🎯 **Context Management** - Automatic summarization for long conversations
15
+
16
+ ## Installation
17
+
18
+ ### From GitHub Packages
19
+
20
+ ```bash
21
+ # Configure npm to use GitHub Packages for @gostudyfetchgo scope
22
+ npm config set @gostudyfetchgo:registry https://npm.pkg.github.com
23
+
24
+ # Install the package (no auth required - it's public!)
25
+ npm install @gostudyfetchgo/sparkecoder
26
+
27
+ # Or with pnpm
28
+ pnpm add @gostudyfetchgo/sparkecoder
29
+ ```
30
+
31
+ ### From Source
32
+
33
+ ```bash
34
+ # Clone the repository
35
+ git clone https://github.com/gostudyfetchgo/sparkecoder.git
36
+ cd sparkecoder
37
+
38
+ # Install dependencies
39
+ pnpm install
40
+
41
+ # Set up environment variables
42
+ export AI_GATEWAY_API_KEY=your_api_key_here
43
+
44
+ # Start the server
45
+ pnpm dev
46
+ ```
47
+
48
+ ### Global CLI Installation
49
+
50
+ ```bash
51
+ npm install -g @gostudyfetchgo/sparkecoder
52
+ sparkecoder start
53
+ ```
54
+
55
+ ## Quick Start
56
+
57
+ ### Initialize Configuration
58
+
59
+ ```bash
60
+ sparkecoder init
61
+ ```
62
+
63
+ This creates a `sparkecoder.config.json` file with default settings.
64
+
65
+ ### Start the Server
66
+
67
+ ```bash
68
+ sparkecoder start
69
+ ```
70
+
71
+ The server runs at `http://localhost:3141` by default.
72
+
73
+ ### Make Your First Request
74
+
75
+ ```bash
76
+ # Create a session and run a prompt
77
+ curl -X POST http://localhost:3141/agents/quick \
78
+ -H "Content-Type: application/json" \
79
+ -d '{"prompt": "List the files in the current directory"}'
80
+ ```
81
+
82
+ ## API Reference
83
+
84
+ ### Sessions
85
+
86
+ | Endpoint | Method | Description |
87
+ |----------|--------|-------------|
88
+ | `/sessions` | GET | List all sessions |
89
+ | `/sessions` | POST | Create a new session |
90
+ | `/sessions/:id` | GET | Get session details |
91
+ | `/sessions/:id` | DELETE | Delete a session |
92
+ | `/sessions/:id/messages` | GET | Get session messages |
93
+ | `/sessions/:id/clear` | POST | Clear session context |
94
+
95
+ ### Agents
96
+
97
+ | Endpoint | Method | Description |
98
+ |----------|--------|-------------|
99
+ | `/agents/:id/run` | POST | Run agent with streaming (SSE) |
100
+ | `/agents/:id/generate` | POST | Run agent without streaming |
101
+ | `/agents/:id/approve/:toolCallId` | POST | Approve pending tool |
102
+ | `/agents/:id/reject/:toolCallId` | POST | Reject pending tool |
103
+ | `/agents/:id/approvals` | GET | Get pending approvals |
104
+ | `/agents/quick` | POST | Create session and run in one request |
105
+
106
+ ### OpenAPI
107
+
108
+ Full OpenAPI specification available at `/openapi.json`.
109
+
110
+ ## Configuration
111
+
112
+ Create a `sparkecoder.config.json` file:
113
+
114
+ ```json
115
+ {
116
+ "defaultModel": "anthropic/claude-sonnet-4-20250514",
117
+ "workingDirectory": ".",
118
+ "toolApprovals": {
119
+ "bash": true,
120
+ "write_file": false,
121
+ "read_file": false
122
+ },
123
+ "skills": {
124
+ "directory": "./skills"
125
+ },
126
+ "context": {
127
+ "maxChars": 200000,
128
+ "autoSummarize": true
129
+ },
130
+ "server": {
131
+ "port": 3141,
132
+ "host": "127.0.0.1"
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### Configuration Options
138
+
139
+ | Option | Description | Default |
140
+ |--------|-------------|---------|
141
+ | `defaultModel` | Vercel AI Gateway model string | `anthropic/claude-opus-4-5` |
142
+ | `workingDirectory` | Base directory for file operations | Current directory |
143
+ | `toolApprovals` | Which tools require user approval | `{ bash: true }` |
144
+ | `skills.directory` | Directory containing skill files | `./skills` |
145
+ | `context.maxChars` | Max context size before summarization | `200000` |
146
+ | `context.autoSummarize` | Enable automatic summarization | `true` |
147
+ | `server.port` | HTTP server port | `3141` |
148
+ | `server.host` | HTTP server host | `127.0.0.1` |
149
+
150
+ ## Tools
151
+
152
+ ### bash
153
+ Execute shell commands in the working directory.
154
+
155
+ ```json
156
+ {
157
+ "command": "ls -la"
158
+ }
159
+ ```
160
+
161
+ ### read_file
162
+ Read file contents with optional line range.
163
+
164
+ ```json
165
+ {
166
+ "path": "src/index.ts",
167
+ "startLine": 1,
168
+ "endLine": 50
169
+ }
170
+ ```
171
+
172
+ ### write_file
173
+ Write or edit files. Supports two modes:
174
+
175
+ **Full write:**
176
+ ```json
177
+ {
178
+ "path": "new-file.ts",
179
+ "mode": "full",
180
+ "content": "// New file content"
181
+ }
182
+ ```
183
+
184
+ **String replacement:**
185
+ ```json
186
+ {
187
+ "path": "existing-file.ts",
188
+ "mode": "str_replace",
189
+ "old_string": "const x = 1;",
190
+ "new_string": "const x = 2;"
191
+ }
192
+ ```
193
+
194
+ ### todo
195
+ Manage task lists for complex operations.
196
+
197
+ ```json
198
+ {
199
+ "action": "add",
200
+ "items": [
201
+ { "content": "Step 1: Analyze code" },
202
+ { "content": "Step 2: Implement fix" }
203
+ ]
204
+ }
205
+ ```
206
+
207
+ ### load_skill
208
+ Load specialized knowledge into context.
209
+
210
+ ```json
211
+ {
212
+ "action": "load",
213
+ "skillName": "Debugging"
214
+ }
215
+ ```
216
+
217
+ ## Skills
218
+
219
+ Skills are markdown files with specialized knowledge. Place them in your skills directory:
220
+
221
+ ```markdown
222
+ ---
223
+ name: My Custom Skill
224
+ description: Description of what this skill provides
225
+ ---
226
+
227
+ # My Custom Skill
228
+
229
+ Detailed content that will be loaded into context...
230
+ ```
231
+
232
+ Built-in skills:
233
+ - **Debugging** - Systematic debugging approaches
234
+ - **Code Review** - Code review checklists and best practices
235
+ - **Refactoring** - Safe refactoring patterns and techniques
236
+
237
+ ## CLI Commands
238
+
239
+ ```bash
240
+ sparkecoder start # Start the HTTP server
241
+ sparkecoder chat # Interactive chat with the agent
242
+ sparkecoder init # Create config file
243
+ sparkecoder sessions # List all sessions
244
+ sparkecoder status # Check if server is running
245
+ sparkecoder config # Show current configuration
246
+ sparkecoder info # Show version and environment
247
+ ```
248
+
249
+ ### Interactive Chat
250
+
251
+ Start an interactive chat session with the agent:
252
+
253
+ ```bash
254
+ # Start a new chat session
255
+ sparkecoder chat
256
+
257
+ # Resume an existing session
258
+ sparkecoder chat --session <session-id>
259
+
260
+ # Start with custom options
261
+ sparkecoder chat --name "My Project" --model "anthropic/claude-sonnet-4-20250514"
262
+ ```
263
+
264
+ **In-chat commands:**
265
+ - `/quit` or `/exit` - Exit the chat
266
+ - `/clear` - Clear conversation history
267
+ - `/session` - Show current session info
268
+ - `/tools` - List available tools
269
+
270
+ ## Streaming Protocol
271
+
272
+ The API uses Server-Sent Events (SSE) following the [Vercel AI SDK data stream protocol](https://sdk.vercel.ai/docs/ai-sdk-ui/stream-protocol).
273
+
274
+ Compatible with `useChat` from `@ai-sdk/react`:
275
+
276
+ ```tsx
277
+ import { useChat } from '@ai-sdk/react';
278
+
279
+ const { messages, sendMessage } = useChat({
280
+ api: 'http://localhost:3141/agents/SESSION_ID/run',
281
+ });
282
+ ```
283
+
284
+ ## Tool Approvals
285
+
286
+ Configure which tools require approval:
287
+
288
+ ```json
289
+ {
290
+ "toolApprovals": {
291
+ "bash": true, // Requires approval
292
+ "write_file": true // Requires approval
293
+ }
294
+ }
295
+ ```
296
+
297
+ When approval is required:
298
+ 1. The agent pauses and streams an `approval-required` event
299
+ 2. Call `/agents/:id/approve/:toolCallId` to approve
300
+ 3. Call `/agents/:id/reject/:toolCallId` to reject
301
+
302
+ ## Environment Variables
303
+
304
+ | Variable | Description |
305
+ |----------|-------------|
306
+ | `AI_GATEWAY_API_KEY` | Vercel AI Gateway API key (required) |
307
+ | `SPARKECODER_MODEL` | Override default model |
308
+ | `SPARKECODER_PORT` | Override server port |
309
+ | `DATABASE_PATH` | Override database path |
310
+
311
+ ## Development
312
+
313
+ ```bash
314
+ # Run in development mode with hot reload
315
+ pnpm dev
316
+
317
+ # Type check
318
+ pnpm typecheck
319
+
320
+ # Build for production
321
+ pnpm build
322
+
323
+ # Run production build
324
+ pnpm start
325
+ ```
326
+
327
+ ## Testing
328
+
329
+ Sparkecoder includes comprehensive end-to-end tests that make actual API calls to the LLM.
330
+
331
+ ```bash
332
+ # Run all E2E tests (requires AI_GATEWAY_API_KEY)
333
+ pnpm test:e2e
334
+
335
+ # Run tests in watch mode
336
+ pnpm test:watch
337
+ ```
338
+
339
+ The tests cover:
340
+ - Health & server endpoints
341
+ - Session management (CRUD operations)
342
+ - Agent text generation (streaming & non-streaming)
343
+ - File operations (create, read, edit)
344
+ - Bash command execution
345
+ - Todo management
346
+ - Multi-turn conversations with context
347
+ - Tool approvals workflow
348
+
349
+ **Note:** E2E tests require a valid `AI_GATEWAY_API_KEY` and will make real LLM calls. They create a temporary `.test-workspace` directory that is cleaned up after tests complete.
350
+
351
+ ## License
352
+
353
+ Proprietary - All rights reserved.
@@ -0,0 +1,5 @@
1
+ import 'ai';
2
+ import '../schema-EPbMMFza.js';
3
+ export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, C as ContextManager, d as buildSystemPrompt } from '../index-BxpkHy7X.js';
4
+ import 'drizzle-orm/sqlite-core';
5
+ import 'zod';