ftown-bridge 0.26.0 → 0.27.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 (64) hide show
  1. package/dist/attention-cli.d.ts +32 -0
  2. package/dist/attention-cli.js +310 -0
  3. package/dist/attention-cli.js.map +1 -0
  4. package/dist/attention-events.d.ts +2 -1
  5. package/dist/attention-events.js.map +1 -1
  6. package/dist/attention-store.d.ts +6 -3
  7. package/dist/attention-store.js +60 -2
  8. package/dist/attention-store.js.map +1 -1
  9. package/dist/brief-cli.d.ts +10 -0
  10. package/dist/brief-cli.js +163 -0
  11. package/dist/brief-cli.js.map +1 -0
  12. package/dist/command-rpc.js +18 -15
  13. package/dist/command-rpc.js.map +1 -1
  14. package/dist/coordination/attention-routing.d.ts +37 -0
  15. package/dist/coordination/attention-routing.js +154 -0
  16. package/dist/coordination/attention-routing.js.map +1 -0
  17. package/dist/coordination/contract-b.d.ts +206 -0
  18. package/dist/coordination/contract-b.js +58 -0
  19. package/dist/coordination/contract-b.js.map +1 -0
  20. package/dist/coordination/format.js +13 -0
  21. package/dist/coordination/format.js.map +1 -1
  22. package/dist/coordination/routes-brief.d.ts +10 -0
  23. package/dist/coordination/routes-brief.js +149 -0
  24. package/dist/coordination/routes-brief.js.map +1 -0
  25. package/dist/coordination/routes-worktrees.d.ts +29 -0
  26. package/dist/coordination/routes-worktrees.js +138 -0
  27. package/dist/coordination/routes-worktrees.js.map +1 -0
  28. package/dist/coordination/wiring.d.ts +11 -2
  29. package/dist/coordination/wiring.js +31 -9
  30. package/dist/coordination/wiring.js.map +1 -1
  31. package/dist/coordination-cli.js +6 -0
  32. package/dist/coordination-cli.js.map +1 -1
  33. package/dist/create-ftown-session.d.ts +8 -1
  34. package/dist/create-ftown-session.js +164 -104
  35. package/dist/create-ftown-session.js.map +1 -1
  36. package/dist/ftown-cli.js +11 -2
  37. package/dist/ftown-cli.js.map +1 -1
  38. package/dist/index.js +4 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/local-api-server.d.ts +24 -0
  41. package/dist/local-api-server.js +462 -31
  42. package/dist/local-api-server.js.map +1 -1
  43. package/dist/mail-delivery.d.ts +18 -4
  44. package/dist/mail-delivery.js +50 -8
  45. package/dist/mail-delivery.js.map +1 -1
  46. package/dist/security/bridge/permissions.js +34 -4
  47. package/dist/security/bridge/permissions.js.map +1 -1
  48. package/dist/session-controller.d.ts +17 -1
  49. package/dist/session-controller.js +93 -2
  50. package/dist/session-controller.js.map +1 -1
  51. package/dist/sessions-commands.js +65 -5
  52. package/dist/sessions-commands.js.map +1 -1
  53. package/dist/types.d.ts +5 -0
  54. package/dist/worktrees-cli.d.ts +39 -0
  55. package/dist/worktrees-cli.js +168 -0
  56. package/dist/worktrees-cli.js.map +1 -0
  57. package/dist/worktrees.d.ts +16 -0
  58. package/dist/worktrees.js +292 -0
  59. package/dist/worktrees.js.map +1 -0
  60. package/hooks/ftown-antigravity-hook.sh +12 -6
  61. package/package.json +2 -2
  62. package/skills/ftown/SKILL.md +46 -5
  63. package/skills/ftown/references/orchestrator.md +26 -27
  64. package/skills/ftown/references/sessions.md +91 -8
