@hiveai/mcp 0.4.5 → 0.6.0

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/dist/server.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { HaivePaths } from '@hiveai/core';
2
+ import { HaivePaths, ConfidenceLevel } from '@hiveai/core';
3
+ import { z } from 'zod';
3
4
 
4
5
  interface HaiveContext {
5
6
  paths: HaivePaths;
@@ -22,6 +23,491 @@ declare class SessionTracker {
22
23
  private registerShutdownHandler;
23
24
  }
24
25
 
26
+ declare const GetBriefingInputSchema: {
27
+ task: z.ZodOptional<z.ZodString>;
28
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
29
+ max_tokens: z.ZodDefault<z.ZodNumber>;
30
+ max_memories: z.ZodDefault<z.ZodNumber>;
31
+ include_project_context: z.ZodDefault<z.ZodBoolean>;
32
+ include_module_contexts: z.ZodDefault<z.ZodBoolean>;
33
+ semantic: z.ZodDefault<z.ZodBoolean>;
34
+ include_stale: z.ZodDefault<z.ZodBoolean>;
35
+ track: z.ZodDefault<z.ZodBoolean>;
36
+ format: z.ZodDefault<z.ZodEnum<["full", "compact"]>>;
37
+ symbols: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
38
+ min_semantic_score: z.ZodDefault<z.ZodNumber>;
39
+ };
40
+ type GetBriefingInput = {
41
+ [K in keyof typeof GetBriefingInputSchema]: z.infer<(typeof GetBriefingInputSchema)[K]>;
42
+ };
43
+ interface BriefingMemory {
44
+ id: string;
45
+ scope: string;
46
+ type: string;
47
+ module?: string;
48
+ tags: string[];
49
+ status: string;
50
+ confidence: ConfidenceLevel;
51
+ /** Present when confidence is 'low' or 'unverified' — AI should weight this memory cautiously. */
52
+ unverified?: true;
53
+ read_count: number;
54
+ reasons: Array<"anchor" | "module" | "domain" | "semantic">;
55
+ match_quality: "exact" | "partial" | "semantic";
56
+ semantic_score?: number;
57
+ body: string;
58
+ file_path: string;
59
+ }
60
+ interface CodeMapSymbolHit {
61
+ symbol: string;
62
+ /** files that export this symbol */
63
+ locations: Array<{
64
+ file: string;
65
+ kind: string;
66
+ line: number;
67
+ description?: string;
68
+ }>;
69
+ }
70
+ interface ActionRequiredItem {
71
+ /** Memory id containing the alert */
72
+ id: string;
73
+ /** Short human-readable summary of the issue */
74
+ summary: string;
75
+ /**
76
+ * The exact message to show the developer before doing anything.
77
+ * Copy-paste this verbatim — do NOT paraphrase or act before confirmation.
78
+ */
79
+ developer_message: string;
80
+ }
81
+ interface BriefingOutput {
82
+ task?: string;
83
+ search_mode: "semantic" | "literal_fallback" | "literal";
84
+ match_quality_note?: string;
85
+ inferred_modules: string[];
86
+ last_session?: {
87
+ id: string;
88
+ scope: string;
89
+ revision_count: number;
90
+ body: string;
91
+ };
92
+ project_context: {
93
+ content: string;
94
+ truncated: boolean;
95
+ is_template?: boolean;
96
+ auto_generated?: boolean;
97
+ } | null;
98
+ module_contexts: Array<{
99
+ name: string;
100
+ content: string;
101
+ truncated: boolean;
102
+ }>;
103
+ memories: BriefingMemory[];
104
+ symbol_locations?: CodeMapSymbolHit[];
105
+ /**
106
+ * Memories that require explicit human confirmation before any code action.
107
+ * IMPORTANT: for each item, show developer_message to the developer and
108
+ * wait for explicit approval before modifying any code.
109
+ * These are surfaced separately from memories to make them impossible to miss.
110
+ */
111
+ action_required: ActionRequiredItem[];
112
+ decay_warnings: string[];
113
+ setup_warnings: string[];
114
+ /**
115
+ * True when this briefing carries little actionable signal:
116
+ * - project-context.md is still the default template
117
+ * - no memories matched the task (or none exist at all)
118
+ * - no previous session recap
119
+ * Clients can use this flag to skip surfacing a near-empty briefing to the model.
120
+ */
121
+ low_value?: true;
122
+ /**
123
+ * Short, action-oriented hints surfaced to the agent based on the briefing payload.
124
+ * Examples: "haive is uninitialized — use Read/Grep directly", "gotcha memories present — read first".
125
+ * Always non-empty when low_value=true.
126
+ */
127
+ hints?: string[];
128
+ estimated_tokens: number;
129
+ budget: {
130
+ max_tokens: number;
131
+ spent: {
132
+ project: number;
133
+ modules: number;
134
+ memories: number;
135
+ };
136
+ };
137
+ }
138
+ declare function getBriefing(input: GetBriefingInput, ctx: HaiveContext): Promise<BriefingOutput>;
139
+
140
+ declare const CodeMapInputSchema: {
141
+ file: z.ZodOptional<z.ZodString>;
142
+ symbol: z.ZodOptional<z.ZodString>;
143
+ paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
144
+ max_files: z.ZodDefault<z.ZodNumber>;
145
+ max_tokens: z.ZodOptional<z.ZodNumber>;
146
+ };
147
+ type CodeMapInput = {
148
+ [K in keyof typeof CodeMapInputSchema]: z.infer<(typeof CodeMapInputSchema)[K]>;
149
+ };
150
+ interface CodeMapToolOutput {
151
+ available: boolean;
152
+ generated_at?: string;
153
+ total_files?: number;
154
+ files: Array<{
155
+ path: string;
156
+ summary?: string;
157
+ loc: number;
158
+ exports: Array<{
159
+ name: string;
160
+ kind: string;
161
+ description?: string;
162
+ line: number;
163
+ }>;
164
+ }>;
165
+ /** Number of matched files dropped due to max_files / max_tokens. */
166
+ truncated?: number;
167
+ /** True when at least one file was dropped to fit the token budget. */
168
+ budget_clipped?: true;
169
+ notice?: string;
170
+ }
171
+ declare function codeMapTool(input: CodeMapInput, ctx: HaiveContext): Promise<CodeMapToolOutput>;
172
+
173
+ declare const GetRecapInputSchema: {
174
+ scope: z.ZodDefault<z.ZodEnum<["personal", "team", "any"]>>;
175
+ };
176
+ type GetRecapInput = {
177
+ [K in keyof typeof GetRecapInputSchema]: z.infer<(typeof GetRecapInputSchema)[K]>;
178
+ };
179
+ interface GetRecapOutput {
180
+ recap: {
181
+ id: string;
182
+ scope: string;
183
+ revision_count: number;
184
+ created_at: string;
185
+ body: string;
186
+ } | null;
187
+ notice?: string;
188
+ }
189
+ /**
190
+ * Lightweight alternative to get_briefing when you ONLY need the previous
191
+ * session recap (e.g. resuming a long task between sessions). Skips project
192
+ * context, modules, and memory ranking — pays only the recap's token cost.
193
+ */
194
+ declare function getRecap(input: GetRecapInput, ctx: HaiveContext): Promise<GetRecapOutput>;
195
+
196
+ declare const MemRelevantToInputSchema: {
197
+ task: z.ZodString;
198
+ files: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
199
+ limit: z.ZodDefault<z.ZodNumber>;
200
+ min_semantic_score: z.ZodDefault<z.ZodNumber>;
201
+ format: z.ZodDefault<z.ZodEnum<["full", "compact"]>>;
202
+ };
203
+ type MemRelevantToInput = {
204
+ [K in keyof typeof MemRelevantToInputSchema]: z.infer<(typeof MemRelevantToInputSchema)[K]>;
205
+ };
206
+ interface MemRelevantToOutput {
207
+ task: string;
208
+ search_mode: "semantic" | "literal_fallback" | "literal";
209
+ memories: BriefingMemory[];
210
+ hints?: string[];
211
+ /**
212
+ * True when the search returned zero memories — clients can skip surfacing
213
+ * an empty payload to the model.
214
+ */
215
+ empty?: true;
216
+ }
217
+ /**
218
+ * One-shot ranked memories for a task. Use instead of get_briefing when you
219
+ * already have project context loaded and only want the relevant memory layer.
220
+ *
221
+ * Runs the same ranking (anchor / module / literal / semantic) as get_briefing
222
+ * but skips project_context, module_contexts, action_required, etc. — paying
223
+ * only the cost of the memory bodies you actually get back.
224
+ */
225
+ declare function memRelevantTo(input: MemRelevantToInput, ctx: HaiveContext): Promise<MemRelevantToOutput>;
226
+
227
+ declare const CodeSearchInputSchema: {
228
+ query: z.ZodString;
229
+ k: z.ZodDefault<z.ZodNumber>;
230
+ min_score: z.ZodDefault<z.ZodNumber>;
231
+ };
232
+ type CodeSearchInput = {
233
+ [K in keyof typeof CodeSearchInputSchema]: z.infer<(typeof CodeSearchInputSchema)[K]>;
234
+ };
235
+ interface CodeSearchHit {
236
+ file: string;
237
+ name: string;
238
+ kind: string;
239
+ line: number;
240
+ description?: string;
241
+ score: number;
242
+ }
243
+ interface CodeSearchOutput {
244
+ available: boolean;
245
+ hits: CodeSearchHit[];
246
+ notice?: string;
247
+ }
248
+ declare function codeSearch(input: CodeSearchInput, ctx: HaiveContext): Promise<CodeSearchOutput>;
249
+
250
+ declare const WhyThisFileInputSchema: {
251
+ path: z.ZodString;
252
+ git_log_limit: z.ZodDefault<z.ZodNumber>;
253
+ memory_limit: z.ZodDefault<z.ZodNumber>;
254
+ };
255
+ type WhyThisFileInput = {
256
+ [K in keyof typeof WhyThisFileInputSchema]: z.infer<(typeof WhyThisFileInputSchema)[K]>;
257
+ };
258
+ interface WhyThisFileOutput {
259
+ file: string;
260
+ exists: boolean;
261
+ recent_commits: Array<{
262
+ sha: string;
263
+ author: string;
264
+ relative_date: string;
265
+ subject: string;
266
+ }>;
267
+ memories: Array<{
268
+ id: string;
269
+ type: string;
270
+ scope: string;
271
+ confidence: string;
272
+ body_preview: string;
273
+ }>;
274
+ code_map_entry: {
275
+ summary?: string;
276
+ loc: number;
277
+ exports: Array<{
278
+ name: string;
279
+ kind: string;
280
+ line: number;
281
+ description?: string;
282
+ }>;
283
+ } | null;
284
+ hints?: string[];
285
+ }
286
+ /**
287
+ * One-shot file-context lookup: combines recent git history, memories anchored
288
+ * to the path, and the code-map entry. Designed to answer "why is this file
289
+ * the way it is?" in a single call instead of 3-4 manual ones.
290
+ */
291
+ declare function whyThisFile(input: WhyThisFileInput, ctx: HaiveContext): Promise<WhyThisFileOutput>;
292
+
293
+ declare const AntiPatternsCheckInputSchema: {
294
+ diff: z.ZodOptional<z.ZodString>;
295
+ paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
296
+ limit: z.ZodDefault<z.ZodNumber>;
297
+ semantic: z.ZodDefault<z.ZodBoolean>;
298
+ };
299
+ type AntiPatternsCheckInput = {
300
+ [K in keyof typeof AntiPatternsCheckInputSchema]: z.infer<(typeof AntiPatternsCheckInputSchema)[K]>;
301
+ };
302
+ interface AntiPatternsWarning {
303
+ id: string;
304
+ type: "attempt" | "gotcha";
305
+ scope: string;
306
+ confidence: string;
307
+ body_preview: string;
308
+ reasons: Array<"anchor" | "literal" | "semantic">;
309
+ semantic_score?: number;
310
+ }
311
+ interface AntiPatternsCheckOutput {
312
+ /** Total number of attempt+gotcha memories that exist in this project. */
313
+ scanned: number;
314
+ warnings: AntiPatternsWarning[];
315
+ notice?: string;
316
+ }
317
+ /**
318
+ * Scan a diff (or set of paths) against documented attempt/gotcha memories.
319
+ * Surfaces "you are about to repeat a known mistake" warnings BEFORE you commit.
320
+ *
321
+ * Matching strategy:
322
+ * 1. Anchor — memories anchored to any of the changed paths
323
+ * 2. Literal — tokens from the diff overlap with memory body
324
+ * 3. Semantic — cosine similarity (when enabled and index available)
325
+ */
326
+ declare function antiPatternsCheck(input: AntiPatternsCheckInput, ctx: HaiveContext): Promise<AntiPatternsCheckOutput>;
327
+
328
+ declare const MemDistillInputSchema: {
329
+ since_days: z.ZodDefault<z.ZodNumber>;
330
+ min_cluster: z.ZodDefault<z.ZodNumber>;
331
+ type_filter: z.ZodDefault<z.ZodEnum<["gotcha", "attempt", "all"]>>;
332
+ scope: z.ZodDefault<z.ZodEnum<["personal", "team", "module", "any"]>>;
333
+ };
334
+ type MemDistillInput = {
335
+ [K in keyof typeof MemDistillInputSchema]: z.infer<(typeof MemDistillInputSchema)[K]>;
336
+ };
337
+ interface DistillCluster {
338
+ suggested_topic: string;
339
+ suggested_type: "convention" | "gotcha";
340
+ member_ids: string[];
341
+ overlapping_paths: string[];
342
+ common_keywords: string[];
343
+ sample_titles: string[];
344
+ /** ISO date of the latest member */
345
+ latest_at: string;
346
+ }
347
+ interface MemDistillOutput {
348
+ scanned: number;
349
+ /** Memories that didn't fit any cluster (kept here so callers can inspect singletons). */
350
+ singletons: number;
351
+ clusters: DistillCluster[];
352
+ notice?: string;
353
+ }
354
+ /**
355
+ * Cluster recurring observations / attempts so a human can collapse N similar
356
+ * memories into one richer convention/gotcha. Uses cheap heuristics (anchor
357
+ * path overlap + body keyword overlap) — no embeddings needed.
358
+ *
359
+ * Output is *advisory*: nothing is written to disk. The caller (CLI / human)
360
+ * decides whether to mem_save the consolidated form.
361
+ */
362
+ declare function memDistill(input: MemDistillInput, ctx: HaiveContext): Promise<MemDistillOutput>;
363
+
364
+ declare const WhyThisDecisionInputSchema: {
365
+ id: z.ZodString;
366
+ git_log_limit: z.ZodDefault<z.ZodNumber>;
367
+ };
368
+ type WhyThisDecisionInput = {
369
+ [K in keyof typeof WhyThisDecisionInputSchema]: z.infer<(typeof WhyThisDecisionInputSchema)[K]>;
370
+ };
371
+ interface WhyThisDecisionOutput {
372
+ found: boolean;
373
+ decision?: {
374
+ id: string;
375
+ type: string;
376
+ scope: string;
377
+ status: string;
378
+ confidence: string;
379
+ body: string;
380
+ created_at: string;
381
+ };
382
+ /** Memories explicitly linked via related_ids on the decision (or vice versa). */
383
+ related: Array<{
384
+ id: string;
385
+ type: string;
386
+ scope: string;
387
+ confidence: string;
388
+ body_preview: string;
389
+ relation: "explicit" | "back-link";
390
+ }>;
391
+ /** Other memories anchored to overlapping paths — implicit context. */
392
+ path_neighbors: Array<{
393
+ id: string;
394
+ type: string;
395
+ scope: string;
396
+ confidence: string;
397
+ overlap: string[];
398
+ body_preview: string;
399
+ }>;
400
+ /** Recent git commits touching any of the decision's anchored paths. */
401
+ recent_commits: Array<{
402
+ path: string;
403
+ sha: string;
404
+ author: string;
405
+ relative_date: string;
406
+ subject: string;
407
+ }>;
408
+ hints?: string[];
409
+ notice?: string;
410
+ }
411
+ /**
412
+ * Trace the genealogy of a `decision` memory: the decision itself + memories
413
+ * explicitly linked to it + memories anchored to overlapping paths + recent
414
+ * commits touching those paths. One call instead of 4-5 manual lookups.
415
+ *
416
+ * Works on any memory type, but is optimized for `decision` and `architecture`.
417
+ */
418
+ declare function whyThisDecision(input: WhyThisDecisionInput, ctx: HaiveContext): Promise<WhyThisDecisionOutput>;
419
+
420
+ declare const MemConflictsInputSchema: {
421
+ id: z.ZodString;
422
+ min_score: z.ZodDefault<z.ZodNumber>;
423
+ semantic: z.ZodDefault<z.ZodBoolean>;
424
+ };
425
+ type MemConflictsInput = {
426
+ [K in keyof typeof MemConflictsInputSchema]: z.infer<(typeof MemConflictsInputSchema)[K]>;
427
+ };
428
+ type ConflictReason = "opposite-status" | "attempt-vs-convention-same-paths" | "polarity-keywords" | "explicit-contradiction-tag";
429
+ interface ConflictHit {
430
+ id: string;
431
+ type: string;
432
+ scope: string;
433
+ status: string;
434
+ confidence: string;
435
+ body_preview: string;
436
+ similarity: number | null;
437
+ reasons: ConflictReason[];
438
+ shared_paths: string[];
439
+ }
440
+ interface MemConflictsOutput {
441
+ found: boolean;
442
+ target?: {
443
+ id: string;
444
+ type: string;
445
+ status: string;
446
+ };
447
+ scanned: number;
448
+ conflicts: ConflictHit[];
449
+ notice?: string;
450
+ }
451
+ /**
452
+ * Find memories that potentially CONTRADICT the given memory. Useful before
453
+ * relying on a memory's advice — surfaces "another memory says the opposite".
454
+ *
455
+ * Detection layers (any of these triggers a hit):
456
+ * - Opposite status: target is validated, neighbor is rejected — for the same topic
457
+ * - Type mismatch on overlapping paths: an `attempt` (don't do X) coexists with
458
+ * a `convention` (do X) anchored to overlapping paths
459
+ * - Polarity keywords: target says "use X" while a semantic neighbor says "don't use X"
460
+ * - Explicit contradiction tag (#contradicts:<id>) in either body
461
+ */
462
+ declare function memConflicts(input: MemConflictsInput, ctx: HaiveContext): Promise<MemConflictsOutput>;
463
+
464
+ declare const PreCommitCheckInputSchema: {
465
+ diff: z.ZodOptional<z.ZodString>;
466
+ paths: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
467
+ block_on: z.ZodDefault<z.ZodEnum<["any", "high-confidence", "never"]>>;
468
+ semantic: z.ZodDefault<z.ZodBoolean>;
469
+ };
470
+ type PreCommitCheckInput = {
471
+ [K in keyof typeof PreCommitCheckInputSchema]: z.infer<(typeof PreCommitCheckInputSchema)[K]>;
472
+ };
473
+ interface PreCommitCheckOutput {
474
+ /** True when at least one finding meets the configured block_on threshold. */
475
+ should_block: boolean;
476
+ /** Per-section summary; clients should surface the warnings + reasons to the user. */
477
+ summary: {
478
+ anti_patterns: number;
479
+ relevant_memories: number;
480
+ stale_anchors: number;
481
+ };
482
+ warnings: AntiPatternsWarning[];
483
+ /** Memories anchored to the touched files — convention reminders for the change author. */
484
+ relevant_memories: Array<{
485
+ id: string;
486
+ type: string;
487
+ confidence: string;
488
+ body_preview: string;
489
+ }>;
490
+ /** Memories whose anchored paths overlap with the diff AND are now stale — likely outdated knowledge. */
491
+ stale_anchors: Array<{
492
+ id: string;
493
+ paths: string[];
494
+ body_preview: string;
495
+ }>;
496
+ notice?: string;
497
+ }
498
+ /**
499
+ * One-shot "should I block this commit?" check.
500
+ *
501
+ * Combines three signals into a single call agents and git hooks can consume:
502
+ * 1. anti_patterns_check — known gotchas/attempts that match the diff
503
+ * 2. mem_for_files — conventions/decisions anchored to touched files
504
+ * 3. mem_verify — memories whose anchors are stale (knowledge may be wrong)
505
+ *
506
+ * Returns should_block per the configured threshold, plus the raw findings so
507
+ * the caller can render them. CLI wrapper: `haive precommit`.
508
+ */
509
+ declare function preCommitCheck(input: PreCommitCheckInput, ctx: HaiveContext): Promise<PreCommitCheckOutput>;
510
+
25
511
  declare const SERVER_NAME = "haive";
26
512
  declare const SERVER_VERSION: string;
27
513
  declare function createHaiveServer(options?: CreateContextOptions): {
@@ -30,4 +516,4 @@ declare function createHaiveServer(options?: CreateContextOptions): {
30
516
  tracker: SessionTracker;
31
517
  };
32
518
 
33
- export { SERVER_NAME, SERVER_VERSION, createHaiveServer };
519
+ export { type AntiPatternsCheckInput, type AntiPatternsCheckOutput, type BriefingOutput, type CodeMapInput, type CodeMapToolOutput, type CodeSearchInput, type CodeSearchOutput, type GetBriefingInput, type GetRecapInput, type GetRecapOutput, type MemConflictsInput, type MemConflictsOutput, type MemDistillInput, type MemDistillOutput, type MemRelevantToInput, type MemRelevantToOutput, type PreCommitCheckInput, type PreCommitCheckOutput, SERVER_NAME, SERVER_VERSION, type WhyThisDecisionInput, type WhyThisDecisionOutput, type WhyThisFileInput, type WhyThisFileOutput, antiPatternsCheck, codeMapTool, codeSearch, createHaiveServer, getBriefing, getRecap, memConflicts, memDistill, memRelevantTo, preCommitCheck, whyThisDecision, whyThisFile };