@softure-ai/skills 0.20.0 → 0.21.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 CHANGED
@@ -29,7 +29,8 @@ What the installer does (idempotent; re-run on every `npm install`):
29
29
  It never overwrites a skill folder it did not install. Flags: `--dry-run`, `--target <dir>`,
30
30
  `--no-gitignore` (commit the skills instead).
31
31
 
32
- **CI line.** Add one step to the project's CI check, documentation-only changes included:
32
+ **CI line.** Add one step to the project's CI check, documentation-only changes included (in a project
33
+ that already has history, once the rollout below brings the doctor to zero):
33
34
 
34
35
  ```bash
35
36
  npx softure-skills doctor
@@ -40,6 +41,22 @@ It fails on drift in `context/` (a roadmap left after its archive, archived chan
40
41
  line until a workflow runs it. `npx softure-skills state` regenerates `context/state.json`, which the
41
42
  scripts otherwise write themselves.
42
43
 
44
+ **Rolling out to an existing project** (WORKFLOW §12.4). A project that adopted the package earlier
45
+ usually fails on history. Put it right, in this order, one pass per repository:
46
+
47
+ 1. `npx softure-skills doctor --fix`, then `--fix --write`: the mechanical repairs (archived change
48
+ statuses, with the old value kept as `legacy_status`; archive index links to moved files). Commit.
49
+ 2. `npx softure-skills doctor --sweep --json`, worked by an agent with the `softure-doctor` skill
50
+ ("Sweep history to zero"): every entry settled with its evidence (commit, release, file), never
51
+ without, in one change, until the doctor exits 0.
52
+ 3. The owner's short list: only real owner items (an open decision, a step outside the repository),
53
+ carried to the live roadmap or an `owner-word` issue.
54
+ 4. The CI line above, once the doctor is at zero.
55
+
56
+ `npx softure-skills doctor --baseline` exists only as a last resort, for a project that cannot finish
57
+ the history sweep at once: it accepts today's failures in `context/doctor-baseline.json`, the check
58
+ then fails on anything new, and the file only shrinks. The recommended path is the sweep to zero.
59
+
43
60
  ## Many projects at once
44
61
 
45
62
  `npx softure-skills portfolio` is read-only: it reads `context/state.json` from the main branch of every
@@ -50,7 +67,9 @@ listed repository (arguments, or `~/.config/softure/portfolio.json` outside any
50
67
  ```
51
68
 
52
69
  `--owner` prints only what waits for the owner across all projects, oldest first; `--json` gives the same
53
- data to another tool; `--source api` reads through the GitHub API instead of git. See WORKFLOW §12.3.
70
+ data to another tool; `--source api` reads through the GitHub API instead of git. The last release comes
71
+ from the forge (the latest GitHub release through `gh`, else the highest `v*` tag); a value only a roadmap
72
+ recorded is labelled `(roadmap)`. See WORKFLOW §12.3.
54
73
 
55
74
  **Operating mode.** `context/workflow.json` → `mode` is `"manual"` (default) or `"autonomous"`, and the
56
75
  installer injects only that mode's section into the rules block:
package/WORKFLOW.md CHANGED
@@ -376,6 +376,12 @@ the end", otherwise by the owner). Gates, all checked on `<main>` and reported t
376
376
  when one exists; otherwise the summary records `integration: covered by the release on <sha>
377
377
  (coveredByRelease)`. The release's integration result gates the deploy, not the archive; its reds become new
378
378
  roadmap rows as usual.
379
+ 4. no open `- [ ]` under `## Owner decisions and checks`: the close **refuses** to archive with one. Each entry is
380
+ ticked with its evidence (`— done: <sha | release | path>`), ticked as obsolete (`— obsolete: <reason>`), or
381
+ carried to the next or a queued roadmap's owner section, or an `owner-word` issue (§8.6), and ticked with where it
382
+ went (`— carried to <path | #N>`). An archived roadmap holds no owner entry: the owner queue never reads one
383
+ (§12.1), and the doctor fails on it (`archived-roadmap-open-checks`). Open `## Before the next release` steps
384
+ stay: they wait for the release, which comes after the close.
379
385
 
380
386
  **Close before the release.** The release reads the roadmap to list what ships, so the archived file is the single
381
387
  stable input for every release of that roadmap: the first attempt, a retry after a failed release, a redeploy or a
