@ucsandman/legcli 0.8.0 → 0.9.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 (110) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/NOTICE +8 -0
  3. package/README.md +601 -560
  4. package/bin/fake-agent.mjs +4 -4
  5. package/bin/leg.mjs +21 -12
  6. package/docs/DECISIONS.md +20 -2
  7. package/docs/ERRORS.md +71 -0
  8. package/docs/README.md +2 -0
  9. package/docs/REUSE.md +1 -1
  10. package/docs/VOCABULARY.md +21 -0
  11. package/docs/board-guide.md +13 -0
  12. package/docs/cli-contracts.md +22 -1
  13. package/docs/concepts.md +42 -3
  14. package/docs/configuration.md +22 -1
  15. package/docs/faq.md +19 -0
  16. package/docs/getting-started.md +272 -251
  17. package/docs/harness.md +319 -0
  18. package/fixtures/verified.json +1 -1
  19. package/package.json +7 -3
  20. package/scripts/build-docs-site.mjs +11 -4
  21. package/scripts/check-branding.mjs +118 -0
  22. package/scripts/check-claims.mjs +1 -1
  23. package/scripts/license-sign.mjs +1 -1
  24. package/scripts/limits-table.mjs +1 -1
  25. package/scripts/live-limits.mjs +1 -1
  26. package/scripts/npm-publish-gate.mjs +114 -0
  27. package/scripts/probe.mjs +4 -3
  28. package/scripts/seed-fake-cards.mjs +4 -3
  29. package/scripts/seed-floor-board.mjs +5 -4
  30. package/scripts/seed-wes-board.mjs +5 -4
  31. package/scripts/stripe-setup.mjs +1 -1
  32. package/scripts/sync-harness-engine.mjs +159 -0
  33. package/scripts/sync-leg-agents.mjs +127 -0
  34. package/src/accounts.mjs +1 -2
  35. package/src/adapters/codex.mjs +1 -1
  36. package/src/attach.mjs +75 -19
  37. package/src/auth.mjs +2 -2
  38. package/src/board/board.js +3 -3
  39. package/src/board/sessions.js +77 -3
  40. package/src/bundle.mjs +54 -8
  41. package/src/chain.mjs +1 -1
  42. package/src/contract.mjs +4 -3
  43. package/src/fsx.mjs +5 -2
  44. package/src/handoff.mjs +6 -6
  45. package/src/harness/cli.mjs +281 -0
  46. package/src/harness/fingerprint.mjs +68 -0
  47. package/src/harness/index.mjs +407 -0
  48. package/src/harness/registry.mjs +124 -0
  49. package/src/harness/vendor/agnostic-ai/LICENSE +21 -0
  50. package/src/harness/vendor/agnostic-ai/UPSTREAM.json +30 -0
  51. package/src/harness/vendor/agnostic-ai/core/safety/guards.json +96 -0
  52. package/src/harness/vendor/agnostic-ai/core/templates/targets.json +252 -0
  53. package/src/harness/vendor/agnostic-ai/engine/harness/README.md +199 -0
  54. package/src/harness/vendor/agnostic-ai/engine/harness/apply.cjs +247 -0
  55. package/src/harness/vendor/agnostic-ai/engine/harness/bundle.cjs +243 -0
  56. package/src/harness/vendor/agnostic-ai/engine/harness/capture.cjs +119 -0
  57. package/src/harness/vendor/agnostic-ai/engine/harness/common.cjs +375 -0
  58. package/src/harness/vendor/agnostic-ai/engine/harness/index.cjs +55 -0
  59. package/src/harness/vendor/agnostic-ai/engine/harness/sources/claude.cjs +330 -0
  60. package/src/harness/vendor/agnostic-ai/engine/harness/sources/codex.cjs +314 -0
  61. package/src/harness/vendor/agnostic-ai/engine/harness/status.cjs +171 -0
  62. package/src/harness/vendor/agnostic-ai/engine/harness/targets/agy.cjs +113 -0
  63. package/src/harness/vendor/agnostic-ai/engine/harness/targets/claude.cjs +158 -0
  64. package/src/harness/vendor/agnostic-ai/engine/harness/targets/codex.cjs +832 -0
  65. package/src/harness/vendor/agnostic-ai/engine/harness/targets/cursor.cjs +87 -0
  66. package/src/harness/vendor/agnostic-ai/engine/harness/targets/gemini.cjs +128 -0
  67. package/src/harness/vendor/agnostic-ai/engine/harness/targets/generic.cjs +424 -0
  68. package/src/harness/vendor/agnostic-ai/engine/harness/toml.cjs +149 -0
  69. package/src/harness/vendor/agnostic-ai/engine/hooks/shim.cjs +431 -0
  70. package/src/hook.mjs +49 -49
  71. package/src/land.mjs +7 -35
  72. package/src/launcher.mjs +38 -26
  73. package/src/ledger.mjs +6 -6
  74. package/src/license.mjs +10 -9
  75. package/src/live-capture.mjs +1 -1
  76. package/src/mergequeue.mjs +5 -5
  77. package/src/orchestrator.mjs +28 -4
  78. package/src/preferences.mjs +37 -3
  79. package/src/redact.mjs +1 -1
  80. package/src/resume.mjs +17 -15
  81. package/src/runner.mjs +2 -2
  82. package/src/scheduler.mjs +1 -1
  83. package/src/server.mjs +38 -10
  84. package/src/session-detail.mjs +15 -1
  85. package/src/sessions.mjs +6 -3
  86. package/src/share.mjs +2 -2
  87. package/src/stations/agent.mjs +1 -1
  88. package/src/sync/dashclaw.mjs +4 -4
  89. package/src/synthesis.mjs +165 -0
  90. package/src/taps/agy.mjs +2 -2
  91. package/src/taps/claude-usage.mjs +1 -1
  92. package/src/taps/claude.mjs +170 -170
  93. package/src/taps/codex.mjs +286 -286
  94. package/src/taps/grok.mjs +2 -2
  95. package/src/trust.mjs +205 -36
  96. package/src/usage.mjs +5 -1
  97. package/src/worktree.mjs +5 -4
  98. package/fixtures/live/agy/attempt-1-scratch-workspace.out.log +0 -1
  99. package/fixtures/live/agy/err.log +0 -0
  100. package/fixtures/live/agy/out.log +0 -1
  101. package/fixtures/live/agy/supervisor.log +0 -2
  102. package/fixtures/live/claude/err.log +0 -0
  103. package/fixtures/live/claude/out.log +0 -1
  104. package/fixtures/live/claude/supervisor.log +0 -2
  105. package/fixtures/live/codex/err.log +0 -1
  106. package/fixtures/live/codex/out.log +0 -8
  107. package/fixtures/live/codex/supervisor.log +0 -2
  108. package/fixtures/live/grok/err.log +0 -32
  109. package/fixtures/live/grok/out.log +0 -7
  110. package/fixtures/live/grok/supervisor.log +0 -2
