context-vault 3.1.6 → 3.1.7
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/bin/cli.js +1369 -1774
- package/node_modules/@context-vault/core/dist/capture.d.ts +1 -1
- package/node_modules/@context-vault/core/dist/capture.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/capture.js +34 -47
- package/node_modules/@context-vault/core/dist/capture.js.map +1 -1
- package/node_modules/@context-vault/core/dist/categories.js +30 -30
- package/node_modules/@context-vault/core/dist/config.d.ts +1 -1
- package/node_modules/@context-vault/core/dist/config.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/config.js +37 -43
- package/node_modules/@context-vault/core/dist/config.js.map +1 -1
- package/node_modules/@context-vault/core/dist/constants.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/constants.js +4 -4
- package/node_modules/@context-vault/core/dist/constants.js.map +1 -1
- package/node_modules/@context-vault/core/dist/db.d.ts +2 -2
- package/node_modules/@context-vault/core/dist/db.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/db.js +21 -20
- package/node_modules/@context-vault/core/dist/db.js.map +1 -1
- package/node_modules/@context-vault/core/dist/embed.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/embed.js +11 -11
- package/node_modules/@context-vault/core/dist/embed.js.map +1 -1
- package/node_modules/@context-vault/core/dist/files.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/files.js +12 -13
- package/node_modules/@context-vault/core/dist/files.js.map +1 -1
- package/node_modules/@context-vault/core/dist/formatters.js +5 -5
- package/node_modules/@context-vault/core/dist/frontmatter.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/frontmatter.js +23 -23
- package/node_modules/@context-vault/core/dist/frontmatter.js.map +1 -1
- package/node_modules/@context-vault/core/dist/index.d.ts +1 -1
- package/node_modules/@context-vault/core/dist/index.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/index.js +58 -46
- package/node_modules/@context-vault/core/dist/index.js.map +1 -1
- package/node_modules/@context-vault/core/dist/ingest-url.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/ingest-url.js +30 -33
- package/node_modules/@context-vault/core/dist/ingest-url.js.map +1 -1
- package/node_modules/@context-vault/core/dist/main.d.ts +13 -13
- package/node_modules/@context-vault/core/dist/main.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/main.js +12 -12
- package/node_modules/@context-vault/core/dist/main.js.map +1 -1
- package/node_modules/@context-vault/core/dist/search.d.ts +1 -1
- package/node_modules/@context-vault/core/dist/search.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/search.js +20 -22
- package/node_modules/@context-vault/core/dist/search.js.map +1 -1
- package/node_modules/@context-vault/core/dist/types.d.ts +1 -1
- package/node_modules/@context-vault/core/package.json +1 -1
- package/node_modules/@context-vault/core/src/capture.ts +44 -81
- package/node_modules/@context-vault/core/src/categories.ts +30 -30
- package/node_modules/@context-vault/core/src/config.ts +45 -60
- package/node_modules/@context-vault/core/src/constants.ts +8 -10
- package/node_modules/@context-vault/core/src/db.ts +37 -56
- package/node_modules/@context-vault/core/src/embed.ts +15 -26
- package/node_modules/@context-vault/core/src/files.ts +13 -16
- package/node_modules/@context-vault/core/src/formatters.ts +5 -5
- package/node_modules/@context-vault/core/src/frontmatter.ts +26 -30
- package/node_modules/@context-vault/core/src/index.ts +94 -100
- package/node_modules/@context-vault/core/src/ingest-url.ts +56 -93
- package/node_modules/@context-vault/core/src/main.ts +13 -18
- package/node_modules/@context-vault/core/src/search.ts +34 -56
- package/node_modules/@context-vault/core/src/types.ts +1 -1
- package/package.json +2 -2
- package/scripts/postinstall.js +18 -25
- package/scripts/prepack.js +13 -19
- package/src/archive.js +211 -0
- package/src/error-log.js +7 -7
- package/src/helpers.js +11 -13
- package/src/linking.js +8 -11
- package/src/migrate-dirs.js +139 -0
- package/src/register-tools.js +46 -48
- package/src/server.js +73 -99
- package/src/status.js +35 -71
- package/src/telemetry.js +18 -22
- package/src/temporal.js +19 -30
- package/src/tools/clear-context.js +15 -18
- package/src/tools/context-status.js +37 -57
- package/src/tools/create-snapshot.js +45 -57
- package/src/tools/delete-context.js +11 -12
- package/src/tools/get-context.js +112 -160
- package/src/tools/ingest-project.js +66 -86
- package/src/tools/ingest-url.js +25 -41
- package/src/tools/list-buckets.js +19 -25
- package/src/tools/list-context.js +35 -58
- package/src/tools/save-context.js +126 -182
- package/src/tools/session-start.js +46 -62
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
import { normalizeKind } from
|
|
3
|
-
import { categoryFor } from
|
|
4
|
-
import { ok, err, errWithHint } from
|
|
5
|
-
import { resolveTemporalParams } from
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { normalizeKind } from '@context-vault/core/files';
|
|
3
|
+
import { categoryFor } from '@context-vault/core/categories';
|
|
4
|
+
import { ok, err, errWithHint } from '../helpers.js';
|
|
5
|
+
import { resolveTemporalParams } from '../temporal.js';
|
|
6
6
|
|
|
7
|
-
export const name =
|
|
7
|
+
export const name = 'list_context';
|
|
8
8
|
|
|
9
9
|
export const description =
|
|
10
|
-
|
|
10
|
+
'Browse vault entries without a search query. Returns id, title, kind, category, tags, created_at, updated_at. Use get_context with a query for semantic search. Use this to browse by tags or find recent entries.';
|
|
11
11
|
|
|
12
12
|
export const inputSchema = {
|
|
13
|
-
kind: z
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.describe("Filter by category"),
|
|
21
|
-
tags: z
|
|
22
|
-
.array(z.string())
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Filter by tags (entries must match at least one)"),
|
|
25
|
-
since: z
|
|
26
|
-
.string()
|
|
27
|
-
.optional()
|
|
28
|
-
.describe("ISO date, return entries created after this"),
|
|
29
|
-
until: z
|
|
30
|
-
.string()
|
|
31
|
-
.optional()
|
|
32
|
-
.describe("ISO date, return entries created before this"),
|
|
33
|
-
limit: z
|
|
34
|
-
.number()
|
|
35
|
-
.optional()
|
|
36
|
-
.describe("Max results to return (default 20, max 100)"),
|
|
37
|
-
offset: z.number().optional().describe("Skip first N results for pagination"),
|
|
13
|
+
kind: z.string().optional().describe("Filter by kind (e.g. 'insight', 'decision', 'pattern')"),
|
|
14
|
+
category: z.enum(['knowledge', 'entity', 'event']).optional().describe('Filter by category'),
|
|
15
|
+
tags: z.array(z.string()).optional().describe('Filter by tags (entries must match at least one)'),
|
|
16
|
+
since: z.string().optional().describe('ISO date, return entries created after this'),
|
|
17
|
+
until: z.string().optional().describe('ISO date, return entries created before this'),
|
|
18
|
+
limit: z.number().optional().describe('Max results to return (default 20, max 100)'),
|
|
19
|
+
offset: z.number().optional().describe('Skip first N results for pagination'),
|
|
38
20
|
};
|
|
39
21
|
|
|
40
22
|
/**
|
|
@@ -45,7 +27,7 @@ export const inputSchema = {
|
|
|
45
27
|
export async function handler(
|
|
46
28
|
{ kind, category, tags, since, until, limit, offset },
|
|
47
29
|
ctx,
|
|
48
|
-
{ ensureIndexed, reindexFailed }
|
|
30
|
+
{ ensureIndexed, reindexFailed }
|
|
49
31
|
) {
|
|
50
32
|
const { config } = ctx;
|
|
51
33
|
|
|
@@ -56,11 +38,10 @@ export async function handler(
|
|
|
56
38
|
until = resolved.until;
|
|
57
39
|
|
|
58
40
|
const kindFilter = kind ? normalizeKind(kind) : null;
|
|
59
|
-
const effectiveCategory =
|
|
60
|
-
category || (kindFilter ? categoryFor(kindFilter) : null);
|
|
41
|
+
const effectiveCategory = category || (kindFilter ? categoryFor(kindFilter) : null);
|
|
61
42
|
let effectiveSince = since || null;
|
|
62
43
|
let autoWindowed = false;
|
|
63
|
-
if (effectiveCategory ===
|
|
44
|
+
if (effectiveCategory === 'event' && !since && !until) {
|
|
64
45
|
const decayMs = (config.eventDecayDays || 30) * 86400000;
|
|
65
46
|
effectiveSince = new Date(Date.now() - decayMs).toISOString();
|
|
66
47
|
autoWindowed = true;
|
|
@@ -70,24 +51,24 @@ export async function handler(
|
|
|
70
51
|
const params = [];
|
|
71
52
|
|
|
72
53
|
if (kindFilter) {
|
|
73
|
-
clauses.push(
|
|
54
|
+
clauses.push('kind = ?');
|
|
74
55
|
params.push(kindFilter);
|
|
75
56
|
}
|
|
76
57
|
if (category) {
|
|
77
|
-
clauses.push(
|
|
58
|
+
clauses.push('category = ?');
|
|
78
59
|
params.push(category);
|
|
79
60
|
}
|
|
80
61
|
if (effectiveSince) {
|
|
81
|
-
clauses.push(
|
|
62
|
+
clauses.push('created_at >= ?');
|
|
82
63
|
params.push(effectiveSince);
|
|
83
64
|
}
|
|
84
65
|
if (until) {
|
|
85
|
-
clauses.push(
|
|
66
|
+
clauses.push('created_at <= ?');
|
|
86
67
|
params.push(until);
|
|
87
68
|
}
|
|
88
69
|
clauses.push("(expires_at IS NULL OR expires_at > datetime('now'))");
|
|
89
70
|
|
|
90
|
-
const where = clauses.length ? `WHERE ${clauses.join(
|
|
71
|
+
const where = clauses.length ? `WHERE ${clauses.join(' AND ')}` : '';
|
|
91
72
|
const effectiveLimit = Math.min(limit || 20, 100);
|
|
92
73
|
const effectiveOffset = offset || 0;
|
|
93
74
|
// When tag-filtering, over-fetch to compensate for post-filter reduction
|
|
@@ -97,21 +78,19 @@ export async function handler(
|
|
|
97
78
|
let total;
|
|
98
79
|
let rows;
|
|
99
80
|
try {
|
|
100
|
-
total = ctx.db
|
|
101
|
-
.prepare(`SELECT COUNT(*) as c FROM vault ${where}`)
|
|
102
|
-
.get(...countParams).c;
|
|
81
|
+
total = ctx.db.prepare(`SELECT COUNT(*) as c FROM vault ${where}`).get(...countParams).c;
|
|
103
82
|
|
|
104
83
|
params.push(fetchLimit, effectiveOffset);
|
|
105
84
|
rows = ctx.db
|
|
106
85
|
.prepare(
|
|
107
|
-
`SELECT id, title, kind, category, tags, created_at, updated_at, SUBSTR(body, 1, 120) as preview FROM vault ${where} ORDER BY created_at DESC LIMIT ? OFFSET
|
|
86
|
+
`SELECT id, title, kind, category, tags, created_at, updated_at, SUBSTR(body, 1, 120) as preview FROM vault ${where} ORDER BY created_at DESC LIMIT ? OFFSET ?`
|
|
108
87
|
)
|
|
109
88
|
.all(...params);
|
|
110
89
|
} catch (e) {
|
|
111
90
|
return errWithHint(
|
|
112
91
|
e.message,
|
|
113
|
-
|
|
114
|
-
|
|
92
|
+
'DB_ERROR',
|
|
93
|
+
'context-vault list_context DB_ERROR. Check `cat ~/.context-mcp/error.log | tail -5` and help me debug.'
|
|
115
94
|
);
|
|
116
95
|
}
|
|
117
96
|
|
|
@@ -129,45 +108,43 @@ export async function handler(
|
|
|
129
108
|
if (autoWindowed) {
|
|
130
109
|
const days = config.eventDecayDays || 30;
|
|
131
110
|
return ok(
|
|
132
|
-
`No entries found matching the given filters in events (last ${days} days).\nTry with \`since: "YYYY-MM-DD"\` to search older events
|
|
111
|
+
`No entries found matching the given filters in events (last ${days} days).\nTry with \`since: "YYYY-MM-DD"\` to search older events.`
|
|
133
112
|
);
|
|
134
113
|
}
|
|
135
|
-
return ok(
|
|
114
|
+
return ok('No entries found matching the given filters.');
|
|
136
115
|
}
|
|
137
116
|
|
|
138
117
|
const lines = [];
|
|
139
118
|
if (reindexFailed)
|
|
140
119
|
lines.push(
|
|
141
|
-
`> **Warning:** Auto-reindex failed. Results may be stale. Run \`context-vault reindex\` to fix.\n
|
|
120
|
+
`> **Warning:** Auto-reindex failed. Results may be stale. Run \`context-vault reindex\` to fix.\n`
|
|
142
121
|
);
|
|
143
122
|
lines.push(`## Vault Entries (${filtered.length} shown, ${total} total)\n`);
|
|
144
123
|
if (autoWindowed) {
|
|
145
124
|
const days = config.eventDecayDays || 30;
|
|
146
125
|
lines.push(
|
|
147
|
-
`> ℹ Event search limited to last ${days} days. Use \`since\` parameter for older results.\n
|
|
126
|
+
`> ℹ Event search limited to last ${days} days. Use \`since\` parameter for older results.\n`
|
|
148
127
|
);
|
|
149
128
|
}
|
|
150
129
|
for (const r of filtered) {
|
|
151
130
|
const entryTags = r.tags ? JSON.parse(r.tags) : [];
|
|
152
|
-
const tagStr = entryTags.length ? entryTags.join(
|
|
131
|
+
const tagStr = entryTags.length ? entryTags.join(', ') : 'none';
|
|
153
132
|
const dateStr =
|
|
154
133
|
r.updated_at && r.updated_at !== r.created_at
|
|
155
134
|
? `${r.created_at} (updated ${r.updated_at})`
|
|
156
135
|
: r.created_at;
|
|
157
136
|
lines.push(
|
|
158
|
-
`- **${r.title ||
|
|
137
|
+
`- **${r.title || '(untitled)'}** [${r.kind}/${r.category}] — ${tagStr} — ${dateStr} — \`${r.id}\``
|
|
159
138
|
);
|
|
160
139
|
if (r.preview)
|
|
161
|
-
lines.push(
|
|
162
|
-
` ${r.preview.replace(/\n+/g, " ").trim()}${r.preview.length >= 120 ? "…" : ""}`,
|
|
163
|
-
);
|
|
140
|
+
lines.push(` ${r.preview.replace(/\n+/g, ' ').trim()}${r.preview.length >= 120 ? '…' : ''}`);
|
|
164
141
|
}
|
|
165
142
|
|
|
166
143
|
if (effectiveOffset + effectiveLimit < total) {
|
|
167
144
|
lines.push(
|
|
168
|
-
`\n_Page ${Math.floor(effectiveOffset / effectiveLimit) + 1}. Use offset: ${effectiveOffset + effectiveLimit} for next page._
|
|
145
|
+
`\n_Page ${Math.floor(effectiveOffset / effectiveLimit) + 1}. Use offset: ${effectiveOffset + effectiveLimit} for next page._`
|
|
169
146
|
);
|
|
170
147
|
}
|
|
171
148
|
|
|
172
|
-
return ok(lines.join(
|
|
149
|
+
return ok(lines.join('\n'));
|
|
173
150
|
}
|