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.
Files changed (82) hide show
  1. package/bin/cli.js +1369 -1774
  2. package/node_modules/@context-vault/core/dist/capture.d.ts +1 -1
  3. package/node_modules/@context-vault/core/dist/capture.d.ts.map +1 -1
  4. package/node_modules/@context-vault/core/dist/capture.js +34 -47
  5. package/node_modules/@context-vault/core/dist/capture.js.map +1 -1
  6. package/node_modules/@context-vault/core/dist/categories.js +30 -30
  7. package/node_modules/@context-vault/core/dist/config.d.ts +1 -1
  8. package/node_modules/@context-vault/core/dist/config.d.ts.map +1 -1
  9. package/node_modules/@context-vault/core/dist/config.js +37 -43
  10. package/node_modules/@context-vault/core/dist/config.js.map +1 -1
  11. package/node_modules/@context-vault/core/dist/constants.d.ts.map +1 -1
  12. package/node_modules/@context-vault/core/dist/constants.js +4 -4
  13. package/node_modules/@context-vault/core/dist/constants.js.map +1 -1
  14. package/node_modules/@context-vault/core/dist/db.d.ts +2 -2
  15. package/node_modules/@context-vault/core/dist/db.d.ts.map +1 -1
  16. package/node_modules/@context-vault/core/dist/db.js +21 -20
  17. package/node_modules/@context-vault/core/dist/db.js.map +1 -1
  18. package/node_modules/@context-vault/core/dist/embed.d.ts.map +1 -1
  19. package/node_modules/@context-vault/core/dist/embed.js +11 -11
  20. package/node_modules/@context-vault/core/dist/embed.js.map +1 -1
  21. package/node_modules/@context-vault/core/dist/files.d.ts.map +1 -1
  22. package/node_modules/@context-vault/core/dist/files.js +12 -13
  23. package/node_modules/@context-vault/core/dist/files.js.map +1 -1
  24. package/node_modules/@context-vault/core/dist/formatters.js +5 -5
  25. package/node_modules/@context-vault/core/dist/frontmatter.d.ts.map +1 -1
  26. package/node_modules/@context-vault/core/dist/frontmatter.js +23 -23
  27. package/node_modules/@context-vault/core/dist/frontmatter.js.map +1 -1
  28. package/node_modules/@context-vault/core/dist/index.d.ts +1 -1
  29. package/node_modules/@context-vault/core/dist/index.d.ts.map +1 -1
  30. package/node_modules/@context-vault/core/dist/index.js +58 -46
  31. package/node_modules/@context-vault/core/dist/index.js.map +1 -1
  32. package/node_modules/@context-vault/core/dist/ingest-url.d.ts.map +1 -1
  33. package/node_modules/@context-vault/core/dist/ingest-url.js +30 -33
  34. package/node_modules/@context-vault/core/dist/ingest-url.js.map +1 -1
  35. package/node_modules/@context-vault/core/dist/main.d.ts +13 -13
  36. package/node_modules/@context-vault/core/dist/main.d.ts.map +1 -1
  37. package/node_modules/@context-vault/core/dist/main.js +12 -12
  38. package/node_modules/@context-vault/core/dist/main.js.map +1 -1
  39. package/node_modules/@context-vault/core/dist/search.d.ts +1 -1
  40. package/node_modules/@context-vault/core/dist/search.d.ts.map +1 -1
  41. package/node_modules/@context-vault/core/dist/search.js +20 -22
  42. package/node_modules/@context-vault/core/dist/search.js.map +1 -1
  43. package/node_modules/@context-vault/core/dist/types.d.ts +1 -1
  44. package/node_modules/@context-vault/core/package.json +1 -1
  45. package/node_modules/@context-vault/core/src/capture.ts +44 -81
  46. package/node_modules/@context-vault/core/src/categories.ts +30 -30
  47. package/node_modules/@context-vault/core/src/config.ts +45 -60
  48. package/node_modules/@context-vault/core/src/constants.ts +8 -10
  49. package/node_modules/@context-vault/core/src/db.ts +37 -56
  50. package/node_modules/@context-vault/core/src/embed.ts +15 -26
  51. package/node_modules/@context-vault/core/src/files.ts +13 -16
  52. package/node_modules/@context-vault/core/src/formatters.ts +5 -5
  53. package/node_modules/@context-vault/core/src/frontmatter.ts +26 -30
  54. package/node_modules/@context-vault/core/src/index.ts +94 -100
  55. package/node_modules/@context-vault/core/src/ingest-url.ts +56 -93
  56. package/node_modules/@context-vault/core/src/main.ts +13 -18
  57. package/node_modules/@context-vault/core/src/search.ts +34 -56
  58. package/node_modules/@context-vault/core/src/types.ts +1 -1
  59. package/package.json +2 -2
  60. package/scripts/postinstall.js +18 -25
  61. package/scripts/prepack.js +13 -19
  62. package/src/archive.js +211 -0
  63. package/src/error-log.js +7 -7
  64. package/src/helpers.js +11 -13
  65. package/src/linking.js +8 -11
  66. package/src/migrate-dirs.js +139 -0
  67. package/src/register-tools.js +46 -48
  68. package/src/server.js +73 -99
  69. package/src/status.js +35 -71
  70. package/src/telemetry.js +18 -22
  71. package/src/temporal.js +19 -30
  72. package/src/tools/clear-context.js +15 -18
  73. package/src/tools/context-status.js +37 -57
  74. package/src/tools/create-snapshot.js +45 -57
  75. package/src/tools/delete-context.js +11 -12
  76. package/src/tools/get-context.js +112 -160
  77. package/src/tools/ingest-project.js +66 -86
  78. package/src/tools/ingest-url.js +25 -41
  79. package/src/tools/list-buckets.js +19 -25
  80. package/src/tools/list-context.js +35 -58
  81. package/src/tools/save-context.js +126 -182
  82. package/src/tools/session-start.js +46 -62
@@ -1,40 +1,22 @@
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";
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 = "list_context";
7
+ export const name = 'list_context';
8
8
 
9
9
  export const description =
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.";
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
- .string()
15
- .optional()
16
- .describe("Filter by kind (e.g. 'insight', 'decision', 'pattern')"),
17
- category: z
18
- .enum(["knowledge", "entity", "event"])
19
- .optional()
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 === "event" && !since && !until) {
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("kind = ?");
54
+ clauses.push('kind = ?');
74
55
  params.push(kindFilter);
75
56
  }
76
57
  if (category) {
77
- clauses.push("category = ?");
58
+ clauses.push('category = ?');
78
59
  params.push(category);
79
60
  }
80
61
  if (effectiveSince) {
81
- clauses.push("created_at >= ?");
62
+ clauses.push('created_at >= ?');
82
63
  params.push(effectiveSince);
83
64
  }
84
65
  if (until) {
85
- clauses.push("created_at <= ?");
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(" AND ")}` : "";
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
- "DB_ERROR",
114
- "context-vault list_context DB_ERROR. Check `cat ~/.context-mcp/error.log | tail -5` and help me debug.",
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("No entries found matching the given filters.");
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(", ") : "none";
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 || "(untitled)"}** [${r.kind}/${r.category}] — ${tagStr} — ${dateStr} — \`${r.id}\``,
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("\n"));
149
+ return ok(lines.join('\n'));
173
150
  }