@hiveai/mcp 0.9.5 → 0.9.6
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/index.js +105 -21
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +28 -2
- package/dist/server.js +107 -21
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import * as _hiveai_core from '@hiveai/core';
|
|
3
|
-
import { HaivePaths, ConfidenceLevel, resolveProjectInfo } from '@hiveai/core';
|
|
3
|
+
import { HaivePaths, ConfidenceLevel, resolveProjectInfo, readRuntimeJournalTail } from '@hiveai/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
interface HaiveContext {
|
|
@@ -611,17 +611,43 @@ declare const MemConflictCandidatesInputSchema: {
|
|
|
611
611
|
min_jaccard: z.ZodDefault<z.ZodNumber>;
|
|
612
612
|
max_pairs: z.ZodDefault<z.ZodNumber>;
|
|
613
613
|
max_scan: z.ZodDefault<z.ZodNumber>;
|
|
614
|
+
max_topic_pairs: z.ZodDefault<z.ZodNumber>;
|
|
614
615
|
};
|
|
615
616
|
type MemConflictCandidatesInput = {
|
|
616
617
|
[K in keyof typeof MemConflictCandidatesInputSchema]: z.infer<(typeof MemConflictCandidatesInputSchema)[K]>;
|
|
617
618
|
};
|
|
618
619
|
declare function memConflictCandidates(input: MemConflictCandidatesInput, ctx: HaiveContext): Promise<{
|
|
619
620
|
pairs: _hiveai_core.ConflictCandidatePair[];
|
|
621
|
+
topic_status_pairs: _hiveai_core.TopicStatusPair[];
|
|
620
622
|
scanned: number;
|
|
621
623
|
truncated: boolean;
|
|
622
624
|
notice: string | undefined;
|
|
623
625
|
}>;
|
|
624
626
|
|
|
627
|
+
declare const RuntimeJournalAppendInputSchema: {
|
|
628
|
+
message: z.ZodString;
|
|
629
|
+
kind: z.ZodDefault<z.ZodEnum<["note", "session_end", "mcp"]>>;
|
|
630
|
+
tool: z.ZodOptional<z.ZodString>;
|
|
631
|
+
};
|
|
632
|
+
type RuntimeJournalAppendInput = {
|
|
633
|
+
[K in keyof typeof RuntimeJournalAppendInputSchema]: z.infer<(typeof RuntimeJournalAppendInputSchema)[K]>;
|
|
634
|
+
};
|
|
635
|
+
declare function runtimeJournalAppend(input: RuntimeJournalAppendInput, ctx: HaiveContext): Promise<{
|
|
636
|
+
ok: true;
|
|
637
|
+
path_hint: string;
|
|
638
|
+
}>;
|
|
639
|
+
|
|
640
|
+
declare const RuntimeJournalTailInputSchema: {
|
|
641
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
642
|
+
};
|
|
643
|
+
type RuntimeJournalTailInput = {
|
|
644
|
+
[K in keyof typeof RuntimeJournalTailInputSchema]: z.infer<(typeof RuntimeJournalTailInputSchema)[K]>;
|
|
645
|
+
};
|
|
646
|
+
declare function runtimeJournalTail(input: RuntimeJournalTailInput, ctx: HaiveContext): Promise<{
|
|
647
|
+
entries: Awaited<ReturnType<typeof readRuntimeJournalTail>>;
|
|
648
|
+
empty?: boolean;
|
|
649
|
+
}>;
|
|
650
|
+
|
|
625
651
|
declare const SERVER_NAME = "haive";
|
|
626
652
|
declare const SERVER_VERSION: string;
|
|
627
653
|
declare function createHaiveServer(options?: CreateContextOptions): {
|
|
@@ -644,4 +670,4 @@ declare function runHaiveMcpStdio(options: {
|
|
|
644
670
|
root?: string;
|
|
645
671
|
}): Promise<void>;
|
|
646
672
|
|
|
647
|
-
export { type AntiPatternsCheckInput, type AntiPatternsCheckOutput, type BriefingOutput, type CodeMapInput, type CodeMapToolOutput, type CodeSearchInput, type CodeSearchOutput, type GetBriefingInput, type GetRecapInput, type GetRecapOutput, type MemConflictCandidatesInput, type MemConflictsInput, type MemConflictsOutput, type MemDistillInput, type MemDistillOutput, type MemRelevantToInput, type MemRelevantToOutput, type MemResolveProjectInput, type MemSuggestTopicInput, type MemTimelineInput, type PatternDetectInput, type PatternDetectOutput, type PreCommitCheckInput, type PreCommitCheckOutput, SERVER_NAME, SERVER_VERSION, type WhyThisDecisionInput, type WhyThisDecisionOutput, type WhyThisFileInput, type WhyThisFileOutput, antiPatternsCheck, codeMapTool, codeSearch, createHaiveServer, getBriefing, getRecap, memConflictCandidates, memConflicts, memDistill, memRelevantTo, memResolveProject, memSuggestTopic, memTimeline, parseMcpCliArgs, patternDetect, preCommitCheck, printHaiveMcpVersion, runHaiveMcpStdio, whyThisDecision, whyThisFile };
|
|
673
|
+
export { type AntiPatternsCheckInput, type AntiPatternsCheckOutput, type BriefingOutput, type CodeMapInput, type CodeMapToolOutput, type CodeSearchInput, type CodeSearchOutput, type GetBriefingInput, type GetRecapInput, type GetRecapOutput, type MemConflictCandidatesInput, type MemConflictsInput, type MemConflictsOutput, type MemDistillInput, type MemDistillOutput, type MemRelevantToInput, type MemRelevantToOutput, type MemResolveProjectInput, type MemSuggestTopicInput, type MemTimelineInput, type PatternDetectInput, type PatternDetectOutput, type PreCommitCheckInput, type PreCommitCheckOutput, type RuntimeJournalAppendInput, type RuntimeJournalTailInput, SERVER_NAME, SERVER_VERSION, type WhyThisDecisionInput, type WhyThisDecisionOutput, type WhyThisFileInput, type WhyThisFileOutput, antiPatternsCheck, codeMapTool, codeSearch, createHaiveServer, getBriefing, getRecap, memConflictCandidates, memConflicts, memDistill, memRelevantTo, memResolveProject, memSuggestTopic, memTimeline, parseMcpCliArgs, patternDetect, preCommitCheck, printHaiveMcpVersion, runHaiveMcpStdio, runtimeJournalAppend, runtimeJournalTail, whyThisDecision, whyThisFile };
|
package/dist/server.js
CHANGED
|
@@ -1125,7 +1125,11 @@ import {
|
|
|
1125
1125
|
import { z as z16 } from "zod";
|
|
1126
1126
|
|
|
1127
1127
|
// src/session-tracker.ts
|
|
1128
|
-
import {
|
|
1128
|
+
import {
|
|
1129
|
+
appendUsageEvent,
|
|
1130
|
+
appendRuntimeJournalEntry,
|
|
1131
|
+
loadConfig as loadConfig2
|
|
1132
|
+
} from "@hiveai/core";
|
|
1129
1133
|
import { mkdir as mkdir5, writeFile as writeFile9, rm } from "fs/promises";
|
|
1130
1134
|
import { existsSync as existsSync16 } from "fs";
|
|
1131
1135
|
import path7 from "path";
|
|
@@ -1198,6 +1202,14 @@ var SessionTracker = class {
|
|
|
1198
1202
|
recapId = result.id;
|
|
1199
1203
|
} catch {
|
|
1200
1204
|
}
|
|
1205
|
+
void appendRuntimeJournalEntry(this.ctx.paths, {
|
|
1206
|
+
kind: "session_end",
|
|
1207
|
+
message: recapId ? `auto session close | ${toolSummary} | recap:${recapId}` : `auto session close | ${toolSummary}`,
|
|
1208
|
+
meta: {
|
|
1209
|
+
recap_id: recapId ?? null,
|
|
1210
|
+
total_tool_calls: totalCalls
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1201
1213
|
const ranPostTask = this.events.some(
|
|
1202
1214
|
(e) => e.tool === "mem_session_end" && !e.summary?.startsWith("Auto-captured")
|
|
1203
1215
|
);
|
|
@@ -3068,19 +3080,27 @@ function gitFileDiff(root, file, sinceDays) {
|
|
|
3068
3080
|
|
|
3069
3081
|
// src/tools/mem-conflict-candidates.ts
|
|
3070
3082
|
import { existsSync as existsSync27 } from "fs";
|
|
3071
|
-
import {
|
|
3083
|
+
import {
|
|
3084
|
+
findLexicalConflictPairs,
|
|
3085
|
+
findTopicStatusConflictPairs,
|
|
3086
|
+
loadMemoriesFromDir as loadMemoriesFromDir21
|
|
3087
|
+
} from "@hiveai/core";
|
|
3072
3088
|
import { z as z30 } from "zod";
|
|
3073
3089
|
var MemConflictCandidatesInputSchema = {
|
|
3074
3090
|
since_days: z30.number().int().positive().max(3650).default(365).describe("Only memories created since N days ago"),
|
|
3075
3091
|
types: z30.array(z30.enum(["decision", "architecture", "convention", "gotcha"])).default(["decision", "architecture"]).describe("Memory types scanned for pairwise lexical overlap"),
|
|
3076
3092
|
min_jaccard: z30.number().min(0).max(1).default(0.45).describe("Minimum Jaccard token similarity to surface as a candidate pair"),
|
|
3077
3093
|
max_pairs: z30.number().int().positive().max(100).default(20).describe("Cap pairs returned"),
|
|
3078
|
-
max_scan: z30.number().int().positive().max(2e3).default(500).describe("Maximum memories sampled for O(n\xB2) scan \u2014 excess dropped after chronological sort.")
|
|
3094
|
+
max_scan: z30.number().int().positive().max(2e3).default(500).describe("Maximum memories sampled for O(n\xB2) scan \u2014 excess dropped after chronological sort."),
|
|
3095
|
+
max_topic_pairs: z30.number().int().positive().max(100).default(20).describe(
|
|
3096
|
+
"Cap for extra signal: memories sharing the same topic with validated vs rejected status."
|
|
3097
|
+
)
|
|
3079
3098
|
};
|
|
3080
3099
|
async function memConflictCandidates(input, ctx) {
|
|
3081
3100
|
if (!existsSync27(ctx.paths.memoriesDir)) {
|
|
3082
3101
|
return {
|
|
3083
3102
|
pairs: [],
|
|
3103
|
+
topic_status_pairs: [],
|
|
3084
3104
|
scanned: 0,
|
|
3085
3105
|
truncated: false,
|
|
3086
3106
|
notice: "No .ai/memories directory."
|
|
@@ -3094,8 +3114,9 @@ async function memConflictCandidates(input, ctx) {
|
|
|
3094
3114
|
maxPairs: input.max_pairs,
|
|
3095
3115
|
maxScan: input.max_scan
|
|
3096
3116
|
});
|
|
3097
|
-
const
|
|
3098
|
-
|
|
3117
|
+
const topicStatusPairs = findTopicStatusConflictPairs(all, input.max_topic_pairs);
|
|
3118
|
+
const notice = pairs.length === 0 && topicStatusPairs.length === 0 ? "No lexical or topic-status candidates \u2014 widen since_days/types or lower min_jaccard." : void 0;
|
|
3119
|
+
return { pairs, topic_status_pairs: topicStatusPairs, scanned, truncated, notice };
|
|
3099
3120
|
}
|
|
3100
3121
|
|
|
3101
3122
|
// src/tools/mem-resolve-project.ts
|
|
@@ -3149,13 +3170,47 @@ async function memTimeline(input, ctx) {
|
|
|
3149
3170
|
return { entries, total: entries.length, notice };
|
|
3150
3171
|
}
|
|
3151
3172
|
|
|
3152
|
-
// src/
|
|
3173
|
+
// src/tools/runtime-journal-append.ts
|
|
3174
|
+
import { appendRuntimeJournalEntry as appendRuntimeJournalEntry2 } from "@hiveai/core";
|
|
3153
3175
|
import { z as z34 } from "zod";
|
|
3176
|
+
var RuntimeJournalAppendInputSchema = {
|
|
3177
|
+
message: z34.string().min(1).describe("Short line to append to the runtime session journal"),
|
|
3178
|
+
kind: z34.enum(["note", "session_end", "mcp"]).default("note"),
|
|
3179
|
+
tool: z34.string().optional().describe("When kind=mcp, which tool name (optional)")
|
|
3180
|
+
};
|
|
3181
|
+
async function runtimeJournalAppend(input, ctx) {
|
|
3182
|
+
await appendRuntimeJournalEntry2(ctx.paths, {
|
|
3183
|
+
kind: input.kind,
|
|
3184
|
+
message: input.message,
|
|
3185
|
+
...input.tool ? { tool: input.tool } : {}
|
|
3186
|
+
});
|
|
3187
|
+
return {
|
|
3188
|
+
ok: true,
|
|
3189
|
+
path_hint: `${ctx.paths.runtimeDir}/session-journal.ndjson`
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
// src/tools/runtime-journal-tail.ts
|
|
3194
|
+
import { readRuntimeJournalTail } from "@hiveai/core";
|
|
3195
|
+
import { z as z35 } from "zod";
|
|
3196
|
+
var RuntimeJournalTailInputSchema = {
|
|
3197
|
+
limit: z35.number().int().positive().max(500).default(30).describe("Last N journal entries to return")
|
|
3198
|
+
};
|
|
3199
|
+
async function runtimeJournalTail(input, ctx) {
|
|
3200
|
+
const entries = await readRuntimeJournalTail(ctx.paths, input.limit);
|
|
3201
|
+
if (entries.length === 0) {
|
|
3202
|
+
return { entries: [], empty: true };
|
|
3203
|
+
}
|
|
3204
|
+
return { entries };
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
// src/prompts/bootstrap-project.ts
|
|
3208
|
+
import { z as z36 } from "zod";
|
|
3154
3209
|
var BootstrapProjectArgsSchema = {
|
|
3155
|
-
module:
|
|
3210
|
+
module: z36.string().optional().describe(
|
|
3156
3211
|
"Optional module name to scope the analysis to (writes to .ai/modules/<module>/context.md)"
|
|
3157
3212
|
),
|
|
3158
|
-
focus:
|
|
3213
|
+
focus: z36.string().optional().describe("Optional area to emphasize (e.g. 'data layer', 'API surface')")
|
|
3159
3214
|
};
|
|
3160
3215
|
var ROOT_TEMPLATE = `# Project context
|
|
3161
3216
|
|
|
@@ -3237,10 +3292,10 @@ ${template}\`\`\`
|
|
|
3237
3292
|
}
|
|
3238
3293
|
|
|
3239
3294
|
// src/prompts/post-task.ts
|
|
3240
|
-
import { z as
|
|
3295
|
+
import { z as z37 } from "zod";
|
|
3241
3296
|
var PostTaskArgsSchema = {
|
|
3242
|
-
task_summary:
|
|
3243
|
-
files_touched:
|
|
3297
|
+
task_summary: z37.string().optional().describe("One sentence describing what you just did"),
|
|
3298
|
+
files_touched: z37.array(z37.string()).optional().describe("Files you created or modified during the task")
|
|
3244
3299
|
};
|
|
3245
3300
|
function postTaskPrompt(args, ctx) {
|
|
3246
3301
|
const taskLine = args.task_summary ? `
|
|
@@ -3324,12 +3379,12 @@ When done, respond with a brief summary: "Saved N memories: [list of IDs]. Sessi
|
|
|
3324
3379
|
}
|
|
3325
3380
|
|
|
3326
3381
|
// src/prompts/import-docs.ts
|
|
3327
|
-
import { z as
|
|
3382
|
+
import { z as z38 } from "zod";
|
|
3328
3383
|
var ImportDocsArgsSchema = {
|
|
3329
|
-
content:
|
|
3330
|
-
source:
|
|
3331
|
-
scope:
|
|
3332
|
-
dry_run:
|
|
3384
|
+
content: z38.string().describe("The documentation content to analyze and import as memories (Markdown, README, ADR, etc.)"),
|
|
3385
|
+
source: z38.string().optional().describe("Origin of the content (file path, URL, or document title) \u2014 used to anchor memories"),
|
|
3386
|
+
scope: z38.enum(["personal", "team"]).default("team").describe("Scope to assign to created memories"),
|
|
3387
|
+
dry_run: z38.boolean().default(false).describe("If true, describe what would be saved without actually calling mem_save")
|
|
3333
3388
|
};
|
|
3334
3389
|
function importDocsPrompt(args, ctx) {
|
|
3335
3390
|
const sourceLine = args.source ? `
|
|
@@ -3394,7 +3449,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
3394
3449
|
|
|
3395
3450
|
// src/server.ts
|
|
3396
3451
|
var SERVER_NAME = "haive";
|
|
3397
|
-
var SERVER_VERSION = "0.9.
|
|
3452
|
+
var SERVER_VERSION = "0.9.6";
|
|
3398
3453
|
function jsonResult(data) {
|
|
3399
3454
|
return {
|
|
3400
3455
|
content: [
|
|
@@ -4077,14 +4132,17 @@ function createHaiveServer(options = {}) {
|
|
|
4077
4132
|
server.tool(
|
|
4078
4133
|
"mem_conflict_candidates",
|
|
4079
4134
|
[
|
|
4080
|
-
"Bulk
|
|
4135
|
+
"Bulk scan for conflict CANDIDATES (not proof):",
|
|
4081
4136
|
"",
|
|
4082
|
-
"
|
|
4137
|
+
" 1. Lexical similarity (Jaccard) on decision/architecture-like pairs",
|
|
4138
|
+
" 2. Same frontmatter.topic with validated vs rejected \u2014 quick human-review signal",
|
|
4139
|
+
"",
|
|
4140
|
+
"Advisory only \u2014 follow with mem_conflicts_with on specific ids.",
|
|
4083
4141
|
"",
|
|
4084
4142
|
"PARAMETERS:",
|
|
4085
|
-
" since_days, types, min_jaccard, max_pairs, max_scan",
|
|
4143
|
+
" since_days, types, min_jaccard, max_pairs, max_scan, max_topic_pairs",
|
|
4086
4144
|
"",
|
|
4087
|
-
"RETURNS: { pairs
|
|
4145
|
+
"RETURNS: { pairs, topic_status_pairs, scanned, truncated, notice? }"
|
|
4088
4146
|
].join("\n"),
|
|
4089
4147
|
MemConflictCandidatesInputSchema,
|
|
4090
4148
|
async (input) => {
|
|
@@ -4092,6 +4150,32 @@ function createHaiveServer(options = {}) {
|
|
|
4092
4150
|
return jsonResult(await memConflictCandidates(input, context));
|
|
4093
4151
|
}
|
|
4094
4152
|
);
|
|
4153
|
+
server.tool(
|
|
4154
|
+
"runtime_journal_append",
|
|
4155
|
+
[
|
|
4156
|
+
"Append one line to `.ai/.runtime/session-journal.ndjson` \u2014 machine-local session continuity.",
|
|
4157
|
+
"",
|
|
4158
|
+
"Does NOT replace team memories; complements mem_session_end recaps for local traces.",
|
|
4159
|
+
"",
|
|
4160
|
+
"PARAMETERS: message, kind (note|session_end|mcp), optional tool",
|
|
4161
|
+
"",
|
|
4162
|
+
"RETURNS: { ok, path_hint }"
|
|
4163
|
+
].join("\n"),
|
|
4164
|
+
RuntimeJournalAppendInputSchema,
|
|
4165
|
+
async (input) => jsonResult(await runtimeJournalAppend(input, context))
|
|
4166
|
+
);
|
|
4167
|
+
server.tool(
|
|
4168
|
+
"runtime_journal_tail",
|
|
4169
|
+
[
|
|
4170
|
+
"Read the last N entries from the runtime session journal (parsed JSON lines).",
|
|
4171
|
+
"",
|
|
4172
|
+
"PARAMETERS: limit (default 30, max 500)",
|
|
4173
|
+
"",
|
|
4174
|
+
"RETURNS: { entries: [...], empty?: true }"
|
|
4175
|
+
].join("\n"),
|
|
4176
|
+
RuntimeJournalTailInputSchema,
|
|
4177
|
+
async (input) => jsonResult(await runtimeJournalTail(input, context))
|
|
4178
|
+
);
|
|
4095
4179
|
server.tool(
|
|
4096
4180
|
"pre_commit_check",
|
|
4097
4181
|
[
|
|
@@ -4250,6 +4334,8 @@ export {
|
|
|
4250
4334
|
preCommitCheck,
|
|
4251
4335
|
printHaiveMcpVersion,
|
|
4252
4336
|
runHaiveMcpStdio,
|
|
4337
|
+
runtimeJournalAppend,
|
|
4338
|
+
runtimeJournalTail,
|
|
4253
4339
|
whyThisDecision,
|
|
4254
4340
|
whyThisFile
|
|
4255
4341
|
};
|