@@ -736,24 +742,29 @@ A project without the file gets it from the first of these runs; nothing has to
736
742
  { "kind": "decision", "source": "context/foundation/roadmap.md#Owner decisions and checks", "item": "SR-5",
737
743
  "since": "2026-11-10", "text": "**SR-5**: choose the ranking provider …" }
738
744
  ],
739
- "last_release": { "version": "v1.4.0", "date": "2026-10-02", "source": "context/foundation/archive/2026-09-30-roadmap.md" }
745
+ "last_release": { "version": "v1.4.0", "date": "2026-10-02", // as a closed roadmap recorded it (§5.2); the
746
+ "source": "context/foundation/archive/2026-09-30-roadmap.md" } // portfolio asks the forge first
740
747
  }
741
748
  ```
742
749
 
743
750
  The schema ships with the package: `skills/softure-doctor/references/state.schema.json`.
744
751
 
745
- **`owner_queue`** is the one list of what waits for the owner, from the main roadmap, the queued roadmaps and the
746
- archived roadmaps:
752
+ **`owner_queue`** is the one list of what waits for the owner, built only from what is live: the main roadmap, the
753
+ queued roadmaps, the open changes, and the pre-release steps of the newest closed roadmap until its release is
754
+ recorded:
747
755
 
748
756
  | `kind` | Comes from |
749
757
  | --- | --- |
750
758
  | `word` | rows `done_code (…; waiting: release)` of the main roadmap (one entry: the release word); every queued roadmap (the word to start it, with its `trigger`) |
751
759
  | `decision` | open `- [ ]` entries under `## Owner decisions and checks` that are not owner steps |
752
- | `step` | `owner step:` entries and manual-mode owner checks `(Manual N.M)`; open `## Before the next release` entries; `done_code` rows waiting for an owner step that has no entry |
760
+ | `step` | `owner step:` entries and manual-mode owner checks `(Manual N.M)`; open `## Before the next release` entries; `done_code` rows waiting for an owner step that has no entry; `**Owner step:**` / `**Owner check:**` lines of an open change's `## Roadmap handoff` |
753
761
  | `secret` | a `step` whose text names a secret, key, token, credential or password |
754
762
 
