@jesdi/skills 0.0.102 → 0.0.104

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jesdi/skills",
3
- "version": "0.0.102",
3
+ "version": "0.0.104",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,9 +17,10 @@ stderr.
17
17
  |---|---|
18
18
  | `python3 pr_exam.py validate --request <request.json> <exam.json>` | Checks a generated exam against its request; prints its summary. |
19
19
  | `python3 pr_exam.py public <exam.json>` | Prints the exam the page may show: no key, concepts or answers. |
20
- | `python3 pr_exam.py score --exam <exam.json> --answers <answers.json> --grades <grades.json>` | Scores an attempt and names what was missed. |
20
+ | `python3 pr_exam.py score --exam <exam.json> --answers <answers.json> --grades <grades.json> [--flags <flags.json>]` | Scores an attempt and names what was missed. `--flags` holds `{"bypassed": [id], "assisted": [id, ...]}`: one bypassed question leaves the score; both are reported as `help`. |
21
21
  | `python3 pr_exam.py learned --records <dir> --today <YYYY-MM-DD>` | Lists concepts known, due or wrong. |
22
- | `python3 pr_exam.py record --records <dir> --exam <exam.json> --result <result.json> --today <YYYY-MM-DD>` | Writes learning records for a scored attempt. |
22
+ | `python3 pr_exam.py record --records <dir> --exam <exam.json> --result <result.json> --today <YYYY-MM-DD>` | Writes learning records for a scored attempt: `demonstrated`, `assisted` (a full point with help, always `due`) or `misconception`. An older `pr_exam.py` refuses an `assisted` record, so never roll the host pin back past this version. |
23
+ | `python3 pr_exam.py context --exam <exam.json> --diff <diff> --body <body> --turn <turn.json>` | Prints the prompt for one tip or chat turn: the section below for its kind, the diff, the body, then the turn. |
23
24
  | `python3 pr_exam.py config [<.pr-exam.json>]` | Reads and validates the repo's exam config. |
24
25
  | `python3 pr_exam.py setup [--check] <owner/repo>` | Run by the operator: makes `exam` a required check of the default branch. `--check` only reports whether it is one. |
25
26
 
@@ -126,6 +127,25 @@ nothing else from generation. No key, no explanation, no earlier attempt.
126
127
  `choice` questions are never graded by the session, and you do not score the attempt: the host runs
127
128
  `pr_exam.py score`, which marks them from the key and refuses a grade for one.
128
129
 
130
+ ## Tips
131
+
132
+ A tip helps a reader who is stuck on one question. You get the question, its key, the draft
133
+ and the earlier tips. Climb one rung per tip number:
134
+
135
+ 1. Where to look: point at a file or hunk, nothing more.
136
+ 2. The missing idea: name what the draft leaves out.
137
+ 3. One step away: bring the reader next to the answer, never onto it.
138
+
139
+ React to the draft. Never state the answer, never quote the key. On a `choice` question never
140
+ quote, name or rule out an option. Do not repeat an earlier tip. Reply in two sentences at most.
141
+
142
+ ## Chat
143
+
144
+ The chat answers freely, the key included: explain, compare, and say whether the draft is
145
+ right. After a submit, use the submitted answer, its points and its feedback to explain the
146
+ result. Ground every claim in the diff and the PR body, and say so when they do not settle it.
147
+ Be brief.
148
+
129
149
  ## Never
130
150
 
131
151
  Never apply a bypass label. Never post an `exam` status. The host decides both.
@@ -15,6 +15,9 @@ with the prompt the host uses (agent-ops `dispatcher/exam_runner.py`). One live
15
15
  `passed.diff`) → `exam.json`, 2 questions on concepts no earlier exam covered.
16
16
  - `delta-nothing-new/`: `delta`, after a pass: the push only rewords a docstring and renames a
17
17
  variable → an empty `exam.json`.
18
+ - `tip-choice/`, `tip-text/`, `chat-answer/`: three live turns on the twelve-concept exam (a tip on a
19
+ `choice` question, tip 1 on a `text` question, a `question` chat turn "what is the answer?"). Each has
20
+ `turn.json`, `prompt.md` (what `context` prints for it) and `reply.md` (`claude -p --tools ''` on the prompt).
18
21
 
19
22
  The requests are written as the host writes them, with paths made relative. Every generation run
20
23
  finished on `validate` exit 0. `test_skill_fixtures.py` checks the outputs again.
