Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(agent-hook-plugin): keep the Kimi Code user turn in captures (#5677)

t0saki1c01e94f3471
diff --git a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
index f552a00a9..111273ea2 100644
--- a/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/cursor/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.10",
+ "version": "0.5.11",
"clients": [
"cursor"
],
diff --git a/examples/agent-hook-plugin/hosts/kimicode-turns.mjs b/examples/agent-hook-plugin/hosts/kimicode-turns.mjs
index 1685ae2d4..dc43d6f53 100644
--- a/examples/agent-hook-plugin/hosts/kimicode-turns.mjs
+++ b/examples/agent-hook-plugin/hosts/kimicode-turns.mjs
@@ -94,7 +94,8 @@ export function extractUnseenKimicodeTurns(wirePath, lastTurnId = null) {
continue;
}
if (row.type === "context.append_message" && row.message?.role === "user") {
- pendingUser = textFromContent(row.message.content) || pendingUser;
+ const kind = row.message.origin?.kind;
+ if (!kind || kind === "user") pendingUser = textFromContent(row.message.content) || pendingUser;
continue;
}
if (row.type === "turn.prompt") {
@@ -113,7 +114,8 @@ export function extractUnseenKimicodeTurns(wirePath, lastTurnId = null) {
}
if (event.type === "content.part" && event.part?.type === "text") {
const turnId = attachPending(event.turnId);
- assistants.set(turnId, `${assistants.get(turnId) || ""}${event.part.text || ""}`);
+ const prev = assistants.get(turnId);
+ assistants.set(turnId, prev ? `${prev}\n${event.part.text || ""}` : event.part.text || "");
}
}
diff --git a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
index 4e6313b2b..eaa9a9435 100644
--- a/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
+++ b/examples/agent-hook-plugin/hosts/kimicode/kimi.plugin.json
@@ -1,6 +1,6 @@
{
"name": "openviking-memory",
- "version": "0.5.10",
+ "version": "0.5.11",
"description": "Long-term semantic memory for Kimi Code CLI, powered by OpenViking.",
"author": {
"name": "OpenViking",
diff --git a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
index 133bb45bd..3f9ec02bf 100644
--- a/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/kimicode/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.10",
+ "version": "0.5.11",
"clients": [
"kimicode"
],
diff --git a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
index 0da0dbf7b..dbfd01a61 100644
--- a/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/trae/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.10",
+ "version": "0.5.11",
"clients": [
"trae",
"trae-cn"
diff --git a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
index cfc6fe342..3168c9c23 100644
--- a/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
+++ b/examples/agent-hook-plugin/hosts/zcode/openviking.integration.json
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "openviking-memory",
- "version": "0.5.10",
+ "version": "0.5.11",
"clients": [
"zcode"
],
diff --git a/examples/agent-hook-plugin/plugin.json b/examples/agent-hook-plugin/plugin.json
index 636e80e04..7bbb8ff80 100644
--- a/examples/agent-hook-plugin/plugin.json
+++ b/examples/agent-hook-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "agent-hook-plugin",
- "version": "0.5.10",
+ "version": "0.5.11",
"description": "Long-term semantic memory for Cursor, TRAE, TRAE CN, ZCode and Kimi Code — powered by OpenViking. Auto-recall relevant memories and capture the conversation as it happens.",
"author": {
"name": "OpenViking",
diff --git a/examples/agent-hook-plugin/tests/kimicode-turns.test.mjs b/examples/agent-hook-plugin/tests/kimicode-turns.test.mjs
index dad221c47..2faf22082 100644
--- a/examples/agent-hook-plugin/tests/kimicode-turns.test.mjs
+++ b/examples/agent-hook-plugin/tests/kimicode-turns.test.mjs
@@ -33,6 +33,56 @@ test("wire decoding groups prompt and assistant text under a stable turn id", ()
]);
});
+test("host-generated user messages do not replace the prompt", () => {
+ const dir = mkdtempSync(join(tmpdir(), "ov-kimi-wire-"));
+ const wire = join(dir, "wire.jsonl");
+ writeFileSync(wire, [
+ JSON.stringify({
+ type: "context.append_message",
+ message: {
+ role: "user",
+ origin: { kind: "hook_result", event: "UserPromptSubmit" },
+ content: [{
+ type: "text",
+ text: '<hook_result hook_event="UserPromptSubmit">\n<openviking-context source="recall">old</openviking-context>\n</hook_result>',
+ }],
+ },
+ }),
+ JSON.stringify({ type: "turn.prompt", turnId: 0, origin: { kind: "user" }, input: [{ type: "text", text: "Fix release.json." }] }),
+ JSON.stringify({ type: "context.append_message", message: { role: "user", origin: { kind: "user" }, content: [{ type: "text", text: "Fix release.json." }] } }),
+ JSON.stringify({
+ type: "context.append_message",
+ message: {
+ role: "user",
+ origin: { kind: "injection", variant: "reminder" },
+ content: [{ type: "text", text: "<system-reminder>\nhost reminder\n</system-reminder>" }],
+ },
+ }),
+ JSON.stringify({ type: "context.append_loop_event", event: { type: "content.part", turnId: 0, part: { type: "text", text: "Done." } } }),
+ JSON.stringify({ type: "turn.ended", turnId: 0, reason: "completed" }),
+ ].join("\n") + "\n");
+
+ assert.deepEqual(extractUnseenKimicodeTurns(wire).turns, [
+ { role: "user", content: "Fix release.json.", turnId: "0" },
+ { role: "assistant", content: "Done.", turnId: "0" },
+ ]);
+});
+
+test("assistant text from consecutive steps is separated", () => {
+ const dir = mkdtempSync(join(tmpdir(), "ov-kimi-wire-"));
+ const wire = join(dir, "wire.jsonl");
+ writeFileSync(wire, [
+ JSON.stringify({ type: "turn.prompt", input: [{ type: "text", text: "question" }] }),
+ JSON.stringify({ type: "context.append_loop_event", event: { type: "content.part", turnId: "3", part: { type: "text", text: "Reading files." } } }),
+ JSON.stringify({ type: "context.append_loop_event", event: { type: "content.part", turnId: "3", part: { type: "text", text: "Done." } } }),
+ ].join("\n") + "\n");
+
+ assert.deepEqual(extractUnseenKimicodeTurns(wire).turns, [
+ { role: "user", content: "question", turnId: "3" },
+ { role: "assistant", content: "Reading files.\nDone.", turnId: "3" },
+ ]);
+});
+
test("turn.ended closes an interrupted user-only turn", () => {
const dir = mkdtempSync(join(tmpdir(), "ov-kimi-wire-"));
const wire = join(dir, "wire.jsonl");