@@ -0,0 +1,292 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { mkdir, realpath } from 'node:fs/promises';
4
+ import { dirname, join, resolve } from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import { WorktreeError, } from './coordination/contract-b.js';
7
+ export { WorktreeError, };
8
+ const execFileAsync = promisify(execFile);
9
+ const GIT_TIMEOUT_MS = 30_000;
10
+ const GIT_MAX_BUFFER = 10 * 1024 * 1024;
11
+ const SLUG_MAX_LENGTH = 48;
12
+ export function slugifyWorktreeName(name) {
13
+ const cleaned = name
14
+ .toLowerCase()
15
+ .replace(/[^a-z0-9]+/g, '-')
16
+ .replace(/^-+|-+$/g, '')
17
+ .slice(0, SLUG_MAX_LENGTH)
18
+ .replace(/-+$/g, '');
19
+ return cleaned || 'session';
20
+ }
21
+ async function runGit(cwd, args) {
22
+ const { stdout, stderr } = await execFileAsync('git', [...args], {
23
+ cwd,
24
+ timeout: GIT_TIMEOUT_MS,
25
+ maxBuffer: GIT_MAX_BUFFER,
26
+ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
27
+ });
28
+ return { stdout, stderr };
29
+ }
30
+ function errorMessage(err) {
31
+ if (err && typeof err === 'object') {
32
+ const stderr = err.stderr;
33
+ if (typeof stderr === 'string' && stderr.trim().length > 0) {
34
+ return stderr.trim();
35
+ }
36
+ const message = err.message;
37
+ if (typeof message === 'string' && message.trim().length > 0) {
38
+ return message.trim();
39
+ }
40
+ }
41
+ return String(err);
42
+ }
43
+ export class GitWorktrees {
44
+ constructor(_options = {}) { }
45
+ async create(req) {
46
+ const fromDir = req.fromDir;
47
+ if (!fromDir || !existsSync(fromDir)) {
48
+ throw new WorktreeError('not_a_repo', `Directory does not exist: ${fromDir}`);
49
+ }
50
+ let topLevelRaw;
51
+ let gitDirRaw;
52
+ let commonDirRaw;
53
+ try {
54
+ topLevelRaw = (await runGit(fromDir, ['rev-parse', '--show-toplevel'])).stdout.trim();
55
+ gitDirRaw = (await runGit(fromDir, ['rev-parse', '--git-dir'])).stdout.trim();
56
+ commonDirRaw = (await runGit(fromDir, ['rev-parse', '--git-common-dir'])).stdout.trim();
57
+ }
58
+ catch (err) {
59
+ throw new WorktreeError('not_a_repo', `Not a git repository (${fromDir}): ${errorMessage(err)}`);
60
+ }
61
+ const topLevel = await realpath(resolve(fromDir, topLevelRaw));
62
+ const gitDir = await realpath(resolve(fromDir, gitDirRaw));
63
+ const commonDir = await realpath(resolve(fromDir, commonDirRaw));
64
+ // When fromDir is itself a linked worktree, gitDir !== commonDir; use the main worktree's root (commonDir parent).
65
+ const repoRoot = gitDir !== commonDir ? await realpath(dirname(commonDir)) : topLevel;
66
+ let base;
67
+ if (req.base !== undefined && req.base.trim().length > 0) {
68
+ base = req.base.trim();
69
+ if (base.startsWith('-')) {
70
+ throw new WorktreeError('git_failed', `Invalid base ref: ${base}`);
71
+ }
72
+ try {
73
+ await runGit(fromDir, ['rev-parse', '--verify', `${base}^{commit}`]);
74
+ }
75
+ catch (err) {
76
+ throw new WorktreeError('git_failed', `Unknown base ref '${base}': ${errorMessage(err)}`);
77
+ }
78
+ }
79
+ else {
80
+ try {
81
+ base = (await runGit(fromDir, ['symbolic-ref', '--short', 'HEAD'])).stdout.trim();
82
+ }
83
+ catch {
84
+ throw new WorktreeError('detached_head', 'detached HEAD; pass --base');
85
+ }
86
+ if (!base) {
87
+ throw new WorktreeError('detached_head', 'detached HEAD; pass --base');
88
+ }
89
+ }
90
+ const slug = slugifyWorktreeName(req.name);
91
+ const rawBranch = req.branch !== undefined ? req.branch.trim() : `ftown/${slug}`;
92
+ if (!rawBranch || rawBranch.startsWith('-') || rawBranch.includes('@{')) {
93
+ throw new WorktreeError('bad_branch', `Invalid branch name: ${req.branch ?? ''}`);
94
+ }
95
+ try {
96
+ const checked = (await runGit(repoRoot, ['check-ref-format', '--branch', rawBranch])).stdout.trim();
97
+ if (checked !== rawBranch) {
98
+ throw new WorktreeError('bad_branch', `Invalid branch name '${rawBranch}'`);
99
+ }
100
+ }
101
+ catch (err) {
102
+ if (err instanceof WorktreeError)
103
+ throw err;
104
+ throw new WorktreeError('bad_branch', `Invalid branch name '${rawBranch}': ${errorMessage(err)}`);
105
+ }
106
+ const branch = rawBranch;
107
+ const worktreePath = join(repoRoot, '.claude', 'worktrees', slug);
108
+ if (existsSync(worktreePath)) {
109
+ throw new WorktreeError('exists', `Worktree path already exists: ${worktreePath}`);
110
+ }
111
+ try {
112
+ await runGit(repoRoot, ['show-ref', '--verify', '--quiet', `refs/heads/${branch}`]);
113
+ throw new WorktreeError('exists', `Branch already exists: ${branch}`);
114
+ }
115
+ catch (err) {
116
+ if (err instanceof WorktreeError)
117
+ throw err;
118
+ }
119
+ await mkdir(dirname(worktreePath), { recursive: true });
120
+ try {
121
+ await runGit(repoRoot, ['worktree', 'add', '-b', branch, worktreePath, base]);
122
+ }
123
+ catch (err) {
124
+ const msg = errorMessage(err);
125
+ if (/already exists|already checked out/i.test(msg)) {
126
+ throw new WorktreeError('exists', msg);
127
+ }
128
+ throw new WorktreeError('git_failed', msg);
129
+ }
130
+ const realWorktreePath = await realpath(worktreePath);
131
+ return {
132
+ repoRoot,
133
+ path: realWorktreePath,
134
+ branch,
135
+ base,
136
+ createdByBridge: true,
137
+ };
138
+ }
139
+ async status(wt) {
140
+ if (!existsSync(wt.path)) {
141
+ return {
142
+ path: wt.path,
143
+ branch: wt.branch,
144
+ base: wt.base,
145
+ exists: false,
146
+ dirty: false,
147
+ ahead: 0,
148
+ unpushed: null,
149
+ mergedIntoBase: false,
150
+ };
151
+ }
152
+ let realWtPath;
153
+ let topLevel;
154
+ try {
155
+ realWtPath = await realpath(wt.path);
156
+ const topOut = (await runGit(realWtPath, ['rev-parse', '--show-toplevel'])).stdout.trim();
157
+ topLevel = await realpath(resolve(realWtPath, topOut));
158
+ }
159
+ catch (err) {
160
+ throw new WorktreeError('git_failed', `Failed to resolve worktree root (${wt.path}): ${errorMessage(err)}`);
161
+ }
162
+ if (topLevel !== realWtPath) {
163
+ throw new WorktreeError('git_failed', `Worktree path '${wt.path}' is not a standalone worktree toplevel (resolved to '${topLevel}')`);
164
+ }
165
+ let dirty;
166
+ try {
167
+ const porcelain = (await runGit(realWtPath, ['status', '--porcelain'])).stdout;
168
+ dirty = porcelain.trim().length > 0;
169
+ }
170
+ catch (err) {
171
+ throw new WorktreeError('git_failed', `Failed to read worktree status: ${errorMessage(err)}`);
172
+ }
173
+ let ahead;
174
+ try {
175
+ const countRaw = (await runGit(realWtPath, ['rev-list', '--count', `${wt.base}..${wt.branch}`])).stdout.trim();
176
+ const parsed = Number.parseInt(countRaw, 10);
177
+ if (!Number.isFinite(parsed) || parsed < 0) {
178
+ throw new Error(`Unexpected rev-list count: ${countRaw}`);
179
+ }
180
+ ahead = parsed;
181
+ }
182
+ catch (err) {
183
+ throw new WorktreeError('git_failed', `Failed to count commits ahead of base: ${errorMessage(err)}`);
184
+ }
185
+ let unpushed = null;
186
+ let upstreamRef;
187
+ try {
188
+ upstreamRef = (await runGit(realWtPath, ['for-each-ref', '--format=%(upstream:short)', `refs/heads/${wt.branch}`])).stdout.trim();
189
+ }
190
+ catch (err) {
191
+ throw new WorktreeError('git_failed', `Failed to inspect branch upstream: ${errorMessage(err)}`);
192
+ }
193
+ if (upstreamRef.length > 0) {
194
+ try {
195
+ const countRaw = (await runGit(realWtPath, ['rev-list', '--count', `${wt.branch}@{u}..${wt.branch}`])).stdout.trim();
196
+ const parsed = Number.parseInt(countRaw, 10);
197
+ if (!Number.isFinite(parsed) || parsed < 0) {
198
+ throw new Error(`Unexpected unpushed count: ${countRaw}`);
199
+ }
200
+ unpushed = parsed;
201
+ }
202
+ catch (err) {
203
+ throw new WorktreeError('git_failed', `Failed to count unpushed commits: ${errorMessage(err)}`);
204
+ }
205
+ }
206
+ let mergedIntoBase = false;
207
+ try {
208
+ await runGit(realWtPath, ['merge-base', '--is-ancestor', wt.branch, wt.base]);
209
+ mergedIntoBase = true;
210
+ }
211
+ catch (err) {
212
+ const code = err?.code;
213
+ if (code === 1) {
214
+ mergedIntoBase = false;
215
+ }
216
+ else {
217
+ throw new WorktreeError('git_failed', `Failed to check merge status: ${errorMessage(err)}`);
218
+ }
219
+ }
220
+ return {
221
+ path: wt.path,
222
+ branch: wt.branch,
223
+ base: wt.base,
224
+ exists: true,
225
+ dirty,
226
+ ahead,
227
+ unpushed,
228
+ mergedIntoBase,
229
+ };
230
+ }
231
+ decide(status) {
232
+ if (!status.exists) {
233
+ return { action: 'retain', reason: 'worktree missing' };
234
+ }
235
+ if (status.dirty) {
236
+ return { action: 'retain', reason: 'uncommitted changes' };
237
+ }
238
+ if (status.mergedIntoBase) {
239
+ return { action: 'remove', deleteBranch: true };
240
+ }
241
+ if (status.unpushed === 0) {
242
+ return { action: 'remove', deleteBranch: false };
243
+ }
244
+ if (status.unpushed !== null && status.unpushed > 0) {
245
+ return {
246
+ action: 'retain',
247
+ reason: `${status.unpushed} unpushed commit${status.unpushed === 1 ? '' : 's'}`,
248
+ };
249
+ }
250
+ if (status.ahead > 0) {
251
+ return {
252
+ action: 'retain',
253
+ reason: `${status.ahead} unmerged commit${status.ahead === 1 ? '' : 's'}`,
254
+ };
255
+ }
256
+ return { action: 'retain', reason: 'unmerged branch' };
257
+ }
258
+ async remove(wt, opts) {
259
+ const removeArgs = ['worktree', 'remove', ...(opts.force ? ['--force'] : []), wt.path];
260
+ try {
261
+ await runGit(wt.repoRoot, removeArgs);
262
+ }
263
+ catch (err) {
264
+ throw new WorktreeError('git_failed', errorMessage(err));
265
+ }
266
+ if (opts.deleteBranch) {
267
+ let merged = false;
268
+ try {
269
+ await runGit(wt.repoRoot, ['merge-base', '--is-ancestor', wt.branch, wt.base]);
270
+ merged = true;
271
+ }
272
+ catch (err) {
273
+ const code = err?.code;
274
+ if (code !== 1) {
275
+ console.warn(`[GitWorktrees] Failed to verify merge status for branch '${wt.branch}': ${errorMessage(err)}`);
276
+ }
277
+ merged = false;
278
+ }
279
+ if (!merged) {
280
+ console.warn(`[GitWorktrees] Refusing to delete unmerged branch '${wt.branch}'`);
281
+ return;
282
+ }
283
+ try {
284
+ await runGit(wt.repoRoot, ['branch', '-d', wt.branch]);
285
+ }
286
+ catch (err) {
287
+ console.warn(`[GitWorktrees] Failed to delete branch '${wt.branch}': ${errorMessage(err)}`);
288
+ }
289
+ }
290
+ }
291
+ }
292
+ //# sourceMappingURL=worktrees.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktrees.js","sourceRoot":"","sources":["../src/worktrees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,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AAC,EAAE,CAAC;oBACf,OAAO,CAAC,IAAI,CAAC,4DAA4D,EAAE,CAAC,MAAM,MAAM,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC/G,CAAC;gBACD,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;YACD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,IAAI,CAAC,sDAAsD,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;gBACjF,OAAO;YACT,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;YACzD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,2CAA2C,EAAE,CAAC,MAAM,MAAM,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -3,9 +3,11 @@
3
3
  # ~/.ftown/antigravity-hook.sh and registered in ~/.gemini/config/hooks.json.
