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
@@ -88,6 +88,44 @@ Pass the cursor back as `--since` to see only what changed.
88
88
  Exit codes for `status`, `board` and `events`: 0 ok, 1 error, 2 usage,
89
89
  3 wait timed out with the condition unmet.
90
90
 
91
+ ## Manager brief
92
+
93
+ A coordinating session keeps a markdown brief plus timestamped notes; the
94
+ dashboard overview renders the brief, the last 10 notes and the session's
95
+ children automatically. The target defaults to `FTOWN_SESSION_ID`.
96
+
97
+ ```bash
98
+ ftown brief show [--json] [--session-id <id>]
99
+ ftown brief set (--file <path.md> | --text <t> | --clear) [--session-id <id>]
100
+ ftown brief note <text...> [--session-id <id>]
101
+ ```
102
+
103
+ Text is markdown, at most 16384 characters; a note is a single line of
104
+ 1–280 characters; at most 50 notes are kept (oldest dropped). Control
105
+ characters except newline and tab are stripped; text over the limit is an
106
+ error (exit 1), never truncated.
107
+
108
+ ## Worktrees
109
+
110
+ Children that write code can get a bridge-created git worktree. The default
111
+ branch is `ftown/<slug(name)>` at `<repoRoot>/.claude/worktrees/<slug(name)>`;
112
+ the base defaults to the current branch of the working directory (a detached
113
+ HEAD needs `--base`). Only bridge-created worktrees are ever removed.
114
+
115
+ ```bash
116
+ ftown sessions create --parent --worktree [--branch <b>] [--base <ref>] [--workdir <dir>]
117
+ ftown sessions remove <id> [--keep-worktree | --force-worktree]
118
+ ftown worktrees list [--json]
119
+ ftown worktrees prune [--json]
120
+ ```
121
+
122
+ On remove, a clean worktree whose branch is merged or fully pushed is
123
+ retired (worktree removed; the branch is deleted only when merged);
124
+ otherwise it is retained and the command prints why (for example
125
+ `worktree retained: 2 unpushed commits`). `--keep-worktree` always retains,
126
+ `--force-worktree` forces removal. `prune` applies the same rule to archived
127
+ sessions only.
128
+
91
129
  ## Preview session files
92
130
 
93
131
  ```bash
@@ -183,7 +221,9 @@ Attention persists an `agent_needs_input` event, returns its exact ID and update
183
221
  the existing dashboard attention flow. Logical duplicate unresolved requests
184
222
  coalesce while recording occurrences; resolving it permits a new incident.
185
223
  Only creation triggers notification, and hosted push remains opt-in with existing
186
- session/harness eligibility. Do not automatically retry an uncertain mutation.
224
+ session/harness eligibility. For a parent-routed item, creation notifies only
225
+ the parent; the dashboard notice and push fire if it is escalated to the human.
226
+ Do not automatically retry an uncertain mutation.
187
227
  Acknowledging/resolving an event never answers or approves a CLI prompt.
188
228
 
189
229
  ### Questions and answers
@@ -223,6 +263,37 @@ FTown session follow the same path and are answered from the dashboard inbox.
223
263
  The terminal picker appears only if the human chooses "Answer in terminal" or
224
264
  after an hour.
225
265
 
266
+ ### Parent-first routing
267
+
268
+ When the asking session has a running parent, the request goes to the parent
269
+ first: the parent receives one waking escalation mail (`[ftown question ...]`)
270
+ naming the commands below, and the human's inbox shows the item greyed as
271
+ "with parent" (the human may still answer it). There is no timer; only the
272
+ parent, or the parent stopping while the item is open, moves it to the human.
273
+
274
+ ```bash
275
+ # Open parent-routed questions from my children (plain: `<child> <eventId> <title>` plus options)
276
+ ftown attention list [--json]
277
+
278
+ # Answer a child's question (as the parent)
279
+ ftown attention answer <child-id> <event-id> (--option <n|label>... | --text <t> | --answers-json <json>) [--json]
280
+
281
+ # Raise it to the human instead (note at most 500 characters)
282
+ ftown attention escalate <child-id> <event-id> [--note <t>] [--json]
283
+
284
+ # Bypass the parent: only the human can provide this
285
+ ftown sessions attention --to human --message "Please paste the API token" --title "Credential needed"
286
+ ```
287
+
288
+ Answer only from facts you hold — the plan, the agreed contract, earlier
289
+ human answers. Preferences and irreversible choices are escalated, not
290
+ answered. A parent answer is delivered exactly like a human answer (live
291
+ waiter, or mail whose sender is the parent session).
292
+
293
+ Exit codes for `ftown attention`: 0 ok, 1 error, 2 usage, 4 forbidden (the
294
+ caller is not the child's parent), 5 conflict (already resolved or already
295
+ escalated to the human).
296
+
226
297
  PR links accept only HTTPS GitHub `/owner/repo/pull/<positive-number>` URLs.
227
298
  Outer whitespace, query/fragment and a trailing slash are normalized; credentials,
228
299
  nondefault ports and other paths/hosts are rejected. No GitHub request is made.
@@ -291,6 +362,9 @@ Fan-out targets are messaged sequentially, one JSON result line per target.
291
362
  | `--command` | Full command override (skips `--shell` builder) |
292
363
  | `--parent` | Set parent to `$FTOWN_SESSION_ID` |
293
364
  | `--parent-id` | Explicit parent session UUID |
365
+ | `--worktree` | Create a bridge-owned git worktree for the session (see Worktrees) |
366
+ | `--branch <b>` | Worktree branch (requires `--worktree`; default `ftown/<slug(name)>`) |
367
+ | `--base <ref>` | Ref the worktree branch starts from (requires `--worktree`) |
294
368
  | `--model` | Harness model name or provider/model pattern (when supported) |
295
369
 
296
370
  Provider-flavored shells (`zai`, `kimi`, `deepseek`, `fireworks`) run Claude
@@ -313,9 +387,9 @@ ftown sessions grep <child-id> --pattern 'FAIL|Error'
313
387
 
314
388
  ### Completion handoff
315
389
 
316
- When the task creates or updates a GitHub PR, associate its actual URL with the
317
- FTown session before the completion notice. Then request user attention once the
318
- task is complete, before the final handoff. Replace the sample URL and summary
390
+ A top-level session (no parent): when the task creates or updates a GitHub PR,
391
+ associate its actual URL with the FTown session before the completion notice.
392
+ Then request user attention once the task is complete, before the final handoff. Replace the sample URL and summary
319
393
  below with truthful outcomes and checks (including checks not run):
320
394
 
321
395
  ```bash
