@jesdi/skills 0.0.76 → 0.0.77

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,6 +17,10 @@ pnpm check
17
17
  `pnpm test:python` and `pnpm check` use `.venv` automatically when no other
18
18
  virtual environment is active. Otherwise they use `python3` from your PATH.
19
19
 
20
+ `pnpm check:fast [file…]` is the fast gate: the type check, then the given
21
+ test files (default: `IMPLEMENT_SPEC_LOCKED`), each `.py` in its own pytest run
22
+ and the `.ts` files in one vitest run. implement-spec takes it as `--fast-gate`.
23
+
20
24
  ## Install skills
21
25
 
22
26
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jesdi/skills",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,6 +32,7 @@
32
32
  "test:python": "sh scripts/test-python.sh",
33
33
  "crap-gate": "sh skills/crap-gate/run.sh",
34
34
  "check": "sh scripts/check.sh",
35
+ "check:fast": "sh scripts/check-fast.sh",
35
36
  "generate-manifest": "tsx scripts/generate-manifest.ts"
36
37
  }
37
38
  }
@@ -11,7 +11,7 @@ description: >-
11
11
  # test-prune: delete what the mutation ratchet proves redundant, strengthen what it proves weak
12
12
 
13
13
  You are the orchestrator. `prune.py` owns every git, make and file operation and every safety
14
- guard; the subagents only write JSON files or test commits. Each role is a fresh subagent with no
14
+ guard; the subagents only write JSON files or tests. Each role is a fresh subagent with no
15
15
  context from the others: the reviewer reads the fixer's proposals, reasons included, and judges
16
16
  them against the code itself.
17
17
 
@@ -130,13 +130,19 @@ when `prune` exited 1 (the status keeps that failure, so the job still goes red)
130
130
  detaches HEAD at the base commit. `nothing to strengthen` ends the loop.
131
131
  2. **Strengthen agent.** Dispatch a fresh subagent with `strengthen-input.json`. Brief: per item,
132
132
  test-first, write the assertion or test that fails against each named mutant and passes on
133
- the real code; touch only `backend/tests/`; make one or more commits per item, each ending
134
- with the trailer line `Test-Prune-Item: <item id>`; leave the tree clean.
133
+ the real code; edit only files under `backend/tests/`, and commit each item with
134
+ `python3 <skill-dir>/prune.py strengthen-commit --item <item id>` as soon as its tests are
135
+ written. Never run `git commit` yourself: the command commits every change under
136
+ `backend/tests/` with the item's trailer, one item per call (an item may take several calls),
137
+ and refuses an unknown or closed item, any change outside `backend/tests/`, or nothing to
138
+ commit. Leave the tree clean.
135
139
  3. `strengthen-verify` rejects commits without a known trailer or outside `backend/tests/`, then
136
140
  proves each item on a cold run: every named id survived on the base and is killed on the
137
141
  head. Unproven items are reverted and closed: a later commit for a closed item is refused. It
138
142
  writes `<state>/strengthen-proof.json`, including the proven head. On failure HEAD stays
139
- where the commits are (detached, unattended): fix and rerun. To abandon the loop instead,
143
+ where the commits are (detached, unattended): fix and rerun. A rejection names the recovery
144
+ that needs no reset: `git checkout <start>`, then commit each item again with
145
+ `strengthen-commit`. To abandon the loop instead,
140
146
  `git checkout <base branch>`; the item commits stay reachable through `git reflog`.
141
147
  4. **Strengthen reviewer.** Dispatch a fresh subagent with `strengthen-proof.json` and the diff
142
148
  of the proven items (`git log -p <start>..HEAD`). Brief: accept an item only when its test
@@ -2,8 +2,8 @@
2
2
  """test-prune: drive the fixer/reviewer prune loop and the strengthen loop over a target repo.
3
3
 
4
4
  collect → (fixer) → review-input → (reviewer) → batch → apply (interactive) | prune (unattended);
5
- strengthen-start → (strengthen agent) → strengthen-verify → (reviewer) → strengthen-finish.
6
- The script owns every git, make and file operation; the agents only write JSON or test commits.
5
+ strengthen-start → (strengthen agent, strengthen-commit per item) → strengthen-verify → (reviewer) → strengthen-finish.
6
+ The script owns every git, make and file operation; the agents only write JSON or test files.
7
7
  """