4
4
  # Translates agy's camelCase hook payload (stdin) to the bridge /hook wire format and POSTs it.
5
5
  # On a turn-end Stop it drains this session's ftown inbox FIRST: with mail it
6
- # prints {"decision":"continue","reason":"<mail>"} and posts nothing (the agent
7
- # keeps working); without mail it posts Stop. On terminationReason
8
- # MAX_FORCED_INVOCATIONS / USER_CANCELED / ERROR it never drains, only posts Stop.
6
+ # prints {"decision":"continue","reason":"<mail>"} (the agent keeps working) and
7
+ # still POSTs Stop so the bridge clears the busy marker (the drain marks the
8
+ # mail delivered, so that Stop finds an empty inbox); without mail it posts
9
+ # Stop. On terminationReason MAX_FORCED_INVOCATIONS / USER_CANCELED / ERROR it
10
+ # never drains, only posts Stop.
9
11
  #
10
12
  # Always exits 0, also on HUP/INT/TERM/PIPE (a non-zero or signalled PreToolUse
11
13
  # hook makes agy BLOCK the tool), and writes nothing to stdout except that one
@@ -15,7 +17,7 @@
15
17
  # Worst-case runtime: ~6s inside agy's 10s hook timeout. The POST tries at most
16
18
  # 2 endpoint candidates x curl --max-time 2 (4s); on Stop the inbox read through
