codewhale.history 2.8.7 → 2.8.9

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.7",
3
+ "version": "2.8.9",
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.
@@ -112,13 +125,85 @@ match, relax the filter and note the fallback to the user).
112
125
  | `type hints` | `:` type annotation in function signatures or variable assignments |
113
126
  | `threading` | `Thread(`, `Lock(`, `Queue(`, or `threading.` |
114
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
+ #### Thinking Suppression (Interactive Mode)
172
+
173
+ During steps 1–4 (selection through presentation), **suppress thinking
174
+ entirely**. Do not include the selected snippet, the original lines, or
175
+ which lines are being removed in your reasoning. The user can see the
176
+ thinking block and it spoils the exercise. Use light thinking only for
177
+ mechanical coordination (e.g., "reading file, selecting lines 42-55,
178
+ removing 2 lines, presenting") — never the actual code.
179
+
180
+ #### Interactive Mode Presentation Format
181
+
182
+ ```
183
+ ---
184
+ ## Round N — Level X · interactive · concept | `path/to/file.py` (lines A–B)
185
+
186
+ ```python
187
+ 48 risk_amount = capital * (risk_per_trade / 100)
188
+ 49 # ... 2 lines removed ...
189
+ 50 return max(shares, 0)
190
+ ```
191
+
192
+ ⚠️ **Interactive — Reconstruction.** 2 lines have been removed (originally
193
+ lines 49–50). Open `path/to/file.py`, find the placeholder, and restore the
194
+ missing logic. When you're done, say **`done`** or **`check my work`**.
195
+
196
+ Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
197
+ ---
198
+ ```
199
+
115
200
  ### 3. Presentation — Show the Snippet
116
201
 
117
202
  For each round, present the snippet with its filename:
118
203
 
119
204
  ```
120
205
  ---
121
- ## Round N — Level X · concept | `path/to/file.py` (lines A–B)
206
+ ## Round N — Level X · [interactive|passive] · concept | `path/to/file.py` (lines A–B)
122
207
 
123
208
  ```python
124
209
  42 def calculate_position_size(
@@ -135,8 +220,8 @@ For each round, present the snippet with its filename:
135
220
  53 return max(shares, 0)
136
221
  ```
137
222
 
138
- **Your turn:** Explain what this code does (application logic) AND how it
139
- works (syntax and semantics). Include any edge cases you notice.
223
+ **Your turn:** (Passive mode) Explain what this code does (application logic)
224
+ AND how it works (syntax and semantics). Include any edge cases you notice.
140
225
 
141
226
  Type `hint` for a clue, `skip` to see the answer, or `stop` to end.
142
227
  ---
@@ -147,6 +232,7 @@ Guidelines:
147
232
  - Strip only excessive blank lines; keep natural spacing
148
233
  - Show the function/class signature with its decorators
149
234
  - Show the filename and line range in the header
235
+ - The mode tag (`· interactive` or `· passive`) always appears in the header
150
236
  - The `· concept` portion only appears when a concept is targeted; omit it during free-play rounds
151
237
  - If the snippet depends on one obvious external type or constant, include a
152
238
  brief inline note
@@ -178,6 +264,46 @@ Evaluate across two dimensions, scaled to the current difficulty level.
178
264
  | 4 | Generator mechanics (`yield`), `async`/`await` internals, descriptor protocol, closures, threading primitives |
179
265
  | 5 | Coroutine internals, metaclass programming, GIL implications, memory model, `__slots__`, MRO, weak references |
180
266
 
267
+ #### C. Interactive Mode Evaluation
268
+
269
+ When mode is `interactive`, evaluation is a diff between the user's restored
270
+ lines and the saved original:
271
+
272
+ | Outcome | Criteria | Feedback |
273
+ |---------|----------|----------|
274
+ | **Exact match** | Lines match character-for-character | ✅ Perfect. Note what the lines do and why they matter. |
275
+ | **Semantic match** | Same logic, different variable names or formatting | ✅ Good — logic is correct. Note the stylistic difference. |
276
+ | **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. |
277
+ | **No match** | Lines are absent or entirely wrong | Strike-1 nudge toward the missing logic. |
278
+
279
+ Do not use the standard three-strikes verbal pipeline for interactive mode.
280
+ Instead, use targeted hints about what the missing lines should compute:
281
+
282
+ **Strike 1** — Category nudge:
283
+ ```
284
+ Not quite. Think about what calculation happens between [visible line above
285
+ the gap] and [visible line below the gap].
286
+ ```
287
+
288
+ **Strike 2** — Near-explicit hint:
289
+ ```
290
+ You need to [specific operation — e.g., "divide risk_amount by price_risk
291
+ and guard against division by zero"].
292
+ ```
293
+
294
+ **Strike 3** — Reveal the original lines and move to the next round:
295
+ ```
296
+ Here's what was removed:
297
+ ```python
298
+ 49 price_risk = abs(entry_price - stop_loss)
299
+ 50 if price_risk == 0:
300
+ 51 return 0
301
+ 52 shares = int(risk_amount / price_risk)
302
+ ```
303
+
304
+ After strike 3, restore the original lines in the file and proceed to the
305
+ next round automatically (no "another round?" prompt).
306
+
181
307
  #### Weighted Evaluation for Targeted Concepts
182
308
 
183
309
  When a concept is targeted (e.g., `teach me decorators`), bias the
@@ -256,15 +382,19 @@ nailed everything at-level, say so and highlight the nuance they caught.
256
382
  | `level N` / `lN` (e.g. `level 5`, `l2`) | Adjust difficulty for subsequent rounds. |
257
383
  | `easier` | Decrease level by 1 (minimum 1). |
258
384
  | `harder` | Increase level by 1 (maximum 5). |
259
- | `stop` / `done` / `end` | End session. Deliver summary. |
385
+ | `interactive` | Switch to interactive (reconstruction) mode for subsequent rounds. |
386
+ | `passive` | Switch to passive (explanation) mode for subsequent rounds. |
387
+ | `done` / `check my work` | (Interactive mode only) Signal that missing lines have been restored. Triggers verification. |
388
+ | `stop` / `end` | End session. Deliver summary. |
260
389
 
261
390
  ### 5. Loop — Keep Going
262
391
 
263
392
  After a successful evaluation or a `next` skip, ask:
264
- "Another round? (yes / no / level N / stop)"
393
+ "Another round? (yes / no / level N / interactive / passive / stop)"
265
394
 
266
395
  After a strike-3 reveal, do **not** ask — proceed directly to the next
267
- round with: "Round N+1 — Level X | `file.py`"
396
+ round with:
397
+ "Round N+1 — Level X · [mode] | `file.py`"
268
398
 
269
399
  ### End-of-Session Summary
270
400
 
@@ -274,7 +404,7 @@ When the user says `stop`:
274
404
  ## Session Summary
275
405
 
276
406
  Rounds completed: 5
277
- Level played: 3
407
+ Level played: 3 · Mode: passive
278
408
  Files covered:
279
409
  - services/position_sizer.py (rounds 1, 4)
280
410
  - agents/news_agent.py (round 2)
@@ -316,12 +446,24 @@ criteria for the Mechanics axis:
316
446
  do not squeeze in another round.
317
447
  - **Stay in teaching mode.** Do not fix bugs, refactor, or edit code during a
318
448
  teaching session unless the user explicitly asks to switch modes.
449
+ - **Interactive mode file edits.** The model MAY remove lines from files to set
450
+ up reconstruction exercises. The model MUST NOT add or modify lines — only
451
+ the user restores code. After the session ends, offer to restore any
452
+ remaining gapped files.
453
+ - **Restore on session end.** When the session ends, check whether any files
454
+ still contain `# ... N lines removed ...` placeholders from interactive mode.
455
+ If so, offer to restore the original lines.
319
456
 
320
457
  ## Verification
321
458
 
322
459
  After each round, confirm:
323
460
  - The snippet was actually read from the file (not hallucinated)
324
461
  - The line numbers match the source
462
+ - The mode was correctly announced in the round header
325
463
  - The feedback accurately describes what the code does
326
464
  - No secrets or PII were exposed
327
465
  - The strike count was tracked correctly
466
+ - (Interactive mode) The original lines were saved before the edit
467
+ - (Interactive mode) The file was re-read before evaluating the user's restoration
468
+ - (Interactive mode) Feedback accurately describes any differences from the original
469
+ - (Interactive mode) Gapped files were restored or the user was offered restoration on session end