anvil-dev-framework 0.1.8 → 0.1.9

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 (117) hide show
  1. package/README.md +48 -18
  2. package/VERSION +1 -1
  3. package/docs/command-reference.md +97 -16
  4. package/docs/system-architecture.md +15 -0
  5. package/global/api/__pycache__/ralph_api.cpython-314.pyc +0 -0
  6. package/global/api/openapi.yaml +357 -0
  7. package/global/api/ralph_api.py +528 -0
  8. package/global/commands/anvil-settings.md +44 -18
  9. package/global/commands/coderabbit-fix.md +282 -0
  10. package/global/commands/evidence.md +23 -6
  11. package/global/commands/hud.md +24 -0
  12. package/global/commands/orient.md +22 -21
  13. package/global/commands/weekly-review.md +21 -1
  14. package/global/config/notifications.yaml.template +50 -0
  15. package/global/hooks/ralph_stop.sh +33 -1
  16. package/global/hooks/statusline.sh +67 -2
  17. package/global/lib/__pycache__/coderabbit_metrics.cpython-314.pyc +0 -0
  18. package/global/lib/__pycache__/command_tracker.cpython-314.pyc +0 -0
  19. package/global/lib/__pycache__/context_optimizer.cpython-314.pyc +0 -0
  20. package/global/lib/__pycache__/linear_provider.cpython-314.pyc +0 -0
  21. package/global/lib/__pycache__/optimization_applier.cpython-314.pyc +0 -0
  22. package/global/lib/__pycache__/ralph_webhooks.cpython-314.pyc +0 -0
  23. package/global/lib/__pycache__/state_manager.cpython-314.pyc +0 -0
  24. package/global/lib/__pycache__/token_analyzer.cpython-314.pyc +0 -0
  25. package/global/lib/__pycache__/token_metrics.cpython-314.pyc +0 -0
  26. package/global/lib/coderabbit_metrics.py +647 -0
  27. package/global/lib/command_tracker.py +147 -0
  28. package/global/lib/log_rotation.py +287 -0
  29. package/global/lib/ralph_events.py +398 -0
  30. package/global/lib/ralph_notifier.py +366 -0
  31. package/global/lib/ralph_webhooks.py +470 -0
  32. package/global/lib/state_manager.py +121 -0
  33. package/global/lib/token_analyzer.py +28 -2
  34. package/global/lib/token_metrics.py +49 -3
  35. package/global/tests/__pycache__/test_command_tracker.cpython-314-pytest-9.0.2.pyc +0 -0
  36. package/global/tests/__pycache__/test_context_optimizer.cpython-314-pytest-9.0.2.pyc +0 -0
  37. package/global/tests/__pycache__/test_linear_filtering.cpython-314-pytest-9.0.2.pyc +0 -0
  38. package/global/tests/__pycache__/test_linear_provider.cpython-314-pytest-9.0.2.pyc +0 -0
  39. package/global/tests/__pycache__/test_optimization_applier.cpython-314-pytest-9.0.2.pyc +0 -0
  40. package/global/tests/__pycache__/test_token_analyzer.cpython-314-pytest-9.0.2.pyc +0 -0
  41. package/global/tests/__pycache__/test_token_analyzer_phase6.cpython-314-pytest-9.0.2.pyc +0 -0
  42. package/global/tests/__pycache__/test_token_metrics.cpython-314-pytest-9.0.2.pyc +0 -0
  43. package/global/tests/test_command_tracker.py +172 -0
  44. package/global/tests/test_token_metrics.py +38 -0
  45. package/global/tools/README.md +153 -0
  46. package/global/tools/__pycache__/anvil-hud.cpython-314.pyc +0 -0
  47. package/global/tools/__pycache__/orient_linear.cpython-314.pyc +0 -0
  48. package/global/tools/__pycache__/ralph-watchcpython-314.pyc +0 -0
  49. package/global/tools/anvil-hud.py +86 -1
  50. package/global/tools/anvil-memory/src/__tests__/ccs/context-monitor.test.ts +472 -0
  51. package/global/tools/anvil-memory/src/__tests__/ccs/fixtures.ts +405 -0
  52. package/global/tools/anvil-memory/src/__tests__/ccs/index.ts +36 -0
  53. package/global/tools/anvil-memory/src/__tests__/ccs/prompt-generator.test.ts +653 -0
  54. package/global/tools/anvil-memory/src/__tests__/ccs/ralph-stop.test.ts +727 -0
  55. package/global/tools/anvil-memory/src/__tests__/ccs/test-utils.ts +340 -0
  56. package/global/tools/anvil-memory/src/__tests__/commands.test.ts +218 -0
  57. package/global/tools/anvil-memory/src/commands/context.ts +322 -0
  58. package/global/tools/anvil-memory/src/db.ts +108 -0
  59. package/global/tools/anvil-memory/src/index.ts +2 -8
  60. package/global/tools/orient_linear.py +159 -0
  61. package/global/tools/ralph-watch +423 -0
  62. package/package.json +2 -1
  63. package/project/.anvil-project.yaml.template +93 -0
  64. package/project/CLAUDE.md.template +343 -0
  65. package/project/agents/README.md +119 -0
  66. package/project/agents/cross-layer-debugger.md +217 -0
  67. package/project/agents/security-code-reviewer.md +162 -0
  68. package/project/constitution.md.template +235 -0
  69. package/project/coordination.md +103 -0
  70. package/project/docs/background-tasks.md +258 -0
  71. package/project/docs/skills-frontmatter.md +243 -0
  72. package/project/examples/README.md +106 -0
  73. package/project/examples/api-route-template.ts +171 -0
  74. package/project/examples/component-template.tsx +110 -0
  75. package/project/examples/hook-template.ts +152 -0
  76. package/project/examples/service-template.ts +207 -0
  77. package/project/examples/test-template.test.tsx +249 -0
  78. package/project/hooks/README.md +491 -0
  79. package/project/hooks/__pycache__/notification.cpython-314.pyc +0 -0
  80. package/project/hooks/__pycache__/post_tool_use.cpython-314.pyc +0 -0
  81. package/project/hooks/__pycache__/pre_tool_use.cpython-314.pyc +0 -0
  82. package/project/hooks/__pycache__/session_start.cpython-314.pyc +0 -0
  83. package/project/hooks/__pycache__/stop.cpython-314.pyc +0 -0
  84. package/project/hooks/notification.py +183 -0
  85. package/project/hooks/permission_request.py +438 -0
  86. package/project/hooks/post_tool_use.py +397 -0
  87. package/project/hooks/pre_compact.py +126 -0
  88. package/project/hooks/pre_tool_use.py +454 -0
  89. package/project/hooks/session_start.py +656 -0
  90. package/project/hooks/stop.py +356 -0
  91. package/project/hooks/subagent_start.py +223 -0
  92. package/project/hooks/subagent_stop.py +215 -0
  93. package/project/hooks/user_prompt_submit.py +110 -0
  94. package/project/hooks/utils/llm/anth.py +114 -0
  95. package/project/hooks/utils/llm/oai.py +114 -0
  96. package/project/hooks/utils/tts/elevenlabs_tts.py +63 -0
  97. package/project/hooks/utils/tts/mlx_audio_tts.py +86 -0
  98. package/project/hooks/utils/tts/openai_tts.py +92 -0
  99. package/project/hooks/utils/tts/pyttsx3_tts.py +75 -0
  100. package/project/linear.yaml.template +23 -0
  101. package/project/product.md.template +238 -0
  102. package/project/retros/README.md +126 -0
  103. package/project/rules/README.md +90 -0
  104. package/project/rules/debugging.md +139 -0
  105. package/project/rules/security-review.md +115 -0
  106. package/project/settings.yaml.template +185 -0
  107. package/project/specs/SPEC-ANV-72-hud-kanban.md +525 -0
  108. package/project/templates/api-python/CLAUDE.md +547 -0
  109. package/project/templates/generic/CLAUDE.md +260 -0
  110. package/project/templates/saas/CLAUDE.md +478 -0
  111. package/project/tests/README.md +140 -0
  112. package/project/tests/__pycache__/test_transcript_parser.cpython-314-pytest-9.0.2.pyc +0 -0
  113. package/project/tests/fixtures/sample-transcript.jsonl +21 -0
  114. package/project/tests/test-hooks.sh +259 -0
  115. package/project/tests/test-lib.sh +248 -0
  116. package/project/tests/test-statusline.sh +165 -0
  117. package/project/tests/test_transcript_parser.py +323 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ```
2
2
  ___ _ ___ _____ _
3
3
  / \ | \ | \ \ / /_ _| |
4
- / /_\ \ | \| |\ \ / / | || | v0.1.8.0 (alpha)
4
+ / /_\ \ | \| |\ \ / / | || | v0.1.9.0 (alpha)
5
5
  / _____ \| |\ | \ V / | || |___
6
6
  /_/ \_\_| \_| \_/ |___|_____|
7
7
 
@@ -10,7 +10,7 @@
10
10
  ══════════════════════════════════════════════════════════
11
11
  ```
