selflore 0.0.1 → 0.1.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/skill/SKILL.md ADDED
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: selflore
3
+ description: Captures "lore" from Claude Code sessions (what the agent did for the developer) and runs a weekly comprehension test on it, so the developer keeps understanding code the agent wrote. Handles /selflore test, /selflore log, /selflore notes, /selflore stats and /selflore focus, and selflore hints that appear in the session context. Capture normally happens automatically in the background; check the session context line "selflore capture=<mode>" before logging anything yourself.
4
+ argument-hint: "test | log | notes | stats | focus"
5
+ ---
6
+
7
+ # selflore
8
+
9
+ selflore captures what you (the agent) did *for* the user, then tests them on it weekly. Getting it wrong is the feature: a miss followed by an immediate explanation is the strongest learning moment.
10
+
11
+ All bookkeeping goes through the data CLI. Never edit `~/.selflore/` files by hand.
12
+
13
+ ```
14
+ SL = {{SL}}
15
+ ```
16
+
17
+ ## Routing
18
+
19
+ Look at the arguments the skill was invoked with:
20
+
21
+ | Argument | Do this |
22
+ |---|---|
23
+ | `test` | Read [references/test.md](references/test.md) and run the weekly test. |
24
+ | `log` | Read [references/log.md](references/log.md) and write a manual entry. |
25
+ | `notes` | Run `{{SL}} notes` (add `--all` or `--project <name>` if the user asks). It opens the notes page in the browser. Reply with one line: that it opened, or the `file://` path if it couldn't open. Don't repeat the entries in chat. |
26
+ | `focus` | Run `{{SL}} focus <arguments>` and show the output verbatim. |
27
+ | `stats` | Run `{{SL}} stats` (add `--project <name>` if the user names one) and show the output verbatim in a code block. Add at most two sentences of interpretation. |
28
+ | none, or a `selflore:` hint in quiet mode | Capture: follow the rules below and [references/capture.md](references/capture.md). |
29
+
30
+ ## Capture mode
31
+
32
+ The session context has a line `selflore capture=<mode>`:
33
+ - **background** (default): selflore captures automatically after turns, outside this session. **Don't log entries yourself.** Only log when the user runs `/selflore log`.
34
+ - **quiet**: you may receive a `selflore:` hint along with a user prompt. Act on it only at a natural pause in the task, after doing what the user asked. Never block or delay their work for it.
35
+ - **off**: log only when the user runs `/selflore log`.
36
+
37
+ ## Focus
38
+
39
+ Run `{{SL}} focus` to see the effective focus for this project: details, design or mixed (with a balance). A project override beats the global setting.
40
+ - **details:** language, library and API specifics. How things behave, edge cases, gotchas.
41
+ - **design:** architecture, data flow, tradeoffs, failure modes, scale.
42
+ - **mixed:** both. Tag each entry honestly and lean toward the chosen balance.
43
+
44
+ `/selflore focus …` passes its arguments straight to `{{SL}} focus …` (e.g. `/selflore focus details --project`). Show the output as-is.
45
+
46
+ ## Capture rules (when you do log)
47
+
48
+ - **The `testable` line is the gate.** If you can't write one sharp question that tests *understanding* (why / what breaks / what happens if / what does this print and why), don't log it.
49
+ - **There's no cap.** Log each real unit of work once. `entry add` merges near-duplicates into the existing untested entry automatically.
50
+ - **Session id:** this comes from the session context line `selflore session_id=<id>`. If it's missing, use `manual-<YYYY-MM-DD>`.
51
+ - **Cost to the user:** near zero. Log quietly in one short tool call, then say a single line like `selflore: logged 1 entry (webhook idempotency)`. Never ask permission to log.
@@ -0,0 +1,63 @@
1
+ # Capturing an entry
2
+
3
+ ## Format
4
+
5
+ Write one markdown entry with frontmatter and pipe it to `entry add`. `id`, `date`, `session`, `project` and `commit` are filled in automatically.
6
+
7
+ ~~~bash
8
+ {{SL}} entry add --session <session_id> <<'LORE'
9
+ ---
10
+ kind: bug # bug | decision | concept | pattern
11
+ level: detail # detail | design (must match the effective focus)
12
+ skill: debugging # debugging | architecture | fundamentals | <a keep_sharp stack name>
13
+ paths: ["src/payments/webhook.ts"]
14
+ testable: "Why must the Stripe webhook handler be idempotent, and what fails without it?"
15
+ ---
16
+ Retries caused double refunds. In-memory dedupe fails across pods;
17
+ moved to a processed_events table keyed on event id.
18
+
19
+ ```ts
20
+ export async function handleWebhook(evt: Stripe.Event) {
21
+ const inserted = await db.processedEvents.insertIgnore({ id: evt.id });
22
+ if (!inserted) return; // already handled
23
+ await applyRefund(evt);
24
+ }
25
+ ```
26
+ LORE
27
+ ~~~
28
+
29
+ Run it from the project's working directory so `project` and `commit` are detected.
30
+
31
+ ## Field rules
32
+
33
+ - **kind**
34
+ - `bug`: something was root-caused and fixed.
35
+ - `decision`: a tradeoff was made, either by you or after the user corrected you.
36
+ - `concept`: an idea the user needs, such as how an API or library actually behaves.
37
+ - `pattern`: a reusable structure that entered the codebase.
38
+ - **level** (check `{{SL}} focus` first):
39
+ - `detail`: language, library or API specifics. Good: "What does this `await` inside `forEach` actually do, and why did the writes run out of order?" Bad: "Which method sorts the array?"
40
+ - `design`: architecture and tradeoffs. Good: "Why a queue instead of cron here, and what breaks with two replicas?" Bad: "What is the queue library called?"
41
+ - If the focus is `details` or `design`, log only that level. In `mixed`, tag each entry honestly.
42
+ - **skill:** use the user's `keep_sharp` area that fits best. Use the stack name, such as `postgres`, when the lore is stack-specific.
43
+ - **paths:** the files involved, relative to the repo root.
44
+ - **testable:** a single question written *now*, while context is fresh. It should test understanding, not trivia:
45
+ - Good: "Why X over Y?", "What breaks if…?", "What happens when the input is…?", "Where would this fail under concurrency?"
46
+ - Bad: "What is the name of the function that…?", "Which file contains…?"
47
+ - **Body:** at most ~120 words of prose saying *what* happened and *why*, including the reason a tradeoff was made or what the root cause was. This is the answer key the grader uses later, so include the facts a correct answer must contain.
48
+ - **Snippet (strongly recommended):** one fenced code block of at most 40 lines with the essential code *as it is now*. The weekly test uses it for predict-behavior and find-the-bug questions, even after the file changes. For a `bug` entry, include the **fixed** code and name the original bug in the prose.
49
+
50
+ ## Responses from `entry add`
51
+
52
+ - `logged <id> [level]`: done. Tell the user in one line.
53
+ - `updated <id> (merged …)`: the moment was close to an existing untested entry, which has been refreshed. Also done.
54
+ - `entry rejected: …`: fix the listed problems and retry once. If there's no good `testable` line, drop the entry.
55
+
56
+ ## Choosing what to log
57
+
58
+ When several moments are candidates, prefer:
59
+ 1. A match with the user's `keep_sharp` areas and the effective focus.
60
+ 2. Bugs and corrected decisions. These are the moments the user is most likely to have missed.
61
+ 3. Anything the user didn't visibly read.
62
+
63
+ Prefer one deep entry over two shallow ones.
@@ -0,0 +1,13 @@
1
+ # /selflore log — manual entry
2
+
3
+ The user said "this was important". It is also the escape hatch for work done outside Claude Code.
4
+
5
+ 1. Work out what they mean from the current conversation. If the conversation has no such context (for example, the work happened in Cursor or Codex), ask for a 2–3 sentence description and any code worth keeping.
6
+ 2. Write the entry exactly as described in [capture.md](capture.md). The same quality bar applies: a real `testable` line and a body that works as an answer key.
7
+ 3. Store it. Check `{{SL}} focus` for the level unless the user said otherwise:
8
+ ```bash
9
+ {{SL}} entry add --session <session_id> <<'LORE'
10
+ …
11
+ LORE
12
+ ```
13
+ 4. Show the user the `testable` question you wrote, in one line, so they can ask you to sharpen it.
@@ -0,0 +1,8 @@
1
+ # /selflore stats
2
+
3
+ ```bash
4
+ {{SL}} stats # all projects
5
+ {{SL}} stats --project <name> # one project
6
+ ```
7
+
8
+ Show the output verbatim in a code block. Afterwards, add at most two sentences, only if the data supports them. For example: the weakest skill area, whether retest pass rate is above first-attempt pass rate (which means the correction step is working), or a large gap between the self-rating and the observed pass rate.
@@ -0,0 +1,87 @@
1
+ # /selflore test — the weekly test
2
+
3
+ Target: about 10 questions in about 20 minutes. Tests are meant to measure **understanding**, not recall.
4
+
5
+ ## 1. Load the material
6
+
7
+ ```bash
8
+ {{SL}} quiz-input
9
+ ```
10
+
11
+ This returns JSON with:
12
+ - `config` (`rating`, `keep_sharp`);
13
+ - `target_questions`, plus `target_split`, the number of `design` and `detail` questions to aim for, set by the user's focus;
14
+ - `retests`: due misses from earlier weeks;
15
+ - `fresh`: entries never tested and less than 3 weeks old;
16
+ - `stale_count`: older untested entries, which are left out on purpose.
17
+
18
+ Each entry has `testable`, a `body` (the answer key, usually with a code snippet), `kind`, `level` (`detail` or `design`), `skill`, `paths` and `commit`.
19
+
20
+ - If both lists are empty, say there is nothing to test yet and stop.
21
+ - **Include every due retest.** Then fill the rest up to `target_questions` with `fresh` entries. Match `target_split` as closely as the available entries allow, and within each level weight toward the `keep_sharp` areas. If there are fewer than 10 entries in total, ask fewer questions. Never pad.
22
+ - Fresh entries you skip stay untested and roll into next week.
23
+
24
+ ## 2. Build the questions (before asking the first one)
25
+
26
+ There is one question per entry. The entry's `level` decides the question family. Pick the best type within it:
27
+
28
+ **Design entries:**
29
+ 1. **explain-why:** "Why did we choose X over Y?" The entry's `testable` line is the starting point; you can sharpen it.
30
+ 2. **what-breaks:** "What fails if we remove or change X?" Ask for the concrete failure, not a vague "it breaks".
31
+ 3. **tradeoff-at-scale:** "What happens to this design at 10× load, with two replicas, or when the dependency is slow?"
32
+
33
+ **Detail entries:**
34
+ 1. **predict-behavior:** show the snippet (or a trimmed piece of it) and ask what happens for a specific, concrete input or condition, and why.
35
+ 2. **find-the-bug:** take the snippet, reintroduce the logged bug from a `bug` entry, and ask the user to locate it and explain the failure. Don't mark the bug in any way, and don't let the change stand out visually.
36
+ 3. **rewrite-from-spec:** "Without looking, write the signature and core logic of…". **At most one per test.**
37
+
38
+ **recall:** only when nothing better fits, at either level.
39
+
40
+ Calibrate to `config.rating`:
41
+
42
+ | Rating | Questions | Hints | What the grader expects |
43
+ |---|---|---|---|
44
+ | 1–3 | Fundamentals-heavy: what the code does and why it's needed | A short hint is offered up front with each question | The core idea plus the *why* |
45
+ | 4–7 | Balanced: why plus one consequence | A hint only if the user asks | The *why* plus at least one concrete consequence |
46
+ | 8–10 | Tradeoffs, failure modes, scale and concurrency edges | None | The *why*, the alternative rejected and when it would break |
47
+
48
+ Don't quote the answer key in the question. If a question needs file context beyond the stored snippet, use the snippet. Don't read the live files to build questions; they may have changed.
49
+
50
+ ## 3. Ask one question at a time
51
+
52
+ Open with: `selflore test — N questions (R retests). Answer in your own words; "skip", "hint", or "unfair" are fine.`
53
+
54
+ For each question:
55
+
56
+ 1. Show `Q<i>/<N> [<type> · <skill>]` followed by the question and any code. Retests are marked `(retest)`.
57
+ 2. **Wait for the user's answer.** Never answer for them, and never move on without their answer.
58
+ 3. Grade strictly against the entry body:
59
+ - **got:** the core *why* is correct and nothing important is wrong. Describing *what* the code does without the *why* is not `got`.
60
+ - **partial:** the right direction, but missing the key reason or consequence, or containing a significant error.
61
+ - **missed:** wrong, empty, "I don't know" or "skip".
62
+ Don't be generous. The user installed this to find gaps, and over-grading defeats it. When in doubt between two levels, choose the lower one.
63
+ 4. **Explain immediately**, before the next question. Give the verdict, then the correct explanation in 2–5 sentences: what they got right, the gap and the real answer. For a miss, add the single sentence they should remember.
64
+ 5. Record it:
65
+ ```bash
66
+ {{SL}} record --entry <id> --grade got|partial|missed --type explain-why|what-breaks|tradeoff-at-scale|predict-behavior|find-the-bug|rewrite-from-spec|recall
67
+ ```
68
+ The CLI decides whether this was a retest and schedules misses and partials for +7 and +21 days. Retests retire after two consecutive passes.
69
+
70
+ Special replies:
71
+ - **"hint":** give one hint that does not reveal the answer, then wait. A correct answer after a hint can still be `got` for ratings of 7 or below. For ratings of 8 and above, it is at most `partial`.
72
+ - **"unfair"** (or the user says the question is wrong or irrelevant): don't argue. Run `{{SL}} suppress <id>`, don't record a grade and move on. If the question was flawed but the entry is fine, say so in one line.
73
+ - **"stop" / "later":** end the quiz early (step 4). Answers recorded so far still count.
74
+
75
+ ## 4. Finish
76
+
77
+ ```bash
78
+ {{SL}} finish-test
79
+ ```
80
+
81
+ Then give a summary of at most 6 lines:
82
+ - The score (got / partial / missed) and how many retests were passed.
83
+ - The one or two misses most worth re-reading, by entry topic.
84
+ - When the next retest is due (from the `record` outputs).
85
+ - A pointer to `/selflore stats` for the trend.
86
+
87
+ No pep talk.
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}