speci 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.
Files changed (70) hide show
  1. package/README.md +523 -0
  2. package/bin/speci.ts +228 -0
  3. package/lib/commands/init.ts +299 -0
  4. package/lib/commands/monitor.ts +579 -0
  5. package/lib/commands/plan.ts +112 -0
  6. package/lib/commands/refactor.ts +157 -0
  7. package/lib/commands/run.ts +531 -0
  8. package/lib/commands/status.ts +209 -0
  9. package/lib/commands/task.ts +133 -0
  10. package/lib/config.ts +644 -0
  11. package/lib/copilot.ts +229 -0
  12. package/lib/errors.ts +166 -0
  13. package/lib/state.ts +148 -0
  14. package/lib/ui/banner.ts +109 -0
  15. package/lib/ui/box.ts +161 -0
  16. package/lib/ui/colors.ts +110 -0
  17. package/lib/ui/glyphs.ts +91 -0
  18. package/lib/ui/palette.ts +118 -0
  19. package/lib/ui/terminal.ts +118 -0
  20. package/lib/utils/atomic-write.ts +147 -0
  21. package/lib/utils/gate.ts +197 -0
  22. package/lib/utils/i18n.ts +92 -0
  23. package/lib/utils/lock.ts +189 -0
  24. package/lib/utils/logger.ts +143 -0
  25. package/lib/utils/preflight.ts +236 -0
  26. package/lib/utils/process.ts +127 -0
  27. package/lib/utils/signals.ts +145 -0
  28. package/lib/utils/suggest.ts +71 -0
  29. package/package.json +38 -0
  30. package/templates/agents/speci-fix.md +107 -0
  31. package/templates/agents/speci-impl.md +152 -0
  32. package/templates/agents/speci-plan.md +771 -0
  33. package/templates/agents/speci-refactor.md +652 -0
  34. package/templates/agents/speci-review.md +169 -0
  35. package/templates/agents/speci-task.md +369 -0
  36. package/templates/agents/speci-tidy.md +84 -0
  37. package/templates/agents/subagents/final_reviewer.prompt.md +143 -0
  38. package/templates/agents/subagents/mvt_generator.prompt.md +171 -0
  39. package/templates/agents/subagents/plan_codebase_context.prompt.md +29 -0
  40. package/templates/agents/subagents/plan_initial_planner.prompt.md +31 -0
  41. package/templates/agents/subagents/plan_refine_architecture.prompt.md +21 -0
  42. package/templates/agents/subagents/plan_refine_dataflow.prompt.md +23 -0
  43. package/templates/agents/subagents/plan_refine_edgecases.prompt.md +23 -0
  44. package/templates/agents/subagents/plan_refine_errors.prompt.md +22 -0
  45. package/templates/agents/subagents/plan_refine_final.prompt.md +25 -0
  46. package/templates/agents/subagents/plan_refine_integration.prompt.md +22 -0
  47. package/templates/agents/subagents/plan_refine_performance.prompt.md +23 -0
  48. package/templates/agents/subagents/plan_refine_requirements.prompt.md +16 -0
  49. package/templates/agents/subagents/plan_refine_security.prompt.md +22 -0
  50. package/templates/agents/subagents/plan_refine_testing.prompt.md +21 -0
  51. package/templates/agents/subagents/plan_requirements_deep_dive.prompt.md +30 -0
  52. package/templates/agents/subagents/progress_generator.prompt.md +178 -0
  53. package/templates/agents/subagents/refactor_analyze_crosscutting.prompt.md +66 -0
  54. package/templates/agents/subagents/refactor_analyze_duplication.prompt.md +65 -0
  55. package/templates/agents/subagents/refactor_analyze_errors.prompt.md +65 -0
  56. package/templates/agents/subagents/refactor_analyze_functions.prompt.md +66 -0
  57. package/templates/agents/subagents/refactor_analyze_naming.prompt.md +65 -0
  58. package/templates/agents/subagents/refactor_analyze_performance.prompt.md +66 -0
  59. package/templates/agents/subagents/refactor_analyze_state.prompt.md +66 -0
  60. package/templates/agents/subagents/refactor_analyze_structure.prompt.md +64 -0
  61. package/templates/agents/subagents/refactor_analyze_testing.prompt.md +66 -0
  62. package/templates/agents/subagents/refactor_analyze_types.prompt.md +66 -0
  63. package/templates/agents/subagents/refactor_review_completeness.prompt.md +63 -0
  64. package/templates/agents/subagents/refactor_review_final.prompt.md +63 -0
  65. package/templates/agents/subagents/refactor_review_risks.prompt.md +63 -0
  66. package/templates/agents/subagents/refactor_review_roadmap.prompt.md +63 -0
  67. package/templates/agents/subagents/refactor_review_technical.prompt.md +63 -0
  68. package/templates/agents/subagents/task_generator.prompt.md +145 -0
  69. package/templates/agents/subagents/task_reviewer.prompt.md +85 -0
  70. package/templates/speci.config.json +36 -0
