@jesdi/skills 0.0.74 → 0.0.75
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/package.json +1 -1
- package/skills/implement-spec/README.md +1 -0
- package/skills/implement-spec/driver_final.py +8 -0
- package/skills/implement-spec/driver_merge.py +20 -2
- package/skills/implement-spec/driver_tidy.py +2 -8
- package/skills/implement-spec/tests/test_final.py +27 -0
- package/skills/implement-spec/tests/test_merge.py +8 -0
- package/skills/implement-spec/tests/test_tidy.py +3 -1
- package/skills/implement-spec/tests/test_walk.py +3 -1
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -148,6 +148,7 @@ History rules:
|
|
|
148
148
|
- The branch is rewritten once, before the first review, and never after it. Fixes of the final review stay as `fix(NN)` commits.
|
|
149
149
|
- A history that `origin` already has is never rewritten. When `origin` has the PR branch or one of its commits, the driver does no tidy and no rebase. The gate, the final review and a fast-forward push still run.
|
|
150
150
|
- The push happens only when the branch tip is the reviewed tip and that tip has a green gate record.
|
|
151
|
+
- With `commit.gpgsign` on, the driver signs every commit it makes (ticket merges, tidied and renamed commits) with the configured key. The push happens only when every commit that `origin` lacks has a good signature (`%G?` is `G`); otherwise the end of run is BLOCKED and nothing is pushed.
|
|
151
152
|
|
|
152
153
|
A repository with no `origin` remote skips only step 2 and step 6. The tidied commits stay on the commit that the PR branch had when the run started, and the review range starts there. One ledger sentence says that the rebase and the push were skipped. The driver prints the two tips and ends with exit 0. When you add `origin` after such an end of run, `--push` does not push: the branch is on no base of that remote, so the end of run is BLOCKED.
|
|
153
154
|
|
|
@@ -537,6 +537,13 @@ def _open_pr(run: Run, final: dict, tickets: list[Ticket]) -> str:
|
|
|
537
537
|
return url
|
|
538
538
|
|
|
539
539
|
|
|
540
|
+
def _require_signed(run: Run, tip: str) -> None:
|
|
541
|
+
"""Block the push when commit.gpgsign is on and a commit that origin lacks has no good signature."""
|
|
542
|
+
if bad := driver_merge.unsigned(tip):
|
|
543
|
+
raise Blocked(f"commit.gpgsign is on but {len(bad)} commit{'s' if len(bad) > 1 else ''} of {run.pr} "
|
|
544
|
+
f"{'have' if len(bad) > 1 else 'has'} no good signature ({', '.join(bad)}): nothing is pushed")
|
|
545
|
+
|
|
546
|
+
|
|
540
547
|
def _push(run: Run, final: dict, tickets: list[Ticket]) -> list[str]:
|
|
541
548
|
"""Push the reviewed tip to origin, once and with no force, then open the PR, once. Returns the lines for the
|
|
542
549
|
operator."""
|
|
@@ -550,6 +557,7 @@ def _push(run: Run, final: dict, tickets: list[Ticket]) -> list[str]:
|
|
|
550
557
|
if not shutil.which("gh"):
|
|
551
558
|
raise Blocked("gh is not on PATH: nothing is pushed")
|
|
552
559
|
if final["pushed"] != tip:
|
|
560
|
+
_require_signed(run, tip)
|
|
553
561
|
# The commit, not the branch name: what leaves the machine is the tip the review covered.
|
|
554
562
|
sent = git(".", "push", "-q", "origin", f"{tip}:refs/heads/{run.pr}")
|
|
555
563
|
if sent.returncode:
|
|
@@ -19,6 +19,25 @@ def identity(tip: str, slot: str = ".") -> dict[str, str]:
|
|
|
19
19
|
return {"GIT_AUTHOR_NAME": name, "GIT_AUTHOR_EMAIL": email, "GIT_COMMITTER_NAME": name, "GIT_COMMITTER_EMAIL": email}
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
def signs() -> bool:
|
|
23
|
+
"""commit.gpgsign is on: every commit the driver makes must be signed."""
|
|
24
|
+
return git(".", "config", "--type=bool", "commit.gpgsign").stdout.strip() == "true"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def commit_tree(args: list[str], env: dict[str, str]) -> subprocess.CompletedProcess:
|
|
28
|
+
"""`git commit-tree` with `env` on top of os.environ, signed when commit.gpgsign is on: commit-tree ignores it."""
|
|
29
|
+
sign = ["-S"] if signs() else []
|
|
30
|
+
return subprocess.run(["git", "commit-tree", *sign, *args], capture_output=True, text=True, env={**os.environ, **env})
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def unsigned(tip: str) -> list[str]:
|
|
34
|
+
"""The commits of `tip` that origin does not have and that have no good signature, when commit.gpgsign is on."""
|
|
35
|
+
if not signs():
|
|
36
|
+
return []
|
|
37
|
+
rows = git(".", "log", "--format=%h %G?", tip, "--not", "--remotes=origin").stdout.splitlines()
|
|
38
|
+
return [row.split()[0] for row in rows if not row.endswith(" G")]
|
|
39
|
+
|
|
40
|
+
|
|
22
41
|
def commit(pr_tip: str, tip: str, message: str) -> tuple[str, str]:
|
|
23
42
|
"""(the commit the PR branch gets, "") or ("", the error): `pr_tip` when the ticket is merged already, `tip`
|
|
24
43
|
for a fast-forward, else a new merge commit."""
|
|
@@ -30,8 +49,7 @@ def commit(pr_tip: str, tip: str, message: str) -> tuple[str, str]:
|
|
|
30
49
|
if tree.returncode:
|
|
31
50
|
files = ", ".join(tree.stdout.splitlines()[1:]) or tree.stderr.strip()
|
|
32
51
|
return "", f"the merge into the PR branch conflicts in {files}"
|
|
33
|
-
made =
|
|
34
|
-
capture_output=True, text=True, env={**os.environ, **identity(tip)})
|
|
52
|
+
made = commit_tree([tree.stdout.strip(), "-p", pr_tip, "-p", tip, "-m", message], identity(tip))
|
|
35
53
|
return (made.stdout.strip(), "") if made.returncode == 0 else ("", f"git commit-tree failed: {made.stderr.strip()}")
|
|
36
54
|
|
|
37
55
|
|
|
@@ -5,9 +5,6 @@ Nothing here checks out a tree or moves a ref: a new commit takes the tree of an
|
|
|
5
5
|
"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
import os
|
|
9
|
-
import subprocess
|
|
10
|
-
|
|
11
8
|
import driver_merge
|
|
12
9
|
from driver_slots import git
|
|
13
10
|
from driver_tickets import Ticket
|
|
@@ -31,11 +28,8 @@ def same_tree(one: str, other: str) -> bool:
|
|
|
31
28
|
def _commit(source: str, parent: str, words: str) -> str:
|
|
32
29
|
"""A commit on `parent` with the tree and the author of `source` and the message `words`; "" when git fails."""
|
|
33
30
|
name, email, date = git(".", "log", "-1", "--format=%an%n%ae%n%aI", source).stdout.splitlines() or [""] * 3
|
|
34
|
-
env = {**
|
|
35
|
-
|
|
36
|
-
made = subprocess.run(["git", "commit-tree", f"{source}^{{tree}}", "-p", parent, "-m", words.strip() + "\n"],
|
|
37
|
-
capture_output=True, text=True, env=env)
|
|
38
|
-
return made.stdout.strip()
|
|
31
|
+
env = {**driver_merge.identity(source), "GIT_AUTHOR_NAME": name, "GIT_AUTHOR_EMAIL": email, "GIT_AUTHOR_DATE": date}
|
|
32
|
+
return driver_merge.commit_tree([f"{source}^{{tree}}", "-p", parent, "-m", words.strip() + "\n"], env).stdout.strip()
|
|
39
33
|
|
|
40
34
|
|
|
41
35
|
def rewrite(parent: str, steps: list[tuple[str, str]]) -> list[str]:
|
|
@@ -23,10 +23,13 @@ Interface choices (ticket 06):
|
|
|
23
23
|
commit of the rebase that touches the same file conflicts again.
|
|
24
24
|
"""
|
|
25
25
|
import json
|
|
26
|
+
import os
|
|
26
27
|
import re
|
|
27
28
|
import shutil
|
|
28
29
|
import subprocess
|
|
29
30
|
import sys
|
|
31
|
+
import tempfile
|
|
32
|
+
from pathlib import Path
|
|
30
33
|
from types import SimpleNamespace
|
|
31
34
|
|
|
32
35
|
import pytest
|
|
@@ -501,6 +504,30 @@ def test_unattended_with_a_blocked_ticket_pushes_nothing_and_exits_1(tmp_path):
|
|
|
501
504
|
assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["01"]}
|
|
502
505
|
|
|
503
506
|
|
|
507
|
+
def test_with_commit_gpgsign_on_every_pushed_commit_is_signed_with_the_configured_key(tmp_path):
|
|
508
|
+
gpg = shutil.which("gpg")
|
|
509
|
+
if not gpg:
|
|
510
|
+
pytest.skip("no gpg")
|
|
511
|
+
home = Path(tempfile.mkdtemp(prefix="gpg", dir="/tmp")) # the agent socket path must stay short
|
|
512
|
+
try:
|
|
513
|
+
rig = Final(tmp_path, THREE)
|
|
514
|
+
rig.env["GNUPGHOME"] = str(home)
|
|
515
|
+
subprocess.run([gpg, "--batch", "--passphrase", "", "--quick-gen-key", "t <t@example.com>", "ed25519",
|
|
516
|
+
"sign", "never"], env=rig.env, check=True, capture_output=True)
|
|
517
|
+
rig.env.update(GIT_CONFIG_COUNT="3", GIT_CONFIG_VALUE_0="true", GIT_CONFIG_KEY_1="gpg.program",
|
|
518
|
+
GIT_CONFIG_VALUE_1=gpg, GIT_CONFIG_KEY_2="user.signingkey", GIT_CONFIG_VALUE_2="t@example.com")
|
|
519
|
+
rig.run(plan(), *UNATTENDED)
|
|
520
|
+
assert rig.code == 0, rig.output()
|
|
521
|
+
pushed = git(rig.repo, "rev-list", f"{rig.start}..{ref(rig.origin, 'refs/heads/feat/csv')}").split()
|
|
522
|
+
assert len(pushed) == 3
|
|
523
|
+
for commit in pushed:
|
|
524
|
+
verified = subprocess.run(["git", "verify-commit", commit], cwd=rig.repo, env=rig.env, capture_output=True)
|
|
525
|
+
assert verified.returncode == 0, (commit, verified.stderr)
|
|
526
|
+
finally:
|
|
527
|
+
subprocess.run([str(Path(gpg).with_name("gpgconf")), "--kill", "gpg-agent"], env={**os.environ, "GNUPGHOME": str(home)})
|
|
528
|
+
shutil.rmtree(home, ignore_errors=True)
|
|
529
|
+
|
|
530
|
+
|
|
504
531
|
# ---------------------------------------------------------------- the merge-risk block of the PR body (ticket 15)
|
|
505
532
|
|
|
506
533
|
PR_RISK = SKILL.parent / "pr-risk"
|
|
@@ -142,3 +142,11 @@ def test_begin_opens_the_conflicting_merge_on_a_machine_with_no_git_identity(rep
|
|
|
142
142
|
monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
|
|
143
143
|
monkeypatch.delenv("GIT_CONFIG_COUNT")
|
|
144
144
|
assert driver_merge.begin(".", pr_tip) == ["a.txt"]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_unsigned_lists_the_commits_origin_lacks_only_when_commit_gpgsign_is_on(repo, monkeypatch):
|
|
148
|
+
repo()
|
|
149
|
+
tip = sh("git", "rev-parse", "--short", "HEAD")
|
|
150
|
+
assert driver_merge.unsigned("HEAD") == []
|
|
151
|
+
monkeypatch.setenv("GIT_CONFIG_VALUE_2", "true") # the fixture's commit.gpgsign
|
|
152
|
+
assert driver_merge.unsigned("HEAD") == [tip]
|
|
@@ -52,9 +52,11 @@ class Inside(test_final.Final):
|
|
|
52
52
|
|
|
53
53
|
@pytest.fixture(autouse=True)
|
|
54
54
|
def tools(monkeypatch, tmp_path):
|
|
55
|
-
"""The fake `gh` of the rig is on PATH,
|
|
55
|
+
"""The fake `gh` of the rig is on PATH, no git call of an agent opens an editor, and the driver signs no commit."""
|
|
56
56
|
monkeypatch.setenv("PATH", f"{tmp_path / 'bin'}{os.pathsep}{os.environ['PATH']}")
|
|
57
57
|
monkeypatch.setenv("GIT_EDITOR", "true")
|
|
58
|
+
for name, value in (("GIT_CONFIG_COUNT", "1"), ("GIT_CONFIG_KEY_0", "commit.gpgsign"), ("GIT_CONFIG_VALUE_0", "false")):
|
|
59
|
+
monkeypatch.setenv(name, value)
|
|
58
60
|
|
|
59
61
|
|
|
60
62
|
def stray(rig, text="by hand"):
|
|
@@ -159,7 +159,9 @@ def make_env(tmp):
|
|
|
159
159
|
for cli in ("claude", "codex"):
|
|
160
160
|
(bin_dir / cli).write_text("#!/bin/sh\nexit 1\n")
|
|
161
161
|
(bin_dir / cli).chmod(0o755)
|
|
162
|
-
|
|
162
|
+
# The driver's own commits are signed when commit.gpgsign is on: a test opts in, the operator's config does not.
|
|
163
|
+
return dict(os.environ, PATH=str(bin_dir), GIT_CONFIG_COUNT="1", GIT_CONFIG_KEY_0="commit.gpgsign",
|
|
164
|
+
GIT_CONFIG_VALUE_0="false")
|
|
163
165
|
|
|
164
166
|
|
|
165
167
|
class Rig:
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-10-
|
|
3
|
+
"generatedAt": "2026-10-29T01:26:25.649Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "implement-spec",
|
|
61
|
-
"version": "0.1.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.45",
|
|
62
|
+
"hash": "sha256-414150538cb2f16ab2d27a7c49fd1ee49fc92ac009e775afe9df9ebc46348c1f",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|