@softure-ai/skills 0.22.0 → 0.24.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 +21 -8
- package/WORKFLOW.md +88 -16
- package/package.json +1 -1
- package/rules/AGENTS.md +8 -3
- package/scripts/install.mjs +37 -8
- package/scripts/portfolio.py +83 -10
- package/skills/softure-doctor/SKILL.md +21 -8
- package/skills/softure-doctor/references/state.schema.json +4 -2
- package/skills/softure-doctor/scripts/context_state.py +119 -8
- package/skills/softure-doctor/scripts/doctor.py +111 -11
- package/skills/softure-doctor/scripts/doctor_fix.py +66 -0
- package/skills/softure-doctor/scripts/doctor_sweep.py +174 -8
- package/skills/softure-init/SKILL.md +5 -0
- package/skills/softure-init/references/example.md +3 -1
- package/skills/softure-roadmap/SKILL.md +18 -4
- package/skills/softure-roadmap/references/example-roadmap.md +30 -0
- package/skills/softure-roadmap/references/slicing.md +12 -3
|
@@ -19,14 +19,19 @@ release is recorded. An unticked entry left in any other archived roadmap is his
|
|
|
19
19
|
(`../references/state.schema.json`). A reader needs this one file per repository instead of parsing
|
|
20
20
|
the markdown.
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Every owner-queue entry has an `id`: a short hash of its `source`, `item` and text, taken when the entry first
|
|
23
|
+
appears. `id` and `since` are kept from the previous file for an entry that is still there, also when only its
|
|
24
|
+
wording changed or its heading moved within the same file (the same item, or text that is still close enough),
|
|
25
|
+
so a reader can follow one entry across rewrites and "oldest first" stays true. `updated_at` changes only when the
|
|
26
|
+
content does.
|
|
24
27
|
|
|
25
28
|
Importable: `from context_state import build_state, render_state, FsReader, GitReader, IndexReader`.
|
|
26
29
|
"""
|
|
27
30
|
from __future__ import annotations
|
|
28
31
|
|
|
29
32
|
import datetime as dt
|
|
33
|
+
import difflib
|
|
34
|
+
import hashlib
|
|
30
35
|
import json
|
|
31
36
|
import os
|
|
32
37
|
import re
|
|
@@ -35,7 +40,7 @@ import sys
|
|
|
35
40
|
|
|
36
41
|
sys.dont_write_bytecode = True # no __pycache__ inside the consumer's .claude/skills
|
|
37
42
|
|
|
38
|
-
SCHEMA_VERSION =
|
|
43
|
+
SCHEMA_VERSION = 2
|
|
39
44
|
STATE_PATH = "context/state.json"
|
|
40
45
|
WORKFLOW_PATH = "context/workflow.json"
|
|
41
46
|
ROADMAP_PATH = "context/foundation/roadmap.md"
|
|
@@ -417,7 +422,7 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
417
422
|
active = None
|
|
418
423
|
roadmap_text = reader.read(ROADMAP_PATH)
|
|
419
424
|
rows_by_change: dict[str, dict] = {}
|
|
420
|
-
if roadmap_text is not None:
|
|
425
|
+
if roadmap_text is not None and not is_idle_placeholder(roadmap_text):
|
|
421
426
|
meta = frontmatter(roadmap_text)
|
|
422
427
|
rows = roadmap_rows(roadmap_text)
|
|
423
428
|
done, total = _summary(rows)
|
|
@@ -487,14 +492,13 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
487
492
|
owner_queue += _handoff_entries(f"{CHANGES_DIR}/{name}/change.md", text, meta.get("roadmap_item"),
|
|
488
493
|
meta.get("updated") or today)
|
|
489
494
|
|
|
490
|
-
|
|
491
|
-
for entry in owner_queue:
|
|
492
|
-
entry["since"] = previous.get(_entry_key(entry)) or entry["since"]
|
|
495
|
+
owner_queue = carry_identity(owner_queue, (prior or {}).get("owner_queue") or [])
|
|
493
496
|
owner_queue.sort(key=lambda entry: (entry["since"] or "", entry["source"], entry["text"]))
|
|
494
497
|
|
|
495
498
|
state = {
|
|
496
499
|
"schema_version": SCHEMA_VERSION,
|
|
497
|
-
"project": workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
|
|
500
|
+
"project": (workflow.get("project") or (frontmatter(roadmap_text).get("project") if roadmap_text else None)
|
|
501
|
+
or repository_name(reader)),
|
|
498
502
|
"mode": workflow.get("mode") or "manual",
|
|
499
503
|
"main_branch": workflow.get("mainBranch"),
|
|
500
504
|
"updated_at": now or dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"),
|
|
@@ -507,6 +511,26 @@ def build_state(reader, prior: dict | None = None, now: str | None = None) -> di
|
|
|
507
511
|
return state
|
|
508
512
|
|
|
509
513
|
|
|
514
|
+
def is_idle_placeholder(text: str) -> bool:
|
|
515
|
+
"""A `roadmap.md` that only says there is no active roadmap (`status: idle` or `roadmap: none`)."""
|
|
516
|
+
meta = frontmatter(text)
|
|
517
|
+
return (meta.get("status") or "").lower() == "idle" or (meta.get("roadmap") or "").lower() == "none"
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
def repository_name(reader) -> str:
|
|
521
|
+
"""The repository's name: the last segment of `origin`'s URL, else the checkout's folder name.
|
|
522
|
+
|
|
523
|
+
The last fallback for `project`, so a project between roadmaps without `project` in workflow.json still
|
|
524
|
+
has a name. The URL comes first because a checkout's folder can be named anything (a worktree, a clone
|
|
525
|
+
into a temporary folder).
|
|
526
|
+
"""
|
|
527
|
+
folder = getattr(reader, "root", None) or getattr(reader, "repo", None) or os.getcwd()
|
|
528
|
+
url = subprocess.run(["git", "-C", folder, "remote", "get-url", "origin"], capture_output=True,
|
|
529
|
+
text=True).stdout.strip()
|
|
530
|
+
name = re.split(r"[/:]", url.rstrip("/"))[-1] if url else os.path.basename(os.path.abspath(folder))
|
|
531
|
+
return re.sub(r"\.git$", "", name) or "unnamed"
|
|
532
|
+
|
|
533
|
+
|
|
510
534
|
def _start_order(text: str) -> str | None:
|
|
511
535
|
"""A run-wide order about starting the roadmap (`> - Start: …`), when the header has one."""
|
|
512
536
|
for line in (text or "").splitlines():
|
|
@@ -520,6 +544,93 @@ def _entry_key(entry: dict) -> tuple:
|
|
|
520
544
|
return (entry.get("kind"), entry.get("source"), entry.get("text"))
|
|
521
545
|
|
|
522
546
|
|
|
547
|
+
# Text of an unmatched entry this close to a prior entry's text (difflib ratio) is the same entry reworded.
|
|
548
|
+
REWORD_RATIO = 0.6
|
|
549
|
+
# The same, across headings of one file (a moved entry): stricter, because the section changed too.
|
|
550
|
+
MOVED_RATIO = 0.8
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def entry_id(entry: dict) -> str:
|
|
554
|
+
"""A short id for a new owner-queue entry: a hash of its source, item and first line."""
|
|
555
|
+
first_line = (entry.get("text") or "").strip().splitlines()[0] if (entry.get("text") or "").strip() else ""
|
|
556
|
+
seed = "\n".join((entry.get("source") or "", entry.get("item") or "", first_line))
|
|
557
|
+
return "oq-" + hashlib.sha1(seed.encode("utf-8")).hexdigest()[:10]
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
def _file_of(source: str | None) -> str:
|
|
561
|
+
return (source or "").split("#", 1)[0]
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def _same_entry_score(new: dict, old: dict) -> float | None:
|
|
565
|
+
"""How surely `old` (prior file) is `new` reworded or moved; None when it is not."""
|
|
566
|
+
if _file_of(new.get("source")) != _file_of(old.get("source")):
|
|
567
|
+
return None
|
|
568
|
+
same_section = new.get("source") == old.get("source")
|
|
569
|
+
ratio = difflib.SequenceMatcher(None, new.get("text") or "", old.get("text") or "").ratio()
|
|
570
|
+
if new.get("item") and new.get("item") == old.get("item") and new.get("kind") == old.get("kind"):
|
|
571
|
+
return 1.0 + ratio + (1.0 if same_section else 0.0)
|
|
572
|
+
if new.get("item") != old.get("item"):
|
|
573
|
+
return None
|
|
574
|
+
if ratio >= (REWORD_RATIO if same_section else MOVED_RATIO):
|
|
575
|
+
return ratio + (1.0 if same_section else 0.0)
|
|
576
|
+
return None
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def carry_identity(entries: list[dict], prior: list[dict]) -> list[dict]:
|
|
580
|
+
"""Give every entry an `id` and keep `id` and `since` of the prior entry it continues.
|
|
581
|
+
|
|
582
|
+
An entry with the same kind, source and text as a prior one continues it. Each remaining entry continues the
|
|
583
|
+
prior one it matches best: the same file, and the same item and kind, or (without an item) text that is still
|
|
584
|
+
close enough (`REWORD_RATIO` under the same heading, `MOVED_RATIO` under another). A prior entry is continued
|
|
585
|
+
at most once. Anything else is new and gets a fresh id; ids stay unique within the queue.
|
|
586
|
+
"""
|
|
587
|
+
unmatched = list(prior)
|
|
588
|
+
exact: dict[tuple, list[dict]] = {}
|
|
589
|
+
for old in unmatched:
|
|
590
|
+
exact.setdefault(_entry_key(old), []).append(old)
|
|
591
|
+
pending = []
|
|
592
|
+
for entry in entries:
|
|
593
|
+
candidates = exact.get(_entry_key(entry))
|
|
594
|
+
if candidates:
|
|
595
|
+
old = candidates.pop(0)
|
|
596
|
+
unmatched.remove(old)
|
|
597
|
+
_continue(entry, old)
|
|
598
|
+
else:
|
|
599
|
+
pending.append(entry)
|
|
600
|
+
pairs = []
|
|
601
|
+
for new_index, entry in enumerate(pending):
|
|
602
|
+
for old_index, old in enumerate(unmatched):
|
|
603
|
+
score = _same_entry_score(entry, old)
|
|
604
|
+
if score is not None:
|
|
605
|
+
pairs.append((score, new_index, old_index))
|
|
606
|
+
taken_new: set[int] = set()
|
|
607
|
+
taken_old: set[int] = set()
|
|
608
|
+
for _score, new_index, old_index in sorted(pairs, key=lambda pair: (-pair[0], pair[1], pair[2])):
|
|
609
|
+
if new_index in taken_new or old_index in taken_old:
|
|
610
|
+
continue
|
|
611
|
+
taken_new.add(new_index)
|
|
612
|
+
taken_old.add(old_index)
|
|
613
|
+
_continue(pending[new_index], unmatched[old_index])
|
|
614
|
+
used: set[str] = set()
|
|
615
|
+
result = []
|
|
616
|
+
for entry in entries:
|
|
617
|
+
ident = entry.get("id") if entry.get("id") not in used else None
|
|
618
|
+
if not ident:
|
|
619
|
+
base = entry_id(entry)
|
|
620
|
+
ident, suffix = base, 2
|
|
621
|
+
while ident in used:
|
|
622
|
+
ident, suffix = f"{base}-{suffix}", suffix + 1
|
|
623
|
+
used.add(ident)
|
|
624
|
+
result.append({"id": ident, **{key: value for key, value in entry.items() if key != "id"}})
|
|
625
|
+
return result
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
def _continue(entry: dict, old: dict) -> None:
|
|
629
|
+
if old.get("id"):
|
|
630
|
+
entry["id"] = old["id"]
|
|
631
|
+
entry["since"] = old.get("since") or entry["since"]
|
|
632
|
+
|
|
633
|
+
|
|
523
634
|
def comparable(state: dict | None) -> dict | None:
|
|
524
635
|
"""The state without what a rewrite may change on its own (VOLATILE_FIELDS, VOLATILE_SOURCES)."""
|
|
525
636
|
if state is None:
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
doctor.py [--root <dir>] [--json]
|
|
5
5
|
doctor.py --fix [--write] [--json] mechanical repairs of history (dry run unless --write)
|
|
6
|
-
doctor.py --sweep [--json]
|
|
6
|
+
doctor.py --sweep [--json] [--no-forge] every remaining failure as a worklist with evidence (read-only;
|
|
7
|
+
asks the forge through `gh` about post-merge steps unless --no-forge)
|
|
7
8
|
doctor.py --baseline last resort: accept today's failures in context/doctor-baseline.json
|
|
8
9
|
npx softure-skills doctor [...] (the same, from the installed package)
|
|
9
10
|
|
|
10
|
-
Adopting projects run it in
|
|
11
|
-
drift happens).
|
|
12
|
-
|
|
11
|
+
Adopting projects run it in a CI job named `context-doctor`, documentation-only changes included (that is where the
|
|
12
|
+
drift happens). In GitHub Actions it also writes the failure codes as annotations of that check run (the first one,
|
|
13
|
+
titled `context-doctor failure codes`, lists every code with its count) and as the job summary, so a reader of the
|
|
14
|
+
forge API sees the codes on the main branch's head without a checkout. `softure-archive` and `softure-roadmap
|
|
15
|
+
--close` run it before their commit and fix what they own. Each problem is one line `FAIL <code> <path>: <what>`; the codes:
|
|
13
16
|
|
|
14
17
|
roadmap-archived-not-removed roadmap.md is still there although the same roadmap is in foundation/archive/
|
|
15
18
|
roadmap-status-mismatch roadmap.md `status` contradicts its rows (done with open rows; waiting)
|
|
@@ -221,6 +224,40 @@ def open_checks(text: str, include_release: bool = True) -> list[str]:
|
|
|
221
224
|
return found
|
|
222
225
|
|
|
223
226
|
|
|
227
|
+
# A carry marker: the line says which roadmap took the entry over (`→ roadmap-later`, `carried to
|
|
228
|
+
# roadmaps/roadmap-later.md`, `carried over to roadmap.md`).
|
|
229
|
+
CARRY_RE = re.compile(r"(?:→|->|\bcarried(?:\s+over)?\s+to)\s*\**\s*`?(?P<target>(?:[\w.-]+/)*roadmap"
|
|
230
|
+
r"(?:-[A-Za-z0-9][\w-]*?(?:\.md)?|\.md))(?![\w-])`?", re.IGNORECASE)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def carry_target(text: str) -> str | None:
|
|
234
|
+
"""The roadmap a carry marker in `text` names (as written), or None."""
|
|
235
|
+
match = CARRY_RE.search(text or "")
|
|
236
|
+
return match.group("target") if match else None
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def resolve_carry(reader, target: str | None) -> str | None:
|
|
240
|
+
"""The file of the roadmap a carry marker names, when it exists (queued, archived, or the live one)."""
|
|
241
|
+
if not target:
|
|
242
|
+
return None
|
|
243
|
+
name = target.rsplit("/", 1)[-1]
|
|
244
|
+
if name == "roadmap.md":
|
|
245
|
+
text = reader.read(ROADMAP_PATH)
|
|
246
|
+
return ROADMAP_PATH if text is not None else None
|
|
247
|
+
slug = name[len("roadmap-"):]
|
|
248
|
+
slug = slug[:-3] if slug.endswith(".md") else slug
|
|
249
|
+
queued = f"{QUEUED_DIR}/roadmap-{slug}.md"
|
|
250
|
+
if reader.read(queued) is not None:
|
|
251
|
+
return queued
|
|
252
|
+
live = reader.read(ROADMAP_PATH)
|
|
253
|
+
if live is not None and frontmatter(live).get("roadmap") == slug:
|
|
254
|
+
return ROADMAP_PATH
|
|
255
|
+
for path in _files(reader, ARCHIVE_ROADMAPS_DIR, r"^\d{4}-\d{2}-\d{2}-roadmap.*\.md$"):
|
|
256
|
+
if frontmatter(reader.read(path) or "").get("roadmap") == slug or path.endswith(f"roadmap-{slug}.md"):
|
|
257
|
+
return path
|
|
258
|
+
return None
|
|
259
|
+
|
|
260
|
+
|
|
224
261
|
def check_archived_roadmaps(reader) -> list[Finding]:
|
|
225
262
|
findings: list[Finding] = []
|
|
226
263
|
pending = pending_release_roadmap(reader)
|
|
@@ -583,18 +620,19 @@ def run_baseline(reader, root: str, git_root: str | None) -> int:
|
|
|
583
620
|
return 1 if change["refused"] else 0
|
|
584
621
|
|
|
585
622
|
|
|
586
|
-
def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
623
|
+
def run_sweep(reader, root: str, git_root: str | None, as_json: bool, use_forge: bool = True) -> int:
|
|
587
624
|
"""`--sweep`: the worklist of every failure with its evidence; exit 1 while anything is left."""
|
|
588
625
|
import doctor_sweep
|
|
589
626
|
|
|
590
|
-
entries = doctor_sweep.sweep(reader, git_root)
|
|
627
|
+
entries = doctor_sweep.sweep(reader, git_root, doctor_sweep.Forge(git_root, enabled=use_forge))
|
|
591
628
|
owner = [entry for entry in entries if entry["class"] == "owner"]
|
|
592
629
|
superseded = [entry for entry in entries if entry["class"] == "superseded"]
|
|
593
|
-
|
|
630
|
+
forge = [entry for entry in entries if entry["class"] == "forge"]
|
|
631
|
+
with_evidence = len(entries) - len(owner) - len(superseded) - len(forge)
|
|
594
632
|
if as_json:
|
|
595
633
|
print(json.dumps({"root": root, "entries": entries,
|
|
596
634
|
"summary": {"total": len(entries), "with_evidence": with_evidence,
|
|
597
|
-
"superseded": len(superseded), "owner": len(owner)}},
|
|
635
|
+
"superseded": len(superseded), "forge": len(forge), "owner": len(owner)}},
|
|
598
636
|
indent=2, ensure_ascii=False))
|
|
599
637
|
return 1 if entries else 0
|
|
600
638
|
if not entries:
|
|
@@ -607,16 +645,76 @@ def run_sweep(reader, root: str, git_root: str | None, as_json: bool) -> int:
|
|
|
607
645
|
print(f" evidence {evidence['kind']} {evidence['ref']}: {evidence['note']}")
|
|
608
646
|
if entry["class"] == "superseded":
|
|
609
647
|
print(" superseded: later work made it obsolete; close it yourself, never forward it")
|
|
648
|
+
if entry["class"] == "forge":
|
|
649
|
+
print(" forge: check it with `gh` before anything goes to the owner")
|
|
650
|
+
for tried in entry["tried"]:
|
|
651
|
+
print(f" tried: {tried}")
|
|
610
652
|
if entry["owner"]:
|
|
611
653
|
print(f" owner ({entry['owner_reason']}): only the owner can settle it")
|
|
612
654
|
for tried in entry["tried"]:
|
|
613
655
|
print(f" tried: {tried}")
|
|
614
656
|
print(f" settle: {entry['settle']}")
|
|
615
657
|
print(f"softure-doctor --sweep: {len(entries)} entr{'y' if len(entries) == 1 else 'ies'} to settle, "
|
|
616
|
-
f"{with_evidence} with evidence, {len(superseded)} superseded, {len(
|
|
658
|
+
f"{with_evidence} with evidence, {len(superseded)} superseded, {len(forge)} to check with the forge, "
|
|
659
|
+
f"{len(owner)} for the owner")
|
|
617
660
|
return 1
|
|
618
661
|
|
|
619
662
|
|
|
663
|
+
# The annotation that lists every failure code of a run; readers of the check run (portfolio --source api) find it
|
|
664
|
+
# by this title. GitHub keeps only the first few annotations of a step, so the codes come first, in one annotation.
|
|
665
|
+
CI_CODES_TITLE = "context-doctor failure codes"
|
|
666
|
+
CI_ANNOTATION_LIMIT = 9
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def failure_codes(failures: list[Finding]) -> list[tuple[str, int]]:
|
|
670
|
+
counts: dict[str, int] = {}
|
|
671
|
+
for failure in failures:
|
|
672
|
+
counts[failure.code] = counts.get(failure.code, 0) + 1
|
|
673
|
+
return sorted(counts.items())
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def _escape(value: str, property_value: bool = False) -> str:
|
|
677
|
+
value = value.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
|
|
678
|
+
return value.replace(":", "%3A").replace(",", "%2C") if property_value else value
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def report_to_ci(failures: list[Finding], env: dict | None = None, out=None) -> None:
|
|
682
|
+
"""In GitHub Actions: the failure codes as annotations of the check run, and a job summary.
|
|
683
|
+
|
|
684
|
+
The first annotation (title `CI_CODES_TITLE`) lists every code with its count, so a reader of the check run
|
|
685
|
+
through the forge API gets the codes without a checkout; one annotation per failure follows, up to the limit.
|
|
686
|
+
The job summary (`$GITHUB_STEP_SUMMARY`) holds the same table. Outside Actions nothing changes.
|
|
687
|
+
"""
|
|
688
|
+
env = os.environ if env is None else env
|
|
689
|
+
out = out or sys.stdout
|
|
690
|
+
if env.get("GITHUB_ACTIONS") != "true":
|
|
691
|
+
return
|
|
692
|
+
codes = failure_codes(failures)
|
|
693
|
+
if codes:
|
|
694
|
+
listed = ", ".join(f"{code} ({count})" for code, count in codes)
|
|
695
|
+
print(f"::error title={_escape(CI_CODES_TITLE, True)}::{_escape(listed)}", file=out)
|
|
696
|
+
for failure in failures[:CI_ANNOTATION_LIMIT]:
|
|
697
|
+
print(f"::error file={_escape(failure.path, True)},title={_escape(failure.code, True)}::"
|
|
698
|
+
f"{_escape(failure.message)}", file=out)
|
|
699
|
+
target = env.get("GITHUB_STEP_SUMMARY")
|
|
700
|
+
if not target:
|
|
701
|
+
return
|
|
702
|
+
lines = ["### context-doctor", ""]
|
|
703
|
+
if codes:
|
|
704
|
+
lines += [f"{len(failures)} problem(s) in the context/ contract (WORKFLOW.md §12).", "",
|
|
705
|
+
"| Code | Count | First path |", "| --- | --- | --- |"]
|
|
706
|
+
for code, count in codes:
|
|
707
|
+
first = next(failure.path for failure in failures if failure.code == code)
|
|
708
|
+
lines.append(f"| `{code}` | {count} | `{first}` |")
|
|
709
|
+
else:
|
|
710
|
+
lines.append("context/ contract OK")
|
|
711
|
+
try:
|
|
712
|
+
with open(target, "a", encoding="utf-8") as fh:
|
|
713
|
+
fh.write("\n".join(lines) + "\n")
|
|
714
|
+
except OSError:
|
|
715
|
+
pass
|
|
716
|
+
|
|
717
|
+
|
|
620
718
|
def main(argv: list[str] | None = None) -> int:
|
|
621
719
|
args = list(sys.argv[1:] if argv is None else argv)
|
|
622
720
|
if "-h" in args or "--help" in args:
|
|
@@ -626,13 +724,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
626
724
|
fix = _take(args, "--fix")
|
|
627
725
|
write = _take(args, "--write")
|
|
628
726
|
do_sweep = _take(args, "--sweep")
|
|
727
|
+
no_forge = _take(args, "--no-forge")
|
|
629
728
|
do_baseline = _take(args, "--baseline")
|
|
630
729
|
root = None
|
|
631
730
|
if "--root" in args:
|
|
632
731
|
k = args.index("--root")
|
|
633
732
|
root = os.path.abspath(args[k + 1])
|
|
634
733
|
del args[k:k + 2]
|
|
635
|
-
if args or (write and not fix) or sum((fix, do_sweep, do_baseline)) > 1:
|
|
734
|
+
if args or (write and not fix) or sum((fix, do_sweep, do_baseline)) > 1 or (no_forge and not do_sweep):
|
|
636
735
|
print(__doc__, file=sys.stderr)
|
|
637
736
|
return 2
|
|
638
737
|
top = subprocess.run(["git", "-C", root or os.getcwd(), "rev-parse", "--show-toplevel"],
|
|
@@ -650,7 +749,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
650
749
|
if fix:
|
|
651
750
|
return run_fix(reader, root, git_root, write, as_json)
|
|
652
751
|
if do_sweep:
|
|
653
|
-
return run_sweep(reader, root, git_root, as_json)
|
|
752
|
+
return run_sweep(reader, root, git_root, as_json, use_forge=not no_forge)
|
|
654
753
|
if do_baseline:
|
|
655
754
|
return run_baseline(reader, root, git_root)
|
|
656
755
|
findings = run_checks(reader, git_root)
|
|
@@ -661,6 +760,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
661
760
|
return 1 if failures else 0
|
|
662
761
|
for finding in findings:
|
|
663
762
|
print(finding)
|
|
763
|
+
report_to_ci(failures)
|
|
664
764
|
baselined = sum(1 for f in findings if f.severity == "baselined")
|
|
665
765
|
if baselined:
|
|
666
766
|
print(f"softure-doctor: {baselined} failure(s) accepted by {BASELINE_PATH} (last resort; sweep them to zero)")
|
|
@@ -17,6 +17,11 @@ Three shapes are mechanical, and only files under `context/` are edited:
|
|
|
17
17
|
dropped Progress item an unticked item of an archived plan's `## Progress` that is struck through or
|
|
18
18
|
carries a dropped/cancelled/not-applicable note is normalised to
|
|
19
19
|
`- [x] ~~<item>~~ — dropped: <note>` (the doctor already reads it as dropped)
|
|
20
|
+
carried entry an unticked owner check or pre-release step of an archived roadmap, or an open row,
|
|
21
|
+
whose text carries a carry marker (`→ roadmap-<slug>`, `carried to <roadmap>`) naming a
|
|
22
|
+
roadmap that exists (queued, archived or the live one): the check is ticked
|
|
23
|
+
`- [x] <text> — carried to <path>`, the row (and its item block) becomes
|
|
24
|
+
`carried (to <path>)`; a marker whose roadmap does not exist is left alone and named
|
|
20
25
|
|
|
21
26
|
Everything else (an index row whose target is not in the history this checkout holds, a live index)
|
|
22
27
|
is a judgement case: `doctor.py --sweep` lists it with evidence. A shallow clone works: what it cannot
|
|
@@ -221,6 +226,8 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
221
226
|
if lines != text.split("\n"):
|
|
222
227
|
files[rel] = "\n".join(lines)
|
|
223
228
|
|
|
229
|
+
_plan_carried(reader, files, edits, skipped)
|
|
230
|
+
|
|
224
231
|
history = History(root)
|
|
225
232
|
for missing in doctor.missing_index_targets(reader):
|
|
226
233
|
if not missing["path"].startswith(ARCHIVE_PREFIXES):
|
|
@@ -263,6 +270,65 @@ def plan_fixes(reader, root: str | None) -> dict:
|
|
|
263
270
|
return {"edits": edits, "skipped": skipped, "files": files}
|
|
264
271
|
|
|
265
272
|
|
|
273
|
+
def _foundation_relative(path: str) -> str:
|
|
274
|
+
prefix = "context/foundation/"
|
|
275
|
+
return path[len(prefix):] if path.startswith(prefix) else path
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _plan_carried(reader, files: dict[str, str], edits: list[dict], skipped: list[dict]) -> None:
|
|
279
|
+
"""Tick carry-marked checks and close carry-marked rows of archived roadmaps whose target roadmap exists."""
|
|
280
|
+
import doctor # noqa: E402
|
|
281
|
+
|
|
282
|
+
from context_state import CHECKBOX_RE, OWNER_SECTION, RELEASE_SECTION, pending_release_roadmap, roadmap_rows
|
|
283
|
+
|
|
284
|
+
pending = pending_release_roadmap(reader)
|
|
285
|
+
for path in doctor._archived_roadmaps(reader):
|
|
286
|
+
text = files.get(path, reader.read(path) or "")
|
|
287
|
+
lines = text.split("\n")
|
|
288
|
+
wanted = {OWNER_SECTION} | ({RELEASE_SECTION} if path != pending else set())
|
|
289
|
+
open_rows = {row["id"]: row for row in roadmap_rows(text) if row["status"] not in doctor.CLOSED_STATUSES}
|
|
290
|
+
section = None
|
|
291
|
+
for index, line in enumerate(lines):
|
|
292
|
+
if line.startswith("## "):
|
|
293
|
+
section = line[3:].strip()
|
|
294
|
+
continue
|
|
295
|
+
box = CHECKBOX_RE.match(line)
|
|
296
|
+
row = re.match(r"^\|\s*\*\*([A-Z]+-\d+)\*\*\s*\|", line)
|
|
297
|
+
if box and box.group("mark") == " " and section in wanted:
|
|
298
|
+
subject = box.group("text")
|
|
299
|
+
elif row and row.group(1) in open_rows:
|
|
300
|
+
subject = [cell.strip() for cell in line.strip().strip("|").split("|")][-1]
|
|
301
|
+
else:
|
|
302
|
+
continue
|
|
303
|
+
target = doctor.carry_target(subject)
|
|
304
|
+
if not target:
|
|
305
|
+
continue
|
|
306
|
+
found = doctor.resolve_carry(reader, target)
|
|
307
|
+
if not found:
|
|
308
|
+
skipped.append({"code": "archived-roadmap-open-checks" if box else "archived-roadmap-open-items",
|
|
309
|
+
"path": path, "line": index + 1,
|
|
310
|
+
"why": f"carry marker names `{target}`, which is no queued, archived or live roadmap"})
|
|
311
|
+
continue
|
|
312
|
+
where = _foundation_relative(found)
|
|
313
|
+
if box:
|
|
314
|
+
lines[index] = line.replace("- [ ] ", "- [x] ", 1).rstrip() + f" — carried to {where}"
|
|
315
|
+
edits.append({"code": "archived-roadmap-open-checks", "path": path, "line": index + 1,
|
|
316
|
+
"what": f"carried check ticked: carried to {where}"})
|
|
317
|
+
else:
|
|
318
|
+
old_status = subject
|
|
319
|
+
new_status = f"carried (to {where})"
|
|
320
|
+
head = line.rstrip()
|
|
321
|
+
cut = head.rstrip("|").rstrip().rfind(old_status)
|
|
322
|
+
lines[index] = head[:cut] + new_status + head[cut + len(old_status):]
|
|
323
|
+
for block_index, block_line in enumerate(lines):
|
|
324
|
+
if block_line.strip() == f"- **Status:** {old_status}":
|
|
325
|
+
lines[block_index] = block_line.replace(old_status, new_status, 1)
|
|
326
|
+
edits.append({"code": "archived-roadmap-open-items", "path": path, "line": index + 1,
|
|
327
|
+
"what": f"{row.group(1)} {old_status} -> {new_status}"})
|
|
328
|
+
if lines != text.split("\n"):
|
|
329
|
+
files[path] = "\n".join(lines)
|
|
330
|
+
|
|
331
|
+
|
|
266
332
|
def apply_fixes(root: str, files: dict[str, str]) -> None:
|
|
267
333
|
for rel, text in files.items():
|
|
268
334
|
if not rel.startswith("context/"):
|