codewhale.history 2.8.0 → 2.8.2

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
@@ -38,10 +38,74 @@ codewhale-tools-install -p <target-path> # specific workspace
38
38
  ```
39
39
 
40
40
  ## After install
41
- - **`//tools`** — lists every tool available in the current session
42
- - **`//history`** — lists all chat sessions for the current workspace with cost totals
43
- - **`//snapshot`** toggle pre-edit file backups (`on`, `off`, `status`)
44
- - **`//teach-me`** interactive code quiz that tests your knowledge of the current codebase
41
+
42
+ ### `//tools`
43
+ Lists every tool available in the current session, grouped by category (File I/O,
44
+ Search, Git, Sub-agents, Shell, Planning, etc.), with a brief description of what
45
+ each tool does. Read-only — no files touched.
46
+
47
+ ### `//history`
48
+ Lists all chat sessions for the current workspace. Each session row shows:
49
+
50
+ - **Date/time** — when the session was created
51
+ - **Title** — session title
52
+ - **Messages** — message count for that session
53
+ - **Tokens** — tokens consumed (with thousands separators)
54
+ - **Cost** — session cost in USD (to 4 decimal places)
55
+ - **Model** — which model was used
56
+
57
+ A **TOTAL** row at the bottom summarizes the number of sessions, total messages,
58
+ total tokens, and total cost across all sessions.
59
+
60
+ ### `//snapshot`
61
+ Toggle pre-edit file backups: `//snapshot on`, `//snapshot off`,
62
+ `//snapshot status`.
63
+
64
+ **Why you'll want this:** Snapshot is designed for folders that are **not** Git
65
+ repos — especially folders full of Office documents (`.docx`, `.pptx`, `.xlsx`,
66
+ `.pdf`) that an AI agent is about to edit. Before every file modification,
67
+ snapshot saves a timestamped copy into `_snapshots/` so you can always get back
68
+ to the pre-AI version:
69
+
70
+ ```
71
+ report.docx → _snapshots/report.2026-06-21_14-30-00.docx
72
+ ```
73
+
74
+ If the workspace already has a `.git` directory, snapshot politely declines —
75
+ Git already has your back.
76
+
77
+ ### `//teach-me`
78
+ An interactive code-teaching quiz that randomly selects real snippets from your
79
+ current project and quizzes you on what they do and how they work. Great for
80
+ onboarding to a new codebase or sharpening your language skills.
81
+
82
+ **Triggers:** `teach me` · `quiz me` · `test my knowledge` · `code quiz` ·
83
+ `drill me`
84
+
85
+ **Modifiers (combine freely):**
86
+
87
+ | Modifier | Example | What it does |
88
+ |----------|---------|-------------|
89
+ | Language | `teach me python` | Restrict to Python, TypeScript, Rust, Go, Java… |
90
+ | Level | `teach me level 3` or `teach me l3` | Set difficulty 1–5 (default: 3) |
91
+ | Scope | `teach me services/` | Narrow to a specific file or folder |
92
+ | Concept | `teach me decorators` | Target: decorators, async, generators, context managers, comprehensions, error handling, type hints, threading |
93
+
94
+ **Difficulty levels:**
95
+
96
+ | Level | Line range | What you'll face |
97
+ |-------|-----------|------------------|
98
+ | 1 | 5–15 | Straight-line logic, `if`/`else`, basic function calls |
99
+ | 2 | 8–20 | Loops, list/dict operations, simple `try`/`except` |
100
+ | 3 | 12–30 | Comprehensions, decorators, `with` statements, multiple branches |
101
+ | 4 | 18–45 | Generators, `async`/`await`, descriptors, threading, closures |
102
+ | 5 | 25–55 | Metaclasses, complex async patterns, multi-threading, architectural glue |
103
+
104
+ **Mid-round commands:** `hint` (get a nudge) · `skip` (see the answer) ·
105
+ `next` (draw a new snippet) · `level N` · `easier` · `harder` · `stop`
106
+
107
+ **At the end** you get a session summary: rounds completed, files covered, what
108
+ you're strong on, what to review, and a suggested next level.
45
109
 
46
110
  ## Requirements
47
111
  - 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.0",
