learning-agent 0.2.0 → 0.2.1

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/CHANGELOG.md CHANGED
@@ -7,6 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.1] - 2026-02-01
11
+
12
+ ### Added
13
+
14
+ - **CLI Commands**
15
+ - `lna` short alias for `learning-agent` CLI
16
+ - `show <id>` - Display lesson details
17
+ - `update <id>` - Modify lesson fields (insight, severity, tags, confirmed)
18
+ - `delete <id>` - Create tombstone for lesson removal
19
+ - `download-model` - Download embedding model (~278MB)
20
+ - `--severity` flag for `learn` command to set lesson severity
21
+
22
+ - **Documentation**
23
+ - Complete lesson schema documentation in README
24
+ - Required vs optional fields explained
25
+ - Session-start loading requirements (type=full + severity=high + confirmed=true)
26
+ - "Never Edit JSONL Directly" warning in AGENTS.md template
27
+
28
+ ### Changed
29
+
30
+ - `setup claude` now defaults to project-local (was global)
31
+ - `setup claude --global` required for global installation
32
+ - `init` now includes `setup claude` step by default
33
+ - Auto-sync SQLite after every CLI mutation (learn, update, delete, import)
34
+
35
+ ### Fixed
36
+
37
+ - Pre-commit hook now inserted before exit statements (not appended after)
38
+ - JSONL edits properly sync to SQLite index
39
+ - High-severity lessons load correctly at session start
40
+
10
41
  ## [0.2.0] - 2026-01-31
11
42
 
12
43
  ### Added
@@ -110,5 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
110
141
  - Vitest test suite
111
142
  - tsup build configuration
112
143
 