@@ -329,8 +403,10 @@ For tasks without a PR, omit the PR command and PR summary. Use the verified
329
403
 
330
404
  Send one completion request per completed task, not repeated per-turn notices.
331
405
  Logical duplicate coalescing does not justify retries after an uncertain outcome;
332
- inspect the existing request first, as described above. Child agents still send
333
- their assigned result to the parent; the user attention request is additional.
406
+ inspect the existing request first, as described above. Child agents do not
407
+ raise "Work complete": they set their card to `done` and send their assigned
408
+ result to the parent, and the parent raises one completion notice for the
409
+ whole job.
334
410
 
335
411
  ## Environment
336
412
 
@@ -361,7 +437,14 @@ The CLI wraps the loopback API. Raw access if needed:
361
437
  | GET | `/api/sessions` | List |
362
438
  | POST | `/api/sessions` | Create |
363
439
  | PATCH | `/api/sessions/:id` | Rename, move or associate a PR (`{ name?, parentSessionId?, pullRequestUrl? }`; `null` detaches/clears) |
364
- | POST | `/api/sessions/:id/attention` | Request human input (`{ message, title?, questions? }`) → `{ event }`; invalid `questions` → 400 `invalid_prompt` |
440
+ | POST | `/api/sessions/:id/attention` | Request input (`{ message, title?, questions?, to?: 'human' }`) → `{ event }`; invalid `questions` → 400 `invalid_prompt` |
441
+ | POST | `/api/sessions/:id/attention/:eventId/answer` | Parent answers a child (`{ answers }`); 403 not the parent, 409 resolved |
442
+ | POST | `/api/sessions/:id/attention/:eventId/escalate` | Parent raises it to the human (`{ note? }`); 403 not the parent, 409 already human/resolved |
443
+ | GET | `/api/sessions/:id/attention/routed` | Open parent-routed items of my children → `{ items }` |
444
+ | GET/PUT/DELETE | `/api/sessions/:id/brief` | Read, set/clear (`{ text: string \| null }`) or delete the manager brief |
445
+ | POST | `/api/sessions/:id/brief/notes` | Append a brief note (`{ text }`) |
446
+ | GET | `/api/worktrees` | List bridge-owned worktrees with git status |
447
+ | POST | `/api/worktrees/prune` | Retire eligible archived worktrees → `{ removed, retained }` |
365
448
  | GET | `/api/sessions/:id/attention/:eventId` | Read one item (`?waitSeconds=0..25` long-polls until resolved) → `{ event }`; 404 `attention_not_found` |
366
449
  | POST | `/api/sessions/:id/attention/ask` | Harness hook: record an AskUserQuestion (`{ toolName, toolUseId, toolInput }`) → `{ event }` or `null` if not promptable |
367
450
  | GET | `/api/sessions/:id/screen` | Terminal lines |
@@ -373,7 +456,7 @@ The CLI wraps the loopback API. Raw access if needed:
373
456
  | POST | `/api/sessions/:id/message` | Inject a message line as keystrokes (`{ text, from? }`) |
374
457
  | PUT | `/api/sessions/:id/preview` | Replace or add preview files, local CLI only (`{ paths: string[], mode: 'replace' \| 'add' }`) |
375
458
  | DELETE | `/api/sessions/:id/preview` | Remove preview files by name or clear the preview, local CLI only (`{ names?: string[] }`; absent names clears all) |
376
- | DELETE | `/api/sessions/:id` | Remove (tombstone-archived) |
459
+ | DELETE | `/api/sessions/:id` | Remove (tombstone-archived; `?worktree=keep\|force` overrides worktree retirement) |
377
460
  | GET | `/api/archive` | List removed-session tombstones |
378
461
  | POST | `/api/sessions/:id/revive` | Recreate a removed session (new id) |
379
462