codewhale.history 2.8.6 → 2.8.8

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
@@ -78,8 +78,11 @@ Git already has your back.
78
78
 
79
79
  ### `//teach-me`
80
80
  An interactive code-teaching quiz that randomly selects real snippets from your
81
- current project and quizzes you on what they do and how they work. Great for
82
- onboarding to a new codebase or sharpening your language skills.
81
+ current project. Two modes across five difficulty levels:
82
+
83
+ - **Passive** (default): Explain what the code does and how it works.
84
+ - **Interactive**: Lines are removed from the file — you restore the missing
85
+ logic, then say `done` for the model to verify your work.
83
86
 
84
87
  **Triggers:** `teach me` · `quiz me` · `test my knowledge` · `code quiz` ·
85
88
  `drill me`
@@ -90,6 +93,7 @@ onboarding to a new codebase or sharpening your language skills.
90
93
  |----------|---------|-------------|
91
94
  | Language | `teach me python` | Restrict to Python, TypeScript, Rust, Go, Java… |
92
95
  | Level | `teach me level 3` or `teach me l3` | Set difficulty 1–5 (default: 3) |
96
+ | Mode | `teach me interactive` | Reconstruction mode — you restore missing lines |
93
97
  | Scope | `teach me services/` | Narrow to a specific file or folder |
94
98
  | Concept | `teach me decorators` | Target: decorators, async, generators, context managers, comprehensions, error handling, type hints, threading |
95
99
 
@@ -104,10 +108,11 @@ onboarding to a new codebase or sharpening your language skills.
104
108
  | 5 | 25–55 | Metaclasses, complex async patterns, multi-threading, architectural glue |
105
109
 
106
110
  **Mid-round commands:** `hint` (get a nudge) · `skip` (see the answer) ·
107
- `next` (draw a new snippet) · `level N` · `easier` · `harder` · `stop`
111
+ `next` (draw a new snippet) · `level N` · `easier` · `harder` ·
112
+ `interactive` · `passive` · `done` (verify restoration) · `stop`
108
113
 
109
- **At the end** you get a session summary: rounds completed, files covered, what
110
- you're strong on, what to review, and a suggested next level.
114
+ **At the end** you get a session summary: rounds completed, mode, files covered,
115
+ what you're strong on, what to review, and a suggested next level.
111
116
 
112
117
  ## Requirements
113
118
  - Node.js (for the `codewhale-history` command)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codewhale.history",
3
- "version": "2.8.6",
3
+ "version": "2.8.8",
4
4
  "description": "CodeWhale utility commands: session history, tool listing, file snapshot, interactive code quiz — global install",
