driftguard-mcp 0.1.6 → 0.1.7
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/bin.js +17 -56
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -744,15 +744,6 @@ function createWindows(messages, windowSize) {
|
|
|
744
744
|
}
|
|
745
745
|
return windows;
|
|
746
746
|
}
|
|
747
|
-
function extractTopTerms(messages, n = 5) {
|
|
748
|
-
const freq = /* @__PURE__ */ new Map();
|
|
749
|
-
for (const msg of messages) {
|
|
750
|
-
for (const term of tokenize(msg.content)) {
|
|
751
|
-
freq.set(term, (freq.get(term) ?? 0) + 1);
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
return [...freq.entries()].sort((a, b) => b[1] - a[1]).slice(0, n).map(([term]) => term);
|
|
755
|
-
}
|
|
756
747
|
function extractNgrams(text, n = 3) {
|
|
757
748
|
const tokens = tokenize(text).filter((w) => !/^\d/.test(w));
|
|
758
749
|
if (tokens.length < n) return /* @__PURE__ */ new Set();
|
|
@@ -2166,52 +2157,27 @@ var mcp_server_exports = {};
|
|
|
2166
2157
|
__export(mcp_server_exports, {
|
|
2167
2158
|
main: () => main
|
|
2168
2159
|
});
|
|
2169
|
-
function buildHandoff(
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
const durationStr = durationMin !== null ? durationMin >= 60 ? `${Math.floor(durationMin / 60)}h ${durationMin % 60}m` : `${durationMin}m` : "unknown duration";
|
|
2173
|
-
const topTerms = extractTopTerms(chatMessages, 6);
|
|
2174
|
-
const topicsStr = topTerms.length > 0 ? topTerms.join(", ") : "not enough content to determine";
|
|
2175
|
-
const recentUserMessages = messages.filter((m) => m.role === "user").slice(-3).map((m, i) => `${i + 1}. ${m.content.slice(0, 200)}${m.content.length > 200 ? "\u2026" : ""}`).join("\n");
|
|
2176
|
-
let lastCodeSnippet = "";
|
|
2177
|
-
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2178
|
-
const match = [...messages[i].content.matchAll(/```(\w*)\n([\s\S]*?)```/g)].pop();
|
|
2179
|
-
if (match) {
|
|
2180
|
-
const lang = match[1] || "";
|
|
2181
|
-
const code = match[2].split("\n").slice(0, 20).join("\n");
|
|
2182
|
-
lastCodeSnippet = `\`\`\`${lang}
|
|
2183
|
-
${code}
|
|
2184
|
-
\`\`\``;
|
|
2185
|
-
break;
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
const lines = [
|
|
2189
|
-
`## Context Handoff`,
|
|
2190
|
-
``,
|
|
2191
|
-
`**Drift:** ${analysis.score}/100 ${emoji} ${level.toUpperCase()} | **Messages:** ${messages.length} | **Duration:** ${durationStr}`,
|
|
2160
|
+
function buildHandoff() {
|
|
2161
|
+
return [
|
|
2162
|
+
`Please write a \`handoff.md\` file in the current working directory with the following structure:`,
|
|
2192
2163
|
``,
|
|
2193
|
-
|
|
2164
|
+
`## What we accomplished`,
|
|
2165
|
+
`A clear summary of everything completed this session.`,
|
|
2194
2166
|
``,
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
];
|
|
2198
|
-
if (lastCodeSnippet) {
|
|
2199
|
-
lines.push(``, `**Last code context:**`, lastCodeSnippet);
|
|
2200
|
-
}
|
|
2201
|
-
lines.push(
|
|
2167
|
+
`## Current state`,
|
|
2168
|
+
`Where things stand right now \u2014 what's working, what's broken, what's in progress.`,
|
|
2202
2169
|
``,
|
|
2203
|
-
|
|
2204
|
-
|
|
2170
|
+
`## Files modified`,
|
|
2171
|
+
`List of files changed this session and what changed in each.`,
|
|
2205
2172
|
``,
|
|
2206
|
-
|
|
2207
|
-
`
|
|
2173
|
+
`## Open questions / next steps`,
|
|
2174
|
+
`Anything unresolved, pending decisions, or what should be done next.`,
|
|
2208
2175
|
``,
|
|
2209
|
-
|
|
2210
|
-
|
|
2176
|
+
`## Context for next session`,
|
|
2177
|
+
`Key decisions, constraints, or background a fresh session needs to continue without losing context.`,
|
|
2211
2178
|
``,
|
|
2212
|
-
`
|
|
2213
|
-
);
|
|
2214
|
-
return lines.join("\n");
|
|
2179
|
+
`Write the file now.`
|
|
2180
|
+
].join("\n");
|
|
2215
2181
|
}
|
|
2216
2182
|
async function main() {
|
|
2217
2183
|
const transport = new import_stdio.StdioServerTransport();
|
|
@@ -2228,7 +2194,6 @@ var init_mcp_server = __esm({
|
|
|
2228
2194
|
init_session_resolver();
|
|
2229
2195
|
init_drift_calculator();
|
|
2230
2196
|
init_types();
|
|
2231
|
-
init_topic_analyzer();
|
|
2232
2197
|
init_config();
|
|
2233
2198
|
init_storage();
|
|
2234
2199
|
init_ui();
|
|
@@ -2322,16 +2287,12 @@ var init_mcp_server = __esm({
|
|
|
2322
2287
|
];
|
|
2323
2288
|
if (trendLine) lines.push(``, trendLine);
|
|
2324
2289
|
if (isDegrading) {
|
|
2325
|
-
lines.push(
|
|
2326
|
-
``,
|
|
2327
|
-
`---`,
|
|
2328
|
-
buildHandoff(analysis, messages, chatMessages, emoji, level)
|
|
2329
|
-
);
|
|
2290
|
+
lines.push(``, `---`, buildHandoff());
|
|
2330
2291
|
}
|
|
2331
2292
|
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
2332
2293
|
}
|
|
2333
2294
|
if (request.params.name === "get_handoff") {
|
|
2334
|
-
return { content: [{ type: "text", text: buildHandoff(
|
|
2295
|
+
return { content: [{ type: "text", text: buildHandoff() }] };
|
|
2335
2296
|
}
|
|
2336
2297
|
if (request.params.name === "get_trend") {
|
|
2337
2298
|
if (!storage) {
|