ftown 0.27.0 → 0.28.1

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 (62) hide show
  1. package/dist/attention-store.js +34 -2
  2. package/dist/attention-store.js.map +1 -1
  3. package/dist/command-rpc.d.ts +11 -0
  4. package/dist/command-rpc.js +79 -15
  5. package/dist/command-rpc.js.map +1 -1
  6. package/dist/coordination/board.js +82 -3
  7. package/dist/coordination/board.js.map +1 -1
  8. package/dist/coordination/contract-c.d.ts +117 -0
  9. package/dist/coordination/contract-c.js +47 -0
  10. package/dist/coordination/contract-c.js.map +1 -0
  11. package/dist/coordination/contract.d.ts +8 -1
  12. package/dist/coordination/contract.js +1 -1
  13. package/dist/coordination/contract.js.map +1 -1
  14. package/dist/coordination/format.js +37 -11
  15. package/dist/coordination/format.js.map +1 -1
  16. package/dist/coordination/plan.d.ts +74 -0
  17. package/dist/coordination/plan.js +534 -0
  18. package/dist/coordination/plan.js.map +1 -0
  19. package/dist/coordination/routes-plan.d.ts +13 -0
  20. package/dist/coordination/routes-plan.js +182 -0
  21. package/dist/coordination/routes-plan.js.map +1 -0
  22. package/dist/coordination/wiring.d.ts +6 -0
  23. package/dist/coordination/wiring.js +50 -2
  24. package/dist/coordination/wiring.js.map +1 -1
  25. package/dist/coordination-cli.d.ts +6 -1
  26. package/dist/coordination-cli.js +17 -7
  27. package/dist/coordination-cli.js.map +1 -1
  28. package/dist/create-ftown-session.d.ts +18 -0
  29. package/dist/create-ftown-session.js +44 -0
  30. package/dist/create-ftown-session.js.map +1 -1
  31. package/dist/ftown-cli.js +5 -2
  32. package/dist/ftown-cli.js.map +1 -1
  33. package/dist/index.js +28 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/local-api-server.js +14 -4
  36. package/dist/local-api-server.js.map +1 -1
  37. package/dist/local-pair-cli.js +2 -3
  38. package/dist/local-pair-cli.js.map +1 -1
  39. package/dist/plan-cli.d.ts +52 -0
  40. package/dist/plan-cli.js +374 -0
  41. package/dist/plan-cli.js.map +1 -0
  42. package/dist/security/bridge/permissions.js +21 -1
  43. package/dist/security/bridge/permissions.js.map +1 -1
  44. package/dist/security-cli.d.ts +13 -2
  45. package/dist/security-cli.js +35 -6
  46. package/dist/security-cli.js.map +1 -1
  47. package/dist/sessions-commands.js +10 -0
  48. package/dist/sessions-commands.js.map +1 -1
  49. package/dist/types.d.ts +4 -1
  50. package/dist/wire-types.d.ts +2 -0
  51. package/dist/wire-types.js.map +1 -1
  52. package/muse-plugin/.muse-plugin/plugin.json +41 -1
  53. package/muse-plugin/hooks/ftown-post-tool-use-failure.sh +27 -0
  54. package/muse-plugin/hooks/ftown-post-tool-use.sh +26 -0
  55. package/muse-plugin/hooks/ftown-pre-tool-use.sh +26 -0
  56. package/muse-plugin/hooks/ftown-user-prompt-submit.sh +26 -0
  57. package/muse-plugin/lib/ftown-hook.sh +42 -5
  58. package/opencode-plugin/ftown.js +121 -11
  59. package/package.json +2 -2
  60. package/skills/ftown/SKILL.md +42 -0
  61. package/skills/ftown/references/orchestrator.md +29 -25
  62. package/skills/ftown/references/sessions.md +64 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ftown",
3
- "version": "0.27.0",
3
+ "version": "0.28.1",
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": "443f64c38ecd3d577f762d5e87986221fac1d26a"
76
+ "gitHead": "1d602fcdc7e33f265c1f486ce9e26f03654f4dec"
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 plan
57
+ ftown plan add "Review the API client" --after p1 --priority 1
58
+ ftown sessions create --parent --plan-item p2 --prompt "Review the API client"
56
59
  ftown brief set --file brief.md
