@softure-ai/skills 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +71 -2
- package/WORKFLOW.md +308 -0
- package/package.json +31 -4
- package/rules/AGENTS.md +78 -0
- package/scripts/install.mjs +151 -0
- package/scripts/uninstall.mjs +49 -0
- package/skills/softure-archive/SKILL.md +100 -0
- package/skills/softure-code-review/SKILL.md +124 -0
- package/skills/softure-frame/SKILL.md +113 -0
- package/skills/softure-impl-review/SKILL.md +150 -0
- package/skills/softure-implement/SKILL.md +141 -0
- package/skills/softure-init/SKILL.md +131 -0
- package/skills/softure-lesson/SKILL.md +99 -0
- package/skills/softure-new/SKILL.md +127 -0
- package/skills/softure-plan/SKILL.md +157 -0
- package/skills/softure-plan/references/progress-format.md +79 -0
- package/skills/softure-plan-review/SKILL.md +152 -0
- package/skills/softure-prd/SKILL.md +132 -0
- package/skills/softure-research/SKILL.md +165 -0
- package/skills/softure-roadmap/SKILL.md +128 -0
- package/skills/softure-rule-review/SKILL.md +121 -0
- package/skills/softure-shape/SKILL.md +128 -0
- package/skills/softure-worktree/SKILL.md +888 -0
- package/skills/softure-worktree/scripts/wt-integration.sh +59 -0
- package/skills/softure-worktree/scripts/wt-open.sh +57 -0
- package/skills/softure-worktree/scripts/wt-roadmap.py +301 -0
- package/skills/softure-worktree/scripts/wt-status.sh +70 -0
- package/skills/softure-worktree/scripts/wt_config.py +109 -0
- package/skills/softure-worktree-manager/SKILL.md +553 -0
- package/skills/softure-worktree-manager/scripts/wm-launch.sh +52 -0
- package/skills/softure-worktree-manager/scripts/wm-report.sh +45 -0
- package/skills/softure-worktree-manager/scripts/wm-resume.sh +132 -0
- package/skills/softure-worktree-manager/scripts/wm-watch.sh +49 -0
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: softure-worktree-manager
|
|
3
|
+
description: >
|
|
4
|
+
Coordinate several /softure-worktree changes at once from one session: read
|
|
5
|
+
the roadmap, pick the ready items that can run side by side without touching
|
|
6
|
+
the same code (worktree.maxParallel by default, more when more are safe),
|
|
7
|
+
queue them in context/changes/, launch each in its own background Claude
|
|
8
|
+
session, watch the roadmap until each reaches ready_to_merge, then merge
|
|
9
|
+
them into the main branch one by one — resolving conflicts and migration
|
|
10
|
+
collisions itself — mark them done, and immediately launch whatever became
|
|
11
|
+
unblocked. Runs until the whole roadmap is realised — only items blocked on
|
|
12
|
+
something outside the repo remain. Resumes by itself: started in a fresh
|
|
13
|
+
session, it reads the roadmap, adopts every change already in flight (merges
|
|
14
|
+
the ready ones, wakes stuck workers, relaunches dead ones) and carries on. No
|
|
15
|
+
tag, no release, no deploy (the owner's); pushes the main branch only when
|
|
16
|
+
the roadmap header orders it, then runs the full integration suite on it.
|
|
17
|
+
Use when the user invokes /softure-worktree-manager, or says "run the
|
|
18
|
+
roadmap in parallel", "coordinate the worktrees", "take over the roadmap",
|
|
19
|
+
"launch the next batch and handle the merges", "take over the merges of these
|
|
20
|
+
sessions", "resume the manager".
|
|
21
|
+
argument-hint: "[--max N] [--paste] [--dry-run] [--adopt ID,ID…] [--status-every N] | status"
|
|
22
|
+
allowed-tools:
|
|
23
|
+
- Read
|
|
24
|
+
- Glob
|
|
25
|
+
- Grep
|
|
26
|
+
- Write
|
|
27
|
+
- Edit
|
|
28
|
+
- Bash
|
|
29
|
+
- Agent
|
|
30
|
+
- Skill
|
|
31
|
+
- Monitor
|
|
32
|
+
- SendMessage
|
|
33
|
+
- ListAgents
|
|
34
|
+
- TaskStop
|
|
35
|
+
- CronCreate
|
|
36
|
+
- CronList
|
|
37
|
+
- CronDelete
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# /softure-worktree-manager — Parallel Changes, One Coordinator
|
|
41
|
+
|
|
42
|
+
`/softure-worktree` carries **one** change in its own worktree and stops at
|
|
43
|
+
READY, waiting for the owner's signal. This skill is the owner's side of that
|
|
44
|
+
loop, done by a session: it decides **which** changes may run together, starts
|
|
45
|
+
them, waits, and gives the merge signal itself — one change at a time.
|
|
46
|
+
|
|
47
|
+
**Project configuration** comes from `context/workflow.json` (`WORKFLOW.md`
|
|
48
|
+
§2): `<main>` is `mainBranch`, the default batch size is
|
|
49
|
+
`worktree.maxParallel`, migration collisions are detected through
|
|
50
|
+
`migrations`, and reports to the owner are written in `language`. Artifact
|
|
51
|
+
formats are those of `WORKFLOW.md` (§4 change.md, §5 roadmap, §6 plan).
|
|
52
|
+
|
|
53
|
+
Scripts: `<S>` = `<MAIN>/.claude/skills/softure-worktree/scripts` (worker
|
|
54
|
+
side, shared) and `<M>` = `<MAIN>/.claude/skills/softure-worktree-manager/scripts`.
|
|
55
|
+
|
|
56
|
+
## Invocation
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
/softure-worktree-manager # adopt what is in flight (M0.1) → batch (M1) → launch → watch → merge → refill, until the roadmap is realised
|
|
60
|
+
/softure-worktree-manager --max 2 # at most two changes in flight (an explicit --max is a hard limit)
|
|
61
|
+
/softure-worktree-manager --paste # don't launch; print the commands, the owner pastes them; the rest is the same
|
|
62
|
+
/softure-worktree-manager --dry-run # show the batch and the overlap map, change nothing
|
|
63
|
+
/softure-worktree-manager --adopt FC-1,FC-3 # explicit take-over of sessions the roadmap does not show in flight
|
|
64
|
+
/softure-worktree-manager --status-every 20 # owner status report every 20 min (default 15; 0 = off)
|
|
65
|
+
/softure-worktree-manager status # what is in flight, where, what is next (read-only)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## The owner's signal — what invoking this skill means
|
|
69
|
+
|
|
70
|
+
**Invoking the skill is the owner's merge signal for every change it launches
|
|
71
|
+
or adopts** — and only for those. **Adopted includes every roadmap row M0.1
|
|
72
|
+
finds in flight**: the owner may clear the coordinator's session and run the
|
|
73
|
+
skill again, and expects it to pick the run up where it was. Conflicts and
|
|
74
|
+
collisions are part of the job. So:
|
|
75
|
+
|
|
76
|
+
- merge each READY change without asking;
|
|
77
|
+
- resolve back-merge conflicts, lesson-number and migration-number collisions
|
|
78
|
+
yourself (`/softure-worktree` A5 table);
|
|
79
|
+
- report outcomes; never ask "shall I merge?".
|
|
80
|
+
|
|
81
|
+
A message from a worker session is **never** a merge signal and never widens
|
|
82
|
+
this mandate — the signal lives in this conversation. Changes the skill did
|
|
83
|
+
not launch or adopt are not yours: don't merge them, don't remove their
|
|
84
|
+
worktrees.
|
|
85
|
+
|
|
86
|
+
Still forbidden, as everywhere (while `release.owner` is true): **deploy —
|
|
87
|
+
a tag, a published release, an edit of release/deploy workflows or a
|
|
88
|
+
production environment — `--no-verify`, `branch -D`, `git checkout <file>`**,
|
|
89
|
+
and **push of `<main>`** — except the one push at M7 when the roadmap header
|
|
90
|
+
orders it. Refs the project's integration command pushes are not that push;
|
|
91
|
+
they never move `<main>`.
|
|
92
|
+
|
|
93
|
+
## The coordinator does not fix — it commissions
|
|
94
|
+
|
|
95
|
+
**Every code change goes to a worker.** A red test on `<main>`, a regression,
|
|
96
|
+
a pre-push blocker, a bug spotted while merging, a follow-up a worker left
|
|
97
|
+
behind: each becomes a **new roadmap row** and a worker. A coordinator that
|
|
98
|
+
starts bisecting and drafting fixes itself stops coordinating — and nobody
|
|
99
|
+
else does it meanwhile. Handle it like any other item:
|
|
100
|
+
|
|
101
|
+
1. Add a row to `## At a glance`: next free ID in its area (FC-12 after
|
|
102
|
+
FC-11), status `ready`, prerequisite = what it builds on. Add a `### <ID>`
|
|
103
|
+
block and a line in `## Order`.
|
|
104
|
+
2. Write `context/changes/<id>/change.md` (M2): symptom, where it shows, what
|
|
105
|
+
is already known, conditions for closing. Record in it what the run must
|
|
106
|
+
not lose: exact failing test names, commits, numbers, run URLs.
|
|
107
|
+
3. Commit (documents only, own paths). Then M3 launch, then the Monitor.
|
|
108
|
+
|
|
109
|
+
**Diagnose only as far as the `change.md` needs.** Read the failure output,
|
|
110
|
+
the handoff note, the trace a worker already left. **No bisection, no
|
|
111
|
+
experiments, no draft fixes of your own** — that is the worker's research, in
|
|
112
|
+
its own worktree under its own `/softure-research`.
|
|
113
|
+
|
|
114
|
+
What the coordinator does with its own hands:
|
|
115
|
+
|
|
116
|
+
- roadmap and `context/changes/` documents;
|
|
117
|
+
- merges, including conflict resolution inside M5 (that part is its mandate);
|
|
118
|
+
- cleanup (M0.2, M5);
|
|
119
|
+
- the push at M7 and the full integration run on `<main>`.
|
|
120
|
+
|
|
121
|
+
Nothing else.
|
|
122
|
+
|
|
123
|
+
## Loop
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
M0 preflight → M0.1 adopt in-flight → M0.2 leftovers → M1 pick batch → M2 queue in changes/ → M3 launch → M4 watch ─┬→ M5 merge one → M6 refill ─┐
|
|
127
|
+
└──────────── (next event) ←─┘
|
|
128
|
+
nothing ready & nothing running → M7 report (+ push if the header orders it)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### M0 — Preflight (main tree, `<main>`)
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
python3 <S>/wt_config.py --json # main branch, maxParallel, migrations, language
|
|
135
|
+
git branch --show-current # <main>
|
|
136
|
+
git status --short # record foreign WIP; never touch it
|
|
137
|
+
bash <S>/wt-status.sh --files # live worktrees, their files, free lesson/migration numbers
|
|
138
|
+
claude agents --json # background + interactive sessions
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Plus `ListAgents` for peer sessions — its header names **this** session;
|
|
142
|
+
remember it, M0.1 compares against it. Read `context/foundation/roadmap.md`:
|
|
143
|
+
the header note (run-wide orders from the owner such as parallelism or the
|
|
144
|
+
final push), `## At a glance`, `## Order`, each candidate's `### <ID>` block.
|
|
145
|
+
|
|
146
|
+
### M0.1 — Resume what is already in flight (every run, before M1)
|
|
147
|
+
|
|
148
|
+
A run is often not the first one: the owner clears the coordinator's session
|
|
149
|
+
(or it dies — power cut, usage limit) and invokes the skill again, while the
|
|
150
|
+
workers keep running as background processes. The fresh session must pick the
|
|
151
|
+
run up **without being told what is in flight** — the roadmap on `<main>`
|
|
152
|
+
says it. So, before picking anything new:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
bash <M>/wm-resume.sh
|
|
156
|
+
# RESUME <ID> <change-id> action=… stage="…" wt=… branch=… session=… proc=… coord=… coord_alive=… last="…"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
One line per roadmap row in flight (`in_progress` or `ready_to_merge`).
|
|
160
|
+
**Every such row is adopted** — this session merges it and cleans it up,
|
|
161
|
+
exactly like one it launched. Act on each line:
|
|
162
|
+
|
|
163
|
+
| action | what it means | do |
|
|
164
|
+
| --- | --- | --- |
|
|
165
|
+
| `MERGE` | the row says `ready_to_merge` | M5 now, one at a time (after the whole table is handled) |
|
|
166
|
+
| `ADOPT` | worker process alive and working | nothing to wake — add it to the Monitor. When `coord` is not this session, also `SendMessage <change-id>`: "the coordinator is now <this session> — I do the merge; send questions here; keep working, no reply needed" |
|
|
167
|
+
| `NUDGE` | worker alive but its last message is a usage limit, a machine sleep or an API/network error | usage limit with a reset time still ahead → wait for it (one-shot `CronCreate` at that time); otherwise `SendMessage` "you were interrupted by <cause> — continue from <last commit/step>". If the send fails ("not reachable"), treat as `RELAUNCH` |
|
|
168
|
+
| `RELAUNCH` | no live worker process; worktree and branch still there | `claude stop <session>` (clears the dead entry — `wm-launch.sh` refuses a name whose state is not `done`), then `wm-launch.sh <ID> <change-id> <this session>`; the worker resumes from its branch (`/softure-worktree` A0, resume ladder). Check `git -C <WT> status` first — uncommitted files stay, the worker picks them up |
|
|
169
|
+
| `FIX-ROW` | `<main>` already has the merge commit, the row was never flipped | set the row (table and block) to `done` / `done_code` from the archived `change.md` and commit (documents only); remove a leftover worktree/branch if the merge is on `<main>` (`git branch -d` refuses otherwise — good) |
|
|
170
|
+
| `REPORT` | row in flight, no branch and no worktree | tell the owner; don't guess — the change may live on another machine or in a cloud session |
|
|
171
|
+
|
|
172
|
+
`coord` is the coordinator named in the worker's launch prompt (`wm-launch.sh`
|
|
173
|
+
writes it there as `coordinator-session <name>`); `coord_alive` says whether
|
|
174
|
+
that session still runs.
|
|
175
|
+
|
|
176
|
+
- `coord` is **this session** (same name after `/clear` — the process stays)
|
|
177
|
+
or `coord_alive=no` → adopt as the table says.
|
|
178
|
+
- `coord` is **another live session** → a second coordinator would merge the
|
|
179
|
+
same branches twice. Send it a take-over notice first: `SendMessage <coord>`
|
|
180
|
+
"I am taking over roadmap coordination (/softure-worktree-manager) — delete
|
|
181
|
+
your status cron (CronDelete) and stop your wm-watch Monitor (TaskStop), do
|
|
182
|
+
not merge; confirm in one sentence". Adopt after it confirms or goes idle
|
|
183
|
+
without objecting; if it answers that it is mid-merge, wait for that merge,
|
|
184
|
+
then adopt. The owner's invocation here is the signal — the old session
|
|
185
|
+
gives way (M4, event "take-over notice").
|
|
186
|
+
|
|
187
|
+
Then report the resume table to the owner in one block (ID, stage, action
|
|
188
|
+
taken), arm the Monitor over **all** adopted IDs plus whatever M3 launches
|
|
189
|
+
(M4), arm the status cron (M4 — `CronList` first, a cleared session has none),
|
|
190
|
+
and continue with M1 for the free slots.
|
|
191
|
+
|
|
192
|
+
### M0.2 — Leftovers: every worktree, branch and session maps to a row in flight
|
|
193
|
+
|
|
194
|
+
Run on every run, after M0.1, and report it in the resume table:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
git worktree list
|
|
198
|
+
for b in $(git branch --format='%(refname:short)' | grep -vx "<main>"); do
|
|
199
|
+
echo "$b ahead=$(git rev-list --count <main>..$b) merged=$(git merge-base --is-ancestor $b <main> && echo yes || echo no)"
|
|
200
|
+
done
|
|
201
|
+
claude agents --json # background sessions are named after their change-id
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
For anything that maps to no row in flight:
|
|
205
|
+
|
|
206
|
+
| leftover | do |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| branch already merged into `<main>` (`merged=yes`, `ahead=0`), with or without a worktree | remove the worktree, `git branch -d` (refuses if not merged — good) |
|
|
209
|
+
| background session of a change already `done` / `done_code` / archived | `claude stop <short-id>` |
|
|
210
|
+
| the coordinator's own helper worktree (shouldn't exist — see "does not fix") | remove it |
|
|
211
|
+
| unmerged branch with no row in any roadmap | report it and leave it alone; it may be someone's work |
|
|
212
|
+
|
|
213
|
+
Cleaning up after a change that is already on `<main>` loses nothing, so it
|
|
214
|
+
needs no adoption. Anything unmerged still does.
|
|
215
|
+
|
|
216
|
+
### M1 — Pick the batch
|
|
217
|
+
|
|
218
|
+
**Eligible** (as `/softure-worktree` A1): `Status` is `ready`, `Mode` is
|
|
219
|
+
`autonomous`; not in flight; every prerequisite is `done` or `done_code` **on
|
|
220
|
+
`<main>`**. `proposed` whenever no `ready` item can take a free slot right now
|
|
221
|
+
(all waiting on prerequisites or colliding) — a slot doesn't sit idle; `ready`
|
|
222
|
+
items still come first. `blocked` and `Mode: owner` never.
|
|
223
|
+
|
|
224
|
+
**A prerequisite in flight means wait for its merge — then launch at once.**
|
|
225
|
+
Don't start the next item early on the prerequisite's branch (`--base`), even
|
|
226
|
+
when it is already at `impl-review`: an early start builds on code that may
|
|
227
|
+
still change. M5 → M6 run back to back, so the refill happens right after the
|
|
228
|
+
merge's cleanup, in the same turn.
|
|
229
|
+
|
|
230
|
+
**Parallel-safe** — this is the part the skill adds. For each eligible item,
|
|
231
|
+
build its **code surface** before choosing:
|
|
232
|
+
|
|
233
|
+
1. files named in its roadmap block and in `context/changes/<id>/` (or the
|
|
234
|
+
backlog entry);
|
|
235
|
+
2. `grep -rl` for the symbols and constants those name — the importers the
|
|
236
|
+
change will likely edit, not every reader;
|
|
237
|
+
3. whether it will need a **migration** (schema column, new table).
|
|
238
|
+
|
|
239
|
+
Then choose greedily in `## Order`, up to `--max` (default
|
|
240
|
+
`worktree.maxParallel`, soft — see below), keeping the batch **pairwise
|
|
241
|
+
disjoint in code files** and with **at most one migration**. Shared documents
|
|
242
|
+
(`roadmap.md`, `lessons.md`, `prd.md`) don't count — A5 resolves them
|
|
243
|
+
mechanically.
|
|
244
|
+
|
|
245
|
+
**Hot files.** Every codebase has a few files that most changes touch (a
|
|
246
|
+
central page, a large form component, the API or tool catalogue, the main
|
|
247
|
+
dashboard). Find them once per run (`git log --since=60.days --name-only
|
|
248
|
+
--format= | sort | uniq -c | sort -rn | head -20`, plus what `## Order` says)
|
|
249
|
+
and allow at most one change per batch on each. Assume an item that adds a
|
|
250
|
+
field to the core model also touches the layers that expose and display it,
|
|
251
|
+
unless its block says otherwise.
|
|
252
|
+
|
|
253
|
+
Semantic dependency counts as overlap too: an item whose **content** depends
|
|
254
|
+
on another's result waits even without a shared file.
|
|
255
|
+
|
|
256
|
+
Print the table — item, surface, migration?, verdict (`in batch` / `waits for
|
|
257
|
+
<ID>` / `collides with <ID>: <file>`) — so the owner can see why the batch is
|
|
258
|
+
what it is. `--dry-run` stops here.
|
|
259
|
+
|
|
260
|
+
Fewer parallel-safe items than slots is a normal result. Launch what is safe;
|
|
261
|
+
don't fill slots with a colliding item.
|
|
262
|
+
|
|
263
|
+
**The default batch size is soft, not a ceiling.** More parallel-safe items
|
|
264
|
+
than `maxParallel` → launch all of them (one at a time, as M3 says). An
|
|
265
|
+
explicit `--max N` from the owner is a hard limit, and so is a number in the
|
|
266
|
+
roadmap header. **Scale back when sessions starve each other.** Check before
|
|
267
|
+
every launch above the default, and in each status report while more than the
|
|
268
|
+
default are in flight. Act on a sustained trend or its effects, not one
|
|
269
|
+
reading:
|
|
270
|
+
|
|
271
|
+
| signal | how to read it |
|
|
272
|
+
| --- | --- |
|
|
273
|
+
| load average | `uptime` — the 5-minute value keeps staying above ~2× cores (`getconf _NPROCESSORS_ONLN`, or `nproc` / `sysctl -n hw.ncpu`) |
|
|
274
|
+
| memory | Linux: `free -m` (available below ~20%, swap growing); macOS: `memory_pressure \| tail -1` or `vm_stat` pageouts growing |
|
|
275
|
+
| in the workers | the test gate much slower than usual; timing-sensitive tests red that are green alone; workers reporting timeouts |
|
|
276
|
+
|
|
277
|
+
**Scaling back means not refilling freed slots** until the signals drop.
|
|
278
|
+
Workers already running are not stopped — each one carries its own branch.
|
|
279
|
+
Record it in the status report: "slot held — <signal>".
|
|
280
|
+
|
|
281
|
+
### M2 — Queue in `context/changes/`
|
|
282
|
+
|
|
283
|
+
**What is being realised sits in `changes/`; a topic lives in one place.** For
|
|
284
|
+
each picked item without a folder:
|
|
285
|
+
|
|
286
|
+
- a backlog entry exists → `git mv` it into `context/changes/<id>/` (as
|
|
287
|
+
`backlog-input.md` when it is not already a `change.md`), remove the empty
|
|
288
|
+
directory, fix its relative links;
|
|
289
|
+
- write `context/changes/<id>/change.md` (`WORKFLOW.md` §4, `status: new`,
|
|
290
|
+
`roadmap_item: <ID>`) with the item's roadmap block quoted under
|
|
291
|
+
`## Context`;
|
|
292
|
+
- point the roadmap item block at the new folder.
|
|
293
|
+
|
|
294
|
+
Commit on `<main>`, **own paths only** (`git add context/changes
|
|
295
|
+
context/backlog context/foundation/roadmap.md`) — documents only, no test gate
|
|
296
|
+
when the project's rules allow it. The roadmap status stays `ready`;
|
|
297
|
+
`/softure-worktree` flips it to `in_progress` itself.
|
|
298
|
+
|
|
299
|
+
### M3 — Launch
|
|
300
|
+
|
|
301
|
+
Default — a background session:
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
bash <M>/wm-launch.sh <ID> <change-id> <this-session-name>
|
|
305
|
+
# → SESSION <change-id> <short-id> <session-uuid>
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
The script runs `claude --bg -n <change-id> "/softure-worktree <ID> …"` from
|
|
309
|
+
the main tree (the prompt tells the worker: stop at READY, don't merge, send
|
|
310
|
+
unanswerable questions to the coordinator) and reads the session id back from
|
|
311
|
+
`claude agents --json`. Background sessions also show up in IDE session
|
|
312
|
+
panels; some IDE extensions cannot reattach them as a tab and show an exit
|
|
313
|
+
error — harmless, the worker keeps running. Live view: `claude attach
|
|
314
|
+
<short-id>` in a terminal.
|
|
315
|
+
|
|
316
|
+
Launch **one at a time**, a few seconds apart: every worker starts with
|
|
317
|
+
`wt-roadmap.py open`, which commits to `<main>`; simultaneous commits race.
|
|
318
|
+
|
|
319
|
+
`--paste` — print one fenced `/softure-worktree <ID>` block per item for the
|
|
320
|
+
owner to paste into separate windows, then `SendMessage` each new peer (find it
|
|
321
|
+
with `ListAgents` once it appears) the same instruction the script puts in the
|
|
322
|
+
prompt.
|
|
323
|
+
|
|
324
|
+
`--adopt` — for sessions already running that the roadmap does not show in
|
|
325
|
+
flight (M0.1 adopts the rest by itself): `SendMessage` each peer that merges
|
|
326
|
+
are now done by this session; nothing else changes for them.
|
|
327
|
+
|
|
328
|
+
Never start a second session for a change that already has one
|
|
329
|
+
(`wm-launch.sh` refuses: exit 3).
|
|
330
|
+
|
|
331
|
+
### M4 — Watch
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
Monitor(
|
|
335
|
+
description: "softure-worktree-manager: <IDs>",
|
|
336
|
+
timeout_ms: 1800000,
|
|
337
|
+
command: "bash <M>/wm-watch.sh FC-1:landing-hero-balance FC-3:pricing-one-section")
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Events: `STAGE <ID> <status>` on every stage change, `READY <ID>` at
|
|
341
|
+
`ready_to_merge`, `SESSION <change-id> <kind>/<status>/<state>` and `GONE
|
|
342
|
+
<change-id>` for the worker process. The monitor expires after 30 minutes —
|
|
343
|
+
**re-arm it at each expiry** with the IDs still in flight. Don't poll by hand
|
|
344
|
+
and don't sleep; events wake the session.
|
|
345
|
+
|
|
346
|
+
Between events, end the turn with one line (what is in flight, which stage).
|
|
347
|
+
|
|
348
|
+
**Periodic status for the owner — arm it together with the first Monitor.**
|
|
349
|
+
Stage events arrive irregularly, and a worker can sit in one stage for half an
|
|
350
|
+
hour. Right after the first launch (M3), `CronList` (reuse an existing status
|
|
351
|
+
job), then:
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
CronCreate(
|
|
355
|
+
cron: "4,19,34,49 * * * *", # every 15 min, off the :00/:30 marks
|
|
356
|
+
recurring: true,
|
|
357
|
+
prompt: "Status for the owner + loop heartbeat (/softure-worktree-manager). If several of these fired while busy, do one. 1) bash <M>/wm-resume.sh + the latest commits of the worker branches. 2) Report briefly as a table: ID, stage, what moved since the last status, session alive?; what merged; what is next. Nothing moved → one line. 3) Resume the loop by the wm-resume actions (M0.1 table): MERGE → M5 and M6; NUDGE → SendMessage 'continue' (usage limit: after its reset time); RELAUNCH → claude stop + wm-launch.sh; wm-watch Monitor expired → re-arm with the IDs in flight; free slot and a ready item without collision → M1–M3. Work until the roadmap is done / done_code. 4) End → M7 (push <main> only if the roadmap header orders it; then the integration suite on <main> and its result into the report; tag, release and deploy never — those are the owner's) and CronDelete this job. Write the report in the language from context/workflow.json.")
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
This prompt is also the run's **heartbeat**: a worker stuck on a usage limit
|
|
361
|
+
or a machine that slept emits no stage event, so without it the run stalls
|
|
362
|
+
silently.
|
|
363
|
+
|
|
364
|
+
`--status-every N` changes the period (build the minute list from an
|
|
365
|
+
off-mark offset: N=20 → `7,27,47 * * * *`); `--status-every 0` skips it. Arm
|
|
366
|
+
it **once** per run — M6 re-arms the Monitor, not the cron. Remember its id:
|
|
367
|
+
M7 deletes it. Tell the owner the first fire time, that it waits while a merge
|
|
368
|
+
is in progress (cron fires only when the session is idle), and that stage
|
|
369
|
+
events and merges are still reported immediately.
|
|
370
|
+
|
|
371
|
+
The report itself: a table — ID, stage, what moved since the last report (new
|
|
372
|
+
commits on the branch, stage change), session alive? — then merged since the
|
|
373
|
+
last report and next in line. Nothing moved → one line; don't pad it.
|
|
374
|
+
|
|
375
|
+
| event | action |
|
|
376
|
+
| --- | --- |
|
|
377
|
+
| `STAGE` | one line to the owner; nothing else |
|
|
378
|
+
| `READY <ID>` | M5 for that item (queue if a merge is running) |
|
|
379
|
+
| `SESSION …/done` or `GONE` **without** READY | the worker stopped early. Read `bash <M>/wm-report.sh <change-id>` (its last message) or the stage / `## Progress` in the worktree. An escalation from `/softure-worktree` → handle below. A crash mid-chain → relaunch with `wm-launch.sh` (the worker resumes from its branch). |
|
|
380
|
+
| no stage event for a long time, `claude agents --json` shows workers `state: blocked` | most likely the **usage limit**: every worker stops at once with a "session limit · resets <time>" message (read the transcript tail with `wm-report.sh`). Nothing is broken and the branch is intact; after the reset time `SendMessage` each worker "the limit has reset — continue from <last commit/step>" and it resumes in the same session. Don't relaunch — a second session for the same change is refused anyway. If the worker was mid-integration (A3.8), tell it to read the finished run's result before starting a new one. |
|
|
381
|
+
| a worker's `SendMessage` question | answer it if the material settles it (code, `lessons.md`, PRD, dev database); otherwise relay to the owner and let the worker continue with other work |
|
|
382
|
+
| a worker's signal for **another** change (a file of theirs, a shared contract) | relay it to that worker by `SendMessage` with the contract spelled out (props, labels its tests use); if the other change has not started yet, append it to its `change.md` under `## Notes` instead |
|
|
383
|
+
| a **take-over notice** from another session running this skill (M0.1) | the owner started a newer coordinator — give way: `CronDelete` the status job, `TaskStop` the Monitor, finish a merge already under way (never leave `<main>` mid-merge), reply one sentence with what you handed over, then stop coordinating |
|
|
384
|
+
|
|
385
|
+
### M5 — Merge one (on READY)
|
|
386
|
+
|
|
387
|
+
Run `/softure-worktree` **Phase B** for that change (`Skill
|
|
388
|
+
softure-worktree`, args `merge <change-id>`), from the main tree, with these
|
|
389
|
+
points of this skill:
|
|
390
|
+
|
|
391
|
+
- **Signal:** given (invocation). Don't wait for "merge".
|
|
392
|
+
- **One merge at a time.** `<main>` moves with each; the next READY branch is
|
|
393
|
+
then behind — B2 back-merges it inside its worktree (`git -C <WT> merge
|
|
394
|
+
<main>`) with the A5 conflict table, commits with the hook only, and comes
|
|
395
|
+
back. That is this session's job now, not the worker's.
|
|
396
|
+
- **Conflicts and collisions — resolve, don't stop:** roadmap row → branch,
|
|
397
|
+
other rows → `<main>`; `lessons.md` → renumber to the next free
|
|
398
|
+
(`wt-status.sh`) and fix references; migration number clash → `<main>`
|
|
399
|
+
keeps its number, regenerate yours (`migrations.regenerate`) and restore
|
|
400
|
+
hand edits (A5); code → on the merits, then run the tests of the touched
|
|
401
|
+
files.
|
|
402
|
+
**Resolve the roadmap row by row, never hunk by hunk.** One conflict hunk
|
|
403
|
+
often spans several adjacent table rows: yours plus a neighbour whose stage
|
|
404
|
+
moved on `<main>` meanwhile. Taking the whole hunk from the branch puts that
|
|
405
|
+
neighbour back to a stale stage. Inside each hunk, pair the lines by row ID:
|
|
406
|
+
take the merged change's row (`| **<ID>** |` and its `### <ID>` block) from
|
|
407
|
+
the branch and every other line from `<main>`. After the commit, compare
|
|
408
|
+
every `in_progress` row's stage with its `### <ID>` block.
|
|
409
|
+
- **B3 foreign WIP on `<main>`:** only another session's roadmap/lessons lines
|
|
410
|
+
→ park and restore as B3 says; code → wait for that session, report.
|
|
411
|
+
- **Cleanup** removes the worktree and the branch of the merged change (the
|
|
412
|
+
skill launched or adopted it — B5's "only your own" means exactly these).
|
|
413
|
+
Then stop the worker: `claude stop <short-id>` for a background session;
|
|
414
|
+
`SendMessage` "merged — you can close" for a pasted/adopted one.
|
|
415
|
+
- **Carry every signal into the roadmap — only when there is one.** The READY
|
|
416
|
+
report lives in a worker session that closes after the merge; the release
|
|
417
|
+
and the roadmap's archive happen later, from `<main>`. Whatever the worker
|
|
418
|
+
left for the owner must survive in the roadmap, or it is lost. Sources,
|
|
419
|
+
before the merge:
|
|
420
|
+
1. the READY report — `wm-report.sh <change-id>` (background) or
|
|
421
|
+
`wm-report.sh <sessionId>` (pasted/adopted), or the report the worker sent
|
|
422
|
+
by `SendMessage`;
|
|
423
|
+
2. the branch's `plan.md` → `## Progress`: every `- [ ]` left open (Manual
|
|
424
|
+
items the worker could not verify);
|
|
425
|
+
3. `reviews/impl-review.md`: findings accepted as risk or deferred.
|
|
426
|
+
|
|
427
|
+
Sort each signal into one of two roadmap sections:
|
|
428
|
+
|
|
429
|
+
| signal | section | entry |
|
|
430
|
+
| --- | --- | --- |
|
|
431
|
+
| a pre-release step: migration to watch, production secret, build-time variable, scheduled job, one-off command, production check | **`## Before the next release`** (the owner's checklist before publishing; create it above `## Owner decisions and checks` if missing) | numbered step with the exact command/file |
|
|
432
|
+
| anything else for the owner: visual/tone check, open question, product decision, suggestion, deferred finding | **`## Owner decisions and checks`** | `- [ ] **<ID>**: <what to decide/check> (<Manual N.M / finding>). <evidence path>` |
|
|
433
|
+
|
|
434
|
+
One signal, one place: if a check gates the deploy, it goes to the release
|
|
435
|
+
section and the decisions section only points at it. Don't duplicate what
|
|
436
|
+
the worker already wrote there. **Nothing to report → write nothing** — an
|
|
437
|
+
empty entry is noise in the lists the owner reads before a deploy. Commit
|
|
438
|
+
together with the merge's roadmap fix-up (documents only, own paths).
|
|
439
|
+
|
|
440
|
+
**Integration line of the READY report.** New reds must be "none" — a worker
|
|
441
|
+
reporting READY with new reds has not finished A3.8; send it back
|
|
442
|
+
(`SendMessage`), don't merge. Reds the worker lists as **already on
|
|
443
|
+
`<main>`** are a signal of their own: unless a roadmap row already carries
|
|
444
|
+
them, queue them as a new row and a worker ("does not fix"), with the test
|
|
445
|
+
names and the run URL in its `change.md`.
|
|
446
|
+
- **Roadmap:** after the merge the row must read `done` / `done_code` (the
|
|
447
|
+
branch wrote it at archive). Check it on `<main>`; if it still says
|
|
448
|
+
`ready_to_merge`, fix that row (table and block) alone and commit.
|
|
449
|
+
- **Report** per merge, three lines: merge SHA, conflicts and how resolved,
|
|
450
|
+
what waits for the release.
|
|
451
|
+
|
|
452
|
+
### M6 — Refill
|
|
453
|
+
|
|
454
|
+
**The run does not stop between items.** Closing one change is never an end
|
|
455
|
+
point: pick the next item, queue it, launch it, keep the order of `## Order`,
|
|
456
|
+
without asking.
|
|
457
|
+
|
|
458
|
+
After every merge, run M1 again with the free slots: items whose prerequisites
|
|
459
|
+
just landed become eligible now, not after the whole batch. Queue (M2), launch
|
|
460
|
+
(M3), add them to the watch (re-arm the Monitor with the new ID list —
|
|
461
|
+
`TaskStop` the old one first).
|
|
462
|
+
|
|
463
|
+
### M7 — Done
|
|
464
|
+
|
|
465
|
+
**Done means the roadmap is realised:** every item is `done` / `done_code`,
|
|
466
|
+
except items `blocked` on something outside the repo or `Mode: owner`. A
|
|
467
|
+
`ready` item waiting on a prerequisite in flight is **not** done — keep
|
|
468
|
+
watching. A `proposed` item is not done either — it runs under M1's rule. Only
|
|
469
|
+
then, with nothing in flight → `TaskStop` the monitor, `CronDelete` the status
|
|
470
|
+
job (M4), and report: what merged (SHAs), what waits for the release
|
|
471
|
+
(`## Before the next release`), the result of the full integration suite on
|
|
472
|
+
`<main>` (below), every open entry in `## Owner decisions and checks` (the
|
|
473
|
+
owner answers these before the release and before the roadmap is archived),
|
|
474
|
+
what is left and why (`blocked`, `owner`, `proposed`, a collision), and
|
|
475
|
+
whether `<main>` was pushed.
|
|
476
|
+
|
|
477
|
+
**The final push — only when the roadmap header orders it** ("Push main
|
|
478
|
+
branch: at the end"). Then, and only then, after the report's facts are
|
|
479
|
+
settled: `git push origin <main>` through the pre-push hook — never
|
|
480
|
+
`--no-verify`. A red hook stops the push — **and does not end the run**: queue
|
|
481
|
+
the failure as a new roadmap row and a worker, keep watching, push after its
|
|
482
|
+
merge. No header order → no push of `<main>`; say so.
|
|
483
|
+
|
|
484
|
+
**Then the full integration suite on `<main>`** — from the main tree on
|
|
485
|
+
`<main>`:
|
|
486
|
+
|
|
487
|
+
```bash
|
|
488
|
+
bash <S>/wt-integration.sh <main> # exit 0 green, 1 red, 75 no result yet, 78 not configured
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Run it after the push (or, with no push ordered, on the local `<main>`). Its
|
|
492
|
+
result is the baseline every next worker's "new reds" are measured against,
|
|
493
|
+
and the owner's signal before the release. Put the line into the final report:
|
|
494
|
+
`integration <main>: <green|red> <passed>/<total> on <sha> — <url>; reds:
|
|
495
|
+
<list or "none">`. Red → **does not end the run** either: each red becomes a
|
|
496
|
+
new roadmap row and a worker (test names and the run URL in its `change.md`,
|
|
497
|
+
the header note points to the row); after its merge, push (if ordered) and run
|
|
498
|
+
this again. `75` → the run is still going; wait for it and read the result,
|
|
499
|
+
don't start a new run over a moving one. **Tag, release and deploy never** —
|
|
500
|
+
the owner publishes the release after answering `## Owner decisions and
|
|
501
|
+
checks`.
|
|
502
|
+
|
|
503
|
+
## status
|
|
504
|
+
|
|
505
|
+
`wm-resume.sh` (one line per row in flight, with the action a fresh run would
|
|
506
|
+
take), `wt-status.sh`, `claude agents --json` → a table: ID, change-id, stage,
|
|
507
|
+
session (background id / window), action, next in line. Read-only — `status`
|
|
508
|
+
changes nothing.
|
|
509
|
+
|
|
510
|
+
## Escalations — the only reasons to stop and ask the owner
|
|
511
|
+
|
|
512
|
+
1. A code conflict whose right resolution changes **what a user sees or is
|
|
513
|
+
told** in a way neither branch's plan decided.
|
|
514
|
+
2. A worker needs something only the owner has (a secret, a production step, a
|
|
515
|
+
product rule) and no other ready work remains for the coordinator.
|
|
516
|
+
3. `/softure-worktree` escalation 3 (work spans sessions and `<main>` is the
|
|
517
|
+
only copy) — ask about pushing.
|
|
518
|
+
|
|
519
|
+
Everything else is decided and written into the report.
|
|
520
|
+
|
|
521
|
+
## Invariants
|
|
522
|
+
|
|
523
|
+
- **One coordinator per repo.** A newer invocation takes over from an older
|
|
524
|
+
live coordinator by the take-over notice (M0.1) — never two coordinating at
|
|
525
|
+
once.
|
|
526
|
+
- **Every run starts with M0.1.** A fresh session adopts every roadmap row in
|
|
527
|
+
flight before it launches anything new; nothing in flight is left without a
|
|
528
|
+
coordinator.
|
|
529
|
+
- **Only launched or adopted changes are merged or cleaned up** (adopted =
|
|
530
|
+
M0.1 or `--adopt`). One exception: leftovers of changes already on `<main>`
|
|
531
|
+
(M0.2), because removing them loses nothing.
|
|
532
|
+
- **The coordinator writes no code.** Every fix, even a one-line test fix and
|
|
533
|
+
even a pre-push blocker, is a roadmap row and a worker. The coordinator
|
|
534
|
+
commits only roadmap and `changes/` documents, merges, and merge-conflict
|
|
535
|
+
resolutions.
|
|
536
|
+
- **Every worktree, branch and background session maps to a row in flight**
|
|
537
|
+
(M0.2). Stale ones get removed, not carried over.
|
|
538
|
+
- **Merges are serial; launches are serial; workers run in parallel.**
|
|
539
|
+
- **The batch is pairwise disjoint in code files, ≤ 1 migration**, and
|
|
540
|
+
respects content dependencies and hot files.
|
|
541
|
+
- **`context/changes/` holds exactly the queued and running changes**; the
|
|
542
|
+
roadmap on `<main>` always shows each one's stage.
|
|
543
|
+
- **No signal is lost.** Every open Manual item, question, suggestion or
|
|
544
|
+
pre-release step a worker left stands in one of the two roadmap sections
|
|
545
|
+
before its worktree is removed.
|
|
546
|
+
- **The run ends only when the roadmap is realised** (M7) — never after one
|
|
547
|
+
item, never after one batch.
|
|
548
|
+
- **The owner hears from the run on a clock** — a status cron is armed while
|
|
549
|
+
anything is in flight (unless `--status-every 0`) and deleted at M7.
|
|
550
|
+
- **No tag, no release, no deploy, ever** (while `release.owner` is true).
|
|
551
|
+
**No push of `<main>`** — except the single push at M7 that the roadmap
|
|
552
|
+
header orders; the full integration suite on `<main>` follows it and goes
|
|
553
|
+
into the final report.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Start one /softure-worktree session in the background.
|
|
3
|
+
#
|
|
4
|
+
# wm-launch.sh <roadmap-id> <change-id> [coordinator-name]
|
|
5
|
+
#
|
|
6
|
+
# Prints: SESSION <change-id> <short-id> <session-uuid>
|
|
7
|
+
# Exit: 3 a live session with this name already exists · 4 the session did not register
|
|
8
|
+
#
|
|
9
|
+
# Why this shape:
|
|
10
|
+
# - `claude --bg "<prompt>"` starts a full session that SUBMITS the prompt by itself —
|
|
11
|
+
# no keystrokes, no OS permissions.
|
|
12
|
+
# - `--bg` ignores `--session-id`, so the id is read back from `claude agents --json` by name.
|
|
13
|
+
# - Background sessions also appear in IDE session panels. Some IDE extensions cannot
|
|
14
|
+
# reattach PTY-backed background sessions and show an exit error when opened as a tab;
|
|
15
|
+
# the worker keeps running regardless. Live view: `claude attach <short-id>`.
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
ID="${1:?roadmap id}"
|
|
19
|
+
CID="${2:?change id}"
|
|
20
|
+
COORD="${3:-coordinator}"
|
|
21
|
+
MAIN="$(git rev-parse --path-format=absolute --git-common-dir | sed 's#/\.git$##')"
|
|
22
|
+
cd "$MAIN"
|
|
23
|
+
|
|
24
|
+
if claude agents --json 2>/dev/null | python3 -c '
|
|
25
|
+
import json,sys
|
|
26
|
+
d=json.load(sys.stdin); d=d if isinstance(d,list) else d.get("agents",[])
|
|
27
|
+
sys.exit(0 if any(x.get("name")==sys.argv[1] and x.get("state")!="done" for x in d) else 1)' "$CID"; then
|
|
28
|
+
echo "ALREADY-RUNNING $CID" >&2; exit 3
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# The literal "coordinator-session <name>" is parsed back by wm-resume.sh — keep it.
|
|
32
|
+
PROMPT="/softure-worktree $ID
|
|
33
|
+
|
|
34
|
+
Launched by coordinator-session $COORD (/softure-worktree-manager). The coordinator merges into the main branch: carry the change to READY (roadmap row \`ready_to_merge\` via wt-roadmap.py ready) and stop. Do not merge, do not remove the worktree. Before archiving, run the full integration suite (wt-integration.sh <change-id>, A3.8) — fix every new red and put the result into the READY report. Do not ask the owner — decide (Prime Directive in /softure-worktree); a question the material cannot settle goes to $COORD via SendMessage. A deploy is a release the owner publishes: no tags, no releases, no edits of release workflows. Pre-release steps (migration, production secret, scheduled job, one-off command) go into the roadmap section \`## Before the next release\` and into the READY report."
|
|
35
|
+
|
|
36
|
+
claude --bg -n "$CID" "$PROMPT" >/dev/null
|
|
37
|
+
|
|
38
|
+
SID=""
|
|
39
|
+
for _ in $(seq 1 20); do
|
|
40
|
+
SID=$(claude agents --json 2>/dev/null | python3 -c '
|
|
41
|
+
import json,sys
|
|
42
|
+
d=json.load(sys.stdin); d=d if isinstance(d,list) else d.get("agents",[])
|
|
43
|
+
m=[x for x in d if x.get("name")==sys.argv[1] and x.get("kind")=="background"]
|
|
44
|
+
m.sort(key=lambda x:x.get("startedAt",0))
|
|
45
|
+
print((m[-1].get("id","") + " " + m[-1]["sessionId"]) if m else "")' "$CID")
|
|
46
|
+
[ -n "$SID" ] && break
|
|
47
|
+
sleep 1
|
|
48
|
+
done
|
|
49
|
+
[ -n "$SID" ] || { echo "NO-SESSION $CID — claude --bg did not register" >&2; exit 4; }
|
|
50
|
+
|
|
51
|
+
set -- $SID
|
|
52
|
+
echo "SESSION $CID $1 $2"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Print the last assistant text message of a session — for a worker, its READY report.
|
|
3
|
+
#
|
|
4
|
+
# wm-report.sh <change-id | session-uuid>
|
|
5
|
+
#
|
|
6
|
+
# A change-id is resolved through `claude agents --json` (background sessions launched by
|
|
7
|
+
# wm-launch.sh are named after the change). Pasted/adopted sessions have other names — pass
|
|
8
|
+
# their sessionId (ListAgents / `claude agents --json`). Reads the transcript
|
|
9
|
+
# ~/.claude/projects/<repo-slug>/<sessionId>.jsonl, so it works for background and
|
|
10
|
+
# interactive sessions alike, and after they stop.
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
KEY="${1:?change-id or session uuid}"
|
|
13
|
+
MAIN="$(git rev-parse --path-format=absolute --git-common-dir | sed 's#/\.git$##')"
|
|
14
|
+
SLUG="$(printf %s "$MAIN" | sed 's#[/_.]#-#g')"
|
|
15
|
+
|
|
16
|
+
if [[ "$KEY" =~ ^[0-9a-f]{8}-[0-9a-f]{4}- ]]; then
|
|
17
|
+
SID="$KEY"
|
|
18
|
+
else
|
|
19
|
+
SID=$(claude agents --json 2>/dev/null | python3 -c '
|
|
20
|
+
import json,sys
|
|
21
|
+
d=json.load(sys.stdin); d=d if isinstance(d,list) else d.get("agents",[])
|
|
22
|
+
m=sorted((x for x in d if x.get("name")==sys.argv[1]), key=lambda x:x.get("startedAt",0))
|
|
23
|
+
print(m[-1]["sessionId"] if m else "")' "$KEY")
|
|
24
|
+
fi
|
|
25
|
+
[ -n "$SID" ] || { echo "NO-SESSION $KEY" >&2; exit 4; }
|
|
26
|
+
|
|
27
|
+
F="$HOME/.claude/projects/$SLUG/$SID.jsonl"
|
|
28
|
+
[ -f "$F" ] || { echo "NO-TRANSCRIPT $F" >&2; exit 5; }
|
|
29
|
+
|
|
30
|
+
python3 - "$F" <<'PY'
|
|
31
|
+
import json, sys
|
|
32
|
+
last = ""
|
|
33
|
+
for line in open(sys.argv[1], encoding="utf-8"):
|
|
34
|
+
try:
|
|
35
|
+
d = json.loads(line)
|
|
36
|
+
except ValueError:
|
|
37
|
+
continue
|
|
38
|
+
if d.get("type") != "assistant":
|
|
39
|
+
continue
|
|
40
|
+
c = d.get("message", {}).get("content")
|
|
41
|
+
t = "".join(x.get("text", "") for x in c if isinstance(x, dict) and x.get("type") == "text") if isinstance(c, list) else str(c or "")
|
|
42
|
+
if t.strip():
|
|
43
|
+
last = t
|
|
44
|
+
print(last)
|
|
45
|
+
PY
|