12
12
 
13
- # Anvil Development Framework <sup>v0.1.8.0</sup>
13
+ # Anvil Development Framework <sup>v0.1.9.0</sup>
14
14
 
15
15
  > **A structured AI development system for solo builders who demand production-quality output.**
16
16
 
@@ -18,20 +18,21 @@ Anvil is a comprehensive framework for AI-assisted software development that com
18
18
 
19
19
  ---
20
20
 
21
- ## 📦 Latest Changes in v0.1.8.0
21
+ ## 📦 Latest Changes in v0.1.9.0
22
22
 
23
- *Released: 2026-01-16*
23
+ *Released: 2026-01-17*
24
24
 
25
+ - **Ralph Visibility & Notification System** (ANV-298) — Real-time monitoring for autonomous execution
26
+ - Live terminal watcher (`ralph-watch`) with progress bars and event stream
27
+ - macOS Notification Center and TTS announcements for milestones
28
+ - Slack/Discord webhook integrations for team visibility
29
+ - REST API with SSE for future GUI integration
30
+ - Toggle notifications: `--enable/--disable {all,macos,tts,slack,discord}`
25
31
  - **Token Efficiency Audit Framework** — Complete token consumption tracking and optimization
26
32
  - `/efficiency` command for historical analysis with weekly/monthly reports
