@softure-ai/skills 0.21.0 → 0.23.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 +19 -10
- package/WORKFLOW.md +45 -23
- package/package.json +1 -1
- package/rules/AGENTS.md +1 -1
- package/scripts/install.mjs +37 -8
- package/scripts/portfolio.py +61 -8
- package/skills/softure-doctor/SKILL.md +35 -17
- package/skills/softure-doctor/references/state.schema.json +2 -1
- package/skills/softure-doctor/scripts/context_state.py +39 -3
- package/skills/softure-doctor/scripts/doctor.py +140 -35
- package/skills/softure-doctor/scripts/doctor_fix.py +64 -20
- package/skills/softure-doctor/scripts/doctor_sweep.py +180 -36
- package/skills/softure-init/SKILL.md +5 -0
- package/skills/softure-init/references/example.md +3 -1
package/README.md
CHANGED
|
@@ -29,16 +29,24 @@ 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
|
|
33
|
-
that already has history, once the rollout below
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
**CI job.** Run the doctor in a CI job named `context-doctor`, with no paths filter and no condition, so
|
|
33
|
+
documentation-only changes are checked too (in a project that already has history, once the rollout below
|
|
34
|
+
brings the doctor to zero). Keep that name: outside readers (`portfolio --source api`, an aggregator) look for
|
|
35
|
+
the `context-doctor` check run on the main branch's head.
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
context-doctor:
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
- run: npx --yes --package @softure-ai/skills@<version> softure-skills doctor
|
|
43
|
+
env:
|
|
44
|
+
npm_config_ignore_scripts: "true"
|
|
37
45
|
```
|
|
38
46
|
|
|
39
47
|
It fails on drift in `context/` (a roadmap left after its archive, archived changes not stamped,
|
|
40
48
|
`## Summary` placeholders, a stale `context/state.json`, …; WORKFLOW §12). The installer prints the
|
|
41
|
-
|
|
49
|
+
job until a workflow runs the doctor, and asks to rename a job that runs it under another name. `npx softure-skills state` regenerates `context/state.json`, which the
|
|
42
50
|
scripts otherwise write themselves.
|
|
43
51
|
|
|
44
52
|
**Rolling out to an existing project** (WORKFLOW §12.4). A project that adopted the package earlier
|
|
@@ -48,10 +56,11 @@ usually fails on history. Put it right, in this order, one pass per repository:
|
|
|
48
56
|
statuses, with the old value kept as `legacy_status`; archive index links to moved files). Commit.
|
|
49
57
|
2. `npx softure-skills doctor --sweep --json`, worked by an agent with the `softure-doctor` skill
|
|
50
58
|
("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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
without, in one change, until the doctor exits 0. Entries classed `superseded` (later roadmaps,
|
|
60
|
+
releases or changes made them obsolete) are closed by the agent as obsolete, never forwarded.
|
|
61
|
+
3. The owner's short list: only real owner items (a decision about future work, a secret, account or
|
|
62
|
+
connector, a step outside the repository), carried to the live roadmap or an `owner-word` issue.
|
|
63
|
+
4. The `context-doctor` job above, once the doctor is at zero.
|
|
55
64
|
|
|
56
65
|
`npx softure-skills doctor --baseline` exists only as a last resort, for a project that cannot finish
|
|
57
66
|
the history sweep at once: it accepts today's failures in `context/doctor-baseline.json`, the check
|
package/WORKFLOW.md
CHANGED
|
@@ -723,10 +723,11 @@ A project without the file gets it from the first of these runs; nothing has to
|
|
|
723
723
|
```jsonc
|
|
724
724
|
{
|
|
725
725
|
"schema_version": 1,
|
|
726
|
-
"project": "Example clinic", // workflow.json `project`, else the roadmap's
|
|
726
|
+
"project": "Example clinic", // workflow.json `project`, else the roadmap's, else the repository name; never null
|
|
727
727
|
"mode": "autonomous", "main_branch": "main",
|
|
728
728
|
"updated_at": "2026-11-20T09:00:00Z", // changes only when the content does
|
|
729
|
-
"active_roadmap": { // null when there is no roadmap.md
|
|
729
|
+
"active_roadmap": { // null when there is no roadmap.md, or it is the idle placeholder
|
|
730
|
+
// (front matter `status: idle` or `roadmap: none`)
|
|
730
731
|
"slug": "search", "title": "…", "status": "ready", "version": "2", "path": "context/foundation/roadmap.md",
|
|
731
732
|
"done": 2, "total": 5, // done = rows done or done_code (the report's X of N)
|
|
732
733
|
"items": [ // rows not done yet
|
|
@@ -780,13 +781,13 @@ its own `change.md` without touching `state.json`, and stays green.
|
|
|
780
781
|
| `roadmap-archived-not-removed` | `roadmap.md` is still there although the same roadmap (slug and version) is in `foundation/archive/` |
|
|
781
782
|
| `roadmap-status-mismatch` | `roadmap.md` says `done` while rows are open, or `waiting` (a queued roadmap's status) |
|
|
782
783
|
| `archived-change-status` | an archived `change.md` whose status is not `archived` |
|
|
783
|
-
| `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate) |
|
|
784
|
+
| `archived-change-progress` | an archived `plan.md` with unticked Automated items (open Manual items are legitimate; an item struck through or carrying a dropped/cancelled/not-applicable note is dropped, not open) |
|
|
784
785
|
| `archived-roadmap-open-items` | an archived roadmap with rows that are not `done`, `done_code`, dropped or carried |
|
|
785
|
-
| `archived-roadmap-summary` | an archived roadmap whose `## Summary` merge column holds
|
|
786
|
+
| `archived-roadmap-summary` | an archived roadmap whose `## Summary` item table (the table with a merge column; other tables there are ignored) holds a placeholder in the merge column; a SHA, a release tag, `carried`, `dropped` and `— <reason>` pass |
|
|
786
787
|
| `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 |
|
|
787
788
|
| `queued-roadmap-done` | a queued roadmap whose rows are all done, never archived |
|
|
788
789
|
| `backlog-without-roadmap` | `backlog/roadmap-<slug>/` without `roadmaps/roadmap-<slug>.md` (or the promoted main roadmap) |
|
|
789
|
-
| `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links or
|
|
790
|
+
| `index-missing-file` | a table row of a `README.md` or `INDEX.md` under `context/` that links a missing file: a markdown link, or a cell that is only a path in a file column (`File`, `Path`, `Document`, `Link`); a path mentioned in a description cell is not a link |
|
|
790
791
|
| `state-missing` | `context/state.json` is gone although git history holds it |
|
|
791
792
|
| `state-stale` | `context/state.json` does not match the markdown |
|
|
792
793
|
| `baseline-stale` | `context/doctor-baseline.json` lists a failure that no longer occurs (remove it), or is unreadable |
|
|
@@ -796,11 +797,13 @@ left after them; `--fix --write` applies them, only under `context/`, and a seco
|
|
|
796
797
|
|
|
797
798
|
- an archived change's `status` becomes `archived`; the old value is kept as `legacy_status` in its front matter;
|
|
798
799
|
- 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
|
-
|
|
800
|
+
the file's current path when git history shows where it moved (rename detection, followed across moves); a file
|
|
801
|
+
deleted on purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
802
|
+
- an unticked Progress item of an archived plan that is struck through or carries a dropped/cancelled/not-applicable
|
|
803
|
+
note is normalised to `- [x] ~~<item>~~ — dropped: <note>`.
|
|
801
804
|
|
|
802
|
-
A row whose
|
|
803
|
-
|
|
805
|
+
A row whose move or deletion the history does not show, and a live index, are left alone and named. A shallow clone
|
|
806
|
+
works on the commits it holds and names what lies past its edge. Everything else is a judgement case.
|
|
804
807
|
|
|
805
808
|
**Judgement cases: the sweep.** `npx softure-skills doctor --sweep [--json]` (read-only) lists every remaining failure
|
|
806
809
|
as one worklist entry per thing to settle (an unticked Progress item, a `## Summary` placeholder, an open row, an open
|
|
@@ -808,11 +811,16 @@ owner check), with `path`, `line`, the exact `text`, and evidence pointers found
|
|
|
808
811
|
Progress items the commits that touched the phase's files after the plan's date (and the SHA the phase's ticked items
|
|
809
812
|
cite); for `## Summary` placeholders the merge commit of the item's change (first-parent log, branch name, change ID in
|
|
810
813
|
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.
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
814
|
+
and later roadmaps that mention the item. Each entry has a class. `evidence`: the repository settles it. `superseded`:
|
|
815
|
+
no direct evidence, but later work made it obsolete (for an owner check or open row of an archived roadmap, a later
|
|
816
|
+
roadmap was closed and a release shipped after it, or the same item ID or file area appears in a later archived change;
|
|
817
|
+
for a Progress item, a later phase of the same plan is ticked); its evidence names that roadmap, release or change, and
|
|
818
|
+
the agent closes it as `obsolete: superseded by <ref>` itself, never forwards it. `owner`: only for what is still
|
|
819
|
+
meaningful today, a decision about future work, a secret, account or connector, or a step outside the repository whose
|
|
820
|
+
effect the agent cannot see; the entry says which (`owner_reason`) and what the sweep looked for (`tried`). The
|
|
821
|
+
`softure-doctor` skill ("Sweep history to zero") tells an agent how to work it: every entry is settled with its evidence
|
|
822
|
+
written into the line, never without; the owner entries are carried to the live roadmap's `## Owner decisions and
|
|
823
|
+
checks` or an `owner-word` issue and collected in one short list for the owner; nothing else is left open.
|
|
816
824
|
|
|
817
825
|
**Baseline: a last resort.** For a project that cannot finish the sweep at once, `doctor --baseline` writes the failures
|
|
818
826
|
that remain to `context/doctor-baseline.json` (`{ "note", "created", "entries": [ { "code", "path", "message" } ] }`).
|
|
@@ -822,9 +830,22 @@ fixed entries, never adds one (it names them and exits 1), and removes the file
|
|
|
822
830
|
never baselined; `--fix` and `--sweep` ignore it. It is the owner's call, recorded in the commit; the recommended path
|
|
823
831
|
is the sweep to zero.
|
|
824
832
|
|
|
825
|
-
A project that has never written `state.json` gets a note, not a failure. **Adopting projects run the doctor in
|
|
826
|
-
|
|
827
|
-
|
|
833
|
+
A project that has never written `state.json` gets a note, not a failure. **Adopting projects run the doctor in a CI
|
|
834
|
+
job named `context-doctor`**, with no paths filter and no condition, so documentation-only changes are checked too and
|
|
835
|
+
an outside reader finds the result by that name: the check run `context-doctor` on the main branch's head says whether
|
|
836
|
+
the project's context contract is green (`portfolio --source api` reads it). Keep the job name, whatever the rest of
|
|
837
|
+
the workflow looks like. The installer prints the job until a workflow under `.github/workflows/` runs the doctor, and
|
|
838
|
+
asks to rename it while the job that runs it has another name:
|
|
839
|
+
|
|
840
|
+
```yaml
|
|
841
|
+
context-doctor: # keep this name: readers look for the check run "context-doctor"
|
|
842
|
+
runs-on: ubuntu-latest
|
|
843
|
+
steps:
|
|
844
|
+
- uses: actions/checkout@v4
|
|
845
|
+
- run: npx --yes --package @softure-ai/skills@<version> softure-skills doctor
|
|
846
|
+
env:
|
|
847
|
+
npm_config_ignore_scripts: "true" # run the doctor only, no install into the checkout
|
|
848
|
+
``` `softure-archive` and `softure-roadmap --close` run it before their commit
|
|
828
849
|
and fix what they own.
|
|
829
850
|
|
|
830
851
|
### 12.3 Portfolio: many projects at once
|
|
@@ -843,7 +864,8 @@ The config file lives outside every project (`--config <file>`, `$SOFTURE_PORTFO
|
|
|
843
864
|
where `repo` is `owner/name`, a git URL or a local path. One row per project:
|
|
844
865
|
`project | active roadmap X/N | queued | open changes | owner queue | last release | doctor`. The doctor runs on the
|
|
845
866
|
same tree; a project without `state.json` yet gets one built in memory (marked `*`). `--source api` reads only
|
|
846
|
-
`state.json` through `gh api`
|
|
867
|
+
`state.json` through `gh api` and runs no doctor; its doctor column is the `context-doctor` check run on the main
|
|
868
|
+
branch's head (`ok`, `failing`, `pending`, or `missing` when the project has no job by that name). **Last release comes from the forge** when it can: the latest GitHub
|
|
847
869
|
release through `gh api` (both modes, for a GitHub repository; a local checkout counts when its `origin` is on GitHub),
|
|
848
870
|
else the highest `v*` tag (git mode), else `state.json` → `last_release`, which only records what a closed roadmap
|
|
849
871
|
wrote and is shown labelled: `v1.4.0 (roadmap, 2026-10-02)`. `--json` gives `last_release`, `last_release_date` and
|
|
@@ -861,12 +883,12 @@ long ago. The history is put right, not hidden. One pass per repository, in this
|
|
|
861
883
|
`softure-doctor` skill describes ("Sweep history to zero"): every tick, SHA, status and obsolete mark carries its
|
|
862
884
|
evidence (commit, release, file), never without. Regenerate the state, re-run the doctor until it exits 0, and land it
|
|
863
885
|
as one change: `docs(context): settle history to zero`.
|
|
864
|
-
3. **The owner's list.** What only the owner can settle (a decision
|
|
865
|
-
nothing shows done) was carried to the live roadmap's `## Owner decisions and checks` or an `owner-word` issue; the
|
|
886
|
+
3. **The owner's list.** What only the owner can settle (a decision about future work, a secret, account or connector,
|
|
887
|
+
a step outside the repository that nothing shows done) was carried to the live roadmap's `## Owner decisions and checks` or an `owner-word` issue; the
|
|
866
888
|
agent's report lists it once, short: `ID | what the owner decides or does | where it lives now`. Nothing else
|
|
867
889
|
waits, so `portfolio --owner` shows only these and the live roadmaps' entries.
|
|
868
|
-
4. **The CI
|
|
869
|
-
(
|
|
890
|
+
4. **The CI job at zero.** Once `npx softure-skills doctor` exits 0 on the main branch, add the `context-doctor` job
|
|
891
|
+
(§12.2; no paths filter, no condition), or rename the job that already runs the doctor to `context-doctor`. From then on every new drift is red where it happens.
|
|
870
892
|
|
|
871
893
|
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
|
-
|
|
894
|
+
`context-doctor` job 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.
|
|
3
|
+
"version": "0.23.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
|
@@ -37,7 +37,7 @@ The full contract is in `node_modules/@softure-ai/skills/WORKFLOW.md`.
|
|
|
37
37
|
|
|
38
38
|
`context/state.json` is the machine-readable state of the project (WORKFLOW §12). Only scripts write
|
|
39
39
|
it (`wt-roadmap.py`, and `context_state.py write --staged` in `softure-archive` and `softure-roadmap`),
|
|
40
|
-
in the same commit as the markdown; never edit it by hand. CI runs `npx softure-skills doctor
|
|
40
|
+
in the same commit as the markdown; never edit it by hand. CI runs `npx softure-skills doctor` in the job `context-doctor` (keep that name), which
|
|
41
41
|
fails on drift in `context/`: fix the file it names, never the check.
|
|
42
42
|
|
|
43
43
|
**Every change goes through the chain, however small.** A one-line fix reported in chat is a change
|
package/scripts/install.mjs
CHANGED
|
@@ -49,6 +49,18 @@ const SUBCOMMANDS = {
|
|
|
49
49
|
portfolio: [path.join(PACKAGE_ROOT, "scripts", "portfolio.py"), []],
|
|
50
50
|
};
|
|
51
51
|
const CI_LINE = "npx softure-skills doctor";
|
|
52
|
+
// The CI job that runs the doctor has this fixed name, so a reader (portfolio --source api, an aggregator)
|
|
53
|
+
// finds its check run on the main branch's head. No paths filter and no condition: it runs on every push.
|
|
54
|
+
const CI_JOB = "context-doctor";
|
|
55
|
+
const CI_JOB_YAML = (version) => [
|
|
56
|
+
` ${CI_JOB}: # keep this name: readers look for the check run "${CI_JOB}"`,
|
|
57
|
+
" runs-on: ubuntu-latest",
|
|
58
|
+
" steps:",
|
|
59
|
+
" - uses: actions/checkout@v4",
|
|
60
|
+
` - run: npx --yes --package @softure-ai/skills@${version} softure-skills doctor`,
|
|
61
|
+
" env:",
|
|
62
|
+
" npm_config_ignore_scripts: \"true\" # run the doctor only, no install into the checkout",
|
|
63
|
+
].join("\n");
|
|
52
64
|
// Issues with this label carry an owner decision the coordinator acts on (WORKFLOW.md §8.6).
|
|
53
65
|
const OWNER_WORD_LABEL = {
|
|
54
66
|
name: "owner-word",
|
|
@@ -80,14 +92,25 @@ function runSubcommand(name, args) {
|
|
|
80
92
|
return result.status ?? 1;
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
//
|
|
84
|
-
|
|
95
|
+
// How the project's GitHub workflows run the doctor: "named" (in a job whose id or name is CI_JOB),
|
|
96
|
+
// "unnamed" (somewhere else), or "none".
|
|
97
|
+
function doctorInCi(projectRoot) {
|
|
85
98
|
const dir = path.join(projectRoot, ".github", "workflows");
|
|
86
|
-
if (!fs.existsSync(dir)) return
|
|
87
|
-
|
|
99
|
+
if (!fs.existsSync(dir)) return "none";
|
|
100
|
+
const texts = fs
|
|
88
101
|
.readdirSync(dir)
|
|
89
102
|
.filter((name) => /\.ya?ml$/.test(name))
|
|
90
|
-
.
|
|
103
|
+
.map((name) => fs.readFileSync(path.join(dir, name), "utf8"))
|
|
104
|
+
.filter((text) => text.includes("softure-skills doctor"));
|
|
105
|
+
if (texts.length === 0) return "none";
|
|
106
|
+
return texts.some((text) => hasCiJob(text)) ? "named" : "unnamed";
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// True when a workflow has a job whose id or `name:` is CI_JOB (the name its check run carries).
|
|
110
|
+
function hasCiJob(text) {
|
|
111
|
+
const id = new RegExp(`^\\s+${CI_JOB}:\\s*(#.*)?$`, "m");
|
|
112
|
+
const name = new RegExp(`^\\s+name:\\s*["']?${CI_JOB}["']?\\s*(#.*)?$`, "m");
|
|
113
|
+
return id.test(text) || name.test(text);
|
|
91
114
|
}
|
|
92
115
|
|
|
93
116
|
function parseArgs(argv) {
|
|
@@ -283,8 +306,14 @@ function install(options) {
|
|
|
283
306
|
const prefix = options.isDryRun ? "[softure-skills] (dry run)" : "[softure-skills]";
|
|
284
307
|
for (const action of actions) console.log(`${prefix} ${action}`);
|
|
285
308
|
console.log(`${prefix} ${PACKAGE.name}@${PACKAGE.version} -> ${projectRoot}`);
|
|
286
|
-
if (
|
|
287
|
-
console.log(`${prefix}
|
|
309
|
+
if (fs.existsSync(path.join(projectRoot, WORKFLOW_CONFIG_PATH)) && !workflowConfig.project) {
|
|
310
|
+
console.log(`${prefix} ${WORKFLOW_CONFIG_PATH}: add "project": "<the name the project calls itself>" (context/state.json falls back to the repository name; softure-init asks for it)`);
|
|
311
|
+
}
|
|
312
|
+
const ci = doctorInCi(projectRoot);
|
|
313
|
+
if (ci === "none") {
|
|
314
|
+
console.log(`${prefix} CI: once \`${CI_LINE}\` exits 0 (rollout: doctor --fix, doctor --sweep; WORKFLOW.md §12.4), add this job to a workflow under .github/workflows/ that runs on every push and pull request, documentation-only changes included:\n${CI_JOB_YAML(PACKAGE.version)}`);
|
|
315
|
+
} else if (ci === "unnamed") {
|
|
316
|
+
console.log(`${prefix} CI: run the doctor in a job named \`${CI_JOB}\` (no paths filter, no condition), so its check run can be found by that name (WORKFLOW.md §12.2):\n${CI_JOB_YAML(PACKAGE.version)}`);
|
|
288
317
|
}
|
|
289
318
|
}
|
|
290
319
|
|
|
@@ -302,4 +331,4 @@ try {
|
|
|
302
331
|
process.exit(isPostinstall ? 0 : 1);
|
|
303
332
|
}
|
|
304
333
|
|
|
305
|
-
export { CI_LINE, OWNER_WORD_LABEL, replaceManagedBlock, selectRuleSections };
|
|
334
|
+
export { CI_JOB, CI_LINE, OWNER_WORD_LABEL, hasCiJob, replaceManagedBlock, selectRuleSections };
|
package/scripts/portfolio.py
CHANGED
|
@@ -17,8 +17,9 @@ branch is read; a local checkout is read at `origin/<mainBranch>` when that ref
|
|
|
17
17
|
`--source git` (default) reads `context/` of the main branch through git (a shallow, sparse, blob-less
|
|
18
18
|
clone into a temporary folder for a remote), takes `context/state.json`, and runs softure-doctor on the
|
|
19
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`)
|
|
21
|
-
|
|
20
|
+
`--source api` reads only `context/state.json` through the GitHub API (`gh api`) and runs no doctor: the
|
|
21
|
+
doctor column shows the `context-doctor` check run on the main branch's head instead (`ok`, `failing`,
|
|
22
|
+
`pending`, or `missing` when the project's CI has no job by that name).
|
|
22
23
|
|
|
23
24
|
Default output, one row per project:
|
|
24
25
|
|
|
@@ -30,7 +31,8 @@ repository, in both modes; a local checkout counts when its `origin` is on GitHu
|
|
|
30
31
|
`SOFTURE_GH` names another `gh` binary.
|
|
31
32
|
|
|
32
33
|
`--owner` prints only the owner queue across all projects, oldest first. `--json` prints the same data
|
|
33
|
-
for another tool (`last_release` is the version; `last_release_source` is `release`, `tag` or `roadmap
|
|
34
|
+
for another tool (`last_release` is the version; `last_release_source` is `release`, `tag` or `roadmap`;
|
|
35
|
+
with `--source api`, `doctor_check` is the check run's status and `doctor_check_url` its page). Exit 1 when a project could not be read (its row says why); nothing is ever written
|
|
34
36
|
outside a temporary folder.
|
|
35
37
|
"""
|
|
36
38
|
from __future__ import annotations
|
|
@@ -53,6 +55,9 @@ import doctor # noqa: E402
|
|
|
53
55
|
DEFAULT_CONFIG = os.path.join("~", ".config", "softure", "portfolio.json")
|
|
54
56
|
GITHUB_RE = re.compile(r"github\.com[:/]([\w.-]+/[\w.-]+?)(?:\.git)?/?$")
|
|
55
57
|
SEMVER_RE = re.compile(r"^v?(\d+)\.(\d+)\.(\d+)$")
|
|
58
|
+
# The CI job every adopting project runs the doctor in (WORKFLOW.md §12.2); its check run carries this name.
|
|
59
|
+
DOCTOR_CHECK = "context-doctor"
|
|
60
|
+
PASSING = ("success", "neutral", "skipped")
|
|
56
61
|
|
|
57
62
|
|
|
58
63
|
def git(*args: str, cwd: str | None = None, check: bool = True) -> subprocess.CompletedProcess:
|
|
@@ -128,6 +133,44 @@ def forge_release(slug: str | None) -> dict | None:
|
|
|
128
133
|
return {"version": data["tag_name"], "date": (data.get("published_at") or "")[:10] or None, "source": "release"}
|
|
129
134
|
|
|
130
135
|
|
|
136
|
+
def gh_json(path: str):
|
|
137
|
+
"""`gh api <path>` as JSON; None without gh, access or a valid answer."""
|
|
138
|
+
try:
|
|
139
|
+
shown = subprocess.run([gh(), "api", path], capture_output=True, text=True, timeout=30)
|
|
140
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
141
|
+
return None
|
|
142
|
+
if shown.returncode != 0:
|
|
143
|
+
return None
|
|
144
|
+
try:
|
|
145
|
+
return json.loads(shown.stdout)
|
|
146
|
+
except json.JSONDecodeError:
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def doctor_check(slug: str, branch: str | None) -> dict:
|
|
151
|
+
"""The newest `context-doctor` check run on the head of `branch` (else the default branch).
|
|
152
|
+
|
|
153
|
+
`status` is `ok`, `failing`, `pending`, `missing` (no check run by that name), or `unknown` (the forge
|
|
154
|
+
could not be asked).
|
|
155
|
+
"""
|
|
156
|
+
if not branch:
|
|
157
|
+
branch = (gh_json(f"repos/{slug}") or {}).get("default_branch")
|
|
158
|
+
if not branch:
|
|
159
|
+
return {"status": "unknown", "url": None}
|
|
160
|
+
data = gh_json(f"repos/{slug}/commits/{branch}/check-runs?check_name={DOCTOR_CHECK}&filter=latest")
|
|
161
|
+
if not isinstance(data, dict):
|
|
162
|
+
return {"status": "unknown", "url": None}
|
|
163
|
+
runs = [run for run in data.get("check_runs") or [] if run.get("name") == DOCTOR_CHECK]
|
|
164
|
+
if not runs:
|
|
165
|
+
return {"status": "missing", "url": None}
|
|
166
|
+
run = max(runs, key=lambda run: (run.get("started_at") or "", run.get("id") or 0))
|
|
167
|
+
if run.get("status") != "completed":
|
|
168
|
+
status = "pending"
|
|
169
|
+
else:
|
|
170
|
+
status = "ok" if run.get("conclusion") in PASSING else "failing"
|
|
171
|
+
return {"status": status, "url": run.get("html_url")}
|
|
172
|
+
|
|
173
|
+
|
|
131
174
|
def pick_release(forge: dict | None, tag: dict | None, state: dict | None) -> dict:
|
|
132
175
|
"""The forge's release, else the highest tag, else the roadmap-recorded value (labelled as such)."""
|
|
133
176
|
for found in (forge, tag):
|
|
@@ -216,8 +259,10 @@ def read_api(project: dict) -> dict:
|
|
|
216
259
|
elif "404" not in shown.stderr and "Not Found" not in shown.stderr:
|
|
217
260
|
raise RuntimeError(f"gh api failed: {shown.stderr.strip()[:200]}")
|
|
218
261
|
release = pick_release(forge_release(slug), None, state)
|
|
262
|
+
check = doctor_check(slug, project.get("branch"))
|
|
219
263
|
return {"branch": project.get("branch") or "default", "state": state, "state_source": source,
|
|
220
|
-
"doctor": None,
|
|
264
|
+
"doctor": None, "doctor_check": check["status"], "doctor_check_url": check["url"],
|
|
265
|
+
**release_fields(release)}
|
|
221
266
|
|
|
222
267
|
|
|
223
268
|
def release_fields(release: dict) -> dict:
|
|
@@ -248,17 +293,25 @@ def collect(projects: list[dict], source: str) -> list[dict]:
|
|
|
248
293
|
return rows
|
|
249
294
|
|
|
250
295
|
|
|
296
|
+
def check_cell(row: dict) -> str:
|
|
297
|
+
"""The doctor column of a row read through the API: the `context-doctor` check run, else `n/a`."""
|
|
298
|
+
check = row.get("doctor_check")
|
|
299
|
+
return check if check and check != "unknown" else "n/a"
|
|
300
|
+
|
|
301
|
+
|
|
251
302
|
def summary_cells(row: dict) -> list[str]:
|
|
252
303
|
name = row["name"] + ("*" if row.get("state_source") == "built" else "")
|
|
253
304
|
if row["error"]:
|
|
254
305
|
return [name, f"error: {row['error']}", "", "", "", "", ""]
|
|
255
306
|
state = row["state"]
|
|
256
307
|
if state is None:
|
|
257
|
-
return [name, "no state.json", "—", "—", "—", release_cell(row),
|
|
308
|
+
return [name, "no state.json", "—", "—", "—", release_cell(row), check_cell(row)]
|
|
258
309
|
active = state.get("active_roadmap")
|
|
259
310
|
roadmap = f"{active.get('slug') or '?'} {active['done']}/{active['total']}" if active else "—"
|
|
260
|
-
|
|
261
|
-
|
|
311
|
+
if row["doctor"] is not None:
|
|
312
|
+
doctor_cell = "ok" if not row["doctor"] else f"{len(row['doctor'])} failing"
|
|
313
|
+
else:
|
|
314
|
+
doctor_cell = check_cell(row)
|
|
262
315
|
return [name, roadmap, str(len(state.get("queued", []))), str(len(state.get("open_changes", []))),
|
|
263
316
|
str(len(state.get("owner_queue", []))), release_cell(row), doctor_cell]
|
|
264
317
|
|
|
@@ -325,4 +378,4 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
325
378
|
|
|
326
379
|
|
|
327
380
|
if __name__ == "__main__":
|
|
328
|
-
sys.exit(main
|
|
381
|
+
sys.exit(context_state.quiet_broken_pipe(main))
|
|
@@ -36,9 +36,10 @@ backlog), §5.2 (closing a roadmap), §6 (Progress). Two scripts next to this fi
|
|
|
36
36
|
|
|
37
37
|
## When it runs
|
|
38
38
|
|
|
39
|
-
- **CI of every adopting project**, documentation-only changes included: `npx softure-skills doctor`
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
- **CI of every adopting project**, documentation-only changes included: `npx softure-skills doctor` in a job
|
|
40
|
+
named `context-doctor`, with no paths filter and no condition (the installer prints the job; WORKFLOW §12.2).
|
|
41
|
+
Keep the name: outside readers look for that check run on the main branch's head. A project with history adds it after the rollout (WORKFLOW §12.4):
|
|
42
|
+
`--fix --write`, the sweep to zero, the owner's short list, then the CI job. Drift happens in the documents, so a CI that skips doc-only
|
|
42
43
|
changes misses it.
|
|
43
44
|
- **`softure-archive`** (on the main branch) and **`softure-roadmap`** (record, `--queue`, `--promote`,
|
|
44
45
|
`--close`): `context_state.py write --staged` right before the commit, then `doctor.py`; each fixes
|
|
@@ -54,37 +55,47 @@ Each problem is one line `FAIL <code> <path>: <what>`. Fix the file it names, ne
|
|
|
54
55
|
| `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) |
|
|
55
56
|
| `roadmap-status-mismatch` | set `status` to match the rows (`done` only when every row is closed; `waiting` belongs to queued roadmaps) |
|
|
56
57
|
| `archived-change-status` | stamp the archived `change.md` `status: archived` (and `archived_at`) |
|
|
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
|
|
58
|
+
| `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>`. An item struck through or carrying a dropped/cancelled/not-applicable note is already dropped and never counts (`--fix` normalises it) |
|
|
58
59
|
| `archived-roadmap-open-items` | rows of an archived roadmap end `done`, `done_code`, dropped or carried (with where they went) |
|
|
59
60
|
| `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 |
|
|
60
|
-
| `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into
|
|
61
|
+
| `archived-roadmap-summary` | put the merge SHA (`git log --merges --grep "<change-id>"`) into the row's merge cell. Only the item table (the one with a merge column) is read; a SHA, a release tag (where the roadmap records a release instead of a merge), `carried`, `dropped` and `— <reason>` pass |
|
|
61
62
|
| `queued-roadmap-done` | archive the finished queued roadmap to `foundation/archive/` |
|
|
62
63
|
| `backlog-without-roadmap` | move live entries to a queued roadmap, then remove the folder |
|
|
63
|
-
| `index-missing-file` | fix or drop the
|
|
64
|
+
| `index-missing-file` | a real link (a markdown link, or a cell that is only a path in a file column) points at a missing file: fix or drop the row; a path mentioned in a description cell never fails |
|
|
64
65
|
| `state-missing` / `state-stale` | `context_state.py write`, commit `context/state.json` |
|
|
65
66
|
| `baseline-stale` | a baselined failure is fixed: `doctor.py --baseline` rewrites the file without it (commit it) |
|
|
66
67
|
|
|
67
68
|
## Mechanical repairs: `--fix`
|
|
68
69
|
|
|
69
70
|
`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.
|
|
71
|
+
applies them. It writes only under `context/`, and a second run changes nothing. Three shapes are
|
|
71
72
|
mechanical:
|
|
72
73
|
|
|
73
74
|
- `archived-change-status`: the archived `change.md` gets `status: archived`, and the old value is kept
|
|
74
75
|
as `legacy_status` in its front matter (`implemented`, `done`, `impl_reviewed`, … stay readable);
|
|
75
76
|
- `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
|
|
77
|
-
|
|
77
|
+
path when git history shows where it moved (renames followed across several moves); a file deleted on
|
|
78
|
+
purpose (git shows the deletion, no rename) is marked `(removed in <sha>)` with the deleting commit;
|
|
79
|
+
- a dropped Progress item of an archived plan (unticked, but struck through or carrying an explicit
|
|
80
|
+
dropped/cancelled/not-applicable note) is normalised to `- [x] ~~<item>~~ — dropped: <note>`.
|
|
78
81
|
|
|
79
|
-
It skips, and names, every row it cannot settle from history (a live index, a target
|
|
80
|
-
|
|
82
|
+
It skips, and names, every row it cannot settle from history (a live index, a target whose move or
|
|
83
|
+
deletion the history does not show). A shallow clone works on the commits it holds and names what lies
|
|
84
|
+
past its edge (`git fetch --deepen <n>` reaches further). Those and every other failure are judgement cases.
|
|
81
85
|
|
|
82
86
|
## Sweep history to zero
|
|
83
87
|
|
|
84
88
|
`doctor.py --sweep --json` lists every failure left after `--fix` as one entry per thing to settle:
|
|
85
89
|
`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
|
|
87
|
-
|
|
90
|
+
`release` or `file`, each with a note), `settle` (what to do), and a `class`:
|
|
91
|
+
|
|
92
|
+
| Class | Means | Who settles it |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `evidence` | the repository holds proof (below) | the agent, with that proof |
|
|
95
|
+
| `superseded` | no direct proof, but later work made it obsolete: for an owner check or open row of an archived roadmap, a later roadmap was closed and a release shipped after it, or the same item ID or file area appears in a later archived change; for a Progress item, a later phase of the same plan is ticked. Its `evidence` names the roadmap, release or change | the agent, as obsolete; never forwarded |
|
|
96
|
+
| `owner` (`owner: true`) | still meaningful today and only the owner can settle it: a decision about future work (`owner_reason: decision`), a secret, account or connector (`secret`), a step outside the repository whose effect the agent cannot see (`outside`), or nothing found at all (`unsettled`). `tried` says what the sweep looked for | the owner |
|
|
97
|
+
|
|
98
|
+
The evidence it looks for:
|
|
88
99
|
|
|
89
100
|
| Code | Evidence |
|
|
90
101
|
|---|---|
|
|
@@ -101,13 +112,20 @@ Work the list in one change per repository (`docs(context): settle history to ze
|
|
|
101
112
|
it proves. **Settle with evidence, never without:** write the proof into the line itself.
|
|
102
113
|
- Progress item: `- [x] <text> — <sha>` when that commit did it; `- [x] ~~<text>~~ — dropped: <reason>`
|
|
103
114
|
when the evidence shows it was never done and is no longer wanted.
|
|
104
|
-
- Summary placeholder: the merge SHA in the `Merge` cell
|
|
115
|
+
- Summary placeholder: the merge SHA in the `Merge` cell (a release tag, `carried`, `dropped` or
|
|
116
|
+
`— <reason>` where there is no merge).
|
|
105
117
|
- Open row: `done` (it shipped), `carried (to <path>)` (a later roadmap took it), `dropped (<reason>)`.
|
|
106
118
|
- Open check: `- [x] <text> — done: <sha | release | path>`, `- [x] <text> — obsolete: <reason, with
|
|
107
119
|
the evidence that made it obsolete>`, or carried (below).
|
|
120
|
+
- `superseded` entry: close it yourself as obsolete, with its evidence: `- [x] <text> — obsolete:
|
|
121
|
+
superseded by <release / roadmap / change>` (a row: `dropped (obsolete: superseded by <ref>)`).
|
|
122
|
+
Never forward it to the owner: a screenshot review of a page rebuilt since, or "after the release,
|
|
123
|
+
re-run X" for a release long gone, has no answer the owner could give.
|
|
108
124
|
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
|
|
110
|
-
|
|
125
|
+
not settle it, nothing later superseded it, and only the owner can: a decision about future work
|
|
126
|
+
that is still open, a secret, account or connector, or a step outside the repository (a production
|
|
127
|
+
setting, a real device) whose effect the agent cannot see. Before forwarding an `unsettled` entry,
|
|
128
|
+
try what its `tried` lines did not, and say in the report what you tried. Carry it to the
|
|
111
129
|
live roadmap's `## Owner decisions and checks` (or an `owner-word` issue, WORKFLOW §8.6) and tick
|
|
112
130
|
the archived line `— carried to <path | #N>`. Never carry a check whose work the evidence shows done,
|
|
113
131
|
and never tick a decision on the owner's behalf.
|
|
@@ -137,7 +155,7 @@ script run creates it.
|
|
|
137
155
|
- `context/state.json` is written by scripts only. Never edit it by hand; regenerate it.
|
|
138
156
|
- Never tick, fill or close anything in the sweep without the evidence written into the line.
|
|
139
157
|
- The doctor never edits anything, except `--fix --write`, which is run on purpose and edits only the
|
|
140
|
-
|
|
158
|
+
mechanical shapes above. A skill that runs it fixes only the files it owns in that run.
|
|
141
159
|
- `open_changes`, `updated_at` and owner-queue entries from open changes are refreshed on every write
|
|
142
160
|
and never make the file stale, so a change branch that edits its own `change.md` keeps a green doctor.
|
|
143
161
|
- `owner_queue` reads only what is live (WORKFLOW §12.1): an unticked entry left in an archived roadmap
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
"additionalProperties": false,
|
|
10
10
|
"properties": {
|
|
11
11
|
"schema_version": { "type": "integer", "enum": [1] },
|
|
12
|
-
"project": { "type":
|
|
12
|
+
"project": { "type": "string", "description": "workflow.json `project`, else the active roadmap's `project`, else the repository name (origin's URL, else the folder); never null" },
|
|
13
13
|
"mode": { "type": "string", "enum": ["manual", "autonomous"] },
|
|
14
14
|
"main_branch": { "type": ["string", "null"] },
|
|
15
15
|
"updated_at": { "type": "string", "description": "UTC ISO 8601; changes only when the content does" },
|
|
16
16
|
"active_roadmap": {
|
|
17
17
|
"type": ["object", "null"],
|
|
18
|
+
"description": "null when roadmap.md is absent or is the idle placeholder (status: idle or roadmap: none)",
|
|
18
19
|
"required": ["slug", "title", "status", "version", "path", "done", "total", "items"],
|
|
19
20
|
"additionalProperties": false,
|
|
20
21
|
"properties": {
|
|
@@ -417,7 +417,7 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
417
417
|
active = None
|
|
418
418
|
roadmap_text = reader.read(ROADMAP_PATH)
|
|
419
419
|
rows_by_change: dict[str, dict] = {}
|
|
420
|
-
if roadmap_text is not None:
|
|
420
|
+
if roadmap_text is not None and not is_idle_placeholder(roadmap_text):
|
|
421
421
|
meta = frontmatter(roadmap_text)
|
|
422
422
|
rows = roadmap_rows(roadmap_text)
|
|
423
423
|
done, total = _summary(rows)
|
|
@@ -494,7 +494,8 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
494
494
|
|
|
495
495
|
state = {
|
|
496
496
|
"schema_version": SCHEMA_VERSION,
|
|
497
|
-
"project": workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
|
|
497
|
+
"project": (workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
|
|
498
|
+
or repository_name(reader)),
|
|
498
499
|
"mode": workflow.get("mode") or "manual",
|
|
499
500
|
"main_branch": workflow.get("mainBranch"),
|
|
500
501
|
"updated_at": now or dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"),
|
|
@@ -507,6 +508,26 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
507
508
|
return state
|
|
508
509
|
|
|
509
510
|
|
|
511
|
+
def is_idle_placeholder(text: str) -> bool:
|
|
512
|
+
"""A `roadmap.md` that only says there is no active roadmap (`status: idle` or `roadmap: none`)."""
|
|
513
|
+
meta = frontmatter(text)
|
|
514
|
+
return (meta.get("status") or "").lower() == "idle" or (meta.get("roadmap") or "").lower() == "none"
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def repository_name(reader) -> str:
|
|
518
|
+
"""The repository's name: the last segment of `origin`'s URL, else the checkout's folder name.
|
|
519
|
+
|
|
520
|
+
The last fallback for `project`, so a project between roadmaps without `project` in workflow.json still
|
|
521
|
+
has a name. The URL comes first because a checkout's folder can be named anything (a worktree, a clone
|
|
522
|
+
into a temporary folder).
|
|
523
|
+
"""
|
|
524
|
+
folder = getattr(reader, "root", None) or getattr(reader, "repo", None) or os.getcwd()
|
|
525
|
+
url = subprocess.run(["git", "-C", folder, "remote", "get-url", "origin"], capture_output=True,
|
|
526
|
+
text=True).stdout.strip()
|
|
527
|
+
name = re.split(r"[/:]", url.rstrip("/"))[-1] if url else os.path.basename(os.path.abspath(folder))
|
|
528
|
+
return re.sub(r"\.git$", "", name) or "unnamed"
|
|
529
|
+
|
|
530
|
+
|
|
510
531
|
def _start_order(text: str) -> str | None:
|
|
511
532
|
"""A run-wide order about starting the roadmap (`> - Start: …`), when the header has one."""
|
|
512
533
|
for line in (text or "").splitlines():
|
|
@@ -581,6 +602,21 @@ def repo_root(start: str) -> str:
|
|
|
581
602
|
return out.stdout.strip() if out.returncode == 0 else os.path.abspath(start)
|
|
582
603
|
|
|
583
604
|
|
|
605
|
+
def quiet_broken_pipe(run) -> int:
|
|
606
|
+
"""Run a CLI entry point; when stdout is closed early (`doctor --sweep | head`), stop quietly with 141.
|
|
607
|
+
|
|
608
|
+
141 is what a shell reports for a process ended by SIGPIPE; no traceback, no "Exception ignored".
|
|
609
|
+
"""
|
|
610
|
+
try:
|
|
611
|
+
code = run()
|
|
612
|
+
sys.stdout.flush()
|
|
613
|
+
return code
|
|
614
|
+
except BrokenPipeError:
|
|
615
|
+
devnull = os.open(os.devnull, os.O_WRONLY)
|
|
616
|
+
os.dup2(devnull, sys.stdout.fileno()) # the interpreter's final flush must not fail again
|
|
617
|
+
return 141
|
|
618
|
+
|
|
619
|
+
|
|
584
620
|
def main(argv: list[str] | None = None) -> int:
|
|
585
621
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
586
622
|
root = None
|
|
@@ -619,4 +655,4 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
619
655
|
|
|
620
656
|
|
|
621
657
|
if __name__ == "__main__":
|
|
622
|
-
sys.exit(main
|
|
658
|
+
sys.exit(quiet_broken_pipe(main))
|