8
8
  from __future__ import annotations
9
9
 
@@ -17,12 +17,12 @@ from pathlib import Path
17
17
  from prune_repo import BadInput, Fail, Repo, State, read_agent_json
18
18
  from prune_review import batch, collect, review_input
19
19
  from prune_runs import apply, prune
20
- from prune_strengthen import strengthen_finish, strengthen_start, strengthen_verify
20
+ from prune_strengthen import strengthen_commit, strengthen_finish, strengthen_start, strengthen_verify
21
21
 
22
22
  COMMANDS = {
23
23
  "collect": collect, "review-input": review_input, "batch": batch, "apply": apply, "prune": prune,
24
24
  "strengthen-start": strengthen_start, "strengthen-verify": strengthen_verify,
25
- "strengthen-finish": strengthen_finish,
25
+ "strengthen-commit": strengthen_commit, "strengthen-finish": strengthen_finish,
26
26
  }
27
27
 
28
28
 
@@ -54,6 +54,7 @@ def build_parser():
54
54
  sub.add_parser("apply", parents=[common])
55
55
  sub.add_parser("prune", parents=[common])
56
56
  sub.add_parser("strengthen-start", parents=[common])
57
+ sub.add_parser("strengthen-commit", parents=[common]).add_argument("--item", required=True)
57
58
  sub.add_parser("strengthen-verify", parents=[common])
58
59
  sub.add_parser("strengthen-finish", parents=[common]).add_argument("--reviews", required=True)
59
60
  return parser
@@ -119,6 +119,11 @@ class Repo:
119
119
  fields.pop(0)
120
120
  return paths
121
121
 
122
+ def changes(self) -> list[str]:
123
+ """Every staged, unstaged or untracked path, from `git status --porcelain -z --no-renames`."""
124
+ out = self.git("status", "--porcelain", "-z", "--no-renames", "--untracked-files=all")
125
+ return [entry[3:] for entry in out.split("\0") if entry]
126
+
122
127
  def require_clean(self) -> None:
123
128
  dirty = self.dirty()
124
129
  if dirty:
@@ -47,8 +47,9 @@ def strengthen_start(ctx) -> int:
47
47
  ctx.state.save("strengthen.json", {"start": start, "verified": False, "items": work,
48
48
  "status": {i["id"]: "open" for i in work}, "closed": {}})
49
49
  path = ctx.state.save("strengthen-input.json", {"start": start, "items": work})
50
- ctx.state.emit(f"{len(work)} strengthen items → {path}\nCommit each item test-first on top of {start[:12]}: one or more "
51
- f"commits per item, each touching only backend/tests/ and ending with the trailer `{TRAILER}: <item id>`.")
50
+ ctx.state.emit(f"{len(work)} strengthen items → {path}\nWrite each item's tests test-first on top of {start[:12]}, touching "
51
+ f"only backend/tests/, and commit each item with `prune.py strengthen-commit --item <item id>` (one item "
52
+ f"per call; an item may take several). Never run `git commit` yourself.")
52
53
  return 0
53
54
 
54
55
 
@@ -77,11 +78,21 @@ def reopened(history: list, closed: dict) -> list:
77
78
  if len(items) == 1 and items[0] in closed and i > position.get(closed[items[0]], -1)]
78
79
 
79
80
 
81
+ def _recovery(start: str) -> str:
82
+ """How to redo rejected commits with checkout, edits and commits alone (no reset)."""
83
+ return (f"Redo them one item per commit: `git checkout {start}`, then write each item's tests again and "
84
+ f"commit each item with `prune.py strengthen-commit --item <item id>`.")
85
+
86
+
87
+ def _require_descends(repo, start: str) -> None:
88
+ if repo.run_git("merge-base", "--is-ancestor", start, "HEAD").returncode:
89
+ raise BadInput(f"HEAD does not descend from the strengthen start {start}")
90
+
91
+
80
92
  def _commits(repo, st: dict) -> list:
