@seanhogg/builderforce-memory-mcp 2026.10.22 → 2026.10.23
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-hooks.d.ts","sourceRoot":"","sources":["../../src/install/claude-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA2B3C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"claude-hooks.d.ts","sourceRoot":"","sources":["../../src/install/claude-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AA2B3C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAqPjE;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,IAAI,MAAM,CAiCzC;AAED,qFAAqF;AACrF,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAOpE;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;EAKd,CAAC;AAEX,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAAC,CAAC;AAEvG;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,SAAyB,GAAG,UAAU,CAQpF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACtB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAmDrE"}
|
|
@@ -194,26 +194,52 @@ if (mode === "--capture") {
|
|
|
194
194
|
const msgs = [];
|
|
195
195
|
for (const ln of raw.split("\\n")) { if (ln.trim()) { try { msgs.push(JSON.parse(ln)); } catch { /* partial */ } } }
|
|
196
196
|
|
|
197
|
+
// The harness also writes user-role entries the person never typed. A subagent
|
|
198
|
+
// hand-back or a background-task notification is a whole entry of harness text, so
|
|
199
|
+
// when the newest one is that, there is no human instruction to capture. Reminders
|
|
200
|
+
// and IDE/slash-command echoes ride inside a real message, so they are cut out of it.
|
|
201
|
+
const HARNESS_ENTRY_TAGS = ["agent-message", "task-notification"];
|
|
202
|
+
const INJECTED_BLOCK_TAGS = [
|
|
203
|
+
"system-reminder", "ide_opened_file", "ide_selection", "local-command-caveat",
|
|
204
|
+
"local-command-stdout", "command-name", "command-message", "command-args",
|
|
205
|
+
];
|
|
206
|
+
const stripBlocks = (txt) => {
|
|
207
|
+
let out = txt;
|
|
208
|
+
for (const tag of INJECTED_BLOCK_TAGS) {
|
|
209
|
+
for (;;) {
|
|
210
|
+
const start = out.indexOf("<" + tag);
|
|
211
|
+
if (start < 0) break;
|
|
212
|
+
const close = out.indexOf("</" + tag + ">", start);
|
|
213
|
+
out = out.slice(0, start) + (close < 0 ? "" : out.slice(close + tag.length + 3));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return out.trim();
|
|
217
|
+
};
|
|
218
|
+
|
|
197
219
|
let lastUserText = "";
|
|
220
|
+
let sawUser = false;
|
|
198
221
|
let rememberedThisTurn = false;
|
|
199
|
-
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
222
|
+
for (let i = msgs.length - 1; i >= 0 && !sawUser; i--) {
|
|
200
223
|
const m = msgs[i] || {};
|
|
201
224
|
const inner = m.message || m;
|
|
202
225
|
const role = inner.role;
|
|
203
226
|
const content = inner.content;
|
|
204
|
-
if (role === "assistant"
|
|
227
|
+
if (role === "assistant") {
|
|
205
228
|
if (Array.isArray(content)) for (const c of content) {
|
|
206
229
|
if (c && c.type === "tool_use" && typeof c.name === "string" && c.name.includes("memory_remember")) rememberedThisTurn = true;
|
|
207
230
|
}
|
|
208
231
|
}
|
|
209
|
-
if (role === "user"
|
|
232
|
+
if (role === "user") {
|
|
210
233
|
let txt = "";
|
|
211
234
|
if (typeof content === "string") txt = content;
|
|
212
235
|
else if (Array.isArray(content)) for (const c of content) {
|
|
213
236
|
if (typeof c === "string") txt += c + " ";
|
|
214
237
|
else if (c && c.type === "text" && typeof c.text === "string") txt += c.text + " ";
|
|
215
238
|
}
|
|
216
|
-
if (txt.trim())
|
|
239
|
+
if (!txt.trim()) continue; // a tool result, not a turn
|
|
240
|
+
sawUser = true;
|
|
241
|
+
if (m.isMeta || HARNESS_ENTRY_TAGS.some((tag) => txt.includes("<" + tag))) break;
|
|
242
|
+
lastUserText = stripBlocks(txt);
|
|
217
243
|
}
|
|
218
244
|
}
|
|
219
245
|
if (!lastUserText || rememberedThisTurn) process.exit(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-hooks.js","sourceRoot":"","sources":["../../src/install/claude-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnE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AAK,CAAC,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,UAAU;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAE/E,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;AACjG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seanhogg/builderforce-memory-mcp",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.23",
|
|
4
4
|
"mcpName": "io.github.SeanHogg/builderforce-memory",
|
|
5
5
|
"description": "BuilderForce Agent Memory — MCP transport. Exposes @seanhogg/builderforce-memory to any MCP client (Claude Agent SDK in-process, stdio, or HTTP) over a pluggable MemoryBackend, with token-saving fetch-on-demand recall.",
|
|
6
6
|
"type": "module",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@anthropic-ai/claude-agent-sdk": ">=0.1.0",
|
|
59
|
-
"@seanhogg/builderforce-memory": "^2026.10.
|
|
60
|
-
"@seanhogg/builderforce-memory-engine": "^2026.10.
|
|
59
|
+
"@seanhogg/builderforce-memory": "^2026.10.23",
|
|
60
|
+
"@seanhogg/builderforce-memory-engine": "^2026.10.23",
|
|
61
61
|
"fake-indexeddb": "^6.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"fake-indexeddb": "^6.0.0",
|
|
84
84
|
"typescript": "^6.0.3",
|
|
85
85
|
"@typescript/native-preview": "7.0.0-dev.20260627.2",
|
|
86
|
-
"@seanhogg/builderforce-memory": "2026.10.
|
|
87
|
-
"@seanhogg/builderforce-memory-engine": "2026.10.
|
|
86
|
+
"@seanhogg/builderforce-memory": "2026.10.23",
|
|
87
|
+
"@seanhogg/builderforce-memory-engine": "2026.10.23"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=18.0.0"
|
package/server.json
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"source": "github",
|
|
9
9
|
"subfolder": "packages/memory-mcp"
|
|
10
10
|
},
|
|
11
|
-
"version": "2026.10.
|
|
11
|
+
"version": "2026.10.23",
|
|
12
12
|
"websiteUrl": "https://builderforce.ai",
|
|
13
13
|
"packages": [
|
|
14
14
|
{
|
|
15
15
|
"registryType": "npm",
|
|
16
16
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
17
17
|
"identifier": "@seanhogg/builderforce-memory-mcp",
|
|
18
|
-
"version": "2026.10.
|
|
18
|
+
"version": "2026.10.23",
|
|
19
19
|
"transport": {
|
|
20
20
|
"type": "stdio"
|
|
21
21
|
},
|
|
@@ -200,26 +200,52 @@ if (mode === "--capture") {
|
|
|
200
200
|
const msgs = [];
|
|
201
201
|
for (const ln of raw.split("\\n")) { if (ln.trim()) { try { msgs.push(JSON.parse(ln)); } catch { /* partial */ } } }
|
|
202
202
|
|
|
203
|
+
// The harness also writes user-role entries the person never typed. A subagent
|
|
204
|
+
// hand-back or a background-task notification is a whole entry of harness text, so
|
|
205
|
+
// when the newest one is that, there is no human instruction to capture. Reminders
|
|
206
|
+
// and IDE/slash-command echoes ride inside a real message, so they are cut out of it.
|
|
207
|
+
const HARNESS_ENTRY_TAGS = ["agent-message", "task-notification"];
|
|
208
|
+
const INJECTED_BLOCK_TAGS = [
|
|
209
|
+
"system-reminder", "ide_opened_file", "ide_selection", "local-command-caveat",
|
|
210
|
+
"local-command-stdout", "command-name", "command-message", "command-args",
|
|
211
|
+
];
|
|
212
|
+
const stripBlocks = (txt) => {
|
|
213
|
+
let out = txt;
|
|
214
|
+
for (const tag of INJECTED_BLOCK_TAGS) {
|
|
215
|
+
for (;;) {
|
|
216
|
+
const start = out.indexOf("<" + tag);
|
|
217
|
+
if (start < 0) break;
|
|
218
|
+
const close = out.indexOf("</" + tag + ">", start);
|
|
219
|
+
out = out.slice(0, start) + (close < 0 ? "" : out.slice(close + tag.length + 3));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return out.trim();
|
|
223
|
+
};
|
|
224
|
+
|
|
203
225
|
let lastUserText = "";
|
|
226
|
+
let sawUser = false;
|
|
204
227
|
let rememberedThisTurn = false;
|
|
205
|
-
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
228
|
+
for (let i = msgs.length - 1; i >= 0 && !sawUser; i--) {
|
|
206
229
|
const m = msgs[i] || {};
|
|
207
230
|
const inner = m.message || m;
|
|
208
231
|
const role = inner.role;
|
|
209
232
|
const content = inner.content;
|
|
210
|
-
if (role === "assistant"
|
|
233
|
+
if (role === "assistant") {
|
|
211
234
|
if (Array.isArray(content)) for (const c of content) {
|
|
212
235
|
if (c && c.type === "tool_use" && typeof c.name === "string" && c.name.includes("memory_remember")) rememberedThisTurn = true;
|
|
213
236
|
}
|
|
214
237
|
}
|
|
215
|
-
if (role === "user"
|
|
238
|
+
if (role === "user") {
|
|
216
239
|
let txt = "";
|
|
217
240
|
if (typeof content === "string") txt = content;
|
|
218
241
|
else if (Array.isArray(content)) for (const c of content) {
|
|
219
242
|
if (typeof c === "string") txt += c + " ";
|
|
220
243
|
else if (c && c.type === "text" && typeof c.text === "string") txt += c.text + " ";
|
|
221
244
|
}
|
|
222
|
-
if (txt.trim())
|
|
245
|
+
if (!txt.trim()) continue; // a tool result, not a turn
|
|
246
|
+
sawUser = true;
|
|
247
|
+
if (m.isMeta || HARNESS_ENTRY_TAGS.some((tag) => txt.includes("<" + tag))) break;
|
|
248
|
+
lastUserText = stripBlocks(txt);
|
|
223
249
|
}
|
|
224
250
|
}
|
|
225
251
|
if (!lastUserText || rememberedThisTurn) process.exit(0);
|