57
60
  ftown attention list
58
61
  ftown worktrees list
@@ -128,6 +131,45 @@ ftown board --wait --until any-done --timeout 300
128
131
  ftown events --wait
129
132
  ```
130
133
 
134
+ Plain `ftown board` appends a `planned` section with up to 5 ready plan
135
+ items (`→ <id> <title>`, then `+N more`). `ftown board --all` also shows
136
+ retired (archived) children after the live ones, suffixed `(retired)`.
137
+ Tree events include the `plan` kind for plan changes and `removed` when a
138
+ child is removed or archived while not already exited.
139
+
140
+ ## Plan list
141
+
142
+ Keep the plan on the manager: `ftown plan` defaults to your own session
143
+ (`$FTOWN_SESSION_ID`, the manager), and `--session-id <id>` targets another
144
+ session's plan. This is the manager's plan, not a ticket system — it is a
145
+ short ordered todo list the manager keeps for its own coordination. Add
146
+ items, order them with precedence, and link each child to one item:
147
+
148
+ ```bash
149
+ ftown plan [--json] [--session-id <id>]
150
+ ftown plan add <title...> [--note <t>] [--after <id,id>] [--priority 1|2|3]
151
+ ftown plan start <id> --session <child-id>
152
+ ftown plan done <id>
153
+ ftown plan drop <id>
154
+ ftown plan todo <id>
155
+ ftown plan edit <id> [--title <t>] [--note <t>|--no-note] [--after <ids>|--no-after] [--priority n]
156
+ ftown plan rm <id>
157
+ ftown sessions create --parent --plan-item <id> --prompt "<task>"
158
+ ```
159
+
160
+ Precedence comes from `--after <id,id>` and `--priority 1|2|3` (1 is
161
+ highest). An item is ready when it is `todo` and every item in its `after`
162
+ list is `done` or `dropped`; the list shows `→` ready, `·` waiting, `▸`
163
+ started, `✓` done and `✗` dropped. Creating a child with `--plan-item <id>`
164
+ requires a parent, fails before creating anything when the item is unknown
165
+ or not `todo`, and otherwise marks the item `started` with that child
166
+ linked. When the linked child's card becomes `done`, its item becomes
167
+ `done` too; a `failed` card leaves the item `started` for the manager to
168
+ decide. `ftown plan start <id> --session <child-id>` links an existing
169
+ child by hand, and `done`/`drop`/`todo` set the state directly. Every plan
170
+ change emits one `plan` tree event (`<id> <state>: <title>`, plus
171
+ ` → ready: …` when items become ready). Exit codes: 0 ok, 1 error, 2 usage.
172
+
131
173
  **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
174
  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
175
 
@@ -1,39 +1,43 @@
1
1
  # Worker coordination examples
2
2
 
3
- Read `../SKILL.md` for identity, reporting and cleanup behavior, and
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.
3
+ Read `../SKILL.md` for identity, reporting and cleanup, and
4
+ `sessions.md` for the command reference. No special orchestrator mode is needed.
6
5
 
7
6
  List existing sessions before creating another worker. Give each worker a
8
- bounded task, clear writable files and acceptance checks; save the returned
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
7
+ bounded task, clear writable files and checks; save the returned
8
+ `session.id`. Omit `--shell` to inherit your harness. Before picking a CLI,
9
+ model and effort, run `ftown quota --json` and follow `quota.md` (owner
12
10
  tiers first); never route to `exhausted`.
13
11
 
12
+ Keep the plan on the manager — the manager's plan, not a ticket system.
13
+ Add steps with `ftown plan add` (`--after`/`--priority` set precedence;
14
+ ready = every `after` done or dropped) and create each child with
15
+ `--plan-item`, so its item starts and completes with the child:
16
+
14
17
  ```bash
15
18
  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."
19
+ ftown plan add "Fix the auth bug" --priority 1
20
+ ftown sessions create --parent --plan-item p1 --worktree --workdir /path/to/repo --name fix-auth --prompt "Fix auth; run checks."
18
21
  ftown board --wait --until any-done --timeout 300
19
- ftown brief note "First worker done; reviewing"
20
22
  ftown attention list
