swarm-tickets 1.0.0 → 2.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/LICENSE.txt CHANGED
File without changes
package/README.md CHANGED
@@ -2,13 +2,15 @@
2
2
 
3
3
  Lightweight ticket tracking system designed for AI-powered bug fixing workflows with Claude-flow/Claude Code.
4
4
 
5
- Track bugs, errors, and issues in a simple JSON file that both humans and AI agents can read and update. Perfect for projects where you want Claude to autonomously fix tickets.
5
+ Track bugs, errors, and issues that both humans and AI agents can read and update. Perfect for projects where you want Claude to autonomously fix tickets.
6
6
 
7
7
  ## ✨ Features
8
8
 
9
- - 📝 **Simple JSON-based storage** - No database required
9
+ - 📝 **Multiple storage backends** - JSON, SQLite, or Supabase
10
10
  - 🤖 **AI-friendly format** - Designed for Claude swarm workflows
11
11
  - 🎨 **Beautiful web UI** - View and manage tickets in your browser
12
+ - 💬 **Comment system** - Human and AI collaboration on tickets
13
+ - 🐛 **Bug Report Widget** - Embeddable widget for end-user bug reports
12
14
  - 💾 **Automatic backups** - Never lose ticket history
13
15
  - 🔧 **RESTful API** - Integrate with any tool
14
16
  - ⚙️ **Configurable labels** - Customize field names for your project
@@ -60,12 +62,151 @@ curl -X POST http://localhost:3456/api/tickets \
60
62
 
61
63
  Click the "📋 Quick Prompt" button on any ticket, paste into Claude Code/flow, and watch it work!
62
64
 
