@pruddiman/dispatch 0.0.1 → 1.2.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.
Files changed (4) hide show
  1. package/README.md +178 -225
  2. package/dist/cli.js +812 -569
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +10 -4
package/README.md CHANGED
@@ -1,308 +1,261 @@
1
- # dispatch
1
+ # Dispatch
2
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.
3
+ AI agent orchestration CLI — parse work items from GitHub Issues, Azure DevOps, or local markdown files, dispatch each unit of work to a coding agent (OpenCode, GitHub Copilot, Claude Code, or OpenAI Codex), and commit results with conventional commits.
4
4
 
5
- ## Why dispatch?
5
+ ## What it does
6
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:
7
+ Dispatch closes the gap between issue trackers and AI coding agents. It:
8
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 |
9
+ 1. **Fetches work items** from GitHub Issues, Azure DevOps Work Items, or local markdown specs.
10
+ 2. **Generates structured specs** via an AI agent that explores the codebase and produces task lists.
11
+ 3. **Plans and executes** each task in isolated AI sessions, with an optional two-phase planner-then-executor pipeline.
12
+ 4. **Manages the git lifecycle** — branching, committing with conventional commit messages, pushing, and opening pull requests that auto-close the originating issue.
41
13
 
42
14
  ## Prerequisites
43
15
 
44
- ### Node.js and npm
45
-
46
- Install [Node.js](https://nodejs.org/) **>= 20.12.0** (npm is included). Verify your installation:
16
+ ### Node.js
47
17
 
48
- ```sh
49
- node --version # must be >= 20.12.0
50
- ```
51
-
52
- ### AI Agent Runtime
18
+ Node.js **>= 20.12.0** is required.
53
19
 
54
- At least one AI agent runtime must be installed and authenticated with a default model configured. dispatch cannot function without a provider backend.
20
+ ### AI provider (choose one)
55
21
 
56
- **OpenCode**
22
+ **OpenCode** (default):
57
23
 
58
24
  ```sh
59
- # Install
25
+ # Install OpenCode
60
26
  curl -fsSL https://opencode.ai/install | bash
61
27
  # or: npm install -g opencode-ai
62
- ```
63
-
64
- Launch `opencode` and run the `/connect` command to configure your LLM provider. Then verify:
65
28
 
66
- ```sh
67
- opencode --version
29
+ # Configure an LLM provider (Anthropic, OpenAI, etc.)
30
+ opencode
31
+ # then run: /connect
68
32
  ```
69
33
 
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).
34
+ **GitHub Copilot**:
75
35
 
76
36
  ```sh
77
- # Install
78
- npm install -g @github/copilot
79
- ```
37
+ # Requires an active GitHub Copilot subscription
80
38
 
81
- Launch `copilot` and follow the `/login` prompt to authenticate. Then verify:
39
+ # Install the Copilot CLI
40
+ npm install -g @github/copilot # requires Node.js 22+
41
+ # or: brew install copilot-cli
42
+ # or: winget install GitHub.Copilot
82
43
 
83
- ```sh
84
- copilot --version
44
+ # Authenticate
45
+ copilot
46
+ # then run: /login
85
47
  ```
86
48
 
87
- See [Copilot backend docs](./docs/provider-system/copilot-backend.md) for full setup options.
88
-
89
- ## Installation
49
+ For CI environments, set one of these environment variables instead of logging in interactively:
50
+ - `COPILOT_GITHUB_TOKEN` — GitHub PAT with **Copilot Requests** permission (highest priority)
51
+ - `GH_TOKEN` — standard GitHub CLI token
52
+ - `GITHUB_TOKEN` — commonly used in CI
90
53
 
91
- ```bash
92
- npm install -g @pruddiman/dispatch
93
- ```
54
+ **Claude Code** (`--provider claude`):
94
55
 
95
- Or run directly without installing:
56
+ ```sh
57
+ # Install Claude Code CLI
58
+ npm install -g @anthropic-ai/claude-code
96
59
 
97
- ```bash
98
- npx @pruddiman/dispatch
60
+ # Authenticate
61
+ claude login
62
+ # or set ANTHROPIC_API_KEY in your environment
99
63
  ```
100
64
 
101
- ## Quick Start
102
-
103
- dispatch operates as a three-stage pipeline:
104
-
105
- ### 1. Generate specs from issues
65
+ Default model: `claude-sonnet-4`. Available models: `claude-sonnet-4`, `claude-sonnet-4-5`, `claude-opus-4-6`, `claude-haiku-3-5`.
106
66
 
107
- Fetch issues from your tracker and generate structured markdown specs with task checkboxes:
67
+ **OpenAI Codex** (`--provider codex`):
108
68
 
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"
69
+ ```sh
70
+ # Install the Codex CLI
71
+ npm install -g @openai/codex
115
72
 