21
- ftown harness mail send <worker-id> --type task "Check the expired-token case too"
23
+ ftown harness mail send <worker-id> --type task "Check the expired-token case"
22
24
  ```
23
25
 
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.
26
+ Loop: keep the plan on the manager, create children with `--plan-item`,
27
+ `ftown board --wait --until any-done` (or `any-blocked`/`any-ready`/
28
+ `all-done`), act, repeat until all are done. Children keep cards current;
29
+ progress goes on the card, never as mail. A child's question comes to you
30
+ first: answer from facts you hold with `ftown attention answer`, or
31
+ escalate preferences and irreversible choices
32
+ with `ftown attention escalate --note`. Mail is for directed
33
+ instructions, results and escalations; read it with
34
+ `ftown harness mail read`. Each mail batch nudges at most once (a digest
35
+ may be appended). Use `ftown sessions screen <worker-id> --limit 100`
36
+ only to investigate. Parallel tasks need disjoint write
37
+ ownership and serialized shared resources. Children set their card to
38
+ done and report to the parent; you raise one "Work complete" notice
39
+ for the whole job.
36
40
 
37
- After accepting a result, follow up before explicit cleanup with
41
+ After accepting a result, clean up with
38
42
  `ftown sessions remove <worker-id>`, which retires a clean, merged or pushed
39
- bridge worktree and otherwise keeps it and says why.
43
+ worktree and otherwise keeps it and says why.
@@ -76,18 +76,73 @@ ftown board [--json] [--since <n>] [--ready] [--all] [--session-id <id>]
76
76
  # Wait until a board condition holds
77
77
  ftown board [--wait --until any-change|any-done|any-blocked|all-done|any-ready [--timeout <s≤300>]] [--session-id <id>]
78
78
 
79
- # Tree events for my tree (status, attention, pr, preview, exit, idle, result, mail)
79
+ # Tree events for my tree (status, attention, pr, preview, exit, idle, result, mail, plan, removed)
80
80
  ftown events [--json] [--since <n>] [--limit <n>] [--wait [--timeout <s≤300>]] [--session-id <id>]
81
81
  ```
82
82
 
83
83
  `--ready` lists only children whose PR checks passed and who are not done;
84
- `--all` includes archived/completed children; `--since <n>` limits the board
85
- to children with events after that cursor (the board prints its cursor).
86
- Pass the cursor back as `--since` to see only what changed.
84
+ `--all` includes retired (archived) children after the live ones, newest
85
+ first, capped at 50 and suffixed `(retired)` in plain output; `--since <n>`
86
+ limits the board to children with events after that cursor (the board
87
+ prints its cursor). Pass the cursor back as `--since` to see only what
88
+ changed. Plain board output appends a `planned` section after the child
89
+ rows: up to 5 ready plan items as `→ <id> <title>`, then `+N more` when
90
+ more are ready.
91
+
92
+ Tree events also include `plan` (one per plan change, summary
93
+ `<id> <state>: <title>`, plus ` → ready: <id>, …` when items become ready)
94
+ and `removed` (summary `removed`, when a child is removed or archived
95
+ while not already exited).
87
96
 
88
97
  Exit codes for `status`, `board` and `events`: 0 ok, 1 error, 2 usage,
89
98
  3 wait timed out with the condition unmet.
90
99
 
