selflore 0.1.0 → 0.2.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.
Files changed (44) hide show
  1. package/README.md +64 -31
  2. package/dist/cli.js +81 -19
  3. package/dist/hooks/user-prompt-submit.js +2 -1
  4. package/dist/init.js +26 -10
  5. package/dist/lib/background.js +23 -4
  6. package/dist/lib/capture-prompt.js +13 -7
  7. package/dist/lib/commands.js +199 -35
  8. package/dist/lib/config.js +24 -4
  9. package/dist/lib/entries.js +56 -4
  10. package/dist/lib/heat.js +141 -0
  11. package/dist/lib/hook-logic.js +44 -9
  12. package/dist/lib/index-cache.js +46 -0
  13. package/dist/lib/links.js +58 -0
  14. package/dist/lib/logo.js +6 -0
  15. package/dist/lib/notes-graph.js +585 -0
  16. package/dist/lib/notes-html.js +148 -339
  17. package/dist/lib/notes-page-css.js +279 -0
  18. package/dist/lib/notes-page-js.js +959 -0
  19. package/dist/lib/notes.js +19 -13
  20. package/dist/lib/nudge.js +2 -1
  21. package/dist/lib/paths.js +6 -0
  22. package/dist/lib/question.js +19 -0
  23. package/dist/lib/queue.js +6 -4
  24. package/dist/lib/recall.js +149 -0
  25. package/dist/lib/results.js +1 -0
  26. package/dist/lib/retag.js +150 -0
  27. package/dist/lib/server-launch.js +73 -0
  28. package/dist/lib/server.js +120 -0
  29. package/dist/lib/session.js +1 -1
  30. package/dist/lib/signals.js +51 -0
  31. package/dist/lib/stats.js +71 -44
  32. package/dist/lib/struggle.js +120 -0
  33. package/dist/lib/surface.js +75 -0
  34. package/dist/lib/transcript.js +61 -15
  35. package/dist/lib/ui.js +127 -0
  36. package/dist/notes-server.js +39 -0
  37. package/dist/sl.js +29 -4
  38. package/dist/vendor/graph3d.js +5402 -0
  39. package/package.json +6 -3
  40. package/skill/SKILL.md +6 -5
  41. package/skill/references/capture.md +6 -5
  42. package/skill/references/recall.md +44 -0
  43. package/skill/references/stats.md +5 -1
  44. package/skill/references/test.md +35 -30
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "selflore",
3
- "version": "0.1.0",
4
- "description": "Own what your agent builds. A Claude Code skill that captures what your agent did for you and tests you on it weekly.",
3
+ "version": "0.2.0",
4
+ "description": "Your agent wrote it. selflore remembers why. A Claude Code skill that keeps notes on what your agent built, answers your questions from them, and quizzes you only when you ask.",
5
5
  "keywords": [
6
6
  "claude",
7
7
  "claude-skill",
@@ -28,12 +28,15 @@
28
28
  "node": ">=18"
29
29
  },
30
30
  "scripts": {
31
- "build": "tsc",
31
+ "build": "tsc && node scripts/bundle-graph3d.mjs",
32
32
  "test": "vitest run",
33
33
  "prepublishOnly": "npm run build"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^26.6.3",
37
+ "3d-force-graph": "1.80.3",
38
+ "esbuild": "0.28.2",
39
+ "three": "0.187.0",
37
40
  "typescript": "^7.0.2",
38
41
  "vitest": "^5.0.3"
39
42
  },
package/skill/SKILL.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ---
2
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"
3
+ description: Keeps dated notes on what the agent built for the developer and why, so the developer keeps understanding their own code. Use it when the developer asks how or why something in their own codebase works (answer from their notes), for /selflore recall, test, log, notes, stats and focus, and for any "selflore:" line 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: "recall <question> | test | log | notes | stats | focus"
5
5
  ---
6
6
 
7
7
  # selflore
8
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.
9
+ selflore keeps notes on what you (the agent) did *for* the user and why. The notes answer the user's questions later, with a date, and the user can ask to be tested on any topic. Nothing is ever due or overdue: never tell the user they are behind, and never suggest a test unless a `selflore:` line in the session context tells you to.
10
10
 
11
11
  All bookkeeping goes through the data CLI. Never edit `~/.selflore/` files by hand.
12
12
 
