@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/index.js
CHANGED
|
@@ -1127,7 +1127,11 @@ import {
|
|
|
1127
1127
|
import { z as z16 } from "zod";
|
|
1128
1128
|
|
|
1129
1129
|
// src/session-tracker.ts
|
|
1130
|
-
import {
|
|
1130
|
+
import {
|
|
1131
|
+
appendUsageEvent,
|
|
1132
|
+
appendRuntimeJournalEntry,
|
|
1133
|
+
loadConfig as loadConfig2
|
|
1134
|
+
} from "@hiveai/core";
|
|
1131
1135
|
import { mkdir as mkdir5, writeFile as writeFile9, rm } from "fs/promises";
|
|
1132
1136
|
import { existsSync as existsSync16 } from "fs";
|
|
1133
1137
|
import path7 from "path";
|
|
@@ -1200,6 +1204,14 @@ var SessionTracker = class {
|
|
|
1200
1204
|
recapId = result.id;
|
|
1201
1205
|
} catch {
|
|
1202
1206
|
}
|
|
1207
|
+
void appendRuntimeJournalEntry(this.ctx.paths, {
|
|
1208
|
+
kind: "session_end",
|
|
1209
|
+
message: recapId ? `auto session close | ${toolSummary} | recap:${recapId}` : `auto session close | ${toolSummary}`,
|
|
1210
|
+
meta: {
|
|
1211
|
+
recap_id: recapId ?? null,
|
|
1212
|
+
total_tool_calls: totalCalls
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1203
1215
|
const ranPostTask = this.events.some(
|
|
1204
1216
|
(e) => e.tool === "mem_session_end" && !e.summary?.startsWith("Auto-captured")
|
|
1205
1217
|
);
|
|
@@ -3070,19 +3082,27 @@ function gitFileDiff(root, file, sinceDays) {
|
|
|
3070
3082
|
|
|
3071
3083
|
// src/tools/mem-conflict-candidates.ts
|
|
3072
3084
|
import { existsSync as existsSync27 } from "fs";
|
|
3073
|
-
import {
|
|
3085
|
+
import {
|
|
3086
|
+
findLexicalConflictPairs,
|
|
3087
|
+
findTopicStatusConflictPairs,
|
|
3088
|
+
loadMemoriesFromDir as loadMemoriesFromDir21
|
|
3089
|
+
} from "@hiveai/core";
|
|
3074
3090
|
import { z as z30 } from "zod";
|
|
3075
3091
|
var MemConflictCandidatesInputSchema = {
|
|
3076
3092
|
since_days: z30.number().int().positive().max(3650).default(365).describe("Only memories created since N days ago"),
|
|
3077
3093
|
types: z30.array(z30.enum(["decision", "architecture", "convention", "gotcha"])).default(["decision", "architecture"]).describe("Memory types scanned for pairwise lexical overlap"),
|
|
3078
3094
|
min_jaccard: z30.number().min(0).max(1).default(0.45).describe("Minimum Jaccard token similarity to surface as a candidate pair"),
|
|
3079
3095
|
max_pairs: z30.number().int().positive().max(100).default(20).describe("Cap pairs returned"),
|
|
3080
|
-
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.")
|
|
3096
|
+
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."),
|
|
3097
|
+
max_topic_pairs: z30.number().int().positive().max(100).default(20).describe(
|
|
3098
|
+
"Cap for extra signal: memories sharing the same topic with validated vs rejected status."
|
|
3099
|
+
)
|
|
3081
3100
|
};
|
|
3082
3101
|
async function memConflictCandidates(input, ctx) {
|
|
3083
3102
|
if (!existsSync27(ctx.paths.memoriesDir)) {
|
|
3084
3103
|
return {
|
|
3085
3104
|
pairs: [],
|
|
3105
|
+
topic_status_pairs: [],
|
|
3086
3106
|
scanned: 0,
|
|
3087
3107
|
truncated: false,
|
|
3088
3108
|
notice: "No .ai/memories directory."
|
|
@@ -3096,8 +3116,9 @@ async function memConflictCandidates(input, ctx) {
|
|
|
3096
3116
|
maxPairs: input.max_pairs,
|
|
3097
3117
|
maxScan: input.max_scan
|
|
3098
3118
|
});
|
|
3099
|
-
const
|
|
3100
|
-
|
|
3119
|
+
const topicStatusPairs = findTopicStatusConflictPairs(all, input.max_topic_pairs);
|
|
3120
|
+
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;
|
|
3121
|
+
return { pairs, topic_status_pairs: topicStatusPairs, scanned, truncated, notice };
|
|
3101
3122
|
}
|
|
3102
3123
|
|
|
3103
3124
|
// src/tools/mem-resolve-project.ts
|
|
@@ -3151,13 +3172,47 @@ async function memTimeline(input, ctx) {
|
|
|
3151
3172
|
return { entries, total: entries.length, notice };
|
|
3152
3173
|
}
|
|
3153
3174
|
|
|
3154
|
-
// src/
|
|
3175
|
+
// src/tools/runtime-journal-append.ts
|
|
3176
|
+
import { appendRuntimeJournalEntry as appendRuntimeJournalEntry2 } from "@hiveai/core";
|
|
3155
3177
|
import { z as z34 } from "zod";
|
|
3178
|
+
var RuntimeJournalAppendInputSchema = {
|
|
3179
|
+
message: z34.string().min(1).describe("Short line to append to the runtime session journal"),
|
|
3180
|
+
kind: z34.enum(["note", "session_end", "mcp"]).default("note"),
|
|
3181
|
+
tool: z34.string().optional().describe("When kind=mcp, which tool name (optional)")
|
|
3182
|
+
};
|
|
3183
|
+
async function runtimeJournalAppend(input, ctx) {
|
|
3184
|
+
await appendRuntimeJournalEntry2(ctx.paths, {
|
|
3185
|
+
kind: input.kind,
|
|
3186
|
+
message: input.message,
|
|
3187
|
+
...input.tool ? { tool: input.tool } : {}
|
|
3188
|
+
});
|
|
3189
|
+
return {
|
|
3190
|
+
ok: true,
|
|
3191
|
+
path_hint: `${ctx.paths.runtimeDir}/session-journal.ndjson`
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
|
|
3195
|
+
// src/tools/runtime-journal-tail.ts
|
|
3196
|
+
import { readRuntimeJournalTail } from "@hiveai/core";
|
|
3197
|
+
import { z as z35 } from "zod";
|
|
3198
|
+
var RuntimeJournalTailInputSchema = {
|
|
3199
|
+
limit: z35.number().int().positive().max(500).default(30).describe("Last N journal entries to return")
|
|
3200
|
+
};
|
|
3201
|
+
async function runtimeJournalTail(input, ctx) {
|
|
3202
|
+
const entries = await readRuntimeJournalTail(ctx.paths, input.limit);
|
|
3203
|
+
if (entries.length === 0) {
|
|
3204
|
+
return { entries: [], empty: true };
|
|
3205
|
+
}
|
|
3206
|
+
return { entries };
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
// src/prompts/bootstrap-project.ts
|
|
3210
|
+
import { z as z36 } from "zod";
|
|
3156
3211
|
var BootstrapProjectArgsSchema = {
|
|
3157
|
-
module:
|
|
3212
|
+
module: z36.string().optional().describe(
|
|
3158
3213
|
"Optional module name to scope the analysis to (writes to .ai/modules/<module>/context.md)"
|
|
3159
3214
|
),
|
|
3160
|
-
focus:
|
|
3215
|
+
focus: z36.string().optional().describe("Optional area to emphasize (e.g. 'data layer', 'API surface')")
|
|
3161
3216
|
};
|
|
3162
3217
|
var ROOT_TEMPLATE = `# Project context
|
|
3163
3218
|
|
|
@@ -3239,10 +3294,10 @@ ${template}\`\`\`
|
|
|
3239
3294
|
}
|
|
3240
3295
|
|
|
3241
3296
|
// src/prompts/post-task.ts
|
|
3242
|
-
import { z as
|
|
3297
|
+
import { z as z37 } from "zod";
|
|
3243
3298
|
var PostTaskArgsSchema = {
|
|
3244
|
-
task_summary:
|
|
3245
|
-
files_touched:
|
|
3299
|
+
task_summary: z37.string().optional().describe("One sentence describing what you just did"),
|
|
3300
|
+
files_touched: z37.array(z37.string()).optional().describe("Files you created or modified during the task")
|
|
3246
3301
|
};
|
|
3247
3302
|
function postTaskPrompt(args, ctx) {
|
|
3248
3303
|
const taskLine = args.task_summary ? `
|
|
@@ -3326,12 +3381,12 @@ When done, respond with a brief summary: "Saved N memories: [list of IDs]. Sessi
|
|
|
3326
3381
|
}
|
|
3327
3382
|
|
|
3328
3383
|
// src/prompts/import-docs.ts
|
|
3329
|
-
import { z as
|
|
3384
|
+
import { z as z38 } from "zod";
|
|
3330
3385
|
var ImportDocsArgsSchema = {
|
|
3331
|
-
content:
|
|
3332
|
-
source:
|
|
3333
|
-
scope:
|
|
3334
|
-
dry_run:
|
|
3386
|
+
content: z38.string().describe("The documentation content to analyze and import as memories (Markdown, README, ADR, etc.)"),
|
|
3387
|
+
source: z38.string().optional().describe("Origin of the content (file path, URL, or document title) \u2014 used to anchor memories"),
|
|
3388
|
+
scope: z38.enum(["personal", "team"]).default("team").describe("Scope to assign to created memories"),
|
|
3389
|
+
dry_run: z38.boolean().default(false).describe("If true, describe what would be saved without actually calling mem_save")
|
|
3335
3390
|
};
|
|
3336
3391
|
function importDocsPrompt(args, ctx) {
|
|
3337
3392
|
const sourceLine = args.source ? `
|
|
@@ -3396,7 +3451,7 @@ When done, respond with: "Imported N memories: [list of IDs]" or "Nothing action
|
|
|
3396
3451
|
|
|
3397
3452
|
// src/server.ts
|
|
3398
3453
|
var SERVER_NAME = "haive";
|
|
3399
|
-
var SERVER_VERSION = "0.9.
|
|
3454
|
+
var SERVER_VERSION = "0.9.6";
|
|
3400
3455
|
function jsonResult(data) {
|
|
3401
3456
|
return {
|
|
3402
3457
|
content: [
|
|
@@ -4079,14 +4134,17 @@ function createHaiveServer(options = {}) {
|
|
|
4079
4134
|
server.tool(
|
|
4080
4135
|
"mem_conflict_candidates",
|
|
4081
4136
|
[
|
|
4082
|
-
"Bulk
|
|
4137
|
+
"Bulk scan for conflict CANDIDATES (not proof):",
|
|
4083
4138
|
"",
|
|
4084
|
-
"
|
|
4139
|
+
" 1. Lexical similarity (Jaccard) on decision/architecture-like pairs",
|
|
4140
|
+
" 2. Same frontmatter.topic with validated vs rejected \u2014 quick human-review signal",
|
|
4141
|
+
"",
|
|
4142
|
+
"Advisory only \u2014 follow with mem_conflicts_with on specific ids.",
|
|
4085
4143
|
"",
|
|
4086
4144
|
"PARAMETERS:",
|
|
4087
|
-
" since_days, types, min_jaccard, max_pairs, max_scan",
|
|
4145
|
+
" since_days, types, min_jaccard, max_pairs, max_scan, max_topic_pairs",
|
|
4088
4146
|
"",
|
|
4089
|
-
"RETURNS: { pairs
|
|
4147
|
+
"RETURNS: { pairs, topic_status_pairs, scanned, truncated, notice? }"
|
|
4090
4148
|
].join("\n"),
|
|
4091
4149
|
MemConflictCandidatesInputSchema,
|
|
4092
4150
|
async (input) => {
|
|
@@ -4094,6 +4152,32 @@ function createHaiveServer(options = {}) {
|
|
|
4094
4152
|
return jsonResult(await memConflictCandidates(input, context));
|
|
4095
4153
|
}
|
|
4096
4154
|
);
|
|
4155
|
+
server.tool(
|
|
4156
|
+
"runtime_journal_append",
|
|
4157
|
+
[
|
|
4158
|
+
"Append one line to `.ai/.runtime/session-journal.ndjson` \u2014 machine-local session continuity.",
|
|
4159
|
+
"",
|
|
4160
|
+
"Does NOT replace team memories; complements mem_session_end recaps for local traces.",
|
|
4161
|
+
"",
|
|
4162
|
+
"PARAMETERS: message, kind (note|session_end|mcp), optional tool",
|
|
4163
|
+
"",
|
|
4164
|
+
"RETURNS: { ok, path_hint }"
|
|
4165
|
+
].join("\n"),
|
|
4166
|
+
RuntimeJournalAppendInputSchema,
|
|
4167
|
+
async (input) => jsonResult(await runtimeJournalAppend(input, context))
|
|
4168
|
+
);
|
|
4169
|
+
server.tool(
|
|
4170
|
+
"runtime_journal_tail",
|
|
4171
|
+
[
|
|
4172
|
+
"Read the last N entries from the runtime session journal (parsed JSON lines).",
|
|
4173
|
+
"",
|
|
4174
|
+
"PARAMETERS: limit (default 30, max 500)",
|
|
4175
|
+
"",
|
|
4176
|
+
"RETURNS: { entries: [...], empty?: true }"
|
|
4177
|
+
].join("\n"),
|
|
4178
|
+
RuntimeJournalTailInputSchema,
|
|
4179
|
+
async (input) => jsonResult(await runtimeJournalTail(input, context))
|
|
4180
|
+
);
|
|
4097
4181
|
server.tool(
|
|
4098
4182
|
"pre_commit_check",
|
|
4099
4183
|
[
|