context-vault 3.19.0 → 3.20.0

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.
Files changed (31) hide show
  1. package/bin/cli.js +516 -4
  2. package/node_modules/@context-vault/core/dist/main.d.ts +1 -0
  3. package/node_modules/@context-vault/core/dist/main.d.ts.map +1 -1
  4. package/node_modules/@context-vault/core/dist/main.js +2 -0
  5. package/node_modules/@context-vault/core/dist/main.js.map +1 -1
  6. package/node_modules/@context-vault/core/dist/search.d.ts +1 -0
  7. package/node_modules/@context-vault/core/dist/search.d.ts.map +1 -1
  8. package/node_modules/@context-vault/core/dist/search.js +10 -1
  9. package/node_modules/@context-vault/core/dist/search.js.map +1 -1
  10. package/node_modules/@context-vault/core/dist/search.test.d.ts +2 -0
  11. package/node_modules/@context-vault/core/dist/search.test.d.ts.map +1 -0
  12. package/node_modules/@context-vault/core/dist/search.test.js +49 -0
  13. package/node_modules/@context-vault/core/dist/search.test.js.map +1 -0
  14. package/node_modules/@context-vault/core/package.json +9 -1
  15. package/node_modules/@context-vault/core/src/main.ts +3 -0
  16. package/node_modules/@context-vault/core/src/search.test.ts +59 -0
  17. package/node_modules/@context-vault/core/src/search.ts +11 -1
  18. package/package.json +2 -2
  19. package/.claude-plugin/README.md +0 -219
  20. package/.claude-plugin/plugin.json +0 -11
  21. package/commands/vault-cleanup.md +0 -43
  22. package/commands/vault-snapshot.md +0 -43
  23. package/commands/vault-status.md +0 -35
  24. package/dist/tools/session-start.d.ts +0 -25
  25. package/dist/tools/session-start.d.ts.map +0 -1
  26. package/dist/tools/session-start.js +0 -469
  27. package/dist/tools/session-start.js.map +0 -1
  28. package/skills/context-assembly/SKILL.md +0 -308
  29. package/skills/knowledge-capture/SKILL.md +0 -303
  30. package/skills/memory-management/SKILL.md +0 -237
  31. package/src/tools/session-start.ts +0 -527