@@ -20,9 +20,10 @@ Look at the arguments the skill was invoked with:
20
20
 
21
21
  | Argument | Do this |
22
22
  |---|---|
23
- | `test` | Read [references/test.md](references/test.md) and run the weekly test. |
23
+ | `test`, with or without something after it (`test`, `test nebula/v0`, `test react`, `test auth flow in nebula`) | Read [references/test.md](references/test.md) and run a short test on what the user named. Anything in their own words works. |
24
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. |
25
+ | `recall <question>`, or the user asks how or why something in their own code works | Read [references/recall.md](references/recall.md) and answer from their notes. |
26
+ | `notes` | Run `{{SL}} notes` (add `--project <name>` if the user asks). It opens the notes page in the browser. Reply with one line: that it opened (or the URL it printed), and that the page has Map, Notes and Stats views and a **Test me** button for a self-graded test. Don't repeat the entries in chat. |
26
27
  | `focus` | Run `{{SL}} focus <arguments>` and show the output verbatim. |
27
28
  | `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
29
  | none, or a `selflore:` hint in quiet mode | Capture: follow the rules below and [references/capture.md](references/capture.md). |
@@ -9,7 +9,7 @@ Write one markdown entry with frontmatter and pipe it to `entry add`. `id`, `dat
9
9
  ---
10
10
  kind: bug # bug | decision | concept | pattern
11
11
  level: detail # detail | design (must match the effective focus)
12
- skill: debugging # debugging | architecture | fundamentals | <a keep_sharp stack name>
12
+ topics: ["stripe webhooks", "idempotency"] # 1–3: the technology first, then the concept
13
13
  paths: ["src/payments/webhook.ts"]
14
14
  testable: "Why must the Stripe webhook handler be idempotent, and what fails without it?"
15
15
  ---
@@ -39,12 +39,13 @@ Run it from the project's working directory so `project` and `commit` are detect
39
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
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
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.
42
+ - **topics:** 1 to 3, lowercase. First the technology, library or subsystem (`postgres`, `fastapi`, `stripe webhooks`), then the concept (`idempotency`, `retry logic`, `race condition`). This is how the user finds and groups notes later, so reuse a topic the project already has (`{{SL}} entry list` shows them) before inventing one. Never a kind of work: not `architecture`, `debugging`, `fundamentals` or `design`.
43
+ - **origin** (optional): `asked` when the user asked for this explanation, `bugfix` when something failed and was root-caused, `dependency` for a new or changed library, `write` otherwise. Left out, it is inferred from the kind.
43
44
  - **paths:** the files involved, relative to the repo root.
44
45
  - **testable:** a single question written *now*, while context is fresh. It should test understanding, not trivia:
45
46
  - Good: "Why X over Y?", "What breaks if…?", "What happens when the input is…?", "Where would this fail under concurrency?"
46
47
  - 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
+ - **Body:** at most ~120 words. Lead with what the code alone can't tell anyone: why it was done this way, what was rejected, which bug or constraint forced it. Then what the code does, only as much as the why needs. This is the note the user reads later and the answer key a test is graded against, so include the facts a correct answer must contain.
48
49
  - **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
 
50
51
  ## Responses from `entry add`
@@ -56,8 +57,8 @@ Run it from the project's working directory so `project` and `commit` are detect
56
57
  ## Choosing what to log
57
58
 
58
59
  When several moments are candidates, prefer:
59
- 1. A match with the user's `keep_sharp` areas and the effective focus.
60
+ 1. Something the user asked to have explained. They have just said what they didn't know. (Skip one-line facts: what a flag does, where a file lives.)
60
61
  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
+ 3. A match with the user's `keep_sharp` areas and the effective focus.
62
63
 
63
64
  Prefer one deep entry over two shallow ones.
