























@@ -22,7 +22,14 @@ const resolveCommandSecretRefsViaGateway = vi.hoisted(() =>
2222);
23232424async function expectPathMissing(targetPath: string): Promise<void> {
25-await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
25+let error: unknown;
26+try {
27+await fs.stat(targetPath);
28+} catch (caught) {
29+error = caught;
30+}
31+expect(error).toBeInstanceOf(Error);
32+expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
2633}
27342835vi.mock("./cli.host.runtime.js", async () => {
@@ -666,10 +673,10 @@ describe("memory cli", () => {
666673667674expectLogged(log, "Dream repair: archived session corpus");
668675expectLogged(log, "Dream archive:");
669-await expect(fs.access(sessionCorpusDir)).rejects.toMatchObject({ code: "ENOENT" });
670-await expect(
671-fs.access(path.join(workspaceDir, "memory", ".dreams", "session-ingestion.json")),
672-).rejects.toMatchObject({ code: "ENOENT" });
676+await expectPathMissing(sessionCorpusDir);
677+await expectPathMissing(
678+path.join(workspaceDir, "memory", ".dreams", "session-ingestion.json"),
679+);
673680await expect(fs.readFile(path.join(workspaceDir, "DREAMS.md"), "utf-8")).resolves.toContain(
674681"# Dream Diary",
675682);
@@ -1776,13 +1783,64 @@ describe("memory cli", () => {
17761783const storePath = path.join(workspaceDir, "memory", ".dreams", "short-term-recall.json");
17771784const storeRaw = await waitFor(async () => await fs.readFile(storePath, "utf-8"));
17781785const store = JSON.parse(storeRaw) as {
1779-entries?: Record<string, { path: string; recallCount: number }>;
1786+entries?: Record<
1787+string,
1788+{
1789+key: string;
1790+path: string;
1791+startLine: number;
1792+endLine: number;
1793+source: string;
1794+snippet: string;
1795+recallCount: number;
1796+dailyCount: number;
1797+groundedCount: number;
1798+totalScore: number;
1799+maxScore: number;
1800+firstRecalledAt: string;
1801+lastRecalledAt: string;
1802+queryHashes: string[];
1803+recallDays: string[];
1804+conceptTags: string[];
1805+}
1806+>;
17801807};
17811808const entries = Object.values(store.entries ?? {});
17821809expect(entries).toHaveLength(1);
1783-expect(entries[0]).toMatchObject({
1810+const entry = entries[0];
1811+expect(entry).toBeDefined();
1812+if (!entry) {
1813+throw new Error("Expected short-term recall entry");
1814+}
1815+expect(entry.firstRecalledAt).toMatch(/^\d{4}-\d{2}-\d{2}T/);
1816+expect(entry.lastRecalledAt).toBe(entry.firstRecalledAt);
1817+expect(entry.recallDays).toHaveLength(1);
1818+expect(entry.recallDays[0]).toMatch(/^\d{4}-\d{2}-\d{2}$/);
1819+expect(entry.queryHashes).toHaveLength(1);
1820+expect(entry.queryHashes[0]).toMatch(/^[0-9a-f]{12}$/);
1821+expect({
1822+ ...entry,
1823+firstRecalledAt: "<now>",
1824+lastRecalledAt: "<now>",
1825+recallDays: ["<today>"],
1826+queryHashes: ["<hash>"],
1827+}).toEqual({
1828+key: "memory:memory/2026-04-03.md:1:2",
17841829path: "memory/2026-04-03.md",
1830+startLine: 1,
1831+endLine: 2,
1832+source: "memory",
1833+snippet: "Move backups to S3 Glacier.",
17851834recallCount: 1,
1835+dailyCount: 0,
1836+groundedCount: 0,
1837+totalScore: 0.91,
1838+maxScore: 0.91,
1839+firstRecalledAt: "<now>",
1840+lastRecalledAt: "<now>",
1841+queryHashes: ["<hash>"],
1842+recallDays: ["<today>"],
1843+conceptTags: ["backup", "backups", "glacier"],
17861844});
17871845expect(close).toHaveBeenCalled();
17881846});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。