@softure-ai/skills 0.19.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 +25 -0
- package/WORKFLOW.md +141 -6
- package/package.json +2 -1
- package/rules/AGENTS.md +26 -1
- package/scripts/install.mjs +67 -1
- package/scripts/portfolio.py +259 -0
- package/skills/softure-archive/SKILL.md +15 -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-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,259 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""softure-skills portfolio: where every adopting project stands, from its context/state.json. Read-only.
|
|
3
|
+
|
|
4
|
+
softure-skills portfolio [<repo> ...] [--config <file>] [--owner] [--json] [--source git|api]
|
|
5
|
+
|
|
6
|
+
Repositories come from the arguments or from a config file outside any project (default
|
|
7
|
+
`~/.config/softure/portfolio.json`, or `$SOFTURE_PORTFOLIO`):
|
|
8
|
+
|
|
9
|
+
{ "projects": [ { "name": "shop", "repo": "acme/shop", "branch": "main" },
|
|
10
|
+
{ "repo": "https://git.example.com/acme/api.git" },
|
|
11
|
+
{ "name": "local", "repo": "~/code/app" } ] }
|
|
12
|
+
|
|
13
|
+
A repo is `owner/name` (GitHub), a git URL, or a local checkout. Without `branch` the remote's default
|
|
14
|
+
branch is read; a local checkout is read at `origin/<mainBranch>` when that ref exists, else at
|
|
15
|
+
`<mainBranch>` (no fetch: nothing is written to it).
|
|
16
|
+
|
|
17
|
+
`--source git` (default) reads `context/` of the main branch through git (a shallow, sparse, blob-less
|
|
18
|
+
clone into a temporary folder for a remote), takes `context/state.json`, and runs softure-doctor on the
|
|
19
|
+
same tree. A project without `state.json` gets one built in memory and is marked `*`.
|
|
20
|
+
`--source api` reads only `context/state.json` through the GitHub API (`gh api`); the doctor column
|
|
21
|
+
then shows `n/a`.
|
|
22
|
+
|
|
23
|
+
Default output, one row per project:
|
|
24
|
+
|
|
25
|
+
project | active roadmap X/N | queued | open changes | owner queue | last release | doctor
|
|
26
|
+
|
|
27
|
+
`--owner` prints only the owner queue across all projects, oldest first. `--json` prints the same data
|
|
28
|
+
for another tool. Exit 1 when a project could not be read (its row says why); nothing is ever written
|
|
29
|
+
outside a temporary folder.
|
|
30
|
+
"""
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
import datetime as dt
|
|
34
|
+
import json
|
|
35
|
+
import os
|
|
36
|
+
import re
|
|
37
|
+
import shutil
|
|
38
|
+
import subprocess
|
|
39
|
+
import sys
|
|
40
|
+
import tempfile
|
|
41
|
+
|
|
42
|
+
sys.dont_write_bytecode = True
|
|
43
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
44
|
+
sys.path.insert(0, os.path.join(HERE, "..", "skills", "softure-doctor", "scripts"))
|
|
45
|
+
import context_state # noqa: E402
|
|
46
|
+
import doctor # noqa: E402
|
|
47
|
+
|
|
48
|
+
DEFAULT_CONFIG = os.path.join("~", ".config", "softure", "portfolio.json")
|
|
49
|
+
SEMVER_RE = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)$")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def git(*args: str, cwd: str | None = None, check: bool = True) -> subprocess.CompletedProcess:
|
|
53
|
+
env = {**os.environ, "GIT_TERMINAL_PROMPT": "0"}
|
|
54
|
+
return subprocess.run(["git", *args], cwd=cwd, capture_output=True, text=True, check=check, env=env)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def load_projects(args: list[str], config: str | None) -> list[dict]:
|
|
58
|
+
if args:
|
|
59
|
+
return [{"repo": repo} for repo in args]
|
|
60
|
+
path = os.path.expanduser(config or os.environ.get("SOFTURE_PORTFOLIO") or DEFAULT_CONFIG)
|
|
61
|
+
if not os.path.exists(path):
|
|
62
|
+
sys.exit(f"no repositories: pass them as arguments or list them in {path} (see --help)")
|
|
63
|
+
with open(path, encoding="utf-8") as fh:
|
|
64
|
+
data = json.load(fh)
|
|
65
|
+
entries = data.get("projects", data) if isinstance(data, dict) else data
|
|
66
|
+
projects = []
|
|
67
|
+
for entry in entries:
|
|
68
|
+
projects.append({"repo": entry} if isinstance(entry, str) else dict(entry))
|
|
69
|
+
return projects
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def project_name(project: dict) -> str:
|
|
73
|
+
if project.get("name"):
|
|
74
|
+
return project["name"]
|
|
75
|
+
repo = project["repo"].rstrip("/")
|
|
76
|
+
return re.sub(r"\.git$", "", repo.rsplit("/", 1)[-1].rsplit(":", 1)[-1])
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def is_local(repo: str) -> bool:
|
|
80
|
+
return os.path.isdir(os.path.expanduser(repo))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def remote_url(repo: str) -> str:
|
|
84
|
+
if re.fullmatch(r"[\w.-]+/[\w.-]+", repo):
|
|
85
|
+
return f"https://github.com/{repo}.git"
|
|
86
|
+
return repo
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def highest_tag(tags: list[str]) -> str | None:
|
|
90
|
+
versions = [(tuple(int(n) for n in SEMVER_RE.match(tag).groups()), tag) for tag in tags if SEMVER_RE.match(tag)]
|
|
91
|
+
return max(versions)[1] if versions else None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def local_ref(path: str, branch: str | None) -> str:
|
|
95
|
+
if not branch:
|
|
96
|
+
raw = git("show", "HEAD:context/workflow.json", cwd=path, check=False).stdout
|
|
97
|
+
try:
|
|
98
|
+
branch = json.loads(raw).get("mainBranch") if raw else None
|
|
99
|
+
except json.JSONDecodeError:
|
|
100
|
+
branch = None
|
|
101
|
+
for ref in ([f"origin/{branch}", branch] if branch else []) + ["HEAD"]:
|
|
102
|
+
if git("rev-parse", "--verify", "-q", f"{ref}^{{commit}}", cwd=path, check=False).returncode == 0:
|
|
103
|
+
return ref
|
|
104
|
+
return "HEAD"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def read_git(project: dict) -> dict:
|
|
108
|
+
"""State, doctor findings and last release of one project, read through git."""
|
|
109
|
+
repo = project["repo"]
|
|
110
|
+
tmp = None
|
|
111
|
+
try:
|
|
112
|
+
if is_local(repo):
|
|
113
|
+
path = os.path.expanduser(repo)
|
|
114
|
+
ref = local_ref(path, project.get("branch"))
|
|
115
|
+
reader = context_state.GitReader(path, ref)
|
|
116
|
+
tags = git("tag", "-l", "v*", cwd=path, check=False).stdout.split()
|
|
117
|
+
branch = ref
|
|
118
|
+
else:
|
|
119
|
+
tmp = tempfile.mkdtemp(prefix="softure-portfolio-")
|
|
120
|
+
url = remote_url(repo)
|
|
121
|
+
clone = ["clone", "-q", "--depth", "1", "--filter=blob:none", "--sparse"]
|
|
122
|
+
if project.get("branch"):
|
|
123
|
+
clone += ["--branch", project["branch"]]
|
|
124
|
+
result = git(*clone, url, tmp, check=False)
|
|
125
|
+
if result.returncode != 0:
|
|
126
|
+
raise RuntimeError(f"git clone failed: {result.stderr.strip()[:200]}")
|
|
127
|
+
git("sparse-checkout", "set", "--no-cone", "/context/", cwd=tmp, check=False)
|
|
128
|
+
reader = context_state.FsReader(tmp)
|
|
129
|
+
branch = git("rev-parse", "--abbrev-ref", "HEAD", cwd=tmp, check=False).stdout.strip()
|
|
130
|
+
listed = git("ls-remote", "--tags", "--refs", url, "v*", check=False).stdout
|
|
131
|
+
tags = [line.split("refs/tags/", 1)[1] for line in listed.splitlines() if "refs/tags/" in line]
|
|
132
|
+
if not reader.exists("context"):
|
|
133
|
+
raise RuntimeError(f"no context/ on {branch}")
|
|
134
|
+
state, source = context_state.load_prior(reader), "stored"
|
|
135
|
+
if state is None:
|
|
136
|
+
state, source = context_state.build_state(reader), "built"
|
|
137
|
+
findings = doctor.run_checks(reader, None)
|
|
138
|
+
failures = [f.as_dict() for f in findings if f.severity == "fail"]
|
|
139
|
+
release = (state.get("last_release") or {}).get("version") or highest_tag(tags)
|
|
140
|
+
return {"branch": branch, "state": state, "state_source": source, "doctor": failures, "last_release": release}
|
|
141
|
+
finally:
|
|
142
|
+
if tmp:
|
|
143
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def read_api(project: dict) -> dict:
|
|
147
|
+
"""State and last release of one GitHub project, through `gh api`; no doctor."""
|
|
148
|
+
repo = project["repo"]
|
|
149
|
+
match = re.search(r"github\.com[:/]([\w.-]+/[\w.-]+?)(?:\.git)?/?$", repo)
|
|
150
|
+
slug = match.group(1) if match else repo
|
|
151
|
+
if not re.fullmatch(r"[\w.-]+/[\w.-]+", slug):
|
|
152
|
+
raise RuntimeError("--source api needs a GitHub repository (owner/name)")
|
|
153
|
+
ref = f"?ref={project['branch']}" if project.get("branch") else ""
|
|
154
|
+
shown = subprocess.run(["gh", "api", "-H", "Accept: application/vnd.github.raw",
|
|
155
|
+
f"repos/{slug}/contents/context/state.json{ref}"], capture_output=True, text=True)
|
|
156
|
+
state, source = None, "missing"
|
|
157
|
+
if shown.returncode == 0:
|
|
158
|
+
state, source = json.loads(shown.stdout), "stored"
|
|
159
|
+
elif "404" not in shown.stderr and "Not Found" not in shown.stderr:
|
|
160
|
+
raise RuntimeError(f"gh api failed: {shown.stderr.strip()[:200]}")
|
|
161
|
+
latest = subprocess.run(["gh", "api", f"repos/{slug}/releases/latest", "--jq", ".tag_name"],
|
|
162
|
+
capture_output=True, text=True)
|
|
163
|
+
release = ((state or {}).get("last_release") or {}).get("version") or (
|
|
164
|
+
latest.stdout.strip() if latest.returncode == 0 else None)
|
|
165
|
+
return {"branch": project.get("branch") or "default", "state": state, "state_source": source,
|
|
166
|
+
"doctor": None, "last_release": release}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def collect(projects: list[dict], source: str) -> list[dict]:
|
|
170
|
+
rows = []
|
|
171
|
+
for project in projects:
|
|
172
|
+
row = {"name": project_name(project), "repo": project["repo"], "error": None}
|
|
173
|
+
try:
|
|
174
|
+
row.update(read_api(project) if source == "api" else read_git(project))
|
|
175
|
+
except (RuntimeError, OSError, subprocess.CalledProcessError, json.JSONDecodeError) as exc:
|
|
176
|
+
row.update({"branch": project.get("branch"), "state": None, "state_source": "missing",
|
|
177
|
+
"doctor": None, "last_release": None, "error": str(exc)})
|
|
178
|
+
rows.append(row)
|
|
179
|
+
return rows
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def summary_cells(row: dict) -> list[str]:
|
|
183
|
+
name = row["name"] + ("*" if row.get("state_source") == "built" else "")
|
|
184
|
+
if row["error"]:
|
|
185
|
+
return [name, f"error: {row['error']}", "", "", "", "", ""]
|
|
186
|
+
state = row["state"]
|
|
187
|
+
if state is None:
|
|
188
|
+
return [name, "no state.json", "—", "—", "—", row["last_release"] or "—", "n/a"]
|
|
189
|
+
active = state.get("active_roadmap")
|
|
190
|
+
roadmap = f"{active.get('slug') or '?'} {active['done']}/{active['total']}" if active else "—"
|
|
191
|
+
doctor_cell = "n/a" if row["doctor"] is None else ("ok" if not row["doctor"] else
|
|
192
|
+
f"{len(row['doctor'])} failing")
|
|
193
|
+
return [name, roadmap, str(len(state.get("queued", []))), str(len(state.get("open_changes", []))),
|
|
194
|
+
str(len(state.get("owner_queue", []))), row["last_release"] or "—", doctor_cell]
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def owner_entries(rows: list[dict]) -> list[dict]:
|
|
198
|
+
entries = []
|
|
199
|
+
for row in rows:
|
|
200
|
+
for entry in (row["state"] or {}).get("owner_queue", []):
|
|
201
|
+
entries.append({"project": row["name"], **entry})
|
|
202
|
+
entries.sort(key=lambda entry: (entry.get("since") or "", entry["project"], entry.get("text", "")))
|
|
203
|
+
return entries
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def table(header: list[str], body: list[list[str]]) -> str:
|
|
207
|
+
def clean(cell: str) -> str:
|
|
208
|
+
return str(cell).replace("|", "\\|").replace("\n", " ")
|
|
209
|
+
lines = ["| " + " | ".join(header) + " |", "| " + " | ".join("---" for _ in header) + " |"]
|
|
210
|
+
lines += ["| " + " | ".join(clean(cell) for cell in cells) + " |" for cells in body]
|
|
211
|
+
return "\n".join(lines)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def main(argv: list[str] | None = None) -> int:
|
|
215
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
216
|
+
if "-h" in args or "--help" in args:
|
|
217
|
+
print(__doc__)
|
|
218
|
+
return 0
|
|
219
|
+
flags = {flag: flag in args for flag in ("--owner", "--json")}
|
|
220
|
+
args = [arg for arg in args if arg not in flags]
|
|
221
|
+
options = {"--config": None, "--source": "git"}
|
|
222
|
+
for key in options:
|
|
223
|
+
if key in args:
|
|
224
|
+
k = args.index(key)
|
|
225
|
+
options[key] = args[k + 1]
|
|
226
|
+
del args[k:k + 2]
|
|
227
|
+
if options["--source"] not in ("git", "api"):
|
|
228
|
+
print("--source is git or api", file=sys.stderr)
|
|
229
|
+
return 2
|
|
230
|
+
unknown = [arg for arg in args if arg.startswith("--")]
|
|
231
|
+
if unknown:
|
|
232
|
+
print(f"unknown option {unknown[0]} (see --help)", file=sys.stderr)
|
|
233
|
+
return 2
|
|
234
|
+
rows = collect(load_projects(args, options["--config"]), options["--source"])
|
|
235
|
+
generated = dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
|
236
|
+
if flags["--json"]:
|
|
237
|
+
if flags["--owner"]:
|
|
238
|
+
print(json.dumps({"generated_at": generated, "owner_queue": owner_entries(rows)}, indent=2,
|
|
239
|
+
ensure_ascii=False))
|
|
240
|
+
else:
|
|
241
|
+
print(json.dumps({"generated_at": generated, "projects": rows}, indent=2, ensure_ascii=False))
|
|
242
|
+
elif flags["--owner"]:
|
|
243
|
+
entries = owner_entries(rows)
|
|
244
|
+
print(table(["since", "project", "kind", "what", "source"],
|
|
245
|
+
[[e.get("since") or "—", e["project"], e["kind"], e["text"],
|
|
246
|
+
e["source"].replace("context/", "")] for e in entries]) if entries else "Nothing waits for the owner.")
|
|
247
|
+
else:
|
|
248
|
+
print(table(["project", "active roadmap X/N", "queued", "open changes", "owner queue", "last release", "doctor"],
|
|
249
|
+
[summary_cells(row) for row in rows]))
|
|
250
|
+
if any(row.get("state_source") == "built" for row in rows):
|
|
251
|
+
print("\n* no context/state.json on the main branch yet; built from the markdown for this report")
|
|
252
|
+
errors = [row for row in rows if row["error"]]
|
|
253
|
+
for row in errors:
|
|
254
|
+
print(f"{row['name']}: {row['error']}", file=sys.stderr)
|
|
255
|
+
return 1 if errors else 0
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
if __name__ == "__main__":
|
|
259
|
+
sys.exit(main())
|
|
@@ -36,7 +36,7 @@ re-running is always safe. Report what you found and what you completed.
|
|
|
36
36
|
| Found | Do |
|
|
37
37
|
|---|---|
|
|
38
38
|
| `context/changes/<id>/change.md` | continue |
|
|
39
|
-
| no folder in `changes/`, but `context/archive/*-<id>/` | already archived: report the path. If its roadmap row is not `done` / `done_code`, offer to finish only steps 3 to
|
|
39
|
+
| no folder in `changes/`, but `context/archive/*-<id>/` | already archived: report the path. If its roadmap row is not `done` / `done_code`, offer to finish only steps 3 to 9 on the archived folder |
|
|
40
40
|
| `status: archived`, folder still in `changes/` | an earlier run stopped after the stamp. An uncommitted diff of change.md limited to the stamp is that run's own and does not count as uncommitted work; resume at step 2 once the other checks pass |
|
|
41
41
|
| `created` missing or not `YYYY-MM-DD` | stop: the archive folder name cannot be derived |
|
|
42
42
|
| nothing | stop: name the folders that do exist |
|
|
@@ -119,13 +119,20 @@ hard stops. Sample reports: [references/example-archive.md](references/example-a
|
|
|
119
119
|
hit to `archive/<created>-<id>`. Links inside the archived folder are relative and stay valid.
|
|
120
120
|
6. **Verify** that the old folder is gone, the new one exists, the roadmap row has exactly one
|
|
121
121
|
match, and no dangling `changes/<id>` links remain.
|
|
122
|
-
7. **
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
7. **State and doctor** (WORKFLOW §12; skip both with `--handoff`: the branch never writes
|
|
123
|
+
`context/state.json`, `wt-roadmap.py done` does after the merge). Once the paths below are
|
|
124
|
+
staged, run `python3 .claude/skills/softure-doctor/scripts/context_state.py write --staged`
|
|
125
|
+
(it reads the index and stages `context/state.json`), then
|
|
126
|
+
`python3 .claude/skills/softure-doctor/scripts/doctor.py`. Fix what this archive owns (this
|
|
127
|
+
change's `change.md` stamp, its Progress, its index rows, the state) and re-run; name any other
|
|
128
|
+
failure in the report without touching it. A project without the scripts installed skips this.
|
|
129
|
+
8. **Commit** with `chore(archive): close <change-id>`, staging only the touched paths: the
|
|
130
|
+
archive folder, the roadmap (unless step 3 left it unstaged), `context/state.json` (step 7), and
|
|
131
|
+
the files whose links you fixed. Before committing, `git diff --cached --name-only` must list nothing else. Never
|
|
125
132
|
`--no-verify`; if a hook fails, fix the cause and commit again (a new commit, never an amend).
|
|
126
133
|
In `--auto`, the commit body lists the soft warnings.
|
|
127
|
-
|
|
128
|
-
checks added, links fixed, edits skipped or left unstaged, and the commit SHA. The commit is
|
|
134
|
+
9. **Report:** old and new path, the stamp, the roadmap transition (or "no matching row"), owner
|
|
135
|
+
checks added, links fixed, edits skipped or left unstaged, the doctor result, and the commit SHA. The commit is
|
|
129
136
|
local: never push from this skill.
|
|
130
137
|
|
|
131
138
|
## Without a plan
|
|
@@ -193,6 +200,8 @@ row by row during the merge. Do not touch rows of other items.
|
|
|
193
200
|
with `--handoff`, `roadmap.md` untouched and `## Roadmap handoff` written instead.
|
|
194
201
|
- [ ] Open Manual items listed for the owner (manual mode), or none left but `(owner only: …)` ones,
|
|
195
202
|
written as owner steps (`--auto`); deploy prerequisites under `## Before the next release`.
|
|
203
|
+
- [ ] `context/state.json` regenerated from the index and staged, the doctor green on what this
|
|
204
|
+
archive owns (not with `--handoff`).
|
|
196
205
|
- [ ] No dangling links; one commit, conventional message, not pushed.
|
|
197
206
|
|
|
198
207
|
## Anti-patterns
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: softure-doctor
|
|
3
|
+
description: >
|
|
4
|
+
Check a project's context/ contract and keep its machine-readable state current: regenerate
|
|
5
|
+
context/state.json (active roadmap, queued roadmaps, open changes, and one owner_queue of
|
|
6
|
+
everything that waits for the owner) and fail on drift: a roadmap left after its archive, archived
|
|
7
|
+
changes that are not stamped or have unticked Automated items, Summary placeholders instead of
|
|
8
|
+
merge SHAs, archived roadmaps with open rows, queued roadmaps that are fully done, backlog folders
|
|
9
|
+
without their roadmap, index rows pointing at missing files, and a missing or stale state.json.
|
|
10
|
+
Use in CI, before an archive or roadmap commit, or when the user says "check the context",
|
|
11
|
+
"run the doctor", "what waits for me", "refresh the state".
|
|
12
|
+
argument-hint: "[doctor | state write|print|check] [--root <dir>] [--json] [--staged]"
|
|
13
|
+
allowed-tools:
|
|
14
|
+
- Read
|
|
15
|
+
- Bash
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# softure-doctor: the context/ contract as a check
|
|
19
|
+
|
|
20
|
+
Contract: `WORKFLOW.md` §12 (state.json and the doctor), §5 (roadmap), §5.1 (queued roadmaps and the
|
|
21
|
+
backlog), §5.2 (closing a roadmap), §6 (Progress). Two scripts next to this file (`<S>` below):
|
|
22
|
+
|
|
23
|
+
| Command | Does |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `python3 <S>/doctor.py [--json]` | every check; exit 1 on a failure. Same as `npx softure-skills doctor` |
|
|
26
|
+
| `python3 <S>/context_state.py write` | regenerate `context/state.json` from the working tree |
|
|
27
|
+
| `python3 <S>/context_state.py write --staged` | regenerate it from what is staged, and stage it (use right before a commit) |
|
|
28
|
+
| `python3 <S>/context_state.py print` / `check` | show it / exit 1 when it is missing or stale |
|
|
29
|
+
|
|
30
|
+
`<S>` is `.claude/skills/softure-doctor/scripts` in an installed project.
|
|
31
|
+
|
|
32
|
+
## When it runs
|
|
33
|
+
|
|
34
|
+
- **CI of every adopting project**, documentation-only changes included: `npx softure-skills doctor`
|
|
35
|
+
(the installer prints this line). Drift happens in the documents, so a CI that skips doc-only
|
|
36
|
+
changes misses it.
|
|
37
|
+
- **`softure-archive`** (on the main branch) and **`softure-roadmap`** (record, `--queue`, `--promote`,
|
|
38
|
+
`--close`): `context_state.py write --staged` right before the commit, then `doctor.py`; each fixes
|
|
39
|
+
what it owns and names the rest in its report.
|
|
40
|
+
- **`wt-roadmap.py`** writes `context/state.json` itself in every mode, in the same commit as `roadmap.md`.
|
|
41
|
+
|
|
42
|
+
## Reading the result
|
|
43
|
+
|
|
44
|
+
Each problem is one line `FAIL <code> <path>: <what>`. Fix the file it names, never the check:
|
|
45
|
+
|
|
46
|
+
| Code | Fix |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `roadmap-archived-not-removed` | the close moved a copy and left `roadmap.md`: remove it (promote the next one only on the owner's word) |
|
|
49
|
+
| `roadmap-status-mismatch` | set `status` to match the rows (`done` only when every row is closed; `waiting` belongs to queued roadmaps) |
|
|
50
|
+
| `archived-change-status` | stamp the archived `change.md` `status: archived` (and `archived_at`) |
|
|
51
|
+
| `archived-change-progress` | the change was archived with open Automated items: tick them with their SHA when the work is on the main branch, or mark them `~~dropped~~ — dropped: <reason>` |
|
|
52
|
+
| `archived-roadmap-open-items` | rows of an archived roadmap end `done`, `done_code`, dropped or carried (with where they went) |
|
|
53
|
+
| `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into each `## Summary` row |
|
|
54
|
+
| `queued-roadmap-done` | archive the finished queued roadmap to `foundation/archive/` |
|
|
55
|
+
| `backlog-without-roadmap` | move live entries to a queued roadmap, then remove the folder |
|
|
56
|
+
| `index-missing-file` | fix or drop the index row |
|
|
57
|
+
| `state-missing` / `state-stale` | `context_state.py write`, commit `context/state.json` |
|
|
58
|
+
|
|
59
|
+
A project that has never written `context/state.json` gets a `note`, not a failure, until the first
|
|
60
|
+
script run creates it.
|
|
61
|
+
|
|
62
|
+
## Rules
|
|
63
|
+
|
|
64
|
+
- `context/state.json` is written by scripts only. Never edit it by hand; regenerate it.
|
|
65
|
+
- The doctor never edits anything. A skill that runs it fixes only the files it owns in that run.
|
|
66
|
+
- `open_changes` and `updated_at` are refreshed on every write and never make the file stale, so a
|
|
67
|
+
change branch that edits its own `change.md` keeps a green doctor.
|
|
68
|
+
- Owner-word issues (label `owner-word`, WORKFLOW §8.6) live on the forge, not in `state.json`;
|
|
69
|
+
an aggregator reads both.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/SOFTURE/SKILLS/skills/softure-doctor/references/state.schema.json",
|
|
4
|
+
"title": "context/state.json",
|
|
5
|
+
"description": "Machine-readable state of a project that follows the SOFTURE workflow (WORKFLOW.md §12). Written only by scripts.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["schema_version", "project", "mode", "main_branch", "updated_at", "active_roadmap", "queued",
|
|
8
|
+
"open_changes", "owner_queue", "last_release"],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"schema_version": { "type": "integer", "enum": [1] },
|
|
12
|
+
"project": { "type": ["string", "null"], "description": "workflow.json `project`, else the roadmap's `project`" },
|
|
13
|
+
"mode": { "type": "string", "enum": ["manual", "autonomous"] },
|
|
14
|
+
"main_branch": { "type": ["string", "null"] },
|
|
15
|
+
"updated_at": { "type": "string", "description": "UTC ISO 8601; changes only when the content does" },
|
|
16
|
+
"active_roadmap": {
|
|
17
|
+
"type": ["object", "null"],
|
|
18
|
+
"required": ["slug", "title", "status", "version", "path", "done", "total", "items"],
|
|
19
|
+
"additionalProperties": false,
|
|
20
|
+
"properties": {
|
|
21
|
+
"slug": { "type": ["string", "null"] },
|
|
22
|
+
"title": { "type": ["string", "null"] },
|
|
23
|
+
"status": { "type": ["string", "null"] },
|
|
24
|
+
"version": { "type": ["string", "null"] },
|
|
25
|
+
"path": { "type": "string" },
|
|
26
|
+
"done": { "type": "integer", "description": "rows done or done_code" },
|
|
27
|
+
"total": { "type": "integer" },
|
|
28
|
+
"items": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"description": "rows not done yet",
|
|
31
|
+
"items": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"required": ["id", "change_id", "outcome", "status", "stage", "since", "detail", "prerequisites", "mode"],
|
|
34
|
+
"additionalProperties": false,
|
|
35
|
+
"properties": {
|
|
36
|
+
"id": { "type": "string" },
|
|
37
|
+
"change_id": { "type": ["string", "null"] },
|
|
38
|
+
"outcome": { "type": ["string", "null"] },
|
|
39
|
+
"status": { "type": "string" },
|
|
40
|
+
"stage": { "type": ["string", "null"] },
|
|
41
|
+
"since": { "type": ["string", "null"] },
|
|
42
|
+
"detail": { "type": ["string", "null"] },
|
|
43
|
+
"prerequisites": { "type": "array", "items": { "type": "string" } },
|
|
44
|
+
"mode": { "type": ["string", "null"] }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"queued": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"required": ["slug", "title", "status", "path", "start_condition", "done", "total", "items"],
|
|
55
|
+
"additionalProperties": false,
|
|
56
|
+
"properties": {
|
|
57
|
+
"slug": { "type": "string" },
|
|
58
|
+
"title": { "type": ["string", "null"] },
|
|
59
|
+
"status": { "type": ["string", "null"] },
|
|
60
|
+
"path": { "type": "string" },
|
|
61
|
+
"start_condition": { "type": ["string", "null"] },
|
|
62
|
+
"done": { "type": "integer" },
|
|
63
|
+
"total": { "type": "integer" },
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"required": ["id", "change_id", "outcome", "status"],
|
|
69
|
+
"additionalProperties": false,
|
|
70
|
+
"properties": {
|
|
71
|
+
"id": { "type": "string" },
|
|
72
|
+
"change_id": { "type": ["string", "null"] },
|
|
73
|
+
"outcome": { "type": ["string", "null"] },
|
|
74
|
+
"status": { "type": "string" }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"open_changes": {
|
|
82
|
+
"type": "array",
|
|
83
|
+
"description": "folders in context/changes/ on the branch the file was written on; refreshed on every script run",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"required": ["change_id", "title", "status", "roadmap_item", "updated", "stage"],
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": {
|
|
89
|
+
"change_id": { "type": "string" },
|
|
90
|
+
"title": { "type": ["string", "null"] },
|
|
91
|
+
"status": { "type": ["string", "null"] },
|
|
92
|
+
"roadmap_item": { "type": ["string", "null"] },
|
|
93
|
+
"updated": { "type": ["string", "null"] },
|
|
94
|
+
"stage": { "type": ["string", "null"] }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"owner_queue": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"description": "everything that waits for the owner, oldest first",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"required": ["kind", "source", "item", "since", "text"],
|
|
104
|
+
"additionalProperties": false,
|
|
105
|
+
"properties": {
|
|
106
|
+
"kind": { "type": "string", "enum": ["word", "decision", "step", "secret"] },
|
|
107
|
+
"source": { "type": "string", "description": "file, then `#` and the heading" },
|
|
108
|
+
"item": { "type": ["string", "null"], "description": "roadmap item ID, when the entry names one" },
|
|
109
|
+
"since": { "type": ["string", "null"], "description": "YYYY-MM-DD" },
|
|
110
|
+
"text": { "type": "string" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"last_release": {
|
|
115
|
+
"type": ["object", "null"],
|
|
116
|
+
"required": ["version", "date", "source"],
|
|
117
|
+
"additionalProperties": false,
|
|
118
|
+
"properties": {
|
|
119
|
+
"version": { "type": "string" },
|
|
120
|
+
"date": { "type": ["string", "null"] },
|
|
121
|
+
"source": { "type": "string" }
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|