116
- # From an inline text description
117
- dispatch --spec "add dark mode toggle to settings page"
73
+ # Authenticate via environment variable
74
+ export OPENAI_API_KEY=sk-...
118
75
  ```
119
76
 
120
- This creates spec files in `.dispatch/specs/` (e.g., `42-add-auth.md`) with `- [ ]` task items.
77
+ Default model: `o4-mini`. Available models: `o4-mini`, `o3-mini`, `codex-mini-latest`.
121
78
 
122
- To regenerate existing specs, use `--respec`:
79
+ ### Issue tracker (choose based on your repo)
123
80
 
124
- ```bash
125
- # Regenerate all existing specs
126
- dispatch --respec
81
+ **GitHub** (`--source github`):
127
82
 
128
- # Regenerate specs for specific issues
129
- dispatch --respec 42,43,44
83
+ ```sh
84
+ # Install the GitHub CLI
85
+ # https://cli.github.com/
130
86
 
131
- # Regenerate specs matching a glob pattern
132
- dispatch --respec "specs/*.md"
87
+ gh auth login
133
88
  ```
134
89
 
135
- ### 2. Execute tasks
90
+ **Azure DevOps** (`--source azdevops`):
136
91
 
137
- Run the generated specs through the plan-and-execute pipeline:
92
+ ```sh
93
+ # Install the Azure CLI
94
+ # https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
138
95
 
139
- ```bash
140
- dispatch ".dispatch/specs/*.md"
96
+ az login
97
+ az extension add --name azure-devops
141
98
  ```
142
99
 
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
100
+ **Local markdown** (`--source md`): No external tools or authentication required.
148
101
 
149
- ### 3. Fix failing tests
102
+ ## Installation
150
103
 
151
- Run tests and automatically fix failures via an AI agent:
104
+ ```sh
105
+ # Global install — adds `dispatch` to PATH
106
+ npm install -g @pruddiman/dispatch
152
107
 
153
- ```bash
154
- dispatch --fix-tests
155
- ```
108
+ # Run without installing
109
+ npx @pruddiman/dispatch
156
110
 
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
111
+ # Local project install
112
+ npm install --save-dev @pruddiman/dispatch
113
+ npx dispatch
170
114
  ```
171
115
 
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
116
+ ## Quick start
182
117
 
183
- ```bash
118
+ ```sh
119
+ # Run interactive configuration wizard (first-time setup)
184
120
  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
121
 
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.
122
+ # Dispatch all open issues to AI agents
123
+ dispatch
193
124
 
194
- ## Requirements
125
+ # Dispatch specific issues
126
+ dispatch 42 43 44
195
127
 
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 |
128
+ # Dry run list tasks without executing
129
+ dispatch --dry-run
203
130
 
204
- ## Development
131
+ # Use GitHub Copilot instead of OpenCode
132
+ dispatch --provider copilot
205
133
 
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
134
+ # Generate specs from issues (before dispatching)
135
+ dispatch --spec 42,43
213
136
  ```
214
137
 
215
- Additional commands:
138
+ ## Pipeline modes
216
139
 
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"
140
+ | Mode | Flag | Description |
141
+ |------|------|-------------|
142
+ | **Dispatch** | *(default)* | Plan and execute tasks; manage full git lifecycle |
143
+ | **Spec generation** | `--spec` / `--respec` | Convert issues into structured markdown spec files |
144
+ | **Fix tests** | `--fix-tests` | Detect and auto-fix failing tests via AI |
225
145
 
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.
146
+ ## Task files
227
147
 
228
- **Fix:** pass `--source` explicitly:
148
+ Dispatch reads work items from markdown files with `- [ ] ...` checkbox syntax:
229
149
 
230
- ```sh
231
- dispatch --source github "tasks.md"
232
- dispatch --source azdevops "tasks.md"
233
- ```
150
+ ```markdown
151
+ # My Feature
234
152
 
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
153
+ - [ ] (P) Add the login endpoint
154
+ - [ ] (P) Write unit tests for the login endpoint
155
+ - [ ] (S) Update the API documentation
244
156
  ```
245
157
 
246
- If not installed, see [OpenCode setup](./docs/provider-system/opencode-backend.md) or [Copilot setup](./docs/provider-system/copilot-backend.md).
158
+ Each unchecked item is dispatched to an AI agent. An optional mode prefix controls execution batching:
247
159
 
248
- ### Planning timeout exceeded
160
+ | Prefix | Mode | Behavior |
161
+ |--------|------|----------|
162
+ | `(P)` | Parallel | Tasks run concurrently (up to `--concurrency`) |
163
+ | `(S)` | Serial | Tasks run one at a time |
164
+ | `(I)` | Isolated | Each task runs in a dedicated worktree |
249
165
 
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.
166
+ Tasks are marked `[x]` when complete. Rerunning dispatch skips already-completed tasks.
251
167
 
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.
168
+ ## Configuration
267
169
 
