555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { scopeSearchFilters, scopeWriteParams, asScope, resolveDefaultScope } from "./scope";
|
|
|
|
describe("memory scope (pi-agent parity)", () => {
|
|
test("project scope = this repo", () => {
|
|
expect(scopeSearchFilters("project", "u", "app", "run")).toEqual({
|
|
user_id: "u",
|
|
app_id: "app",
|
|
});
|
|
expect(scopeWriteParams("project", "u", "app", "run")).toEqual({
|
|
user_id: "u",
|
|
app_id: "app",
|
|
});
|
|
});
|
|
|
|
test("session scope adds run_id", () => {
|
|
expect(scopeSearchFilters("session", "u", "app", "run")).toEqual({
|
|
user_id: "u",
|
|
app_id: "app",
|
|
run_id: "run",
|
|
});
|
|
expect(scopeWriteParams("session", "u", "app", "run")).toEqual({
|
|
user_id: "u",
|
|
app_id: "app",
|
|
run_id: "run",
|
|
});
|
|
});
|
|
|
|
test("global scope spans all the user's projects (matches pi-agent)", () => {
|
|
expect(scopeSearchFilters("global", "u", "app", "run")).toEqual({
|
|
user_id: "u",
|
|
app_id: "*",
|
|
});
|
|
// global writes drop app_id so the memory is user-wide, not project-bound
|
|
expect(scopeWriteParams("global", "u", "app", "run")).toEqual({ user_id: "u" });
|
|
});
|
|
|
|
test("default scope is project when settings are absent", () => {
|
|
expect(resolveDefaultScope(null)).toBe("project");
|
|
expect(resolveDefaultScope(undefined)).toBe("project");
|
|
expect(resolveDefaultScope({})).toBe("project");
|
|
});
|
|
|
|
test("default scope reads default_scope from settings", () => {
|
|
expect(resolveDefaultScope({ default_scope: "session" })).toBe("session");
|
|
expect(resolveDefaultScope({ default_scope: "global" })).toBe("global");
|
|
expect(resolveDefaultScope({ default_scope: "project" })).toBe("project");
|
|
});
|
|
|
|
test("default scope normalizes an invalid default_scope to project", () => {
|
|
expect(resolveDefaultScope({ default_scope: "nonsense" })).toBe("project");
|
|
expect(resolveDefaultScope({ default_scope: 42 })).toBe("project");
|
|
});
|
|
|
|
test("asScope normalizes unknown values to project", () => {
|
|
expect(asScope("global")).toBe("global");
|
|
expect(asScope("session")).toBe("session");
|
|
expect(asScope("project")).toBe("project");
|
|
expect(asScope("nonsense")).toBe("project");
|
|
expect(asScope(undefined)).toBe("project");
|
|
});
|
|
});
|