755
- An archived roadmap contributes only its open checkboxes (its `## Before the next release` only until its
756
- `## Summary` records a release). `source` is the file, `#`, and the heading; `item` the roadmap ID the entry names;
763
+ An archived roadmap contributes nothing, with one exception: the newest one, while its `## Summary` records no
764
+ `Release:` line, contributes its open `## Before the next release` steps (the close comes before the release, §5.2).
765
+ An unticked entry in any other archived roadmap, and any unticked `## Owner decisions and checks` entry in an archived
766
+ roadmap, is history to settle (the doctor's `archived-roadmap-open-checks`), not something that waits for the owner.
767
+ Entries from open changes are refreshed on every write and never make the file stale, like `open_changes`. `source` is the file, `#`, and the heading; `item` the roadmap ID the entry names;
757
768
  `since` the date in the entry, else the file's `updated`, and once written it is kept for that entry on every
758
769
  rewrite. Owner-word issues (§8.6) live on the forge, not here.
759
770
 
@@ -772,11 +783,44 @@ its own `change.md` without touching `state.json`, and stays green.
772
783
  | `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate) |
773
784
  | `archived-roadmap-open-items` | an archived roadmap with rows that are not `done`, `done_code`, dropped or carried |
774
785
  | `archived-roadmap-summary` | an archived roadmap whose `## Summary` merge column holds placeholders instead of SHAs |
786
+ | `archived-roadmap-open-checks` | an archived roadmap with an unticked `## Owner decisions and checks` entry, or an unticked `## Before the next release` step once its release is recorded or a later roadmap was closed |
775
787
  | `queued-roadmap-done` | a queued roadmap whose rows are all done, never archived |
776
788
  | `backlog-without-roadmap` | `backlog/roadmap-<slug>/` without `roadmaps/roadmap-<slug>.md` (or the promoted main roadmap) |
777
789
  | `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links or names a missing file |
778
790
  | `state-missing` | `context/state.json` is gone although git history holds it |
779
791
  | `state-stale` | `context/state.json` does not match the markdown |
792
+ | `baseline-stale` | `context/doctor-baseline.json` lists a failure that no longer occurs (remove it), or is unreadable |
793
+
794
+ **Mechanical repairs.** `npx softure-skills doctor --fix` prints the edits that need no judgement, and the failures
795
+ left after them; `--fix --write` applies them, only under `context/`, and a second run changes nothing:
796
+
797
+ - an archived change's `status` becomes `archived`; the old value is kept as `legacy_status` in its front matter;
798
+ - an index row inside `context/archive/` or `context/foundation/archive/` that links a missing file is rewritten to
799
+ the file's current path when git history shows where it moved (rename detection, followed across moves);
800
+ otherwise it is marked `(moved, not found; last seen in <sha>: <path>)` with the last commit that had the file.
801
+
802
+ A row whose target was never in git history, a live index, and a checkout without full history are left alone and
803
+ named. Everything else is a judgement case.
804
+
805
+ **Judgement cases: the sweep.** `npx softure-skills doctor --sweep [--json]` (read-only) lists every remaining failure
806
+ as one worklist entry per thing to settle (an unticked Progress item, a `## Summary` placeholder, an open row, an open
807
+ owner check), with `path`, `line`, the exact `text`, and evidence pointers found in the repository alone: for unticked
808
+ Progress items the commits that touched the phase's files after the plan's date (and the SHA the phase's ticked items
809
+ cite); for `## Summary` placeholders the merge commit of the item's change (first-parent log, branch name, change ID in
810
+ the message); for open rows and owner checks the item's archived change, merge commit, the release that contains it,
811
+ and later roadmaps that mention the item. An entry with no evidence is marked `owner`. The `softure-doctor` skill
812
+ ("Sweep history to zero") tells an agent how to work it: every entry is settled with its evidence written into the line,
813
+ never without; what only the owner can settle (a real open decision, a step outside the repository) is carried to the
814
+ live roadmap's `## Owner decisions and checks` or an `owner-word` issue and collected in one short list for the owner;
815
+ nothing else is left open.
816
+
817
+ **Baseline: a last resort.** For a project that cannot finish the sweep at once, `doctor --baseline` writes the failures
818
+ that remain to `context/doctor-baseline.json` (`{ "note", "created", "entries": [ { "code", "path", "message" } ] }`).
819
+ The check then reports those as `baselined` and fails only on a new failure (a code and path not in the file) and on an
820
+ entry that was fixed but not removed (`baseline-stale`). The file only shrinks: running `--baseline` again drops the
821
+ fixed entries, never adds one (it names them and exits 1), and removes the file once it is empty. State findings are
822
+ never baselined; `--fix` and `--sweep` ignore it. It is the owner's call, recorded in the commit; the recommended path
823
+ is the sweep to zero.
780
824
 
781
825
  A project that has never written `state.json` gets a note, not a failure. **Adopting projects run the doctor in their
782
826
  CI check**, documentation-only changes included; the installer prints the line (`npx softure-skills doctor`) until a
