@softure-ai/skills 0.18.0 → 0.19.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/README.md +1 -0
- package/WORKFLOW.md +68 -1
- package/package.json +1 -1
- package/rules/AGENTS.md +7 -0
- package/skills/softure-archive/SKILL.md +2 -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/README.md
CHANGED
|
@@ -94,6 +94,7 @@ operating modes.
|
|
|
94
94
|
| hygiene | `softure-code-review` | review of a diff against conventions |
|
|
95
95
|
| | `softure-lesson` | numbered rule in `lessons.md` |
|
|
96
96
|
| | `softure-rule-review` | audit of AGENTS.md / CLAUDE.md / skills |
|
|
97
|
+
| | `softure-evidence` | screenshots and recordings in the evidence store (never git) + the evidence page |
|
|
97
98
|
|
|
98
99
|
Every interactive skill accepts `--auto`: it decides instead of asking and records each
|
|
99
100
|
decision in the artifact. The orchestrators always use it, and `mode: "autonomous"` implies it.
|
package/WORKFLOW.md
CHANGED
|
@@ -24,6 +24,7 @@ hygiene (any time)
|
|
|
24
24
|
softure-code-review review a diff against the project conventions
|
|
25
25
|
softure-rule-review audit AI rule files (AGENTS.md, CLAUDE.md, skills) for drift and contradictions
|
|
26
26
|
softure-lesson turn a repeated mistake into a numbered rule
|
|
27
|
+
softure-evidence store screenshots and recordings outside git, by name, on one evidence page (§11)
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
Each step produces a durable artifact the next step reads. A step never starts without its
|
|
@@ -102,6 +103,15 @@ or languages.
|
|
|
102
103
|
"research": { // optional: extra knowledge sources softure-research should consult
|
|
103
104
|
"sources": ["docs/", "context/foundation/prd.md"]
|
|
104
105
|
},
|
|
106
|
+
"evidence": { // optional: where screenshots, frame grabs and recordings live (§11); never git
|
|
107
|
+
"store": "artifact", // "artifact": the asset store of one evidence page (`url`), hosted cloud sessions;
|
|
108
|
+
// "project-files": the hosted project's shared files (`path`); "dir": a folder outside
|
|
109
|
+
// the repository (`path`), local runs; "command": object storage behind `upload`
|
|
110
|
+
"url": "https://claude.ai/code/artifact/<id>", // artifact: the per-project evidence page
|
|
111
|
+
"path": null, // project-files: "<project-slug>/evidence"; dir: e.g. "~/softure-evidence/<repo>"
|
|
112
|
+
"upload": null, // command: e.g. "scripts/evidence-upload.sh {file} {key}", prints the link last
|
|
113
|
+
"retainMonths": null // null: keep forever (default); N: prune evidence of changes archived N months ago
|
|
114
|
+
},
|
|
105
115
|
"install": { // optional: read by the installer on every `npm install`
|
|
106
116
|
"gitignore": true, // false: commit the installed skills (e.g. cloud sessions that never run npm install)
|
|
107
117
|
"rules": ["language", "workflow", "conventions"], // sections of rules/AGENTS.md to inject; default: all.
|
|
@@ -172,6 +182,9 @@ context/
|
|
|
172
182
|
|
|
173
183
|
`change-id` is kebab-case, ASCII, at most 40 characters, unique across `changes/` and `archive/`.
|
|
174
184
|
|
|
185
|
+
**No binaries under `context/`.** Screenshots, frame grabs and recordings go to the evidence store and
|
|
186
|
+
are linked, never committed; owner material stays in the project files and is referenced by path (§11).
|
|
187
|
+
|
|
175
188
|
**Headings are fixed English** in every artifact (`## Intent`, `## Progress`, `## Done`, `## Owner decisions and checks`, …),
|
|
176
189
|
regardless of `language`. Scripts and orchestrators find sections by these headings. Only the prose under them is
|
|
177
190
|
written in `language`.
|
|
@@ -418,7 +431,8 @@ Rules:
|
|
|
418
431
|
`Owner step:` lines, never owner checks (AGENTS.md → Operating mode: autonomous).
|
|
419
432
|
- Notation:
|
|
420
433
|
- done: `- [x] N.M text — <sha>`;
|
|
421
|
-
- a Manual item the agent verified itself: `- [x] N.M text — <sha> (verified by agent: <how>)`;
|
|
434
|
+
- a Manual item the agent verified itself: `- [x] N.M text — <sha> (verified by agent: <how>)`; when the
|
|
435
|
+
proof is visual, the stored files are linked: `(verified by agent: <how> → <result>; <link>[, <link>])` (§11);
|
|
422
436
|
- dropped mid-flight: `- [x] ~~N.M text~~ — dropped: <reason>`.
|
|
423
437
|
- SHA: the phase commit is created first, then its SHA is written into Progress. Never amend that edit into the
|
|
424
438
|
phase commit (the amend changes the SHA it records). It rides with the next commit of the change, or goes into a
|
|
@@ -599,3 +613,56 @@ MCP access tokens, billing/trial, GDPR export/delete, consent, channel analytics
|
|
|
599
613
|
checks and UI primitives. If a module covers the need, the plan uses the module, configured
|
|
600
614
|
through `softure.config.ts`. If a module almost covers it, the plan records the gap as an
|
|
601
615
|
issue for SOFTURE/AI instead of re-implementing it locally.
|
|
616
|
+
|
|
617
|
+
## 11. Project files and evidence
|
|
618
|
+
|
|
619
|
+
Two kinds of material never enter git: **owner material** kept outside the repository, and **run
|
|
620
|
+
evidence** (screenshots, frame grabs, recordings) a run produces. Both are kept durably, under
|
|
621
|
+
predictable names, and referenced from the repository by path or link.
|
|
622
|
+
|
|
623
|
+
### 11.1 Project files (owner material)
|
|
624
|
+
|
|
625
|
+
A hosted project's shared files (or the owner's equivalent folder) hold the project's briefs,
|
|
626
|
+
concepts, private data and design material, in one layout:
|
|
627
|
+
|
|
628
|
+
```
|
|
629
|
+
<project-slug>/
|
|
630
|
+
INDEX.md file → what it is → who reads it
|
|
631
|
+
briefs/YYYY-MM-DD-<topic>.md concepts, owner roadmaps, private data
|
|
632
|
+
data/YYYY-MM-DD-<topic>.<ext> exports, real seed data, documents
|
|
633
|
+
design/<screen>-<variant>.<ext> mock-ups, inspiration, brand material
|
|
634
|
+
evidence/ run evidence when `evidence.store` is "project-files" (§11.2)
|
|
635
|
+
archive/ superseded files
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
- Lowercase kebab-case, a date prefix, no version or `-final` suffixes: the version lives in the content.
|
|
639
|
+
A superseded file moves to `archive/`; `INDEX.md` gets one line per file.
|
|
640
|
+
- The repository references a file by path (`project files: <project-slug>/briefs/2026-11-02-roadmap.md`)
|
|
641
|
+
and never copies its content. Anything with personal data, real bookings, amounts or addresses lives
|
|
642
|
+
there, never in the repository.
|
|
643
|
+
- `softure-init` writes the `INDEX.md` template when the shared files are reachable and it is missing,
|
|
644
|
+
otherwise prints it for the owner (`softure-init/references/templates.md`).
|
|
645
|
+
|
|
646
|
+
### 11.2 Run evidence
|
|
647
|
+
|
|
648
|
+
- **Store:** `evidence.store` (§2), outside git. `artifact` (the asset store of one per-project
|
|
649
|
+
evidence page) suits hosted cloud sessions: it needs no secret and the owner browses the page.
|
|
650
|
+
`project-files` suits sessions that can write the shared files, `dir` local runs, `command` object
|
|
651
|
+
storage (R2/S3) behind a project script that holds its own key. Never `context/changes/<id>/`.
|
|
652
|
+
- **Name:** `<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.webp`, e.g.
|
|
653
|
+
`add-side-map/01-map-panel-after-390-dark.webp`. WebP at quality 85; PNG only above the WebP size
|
|
654
|
+
limit (a side over 16383 px); recordings keep their format.
|
|
655
|
+
- **Link:** each Progress item that relied on visual evidence links its stored files (§6 notation)
|
|
656
|
+
instead of describing them. `softure-impl-review` treats a visual claim without a link that opens as
|
|
657
|
+
missing evidence.
|
|
658
|
+
- **Page:** one evidence page per project lists the changes newest first, a thumbnail grid per change,
|
|
659
|
+
`before` and `after` of the same screen, width and theme side by side.
|
|
660
|
+
- **Gate:** `softure-archive` stops when the change folder holds an image or a recording.
|
|
661
|
+
- **Retention:** kept forever by default; `evidence.retainMonths` (or the owner's word) prunes the
|
|
662
|
+
evidence of changes archived that many months ago.
|
|
663
|
+
- **Exception:** visual-regression baselines that tests compare against stay in the repository, next
|
|
664
|
+
to their tests.
|
|
665
|
+
|
|
666
|
+
`softure-evidence` (`scripts/evidence.py`) does the naming, the conversion, the store and the page:
|
|
667
|
+
`save`, `list`, `render`, `check`, `prune`. Without a configured store it keeps a local copy, reports it
|
|
668
|
+
as not durable, and the setup gap goes to the owner once.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softure-ai/skills",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "SOFTURE agent skills: a spec-driven delivery workflow (shape → prd → roadmap → plan → implement → review) plus parallel worktree orchestration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/rules/AGENTS.md
CHANGED
|
@@ -46,6 +46,13 @@ missing) or `autonomous`. Its rules are the `## Operating mode` section below; i
|
|
|
46
46
|
section in this block. Switch modes only on the owner's explicit word: set `mode`, re-run the installer
|
|
47
47
|
(`npx softure-skills`) so this block follows, commit both as `docs(rules): switch to <mode> mode`.
|
|
48
48
|
|
|
49
|
+
**Project files and evidence (WORKFLOW §11).** No screenshot, frame grab or recording enters git
|
|
50
|
+
(visual-regression baselines next to their tests excepted). Save each with `softure-evidence` to the
|
|
51
|
+
store in `workflow.json` → `evidence`, named `<change-id>/<NN>-<what>-<before|after>-<width>-<theme>.webp`,
|
|
52
|
+
and link the stored files from the Progress item they prove. Owner material (briefs, real data, designs)
|
|
53
|
+
stays in the project files (`<project-slug>/briefs|data|design/`, listed in `INDEX.md`) and is referenced
|
|
54
|
+
by path, never copied into the repository.
|
|
55
|
+
|
|
49
56
|
Execution state lives only in the `## Progress` section of `plan.md`. Commands, the main branch
|
|
50
57
|
and the artifact language come from `context/workflow.json`. Before building anything generic
|
|
51
58
|
(auth, mail, feature switches, billing, GDPR, analytics, UI primitives), check the
|
|
@@ -47,6 +47,7 @@ re-running is always safe. Report what you found and what you completed.
|
|
|
47
47
|
|---|---|---|
|
|
48
48
|
| no uncommitted changes in the change folder or the files the change touched (`git status --porcelain -- <paths>`) | yes: commit them first; never archive over uncommitted work of the change | other uncommitted paths (someone else's WIP): leave them, never stage them |
|
|
49
49
|
| nothing staged that is not part of this change (`git diff --cached --name-only`) | yes: it would ride along in the archive commit. Name the paths; never unstage them yourself, they may be someone's work | |
|
|
50
|
+
| no image or recording in the change folder (`python3 .claude/skills/softure-evidence/scripts/evidence.py check context/changes/<id>`) | yes: run evidence never enters `archive/` (WORKFLOW §11). Save each file with `softure-evidence`, link it from its Progress item, `git rm` it, commit, then archive | |
|
|
50
51
|
| change.md `status` is `impl_reviewed` | | `implemented` (no review) or earlier |
|
|
51
52
|
| plan.md exists | | no: work done without the chain (interactively, or a change that turned out to need no code). Archive it anyway, see "Without a plan" |
|
|
52
53
|
| plan.md Progress: no open `#### Automated` items | yes: name them | |
|
|
@@ -186,6 +187,7 @@ row by row during the merge. Do not touch rows of other items.
|
|
|
186
187
|
## Checklist
|
|
187
188
|
|
|
188
189
|
- [ ] No uncommitted files of the change before and after; nobody else's WIP or staged work in the commit.
|
|
190
|
+
- [ ] `evidence.py check` clean on the change folder: no image or recording goes into `archive/`.
|
|
189
191
|
- [ ] `status: archived` and `archived_at` set, the stamp inside the commit; folder named by `created`.
|
|
190
192
|
- [ ] Roadmap row last cell, item block status, `## Done` and `updated` all changed (or the skip is reported);
|
|
191
193
|
with `--handoff`, `roadmap.md` untouched and `## Roadmap handoff` written instead.
|
|
@@ -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).
|
|
@@ -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
|
|
75
|
-
|
|
76
|
-
|
|
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>)`.
|
|
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>])
|
|
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 (
|
|
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:
|
|
185
|
-
→ - [x] 2.5 email renders in light and dark mail themes — 7c41e0b (verified by agent:
|
|
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
|
|
110
|
-
the cursor is not a pointer.
|
|
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:
|
|
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
|
|
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. **
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
```
|