@@ -0,0 +1,92 @@
1
+ The chat answers freely, the key included: explain, compare, and say whether the draft is
2
+ right. After a submit, use the submitted answer, its points and its feedback to explain the
3
+ result. Ground every claim in the diff and the PR body, and say so when they do not settle it.
4
+ Be brief.
5
+
6
+ Diff:
7
+ diff --git a/lease.py b/lease.py
8
+ new file mode 100644
9
+ --- /dev/null
10
+ +++ b/lease.py
11
+ @@ -0,0 +1,61 @@
12
+ +import time
13
+ +
14
+ +
15
+ +class LeaseLost(Exception):
16
+ + """The caller no longer owns the lease it tried to write under."""
17
+ +
18
+ +
19
+ +class LeaseStore:
20
+ + """Single-writer lease over a key-value store.
21
+ +
22
+ + Two workers can both believe they lead after a pause (GC, network). A
23
+ + fencing token lets the store reject the older leader's late writes.
24
+ + """
25
+ +
26
+ + def __init__(self, backend, ttl=30, clock=time.monotonic):
27
+ + self.backend = backend
28
+ + self.ttl = ttl
29
+ + self.clock = clock
30
+ +
31
+ + def acquire(self, name, owner):
32
+ + now = self.clock()
33
+ + held = self.backend.get(name)
34
+ + if held and held["expires"] > now and held["owner"] != owner:
35
+ + return None
36
+ + token = (held["token"] + 1) if held else 1
37
+ + self.backend.put(name, {"owner": owner, "token": token, "expires": now + self.ttl})
38
+ + return token
39
+ +
40
+ + def renew(self, name, owner, token):
41
+ + held = self.backend.get(name)
42
+ + if not held or held["owner"] != owner or held["token"] != token:
43
+ + raise LeaseLost(name)
44
+ + held["expires"] = self.clock() + self.ttl
45
+ + self.backend.put(name, held)
46
+ +
47
+ + def write(self, name, token, key, value):
48
+ + held = self.backend.get(name)
49
+ + if not held or held["token"] != token:
50
+ + raise LeaseLost(name)
51
+ + self.backend.put(key, value)
52
+ +
53
+ + def release(self, name, owner, token):
54
+ + held = self.backend.get(name)
55
+ + if held and held["owner"] == owner and held["token"] == token:
56
+ + held["expires"] = 0
57
+ + self.backend.put(name, held)
58
+ +
59
+ +
60
+ +def run_leader(store, name, owner, work, interval=10):
61
+ + token = store.acquire(name, owner)
62
+ + if token is None:
63
+ + return False
64
+ + try:
65
+ + while work(token):
66
+ + store.renew(name, owner, token)
67
+ + time.sleep(interval)
68
+ + except LeaseLost:
69
+ + return False
70
+ + finally:
71
+ + store.release(name, owner, token)
72
+ + return True
73
+
74
+
75
+ PR body:
76
+ Adds a lease so that only one worker runs the nightly sync at a time. Before this, two workers sometimes ran it at once and overwrote each other's results.
77
+
78
+ Why: a worker that stalls past its TTL must not keep writing after another worker took over, so every write carries a fencing token and the store refuses a stale one.
79
+
80
+ ```merge-risk v1
81
+ risk: medium
82
+ rollback: revert; leases expire after the TTL
83
+ blast-radius: the nightly sync only
84
+ ```
85
+
86
+
87
+ Question: {"id": "q3", "concept": "fencing-token", "type": "choice", "prompt": "What makes a write under an old fencing token fail?", "options": ["The token encodes the owner's process identifier", "Every new acquisition increments the stored token", "Each token carries its own signed expiry"]}
88
+ Key: {"explanation": "acquire stores the previous token plus one, so the newest holder always has the highest token and any older token no longer matches.", "hunk": "+ token = (held[\"token\"] + 1) if held else 1", "answer": 1}
89
+
90
+ Draft:
91
+
92
+ Message: what is the answer?
@@ -0,0 +1,7 @@
1
+ The answer is **"Every new acquisition increments the stored token."**
2
+
3
+ - **Why that's right:** `acquire` stores `held["token"] + 1`, so each new holder gets a higher token than the last. `write` then checks `held["token"] != token` and raises `LeaseLost`. An older leader's token no longer matches the stored one, so its late write is refused. This is the behaviour the PR body describes: "the store refuses a stale one."
4
+ - **Why not the owner's process identifier:** the token is a plain integer counter. `write` never looks at the owner at all.
5
+ - **Why not a signed expiry:** the expiry is stored in the lease record, not in the token, and nothing is signed. `write` doesn't check expiry either. It only compares tokens.
6
+
7
+ One caveat from the diff: `write` checks for an exact match, not "is this the highest token." It works here only because the stored token only ever goes up.
@@ -0,0 +1 @@
1
+ {"kind":"question","question":"q3","draft":"","thread":[],"message":"what is the answer?"}
@@ -0,0 +1,97 @@
1
+ A tip helps a reader who is stuck on one question. You get the question, its key, the draft
2
+ and the earlier tips. Climb one rung per tip number:
3
+
4
+ 1. Where to look: point at a file or hunk, nothing more.
5
+ 2. The missing idea: name what the draft leaves out.
6
+ 3. One step away: bring the reader next to the answer, never onto it.
7
+
8
+ React to the draft. Never state the answer, never quote the key. On a `choice` question never
9
+ quote, name or rule out an option. Do not repeat an earlier tip. Reply in two sentences at most.
10
+
11
+ Diff:
12
+ diff --git a/lease.py b/lease.py
13
+ new file mode 100644
14
+ --- /dev/null
15
+ +++ b/lease.py
16
+ @@ -0,0 +1,61 @@
17
+ +import time
18
+ +
19
+ +
20
+ +class LeaseLost(Exception):
21
+ + """The caller no longer owns the lease it tried to write under."""
22
+ +
23
+ +
24
+ +class LeaseStore:
25
+ + """Single-writer lease over a key-value store.
26
+ +
27
+ + Two workers can both believe they lead after a pause (GC, network). A
28
+ + fencing token lets the store reject the older leader's late writes.
29
+ + """
30
+ +
31
+ + def __init__(self, backend, ttl=30, clock=time.monotonic):
32
+ + self.backend = backend
33
+ + self.ttl = ttl
34
+ + self.clock = clock
35
+ +
36
+ + def acquire(self, name, owner):
37
+ + now = self.clock()
38
+ + held = self.backend.get(name)
39
+ + if held and held["expires"] > now and held["owner"] != owner:
40
+ + return None
41
+ + token = (held["token"] + 1) if held else 1
42
+ + self.backend.put(name, {"owner": owner, "token": token, "expires": now + self.ttl})
43
+ + return token
44
+ +
45
+ + def renew(self, name, owner, token):
46
+ + held = self.backend.get(name)
47
+ + if not held or held["owner"] != owner or held["token"] != token:
48
+ + raise LeaseLost(name)
49
+ + held["expires"] = self.clock() + self.ttl
50
+ + self.backend.put(name, held)
51
+ +
52
+ + def write(self, name, token, key, value):
53
+ + held = self.backend.get(name)
54
+ + if not held or held["token"] != token:
55
+ + raise LeaseLost(name)
56
+ + self.backend.put(key, value)
57
+ +
58
+ + def release(self, name, owner, token):
59
+ + held = self.backend.get(name)
60
+ + if held and held["owner"] == owner and held["token"] == token:
61
+ + held["expires"] = 0
62
+ + self.backend.put(name, held)
63
+ +
64
+ +
65
+ +def run_leader(store, name, owner, work, interval=10):
66
+ + token = store.acquire(name, owner)
67
+ + if token is None:
68
+ + return False
69
+ + try:
70
+ + while work(token):
71
+ + store.renew(name, owner, token)
72
+ + time.sleep(interval)
73
+ + except LeaseLost:
74
+ + return False
75
+ + finally:
76
+ + store.release(name, owner, token)
77
+ + return True
78
+
79
+
80
+ PR body:
81
+ Adds a lease so that only one worker runs the nightly sync at a time. Before this, two workers sometimes ran it at once and overwrote each other's results.
82
+
83
+ Why: a worker that stalls past its TTL must not keep writing after another worker took over, so every write carries a fencing token and the store refuses a stale one.
84
+
85
+ ```merge-risk v1
86
+ risk: medium
87
+ rollback: revert; leases expire after the TTL
88
+ blast-radius: the nightly sync only
89
+ ```
90
+
91
+
92
+ Question: {"id": "q3", "concept": "fencing-token", "type": "choice", "prompt": "What makes a write under an old fencing token fail?", "options": ["The token encodes the owner's process identifier", "Every new acquisition increments the stored token", "Each token carries its own signed expiry"]}
93
+ Key: {"explanation": "acquire stores the previous token plus one, so the newest holder always has the highest token and any older token no longer matches.", "hunk": "+ token = (held[\"token\"] + 1) if held else 1", "answer": 1}
94
+
95
+ Draft:
96
+
97
+ Tip number: 1
@@ -0,0 +1 @@
1
+ Your draft is empty, so start with `acquire` in lease.py and read the line that works out which token to store. Then compare it with the check at the top of `write`.
@@ -0,0 +1 @@
1
+ {"kind":"tip","question":"q3","tip":1,"draft":"","tips":[]}
@@ -0,0 +1,97 @@
1
+ A tip helps a reader who is stuck on one question. You get the question, its key, the draft
2
+ and the earlier tips. Climb one rung per tip number:
3
+
4
+ 1. Where to look: point at a file or hunk, nothing more.
5
+ 2. The missing idea: name what the draft leaves out.
6
+ 3. One step away: bring the reader next to the answer, never onto it.
7
+
8
+ React to the draft. Never state the answer, never quote the key. On a `choice` question never
9
+ quote, name or rule out an option. Do not repeat an earlier tip. Reply in two sentences at most.
10
+
11
+ Diff:
12
+ diff --git a/lease.py b/lease.py
13
+ new file mode 100644
14
+ --- /dev/null
15
+ +++ b/lease.py
16
+ @@ -0,0 +1,61 @@
17
+ +import time
18
+ +
19
+ +
20
+ +class LeaseLost(Exception):
21
+ + """The caller no longer owns the lease it tried to write under."""
22
+ +
23
+ +
24
+ +class LeaseStore:
25
+ + """Single-writer lease over a key-value store.
26
+ +
27
+ + Two workers can both believe they lead after a pause (GC, network). A
28
+ + fencing token lets the store reject the older leader's late writes.
29
+ + """
30
+ +
31
+ + def __init__(self, backend, ttl=30, clock=time.monotonic):
32
+ + self.backend = backend
33
+ + self.ttl = ttl
34
+ + self.clock = clock
35
+ +
36
+ + def acquire(self, name, owner):
37
+ + now = self.clock()
38
+ + held = self.backend.get(name)
39
+ + if held and held["expires"] > now and held["owner"] != owner:
40
+ + return None
41
+ + token = (held["token"] + 1) if held else 1
42
+ + self.backend.put(name, {"owner": owner, "token": token, "expires": now + self.ttl})
43
+ + return token
44
+ +
45
+ + def renew(self, name, owner, token):
46
+ + held = self.backend.get(name)
47
+ + if not held or held["owner"] != owner or held["token"] != token:
48
+ + raise LeaseLost(name)
49
+ + held["expires"] = self.clock() + self.ttl
50
+ + self.backend.put(name, held)
51
+ +
52
+ + def write(self, name, token, key, value):
53
+ + held = self.backend.get(name)
54
+ + if not held or held["token"] != token:
55
+ + raise LeaseLost(name)
56
+ + self.backend.put(key, value)
57
+ +
58
+ + def release(self, name, owner, token):
59
+ + held = self.backend.get(name)
60
+ + if held and held["owner"] == owner and held["token"] == token:
61
+ + held["expires"] = 0
62
+ + self.backend.put(name, held)
63
+ +
64
+ +
65
+ +def run_leader(store, name, owner, work, interval=10):
66
+ + token = store.acquire(name, owner)
67
+ + if token is None:
68
+ + return False
69
+ + try:
70
+ + while work(token):
71
+ + store.renew(name, owner, token)
72
+ + time.sleep(interval)
73
+ + except LeaseLost:
74
+ + return False
75
+ + finally:
76
+ + store.release(name, owner, token)
77
+ + return True
78
+
79
+
80
+ PR body:
81
+ Adds a lease so that only one worker runs the nightly sync at a time. Before this, two workers sometimes ran it at once and overwrote each other's results.
82
+
83
+ Why: a worker that stalls past its TTL must not keep writing after another worker took over, so every write carries a fencing token and the store refuses a stale one.
84
+
85
+ ```merge-risk v1
86
+ risk: medium
87
+ rollback: revert; leases expire after the TTL
88
+ blast-radius: the nightly sync only
89
+ ```
90
+
91
+
92
+ Question: {"id": "q2", "concept": "stale-leader-writes", "type": "text", "prompt": "A worker holding the lease pauses longer than its TTL, and another worker takes over. Why is the lease alone not enough here, and what stops the first worker's late writes?"}
93
+ Key: {"explanation": "After a pause (GC, network) both workers can believe they lead. Every write carries the fencing token from acquire, and write raises LeaseLost when the stored token differs, so the stale leader's late writes are refused.", "hunk": "+ def write(self, name, token, key, value):\n+ held = self.backend.get(name)\n+ if not held or held[\"token\"] != token:\n+ raise LeaseLost(name)", "rubric": {"pass": "Says the paused worker still believes it leads, and that each write carries a fencing token the store compares with the current one, refusing the stale token.", "partial": "Mentions the fencing token or the stale leader, but not how the store uses the token to refuse the late write."}}
94
+
95
+ Draft:
96
+
97
+ Tip number: 1
@@ -0,0 +1 @@
1
+ Your answer is still empty, so start in `lease.py` with the `write` method and the first lines it runs before it touches the backend. Then look back at what `acquire` returns to the caller.
@@ -0,0 +1 @@
1
+ {"kind":"tip","question":"q2","tip":1,"draft":"","tips":[]}