27
33
  - `/token-budget` command for session budget management with alerts
28
- - Efficiency scoring (0-100), trend detection, and automated recommendations
29
34
  - **CodeRabbit Deep Integration** — Automated code review workflow
30
35
  - Enhanced `.coderabbit.yaml` with pre-merge checks and custom Anvil validations
31
- - `/evidence` command integration with enforcement levels (soft/hard)
32
- - **Insights Watermark System** — Prevents re-analyzing processed retrospectives
33
- - Manifest tracking in `.claude/insights/.manifest.json`
34
- - `--all` flag to force re-analysis when needed
35
36
 
36
37
  See [CHANGELOG.md](CHANGELOG.md) for complete history.
37
38
 
@@ -157,16 +158,9 @@ npm install -g anvil-dev-framework
157
158
  anvil init
158
159
  ```
159
160
 
160
- **Option 3: Homebrew (macOS)** *(coming soon)*
161
+ **Option 3: From Source**
161
162
  ```bash
162
- brew tap alexandercahiz/anvil
163
- brew install anvil
164
- anvil init
165
- ```
166
-
167
- **Option 4: From Source**
168
- ```bash
169
- git clone https://github.com/alexandercahiz/anvil-dev-framework.git
163
+ git clone https://github.com/AMPMIO/anvil-dev-framework.git
170
164
  cd anvil-dev-framework
171
165
  ./scripts/install.sh # Auto-configures PATH
172
166
  anvil init
@@ -541,6 +535,40 @@ This remains your **default approach** for all normal development work.
541
535
 
542
536
  **Recommendation**: Start with `--max-iterations 10` to understand costs before running overnight.
543
537
 
