feat: package continuity plugin MVP docs and receipt store

This commit is contained in:
Eve
2026-04-24 17:32:47 +08:00
parent acf83824b7
commit b9ccc3d096
6 changed files with 580 additions and 43 deletions

View File

@@ -0,0 +1,38 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { buildReceiptFilename, slugifyReceiptSegment, writeReceipt } from '../src/continuity/receipt-store.mjs';
function test(name, fn) {
Promise.resolve()
.then(fn)
.then(() => console.log(`ok - ${name}`))
.catch((error) => {
console.error(`not ok - ${name}`);
throw error;
});
}
assert.equal(slugifyReceiptSegment(' Plan ID / 01 '), 'plan-id-01');
const built = buildReceiptFilename({ planId: 'Plan ID', dispatchRunId: 'Run 01' });
assert.equal(built.filename, 'receipt-plan-id-run-01.json');
test('writes receipt using canonical filename', async () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'continuity-receipt-store-'));
const receipt = {
planId: 'Plan ID',
currentTask: 'task-7',
nextDerivedAction: { type: 'message_subagent' },
dispatchedAt: '2026-04-24T09:00:00.000Z',
dispatchRunId: 'Run 01',
childSessionKey: 'child-1',
replyClosureState: 'completed',
};
const receiptPath = await writeReceipt({ receiptDir: dir, receipt });
assert.match(receiptPath, /receipt-plan-id-run-01\.json$/);
assert.equal(fs.existsSync(receiptPath), true);
});
console.log('continuity.receipt-store.test.mjs PASS');