@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.
@@ -17,9 +17,20 @@ evidence found in the repository, and how to settle it:
17
17
  the roadmap was closed
18
18
  anything else the file to fix (and `--fix` for the mechanical shapes)
19
19
 
20
- An entry with no evidence at all carries `"owner": true`: only the owner can settle it, and it goes to
21
- the owner's list (WORKFLOW §12.4). The skill section "Sweep history to zero" tells an agent how to work
22
- the list: settle every entry with its evidence, never without.
20
+ Every entry has a `class`:
21
+
22
+ evidence the repository holds evidence that settles it (above); the agent settles it with that proof
23
+ superseded no direct evidence, but later work made it obsolete: for an owner check or open row of an
24
+ archived roadmap, a later roadmap was closed and a release shipped after it, or the same
25
+ item ID or file area appears in a later archived change; for a Progress item, a later
26
+ phase of the same plan is ticked (or a later archived change has the item's area). The
27
+ agent closes it as `obsolete: superseded by <ref>` itself, never forwards it
28
+ owner only the owner can settle it: a decision about future work, a secret, account or connector,
29
+ or a step outside the repository whose effect the agent cannot see (`owner_reason` says
30
+ which; `unsettled` when nothing at all was found), with `tried`: what the sweep looked for
31
+
32
+ `"owner": true` marks the owner class. The skill section "Sweep history to zero" tells an agent how to
33
+ work the list: settle every entry with its evidence, never without.
23
34
 
24
35
  Importable: `from doctor_sweep import sweep`.
25
36
  """
@@ -33,24 +44,48 @@ import sys
33
44
  sys.dont_write_bytecode = True
34
45
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
35
46
  from context_state import ( # noqa: E402
36
- ARCHIVE_ROADMAPS_DIR, OWNER_SECTION, QUEUED_DIR, RELEASE_SECTION, ROADMAP_PATH, CHECKBOX_RE,
37
- ITEM_REF_RE, archived_roadmap_files, frontmatter, pending_release_roadmap, roadmap_rows, sections,
47
+ ARCHIVE_ROADMAPS_DIR, OWNER_SECTION, QUEUED_DIR, RELEASE_LINE_RE, RELEASE_SECTION, ROADMAP_PATH, CHECKBOX_RE,
48
+ ITEM_REF_RE, SECRET_RE, archived_roadmap_files, frontmatter, pending_release_roadmap, roadmap_rows, sections,
38
49
  )
39
50
 
40
51
  SHA_TAIL_RE = re.compile(r"\b([0-9a-f]{7,40})\b")
41
52
  PATH_RE = re.compile(r"`((?:[\w.-]+/)+[\w.-]+\.\w+|[\w.-]+\.(?:ts|tsx|js|jsx|mjs|py|cs|go|rs|java|kt|rb|php|sql|css|scss|html|json|yml|yaml|sh))`")
42
53
  SEMVER_TAG_RE = re.compile(r"^v?\d+\.\d+\.\d+")
54
+ AREA_RE = re.compile(r"`((?:\.{0,2}/)?(?:[\w.@-]+/)+[\w.@-]*)`")
43
55
  LIMIT = 3
44
56
 
57
+ # What only the owner can settle (WORKFLOW §12.4); everything else is the agent's.
58
+ OWNER_KINDS = (
59
+ ("decision", re.compile(r"\b(?:decide|decision|choose|agree on|sign[- ]off)\b", re.IGNORECASE)),
60
+ ("secret", re.compile(SECRET_RE.pattern + r"|\b(?:accounts?|connectors?|oauth|dns|domains?|certificates?|billing"
61
+ r"|subscriptions?|licen[cs]es?)\b|`[A-Z][A-Z0-9]*_[A-Z0-9_]+`", re.IGNORECASE)),
62
+ ("outside", re.compile(r"\b(?:in production|on production|production (?:environment|settings?)|in staging"
63
+ r"|app store|play store|real (?:phone|device)|with the (?:client|customer|vendor)"
64
+ r"|support ticket|by (?:e-?mail|phone) to)\b", re.IGNORECASE)),
65
+ )
66
+
45
67
  SETTLE = {
46
68
  "archived-change-progress": "tick it with the SHA that did it (`- [x] <text> — <sha>`), or, when the work was "
47
69
  "never done, `- [x] ~~<text>~~ — dropped: <reason>`",
48
- "archived-roadmap-summary": "put the merge SHA into the row's Merge cell (`—` only for a carried or dropped row)",
70
+ "archived-roadmap-summary": "put the merge SHA into the row's Merge cell (a release tag where the roadmap records "
71
+ "a release instead; `carried`, `dropped` or `— <reason>` for a row with no merge)",
49
72
  "archived-roadmap-open-items": "set the row's status to `done` when the evidence shows it shipped, "
50
73
  "`carried (to <path>)` when a later roadmap took it, or `dropped (<reason>)`",
51
74
  "archived-roadmap-open-checks": "tick it with its evidence (`— done: <sha | release | path>`), as obsolete "
52
75
  "(`— obsolete: <reason>`), or carry it to a live roadmap or an owner-word issue "
53
76
  "and tick it with where it went (`— carried to <path | #N>`)",
77
+ }
78
+
79
+ SETTLE_SUPERSEDED = {
80
+ "archived-change-progress": "close it yourself: `- [x] <text> — obsolete: superseded by <ref>` (never forward it)",
81
+ "archived-roadmap-open-items": "set the row's status to `dropped (obsolete: superseded by <ref>)` (never forward it)",
82
+ "archived-roadmap-open-checks": "close it yourself: `- [x] <text> — obsolete: superseded by <ref>` "
83
+ "(never forward it to the owner)",
84
+ }
85
+
86
+ SETTLE_OWNER = {
87
+ "archived-roadmap-open-checks": "the owner's: carry it to the live roadmap's `## Owner decisions and checks` (or "
88
+ "an owner-word issue) and tick it `— carried to <path | #N>`",
54
89
  "archived-change-status": "mechanical: `doctor --fix --write`",
55
90
  "index-missing-file": "point the row at the file's current path, or drop the row",
56
91
  "roadmap-archived-not-removed": "remove roadmap.md (the close moved it)",
@@ -68,9 +103,11 @@ class Git:
68
103
  def __init__(self, root: str | None) -> None:
69
104
  self.root = root
70
105
  self.usable = False
106
+ self.shallow = False
71
107
  if root:
72
108
  probe = self._run("rev-parse", "--is-shallow-repository")
73
- self.usable = probe.returncode == 0 and probe.stdout.strip() == "false"
109
+ self.usable = probe.returncode == 0
110
+ self.shallow = probe.stdout.strip() == "true"
74
111
 
75
112
  def _run(self, *args: str) -> subprocess.CompletedProcess:
76
113
  return subprocess.run(["git", "-C", self.root or ".", *args], capture_output=True, text=True)
@@ -105,15 +142,15 @@ class Git:
105
142
  tags = [tag for tag in out.stdout.split() if SEMVER_TAG_RE.match(tag)]
106
143
  return tags[0] if tags else None
107
144
 
108
- def release_after(self, day: str | None) -> dict | None:
109
- """The first release tag created on or after `day`."""
145
+ def release_after(self, day: str | None, strict: bool = False) -> dict | None:
146
+ """The first release tag created on or after `day` (after it, with `strict`)."""
110
147
  if not self.usable or not day:
111
148
  return None
112
149
  out = self._run("for-each-ref", "--sort=creatordate", "--format=%(refname:short)\t%(creatordate:short)",
113
150
  "refs/tags")
114
151
  for line in out.stdout.splitlines():
115
152
  tag, _, date = line.partition("\t")
116
- if SEMVER_TAG_RE.match(tag) and date >= day:
153
+ if SEMVER_TAG_RE.match(tag) and (date > day if strict else date >= day):
117
154
  return {"tag": tag, "date": date}
118
155
  return None
119
156
 
@@ -178,10 +215,109 @@ def _item_evidence(reader, git: Git, path: str, item: str | None, change_id: str
178
215
  return evidence
179
216
 
180
217
 
218
+ def owner_kind(text: str) -> str | None:
219
+ """`decision`, `secret` or `outside` when the line is something only the owner can settle; None otherwise."""
220
+ for kind, pattern in OWNER_KINDS:
221
+ if pattern.search(text or ""):
222
+ return kind
223
+ return None
224
+
225
+
181
226
  def _entry(code: str, path: str, line: int | None, text: str, subject: str, evidence: list[dict],
227
+ superseded: list[dict] | None = None, tried: list[str] | None = None, owner_text: str | None = None,
182
228
  **extra) -> dict:
229
+ """One worklist entry, classed `evidence`, `superseded` or `owner` (in that order of proof).
230
+
231
+ `owner_text` (the line, for checks and Progress items) lets a decision, a secret or a step outside the
232
+ repository stay the owner's even when later work exists; anything else without direct evidence is
233
+ superseded when later work made it obsolete, and the owner's (`unsettled`) only when nothing was found.
234
+ """
235
+ kind = owner_kind(owner_text) if owner_text is not None else None
236
+ if evidence:
237
+ klass, reason, settle = "evidence", None, SETTLE.get(code, "fix the file it names")
238
+ elif kind:
239
+ klass, reason, settle = "owner", kind, SETTLE_OWNER.get(code, SETTLE.get(code, "fix the file it names"))
240
+ elif superseded:
241
+ klass, reason, settle = "superseded", None, SETTLE_SUPERSEDED.get(code, SETTLE.get(code, "fix the file it names"))
242
+ evidence = superseded
243
+ else:
244
+ klass, reason, settle = "owner", "unsettled", SETTLE.get(code, "fix the file it names")
183
245
  return {"code": code, "path": path, "line": line, "text": text, "subject": subject, "evidence": evidence,
184
- "owner": not evidence, "settle": SETTLE.get(code, "fix the file it names"), **extra}
246
+ "class": klass, "owner": klass == "owner", "owner_reason": reason,
247
+ "tried": [] if klass == "evidence" else (tried or []), "settle": settle, **extra}
248
+
249
+
250
+ # ---------------------------------------------------------------- superseded
251
+
252
+
253
+ def _areas(text: str) -> list[str]:
254
+ """File areas a line names: the folder of each backticked path (`src/booking/page.tsx` -> `src/booking/`)."""
255
+ areas = []
256
+ for path in AREA_RE.findall(text or "") + PATH_RE.findall(text or ""):
257
+ folder = path if path.endswith("/") else (os.path.dirname(path) + "/" if "/" in path else "")
258
+ if folder and folder not in areas and folder.strip("./"):
259
+ areas.append(folder.lstrip("./") if folder.startswith("./") else folder)
260
+ return areas
261
+
262
+
263
+ def _later_changes(reader, day: str | None, needles: list[str], exclude: str | None = None) -> list[dict]:
264
+ """Archived changes dated after `day` whose change.md or plan.md names an item ID, change ID or file area."""
265
+ needles = [needle for needle in needles if needle]
266
+ if not day or not needles:
267
+ return []
268
+ found = []
269
+ for name, is_dir in sorted(reader.listdir("context/archive")):
270
+ date = re.match(r"^(\d{4}-\d{2}-\d{2})-", name)
271
+ folder = f"context/archive/{name}"
272
+ if not is_dir or not date or date.group(1) <= day or folder == exclude:
273
+ continue
274
+ for rel in ("change.md", "plan.md"):
275
+ text = reader.read(f"{folder}/{rel}") or ""
276
+ hit = next((needle for needle in needles
277
+ if re.search(r"(?<![\w-])" + re.escape(needle) + (r"" if needle.endswith("/") else r"(?![\w-])"),
278
+ text)), None)
279
+ if hit:
280
+ found.append(_evidence("file", f"{folder}/", f"a later archived change on the same "
281
+ f"{'area' if hit.endswith('/') else 'item'} (`{hit}`)"))
282
+ break
283
+ if found:
284
+ break
285
+ return found
286
+
287
+
288
+ def _later_release(reader, git: Git, day: str, later: list[str]) -> dict | None:
289
+ """The first release after `day`: a release tag, else a `Release:` line of a later archived roadmap."""
290
+ tag = git.release_after(day, strict=True)
291
+ if tag:
292
+ return _evidence("release", tag["tag"], f"released {tag['date']}, after {day}")
293
+ for path in later:
294
+ for line in sections(reader.read(path) or "").get("Summary", []):
295
+ match = RELEASE_LINE_RE.match(line.strip())
296
+ if match and (match.group("date") or "9999") > day:
297
+ return _evidence("release", match.group("version"), f"released {match.group('date') or 'later'}, "
298
+ f"recorded in {path}")
299
+ return None
300
+
301
+
302
+ def _superseded_roadmap_entry(reader, git: Git, path: str, text: str, needles: list[str]) -> tuple[list, list]:
303
+ """(superseded evidence, what was tried) for an open check or row of the archived roadmap `path`."""
304
+ closed_on = _date_of(path, frontmatter(reader.read(path) or "")) or ""
305
+ later = [p for p in archived_roadmap_files(reader) if p > path and roadmap_rows(reader.read(p) or "")]
306
+ tried = []
307
+ evidence: list[dict] = []
308
+ release = _later_release(reader, git, closed_on, later) if later else None
309
+ if later and release:
310
+ evidence = [_evidence("file", later[0], f"a later roadmap, closed after {closed_on}"), release]
311
+ tried.append(f"a later closed roadmap: {later[0] if later else 'none'}; a release after {closed_on}: "
312
+ f"{release['ref'] if release else 'none'}")
313
+ areas = _areas(text)
314
+ if not evidence:
315
+ evidence = _later_changes(reader, closed_on, needles + areas)
316
+ tried.append(f"later archived changes naming {', '.join(f'`{n}`' for n in needles + areas) or 'its item or area'}: "
317
+ + ("found" if evidence else "none"))
318
+ if git.shallow:
319
+ tried.append("the history is a shallow clone; `git fetch --deepen <n>` may find more")
320
+ return evidence, tried
185
321
 
186
322
 
187
323
  # ---------------------------------------------------------------- per failure code
@@ -211,6 +347,8 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
211
347
  in_progress = False
212
348
  phase = None
213
349
  phase_shas: dict[str, list[str]] = {}
350
+ phase_marks: dict[str, list[bool]] = {}
351
+ phase_lines: dict[str, int] = {}
214
352
  pending: list[tuple[int, str, str, str]] = []
215
353
  for number, line in enumerate(_lines(text), start=1):
216
354
  if line.startswith("## "):
@@ -221,10 +359,12 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
221
359
  heading = re.match(r"^### Phase (\d+)", line)
222
360
  if heading:
223
361
  phase = heading.group(1)
362
+ phase_lines.setdefault(phase, number)
224
363
  continue
225
364
  box = CHECKBOX_RE.match(line)
226
365
  if not box:
227
366
  continue
367
+ phase_marks.setdefault(phase or "", []).append(box.group("mark") != " ")
228
368
  if box.group("mark") != " ":
229
369
  tail = line.rsplit(" — ", 1)[-1] if " — " in line else ""
230
370
  phase_shas.setdefault(phase or "", []).extend(SHA_TAIL_RE.findall(tail))
@@ -237,7 +377,20 @@ def _progress_entries(reader, git: Git, path: str) -> list[dict]:
237
377
  files = sorted(set(phase_files.get(phase, [])))
238
378
  evidence += _commit_evidence(git.touching(files, since), f"touched {', '.join(files)} after {since}")
239
379
  evidence += _commit_evidence(merges, "merge of the change")
240
- entries.append(_entry("archived-change-progress", path, number, line, subject, evidence))
380
+ later = [p for p, marks in phase_marks.items() if p.isdigit() and phase.isdigit() and int(p) > int(phase)
381
+ and marks and all(marks)]
382
+ superseded = [_evidence("file", f"{path}:{phase_lines[p]}", f"phase {p}, later in the same plan, is ticked")
383
+ for p in sorted(later, key=int)[:1]]
384
+ tried = [f"commits citing or touching phase {phase or '?'} and merges naming `{change_id}`: none",
385
+ f"a later phase of the plan, all ticked: {'phase ' + later[0] if later else 'none'}"]
386
+ if not superseded:
387
+ superseded = _later_changes(reader, since, _areas(subject), exclude=folder)
388
+ tried.append(f"later archived changes on its area ({', '.join(_areas(subject)) or 'no area named'}): "
389
+ + ("found" if superseded else "none"))
390
+ if git.shallow:
391
+ tried.append("the history is a shallow clone; `git fetch --deepen <n>` may find more")
392
+ entries.append(_entry("archived-change-progress", path, number, line, subject, evidence,
393
+ superseded=superseded, tried=tried, owner_text=subject))
241
394
  return entries
242
395
 
243
396
 
@@ -250,26 +403,11 @@ def _summary_entries(reader, git: Git, path: str) -> list[dict]:
250
403
 
251
404
  text = reader.read(path) or ""
252
405
  rows = _roadmap_rows_by_id(text)
253
- bad = {entry.split(":", 1)[0] for entry in doctor.summary_placeholders(text)}
254
406
  entries = []
255
- in_summary = False
256
- header = None
257
- for number, line in enumerate(_lines(text), start=1):
258
- if line.startswith("## "):
259
- in_summary = line[3:].strip() == "Summary"
260
- header = None
261
- continue
262
- if not in_summary or not line.strip().startswith("|"):
263
- continue
264
- cells = [cell.strip() for cell in line.strip().strip("|").split("|")]
265
- if header is None:
266
- header = [cell.lower() for cell in cells]
267
- continue
268
- if cells[0] not in bad:
407
+ for row in doctor.summary_rows(text):
408
+ if row["ok"]:
269
409
  continue
270
- index = header.index("merge") if "merge" in header else len(cells) - 1
271
- cell = cells[index] if index < len(cells) else ""
272
- item = cells[0]
410
+ item, cell = row["item"], row["cell"]
273
411
  change_id = (rows.get(item) or {}).get("change_id")
274
412
  evidence = _commit_evidence(git.merges_for(change_id), "merge of the item's change")
275
413
  folder = _archived_change_folder(reader, change_id)
@@ -277,7 +415,7 @@ def _summary_entries(reader, git: Git, path: str) -> list[dict]:
277
415
  shas = SHA_TAIL_RE.findall(reader.read(f"{folder}/plan.md") or "")
278
416
  if shas:
279
417
  evidence.append(_evidence("commit", shas[-1], f"last SHA in {folder}/plan.md (not a merge; prefer the merge)"))
280
- entries.append(_entry("archived-roadmap-summary", path, number, line, f"{item}: {cell}", evidence,
418
+ entries.append(_entry("archived-roadmap-summary", path, row["line"], row["text"], f"{item}: {cell}", evidence,
281
419
  cell=cell, item=item, change_id=change_id))
282
420
  return entries
283
421
 
@@ -295,8 +433,11 @@ def _open_item_entries(reader, git: Git, path: str) -> list[dict]:
295
433
  row = rows.pop(match.group(1))
296
434
  status = [cell.strip() for cell in line.strip().strip("|").split("|")][-1]
297
435
  evidence = _item_evidence(reader, git, path, row["id"], row["change_id"])
436
+ superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
437
+ reader, git, path, line, [row["id"], row["change_id"]])
298
438
  entries.append(_entry("archived-roadmap-open-items", path, number, line, f"{row['id']} ({row['status']})",
299
- evidence, item=row["id"], change_id=row["change_id"], status=status))
439
+ evidence, superseded=superseded, tried=tried, item=row["id"],
440
+ change_id=row["change_id"], status=status))
300
441
  return entries
301
442
 
302
443
 
@@ -322,8 +463,11 @@ def _open_check_entries(reader, git: Git, path: str) -> list[dict]:
322
463
  evidence = _item_evidence(reader, git, path, item, change_id) if item else []
323
464
  if release and section == RELEASE_SECTION:
324
465
  evidence.append(_evidence("release", release["tag"], f"released {release['date']}, after the close"))
466
+ superseded, tried = ([], []) if evidence else _superseded_roadmap_entry(
467
+ reader, git, path, line, [item, change_id] if item else [])
325
468
  entries.append(_entry("archived-roadmap-open-checks", path, number, line, box.group("text").strip(),
326
- evidence, item=item, change_id=change_id, section=section))
469
+ evidence, superseded=superseded, tried=tried, owner_text=box.group("text"),
470
+ item=item, change_id=change_id, section=section))
327
471
  return entries
328
472
 
329
473
 
@@ -341,12 +485,12 @@ def _index_entries(reader, root: str | None) -> list[dict]:
341
485
  evidence.append(_evidence("file", traced[1], f"`{missing['target']}` moved here (git rename history)"))
342
486
  break
343
487
  if traced:
344
- evidence.append(_evidence("commit", traced[1], f"the last commit that had `{candidate}`; "
345
- "it was deleted, not moved"))
488
+ evidence.append(_evidence("commit", traced[1], f"deleted `{candidate}` on purpose (no rename); "
489
+ "`doctor --fix --write` marks the row (removed in it)"))
346
490
  break
347
491
  if not evidence:
348
492
  evidence.append(_evidence("file", f"{missing['path']}:{missing['line']}",
349
- "the target was never in git history: fix the link or drop the row"))
493
+ "git shows no move or deletion of the target: fix the link or drop the row"))
350
494
  entries.append(_entry("index-missing-file", missing["path"], missing["line"], missing["text"],
351
495
  f"`{missing['target']}`", evidence, target=missing["target"]))
352
496
  return entries
@@ -53,6 +53,10 @@ start any work: no change, PRD or roadmap is created here.
53
53
  - Non-JS stacks: `*.sln`/`*.csproj` -> `dotnet build` / `dotnet test`; `pyproject.toml` ->
54
54
  `ruff check` / `pytest`; `go.mod` -> `go vet ./...` / `go test ./...`. Use them only if the
55
55
  tool's config is actually present.
56
+ - Project name (`project`): the name the project calls itself, from the README's first heading, else
57
+ `package.json` -> `name` (without the scope), else the repository name. It names the project in
58
+ `context/state.json` and every report, between roadmaps too. Interactive: ask once, with the
59
+ detected name as the recommended answer. An existing `project` is never changed here.
56
60
  - Main branch: `git symbolic-ref refs/remotes/origin/HEAD`, falling back to whichever of
57
61
  `main`/`master` exists locally.
58
62
  - Migrations: look for `drizzle/`, `migrations/`, `prisma/migrations/`, `db/migrate/` and
@@ -120,6 +124,7 @@ Required keys and the ones init writes by default:
120
124
 
121
125
  ```json
122
126
  {
127
+ "project": "Example clinic",
123
128
  "mode": "manual",
124
129
  "language": "en",
125
130
  "chatLanguage": "pl",
@@ -8,6 +8,7 @@ A fictional repo, first run, interactive. Use it for the shape of the plan and t
8
8
  - `package.json` scripts: `typecheck: "tsc --noEmit"`, `lint: "eslint ."`, `test: "vitest run"`,
9
9
  `test:e2e: "playwright test"`, `stack:test: "docker compose -f docker/test.yml up -d && playwright test; docker compose -f docker/test.yml down"`,
10
10
  `db:generate: "drizzle-kit generate"`.
11
+ - README's first heading `# Booking` -> project `Booking`.
11
12
  - `origin/HEAD` -> `origin/main`.
12
13
  - `drizzle/` with `0000_init.sql` ... `0014_slots_index.sql`.
13
14
  - `.env` present.
@@ -28,6 +29,7 @@ context/
28
29
 
29
30
  ```json
30
31
  {
32
+ "project": "Booking",
31
33
  "language": "en",
32
34
  "mainBranch": "main",
33
35
  "gates": {
@@ -51,7 +53,7 @@ context/
51
53
  ```
52
54
 
53
55
  ```text
54
- read: gates.*, migrations.dir, mainBranch (origin/HEAD)
56
+ read: project (README heading), gates.*, migrations.dir, mainBranch (origin/HEAD)
55
57
  inferred: integration.local -> stack:test (brings up its own stack; test:e2e expects a running app)
56
58
  migrations.pattern -> from 15 existing file names
57
59
  Optional keys you may want: timezone, integration.cadence, worktree.cloudState, install.