learning-agent 0.2.1 → 0.2.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/CHANGELOG.md +47 -1
- package/README.md +26 -101
- package/dist/cli.js +1326 -1236
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +38 -0
- package/dist/index.js +85 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.2] - 2026-02-01
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Age-based Temporal Validity** (LANDSCAPE.md: eik)
|
|
15
|
+
- `CompactionLevelSchema` for lesson lifecycle (0=active, 1=flagged, 2=archived)
|
|
16
|
+
- Age distribution display in `stats` command (<30d, 30-90d, >90d)
|
|
17
|
+
- Age warnings in `load-session` for lessons older than 90 days
|
|
18
|
+
- New schema fields: `compactionLevel`, `compactedAt`, `lastRetrieved`
|
|
19
|
+
|
|
20
|
+
- **Manual Invalidation** (LANDSCAPE.md: mov)
|
|
21
|
+
- `learning-agent wrong <id>` - Mark a lesson as invalid/wrong
|
|
22
|
+
- `learning-agent validate <id>` - Re-enable a previously invalidated lesson
|
|
23
|
+
- `list --invalidated` flag to show only invalidated lessons
|
|
24
|
+
- New schema fields: `invalidatedAt`, `invalidationReason`
|
|
25
|
+
|
|
26
|
+
- **Optional Citation Field** (LANDSCAPE.md: tn3)
|
|
27
|
+
- `CitationSchema` for lesson provenance tracking
|
|
28
|
+
- Store file path, line number, and git commit with lessons
|
|
29
|
+
- `learn --citation <file:line>` and `--citation-commit <hash>` flags
|
|
30
|
+
|
|
31
|
+
- **Count Warning** (LANDSCAPE.md: qp9)
|
|
32
|
+
- Warning in `stats` when lesson count exceeds 20 (context pollution prevention)
|
|
33
|
+
- Note in `load-session` when total lessons may degrade retrieval quality
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- Lesson schema now includes optional fields for citation, age-tracking, and invalidation
|
|
38
|
+
- `list` command shows `[INVALID]` marker for invalidated lessons
|
|
39
|
+
- `load-session` JSON output includes `totalCount` field
|
|
40
|
+
- CLI refactored into command modules (`src/commands/`) for maintainability
|
|
41
|
+
- Age calculation logic centralized in `src/utils.ts`
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- **SQLite schema now stores v0.2.2 fields** (x9y)
|
|
46
|
+
- Added columns: `invalidated_at`, `invalidation_reason`, `citation_*`, `compaction_level`, `compacted_at`
|
|
47
|
+
- `rebuildIndex` preserves all v0.2.2 fields during cache rebuild
|
|
48
|
+
- `rowToLesson` correctly maps all fields back to Lesson objects
|
|
49
|
+
|
|
50
|
+
- **Retrieval paths filter out invalidated lessons** (z8k)
|
|
51
|
+
- `searchKeyword` excludes lessons with `invalidated_at` set
|
|
52
|
+
- `searchVector` skips invalidated lessons during scoring
|
|
53
|
+
- `loadSessionLessons` filters out invalidated high-severity lessons
|
|
54
|
+
|
|
10
55
|
## [0.2.1] - 2026-02-01
|
|
11
56
|
|
|
12
57
|
### Added
|
|
@@ -141,7 +186,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
141
186
|
- Vitest test suite
|
|
142
187
|
- tsup build configuration
|
|
143
188
|
|
|
144
|
-
[Unreleased]: https://github.com/Nathandela/learning_agent/compare/v0.2.
|
|
189
|
+
[Unreleased]: https://github.com/Nathandela/learning_agent/compare/v0.2.2...HEAD
|
|
190
|
+
[0.2.2]: https://github.com/Nathandela/learning_agent/compare/v0.2.1...v0.2.2
|
|
145
191
|
[0.2.1]: https://github.com/Nathandela/learning_agent/compare/v0.2.0...v0.2.1
|
|
146
192
|
[0.2.0]: https://github.com/Nathandela/learning_agent/compare/v0.1.0...v0.2.0
|
|
147
193
|
[0.1.0]: https://github.com/Nathandela/learning_agent/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -93,18 +93,30 @@ pnpm download-model
|
|
|
93
93
|
# Capture a lesson manually
|
|
94
94
|
pnpm learn "Use Polars for large files, not pandas"
|
|
95
95
|
|
|
96
|
+
# Capture with citation (file:line provenance)
|
|
97
|
+
learning-agent learn "API requires auth header" --citation src/api.ts:42
|
|
98
|
+
|
|
96
99
|
# Search lessons
|
|
97
100
|
learning-agent search "data processing"
|
|
98
101
|
|
|
99
|
-
# Rebuild index from JSONL
|
|
100
|
-
learning-agent rebuild
|
|
101
|
-
|
|
102
102
|
# List all lessons
|
|
103
103
|
learning-agent list
|
|
104
104
|
|
|
105
|
-
#
|
|
105
|
+
# List only invalidated lessons
|
|
106
|
+
learning-agent list --invalidated
|
|
107
|
+
|
|
108
|
+
# Mark a lesson as wrong/invalid
|
|
109
|
+
learning-agent wrong L12345678 --reason "This advice was incorrect"
|
|
110
|
+
|
|
111
|
+
# Re-enable an invalidated lesson
|
|
112
|
+
learning-agent validate L12345678
|
|
113
|
+
|
|
114
|
+
# Show database stats (includes age distribution)
|
|
106
115
|
learning-agent stats
|
|
107
116
|
|
|
117
|
+
# Rebuild index from JSONL
|
|
118
|
+
learning-agent rebuild
|
|
119
|
+
|
|
108
120
|
# Compact and archive old lessons
|
|
109
121
|
learning-agent compact
|
|
110
122
|
```
|
|
@@ -182,120 +194,33 @@ import {
|
|
|
182
194
|
|
|
183
195
|
See [examples/](examples/) for usage examples.
|
|
184
196
|
|
|
185
|
-
## Lesson
|
|
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)
|
|
197
|
+
## Lesson Types
|
|
243
198
|
|
|
199
|
+
### Quick Lesson (fast capture)
|
|
244
200
|
```json
|
|
245
201
|
{
|
|
246
|
-
"id": "
|
|
202
|
+
"id": "L001",
|
|
247
203
|
"type": "quick",
|
|
248
204
|
"trigger": "Used pandas for 500MB file",
|
|
249
|
-
"insight": "Polars
|
|
205
|
+
"insight": "Polars 10x faster",
|
|
250
206
|
"tags": ["performance", "polars"],
|
|
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": []
|
|
207
|
+
"source": "user_correction"
|
|
257
208
|
}
|
|
258
209
|
```
|
|
259
210
|
|
|
260
|
-
|
|
261
|
-
|
|
211
|
+
### Full Lesson (detailed, high-severity)
|
|
262
212
|
```json
|
|
263
213
|
{
|
|
264
|
-
"id": "
|
|
214
|
+
"id": "L002",
|
|
265
215
|
"type": "full",
|
|
266
216
|
"trigger": "Auth API returned 401 despite valid token",
|
|
267
217
|
"insight": "API requires X-Request-ID header",
|
|
268
|
-
"evidence": "Traced in network tab, header
|
|
269
|
-
"tags": ["api", "auth"],
|
|
218
|
+
"evidence": "Traced in network tab, header missing",
|
|
270
219
|
"severity": "high",
|
|
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
|
-
}
|
|
220
|
+
"source": "test_failure"
|
|
281
221
|
}
|
|
282
222
|
```
|
|
283
223
|
|
|
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
|
-
|
|
299
224
|
## Technology Stack
|
|
300
225
|
|
|
301
226
|
| Component | Technology |
|
|
@@ -324,7 +249,7 @@ pnpm lint
|
|
|
324
249
|
|
|
325
250
|
## Project Status
|
|
326
251
|
|
|
327
|
-
Version 0.2.
|
|
252
|
+
Version 0.2.2 - Hardening release with quality gates based on [LANDSCAPE.md](doc/LANDSCAPE.md) reviewer feedback. Adds age-based validity warnings, manual invalidation commands, optional citation tracking, and context pollution warnings. See [CHANGELOG.md](CHANGELOG.md) for details.
|
|
328
253
|
|
|
329
254
|
## Documentation
|
|
330
255
|
|