113
- [Unreleased]: https://github.com/nathanbraun/learning_agent/compare/v0.1.0...HEAD
114
- [0.1.0]: https://github.com/nathanbraun/learning_agent/releases/tag/v0.1.0
144
+ [Unreleased]: https://github.com/Nathandela/learning_agent/compare/v0.2.1...HEAD
145
+ [0.2.1]: https://github.com/Nathandela/learning_agent/compare/v0.2.0...v0.2.1
146
+ [0.2.0]: https://github.com/Nathandela/learning_agent/compare/v0.1.0...v0.2.0
147
+ [0.1.0]: https://github.com/Nathandela/learning_agent/releases/tag/v0.1.0
package/README.md CHANGED
@@ -182,33 +182,120 @@ import {
182
182
 
183
183
  See [examples/](examples/) for usage examples.
184
184
 
185
- ## Lesson Types
185
+ ## Lesson Schema
186
+
187
+ Lessons are stored in JSONL format with Zod validation. Understanding the schema is critical for correct usage.
188
+
189
+ ### Required Fields
190
+
191
+ Every lesson **must** have these fields:
192
+
193
+ | Field | Type | Description |
194
+ |-------|------|-------------|
195
+ | `id` | string | Unique identifier (e.g., "L1a2b3c4d") |
196
+ | `type` | "quick" \| "full" | Lesson quality tier (see below) |
197
+ | `trigger` | string | What caused this lesson to be learned |
198
+ | `insight` | string | The actual lesson content |
199
+ | `tags` | string[] | Categorization tags (can be empty) |
200
+ | `source` | enum | How it was captured: "user_correction", "self_correction", "test_failure", "manual" |
201
+ | `context` | object | `{ tool: string, intent: string }` - what was happening |
202
+ | `created` | string | ISO8601 timestamp |
203
+ | `confirmed` | boolean | Whether user confirmed this lesson |
204
+ | `supersedes` | string[] | IDs of lessons this replaces (can be empty) |
205
+ | `related` | string[] | IDs of related lessons (can be empty) |
206
+
207
+ ### Optional Fields
208
+
209
+ | Field | Type | Description |
210
+ |-------|------|-------------|
211
+ | `evidence` | string | Supporting evidence (typically for "full" type) |
212
+ | `severity` | "high" \| "medium" \| "low" | Importance level |
213
+ | `pattern` | object | `{ bad: string, good: string }` - code pattern |
214
+ | `deleted` | boolean | Tombstone marker for deletions |
215
+ | `retrievalCount` | number | Times this lesson was retrieved |
216
+
217
+ ### Type vs Severity (Important!)
218
+
219
+ **`type`** and **`severity`** are **separate** fields:
220
+
221
+ - **`type`**: Quality tier of the lesson
222
+ - `"quick"` - Minimal capture, fast to create
223
+ - `"full"` - Detailed lesson with evidence/patterns
224
+
225
+ - **`severity`**: Importance level (optional field)
226
+ - `"high"` - Critical, loaded at every session start
227
+ - `"medium"` - Important, retrieved when relevant
228
+ - `"low"` - Minor, lower retrieval priority
229
+
230
+ **Common mistake**: Using `type: "high"` instead of `type: "full"` with `severity: "high"`.
231
+
232
+ ### Session-Start Loading
233
+
234
+ High-severity lessons are automatically loaded at session start. For a lesson to load:
235
+
236
+ 1. `type` must be `"full"`
237
+ 2. `severity` must be `"high"`
238
+ 3. `confirmed` must be `true`
239
+
240
+ ### Complete Examples
241
+
242
+ #### Quick Lesson (minimal)
186
243
 
187
- ### Quick Lesson (fast capture)
188
244
  ```json
189
245
  {
190
- "id": "L001",
246
+ "id": "L1a2b3c4d",
191
247
  "type": "quick",
192
248
  "trigger": "Used pandas for 500MB file",
193
- "insight": "Polars 10x faster",
249
+ "insight": "Polars is 10x faster for large files",
194
250
  "tags": ["performance", "polars"],
195
- "source": "user_correction"
251
+ "source": "user_correction",
252
+ "context": { "tool": "edit", "intent": "optimize CSV processing" },
253
+ "created": "2025-01-30T14:00:00Z",
254
+ "confirmed": true,
255
+ "supersedes": [],
256
+ "related": []
196
257
  }
197
258
  ```
198
259
 
199
- ### Full Lesson (detailed, high-severity)
260
+ #### Full Lesson with High Severity (loads at session start)
261
+
200
262
  ```json
201
263
  {
202
- "id": "L002",
264
+ "id": "L5e6f7g8h",
203
265
  "type": "full",
204
266
  "trigger": "Auth API returned 401 despite valid token",
205
267
  "insight": "API requires X-Request-ID header",
206
- "evidence": "Traced in network tab, header missing",
268
+ "evidence": "Traced in network tab, header was missing",
269
+ "tags": ["api", "auth"],
207
270
  "severity": "high",
208
- "source": "test_failure"
271
+ "source": "test_failure",
272
+ "context": { "tool": "bash", "intent": "run auth integration tests" },
273
+ "created": "2025-01-30T15:30:00Z",
274
+ "confirmed": true,
275
+ "supersedes": [],
276
+ "related": ["L1a2b3c4d"],
277
+ "pattern": {
278
+ "bad": "requests.get(url, headers={'Authorization': token})",
279
+ "good": "requests.get(url, headers={'Authorization': token, 'X-Request-ID': uuid4()})"
280
+ }
209
281
  }
210
282
  ```
211
283
 
284
+ ### Creating Lessons via CLI
285
+
286
+ Always use the CLI to create lessons (never edit JSONL directly):
287
+
288
+ ```bash
289
+ # Quick lesson
290
+ npx lna learn "Use Polars for large files"
291
+
292
+ # Full lesson with high severity (loads at session start)
293
+ npx lna learn "API requires X-Request-ID header" --severity high
294
+
295
+ # With trigger context
296
+ npx lna learn "Use uv not pip" --trigger "pip was slow" --severity medium
297
+ ```
298
+
212
299
  ## Technology Stack
213
300
 
214
301
  | Component | Technology |
@@ -237,7 +324,7 @@ pnpm lint
237
324
 
238
325
  ## Project Status
239
326
 
240
- Version 0.2.0 - Claude Code hooks integration complete. See [doc/SPEC.md](doc/SPEC.md) for the full specification and [CHANGELOG.md](CHANGELOG.md) for recent changes.
327
+ Version 0.2.1 - Bug fixes and documentation improvements. See [doc/SPEC.md](doc/SPEC.md) for the full specification and [CHANGELOG.md](CHANGELOG.md) for recent changes.
241
328
 
242
329
  ## Documentation
243
330