65
+ ## 💾 Storage Options
66
+
67
+ Swarm Tickets supports three storage backends:
68
+
69
+ ### JSON (Default)
70
+ No configuration needed. Tickets are stored in `./tickets.json`.
71
+
72
+ ```bash
73
+ # Explicit configuration (optional)
74
+ export SWARM_TICKETS_STORAGE=json
75
+ npx swarm-tickets
76
+ ```
77
+
78
+ ### SQLite (Local SQL)
79
+ For better performance and query capabilities with a local database.
80
+
81
+ > **Note:** `better-sqlite3` is an optional dependency because it requires native compilation. Only install if you want SQLite storage.
82
+
83
+ ```bash
84
+ # Install optional dependency
85
+ npm install better-sqlite3
86
+
87
+ # Configure
88
+ export SWARM_TICKETS_STORAGE=sqlite
89
+ export SWARM_TICKETS_SQLITE_PATH=./tickets.db # optional, default: ./tickets.db
90
+
91
+ npx swarm-tickets
92
+ ```
93
+
94
+ ### Supabase (Cloud SQL)
95
+ For team collaboration, cloud storage, and production deployments.
96
+
97
+ ```bash
98
+ # Install optional dependency
99
+ npm install @supabase/supabase-js
100
+
101
+ # Configure
102
+ export SWARM_TICKETS_STORAGE=supabase
103
+ export SUPABASE_URL=https://your-project.supabase.co
104
+ export SUPABASE_ANON_KEY=your-anon-key
105
+
106
+ # Optional: For auto-table creation
107
+ export SUPABASE_SERVICE_ROLE_KEY=your-service-key
108
+
109
+ npx swarm-tickets
110
+ ```
111
+
112
+ #### Finding Your Supabase Credentials
113
+
114
+ 1. Go to [supabase.com](https://supabase.com) and create a project (or open existing)
115
+ 2. Navigate to **Project Settings** > **API**
116
+ 3. Copy these values:
117
+ - **Project URL** → use as `SUPABASE_URL`
118
+ - **anon public** key → use as `SUPABASE_ANON_KEY`
119
+ - **service_role** key → use as `SUPABASE_SERVICE_ROLE_KEY` (keep secret!)
120
+
121
+ #### Supabase Manual Setup
122
+
123
+ If you prefer to create tables manually (recommended for production):
124
+
125
+ > To run the SQL: Go to your Supabase Dashboard > **SQL Editor** > **New query**, paste the SQL below, and click **Run**.
126
+
127
+ ```sql
128
+ -- Supabase SQL Schema for swarm-tickets
129
+
130
+ -- Main tickets table
131
+ CREATE TABLE IF NOT EXISTS tickets (
132
+ id TEXT PRIMARY KEY,
133
+ route TEXT NOT NULL,
134
+ f12_errors TEXT DEFAULT '',
135
+ server_errors TEXT DEFAULT '',
136
+ description TEXT DEFAULT '',
137
+ status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'in-progress', 'fixed', 'closed')),
138
+ priority TEXT CHECK (priority IS NULL OR priority IN ('critical', 'high', 'medium', 'low')),
139
+ namespace TEXT,
140
+ created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
141
+ updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
142
+ );
143
+
144
+ -- Related tickets junction table
145
+ CREATE TABLE IF NOT EXISTS ticket_relations (
146
+ id SERIAL PRIMARY KEY,
147
+ ticket_id TEXT NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
148
+ related_ticket_id TEXT NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
149
+ UNIQUE(ticket_id, related_ticket_id)
150
+ );
151
+
152
+ -- Swarm actions log
153
+ CREATE TABLE IF NOT EXISTS swarm_actions (
154
+ id SERIAL PRIMARY KEY,
155
+ ticket_id TEXT NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
156
+ timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
157
+ action TEXT NOT NULL,
158
+ result TEXT
159
+ );
160
+
161
+ -- Comments table
162
+ CREATE TABLE IF NOT EXISTS comments (
163
+ id TEXT PRIMARY KEY,
164
+ ticket_id TEXT NOT NULL REFERENCES tickets(id) ON DELETE CASCADE,
165
+ timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
166
+ type TEXT NOT NULL DEFAULT 'human' CHECK (type IN ('human', 'ai')),
167
+ author TEXT DEFAULT 'anonymous',
168
+ content TEXT DEFAULT '',
169
+ metadata JSONB DEFAULT '{}',
170
+ edited_at TIMESTAMP WITH TIME ZONE
171
+ );
172
+
173
+ -- API Keys for bug report widget
174
+ CREATE TABLE IF NOT EXISTS api_keys (
175
+ id SERIAL PRIMARY KEY,
176
+ key TEXT UNIQUE NOT NULL,
177
+ name TEXT,
178
+ created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
179
+ last_used TIMESTAMP WITH TIME ZONE,
180
+ rate_limit INTEGER DEFAULT 100,
181
+ enabled BOOLEAN DEFAULT true
182
+ );
183
+
184
+ -- Rate limiting table
185
+ CREATE TABLE IF NOT EXISTS rate_limits (
186
+ id SERIAL PRIMARY KEY,
187
+ identifier TEXT NOT NULL,
188
+ window_start TIMESTAMP WITH TIME ZONE NOT NULL,
189
+ request_count INTEGER DEFAULT 1,
190
+ UNIQUE(identifier, window_start)
191
+ );
192
+
193
+ -- Create indexes
194
+ CREATE INDEX IF NOT EXISTS idx_tickets_status ON tickets(status);
195
+ CREATE INDEX IF NOT EXISTS idx_tickets_priority ON tickets(priority);
196
+ CREATE INDEX IF NOT EXISTS idx_tickets_route ON tickets(route);
197
+ CREATE INDEX IF NOT EXISTS idx_tickets_created_at ON tickets(created_at);
198
+ CREATE INDEX IF NOT EXISTS idx_swarm_actions_ticket_id ON swarm_actions(ticket_id);
199
+ CREATE INDEX IF NOT EXISTS idx_comments_ticket_id ON comments(ticket_id);
200
+ ```
201
+
63
202
  ## 🤖 Using with Claude
64
203
 
65
204
  The package includes a Claude skill that teaches Claude how to:
66
- - Read and update tickets from `tickets.json`
205
+ - Read and update tickets
67
206
  - Set priorities and track related tickets
68
207
  - Add swarm actions documenting fixes
208
+ - Add comments to discuss issues
209
+ - Close and reopen tickets
69
210
  - Update status as work progresses
70
211
 
71
212
  Just reference the ticket ID in your prompt:
@@ -75,11 +216,107 @@ Please investigate and fix ticket TKT-1234567890
75
216
  ```
76
217
 
77
218
  Claude will:
78
- 1. Read the ticket details from `tickets.json`
219
+ 1. Read the ticket details
79
220
  2. Investigate the errors
80
221
  3. Fix the issue
81
222
  4. Update the ticket with status and actions taken
82
223
 
224
+ ## 💬 Comments System
225
+
226
+ Add comments to tickets for human-AI collaboration:
227
+
228
+ ```bash
229
+ # Add a human comment
230
+ curl -X POST http://localhost:3456/api/tickets/TKT-123/comments \
231
+ -H "Content-Type: application/json" \
232
+ -d '{
233
+ "type": "human",
234
+ "author": "developer",
235
+ "content": "I think this is related to the auth refactor"
236
+ }'
237
+
238
+ # Add an AI comment
239
+ curl -X POST http://localhost:3456/api/tickets/TKT-123/comments \
240
+ -H "Content-Type: application/json" \
241
+ -d '{
242
+ "type": "ai",
243
+ "author": "claude",
244
+ "content": "After analyzing the stack trace, this appears to be a null reference issue",
245
+ "metadata": {"analysisType": "stack-trace", "confidence": "high"}
246
+ }'
247
+ ```
248
+
249
+ ## 🐛 Bug Report Widget
250
+
251
+ Let end-users report bugs directly from your application. The widget JavaScript is served automatically by the swarm-tickets server.
252
+
253
+ ### Embed the Widget
254
+
255
+ ```html
256
+ <!-- For local development -->
257
+ <script src="http://localhost:3456/bug-report-widget.js"
258
+ data-endpoint="http://localhost:3456/api/bug-report"
259
+ data-position="bottom-right"
260
+ data-theme="dark">
261
+ </script>
262
+
263
+ <!-- For production (use your actual server URL) -->
264
+ <script src="https://your-server.com/bug-report-widget.js"
265
+ data-endpoint="https://your-server.com/api/bug-report"
266
+ data-api-key="stk_your_api_key"
267
+ data-position="bottom-right"
268
+ data-theme="dark">
269
+ </script>
270
+ ```
271
+
272
+ ### Or Initialize Programmatically
273
+
274
+ ```javascript
275
+ SwarmBugReport.init({
276
+ endpoint: 'https://your-server:3456/api/bug-report',
277
+ apiKey: 'stk_your_api_key', // optional
278
+ position: 'bottom-right', // bottom-right, bottom-left, top-right, top-left
279
+ theme: 'dark', // dark or light
280
+ buttonText: 'Report Bug',
281
+ collectErrors: true // auto-capture console errors
282
+ });
283
+ ```
284
+
285
+ ### Widget Options
286
+
287
+ | Option | Default | Description |
288
+ |--------|---------|-------------|
289
+ | `endpoint` | `/api/bug-report` | API endpoint URL |
290
+ | `apiKey` | `null` | API key for authentication |
291
+ | `position` | `bottom-right` | Widget position |
292
+ | `theme` | `dark` | `dark` or `light` |
293
+ | `buttonText` | `Report Bug` | Button label |
294
+ | `buttonIcon` | `🐛` | Button icon |
295
+ | `collectErrors` | `true` | Auto-capture console errors |
296
+ | `maxErrors` | `10` | Max errors to collect |
297
+
298
+ ### Generate API Keys (SQLite/Supabase only)
299
+
300
+ > **Note:** API key management requires SQLite or Supabase storage. JSON storage mode does not persist API keys between server restarts.
301
+
302
+ ```bash
303
+ # Create an API key
304
+ curl -X POST http://localhost:3456/api/admin/api-keys \
305
+ -H "Content-Type: application/json" \
306
+ -d '{"name": "Production Widget"}'
307
+
308
+ # List API keys
309
+ curl http://localhost:3456/api/admin/api-keys
310
+
311
+ # Revoke an API key
312
+ curl -X DELETE http://localhost:3456/api/admin/api-keys/stk_xxx
313
+ ```
314
+
315
+ ### Rate Limiting
316
+
317
+ - With API key: 1000 requests per hour
318
+ - Without API key: 10 requests per hour per IP
319
+
83
320
  ## ⚙️ Configuration
84
321
 
85
322
  ### Custom Project Name & Labels
@@ -100,65 +337,54 @@ PORT=4000 npx swarm-tickets
100
337
 
101
338
  Or the server will automatically find the next available port if 3456 is busy.
102
339
 
103
- ## 📖 API Reference
104
-
105
- ### Get all tickets
106
- ```
107
- GET /api/tickets
108
- ```
109
-
110
- ### Get single ticket
111
- ```
112
- GET /api/tickets/:id
113
- ```
114
-
115
- ### Create ticket
116
- ```
117
- POST /api/tickets
118
- Content-Type: application/json
119
-
120
- {
121
- "route": "/page/path",
122
- "f12Errors": "Browser console errors",
123
- "serverErrors": "Server console errors",
124
- "description": "Optional description",
125
- "status": "open|in-progress|fixed|closed"
126
- }
127
- ```
340
+ ### Environment Variables
128
341
 
129
- ### Update ticket
130
- ```
131
- PATCH /api/tickets/:id
132
- Content-Type: application/json
342
+ | Variable | Default | Description |
343
+ |----------|---------|-------------|
344
+ | `PORT` | `3456` | Server port |
345
+ | `SWARM_TICKETS_STORAGE` | `json` | Storage backend: `json`, `sqlite`, `supabase` |
346
+ | `SWARM_TICKETS_JSON_PATH` | `./tickets.json` | JSON file path |
347
+ | `SWARM_TICKETS_SQLITE_PATH` | `./tickets.db` | SQLite database path |
348
+ | `SUPABASE_URL` | - | Supabase project URL |
349
+ | `SUPABASE_ANON_KEY` | - | Supabase anonymous key |
350
+ | `SUPABASE_SERVICE_ROLE_KEY` | - | Supabase service role key (for auto-setup) |
133
351
 