100
+ ## Plan list
101
+
102
+ The plan is the manager's plan, not a ticket system: a todo list with
103
+ precedence stored on the manager (parent) session. It defaults to
104
+ `FTOWN_SESSION_ID`; `--session-id <id>` targets another session's plan.
105
+
106
+ ```bash
107
+ # List in plan order (--json passes the PlanView through)
108
+ ftown plan [--json] [--session-id <id>]
109
+
110
+ # Add (title is the remaining words; precedence via --after/--priority)
111
+ ftown plan add <title...> [--note <t>] [--after <id,id>] [--priority 1|2|3] [--session-id <id>]
112
+
113
+ # Link an existing child, or set state directly
114
+ ftown plan start <id> --session <child-id> [--session-id <id>]
115
+ ftown plan done <id> [--session-id <id>]
116
+ ftown plan drop <id> [--session-id <id>]
117
+ ftown plan todo <id> [--session-id <id>]
118
+
119
+ # Edit or remove (removing strips the id from other items' after lists)
120
+ ftown plan edit <id> [--title <t>] [--note <t>|--no-note] [--after <ids>|--no-after] [--priority n] [--session-id <id>]
121
+ ftown plan rm <id> [--session-id <id>]
122
+
123
+ # Create a child for a plan item (marks it started, linked to the child)
124
+ ftown sessions create --parent --plan-item <id> --prompt "<task>"
125
+ ```
126
+
127
+ List marks: `→` ready, `·` waiting, `▸` started, `✓` done, `✗` dropped,
128
+ printed as `<mark> <id> [P<priority>] <title>` plus `(after p1,p2)` or
129
+ `→ <child name>` when linked. Ordering is ready first, then waiting (both
130
+ by priority ascending, then creation time), then started, done and
131
+ dropped. An item is ready when it is `todo` and every item in its `after`
132
+ list is `done` or `dropped`; precedence is set only with `--after` and
133
+ `--priority` (1 is highest). Item ids are `p<n>` and are never reused.
134
+ Limits: 200 items, title 140 characters, note 500, at most 20 `after`
135
+ ids; `after` ids must exist, with no self-reference or cycles.
136
+
137
+ `--plan-item <id>` (on `ftown sessions create`, requires `--parent` or
138
+ `--parent-id`) fails with an error before any session is created when the
139
+ item is unknown or not `todo`; after creation the item becomes `started`
140
+ with the child linked, and a linking failure only warns (the session
141
+ stays). When a linked child's card becomes `done`, the item becomes
142
+ `done`; a `failed` card leaves it `started` for the manager to decide.
143
+ Setting an item back to `todo` clears its linked session. Exit codes for
144
+ `ftown plan`: 0 ok, 1 error, 2 usage.
145
+
91
146
  ## Manager brief
92
147
 
93
148
  A coordinating session keeps a markdown brief plus timestamped notes; the
@@ -362,6 +417,7 @@ Fan-out targets are messaged sequentially, one JSON result line per target.
362
417
  | `--command` | Full command override (skips `--shell` builder) |
363
418
  | `--parent` | Set parent to `$FTOWN_SESSION_ID` |
364
419
  | `--parent-id` | Explicit parent session UUID |
420
+ | `--plan-item <id>` | Do plan item `p<n>` of the parent (requires `--parent` or `--parent-id`; see Plan list) |
365
421
  | `--worktree` | Create a bridge-owned git worktree for the session (see Worktrees) |
366
422
  | `--branch <b>` | Worktree branch (requires `--worktree`; default `ftown/<slug(name)>`) |
367
423
  | `--base <ref>` | Ref the worktree branch starts from (requires `--worktree`) |
@@ -443,6 +499,10 @@ The CLI wraps the loopback API. Raw access if needed:
443
499
  | GET | `/api/sessions/:id/attention/routed` | Open parent-routed items of my children → `{ items }` |
444
500
  | GET/PUT/DELETE | `/api/sessions/:id/brief` | Read, set/clear (`{ text: string \| null }`) or delete the manager brief |
445
501
  | POST | `/api/sessions/:id/brief/notes` | Append a brief note (`{ text }`) |
502
+ | GET | `/api/sessions/:id/plan` | Read the plan (`PlanView`: ordered items plus ready ids) |
503
+ | POST | `/api/sessions/:id/plan` | Add a plan item (`{ title, note?, after?, priority? }`) → `{ item }` |
504
+ | PATCH | `/api/sessions/:id/plan/:itemId` | Edit a plan item (`{ title?, note?: string\|null, after?, priority?, state?, sessionId?: string\|null }`) → `{ item }`; item id is `p<n>` |
505
+ | DELETE | `/api/sessions/:id/plan/:itemId` | Remove a plan item (strips it from other items' `after`) → `{ ok: true }` |
446
506
  | GET | `/api/worktrees` | List bridge-owned worktrees with git status |
447
507
  | POST | `/api/worktrees/prune` | Retire eligible archived worktrees → `{ removed, retained }` |
448
508
  | GET | `/api/sessions/:id/attention/:eventId` | Read one item (`?waitSeconds=0..25` long-polls until resolved) → `{ event }`; 404 `attention_not_found` |