feat: package continuity plugin MVP docs and receipt store
This commit is contained in:
38
plugins/continuity/test/continuity.receipt-store.test.mjs
Normal file
38
plugins/continuity/test/continuity.receipt-store.test.mjs
Normal 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');
|
||||
Reference in New Issue
Block a user