538
+ ### Monitoring Ralph Sessions
539
+
540
+ Watch Ralph progress in real-time with the visibility tools:
541
+
542
+ ```bash
543
+ # Terminal 1: Run Ralph
544
+ /ralph start --issue ANV-209
545
+
546
+ # Terminal 2: Watch progress (full display)
547
+ python3 global/tools/ralph-watch
548
+
549
+ # Or compact single-line mode
550
+ python3 global/tools/ralph-watch --compact
551
+ ```
552
+
553
+ **Notification Options:**
554
+ ```bash
555
+ # Toggle notifications
556
+ python3 global/lib/ralph_notifier.py --disable tts # Mute TTS
557
+ python3 global/lib/ralph_notifier.py --enable macos # Enable desktop
558
+
559
+ # Start API server for external monitoring
560
+ python3 global/api/ralph_api.py --port 8765
561
+ ```
562
+
563
+ **Event Types:**
564
+ - `session_started` — Ralph begins work
565
+ - `subtask_complete` — Linear subtask finished
566
+ - `session_complete` — All work done
567
+ - `error_occurred` — Something went wrong
568
+ - `circuit_breaker` — No file changes detected (stuck)
569
+
570
+ See `global/tools/README.md` for full documentation.
571
+
544
572
  ### Decision Flowchart
545
573
 
546
574
  ```
@@ -690,6 +718,7 @@ Anvil uses **four-part versioning**: `MILESTONE.MAJOR.MINOR.PATCH`
690
718
  ---
691
719
 
692
720
  ### Future (Post-1.0)
721
+ - [ ] Homebrew CLI distribution (macOS/Linux)
693
722
  - [ ] Additional templates (mobile, Rails, Go)
694
723
  - [ ] VS Code extension
695
724
  - [ ] Dashboard for metrics
@@ -701,6 +730,7 @@ Anvil uses **four-part versioning**: `MILESTONE.MAJOR.MINOR.PATCH`
701
730
 
702
731
  | Document | Description |
703
732
  |----------|-------------|
733
+ | [System Architecture](docs/system-architecture.md) | **OVERVIEW** — How Linear + CodeRabbit + Claude Code + Memory integrate |
704
734
  | [Session Workflow](docs/session-workflow.md) | **START HERE** — Daily coding workflow |
705
735
  | [Local Issue Tracking](docs/local-issues.md) | File-based issues without Linear |
706
736
  | [Sync Guide](docs/sync.md) | Keep projects updated with framework changes |
package/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8.0
1
+ 0.1.9.0
@@ -22,6 +22,7 @@
22
22
  | `/discover` | File discovered work (bugs, debt) during implementation |
23
23
  | `/validate` | Environment validation before code changes |
24
24
  | `/evidence` | Capture quality gate proof before PR |
25
+ | `/coderabbit-fix` | Apply CodeRabbit PR feedback automatically |
25
26
  | `/linear-setup` | Configure Linear integration for project |
26
27
  | `/anvil-sync` | Sync framework updates to project |
27
28
  | `/anvil-settings` | Manage framework settings |
@@ -70,6 +71,7 @@
70
71
  - [Quality Commands](#quality-commands)
71
72
  - [/validate](#validate)
72
73
  - [/evidence](#evidence)
74
+ - [/coderabbit-fix](#coderabbit-fix)
73
75
  - [/healthcheck](#healthcheck)
74
76
  - [/retro](#retro)
75
77
  - [Token Efficiency Commands](#token-efficiency-commands)
@@ -111,15 +113,9 @@ bun install -g anvil-dev-framework
111
113
  npm install -g anvil-dev-framework
112
114
  ```
113
115
 
114
- **Option 3: Homebrew (macOS)** *(coming soon)*
116
+ **Option 3: From Source**
115
117
  ```bash
116
- brew tap alexandercahiz/anvil
117
- brew install anvil
118
- ```
119
-
120
- **Option 4: From Source**
121
- ```bash
122
- git clone https://github.com/alexandercahiz/anvil-dev-framework.git
118
+ git clone https://github.com/AMPMIO/anvil-dev-framework.git
123
119
  cd anvil-dev-framework
124
120
  ./scripts/install.sh # Auto-configures PATH
125
121
  ```
@@ -459,7 +455,7 @@ Anvil provides 23 slash commands organized into six categories:
459
455
  |----------|----------|---------|
