context-vault 3.1.7 → 3.1.8
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 +11 -11
- package/dist/archive.d.ts +23 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +197 -0
- package/dist/archive.js.map +1 -0
- package/dist/consolidation.d.ts +14 -0
- package/dist/consolidation.d.ts.map +1 -0
- package/dist/consolidation.js +59 -0
- package/dist/consolidation.js.map +1 -0
- package/dist/error-log.d.ts +4 -0
- package/dist/error-log.d.ts.map +1 -0
- package/dist/error-log.js +33 -0
- package/dist/error-log.js.map +1 -0
- package/dist/helpers.d.ts +10 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +42 -0
- package/dist/helpers.js.map +1 -0
- package/dist/linking.d.ts +13 -0
- package/dist/linking.d.ts.map +1 -0
- package/dist/linking.js +86 -0
- package/dist/linking.js.map +1 -0
- package/dist/migrate-dirs.d.ts +16 -0
- package/dist/migrate-dirs.d.ts.map +1 -0
- package/dist/migrate-dirs.js +127 -0
- package/dist/migrate-dirs.js.map +1 -0
- package/dist/register-tools.d.ts +3 -0
- package/dist/register-tools.d.ts.map +1 -0
- package/dist/register-tools.js +161 -0
- package/dist/register-tools.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +241 -0
- package/dist/server.js.map +1 -0
- package/dist/status.d.ts +18 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +265 -0
- package/dist/status.js.map +1 -0
- package/dist/telemetry.d.ts +6 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +74 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/temporal.d.ts +9 -0
- package/dist/temporal.d.ts.map +1 -0
- package/dist/temporal.js +76 -0
- package/dist/temporal.js.map +1 -0
- package/dist/tools/clear-context.d.ts +11 -0
- package/dist/tools/clear-context.d.ts.map +1 -0
- package/dist/tools/clear-context.js +28 -0
- package/dist/tools/clear-context.js.map +1 -0
- package/dist/tools/context-status.d.ts +6 -0
- package/dist/tools/context-status.d.ts.map +1 -0
- package/dist/tools/context-status.js +160 -0
- package/dist/tools/context-status.js.map +1 -0
- package/dist/tools/create-snapshot.d.ts +13 -0
- package/dist/tools/create-snapshot.d.ts.map +1 -0
- package/dist/tools/create-snapshot.js +161 -0
- package/dist/tools/create-snapshot.js.map +1 -0
- package/dist/tools/delete-context.d.ts +9 -0
- package/dist/tools/delete-context.d.ts.map +1 -0
- package/dist/tools/delete-context.js +45 -0
- package/dist/tools/delete-context.js.map +1 -0
- package/dist/tools/get-context.d.ts +85 -0
- package/dist/tools/get-context.d.ts.map +1 -0
- package/dist/tools/get-context.js +576 -0
- package/dist/tools/get-context.js.map +1 -0
- package/dist/tools/ingest-project.d.ts +11 -0
- package/dist/tools/ingest-project.d.ts.map +1 -0
- package/dist/tools/ingest-project.js +226 -0
- package/dist/tools/ingest-project.js.map +1 -0
- package/dist/tools/ingest-url.d.ts +11 -0
- package/dist/tools/ingest-url.d.ts.map +1 -0
- package/dist/tools/ingest-url.js +62 -0
- package/dist/tools/ingest-url.js.map +1 -0
- package/dist/tools/list-buckets.d.ts +9 -0
- package/dist/tools/list-buckets.d.ts.map +1 -0
- package/dist/tools/list-buckets.js +76 -0
- package/dist/tools/list-buckets.js.map +1 -0
- package/dist/tools/list-context.d.ts +19 -0
- package/dist/tools/list-context.d.ts.map +1 -0
- package/dist/tools/list-context.js +110 -0
- package/dist/tools/list-context.js.map +1 -0
- package/dist/tools/save-context.d.ts +36 -0
- package/dist/tools/save-context.d.ts.map +1 -0
- package/dist/tools/save-context.js +458 -0
- package/dist/tools/save-context.js.map +1 -0
- package/dist/tools/session-start.d.ts +11 -0
- package/dist/tools/session-start.d.ts.map +1 -0
- package/dist/tools/session-start.js +224 -0
- package/dist/tools/session-start.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/node_modules/@context-vault/core/dist/constants.d.ts +1 -1
- package/node_modules/@context-vault/core/dist/constants.d.ts.map +1 -1
- package/node_modules/@context-vault/core/dist/constants.js +1 -1
- package/node_modules/@context-vault/core/dist/constants.js.map +1 -1
- package/node_modules/@context-vault/core/package.json +1 -1
- package/node_modules/@context-vault/core/src/constants.ts +1 -1
- package/package.json +10 -4
- package/src/{archive.js → archive.ts} +63 -30
- package/src/consolidation.ts +78 -0
- package/src/{error-log.js → error-log.ts} +3 -3
- package/src/{helpers.js → helpers.ts} +11 -5
- package/src/{linking.js → linking.ts} +14 -9
- package/src/{migrate-dirs.js → migrate-dirs.ts} +21 -8
- package/src/{register-tools.js → register-tools.ts} +21 -11
- package/src/{server.js → server.ts} +26 -20
- package/src/{status.js → status.ts} +60 -38
- package/src/{telemetry.js → telemetry.ts} +8 -4
- package/src/{temporal.js → temporal.ts} +10 -3
- package/src/tools/{clear-context.js → clear-context.ts} +2 -5
- package/src/tools/{context-status.js → context-status.ts} +6 -9
- package/src/tools/{create-snapshot.js → create-snapshot.ts} +11 -10
- package/src/tools/{delete-context.js → delete-context.ts} +9 -9
- package/src/tools/{get-context.js → get-context.ts} +39 -54
- package/src/tools/{ingest-project.js → ingest-project.ts} +19 -11
- package/src/tools/{ingest-url.js → ingest-url.ts} +11 -8
- package/src/tools/{list-buckets.js → list-buckets.ts} +11 -15
- package/src/tools/{list-context.js → list-context.ts} +13 -15
- package/src/tools/{save-context.js → save-context.ts} +42 -42
- package/src/tools/{session-start.js → session-start.ts} +29 -20
- package/src/types.ts +29 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { gatherVaultStatus, computeGrowthWarnings } from '../status.js';
|
|
4
|
+
import { errorLogPath, errorLogCount } from '../error-log.js';
|
|
5
|
+
import { ok, err } from '../helpers.js';
|
|
6
|
+
function relativeTime(ts) {
|
|
7
|
+
const secs = Math.floor((Date.now() - ts) / 1000);
|
|
8
|
+
if (secs < 60)
|
|
9
|
+
return `${secs}s ago`;
|
|
10
|
+
const mins = Math.floor(secs / 60);
|
|
11
|
+
if (mins < 60)
|
|
12
|
+
return `${mins} minute${mins === 1 ? '' : 's'} ago`;
|
|
13
|
+
const hrs = Math.floor(mins / 60);
|
|
14
|
+
return `${hrs} hour${hrs === 1 ? '' : 's'} ago`;
|
|
15
|
+
}
|
|
16
|
+
export const name = 'context_status';
|
|
17
|
+
export const description = 'Show vault health: resolved config, file counts per kind, database size, and any issues. Use to verify setup or troubleshoot. Call this when a user asks about their vault or to debug search issues.';
|
|
18
|
+
export const inputSchema = {};
|
|
19
|
+
export function handler(_args, ctx) {
|
|
20
|
+
try {
|
|
21
|
+
const { config } = ctx;
|
|
22
|
+
const status = gatherVaultStatus(ctx);
|
|
23
|
+
const hasIssues = status.stalePaths || (status.embeddingStatus?.missing ?? 0) > 0;
|
|
24
|
+
const healthIcon = hasIssues ? '⚠' : '✓';
|
|
25
|
+
const lines = [
|
|
26
|
+
`## ${healthIcon} Vault Status (connected)`,
|
|
27
|
+
``,
|
|
28
|
+
`Vault: ${config.vaultDir} (${config.vaultDirExists ? status.fileCount + ' files' : 'missing'})`,
|
|
29
|
+
`Database: ${config.dbPath} (${status.dbSize})`,
|
|
30
|
+
`Dev dir: ${config.devDir}`,
|
|
31
|
+
`Data dir: ${config.dataDir}`,
|
|
32
|
+
`Config: ${config.configPath}`,
|
|
33
|
+
`Resolved via: ${status.resolvedFrom}`,
|
|
34
|
+
`Schema: v9 (updated_at, superseded_by)`,
|
|
35
|
+
];
|
|
36
|
+
if (status.embeddingStatus) {
|
|
37
|
+
const { indexed, total, missing } = status.embeddingStatus;
|
|
38
|
+
const pct = total > 0 ? Math.round((indexed / total) * 100) : 100;
|
|
39
|
+
lines.push(`Embeddings: ${indexed}/${total} (${pct}%)`);
|
|
40
|
+
}
|
|
41
|
+
if (status.embedModelAvailable === false) {
|
|
42
|
+
lines.push(`Embed model: unavailable (semantic search disabled, FTS still works)`);
|
|
43
|
+
}
|
|
44
|
+
else if (status.embedModelAvailable === true) {
|
|
45
|
+
lines.push(`Embed model: loaded`);
|
|
46
|
+
}
|
|
47
|
+
lines.push(`Decay: ${config.eventDecayDays} days (event recency window)`);
|
|
48
|
+
if (status.expiredCount > 0) {
|
|
49
|
+
lines.push(`Expired: ${status.expiredCount} entries pending prune (run \`context-vault prune\` to remove now)`);
|
|
50
|
+
}
|
|
51
|
+
lines.push(``, `### Indexed`);
|
|
52
|
+
if (status.kindCounts.length) {
|
|
53
|
+
for (const { kind, c } of status.kindCounts)
|
|
54
|
+
lines.push(`- ${c} ${kind}s`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
lines.push(`- (empty)`);
|
|
58
|
+
}
|
|
59
|
+
if (status.categoryCounts.length) {
|
|
60
|
+
lines.push(``);
|
|
61
|
+
lines.push(`### Categories`);
|
|
62
|
+
for (const { category, c } of status.categoryCounts)
|
|
63
|
+
lines.push(`- ${category}: ${c}`);
|
|
64
|
+
}
|
|
65
|
+
if (status.subdirs.length) {
|
|
66
|
+
lines.push(``);
|
|
67
|
+
lines.push(`### Disk Directories`);
|
|
68
|
+
for (const { name, count } of status.subdirs)
|
|
69
|
+
lines.push(`- ${name}/: ${count} files`);
|
|
70
|
+
}
|
|
71
|
+
if (status.stalePaths) {
|
|
72
|
+
lines.push(``);
|
|
73
|
+
lines.push(`### ⚠ Stale Paths`);
|
|
74
|
+
lines.push(`DB contains ${status.staleCount} paths not matching current vault dir.`);
|
|
75
|
+
lines.push(`Auto-reindex will fix this on next search or save.`);
|
|
76
|
+
}
|
|
77
|
+
if (status.staleKnowledge?.length > 0) {
|
|
78
|
+
lines.push(``);
|
|
79
|
+
lines.push(`### ⚠ Potentially Stale Knowledge`);
|
|
80
|
+
lines.push(`Not updated within kind staleness window (pattern: 180d, decision: 365d, reference: 90d):`);
|
|
81
|
+
for (const entry of status.staleKnowledge) {
|
|
82
|
+
const lastUpdated = entry.last_updated ? entry.last_updated.split('T')[0] : 'unknown';
|
|
83
|
+
lines.push(`- "${entry.title}" (${entry.kind}) — last updated ${lastUpdated}`);
|
|
84
|
+
}
|
|
85
|
+
lines.push(`Use save_context to refresh or add expires_at to retire stale entries.`);
|
|
86
|
+
}
|
|
87
|
+
// Error log
|
|
88
|
+
const logPath = errorLogPath(config.dataDir);
|
|
89
|
+
const logCount = errorLogCount(config.dataDir);
|
|
90
|
+
if (logCount > 0) {
|
|
91
|
+
lines.push(``, `### Startup Error Log`);
|
|
92
|
+
lines.push(`- Path: ${logPath}`);
|
|
93
|
+
lines.push(`- Entries: ${logCount} (share this file for support)`);
|
|
94
|
+
}
|
|
95
|
+
// Last startup error
|
|
96
|
+
const lastErrorPath = join(config.dataDir, '.last-error');
|
|
97
|
+
if (existsSync(lastErrorPath)) {
|
|
98
|
+
try {
|
|
99
|
+
const lastError = readFileSync(lastErrorPath, 'utf-8').trim();
|
|
100
|
+
lines.push(``, `### Last Startup Error`);
|
|
101
|
+
lines.push(`\`\`\``);
|
|
102
|
+
lines.push(lastError);
|
|
103
|
+
lines.push(`\`\`\``);
|
|
104
|
+
}
|
|
105
|
+
catch { }
|
|
106
|
+
}
|
|
107
|
+
// Health: session-level tool call stats
|
|
108
|
+
const ts = ctx.toolStats;
|
|
109
|
+
if (ts) {
|
|
110
|
+
lines.push(``, `### Health`);
|
|
111
|
+
lines.push(`- Tool calls (session): ${ts.ok} ok, ${ts.errors} errors`);
|
|
112
|
+
if (ts.lastError) {
|
|
113
|
+
const { tool, code, timestamp } = ts.lastError;
|
|
114
|
+
lines.push(`- Last error: ${tool ?? 'unknown'} — ${code} (${relativeTime(timestamp)})`);
|
|
115
|
+
}
|
|
116
|
+
if (status.autoCapturedFeedbackCount > 0) {
|
|
117
|
+
lines.push(`- Auto-captured feedback entries: ${status.autoCapturedFeedbackCount} (run get_context with kind:feedback tags:auto-captured)`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Growth warnings
|
|
121
|
+
const growth = computeGrowthWarnings(status, config.thresholds);
|
|
122
|
+
if (growth.hasWarnings) {
|
|
123
|
+
lines.push('', '### ⚠ Vault Growth Warning');
|
|
124
|
+
for (const w of growth.warnings) {
|
|
125
|
+
lines.push(` ${w.message}`);
|
|
126
|
+
}
|
|
127
|
+
if (growth.kindBreakdown.length) {
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push(' Breakdown by kind:');
|
|
130
|
+
for (const { kind, count, pct } of growth.kindBreakdown) {
|
|
131
|
+
lines.push(` ${kind}: ${count.toLocaleString()} (${pct}%)`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (growth.actions.length) {
|
|
135
|
+
lines.push('', 'Suggested growth actions:');
|
|
136
|
+
for (const a of growth.actions) {
|
|
137
|
+
lines.push(` • ${a}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Suggested actions
|
|
142
|
+
const actions = [];
|
|
143
|
+
if (status.stalePaths)
|
|
144
|
+
actions.push('- Run `context-vault reindex` to fix stale paths');
|
|
145
|
+
if ((status.embeddingStatus?.missing ?? 0) > 0)
|
|
146
|
+
actions.push('- Run `context-vault reindex` to generate missing embeddings');
|
|
147
|
+
if (!config.vaultDirExists)
|
|
148
|
+
actions.push('- Run `context-vault setup` to create the vault directory');
|
|
149
|
+
if (status.kindCounts.length === 0 && config.vaultDirExists)
|
|
150
|
+
actions.push('- Use `save_context` to add your first entry');
|
|
151
|
+
if (actions.length) {
|
|
152
|
+
lines.push('', '### Suggested Actions', ...actions);
|
|
153
|
+
}
|
|
154
|
+
return ok(lines.join('\n'));
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
return err(e instanceof Error ? e.message : String(e), 'STATUS_FAILED');
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=context-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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AM,CAAC,eAAe,EAAE,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,CAAC,cAAc;YACxB,OAAO,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QAC5E,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,cAAc;YACzD,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAE/D,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LocalCtx, SharedCtx, ToolResult } from '../types.js';
|
|
3
|
+
export declare const name = "create_snapshot";
|
|
4
|
+
export declare const description = "Pull all relevant vault entries matching a topic, deduplicate, and save them as a structured context brief (kind: 'brief'). Entries are formatted as markdown \u2014 no external API or LLM call required. The calling agent can synthesize the gathered content directly. Retrieve with: get_context(kind: 'brief', identity_key: '<key>').";
|
|
5
|
+
export declare const inputSchema: {
|
|
6
|
+
topic: z.ZodString;
|
|
7
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
buckets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
kinds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
identity_key: z.ZodOptional<z.ZodString>;
|
|
11
|
+
};
|
|
12
|
+
export declare function handler({ topic, tags, buckets, kinds, identity_key }: Record<string, any>, ctx: LocalCtx, { ensureIndexed }: SharedCtx): Promise<ToolResult>;
|
|
13
|
+
//# sourceMappingURL=create-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/create-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMnE,eAAO,MAAM,IAAI,oBAAoB,CAAC;AAEtC,eAAO,MAAM,WAAW,iVACmT,CAAC;AAE5U,eAAO,MAAM,WAAW;;;;;;CAsBvB,CAAC;AA+CF,wBAAsB,OAAO,CAC3B,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAClE,GAAG,EAAE,QAAQ,EACb,EAAE,aAAa,EAAE,EAAE,SAAS,GAC3B,OAAO,CAAC,UAAU,CAAC,CA2GrB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { hybridSearch } from '@context-vault/core/search';
|
|
3
|
+
import { captureAndIndex } from '@context-vault/core/capture';
|
|
4
|
+
import { normalizeKind } from '@context-vault/core/files';
|
|
5
|
+
import { ok, err, ensureVaultExists } from '../helpers.js';
|
|
6
|
+
const NOISE_KINDS = new Set(['prompt-history', 'task-notification']);
|
|
7
|
+
const MAX_ENTRIES_FOR_GATHER = 40;
|
|
8
|
+
const MAX_BODY_PER_ENTRY = 600;
|
|
9
|
+
export const name = 'create_snapshot';
|
|
10
|
+
export const description = "Pull all relevant vault entries matching a topic, deduplicate, and save them as a structured context brief (kind: 'brief'). Entries are formatted as markdown — no external API or LLM call required. The calling agent can synthesize the gathered content directly. Retrieve with: get_context(kind: 'brief', identity_key: '<key>').";
|
|
11
|
+
export const inputSchema = {
|
|
12
|
+
topic: z.string().describe('The topic or project name to snapshot'),
|
|
13
|
+
tags: z
|
|
14
|
+
.array(z.string())
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Optional tag filters — entries must match at least one'),
|
|
17
|
+
buckets: z
|
|
18
|
+
.array(z.string())
|
|
19
|
+
.optional()
|
|
20
|
+
.describe("Filter by project-scoped buckets. Each name expands to a 'bucket:<name>' tag. Composes with 'tags' via OR (entries matching any tag or any bucket are included)."),
|
|
21
|
+
kinds: z
|
|
22
|
+
.array(z.string())
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Optional kind filters to restrict which entry types are pulled'),
|
|
25
|
+
identity_key: z
|
|
26
|
+
.string()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Deterministic key for the saved brief (defaults to slugified topic). Use the same key to overwrite a previous snapshot.'),
|
|
29
|
+
};
|
|
30
|
+
function formatGatheredEntries(topic, entries) {
|
|
31
|
+
const header = [
|
|
32
|
+
`# ${topic} — Context Brief`,
|
|
33
|
+
'',
|
|
34
|
+
`*Gathered from ${entries.length} vault ${entries.length === 1 ? 'entry' : 'entries'}. Synthesize the content below to extract key decisions, patterns, and constraints.*`,
|
|
35
|
+
'',
|
|
36
|
+
'---',
|
|
37
|
+
'',
|
|
38
|
+
].join('\n');
|
|
39
|
+
const body = entries
|
|
40
|
+
.map((e, i) => {
|
|
41
|
+
const tags = e.tags ? JSON.parse(e.tags) : [];
|
|
42
|
+
const tagStr = tags.length ? tags.join(', ') : 'none';
|
|
43
|
+
const updated = e.updated_at || e.created_at || 'unknown';
|
|
44
|
+
const bodyText = e.body
|
|
45
|
+
? e.body.slice(0, MAX_BODY_PER_ENTRY) + (e.body.length > MAX_BODY_PER_ENTRY ? '…' : '')
|
|
46
|
+
: '(no body)';
|
|
47
|
+
const title = e.title || `Entry ${i + 1}`;
|
|
48
|
+
return [
|
|
49
|
+
`## ${i + 1}. [${e.kind}] ${title}`,
|
|
50
|
+
'',
|
|
51
|
+
`**Tags:** ${tagStr}`,
|
|
52
|
+
`**Updated:** ${updated}`,
|
|
53
|
+
`**ID:** \`${e.id}\``,
|
|
54
|
+
'',
|
|
55
|
+
bodyText,
|
|
56
|
+
'',
|
|
57
|
+
'---',
|
|
58
|
+
'',
|
|
59
|
+
].join('\n');
|
|
60
|
+
})
|
|
61
|
+
.join('');
|
|
62
|
+
return header + body;
|
|
63
|
+
}
|
|
64
|
+
function slugifyTopic(topic) {
|
|
65
|
+
return topic
|
|
66
|
+
.toLowerCase()
|
|
67
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
68
|
+
.replace(/^-+|-+$/g, '')
|
|
69
|
+
.slice(0, 120);
|
|
70
|
+
}
|
|
71
|
+
export async function handler({ topic, tags, buckets, kinds, identity_key }, ctx, { ensureIndexed }) {
|
|
72
|
+
const { config } = ctx;
|
|
73
|
+
const vaultErr = ensureVaultExists(config);
|
|
74
|
+
if (vaultErr)
|
|
75
|
+
return vaultErr;
|
|
76
|
+
if (!topic?.trim()) {
|
|
77
|
+
return err('Required: topic (non-empty string)', 'INVALID_INPUT');
|
|
78
|
+
}
|
|
79
|
+
await ensureIndexed();
|
|
80
|
+
const normalizedKinds = kinds?.map(normalizeKind) ?? [];
|
|
81
|
+
const bucketTags = buckets?.length ? buckets.map((b) => `bucket:${b}`) : [];
|
|
82
|
+
const effectiveTags = [...(tags ?? []), ...bucketTags];
|
|
83
|
+
let candidates = [];
|
|
84
|
+
try {
|
|
85
|
+
if (normalizedKinds.length > 0) {
|
|
86
|
+
for (const kindFilter of normalizedKinds) {
|
|
87
|
+
const rows = await hybridSearch(ctx, topic, {
|
|
88
|
+
kindFilter,
|
|
89
|
+
limit: Math.ceil(MAX_ENTRIES_FOR_GATHER / normalizedKinds.length),
|
|
90
|
+
includeSuperseeded: false,
|
|
91
|
+
});
|
|
92
|
+
candidates.push(...rows);
|
|
93
|
+
}
|
|
94
|
+
const seen = new Set();
|
|
95
|
+
candidates = candidates.filter((r) => {
|
|
96
|
+
if (seen.has(r.id))
|
|
97
|
+
return false;
|
|
98
|
+
seen.add(r.id);
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
candidates = await hybridSearch(ctx, topic, {
|
|
104
|
+
limit: MAX_ENTRIES_FOR_GATHER,
|
|
105
|
+
includeSuperseeded: false,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
return err(e instanceof Error ? e.message : String(e), 'SEARCH_FAILED');
|
|
111
|
+
}
|
|
112
|
+
if (effectiveTags.length) {
|
|
113
|
+
candidates = candidates.filter((r) => {
|
|
114
|
+
const entryTags = r.tags ? JSON.parse(r.tags) : [];
|
|
115
|
+
return effectiveTags.some((t) => entryTags.includes(t));
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const noiseIds = candidates.filter((r) => NOISE_KINDS.has(r.kind)).map((r) => r.id);
|
|
119
|
+
const gatherEntries = candidates.filter((r) => !NOISE_KINDS.has(r.kind));
|
|
120
|
+
if (gatherEntries.length === 0) {
|
|
121
|
+
return err(`No entries found for topic "${topic}". Try a broader topic or different tags.`, 'NO_ENTRIES');
|
|
122
|
+
}
|
|
123
|
+
const briefBody = formatGatheredEntries(topic, gatherEntries);
|
|
124
|
+
const effectiveIdentityKey = identity_key ?? `snapshot-${slugifyTopic(topic)}`;
|
|
125
|
+
const briefTags = ['snapshot', ...(tags ?? []), ...(normalizedKinds.length > 0 ? [] : [])];
|
|
126
|
+
const supersedes = noiseIds.length > 0 ? noiseIds : undefined;
|
|
127
|
+
let entry;
|
|
128
|
+
try {
|
|
129
|
+
entry = await captureAndIndex(ctx, {
|
|
130
|
+
kind: 'brief',
|
|
131
|
+
title: `${topic} — Context Brief`,
|
|
132
|
+
body: briefBody,
|
|
133
|
+
tags: briefTags,
|
|
134
|
+
source: 'create_snapshot',
|
|
135
|
+
identity_key: effectiveIdentityKey,
|
|
136
|
+
supersedes,
|
|
137
|
+
meta: {
|
|
138
|
+
topic,
|
|
139
|
+
entry_count: gatherEntries.length,
|
|
140
|
+
noise_superseded: noiseIds.length,
|
|
141
|
+
synthesized_from: gatherEntries.map((e) => e.id),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
return err(e instanceof Error ? e.message : String(e), 'SAVE_FAILED');
|
|
147
|
+
}
|
|
148
|
+
const parts = [
|
|
149
|
+
`✓ Snapshot created → id: ${entry.id}`,
|
|
150
|
+
` title: ${entry.title}`,
|
|
151
|
+
` identity_key: ${effectiveIdentityKey}`,
|
|
152
|
+
` synthesized from: ${gatherEntries.length} entries`,
|
|
153
|
+
noiseIds.length > 0 ? ` noise superseded: ${noiseIds.length} entries` : null,
|
|
154
|
+
'',
|
|
155
|
+
"_Retrieve with: get_context(kind: 'brief', identity_key: '" + effectiveIdentityKey + "')_",
|
|
156
|
+
]
|
|
157
|
+
.filter((l) => l !== null)
|
|
158
|
+
.join('\n');
|
|
159
|
+
return ok(parts);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=create-snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-snapshot.js","sourceRoot":"","sources":["../../src/tools/create-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAG3D,MAAM,WAAW,G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E,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACjD;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,KAAK,GAAG;QACZ,4BAA4B,KAAK,CAAC,EAAE,EAAE;QACtC,YAAY,KAAK,CAAC,KAAK,EAAE;QACzB,mBAAmB,oBAAoB,EAAE;QACzC,uBAAuB,aAAa,CAAC,MAAM,UAAU;QACrD,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,uBAAuB,QAAQ,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,IAAI;QAC7E,EAAE;QACF,4DAA4D,GAAG,oBAAoB,GAAG,KAAK;KAC5F;SACE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LocalCtx, SharedCtx, ToolResult } from '../types.js';
|
|
3
|
+
export declare const name = "delete_context";
|
|
4
|
+
export declare const description = "Delete an entry from your vault by its ULID id. Removes the file from disk and cleans up the search index.";
|
|
5
|
+
export declare const inputSchema: {
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler({ id }: Record<string, any>, ctx: LocalCtx, { ensureIndexed }: SharedCtx): Promise<ToolResult>;
|
|
9
|
+
//# sourceMappingURL=delete-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-context.d.ts","sourceRoot":"","sources":["../../src/tools/delete-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEnE,eAAO,MAAM,IAAI,mBAAmB,CAAC;AAErC,eAAO,MAAM,WAAW,+GACsF,CAAC;AAE/G,eAAO,MAAM,WAAW;;CAEvB,CAAC;AAEF,wBAAsB,OAAO,CAC3B,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,GAAG,EAAE,QAAQ,EACb,EAAE,aAAa,EAAE,EAAE,SAAS,GAC3B,OAAO,CAAC,UAAU,CAAC,CAkCrB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { unlinkSync } from 'node:fs';
|
|
3
|
+
import { ok, err } from '../helpers.js';
|
|
4
|
+
export const name = 'delete_context';
|
|
5
|
+
export const description = 'Delete an entry from your vault by its ULID id. Removes the file from disk and cleans up the search index.';
|
|
6
|
+
export const inputSchema = {
|
|
7
|
+
id: z.string().describe('The entry ULID to delete'),
|
|
8
|
+
};
|
|
9
|
+
export async function handler({ id }, ctx, { ensureIndexed }) {
|
|
10
|
+
if (!id?.trim())
|
|
11
|
+
return err('Required: id (non-empty string)', 'INVALID_INPUT');
|
|
12
|
+
await ensureIndexed();
|
|
13
|
+
const entry = ctx.stmts.getEntryById.get(id);
|
|
14
|
+
if (!entry)
|
|
15
|
+
return err(`Entry not found: ${id}`, 'NOT_FOUND');
|
|
16
|
+
try {
|
|
17
|
+
// Delete DB record first — if this fails, the file stays and no orphan is created
|
|
18
|
+
const rowidResult = ctx.stmts.getRowid.get(id);
|
|
19
|
+
if (rowidResult?.rowid) {
|
|
20
|
+
try {
|
|
21
|
+
ctx.deleteVec(Number(rowidResult.rowid));
|
|
22
|
+
}
|
|
23
|
+
catch { }
|
|
24
|
+
}
|
|
25
|
+
ctx.stmts.deleteEntry.run(id);
|
|
26
|
+
// Delete file from disk after successful DB delete
|
|
27
|
+
let fileWarning = null;
|
|
28
|
+
if (entry.file_path) {
|
|
29
|
+
try {
|
|
30
|
+
unlinkSync(entry.file_path);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
if (e.code !== 'ENOENT') {
|
|
34
|
+
fileWarning = `file could not be removed from disk (${e.code}): ${entry.file_path}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const msg = `Deleted ${entry.kind}: ${entry.title || '(untitled)'} [${id}]`;
|
|
39
|
+
return ok(fileWarning ? `${msg}\nWarning: ${fileWarning}` : msg);
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return err(e instanceof Error ? e.message : String(e), 'DELETE_FAILED');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=delete-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-context.js","sourceRoot":"","sources":["../../src/tools/delete-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGxC,MAAM,CAAC,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAErC,MAAM,CAAC,MAAM,WAAW,GACtB,4GAA4G,CAAC;AAE/G,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;CACpD,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,EAAE,EAAE,EAAuB,EAC3B,GAAa,EACb,EAAE,aAAa,EAAa;IAE5B,IAAI,CAAC,EAAE,E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AW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LocalCtx, SharedCtx, ToolResult } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Truncate a body string to ~SKELETON_BODY_CHARS, breaking at sentence or
|
|
5
|
+
* word boundary. Returns the truncated string with "..." appended.
|
|
6
|
+
*/
|
|
7
|
+
export declare function skeletonBody(body: string | null | undefined): string;
|
|
8
|
+
/**
|
|
9
|
+
* Detect conflicts among a set of search result entries.
|
|
10
|
+
*
|
|
11
|
+
* Two checks are performed:
|
|
12
|
+
* 1. Supersession: if entry A's `superseded_by` points to any entry B in the
|
|
13
|
+
* result set, A is stale and should be discarded in favour of B.
|
|
14
|
+
* 2. Stale duplicate: two entries share the same kind and at least one common
|
|
15
|
+
* tag, but their `updated_at` timestamps differ by more than
|
|
16
|
+
* STALE_DUPLICATE_DAYS days — suggesting the older one may be outdated.
|
|
17
|
+
*
|
|
18
|
+
* No LLM calls, no new dependencies — pure in-memory set operations on the
|
|
19
|
+
* rows already fetched from the DB.
|
|
20
|
+
*
|
|
21
|
+
* @param {Array} entries - Result rows (as returned by hybridSearch / filter-only mode)
|
|
22
|
+
* @param {import('@context-vault/core/types').BaseCtx} _ctx
|
|
23
|
+
* @returns {Array<{entry_a_id: string, entry_b_id: string, reason: string, recommendation: string}>}
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectConflicts(entries: any[], _ctx: any): Array<{
|
|
26
|
+
entry_a_id: string;
|
|
27
|
+
entry_b_id: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
recommendation: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Detect tag clusters that would benefit from consolidation via create_snapshot.
|
|
33
|
+
* A suggestion is emitted when a tag appears on threshold+ entries in the full
|
|
34
|
+
* vault AND no recent brief (kind='brief') exists for that tag within the
|
|
35
|
+
* staleness window.
|
|
36
|
+
*
|
|
37
|
+
* Tag counts are derived from the full vault (not just the search result set)
|
|
38
|
+
* so the check reflects the true size of the knowledge cluster. Only tags that
|
|
39
|
+
* appear in the current search results are evaluated — this keeps the check
|
|
40
|
+
* targeted to what the user is actually working with.
|
|
41
|
+
*
|
|
42
|
+
* @param {Array} entries - Search result rows (used to select candidate tags)
|
|
43
|
+
* @param {import('node:sqlite').DatabaseSync} db - Database handle for vault-wide counts and brief lookups
|
|
44
|
+
* @param {{ tagThreshold?: number, maxAgeDays?: number }} opts - Configurable thresholds
|
|
45
|
+
* @returns {Array<{tag: string, entry_count: number, last_snapshot_age_days: number|null}>}
|
|
46
|
+
*/
|
|
47
|
+
export declare function detectConsolidationHints(entries: any[], db: any, opts?: {
|
|
48
|
+
tagThreshold?: number;
|
|
49
|
+
maxAgeDays?: number;
|
|
50
|
+
}): Array<{
|
|
51
|
+
tag: string;
|
|
52
|
+
entry_count: number;
|
|
53
|
+
last_snapshot_age_days: number | null;
|
|
54
|
+
}>;
|
|
55
|
+
export declare const name = "get_context";
|
|
56
|
+
export declare const description = "Search your knowledge vault. Returns entries ranked by relevance using hybrid full-text + semantic search. Use this to find insights, decisions, patterns, or any saved context. Each result includes an `id` you can use with save_context or delete_context.";
|
|
57
|
+
export declare const inputSchema: {
|
|
58
|
+
query: z.ZodOptional<z.ZodString>;
|
|
59
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
60
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
knowledge: "knowledge";
|
|
62
|
+
entity: "entity";
|
|
63
|
+
event: "event";
|
|
64
|
+
}>>;
|
|
65
|
+
identity_key: z.ZodOptional<z.ZodString>;
|
|
66
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
|
+
buckets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
68
|
+
since: z.ZodOptional<z.ZodString>;
|
|
69
|
+
until: z.ZodOptional<z.ZodString>;
|
|
70
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
include_superseded: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
detect_conflicts: z.ZodOptional<z.ZodBoolean>;
|
|
73
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
pivot_count: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
include_ephemeral: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
include_events: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
events: "events";
|
|
79
|
+
hot: "hot";
|
|
80
|
+
all: "all";
|
|
81
|
+
}>>;
|
|
82
|
+
follow_links: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
};
|
|
84
|
+
export declare function handler({ query, kind, category, identity_key, tags, buckets, since, until, limit, include_superseded, detect_conflicts, max_tokens, pivot_count, include_ephemeral, include_events, scope, follow_links, }: Record<string, any>, ctx: LocalCtx, { ensureIndexed, reindexFailed }: SharedCtx): Promise<ToolResult>;
|
|
85
|
+
//# sourceMappingURL=get-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context.d.ts","sourceRoot":"","sources":["../../src/tools/get-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASnE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAapE;AAED;;;;;;;;;;;;;;;;G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