5
5
  "bin": {
6
6
  "codewhale-history": "./_list_sessions.js",
@@ -1,14 +1,18 @@
1
1
  ---
2
2
  name: teach-me
3
- description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic and language semantics. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5.
3
+ description: Interactive code-teaching quiz. Selects random snippets from the current project and quizzes the user on application logic and language semantics. Triggered by 'teach me', 'quiz me', 'test my knowledge', 'code quiz', or 'drill me'. Supports difficulty levels 1–5 and two modes: passive (explain) and interactive (reconstruct).
4
4
  ---
5
5
 
6
6
  # Teach Me — Interactive Code Quiz
7
7
 
8
8
  An interactive teaching session that randomly selects code snippets from the
9
- current project, presents them to the user, asks the user to explain them, and
10
- provides constructive feedback on both **application logic** (what the code
11
- accomplishes) and **language mechanics** (syntax and semantics).
9
+ current project. Two modes:
10
+
11
+ - **Passive** (default): presents code, asks the user to explain it, and
12
+ provides constructive feedback on **application logic** (what the code
13
+ accomplishes) and **language mechanics** (syntax and semantics).
14
+ - **Interactive**: removes lines from the file; the user restores them and
15
+ says `done`; the model diffs against the original and gives feedback.
12
16
 
13
17
  ## Session Trigger
14
18
 
@@ -32,7 +36,16 @@ Optionally followed by modifiers:
32
36
  `teach me error handling`, `teach me type hints`, `teach me threading`
33
37
 
34
38
  Modifiers combine freely: `teach me decorators level 4`,
35
- `teach me async services/`, `teach me generators l2`
39
+ `teach me async services/`, `teach me generators l2`,
40
+ `teach me level 2 interactive`, `teach me interactive decorators`
41
+
42
+ Two modes are available, orthogonal to difficulty:
43
+
44
+ - **`passive`** (default) — You explain what the code does and how it works.
45
+ - **`interactive`** — Lines are removed from the file; you restore the missing
46
+ logic. When done, say `done` or `check my work` and the model verifies.
47
+
48
+ Switch modes mid-session with `interactive` or `passive`.
36
49
 
37
50
  If no level is specified, default to **level 3** and adjust based on
38
51
  performance across rounds.
@@ -57,7 +70,9 @@ specified a language, filter by extension.
57
70
  ### 2. Selection — Pick a Snippet
58
71
 
59
72
  Randomly select a file from the index, then randomly select a function,
60
- method, or logical block from that file. Use these rules:
73
+ method, or logical block from that file. **Re-read the file before each round**
74
+ to ensure the snippet reflects the current on-disk state — the code may have
75
+ changed since the session started. Use these rules:
61
76
 
62
77
  #### Good Snippets (select these)
63
78
  - Functions or methods 5–55 lines long (after stripping docstrings and blank lines)
@@ -110,13 +125,76 @@ match, relax the filter and note the fallback to the user).
110
125
  | `type hints` | `:` type annotation in function signatures or variable assignments |
111
126
  | `threading` | `Thread(`, `Lock(`, `Queue(`, or `threading.` |
112
127
 
128
+ ### 2b. Interactive Mode — Reconstruction
129
+
130
+ When mode is `interactive`, each round follows a different flow from passive
131
+ explanation. The model removes lines from the file and the user restores them.
132
+
133
+ #### Lines Removed by Level
134
+
135
+ | Level | Snippet lines | Lines removed |
136
+ |-------|--------------|---------------|
137
+ | 1 | 5–15 | 1 |
138
+ | 2 | 8–20 | 1–2 |
139
+ | 3 | 12–30 | 1–2 |
140
+ | 4 | 18–45 | 2–3 |
141
+ | 5 | 25–55 | 2–3 |
142
+
143
+ #### Lines to Remove — Selection Heuristic
144
+
145
+ - **Remove:** assignment statements, conditional branches, loop bodies, return
146
+ statements, function calls — lines that carry semantic weight and that
147
+ downstream lines depend on. Removing them should break the function.
148
+ - **Never remove:** imports, blank lines, closing braces/brackets/parens,
149
+ decorator lines, function/class signatures, docstrings, comments.
150
+ - Replace each removed span with a single placeholder comment:
151
+ `# ... N lines removed ...`
152
+ - After removing lines from the file, **save the original lines** in memory for
153
+ later diffing against the user's restoration.
154
+
155
+ #### Interactive Mode Per-Round Flow
156
+
157
+ 1. **Select** a snippet using the standard rules (section 2).
158
+ 2. **Save** the original lines in memory.
159
+ 3. **Remove** 1–3 lines from the actual file on disk using `edit_file`.
160
+ 4. **Present** the gapped snippet with the placeholder and the original line
161
+ numbers.
162
+ 5. **Instruct:** "Open `<file>`, restore the missing logic at the gap.
163
+ Say `done` or `check my work` when ready."
164
+ 6. **Wait.** Do not evaluate, hint, or proceed until the user signals
165
+ completion.
166
+ 7. **Re-read** the file. Diff the user's restored lines against the saved
167
+ original.
168
+ 8. **Feedback** (see Interactive Evaluation below). Offer to restore the
169
+ original if the user wants to undo.
170
+
171
+ #### Interactive Mode Presentation Format
172
+
173
+ ```
174
+ ---
175
+ ## Round N — Level X · interactive · concept | `path/to/file.py` (lines A–B)
176
+
177
+ ```python
178
+ 48 risk_amount = capital * (risk_per_trade / 100)
179
+ 49 # ... 2 lines removed ...
180
+ 50 return max(shares, 0)
181
+ ```
182
+
183
+ ⚠️ **Interactive — Reconstruction.** 2 lines have been removed (originally
184
+ lines 49–50). Open `path/to/file.py`, find the placeholder, and restore the
185
+ missing logic. When you're done, say **`done`** or **`check my work`**.
186
+
187
+ Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
188
+ ---
189
+ ```
190
+
113
191
  ### 3. Presentation — Show the Snippet
