@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.
- package/ONBOARD.md +1 -1
- package/README.md +26 -0
- package/WORKFLOW.md +209 -7
- package/package.json +2 -1
- package/rules/AGENTS.md +33 -1
- package/scripts/install.mjs +67 -1
- package/scripts/portfolio.py +259 -0
- package/skills/softure-archive/SKILL.md +17 -6
- package/skills/softure-doctor/SKILL.md +69 -0
- package/skills/softure-doctor/references/state.schema.json +125 -0
- package/skills/softure-doctor/scripts/context_state.py +578 -0
- package/skills/softure-doctor/scripts/doctor.py +340 -0
- package/skills/softure-evidence/SKILL.md +104 -0
- package/skills/softure-evidence/scripts/evidence.py +435 -0
- package/skills/softure-impl-review/SKILL.md +6 -3
- package/skills/softure-implement/SKILL.md +9 -2
- package/skills/softure-implement/references/phase-commit.md +4 -3
- package/skills/softure-implement/references/worked-example.md +5 -3
- package/skills/softure-init/SKILL.md +18 -5
- package/skills/softure-init/references/templates.md +20 -0
- package/skills/softure-roadmap/SKILL.md +12 -1
- package/skills/softure-worktree/scripts/wt-roadmap.py +66 -5
- package/skills/softure-worktree-manager/SKILL.md +7 -1
- package/skills/softure-worktree-manager/references/report-routine.md +3 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""softure-doctor: check the `context/` contract of a project (WORKFLOW.md §12) and exit non-zero on drift.
|
|
3
|
+
|
|
4
|
+
doctor.py [--root <dir>] [--json]
|
|
5
|
+
npx softure-skills doctor (the same, from the installed package)
|
|
6
|
+
|
|
7
|
+
Adopting projects run it in their CI check, documentation-only changes included (that is where the
|
|
8
|
+
drift happens). `softure-archive` and `softure-roadmap --close` run it before their commit and fix
|
|
9
|
+
what they own. Each problem is one line `FAIL <code> <path>: <what>`; the codes:
|
|
10
|
+
|
|
11
|
+
roadmap-archived-not-removed roadmap.md is still there although the same roadmap is in foundation/archive/
|
|
12
|
+
roadmap-status-mismatch roadmap.md `status` contradicts its rows (done with open rows; waiting)
|
|
13
|
+
archived-change-status an archived change.md whose status is not `archived`
|
|
14
|
+
archived-change-progress an archived plan.md with unticked Automated items in `## Progress`
|
|
15
|
+
archived-roadmap-open-items an archived roadmap with rows that are not done, done_code, dropped or carried
|
|
16
|
+
archived-roadmap-summary an archived roadmap whose `## Summary` merge column holds placeholders, not SHAs
|
|
17
|
+
queued-roadmap-done a queued roadmap in foundation/roadmaps/ whose rows are all done
|
|
18
|
+
backlog-without-roadmap a backlog/roadmap-<slug>/ folder without its queued (or promoted) roadmap
|
|
19
|
+
index-missing-file an index row (README.md / INDEX.md table under context/) links a missing file
|
|
20
|
+
state-missing context/state.json is missing although the project has written it before
|
|
21
|
+
state-stale context/state.json does not match the markdown
|
|
22
|
+
|
|
23
|
+
A project that has never written `context/state.json` (it adopted the package before the file existed)
|
|
24
|
+
gets a note, not a failure: the first run of `wt-roadmap.py`, `softure-archive` or `softure-roadmap`
|
|
25
|
+
creates it. Fix a stale or missing file with `npx softure-skills state` (or
|
|
26
|
+
`python3 .claude/skills/softure-doctor/scripts/context_state.py write`) and commit it.
|
|
27
|
+
|
|
28
|
+
Importable: `from doctor import run_checks` (takes any reader of context_state).
|
|
29
|
+
"""
|
|
30
|
+
from __future__ import annotations
|
|
31
|
+
|
|
32
|
+
import json
|
|
33
|
+
import os
|
|
34
|
+
import re
|
|
35
|
+
import subprocess
|
|
36
|
+
import sys
|
|
37
|
+
|
|
38
|
+
sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/skills
|
|
39
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
40
|
+
from context_state import ( # noqa: E402
|
|
41
|
+
ARCHIVE_ROADMAPS_DIR, CHANGES_DIR, QUEUED_DIR, ROADMAP_PATH, STATE_PATH, FsReader, frontmatter,
|
|
42
|
+
roadmap_rows, sections, staleness,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
ARCHIVE_DIR = "context/archive"
|
|
46
|
+
BACKLOG_DIR = "context/backlog"
|
|
47
|
+
CLOSED_STATUSES = ("done", "done_code", "dropped", "carried")
|
|
48
|
+
SHA_RE = re.compile(r"\b[0-9a-f]{7,40}\b")
|
|
49
|
+
EMPTY_MERGE = {"—", "-", "–", "n/a", "none", "no merge", "not merged"}
|
|
50
|
+
LINK_RE = re.compile(r"\[[^\]]*\]\(([^)\s]+)(?:\s+\"[^\"]*\")?\)")
|
|
51
|
+
INDEX_NAMES = ("README.md", "INDEX.md")
|
|
52
|
+
CODE_PATH_RE = re.compile(r"`((?:\.{1,2}/)?(?:[\w.-]+/)*[\w.-]+\.md|(?:\.{1,2}/)?(?:[\w.-]+/)+)`")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class Finding:
|
|
56
|
+
def __init__(self, code: str, path: str, message: str, severity: str = "fail") -> None:
|
|
57
|
+
self.code, self.path, self.message, self.severity = code, path, message, severity
|
|
58
|
+
|
|
59
|
+
def as_dict(self) -> dict:
|
|
60
|
+
return {"code": self.code, "path": self.path, "message": self.message, "severity": self.severity}
|
|
61
|
+
|
|
62
|
+
def __str__(self) -> str:
|
|
63
|
+
label = "FAIL" if self.severity == "fail" else "note"
|
|
64
|
+
return f"{label} {self.code} {self.path}: {self.message}"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _files(reader, directory: str, pattern: str) -> list[str]:
|
|
68
|
+
return [f"{directory}/{name}" for name, is_dir in reader.listdir(directory)
|
|
69
|
+
if not is_dir and re.match(pattern, name)]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _archived_roadmaps(reader) -> list[str]:
|
|
73
|
+
"""Archived roadmap files: `<date>-roadmap*.md` in foundation/archive/ that carry a roadmap table."""
|
|
74
|
+
paths = _files(reader, ARCHIVE_ROADMAPS_DIR, r"^\d{4}-\d{2}-\d{2}-roadmap.*\.md$")
|
|
75
|
+
return [path for path in paths if roadmap_rows(reader.read(path) or "")]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def check_main_roadmap(reader) -> list[Finding]:
|
|
79
|
+
findings: list[Finding] = []
|
|
80
|
+
text = reader.read(ROADMAP_PATH)
|
|
81
|
+
if text is None:
|
|
82
|
+
return findings
|
|
83
|
+
meta = frontmatter(text)
|
|
84
|
+
slug, version = meta.get("roadmap"), meta.get("version")
|
|
85
|
+
if slug:
|
|
86
|
+
for path in _archived_roadmaps(reader):
|
|
87
|
+
archived = frontmatter(reader.read(path) or "")
|
|
88
|
+
if archived.get("roadmap") == slug and (not version or not archived.get("version")
|
|
89
|
+
or archived.get("version") == version):
|
|
90
|
+
findings.append(Finding("roadmap-archived-not-removed", ROADMAP_PATH,
|
|
91
|
+
f"roadmap `{slug}` is already archived as {path}; remove roadmap.md "
|
|
92
|
+
"(the close moves it, WORKFLOW §5.2)"))
|
|
93
|
+
break
|
|
94
|
+
rows = roadmap_rows(text)
|
|
95
|
+
status = meta.get("status")
|
|
96
|
+
open_rows = [row["id"] for row in rows if row["status"] not in CLOSED_STATUSES]
|
|
97
|
+
if status == "done" and open_rows:
|
|
98
|
+
findings.append(Finding("roadmap-status-mismatch", ROADMAP_PATH,
|
|
99
|
+
f"status is done but rows are open: {', '.join(open_rows)}"))
|
|
100
|
+
if status == "waiting":
|
|
101
|
+
findings.append(Finding("roadmap-status-mismatch", ROADMAP_PATH,
|
|
102
|
+
"status is waiting, which belongs to a queued roadmap; the main roadmap is "
|
|
103
|
+
"draft, ready or done (a promote sets ready)"))
|
|
104
|
+
return findings
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def check_archived_changes(reader) -> list[Finding]:
|
|
108
|
+
findings: list[Finding] = []
|
|
109
|
+
for name, is_dir in reader.listdir(ARCHIVE_DIR):
|
|
110
|
+
if not is_dir:
|
|
111
|
+
continue
|
|
112
|
+
folder = f"{ARCHIVE_DIR}/{name}"
|
|
113
|
+
change = reader.read(f"{folder}/change.md")
|
|
114
|
+
if change is not None:
|
|
115
|
+
status = frontmatter(change).get("status")
|
|
116
|
+
if status != "archived":
|
|
117
|
+
findings.append(Finding("archived-change-status", f"{folder}/change.md",
|
|
118
|
+
f"status is {status or 'missing'}, expected archived"))
|
|
119
|
+
plan = reader.read(f"{folder}/plan.md")
|
|
120
|
+
if plan is not None:
|
|
121
|
+
open_items = unticked_automated(plan)
|
|
122
|
+
if open_items:
|
|
123
|
+
listed = "; ".join(open_items[:3]) + ("; …" if len(open_items) > 3 else "")
|
|
124
|
+
findings.append(Finding("archived-change-progress", f"{folder}/plan.md",
|
|
125
|
+
f"{len(open_items)} unticked Automated item(s) in ## Progress: {listed}"))
|
|
126
|
+
return findings
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def unticked_automated(plan: str) -> list[str]:
|
|
130
|
+
"""Open `- [ ]` items of `## Progress` that are not under a `#### Manual` heading.
|
|
131
|
+
|
|
132
|
+
Open Manual items are legitimate in an archived plan (manual mode carries them to the owner).
|
|
133
|
+
"""
|
|
134
|
+
progress = sections(plan).get("Progress", [])
|
|
135
|
+
open_items = []
|
|
136
|
+
manual = False
|
|
137
|
+
for line in progress:
|
|
138
|
+
if line.startswith("#### "):
|
|
139
|
+
manual = line[5:].strip().lower().startswith("manual")
|
|
140
|
+
continue
|
|
141
|
+
if line.startswith("### "):
|
|
142
|
+
manual = False
|
|
143
|
+
continue
|
|
144
|
+
match = re.match(r"^\s*- \[ \] (.+)$", line)
|
|
145
|
+
if match and not manual:
|
|
146
|
+
open_items.append(match.group(1).strip())
|
|
147
|
+
return open_items
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def check_archived_roadmaps(reader) -> list[Finding]:
|
|
151
|
+
findings: list[Finding] = []
|
|
152
|
+
for path in _archived_roadmaps(reader):
|
|
153
|
+
text = reader.read(path) or ""
|
|
154
|
+
open_rows = [f"{row['id']} ({row['status']})" for row in roadmap_rows(text)
|
|
155
|
+
if row["status"] not in CLOSED_STATUSES]
|
|
156
|
+
if open_rows:
|
|
157
|
+
findings.append(Finding("archived-roadmap-open-items", path,
|
|
158
|
+
f"rows not done, done_code, dropped or carried: {', '.join(open_rows)}"))
|
|
159
|
+
bad = summary_placeholders(text)
|
|
160
|
+
if bad:
|
|
161
|
+
findings.append(Finding("archived-roadmap-summary", path,
|
|
162
|
+
"## Summary merge column holds placeholders instead of merge SHAs: "
|
|
163
|
+
+ "; ".join(bad[:4])))
|
|
164
|
+
return findings
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def summary_placeholders(text: str) -> list[str]:
|
|
168
|
+
"""Rows of the `## Summary` table whose `Merge` cell holds no SHA (and is not an explicit dash)."""
|
|
169
|
+
lines = sections(text).get("Summary", [])
|
|
170
|
+
header = None
|
|
171
|
+
bad = []
|
|
172
|
+
for line in lines:
|
|
173
|
+
if not line.strip().startswith("|"):
|
|
174
|
+
continue
|
|
175
|
+
parts = [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
176
|
+
if header is None:
|
|
177
|
+
header = [cell.lower() for cell in parts]
|
|
178
|
+
continue
|
|
179
|
+
if all(re.fullmatch(r":?-{3,}:?", cell) for cell in parts if cell):
|
|
180
|
+
continue
|
|
181
|
+
index = header.index("merge") if "merge" in header else len(parts) - 1
|
|
182
|
+
cell = parts[index] if index < len(parts) else ""
|
|
183
|
+
if SHA_RE.search(cell) or cell.strip("`* ").lower() in EMPTY_MERGE:
|
|
184
|
+
continue
|
|
185
|
+
bad.append(f"{parts[0]}: \"{cell}\"")
|
|
186
|
+
return bad
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def check_queued_and_backlog(reader) -> list[Finding]:
|
|
190
|
+
findings: list[Finding] = []
|
|
191
|
+
queued_slugs = set()
|
|
192
|
+
for path in _files(reader, QUEUED_DIR, r"^roadmap-.+\.md$"):
|
|
193
|
+
text = reader.read(path) or ""
|
|
194
|
+
slug = os.path.basename(path)[len("roadmap-"):-len(".md")]
|
|
195
|
+
queued_slugs.add(slug)
|
|
196
|
+
rows = roadmap_rows(text)
|
|
197
|
+
if rows and all(row["status"] in ("done", "done_code") for row in rows):
|
|
198
|
+
findings.append(Finding("queued-roadmap-done", path,
|
|
199
|
+
f"all {len(rows)} rows are done but the roadmap is still queued; "
|
|
200
|
+
"archive it to foundation/archive/ (WORKFLOW §5.2)"))
|
|
201
|
+
main = frontmatter(reader.read(ROADMAP_PATH) or "")
|
|
202
|
+
for name, is_dir in reader.listdir(BACKLOG_DIR):
|
|
203
|
+
if not is_dir or not name.startswith("roadmap-"):
|
|
204
|
+
continue
|
|
205
|
+
slug = name[len("roadmap-"):]
|
|
206
|
+
promoted = main.get("roadmap") == slug or (main.get("backlog") or "").rstrip("/").endswith(name)
|
|
207
|
+
if slug not in queued_slugs and not promoted:
|
|
208
|
+
findings.append(Finding("backlog-without-roadmap", f"{BACKLOG_DIR}/{name}/",
|
|
209
|
+
f"no {QUEUED_DIR}/roadmap-{slug}.md and the main roadmap is not `{slug}`; "
|
|
210
|
+
"move live entries to a queued roadmap or remove the folder (WORKFLOW §5.1)"))
|
|
211
|
+
return findings
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def check_indexes(reader) -> list[Finding]:
|
|
215
|
+
findings: list[Finding] = []
|
|
216
|
+
for path in _walk(reader, "context"):
|
|
217
|
+
if os.path.basename(path) not in INDEX_NAMES:
|
|
218
|
+
continue
|
|
219
|
+
base = os.path.dirname(path)
|
|
220
|
+
for line in (reader.read(path) or "").splitlines():
|
|
221
|
+
if not line.strip().startswith("|"):
|
|
222
|
+
continue
|
|
223
|
+
for target in LINK_RE.findall(line):
|
|
224
|
+
if re.match(r"^[a-z][a-z0-9+.-]*:", target, re.IGNORECASE) or target.startswith("#"):
|
|
225
|
+
continue
|
|
226
|
+
rel = target.split("#", 1)[0]
|
|
227
|
+
if not rel:
|
|
228
|
+
continue
|
|
229
|
+
resolved = os.path.normpath(os.path.join(base, rel)).replace(os.sep, "/")
|
|
230
|
+
if resolved.startswith("..") or not resolved.startswith("context/"):
|
|
231
|
+
continue # outside context/: not this check's business
|
|
232
|
+
if not reader.exists(resolved.rstrip("/")):
|
|
233
|
+
findings.append(Finding("index-missing-file", path, f"row links `{target}`, which does not exist"))
|
|
234
|
+
for target in CODE_PATH_RE.findall(line):
|
|
235
|
+
# A path in backticks: relative to the index, to context/ or to the repository root.
|
|
236
|
+
candidates = [os.path.normpath(os.path.join(prefix, target)).replace(os.sep, "/").rstrip("/")
|
|
237
|
+
for prefix in (base, "context", ".")]
|
|
238
|
+
inside = [c for c in candidates if c.startswith("context/")]
|
|
239
|
+
if inside and not any(reader.exists(c) for c in inside):
|
|
240
|
+
findings.append(Finding("index-missing-file", path, f"row names `{target}`, which does not exist"))
|
|
241
|
+
return findings
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def _walk(reader, directory: str) -> list[str]:
|
|
245
|
+
out = []
|
|
246
|
+
for name, is_dir in reader.listdir(directory):
|
|
247
|
+
path = f"{directory}/{name}"
|
|
248
|
+
if is_dir:
|
|
249
|
+
out += _walk(reader, path)
|
|
250
|
+
else:
|
|
251
|
+
out.append(path)
|
|
252
|
+
return out
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def ever_written(root: str | None) -> bool | None:
|
|
256
|
+
"""Whether git history has ever held context/state.json; None when that cannot be told."""
|
|
257
|
+
if not root:
|
|
258
|
+
return None
|
|
259
|
+
probe = subprocess.run(["git", "-C", root, "rev-parse", "--is-shallow-repository"],
|
|
260
|
+
capture_output=True, text=True)
|
|
261
|
+
if probe.returncode != 0 or probe.stdout.strip() == "true":
|
|
262
|
+
return None
|
|
263
|
+
log = subprocess.run(["git", "-C", root, "log", "--all", "-1", "--format=%H", "--", STATE_PATH],
|
|
264
|
+
capture_output=True, text=True)
|
|
265
|
+
return log.returncode == 0 and bool(log.stdout.strip())
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def check_state(reader, root: str | None) -> list[Finding]:
|
|
269
|
+
if not reader.exists("context"):
|
|
270
|
+
return []
|
|
271
|
+
problem = staleness(reader)
|
|
272
|
+
if problem is None:
|
|
273
|
+
return []
|
|
274
|
+
if problem == "missing":
|
|
275
|
+
if ever_written(root):
|
|
276
|
+
return [Finding("state-missing", STATE_PATH,
|
|
277
|
+
"missing, but git history holds it: regenerate it (`npx softure-skills state`) and commit")]
|
|
278
|
+
return [Finding("state-missing", STATE_PATH,
|
|
279
|
+
"not written yet; the next wt-roadmap.py, softure-archive or softure-roadmap run creates it",
|
|
280
|
+
severity="note")]
|
|
281
|
+
return [Finding("state-stale", STATE_PATH,
|
|
282
|
+
f"{problem}; regenerate it (`npx softure-skills state`) and commit")]
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def run_checks(reader, root: str | None = None) -> list[Finding]:
|
|
286
|
+
"""Every finding for the project `reader` sees. `root` (a git checkout) enables the history check."""
|
|
287
|
+
if not reader.exists("context"):
|
|
288
|
+
return []
|
|
289
|
+
findings: list[Finding] = []
|
|
290
|
+
for check in (check_main_roadmap, check_archived_changes, check_archived_roadmaps,
|
|
291
|
+
check_queued_and_backlog, check_indexes):
|
|
292
|
+
findings += check(reader)
|
|
293
|
+
findings += check_state(reader, root)
|
|
294
|
+
return findings
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def main(argv: list[str] | None = None) -> int:
|
|
298
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
299
|
+
if "-h" in args or "--help" in args:
|
|
300
|
+
print(__doc__)
|
|
301
|
+
return 0
|
|
302
|
+
as_json = "--json" in args
|
|
303
|
+
args = [arg for arg in args if arg != "--json"]
|
|
304
|
+
root = None
|
|
305
|
+
if "--root" in args:
|
|
306
|
+
k = args.index("--root")
|
|
307
|
+
root = os.path.abspath(args[k + 1])
|
|
308
|
+
del args[k:k + 2]
|
|
309
|
+
if args:
|
|
310
|
+
print(__doc__, file=sys.stderr)
|
|
311
|
+
return 2
|
|
312
|
+
top = subprocess.run(["git", "-C", root or os.getcwd(), "rev-parse", "--show-toplevel"],
|
|
313
|
+
capture_output=True, text=True)
|
|
314
|
+
toplevel = os.path.realpath(top.stdout.strip()) if top.returncode == 0 else None
|
|
315
|
+
root = root or toplevel or os.getcwd()
|
|
316
|
+
git_root = root if toplevel and toplevel == os.path.realpath(root) else None
|
|
317
|
+
reader = FsReader(root)
|
|
318
|
+
if not reader.exists("context"):
|
|
319
|
+
if as_json:
|
|
320
|
+
print(json.dumps({"root": root, "failures": [], "notes": ["no context/ directory"]}, indent=2))
|
|
321
|
+
else:
|
|
322
|
+
print(f"softure-doctor: no context/ directory in {root}, nothing to check")
|
|
323
|
+
return 0
|
|
324
|
+
findings = run_checks(reader, git_root)
|
|
325
|
+
failures = [f for f in findings if f.severity == "fail"]
|
|
326
|
+
if as_json:
|
|
327
|
+
print(json.dumps({"root": root, "failures": [f.as_dict() for f in failures],
|
|
328
|
+
"notes": [f.as_dict() for f in findings if f.severity != "fail"]}, indent=2))
|
|
329
|
+
return 1 if failures else 0
|
|
330
|
+
for finding in findings:
|
|
331
|
+
print(finding)
|
|
332
|
+
if failures:
|
|
333
|
+
print(f"softure-doctor: {len(failures)} problem(s) in the context/ contract (WORKFLOW.md §12)")
|
|
334
|
+
return 1
|
|
335
|
+
print("softure-doctor: context/ contract OK")
|
|
336
|
+
return 0
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
if __name__ == "__main__":
|
|
340
|
+
sys.exit(main())
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: softure-evidence
|
|
3
|
+
description: >
|
|
4
|
+
Keep run evidence (screenshots, frame grabs, recordings) out of git and easy to browse: name
|
|
5
|
+
each file by the rule `<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.webp`, convert it
|
|
6
|
+
to WebP, store it in the project's evidence store (a folder, the hosted project's shared files,
|
|
7
|
+
an upload command or the asset store of one evidence page), refresh the per-project evidence
|
|
8
|
+
page, and return the link that `## Progress` cites. Also lists a change's evidence, checks a
|
|
9
|
+
folder for committed binaries, and prunes evidence of long-archived changes. Use when a Manual
|
|
10
|
+
item is verified by a screenshot or a recording, when softure-implement or softure-impl-review
|
|
11
|
+
produce visual evidence, or when the user says "save the screenshot", "where are the
|
|
12
|
+
screenshots", "show the evidence", "prune old screenshots".
|
|
13
|
+
argument-hint: "save <file> --change <id> --what <slug> --state before|after --width <px> --theme light|dark | list --change <id> | check <path> | prune --months <N>"
|
|
14
|
+
allowed-tools:
|
|
15
|
+
- Read
|
|
16
|
+
- Glob
|
|
17
|
+
- Bash
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# softure-evidence: every screenshot kept, none in git
|
|
21
|
+
|
|
22
|
+
Contract: `WORKFLOW.md` §11 (project files and evidence) and §2 (`evidence`). The script is
|
|
23
|
+
`scripts/evidence.py` next to this file (`<S>` below); it reads `context/workflow.json` of the
|
|
24
|
+
repository it runs in.
|
|
25
|
+
|
|
26
|
+
## Why
|
|
27
|
+
|
|
28
|
+
Evidence committed to git is carried by every clone forever; evidence written to an ignored
|
|
29
|
+
folder in a cloud container is gone when the container goes. Both leave the owner and the
|
|
30
|
+
reviewer unable to open what the run looked at. The store keeps every file once, outside the
|
|
31
|
+
repository, under a name that says what it shows.
|
|
32
|
+
|
|
33
|
+
## Name
|
|
34
|
+
|
|
35
|
+
`<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.<ext>`, all lowercase kebab-case:
|
|
36
|
+
|
|
37
|
+
- `NN`: two digits, the order within the change (the script picks the next one in file stores);
|
|
38
|
+
- `what`: the screen or state shown (`map-panel`, `cancel-button-disabled`);
|
|
39
|
+
- `before` (the main branch, or the state before the phase) or `after` (this change);
|
|
40
|
+
- `width`: the viewport width in px (`390`, `1280`); `theme`: `light` or `dark`;
|
|
41
|
+
- `ext`: `webp` (quality 85); `png` only when a side exceeds the WebP limit of 16383 px; a recording
|
|
42
|
+
keeps its format (`webm`, `mp4`).
|
|
43
|
+
|
|
44
|
+
Example: `add-side-map/01-map-panel-after-390-dark.webp`. A pair `before`/`after` with the same
|
|
45
|
+
`what`, `width` and `theme` sits side by side on the evidence page.
|
|
46
|
+
|
|
47
|
+
## Stores (`evidence.store`)
|
|
48
|
+
|
|
49
|
+
| store | where | link `## Progress` cites | page |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `dir` | a folder outside the repository (`path`, `~` allowed) | the file path | `<path>/index.html`, rewritten on every save |
|
|
52
|
+
| `project-files` | the hosted project's shared files (`path` under `/mnt/project-files`, or `projectFilesRoot`, or `$SOFTURE_PROJECT_FILES`) | `<path>/<key>` | `<path>/index.html`, rewritten on every save |
|
|
53
|
+
| `command` | object storage behind the project's own `upload` command (`{file}`, `{key}`; prints the link last) | the printed link | the store's own listing |
|
|
54
|
+
| `artifact` | the asset store of one evidence page (`url`) | the asset url | that page, republished by the agent |
|
|
55
|
+
|
|
56
|
+
No store configured: the script keeps the file in `~/.cache/softure-evidence/<repo>/`, prints
|
|
57
|
+
`"durable": false`, and the Progress line says `(evidence not stored: no evidence.store)`.
|
|
58
|
+
Report it once to the owner as a setup gap (`softure-init` proposes a store); never commit the file
|
|
59
|
+
instead.
|
|
60
|
+
|
|
61
|
+
## Procedure: save one file
|
|
62
|
+
|
|
63
|
+
1. Take the screenshot or recording into a scratch folder **outside** the repository (or a
|
|
64
|
+
git-ignored one), never into `context/`.
|
|
65
|
+
2. `python3 <S>/evidence.py save <file> --change <id> --what <slug> --state after --width 390 --theme dark`.
|
|
66
|
+
It prints one JSON line: `key`, `link`, `durable`, an optional `warning` (for example "kept PNG")
|
|
67
|
+
and, for `artifact`, `next`.
|
|
68
|
+
3. `artifact` store only: upload the converted file (`file` in the output) to the asset store of the
|
|
69
|
+
page at `evidence.url` with your artifact tool, read the page's current HTML, then
|
|
70
|
+
`python3 <S>/evidence.py render --from-page <page.html> --add <key>=<asset url> --out <page.html>`
|
|
71
|
+
and republish the page to the same url. The page's data block is the manifest: never rebuild it
|
|
72
|
+
from memory.
|
|
73
|
+
4. Cite the link in the Progress item that relied on it:
|
|
74
|
+
`- [x] 2.4 … — <sha> (verified by agent: <how> → <result>; <link>[, <link>])`.
|
|
75
|
+
5. Delete the scratch copy once the store holds it.
|
|
76
|
+
|
|
77
|
+
## Other commands
|
|
78
|
+
|
|
79
|
+
- `list --change <id>`: the change's stored files (file stores; the others say where to look).
|
|
80
|
+
- `check <path> …`: exit 1 when any image or recording lies under the paths. `softure-archive` runs it
|
|
81
|
+
on the change folder as a hard stop.
|
|
82
|
+
- `prune --months <N> [--apply]`: delete the evidence of changes archived N or more months ago (file
|
|
83
|
+
stores; dry run without `--apply`). Only on the owner's word or a set `evidence.retainMonths`;
|
|
84
|
+
the default is to keep evidence forever.
|
|
85
|
+
- `render --from-dir <store> --out <store>/index.html`: rebuild the page of a file store by hand.
|
|
86
|
+
|
|
87
|
+
## Exceptions
|
|
88
|
+
|
|
89
|
+
Visual-regression baselines that tests compare against stay in the repository, next to their
|
|
90
|
+
tests (`__screenshots__/`, `*-snapshots/`). They are test fixtures, not run evidence.
|
|
91
|
+
|
|
92
|
+
## Checklist
|
|
93
|
+
|
|
94
|
+
- [ ] No image or recording added under `context/` or anywhere else in the diff, baselines excepted.
|
|
95
|
+
- [ ] Every file named by the rule, WebP unless the script said why not.
|
|
96
|
+
- [ ] Every Progress item that relied on visual evidence links its stored files.
|
|
97
|
+
- [ ] `artifact` store: the page republished with the new entries, nothing dropped from its data block.
|
|
98
|
+
|
|
99
|
+
## Anti-patterns
|
|
100
|
+
|
|
101
|
+
- `reviews/p2-*.png` in the change folder "just for the review".
|
|
102
|
+
- A Progress line that says "screenshot looked fine" with nothing anyone can open.
|
|
103
|
+
- Copying owner material (briefs, real data) into the repository instead of referencing its path in
|
|
104
|
+
the project files (WORKFLOW §11).
|