17
19
  # `ftown security proxy` uses a 2s request timeout and happens before the POST,
18
- # and when it delivers mail no POST follows.
20
+ # and the POST also follows when the drain delivers mail (busy-marker clear).
19
21
  #
20
22
  # bash 3.2 compatible (macOS /bin/bash). No set -e on purpose; no temp files.
21
23
  # The hook's working directory is agy's hooks.json folder, so pwd is never used.
@@ -160,9 +162,13 @@ drain_mail() {
160
162
 
161
163
  MAIL_OUT=""
162
164
  if drain_mail; then
163
- # Mail delivered: the agent continues, so the session stays busy (no POST).
164
- # stderr is silenced so a reader that closed the pipe cannot see "Broken pipe".
165
+ # Mail delivered: the agent continues on the decision line, but the Stop is
166
+ # still POSTed so the bridge clears the busy marker (this hook posts no other
167
+ # Stop while the mail turn runs). The decision line goes out first; the POST
168
+ # is fire-and-forget and silenced. stderr is silenced so a reader that closed
169
+ # the pipe cannot see "Broken pipe".
165
170
  printf '%s\n' "$MAIL_OUT" 2>/dev/null
171
+ post_hook "$PAYLOAD" >/dev/null 2>&1 || true
166
172
  exit 0
167
173
  fi
168
174
  post_hook "$PAYLOAD"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ftown-bridge",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "CLI bridge for ftown — generic PTY-over-Centrifugo relay",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -73,5 +73,5 @@
73
73
  "overrides": {
74
74
  "qs": "6.16.1"
75
75
  },
76
- "gitHead": "033b06c892db214c1104779f68ef4f36e3c567f8"
76
+ "gitHead": "443f64c38ecd3d577f762d5e87986221fac1d26a"
77
77
  }
