@afokapu/atdd-flow 0.2.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 Alec Fokapu
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,226 @@
1
+ # ATDD Workflow
2
+
3
+ `atdd-flow` is a filesystem-first control plane for coordinated coding agents. It keeps durable coordination in a separate Git-backed **Desk**, not inside the code repositories and worktrees being changed.
4
+
5
+ ## The model
6
+
7
+ ```text
8
+ Desk (private Git repository) Code repositories / worktrees
9
+ ├── work/<project>/ └── implementation only
10
+ │ ├── project.yaml policy
11
+ │ ├── seats/ replaceable responsibilities and handoffs
12
+ │ └── tasks/ delivery, criteria, and proof
13
+ └── threads/ conversation and immutable messages
14
+ ```
15
+
16
+ - A **seat** owns responsibility, branch, worktree, checkpoint, and host addresses; a **task** owns its brief, ownership, dependencies, criteria, and proof.
17
+ - A **thread** owns messages, receipts, results, and decisions; a **host** owns panes and notifications—never durable state.
18
+
19
+ A stable address, such as `driver.runtime@resolver-os`, survives a different pane, host, model, or replacement agent. A replacement reads its durable seat, task, checkpoint, and threads rather than predecessor-private context.
20
+
21
+ Workflow is a YAML protocol and CLI—not a database, daemon, agent runtime, or task-management SaaS. Git supplies history and replication; a multiplexer may wake an agent, but never owns state.
22
+
23
+ ## Install and create a Desk
24
+
25
+ Install locally in every code repository whose agents use Workflow:
26
+
27
+ ```sh
28
+ bun add -d @afokapu/atdd-flow@latest
29
+ ```
30
+
31
+ ### Migrating from ATDD Workflow
32
+
33
+ Install `@afokapu/atdd-flow` and replace `atdd-workflow` (including `bunx atdd-workflow`) with
34
+ `atdd-flow`. Existing Desk YAML schemas and `ATDD_WORKFLOW_ROOT` remain compatible.
35
+
36
+ The operator creates one private Desk for projects that coordinate together:
37
+
38
+ ```sh
39
+ atdd-flow init "$HOME/Github/desk" --git
40
+ export ATDD_WORKFLOW_ROOT="$HOME/Github/desk"
41
+ ```
42
+
43
+ Use `--root "$HOME/Github/desk"` for one-off commands. Keeping the Desk separate avoids code-branch conflicts and permits cross-repository work.
44
+
45
+ ### Declare launch executables once
46
+
47
+ `desk.yaml` owns the executable names that every seat may use. Give each name
48
+ an absolute command path when the host does not guarantee a shared `PATH`:
49
+
50
+ ```yaml
51
+ schema: atdd-workflow/desk/v1
52
+ desk: desk
53
+ application: tuios
54
+ executables:
55
+ claude: /Users/you/.local/bin/claude
56
+ codex: /opt/homebrew/bin/codex
57
+ pi: /opt/homebrew/bin/pi
58
+ kimi: /Users/you/.kimi-code/bin/kimi
59
+ ```
60
+
61
+ The executable registry is transport configuration, not model allocation. New seats do not pin an
62
+ agent. Instead, `models.yaml` declares the launchable model portfolio in descending capability order:
63
+
64
+ ```yaml
65
+ schema: atdd-workflow/models/v1
66
+ models:
67
+ - id: frontier
68
+ executable: claude
69
+ args: [--model, opus]
70
+ - id: standard
71
+ executable: claude
72
+ args: [--model, sonnet]
73
+ - id: codex
74
+ executable: codex
75
+ - id: glm
76
+ executable: glm
77
+ enabled: false
78
+ ```
79
+
80
+ Order is policy: strongest first, weakest last. Entries whose executable is unavailable, or whose
81
+ `enabled` flag is false, are excluded. For ordinary phase work, Jev sees the seat's active work and
82
+ selects the weakest available model sufficient for that responsibility. If model selection is unavailable
83
+ or low-confidence, Workflow conservatively launches the strongest available model. Final behavioral
84
+ review has its own bounded routing step described below. Older Desks without `models.yaml` continue
85
+ to honor a legacy seat `agent` through the executable registry.
86
+
87
+ ## Configure worktrees and seats
88
+
89
+ Create a project, then set its policy in `work/<project>/project.yaml`:
90
+
91
+ ```sh
92
+ atdd-flow project init resolver-os
93
+ ```
94
+
95
+ ```yaml
96
+ repository: /Users/you/Github/resolver-os
97
+ worktree_root: /Users/you/Github/worktrees/resolver-os
98
+ roles:
99
+ coordinator: { address: coordinator@{project}, branch: main, worktree: '{repository}' }
100
+ driver: { address: driver.{name}@{project}, branch: delivery/{name}, base: main, worktree: '{worktree_root}/{name}' }
101
+ ```
102
+
103
+ The operator or coordinator creates seats; drivers do not choose their policy:
104
+
105
+ ```sh
106
+ atdd-flow spawn resolver-os coordinator main --worktree /Users/you/Github/resolver-os
107
+ atdd-flow spawn resolver-os driver runtime
108
+ ```
109
+
110
+ `spawn` creates missing driver worktrees through Git: this example creates `/Users/you/Github/worktrees/resolver-os/runtime` on `delivery/runtime`. ATDD Bun owns safe retirement, not creation. A seat can own several tasks.
111
+
112
+ ## Deliver work
113
+
114
+ ```text
115
+ todo → in_progress → review → done
116
+ ```
117
+
118
+ The coordinator assigns; the driver implements, proves each criterion, and submits for review; only the coordinator marks the task done.
119
+
120
+ ```sh
121
+ atdd-flow task add resolver-os runtime-rollout --title 'Complete runtime rollout' \
122
+ --coordinator coordinator@resolver-os --assignee driver.runtime@resolver-os \
123
+ --done-when 'Checks pass'
124
+ atdd-flow task start resolver-os runtime-rollout --by driver.runtime@resolver-os
125
+ atdd-flow task prove resolver-os runtime-rollout --by driver.runtime@resolver-os --item 1 --proof 'CI run 42'
126
+ atdd-flow task review resolver-os runtime-rollout --by driver.runtime@resolver-os
127
+ atdd-flow behavioral-review launch resolver-os runtime-rollout --by coordinator@resolver-os \
128
+ --application tuios --placement resolver-os --gate 'CI run 42'
129
+ # the reviewer persists APPROVE, RETURN, or ESCALATE through behavioral-review record
130
+ atdd-flow task done resolver-os runtime-rollout --by coordinator@resolver-os
131
+ ```
132
+
133
+ Proof is a compact PR, CI run, report, commit range, deployment, or thread reference. Dependencies gate prerequisites; independent tasks are parallel-ready. Use `task block` only for a real external blocker, then checkpoint exact state and next action. For deliveries explicitly governed by the `workflow` ATDD Bun profile, `review → done` additionally requires a durable final behavioral-review result with decision `APPROVE` for the current clean delivery commit. For an idle driver’s final task, `task done ... --retire-assignee` delegates clean-and-merged worktree retirement to ATDD Bun.
134
+
135
+ ## Communicate and hand over
136
+
137
+ Threads are the durable inbox/outbox. Workflow persists a message before a best-effort host notification, so a closed pane, rate limit, or missed prompt cannot lose it.
138
+
139
+ ```sh
140
+ atdd-flow thread start --with coordinator@resolver-os,driver.runtime@resolver-os \
141
+ --subject 'Runtime rollout' --task resolver-os/runtime-rollout
142
+ atdd-flow post T-... --from coordinator@resolver-os --to driver.runtime@resolver-os \
143
+ --expects-result --body 'Implement the task and return proof references.'
144
+ atdd-flow result T-... M-... --from driver.runtime@resolver-os --body 'CI run 42; PR #81.'
145
+ ```
146
+
147
+ For a shared boundary: driver → coordinator → affected coordinator(s) → minimum agreement in a thread → driver. `--to all` broadcasts; requested results remain outstanding until every recipient replies. Checkpoints are short handoffs, not logs; update at responsibility transitions and before replacing an agent.
148
+
149
+ ## Inspect, host, and guide agents
150
+
151
+ ```sh
152
+ atdd-flow status
153
+ atdd-flow status seat driver.runtime@resolver-os
154
+ atdd-flow open driver.runtime@resolver-os
155
+ ```
156
+
157
+ TUIOS is the primary live host; tmux and Herdr have notification adapters. TUIOS launch targets the named session, never the focused session:
158
+
159
+ ```sh
160
+ atdd-flow attach driver.runtime@resolver-os --application tuios
161
+ atdd-flow launch driver.runtime@resolver-os --application tuios --placement resolver-os
162
+ ```
163
+
164
+ Launch selects a model from `models.yaml`, starts that model's executable in the seat's declared worktree, passes `ATDD_WORKFLOW_ROOT` and `ATDD_WORKFLOW_SEAT`, records the selected model on the live runtime binding, and asks the agent to read its seat. Other hosts remain correct without an adapter; their operator supplies that prompt.
165
+
166
+ With ATDD Bun, enable the Workflow profile:
167
+
168
+ ```yaml
169
+ profiles: [planner, coder, tester, traceability, security, workflow]
170
+ ```
171
+
172
+ The lifecycle convention makes agents read CLI help and durable records, prefer the smallest sufficient change, avoid speculative scope, work until review-ready or explicitly blocked, prove criteria, and coordinate boundaries through coordinators. ATDD Bun remains repository and merge authority.
173
+
174
+ ### Final behavioral reconciliation
175
+
176
+ Phase work does not add a writer/reviewer pair after every artifact. The next phase consumes and
177
+ semantically challenges the previous phase while ATDD Bun provides deterministic enforcement. The
178
+ explicit independent review is reserved for the terminal integration boundary:
179
+
180
+ ```text
181
+ implementation → deterministic gates → task review → JEV routing
182
+ → behavioral reviewer → coordinator decision → done/merge
183
+ ```
184
+
185
+ ATDD Bun owns the substantive method through
186
+ `atdd-bun.review.behavioral-reconciliation`. Workflow first runs deterministic ATDD Bun gates; a red
187
+ gate prevents reviewer launch. JEV then classifies only the required review surface
188
+ (`LOCAL | ASSEMBLED | JOURNEY | SYSTEM`) plus bounded routing signals such as proof boundary,
189
+ cross-path scope, consequence, and runtime observability. JEV does not decide correctness.
190
+
191
+ Workflow selects the reviewer model from `models.yaml`, creates a task-scoped reviewer seat in the
192
+ delivery worktree, injects the full installed ATDD Bun review convention into the reviewer prompt, and
193
+ presents inputs in intent-first order. The reviewer records a structured result with
194
+ `APPROVE | RETURN | ESCALATE`; it never mutates task state. Review attempts are retained in
195
+ `work/<project>/tasks/<task>.reviews.yaml` and are bound to a clean delivery commit.
196
+
197
+ `APPROVE` makes the task eligible for coordinator completion. `RETURN` is evidence for the
198
+ coordinator to move `review → in_progress`. `ESCALATE` leaves the task in review (or the coordinator
199
+ may explicitly block it) while authoritative intent is resolved. Only the coordinator can transition
200
+ `review → done`.
201
+
202
+ ## Optional Jev helper
203
+
204
+ Jev is read-only; it cannot mutate state, approve proof, or override ATDD Bun.
205
+
206
+ ```sh
207
+ atdd-flow scout --goal 'Fix payment retry behavior' --path src/payment/retry.ts --path src/profile/avatar.ts
208
+ atdd-flow focus-check resolver-os runtime-rollout --action 'Add a generic retry orchestration service'
209
+ ```
210
+
211
+ `scout` selects likely files. `focus-check` returns `REQUIRED`, `USEFUL_BUT_NOT_REQUIRED`, or `SPECULATIVE`.
212
+ The final behavioral-review launcher also uses JEV System-1 for bounded routing questions only; low
213
+ routing confidence becomes conservative `SYSTEM` routing. Use Jev judgments as routing advice, never
214
+ as correctness or completion authority. If scouting or focus judgment is unavailable, use repository
215
+ evidence and prefer the smaller reversible solution; if model selection is unavailable, escalate
216
+ conservatively to the strongest available candidate.
217
+
218
+ On macOS, Jev reads its TypeSafe key only from Keychain item `atdd-workflow.typesafe`; `TYPESAFE_API_KEY` is a temporary or CI override. The secret is never written to Desk records, output, Git, npm, or GitHub.
219
+
220
+ ## Command reference
221
+
222
+ ```sh
223
+ bunx atdd-flow --help
224
+ ```
225
+
226
+ Installed help is the authoritative syntax for that version.
package/bin/atdd-flow ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import "../src/cli.ts";
@@ -0,0 +1,183 @@
1
+ schema_version: 1.1.0
2
+ rule_id: atdd-workflow.workflow.lifecycle
3
+ kind: policy
4
+ status: active
5
+ name: Coordinate durable agent work through seats, tasks, and threads
6
+ statement: >-
7
+ When the workflow profile is active, agents coordinate durable work through the locally installed
8
+ atdd-flow CLI and its YAML coordination root. A seat owns its runtime binding, branch and
9
+ worktree; a task owns its delivery state and proof; a thread owns its conversation. Drivers favor
10
+ the smallest effective implementation, coordinate shared-boundary decisions through their
11
+ coordinators, and continue assigned work until it is review-ready or explicitly blocked.
12
+ terms:
13
+ - term_id: workflow_root
14
+ text: >-
15
+ The separate coordination repository holding work/, threads/, and the durable YAML records.
16
+ - term_id: seat
17
+ text: >-
18
+ A replaceable agent responsibility with a purpose, worktree/branch binding, checkpoint, and
19
+ optional native application addresses.
20
+ - term_id: retirement
21
+ text: >-
22
+ The final housekeeping step for an idle driver seat. It is delegated to ATDD Bun rather than
23
+ performed with raw Git commands.
24
+ - term_id: smallest_sufficient_change
25
+ text: >-
26
+ The least broad implementation that correctly satisfies the current task's done_when criteria
27
+ and the repository's existing conventions.
28
+ - term_id: responsibility_boundary
29
+ text: >-
30
+ A point where implementation requires agreement about vocabulary, interfaces, contracts,
31
+ ownership, or responsibility shared with another seat or project.
32
+ - term_id: boundary_handshake
33
+ text: >-
34
+ The coordinator-mediated agreement used when a driver reaches a shared responsibility boundary.
35
+ Coordinators resolve only the minimum shared contract necessary to continue implementation and
36
+ record that agreement durably in a Workflow thread.
37
+ - term_id: review_ready
38
+ text: >-
39
+ A task state reached only after required implementation and verification are complete, every
40
+ done_when criterion carries proof, the task has been moved to review, and the coordinator has
41
+ received the result.
42
+ - term_id: model_portfolio
43
+ text: >-
44
+ The models.yaml list of launchable model candidates, ordered strongest to weakest. Seats do not
45
+ normally own a model; Jev selects the weakest available candidate sufficient for the current work.
46
+ - term_id: behavioral_review
47
+ text: >-
48
+ The independent final semantic reconciliation performed after deterministic gates and before a
49
+ Workflow-governed task may move from review to done. ATDD Bun owns the substantive review method;
50
+ Workflow owns routing, reviewer allocation, durable evidence, and lifecycle enforcement.
51
+ content:
52
+ summary: >-
53
+ Use coordination records as the durable source of truth. Drivers implement the smallest effective
54
+ solution, coordinators resolve shared-boundary ambiguity, and an assigned task continues until
55
+ review-ready or explicitly blocked.
56
+ normative_text: |
57
+ Before taking workflow action in a repository, run `atdd-flow --help` to discover the
58
+ commands and current syntax available in the installed CLI. If the executable is project-local
59
+ and not on PATH, run `bunx atdd-flow --help`. Treat that help output as the command authority:
60
+ do not invent flags, infer command forms from memory, or rely on an older agent's instructions.
61
+
62
+ Start from the current seat, checkpoint, assigned tasks, and relevant thread records. A replacement
63
+ agent resumes from those records; it does not depend on a conversation with its predecessor.
64
+
65
+ A driver starts only its assigned ready task. Treat the task's done_when criteria as the required
66
+ delivery scope. Prefer existing repository patterns, components, dependencies, contracts, and
67
+ abstractions. When multiple implementations are correct, choose the smallest effective change that
68
+ agrees with the existing system.
69
+
70
+ Do not redesign adjacent systems, introduce generalized infrastructure, add dependencies, create
71
+ abstractions for hypothetical future requirements, or perform unrelated cleanup merely because the
72
+ opportunity was discovered. Broaden the implementation only when a done_when criterion requires it,
73
+ the current design cannot correctly satisfy the task without it, or the broader change is necessary
74
+ to resolve a verified blocker.
75
+
76
+ Work criterion by criterion. Continue from the next unmet done_when criterion through
77
+ implementation, verification, and proof rather than treating successful code generation as task
78
+ completion.
79
+
80
+ An autonomous work turn on an assigned in_progress task must not intentionally end while required
81
+ work remains actionable. Complete the required implementation, run the relevant tests and ATDD Bun
82
+ checks, correct failures caused by the work, record proof for every done_when criterion, move the
83
+ task to review, and send the coordinator a result. Continue until the task is review-ready or
84
+ explicitly blocked.
85
+
86
+ If completion is impossible, record the blocker, checkpoint the exact current state and next action,
87
+ and notify the coordinator. Do not silently leave actionable required work unfinished.
88
+
89
+ When a driver reaches a responsibility boundary involving shared vocabulary, endpoint shape,
90
+ contracts, artifact ownership, or another participant's responsibility, do not independently
91
+ redefine the shared contract. Send the concrete boundary question to the driver's coordinator.
92
+
93
+ The coordinator aligns directly with affected coordinators through the existing durable thread
94
+ mechanism. Resolve only the minimum shared vocabulary, interface, ownership, or responsibility split
95
+ needed for the current work. Prefer an existing convention or contract over inventing a new one.
96
+ Record the agreement in the relevant thread and communicate the result back to affected drivers.
97
+
98
+ Boundary coordination is not an invitation to redesign adjacent systems or solve hypothetical future
99
+ needs. A settled boundary decision remains in force unless implementation produces concrete evidence
100
+ that it cannot satisfy the task.
101
+
102
+ A driver waiting on a boundary decision continues any independent required work that remains
103
+ actionable. Mark the task blocked only when the unresolved decision prevents further meaningful
104
+ progress.
105
+
106
+ Use `atdd-flow scout` only when repository scope is genuinely unclear or candidate files are
107
+ numerous. Use `atdd-flow focus-check` only before a likely scope expansion such as a new
108
+ dependency, generalized abstraction, persistent schema, architecture change, adjacent refactor, or
109
+ unrelated defect. These read-only Jev judgments advise scope; they do not own correctness or completion.
110
+
111
+ New seats do not pin a model. The Desk's models.yaml is ordered strongest to weakest, and ordinary
112
+ launches ask Jev for the weakest available model sufficient for the seat's current active work. If
113
+ Jev model selection is unavailable or low-confidence, use the strongest available configured model.
114
+ A legacy Desk without models.yaml may continue to use its pinned seat agent.
115
+
116
+ Do not add a writer/reviewer pair after every development phase. The next phase consumes and
117
+ semantically challenges the prior phase while active ATDD Bun conventions provide deterministic
118
+ enforcement. Reserve the explicit independent semantic reviewer for the final integration boundary.
119
+
120
+ A driver records proof for every done_when criterion, moves the completed task to review, and sends
121
+ its coordinator a result. Before a final behavioral reviewer is launched, Workflow runs the
122
+ deterministic ATDD Bun gates in the delivery worktree. If a strict gate is red, do not invoke the
123
+ semantic reviewer; return the discrepancy to the appropriate implementation phase.
124
+
125
+ After deterministic gates pass, Jev may answer only bounded routing questions for final review. It
126
+ classifies the required review surface as LOCAL, ASSEMBLED, JOURNEY, or SYSTEM and supplies routing
127
+ signals such as behavior-affecting versus behavior-preserving intent, highest relevant proof
128
+ boundary, cross-path scope, consequence, reconciliation shape, runtime observability, and confidence.
129
+ Jev must not approve a delivery, decide semantic correctness, mutate task state, or redefine intent.
130
+ Low-confidence routing is treated conservatively as SYSTEM.
131
+
132
+ Workflow maps the bounded routing result through models.yaml to select a reviewer model, creates a
133
+ task-scoped reviewer responsibility in the delivery worktree, and provides the reviewer inputs in
134
+ this order: task criteria/source; relevant plan artifacts; deterministic gate evidence; executable
135
+ proof; runtime/worktree; then implementation/diff context. The complete installed
136
+ atdd-bun.review.behavioral-reconciliation convention is the authoritative review method and must be
137
+ included in the reviewer prompt. Workflow must not duplicate that methodology in its own convention.
138
+
139
+ The reviewer records durable structured evidence containing intent sources, expected behavior,
140
+ exercised boundary and evidence, observed behavior, reconciliation findings, a decision of APPROVE,
141
+ RETURN, or ESCALATE, rationale, and confidence. The reviewer does not mutate task state. APPROVE
142
+ makes the current clean delivery commit eligible for coordinator completion. RETURN is evidence for
143
+ the coordinator to move review back to in_progress. ESCALATE leaves the task in review, or the
144
+ coordinator may explicitly block it, until authoritative intent is resolved. Only the coordinator
145
+ may move review to done.
146
+
147
+ For repositories explicitly governed by the workflow profile, Workflow deterministically prevents
148
+ review -> done unless the latest behavioral-review attempt is complete, records APPROVE, and matches
149
+ the current clean delivery commit. These checks prove that the required review occurred and applies
150
+ to the delivery being completed; they do not prove the reviewer's semantic judgment is correct.
151
+
152
+ A driver seat may own more than one task. A coordinator uses
153
+ `atdd-flow task done <project> <task> --by <coordinator> --retire-assignee` only when every
154
+ task assigned to that driver in the project is done and the seat is intentionally being retired.
155
+ That operation delegates to `atdd-bun worktree finish --delete-branch`; do not remove a worktree,
156
+ delete a delivery branch, or force cleanup through raw Git. A failed retirement leaves the task in
157
+ review and writes a blocked checkpoint for investigation.
158
+
159
+ Before working in or retiring a driver worktree, install that repository's local dependencies there.
160
+ Retirement resolves ATDD Bun from the worktree's local node_modules/.bin so it does not depend on a
161
+ developer's global executable installation.
162
+
163
+ Use the atdd-flow CLI to mutate workflow records. Read task, seat, checkpoint, and thread YAML
164
+ before acting; do not treat terminal pane history, a multiplexer, an optional judgment helper, or an
165
+ agent's private memory as durable coordination state.
166
+ fix_hint: >-
167
+ Return to the assigned task and its unmet done_when criteria. Remove speculative scope that is not
168
+ required for correctness. Resolve shared boundary ambiguity through the relevant coordinators.
169
+ Complete remaining verification and proof, or explicitly record the blocker and next action.
170
+ exceptions:
171
+ - A broader change is permitted when it is necessary to satisfy the current task correctly or resolve
172
+ a verified blocker.
173
+ - A driver may continue independent work while waiting for a boundary decision.
174
+ - A task may be completed normally without retiring its assignee when that driver still has work.
175
+ - A live host may notify an agent to inspect its seat, but it never owns the durable state.
176
+ - An optional Jev scouting, focus, final-review-routing, or model-selection judgment may advise
177
+ execution, but it never owns task state, proof, correctness, or completion authority.
178
+ metadata:
179
+ aliases:
180
+ - ATDD-WORKFLOW-LIFECYCLE
181
+ introduced_in: 0.1.3
182
+ implementation:
183
+ type: none
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@afokapu/atdd-flow",
3
+ "version": "0.2.0",
4
+ "description": "Filesystem-first Desk registry for projects, seats, tasks, threads, and handoffs.",
5
+ "type": "module",
6
+ "bin": {
7
+ "atdd-flow": "bin/atdd-flow"
8
+ },
9
+ "scripts": {
10
+ "workflow": "bun run src/cli.ts",
11
+ "check": "bun run src/cli.ts --help",
12
+ "test": "bun test"
13
+ },
14
+ "files": [
15
+ "bin",
16
+ "conventions",
17
+ "src",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "keywords": [
22
+ "atdd",
23
+ "workflow",
24
+ "agents",
25
+ "multi-agent",
26
+ "coordination",
27
+ "bun"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/afokapu/atdd-flow.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/afokapu/atdd-flow/issues"
35
+ },
36
+ "homepage": "https://github.com/afokapu/atdd-flow#readme",
37
+ "license": "MIT",
38
+ "engines": {
39
+ "bun": ">=1.3.0"
40
+ },
41
+ "devDependencies": {
42
+ "@afokapu/atdd-bun": "^0.10.44"
43
+ },
44
+ "dependencies": {
45
+ "@typesafe-ai/sdk": "^0.6.0"
46
+ }
47
+ }
@@ -0,0 +1,88 @@
1
+ import { run } from "./core";
2
+
3
+ type Environment = Record<string, string | undefined>;
4
+
5
+ const value = (environment: Environment, name: string, application: string) => {
6
+ const current = environment[name];
7
+ if (!current) throw new Error(`Cannot discover ${application} here: ${name} is not set.`);
8
+ return current;
9
+ };
10
+
11
+ /**
12
+ * Native host location discovery. These values come from the host process,
13
+ * rather than from an agent, title, label, or whichever pane happens to have
14
+ * focus in the UI.
15
+ */
16
+ export function discoverAddress(application: string, environment: Environment = process.env): string {
17
+ const discoverers: Record<string, () => string> = {
18
+ herdr: () => value(environment, "HERDR_PANE_ID", "Herdr"),
19
+ tmux: () => value(environment, "TMUX_PANE", "tmux"),
20
+ tuios: () => `${value(environment, "TUIOS_SESSION", "TUIOS")}/${value(environment, "TUIOS_WINDOW_ID", "TUIOS")}`,
21
+ };
22
+ const discover = discoverers[application];
23
+ if (!discover) throw new Error(`No deterministic discovery adapter is installed for ${application}.`);
24
+ return discover();
25
+ }
26
+
27
+ export function notificationCommand(application: string, address: string, notice: string): string[] | undefined {
28
+ const commands: Record<string, () => string[] | undefined> = {
29
+ tmux: () => ["tmux", "send-keys", "-t", address, notice, "Enter"],
30
+ // A Herdr pane id is the canonical runtime address. `pane send-text` is
31
+ // supported by both standalone Herdr and TUIOS's embedded Herdr server;
32
+ // `agent send` is not available on every embedded-server version.
33
+ herdr: () => ["herdr", "pane", "send-text", address, notice],
34
+ tuios: () => {
35
+ const separator = address.indexOf("/");
36
+ if (separator < 1 || separator === address.length - 1) return undefined;
37
+ return ["tuios", "queue", "-s", address.slice(0, separator), "-w", address.slice(separator + 1), notice];
38
+ },
39
+ };
40
+ return commands[application]?.();
41
+ }
42
+
43
+ export type LaunchRequest = {
44
+ application: string;
45
+ placement: string;
46
+ name: string;
47
+ worktree: string;
48
+ agent: string;
49
+ args?: string[];
50
+ environment?: Record<string, string>;
51
+ root: string;
52
+ seat: string;
53
+ };
54
+
55
+ /** A launch placement names a host container, never the currently visible UI. */
56
+ export function launchCommand(request: LaunchRequest): string[] {
57
+ const environment = [
58
+ "/usr/bin/env",
59
+ `ATDD_WORKFLOW_ROOT=${request.root}`,
60
+ `ATDD_WORKFLOW_SEAT=${request.seat}`,
61
+ ...Object.entries(request.environment ?? {}).map(([key, value]) => `${key}=${value}`),
62
+ request.agent,
63
+ ...(request.args ?? []),
64
+ ];
65
+ if (request.application === "tuios") {
66
+ return [
67
+ "tuios", "new-window", request.name,
68
+ "-s", request.placement,
69
+ "--cwd", request.worktree,
70
+ "--no-focus", "--print-id", "--",
71
+ ...environment,
72
+ ];
73
+ }
74
+ throw new Error(`No deterministic launch adapter is installed for ${request.application}.`);
75
+ }
76
+
77
+ export function launchedAddress(application: string, placement: string, output: string) {
78
+ if (application !== "tuios") throw new Error(`No deterministic launch adapter is installed for ${application}.`);
79
+ const window = output.split(/\s+/)[0];
80
+ if (!window) throw new Error("TUIOS created a window without returning its id.");
81
+ return `${placement}/${window}`;
82
+ }
83
+
84
+ export async function notify(application: string, address: string, notice: string) {
85
+ const command = notificationCommand(application, address, notice);
86
+ if (!command) return;
87
+ await run(command, true);
88
+ }