package/README.md ADDED
@@ -0,0 +1,523 @@
1
+ # speci
2
+
3
+ AI-powered implementation loop orchestrator for GitHub Copilot.
4
+
5
+ ## Features
6
+
7
+ - **Automated Implementation Loops** - Orchestrates Copilot-driven development workflows
8
+ - **Gate Validation** - Runs lint, typecheck, and test commands before committing
9
+ - **Progress Tracking** - Maintains state in PROGRESS.md with task completion tracking
10
+ - **Real-time Monitoring** - TUI-based log viewer with live updates
11
+ - **Beautiful CLI** - Ice Blue styling with unicode glyphs and ANSI colors
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Initialize speci in your project
17
+ npx tsx bin/speci.ts init
18
+
19
+ # Start the implementation loop
20
+ npx tsx bin/speci.ts run
21
+ ```
22
+
23
+ ## Installation
24
+
25
+ ### Prerequisites
26
+
27
+ - **Node.js** 22.x or later
28
+ - **GitHub Copilot CLI** installed and authenticated
29
+ - **Git repository** initialized in your project
30
+
31
+ ### Install GitHub Copilot CLI
32
+
33
+ ```bash
34
+ # Install via npm (all platforms)
35
+ npm install -g @github/copilot
36
+
37
+ # Or via WinGet (Windows)
38
+ winget install GitHub.Copilot
39
+
40
+ # Or via Homebrew (macOS/Linux)
41
+ brew install copilot-cli
42
+ ```
43
+
44
+ On first launch, use the `/login` slash command to authenticate, or set the `GH_TOKEN` environment variable with a personal access token.
45
+
46
+ See https://docs.github.com/en/copilot/how-tos/copilot-cli/install-copilot-cli for more details.
47
+
48
+ ### Running speci
49
+
50
+ speci is designed to run with `tsx` for development:
51
+
52
+ ```bash
53
+ # Clone the repository
54
+ git clone <repository-url>
55
+ cd speci
56
+
57
+ # Install dependencies
58
+ npm install
59
+
60
+ # Run speci
61
+ npx tsx bin/speci.ts --help
62
+ ```
63
+
64
+ For production use, you can install globally (after publishing to npm):
65
+
66
+ ```bash
67
+ npm install -g speci
68
+ ```
69
+
70
+ ## Commands
71
+
72
+ ### `speci init` (alias: `i`)
73
+
74
+ Initialize speci in your current project by creating configuration files and directory structure.
75
+
76
+ **Usage:**
77
+
78
+ ```bash
79
+ speci init [options]
80
+ ```
81
+
82
+ **Options:**
83
+
84
+ - `-y, --yes` - Accept all defaults without prompts
85
+ - `-v, --verbose` - Show detailed output
86
+
87
+ **Creates:**
88
+
89
+ - `speci.config.json` - Configuration file
90
+ - `docs/tasks/` - Task definition directory
91
+ - `.speci-logs/` - Log file directory
92
+
93
+ **Examples:**
94
+
95
+ ```bash
96
+ # Interactive setup wizard
97
+ speci init
98
+
99
+ # Quick setup with defaults
100
+ speci init --yes
101
+
102
+ # Short alias version
103
+ speci i -y
104
+ ```
105
+
106
+ ### `speci plan` (alias: `p`)
107
+
108
+ Generate an implementation plan interactively using Copilot.
109
+
110
+ **Usage:**
111
+
112
+ ```bash
113
+ speci plan [options]
114
+ ```
115
+
116
+ **Options:**
117
+
118
+ - `-a, --agent <path>` - Use custom agent file
119
+ - `-o, --output <path>` - Save plan to specific file
120
+ - `-v, --verbose` - Show detailed output
121
+
122
+ **Examples:**
123
+
124
+ ```bash
125
+ # Start interactive planning session
126
+ speci plan
127
+
128
+ # Save plan to specific file
129
+ speci plan --output docs/plan.md
130
+
131
+ # Use custom agent
132
+ speci p -a custom-agent.md
133
+ ```
134
+
135
+ ### `speci task` (alias: `t`)
136
+
137
+ Generate task definitions from an implementation plan.
138
+
139
+ **Usage:**
140
+
141
+ ```bash
142
+ speci task --plan <path> [options]
143
+ ```
144
+
145
+ **Options:**
146
+
147
+ - `-p, --plan <path>` - Path to plan file (required)
148
+ - `-a, --agent <path>` - Use custom agent file
149
+ - `-v, --verbose` - Show detailed output
150
+
151
+ **Examples:**
152
+
153
+ ```bash
154
+ # Generate tasks from plan
155
+ speci task --plan docs/plan.md
156
+
157
+ # Short alias version
158
+ speci t -p docs/plan.md
159
+ ```
160
+
161
+ ### `speci refactor` (alias: `r`)
162
+
163
+ Analyze codebase for refactoring opportunities using Copilot.
164
+
165
+ **Usage:**
166
+
167
+ ```bash
168
+ speci refactor [options]
169
+ ```
170
+
171
+ **Options:**
172
+
173
+ - `-s, --scope <path>` - Directory or glob pattern to analyze
174
+ - `-o, --output <path>` - Save refactoring plan to file
175
+ - `-a, --agent <path>` - Use custom agent file
176
+ - `-v, --verbose` - Show detailed output
177
+
178
+ **Examples:**
179
+
180
+ ```bash
181
+ # Analyze entire project
182
+ speci refactor
183
+
184
+ # Analyze specific directory
185
+ speci refactor --scope lib/
186
+
187
+ # Analyze TypeScript files only
188
+ speci r -s "lib/**/*.ts"
189
+ ```
190
+
191
+ ### `speci status` (alias: `s`)
192
+
193
+ Show current loop state and task statistics.
194
+
195
+ **Usage:**
196
+
197
+ ```bash
198
+ speci status [options]
199
+ ```
200
+
201
+ **Options:**
202
+
203
+ - `--json` - Output status as JSON
204
+ - `-v, --verbose` - Show detailed status information
205
+
206
+ **Examples:**
207
+
208
+ ```bash
209
+ # Show current status
210
+ speci status
211
+
212
+ # Output as JSON for scripts
213
+ speci s --json
214
+
215
+ # Detailed status information
216
+ speci status --verbose
217
+ ```
218
+
219
+ **Output Fields:**
220
+
221
+ - Current loop state (WORK_LEFT, IN_REVIEW, COMPLETE, etc.)
222
+ - Task completion statistics
223
+ - Current iteration number
224
+ - Lock status
225
+
226
+ ### `speci run`
227
+
228
+ Execute the implementation loop. Acquires a lock file to prevent concurrent runs.
229
+
230
+ **Usage:**
231
+
232
+ ```bash
233
+ speci run [options]
234
+ ```
235
+
236
+ **Options:**
237
+
238
+ - `--max-iterations <n>` - Maximum loop iterations
239
+ - `--dry-run` - Show what would execute without running
240
+ - `--force` - Override existing lock file
241
+ - `-y, --yes` - Skip confirmation prompt
242
+ - `-v, --verbose` - Show detailed output
243
+
244
+ **Examples:**
245
+
246
+ ```bash
247
+ # Start implementation loop
248
+ speci run
249
+
250
+ # Limit to 5 iterations
251
+ speci run --max-iterations 5
252
+
253
+ # Preview actions without executing
254
+ speci run --dry-run
255
+ ```
256
+
257
+ **Note:** This command intentionally has no short alias for safety.
258
+
259
+ ### `speci monitor` (alias: `m`)
260
+
261
+ Real-time TUI log viewer with live updates.
262
+
263
+ **Usage:**
264
+
265
+ ```bash
266
+ speci monitor [options]
267
+ ```
268
+
269
+ **Options:**
270
+
271
+ - `-l, --log-file <path>` - Custom log file to monitor
272
+ - `--poll-interval <ms>` - Polling interval in milliseconds
273
+ - `--max-lines <n>` - Maximum lines to display
274
+ - `-v, --verbose` - Show detailed output
275
+
276
+ **Examples:**
277
+
278
+ ```bash
279
+ # Monitor default log file
280
+ speci monitor
281
+
282
+ # Short alias version
283
+ speci m
284
+
285
+ # Limit display buffer
286
+ speci monitor --max-lines 1000
287
+ ```
288
+
289
+ **Controls:**
290
+
291
+ - Arrow keys / Page Up/Down - Scroll through log
292
+ - `q` or `Ctrl+C` - Exit monitor
293
+
294
+ ## Configuration
295
+
296
+ ### speci.config.json
297
+
298
+ The configuration file is created by `speci init` and can be customized:
299
+
300
+ ```json
301
+ {
302
+ "version": "1.0.0",
303
+ "paths": {
304
+ "progress": "docs/PROGRESS.md",
305
+ "tasks": "docs/tasks",
306
+ "logs": ".speci-logs",
307
+ "lock": ".speci.lock"
308
+ },
309
+ "agents": {
310
+ "plan": null,
311
+ "task": null,
312
+ "refactor": null,
313
+ "impl": null,
314
+ "review": null,
315
+ "fix": null,
316
+ "tidy": null
317
+ },
318
+ "copilot": {
319
+ "permissions": "allow-all",
320
+ "model": null,
321
+ "extraFlags": []
322
+ },
323
+ "gate": {
324
+ "commands": ["npm run lint", "npm run typecheck", "npm run test"],
325
+ "maxFixAttempts": 3
326
+ },
327
+ "loop": {
328
+ "maxIterations": 100
329
+ }
330
+ }
331
+ ```
332
+
333
+ ### Environment Variables
334
+
335
+ Environment variables can override configuration file settings:
336
+
337
+ | Variable | Config Path | Description |
338
+ | ------------------------ | --------------------- | ---------------------------------- |
339
+ | `SPECI_PROGRESS_PATH` | `paths.progress` | Path to PROGRESS.md file |
340
+ | `SPECI_TASKS_PATH` | `paths.tasks` | Path to tasks directory |
341
+ | `SPECI_LOG_PATH` | `paths.logs` | Path to log directory |
342
+ | `SPECI_LOCK_PATH` | `paths.lock` | Path to lock file |
343
+ | `SPECI_COPILOT_MODEL` | `copilot.model` | Copilot model to use |
344
+ | `SPECI_MAX_ITERATIONS` | `loop.maxIterations` | Maximum loop iterations |
345
+ | `SPECI_ENABLE_AUTO_FIX` | `loop.enableAutoFix` | Enable automatic gate fix attempts |
346
+ | `SPECI_MAX_FIX_ATTEMPTS` | `gate.maxFixAttempts` | Maximum fix attempts |
347
+ | `SPECI_DEBUG` | N/A | Enable debug logging (1 or true) |
348
+ | `NO_COLOR` | N/A | Disable colored output |
349
+
350
+ ## Error Codes
351
+
352
+ speci uses structured error codes for clear diagnostics:
353
+
354
+ ### Prerequisite Errors (ERR-PRE-\*)
355
+
356
+ | Code | Message | Solution |
357
+ | ---------- | -------------------------------- | --------------------------------------------- |
358
+ | ERR-PRE-01 | Copilot CLI is not installed | Run: `npm install -g @github/copilot` |
359
+ | ERR-PRE-02 | Copilot CLI is not authenticated | Run `/login` in Copilot CLI or set `GH_TOKEN` |
360
+ | ERR-PRE-03 | Not a git repository | Run `git init` in your project root |
361
+ | ERR-PRE-04 | Configuration file not found | Run `speci init` to create configuration |
362
+ | ERR-PRE-05 | PROGRESS.md file not found | Run `speci init` or create manually |
363
+
364
+ ### Input Errors (ERR-INP-\*)
365
+
366
+ | Code | Message | Solution |
367
+ | ---------- | ------------------------- | --------------------------------------- |
368
+ | ERR-INP-01 | Required argument missing | Check command usage with `--help` |
369
+ | ERR-INP-02 | Agent file not found | Verify agent path or use bundled agents |
370
+ | ERR-INP-03 | Config file is malformed | Fix JSON syntax in speci.config.json |
371
+ | ERR-INP-04 | Config validation failed | Check config against schema |
372
+ | ERR-INP-05 | Plan file not found | Provide valid path with `--plan` |
373
+
374
+ ### State Errors (ERR-STA-\*)
375
+
376
+ | Code | Message | Solution |
377
+ | ---------- | ------------------------ | ---------------------------------------- |
378
+ | ERR-STA-01 | Lock file already exists | Wait for other instance or use `--force` |
379
+ | ERR-STA-02 | Cannot parse PROGRESS.md | Verify PROGRESS.md format |
380
+ | ERR-STA-03 | Invalid state transition | Check PROGRESS.md state markers |
381
+
382
+ ### Execution Errors (ERR-EXE-\*)
383
+
384
+ | Code | Message | Solution |
385
+ | ---------- | ------------------------- | -------------------------------------------- |
386
+ | ERR-EXE-01 | Gate command failed | Fix lint/typecheck/test errors |
387
+ | ERR-EXE-02 | Copilot execution failed | Check Copilot authentication and permissions |
388
+ | ERR-EXE-03 | Max iterations reached | Review progress and increase limit if needed |
389
+ | ERR-EXE-04 | Max fix attempts exceeded | Review gate failures and fix manually |
390
+
391
+ ### Exit Codes
392
+
393
+ | Code | Meaning |
394
+ | ---- | ------------------------------ |
395
+ | 0 | Success |
396
+ | 1 | General error |
397
+ | 2 | Invalid command or arguments |
398
+ | 130 | Interrupted by SIGINT (Ctrl+C) |
399
+ | 143 | Terminated by SIGTERM |
400
+
401
+ ## Troubleshooting
402
+
403
+ ### "Copilot CLI not found"
404
+
405
+ The GitHub Copilot CLI must be installed:
406
+
407
+ ```bash
408
+ # Install via npm
409
+ npm install -g @github/copilot
410
+
411
+ # Or via WinGet (Windows)
412
+ winget install GitHub.Copilot
413
+
414
+ # Or via Homebrew (macOS/Linux)
415
+ brew install copilot-cli
416
+
417
+ # Verify installation
418
+ copilot --version
419
+ ```
420
+
421
+ ### "Lock file exists"
422
+
423
+ Another speci instance may be running:
424
+
425
+ ```bash
426
+ # Check if speci is running
427
+ ps aux | grep speci
428
+
429
+ # If stale, remove lock manually
430
+ rm .speci.lock
431
+
432
+ # Or force override
433
+ speci run --force
434
+ ```
435
+
436
+ ### "Config file not found"
437
+
438
+ Initialize speci in your project:
439
+
440
+ ```bash
441
+ speci init
442
+ ```
443
+
444
+ ### "PROGRESS.md file not found"
445
+
446
+ Run the task command to generate the progress file from your plan:
447
+
448
+ ```bash
449
+ speci task --plan docs/plan.md
450
+ ```
451
+
452
+ ### Gate Commands Failing
453
+
454
+ Ensure your project has the necessary scripts in `package.json`:
455
+
456
+ ```json
457
+ {
458
+ "scripts": {
459
+ "lint": "eslint . --ext .ts",
460
+ "typecheck": "tsc --noEmit",
461
+ "test": "vitest run"
462
+ }
463
+ }
464
+ ```
465
+
466
+ ### Verbose Mode Not Working
467
+
468
+ Enable verbose output to see detailed logs:
469
+
470
+ ```bash
471
+ # Use --verbose flag
472
+ speci run --verbose
473
+
474
+ # Or set environment variable
475
+ SPECI_DEBUG=1 speci run
476
+ ```
477
+
478
+ ## Verbose Mode
479
+
480
+ Use `--verbose` (or `-v`) with any command for detailed output:
481
+
482
+ ```bash
483
+ # Show detailed execution logs
484
+ speci run --verbose
485
+
486
+ # See config loading details
487
+ speci status --verbose
488
+
489
+ # Debug init process
490
+ speci init --verbose
491
+ ```
492
+
493
+ **Verbose mode shows:**
494
+
495
+ - Stack traces on errors
496
+ - Configuration loading details
497
+ - State transition logs
498
+ - Child process details
499
+ - Debug timing information
500
+
501
+ **Note:** Verbose mode respects `NO_COLOR` environment variable.
502
+
503
+ ## License
504
+
505
+ MIT
506
+
507
+ ## Contributing
508
+
509
+ Contributions are welcome! Please ensure:
510
+
511
+ - Code passes all gates (`npm run lint`, `npm run typecheck`, `npm run test`)
512
+ - Tests are included for new features
513
+ - Documentation is updated
514
+ - Commit messages follow conventional commits format
515
+
516
+ ## Support
517
+
518
+ For issues and questions:
519
+
520
+ - Check the [Troubleshooting](#troubleshooting) section
521
+ - Review [Error Codes](#error-codes) for diagnostics
522
+ - Enable verbose mode (`--verbose`) for detailed logs
523
+ - Open an issue on GitHub with reproduction steps