268
- **Fix:** delete the conflicting branch or use `--no-branch` to skip branch creation entirely:
170
+ Dispatch uses three-tier configuration: CLI flags override config file values, which override hardcoded defaults.
269
171
 
270
172
  ```sh
271
- dispatch --no-branch "tasks.md"
173
+ # Interactive wizard — guided setup for core AI settings (provider/model/source)
174
+ dispatch config
272
175
  ```
273
176
 
274
- ### "No unchecked tasks found"
177
+ Config is stored at `.dispatch/config.json` (relative to the working directory where you run `dispatch`):
275
178
 
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 *
179
+ ```json
180
+ {
181
+ "provider": "copilot",
182
+ "model": "claude-sonnet-4-5",
183
+ "source": "github",
184
+ "testTimeout": 60
185
+ }
284
186
  ```
285
187
 
286
- **Correct format:**
188
+ | Key | Description |
189
+ |-----|-------------|
190
+ | `provider` | AI backend: `opencode` (default), `copilot`, `claude`, or `codex` |
191
+ | `model` | Model to use when spawning agents (provider-specific format) |
192
+ | `source` | Issue tracker: `github`, `azdevops`, or `md` |
193
+ | `testTimeout` | Test execution timeout in seconds (default: 60) |
194
+
195
+ ## Options reference
196
+
197
+ ### Dispatch mode
198
+
199
+ | Option | Default | Description |
200
+ |--------|---------|-------------|
201
+ | `<issue-id...>` | *(all open)* | Issue IDs to dispatch |
202
+ | `--provider <name>` | `opencode` | AI backend (`opencode`, `copilot`, `claude`, `codex`) |
203
+ | `--source <name>` | *(auto-detected)* | Datasource (`github`, `azdevops`, `md`) |
204
+ | `--dry-run` | `false` | List tasks without executing |
205
+ | `--no-plan` | `false` | Skip planner phase, execute directly |
206
+ | `--no-branch` | `false` | Skip branch/push/PR lifecycle |
207
+ | `--concurrency <n>` | *(cpu/memory)* | Max parallel dispatches |
208
+ | `--plan-timeout <min>` | `10` | Planning timeout in minutes |
209
+ | `--plan-retries <n>` | `1` | Retries after planning timeout |
210
+ | `--server-url <url>` | *(none)* | Connect to a running provider server |
211
+ | `--cwd <dir>` | `process.cwd()` | Working directory |
212
+ | `--verbose` | `false` | Show detailed debug output |
213
+
214
+ ### Spec mode
215
+
216
+ | Option | Description |
217
+ |--------|-------------|
218
+ | `--spec <values...>` | Issue numbers, glob pattern, or description. Activates spec mode. |
219
+ | `--respec [values...]` | Regenerate existing specs. Pass no args to regenerate all. |
220
+ | `--source <name>` | Datasource override (auto-detected if omitted) |
221
+ | `--output-dir <dir>` | Output directory for spec files (default: `.dispatch/specs`) |
222
+ | `--org <url>` | Azure DevOps organization URL (required for `azdevops`) |
223
+ | `--project <name>` | Azure DevOps project name (required for `azdevops`) |
224
+
225
+ ## Datasource auto-detection
226
+
227
+ When `--source` is not provided, Dispatch inspects the git `origin` remote URL:
228
+
229
+ | Remote URL contains | Detected source |
230
+ |---------------------|----------------|
231
+ | `github.com` | `github` |
232
+ | `dev.azure.com` | `azdevops` |
233
+ | `visualstudio.com` | `azdevops` |
234
+
235
+ For local-only workflows, pass `--source md` explicitly.
236
+
237
+ ## Exit codes
238
+
239
+ | Code | Meaning |
240
+ |------|---------|
241
+ | `0` | All tasks completed successfully |
242
+ | `1` | One or more tasks failed, or a fatal error occurred |
243
+ | `130` | SIGINT (Ctrl+C) |
244
+ | `143` | SIGTERM |
287
245
 
288
- ```md
289
- - [ ] task description
290
- - [ ] (P) parallel task description
291
- ```
246
+ ## Documentation
292
247
 
293
- ## Error Handling & Recovery
248
+ Full documentation is in the [`docs/`](docs/) directory:
294
249
 
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.
250
+ - [Architecture Overview](docs/architecture.md)
251
+ - [CLI & Orchestration](docs/cli-orchestration/overview.md)
252
+ - [Datasource System](docs/datasource-system/overview.md)
253
+ - [Provider System](docs/provider-system/provider-overview.md)
254
+ - [Task Parsing](docs/task-parsing/overview.md)
255
+ - [Planning & Dispatch](docs/planning-and-dispatch/overview.md)
256
+ - [Spec Generation](docs/spec-generation/overview.md)
257
+ - [Testing](docs/testing/overview.md)
298
258
 
299
259
  ## License
300
260
 
301
261
  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