134
- {
135
- "status": "fixed",
136
- "priority": "high",
137
- "namespace": "components/UserList",
138
- "swarmActions": [...]
139
- }
140
- ```
141
-
142
- ### Add swarm action
143
- ```
144
- POST /api/tickets/:id/swarm-action
145
- Content-Type: application/json
146
-
147
- {
148
- "action": "Fixed null reference in UserList component",
149
- "result": "Tested and verified working"
150
- }
151
- ```
152
-
153
- ### Delete ticket
154
- ```
155
- DELETE /api/tickets/:id
156
- ```
352
+ ## 📖 API Reference
157
353
 
158
- ### Get stats
159
- ```
160
- GET /api/stats
161
- ```
354
+ ### Tickets
355
+
356
+ | Method | Endpoint | Description |
357
+ |--------|----------|-------------|
358
+ | GET | `/api/tickets` | List all tickets (supports `?status=`, `?priority=`, `?route=`) |
359
+ | POST | `/api/tickets` | Create new ticket |
360
+ | GET | `/api/tickets/:id` | Get single ticket |
361
+ | PATCH | `/api/tickets/:id` | Update ticket |
362
+ | DELETE | `/api/tickets/:id` | Delete ticket |
363
+ | POST | `/api/tickets/:id/close` | Close ticket (with optional reason) |
364
+ | POST | `/api/tickets/:id/reopen` | Reopen ticket |
365
+ | POST | `/api/tickets/:id/analyze` | Auto-analyze and set priority |
366
+ | POST | `/api/tickets/:id/swarm-action` | Add swarm action |
367
+
368
+ ### Comments
369
+
370
+ | Method | Endpoint | Description |
371
+ |--------|----------|-------------|
372
+ | GET | `/api/tickets/:id/comments` | Get ticket comments |
373
+ | POST | `/api/tickets/:id/comments` | Add comment |
374
+ | PATCH | `/api/tickets/:id/comments/:commentId` | Update comment |
375
+ | DELETE | `/api/tickets/:id/comments/:commentId` | Delete comment |
376
+
377
+ ### Other
378
+
379
+ | Method | Endpoint | Description |
380
+ |--------|----------|-------------|
381
+ | GET | `/api/stats` | Get ticket statistics |
382
+ | POST | `/api/bug-report` | Submit bug report (rate limited) |
383
+ | GET | `/api/health` | Health check |
384
+ | GET | `/api/admin/storage` | Get storage info |
385
+ | POST | `/api/admin/api-keys` | Create API key |
386
+ | GET | `/api/admin/api-keys` | List API keys |
387
+ | DELETE | `/api/admin/api-keys/:key` | Revoke API key |
162
388
 
163
389
  ## 📁 File Structure
164
390
 
@@ -172,9 +398,14 @@ your-project/
172
398
  │ └── SKILL.md # Claude skill documentation
173
399
  ├── ticket-backups/ # Automatic backups (last 10)
174
400
  ├── ticket-tracker.html # Web UI
175
- ├── tickets.json # Your tickets
401
+ ├── tickets.json # Your tickets (JSON mode)
402
+ ├── tickets.db # Your tickets (SQLite mode)
176
403
  └── node_modules/
177
404
  └── swarm-tickets/
405
+ ├── lib/
406
+ │ └── storage/ # Storage adapters
407
+ ├── bug-report-widget.js # Embeddable widget
408
+ └── ...
178
409
  ```