@@ -53,6 +53,9 @@ ftown sessions preview --clear
53
53
  ftown sessions preview-reply --message "The preview is ready."
54
54
  ftown status set --state working --headline "Reviewing the API client" --progress 0/1
55
55
  ftown board
56
+ ftown brief set --file brief.md
57
+ ftown attention list
58
+ ftown worktrees list
56
59
  ftown harness mail send <session-id> --type task "review the API client"
57
60
  ftown harness mail read
58
61
  ftown env --help
@@ -125,6 +128,21 @@ ftown board --wait --until any-done --timeout 300
125
128
  ftown events --wait
126
129
  ```
127
130
 
131
+ **Delegating work.** Delegate implementation to ftown child sessions (`ftown sessions create --parent ...`) rather than in-process subagents — only sessions appear on the board and dashboard (cards, events, digests, parent-first questions).
132
+ A child session may use its own subagents for reviews and lookups. Pick the CLI and model with `ftown quota --json` (see `references/quota.md`).
133
+
134
+ ## Manager brief
135
+
136
+ If you coordinate children, set a brief at the start and add a note at each
137
+ milestone. The dashboard overview renders the brief and your children
138
+ automatically; you do not build a status page yourself.
139
+
140
+ ```bash
141
+ ftown brief set --file brief.md
142
+ ftown brief note "All workers spawned; waiting on the first results"
143
+ ftown brief show
144
+ ```
145
+
128
146
  ## Human attention and pull requests
129
147
 
130
148
  Use `ftown sessions attention --message "..."` when you need human input. It
@@ -134,6 +152,18 @@ remains opt-in and requires a supported hosted session. Repeating an unresolved
134
152
  request updates its occurrence count; after an uncertain result, inspect the
135
153
  existing request before retrying.
136
154
 
155
+ If you have a parent, your request goes to your parent first, not the human:
156
+ the parent receives one waking escalation mail with the question and the
157
+ commands to answer or escalate it, and the human sees it greyed as "with
158
+ parent" (and may still answer). The parent answers with
159
+ `ftown attention answer <child-id> <event-id> --option <n>` (or
160
+ `--text "<reply>"`) only from facts it holds — the plan, the agreed contract,
161
+ earlier human answers — and escalates preferences and irreversible choices
162
+ with `ftown attention escalate <child-id> <event-id> --note "<context>"`.
163
+ Only the parent raises a parent-routed question to the human. Use
164
+ `ftown sessions attention ... --to human` for things only the human can
165
+ provide, such as credentials or approvals.
166
+
137
167
  ### Questions with answers
138
168
 
139
169
  Add `--option <label>` (repeatable) to ask a question the human answers in the
@@ -145,7 +175,8 @@ not cancel the question; check later with
145
175
  event ID.
146
176
 
147
177
  Delivery: a live waiter receives the answer; otherwise it arrives as ftown mail
148
- from "You" starting with `[ftown attention answer id=...]`.
178
+ from "You" starting with `[ftown attention answer id=...]`. When the parent
179
+ answers, the same delivery applies but the mail sender is the parent session.
149
180
 
150
181
  Claude Code `AskUserQuestion` calls inside an FTown session are answered from
151
182
  the same inbox, and the terminal picker appears only after "Answer in terminal"
@@ -176,12 +207,14 @@ created or updated, before the completion notice: use `ftown sessions pr <URL>`.
176
207
  Omit this step for tasks without a PR; never invent a PR or guess a session
177
208
  identity.
178
209
 
179
- Once the task is complete, request user attention **once per completed task**,
180
- before the final handoff, using `ftown sessions attention --title 'Work complete'
210
+ Once the task is complete, a top-level session requests user attention **once
211
+ per completed task**, before the final handoff, using
212
+ `ftown sessions attention --title 'Work complete'
181
213
  --message "<truthful outcome, checks and PR summary>"`.
