@hiveai/mcp 0.9.0 → 0.9.2
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 +13 -8
- package/dist/index.js +36 -21
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +15 -1
- package/dist/server.js +45 -8
- package/dist/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.ts
CHANGED
|
@@ -543,5 +543,19 @@ declare function createHaiveServer(options?: CreateContextOptions): {
|
|
|
543
543
|
context: HaiveContext;
|
|
544
544
|
tracker: SessionTracker;
|
|
545
545
|
};
|
|
546
|
+
/** Parse argv for the standalone haive-mcp binary / CLI subprocess parity. */
|
|
547
|
+
declare function parseMcpCliArgs(argv: string[]): {
|
|
548
|
+
root?: string;
|
|
549
|
+
versionOnly: boolean;
|
|
550
|
+
};
|
|
551
|
+
/** Print MCP server version (same as haive CLI when bundled together). */
|
|
552
|
+
declare function printHaiveMcpVersion(): void;
|
|
553
|
+
/**
|
|
554
|
+
* Run the MCP server over stdio. Used by `haive-mcp` and by `haive mcp --stdio`
|
|
555
|
+
* when the MCP implementation is bundled into the CLI.
|
|
556
|
+
*/
|
|
557
|
+
declare function runHaiveMcpStdio(options: {
|
|
558
|
+
root?: string;
|
|
559
|
+
}): Promise<void>;
|
|
546
560
|
|
|
547
|
-
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 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, memConflicts, memDistill, memRelevantTo, patternDetect, preCommitCheck, whyThisDecision, whyThisFile };
|
|
561
|
+
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 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, memConflicts, memDistill, memRelevantTo, parseMcpCliArgs, patternDetect, preCommitCheck, printHaiveMcpVersion, runHaiveMcpStdio, whyThisDecision, whyThisFile };
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/server.ts
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
4
|
|
|
4
5
|
// src/context.ts
|
|
5
6
|
import { findProjectRoot, resolveHaivePaths } from "@hiveai/core";
|
|
@@ -137,7 +138,9 @@ var MemSaveInputSchema = {
|
|
|
137
138
|
),
|
|
138
139
|
slug: z4.string().min(1).describe("Short human-readable identifier \u2014 becomes part of the filename"),
|
|
139
140
|
body: z4.string().describe("Markdown body of the memory"),
|
|
140
|
-
scope: z4.enum(["personal", "team", "module"]).
|
|
141
|
+
scope: z4.enum(["personal", "team", "module"]).optional().describe(
|
|
142
|
+
"Visibility scope: personal | team | module. When omitted, falls back to defaultScope in haive.config.json (default: personal)."
|
|
143
|
+
),
|
|
141
144
|
module: z4.string().optional().describe("Module name (required when scope=module)"),
|
|
142
145
|
tags: z4.array(z4.string()).default([]).describe("Tags for filtering"),
|
|
143
146
|
domain: z4.string().optional().describe("Domain (e.g. transactions, billing)"),
|
|
@@ -159,12 +162,14 @@ async function memSave(input, ctx) {
|
|
|
159
162
|
);
|
|
160
163
|
}
|
|
161
164
|
const existing = existsSync4(ctx.paths.memoriesDir) ? await loadMemoriesFromDir2(ctx.paths.memoriesDir) : [];
|
|
165
|
+
const haiveConfig = await loadConfig(ctx.paths);
|
|
166
|
+
const resolvedScope = input.scope ?? haiveConfig.defaultScope ?? "personal";
|
|
162
167
|
const invalidPaths = input.paths.filter(
|
|
163
168
|
(p) => !existsSync4(path3.resolve(ctx.paths.root, p))
|
|
164
169
|
);
|
|
165
170
|
const incomingHash = bodyHash(input.body);
|
|
166
171
|
const hashDuplicate = existing.find(
|
|
167
|
-
({ memory }) => bodyHash(memory.body) === incomingHash && memory.frontmatter.scope ===
|
|
172
|
+
({ memory }) => bodyHash(memory.body) === incomingHash && memory.frontmatter.scope === resolvedScope
|
|
168
173
|
);
|
|
169
174
|
if (hashDuplicate) {
|
|
170
175
|
throw new Error(
|
|
@@ -173,7 +178,7 @@ async function memSave(input, ctx) {
|
|
|
173
178
|
}
|
|
174
179
|
if (input.topic) {
|
|
175
180
|
const topicMatch = existing.find(
|
|
176
|
-
({ memory }) => memory.frontmatter.topic === input.topic && memory.frontmatter.scope ===
|
|
181
|
+
({ memory }) => memory.frontmatter.topic === input.topic && memory.frontmatter.scope === resolvedScope && (!input.module || memory.frontmatter.module === input.module)
|
|
177
182
|
);
|
|
178
183
|
if (topicMatch) {
|
|
179
184
|
const fm = topicMatch.memory.frontmatter;
|
|
@@ -203,8 +208,6 @@ async function memSave(input, ctx) {
|
|
|
203
208
|
};
|
|
204
209
|
}
|
|
205
210
|
}
|
|
206
|
-
const haiveConfig = await loadConfig(ctx.paths);
|
|
207
|
-
const resolvedScope = input.scope !== "personal" ? input.scope : haiveConfig.defaultScope ?? "personal";
|
|
208
211
|
const frontmatter = buildFrontmatter({
|
|
209
212
|
type: input.type,
|
|
210
213
|
slug: input.slug,
|
|
@@ -1459,8 +1462,9 @@ async function getBriefing(input, ctx) {
|
|
|
1459
1462
|
if (input.track && memories.length > 0) {
|
|
1460
1463
|
await trackReads3(ctx.paths, memories.map((m) => m.id));
|
|
1461
1464
|
const freshUsage = await loadUsageIndex7(ctx.paths);
|
|
1465
|
+
const cfg = await loadConfig3(ctx.paths);
|
|
1462
1466
|
const rule = {
|
|
1463
|
-
minReads: DEFAULT_AUTO_PROMOTE_RULE.minReads,
|
|
1467
|
+
minReads: cfg.autoPromoteMinReads ?? DEFAULT_AUTO_PROMOTE_RULE.minReads,
|
|
1464
1468
|
maxRejections: DEFAULT_AUTO_PROMOTE_RULE.maxRejections
|
|
1465
1469
|
};
|
|
1466
1470
|
for (const m of memories) {
|
|
@@ -2808,7 +2812,9 @@ async function patternDetect(input, ctx) {
|
|
|
2808
2812
|
for (const file of configFiles.slice(0, 5)) {
|
|
2809
2813
|
const diff = gitFileDiff(ctx.paths.root, file, input.since_days);
|
|
2810
2814
|
if (!diff) continue;
|
|
2811
|
-
const
|
|
2815
|
+
const parentDir = path11.basename(path11.dirname(file));
|
|
2816
|
+
const baseName = path11.basename(file).replace(/\.[^.]+$/, "");
|
|
2817
|
+
const slug = `${parentDir}-${baseName}`.replace(/[^a-z0-9]/gi, "-").toLowerCase().slice(0, 40);
|
|
2812
2818
|
matches.push({
|
|
2813
2819
|
kind: "config_change",
|
|
2814
2820
|
signal: `Config file modified: ${file}`,
|
|
@@ -3207,7 +3213,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
3207
3213
|
|
|
3208
3214
|
// src/server.ts
|
|
3209
3215
|
var SERVER_NAME = "haive";
|
|
3210
|
-
var SERVER_VERSION = "0.9.
|
|
3216
|
+
var SERVER_VERSION = "0.9.2";
|
|
3211
3217
|
function jsonResult(data) {
|
|
3212
3218
|
return {
|
|
3213
3219
|
content: [
|
|
@@ -3936,6 +3942,34 @@ function createHaiveServer(options = {}) {
|
|
|
3936
3942
|
);
|
|
3937
3943
|
return { server, context, tracker };
|
|
3938
3944
|
}
|
|
3945
|
+
function parseMcpCliArgs(argv) {
|
|
3946
|
+
for (let i = 2; i < argv.length; i++) {
|
|
3947
|
+
const arg = argv[i];
|
|
3948
|
+
if (arg === "--version" || arg === "-V") {
|
|
3949
|
+
return { versionOnly: true };
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
const out = {};
|
|
3953
|
+
for (let i = 2; i < argv.length; i++) {
|
|
3954
|
+
const arg = argv[i];
|
|
3955
|
+
if (arg === "--root" || arg === "-r") {
|
|
3956
|
+
out.root = argv[++i];
|
|
3957
|
+
} else if (arg?.startsWith("--root=")) {
|
|
3958
|
+
out.root = arg.slice("--root=".length);
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3961
|
+
return { root: out.root, versionOnly: false };
|
|
3962
|
+
}
|
|
3963
|
+
function printHaiveMcpVersion() {
|
|
3964
|
+
console.log(SERVER_VERSION);
|
|
3965
|
+
}
|
|
3966
|
+
async function runHaiveMcpStdio(options) {
|
|
3967
|
+
const { server, context } = createHaiveServer({ root: options.root });
|
|
3968
|
+
console.error(
|
|
3969
|
+
`[haive-mcp] starting server v${SERVER_VERSION} (project root: ${context.paths.root})`
|
|
3970
|
+
);
|
|
3971
|
+
await server.connect(new StdioServerTransport());
|
|
3972
|
+
}
|
|
3939
3973
|
export {
|
|
3940
3974
|
SERVER_NAME,
|
|
3941
3975
|
SERVER_VERSION,
|
|
@@ -3948,8 +3982,11 @@ export {
|
|
|
3948
3982
|
memConflicts,
|
|
3949
3983
|
memDistill,
|
|
3950
3984
|
memRelevantTo,
|
|
3985
|
+
parseMcpCliArgs,
|
|
3951
3986
|
patternDetect,
|
|
3952
3987
|
preCommitCheck,
|
|
3988
|
+
printHaiveMcpVersion,
|
|
3989
|
+
runHaiveMcpStdio,
|
|
3953
3990
|
whyThisDecision,
|
|
3954
3991
|
whyThisFile
|
|
3955
3992
|
};
|