feinai 0.5.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/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
+
6
+ ## [0.5.0] - 2026-06-10
7
+
8
+ ### Added
9
+ - `tasca git <cmd>` — safe git wrapper subcommand. Passes through to `opengit`, enforcing a worktree-only whitelist (blocks branch, merge, rebase, checkout, etc.)
10
+ - `opengit` shipped as a binary alongside `tasca` — `bun install -g tasca` now installs both
11
+ - `tasca unblock <TASK-ID> --dep <TASK-ID>` — remove a specific dependency from a task
12
+ - `tasca edit --clear-blocked-by` — clear all dependencies from a task
13
+ - Live Agents Monitor: working directory, repo name, and `.tasca` path shown per agent card
14
+ - Live Agents Monitor: presence indicator — gray dot when idle, green dot with ripple animation when agents are active
15
+ - Live Agents Monitor: elapsed time and spec ID per card
16
+ - `tasca init` now auto-adds `.tasca/` to `.gitignore` if in a git repo
17
+ - Skills: `tasca-implement` — claim one pending task, implement in isolated worktree, run quality gates, push to main
18
+
19
+ ### Changed
20
+ - Dashboard is now English-only — removed i18n/language selector
21
+ - `tasca-implement` SKILL.md updated to use `tasca git` instead of `opengit` directly
22
+ - `package.json`: added `repository`, `homepage`, `bugs` fields
23
+
24
+ ### Skills included
25
+ `tasca-sdd` · `tasca-write-spec` · `tasca-write-tasks` · `tasca-dispatch` · `tasca-implement`
26
+
27
+ ---
28
+
29
+ ## [0.4.0] - 2026-06-08
30
+
31
+ Initial public release. Core CLI with specs, plans, tasks, HTTP dashboard, and SDD skills.
32
+
33
+ ### Features
34
+ - `tasca init / status / list / add / show / take / done / fail / block / release / reopen / edit`
35
+ - `tasca spec` — spec lifecycle (add, start, done, archive, set-content, edit)
36
+ - `tasca plan` — plan revisions per spec
37
+ - `tasca server` — HTTP dashboard + REST API + SSE live updates
38
+ - Live Agents Monitor — real-time view of in-progress tasks with worktree state
39
+ - Atomic `take` — SQL-level concurrency safety for parallel agents
40
+ - Append-only events audit log
41
+ - Skills: `tasca-sdd`, `tasca-write-spec`, `tasca-write-tasks`, `tasca-dispatch`
package/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # tasca — run agents in parallel. know exactly what each one is doing.
2
+
3
+ Working with AI agents on complex features is powerful — until the coordination overhead swallows the productivity. I was using markdown files (`QUEUE.md`, `SPECS-QUEUE.md`, plan checklists) to track specs and tasks across sessions. The files grew without bound. Agents had to read the whole thing to extract a handful of lines. Context windows filled with stale state. Keeping files current after each task required discipline I didn't always have, and the more agents worked in parallel, the more likely a file was to be inconsistent.
4
+
5
+ So I built **tasca**: a dual-interface tool (CLI + HTTP API) that serves both humans and agents. Agents claim tasks atomically, get exactly the context they need, and report results — all in single calls. Humans watch a live dashboard that shows which tasks exist, who's working on them, which files are being touched, and what the final outcome was. The underlying state lives in a local SQLite file and never leaves your machine.
6
+
7
+ It ships with a set of skills — `tasca-sdd`, `tasca-write-spec`, `tasca-write-tasks`, `tasca-dispatch` — that replace the markdown-file side-effects of the SDD workflow with atomic CLI calls. The skills are drop-in replacements: if a project has `.tasca/tasca.db`, Claude uses tasca; otherwise it falls back to regular superpowers markdown flow.
8
+
9
+ ```bash
10
+ tasca take TASK-121-A
11
+ # → {id, subject, description, workplan, packages, quality_gates, worktree, ...}
12
+ # One call. Everything the agent needs to start.
13
+ ```
14
+
15
+ ## Why tasca
16
+
17
+ - **Atomic commands** — `take` returns the full task payload (subject + description + workplan + quality gates) in a single response.
18
+ - **Concurrency-safe** — `take` is an atomic SQL UPDATE; two agents can't claim the same task.
19
+ - **Queryable** — filter by status, owner, spec without parsing markdown.
20
+ - **Auditable** — every operation is logged in an append-only events table.
21
+ - **Local-first** — SQLite file at `.tasca/tasks.db`, no server, no cloud.
22
+
23
+ ## Status
24
+
25
+ Alpha. Built for use in real SDD workflows; API may change before 1.0.
26
+
27
+ ## Install
28
+
29
+ Requires [Bun](https://bun.sh) 1.3+.
30
+
31
+ ```bash
32
+ # From source (recommended during alpha)
33
+ git clone https://github.com/mvisca/tasca
34
+ cd tasca
35
+ bun install
36
+ bun link # registers `tasca` as global command
37
+ ```
38
+
39
+ ### Activate the Claude Code skills
40
+
41
+ `tasca` ships four Claude Code skills that replace the markdown-file SDD workflow end to end. Link them into your global skills directory:
42
+
43
+ ```bash
44
+ mkdir -p ~/.claude/skills
45
+ ln -sfn "$(pwd)/skills/tasca-sdd" ~/.claude/skills/tasca-sdd
46
+ ln -sfn "$(pwd)/skills/tasca-write-spec" ~/.claude/skills/tasca-write-spec
47
+ ln -sfn "$(pwd)/skills/tasca-write-tasks" ~/.claude/skills/tasca-write-tasks
48
+ ln -sfn "$(pwd)/skills/tasca-dispatch" ~/.claude/skills/tasca-dispatch
49
+ ```
50
+
51
+ Skills activate automatically in projects that have `.tasca/tasca.db`.
52
+
53
+ Future install paths (post-alpha):
54
+ - `npm install -g tasca` (with Bun installed)
55
+ - Pre-compiled binaries from GitHub Releases (with checksums)
56
+ - Claude Code marketplace plugin (bundles CLI + skills)
57
+
58
+ ## Quick start
59
+
60
+ ```bash
61
+ # 1. Initialize a tasca DB in your project
62
+ cd my-project
63
+ tasca init
64
+ # → Creates .tasca/tasca.db
65
+
66
+ # 2. Register a spec with its markdown content (typically done by brainstorming skill)
67
+ tasca spec add SPEC-001 "User authentication" \
68
+ --file specs/001-auth/spec.md
69
+ # OR via stdin:
70
+ cat specs/001-auth/spec.md | tasca spec add SPEC-001 "User authentication" --stdin
71
+
72
+ # 3. Register the implementation plan (typically done by writing-plans skill)
73
+ cat plan.md | tasca plan add SPEC-001 --stdin
74
+
75
+ # 4. Add tasks (typically done by writing-plans skill)
76
+ tasca add TASK-001-A "Create auth schema" \
77
+ --spec SPEC-001 \
78
+ --desc "Define Drizzle schema for users table..." \
79
+ --package "@app/auth" \
80
+ --gate "pnpm typecheck" \
81
+ --gate "pnpm test -- --run"
82
+
83
+ # 5. Agent takes the task (atomic — returns full task JSON in single call)
84
+ tasca take TASK-001-A
85
+ # Owner is auto-detected as "{parent_process}:{pid}:{username}"
86
+ # Override via $TASCA_USER env var
87
+
88
+ # 6. Agent marks done
89
+ tasca done TASK-001-A --result "typecheck ✓ test ✓"
90
+
91
+ # 7. Export content when needed
92
+ tasca spec content SPEC-001 > /tmp/spec.md
93
+ tasca plan show SPEC-001 > /tmp/plan.md
94
+ ```
95
+
96
+ ## Commands
97
+
98
+ | Command | Purpose |
99
+ |---|---|
100
+ | `tasca init` | Create `.tasca/tasks.db` in cwd |
101
+ | `tasca status` | Summary: pending / in_progress / completed counts |
102
+ | `tasca list [filters]` | List tasks with optional filters |
103
+ | `tasca add ID "subject"` | Create a new task |
104
+ | `tasca show ID` | Show full task detail |
105
+ | `tasca take ID` | Atomically claim a pending task |
106
+ | `tasca done ID --result "..."` | Mark task completed |
107
+ | `tasca fail ID --error "..."` | Mark task failed |
108
+ | `tasca block ID --by BLOCKER` | Add a dependency |
109
+ | `tasca spec add ID "title"` | Register a spec |
110
+ | `tasca spec list` | List all specs |
111
+ | `tasca spec show ID` | Spec details |
112
+ | `tasca spec start ID` | Mark spec as in progress |
113
+ | `tasca spec done ID --pr N` | Mark spec as completed |
114
+ | `tasca server [--port N]` | Start HTTP dashboard + REST API |
115
+
116
+ Run `tasca --help` for full flag reference.
117
+
118
+ ## Dashboard & API
119
+
120
+ ```bash
121
+ tasca server # starts on http://127.0.0.1:8272 (TASC on phone keypad)
122
+ tasca server --port 8080 # custom port
123
+ ```
124
+
125
+ The dashboard is a single self-contained HTML page (no external assets, ships
126
+ inside the compiled binary). Features:
127
+
128
+ - **Real-time updates via SSE** — no polling; dashboard reacts instantly to CLI mutations from any process
129
+ - **Markdown rendering** — spec content, plans, descriptions all render properly
130
+ - **Action buttons** — take / done / fail tasks and start / done specs directly from the UI
131
+ - **Create from UI** — new spec / new task forms with markdown editor
132
+ - **Full-text search** — searches across specs (title + content) and tasks (subject + description)
133
+ - **Live indicator** — green pulse = SSE connected, red = disconnected
134
+
135
+ ### REST API
136
+
137
+ #### Read endpoints
138
+
139
+ | Method | Path | Returns |
140
+ |---|---|---|
141
+ | GET | `/api/status` | Stats: counts per status |
142
+ | GET | `/api/specs` | Specs with task summary and latest plan version |
143
+ | GET | `/api/specs/:id` | Spec + tasks + plans + latest plan content |
144
+ | GET | `/api/specs/:id/content` | Raw markdown of the spec |
145
+ | GET | `/api/specs/:id/plan` | Raw markdown of the latest plan |
146
+ | GET | `/api/tasks?status=&spec=&owner=` | Filtered task list |
147
+ | GET | `/api/tasks/:id` | Single task |
148
+ | GET | `/api/events?limit=N` | Recent audit log entries |
149
+ | GET | `/api/search?q=...` | Search specs and tasks |
150
+ | GET | `/api/events/stream` | SSE stream of new events as they happen |
151
+
152
+ #### Mutation endpoints (since v0.4)
153
+
154
+ | Method | Path | Body |
155
+ |---|---|---|
156
+ | POST | `/api/specs` | `{id, title, content?}` |
157
+ | POST | `/api/specs/:id/start` | `{}` |
158
+ | POST | `/api/specs/:id/done` | `{pr?, merged_date?}` |
159
+ | POST | `/api/specs/:id/content` | `{content}` (replace) |
160
+ | POST | `/api/specs/:id/plans` | `{content}` (new version) |
161
+ | POST | `/api/tasks` | `{id, subject, description?, spec_id?, packages?, quality_gates?, blocked_by?}` |
162
+ | POST | `/api/tasks/:id/take` | `{owner?}` (atomic; rejects if not pending) |
163
+ | POST | `/api/tasks/:id/done` | `{result}` |
164
+ | POST | `/api/tasks/:id/fail` | `{error}` |
165
+ | POST | `/api/tasks/:id/block` | `{by}` |
166
+
167
+ Set the `X-Tasca-Actor` header to identify yourself in the audit log
168
+ (e.g. `X-Tasca-Actor: dashboard`, `X-Tasca-Actor: ci-bot`). If unset, the
169
+ server infers actor from the User-Agent.
170
+
171
+ ### Security notes
172
+
173
+ The server binds to `127.0.0.1` by default — no external access. There is no
174
+ authentication built in; the model assumes the local machine is trusted (same
175
+ as a dev server). If you bind to `0.0.0.0`, put it behind a reverse proxy with
176
+ auth.
177
+
178
+ ## Output formats
179
+
180
+ ```bash
181
+ tasca list # auto: color if TTY, plain otherwise
182
+ tasca list --plain # explicit plain (no ANSI codes)
183
+ tasca list --json # JSON for agents and scripts
184
+ ```
185
+
186
+ ## Claude Code skills
187
+
188
+ `tasca` ships four skills that cover the full [Spec-Driven Development](https://github.com/anthropics/superpowers) cycle. They replace the markdown-file workflow entirely — no `docs/superpowers/` directory, no growing plan files, no token waste reading stale state.
189
+
190
+ | Skill | When Claude uses it | What it does |
191
+ |---|---|---|
192
+ | `tasca-sdd` | Always, when `.tasca/tasca.db` exists | Master skill — teaches Claude the tasca workflow; activates the others |
193
+ | `tasca-write-spec` | Designing a new feature | Writes spec + implementation plan directly into tasca (`tasca spec add` + `tasca plan add`) |
194
+ | `tasca-write-tasks` | After spec + plan exist | Decomposes the plan into atomic tasks with file-level parallelism analysis and `blocked_by` dependencies |
195
+ | `tasca-dispatch` | Executing a spec | Dispatches subagents into git worktrees; each agent calls `tasca take`, works in isolation, reports via `tasca done` |
196
+
197
+ The skills are drop-in: in projects without tasca, Claude falls back to the regular superpowers markdown flow.
198
+
199
+ ## Architecture
200
+
201
+ ```
202
+ ~/.tasca/ (future) global config
203
+ <project>/.tasca/tasca.db local SQLite, auto-discovered like .git
204
+
205
+ Tables:
206
+ specs (id, numero, title, status, content TEXT, pr, merged_date, ...)
207
+ plans (id, spec_id FK, content TEXT, version, created_at)
208
+ indexed on spec_id for fast lookup; unique(spec_id, version)
209
+ tasks (id, spec_id, subject, description, status, owner,
210
+ blocked_by, packages, quality_gates, result, error, ...)
211
+ events (append-only audit log of every operation, with actor)
212
+ ```
213
+
214
+ `tasca` walks up the directory tree from `cwd` looking for `.tasca/tasca.db`, the same way git locates `.git`. This means you can run `tasca` commands from any subdirectory of your project.
215
+
216
+ ### Why the content lives in the DB
217
+
218
+ `tasca` stores the actual markdown of specs and plans inside SQLite, not as paths to external files. This means:
219
+ - `tasca` is the single source of truth — no risk of broken paths or moved files
220
+ - Plans can have multiple versions tracked (revisions during refinement)
221
+ - Export to markdown is trivial: `tasca spec content SPEC-X > spec.md`
222
+ - An agent calling `tasca spec content SPEC-X` gets the same bytes the human gets, deterministically
223
+
224
+ ### Audit log
225
+
226
+ Every mutation records an event in the `events` table with an `actor` identifier of the form `{parent_process}:{pid}:{username}` (e.g., `claude:12345:m`, `opencode:67890:m`, `bash:99999:m`). Override with `$TASCA_USER` for explicit agent identity.
227
+
228
+ ## License
229
+
230
+ MIT
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "feinai",
3
+ "version": "0.5.0",
4
+ "description": "Task & spec manager for AI agents — parallel worktrees, live dashboard, SDD skills",
5
+ "type": "module",
6
+ "bin": {
7
+ "feinai": "./src/cli.ts",
8
+ "opengit": "./src/opengit.sh"
9
+ },
10
+ "scripts": {
11
+ "dev": "bun src/cli.ts",
12
+ "test": "bun test",
13
+ "build": "bun build src/cli.ts --compile --outfile dist/feina",
14
+ "build:linux-x64": "bun build src/cli.ts --compile --target=bun-linux-x64 --outfile dist/feina-linux-x64",
15
+ "build:linux-arm64": "bun build src/cli.ts --compile --target=bun-linux-arm64 --outfile dist/feina-linux-arm64",
16
+ "build:darwin-x64": "bun build src/cli.ts --compile --target=bun-darwin-x64 --outfile dist/feina-darwin-x64",
17
+ "build:darwin-arm64": "bun build src/cli.ts --compile --target=bun-darwin-arm64 --outfile dist/feina-darwin-arm64",
18
+ "build:all": "bun run build:linux-x64 && bun run build:linux-arm64 && bun run build:darwin-x64 && bun run build:darwin-arm64"
19
+ },
20
+ "keywords": [
21
+ "task-manager",
22
+ "sdd",
23
+ "claude-code",
24
+ "ai-agents",
25
+ "sqlite",
26
+ "cli",
27
+ "feina"
28
+ ],
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/mvisca/feina.git"
33
+ },
34
+ "homepage": "https://github.com/mvisca/feina#readme",
35
+ "bugs": {
36
+ "url": "https://github.com/mvisca/feina/issues"
37
+ },
38
+ "engines": {
39
+ "bun": ">=1.3.0",
40
+ "node": ">=22.5.0"
41
+ },
42
+ "optionalDependencies": {
43
+ "better-sqlite3": ">=9.0.0"
44
+ },
45
+ "files": [
46
+ "src/*.ts",
47
+ "src/*.html",
48
+ "src/*.sh",
49
+ "README.md",
50
+ "LICENSE",
51
+ "CHANGELOG.md",
52
+ "skills/"
53
+ ],
54
+ "devDependencies": {
55
+ "@types/bun": "latest"
56
+ },
57
+ "peerDependencies": {
58
+ "typescript": "^5"
59
+ }
60
+ }
@@ -0,0 +1,233 @@
1
+ ---
2
+ name: feinai-dispatch
3
+ description: Use when tasks exist in feinai for a spec and need to be executed. Dispatches subagents to claim and complete tasks, enforces worktree isolation, handles parallelism (sequential or parallel based on user choice), and resolves merge conflicts and failures by blocking the loop until repair completes. Replaces `subagent-driven-development` from superpowers when feinai is active.
4
+ ---
5
+
6
+ # feinai-dispatch
7
+
8
+ Execute the pending tasks of a SPEC. One responsibility: dispatch subagents in worktrees, integrate their output, handle failures.
9
+
10
+ ## Preconditions
11
+
12
+ 1. `feinai status` succeeds
13
+ 2. The SPEC has pending tasks: `feinai list --spec SPEC-NNN --pending --json` returns non-empty
14
+ 3. The current working directory is a clean git repo (no uncommitted changes blocking worktree creation)
15
+
16
+ If any fails: stop and report. Do not improvise.
17
+
18
+ ## Input
19
+
20
+ User invokes with a SPEC-ID. If missing, ask: *"Which SPEC-ID? (e.g. SPEC-121-B)"*.
21
+
22
+ ---
23
+
24
+ ## Phase 0 — Detect orphans
25
+
26
+ Before doing anything, check for orphaned tasks:
27
+
28
+ ```bash
29
+ feinai list --spec SPEC-NNN --json | jq '.[] | select(.status == "in_progress")'
30
+ ```
31
+
32
+ Any `in_progress` task is a previous run that didn't complete. For each:
33
+
34
+ 1. Check if its `worktree` path still exists on disk
35
+ 2. Check if the worktree has uncommitted work
36
+ 3. Report to the user and ask: *"Task TASK-X is in_progress at <worktree>. Resume, release, or fail?"*
37
+
38
+ Do not proceed to Phase 1 until all orphans are resolved.
39
+
40
+ ---
41
+
42
+ ## Phase 1 — Choose execution mode
43
+
44
+ Read the task graph:
45
+
46
+ ```bash
47
+ feinai list --spec SPEC-NNN --pending --json
48
+ ```
49
+
50
+ Analyze `blocked_by` to find tasks ready to run (no unresolved blockers).
51
+
52
+ If multiple tasks are ready simultaneously, ask the user:
53
+
54
+ > Found N tasks ready: TASK-A, TASK-B, TASK-C.
55
+ > Run **in parallel** (faster, harder to debug) or **sequentially** (safer, slower)?
56
+
57
+ Do NOT decide for the user. The choice is intentional — fallos críticos
58
+ en cadena son una preocupación real del usuario. Respect their answer.
59
+
60
+ ---
61
+
62
+ ## Phase 2 — The dispatch loop
63
+
64
+ For each iteration:
65
+
66
+ ### Step A — Pick the next task(s)
67
+
68
+ - **Sequential mode:** one task whose blockers are all `completed`
69
+ - **Parallel mode:** all ready tasks (max as recommended by the plan)
70
+
71
+ ### Step B — Create worktrees
72
+
73
+ For each task to dispatch:
74
+
75
+ ```bash
76
+ git worktree add .claude/worktrees/TASK-X-id <branch>
77
+ ```
78
+
79
+ Branch naming: `feature/TASK-X-id-slug` derived from the subject.
80
+
81
+ ### Step C — Register the worktree in feinai
82
+
83
+ ```bash
84
+ feinai take TASK-X --json # atomic claim, sin worktree aún
85
+ feinai task edit TASK-X --worktree .claude/worktrees/TASK-X-id
86
+ ```
87
+
88
+ Order matters: take first (atomic reservation), then edit to record the worktree path.
89
+
90
+ ### Step D — Dispatch the subagent
91
+
92
+ Spawn a subagent with this prompt template:
93
+
94
+ > Your task is TASK-X. You are operating in the worktree at <path>.
95
+ > Do not switch branches. Do not edit files outside the worktree.
96
+ >
97
+ > The task is already claimed for you. Begin with:
98
+ > ```
99
+ > feinai show TASK-X --json
100
+ > ```
101
+ > The JSON returns the task description, packages, quality_gates, and spec_context
102
+ > (the full spec + plan_content). Use only that payload — do not read external files
103
+ > unless the description tells you to.
104
+ >
105
+ > Implement the task. Run the quality gates. If they pass:
106
+ > ```
107
+ > feinai done TASK-X --result "<gates summary>"
108
+ > ```
109
+ >
110
+ > If gates fail and you cannot resolve, or if you hit a merge conflict on merge-back:
111
+ > ```
112
+ > feinai fail TASK-X --error "<short reason>"
113
+ > ```
114
+ > and stop. Do not try to recover or improvise.
115
+
116
+ **Parallel mode:** dispatch all subagents in one batch (one tool call with multiple subagent invocations).
117
+
118
+ ### Step E — Wait for results
119
+
120
+ Each subagent returns `done` or `fail`. The tasca DB is the source of truth — re-query it:
121
+
122
+ ```bash
123
+ feinai show TASK-X --json
124
+ ```
125
+
126
+ ### Step F — Integrate (per completed task)
127
+
128
+ For each `completed` task:
129
+
130
+ 1. Run the quality gates **again** in the worktree as a final check
131
+ 2. Merge worktree branch into the working branch
132
+ 3. Remove the worktree: `git worktree remove .claude/worktrees/TASK-X-id`
133
+ 4. Clear the worktree field: `feinai task edit TASK-X --worktree ""`
134
+
135
+ If the merge has conflicts → treat as a failure. Go to Phase 3.
136
+
137
+ ---
138
+
139
+ ## Phase 3 — Failure handling (blocking)
140
+
141
+ When a task fails OR a merge conflict appears:
142
+
143
+ **Stop the loop.** No new tasks dispatch until repair is complete.
144
+
145
+ ### Repair sequence
146
+
147
+ 1. **Attempt your own fix** — read the worktree, the error, the failed task description. If it's a clear typo or trivial issue, fix it inline.
148
+ 2. **If stuck → advisor()** — call the advisor with full context. Wait for the response.
149
+ 3. **If still stuck → ask the user** — present:
150
+ - What failed
151
+ - What you tried
152
+ - The advisor's suggestion (if available)
153
+ - Ask: *"How to proceed? (a) I'll try the suggested fix, (b) escalate to a stronger model, (c) you take over"*
154
+
155
+ ### After repair
156
+
157
+ - If you resolved it: `feinai task edit TASK-X --worktree ...` (if path changed), then `feinai release TASK-X` so it returns to pending, OR `feinai done` if you finished it yourself
158
+ - If user took over: stop. Tell them to relaunch dispatch with: `/feinai-dispatch SPEC-NNN`
159
+
160
+ **Never silently retry.** Always make the failure visible.
161
+
162
+ ---
163
+
164
+ ## Phase 4 — Completion
165
+
166
+ When `feinai list --spec SPEC-NNN --pending --json` returns empty:
167
+
168
+ 1. Verify no `in_progress` left:
169
+ ```bash
170
+ feinai list --spec SPEC-NNN --json | jq '.[] | select(.status != "completed")'
171
+ ```
172
+ Should be empty.
173
+ 2. Run project-wide quality gates (from the plan)
174
+ 3. Report to the user:
175
+ > SPEC-NNN complete. All N tasks done. Quality gates pass.
176
+ > Mark spec done with: `feinai spec done SPEC-NNN --pr <num> --merged <date>` (when you merge to main).
177
+
178
+ ---
179
+
180
+ ## Rules
181
+
182
+ ### Worktree rules (non-negotiable)
183
+
184
+ - ✅ Each task gets its own worktree under `.claude/worktrees/`
185
+ - ✅ Subagent never switches branches, never works outside its worktree
186
+ - ✅ Worktree path is recorded in feinai (`worktree` field) immediately after `take`
187
+ - ❌ Never run `git checkout` on the main working tree during dispatch
188
+ - ❌ Never delete a worktree without first marking the task done/failed/released
189
+
190
+ ### Parallelism rules
191
+
192
+ - The "same file = sequential" decision was already made in `feinai-write-tasks` via `blocked_by`. Trust it.
193
+ - Do NOT second-guess. If `blocked_by` says A→B→C, run them sequentially even in "parallel mode."
194
+ - "Parallel mode" only means: tasks with no inter-dependencies dispatch concurrently.
195
+
196
+ ### Failure rules
197
+
198
+ - One failure = stop the world. Block the loop. Repair before continuing.
199
+ - Failed tasks keep their `worktree` field (we changed this intentionally) — so you can inspect them.
200
+ - Never auto-retry. Repair → release → next loop iteration will re-pick.
201
+
202
+ ### Subagent autonomy boundary
203
+
204
+ - Subagents read only their task payload (via `feinai take` / `feinai show`)
205
+ - Subagents may not call other skills (they have no context)
206
+ - Subagents may not dispatch other subagents
207
+ - All decision-making about scope, parallelism, and failure handling stays in the dispatcher
208
+
209
+ ---
210
+
211
+ ## What NOT to do
212
+
213
+ - ❌ Skip Phase 0 (orphan detection) — you'll dispatch into half-broken state
214
+ - ❌ Dispatch without creating a worktree first
215
+ - ❌ Decide parallel vs sequential without asking the user
216
+ - ❌ Continue the loop while a task is failed
217
+ - ❌ Read every task description yourself — let the subagent do it via `feinai take`
218
+ - ❌ Modify tasks during dispatch — that's `feinai-write-tasks`' job; if specs need changing, stop and tell the user
219
+
220
+ ---
221
+
222
+ ## Quick reference
223
+
224
+ | Need | Command |
225
+ |---|---|
226
+ | Find ready tasks | `feinai list --spec SPEC-N --pending --json` |
227
+ | Find orphans | `feinai list --spec SPEC-N --json \| jq '.[] \| select(.status=="in_progress")'` |
228
+ | Claim a task | `feinai take TASK-X` |
229
+ | Record worktree | `feinai task edit TASK-X --worktree <path>` |
230
+ | Mark done | `feinai done TASK-X --result "..."` |
231
+ | Mark failed (keeps worktree) | `feinai fail TASK-X --error "..."` |
232
+ | Release for retry | `feinai release TASK-X` |
233
+ | Verify all done | `feinai list --spec SPEC-N --json` |