@softure-ai/skills 0.18.0 → 0.20.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.
@@ -0,0 +1,435 @@
1
+ #!/usr/bin/env python3
2
+ """Run evidence (screenshots, frame grabs, recordings) kept outside git (WORKFLOW.md §11).
3
+
4
+ evidence.py name --change <id> --nn <N> --what <slug> --state before|after --width <px> --theme light|dark
5
+ evidence.py save <file> --change <id> --what <slug> --state before|after --width <px> --theme light|dark [--nn <N>]
6
+ evidence.py list --change <id>
7
+ evidence.py render --out <page.html> [--from-dir <dir>] [--from-page <page.html>] [--add <key>=<url> ...] [--title <text>]
8
+ evidence.py check <path> [<path> ...]
9
+ evidence.py prune --months <N> [--apply]
10
+
11
+ Names follow `<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.<ext>`. Images are stored as
12
+ WebP at quality 85; PNG only when a side exceeds the WebP limit (16383 px) or no WebP encoder exists.
13
+ Recordings keep their format.
14
+
15
+ The store comes from `context/workflow.json` -> `evidence`:
16
+ {"store": "dir", "path": "~/softure-evidence/<repo>"} a folder outside the repository
17
+ {"store": "project-files", "path": "<project-slug>/evidence"} the hosted project's shared files
18
+ (root: `projectFilesRoot`, default /mnt/project-files)
19
+ {"store": "command", "upload": "<cmd with {file} and {key}>"} object storage behind a project command;
20
+ the last stdout line is the link
21
+ {"store": "artifact", "url": "<evidence page>"} the asset store of one evidence page;
22
+ the agent uploads with its artifact tool
23
+ No store: the file is kept in ~/.cache/softure-evidence/<repo>/ and reported as not durable.
24
+
25
+ Exit codes: 0 ok, 1 check found binaries / a command failed, 2 usage or configuration error.
26
+ """
27
+ from __future__ import annotations
28
+
29
+ import argparse
30
+ import datetime as dt
31
+ import html
32
+ import json
33
+ import os
34
+ import re
35
+ import shlex
36
+ import shutil
37
+ import subprocess
38
+ import sys
39
+ import tempfile
40
+
41
+ CONFIG_PATH = os.path.join("context", "workflow.json")
42
+ STORES = ("dir", "project-files", "command", "artifact")
43
+ DEFAULT_PROJECT_FILES_ROOT = "/mnt/project-files"
44
+ WEBP_MAX_SIDE = 16383
45
+ WEBP_QUALITY = 85
46
+ IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif", ".bmp", ".tif", ".tiff", ".heic"}
47
+ VIDEO_EXTENSIONS = {".mp4", ".mov", ".webm", ".mkv", ".avi", ".m4v"}
48
+ BINARY_EXTENSIONS = IMAGE_EXTENSIONS | VIDEO_EXTENSIONS
49
+ CHANGE_ID = r"[a-z0-9]+(?:-[a-z0-9]+)*"
50
+ SLUG = r"[a-z0-9]+(?:-[a-z0-9]+)*"
51
+ KEY_RE = re.compile(
52
+ rf"^(?P<change>{CHANGE_ID})/(?P<nn>\d{{2,}})-(?P<what>{SLUG})-(?P<state>before|after)"
53
+ rf"-(?P<width>\d+)-(?P<theme>light|dark)\.(?P<ext>[a-z0-9]+)$"
54
+ )
55
+ DATA_BLOCK_RE = re.compile(
56
+ r'<script type="application/json" id="evidence-data">(?P<data>.*?)</script>', re.DOTALL
57
+ )
58
+
59
+
60
+ def fail(message: str, code: int = 2) -> None:
61
+ print(f"evidence: {message}", file=sys.stderr)
62
+ sys.exit(code)
63
+
64
+
65
+ def repo_root() -> str:
66
+ result = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True)
67
+ return result.stdout.strip() if result.returncode == 0 else os.getcwd()
68
+
69
+
70
+ def load_evidence_config(root: str) -> dict:
71
+ path = os.path.join(root, CONFIG_PATH)
72
+ if not os.path.exists(path):
73
+ return {}
74
+ try:
75
+ with open(path, encoding="utf-8") as fh:
76
+ config = json.load(fh)
77
+ except json.JSONDecodeError as error:
78
+ fail(f"cannot parse {CONFIG_PATH}: {error}")
79
+ evidence = config.get("evidence") if isinstance(config, dict) else None
80
+ if evidence is None:
81
+ return {}
82
+ if not isinstance(evidence, dict):
83
+ fail(f"{CONFIG_PATH}: evidence must be an object")
84
+ store = evidence.get("store")
85
+ if store is not None and store not in STORES:
86
+ fail(f"{CONFIG_PATH}: unknown evidence.store {store!r} (known: {', '.join(STORES)})")
87
+ return evidence
88
+
89
+
90
+ def store_dir(evidence: dict) -> str | None:
91
+ """Folder of a file-based store, or None for the other stores."""
92
+ store = evidence.get("store")
93
+ if store == "dir":
94
+ if not evidence.get("path"):
95
+ fail("evidence.store is 'dir' but evidence.path is missing")
96
+ return os.path.abspath(os.path.expanduser(evidence["path"]))
97
+ if store == "project-files":
98
+ if not evidence.get("path"):
99
+ fail("evidence.store is 'project-files' but evidence.path is missing")
100
+ root = os.environ.get("SOFTURE_PROJECT_FILES") or evidence.get("projectFilesRoot") or DEFAULT_PROJECT_FILES_ROOT
101
+ return os.path.join(root, evidence["path"])
102
+ return None
103
+
104
+
105
+ def fallback_dir(root: str) -> str:
106
+ return os.path.join(os.path.expanduser("~"), ".cache", "softure-evidence", os.path.basename(root))
107
+
108
+
109
+ def build_key(change: str, nn: int, what: str, state: str, width: int, theme: str, ext: str) -> str:
110
+ key = f"{change}/{nn:02d}-{what}-{state}-{width}-{theme}.{ext}"
111
+ if not KEY_RE.match(key) or len(change) > 40:
112
+ fail(f"invalid evidence name {key!r}: change-id and what are lowercase kebab-case, "
113
+ "state is before|after, theme is light|dark, width is a number")
114
+ return key
115
+
116
+
117
+ def parse_key(key: str) -> dict | None:
118
+ match = KEY_RE.match(key)
119
+ return match.groupdict() if match else None
120
+
121
+
122
+ def next_number(folder: str | None, change: str) -> int:
123
+ if folder is None:
124
+ return 1
125
+ numbers = [int(parsed["nn"]) for parsed in (parse_key(f"{change}/{name}") for name in list_names(folder, change)) if parsed]
126
+ return max(numbers, default=0) + 1
127
+
128
+
129
+ def list_names(folder: str, change: str) -> list[str]:
130
+ path = os.path.join(folder, change)
131
+ if not os.path.isdir(path):
132
+ return []
133
+ return sorted(name for name in os.listdir(path) if os.path.isfile(os.path.join(path, name)))
134
+
135
+
136
+ def convert(source: str, target_stem: str) -> tuple[str, str | None]:
137
+ """Write the stored form of `source` next to `target_stem`; return (path, warning)."""
138
+ ext = os.path.splitext(source)[1].lower()
139
+ if ext in VIDEO_EXTENSIONS or ext == ".webp":
140
+ target = target_stem + ext
141
+ shutil.copyfile(source, target)
142
+ return target, None
143
+ if ext not in IMAGE_EXTENSIONS:
144
+ fail(f"{source}: not an image or a recording ({', '.join(sorted(BINARY_EXTENSIONS))})")
145
+ try:
146
+ from PIL import Image # type: ignore
147
+ except ImportError:
148
+ Image = None
149
+ if Image is not None:
150
+ with Image.open(source) as image:
151
+ if max(image.size) > WEBP_MAX_SIDE:
152
+ target = target_stem + ".png"
153
+ image.save(target, "PNG", optimize=True)
154
+ return target, f"kept PNG: {image.size[0]}x{image.size[1]} exceeds the WebP limit of {WEBP_MAX_SIDE} px"
155
+ target = target_stem + ".webp"
156
+ image.save(target, "WEBP", quality=WEBP_QUALITY, method=6)
157
+ return target, None
158
+ if shutil.which("cwebp"):
159
+ target = target_stem + ".webp"
160
+ result = subprocess.run(["cwebp", "-quiet", "-q", str(WEBP_QUALITY), source, "-o", target], capture_output=True, text=True)
161
+ if result.returncode == 0:
162
+ return target, None
163
+ target = target_stem + ext
164
+ shutil.copyfile(source, target)
165
+ return target, f"kept {ext[1:].upper()}: no WebP encoder (install Pillow or cwebp)"
166
+
167
+
168
+ def command_save(args: argparse.Namespace) -> None:
169
+ if not os.path.isfile(args.file):
170
+ fail(f"{args.file}: no such file")
171
+ root = repo_root()
172
+ evidence = load_evidence_config(root)
173
+ store = evidence.get("store")
174
+ folder = store_dir(evidence)
175
+ nn = args.nn if args.nn is not None else next_number(folder or fallback_dir(root), args.change)
176
+ build_key(args.change, nn, args.what, args.state, args.width, args.theme, "png") # validate early
177
+ with tempfile.TemporaryDirectory() as scratch:
178
+ stem = os.path.join(scratch, f"{nn:02d}-{args.what}-{args.state}-{args.width}-{args.theme}")
179
+ converted, warning = convert(args.file, stem)
180
+ ext = os.path.splitext(converted)[1][1:]
181
+ key = build_key(args.change, nn, args.what, args.state, args.width, args.theme, ext)
182
+ result: dict = {"key": key, "store": store, "link": None, "durable": True}
183
+ if warning:
184
+ result["warning"] = warning
185
+ if store in ("dir", "project-files"):
186
+ target = os.path.join(folder, key)
187
+ os.makedirs(os.path.dirname(target), exist_ok=True)
188
+ shutil.copyfile(converted, target)
189
+ result["file"] = target
190
+ result["link"] = target if store == "dir" else f"{evidence['path'].rstrip('/')}/{key}"
191
+ page = os.path.join(folder, "index.html")
192
+ with open(page, "w", encoding="utf-8") as fh:
193
+ fh.write(render_page(entries_from_dir(folder), f"Evidence: {os.path.basename(root)}"))
194
+ result["page"] = page
195
+ elif store == "command":
196
+ template = evidence.get("upload")
197
+ if not template:
198
+ fail("evidence.store is 'command' but evidence.upload is missing")
199
+ command = template.replace("{file}", shlex.quote(converted)).replace("{key}", shlex.quote(key))
200
+ run = subprocess.run(command, shell=True, capture_output=True, text=True)
201
+ if run.returncode != 0:
202
+ fail(f"upload failed ({run.returncode}): {run.stderr.strip() or run.stdout.strip()}", 1)
203
+ lines = [line.strip() for line in run.stdout.splitlines() if line.strip()]
204
+ result["link"] = lines[-1] if lines else None
205
+ else:
206
+ keep = os.path.join(fallback_dir(root), key)
207
+ os.makedirs(os.path.dirname(keep), exist_ok=True)
208
+ shutil.copyfile(converted, keep)
209
+ result["file"] = keep
210
+ if store == "artifact":
211
+ if not evidence.get("url"):
212
+ fail("evidence.store is 'artifact' but evidence.url is missing")
213
+ result["next"] = (f"upload {keep} to the asset store of {evidence['url']}, then add it to the page: "
214
+ f"evidence.py render --from-page <page> --add {key}=<asset url> --out <page>")
215
+ else:
216
+ result["durable"] = False
217
+ result["next"] = "no evidence.store in context/workflow.json: this copy is lost with the machine; set one (softure-init)"
218
+ print(json.dumps(result))
219
+
220
+
221
+ def command_name(args: argparse.Namespace) -> None:
222
+ print(build_key(args.change, args.nn, args.what, args.state, args.width, args.theme, args.ext))
223
+
224
+
225
+ def command_list(args: argparse.Namespace) -> None:
226
+ evidence = load_evidence_config(repo_root())
227
+ folder = store_dir(evidence)
228
+ if folder is None:
229
+ store = evidence.get("store")
230
+ if store == "artifact":
231
+ print(f"evidence lives on the page {evidence.get('url')}: read it with the artifact tool")
232
+ elif store == "command":
233
+ print("evidence lives in the command store: list it with the store's own tools")
234
+ else:
235
+ print("no evidence.store configured")
236
+ return
237
+ for name in list_names(folder, args.change):
238
+ print(f"{args.change}/{name}")
239
+
240
+
241
+ def entries_from_dir(folder: str) -> list[dict]:
242
+ entries = []
243
+ if not os.path.isdir(folder):
244
+ return entries
245
+ for change in sorted(os.listdir(folder)):
246
+ for name in list_names(folder, change):
247
+ key = f"{change}/{name}"
248
+ if parse_key(key) is None:
249
+ continue
250
+ mtime = os.path.getmtime(os.path.join(folder, change, name))
251
+ entries.append({"key": key, "url": key,
252
+ "saved": dt.datetime.fromtimestamp(mtime, dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")})
253
+ return entries
254
+
255
+
256
+ def entries_from_page(page: str) -> list[dict]:
257
+ with open(page, encoding="utf-8") as fh:
258
+ match = DATA_BLOCK_RE.search(fh.read())
259
+ if not match:
260
+ fail(f"{page}: no evidence-data block (not a page made by evidence.py render)")
261
+ data = json.loads(html.unescape(match.group("data")))
262
+ return data.get("entries", [])
263
+
264
+
265
+ def render_page(entries: list[dict], title: str) -> str:
266
+ by_change: dict[str, list[dict]] = {}
267
+ for entry in entries:
268
+ parsed = parse_key(entry["key"])
269
+ if parsed:
270
+ by_change.setdefault(parsed["change"], []).append({**entry, **parsed})
271
+ changes = sorted(by_change, key=lambda change: max(item.get("saved", "") for item in by_change[change]), reverse=True)
272
+ sections = []
273
+ for change in changes:
274
+ rows: dict[tuple, dict] = {}
275
+ for item in by_change[change]:
276
+ row = rows.setdefault((item["what"], item["width"], item["theme"]), {"nn": int(item["nn"])})
277
+ row["nn"] = min(row["nn"], int(item["nn"]))
278
+ row[item["state"]] = item
279
+ cells = []
280
+ for (what, width, theme), row in sorted(rows.items(), key=lambda pair: pair[1]["nn"]):
281
+ pair = []
282
+ for state in ("before", "after"):
283
+ item = row.get(state)
284
+ if item is None:
285
+ pair.append(f'<div class="shot empty"><span>{state}: none</span></div>')
286
+ continue
287
+ url = html.escape(item["url"], quote=True)
288
+ media = (f'<video src="{url}" controls preload="metadata"></video>'
289
+ if f".{item['ext']}" in VIDEO_EXTENSIONS else
290
+ f'<img src="{url}" alt="{html.escape(what)} {state}" loading="lazy">')
291
+ pair.append(f'<a class="shot" href="{url}">{media}<span>{state}</span></a>')
292
+ cells.append(f'<figure><figcaption>{html.escape(what)} · {width} px · {theme}</figcaption>'
293
+ f'<div class="pair">{"".join(pair)}</div></figure>')
294
+ newest = max(item.get("saved", "") for item in by_change[change])[:10]
295
+ sections.append(f'<section><h2>{html.escape(change)} <small>{html.escape(newest)}</small></h2>'
296
+ f'<div class="grid">{"".join(cells)}</div></section>')
297
+ data = html.escape(json.dumps({"entries": sorted(entries, key=lambda entry: entry["key"])}, indent=1), quote=False)
298
+ body = "".join(sections) or "<p>No evidence yet.</p>"
299
+ return f"""<!doctype html>
300
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
301
+ <title>{html.escape(title)}</title>
302
+ <style>
303
+ :root {{ --bg: #ffffff; --fg: #1d1d1f; --muted: #6e6e73; --line: #e2e2e7; --card: #f6f6f8; }}
304
+ @media (prefers-color-scheme: dark) {{ :root:not([data-theme="light"]) {{ --bg: #141416; --fg: #f2f2f4; --muted: #9a9aa2; --line: #2c2c31; --card: #1d1d21; }} }}
305
+ :root[data-theme="dark"] {{ --bg: #141416; --fg: #f2f2f4; --muted: #9a9aa2; --line: #2c2c31; --card: #1d1d21; }}
306
+ body {{ margin: 0; padding: 24px 16px; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, sans-serif; }}
307
+ main {{ max-width: 1200px; margin: 0 auto; }}
308
+ h1 {{ font-size: 22px; margin: 0 0 20px; }}
309
+ h2 {{ font-size: 17px; margin: 28px 0 12px; border-top: 1px solid var(--line); padding-top: 16px; }}
310
+ small, figcaption, .shot span {{ color: var(--muted); font-size: 13px; font-weight: normal; }}
311
+ .grid {{ display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }}
312
+ figure {{ margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }}
313
+ .pair {{ display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }}
314
+ .shot {{ display: flex; flex-direction: column; gap: 4px; text-decoration: none; }}
315
+ .shot img, .shot video {{ width: 100%; height: 220px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); }}
316
+ .empty {{ justify-content: center; align-items: center; min-height: 120px; border: 1px dashed var(--line); border-radius: 6px; }}
317
+ </style></head>
318
+ <body><main><h1>{html.escape(title)}</h1>{body}</main>
319
+ <script type="application/json" id="evidence-data">{data}</script>
320
+ </body></html>
321
+ """
322
+
323
+
324
+ def command_render(args: argparse.Namespace) -> None:
325
+ entries: dict[str, dict] = {}
326
+ if args.from_page and os.path.exists(args.from_page):
327
+ entries.update({entry["key"]: entry for entry in entries_from_page(args.from_page)})
328
+ if args.from_dir:
329
+ entries.update({entry["key"]: entry for entry in entries_from_dir(args.from_dir)})
330
+ now = dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
331
+ for pair in args.add or []:
332
+ key, sep, url = pair.partition("=")
333
+ if not sep or parse_key(key) is None:
334
+ fail(f"--add {pair!r}: expected <change-id>/<NN>-<what>-<state>-<width>-<theme>.<ext>=<url>")
335
+ entries[key] = {"key": key, "url": url, "saved": entries.get(key, {}).get("saved", now)}
336
+ with open(args.out, "w", encoding="utf-8") as fh:
337
+ fh.write(render_page(list(entries.values()), args.title))
338
+ print(f"{args.out}: {len(entries)} files")
339
+
340
+
341
+ def command_check(args: argparse.Namespace) -> None:
342
+ hits = []
343
+ for path in args.paths:
344
+ if os.path.isfile(path):
345
+ candidates = [path]
346
+ else:
347
+ candidates = [os.path.join(base, name) for base, _, names in os.walk(path) for name in names]
348
+ hits.extend(sorted(item for item in candidates if os.path.splitext(item)[1].lower() in BINARY_EXTENSIONS))
349
+ if hits:
350
+ for hit in hits:
351
+ print(f"binary evidence in the repository: {hit}")
352
+ print("move each file to the evidence store (evidence.py save), link it from ## Progress, and delete it here")
353
+ sys.exit(1)
354
+ print("no images or recordings")
355
+
356
+
357
+ def archived_on(root: str, change: str) -> dt.date | None:
358
+ archive = os.path.join(root, "context", "archive")
359
+ if not os.path.isdir(archive):
360
+ return None
361
+ for name in os.listdir(archive):
362
+ if re.fullmatch(rf"\d{{4}}-\d{{2}}-\d{{2}}-{re.escape(change)}", name):
363
+ path = os.path.join(archive, name, "change.md")
364
+ if os.path.exists(path):
365
+ with open(path, encoding="utf-8") as fh:
366
+ match = re.search(r"^archived_at:\s*(\d{4}-\d{2}-\d{2})", fh.read(), re.MULTILINE)
367
+ if match:
368
+ return dt.date.fromisoformat(match.group(1))
369
+ return None
370
+
371
+
372
+ def command_prune(args: argparse.Namespace) -> None:
373
+ root = repo_root()
374
+ evidence = load_evidence_config(root)
375
+ folder = store_dir(evidence)
376
+ if folder is None:
377
+ fail("prune works on the 'dir' and 'project-files' stores; prune other stores with their own tools")
378
+ today = dt.date.fromisoformat(args.today) if args.today else dt.date.today()
379
+ cutoff_month = today.year * 12 + today.month - args.months
380
+ pruned = 0
381
+ for change in sorted(os.listdir(folder)) if os.path.isdir(folder) else []:
382
+ if not os.path.isdir(os.path.join(folder, change)):
383
+ continue
384
+ archived = archived_on(root, change)
385
+ if archived is None or archived.year * 12 + archived.month > cutoff_month:
386
+ continue
387
+ pruned += 1
388
+ if args.apply:
389
+ shutil.rmtree(os.path.join(folder, change))
390
+ print(f"pruned {change} (archived {archived})")
391
+ else:
392
+ print(f"would prune {change} (archived {archived})")
393
+ if not args.apply and pruned:
394
+ print("dry run: add --apply to delete")
395
+
396
+
397
+ def add_name_arguments(parser: argparse.ArgumentParser, nn_required: bool) -> None:
398
+ parser.add_argument("--change", required=True)
399
+ parser.add_argument("--nn", type=int, required=nn_required)
400
+ parser.add_argument("--what", required=True)
401
+ parser.add_argument("--state", required=True, choices=("before", "after"))
402
+ parser.add_argument("--width", required=True, type=int)
403
+ parser.add_argument("--theme", required=True, choices=("light", "dark"))
404
+
405
+
406
+ def main() -> None:
407
+ parser = argparse.ArgumentParser(description="Run evidence kept outside git (WORKFLOW.md §11)")
408
+ commands = parser.add_subparsers(dest="command", required=True)
409
+ name = commands.add_parser("name", help="print the canonical name")
410
+ add_name_arguments(name, nn_required=True)
411
+ name.add_argument("--ext", default="webp")
412
+ save = commands.add_parser("save", help="convert and store one file")
413
+ save.add_argument("file")
414
+ add_name_arguments(save, nn_required=False)
415
+ listing = commands.add_parser("list", help="list a change's stored files")
416
+ listing.add_argument("--change", required=True)
417
+ render = commands.add_parser("render", help="write the evidence page")
418
+ render.add_argument("--out", required=True)
419
+ render.add_argument("--from-dir")
420
+ render.add_argument("--from-page")
421
+ render.add_argument("--add", action="append")
422
+ render.add_argument("--title", default="Evidence")
423
+ check = commands.add_parser("check", help="fail on images or recordings under the paths")
424
+ check.add_argument("paths", nargs="+")
425
+ prune = commands.add_parser("prune", help="delete evidence of changes archived N months ago or earlier")
426
+ prune.add_argument("--months", required=True, type=int)
427
+ prune.add_argument("--apply", action="store_true")
428
+ prune.add_argument("--today", help=argparse.SUPPRESS)
429
+ args = parser.parse_args()
430
+ {"name": command_name, "save": command_save, "list": command_list, "render": command_render,
431
+ "check": command_check, "prune": command_prune}[args.command](args)
432
+
433
+
434
+ if __name__ == "__main__":
435
+ main()
@@ -71,9 +71,12 @@ Read when needed:
71
71
  2. **Audit Progress honesty.** For every `- [x]`, find the evidence: a test name, a file, a
72
72
  command output, a screenshot. Re-run the gates (`gates.*`) and every Automated criterion that
73
73
  names a command; do not trust earlier runs. A ticked box without evidence is **CRITICAL**.
74
- `(verified by agent: …)` must point at something that exists. Open Manual items are pending,
75
- not findings, except in `--auto`: there an open Manual item without `(owner only: <reason>)` is
76
- a WARNING (the run could verify it), decided `fix now` by running its evidence and ticking it
74
+ `(verified by agent: …)` must point at something that exists; a visual claim (screenshot,
75
+ frame grab, recording) must link files in the evidence store (WORKFLOW §11) that open. A visual
76
+ claim with no link, or an image or recording added to the repository (visual-regression
77
+ baselines excepted), is a WARNING, fixed by saving the file with `softure-evidence` and linking
78
+ it. Open Manual items are pending, not findings, except in `--auto`: there an open Manual item
79
+ without `(owner only: <reason>)` is a WARNING (the run could verify it), decided `fix now` by running its evidence and ticking it
77
80
  through `softure-implement`'s notation.
78
81
  3. **Check drift.** Everything the code does that the plan did not ask for, everything the plan
79
82
  asked for that the code does not do. Intentional drift must be explained in plan.md
@@ -110,7 +110,10 @@ mandatory; stop with an error.
110
110
  rendered UI.
111
111
  - Manual items: first try to verify them yourself where a machine can stand in for the eye:
112
112
  screenshots at the stated widths and themes, a recorded request/response, a DB read. Tick
113
- such an item with `(verified by agent: <how>)`. Anything that needs the owner's judgement
113
+ such an item with `(verified by agent: <how>)`. Visual evidence is saved with
114
+ `softure-evidence` (named `<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.webp`, stored
115
+ outside git) and its links go into the tick: `(verified by agent: <how> → <result>; <link>)`.
116
+ Take screenshots into a scratch folder outside the repository, never into the change folder. Anything that needs the owner's judgement
114
117
  stays `- [ ]`. `--auto`: every `(evidence: …)` Manual item is verified by running that
115
118
  evidence; only `(owner only: <reason>)` items stay open (see `## --auto`).
116
119
 
@@ -198,7 +201,8 @@ steps 7 to 9:
198
201
  - **Verify the Manual items yourself.** Run the evidence each Manual item names (test, script,
199
202
  local render, screenshot or frame grab you look at, pipeline run and health check, CI logs,
200
203
  `ffprobe` or schema check) and tick it with
201
- ` — <sha> (verified by agent: <command> → <result>[, <link>])`. Never leave an `(evidence: …)`
204
+ ` — <sha> (verified by agent: <command> → <result>[, <link>])`; a screenshot or recording is
205
+ saved with `softure-evidence` first and the link is its stored file. Never leave an `(evidence: …)`
202
206
  item open for the owner: a check that fails is a defect to fix in the phase; evidence that cannot
203
207
  be produced in this environment is an escalation naming why, not an owner check. Only
204
208
  `(owner only: <reason>)` items stay `- [ ]`. A Manual item with neither annotation (an older
@@ -213,6 +217,7 @@ steps 7 to 9:
213
217
  ## Quality checklist
214
218
 
215
219
  - [ ] Every ticked box was actually checked in this session, by command, query or screenshot.
220
+ - [ ] Every screenshot or recording behind a tick is in the evidence store and linked; none is in the diff.
216
221
  - [ ] Gates are green at every phase commit.
217
222
  - [ ] The diff follows the language rule in AGENTS.md (when the project carries one).
218
223
  - [ ] There is one commit per phase with the WORKFLOW §9 message, and nothing unrelated is staged.
@@ -234,6 +239,8 @@ steps 7 to 9:
234
239
  - Amending after a failed hook: the failed commit never happened, so `--amend` rewrites the
235
240
  previous phase.
236
241
  - Handing every manual item to the user when a screenshot or a query would have settled it.
242
+ - Saving screenshots into `context/changes/<id>/` (they end up in git) or into an ignored folder of a
243
+ cloud container (they vanish with it) instead of the evidence store.
237
244
 
238
245
  ## Handoff
239
246
 
@@ -39,7 +39,8 @@ Passed automatically:
39
39
  - 2.4 Gates green: typecheck, lint, test (412 tests)
40
40
 
41
41
  Verified by me:
42
- - 2.5 email renders in light and dark mail themes (screenshots in reviews/p2-email-*.png)
42
+ - 2.5 email renders in light and dark mail themes (evidence: reminder-email/01-reminder-email-after-600-light.webp,
43
+ reminder-email/02-reminder-email-after-600-dark.webp)
43
44
 
44
45
  Please check:
45
46
  - 2.6 the reminder wording reads naturally to a customer (preview: GET /dev/mail/reminder)
@@ -181,8 +182,8 @@ For every item ticked in this phase that has no suffix yet:
181
182
  ```
182
183
  - [x] 2.1 reminder job selects bookings starting in 23-25 h
183
184
  → - [x] 2.1 reminder job selects bookings starting in 23-25 h — 7c41e0b
184
- - [x] 2.5 email renders in light and dark mail themes (verified by agent: screenshots in reviews/)
185
- → - [x] 2.5 email renders in light and dark mail themes — 7c41e0b (verified by agent: screenshots in reviews/)
185
+ - [x] 2.5 email renders in light and dark mail themes (verified by agent: mail preview → both themes legible; <link>, <link>)
186
+ → - [x] 2.5 email renders in light and dark mail themes — 7c41e0b (verified by agent: mail preview → both themes legible; <link>, <link>)
186
187
  ```
187
188
 
188
189
  Skip items that already carry a SHA; a re-entered sequence must not append twice. Dropped items
@@ -106,8 +106,10 @@ first". The user continues.
106
106
 
107
107
  Test-after: the button and its component tests first, then 2.1 and 2.2 pass and the gates are
108
108
  green. For 2.4 the skill starts the dev server, opens a booking 20 hours out at 390 px in both
109
- themes, takes two screenshots into `reviews/`, and looks at them: the button is greyed out and
110
- the cursor is not a pointer. 2.4 is ticked `(verified by agent: screenshots in reviews/p2-*.png)`.
109
+ themes, takes two screenshots into a scratch folder, and looks at them: the button is greyed out
110
+ and the cursor is not a pointer. `softure-evidence save` stores them as
111
+ `cancellation-window/01-cancel-button-disabled-after-390-light.webp` and `…-390-dark.webp`, and 2.4
112
+ is ticked with their links.
111
113
  2.5 is a judgement about wording, so the gate opens:
112
114
 
113
115
  ```
@@ -175,7 +177,7 @@ Re-scan: no open Automated item; open Manual item 1.4. The skill writes `a61c07e
175
177
  - [x] 2.3 Gates green (typecheck, lint, test) — a61c07e
176
178
 
177
179
  #### Manual
178
- - [x] 2.4 Disabled state is visibly disabled in light and dark themes at 390 px — a61c07e (verified by agent: screenshots in reviews/p2-*.png)
180
+ - [x] 2.4 Disabled state is visibly disabled in light and dark themes at 390 px — a61c07e (verified by agent: dev server, booking 20 h out → greyed out, no pointer; evidence/cancellation-window/01-cancel-button-disabled-after-390-light.webp, evidence/cancellation-window/02-cancel-button-disabled-after-390-dark.webp)
179
181
  - [x] 2.5 The reason text is clear to a customer — a61c07e
180
182
  ```
181
183
 
@@ -37,7 +37,7 @@ start any work: no change, PRD or roadmap is created here.
37
37
 
38
38
  1. **Inventory what exists.** List `context/` recursively, if present. Record each file that
39
39
  already exists. You will not touch these, apart from adding missing keys to
40
- `workflow.json` (step 6). Unknown keys in an existing `workflow.json` are kept as they are.
40
+ `workflow.json` (step 7). Unknown keys in an existing `workflow.json` are kept as they are.
41
41
  2. **Detect the stack.** Read these, and only these, to fill the config:
42
42
  - `package.json` -> `scripts`. Map the gates:
43
43
  - typecheck: the script that runs `tsc`, otherwise `npx tsc --noEmit` when `tsconfig.json` exists.
@@ -78,7 +78,19 @@ start any work: no change, PRD or roadmap is created here.
78
78
  question: "Create this? (Recommended: yes)". Offer the options yes / edit a value / cancel.
79
79
  Name applicable optional keys (below) in one line, without asking about each. `--auto`
80
80
  skips the question; `--dry-run` stops here in both modes.
81
- 6. **Write only what is missing:**
81
+ 6. **Pick the evidence store** (WORKFLOW §11). Use an existing `evidence` key as is. Otherwise
82
+ propose one, recommended by where sessions run: a hosted cloud project with an artifact tool →
83
+ `artifact` (create one private evidence page, `"Evidence: <repo>"`, with
84
+ `softure-evidence/scripts/evidence.py render --out <page.html>`, publish it and write its url);
85
+ a session that can write the hosted project's shared files → `project-files` with
86
+ `path: "<project-slug>/evidence"`; local runs only → `dir` with `path: "~/softure-evidence/<repo>"`;
87
+ object storage the owner already runs → `command` with the owner's upload script. Interactive:
88
+ ask once with that recommendation. `--auto`: write `artifact` when the page could be created,
89
+ `project-files` when the shared files are writable, otherwise nothing and list it as an
90
+ unresolved value. Then the project files (§11.1): when the shared files are reachable and
91
+ `<project-slug>/INDEX.md` is missing, write it from `references/templates.md`; otherwise print
92
+ the template in the report.
93
+ 7. **Write only what is missing:**
82
94
  - `context/workflow.json`: new file, or only the missing keys merged into an existing one.
83
95
  Never change an existing value.
84
96
  - `context/foundation/README.md` and an empty `context/foundation/lessons.md` (`# Lessons` +
@@ -87,11 +99,11 @@ start any work: no change, PRD or roadmap is created here.
87
99
  (templates in `references/templates.md`).
88
100
  - Do **not** create `shape-notes.md`, `prd.md`, `roadmap.md`, `roadmaps/`, change folders
89
101
  or empty directories. Their skills create them on first use.
90
- 7. **Verify.** Re-read `workflow.json` and check that it parses as JSON. For every gate
102
+ 8. **Verify.** Re-read `workflow.json` and check that it parses as JSON. For every gate
91
103
  command, check that the referenced script exists in `package.json` (or that the binary is
92
104
  on PATH). Mark any gate you could not resolve as `null`, never as a guess. Re-running the
93
105
  detection must now produce no new writes.
94
- 8. **Report** a status block, one line per artifact (`created`, `present` or `merged: <keys>`),
106
+ 9. **Report** a status block, one line per artifact (`created`, `present` or `merged: <keys>`),
95
107
  then the unresolved values the owner should fill in, every inferred value with its reason,
96
108
  and the next step. With `mode: "autonomous"`, end it with the project-instructions snippet
97
109
  for hosted projects (WORKFLOW §8.5), `<owner>/<repo>` filled in from `origin`, ready to paste,
@@ -136,6 +148,7 @@ only when it was detected or the user asked for it:
136
148
  | `integration.lookup` | every call starts a run | the project stores results per commit (e.g. a git note) and has a command that prints one |
137
149
  | `integration.coveredByRelease` | `false` | the release pipeline runs the same full suite on the released commit |
138
150
  | `worktree.cloudState` | `"main"` (roadmap state on the main branch, branches never edit `roadmap.md`) | the user runs cloud sessions whose pre-push hook has no cheap path for `context/`-only pushes and wants the state on the branch (`"branch"`) |
151
+ | `evidence` | no store: evidence is kept locally and reported as not durable | step 6 picked a store (the one optional key besides `research.sources` that `--auto` writes) |
139
152
  | `research.sources` | none | step 2 found docs, ADRs or a PRD (interactive: listed in the plan; `--auto`: only paths that exist) |
140
153
  | `install` | gitignore the skills, inject all rule sections | the user wants committed skills or fewer rule sections (the language section always ships; `allowNonEnglishCode: true` only on the owner's explicit word) |
141
154
  | `autonomy` | roadmap as the work source, merge via pull request, `<main>` merged into a branch only when needed (`remergeMain: "when-needed"`; `"on-conflict"` when the main branch takes a migration or a dependency change on nearly every merge and the owner accepts testing the merged result on main and in the release gate; add `relatedTests`, e.g. `npx vitest related --run {files}`, when the test runner has one), reports every 60 min around the clock (`reports.every`, `reports.hours: null`; routines fire at most hourly; the routine is also the run's heartbeat, so keep it 24/7) | `mode` is `autonomous` and the user names issues as the queue, merges by push, or another report cadence |
@@ -150,7 +163,7 @@ fictional repo: read `references/templates.md` **when writing the READMEs** and
150
163
 
151
164
  Detect, write and report without asking. Record every value you inferred (rather than read
152
165
  directly) in the report, e.g. `- mainBranch -> master (origin/HEAD missing; local master exists)`.
153
- Optional keys other than `research.sources` are never written in `--auto`.
166
+ Optional keys other than `research.sources` and `evidence` (step 6) are never written in `--auto`.
154
167
 
155
168
  ## Quality bar
156
169
 
@@ -71,3 +71,23 @@ Planned for later, never what is in flight. A topic lives in exactly one place:
71
71
  Numbered rules from real incidents in this repo (`## L-NNN: <rule>` with **Why**, **How to apply**
72
72
  and **Applies to**). Written by softure-lesson; read by research, frame, plan, implement and the reviews.
73
73
  ```
74
+
75
+ ## `<project-slug>/INDEX.md` (project files, outside the repository)
76
+
77
+ Written into the hosted project's shared files when they are reachable and the file is missing;
78
+ otherwise printed in the report for the owner (WORKFLOW §11.1).
79
+
80
+ ```markdown
81
+ # <project-slug>: project files
82
+
83
+ Owner material kept outside the repository. The repository references these files by path
84
+ (`project files: <project-slug>/briefs/<file>`) and never copies them. Lowercase kebab-case, a date
85
+ prefix, no version or `-final` suffix; superseded files move to `archive/`.
86
+
87
+ | File | What it is | Who reads it |
88
+ |---|---|---|
89
+ | `briefs/YYYY-MM-DD-<topic>.md` | concept, owner roadmap, private data | softure-shape, softure-roadmap |
90
+ | `data/YYYY-MM-DD-<topic>.<ext>` | export, real seed data, document | the change that needs it |
91
+ | `design/<screen>-<variant>.<ext>` | mock-up, inspiration, brand material | softure-plan, softure-implement |
92
+ | `evidence/` | run evidence (when `evidence.store` is "project-files") | the owner, softure-impl-review |
93
+ ```
@@ -78,7 +78,9 @@ Read the PRD in full, not in excerpts.
78
78
  Then write `## Summary` (`| ID | Item | What changed | Merge |`, the merge SHA from
79
79
  `git log --merges --grep "<change-id>"` on `<main>`, plus the integration line), move the file to
80
80
  `foundation/archive/<YYYY-MM-DD>-roadmap.md`, clean up the promoted roadmap's backlog folder and
81
- index row, and commit. With `integration.coveredByRelease` and "Release: at the end" the close does not
81
+ index row, run step 15 (state and doctor), and commit. A `## Summary` row never holds a placeholder
82
+ ("merge SHA after the PR", "this PR"): the close runs on `<main>` after the merges, so every SHA is
83
+ known; a carried or dropped row has `—`. With `integration.coveredByRelease` and "Release: at the end" the close does not
82
84
  wait for the release: the integration line reads `covered by the release on <sha> (coveredByRelease)`
83
85
  unless a green stored result exists. The archived file is what the release notes read (every release
84
86
  of this roadmap, retries and redeploys included); rows waiting for the release keep `done_code`, so
@@ -241,6 +243,15 @@ Overwriting a roadmap without archiving it is never an option. In `--auto`: revi
241
243
  (`--no-open-changes`, recorded in the handoff); never skip it on your own, not even in `--auto`.
242
244
  `--open-changes` is still accepted and changes nothing.
243
245
 
246
+ 15. **State and doctor, before every commit of this skill** (record, `--revise`, `--queue`,
247
+ `--promote`, `--close`; WORKFLOW §12). Stage the files, run
248
+ `python3 .claude/skills/softure-doctor/scripts/context_state.py write --staged` (it reads the
249
+ index and stages `context/state.json`, so it rides in the same commit), then
250
+ `python3 .claude/skills/softure-doctor/scripts/doctor.py`. Fix what this run owns (the roadmap
251
+ files, their backlog folders and index rows, the `## Summary` SHAs) and re-run; name any other
252
+ failure in the handoff without touching it. In `--close` a failure this run owns blocks the
253
+ commit like a failing gate.
254
+
244
255
  A complete, realistic roadmap in this format, with a bad version and why it fails:
245
256
  [references/example-roadmap.md](references/example-roadmap.md) (read before the first roadmap in a
246
257
  project).