@@ -0,0 +1,44 @@
1
+ # Recall: answering from the user's own notes
2
+
3
+ The user asked how or why something in their code works, and selflore has notes on it. The notes were written when the work was done, so they hold what the code can't: why it was built this way, what was rejected, which bug forced a change. The point is for the **user** to understand their code, so the answer is for them, not background for you.
4
+
5
+ ## 1. Find the notes
6
+
7
+ If the session context already listed candidates (a block starting `selflore: the user's own notes may answer this question`), start from those ids. Otherwise:
8
+
9
+ ```bash
10
+ {{SL}} recall "<the user's question, in their words>" # this project; add --all for every project
11
+ ```
12
+
13
+ Each line is a score (0–1), a date, an id and the note's question. Below about 0.5 a match is usually a coincidence of words. If nothing fits the question, **say nothing about selflore** and answer normally. Never mention a candidate you didn't use.
14
+
15
+ ## 2. Read the ones that fit
16
+
17
+ ```bash
18
+ {{SL}} show <id> --session <session_id>
19
+ ```
20
+
21
+ `<session_id>` is in the session context (`selflore session_id=…`). Passing it records that this note answered the user, which is how selflore learns what they keep asking about. Only pass it for a note you actually use in your answer; to peek at one, leave it off.
22
+
23
+ This prints the note and a `code:` line:
24
+
25
+ | `code:` says | What to do |
26
+ |---|---|
27
+ | `unchanged since capture` | The note is current. Answer from it. |
28
+ | `CHANGED since capture` | Read the files it names before answering. Say what the note recorded, then what is different now. |
29
+ | `the files are GONE` | The code it describes may not exist. Say so, and offer to retire the note (`{{SL}} suppress <id>`). |
30
+ | `not checked` | You're in a different project folder. Answer from the note and say it's as of that date. |
31
+
32
+ Read at most the two or three notes that fit best.
33
+
34
+ ## 3. Answer
35
+
36
+ - **Lead with the why and the date:** "From your notes, Oct 12: you moved dedupe to a `processed_events` table because retries were causing double refunds."
37
+ - Then answer the question they actually asked, in 2–6 sentences. Add current code only where it helps.
38
+ - **Never state an old note as current fact** when `code:` says changed or gone. "In October it was X; it has since changed to Z" is the useful answer.
39
+ - If the note turns out to be wrong or no longer matches anything, say so and offer `{{SL}} suppress <id>`.
40
+ - Keep the attribution to that one opening clause. No summary of what selflore is, no list of other notes.
41
+
42
+ ## 4. Don't follow up with a quiz
43
+
44
+ Answer and stop. Offer a check only when the session context has a `selflore: offer` line for this prompt, and then exactly as that line says: one sentence at the end, once. If the user says no or doesn't reply to it, never bring it up again.
@@ -5,4 +5,8 @@
5
5
  {{SL}} stats --project <name> # one project
