specrails-hub 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fjpulidop
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ # specrails hub
2
+
3
+ A local dashboard and CLI for managing all your [specrails](https://github.com/fjpulidop/specrails) projects from a single interface. Visualizes the AI pipeline phases (Architect, Developer, Reviewer, Ship), streams logs in real-time, and lets you launch commands from the browser or terminal.
4
+
5
+ ## Features
6
+
7
+ - **Multi-project hub** — register multiple specrails projects and switch between them with browser-style tabs
8
+ - **Live pipeline visualization** — see Architect, Developer, Reviewer, and Ship phases update in real-time
9
+ - **Streaming logs** — all `claude` CLI output streamed via WebSocket to the browser
10
+ - **Command launcher** — organized into Discovery (propose-spec, auto-propose specs, auto-select specs) and Delivery (implement, batch-implement) sections; other commands available in a collapsible group
11
+ - **Analytics** — cost, duration, token usage, and throughput metrics per project
12
+ - **Conversations** — full-page chat interface with Claude, scoped per project
13
+ - **`srm` CLI** — terminal bridge that auto-routes commands to the correct project
14
+
15
+ ## Prerequisites
16
+
17
+ - Node.js 18+
18
+ - `claude` CLI on your PATH ([Claude Code](https://claude.com/claude-code))
19
+ - At least one project with specrails installed (`npx specrails`)
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install -g @specrails/hub
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```bash
30
+ # Start the hub server
31
+ srm hub start
32
+
33
+ # Register a project
34
+ srm hub add /path/to/your/project
35
+
36
+ # Open in browser
37
+ open http://localhost:4200
38
+ ```
39
+
40
+ On first launch with no projects, you'll see a welcome screen with an "Add your first project" button.
41
+
42
+ ## Architecture
43
+
44
+ ```
45
+ ~/.specrails/
46
+ hub.sqlite # project registry (name, path, slug)
47
+ hub.pid # server PID for clean shutdown
48
+ projects/
49
+ my-app/jobs.sqlite # isolated DB per project (jobs, events, chat)
50
+ api-srv/jobs.sqlite
51
+ ```
52
+
53
+ A single Express process (port 4200) manages all projects. Each project gets its own:
54
+
55
+ - **SQLite database** — jobs, events, chat conversations
56
+ - **QueueManager** — independent job queue (sequential within a project, parallel across projects)
57
+ - **ChatManager** — isolated Claude conversations
58
+
59
+ ```
60
+ ┌─────────────────────────────────────────────────────┐
61
+ │ Express Server (port 4200) │
62
+ │ │
63
+ │ ProjectRegistry │
64
+ │ ├── Project A → { db, queue, chat, cwd } │
65
+ │ ├── Project B → { db, queue, chat, cwd } │
66
+ │ └── Project C → { db, queue, chat, cwd } │
67
+ │ │
68
+ │ Routes: │
69
+ │ /api/hub/* → hub-level operations │
70
+ │ /api/projects/:id/* → project-scoped actions │
71
+ └─────────────────────────────────────────────────────┘
72
+ ```
73
+
74
+ ## UI Overview
75
+
76
+ ```
77
+ ┌───────────────────────────────────────────────────────┐
78
+ │ specrails hub [my-app ●] [api-srv] [dashboard] [+]│
79
+ │ Home Analytics Conversations ⚙ │
80
+ │───────────────────────────────────────────────────────│
81
+ │ │
82
+ │ Command grid, recent jobs, pipeline phases │
83
+ │ │
84
+ └───────────────────────────────────────────────────────┘
85
+ ```
86
+
87
+ - **Tabs** — one per project, green dot when a job is active
88
+ - **Home** — command grid (Discovery and Delivery sections), recent jobs, pipeline phase indicators
89
+ - **Analytics** — cost and token metrics
90
+ - **Conversations** — Claude chat sessions scoped to the project
91
+ - **Settings** (gear icon) — global hub configuration, registered projects
92
+
93
+ ## CLI: `srm`
94
+
95
+ ### Hub management
96
+
97
+ | Command | Description |
98
+ |---------|-------------|
99
+ | `srm hub start [--port N]` | Start the hub server (default port 4200) |
100
+ | `srm hub stop` | Stop the hub server |
101
+ | `srm hub status` | Show hub state and registered projects |
102
+ | `srm hub list` | List all registered projects |
103
+ | `srm hub add <path>` | Register a project |
104
+ | `srm hub remove <id>` | Unregister a project |
105
+
106
+ ### Running commands
107
+
108
+ ```bash
109
+ cd ~/repos/my-app
110
+ srm implement #42 # auto-detects project from CWD
111
+ srm product-backlog # routes to the correct project
112
+ srm "any raw prompt" # passes directly to claude
113
+ ```
114
+
115
+ `srm` detects which project you're in by matching your current directory against registered projects. If the hub isn't running, it falls back to invoking `claude` directly.
116
+
117
+ ### Options
118
+
119
+ | Flag | Description |
120
+ |------|-------------|
121
+ | `--port <n>` | Override default port (4200) |
122
+ | `--status` | Print hub/manager state |
123
+ | `--jobs` | Print recent job history |
124
+ | `--help` | Show usage |
125
+
126
+ ### Output
127
+
128
+ ```
129
+ [srm] running: /sr:implement #42
130
+ [srm] routing via hub → project my-app (a1b2c3d4)
131
+ ... (live claude output) ...
132
+ [srm] done duration: 4m32s cost: $0.08 tokens: 12,400 exit: 0
133
+ ```
134
+
135
+ ## API
136
+
137
+ ### Hub routes
138
+
139
+ | Method | Path | Description |
140
+ |--------|------|-------------|
141
+ | GET | `/api/hub/state` | Hub version, project count, uptime |
142
+ | GET | `/api/hub/projects` | List registered projects |
143
+ | POST | `/api/hub/projects` | Register a project (`{ path }`) |
144
+ | DELETE | `/api/hub/projects/:id` | Unregister a project |
145
+ | GET | `/api/hub/resolve?path=<p>` | Find project by filesystem path |
146
+ | GET | `/api/hub/settings` | Global settings |
147
+ | PUT | `/api/hub/settings` | Update global settings |
148
+
149
+ ### Project-scoped routes
150
+
151
+ All under `/api/projects/:projectId/`:
152
+
153
+ | Method | Path | Description |
154
+ |--------|------|-------------|
155
+ | POST | `/spawn` | Launch a command |
156
+ | GET | `/jobs` | Job history |
157
+ | GET | `/jobs/:id` | Job detail |
158
+ | GET | `/analytics` | Cost and usage metrics |
159
+ | GET | `/config` | Available commands |
160
+ | POST | `/chat/conversations` | Create chat conversation |
161
+ | GET | `/chat/conversations` | List conversations |
162
+ | POST | `/hooks/events` | Pipeline phase notifications |
163
+
164
+ ## Development
165
+
166
+ ```bash
167
+ git clone https://github.com/fjpulidop/specrails-hub.git
168
+ cd specrails-hub
169
+ npm install # install root (server + CLI) dependencies
170
+ cd client && npm install && cd .. # install client dependencies separately
171
+ npm run dev # starts server (4200) + client (4201) concurrently
172
+ ```
173
+
174
+ > **Note:** This repo has two separate `node_modules` trees — one at the root (server + CLI) and one inside `client/` (Vite + React). Both `npm install` calls are required. If you see `sh: tsc: command not found` during `npm run build`, it means one of them is missing.
175
+
176
+ | Script | Description |
177
+ |--------|-------------|
178
+ | `npm run dev` | Start server + client with hot reload |
179
+ | `npm run dev:server` | Server only (tsx watch) |
180
+ | `npm run dev:client` | Client only (Vite) |
181
+ | `npm run build` | Production build (client + CLI) |
182
+ | `npm run typecheck` | TypeScript check (server + client) |
183
+ | `npm test` | Run tests (vitest) |
184
+
185
+ ### Project structure
186
+
187
+ ```
188
+ specrails-hub/
189
+ ├── server/
190
+ │ ├── index.ts # hub entry point
191
+ │ ├── hub-db.ts # hub SQLite (project registry)
192
+ │ ├── project-registry.ts # per-project context manager
193
+ │ ├── hub-router.ts # /api/hub/* routes
194
+ │ ├── project-router.ts # /api/projects/:id/* routes
195
+ │ ├── db.ts # per-project SQLite (jobs, events, chat)
196
+ │ ├── queue-manager.ts # job queue per project
197
+ │ ├── chat-manager.ts # Claude chat per project
198
+ │ ├── config.ts # command discovery
199
+ │ ├── hooks.ts # pipeline event handler
200
+ │ ├── analytics.ts # metrics aggregation
201
+ │ └── types.ts # shared TypeScript types
202
+ ├── client/
203
+ │ └── src/
204
+ │ ├── App.tsx
205
+ │ ├── components/
206
+ │ │ ├── TabBar.tsx # project tabs
207
+ │ │ ├── AddProjectDialog.tsx # register project modal
208
+ │ │ ├── WelcomeScreen.tsx # zero-state
209
+ │ │ ├── ProjectLayout.tsx # per-project wrapper
210
+ │ │ ├── ProjectNavbar.tsx # Home/Analytics/Conversations nav
211
+ │ │ ├── CommandGrid.tsx # command launcher
212
+ │ │ └── ...
213
+ │ ├── hooks/
214
+ │ │ ├── useHub.tsx # hub state context
215
+ │ │ ├── useChat.ts # chat operations
216
+ │ │ ├── usePipeline.ts # pipeline phases
217
+ │ │ └── useSharedWebSocket.tsx
218
+ │ ├── pages/
219
+ │ │ ├── DashboardPage.tsx
220
+ │ │ ├── AnalyticsPage.tsx
221
+ │ │ ├── ConversationsPage.tsx
222
+ │ │ ├── GlobalSettingsPage.tsx
223
+ │ │ └── JobDetailPage.tsx
224
+ │ └── lib/
225
+ │ └── api.ts # dynamic API base routing
226
+ ├── cli/
227
+ │ └── srm.ts # CLI bridge
228
+ ├── package.json
229
+ ├── tsconfig.json
230
+ └── vitest.config.ts
231
+ ```
232
+
233
+ ## WebSocket
234
+
235
+ The server broadcasts events over a single WebSocket connection. All project-scoped messages include a `projectId` field — the client filters by active project.
236
+
237
+ | Message type | Scope | Description |
238
+ |-------------|-------|-------------|
239
+ | `init` | project | Job started |
240
+ | `log` | project | Streaming log line |
241
+ | `phase` | project | Pipeline phase transition |
242
+ | `queue_update` | project | Queue state change |
243
+ | `hub.project_added` | hub | New project registered |
244
+ | `hub.project_removed` | hub | Project unregistered |
245
+
246
+ ## Security
247
+
248
+ - Binds to `127.0.0.1` (loopback only) — **do not expose to a network**
249
+ - No authentication (single-user local tool)
250
+ - All SQL operations use parameterized queries
251
+ - Project paths validated as existing directories on registration
252
+
253
+ ## License
254
+
255
+ MIT