refactor: keep runtime context in memory

This commit is contained in:
2026-06-07 17:07:14 +08:00
parent 1ed7e56f35
commit 9d4e5486e9
11 changed files with 273 additions and 269 deletions
+6 -8
View File
@@ -4,13 +4,13 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { createSkillManagerTool } from "../../.opencode/tools/skill_manager.js";
import { SessionRuntimeContextStore } from "../../src/sessions/runtimeContextStore.js";
import { type RuntimeSessionContext } from "../../src/runtime/sessionContext.js";
import { SkillStore } from "../../src/skills/store.js";
describe("skill_manager tool", () => {
let tempDir: string;
let skillStore: SkillStore;
let contextStore: SessionRuntimeContextStore;
let context: RuntimeSessionContext;
const toolContext = {
abort: new AbortController().signal,
@@ -39,16 +39,14 @@ describe("skill_manager tool", () => {
join(tempDir, "skills"),
join(tempDir, "backup", "skills"),
);
contextStore = new SessionRuntimeContextStore(join(tempDir, "contexts"));
await contextStore.initialize();
await contextStore.write({
context = {
actorKey: "actor-1",
allowLearningWrite: true,
clientSessionId: "client-session-1",
projectKey: "project-1",
sessionId: "session-1",
traceId: "trace-1",
});
};
});
afterEach(async () => {
@@ -58,7 +56,7 @@ describe("skill_manager tool", () => {
it("dispatches skill-level write, overwrite, and remove actions", async () => {
const tool = createSkillManagerTool(
skillStore,
contextStore,
{ read: () => context },
Promise.resolve(),
);
@@ -111,7 +109,7 @@ describe("skill_manager tool", () => {
it("writes the root skills index through the reserved alias", async () => {
const tool = createSkillManagerTool(
skillStore,
contextStore,
{ read: () => context },
Promise.resolve(),
);