460
456
  | **Session** | `/orient`, `/ready`, `/sprint`, `/handoff` | Session lifecycle management |
461
457
  | **Workflow** | `/explore`, `/spec`, `/plan`, `/tasks`, `/change`, `/discover` | Phase-gated development |
462
- | **Quality** | `/validate`, `/evidence`, `/healthcheck`, `/retro` | Quality assurance |
458
+ | **Quality** | `/validate`, `/evidence`, `/coderabbit-fix`, `/healthcheck`, `/retro` | Quality assurance |
463
459
  | **Multi-Agent** | `/hud` | Multi-agent coordination |
464
460
  | **Maintenance** | `/release`, `/shard`, `/decay-review`, `/weekly-review`, `/insights` | System maintenance |
465
461
  | **Setup** | `/linear-setup`, `/anvil-sync`, `/anvil-settings` | Project configuration |
@@ -1207,7 +1203,7 @@ Or if failed:
1207
1203
  | Git Status | ✅ Required | Only expected files changed |
1208
1204
  | Documentation | ⚪ Soft | Prompts if docs may need updating |
1209
1205
  | Changelog | ⚪ Soft | Warns if no [Unreleased] entry |
1210
- | Code Review | Optional | Runs if enabled in config |
1206
+ | Code Review | Default | Runs automatically (enabled by default in v1.4+) |
1211
1207
 
1212
1208
  **Configuration** (`.claude/anvil.config.json`):
1213
1209
 
@@ -1216,16 +1212,21 @@ Or if failed:
1216
1212
  "codeReview": {
1217
1213
  "enabled": true,
1218
1214
  "tool": "coderabbit",
1219
- "command": "coderabbit --prompt-only",
1220
- "enforcement": "soft"
1215
+ "command": "coderabbit review --plain",
1216
+ "enforcement": "soft",
1217
+ "preCommit": false,
1218
+ "prePR": true,
1219
+ "retryOnFix": true
1221
1220
  }
1222
1221
  }
