pi-vault-mind 0.14.2 → 0.16.3
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 +293 -0
- package/README.md +5 -5
- package/agents/broadcaster.agent.md +2 -2
- package/agents/heavy-lifter.agent.md +1 -1
- package/agents/main.agent.md +29 -0
- package/agents/manager.agent.md +1 -1
- package/agents/miner.agent.md +1 -1
- package/dist/packages/obsidian/src/client.js +331 -0
- package/dist/packages/obsidian/src/types.js +1 -0
- package/dist/src/activity.d.ts +49 -0
- package/dist/src/activity.js +175 -0
- package/dist/src/agent-bus/Agent.d.ts +9 -1
- package/dist/src/agent-bus/Agent.js +18 -2
- package/dist/src/agent-bus/index.d.ts +5 -5
- package/dist/src/agent-bus/index.js +1 -1
- package/dist/src/agent-queue.js +12 -3
- package/dist/src/agents/BroadcasterAgent.d.ts +1 -1
- package/dist/src/agents/BroadcasterAgent.js +2 -2
- package/dist/src/agents/HeavyLifterAgent.d.ts +1 -1
- package/dist/src/agents/HeavyLifterAgent.js +2 -2
- package/dist/src/agents/ManagerAgent.js +1 -1
- package/dist/src/agents/MinerAgent.d.ts +1 -1
- package/dist/src/agents/MinerAgent.js +2 -2
- package/dist/src/agents/index.d.ts +2 -2
- package/dist/src/agents/index.js +2 -2
- package/dist/src/auth.d.ts +17 -15
- package/dist/src/auth.js +26 -37
- package/dist/src/autosync.js +2 -2
- package/dist/src/commands.d.ts +2 -19
- package/dist/src/commands.js +301 -231
- package/dist/src/config-keys.d.ts +16 -0
- package/dist/src/config-keys.js +45 -0
- package/dist/src/discover-schema.js +4 -4
- package/dist/src/edits.d.ts +21 -0
- package/dist/src/edits.js +75 -0
- package/dist/src/embedding-probe.d.ts +34 -0
- package/dist/src/embedding-probe.js +142 -0
- package/dist/src/embedding-providers.d.ts +133 -0
- package/dist/src/embedding-providers.js +173 -0
- package/dist/src/embedding-secrets.d.ts +38 -0
- package/dist/src/embedding-secrets.js +291 -0
- package/dist/src/engine.d.ts +6 -0
- package/dist/src/engine.js +78 -6
- package/dist/src/events.js +7 -10
- package/dist/src/extension-packages.d.ts +9 -0
- package/dist/src/extension-packages.js +14 -0
- package/dist/src/git.d.ts +19 -0
- package/dist/src/git.js +78 -0
- package/dist/src/graph.d.ts +2 -1
- package/dist/src/graph.js +47 -13
- package/dist/src/identities-config.d.ts +6 -0
- package/dist/src/identities-config.js +39 -0
- package/dist/src/identity-injector.js +1 -1
- package/dist/src/index.js +9 -26
- package/dist/src/lance.d.ts +9 -0
- package/dist/src/lance.js +143 -203
- package/dist/src/modal-client.d.ts +16 -0
- package/dist/src/modal-client.js +16 -0
- package/dist/src/modal-config.d.ts +37 -14
- package/dist/src/modal-config.js +59 -32
- package/dist/src/model-router.d.ts +27 -0
- package/dist/src/model-router.js +67 -0
- package/dist/src/models.d.ts +42 -0
- package/dist/src/models.js +78 -0
- package/dist/src/personalize.js +17 -3
- package/dist/src/scaffold.d.ts +48 -0
- package/dist/src/scaffold.js +246 -0
- package/dist/src/server.d.ts +47 -4
- package/dist/src/server.js +988 -221
- package/dist/src/session-search.d.ts +63 -0
- package/dist/src/session-search.js +379 -0
- package/dist/src/settings-ui.d.ts +2 -2
- package/dist/src/settings-ui.js +76 -135
- package/dist/src/sync.d.ts +3 -3
- package/dist/src/sync.js +19 -15
- package/dist/src/tool-catalog.d.ts +18 -0
- package/dist/src/tool-catalog.js +232 -0
- package/dist/src/tools/marksman.js +1 -1
- package/dist/src/tools.js +111 -65
- package/dist/src/types.d.ts +127 -71
- package/dist/src/utils.d.ts +57 -6
- package/dist/src/utils.js +114 -28
- package/dist/src/vault-tools.d.ts +34 -0
- package/dist/src/vault-tools.js +99 -0
- package/dist/src/vault-writer.js +4 -1
- package/dist/src/vm-handlers.js +140 -43
- package/dist/src/watcher.js +9 -9
- package/dist/test/activity-tool.test.js +54 -0
- package/dist/test/agent-bus/Agent.test.js +174 -0
- package/dist/test/agent-bus/AgentLoader.test.js +180 -0
- package/dist/test/agent-bus/AgentRegistry.test.js +86 -0
- package/dist/test/agent-bus/LLMProvider.test.js +162 -0
- package/dist/test/agent-bus/TaskQueue.test.js +256 -0
- package/dist/test/agent-dispatch-context.test.js +73 -0
- package/dist/test/agent-queue.test.js +1 -1
- package/dist/test/agents/Agents.test.js +282 -0
- package/dist/test/auth.test.js +57 -56
- package/dist/test/bridge-identity.test.js +34 -3
- package/dist/test/classify-search-mode.test.js +51 -0
- package/dist/test/commands.test.js +410 -0
- package/dist/test/config-merge.test.js +98 -0
- package/dist/test/context-capture.test.js +56 -0
- package/dist/test/discover-schema.test.js +8 -5
- package/dist/test/dispatch.test.js +45 -91
- package/dist/test/edits.test.js +144 -0
- package/dist/test/embedding-probe.test.js +424 -0
- package/dist/test/embedding-providers.test.js +157 -0
- package/dist/test/embedding-secrets.test.js +210 -0
- package/dist/test/engine-identity.test.js +1 -1
- package/dist/test/events.test.js +675 -0
- package/dist/test/git-bridge.test.js +160 -0
- package/dist/test/graph.test.js +464 -0
- package/dist/test/helpers/server.js +81 -0
- package/dist/test/identity-injector.test.js +197 -0
- package/dist/test/index.test.js +5 -7
- package/dist/test/lance-modal.test.js +67 -2
- package/dist/test/lance.test.js +429 -0
- package/dist/test/modal-client.test.js +1 -1
- package/dist/test/modal-config.test.js +92 -79
- package/dist/test/model-readiness.test.js +122 -0
- package/dist/test/model-router.test.js +99 -0
- package/dist/test/obsidian-client.test.js +42 -0
- package/dist/test/personalize.test.js +1 -1
- package/dist/test/rest-models.test.js +153 -0
- package/dist/test/rest-queue.test.js +135 -87
- package/dist/test/rest-setup.test.js +625 -115
- package/dist/test/rest-vm.test.js +355 -94
- package/dist/test/server-cors.test.js +48 -0
- package/dist/test/server-ws.test.js +61 -34
- package/dist/test/session-crud.test.js +323 -0
- package/dist/test/session-search.test.js +139 -0
- package/dist/test/settings-ui.test.js +113 -4
- package/dist/test/sync.test.js +12 -12
- package/dist/test/tombstone.test.js +8 -10
- package/dist/test/tool-catalog.test.js +86 -0
- package/dist/test/utils.test.js +588 -0
- package/dist/test/vault-tools.test.js +103 -12
- package/dist/test/vault-writer.test.js +371 -0
- package/dist/test/vm-handlers.test.js +620 -0
- package/extension-packages.json +9 -0
- package/package.json +107 -90
- package/pi-vault-mind.config.example.json +24 -2
- package/scripts/check-deps.sh +35 -32
- package/scripts/cli-e2e.mjs +215 -0
- package/scripts/configuration-e2e.mjs +783 -0
- package/scripts/e2e-commands.mjs +391 -0
- package/scripts/e2e-ws.mjs +3 -2
- package/scripts/fetch-modal-token.sh +4 -3
- package/scripts/generate-config-keys-json.mjs +45 -0
- package/scripts/generate-extension-packages-json.mjs +55 -0
- package/scripts/pi-session-query +0 -0
- package/scripts/publish-obsidian-plugin.sh +0 -0
- package/scripts/reset-test-vault.sh +2 -2
- package/scripts/setup-test-config.sh +0 -0
- package/scripts/setup-vault-pi.sh +48 -9
- package/scripts/test-slash-commands.mjs +2 -2
- package/scripts/vault-pi.sh +12 -3
- package/skills/github-release-notes-file/SKILL.md +42 -0
- package/skills/obsidian-guided-test-session/SKILL.md +110 -0
- package/skills/obsidian-interactive-test/SKILL.md +88 -0
- package/skills/obsidian-plugin-publish/SKILL.md +58 -0
- package/skills/pi-vault-mind-release/SKILL.md +141 -0
- package/skills/pre-test-release/SKILL.md +116 -0
- package/dist/test/auto-indexer.test.js +0 -2
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only tool catalog — enumerates all tools available to pi agents.
|
|
3
|
+
* Built-in tools are sourced from src/bridge.ts BuiltInTools type.
|
|
4
|
+
* vm_* tools are sourced from src/vm-handlers.ts registerAllExtensionTools.
|
|
5
|
+
*/
|
|
6
|
+
const BUILTIN_TOOLS = [
|
|
7
|
+
{ name: "read", kind: "builtin", description: "Read file contents with line-numbered output" },
|
|
8
|
+
{ name: "write", kind: "builtin", description: "Create or overwrite a file" },
|
|
9
|
+
{ name: "edit", kind: "builtin", description: "Surgical text edits with line-number anchoring" },
|
|
10
|
+
{ name: "bash", kind: "builtin", description: "Run shell commands" },
|
|
11
|
+
{ name: "grep", kind: "builtin", description: "Search files with regex patterns" },
|
|
12
|
+
{ name: "find", kind: "builtin", description: "Locate files by name pattern" },
|
|
13
|
+
{ name: "ls", kind: "builtin", description: "List directory contents" },
|
|
14
|
+
];
|
|
15
|
+
const EXTENSION_TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
name: "vm_search",
|
|
18
|
+
kind: "vm_search",
|
|
19
|
+
description: "mode='auto' (recommended) infers the strategy from the query. Search vault collections. Defaults to hybrid (vector+FTS rank-merge). Use mode='semantic' for vector-only, 'fts' for keyword, 'graph' for entity traversal, 'vault' for Obsidian-native title/path/tag search, 'full' for all merged.",
|
|
20
|
+
params: {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
collection: { type: "string", description: "Collection name", default: "main" },
|
|
24
|
+
query: { type: "string", description: "Search query" },
|
|
25
|
+
mode: {
|
|
26
|
+
type: "string",
|
|
27
|
+
enum: ["auto", "hybrid", "semantic", "fts", "graph", "vault", "full"],
|
|
28
|
+
default: "hybrid",
|
|
29
|
+
},
|
|
30
|
+
limit: { type: "number", default: 5 },
|
|
31
|
+
entity: { type: "string", description: "Entity name (graph mode only)" },
|
|
32
|
+
depth: { type: "number", default: 1, description: "Traversal depth (graph mode only)" },
|
|
33
|
+
},
|
|
34
|
+
required: ["query"],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "vm_query",
|
|
39
|
+
kind: "vm_search",
|
|
40
|
+
description: "Deterministic JSONL search by collection name. Use for exact lookups and filtered retrieval.",
|
|
41
|
+
},
|
|
42
|
+
{ name: "vm_append", kind: "vm_data", description: "Append an entry to a vault collection" },
|
|
43
|
+
{
|
|
44
|
+
name: "vm_promote",
|
|
45
|
+
kind: "vm_data",
|
|
46
|
+
description: "Promote a pending entry to the main collection",
|
|
47
|
+
},
|
|
48
|
+
{ name: "vm_ingest", kind: "vm_data", description: "Ingest content into a vault collection" },
|
|
49
|
+
{ name: "vm_export", kind: "vm_data", description: "Export collection data" },
|
|
50
|
+
{
|
|
51
|
+
name: "vm_stats",
|
|
52
|
+
kind: "vm_data",
|
|
53
|
+
description: "Collection statistics (count, size, malformed entries)",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "vm_status",
|
|
57
|
+
kind: "vm_config",
|
|
58
|
+
description: "Server and embedding configuration status",
|
|
59
|
+
},
|
|
60
|
+
{ name: "vm_describe", kind: "vm_config", description: "Describe a vault collection schema" },
|
|
61
|
+
{
|
|
62
|
+
name: "vm_configure",
|
|
63
|
+
kind: "vm_config",
|
|
64
|
+
description: "Read or update vault-mind configuration",
|
|
65
|
+
},
|
|
66
|
+
{ name: "vm_sync", kind: "vm_sync", description: "Sync embeddings with remote Modal endpoint" },
|
|
67
|
+
{
|
|
68
|
+
name: "discover_schema",
|
|
69
|
+
kind: "vm_config",
|
|
70
|
+
description: "Infer the schema of an unconfigured .jsonl file by sampling its first N rows and register it as a collection.",
|
|
71
|
+
params: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
file: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Path to the .jsonl file (absolute or relative to the project root)",
|
|
77
|
+
},
|
|
78
|
+
name: {
|
|
79
|
+
type: "string",
|
|
80
|
+
description: "Collection name to register (defaults to the file basename)",
|
|
81
|
+
},
|
|
82
|
+
sample: {
|
|
83
|
+
type: "number",
|
|
84
|
+
description: "Number of rows to sample for schema inference (default: 100)",
|
|
85
|
+
default: 100,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: ["file"],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "tombstone_entry",
|
|
93
|
+
kind: "vm_data",
|
|
94
|
+
description: "Mark a entry as deleted by replacing it with a tombstone record in the JSONL log.",
|
|
95
|
+
params: {
|
|
96
|
+
type: "object",
|
|
97
|
+
properties: {
|
|
98
|
+
collection: { type: "string", description: "Collection name containing the entry" },
|
|
99
|
+
entryId: { type: "string", description: "ID of the entry to tombstone" },
|
|
100
|
+
},
|
|
101
|
+
required: ["collection", "entryId"],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "vault_read",
|
|
106
|
+
kind: "vm_data",
|
|
107
|
+
description: "Read the contents of a file relative to the vault root.",
|
|
108
|
+
params: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
path: { type: "string", description: "Relative path from the vault root" },
|
|
112
|
+
},
|
|
113
|
+
required: ["path"],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "vault_write",
|
|
118
|
+
kind: "vm_data",
|
|
119
|
+
description: "Create or overwrite a file inside the Obsidian vault.",
|
|
120
|
+
params: {
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: {
|
|
123
|
+
path: { type: "string", description: "Relative path from the vault root" },
|
|
124
|
+
content: { type: "string", description: "Full content to write" },
|
|
125
|
+
},
|
|
126
|
+
required: ["path", "content"],
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "vault_append",
|
|
131
|
+
kind: "vm_data",
|
|
132
|
+
description: "Append content to the end of an existing vault file.",
|
|
133
|
+
params: {
|
|
134
|
+
type: "object",
|
|
135
|
+
properties: {
|
|
136
|
+
path: { type: "string", description: "Relative path from the vault root" },
|
|
137
|
+
content: { type: "string", description: "Content to append" },
|
|
138
|
+
},
|
|
139
|
+
required: ["path", "content"],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "vault_search",
|
|
144
|
+
kind: "vm_search",
|
|
145
|
+
description: "Full-text search across indexed vault notes in the default collection.",
|
|
146
|
+
params: {
|
|
147
|
+
type: "object",
|
|
148
|
+
properties: {
|
|
149
|
+
query: { type: "string", description: "Keyword or phrase to search for" },
|
|
150
|
+
limit: { type: "number", description: "Max results (default 10)", default: 10 },
|
|
151
|
+
},
|
|
152
|
+
required: ["query"],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "vault_list",
|
|
157
|
+
kind: "vm_data",
|
|
158
|
+
description: "List files in the Obsidian vault with optional folder and glob filters.",
|
|
159
|
+
params: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
folder: { type: "string", description: "Optional subfolder to scope the listing" },
|
|
163
|
+
pattern: { type: "string", description: "Optional glob pattern to filter results" },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "vault_tags",
|
|
169
|
+
kind: "vm_data",
|
|
170
|
+
description: "Extract and count tags from markdown frontmatter across the vault.",
|
|
171
|
+
params: { type: "object", properties: {} },
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "vm_backlinks",
|
|
175
|
+
kind: "vm_data",
|
|
176
|
+
description: "Find Obsidian notes that link to a given note. Uses the Marksman Markdown LSP when available.",
|
|
177
|
+
params: {
|
|
178
|
+
type: "object",
|
|
179
|
+
properties: {
|
|
180
|
+
note: { type: "string", description: "Target note path or title" },
|
|
181
|
+
},
|
|
182
|
+
required: ["note"],
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "vm_broken_links",
|
|
187
|
+
kind: "vm_data",
|
|
188
|
+
description: "List broken [[wikilinks]] and relative Markdown links across the vault using Marksman workspace diagnostics.",
|
|
189
|
+
params: { type: "object", properties: {} },
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "vm_related",
|
|
193
|
+
kind: "vm_data",
|
|
194
|
+
description: "Build a neighborhood graph around a note using backlinks and forward links from the Marksman Markdown LSP.",
|
|
195
|
+
params: {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
entity: { type: "string", description: "Center note path or title" },
|
|
199
|
+
depth: { type: "number", description: "Traversal depth (1-3, default 1)" },
|
|
200
|
+
},
|
|
201
|
+
required: ["entity"],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "vm_codegraph_impact",
|
|
206
|
+
kind: "vm_data",
|
|
207
|
+
description: "Report which code depends on a given symbol using the workspace codegraph index.",
|
|
208
|
+
params: {
|
|
209
|
+
type: "object",
|
|
210
|
+
properties: {
|
|
211
|
+
symbol: {
|
|
212
|
+
type: "string",
|
|
213
|
+
description: "Symbol name to look up (function, class, variable, type, etc.)",
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
required: ["symbol"],
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
];
|
|
220
|
+
const ALL_TOOLS = [...BUILTIN_TOOLS, ...EXTENSION_TOOLS];
|
|
221
|
+
/** Return all 30 tools (7 built-in + 23 extension tools). */
|
|
222
|
+
export function listAllTools() {
|
|
223
|
+
return ALL_TOOLS;
|
|
224
|
+
}
|
|
225
|
+
/** Return the 7 built-in tools. */
|
|
226
|
+
export function listBuiltinTools() {
|
|
227
|
+
return BUILTIN_TOOLS;
|
|
228
|
+
}
|
|
229
|
+
/** Return the 23 extension tools. */
|
|
230
|
+
export function listExtensionTools() {
|
|
231
|
+
return EXTENSION_TOOLS;
|
|
232
|
+
}
|
|
@@ -446,7 +446,7 @@ const withMarksmanClient = async (ctx, operation) => {
|
|
|
446
446
|
content: [
|
|
447
447
|
{
|
|
448
448
|
type: "text",
|
|
449
|
-
text: "No default vault configured. Run /vm
|
|
449
|
+
text: "No default vault configured. Run /vm setup or set vaultMind.vaults.default.path.",
|
|
450
450
|
},
|
|
451
451
|
],
|
|
452
452
|
details: {},
|
package/dist/src/tools.js
CHANGED
|
@@ -3,12 +3,13 @@ import * as path from "node:path";
|
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { registerDiscoverSchemaTool } from "./discover-schema.js";
|
|
5
5
|
import { graphUpsert, queryGraph } from "./graph.js";
|
|
6
|
-
import { getStatus, queryCollection, searchFts, searchHybrid, upsertEntry, } from "./lance.js";
|
|
6
|
+
import { getStatus, queryCollection, searchFts, searchHybrid, searchHybridRanked, upsertEntry, } from "./lance.js";
|
|
7
|
+
import { resolveSessionsDir, searchSessions } from "./session-search.js";
|
|
7
8
|
import { registerTombstoneTool } from "./tombstone.js";
|
|
8
9
|
import { registerCodegraphTool } from "./tools/codegraph.js";
|
|
9
10
|
import { registerMarksmanTools } from "./tools/marksman.js";
|
|
10
|
-
import { collectionNames, ensureDir, findConfig, loadConfig } from "./utils.js";
|
|
11
|
-
import { registerVaultTools } from "./vault-tools.js";
|
|
11
|
+
import { collectionNames, ensureDir, findConfig, getConfigPath, loadConfig } from "./utils.js";
|
|
12
|
+
import { classifySearchMode, normalizeGraphResult, registerVaultTools, searchVaultNative, } from "./vault-tools.js";
|
|
12
13
|
import { VaultWriter } from "./vault-writer.js";
|
|
13
14
|
/** Jaccard similarity over character bigrams. Returns 0–1. */
|
|
14
15
|
export const jaccardSimilarity = (a, b) => {
|
|
@@ -93,7 +94,7 @@ export const registerTools = (pi) => {
|
|
|
93
94
|
};
|
|
94
95
|
if (!pendingDef)
|
|
95
96
|
return {
|
|
96
|
-
content: [{ type: "text", text: "Pending collection not configured. Run /vm
|
|
97
|
+
content: [{ type: "text", text: "Pending collection not configured. Run /vm setup." }],
|
|
97
98
|
details: {},
|
|
98
99
|
};
|
|
99
100
|
if (!fs.existsSync(sourceDef.path))
|
|
@@ -144,73 +145,118 @@ export const registerTools = (pi) => {
|
|
|
144
145
|
/* ── vm_search ── */
|
|
145
146
|
pi.registerTool({
|
|
146
147
|
name: "vm_search",
|
|
147
|
-
label: "VaultMind
|
|
148
|
-
description: "
|
|
149
|
-
promptSnippet: 'vm_search(collection="main", query="...", limit=5)',
|
|
148
|
+
label: "VaultMind Search",
|
|
149
|
+
description: "mode='auto' (recommended) infers the strategy from the query. Search vault collections. Defaults to hybrid (vector+FTS rank-merge). Use mode='semantic' for vector-only, 'fts' for keyword, 'graph' for entity traversal, 'vault' for Obsidian-native title/path/tag search, 'full' for all merged.",
|
|
150
|
+
promptSnippet: 'vm_search(collection="main", query="...", mode="hybrid", limit=5)',
|
|
150
151
|
promptGuidelines: [
|
|
151
|
-
"Use vm_search
|
|
152
|
-
"
|
|
152
|
+
"Use vm_search as the default search tool.",
|
|
153
|
+
"mode='hybrid' (default) merges vector semantic and full-text results with vector ranked first.",
|
|
154
|
+
"mode='semantic' is vector-only; mode='fts' is keyword-only; mode='graph' traverses entity relations; mode='vault' searches the Obsidian vault's own title/path/tag index; mode='full' runs all backends and merges results.",
|
|
155
|
+
"For graph mode, pass entity (defaults to query) and depth (defaults to 1).",
|
|
153
156
|
],
|
|
154
157
|
parameters: Type.Object({
|
|
155
158
|
collection: Type.String({ description: "Collection name (e.g. main)", default: "main" }),
|
|
156
|
-
query: Type.String({ description: "Natural-language search query" }),
|
|
159
|
+
query: Type.String({ description: "Natural-language or keyword search query" }),
|
|
160
|
+
mode: Type.Optional(Type.Union([
|
|
161
|
+
Type.Literal("auto"),
|
|
162
|
+
Type.Literal("hybrid"),
|
|
163
|
+
Type.Literal("semantic"),
|
|
164
|
+
Type.Literal("fts"),
|
|
165
|
+
Type.Literal("graph"),
|
|
166
|
+
Type.Literal("vault"),
|
|
167
|
+
Type.Literal("full"),
|
|
168
|
+
], { default: "hybrid", description: "Search mode" })),
|
|
157
169
|
limit: Type.Optional(Type.Number({ description: "Max results (default 5)" })),
|
|
170
|
+
entity: Type.Optional(Type.String({ description: "Entity (graph mode only)" })),
|
|
171
|
+
depth: Type.Optional(Type.Number({ description: "Traversal depth (graph mode only)", default: 1 })),
|
|
172
|
+
sources: Type.Optional(Type.Array(Type.Union([Type.Literal("vault"), Type.Literal("sessions")]), {
|
|
173
|
+
default: ["vault"],
|
|
174
|
+
description: "Sources to search: 'vault' (default, collections/index) and/or 'sessions' (Pi session .jsonl files). Merges hits from all listed sources.",
|
|
175
|
+
})),
|
|
158
176
|
}),
|
|
159
177
|
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
160
178
|
const cfg = loadConfig(ctx.cwd);
|
|
179
|
+
const collection = params.collection;
|
|
180
|
+
const query = params.query;
|
|
181
|
+
const mode = params.mode ?? "hybrid";
|
|
182
|
+
const limit = params.limit ?? 5;
|
|
183
|
+
const entity = params.entity ?? query;
|
|
184
|
+
const depth = params.depth ?? 1;
|
|
185
|
+
const sources = Array.isArray(params.sources) ? params.sources : ["vault"];
|
|
186
|
+
const resolvedMode = mode === "auto" ? classifySearchMode(query).mode : mode;
|
|
161
187
|
try {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
188
|
+
let results;
|
|
189
|
+
let graphMessage;
|
|
190
|
+
if (resolvedMode === "hybrid") {
|
|
191
|
+
results = await searchHybridRanked(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind);
|
|
192
|
+
}
|
|
193
|
+
else if (resolvedMode === "semantic") {
|
|
194
|
+
results = await searchHybrid(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind);
|
|
195
|
+
}
|
|
196
|
+
else if (resolvedMode === "fts") {
|
|
197
|
+
results = await searchFts(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind);
|
|
198
|
+
}
|
|
199
|
+
else if (resolvedMode === "graph") {
|
|
200
|
+
const graphNorm = normalizeGraphResult(await queryGraph(cfg.vaultMind.dataDir, cfg.vaultMind, entity, depth, undefined));
|
|
201
|
+
results = graphNorm.hits;
|
|
202
|
+
graphMessage = graphNorm.message;
|
|
203
|
+
}
|
|
204
|
+
else if (resolvedMode === "vault") {
|
|
205
|
+
results = await searchVaultNative(cfg.vaultMind.vaults?.default?.path ?? "", query, limit);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
const [hybridResults, semanticResults, ftsResults, graphResult, vaultResults] = await Promise.all([
|
|
209
|
+
searchHybridRanked(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind).catch(() => []),
|
|
210
|
+
searchHybrid(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind).catch(() => []),
|
|
211
|
+
searchFts(cfg.vaultMind.dataDir, collection, query, limit, cfg.vaultMind).catch(() => []),
|
|
212
|
+
queryGraph(cfg.vaultMind.dataDir, cfg.vaultMind, entity, depth, undefined).catch(() => ({ entities: [], relations: [] })),
|
|
213
|
+
searchVaultNative(cfg.vaultMind.vaults?.default?.path ?? "", query, limit).catch(() => []),
|
|
214
|
+
]);
|
|
215
|
+
const graphNorm = normalizeGraphResult(graphResult);
|
|
216
|
+
const tagged = [
|
|
217
|
+
...hybridResults.map((r) => ({
|
|
218
|
+
...r,
|
|
219
|
+
_source: "hybrid",
|
|
220
|
+
})),
|
|
221
|
+
...semanticResults.map((r) => ({
|
|
222
|
+
...r,
|
|
223
|
+
_source: "semantic",
|
|
224
|
+
})),
|
|
225
|
+
...ftsResults.map((r) => ({
|
|
226
|
+
...r,
|
|
227
|
+
_source: "fts",
|
|
228
|
+
})),
|
|
229
|
+
...graphNorm.hits.map((r) => ({
|
|
230
|
+
...r,
|
|
231
|
+
_source: "graph",
|
|
232
|
+
})),
|
|
233
|
+
...vaultResults.map((r) => ({
|
|
234
|
+
...r,
|
|
235
|
+
_source: "vault",
|
|
236
|
+
})),
|
|
237
|
+
];
|
|
238
|
+
const seen = new Set();
|
|
239
|
+
const merged = [];
|
|
240
|
+
for (const row of tagged) {
|
|
241
|
+
const key = String(row.id ?? row.fact ?? JSON.stringify(row));
|
|
242
|
+
if (!seen.has(key)) {
|
|
243
|
+
seen.add(key);
|
|
244
|
+
merged.push(row);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
results = merged.slice(0, limit);
|
|
248
|
+
}
|
|
249
|
+
if (sources.includes("sessions")) {
|
|
250
|
+
results = [...results, ...searchSessions(resolveSessionsDir(), query, limit)];
|
|
251
|
+
}
|
|
252
|
+
const text = graphMessage !== undefined && results.length === 0
|
|
253
|
+
? JSON.stringify({ hits: results, message: graphMessage }, null, 2)
|
|
254
|
+
: JSON.stringify(results, null, 2);
|
|
255
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
211
256
|
}
|
|
212
257
|
catch (error) {
|
|
213
|
-
|
|
258
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
259
|
+
return { content: [{ type: "text", text: `Error: ${message}` }], details: {} };
|
|
214
260
|
}
|
|
215
261
|
},
|
|
216
262
|
});
|
|
@@ -287,7 +333,7 @@ export const registerTools = (pi) => {
|
|
|
287
333
|
promptGuidelines: [
|
|
288
334
|
"Use when you know the collection name and need exact matches.",
|
|
289
335
|
"query does substring search across all text fields; filters does exact key-value matching.",
|
|
290
|
-
"If the collection is missing, run /vm
|
|
336
|
+
"If the collection is missing, run /vm setup first.",
|
|
291
337
|
],
|
|
292
338
|
parameters: Type.Object({
|
|
293
339
|
collection: Type.String({ description: "Collection name (e.g. main, pending)" }),
|
|
@@ -314,7 +360,7 @@ export const registerTools = (pi) => {
|
|
|
314
360
|
content: [
|
|
315
361
|
{
|
|
316
362
|
type: "text",
|
|
317
|
-
text: `Collection "${params.collection}" not found at ${def.path}. Run /vm
|
|
363
|
+
text: `Collection "${params.collection}" not found at ${def.path}. Run /vm setup.`,
|
|
318
364
|
},
|
|
319
365
|
],
|
|
320
366
|
details: {},
|
|
@@ -489,7 +535,7 @@ export const registerTools = (pi) => {
|
|
|
489
535
|
config: Type.Optional(Type.Record(Type.String(), Type.Any(), { description: "Partial config object to merge" })),
|
|
490
536
|
}),
|
|
491
537
|
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
492
|
-
const cfgPath =
|
|
538
|
+
const cfgPath = getConfigPath(ctx.cwd);
|
|
493
539
|
if (params.action === "read" || !params.config) {
|
|
494
540
|
const cfg = loadConfig(ctx.cwd);
|
|
495
541
|
return { content: [{ type: "text", text: JSON.stringify(cfg, null, 2) }], details: {} };
|
|
@@ -540,7 +586,7 @@ export const registerTools = (pi) => {
|
|
|
540
586
|
content: [
|
|
541
587
|
{
|
|
542
588
|
type: "text",
|
|
543
|
-
text: `Collection "${params.collection}" not found at ${def.path}. Run /vm
|
|
589
|
+
text: `Collection "${params.collection}" not found at ${def.path}. Run /vm setup.`,
|
|
544
590
|
},
|
|
545
591
|
],
|
|
546
592
|
details: {},
|
|
@@ -592,7 +638,7 @@ export const registerTools = (pi) => {
|
|
|
592
638
|
const cfg = loadConfig(ctx.cwd);
|
|
593
639
|
const lines = [
|
|
594
640
|
"pi-vault-mind Stats",
|
|
595
|
-
`Config path:
|
|
641
|
+
`Config path: ${findConfig(ctx.cwd).project || "(none)"}`,
|
|
596
642
|
"",
|
|
597
643
|
`LanceDB DataDir: ${cfg.vaultMind.dataDir}`,
|
|
598
644
|
`Injectors: ${cfg.injectors.length}`,
|