182
214
  Do not send a completion notice every turn; retain the uncertain-result guidance
183
- above. Children must still report their result to the parent as assigned; user
184
- attention does not replace that reporting. See the completion example in
215
+ above. If you have a parent, do not raise "Work complete": set your card to
216
+ `done` and report your result to the parent as assigned; the parent raises one
217
+ completion notice for the whole job. See the completion example in
185
218
  `references/sessions.md`.
186
219
 
187
220
  ## Cleanup
@@ -199,6 +232,14 @@ ftown sessions revive <archived-session-id>
199
232
  Removal archives the session; revival creates a new session id and resumes its
200
233
  agent conversation when supported. Preserve useful results before cleanup.
201
234
 
235
+ For children that write code, create them with their own worktree:
236
+ `ftown sessions create --parent --worktree [--branch <b>] [--base <ref>]`.
237
+ `ftown sessions remove <id>` retires a bridge-created worktree when it is
238
+ clean and merged or pushed; otherwise it keeps the worktree and says why.
239
+ `--keep-worktree` always keeps it, `--force-worktree` forces removal.
240
+ Inspect or clean up archived worktrees with `ftown worktrees list` and
241
+ `ftown worktrees prune`.
242
+
202
243
  ## Connection and compatibility
203
244
 
204
245
  The commands read `~/.ftown/bridge.json`. Anyone who can read that file can