3
+ "version": "2.8.2",
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",
@@ -26,6 +26,13 @@ Optionally followed by modifiers:
26
26
  - `teach me python` — restrict to a specific language
27
27
  - `teach me level 3` / `teach me l3` — set difficulty (1–5)
28
28
  - `teach me <file or module>` — narrow scope to a specific file, directory, or module
29
+ - `teach me <concept>` — target a specific language concept. Examples:
30
+ `teach me decorators`, `teach me async`, `teach me generators`,
31
+ `teach me context managers`, `teach me comprehensions`,
32
+ `teach me error handling`, `teach me type hints`, `teach me threading`
33
+
34
+ Modifiers combine freely: `teach me decorators level 4`,
35
+ `teach me async services/`, `teach me generators l2`
29
36
 
30
37
  If no level is specified, default to **level 3** and adjust based on
31
38
  performance across rounds.
@@ -84,13 +91,32 @@ Do not repeat a snippet unless the user explicitly asks or all candidates
84
91
  are exhausted. Prefer cycling through files before returning to the same
85
92
  file.
86
93
 
94
+ #### Concept Targeting
95
+
96
+ When the user targets a specific concept, filter snippets to ensure they
97
+ contain that concept. After selecting a random candidate, verify it with
98
+ `grep_files` on the file for the concept signal. If the candidate doesn't
99
+ match, pick another random snippet (retry up to 10 times; if still no
100
+ match, relax the filter and note the fallback to the user).
101
+
102
+ | Trigger phrase | Signal to verify in the snippet |
103
+ |---|---|
104
+ | `decorators` | `@` immediately above a `def` line |
105
+ | `async` | `async def` or `await` |
106
+ | `generators` | `yield` |
107
+ | `context managers` | `with` statement or `__enter__`/`__exit__` |
108
+ | `comprehensions` | `for ... in` inside `[`, `{`, or `(` |
109
+ | `error handling` | `try:`, `except`, or `finally` |
110
+ | `type hints` | `:` type annotation in function signatures or variable assignments |
111
+ | `threading` | `Thread(`, `Lock(`, `Queue(`, or `threading.` |
112
+
87
113
  ### 3. Presentation — Show the Snippet
88
114
 
89
115
  For each round, present the snippet with its filename:
90
116
 
91
117
  ```
92
118
  ---
93
- ## Round N — Level X | `path/to/file.py` (lines A–B)
119
+ ## Round N — Level X · concept | `path/to/file.py` (lines A–B)
94
120
 
95
121
  ```python
96
122
  42 def calculate_position_size(
@@ -119,6 +145,7 @@ Guidelines:
119
145
  - Strip only excessive blank lines; keep natural spacing
120
146
  - Show the function/class signature with its decorators
121
147
  - Show the filename and line range in the header
148
+ - The `· concept` portion only appears when a concept is targeted; omit it during free-play rounds
122
149
  - If the snippet depends on one obvious external type or constant, include a
123
150
  brief inline note
124
151
  - **Before presenting, scan for secrets.** Redact API keys, tokens, passwords,
@@ -149,6 +176,20 @@ Evaluate across two dimensions, scaled to the current difficulty level.
149
176
  | 4 | Generator mechanics (`yield`), `async`/`await` internals, descriptor protocol, closures, threading primitives |
150
177
  | 5 | Coroutine internals, metaclass programming, GIL implications, memory model, `__slots__`, MRO, weak references |
151
178
 
179
+ #### Weighted Evaluation for Targeted Concepts
180
+
181
+ When a concept is targeted (e.g., `teach me decorators`), bias the
182
+ evaluation toward that concept:
183
+
184
+ - **Mechanics axis:** The targeted concept carries extra weight. Missing
185
+ it is a significant gap even if other mechanics are handled well.
186
+ - **Strike hints:** Always steer strike 1 toward the targeted concept
187
+ before hinting about any other missed item.
188
+ - **Feedback ordering:** List the targeted concept first under "What you
189
+ missed" or "What you could sharpen."
190
+ - **Success bar:** To "meet expectations," the user must correctly
191
+ explain the targeted concept at the current level's depth.
192
+
152
193
  #### The Three-Strikes Rule
153
194
 
154
195
  If the user's answer does **not** meet the expectations for the current