1223
1222
  ```
1224
1223
 
1225
- Code review enforcement levels:
1226
- - **hard**: Run automatically, block PR if critical issues
1227
- - **soft**: Prompt "Run code review? (recommended)"
1228
- - **manual**: Skip automatic prompt, user triggers when wanted
1224
+ Code review configuration:
1225
+ - **enabled**: true by default (set to false to disable)
1226
+ - **enforcement**: `soft` (warn but allow) or `hard` (block on critical)
1227
+ - **preCommit**: run review before commits (default: false)
1228
+ - **prePR**: run review in /evidence (default: true)
1229
+ - **retryOnFix**: re-run review after fixes applied (default: true)
1229
1230
 
1230
1231
  **Output Format**:
1231
1232
 
@@ -1276,6 +1277,86 @@ Changes to be committed:
1276
1277
 
1277
1278
  ---
1278
1279
 
1280
+ ### /coderabbit-fix
1281
+
1282
+ **Purpose**: Apply CodeRabbit PR feedback automatically.
1283
+
1284
+ **When to Use**: After CodeRabbit review identifies issues on your PR.
1285
+
1286
+ **What It Does**:
1287
+ 1. Fetches CodeRabbit comments from the current PR via GitHub CLI
1288
+ 2. Parses suggestions, warnings, and errors
1289
+ 3. Applies fixes bottom-up (preserves line numbers)
1290
+ 4. Re-runs CodeRabbit review if `retryOnFix` enabled
1291
+ 5. Commits changes with CodeRabbit co-author attribution
1292
+
1293
+ **Prerequisites**:
1294
+ - PR must exist (created with `gh pr create`)
1295
+ - GitHub CLI (`gh`) installed and authenticated
1296
+ - CodeRabbit integration enabled on the repository
1297
+
1298
+ **Arguments**:
1299
+
1300
+ | Argument | Required | Description |
1301
+ |----------|----------|-------------|
1302
+ | `--pr` | No | PR number (default: current branch's PR) |
1303
+ | `--dry-run` | No | Show what would be fixed without applying |
1304
+
1305
+ **Configuration** (`.claude/anvil.config.json`):
1306
+ ```json
1307
+ {
1308
+ "codeReview": {
1309
+ "enabled": true,
1310
+ "tool": "coderabbit",
1311
+ "command": "coderabbit review --plain",
1312
+ "retryOnFix": true
1313
+ }
1314
+ }
1315
+ ```
1316
+
1317
+ **Output Format**:
1318
+
1319
+ ```markdown
1320
+ ## CodeRabbit Fix Report
1321
+
1322
+ ### PR: #123 (feature/password-reset)
1323
+
1324
+ ### Issues Found
1325
+ | Type | File | Line | Issue |
1326
+ |------|------|------|-------|
1327
+ | Error | src/auth.ts | 42 | Potential SQL injection |
1328
+ | Warning | src/utils.ts | 15 | Unused import |
1329
+ | Suggestion | src/api.ts | 88 | Consider error handling |
1330
+
1331
+ ### Fixes Applied
1332
+ - ✅ src/auth.ts:42 — Parameterized query
1333
+ - ✅ src/utils.ts:15 — Removed unused import
1334
+ - ⚠️ src/api.ts:88 — Manual review required
1335
+
1336
+ ### Summary
1337
+ - **Auto-fixed**: 2 issues
1338
+ - **Manual review**: 1 issue
1339
+ - **Re-review**: Running...
1340
+
1341
+ ### Next Steps
1342
+ 1. Review manual items marked ⚠️
1343
+ 2. Commit with: `git commit -m "fix: address CodeRabbit feedback"`
1344
+ ```
1345
+
1346
+ **Integration with /evidence**:
1347
+
1348
+ When CodeRabbit finds issues during `/evidence`:
1349
+ ```
1350
+ ⚠️ CodeRabbit found 3 issues.
1351
+ Run `/coderabbit-fix` to apply suggested fixes automatically.
1352
+ ```
1353
+
1354
+ **Related Commands**:
1355
+ - `/evidence` — Runs CodeRabbit review as part of quality gates
1356
+ - `/weekly-review` — Analyzes CodeRabbit patterns over time
1357
+
1358
+ ---
1359
+
1279
1360
  ### /healthcheck
1280
1361
 
1281
1362
  **Purpose**: Framework diagnostics and session health analysis.
@@ -201,6 +201,21 @@ CodeRabbit is the **automated code reviewer** that catches issues before humans
201
201
  - Custom pre-merge check rules
202
202
  - Automated response to review comments
203
203
 
204
+ **Anvil Config (`.claude/anvil.config.json`):**
205
+ ```json
206
+ {
207
+ "codeReview": {
208
+ "enabled": true,
209
+ "tool": "coderabbit",
210
+ "command": "coderabbit review --plain",
211
+ "enforcement": "soft", // soft = warn, hard = block
212
+ "preCommit": false,
213
+ "prePR": true, // run in /evidence
214
+ "retryOnFix": true // re-run after fixes
215
+ }
216
+ }
217
+ ```
218
+
204
219
  ---
205
220
 
206
221
  ### 3. Claude Code + Anvil Layer
@@ -0,0 +1,357 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Ralph API
4
+ description: |
5
+ REST and SSE API for monitoring Ralph autonomous execution sessions.
6
+
7
+ Provides real-time access to session status, event history, and control commands.
8
+ version: 1.0.0
9
+ contact:
10
+ name: Anvil Framework
11
+ license:
12
+ name: MIT
13
+
14
+ servers:
15
+ - url: http://localhost:8765
16
+ description: Local development server
17
+
18
+ tags:
19
+ - name: Health
20
+ description: Health check endpoints
21
+ - name: Session
22
+ description: Current session information
23
+ - name: Events
24
+ description: Event history and streaming
25
+ - name: Control
26
+ description: Session control commands
27
+
28
+ paths:
29
+ /health:
30
+ get:
31
+ tags: [Health]
32
+ summary: Health check
33
+ description: Returns server health status and connection info
34
+ operationId: getHealth
35
+ responses:
36
+ '200':
37
+ description: Server is healthy
38
+ content:
39
+ application/json:
40
+ schema:
41
+ $ref: '#/components/schemas/HealthResponse'
42
+
43
+ /status:
44
+ get:
45
+ tags: [Session]
46
+ summary: Get current session status
47
+ description: Returns detailed status of the current Ralph session
48
+ operationId: getStatus
49
+ security:
50
+ - ApiKeyAuth: []
51
+ responses:
52
+ '200':
53
+ description: Session status
54
+ content:
55
+ application/json:
56
+ schema:
57
+ $ref: '#/components/schemas/StatusResponse'
58
+ '401':
59
+ $ref: '#/components/responses/Unauthorized'
60
+
61
+ /events:
62
+ get:
63
+ tags: [Events]
64
+ summary: SSE event stream
65
+ description: |
66
+ Server-Sent Events stream for real-time event updates.
67
+
68
+ Events:
69
+ - `status`: Connection status
70
+ - `event`: Ralph event (subtask_complete, error, etc.)
71
+ - `heartbeat`: Keep-alive ping
72
+ operationId: getEvents
73
+ security:
74
+ - ApiKeyAuth: []
75
+ responses:
76
+ '200':
77
+ description: SSE stream established
78
+ content:
79
+ text/event-stream:
80
+ schema:
81
+ type: string
82
+ example: |
83
+ event: status
84
+ data: {"state": "connected", "ralph_active": true}
85
+
86
+ event: event
87
+ data: {"event_type": "subtask_complete", ...}
88
+
89
+ event: heartbeat
90
+ data: {"time": 1234567890.123}
91
+
92
+ /history:
93
+ get:
94
+ tags: [Events]
95
+ summary: Get event history
96
+ description: Returns recent events from the current session
97
+ operationId: getHistory
98
+ security:
99
+ - ApiKeyAuth: []
100
+ parameters:
101
+ - name: limit
102
+ in: query
103
+ description: Maximum number of events to return
104
+ schema:
105
+ type: integer
106
+ default: 50
107
+ minimum: 1
108
+ maximum: 500
109
+ responses:
110
+ '200':
111
+ description: Event history
112
+ content:
113
+ application/json:
114
+ schema:
115
+ $ref: '#/components/schemas/HistoryResponse'
116
+ '401':
117
+ $ref: '#/components/responses/Unauthorized'
118
+
119
+ /sessions:
120
+ get:
121
+ tags: [Session]
122
+ summary: Get past session summaries
123
+ description: Returns summaries of previous Ralph sessions
124
+ operationId: getSessions
125
+ security:
126
+ - ApiKeyAuth: []
127
+ responses:
128
+ '200':
129
+ description: Session summaries
130
+ content:
131
+ application/json:
132
+ schema:
133
+ $ref: '#/components/schemas/SessionsResponse'
134
+ '401':
135
+ $ref: '#/components/responses/Unauthorized'
136
+
137
+ /control:
138
+ post:
139
+ tags: [Control]
140
+ summary: Send control command
141
+ description: Send a control command to the Ralph session (e.g., stop)
142
+ operationId: postControl
143
+ security:
144
+ - ApiKeyAuth: []
145
+ requestBody:
146
+ required: true
147
+ content:
148
+ application/json:
149
+ schema:
150
+ $ref: '#/components/schemas/ControlRequest'
151
+ responses:
152
+ '200':
153
+ description: Command executed
154
+ content:
155
+ application/json:
156
+ schema:
157
+ $ref: '#/components/schemas/ControlResponse'
158
+ '400':
159
+ $ref: '#/components/responses/BadRequest'
160
+ '401':
161
+ $ref: '#/components/responses/Unauthorized'
162
+ '404':
163
+ description: No active session
164
+
165
+ components:
166
+ securitySchemes:
167
+ ApiKeyAuth:
168
+ type: apiKey
169
+ in: header
170
+ name: X-API-Key
171
+ description: Optional API key for authentication
172
+
173
+ schemas:
174
+ HealthResponse:
175
+ type: object
176
+ properties:
177
+ status:
178
+ type: string
179
+ example: healthy
180
+ ralph_active:
181
+ type: boolean
182
+ example: true
183
+ sse_clients:
184
+ type: integer
185
+ example: 2
186
+ timestamp:
187
+ type: string
188
+ format: date-time
189
+
190
+ StatusResponse:
191
+ type: object
192
+ properties:
193
+ active:
194
+ type: boolean
195
+ iteration:
196
+ type: integer
197
+ example: 5
198
+ status:
199
+ type: string
200
+ enum: [running, completed, circuit_breaker, fatal_error, stopped]
201
+ task_name:
202
+ type: string
203
+ example: "Migration Task"
204
+ started_at:
205
+ type: string
206
+ format: date-time
207
+ progress:
208
+ $ref: '#/components/schemas/Progress'
209
+ no_change_count:
210
+ type: integer
211
+ checkpoint_active:
212
+ type: boolean
213
+ linear_subtasks:
214
+ type: array
215
+ items:
216
+ $ref: '#/components/schemas/LinearSubtask'
217
+
218
+ Progress:
219
+ type: object
220
+ properties:
221
+ completed:
222
+ type: integer
223
+ total:
224
+ type: integer
225
+ percent:
226
+ type: number
227
+ format: float
228
+
229
+ LinearSubtask:
230
+ type: object
231
+ properties:
232
+ identifier:
233
+ type: string
234
+ example: ANV-123
235
+ title:
236
+ type: string
237
+ status:
238
+ type: string
239
+ enum: [todo, in_progress, completed]
240
+
241
+ RalphEvent:
242
+ type: object
243
+ properties:
244
+ event_id:
245
+ type: string
246
+ format: uuid
247
+ event_type:
248
+ type: string
249
+ enum:
250
+ - session_started
251
+ - iteration_complete
252
+ - subtask_complete
253
+ - session_complete
254
+ - error_occurred
255
+ - circuit_breaker
256
+ - checkpoint_triggered
257
+ timestamp:
258
+ type: string
259
+ format: date-time
260
+ session_id:
261
+ type: string
262
+ task_name:
263
+ type: string
264
+ iteration:
265
+ type: integer
266
+ progress:
267
+ $ref: '#/components/schemas/Progress'
268
+ payload:
269
+ type: object
270
+ additionalProperties: true
271
+ linear:
272
+ type: object
273
+ properties:
274
+ parent_issue:
275
+ type: string
276
+ subtask:
277
+ type: string
278
+ url:
279
+ type: string
280
+ format: uri
281
+
282
+ HistoryResponse:
283
+ type: object
284
+ properties:
285
+ count:
286
+ type: integer
287
+ events:
288
+ type: array
289
+ items:
290
+ $ref: '#/components/schemas/RalphEvent'
291
+
292
+ SessionSummary:
293
+ type: object
294
+ properties:
295
+ file:
296
+ type: string
297
+ session_id:
298
+ type: string
299
+ task_name:
300
+ type: string
301
+ started_at:
302
+ type: string
303
+ format: date-time
304
+ ended_at:
305
+ type: string
306
+ format: date-time
307
+ event_count:
308
+ type: integer
309
+ final_status:
310
+ type: string
311
+
312
+ SessionsResponse:
313
+ type: object
314
+ properties:
315
+ count:
316
+ type: integer
317
+ sessions:
318
+ type: array
319
+ items:
320
+ $ref: '#/components/schemas/SessionSummary'
321
+
322
+ ControlRequest:
323
+ type: object
324
+ required:
325
+ - command
326
+ properties:
327
+ command:
328
+ type: string
329
+ enum: [stop]
330
+
331
+ ControlResponse:
332
+ type: object
333
+ properties:
334
+ success:
335
+ type: boolean
336
+ message:
337
+ type: string
338
+
339
+ Error:
340
+ type: object
341
+ properties:
342
+ error:
343
+ type: string
344
+
345
+ responses:
346
+ BadRequest:
347
+ description: Bad request
348
+ content:
349
+ application/json:
350
+ schema:
351
+ $ref: '#/components/schemas/Error'
352
+ Unauthorized:
353
+ description: Unauthorized - invalid or missing API key
354
+ content:
355
+ application/json:
356
+ schema:
357
+ $ref: '#/components/schemas/Error'