@pruddiman/dispatch 0.0.1

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/README.md ADDED
@@ -0,0 +1,308 @@
1
+ # dispatch
2
+
3
+ AI agent orchestration CLI — parse markdown task files, dispatch each unit of work to code agents (OpenCode, GitHub Copilot, etc.), and commit results with conventional commits.
4
+
5
+ ## Why dispatch?
6
+
7
+ Manual orchestration of AI coding agents is tedious when a project has many small, well-defined units of work. dispatch solves three problems:
8
+
9
+ - **Context isolation** — each task runs in a fresh agent session so context from one task does not leak into another.
10
+ - **Precision through planning** — an optional two-phase pipeline lets a read-only planner agent explore the codebase first, producing a focused execution plan that the executor agent follows.
11
+ - **Automated record-keeping** — after each task, the markdown file is updated and a conventional commit is created, giving a clean, reviewable git history tied directly to the original task list.
12
+
13
+ The tool is backend-agnostic: it supports multiple issue trackers via a datasource abstraction and multiple AI runtimes via a provider abstraction, letting teams use their existing tools without lock-in.
14
+
15
+ ## Key Features
16
+
17
+ - **Backend-agnostic** provider and datasource abstractions — no vendor lock-in
18
+ - **Two-phase planner-executor pipeline** — optional read-only planner explores the codebase before the executor makes changes (`--no-plan` skips planning)
19
+ - **Markdown as source of truth** — task files use `- [ ]` checkbox syntax with `(P)`arallel, `(S)`erial, and `(I)`solated execution mode prefixes
20
+ - **Automatic conventional commits** — commit type (feat, fix, docs, refactor, etc.) is inferred from task text
21
+ - **Real-time TUI dashboard** — terminal UI with spinner, progress bar, and per-task status tracking
22
+ - **Three-tier configuration** — CLI flags > project-local config file (`.dispatch/config.json`) > defaults
23
+ - **Configurable concurrency** — control parallel task execution per batch
24
+
25
+ ## Supported Backends
26
+
27
+ ### Providers (AI Agent Runtimes)
28
+
29
+ | Provider | SDK | Prompt Model |
30
+ |----------|-----|-------------|
31
+ | OpenCode | `@opencode-ai/sdk` | Async — fire-and-forget + SSE event stream |
32
+ | GitHub Copilot | `@github/copilot-sdk` | Synchronous — blocking request/response |
33
+
34
+ ### Datasources (Issue Trackers)
35
+
36
+ | Datasource | Tool | Auth |
37
+ |------------|------|------|
38
+ | GitHub Issues | `gh` CLI | `gh auth login` |
39
+ | Azure DevOps Work Items | `az` CLI | `az login` |
40
+ | Local Markdown | Filesystem | None |
41
+
42
+ ## Prerequisites
43
+
44
+ ### Node.js and npm
45
+
46
+ Install [Node.js](https://nodejs.org/) **>= 20.12.0** (npm is included). Verify your installation:
47
+
48
+ ```sh
49
+ node --version # must be >= 20.12.0
50
+ ```
51
+
52
+ ### AI Agent Runtime
53
+
54
+ At least one AI agent runtime must be installed and authenticated with a default model configured. dispatch cannot function without a provider backend.
55
+
56
+ **OpenCode**
57
+
58
+ ```sh
59
+ # Install
60
+ curl -fsSL https://opencode.ai/install | bash
61
+ # or: npm install -g opencode-ai
62
+ ```
63
+
64
+ Launch `opencode` and run the `/connect` command to configure your LLM provider. Then verify:
65
+
66
+ ```sh
67
+ opencode --version
68
+ ```
69
+
70
+ See [OpenCode backend docs](./docs/provider-system/opencode-backend.md) for full setup options.
71
+
72
+ **GitHub Copilot**
73
+
74
+ Requires an active [GitHub Copilot subscription](https://github.com/features/copilot/plans).
75
+
76
+ ```sh
77
+ # Install
78
+ npm install -g @github/copilot
79
+ ```
80
+
81
+ Launch `copilot` and follow the `/login` prompt to authenticate. Then verify:
82
+
83
+ ```sh
84
+ copilot --version
85
+ ```
86
+
87
+ See [Copilot backend docs](./docs/provider-system/copilot-backend.md) for full setup options.
88
+
89
+ ## Installation
90
+
91
+ ```bash
92
+ npm install -g @pruddiman/dispatch
93
+ ```
94
+
95
+ Or run directly without installing:
96
+
97
+ ```bash
98
+ npx @pruddiman/dispatch
99
+ ```
100
+
101
+ ## Quick Start
102
+
103
+ dispatch operates as a three-stage pipeline:
104
+
105
+ ### 1. Generate specs from issues
106
+
107
+ Fetch issues from your tracker and generate structured markdown specs with task checkboxes:
108
+
109
+ ```bash
110
+ # From issue numbers
111
+ dispatch --spec 42,43,44
112
+
113
+ # From local markdown files using a glob pattern
114
+ dispatch --spec "drafts/*.md"
115
+
116
+ # From an inline text description
117
+ dispatch --spec "add dark mode toggle to settings page"
118
+ ```
119
+
120
+ This creates spec files in `.dispatch/specs/` (e.g., `42-add-auth.md`) with `- [ ]` task items.
121
+
122
+ To regenerate existing specs, use `--respec`:
123
+
124
+ ```bash
125
+ # Regenerate all existing specs
126
+ dispatch --respec
127
+
128
+ # Regenerate specs for specific issues
129
+ dispatch --respec 42,43,44
130
+
131
+ # Regenerate specs matching a glob pattern
132
+ dispatch --respec "specs/*.md"
133
+ ```
134
+
135
+ ### 2. Execute tasks
136
+
137
+ Run the generated specs through the plan-and-execute pipeline:
138
+
139
+ ```bash
140
+ dispatch ".dispatch/specs/*.md"
141
+ ```
142
+
143
+ For each task, dispatch will:
144
+ 1. **Plan** — a read-only planner agent explores the codebase and produces a detailed execution plan
145
+ 2. **Execute** — an executor agent follows the plan to make code changes
146
+ 3. **Commit** — changes are staged and committed with an inferred conventional commit message
147
+ 4. **Mark complete** — the `- [ ]` checkbox is updated to `- [x]` in the source file
148
+
149
+ ### 3. Fix failing tests
150
+
151
+ Run tests and automatically fix failures via an AI agent:
152
+
153
+ ```bash
154
+ dispatch --fix-tests
155
+ ```
156
+
157
+ ### Common options
158
+
159
+ ```bash
160
+ dispatch --no-plan "tasks.md" # Skip the planning phase
161
+ dispatch --no-branch "tasks.md" # Skip branch creation, push, and PR lifecycle
162
+ dispatch --provider copilot "tasks.md" # Use GitHub Copilot instead of OpenCode
163
+ dispatch --source github "tasks.md" # Explicitly set the datasource
164
+ dispatch --concurrency 3 "tasks.md" # Run up to 3 tasks in parallel
165
+ dispatch --server-url http://localhost:3000 "tasks.md" # Use a running provider server
166
+ dispatch --plan-timeout 15 "tasks.md" # Set planning timeout to 15 minutes
167
+ dispatch --plan-retries 2 "tasks.md" # Retry planning up to 2 times
168
+ dispatch --output-dir ./my-specs --spec 42 # Custom output directory for specs
169
+ dispatch --verbose "tasks.md" # Show detailed debug output
170
+ ```
171
+
172
+ > **Concurrency auto-scaling:** When `--concurrency` is not specified, dispatch
173
+ > automatically computes a safe default using `min(cpuCount, freeMemMB / 500)`,
174
+ > with a minimum of 1. Each concurrent agent process is assumed to consume ~500 MB
175
+ > of memory.
176
+
177
+ ## Configuration
178
+
179
+ dispatch uses a three-tier configuration system: CLI flags > project-local config file (`.dispatch/config.json`) > defaults.
180
+
181
+ ### Interactive configuration
182
+
183
+ ```bash
184
+ dispatch config
185
+ ```
186
+
187
+ Running `dispatch config` launches an interactive wizard that guides you through viewing, setting, and resetting your configuration.
188
+
189
+ Valid config keys: `provider`, `model`, `concurrency`, `source`, `org`, `project`, `workItemType`, `serverUrl`, `planTimeout`, `planRetries`.
190
+
191
+ - **`model`** — AI model override in provider-specific format (e.g. `"claude-sonnet-4-5"` for Copilot, `"anthropic/claude-sonnet-4"` for OpenCode). When omitted the provider uses its default.
192
+ - **`workItemType`** — Azure DevOps work item type (e.g. `"User Story"`, `"Bug"`). Only relevant when using the `azdevops` datasource.
193
+
194
+ ## Requirements
195
+
196
+ | Requirement | Version | Notes |
197
+ |-------------|---------|-------|
198
+ | Node.js | >= 20.12.0 | Required — ESM-only runtime |
199
+ | git | Any | Required — auto-detection, conventional commits |
200
+ | `gh` CLI | Any | Optional — required for GitHub datasource |
201
+ | `az` CLI + azure-devops extension | Any | Optional — required for Azure DevOps datasource |
202
+ | OpenCode or GitHub Copilot | Varies | At least one AI agent runtime required |
203
+
204
+ ## Development
205
+
206
+ ```bash
207
+ git clone https://github.com/PatrickRuddiman/Dispatch.git
208
+ cd Dispatch
209
+ npm install
210
+ npm run build # Build with tsup
211
+ npm test # Run tests with Vitest
212
+ npm run typecheck # Type-check with tsc --noEmit
213
+ ```
214
+
215
+ Additional commands:
216
+
217
+ ```bash
218
+ npm run dev # Watch mode build
219
+ npm run test:watch # Watch mode tests
220
+ ```
221
+
222
+ ## Troubleshooting
223
+
224
+ ### "Could not detect datasource from git remote"
225
+
226
+ dispatch auto-detects whether to use GitHub or Azure DevOps by inspecting your git remote URL. If the remote does not match a known pattern (e.g., no remote configured, or a self-hosted URL), detection falls back to local markdown mode.
227
+
228
+ **Fix:** pass `--source` explicitly:
229
+
230
+ ```sh
231
+ dispatch --source github "tasks.md"
232
+ dispatch --source azdevops "tasks.md"
233
+ ```
234
+
235
+ ### Provider binary not found
236
+
237
+ dispatch requires a provider runtime (`opencode` or `copilot`) to be installed and on your `PATH`. If the binary is missing, the provider will fail to start.
238
+
239
+ **Verify installation:**
240
+
241
+ ```sh
242
+ opencode --version
243
+ copilot --version
244
+ ```
245
+
246
+ If not installed, see [OpenCode setup](./docs/provider-system/opencode-backend.md) or [Copilot setup](./docs/provider-system/copilot-backend.md).
247
+
248
+ ### Planning timeout exceeded
249
+
250
+ The planner phase has a default timeout of **10 minutes** per attempt. If the planner does not finish in time, dispatch retries up to `maxPlanAttempts` times (default: 1 retry) before failing the task.
251
+
252
+ **Fix:** increase the timeout or retries:
253
+
254
+ ```sh
255
+ dispatch --plan-timeout 20 "tasks.md" # 20-minute timeout
256
+ dispatch --plan-retries 3 "tasks.md" # Retry planning up to 3 times
257
+ ```
258
+
259
+ Both values can also be set in `.dispatch/config.json` via the `planTimeout` and `planRetries` keys.
260
+
261
+ ### Branch creation failed
262
+
263
+ dispatch creates a git branch per issue. This can fail if:
264
+
265
+ - You lack write permissions to the repository.
266
+ - A branch with the computed name already exists locally or on the remote.
267
+
268
+ **Fix:** delete the conflicting branch or use `--no-branch` to skip branch creation entirely:
269
+
270
+ ```sh
271
+ dispatch --no-branch "tasks.md"
272
+ ```
273
+
274
+ ### "No unchecked tasks found"
275
+
276
+ dispatch looks for unchecked markdown checkboxes in the `## Tasks` section. Tasks must use the exact format `- [ ]` (hyphen, space, open bracket, space, close bracket) with a space inside the brackets.
277
+
278
+ **Common mistakes:**
279
+
280
+ ```md
281
+ - [] task # wrong — missing space inside brackets
282
+ - [x] task # already checked — dispatch skips these
283
+ * [ ] task # wrong — use - not *
284
+ ```
285
+
286
+ **Correct format:**
287
+
288
+ ```md
289
+ - [ ] task description
290
+ - [ ] (P) parallel task description
291
+ ```
292
+
293
+ ## Error Handling & Recovery
294
+
295
+ - **Batch failure isolation** — when a task fails, other tasks in the same batch continue executing. Failed tasks are tracked and reported in the final summary (e.g., `Done — 5 completed, 1 failed`).
296
+ - **No run resumption** — runs cannot currently be resumed after interruption. Re-running will re-process all unchecked (`- [ ]`) tasks; tasks already marked complete (`- [x]`) in the source file are skipped.
297
+ - **`--dry-run` scope** — `--dry-run` covers task discovery and parsing only. It does not trigger spec generation, planning, or execution.
298
+
299
+ ## License
300
+
301
+ MIT
302
+
303
+ ## Documentation
304
+
305
+ For comprehensive documentation, see the [`docs/`](./docs/) directory:
306
+
307
+ - **[Documentation Index](./docs/index.md)** — entry point with key concepts and navigation guide
308
+ - **[Architecture Overview](./docs/architecture.md)** — system topology, pipeline flows, design decisions, and component index