6
6
  ```
7
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.
8
+ The output opens with **Where you get stuck**: the areas (a topic, in a project) that the user's own behaviour marks as trouble, with the reason — they asked about it again, a test kept failing in those files, or they missed a question on it. Below that are the weekly table and pass rates for the tests they chose to take.
9
+
10
+ Show the output verbatim in a code block. Afterwards, add at most two sentences, only if the data supports them: for example, which area stands out and why. Describe it as where they get stuck, never as a weakness or a score, and don't suggest a test unless they ask.
11
+
12
+ The notes page (`{{SL}} notes`) shows the same thing as a heat map (the Map view, where the page opens) and as a list in the Stats view. Mention it in one line if the user wants a visual.
@@ -1,25 +1,34 @@
1
- # /selflore test — the weekly test
1
+ # /selflore test — a test the user asked for
2
2
 
3
- Target: about 10 questions in about 20 minutes. Tests are meant to measure **understanding**, not recall.
3
+ A test happens only because the user asked. It is short (3–5 questions) and on what they named. It measures **understanding**, not recall.
4
4
 
5
5
  ## 1. Load the material
6
6
 
7
- ```bash
8
- {{SL}} quiz-input
9
- ```
7
+ Look at what came after `test`:
10
8
 
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.
9
+ | The user wrote | Run |
10
+ |---|---|
11
+ | nothing (`/selflore test`) | First `{{SL}} heat --json` (see below), then `{{SL}} quiz-input` with whatever they pick |
12
+ | a project (`test nebula/v0`; names look like `parent/dir`) | `{{SL}} quiz-input --project <name>` |
13
+ | a topic (`test react`) | `{{SL}} quiz-input --topic <name>` |
14
+ | anything else, in their own words (`test auth flow in nebula`, `test me on why the webhook retries`) | `{{SL}} quiz-input --query "<their words>"`, adding `--project <name>` if they named one |
17
15
 
18
- Each entry has `testable`, a `body` (the answer key, usually with a code snippet), `kind`, `level` (`detail` or `design`), `skill`, `paths` and `commit`.
16
+ If you can't tell whether a single word is a project or a topic, try `--topic`; if both lists come back empty, try it as `--query`. If that is empty too, say in one line that there are no notes on it and stop.
19
17
 
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.
18
+ **No scope given.** `{{SL}} heat --json` lists the areas where the user gets stuck (a project and a topic, with why). If it lists any, offer up to three of them plus "recent work" in one short message and let the user pick; then load that scope (`--project <project> --topic <topic>`), or plain `{{SL}} quiz-input` for recent work. If it lists none, go straight to `{{SL}} quiz-input`. In weekly mode skip the choice and run the weekly test.
19
+
20
+ The JSON has:
21
+ - `config`: `rating`, `keep_sharp`, `cadence`;
22
+ - `retests`: questions the user missed or got partly right last time. They come back first, whenever the next test in that area happens;
23
+ - `fresh`: entries never asked, hottest then newest first (at most 30; `fresh_total` is how many there are). With `--query` it is the notes that best match the words, best first, and may include notes already passed;
24
+ - `target_split`: the share of `design` and `detail` questions the user's focus asks for.
25
+
26
+ Each entry has `testable`, a `body` (the answer key, usually with a code snippet), `kind`, `level` (`detail` or `design`), `topics`, `paths` and `commit`.
27
+
28
+ Choosing the questions:
29
+ - If both lists are empty, say there is nothing to test there and stop.
30
+ - Ask **3 to 5** questions (`target_questions` is the most to ask): every `retests` entry first, then `fresh` entries in the order given. Follow `target_split` roughly, and within a level prefer the `keep_sharp` areas. Never pad: with `--query`, drop a note that plainly isn't about what the user asked for.
31
+ - **Weekly mode** (`config.cadence` is `weekly` and the user gave no scope): ask about 10 instead, and run `finish-test` at the end.
23
32
 
24
33
  ## 2. Build the questions (before asking the first one)
25
34
 
@@ -49,39 +58,35 @@ Don't quote the answer key in the question. If a question needs file context bey
49
58
 
50
59
  ## 3. Ask one question at a time
51
60
 
52
- Open with: `selflore test — N questions (R retests). Answer in your own words; "skip", "hint", or "unfair" are fine.`
61
+ Open with: `selflore test — <scope, or "recent work"> — N questions. Answer in your own words; "skip", "hint", or "unfair" are fine.`
53
62
 
54
63
  For each question:
55
64
 
56
- 1. Show `Q<i>/<N> [<type> · <skill>]` followed by the question and any code. Retests are marked `(retest)`.
65
+ 1. Show `Q<i>/<N> [<type> · <first topic>]` followed by the question and any code. Mark an entry from `retests` with `(missed last time)`.
57
66
  2. **Wait for the user's answer.** Never answer for them, and never move on without their answer.
58
67
  3. Grade strictly against the entry body:
59
68
  - **got:** the core *why* is correct and nothing important is wrong. Describing *what* the code does without the *why* is not `got`.
60
69
  - **partial:** the right direction, but missing the key reason or consequence, or containing a significant error.
61
70
  - **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.
71
+ Don't be generous. The user asked for this to find gaps, and over-grading defeats it. When in doubt between two levels, choose the lower one.
63
72
  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
73
  5. Record it:
65
74
  ```bash
66
75
  {{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
76
  ```
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.
77
+ A miss or a partial comes back first the next time the user tests that area, and retires after two passes in a row. Nothing is scheduled.
69
78
 
70
79
  Special replies:
71
80
  - **"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.
81
+ - **"unfair"** (or the user says the question is wrong, irrelevant or about code that no longer exists): 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.
82
+ - **"stop" / "later":** end the test early (step 4). Answers recorded so far still count.
74
83
 
75
84
  ## 4. Finish
76
85
 
77
- ```bash
78
- {{SL}} finish-test
79
- ```
86
+ In weekly mode only, run `{{SL}} finish-test`.
80
87
 
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.
88
+ Then give a summary of at most 4 lines:
89
+ - The score (got / partial / missed).
90
+ - The one or two misses most worth re-reading, by topic.
86
91
 
87
- No pep talk.
92
+ Don't mention when anything is "due", don't suggest the next test, and no pep talk.