learning-agent 0.1.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 +56 -4
- package/README.md +130 -14
- package/dist/cli.js +1670 -518
- package/dist/cli.js.map +1 -1
- package/package.json +12 -20
package/CHANGELOG.md
CHANGED
|
@@ -7,8 +7,48 @@ 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
|
+
|
|
41
|
+
## [0.2.0] - 2026-01-31
|
|
42
|
+
|
|
10
43
|
### Added
|
|
11
44
|
|
|
45
|
+
- **Claude Code Integration**
|
|
46
|
+
- `learning-agent setup claude` - Install SessionStart hooks into Claude Code settings
|
|
47
|
+
- `--project` flag for project-level hooks (vs global)
|
|
48
|
+
- `--uninstall` to remove hooks
|
|
49
|
+
- `--dry-run` to preview changes
|
|
50
|
+
- Automatic lesson injection at session start, resume, and compact events
|
|
51
|
+
|
|
12
52
|
- **Storage Enhancements**
|
|
13
53
|
- Compaction system for archiving old lessons and removing tombstones
|
|
14
54
|
- Smart sync: rebuild index only when JSONL changes
|
|
@@ -27,14 +67,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
27
67
|
- Simplified model download using node-llama-cpp resolveModelFile
|
|
28
68
|
|
|
29
69
|
- **Testing**
|
|
30
|
-
-
|
|
31
|
-
- Property-based tests with fast-check
|
|
70
|
+
- 501 tests with property-based testing (fast-check)
|
|
32
71
|
- Integration tests for capture workflows
|
|
33
72
|
|
|
34
73
|
### Changed
|
|
35
74
|
|
|
36
75
|
- Unified QuickLesson and FullLesson into single Lesson type
|
|
37
76
|
- Removed deprecated type exports
|
|
77
|
+
- `check-plan` now hard-fails on embedding errors (exit non-zero with actionable message)
|
|
78
|
+
- `capture` and `detect --save` now require `--yes` flag for saves
|
|
79
|
+
- `learn` command always saves with `confirmed: true`
|
|
80
|
+
- Hook installation is non-destructive (appends to existing hooks)
|
|
81
|
+
- Hook installation respects `core.hooksPath` git configuration
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
|
|
85
|
+
- Embedding errors no longer masked as "no relevant lessons" in check-plan
|
|
86
|
+
- Git hooks no longer overwrite existing pre-commit hooks
|
|
87
|
+
- AGENTS.md template now includes explicit plan-time instructions
|
|
38
88
|
|
|
39
89
|
## [0.1.0] - 2025-01-30
|
|
40
90
|
|
|
@@ -91,5 +141,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
91
141
|
- Vitest test suite
|
|
92
142
|
- tsup build configuration
|
|
93
143
|
|
|
94
|
-
[Unreleased]: https://github.com/
|
|
95
|
-
[0.1
|
|
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
|
@@ -111,13 +111,42 @@ learning-agent compact
|
|
|
111
111
|
|
|
112
112
|
## Claude Code Integration
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
### Automatic Setup (Recommended)
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Install hooks into Claude Code settings (global)
|
|
118
|
+
npx learning-agent setup claude
|
|
119
|
+
|
|
120
|
+
# Install to project only
|
|
121
|
+
npx learning-agent setup claude --project
|
|
122
|
+
|
|
123
|
+
# Preview what would change
|
|
124
|
+
npx learning-agent setup claude --dry-run
|
|
125
|
+
|
|
126
|
+
# Remove hooks
|
|
127
|
+
npx learning-agent setup claude --uninstall
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This installs a SessionStart hook that automatically loads lessons when Claude starts, resumes, or compacts context.
|
|
131
|
+
|
|
132
|
+
### Manual Setup
|
|
133
|
+
|
|
134
|
+
Add to your `~/.claude/settings.json`:
|
|
115
135
|
|
|
116
136
|
```json
|
|
117
137
|
{
|
|
118
138
|
"hooks": {
|
|
119
|
-
"
|
|
120
|
-
|
|
139
|
+
"SessionStart": [
|
|
140
|
+
{
|
|
141
|
+
"matcher": "startup|resume|compact",
|
|
142
|
+
"hooks": [
|
|
143
|
+
{
|
|
144
|
+
"type": "command",
|
|
145
|
+
"command": "npx learning-agent load-session 2>/dev/null || true"
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
121
150
|
}
|
|
122
151
|
}
|
|
123
152
|
```
|
|
@@ -127,7 +156,7 @@ Add to your `.claude/settings.json` to automatically load lessons:
|
|
|
127
156
|
| Command | Purpose |
|
|
128
157
|
|---------|---------|
|
|
129
158
|
| `load-session` | Load high-severity lessons at session start |
|
|
130
|
-
| `check-plan` | Retrieve relevant lessons when planning |
|
|
159
|
+
| `check-plan --plan "..."` | Retrieve relevant lessons when planning |
|
|
131
160
|
|
|
132
161
|
## API Reference
|
|
133
162
|
|
|
@@ -153,33 +182,120 @@ import {
|
|
|
153
182
|
|
|
154
183
|
See [examples/](examples/) for usage examples.
|
|
155
184
|
|
|
156
|
-
## Lesson
|
|
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)
|
|
157
243
|
|
|
158
|
-
### Quick Lesson (fast capture)
|
|
159
244
|
```json
|
|
160
245
|
{
|
|
161
|
-
"id": "
|
|
246
|
+
"id": "L1a2b3c4d",
|
|
162
247
|
"type": "quick",
|
|
163
248
|
"trigger": "Used pandas for 500MB file",
|
|
164
|
-
"insight": "Polars 10x faster",
|
|
249
|
+
"insight": "Polars is 10x faster for large files",
|
|
165
250
|
"tags": ["performance", "polars"],
|
|
166
|
-
"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": []
|
|
167
257
|
}
|
|
168
258
|
```
|
|
169
259
|
|
|
170
|
-
|
|
260
|
+
#### Full Lesson with High Severity (loads at session start)
|
|
261
|
+
|
|
171
262
|
```json
|
|
172
263
|
{
|
|
173
|
-
"id": "
|
|
264
|
+
"id": "L5e6f7g8h",
|
|
174
265
|
"type": "full",
|
|
175
266
|
"trigger": "Auth API returned 401 despite valid token",
|
|
176
267
|
"insight": "API requires X-Request-ID header",
|
|
177
|
-
"evidence": "Traced in network tab, header missing",
|
|
268
|
+
"evidence": "Traced in network tab, header was missing",
|
|
269
|
+
"tags": ["api", "auth"],
|
|
178
270
|
"severity": "high",
|
|
179
|
-
"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
|
+
}
|
|
180
281
|
}
|
|
181
282
|
```
|
|
182
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
|
+
|
|
183
299
|
## Technology Stack
|
|
184
300
|
|
|
185
301
|
| Component | Technology |
|
|
@@ -208,7 +324,7 @@ pnpm lint
|
|
|
208
324
|
|
|
209
325
|
## Project Status
|
|
210
326
|
|
|
211
|
-
Version 0.1
|
|
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.
|
|
212
328
|
|
|
213
329
|
## Documentation
|
|
214
330
|
|