114
192
 
115
193
  For each round, present the snippet with its filename:
116
194
 
117
195
  ```
118
196
  ---
119
- ## Round N — Level X · concept | `path/to/file.py` (lines A–B)
197
+ ## Round N — Level X · [interactive|passive] · concept | `path/to/file.py` (lines A–B)
120
198
 
121
199
  ```python
122
200
  42 def calculate_position_size(
@@ -133,8 +211,8 @@ For each round, present the snippet with its filename:
133
211
  53 return max(shares, 0)
134
212
  ```
135
213
 
136
- **Your turn:** Explain what this code does (application logic) AND how it
137
- works (syntax and semantics). Include any edge cases you notice.
214
+ **Your turn:** (Passive mode) Explain what this code does (application logic)
215
+ AND how it works (syntax and semantics). Include any edge cases you notice.
138
216
 
139
217
  Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
140
218
  ---
@@ -145,6 +223,7 @@ Guidelines:
145
223
  - Strip only excessive blank lines; keep natural spacing
146
224
  - Show the function/class signature with its decorators
147
225
  - Show the filename and line range in the header
226
+ - The mode tag (`· interactive` or `· passive`) always appears in the header
148
227
  - The `· concept` portion only appears when a concept is targeted; omit it during free-play rounds
149
228
  - If the snippet depends on one obvious external type or constant, include a
150
229
  brief inline note
@@ -176,6 +255,46 @@ Evaluate across two dimensions, scaled to the current difficulty level.
176
255
  | 4 | Generator mechanics (`yield`), `async`/`await` internals, descriptor protocol, closures, threading primitives |
177
256
  | 5 | Coroutine internals, metaclass programming, GIL implications, memory model, `__slots__`, MRO, weak references |
178
257
 
258
+ #### C. Interactive Mode Evaluation
259
+
260
+ When mode is `interactive`, evaluation is a diff between the user's restored
261
+ lines and the saved original:
262
+
263
+ | Outcome | Criteria | Feedback |
264
+ |---------|----------|----------|
265
+ | **Exact match** | Lines match character-for-character | ✅ Perfect. Note what the lines do and why they matter. |
266
+ | **Semantic match** | Same logic, different variable names or formatting | ✅ Good — logic is correct. Note the stylistic difference. |
267
+ | **Partial match** | Some lines correct, some missing/wrong | Point out which line(s) are correct and which need work. Treat as strike 1 or 2 depending on how much is missing. |
268
+ | **No match** | Lines are absent or entirely wrong | Strike-1 nudge toward the missing logic. |
269
+
270
+ Do not use the standard three-strikes verbal pipeline for interactive mode.
271
+ Instead, use targeted hints about what the missing lines should compute:
272
+
273
+ **Strike 1** — Category nudge:
274
+ ```
275
+ Not quite. Think about what calculation happens between [visible line above
276
+ the gap] and [visible line below the gap].
277
+ ```
278
+
279
+ **Strike 2** — Near-explicit hint:
280
+ ```
281
+ You need to [specific operation — e.g., "divide risk_amount by price_risk
282
+ and guard against division by zero"].
283
+ ```
284
+
285
+ **Strike 3** — Reveal the original lines and move to the next round:
286
+ ```
287
+ Here's what was removed:
288
+ ```python
289
+ 49 price_risk = abs(entry_price - stop_loss)
290
+ 50 if price_risk == 0:
291
+ 51 return 0
292
+ 52 shares = int(risk_amount / price_risk)
293
+ ```
294
+
295
+ After strike 3, restore the original lines in the file and proceed to the
296
+ next round automatically (no "another round?" prompt).
297
+
179
298
  #### Weighted Evaluation for Targeted Concepts
180
299
 
181
300
  When a concept is targeted (e.g., `teach me decorators`), bias the
@@ -254,15 +373,19 @@ nailed everything at-level, say so and highlight the nuance they caught.
254
373
  | `level N` / `lN` (e.g. `level 5`, `l2`) | Adjust difficulty for subsequent rounds. |
255
374
  | `easier` | Decrease level by 1 (minimum 1). |
256
375
  | `harder` | Increase level by 1 (maximum 5). |
257
- | `stop` / `done` / `end` | End session. Deliver summary. |
376
+ | `interactive` | Switch to interactive (reconstruction) mode for subsequent rounds. |
377
+ | `passive` | Switch to passive (explanation) mode for subsequent rounds. |
378
+ | `done` / `check my work` | (Interactive mode only) Signal that missing lines have been restored. Triggers verification. |
379
+ | `stop` / `end` | End session. Deliver summary. |
258
380
 
259
381
  ### 5. Loop — Keep Going
260
382
 
261
383
  After a successful evaluation or a `next` skip, ask:
262
- "Another round? (yes / no / level N / stop)"
384
+ "Another round? (yes / no / level N / interactive / passive / stop)"
263
385
 
264
386
  After a strike-3 reveal, do **not** ask — proceed directly to the next
265
- round with: "Round N+1 — Level X | `file.py`"
387
+ round with:
388
+ "Round N+1 — Level X · [mode] | `file.py`"
266
389
 
267
390
  ### End-of-Session Summary
268
391
 
@@ -272,7 +395,7 @@ When the user says `stop`:
272
395
  ## Session Summary
273
396
 
274
397
  Rounds completed: 5
275
- Level played: 3
398
+ Level played: 3 · Mode: passive
276
399
  Files covered:
277
400
  - services/position_sizer.py (rounds 1, 4)
278
401
  - agents/news_agent.py (round 2)
@@ -314,12 +437,24 @@ criteria for the Mechanics axis:
314
437
  do not squeeze in another round.
315
438
  - **Stay in teaching mode.** Do not fix bugs, refactor, or edit code during a
316
439
  teaching session unless the user explicitly asks to switch modes.
440
+ - **Interactive mode file edits.** The model MAY remove lines from files to set
441
+ up reconstruction exercises. The model MUST NOT add or modify lines — only
442
+ the user restores code. After the session ends, offer to restore any
443
+ remaining gapped files.
444
+ - **Restore on session end.** When the session ends, check whether any files
445
+ still contain `# ... N lines removed ...` placeholders from interactive mode.
446
+ If so, offer to restore the original lines.
317
447
 
318
448
  ## Verification
319
449
 
320
450
  After each round, confirm:
321
451
  - The snippet was actually read from the file (not hallucinated)
322
452
  - The line numbers match the source
453
+ - The mode was correctly announced in the round header
323
454
  - The feedback accurately describes what the code does
324
455
  - No secrets or PII were exposed
325
456
  - The strike count was tracked correctly
457
+ - (Interactive mode) The original lines were saved before the edit
458
+ - (Interactive mode) The file was re-read before evaluating the user's restoration
459
+ - (Interactive mode) Feedback accurately describes any differences from the original
460
+ - (Interactive mode) Gapped files were restored or the user was offered restoration on session end