@@ -1,308 +0,0 @@
1
- # Context Assembly — Loading Knowledge at Task Start
2
-
3
- Learn how to load context from your vault at the beginning of a session or task. Assemble relevant knowledge efficiently and prime Claude with exactly what you need.
4
-
5
- ## The Session-Start Protocol
6
-
7
- When you start work on a project or task, follow this 3-step protocol:
8
-
9
- 1. **Scope your context** to the right project (bucket)
10
- 2. **Preload memory** to warm up Claude's context
11
- 3. **Load task-specific context** as needed
12
-
13
- This loads relevant knowledge automatically instead of searching every 5 minutes.
14
-
15
- ## Step 1: Scope Your Context with Buckets
16
-
17
- Every entry in your vault has a bucket tag (bucket:projectname) that scopes it to a project.
18
-
19
- At session start, **tell Claude to focus on one project**:
20
-
21
- ```javascript
22
- clear_context({
23
- scope: "autohub", // Focus on "autohub" project
24
- preload_bucket: "autohub", // Warm-up cache with autohub entries
25
- max_tokens: 4000 // Budget for context (adjust as needed)
26
- })
27
- ```
28
-
29
- This call:
30
- - Clears the previous session's context focus
31
- - Returns recent autohub entries directly in the response (decisions, insights, patterns)
32
- - Sets scope guidance: the response reminds you to filter to autohub in subsequent calls
33
-
34
- **Result:** You get immediate project context in the response. For subsequent `get_context` calls, include `buckets: ["autohub"]` to stay scoped.
35
-
36
- ## Step 2: Get Task-Specific Context
37
-
38
- Once scoped, retrieve context relevant to your specific task:
39
-
40
- ```javascript
41
- get_context({
42
- query: "what decisions have we made about the authentication flow?",
43
- buckets: ["autohub"], // Optional: already scoped, but be explicit
44
- limit: 10, // Limit to 10 entries
45
- max_tokens: 2000 // Stay within token budget
46
- })
47
- ```
48
-
49
- This returns:
50
- - Decisions, insights, and patterns related to auth
51
- - Only from the autohub bucket
52
- - Ranked by relevance
53
- - Fits within your token budget
54
-
55
- **Use cases:**
56
- - "What was our database choice?" → Query for database decisions
57
- - "How do we handle errors in API calls?" → Query for error-handling patterns
58
- - "What stakeholders are involved?" → Query for contact entries
59
- - "What's blocking us on billing?" → Query for blockers or decisions on payments
60
-
61
- ## Step 3: Build Context Briefs for Complex Topics
62
-
63
- When a topic has many scattered entries (5+), don't load them individually. Create a snapshot instead:
64
-
65
- ```javascript
66
- create_snapshot({
67
- topic: "API authentication",
68
- buckets: ["autohub"],
69
- kinds: ["decision", "pattern"] // Optional: only snapshots of these types
70
- })
71
- ```
72
-
73
- The snapshot consolidates all related entries into a single brief. Much more efficient than loading 8 separate entries.
74
-
75
- **When to snapshot:**
76
- - Starting a big new arc (e.g., "API redesign")
77
- - Onboarding a new team member to the project
78
- - Before meetings where you need to present project context
79
- - When assembling context for a complex task (20+ related entries)
80
-
81
- ## Efficient Context Loading: Skeleton Mode
82
-
83
- For large projects with 100+ entries, use **skeleton mode** to keep token use low:
84
-
85
- ```javascript
86
- get_context({
87
- query: "authentication implementation",
88
- buckets: ["autohub"],
89
- pivot_count: 3, // Full body for top 3 entries, skeletons for rest
90
- max_tokens: 2000 // Strict token budget
91
- })
92
- ```
93
-
94
- **Result:**
95
- - Top 3 entries: Full content (title + body + context)
96
- - Remaining entries: Skeleton format (title + tags + first 100 chars)
97
- - Token-efficient: Skeletons use 10% of the tokens of full entries
98
-
99
- **Use skeleton mode when:**
100
- - You have a tight token budget (< 2000 tokens)
101
- - You want breadth over depth (see all related entries, not all details)
102
- - You're exploring a topic (decide which entries deserve deep reading)
103
-
104
- ## Graph Traversal: Follow Related Entries
105
-
106
- Entries can link to each other using `related_to`. Follow these links to find contextually similar entries:
107
-
108
- ```javascript
109
- get_context({
110
- query: "OAuth implementation",
111
- buckets: ["autohub"],
112
- follow_links: true // Include linked entries
113
- })
114
- ```
115
-
116
- This returns:
117
- - Matching entries for "OAuth implementation"
118
- - All entries linked to those entries (related_to links)
119
- - Both forward links (this entry references X) and backlinks (X references this entry)
120
-
121
- **Use when:**
122
- - You want to understand the full decision tree (see what led to this decision)
123
- - You want impact analysis (what other decisions depend on this one?)
124
- - You're tracing a complex topic across multiple entries
125
-
126
- ## Context Budget: Token Management
127
-
128
- Your context budget (`max_tokens`) is precious. Allocate wisely:
129
-
130
- ```javascript
131
- // Tight budget: High-level overview only
132
- get_context({
133
- query: "authentication architecture",
134
- max_tokens: 1000, // ~4-5 entries
135
- pivot_count: 1 // Only top entry in full
136
- })
137
-
138
- // Medium budget: Decision + supporting context
139
- get_context({
140
- query: "authentication architecture",
141
- max_tokens: 3000, // ~10-12 entries
142
- pivot_count: 3 // Top 3 in full, rest as skeletons
143
- })
144
-
145
- // Generous budget: Deep dive with related entries
146
- get_context({
147
- query: "authentication architecture",
148
- max_tokens: 5000, // ~15-20 entries
149
- follow_links: true, // Include related entries
150
- pivot_count: 5 // Top 5 in full
151
- })
152
- ```
153
-
154
- **Guidelines:**
155
- - Reserve 30-50% of your session context for vault entries
156
- - Use skeleton mode to fit more entries in less tokens
157
- - Follow_links expands context; use sparingly with strict max_tokens
158
- - Create snapshots to consolidate large topics into a single entry
159
-
160
- ## Conflict Detection: Spot Outdated Decisions
161
-
162
- When loading context, spot decisions that might be outdated:
163
-
164
- ```javascript
165
- get_context({
166
- query: "database choice",
167
- buckets: ["autohub"],
168
- detect_conflicts: true // Flag superseded or conflicting entries
169
- })
170
- ```
171
-
172
- **Result:**
173
- - Marked entries that have been superseded (newer version exists)
174
- - Flagged entries with conflicting information (different decisions on the same topic)
175
- - Suggests which entries are stale
176
-
177
- **Use when:**
178
- - Loading context from a project you haven't touched in 3+ months
179
- - Starting a new arc that touches a previously decided area
180
- - You suspect decisions have changed since last session
181
-
182
- ## Browsing: When You Don't Know What You're Looking For
183
-
184
- Sometimes you want to browse your vault without a specific query:
185
-
186
- ```javascript
187
- list_context({
188
- tags: ["bucket:autohub"],
189
- kind: "decision", // Only decisions
190
- limit: 20 // Show 20 most recent
191
- })
192
- ```
193
-
194
- Returns a list of entries (title + tags, no full body) so you can browse and decide which to read deeply.
195
-
196
- **Use when:**
197
- - You're onboarding to a project (see what decisions exist)
198
- - You want to refresh memory before a meeting
199
- - You're looking for entries by browse, not search
200
-
201
- ## Common Workflows
202
-
203
- ### Workflow 1: Start Work on a New Feature
204
-
205
- ```javascript
206
- // 1. Scope to project
207
- clear_context({ preload_bucket: "autohub", max_tokens: 4000 })
208
-
209
- // 2. Get architecture decisions
210
- get_context({
211
- query: "overall architecture and tech stack",
212
- limit: 5,
213
- max_tokens: 1500
214
- })
215
-
216
- // 3. Get feature-specific context
217
- get_context({
218
- query: "user authentication flow",
219
- limit: 5,
220
- max_tokens: 1500
221
- })
222
-
223
- // 4. Follow related decisions
224
- get_context({
225
- query: "API security",
226
- follow_links: true,
227
- max_tokens: 1000
228
- })
229
- ```
230
-
231
- Total: ~4500 tokens for a complete project context setup.
232
-
233
- ### Workflow 2: Onboard New Team Member
234
-
235
- ```javascript
236
- // Create a comprehensive snapshot
237
- create_snapshot({
238
- topic: "autohub project overview and key decisions",
239
- buckets: ["autohub"],
240
- kinds: ["decision", "pattern"]
241
- })
242
-
243
- // Share the snapshot as a brief
244
- // (They can read it in 30 minutes instead of searching)
245
- ```
246
-
247
- ### Workflow 3: Deep Dive on Complex Decision
248
-
249
- ```javascript
250
- get_context({
251
- query: "why did we choose Turso over PostgreSQL?",
252
- buckets: ["autohub"],
253
- follow_links: true, // See related decisions (infrastructure, scale, cost)
254
- max_tokens: 3000
255
- })
256
- ```
257
-
258
- ### Workflow 4: End-of-Session Cleanup
259
-
260
- Before ending your session, use the context to inform your captures:
261
-
262
- ```javascript
263
- // What decisions did we make today?
264
- get_context({
265
- query: "today's decisions",
266
- since: "today",
267
- limit: 10
268
- })
269
-
270
- // Do any of today's insights conflict with past entries?
271
- get_context({
272
- query: "authentication implementation",
273
- detect_conflicts: true
274
- })
275
-
276
- // Save new decisions without duplicating old ones
277
- save_context({
278
- kind: "decision",
279
- title: "Updated auth flow",
280
- body: "...",
281
- supersedes: ["old-auth-id"] // Retire old decision
282
- })
283
- ```
284
-
285
- ## Preload and Performance
286
-
287
- **Preload behavior:**
288
- - `clear_context({ preload_bucket: "autohub" })` queries the vault and returns matching entries directly in the response text
289
- - This gives you immediate context without a separate `get_context` call
290
- - There is no shared cache between tools. Each `get_context` call runs its own query.
291
-
292
- **Optimize for speed:**
293
- - Call `clear_context` with `preload_bucket` at session start to get a project overview in one call
294
- - Use `max_tokens` to limit response size (fewer entries = smaller responses)
295
- - Use skeleton mode (`pivot_count`) to reduce token use in `get_context`
296
- - Create snapshots to consolidate many entries into a single brief
297
-
298
- ## Token Budget Checklist
299
-
300
- Before a `get_context` call, verify:
301
-
302
- - [ ] Is max_tokens set to a reasonable value (< 50% of session budget)?
303
- - [ ] Am I using skeleton mode if I need breadth?
304
- - [ ] Is follow_links true only if I need to trace decisions?
305
- - [ ] Did I use a snapshot for large topics?
306
- - [ ] Did I scope with clear_context at session start?
307
-
308
- If you can answer yes to most, your context call will be efficient.
@@ -1,303 +0,0 @@
1
- # Knowledge Capture — Session-End Protocol for Vault
2
-
3
- Learn the session-end capture protocol: how to extract and save insights, decisions, and learning before you leave a task or session.
4
-
5
- ## Why Capture at Session End?
6
-
7
- At the end of each session or task, you have fresh context about:
8
- - What you decided and why
9
- - What you learned (surprises, aha moments, gotchas)
10
- - Patterns you discovered
11
- - What worked well and what didn't
12
- - Next steps and blockers
13
-
14
- **This is the best time to save.** If you don't capture now, this context evaporates. Later, you'll waste time rediscovering it.
15
-
16
- Invest 5-10 minutes at session end to save decisions and insights. You'll thank yourself when the next session starts.
17
-
18
- ## The Session-End Checklist
19
-
20
- At the end of your session, ask yourself these questions. For each yes, save an entry:
21
-
22
- ### Decisions Made
23
- - Did you choose between options? (tech stack, approach, design)
24
- - Did you change direction? (pivot, constraint, new information)
25
- - Did you scope something in or out? (include/exclude features, projects)
26
-
27
- **Example entry:**
28
- ```javascript
29
- save_context({
30
- kind: "decision",
31
- title: "Chose esbuild over Webpack for bundling",
32
- body: `Evaluated Webpack, esbuild, and Turbopack. Chose esbuild because:
33
- - 100x faster builds (15s → 0.2s on our codebase)
34
- - Simpler config for our use case
35
- - Better ESM support
36
- Rejected Webpack (too complex for gains), Turbopack (immature).`,
37
- tags: ["bucket:frontend-infra", "bundling", "build-tools"],
38
- encoding_context: { project: "web-redesign", arc: "perf-optimization", task: "setup-build" },
39
- tier: "durable"
40
- })
41
- ```
42
-
43
- ### Insights & Discoveries
44
- - Did you learn how something works? (system behavior, edge case, pattern)
45
- - Did you encounter a gotcha or surprising behavior?
46
- - Did you find a best practice or anti-pattern?
47
-
48
- **Example entry:**
49
- ```javascript
50
- save_context({
51
- kind: "insight",
52
- title: "SQLite ANALYZE required for query planner efficiency",
53
- body: `After 1M+ rows, SQLite query planner becomes ineffective without ANALYZE.
54
-
55
- Observed: Queries that took 50ms with 100k rows jumped to 5000ms at 1M rows.
56
- Root cause: Query planner using outdated statistics.
57
- Solution: Run ANALYZE after bulk inserts. Restores performance to <100ms.
58
-
59
- Lesson: Add ANALYZE to migration and bulk ETL scripts.`,
60
- tags: ["bucket:context-vault", "database", "performance", "sqlite"],
61
- encoding_context: { project: "context-vault", arc: "scaling", task: "perf-investigation" }
62
- })
63
- ```
64
-
65
- ### Patterns Discovered
66
- - Did you find a repeatable technique or approach?
67
- - Did you establish a convention the team should know?
68
- - Did you find a workaround or hack that works consistently?
69
-
70
- **Example entry:**
71
- ```javascript
72
- save_context({
73
- kind: "pattern",
74
- title: "Always include encoding_context for vault entries",
75
- body: `Saves entries without encoding_context have < 5% recall ratio.
76
- Entries with encoding_context (project, arc, task) have > 25% recall.
77
-
78
- Pattern: Always include encoding_context structured like:
79
- { project: "x", arc: "y", task: "z" }
80
-
81
- This lets Claude find entries months later by context match, not just keywords.`,
82
- tags: ["bucket:context-vault", "vault-practice", "metadata"],
83
- tier: "durable"
84
- })
85
- ```
86
-
87
- ### Lessons Learned
88
- - What went well? What went poorly?
89
- - What will you do differently next time?
90
- - What surprised you? What met expectations?
91
-
92
- **Example entry:**
93
- ```javascript
94
- save_context({
95
- kind: "insight",
96
- title: "Lesson: Async migration failed due to incomplete cleanup",
97
- body: `Migrated from sync to async event handlers. Thought we were careful, but missed:
98
- - One old listener still on the window that created a memory leak
99
- - Two components that expected synchronous behavior and broke
100
- - No rollback path, had to revert by hand
101
-
102
- Lessons:
103
- - Add integration tests for async behavior before migrating
104
- - Create a feature flag to roll back live if needed
105
- - Disable old listeners explicitly before adding new ones`,
106
- tags: ["bucket:web", "async", "migration", "gotcha"],
107
- encoding_context: { project: "web", arc: "event-system-v2", task: "async-migration" }
108
- })
109
- ```
110
-
111
- ### References Worth Keeping
112
- - Did you find a useful doc, guide, or tool?
113
- - Did you discover a library or utility worth bookmarking?
114
- - Did you implement something worth referencing later?
115
-
116
- **Example entry:**
117
- ```javascript
118
- save_context({
119
- kind: "reference",
120
- title: "PostgreSQL EXPLAIN ANALYZE guide",
121
- body: "https://www.postgresql.org/docs/current/sql-explain.html\n\nUse EXPLAIN ANALYZE to see actual vs planned query costs.",
122
- tags: ["database", "postgresql", "performance"],
123
- source: "postgresql.org"
124
- })
125
- ```
126
-
127
- ## Encoding Context: Future-Proof Your Saves
128
-
129
- Always include encoding context so Claude finds entries later, even if the topic changes:
130
-
131
- ```javascript
132
- encoding_context: {
133
- project: "autohub", // What project?
134
- arc: "api-redesign", // What arc?
135
- task: "oauth-flow", // What task?
136
- // Optional:
137
- date: "2026-03-31",
138
- blockers: ["waiting for API docs from vendor"]
139
- }
140
- ```
141
-
142
- Or as freetext:
143
- ```javascript
144
- encoding_context: "Was redesigning auth flow for mobile, ran into SQLite scaling limits"
145
- ```
146
-
147
- This context lets Claude retrieve your entry months later when starting a new auth project, even if you don't mention the old project name.
148
-
149
- ## Cross-Reference with Related Entries
150
-
151
- If your entry relates to existing vault entries, link them:
152
-
153
- ```javascript
154
- save_context({
155
- title: "OAuth 2.0 implementation",
156
- body: "...",
157
- related_to: ["database-choice-id", "auth-architecture-id"], // Link to other entries
158
- tags: ["bucket:autohub", "authentication"]
159
- })
160
- ```
161
-
162
- Then later, Claude can find related decisions by following these links.
163
-
164
- ## Deduplication: Check Before Saving
165
-
166
- Before saving, search for similar entries:
167
-
168
- ```javascript
169
- get_context({
170
- query: "OAuth implementation",
171
- buckets: ["autohub"],
172
- kind: "decision"
173
- })
174
- ```
175
-
176
- If you find a very similar entry (score > 0.85), **update it instead of duplicating:**
177
-
178
- ```javascript
179
- save_context({
180
- id: "existing-oauth-entry-id", // Reuse the ID
181
- body: "Updated implementation notes: ..."
182
- })
183
- ```
184
-
185
- Low-quality deduplication ruins recall ratio. Always check first.
186
-
187
- ## Bucket Scoping: Keep Entries Organized
188
-
189
- Always tag entries with their project bucket:
190
-
191
- ```javascript
192
- tags: ["bucket:autohub", "oauth"] // ✓ Scoped
193
- tags: ["oauth"] // ✗ Hard to find later
194
- ```
195
-
196
- When saving: Use bucket:projectname
197
- When retrieving: Use buckets: ["projectname"]
198
-
199
- ## Snapshot Creation: Consolidate Scattered Entries
200
-
201
- If you discovered 5+ related entries during this session, consolidate them into a snapshot:
202
-
203
- ```javascript
204
- create_snapshot({
205
- topic: "OAuth 2.0 flow in autohub",
206
- buckets: ["autohub"]
207
- })
208
- ```
209
-
210
- This creates a single brief that pulls together decisions, patterns, and lessons across all related entries. Much better for future sessions than searching for 5+ scattered entries.
211
-
212
- ## Workflow: End-of-Session Template
213
-
214
- Use this template at the end of each session:
215
-
216
- ```markdown
217
- ## Session End Capture
218
-
219
- **Project:** [Name]
220
- **Arc:** [Phase or focus area]
221
- **Date:** [YYYY-MM-DD]
222
-
223
- ### Decisions Made
224
- - [ ] ...
225
- - [ ] ...
226
-
227
- ### Insights Discovered
228
- - [ ] ...
229
- - [ ] ...
230
-
231
- ### Patterns Established
232
- - [ ] ...
233
- - [ ] ...
234
-
235
- ### Blockers / Next Steps
236
- - [ ] ...
237
- - [ ] ...
238
-
239
- ### Entries to Save
240
- 1. Decision: [Title]
241
- 2. Insight: [Title]
242
- 3. Pattern: [Title]
243
- ```
244
-
245
- For each item, save an entry to the vault using `save_context()`.
246
-
247
- ## Quick Example: Real Session End
248
-
249
- **End of session on OAuth implementation:**
250
-
251
- 1. **Decisions made:**
252
- - Chose Clerk (managed auth) over Auth0 (cost)
253
- - Decided to implement PKCE flow for mobile
254
-
255
- → Save 2 decision entries
256
-
257
- 2. **Insights discovered:**
258
- - Learned that PKCE requires custom state parameter handling in mobile SDK
259
- - Found that Clerk webhooks are eventually consistent (30s lag)
260
-
261
- → Save 2 insight entries
262
-
263
- 3. **Blockers:**
264
- - Waiting for vendor to whitelist our callback URLs
265
-
266
- → Save to task.md, not vault
267
-
268
- 4. **Lessons learned:**
269
- - Always test OAuth flow end-to-end with real device before production
270
-
271
- → Save 1 lesson entry
272
-
273
- 5. **References found:**
274
- - OAuth 2.0 PKCE spec
275
- - Clerk integration guide
276
-
277
- → Save 2 reference entries
278
-
279
- **Total:** 8 vault entries saved in 10 minutes. Future sessions will discover these automatically.
280
-
281
- ## When NOT to Save
282
-
283
- Skip the vault for:
284
- - Temporary debugging notes (save to session notes instead)
285
- - Task status updates (save to arc.md or task.md)
286
- - Exploratory dead ends (unless they're interesting gotchas)
287
- - Bulk raw data (use references or snapshots instead)
288
-
289
- The vault is for **persistent knowledge**, not task tracking.
290
-
291
- ## Tier Selection Guide
292
-
293
- When saving, choose a tier:
294
-
295
- | Situation | Tier |
296
- |-----------|------|
297
- | New decision we'll use for months | `durable` |
298
- | Current implementation insight | `working` |
299
- | Temporary session note | `ephemeral` (auto-expires in 30d) |
300
- | Architecture pattern we'll reference | `durable` |
301
- | Debugging discovery specific to this bug | `working` (or skip) |
302
-
303
- Default to `working` unless it's architecture or a decision you'll use for a long time.