179
410
 
180
411
  ## 🔧 Local Development
@@ -198,6 +429,7 @@ Add to your `.gitignore` if you don't want to commit tickets:
198
429
 
199
430
  ```
200
431
  tickets.json
432
+ tickets.db
201
433
  ticket-backups/
202
434
  ```
203
435
 
@@ -213,9 +445,12 @@ Built for the Claude community! Issues and PRs welcome.
213
445
 
214
446
  - Use the **Quick Prompt** button to generate Claude-ready prompts
215
447
  - Set **priorities** to help Claude focus on critical issues first
448
+ - Add **comments** to discuss issues with team and AI
216
449
  - Add **swarm actions** to document what was fixed and how
217
450
  - Use **namespaces** to track which files/components were modified
218
451
  - Link **related tickets** to help Claude understand patterns
452
+ - Use **SQLite** for better performance on larger projects
453
+ - Use **Supabase** for team collaboration and cloud deployments
219
454
 
220
455
  ## 🐛 Troubleshooting
221
456
 
@@ -233,6 +468,17 @@ PORT=4000 npx swarm-tickets
233
468
  ### Files not showing up
234
469
  Make sure you're in your project directory when running `npx swarm-tickets`. The server looks for `tickets.json` in the current directory.
235
470
 
471
+ ### SQLite not working
472
+ Install the optional dependency:
473
+ ```bash
474
+ npm install better-sqlite3
475
+ ```
476
+
477
+ ### Supabase not working
478
+ 1. Install the optional dependency: `npm install @supabase/supabase-js`
479
+ 2. Make sure environment variables are set
480
+ 3. Check if tables exist (run migration SQL if needed)
481
+
236
482
  ---
237
483
 
238
484
  Made with ❤️ for Claude-powered development workflows