81
93
  """[(sha, item id)] since start; every commit must name a known, open item and touch only backend/tests/."""
82
94
  start = st["start"]
83
- if repo.run_git("merge-base", "--is-ancestor", start, "HEAD").returncode:
84
- raise BadInput(f"HEAD does not descend from the strengthen start {start}")
95
+ _require_descends(repo, start)
85
96
  errors = ["merge commits since the strengthen start"] if repo.git(
86
97
  "rev-list", "--min-parents=2", f"{start}..HEAD").strip() else []
87
98
  history = _history(repo, start)
@@ -90,10 +101,30 @@ def _commits(repo, st: dict) -> list:
90
101
  errors += commit_problems(sha, items, paths, known)
91
102
  errors += reopened(history, st["closed"])
92
103
  if errors:
93
- raise BadInput("strengthen commits rejected:\n" + "\n".join(errors))
104
+ raise BadInput("strengthen commits rejected:\n" + "\n".join(errors) + "\n" + _recovery(start))
94
105
  return [(sha, items[0]) for sha, items, _ in history]
95
106
 
96
107
 
108
+ def strengthen_commit(ctx) -> int:
109
+ """Commit the working tree's changes under backend/tests/ as one commit for one open item; the
110
+ trailer is written here, so a commit can never name two items."""
111
+ repo, st, item_id = ctx.repo, ctx.state.load("strengthen.json"), ctx.args.item
112
+ status = st["status"].get(item_id)
113
+ if status not in ("open", "proven"):
114
+ raise BadInput(f"{item_id} is not an open strengthen item (status: {status or 'unknown'})")
115
+ _require_descends(repo, st["start"])
116
+ changed = repo.changes()
117
+ outside = [p for p in changed if not p.startswith("backend/tests/")]
118
+ if outside:
119
+ raise BadInput("changes outside backend/tests/, discard them first:\n" + "\n".join(outside))
120
+ if not changed:
121
+ raise BadInput(f"nothing to commit for {item_id}: write its tests under backend/tests/ first")
122
+ repo.git("add", "-A", "--", "backend/tests/")
123
+ repo.git("commit", "-q", "-m", f"test: strengthen {item_id}", "-m", f"{TRAILER}: {item_id}")
124
+ ctx.state.emit(repo.head())
125
+ return 0
126
+
127
+
97
128
  def _revert(repo, item_id: str, commits: list, why: str) -> None:
98
129
  shas = [sha for sha, item in reversed(commits) if item == item_id]
99
130
  if not shas:
@@ -2,6 +2,8 @@
2
2
  import json
3
3
  import re
4
4
 
5
+ import pytest
6
+
5
7
  from prune_harness import PRUNE_BRANCH, REFERENCE, STRENGTHEN_BRANCH, R, arg, cand, case
6
8
 
7
9
  COMPUTE = "rebalancer.compute_trades"
@@ -120,6 +122,28 @@ def test_a_co_author_paragraph_after_the_item_trailer_does_not_hide_it(target):
120
122
  assert all(i in strengthen_pr(target) for i in IDS_7_9)
121
123
 
122
124
 
125
+ def test_a_commit_naming_two_items_is_rejected_with_a_recovery_the_agent_can_run(target):
126
+ # The unattended agent may not reset: the recovery must need only checkout, edits and commits.
127
+ target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
128
+ groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(["x_apply_drift__mutmut_2"])})
129
+ target.ok("strengthen-start")
130
+ start = target.read_state("strengthen.json")["start"]
131
+ path = target.root / "backend/tests/test_rebalancer.py"
132
+ path.write_text(path.read_text() + COMPUTE_TEST + DRIFT_TEST)
133
+ target.git("commit", "-qam", f"test: both\n\nTest-Prune-Item: {COMPUTE}\nTest-Prune-Item: {DRIFT}")
134
+
135
+ verify = target.run("strengthen-verify")
136
+
137
+ assert verify.returncode == 2
138
+ out = verify.stdout + verify.stderr
139
+ assert "one item per commit" in out
140
+ assert f"git checkout {start}" in out
141
+ target.git("checkout", "-q", start)
142
+ target.commit_test(COMPUTE, COMPUTE_TEST)
143
+ target.commit_test(DRIFT, DRIFT_TEST)
144
+ target.ok("strengthen-verify")
145
+
146
+
123
147
  def test_strengthen_item_whose_ids_are_not_all_killed_is_reverted_and_left_out_of_the_pr(target):