@@ -799,5 +843,30 @@ The config file lives outside every project (`--config <file>`, `$SOFTURE_PORTFO
799
843
  where `repo` is `owner/name`, a git URL or a local path. One row per project:
800
844
  `project | active roadmap X/N | queued | open changes | owner queue | last release | doctor`. The doctor runs on the
801
845
  same tree; a project without `state.json` yet gets one built in memory (marked `*`). `--source api` reads only
802
- `state.json` through `gh api` (no doctor). Last release: `state.json` → `last_release`, else the highest `v*` tag
803
- (the latest GitHub release with `--source api`).
846
+ `state.json` through `gh api` (no doctor). **Last release comes from the forge** when it can: the latest GitHub
847
+ release through `gh api` (both modes, for a GitHub repository; a local checkout counts when its `origin` is on GitHub),
848
+ else the highest `v*` tag (git mode), else `state.json` → `last_release`, which only records what a closed roadmap
849
+ wrote and is shown labelled: `v1.4.0 (roadmap, 2026-10-02)`. `--json` gives `last_release`, `last_release_date` and
850
+ `last_release_source` (`release`, `tag` or `roadmap`).
851
+
852
+ ### 12.4 Rolling out the doctor to an existing project
853
+
854
+ A project that adopted the package before the doctor existed usually fails on history: archived changes with old
855
+ status values, archive indexes that link moved files, unticked Progress items and owner checks in roadmaps closed
856
+ long ago. The history is put right, not hidden. One pass per repository, in this order:
857
+
858
+ 1. **Mechanical fixes.** Update the package, then `npx softure-skills doctor --fix` (review the printed edits) and
859
+ `npx softure-skills doctor --fix --write`. Commit: `docs(context): mechanical history fixes (doctor --fix)`.
860
+ 2. **The sweep, worked by an agent.** `npx softure-skills doctor --sweep --json`, settled entry by entry as the
861
+ `softure-doctor` skill describes ("Sweep history to zero"): every tick, SHA, status and obsolete mark carries its
862
+ evidence (commit, release, file), never without. Regenerate the state, re-run the doctor until it exits 0, and land it
863
+ as one change: `docs(context): settle history to zero`.
864
+ 3. **The owner's list.** What only the owner can settle (a decision still open, a step outside the repository that
865
+ nothing shows done) was carried to the live roadmap's `## Owner decisions and checks` or an `owner-word` issue; the
866
+ agent's report lists it once, short: `ID | what the owner decides or does | where it lives now`. Nothing else
867
+ waits, so `portfolio --owner` shows only these and the live roadmaps' entries.
868
+ 4. **The CI line at zero.** Once `npx softure-skills doctor` exits 0 on the main branch, add it to the CI check
869
+ (documentation-only changes included). From then on every new drift is red where it happens.
870
+
871
+ A project that cannot finish step 2 in one change may, on the owner's word, use `doctor --baseline` (§12.2) and add the
872
+ CI line with it; the baseline only shrinks, and the sweep continues until the file is gone.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/skills",
3
- "version": "0.20.0",
3
+ "version": "0.21.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": {
@@ -9,6 +9,9 @@
9
9
  //
10
10
  // Subcommands (run from the project root; Python 3, like the other scripts):
11
11
  // softure-skills doctor [--json] check the context/ contract (WORKFLOW.md §12); exit 1 on drift
12
+ // softure-skills doctor --fix [--write] mechanical repairs of history (dry run unless --write)
13
+ // softure-skills doctor --sweep [--json] worklist of the judgement cases, with evidence (read-only)
14
+ // softure-skills doctor --baseline last resort: accept today's failures; the file only shrinks
12
15
  // softure-skills state [write|print|check] regenerate context/state.json (default: write)
13
16
  // softure-skills portfolio [<repo> ...] [--owner] [--json] read-only table across many repositories
14
17
  //
@@ -281,7 +284,7 @@ function install(options) {
281
284
  for (const action of actions) console.log(`${prefix} ${action}`);
282
285
  console.log(`${prefix} ${PACKAGE.name}@${PACKAGE.version} -> ${projectRoot}`);
283
286
  if (!hasDoctorInCi(projectRoot)) {
284
- console.log(`${prefix} CI: add \`${CI_LINE}\` to the project's CI check, documentation-only changes included (WORKFLOW.md §12)`);
287
+ console.log(`${prefix} CI: add \`${CI_LINE}\` to the project's CI check, documentation-only changes included, once it exits 0 (rollout: doctor --fix, doctor --sweep; WORKFLOW.md §12.4)`);
285
288
  }
286
289
  }
287
290
 
@@ -24,8 +24,13 @@ Default output, one row per project:
24
24
 
25
25
  project | active roadmap X/N | queued | open changes | owner queue | last release | doctor
26
26
 
27
+ Last release comes from the forge when it can: the latest GitHub release through `gh api` (for a GitHub
28
+ repository, in both modes; a local checkout counts when its `origin` is on GitHub), else the highest
29
+ `v*` tag (git mode), else the value a closed roadmap recorded in `state.json`, labelled `(roadmap)`.
30
+ `SOFTURE_GH` names another `gh` binary.
31
+
27
32
  `--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
33
+ for another tool (`last_release` is the version; `last_release_source` is `release`, `tag` or `roadmap`). Exit 1 when a project could not be read (its row says why); nothing is ever written
29
34
  outside a temporary folder.
30
35
  """
31
36
  from __future__ import annotations
@@ -46,6 +51,7 @@ import context_state # noqa: E402
46
51
  import doctor # noqa: E402
47
52
 
48
53
  DEFAULT_CONFIG = os.path.join("~", ".config", "softure", "portfolio.json")
54
+ GITHUB_RE = re.compile(r"github\.com[:/]([\w.-]+/[\w.-]+?)(?:\.git)?/?$")
49
55
  SEMVER_RE = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)$")
50
56
 
51
57
 
@@ -86,6 +92,53 @@ def remote_url(repo: str) -> str:
86
92
  return repo
87
93
 
88
94
 
95
+ def gh() -> str:
96
+ return os.environ.get("SOFTURE_GH") or "gh"
97
+
98
+
99
+ def github_slug(repo: str, local_path: str | None = None) -> str | None:
100
+ """`owner/name` of a GitHub repository: from the argument, or the `origin` of a local checkout."""
101
+ if local_path:
102
+ url = git("remote", "get-url", "origin", cwd=local_path, check=False).stdout.strip()
103
+ match = GITHUB_RE.search(url)
104
+ return match.group(1) if match else None
105
+ if re.fullmatch(r"[\w.-]+/[\w.-]+", repo):
106
+ return repo
107
+ match = GITHUB_RE.search(repo)
108
+ return match.group(1) if match else None
109
+
110
+
111
+ def forge_release(slug: str | None) -> dict | None:
112
+ """The latest GitHub release of `slug` through `gh api`; None without gh, access or a release."""
113
+ if not slug:
114
+ return None
115
+ try:
116
+ shown = subprocess.run([gh(), "api", f"repos/{slug}/releases/latest"], capture_output=True, text=True,
117
+ timeout=30)
118
+ except (OSError, subprocess.TimeoutExpired):
119
+ return None
120
+ if shown.returncode != 0:
121
+ return None
122
+ try:
123
+ data = json.loads(shown.stdout)
124
+ except json.JSONDecodeError:
125
+ return None
126
+ if not data.get("tag_name"):
127
+ return None
128
+ return {"version": data["tag_name"], "date": (data.get("published_at") or "")[:10] or None, "source": "release"}
129
+
130
+
131
+ def pick_release(forge: dict | None, tag: dict | None, state: dict | None) -> dict:
132
+ """The forge's release, else the highest tag, else the roadmap-recorded value (labelled as such)."""
133
+ for found in (forge, tag):
134
+ if found and found.get("version"):
135
+ return found
136
+ recorded = (state or {}).get("last_release") or {}
137
+ if recorded.get("version"):
138
+ return {"version": recorded["version"], "date": recorded.get("date"), "source": "roadmap"}
139
+ return {"version": None, "date": None, "source": None}
140
+
141
+
89
142
  def highest_tag(tags: list[str]) -> str | None:
90
143
  versions = [(tuple(int(n) for n in SEMVER_RE.match(tag).groups()), tag) for tag in tags if SEMVER_RE.match(tag)]
91
144
  return max(versions)[1] if versions else None
@@ -115,6 +168,7 @@ def read_git(project: dict) -> dict:
115
168
  reader = context_state.GitReader(path, ref)
116
169
  tags = git("tag", "-l", "v*", cwd=path, check=False).stdout.split()
117
170
  branch = ref
171
+ slug = github_slug(repo, path)
118
172
  else:
119
173
  tmp = tempfile.mkdtemp(prefix="softure-portfolio-")
120
174
  url = remote_url(repo)
@@ -129,6 +183,7 @@ def read_git(project: dict) -> dict:
129
183
  branch = git("rev-parse", "--abbrev-ref", "HEAD", cwd=tmp, check=False).stdout.strip()
130
184
  listed = git("ls-remote", "--tags", "--refs", url, "v*", check=False).stdout
131
185
  tags = [line.split("refs/tags/", 1)[1] for line in listed.splitlines() if "refs/tags/" in line]
186
+ slug = github_slug(repo)
132
187
  if not reader.exists("context"):
133
188
  raise RuntimeError(f"no context/ on {branch}")
134
189
  state, source = context_state.load_prior(reader), "stored"
@@ -136,8 +191,11 @@ def read_git(project: dict) -> dict:
136
191
  state, source = context_state.build_state(reader), "built"
137
192
  findings = doctor.run_checks(reader, None)
138
193
  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}
194
+ top = highest_tag(tags)
195
+ release = pick_release(forge_release(slug), {"version": top, "date": None, "source": "tag"} if top else None,
196
+ state)
197
+ return {"branch": branch, "state": state, "state_source": source, "doctor": failures,
198
+ **release_fields(release)}
141
199
  finally:
142
200
  if tmp:
143
201
  shutil.rmtree(tmp, ignore_errors=True)
@@ -146,24 +204,34 @@ def read_git(project: dict) -> dict:
146
204
  def read_api(project: dict) -> dict:
147
205
  """State and last release of one GitHub project, through `gh api`; no doctor."""
148
206
  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):
207
+ slug = github_slug(repo)
208
+ if not slug:
152
209
  raise RuntimeError("--source api needs a GitHub repository (owner/name)")
153
210
  ref = f"?ref={project['branch']}" if project.get("branch") else ""
154
- shown = subprocess.run(["gh", "api", "-H", "Accept: application/vnd.github.raw",
211
+ shown = subprocess.run([gh(), "api", "-H", "Accept: application/vnd.github.raw",
155
212
  f"repos/{slug}/contents/context/state.json{ref}"], capture_output=True, text=True)
156
213
  state, source = None, "missing"
157
214
  if shown.returncode == 0:
158
215
  state, source = json.loads(shown.stdout), "stored"
159
216
  elif "404" not in shown.stderr and "Not Found" not in shown.stderr:
160
217
  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)
218
+ release = pick_release(forge_release(slug), None, state)
165
219
  return {"branch": project.get("branch") or "default", "state": state, "state_source": source,
166
- "doctor": None, "last_release": release}
220
+ "doctor": None, **release_fields(release)}
221
+
222
+
223
+ def release_fields(release: dict) -> dict:
224
+ return {"last_release": release["version"], "last_release_date": release["date"],
225
+ "last_release_source": release["source"]}
226
+
227
+
228
+ def release_cell(row: dict) -> str:
229
+ version = row.get("last_release")
230
+ if not version:
231
+ return "—"
232
+ notes = [note for note in ("roadmap" if row.get("last_release_source") == "roadmap" else None,
233
+ row.get("last_release_date")) if note]
234
+ return version + (f" ({', '.join(notes)})" if notes else "")
167
235
 
168
236
 
169
237
  def collect(projects: list[dict], source: str) -> list[dict]:
@@ -174,7 +242,8 @@ def collect(projects: list[dict], source: str) -> list[dict]:
174
242
  row.update(read_api(project) if source == "api" else read_git(project))
175
243
  except (RuntimeError, OSError, subprocess.CalledProcessError, json.JSONDecodeError) as exc:
176
244
  row.update({"branch": project.get("branch"), "state": None, "state_source": "missing",
177
- "doctor": None, "last_release": None, "error": str(exc)})
245
+ "doctor": None, "last_release": None, "last_release_date": None,
246
+ "last_release_source": None, "error": str(exc)})
178
247
  rows.append(row)
179
248
  return rows
180
249
 
@@ -185,13 +254,13 @@ def summary_cells(row: dict) -> list[str]:
185
254
  return [name, f"error: {row['error']}", "", "", "", "", ""]
186
255
  state = row["state"]
187
256
  if state is None:
188
- return [name, "no state.json", "—", "—", "—", row["last_release"] or "—", "n/a"]
257
+ return [name, "no state.json", "—", "—", "—", release_cell(row), "n/a"]
189
258
  active = state.get("active_roadmap")
190
259
  roadmap = f"{active.get('slug') or '?'} {active['done']}/{active['total']}" if active else "—"
191
260
  doctor_cell = "n/a" if row["doctor"] is None else ("ok" if not row["doctor"] else
192
261
  f"{len(row['doctor'])} failing")
193
262
  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]
263
+ str(len(state.get("owner_queue", []))), release_cell(row), doctor_cell]
195
264
 
196
265
 
197
266
  def owner_entries(rows: list[dict]) -> list[dict]:
@@ -3,13 +3,15 @@ name: softure-doctor
3
3
  description: >
4
4
  Check a project's context/ contract and keep its machine-readable state current: regenerate
5
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
6
+ everything live that waits for the owner) and fail on drift: a roadmap left after its archive, archived
7
7
  changes that are not stamped or have unticked Automated items, Summary placeholders instead of
8
8
  merge SHAs, archived roadmaps with open rows, queued roadmaps that are fully done, backlog folders
9
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]"
10
+ Repairs history: --fix for the mechanical shapes, --sweep for a worklist with evidence that an
11
+ agent settles to zero. Use in CI, before an archive or roadmap commit, or when the user says
12
+ "check the context", "run the doctor", "what waits for me", "refresh the state", "clean up the
13
+ history", "sweep the doctor to zero".
14
+ argument-hint: "[doctor [--fix [--write] | --sweep | --baseline] | state write|print|check] [--root <dir>] [--json] [--staged]"
13
15
  allowed-tools:
14
16
  - Read
15
17
  - Bash
@@ -23,6 +25,9 @@ backlog), §5.2 (closing a roadmap), §6 (Progress). Two scripts next to this fi
23
25
  | Command | Does |
24
26
  |---|---|
25
27
  | `python3 <S>/doctor.py [--json]` | every check; exit 1 on a failure. Same as `npx softure-skills doctor` |
28
+ | `python3 <S>/doctor.py --fix [--write]` | the mechanical repairs of history, printed edit by edit; a dry run unless `--write` |
29
+ | `python3 <S>/doctor.py --sweep [--json]` | every remaining failure as a worklist entry with evidence pointers; read-only |
30
+ | `python3 <S>/doctor.py --baseline` | last resort only: accept today's failures in `context/doctor-baseline.json`; it only shrinks |
26
31
  | `python3 <S>/context_state.py write` | regenerate `context/state.json` from the working tree |
27
32
  | `python3 <S>/context_state.py write --staged` | regenerate it from what is staged, and stage it (use right before a commit) |
28
33
  | `python3 <S>/context_state.py print` / `check` | show it / exit 1 when it is missing or stale |
@@ -32,7 +37,8 @@ backlog), §5.2 (closing a roadmap), §6 (Progress). Two scripts next to this fi
32
37
  ## When it runs
33
38
 
34
39
  - **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
40
+ (the installer prints this line). A project with history adds it after the rollout (WORKFLOW §12.4):
41
+ `--fix --write`, the sweep to zero, the owner's short list, then the CI line. Drift happens in the documents, so a CI that skips doc-only
36
42
  changes misses it.
37
43
  - **`softure-archive`** (on the main branch) and **`softure-roadmap`** (record, `--queue`, `--promote`,
38
44
  `--close`): `context_state.py write --staged` right before the commit, then `doctor.py`; each fixes
@@ -50,11 +56,78 @@ Each problem is one line `FAIL <code> <path>: <what>`. Fix the file it names, ne
50
56
  | `archived-change-status` | stamp the archived `change.md` `status: archived` (and `archived_at`) |
51
57
  | `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
58
  | `archived-roadmap-open-items` | rows of an archived roadmap end `done`, `done_code`, dropped or carried (with where they went) |
59
+ | `archived-roadmap-open-checks` | an archived roadmap still holds unticked owner entries: tick each with its evidence (`— done: <sha / release / path>`), as obsolete (`— obsolete: <reason>`), or carry it to a live roadmap or an `owner-word` issue and tick it with where it went |
53
60
  | `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into each `## Summary` row |
54
61
  | `queued-roadmap-done` | archive the finished queued roadmap to `foundation/archive/` |
55
62
  | `backlog-without-roadmap` | move live entries to a queued roadmap, then remove the folder |
56
63
  | `index-missing-file` | fix or drop the index row |
57
64
  | `state-missing` / `state-stale` | `context_state.py write`, commit `context/state.json` |
65
+ | `baseline-stale` | a baselined failure is fixed: `doctor.py --baseline` rewrites the file without it (commit it) |
66
+
67
+ ## Mechanical repairs: `--fix`
68
+
69
+ `doctor.py --fix` prints every edit it would make and the failures left after them; `--fix --write`
70
+ applies them. It writes only under `context/`, and a second run changes nothing. Two shapes are
71
+ mechanical:
72
+
73
+ - `archived-change-status`: the archived `change.md` gets `status: archived`, and the old value is kept
74
+ as `legacy_status` in its front matter (`implemented`, `done`, `impl_reviewed`, … stay readable);
75
+ - `index-missing-file` in an index inside an archive folder: the link is rewritten to the file's current
76
+ path when git history shows where it moved (renames followed across several moves); a file that was
77
+ deleted, not moved, is marked `(moved, not found; last seen in <sha>: <path>)`.
78
+
79
+ It skips, and names, every row it cannot settle from history (a live index, a target that was never
80
+ in git, a shallow checkout). Those and every other failure are judgement cases.
81
+
82
+ ## Sweep history to zero
83
+
84
+ `doctor.py --sweep --json` lists every failure left after `--fix` as one entry per thing to settle:
85
+ `code`, `path`, `line` and the exact `text` of the line, `evidence` (pointers of kind `commit`,
86
+ `release` or `file`, each with a note), `settle` (what to do), and `owner: true` when the repository
87
+ holds no evidence at all. The evidence it looks for:
88
+
89
+ | Code | Evidence |
90
+ |---|---|
91
+ | `archived-change-progress` | the SHA ticked items of the same phase cite; commits that touched the phase's files after the plan's date; the change's merge commit |
92
+ | `archived-roadmap-summary` | the merge (or squash) commit of the item's change on the main line; the last SHA of its archived plan |
93
+ | `archived-roadmap-open-items` | the item's archived change folder, its merge commit, the release that contains it, later roadmaps that mention it |
94
+ | `archived-roadmap-open-checks` | the same for the item the check names, plus the first release after the close (for pre-release steps) |
95
+ | anything else | the file to fix (`index-missing-file`: where git history says the file went, or that it never existed) |
96
+
97
+ Work the list in one change per repository (`docs(context): settle history to zero`):
98
+
99
+ 1. `doctor.py --fix --write` first, and commit it, so the sweep holds only judgement cases.
100
+ 2. For every entry, open its evidence (`git show <sha>`, the file, the release notes) and decide what
101
+ it proves. **Settle with evidence, never without:** write the proof into the line itself.
102
+ - Progress item: `- [x] <text> — <sha>` when that commit did it; `- [x] ~~<text>~~ — dropped: <reason>`
103
+ when the evidence shows it was never done and is no longer wanted.
104
+ - Summary placeholder: the merge SHA in the `Merge` cell.
105
+ - Open row: `done` (it shipped), `carried (to <path>)` (a later roadmap took it), `dropped (<reason>)`.
106
+ - Open check: `- [x] <text> — done: <sha | release | path>`, `- [x] <text> — obsolete: <reason, with
107
+ the evidence that made it obsolete>`, or carried (below).
108
+ 3. **Only true owner items stay open, in one place.** An entry is the owner's when the evidence does
109
+ not settle it and only the owner can: a real decision that is still open, or a step outside the
110
+ repository (a production setting, a secret, an account) that nothing shows as done. Carry it to the
111
+ live roadmap's `## Owner decisions and checks` (or an `owner-word` issue, WORKFLOW §8.6) and tick
112
+ the archived line `— carried to <path | #N>`. Never carry a check whose work the evidence shows done,
113
+ and never tick a decision on the owner's behalf.
114
+ 4. Regenerate the state (`context_state.py write`) and re-run `doctor.py` until it exits 0. Commit.
115
+ 5. Report: failures per code before and after, and **one short list for the owner**: `ID | what the
116
+ owner decides or does | where it lives now`. Nothing else is left open.
117
+
118
+ An entry the agent cannot settle and that is not the owner's (the evidence is ambiguous) is named in
119
+ the report with its evidence, not ticked.
120
+
121
+ ## Baseline: the last resort
122
+
123
+ `doctor.py --baseline` writes the failures that remain to `context/doctor-baseline.json`. The check
124
+ then reports them as `baselined` and fails only on a new failure and on a baseline entry that was
125
+ fixed but not removed (`baseline-stale`). It only shrinks: run again, it drops the fixed entries,
126
+ refuses to add new ones (exit 1, it names them) and removes the file once it is empty. State findings
127
+ are never baselined, and `--fix` and `--sweep` ignore the baseline.
128
+
129
+ Use it only when the owner decides a project cannot finish the sweep in one change; never to get a red
130
+ CI green, and never on your own initiative. Record why in the commit. The sweep to zero is the path.
58
131
 
59
132
  A project that has never written `context/state.json` gets a `note`, not a failure, until the first
60
133
  script run creates it.
@@ -62,8 +135,12 @@ script run creates it.
62
135
  ## Rules
63
136
 
64
137
  - `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.
138
+ - Never tick, fill or close anything in the sweep without the evidence written into the line.
139
+ - The doctor never edits anything, except `--fix --write`, which is run on purpose and edits only the
140
+ two mechanical shapes above. A skill that runs it fixes only the files it owns in that run.
141
+ - `open_changes`, `updated_at` and owner-queue entries from open changes are refreshed on every write
142
+ and never make the file stale, so a change branch that edits its own `change.md` keeps a green doctor.
143
+ - `owner_queue` reads only what is live (WORKFLOW §12.1): an unticked entry left in an archived roadmap
144
+ is a failure to settle, not something that waits for the owner.
68
145
  - Owner-word issues (label `owner-word`, WORKFLOW §8.6) live on the forge, not in `state.json`;
69
146
  an aggregator reads both.