@@ -1,251 +1,272 @@
1
- # Getting started
2
-
3
- For a developer setting up Leg for the first time on their own machine. The
4
- first four sections get an interactive agent running with the board alongside
5
- it. The v0.1 pipeline flow is section 7 onward.
6
-
7
- ## 1. Prerequisites
8
-
9
- - Node 22 or newer (`package.json` sets `"engines": {"node": ">=22"}`).
10
- - git.
11
- - Python 3 with pip, for the `context-handoff-bundle` CLI. This is what writes
12
- and reads the handoff bundles.
13
- - At least one coding-agent CLI, logged in: `claude`, `codex`, `agy` or
14
- `grok`. You do not need all four. With one installed you get the board
15
- and the usage tracking; with two or more you also get the hand-off.
16
-
17
- ## 2. Install
18
-
19
- ```
20
- npm install -g @ucsandman/legcli
21
- pip install -U context-handoff-bundle
22
- ```
23
-
24
- The source repository is private, so there is no clone to install from. The
25
- source you run ships in the package: `$(npm root -g)/legcli/src`, plain
26
- `.mjs`, nothing bundled. Read it before you trust it.
27
-
28
- ## 3. Run an agent
29
-
30
- ```
31
- cd <any repo>
32
- leg claude
33
- ```
34
-
35
- That is the whole setup. `leg claude` runs the real Claude Code in this
36
- terminal with your own settings, hooks and skills. Anything after the agent
37
- name passes straight through:
38
-
39
- ```
40
- leg claude --model haiku
41
- leg codex -m gpt-5.3-codex-spark
42
- leg agy
43
- ```
44
-
45
- The first `leg <agent>` starts the board on http://127.0.0.1:4747 and opens
46
- it once in your browser. Later sessions reuse the same board. Set
47
- `LEG_NO_OPEN=1` to skip the browser.
48
-
49
- Leg strips `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`,
50
- `ANTHROPIC_BASE_URL`, `ANTHROPIC_CUSTOM_HEADERS`, `OPENAI_API_KEY`,
51
- `OPENAI_BASE_URL`, `OPENAI_API_BASE`, `GEMINI_API_KEY`, `GOOGLE_API_KEY`,
52
- `GOOGLE_GEMINI_BASE_URL`, `GOOGLE_GENAI_USE_VERTEXAI`,
53
- `GOOGLE_GENAI_USE_ENTERPRISE`, `GOOGLE_CLOUD_PROJECT`,
54
- `GOOGLE_CLOUD_LOCATION`, `GOOGLE_APPLICATION_CREDENTIALS`, `CLAUDECODE`,
55
- `CLAUDE_CODE_*`, `CLAUDE_EFFORT`, and `CLAUDE_PLUGIN_DATA` from the agent's
56
- environment, then sets `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0` for a detached
57
- Claude print session. The subscription login is always what runs. Nothing in
58
- `~/.claude`, `~/.codex` or agy's home is edited.
59
-
60
- ## 4. What you get while it runs
61
-
62
- - A card on the board for this terminal: agent, account, repo@branch, the first
63
- prompt, turns, the files being touched, 5h and 7d usage.
64
- - A warning at 85 % of either window (`LEG_WARN_PCT`): amber card, an event,
65
- one terminal bell.
66
- - For Codex, the board and active attach poll the read-only app-server
67
- `account/rateLimits/read` response every 60 seconds. Leg maps the returned
68
- 300- and 10080-minute durations to 5h and 7d, shows `<n>% used`, and labels
69
- old readings stale. Only an explicit backend available answer clears a prior
70
- wall; no model turn or hardcoded quota is used.
71
- - A `context-handoff-bundle` for this session, refreshed every two minutes and
72
- at every warning, limit and hand-off.
73
- - At the limit: the bundle is saved, the agent is stopped, and the next option
74
- starts in the same terminal from `.leg/RESUME-<session-id>.md`, copied to
75
- `.leg/RESUME.md`. Order is other logins of
76
- the same agent first, then the remaining agents (claude, codex, agy). When
77
- every option is out, Leg prints each reset time, soonest first, waits with
78
- a countdown, and starts the first one back from the bundle. Ctrl-C quits.
79
-
80
- Force a hand-off at any time with the **Hand off now** button on the card, or
81
- `leg sessions handoff <id>`.
82
-
83
- ## Is the resume file still true?
84
-
85
- ```powershell
86
- leg resume --check # exit 0 current, 1 stale or unstamped, 3 none here
87
- leg resume # the same verdict, then the pointer itself
88
- ```
89
-
90
- Leg stamps every resume file with the commit, the working tree and the
91
- terminals it was written against, and recomputes freshness from git when you
92
- read it. A commit landing, the tree moving, or the terminal it described going
93
- away all make it stale; the terminal card's drawer shows the same verdict under
94
- "What happens next". A session ending rewrites `RESUME.md` to say nothing is in
95
- flight, and the board does the same at start for a terminal that crashed, so
96
- nothing is left describing work that has moved on.
97
-
98
- ## 5. Watching and steering from the CLI
99
-
100
- ```
101
- leg sessions ls every session and its usage
102
- leg sessions show <id>
103
- leg sessions events <id>
104
- leg sessions handoff <id> same as the board button
105
- leg sessions end <id>
106
- leg sessions rm <id> forget an ended session
107
- leg sessions simulate-limit <id> drive the real limit path without a real wall (claude, agy)
108
- leg accounts ls logins and their 5h/7d usage
109
- leg open | down | status the board
110
- ```
111
-
112
- On the board, **Remove** safely prunes an ended session only when its worktree
113
- is clean and its branch is already merged into the base. For a session that
114
- needs to be removed from the board while preserving its work, use the visible
115
- **Remove record** button, read its confirmation, and keep the worktree, branch,
116
- unmerged commits, and dirty files intact.
117
-
118
- ## 6. Where files live
119
-
120
- Everything Leg writes goes under `LEG_HOME` (default `~/.leg`):
121
-
122
- ```
123
- ~/.leg/
124
- sessions/<session-id>/
125
- session.json the live record the board renders
126
- events.jsonl the timeline
127
- control.json board to runner requests
128
- hook.log what Claude Code's hooks sent
129
- claude-settings.json the per-session --settings file
130
- agy.log agy's --log-file, agy sessions only
131
- usage/<agent>--<account>.json
132
- accounts/<agent>/<name>/ extra logins (see configuration.md)
133
- landings.jsonl every Land, for the landed-on-trunk list
134
- board.log the board server's output
135
- ```
136
-
137
- In the repo you run in, Leg writes `.leg/` (session notes, `RESUME.md` and
138
- one `RESUME-<session-id>.md` per hand-off) and `.context-handoffs/` (the
139
- bundles). Both are added to `.git/info/exclude`, so they never show up in
140
- `git status`.
141
-
142
- `leg uninstall --yes` removes `~/.leg` and nothing else.
143
-
144
- ## 7. Pipelines (extras)
145
-
146
- Version 0.1 worked the other way round: you dropped a task card on the board
147
- and Leg ran the agents headless in a git worktree, one per card, with a
148
- fallback chain, path leases, a scheduler and a merge queue. All of that still
149
- works and lives below the Terminals lane. It is no longer the way in.
150
-
151
- ### Preflight
152
-
153
- ```
154
- leg up --dry
155
- ```
156
-
157
- One row per dependency (node, git, `context-handoff-bundle`, each registered
158
- adapter) with `ok` or `missing`, then exit without spawning anything. A
159
- `missing` adapter only matters if a card's chain names it.
160
-
161
- ### Start the board with the scheduler
162
-
163
- ```
164
- npm start
165
- ```
166
-
167
- `npm start` runs the same preflight, boots the board server on
168
- `http://127.0.0.1:4747`, opens it, and streams prefixed, redacted logs. Ctrl-C
169
- stops the server and any agent it started. From another terminal: `npm run
170
- stop` (which runs `leg down`).
171
-
172
- ### A card from the board
173
-
174
- Click **New card**. The form asks for:
175
-
176
- - **Repo path**: an absolute path to a local git repository (at least one
177
- commit).
178
- - **Task**: the text prompt every agent leg gets.
179
- - **Pipeline**: `factory`, `build`, `build-land`, or `custom JSON`.
180
- - **Chain**: one row per adapter, in fallback order.
181
- - **Leases** (comma separated path globs), **Trunk branch** (default `main`),
182
- **Land mode** (`ff` or `pr`), **Test command**, **Title**.
183
- - **Queue immediately**: leave it checked to start the card right away.
184
-
185
- ### A card from the CLI
186
-
187
- ```
188
- leg card add --repo <path-to-a-git-repo> --task "Add a LICENSE file" --chain claude --queue
189
- ```
190
-
191
- Other flags `card add` accepts: `--pipeline <preset|file>`, `--mode
192
- <adapter>=<mode>`, `--max-turns <adapter>=<n>`, `--leases <glob,glob>`,
193
- `--trunk <branch>`, `--land-mode ff|pr`, `--test-command "<cmd>"`, `--title
194
- "<text>"`, `--slug <id>`, `--approve <adapter,...>`.
195
-
196
- The command prints the new card id. Show it, or run it directly:
197
-
198
- ```
199
- leg card show <card-id>
200
- leg card run <card-id>
201
- leg card events <card-id>
202
- ```
203
-
204
- ### Try a pipeline with no real agent
205
-
206
- The `fake` adapter drives `bin/fake-agent.mjs`, a stand-in CLI, so you can see
207
- a full run without a subscription login:
208
-
209
- ```
210
- leg card add --repo <path-to-a-git-repo> --task "demo" --chain fake --fake-mode fake=limit --queue
211
- ```
212
-
213
- `FAKE_MODE` (set per adapter with `--fake-mode <adapter>=<mode>`) picks its
214
- behaviour: `success`, `incomplete`, `limit`, `stall`, `auth`, `crash`,
215
- `no_progress`, and the land-demo modes `break-test` / `fix-test` /
216
- `resolve-rebase`. A chain of two fake adapters (`--chain
217
- fake-claude,fake-codex --fake-mode "fake-claude=limit,fake-codex=success"`)
218
- shows a full handoff; see [DEMO.md](DEMO.md) for the walkthrough with
219
- screenshots.
220
-
221
- ### Where a card's files live
222
-
223
- ```
224
- ~/.leg/
225
- cards/<card-id>/
226
- card.json the card's current state
227
- events-<actor-key>.jsonl one append-only file per writer
228
- driver.lock the process driving the card, only while it runs
229
- unsynced.jsonl DashClaw records to retry (`ledger sync`), if any
230
- runs/<n>/
231
- run.json this run's status, outcome, exit code
232
- prompt.txt the exact prompt sent to the adapter
233
- out.log the adapter's stdout
234
- err.log the adapter's stderr
235
- supervisor.log the runner's own log for this run
236
- locks/land-<hash>.json the merge queue's turn, one per repo root, while a land runs
237
- ACTIVE.md generated summary of open cards
238
- leg.pid written by `leg up`, removed on stop
239
- scheduler.pid written by `leg scheduler start`
240
- ```
241
-
242
- A card's own git worktree lives in the repo it targets, not under
243
- `LEG_HOME`: `<repo>/.leg-worktrees/<card-id>` on branch `leg/<card-id>`.
244
-
245
- ## Next
246
-
247
- - [concepts.md](concepts.md): sessions, accounts, usage windows, the
248
- interactive hand-off, then cards, stations, chains, leases and the land
249
- station.
250
- - [board-guide.md](board-guide.md): every element of the board.
251
- - [configuration.md](configuration.md): every environment variable.
1
+ # Getting started
2
+
3
+ For a developer setting up Leg for the first time on their own machine. The
4
+ first four sections get an interactive agent running with the board alongside
5
+ it. The v0.1 pipeline flow is section 7 onward.
6
+
7
+ ## 1. Prerequisites
8
+
9
+ - Node 22 or newer (`package.json` sets `"engines": {"node": ">=22"}`).
10
+ - git.
11
+ - Python 3 with pip, for the `context-handoff-bundle` CLI. This is what writes
12
+ and reads the handoff bundles.
13
+ - At least one coding-agent CLI, logged in: `claude`, `codex`, `agy` or
14
+ `grok`. You do not need all four. With one installed you get the board
15
+ and the usage tracking; with two or more you also get the hand-off.
16
+
17
+ ## 2. Install
18
+
19
+ ```
20
+ npm install -g @ucsandman/legcli
21
+ pip install -U context-handoff-bundle
22
+ ```
23
+
24
+ `npm install -g leg-agents` is the same release: it pins this version of
25
+ `@ucsandman/legcli` and exposes the same `leg` binary.
26
+
27
+ The source repository is private, so there is no clone to install from. The
28
+ source you run ships in the package: `$(npm root -g)/legcli/src`, plain
29
+ `.mjs`, nothing bundled. Read it before you trust it.
30
+
31
+ ## 3. Run an agent
32
+
33
+ ```
34
+ cd <any repo>
35
+ leg claude
36
+ ```
37
+
38
+ That is the whole setup. `leg claude` runs the real Claude Code in this
39
+ terminal with your own settings, hooks and skills. Anything after the agent
40
+ name passes straight through:
41
+
42
+ ```
43
+ leg claude --model haiku
44
+ leg codex -m gpt-5.3-codex-spark
45
+ leg agy
46
+ ```
47
+
48
+ The first `leg <agent>` starts the board on http://127.0.0.1:4747 and opens
49
+ it once in your browser. Later sessions reuse the same board. Set
50
+ `LEG_NO_OPEN=1` to skip the browser.
51
+
52
+ Leg strips `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`,
53
+ `ANTHROPIC_BASE_URL`, `ANTHROPIC_CUSTOM_HEADERS`, `OPENAI_API_KEY`,
54
+ `OPENAI_BASE_URL`, `OPENAI_API_BASE`, `GEMINI_API_KEY`, `GOOGLE_API_KEY`,
55
+ `GOOGLE_GEMINI_BASE_URL`, `GOOGLE_GENAI_USE_VERTEXAI`,
56
+ `GOOGLE_GENAI_USE_ENTERPRISE`, `GOOGLE_CLOUD_PROJECT`,
57
+ `GOOGLE_CLOUD_LOCATION`, `GOOGLE_APPLICATION_CREDENTIALS`, `CLAUDECODE`,
58
+ `CLAUDE_CODE_*`, `CLAUDE_EFFORT`, and `CLAUDE_PLUGIN_DATA` from the agent's
59
+ environment, then sets `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0` for a detached
60
+ Claude print session. The subscription login is always what runs. Nothing in
61
+ `~/.claude`, `~/.codex` or agy's home is edited.
62
+
63
+ ## 4. What you get while it runs
64
+
65
+ - A card on the board for this terminal: agent, account, repo@branch, the first
66
+ prompt, turns, the files being touched, 5h and 7d usage.
67
+ - A warning at 85 % of either window (`LEG_WARN_PCT`): amber card, an event,
68
+ one terminal bell.
69
+ - For Codex, the board and active attach poll the read-only app-server
70
+ `account/rateLimits/read` response every 60 seconds. Leg maps the returned
71
+ 300- and 10080-minute durations to 5h and 7d, shows `<n>% used`, and labels
72
+ old readings stale. Only an explicit backend available answer clears a prior
73
+ wall; no model turn or hardcoded quota is used.
74
+ - A `context-handoff-bundle` for this session, refreshed every two minutes and
75
+ at every warning, limit and hand-off. If `.leg/SYNTHESIS-<session-id>.md` is
76
+ maintained by the agent, it is inlined into `.leg/RESUME.md` as a `## Synthesis`
77
+ section before the raw bundle dump.
78
+ - At the limit: the bundle is saved, the agent is stopped, and the next option
79
+ starts in the same terminal from `.leg/RESUME-<session-id>.md`, copied to
80
+ `.leg/RESUME.md`. Order is other logins of
81
+ the same agent first, then the remaining agents (claude, codex, agy). When
82
+ every option is out, Leg prints each reset time, soonest first, waits with
83
+ a countdown, and starts the first one back from the bundle. Ctrl-C quits.
84
+
85
+ Force a hand-off at any time with the **Hand off now** button on the card, or
86
+ `leg sessions handoff <id>`.
87
+
88
+ ## Is the resume file still true?
89
+
90
+ ```powershell
91
+ leg resume --check # exit 0 current, 1 stale or unstamped, 3 none here
92
+ leg resume # the same verdict, then the pointer itself
93
+ ```
94
+
95
+ Leg stamps every resume file with the commit, the working tree and the
96
+ terminals it was written against, and recomputes freshness from git when you
97
+ read it. A commit landing, the tree moving, or the terminal it described going
98
+ away all make it stale; the terminal card's drawer shows the same verdict under
99
+ "What happens next". A session ending rewrites `RESUME.md` to say nothing is in
100
+ flight, and the board does the same at start for a terminal that crashed, so
101
+ nothing is left describing work that has moved on.
102
+
103
+ ## 5. Watching and steering from the CLI
104
+
105
+ ```
106
+ leg sessions ls every session and its usage
107
+ leg sessions show <id>
108
+ leg sessions events <id>
109
+ leg sessions handoff <id> same as the board button
110
+ leg sessions end <id>
111
+ leg sessions rm <id> forget an ended session
112
+ leg sessions simulate-limit <id> drive the real limit path without a real wall (claude, agy)
113
+ leg accounts ls logins and their 5h/7d usage
114
+ leg open | down | status the board
115
+ ```
116
+
117
+ On the board, **Remove** safely prunes an ended session only when its worktree
118
+ is clean and its branch is already merged into the base. For a session that
119
+ needs to be removed from the board while preserving its work, use the visible
120
+ **Remove record** button, read its confirmation, and keep the worktree, branch,
121
+ unmerged commits, and dirty files intact.
122
+
123
+ ## 6. Where files live
124
+
125
+ Everything Leg writes goes under `LEG_HOME` (default `~/.leg`):
126
+
127
+ ```
128
+ ~/.leg/
129
+ sessions/<session-id>/
130
+ session.json the live record the board renders
131
+ events.jsonl the timeline
132
+ control.json board to runner requests
133
+ hook.log what Claude Code's hooks sent
134
+ claude-settings.json the per-session --settings file
135
+ agy.log agy's --log-file, agy sessions only
136
+ usage/<agent>--<account>.json
137
+ accounts/<agent>/<name>/ extra logins (see configuration.md)
138
+ landings.jsonl every Land, for the landed-on-trunk list
139
+ board.log the board server's output
140
+ harness/ the portable harness (only after leg harness enable):
141
+ bundle/, harness-state.json, backups/, history.jsonl
142
+ ```
143
+
144
+ In the repo you run in, Leg writes `.leg/` (session notes, `RESUME.md` and
145
+ one `RESUME-<session-id>.md` per hand-off) and `.context-handoffs/` (the
146
+ bundles). Both are added to `.git/info/exclude`, so they never show up in
147
+ `git status`.
148
+
149
+ `leg uninstall --yes` removes `~/.leg` and nothing else.
150
+
151
+ ## Carry your working environment too (optional)
152
+
153
+ By default a hand-off carries the task. `leg harness enable` makes it carry
154
+ the working environment as well: the rules, identity, hooks, skills,
155
+ subagents, slash commands, MCP servers and permissions of the client you
156
+ configure, rendered into the client the hand-off lands on. The first run
157
+ detects your clients, captures the source, prints what each client will
158
+ receive and what it cannot, and writes only after you say yes (or `--yes`).
159
+ Then `leg harness status` shows the state per client, and every hand-off
160
+ prepares the destination under the policy you chose. Read
161
+ [harness.md](harness.md) before enabling it: it says exactly which files are
162
+ written and how they are protected.
163
+
164
+ ## 7. Pipelines (extras)
165
+
166
+ Version 0.1 worked the other way round: you dropped a task card on the board
167
+ and Leg ran the agents headless in a git worktree, one per card, with a
168
+ fallback chain, path leases, a scheduler and a merge queue. All of that still
169
+ works and lives below the Terminals lane. It is no longer the way in.
170
+
171
+ ### Preflight
172
+
173
+ ```
174
+ leg up --dry
175
+ ```
176
+
177
+ One row per dependency (node, git, `context-handoff-bundle`, each registered
178
+ adapter) with `ok` or `missing`, then exit without spawning anything. A
179
+ `missing` adapter only matters if a card's chain names it.
180
+
181
+ ### Start the board with the scheduler
182
+
183
+ ```
184
+ npm start
185
+ ```
186
+
187
+ `npm start` runs the same preflight, boots the board server on
188
+ `http://127.0.0.1:4747`, opens it, and streams prefixed, redacted logs. Ctrl-C
189
+ stops the server and any agent it started. From another terminal: `npm run
190
+ stop` (which runs `leg down`).
191
+
192
+ ### A card from the board
193
+
194
+ Click **New card**. The form asks for:
195
+
196
+ - **Repo path**: an absolute path to a local git repository (at least one
197
+ commit).
198
+ - **Task**: the text prompt every agent leg gets.
199
+ - **Pipeline**: `factory`, `build`, `build-land`, or `custom JSON`.
200
+ - **Chain**: one row per adapter, in fallback order.
201
+ - **Leases** (comma separated path globs), **Trunk branch** (default `main`),
202
+ **Land mode** (`ff` or `pr`), **Test command**, **Title**.
203
+ - **Queue immediately**: leave it checked to start the card right away.
204
+
205
+ ### A card from the CLI
206
+
207
+ ```
208
+ leg card add --repo <path-to-a-git-repo> --task "Add a LICENSE file" --chain claude --queue
209
+ ```
210
+
211
+ Other flags `card add` accepts: `--pipeline <preset|file>`, `--mode
212
+ <adapter>=<mode>`, `--max-turns <adapter>=<n>`, `--leases <glob,glob>`,
213
+ `--trunk <branch>`, `--land-mode ff|pr`, `--test-command "<cmd>"`, `--title
214
+ "<text>"`, `--slug <id>`, `--approve <adapter,...>`.
215
+
216
+ The command prints the new card id. Show it, or run it directly:
217
+
218
+ ```
219
+ leg card show <card-id>
220
+ leg card run <card-id>
221
+ leg card events <card-id>
222
+ ```
223
+
224
+ ### Try a pipeline with no real agent
225
+
226
+ The `fake` adapter drives `bin/fake-agent.mjs`, a stand-in CLI, so you can see
227
+ a full run without a subscription login:
228
+
229
+ ```
230
+ leg card add --repo <path-to-a-git-repo> --task "demo" --chain fake --fake-mode fake=limit --queue
231
+ ```
232
+
233
+ `FAKE_MODE` (set per adapter with `--fake-mode <adapter>=<mode>`) picks its
234
+ behaviour: `success`, `incomplete`, `limit`, `stall`, `auth`, `crash`,
235
+ `no_progress`, and the land-demo modes `break-test` / `fix-test` /
236
+ `resolve-rebase`. A chain of two fake adapters (`--chain
237
+ fake-claude,fake-codex --fake-mode "fake-claude=limit,fake-codex=success"`)
238
+ shows a full handoff; see [DEMO.md](DEMO.md) for the walkthrough with
239
+ screenshots.
240
+
241
+ ### Where a card's files live
242
+
243
+ ```
244
+ ~/.leg/
245
+ cards/<card-id>/
246
+ card.json the card's current state
247
+ events-<actor-key>.jsonl one append-only file per writer
248
+ driver.lock the process driving the card, only while it runs
249
+ unsynced.jsonl DashClaw records to retry (`ledger sync`), if any
250
+ runs/<n>/
251
+ run.json this run's status, outcome, exit code
252
+ prompt.txt the exact prompt sent to the adapter
253
+ out.log the adapter's stdout
254
+ err.log the adapter's stderr
255
+ supervisor.log the runner's own log for this run
256
+ locks/land-<hash>.json the merge queue's turn, one per repo root, while a land runs
257
+ ACTIVE.md generated summary of open cards
258
+ leg.pid written by `leg up`, removed on stop
259
+ scheduler.pid written by `leg scheduler start`
260
+ ```
261
+
262
+ A card's own git worktree lives in the repo it targets, not under
263
+ `LEG_HOME`: `<repo>/.leg-worktrees/<card-id>` on branch `leg/<card-id>`.
264
+
265
+ ## Next
266
+
267
+ - [concepts.md](concepts.md): sessions, accounts, usage windows, the
268
+ interactive hand-off, then cards, stations, chains, leases and the land
269
+ station.
270
+ - [board-guide.md](board-guide.md): every element of the board.
271
+ - [configuration.md](configuration.md): every environment variable.
272
+ - [harness.md](harness.md): the portable harness, what moves between agents and what does not.