wyrm-mcp 7.3.2 → 7.3.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/README.md +8 -14
- package/dist/activation.js +59 -1
- package/dist/agent-daemon.js +281 -4
- package/dist/agent-loop.js +332 -7
- package/dist/analytics.js +236 -13
- package/dist/attribution.js +49 -1
- package/dist/audit.js +457 -2
- package/dist/auto-capture.js +138 -3
- package/dist/auto-orchestrator.js +325 -1
- package/dist/autoconfig.d.ts +50 -0
- package/dist/autoconfig.d.ts.map +1 -1
- package/dist/autoconfig.js +1115 -39
- package/dist/autoconfig.js.map +1 -1
- package/dist/buddy-runner.js +109 -1
- package/dist/buddy.js +564 -14
- package/dist/build-flags.js +15 -1
- package/dist/capabilities.js +183 -3
- package/dist/capture.js +56 -1
- package/dist/causality.js +148 -8
- package/dist/cli.js +281 -20
- package/dist/cloud/cli.js +541 -5
- package/dist/cloud/client.js +221 -1
- package/dist/cloud/crypto.js +85 -1
- package/dist/cloud/machine-id.js +113 -2
- package/dist/cloud/recovery.js +60 -1
- package/dist/cloud/sync-engine.js +543 -7
- package/dist/cloud-backup.js +579 -5
- package/dist/cloud-profile.js +138 -1
- package/dist/cloud-sync-entrypoint.js +47 -1
- package/dist/cloud-sync.js +309 -2
- package/dist/connectors/bridge-source.d.ts +46 -0
- package/dist/connectors/bridge-source.d.ts.map +1 -0
- package/dist/connectors/bridge-source.js +77 -0
- package/dist/connectors/bridge-source.js.map +1 -0
- package/dist/connectors/index.d.ts +24 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/index.js +69 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/ingest.d.ts +16 -0
- package/dist/connectors/ingest.d.ts.map +1 -0
- package/dist/connectors/ingest.js +116 -0
- package/dist/connectors/ingest.js.map +1 -0
- package/dist/connectors/types.d.ts +99 -0
- package/dist/connectors/types.d.ts.map +1 -0
- package/dist/connectors/types.js +17 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/constellation.js +168 -12
- package/dist/content-signature.js +45 -1
- package/dist/context-build-budgeted.js +144 -4
- package/dist/context-ranking.js +69 -1
- package/dist/crypto.js +179 -1
- package/dist/daemon-write-endpoint.js +290 -1
- package/dist/daemon-writer.js +406 -2
- package/dist/database.js +1278 -53
- package/dist/deprecations.js +162 -2
- package/dist/design.js +141 -13
- package/dist/event-replication.js +112 -1
- package/dist/events-sse.js +43 -7
- package/dist/events.js +238 -6
- package/dist/failure-patterns.d.ts +107 -0
- package/dist/failure-patterns.d.ts.map +1 -1
- package/dist/failure-patterns.js +924 -43
- package/dist/failure-patterns.js.map +1 -1
- package/dist/federation.js +236 -12
- package/dist/goals.js +101 -13
- package/dist/golden.js +355 -3
- package/dist/handlers/agent.js +165 -4
- package/dist/handlers/alias-adapters.js +129 -1
- package/dist/handlers/aliases.js +171 -1
- package/dist/handlers/audit.js +87 -1
- package/dist/handlers/boundary.js +221 -1
- package/dist/handlers/capture.js +1114 -73
- package/dist/handlers/causality.js +119 -9
- package/dist/handlers/cloud.js +382 -85
- package/dist/handlers/companion.js +459 -28
- package/dist/handlers/datalake.js +187 -7
- package/dist/handlers/dispatch-context.js +22 -0
- package/dist/handlers/entity.js +256 -25
- package/dist/handlers/events.js +335 -16
- package/dist/handlers/failure.d.ts.map +1 -1
- package/dist/handlers/failure.js +408 -13
- package/dist/handlers/failure.js.map +1 -1
- package/dist/handlers/goals.js +296 -4
- package/dist/handlers/intelligence.js +681 -126
- package/dist/handlers/invoicing.js +70 -1
- package/dist/handlers/mcpclient.js +137 -6
- package/dist/handlers/orchestration.js +125 -40
- package/dist/handlers/output-schemas.js +24 -1
- package/dist/handlers/presence.js +99 -3
- package/dist/handlers/project.js +182 -28
- package/dist/handlers/prompts.js +157 -6
- package/dist/handlers/quest.js +224 -4
- package/dist/handlers/recall.js +237 -13
- package/dist/handlers/registry.js +167 -1
- package/dist/handlers/resources.js +288 -1
- package/dist/handlers/review.js +74 -11
- package/dist/handlers/run.js +498 -16
- package/dist/handlers/search.js +338 -15
- package/dist/handlers/session.js +643 -31
- package/dist/handlers/share.js +184 -8
- package/dist/handlers/shims.js +464 -1
- package/dist/handlers/skill.js +449 -67
- package/dist/handlers/survivors.js +120 -1
- package/dist/handlers/symbols.js +109 -8
- package/dist/handlers/syncops.js +302 -4
- package/dist/handlers/types.js +27 -1
- package/dist/harvest.js +191 -5
- package/dist/hours.js +156 -7
- package/dist/http-auth.js +321 -3
- package/dist/http-fast.js +1302 -22
- package/dist/icons.js +47 -1
- package/dist/importers.js +268 -1
- package/dist/index.js +840 -2
- package/dist/indexer.js +145 -4
- package/dist/intelligence.js +261 -31
- package/dist/internal-dispatch.js +212 -3
- package/dist/keyset.js +110 -1
- package/dist/knowledge-graph.js +176 -12
- package/dist/license.js +441 -2
- package/dist/logger.js +199 -2
- package/dist/maintenance.js +148 -2
- package/dist/mcp-client.js +262 -6
- package/dist/memory-artifacts.js +596 -32
- package/dist/migrate-prompt.js +124 -2
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +799 -42
- package/dist/migrations.js.map +1 -1
- package/dist/performance.js +228 -1
- package/dist/presence.js +140 -11
- package/dist/priority-embed.js +164 -5
- package/dist/providers/embedding-provider.js +196 -1
- package/dist/readonly-gate.js +29 -1
- package/dist/receipt.js +43 -1
- package/dist/rehydration.js +157 -9
- package/dist/reindex.js +88 -1
- package/dist/render-target.js +544 -21
- package/dist/render.js +280 -4
- package/dist/repl-guard.js +173 -1
- package/dist/replication-daemon-entrypoint.js +31 -1
- package/dist/replication-daemon.js +262 -2
- package/dist/rerank.js +142 -1
- package/dist/resilience.js +591 -1
- package/dist/reverse-bridge.js +360 -5
- package/dist/security.js +244 -1
- package/dist/session-seen.js +51 -3
- package/dist/setup.js +260 -1
- package/dist/skill-author.js +168 -5
- package/dist/spec-kit.js +191 -1
- package/dist/sqlite-busy.js +154 -1
- package/dist/statusline.js +315 -11
- package/dist/sub-agent.js +262 -13
- package/dist/summarizer.js +139 -13
- package/dist/symbols.js +283 -7
- package/dist/sync.js +359 -5
- package/dist/tasks-dispatch.js +84 -1
- package/dist/tasks.js +282 -1
- package/dist/token-budget.js +143 -1
- package/dist/tool-analytics.js +129 -7
- package/dist/tool-annotations.js +365 -1
- package/dist/tool-manifest-v2.json +1 -1
- package/dist/tool-manifest.json +1 -1
- package/dist/tool-profiles.js +75 -1
- package/dist/trace-harvest.js +244 -6
- package/dist/types.js +30 -1
- package/dist/ui-dashboard.js +50 -41
- package/dist/ulid.js +81 -1
- package/dist/usage-tracker.js +66 -1
- package/dist/validate.js +129 -1
- package/dist/vault.js +534 -1
- package/dist/vector-init.js +67 -1
- package/dist/vectors.js +184 -3
- package/dist/version-check.js +136 -4
- package/dist/visibility.js +155 -19
- package/dist/wyrm-cli.js +2845 -101
- package/dist/wyrm-cli.js.map +1 -1
- package/dist/wyrm-guard.d.ts.map +1 -1
- package/dist/wyrm-guard.js +475 -14
- package/dist/wyrm-guard.js.map +1 -1
- package/dist/wyrm-loop.js +150 -3
- package/dist/wyrm-manifest.json +1 -1
- package/dist/wyrm-statusline-daemon.js +11 -1
- package/dist/wyrm-statusline.js +56 -4
- package/dist/wyrm-ui.js +77 -9
- package/package.json +1 -1
package/dist/handlers/search.js
CHANGED
|
@@ -1,15 +1,338 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Search domain — ToolSpec contract v2 (v7 F3 T026, hot-path extraction).
|
|
3
|
+
*
|
|
4
|
+
* wyrm_search (FTS ⊕ vector RRF fusion across sessions/quests/data + skills
|
|
5
|
+
* + entities) and wyrm_constellation (the cross-project scoped mode the
|
|
6
|
+
* search survivor absorbs per the task routing), moved VERBATIM from the
|
|
7
|
+
* index.ts dispatch switch + buildAllTools(). The constellation alias keeps
|
|
8
|
+
* routing here through the spine (identity route → this registry entry —
|
|
9
|
+
* same handler code path, never a reimplementation).
|
|
10
|
+
*
|
|
11
|
+
* T019 renderer: the fused section list is the canonical structured body;
|
|
12
|
+
* the 6.x markdown derives from it (ASCII default — ✅/❌ skill markers
|
|
13
|
+
* became [active]/[inactive], spec §6 reformat).
|
|
14
|
+
*
|
|
15
|
+
* @copyright 2026 Ghost Protocol (Pvt) Ltd.
|
|
16
|
+
* @license Proprietary — (c) 2026 Ghost Protocol (Pvt) Ltd. All rights reserved. See LICENSE.
|
|
17
|
+
*/
|
|
18
|
+
import { TOOL_ANNOTATIONS } from '../tool-annotations.js';
|
|
19
|
+
import { renderResult, withGlyph, cacheKeyFor } from '../render.js';
|
|
20
|
+
import { sanitizeFtsQuery } from '../security.js';
|
|
21
|
+
import { constellationQuery } from '../constellation.js';
|
|
22
|
+
export const searchToolSpecs = [
|
|
23
|
+
{
|
|
24
|
+
name: "wyrm_search",
|
|
25
|
+
description: "Use to find anything by keyword or meaning across all projects - find past sessions that mention a topic, look up everything we have about a service, or ask have I solved this problem before in any other project (cross-project constellation). FTS/vector/hybrid; where a function or symbol is defined across repos lives here too (wyrm_symbol_search).",
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
// v7 F3 (T026): property prose compressed to fund the hot-path
|
|
30
|
+
// outputSchemas under the 8K default-surface pin (T022/T025 trade).
|
|
31
|
+
query: { type: "string" },
|
|
32
|
+
type: { type: "string", enum: ["all", "sessions", "quests", "data", "artifacts", "entities"] },
|
|
33
|
+
mode: { type: "string", enum: ["lexical", "semantic", "hybrid"], description: "Default hybrid, else lexical" },
|
|
34
|
+
projectPath: { type: "string", description: "Limit to one project" },
|
|
35
|
+
},
|
|
36
|
+
required: ["query"],
|
|
37
|
+
},
|
|
38
|
+
outputSchema: {
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
query: { type: "string" },
|
|
42
|
+
mode: { type: "string", enum: ["lexical", "semantic", "hybrid"] },
|
|
43
|
+
sections: {
|
|
44
|
+
type: "array",
|
|
45
|
+
items: {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties: {
|
|
48
|
+
label: { type: "string" },
|
|
49
|
+
count: { type: "integer" },
|
|
50
|
+
items: { type: "array", items: { type: "string" } },
|
|
51
|
+
},
|
|
52
|
+
required: ["label", "count", "items"],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
skills: { type: "array" },
|
|
56
|
+
entities: { type: "array" },
|
|
57
|
+
},
|
|
58
|
+
required: ["query", "mode", "sections", "skills", "entities"],
|
|
59
|
+
},
|
|
60
|
+
annotations: TOOL_ANNOTATIONS.wyrm_search,
|
|
61
|
+
aliases: [],
|
|
62
|
+
handler: async (args, { store, graph, vectors, cache, decrypt }) => {
|
|
63
|
+
const { query, type, mode, projectPath } = args;
|
|
64
|
+
const vectorStore = vectors();
|
|
65
|
+
const sanitizedQuery = sanitizeFtsQuery(query);
|
|
66
|
+
const project = projectPath ? store.getProject(projectPath) : undefined;
|
|
67
|
+
const projectId = project?.id;
|
|
68
|
+
const searchType = type || 'all';
|
|
69
|
+
const searchMode = mode || (vectorStore ? 'hybrid' : 'lexical');
|
|
70
|
+
const ftsResultsByType = {};
|
|
71
|
+
if (searchType === 'all' || searchType === 'sessions') {
|
|
72
|
+
if (searchMode !== 'semantic') {
|
|
73
|
+
const sessions = store.searchSessions(sanitizedQuery, projectId);
|
|
74
|
+
ftsResultsByType['session'] = sessions.map((s, i) => ({
|
|
75
|
+
id: s.id,
|
|
76
|
+
snippet: `${s.date}: ${(s.objectives || s.completed || 'No info').slice(0, 80)}`,
|
|
77
|
+
rank: i + 1,
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (searchType === 'all' || searchType === 'quests') {
|
|
82
|
+
if (searchMode !== 'semantic') {
|
|
83
|
+
const quests = store.searchQuests(sanitizedQuery);
|
|
84
|
+
ftsResultsByType['quest'] = quests.map((q, i) => ({
|
|
85
|
+
id: q.id,
|
|
86
|
+
snippet: `#${q.id}: ${q.title}`,
|
|
87
|
+
rank: i + 1,
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (searchType === 'all' || searchType === 'data') {
|
|
92
|
+
if (searchMode !== 'semantic') {
|
|
93
|
+
const data = store.searchData(sanitizedQuery, projectId);
|
|
94
|
+
ftsResultsByType['note'] = data.map((d, i) => ({
|
|
95
|
+
id: d.id,
|
|
96
|
+
snippet: `${d.category}/${d.key}: ${decrypt(d.value).slice(0, 60)}`,
|
|
97
|
+
rank: i + 1,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Memory artifacts: lexical peer of the vector 'artifact' channel below,
|
|
102
|
+
// so keyword search finds patterns/lessons too (RRF-fused by artifact id).
|
|
103
|
+
if (searchType === 'all' || searchType === 'artifacts') {
|
|
104
|
+
if (searchMode !== 'semantic') {
|
|
105
|
+
const artifacts = store.searchArtifacts(sanitizedQuery, projectId);
|
|
106
|
+
ftsResultsByType['artifact'] = artifacts.map((a, i) => ({
|
|
107
|
+
id: a.id,
|
|
108
|
+
snippet: `#${a.id}: ${(a.problem || '').slice(0, 80)}`,
|
|
109
|
+
rank: i + 1,
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
let vectorResults = [];
|
|
114
|
+
if (vectorStore && searchMode !== 'lexical' && (searchType === 'all' || searchType === 'data' || searchType === 'sessions' || searchType === 'quests')) {
|
|
115
|
+
try {
|
|
116
|
+
vectorResults = await vectorStore.search(query, 20, projectId);
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Vector search failed gracefully — continue with FTS
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// ── Reciprocal Rank Fusion (RRF) ──────────────────────────────────────
|
|
123
|
+
// Score formula: Σ 1/(k + rank) where k=60
|
|
124
|
+
const RRF_K = 60;
|
|
125
|
+
const rrfScores = new Map();
|
|
126
|
+
const addFtsToRrf = (contentType, results) => {
|
|
127
|
+
results.forEach((r, idx) => {
|
|
128
|
+
const key = `${contentType}:${r.id}`;
|
|
129
|
+
const existing = rrfScores.get(key);
|
|
130
|
+
const score = 1 / (RRF_K + (idx + 1));
|
|
131
|
+
if (existing) {
|
|
132
|
+
existing.score += score;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
rrfScores.set(key, { score, snippet: r.snippet, type: contentType, id: r.id });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
for (const [contentType, results] of Object.entries(ftsResultsByType)) {
|
|
140
|
+
addFtsToRrf(contentType, results);
|
|
141
|
+
}
|
|
142
|
+
// Add vector results to RRF (sorted by similarity desc → rank 1=most similar)
|
|
143
|
+
const vecByType = {};
|
|
144
|
+
for (const vr of vectorResults) {
|
|
145
|
+
if (!vecByType[vr.content_type])
|
|
146
|
+
vecByType[vr.content_type] = [];
|
|
147
|
+
vecByType[vr.content_type].push(vr);
|
|
148
|
+
}
|
|
149
|
+
for (const [contentType, results] of Object.entries(vecByType)) {
|
|
150
|
+
results.forEach((vr, idx) => {
|
|
151
|
+
const key = `${contentType}:${vr.content_id}`;
|
|
152
|
+
const existing = rrfScores.get(key);
|
|
153
|
+
const score = 1 / (RRF_K + (idx + 1));
|
|
154
|
+
if (existing) {
|
|
155
|
+
existing.score += score;
|
|
156
|
+
existing.snippet += ` (semantic: ${(vr.similarity * 100).toFixed(0)}%)`;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
rrfScores.set(key, { score, snippet: `${contentType} #${vr.content_id} (semantic: ${(vr.similarity * 100).toFixed(0)}%)`, type: contentType, id: vr.content_id });
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
// Sort by RRF score, group fused results by content type
|
|
164
|
+
const fused = Array.from(rrfScores.values()).sort((a, b) => b.score - a.score);
|
|
165
|
+
const sections = [];
|
|
166
|
+
if (fused.length > 0) {
|
|
167
|
+
const byType = {};
|
|
168
|
+
for (const r of fused) {
|
|
169
|
+
if (!byType[r.type])
|
|
170
|
+
byType[r.type] = [];
|
|
171
|
+
byType[r.type].push(r);
|
|
172
|
+
}
|
|
173
|
+
for (const [contentType, results] of Object.entries(byType)) {
|
|
174
|
+
const label = contentType === 'note' ? 'Data' : contentType.charAt(0).toUpperCase() + contentType.slice(1) + 's';
|
|
175
|
+
sections.push({ label, count: results.length, items: results.slice(0, 10).map((r) => r.snippet) });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// Skills search (FTS only — no vector indexing for skills)
|
|
179
|
+
let skills = [];
|
|
180
|
+
if (searchType === 'all' || searchType === 'skills') {
|
|
181
|
+
skills = store.searchSkills(sanitizedQuery, 10).map((s) => ({
|
|
182
|
+
name: s.name,
|
|
183
|
+
category: s.category || 'uncategorized',
|
|
184
|
+
active: !!s.is_active,
|
|
185
|
+
description: s.description,
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
// Entity graph search
|
|
189
|
+
let entities = [];
|
|
190
|
+
if ((searchType === 'all' || searchType === 'entities') && projectId !== undefined) {
|
|
191
|
+
entities = graph.searchEntities(projectId, query, 10).map((e) => ({
|
|
192
|
+
name: e.name,
|
|
193
|
+
type: e.type,
|
|
194
|
+
relationships: graph.getRelationships(e.id, 'both').length,
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
const body = { query, mode: searchMode, sections, skills, entities };
|
|
198
|
+
const response = renderResult(body, (b, g) => {
|
|
199
|
+
let text = withGlyph(g.brand, `**Search Results for "${b.query}"** _(mode: ${b.mode})_`) + '\n\n';
|
|
200
|
+
for (const section of b.sections) {
|
|
201
|
+
text += `## ${section.label} (${section.count})\n`;
|
|
202
|
+
for (const item of section.items)
|
|
203
|
+
text += `${g.bullet} ${item}\n`;
|
|
204
|
+
text += '\n';
|
|
205
|
+
}
|
|
206
|
+
if (b.skills.length > 0) {
|
|
207
|
+
text += `## Skills (${b.skills.length})\n`;
|
|
208
|
+
for (const s of b.skills) {
|
|
209
|
+
text += `${g.bullet} **${s.name}** (${s.category}) [${s.active ? 'active' : 'inactive'}]\n`;
|
|
210
|
+
text += ` ${s.description}\n`;
|
|
211
|
+
}
|
|
212
|
+
text += '\n';
|
|
213
|
+
}
|
|
214
|
+
if (b.entities.length > 0) {
|
|
215
|
+
text += `## Entities (${b.entities.length})\n`;
|
|
216
|
+
for (const e of b.entities) {
|
|
217
|
+
text += `${g.bullet} **${e.name}** _(${e.type})_ -- ${e.relationships} relationship${e.relationships !== 1 ? 's' : ''}\n`;
|
|
218
|
+
}
|
|
219
|
+
text += '\n';
|
|
220
|
+
}
|
|
221
|
+
if (b.sections.length === 0 && b.skills.length === 0 && b.entities.length === 0) {
|
|
222
|
+
text += '_No results found._\n';
|
|
223
|
+
}
|
|
224
|
+
return text;
|
|
225
|
+
}, {
|
|
226
|
+
// WYRM_CHANNEL=structured summary seam: grouped section/skill/entity
|
|
227
|
+
// counts ride structuredContent unchanged; the text channel collapses
|
|
228
|
+
// to this header + a count roll-up so the model still sees the shape.
|
|
229
|
+
summary: (b, g) => {
|
|
230
|
+
const total = b.sections.reduce((n, s) => n + s.count, 0) + b.skills.length + b.entities.length;
|
|
231
|
+
return withGlyph(g.brand, `**Search Results for "${b.query}"** _(mode: ${b.mode})_ -- ${total} result${total !== 1 ? 's' : ''}`);
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
// READ_ONLY_TOOLS cache publish — dispatcher key convention.
|
|
235
|
+
cache.set(cacheKeyFor('wyrm_search', JSON.stringify(args)), response, 20000);
|
|
236
|
+
return response;
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: "wyrm_constellation",
|
|
241
|
+
description: "Cross-project memory query — search every registered Wyrm project at once for matching truths, artifacts, quests, or design references. Returns candidates grouped by project; the calling AI does semantic ranking on its side. Use this when the operator asks 'have I solved this before?', 'where else have I used X?', or any portfolio-spanning question. Honours per-row cross_project_visibility ('within' = invisible across projects, 'org' = shared, 'public' = anywhere).",
|
|
242
|
+
inputSchema: {
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
query: { type: "string", description: "Search keywords. Sanitised; safe FTS5 subset only." },
|
|
246
|
+
kinds: { type: "array", items: { type: "string", enum: ["truth", "artifact", "quest", "decision", "reference"] }, description: "Restrict to specific kinds. Default: all kinds." },
|
|
247
|
+
visibility: { type: "array", items: { type: "string", enum: ["within", "org", "public"] }, description: "Which visibility levels to include. Default: ['org','public'] — strict cross-project gate." },
|
|
248
|
+
per_project_limit: { type: "number", description: "Max hits per project (default 5, max 50)." },
|
|
249
|
+
caller_project_path: { type: "string", description: "Caller's current project path — excluded from results unless 'within' is in visibility." },
|
|
250
|
+
},
|
|
251
|
+
required: ["query"],
|
|
252
|
+
},
|
|
253
|
+
outputSchema: {
|
|
254
|
+
type: "object",
|
|
255
|
+
properties: {
|
|
256
|
+
query: { type: "string" },
|
|
257
|
+
count: { type: "integer" },
|
|
258
|
+
projects: {
|
|
259
|
+
type: "array",
|
|
260
|
+
items: {
|
|
261
|
+
type: "object",
|
|
262
|
+
properties: {
|
|
263
|
+
project: { type: "string" },
|
|
264
|
+
hits: {
|
|
265
|
+
type: "array",
|
|
266
|
+
items: {
|
|
267
|
+
type: "object",
|
|
268
|
+
properties: {
|
|
269
|
+
kind: { type: "string" },
|
|
270
|
+
id: { type: "integer" },
|
|
271
|
+
title: { type: "string" },
|
|
272
|
+
visibility: { type: "string" },
|
|
273
|
+
snippet: { type: ["string", "null"] },
|
|
274
|
+
},
|
|
275
|
+
required: ["kind", "id", "title", "visibility", "snippet"],
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
},
|
|
279
|
+
required: ["project", "hits"],
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
required: ["query", "count", "projects"],
|
|
284
|
+
},
|
|
285
|
+
annotations: TOOL_ANNOTATIONS.wyrm_constellation,
|
|
286
|
+
aliases: [],
|
|
287
|
+
handler: (args, { store, raw }) => {
|
|
288
|
+
const { query: cQuery, kinds: cKinds, visibility: cVis, per_project_limit: cPerProjLimit, caller_project_path: cCallerPath, } = args;
|
|
289
|
+
let callerProjectId;
|
|
290
|
+
if (cCallerPath) {
|
|
291
|
+
const proj = store.getProject(cCallerPath);
|
|
292
|
+
callerProjectId = proj?.id;
|
|
293
|
+
}
|
|
294
|
+
const hits = constellationQuery(raw(), {
|
|
295
|
+
query: cQuery,
|
|
296
|
+
kinds: cKinds,
|
|
297
|
+
visibility: cVis,
|
|
298
|
+
perProjectLimit: cPerProjLimit,
|
|
299
|
+
callerProjectId,
|
|
300
|
+
});
|
|
301
|
+
// Group by project (the 6.x renderConstellation grouping, now body-side).
|
|
302
|
+
const byProject = new Map();
|
|
303
|
+
for (const h of hits) {
|
|
304
|
+
const arr = byProject.get(h.projectName) ?? [];
|
|
305
|
+
arr.push(h);
|
|
306
|
+
byProject.set(h.projectName, arr);
|
|
307
|
+
}
|
|
308
|
+
const body = {
|
|
309
|
+
query: cQuery,
|
|
310
|
+
count: hits.length,
|
|
311
|
+
projects: Array.from(byProject.entries()).map(([project, items]) => ({
|
|
312
|
+
project,
|
|
313
|
+
hits: items.map((h) => ({
|
|
314
|
+
kind: h.kind, id: h.id, title: h.title, visibility: h.visibility, snippet: h.snippet ?? null,
|
|
315
|
+
})),
|
|
316
|
+
})),
|
|
317
|
+
};
|
|
318
|
+
return renderResult(body, (b, g) => {
|
|
319
|
+
if (b.count === 0) {
|
|
320
|
+
return withGlyph(g.brand, `No constellation matches for *${b.query}* across registered projects.`) +
|
|
321
|
+
`\n\n_Set \`cross_project_visibility\` to \`'org'\` or \`'public'\` on the items you want surfaced here. Default is \`'within'\` -- within-project only._`;
|
|
322
|
+
}
|
|
323
|
+
const lines = [withGlyph(g.brand, `**Constellation** -- ${b.count} match(es) for *${b.query}* across ${b.projects.length} project(s)`)];
|
|
324
|
+
for (const p of b.projects) {
|
|
325
|
+
lines.push('');
|
|
326
|
+
lines.push(`### ${p.project}`);
|
|
327
|
+
for (const h of p.hits) {
|
|
328
|
+
lines.push(`${g.bullet} \`${h.kind}:${h.id}\` **${h.title}** (${h.visibility})`);
|
|
329
|
+
if (h.snippet)
|
|
330
|
+
lines.push(` ${h.snippet}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return lines.join('\n');
|
|
334
|
+
});
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
];
|
|
338
|
+
//# sourceMappingURL=search.js.map
|