124
148
  drift_ids = ["x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"]
125
149
  target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
@@ -192,3 +216,123 @@ def test_every_post_batch_mutation_run_starts_from_an_empty_mutants_directory(ta
192
216
  assert all(r["mutants"] in ("absent", "empty") for r in runs), runs
193
217
  assert all(r["KEEP_CACHE"] is None for r in runs), runs
194
218
  assert culprit in target.ids_at(target.remote_sha(PRUNE_BRANCH))
219
+
220
+
221
+ # --- strengthen-commit: prune.py makes each item's commit, one item per call -------------------
222
+
223
+ TESTS_FILE = "backend/tests/test_rebalancer.py"
224
+
225
+
226
+ def write_test(target, source, file=TESTS_FILE):
227
+ path = target.root / file
228
+ path.write_text(path.read_text() + "\n\n" + source.strip("\n") + "\n")
229
+
230
+
231
+ def two_items(target, drift_ids=("x_apply_drift__mutmut_2",)):
232
+ target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
233
+ groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(list(drift_ids))})
234
+ target.ok("strengthen-start")
235
+
236
+
237
+ def refused(target, item, needle):
238
+ head = target.git("rev-parse", "HEAD").strip()
239
+ proc = target.run("strengthen-commit", "--item", item)
240
+ assert proc.returncode == 2, proc.stdout + proc.stderr
241
+ assert needle in proc.stderr, proc.stderr
242
+ assert target.git("rev-parse", "HEAD").strip() == head
243
+ assert target.read_state("status.json")["commands"][-1] == {
244
+ "command": "strengthen-commit", "exit": 2, "reason": proc.stderr.strip().splitlines()[0]}
245
+
246
+
247
+ def test_strengthen_commit_makes_one_commit_per_item_that_strengthen_verify_accepts(target):
248
+ two_items(target)
249
+ shas = []
250
+ for item, source in [(COMPUTE, COMPUTE_TEST), (DRIFT, DRIFT_TEST)]:
251
+ write_test(target, source)
252
+ proc = target.ok("strengthen-commit", "--item", item)
253
+ sha = target.git("rev-parse", "HEAD").strip()
254
+ assert proc.stdout.strip() == sha
255
+ assert target.git("log", "-1", "--format=%s", sha).strip() == f"test: strengthen {item}"
256
+ trailers = target.git("log", "-1", "--format=%(trailers:key=Test-Prune-Item,valueonly)", sha).split()
257
+ assert trailers == [item]
258
+ assert target.git("diff-tree", "--no-commit-id", "--name-only", "-r", sha).split() == [TESTS_FILE]
259
+ shas.append(sha)
260
+ assert target.git("rev-list", "--reverse", f"{target.base}..HEAD").split() == shas
261
+ assert target.git("status", "--porcelain").strip() == ""
262
+
263
+ target.ok("strengthen-verify")
264
+
265
+ assert target.read_state("strengthen.json")["status"] == {
266
+ COMPUTE: "proven", DRIFT: "proven"}
267
+ write_test(target, COMPUTE_TEST.replace("_rounding", "_rounding_again"))
268
+ target.ok("strengthen-commit", "--item", COMPUTE) # a proven item is still open for more commits
269
+
270
+
271
+ def test_strengthen_commit_commits_a_new_test_file_under_backend_tests(target):
272
+ two_items(target)
273
+ (target.root / "backend/tests/test_new.py").write_text(DRIFT_TEST)
274
+
275
+ target.ok("strengthen-commit", "--item", DRIFT)
276
+
277
+ assert target.git("diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD").split() == [
278
+ "backend/tests/test_new.py"]
279
+
280
+
281
+ def test_strengthen_commit_refuses_an_unknown_item(target):
282
+ two_items(target)
283
+ write_test(target, COMPUTE_TEST)
284
+ refused(target, "rebalancer.no_such_group", "rebalancer.no_such_group")
285
+
286
+
287
+ def test_strengthen_commit_refuses_an_item_strengthen_verify_closed(target):
288
+ two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
289
+ write_test(target, DRIFT_TEST)
290
+ target.ok("strengthen-commit", "--item", DRIFT)
291
+ target.ok("strengthen-verify") # DRIFT_TEST leaves _4 alive: the item is reverted and closed
292
+ assert target.read_state("strengthen.json")["status"][DRIFT] == "reverted"
293
+ write_test(target, DRIFT_TEST.replace("_new", "_again"))
294
+ refused(target, DRIFT, "reverted")
295
+
296
+
297
+ def test_strengthen_commit_refuses_before_strengthen_start(target):
298
+ target.prepare([cand(case(1))], accept=[COMPUTE], groups={COMPUTE: strengthen_group(IDS_7_9)})
299
+ write_test(target, COMPUTE_TEST)
300
+ refused(target, COMPUTE, "strengthen.json")
301
+
302
+
303
+ @pytest.mark.parametrize("outside", ["backend/services/rebalancer.py", "backend/notes.txt", "README-x.md"])
304
+ def test_strengthen_commit_refuses_any_change_outside_backend_tests(target, outside):
305
+ two_items(target)
306
+ write_test(target, COMPUTE_TEST)
307
+ path = target.root / outside
308
+ path.write_text((path.read_text() if path.exists() else "") + "\n# edited\n")
309
+ refused(target, COMPUTE, outside)
310
+
311
+
312
+ def test_strengthen_commit_refuses_a_staged_change_outside_backend_tests(target):
313
+ two_items(target)
314
+ write_test(target, COMPUTE_TEST)
315
+ path = target.root / "backend/services/rebalancer.py"
316
+ path.write_text(path.read_text() + "\n# edited\n")
317
+ target.git("add", "backend/services/rebalancer.py")
318
+ target.git("restore", "--worktree", "--source=HEAD", "backend/services/rebalancer.py")
319
+ refused(target, COMPUTE, "backend/services/rebalancer.py")
320
+
321
+
322
+ def test_strengthen_commit_refuses_a_file_moved_into_backend_tests_from_outside(target):
323
+ two_items(target)
324
+ target.git("mv", "backend/services/rebalancer.py", "backend/tests/moved.py")
325
+ refused(target, COMPUTE, "\nbackend/services/rebalancer.py")
326
+
327
+
328
+ def test_strengthen_commit_refuses_when_nothing_changed(target):
329
+ two_items(target)
330
+ refused(target, COMPUTE, "nothing to commit")
331
+
332
+
333
+ def test_strengthen_commit_refuses_a_head_off_the_strengthen_start(target):
334
+ two_items(target)
335
+ target.git("checkout", "-q", "--orphan", "elsewhere")
336
+ target.git("commit", "-q", "-m", "unrelated root")
337
+ write_test(target, COMPUTE_TEST)
338
+ refused(target, COMPUTE, "does not descend")
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-29T07:54:23.516Z",
3
+ "generatedAt": "2026-10-29T12:22:26.879Z",
4
4
  "skills": [
5
5
  {
6
6
  "name": "agents-wayfinder",
@@ -100,8 +100,8 @@
100
100
  },
101
101
  {
102
102
  "name": "test-prune",
103
- "version": "0.1.2",
104
- "hash": "sha256-d6122a5ad5085f040e331744259896bf84ff7211177fea075747c1b50bf79a0e",
103
+ "version": "0.1.3",
104
+ "hash": "sha256-fc4cd53e5898627982dc8b48bf6c5fcea34c3acf492dbfd9a05b4181ce9160ef",
105
105
  "description": "Mutation-guided test pruning: a fixer proposes deleting redundant tests and strengthening weak ones, an independent reviewer accepts or rejects each proposal, and prune.py applies the accepted batch behind a cold mutation run and the ratchet. Use when the user says \"prune tests\", \"test-prune\", \"mutation test pruning\" or \"strengthen weak tests\", or when a scheduled job runs it with `--unattended`."
106
106
  },
107
107
  {