feat: complete Aider Page Data review workflow

This commit is contained in:
john
2026-07-25 09:47:25 +08:00
parent be9c25f1d0
commit 104fb4e370
15 changed files with 914 additions and 30 deletions
+50 -1
View File
@@ -1,6 +1,15 @@
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import os from 'node:os';
import path from 'node:path';
import test from 'node:test';
import { createToolGateway, extractToolInstruction } from './tool-gateway.mjs';
import {
createToolGateway,
extractToolInstruction,
hardenAiderLaunchPlan,
prepareAiderReceiptFile,
resolveAiderReceiptPath,
} from './tool-gateway.mjs';
test('tool gateway extracts text instructions from H5 message content', () => {
assert.equal(
@@ -58,6 +67,46 @@ test('tool gateway honors an explicitly required Aider executor over task defaul
}), 'aider');
});
test('tool gateway resolves and prepares the required Aider receipt without pre-validating it', async () => {
const requestId = 'req-receipt';
const relativePath = `.memind/agent-runs/${requestId}.json`;
const userMessage = {
metadata: {
memindRun: {
validation: {
expectedFile: { path: relativePath, contains: requestId },
},
},
},
};
assert.equal(resolveAiderReceiptPath(userMessage, requestId), relativePath);
const cwd = await fs.mkdtemp(path.join(os.tmpdir(), 'memind-aider-receipt-'));
try {
const target = await prepareAiderReceiptFile(cwd, relativePath);
const pending = JSON.parse(await fs.readFile(target, 'utf8'));
assert.deepEqual(pending, { status: 'pending', executor: 'aider' });
assert.equal((await fs.readFile(target, 'utf8')).includes(requestId), false);
} finally {
await fs.rm(cwd, { recursive: true, force: true });
}
});
test('tool gateway hardens Aider against repository commits and includes the receipt', () => {
const plan = hardenAiderLaunchPlan(
{ ok: true, args: ['--model', 'test-model'] },
'/tmp/work/.memind/agent-runs/req.json',
['/tmp/work/public/order.html'],
);
assert.ok(plan.args.includes('--no-git'));
assert.ok(plan.args.includes('--no-auto-commits'));
assert.ok(plan.args.includes('--no-dirty-commits'));
assert.deepEqual(
plan.args.slice(-2),
['--file', '/tmp/work/.memind/agent-runs/req.json'],
);
assert.ok(plan.args.includes('/tmp/work/public/order.html'));
});
test('tool gateway dry run builds executor launch plan without spawning', async () => {
const plans = [];
const gateway = createToolGateway({