@softure-ai/skills 0.13.0 → 0.15.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/ONBOARD.md +2 -1
- package/README.md +7 -2
- package/WORKFLOW.md +64 -11
- package/package.json +1 -1
- package/rules/AGENTS.md +73 -19
- package/skills/softure-archive/SKILL.md +30 -6
- package/skills/softure-init/SKILL.md +9 -3
- package/skills/softure-worktree/SKILL.md +107 -46
- package/skills/softure-worktree/scripts/wt-merge-check.py +140 -0
- package/skills/softure-worktree/scripts/wt-roadmap.py +172 -18
- package/skills/softure-worktree/scripts/wt-startable.py +153 -0
- package/skills/softure-worktree/scripts/wt_config.py +2 -2
- package/skills/softure-worktree-manager/SKILL.md +40 -14
- package/skills/softure-worktree-manager/references/report-routine.md +11 -5
- package/skills/softure-worktree-manager/scripts/wm-resume.sh +5 -4
|
@@ -4,12 +4,25 @@
|
|
|
4
4
|
wt-roadmap.py open <change-id> [--note "…"] [--dry-run]
|
|
5
5
|
wt-roadmap.py stage <change-id> "<stage>" [--dry-run]
|
|
6
6
|
wt-roadmap.py ready <change-id> [--dry-run]
|
|
7
|
+
wt-roadmap.py done <change-id> [--dry-run]
|
|
8
|
+
wt-roadmap.py done_code <change-id> --waiting "<what>" [--dry-run]
|
|
7
9
|
(cloud sessions additionally: [--cloud] [--branch <branch>] — see below)
|
|
8
10
|
|
|
9
11
|
`open` — status -> **in_progress** (research, since <today>; worktree `../<repo>-<id>`, branch `<id>`[; note])
|
|
10
12
|
`stage` — replaces only the stage inside the parentheses: research -> frame -> plan -> plan-review ->
|
|
11
13
|
implement N/M -> impl-review -> integration -> archive (WORKFLOW.md §5)
|
|
12
14
|
`ready` — **in_progress** (<stage>, since …; <where>) -> **ready_to_merge** (since <today>; <where>)
|
|
15
|
+
`done` — run right after the change's merge: the row and the item block -> `done` (or
|
|
16
|
+
`done_code (<today>; waiting: <what>)`), plus the `## Done`, `## Owner decisions and checks`
|
|
17
|
+
and `## Before the next release` lines. All of it comes from the `## Roadmap handoff`
|
|
18
|
+
section that `softure-archive --handoff` wrote into the archived change.md
|
|
19
|
+
(`context/archive/<created>-<id>/change.md` on the main branch). `done` follows the
|
|
20
|
+
handoff's status; `done_code --waiting "…"` forces `done_code` with that text. Lines
|
|
21
|
+
already present are not added twice, so a re-run is safe.
|
|
22
|
+
|
|
23
|
+
Branches never edit roadmap.md (unless `worktree.cloudState` is "branch"): the roadmap state lives
|
|
24
|
+
on the main branch, written only by this script, so merging the main branch into a change branch
|
|
25
|
+
never conflicts on it.
|
|
13
26
|
|
|
14
27
|
Why a script instead of editing the file: sessions in worktrees used to edit the main tree's
|
|
15
28
|
roadmap without committing. Someone else's uncommitted rows then sat in `roadmap.md`, every
|
|
@@ -30,9 +43,11 @@ fresh state. `--branch <name>` overrides the branch written into the row (defaul
|
|
|
30
43
|
|
|
31
44
|
With `worktree.cloudState: "branch"` in context/workflow.json, a cloud session instead commits
|
|
32
45
|
the edit **on its own branch** (the checkout) and pushes nothing: the branch carries the state
|
|
33
|
-
and `<main>` changes only through the merge.
|
|
34
|
-
|
|
35
|
-
that
|
|
46
|
+
and `<main>` changes only through the merge. Every merge of `<main>` into such a branch then
|
|
47
|
+
conflicts on the roadmap, so prefer the default and give the project's pre-push hook a cheap path
|
|
48
|
+
for pushes that touch only `context/` (WORKFLOW.md §2, CI minutes). Use "branch" only when a
|
|
49
|
+
coordinator assigns the items (so nobody needs to see a claim on `<main>`) and a push to `<main>`
|
|
50
|
+
stays expensive or contended by many sessions.
|
|
36
51
|
"""
|
|
37
52
|
from __future__ import annotations
|
|
38
53
|
|
|
@@ -56,6 +71,9 @@ ROW_RE = re.compile(r"^(?P<head>\|.*\|\s*)(?P<status>[^|]*?)(?P<tail>\s*\|\s*)$"
|
|
|
56
71
|
ID_RE = re.compile(r"^\| \*\*([A-Z]+-\d+)\*\* \|")
|
|
57
72
|
STAGE_RE = re.compile(r"(in_progress\*{0,2} \()([^,;)]*)(, since )")
|
|
58
73
|
READY_RE = re.compile(r"(\*{0,2})in_progress(\*{0,2}) \([^,;)]*, since [0-9-]+; ")
|
|
74
|
+
HANDOFF_RE = re.compile(r"^- \*\*(?P<key>[^*]+):\*\* ?(?P<value>.*)$")
|
|
75
|
+
ARCHIVED_RE = re.compile(r"^Archived [0-9-]+: (?P<outcome>.+?)\.?$")
|
|
76
|
+
DONE_CODE_RE = re.compile(r"^done_code \((?:[0-9-]+; )?waiting: (?P<waiting>.+)\)$")
|
|
59
77
|
|
|
60
78
|
|
|
61
79
|
def git(repo: str, *args: str, env: dict[str, str] | None = None) -> str:
|
|
@@ -89,8 +107,93 @@ def item_id(line: str, change_id: str) -> str:
|
|
|
89
107
|
return match.group(1) if match else change_id
|
|
90
108
|
|
|
91
109
|
|
|
110
|
+
def read_handoff(repo: str, rev: str, change_id: str) -> dict:
|
|
111
|
+
"""Read the archived change folder of `change_id` at `rev` and its `## Roadmap handoff` section.
|
|
112
|
+
|
|
113
|
+
Returns {"archive", "status", "waiting", "outcome", "owner": [...], "release": [...]}. Without a
|
|
114
|
+
handoff section (an archive written before it existed) the outcome falls back to the
|
|
115
|
+
`Archived <date>: <outcome>.` line under `## Notes`, the status to `done`.
|
|
116
|
+
"""
|
|
117
|
+
names = git(repo, "ls-tree", "-d", "--name-only", rev, "context/archive/").splitlines()
|
|
118
|
+
pattern = re.compile(rf"^context/archive/[0-9]{{4}}-[0-9]{{2}}-[0-9]{{2}}-{re.escape(change_id)}$")
|
|
119
|
+
hits = [name for name in names if pattern.match(name)]
|
|
120
|
+
if len(hits) != 1:
|
|
121
|
+
sys.exit(f"{len(hits)} archive folders for `{change_id}` on {rev} — expected exactly 1 "
|
|
122
|
+
f"(run `done` only after the change's merge, which carries its archive commit)")
|
|
123
|
+
text = git(repo, "show", f"{rev}:{hits[0]}/change.md")
|
|
124
|
+
handoff = {"archive": hits[0][len("context/"):] + "/", "status": "done", "waiting": None,
|
|
125
|
+
"outcome": None, "owner": [], "release": [], "found": False}
|
|
126
|
+
section = None
|
|
127
|
+
for line in text.splitlines():
|
|
128
|
+
if line.startswith("## "):
|
|
129
|
+
section = line[3:].strip()
|
|
130
|
+
continue
|
|
131
|
+
if section == "Notes" and handoff["outcome"] is None:
|
|
132
|
+
archived = ARCHIVED_RE.match(line.strip())
|
|
133
|
+
if archived:
|
|
134
|
+
handoff["outcome"] = archived["outcome"]
|
|
135
|
+
if section != "Roadmap handoff":
|
|
136
|
+
continue
|
|
137
|
+
match = HANDOFF_RE.match(line.strip())
|
|
138
|
+
if not match:
|
|
139
|
+
continue
|
|
140
|
+
handoff["found"] = True
|
|
141
|
+
key, value = match["key"].strip().lower(), match["value"].strip()
|
|
142
|
+
if key == "status":
|
|
143
|
+
waiting = DONE_CODE_RE.match(value)
|
|
144
|
+
handoff["status"] = "done_code" if waiting else "done"
|
|
145
|
+
handoff["waiting"] = waiting["waiting"] if waiting else None
|
|
146
|
+
elif key == "done":
|
|
147
|
+
handoff["outcome"] = value
|
|
148
|
+
elif key == "owner check":
|
|
149
|
+
handoff["owner"].append(value)
|
|
150
|
+
elif key == "before the next release":
|
|
151
|
+
handoff["release"].append(value)
|
|
152
|
+
return handoff
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def append_to_section(lines: list[str], heading: str, entry: str, before: tuple[str, ...]) -> None:
|
|
156
|
+
"""Append `entry` at the end of `## <heading>`; create the section in front of the first of `before`
|
|
157
|
+
that exists (else at the end of the file). An entry already present is not added again."""
|
|
158
|
+
if any(line.rstrip("\n") == entry for line in lines):
|
|
159
|
+
return
|
|
160
|
+
start = next((k for k, line in enumerate(lines) if line.rstrip() == f"## {heading}"), None)
|
|
161
|
+
if start is None:
|
|
162
|
+
at = next((k for k, line in enumerate(lines) if line.rstrip() in {f"## {b}" for b in before}), None)
|
|
163
|
+
block = [f"## {heading}\n", f"{entry}\n", "\n"]
|
|
164
|
+
if at is None:
|
|
165
|
+
if lines and not lines[-1].endswith("\n"):
|
|
166
|
+
lines[-1] += "\n"
|
|
167
|
+
if lines and lines[-1].strip():
|
|
168
|
+
block.insert(0, "\n")
|
|
169
|
+
lines.extend(block[:-1])
|
|
170
|
+
else:
|
|
171
|
+
lines[at:at] = block
|
|
172
|
+
return
|
|
173
|
+
end = next((k for k in range(start + 1, len(lines)) if lines[k].startswith("## ")), len(lines))
|
|
174
|
+
while end > start + 1 and not lines[end - 1].strip():
|
|
175
|
+
end -= 1
|
|
176
|
+
if end == len(lines) and lines and not lines[-1].endswith("\n"):
|
|
177
|
+
lines[-1] += "\n"
|
|
178
|
+
lines.insert(end, f"{entry}\n")
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def done_status(handoff: dict, mode: str, arg: str | None, today: str) -> str:
|
|
182
|
+
if mode == "done_code" or handoff["status"] == "done_code":
|
|
183
|
+
return f"done_code ({today}; waiting: {arg or handoff['waiting']})"
|
|
184
|
+
return "done"
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def unchanged(old: str, new: str, target: str) -> bool:
|
|
188
|
+
"""A re-run (e.g. `done` after a retry) whose edit is already in place commits nothing."""
|
|
189
|
+
if re.sub(r"(?m)^updated: .*$", "", old) != re.sub(r"(?m)^updated: .*$", "", new):
|
|
190
|
+
return False
|
|
191
|
+
print(f"roadmap on {target} already up to date — nothing to commit")
|
|
192
|
+
return True
|
|
193
|
+
|
|
194
|
+
|
|
92
195
|
def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
|
|
93
|
-
cloud_branch: str | None = None) -> str:
|
|
196
|
+
cloud_branch: str | None = None, handoff: dict | None = None) -> str:
|
|
94
197
|
lines = text.splitlines(keepends=True)
|
|
95
198
|
i = find_row(lines, change_id)
|
|
96
199
|
today = dt.date.today().isoformat()
|
|
@@ -107,6 +210,13 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
|
|
|
107
210
|
where = f"worktree `../{repo_name}-{change_id}`, branch `{change_id}`"
|
|
108
211
|
lines[i] = set_row_status(lines[i], f"**in_progress** (research, since {today}; {where}{note})")
|
|
109
212
|
body_status = f"- **Status:** in_progress (research, since {today}; {where}{note})\n"
|
|
213
|
+
elif mode in ("done", "done_code"):
|
|
214
|
+
status = done_status(handoff, mode, arg, today)
|
|
215
|
+
current = row_status(lines[i]).strip()
|
|
216
|
+
if current.startswith(("done", "**done")):
|
|
217
|
+
status = current.replace("**", "") # a re-run keeps the recorded date and text
|
|
218
|
+
lines[i] = set_row_status(lines[i], status)
|
|
219
|
+
body_status = f"- **Status:** {status}\n"
|
|
110
220
|
elif mode == "stage":
|
|
111
221
|
new, count = STAGE_RE.subn(lambda m: f"{m[1]}{arg}{m[3]}", lines[i], count=1)
|
|
112
222
|
if count != 1:
|
|
@@ -126,7 +236,7 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
|
|
|
126
236
|
len(lines),
|
|
127
237
|
)
|
|
128
238
|
sidx = next((k for k in range(cid + 1, end) if lines[k].startswith("- **Status:**")), None)
|
|
129
|
-
if mode
|
|
239
|
+
if mode in ("open", "done", "done_code"):
|
|
130
240
|
if sidx is None:
|
|
131
241
|
lines.insert(cid + 1, body_status)
|
|
132
242
|
else:
|
|
@@ -136,17 +246,44 @@ def edit(text: str, mode: str, change_id: str, arg: str | None, repo_name: str,
|
|
|
136
246
|
elif sidx is not None:
|
|
137
247
|
lines[sidx] = READY_RE.sub(lambda m: f"{m[1]}ready_to_merge{m[2]} (since {today}; ", lines[sidx], count=1)
|
|
138
248
|
|
|
249
|
+
if mode in ("done", "done_code"):
|
|
250
|
+
rid = item_id(lines[i], change_id)
|
|
251
|
+
outcome = handoff["outcome"] or "delivered"
|
|
252
|
+
for check in handoff["owner"]:
|
|
253
|
+
append_to_section(lines, "Owner decisions and checks",
|
|
254
|
+
f"- [ ] **{rid}**: {check}. {handoff['archive']}plan.md", ("Done", "Decisions (auto)"))
|
|
255
|
+
for step in handoff["release"]:
|
|
256
|
+
append_to_section(lines, "Before the next release", f"- [ ] {step} (**{rid}**)",
|
|
257
|
+
("Owner decisions and checks", "Done", "Decisions (auto)"))
|
|
258
|
+
append_to_section(lines, "Done", f"- **{rid}** `{change_id}`: {outcome}; archived in `{handoff['archive']}`",
|
|
259
|
+
("Decisions (auto)",))
|
|
260
|
+
|
|
139
261
|
out = "".join(lines)
|
|
140
262
|
return re.sub(r"(?m)^updated: .*$", f"updated: {today}", out, count=1)
|
|
141
263
|
|
|
142
264
|
|
|
143
|
-
def commit_message(text: str, mode: str, change_id: str, arg: str | None, where: str
|
|
265
|
+
def commit_message(text: str, mode: str, change_id: str, arg: str | None, where: str,
|
|
266
|
+
new_text: str | None = None) -> str:
|
|
144
267
|
lines = text.splitlines(keepends=True)
|
|
145
268
|
rid = item_id(lines[find_row(lines, change_id)], change_id)
|
|
146
|
-
label = {"open": f"in_progress ({where})", "stage": arg or "", "ready": "ready_to_merge"
|
|
269
|
+
label = {"open": f"in_progress ({where})", "stage": arg or "", "ready": "ready_to_merge",
|
|
270
|
+
"done": "done", "done_code": "done_code"}[mode]
|
|
271
|
+
if mode in ("done", "done_code") and new_text is not None:
|
|
272
|
+
new_lines = new_text.splitlines(keepends=True)
|
|
273
|
+
label = row_status(new_lines[find_row(new_lines, change_id)]).strip().split(" ")[0]
|
|
147
274
|
return f"docs(roadmap): {rid} {label}\n\n{COAUTHOR}"
|
|
148
275
|
|
|
149
276
|
|
|
277
|
+
def load_handoff(repo: str, rev: str, mode: str, change_id: str) -> dict | None:
|
|
278
|
+
if mode not in ("done", "done_code"):
|
|
279
|
+
return None
|
|
280
|
+
handoff = read_handoff(repo, rev, change_id)
|
|
281
|
+
if not handoff["found"]:
|
|
282
|
+
print(f"note: {handoff['archive']}change.md has no `## Roadmap handoff` — status `done` unless forced, "
|
|
283
|
+
f"no owner-check or release lines", file=sys.stderr)
|
|
284
|
+
return handoff
|
|
285
|
+
|
|
286
|
+
|
|
150
287
|
def push_roadmap_commit(repo: str, sha: str, main: str, env: dict[str, str]) -> subprocess.CompletedProcess:
|
|
151
288
|
"""Push `sha` to `origin/<main>` from a throwaway worktree, never from the session checkout.
|
|
152
289
|
|
|
@@ -184,11 +321,15 @@ def run_cloud(mode: str, change_id: str, arg: str | None, branch: str | None, dr
|
|
|
184
321
|
git(repo, "fetch", "-q", "origin", main)
|
|
185
322
|
base = git(repo, "rev-parse", f"origin/{main}").strip()
|
|
186
323
|
old = git(repo, "show", f"{base}:{ROADMAP}")
|
|
187
|
-
|
|
324
|
+
handoff = load_handoff(repo, base, mode, change_id)
|
|
325
|
+
new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None,
|
|
326
|
+
handoff=handoff)
|
|
188
327
|
if dry:
|
|
189
328
|
sys.stdout.writelines(difflib.unified_diff(old.splitlines(True), new.splitlines(True), f"origin/{main}", "commit"))
|
|
190
329
|
return
|
|
191
|
-
|
|
330
|
+
if unchanged(old, new, f"origin/{main}"):
|
|
331
|
+
return
|
|
332
|
+
msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}", new)
|
|
192
333
|
session = os.environ.get("CLAUDE_CODE_REMOTE_SESSION_ID", "")
|
|
193
334
|
if session.startswith("cse_"):
|
|
194
335
|
msg += f"\nClaude-Session: https://claude.ai/code/session_{session[4:]}"
|
|
@@ -226,13 +367,17 @@ def run_cloud_branch(mode: str, change_id: str, arg: str | None, branch: str | N
|
|
|
226
367
|
work_path = os.path.join(repo, ROADMAP)
|
|
227
368
|
with open(work_path, encoding="utf-8") as fh:
|
|
228
369
|
old = fh.read()
|
|
229
|
-
|
|
370
|
+
handoff = load_handoff(repo, "HEAD", mode, change_id)
|
|
371
|
+
new = edit(old, mode, change_id, arg, repo_name, cloud_branch=branch if mode == "open" else None,
|
|
372
|
+
handoff=handoff)
|
|
230
373
|
if dry:
|
|
231
374
|
sys.stdout.writelines(difflib.unified_diff(old.splitlines(True), new.splitlines(True), current, "commit"))
|
|
232
375
|
return
|
|
376
|
+
if unchanged(old, new, current):
|
|
377
|
+
return
|
|
233
378
|
with open(work_path, "w", encoding="utf-8") as fh:
|
|
234
379
|
fh.write(new)
|
|
235
|
-
msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}")
|
|
380
|
+
msg = commit_message(old, mode, change_id, arg, f"cloud session, branch {branch}", new)
|
|
236
381
|
session = os.environ.get("CLAUDE_CODE_REMOTE_SESSION_ID", "")
|
|
237
382
|
if session.startswith("cse_"):
|
|
238
383
|
msg += f"\nClaude-Session: https://claude.ai/code/session_{session[4:]}"
|
|
@@ -252,7 +397,7 @@ def run_local(mode: str, change_id: str, arg: str | None, dry: bool) -> None:
|
|
|
252
397
|
work_path = os.path.join(main_wt, ROADMAP)
|
|
253
398
|
if dry:
|
|
254
399
|
head_text = git(main_wt, "show", f"HEAD:{ROADMAP}")
|
|
255
|
-
new_head = edit(head_text, mode, change_id, arg, repo_name)
|
|
400
|
+
new_head = edit(head_text, mode, change_id, arg, repo_name, handoff=load_handoff(main_wt, "HEAD", mode, change_id))
|
|
256
401
|
sys.stdout.writelines(difflib.unified_diff(head_text.splitlines(True), new_head.splitlines(True), "HEAD", "commit"))
|
|
257
402
|
return
|
|
258
403
|
|
|
@@ -270,11 +415,15 @@ def run_local(mode: str, change_id: str, arg: str | None, dry: bool) -> None:
|
|
|
270
415
|
|
|
271
416
|
head_sha = git(main_wt, "rev-parse", "HEAD").strip()
|
|
272
417
|
head_text = git(main_wt, "show", f"{head_sha}:{ROADMAP}")
|
|
273
|
-
|
|
274
|
-
|
|
418
|
+
handoff = load_handoff(main_wt, head_sha, mode, change_id)
|
|
419
|
+
new_head = edit(head_text, mode, change_id, arg, repo_name, handoff=handoff)
|
|
420
|
+
if unchanged(head_text, new_head, main):
|
|
421
|
+
return
|
|
422
|
+
msg = commit_message(head_text, mode, change_id, arg, "separate worktree", new_head)
|
|
275
423
|
with open(work_path, encoding="utf-8") as fh:
|
|
276
424
|
work_text = fh.read()
|
|
277
|
-
new_work = new_head if work_text == head_text else edit(work_text, mode, change_id, arg, repo_name
|
|
425
|
+
new_work = new_head if work_text == head_text else edit(work_text, mode, change_id, arg, repo_name,
|
|
426
|
+
handoff=handoff)
|
|
278
427
|
|
|
279
428
|
with tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as tmp:
|
|
280
429
|
tmp.write(new_head)
|
|
@@ -306,7 +455,11 @@ def main() -> None:
|
|
|
306
455
|
dry = "--dry-run" in argv
|
|
307
456
|
cloud = "--cloud" in argv or os.environ.get("CLAUDE_CODE_REMOTE") == "true"
|
|
308
457
|
args = [a for a in argv if a not in ("--dry-run", "--cloud")]
|
|
309
|
-
note = branch = None
|
|
458
|
+
note = branch = waiting = None
|
|
459
|
+
if "--waiting" in args:
|
|
460
|
+
k = args.index("--waiting")
|
|
461
|
+
waiting = args[k + 1]
|
|
462
|
+
del args[k:k + 2]
|
|
310
463
|
if "--note" in args:
|
|
311
464
|
k = args.index("--note")
|
|
312
465
|
note = args[k + 1]
|
|
@@ -316,14 +469,15 @@ def main() -> None:
|
|
|
316
469
|
branch = args[k + 1]
|
|
317
470
|
del args[k:k + 2]
|
|
318
471
|
valid = (
|
|
319
|
-
len(args) >= 2 and args[0] in ("open", "stage", "ready")
|
|
472
|
+
len(args) >= 2 and args[0] in ("open", "stage", "ready", "done", "done_code")
|
|
320
473
|
and (args[0] != "stage" or len(args) == 3)
|
|
321
474
|
and (args[0] == "stage" or len(args) == 2)
|
|
475
|
+
and (args[0] != "done_code" or bool(waiting))
|
|
322
476
|
)
|
|
323
477
|
if not valid:
|
|
324
478
|
sys.exit(__doc__)
|
|
325
479
|
mode, change_id = args[0], args[1]
|
|
326
|
-
arg = note
|
|
480
|
+
arg = {"open": note, "stage": args[2] if mode == "stage" else None, "done_code": waiting}.get(mode)
|
|
327
481
|
if cloud and (load_config().get("worktree") or {}).get("cloudState") == "branch":
|
|
328
482
|
run_cloud_branch(mode, change_id, arg, branch, dry)
|
|
329
483
|
elif cloud:
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Print the startable set of the roadmap on the main branch, so the coordinator's check is mechanical.
|
|
3
|
+
|
|
4
|
+
wt-startable.py [--ref <git-ref>] [--file <path>] [--no-fetch]
|
|
5
|
+
|
|
6
|
+
Reads `context/foundation/roadmap.md` from `origin/<main>` (fetched first; `--ref` picks another ref,
|
|
7
|
+
`--file` a file on disk) and prints one line per item that is not done yet:
|
|
8
|
+
|
|
9
|
+
START FC-3 pricing-one-section no prerequisites
|
|
10
|
+
START FC-5 checkout-summary prerequisites on main: FC-1, FC-2
|
|
11
|
+
PROPOSED FC-9 dark-mode prerequisites on main (start when no START item can take a slot)
|
|
12
|
+
WAIT FC-6 invoice-pdf waiting for FC-5 (in_progress), FC-7 (ready)
|
|
13
|
+
FLIGHT FC-4 password-reset in_progress (implement 2/3, since 2026-10-20; ...)
|
|
14
|
+
BLOCKED FC-8 sso-login blocked (SOFTURE/AI#301)
|
|
15
|
+
OWNER FC-10 release Mode: owner
|
|
16
|
+
|
|
17
|
+
START = `ready`, `Mode` is `autonomous`, every prerequisite `done` or `done_code` on the main branch (or
|
|
18
|
+
none). Every START item that has no thread yet gets one now (`rules/AGENTS.md` → Coordinator duties).
|
|
19
|
+
WAIT always names the missing prerequisite IDs with their status; use them verbatim in the report's
|
|
20
|
+
Stage (`waiting for FC-5, FC-7`). FLIGHT rows are `in_progress` or `ready_to_merge`: they should have a
|
|
21
|
+
thread; one without a thread is adopted (`softure-worktree-manager` M0.1).
|
|
22
|
+
|
|
23
|
+
The script cannot see threads: it lists what the roadmap allows, the coordinator matches it against
|
|
24
|
+
its thread list. Parsing follows WORKFLOW.md §5; a prerequisite ID that is not in the table counts as
|
|
25
|
+
done only when `## Done` names it. Only the `## At a glance` table is read.
|
|
26
|
+
"""
|
|
27
|
+
from __future__ import annotations
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import os
|
|
31
|
+
import re
|
|
32
|
+
import subprocess
|
|
33
|
+
import sys
|
|
34
|
+
|
|
35
|
+
sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/skills
|
|
36
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
37
|
+
from wt_config import main_branch, main_root # noqa: E402
|
|
38
|
+
|
|
39
|
+
ROADMAP = "context/foundation/roadmap.md"
|
|
40
|
+
ID_RE = re.compile(r"[A-Z]+-\d+")
|
|
41
|
+
ROW_RE = re.compile(r"^\| \*\*(?P<id>[A-Z]+-\d+)\*\* \| `(?P<change>[^`]+)` \|")
|
|
42
|
+
DONE_STATUSES = ("done", "done_code")
|
|
43
|
+
FLIGHT_STATUSES = ("in_progress", "ready_to_merge")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def read_roadmap(args: argparse.Namespace) -> str:
|
|
47
|
+
if args.file:
|
|
48
|
+
with open(args.file, encoding="utf-8") as fh:
|
|
49
|
+
return fh.read()
|
|
50
|
+
root = main_root()
|
|
51
|
+
ref = args.ref
|
|
52
|
+
if not ref:
|
|
53
|
+
branch = main_branch(root)
|
|
54
|
+
ref = f"origin/{branch}"
|
|
55
|
+
if not args.no_fetch:
|
|
56
|
+
subprocess.run(["git", "-C", root, "fetch", "-q", "origin", branch], capture_output=True)
|
|
57
|
+
shown = subprocess.run(["git", "-C", root, "show", f"{ref}:{ROADMAP}"], capture_output=True, text=True)
|
|
58
|
+
if shown.returncode != 0:
|
|
59
|
+
sys.exit(f"cannot read {ROADMAP} at {ref}: {shown.stderr.strip()}")
|
|
60
|
+
return shown.stdout
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def cells(line: str) -> list[str]:
|
|
64
|
+
return [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def status_word(status: str) -> str:
|
|
68
|
+
return status.replace("*", "").strip().split(" ", 1)[0].split("(", 1)[0]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def parse(text: str) -> tuple[list[dict], set[str]]:
|
|
72
|
+
items: list[dict] = []
|
|
73
|
+
done_section: set[str] = set()
|
|
74
|
+
section = ""
|
|
75
|
+
for line in text.splitlines():
|
|
76
|
+
if line.startswith("## "):
|
|
77
|
+
section = line[3:].strip().lower()
|
|
78
|
+
continue
|
|
79
|
+
if section == "done":
|
|
80
|
+
done_section.update(ID_RE.findall(line))
|
|
81
|
+
continue
|
|
82
|
+
if section != "at a glance" or not ROW_RE.match(line):
|
|
83
|
+
continue
|
|
84
|
+
row = cells(line)
|
|
85
|
+
if len(row) < 6:
|
|
86
|
+
continue
|
|
87
|
+
items.append({
|
|
88
|
+
"id": row[0].strip("*"),
|
|
89
|
+
"change": row[1].strip("`"),
|
|
90
|
+
"deps": ID_RE.findall(row[3]),
|
|
91
|
+
"mode": row[4].strip().lower(),
|
|
92
|
+
"status": row[-1].replace("*", "").strip(),
|
|
93
|
+
})
|
|
94
|
+
return items, done_section
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def classify(items: list[dict], done_section: set[str]) -> list[tuple[str, dict, str]]:
|
|
98
|
+
status_of = {item["id"]: status_word(item["status"]) for item in items}
|
|
99
|
+
rows = []
|
|
100
|
+
for item in items:
|
|
101
|
+
word = status_word(item["status"])
|
|
102
|
+
if word in DONE_STATUSES:
|
|
103
|
+
continue
|
|
104
|
+
if word in FLIGHT_STATUSES:
|
|
105
|
+
rows.append(("FLIGHT", item, item["status"]))
|
|
106
|
+
continue
|
|
107
|
+
if word == "blocked":
|
|
108
|
+
rows.append(("BLOCKED", item, item["status"]))
|
|
109
|
+
continue
|
|
110
|
+
if item["mode"] == "owner":
|
|
111
|
+
rows.append(("OWNER", item, "Mode: owner"))
|
|
112
|
+
continue
|
|
113
|
+
missing = [
|
|
114
|
+
dep for dep in item["deps"]
|
|
115
|
+
if status_of.get(dep) not in DONE_STATUSES and not (dep not in status_of and dep in done_section)
|
|
116
|
+
]
|
|
117
|
+
if missing:
|
|
118
|
+
named = ", ".join(f"{dep} ({status_of.get(dep, 'not on the roadmap')})" for dep in missing)
|
|
119
|
+
rows.append(("WAIT", item, f"waiting for {named}"))
|
|
120
|
+
continue
|
|
121
|
+
reason = f"prerequisites on main: {', '.join(item['deps'])}" if item["deps"] else "no prerequisites"
|
|
122
|
+
if word == "ready":
|
|
123
|
+
rows.append(("START", item, reason))
|
|
124
|
+
elif word == "proposed":
|
|
125
|
+
rows.append(("PROPOSED", item, f"{reason} (start when no START item can take a slot)"))
|
|
126
|
+
else:
|
|
127
|
+
rows.append(("UNKNOWN", item, f"unrecognised status: {item['status']}"))
|
|
128
|
+
return rows
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def main() -> None:
|
|
132
|
+
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
133
|
+
parser.add_argument("--ref", help="git ref to read the roadmap from (default: origin/<main>)")
|
|
134
|
+
parser.add_argument("--file", help="read this roadmap file instead of a git ref")
|
|
135
|
+
parser.add_argument("--no-fetch", action="store_true", help="do not fetch origin/<main> first")
|
|
136
|
+
args = parser.parse_args()
|
|
137
|
+
|
|
138
|
+
items, done_section = parse(read_roadmap(args))
|
|
139
|
+
if not items:
|
|
140
|
+
sys.exit(f"no roadmap rows found in {ROADMAP} (WORKFLOW.md §5 table format)")
|
|
141
|
+
rows = classify(items, done_section)
|
|
142
|
+
order = ["START", "PROPOSED", "WAIT", "FLIGHT", "BLOCKED", "OWNER", "UNKNOWN"]
|
|
143
|
+
rows.sort(key=lambda row: order.index(row[0]))
|
|
144
|
+
id_width = max((len(item["id"]) for _, item, _ in rows), default=0)
|
|
145
|
+
change_width = max((len(item["change"]) for _, item, _ in rows), default=0)
|
|
146
|
+
for kind, item, detail in rows:
|
|
147
|
+
print(f"{kind:<9} {item['id']:<{id_width}} {item['change']:<{change_width}} {detail}")
|
|
148
|
+
if not rows:
|
|
149
|
+
print("nothing left: every roadmap item is done or done_code")
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
main()
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Always reads the config of the MAIN worktree (first entry of `git worktree list`), so every
|
|
10
10
|
worktree and every script sees the same values. `mainBranch` falls back to origin's HEAD, then
|
|
11
11
|
"main"; `worktree.maxParallel` to 4; `language` to "en"; `mode` to "manual";
|
|
12
|
-
`autonomy.reports.every` to 60.
|
|
12
|
+
`autonomy.reports.every` to 60; `autonomy.remergeMain` to "when-needed".
|
|
13
13
|
|
|
14
14
|
Importable: `from wt_config import load_config, main_root, main_branch`.
|
|
15
15
|
"""
|
|
@@ -26,7 +26,7 @@ DEFAULTS = {
|
|
|
26
26
|
"language": "en",
|
|
27
27
|
"worktree": {"maxParallel": 4, "setup": []},
|
|
28
28
|
"release": {"owner": True},
|
|
29
|
-
"autonomy": {"reports": {"every": 60, "hours": None}},
|
|
29
|
+
"autonomy": {"reports": {"every": 60, "hours": None}, "remergeMain": "when-needed"},
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
|
|
@@ -120,8 +120,24 @@ project's main-chat session: no shell over the workers, no `claude agents`, no
|
|
|
120
120
|
| READY, go | `SendMessage` | cross-session messages, both ways |
|
|
121
121
|
| M5 cleanup | `claude stop` + worktree removal | the thread resolves itself after its pull request is merged; on its merge result check it and resolve it if still open |
|
|
122
122
|
|
|
123
|
+
The coordinator reaches these rules only through the pointer in the project
|
|
124
|
+
instructions (WORKFLOW §8.5, Bootstrap). When a thread reports that the pointer
|
|
125
|
+
is missing, or the coordinator notices it has not loaded the managed block, it
|
|
126
|
+
reads `AGENTS.md` and `context/workflow.json` from the main branch at once and
|
|
127
|
+
follows them for the rest of the run, without waiting for the paste: it gives
|
|
128
|
+
the go and runs the merge queue itself from then on. It posts the snippet to
|
|
129
|
+
the owner with where to paste it, records the missing pointer in memory, and
|
|
130
|
+
repeats it as an owner step in every report until the owner confirms it.
|
|
131
|
+
|
|
123
132
|
A fresh main-chat session starts the run by itself (`AGENTS.md` → Start of a
|
|
124
|
-
run); it does not wait for this skill to be invoked.
|
|
133
|
+
run); it does not wait for this skill to be invoked. It loads the project's
|
|
134
|
+
memory and coordinator conventions first, and records the run state there
|
|
135
|
+
(merge queue holder, routine id, lanes, which forge events do not arrive).
|
|
136
|
+
On every merge result and every report firing it recomputes the startable set
|
|
137
|
+
from the roadmap (M6), nudges a thread whose go has produced no merge SHA
|
|
138
|
+
within 30 minutes, and nudges every working thread silent for 45 minutes or
|
|
139
|
+
more. Where PR events do not reach the threads, they poll their own CI
|
|
140
|
+
(`softure-worktree` → READY).
|
|
125
141
|
|
|
126
142
|
## The coordinator does not fix — it commissions
|
|
127
143
|
|
|
@@ -199,7 +215,7 @@ exactly like one it launched. Act on each line:
|
|
|
199
215
|
| `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" |
|
|
200
216
|
| `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` |
|
|
201
217
|
| `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 |
|
|
202
|
-
| `FIX-ROW` | `<main>` already has the merge commit, the row was never flipped |
|
|
218
|
+
| `FIX-ROW` | `<main>` already has the merge commit, the row was never flipped | `python3 <S>/wt-roadmap.py done <change-id>` (row, block, `## Done`, owner checks and release steps from the archived `change.md`; documents only); remove a leftover worktree/branch if the merge is on `<main>` (`git branch -d` refuses otherwise — good) |
|
|
203
219
|
| `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 |
|
|
204
220
|
|
|
205
221
|
`coord` is the coordinator named in the worker's launch prompt (`wm-launch.sh`
|
|
@@ -387,7 +403,7 @@ job), then:
|
|
|
387
403
|
CronCreate(
|
|
388
404
|
cron: "4,19,34,49 * * * *", # every 15 min, off the :00/:30 marks
|
|
389
405
|
recurring: true,
|
|
390
|
-
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 as the status table (format under 'The report itself'); 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;
|
|
406
|
+
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 as the status table (format under 'The report itself'); 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; recompute the startable set over the whole roadmap (python3 <S>/wt-startable.py), and every START item without a session and without collision → M1–M3. Work until the roadmap is done / done_code. 4) End → M7 (integration suite on <main>, unless the release covers it; close the roadmap and push <main> only if the roadmap header orders it; tag, release and deploy never — those are the owner's) and CronDelete this job. Write the report in chatLanguage (default: language) and the times in the timezone from context/workflow.json; paste the content into the message, never a file to link.")
|
|
391
407
|
```
|
|
392
408
|
|
|
393
409
|
This prompt is also the run's **heartbeat**: a worker stuck on a usage limit
|
|
@@ -463,13 +479,15 @@ points of this skill:
|
|
|
463
479
|
then behind — B2 back-merges it inside its worktree (`git -C <WT> merge
|
|
464
480
|
<main>`) with the A5 conflict table, commits with the hook only, and comes
|
|
465
481
|
back. That is this session's job now, not the worker's.
|
|
466
|
-
- **Conflicts and collisions — resolve, don't stop:** roadmap
|
|
467
|
-
|
|
482
|
+
- **Conflicts and collisions — resolve, don't stop:** `roadmap.md` →
|
|
483
|
+
`<main>` (branches never edit it; only with `cloudState: "branch"`: the
|
|
484
|
+
merged change's row → branch, other rows → `<main>`); `lessons.md` → renumber to the next free
|
|
468
485
|
(`wt-status.sh`) and fix references; migration number clash → `<main>`
|
|
469
486
|
keeps its number, regenerate yours (`migrations.regenerate`) and restore
|
|
470
487
|
hand edits (A5); code → on the merits, then run the tests of the touched
|
|
471
488
|
files.
|
|
472
|
-
**
|
|
489
|
+
**With `cloudState: "branch"`, resolve the roadmap row by row, never hunk by
|
|
490
|
+
hunk.** One conflict hunk
|
|
473
491
|
often spans several adjacent table rows: yours plus a neighbour whose stage
|
|
474
492
|
moved on `<main>` meanwhile. Taking the whole hunk from the branch puts that
|
|
475
493
|
neighbour back to a stale stage. Inside each hunk, pair the lines by row ID:
|
|
@@ -503,7 +521,8 @@ points of this skill:
|
|
|
503
521
|
|
|
504
522
|
One signal, one place: if a check gates the deploy, it goes to the release
|
|
505
523
|
section and the decisions section only points at it. Don't duplicate what
|
|
506
|
-
the worker already wrote there
|
|
524
|
+
the worker already wrote there, nor what `wt-roadmap.py done` took from the
|
|
525
|
+
archived change's `## Roadmap handoff`. **Nothing to report → write nothing** — an
|
|
507
526
|
empty entry is noise in the lists the owner reads before a deploy. Commit
|
|
508
527
|
together with the merge's roadmap fix-up (documents only, own paths).
|
|
509
528
|
|
|
@@ -515,9 +534,10 @@ points of this skill:
|
|
|
515
534
|
`<main>`** are a signal of their own: unless a roadmap row already carries
|
|
516
535
|
them, queue them as a new row and a worker ("does not fix"), with the test
|
|
517
536
|
names and the run URL in its `change.md`.
|
|
518
|
-
- **Roadmap:** after the merge the row must read `done` / `done_code` (
|
|
519
|
-
|
|
520
|
-
|
|
537
|
+
- **Roadmap:** after the merge the row must read `done` / `done_code` (Phase B
|
|
538
|
+
ran `wt-roadmap.py done`; with `cloudState: "branch"` the branch wrote it at
|
|
539
|
+
archive). Check it on `<main>`; if it still says `ready_to_merge`, run
|
|
540
|
+
`python3 <S>/wt-roadmap.py done <change-id>` yourself.
|
|
521
541
|
- **Report** per merge, three lines: merge SHA, conflicts and how resolved,
|
|
522
542
|
what waits for the release.
|
|
523
543
|
|
|
@@ -527,10 +547,16 @@ points of this skill:
|
|
|
527
547
|
point: pick the next item, queue it, launch it, keep the order of `## Order`,
|
|
528
548
|
without asking.
|
|
529
549
|
|
|
530
|
-
After every merge
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
`
|
|
550
|
+
After every merge **and on every status firing**, run M1 again over the whole
|
|
551
|
+
roadmap on `origin/<main>`, not only over the successors of the item that just
|
|
552
|
+
merged: every item that is not done, has no session, and whose prerequisites
|
|
553
|
+
are all `done` / `done_code` on `<main>` (or has none) is eligible now, not
|
|
554
|
+
after the whole batch. An item with no prerequisites is never "unblocked by a
|
|
555
|
+
merge", so a refill that looks only at the merged item never starts it.
|
|
556
|
+
`python3 <S>/wt-startable.py` prints the set (`START` rows; `WAIT` rows name
|
|
557
|
+
the missing prerequisites, which is what the report's `waiting for <IDs>`
|
|
558
|
+
shows). Queue (M2), launch (M3), add them to the watch (re-arm the Monitor
|
|
559
|
+
with the new ID list — `TaskStop` the old one first).
|
|
534
560
|
|
|
535
561
|
### M7 — Done
|
|
536
562
|
|
|
@@ -34,12 +34,18 @@ Roadmap report for <roadmap name> (SOFTURE workflow, AGENTS.md → Operating mod
|
|
|
34
34
|
If several firings queued up while busy, do one.
|
|
35
35
|
- Running as the coordinator: post the roadmap report in the main chat in the standard shape
|
|
36
36
|
(title, "X of N on <main>", the four-column table of the items not done yet, Decision, times),
|
|
37
|
-
in chatLanguage, times in timezone.
|
|
38
|
-
|
|
37
|
+
in chatLanguage, times in timezone. Before posting, run the heartbeat: recompute the startable set
|
|
38
|
+
from roadmap.md on origin/<main> (softure-worktree/scripts/wt-startable.py; never only the
|
|
39
|
+
successors of the last merge) and start a thread for every item that is not done, has no thread
|
|
40
|
+
and has all prerequisites on <main> or none; give the go to every READY thread; nudge every
|
|
41
|
+
thread whose go has produced no merge SHA for 30 minutes and every working thread silent for
|
|
42
|
+
45 minutes or more. Stage "waiting for <IDs>" names the prerequisite IDs not on <main> yet.
|
|
43
|
+
Nothing moved: one line.
|
|
39
44
|
- Running in a session of its own: read <owner/repo> on the main branch (context/foundation/roadmap.md,
|
|
40
|
-
open pull requests and their checks
|
|
41
|
-
facts in one message ("Report due <HH:MM>: X of
|
|
42
|
-
|
|
45
|
+
open pull requests and their checks; the startable set from wt-startable.py), send the
|
|
46
|
+
coordinator's session <coordinator session id> the facts in one message ("Report due <HH:MM>: X of
|
|
47
|
+
N on <main>; startable: <IDs>; <ID> <stage> (PR #N, checks); ...") and ask it to post the report
|
|
48
|
+
and run its heartbeat. Then end this session. Change nothing in
|
|
43
49
|
the repository.
|
|
44
50
|
```
|
|
45
51
|
|