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