@@ -1,40 +1,39 @@
1
1
  # Worker coordination examples
2
2
 
3
3
  Read `../SKILL.md` for identity, reporting and cleanup behavior, and
4
- `sessions.md` for the command reference. These examples add only coordination
5
- steps. Use an ordinary session with the requested task and parent link; no
6
- special orchestrator mode is needed.
4
+ `sessions.md` for the command reference. Use an ordinary session with the
5
+ requested task and parent link; no special orchestrator mode is needed.
7
6
 
8
7
  List existing sessions before creating another worker. Give each worker a
9
8
  bounded task, clear writable files and acceptance checks; save the returned
10
- `session.id` for follow-up. Omit `--shell` to inherit your current harness, or
11
- set it when the task calls for a different harness. Provider flavors require a
12
- bridge-host token configured with `ftown env set <flavor>`.
13
-
14
- Before picking a CLI, model and effort for delegated work, run `ftown quota --json`
15
- and follow the decision procedure in `quota.md` (owner tiers first). Pass the
16
- choice as `--shell <provider>`; add `--model <id>` only with an id from that
17
- harness's model list. Never route to `exhausted`.
9
+ `session.id`. Omit `--shell` to inherit your harness. Provider flavors require
10
+ a bridge-host token configured with `ftown env set <flavor>`. Before picking a
11
+ CLI, model and effort, run `ftown quota --json` and follow `quota.md` (owner
12
+ tiers first); never route to `exhausted`.
18
13
 
19
14
  ```bash
20
- ftown sessions list
21
- ftown sessions create --parent --workdir /path/to/repo --name review-auth \
22
- --prompt "Review auth; read-only. Report concrete findings and validation."
15
+ ftown brief set --file brief.md
16
+ ftown sessions create --parent --worktree --workdir /path/to/repo --name fix-auth \
17
+ --prompt "Fix the auth bug; run the checks; report findings."
23
18
  ftown board --wait --until any-done --timeout 300
24
- ftown board
19
+ ftown brief note "First worker done; reviewing"
20
+ ftown attention list
25
21
  ftown harness mail send <worker-id> --type task "Check the expired-token case too"
26
22
  ```
27
23
 
28
- Coordinate in a loop: spawn children, wait with
29
- `ftown board --wait --until any-done --timeout 300` (or `any-blocked`,
30
- `any-ready`, `all-done`; `ftown events --wait` waits for the next event), act
31
- on the board and mail, then repeat until every child is done. Children keep
32
- their cards current; progress goes on the card, never as mail. Use
33
- `ftown sessions screen <worker-id> --limit 100` only to investigate terminal
34
- detail. Mail handles directed instructions, results and escalations; read it
35
- with `ftown harness mail read`. Each new batch nudges the recipient at most
36
- once, and a nudge may append a one-line digest of child status. Parallel tasks
37
- need disjoint write ownership and serialized shared resources.
24
+ Loop: spawn children, `ftown board --wait --until any-done --timeout 300`
25
+ (or `any-blocked`/`any-ready`/`all-done`), act, repeat until all are done.
26
+ Children keep cards current; progress goes on the card, never as mail. A
27
+ child's question comes to you first: answer from facts you hold with
28
+ `ftown attention answer`, or escalate preferences and irreversible choices
29
+ with `ftown attention escalate --note`. Mail is for directed instructions,
30
+ results and escalations; read it with `ftown harness mail read`. Each new
31
+ batch nudges the recipient at most once, and a nudge may append a one-line
32
+ digest of child status. Use `ftown sessions screen <worker-id> --limit 100`
33
+ only to investigate terminal detail. Parallel tasks need disjoint write
34
+ ownership and serialized shared resources. Children set their card to done
35
+ and mail their result; you raise one "Work complete" notice for the whole job.
38
36
 
39
- After accepting a worker's result, request any concrete follow-up before
40
- explicit cleanup with `ftown sessions remove <worker-id>`.
37
+ After accepting a result, follow up before explicit cleanup with
38
+ `ftown sessions remove <worker-id>`, which retires a clean, merged or pushed
39
+ bridge worktree and otherwise keeps it and says why.