Files
Agent-Workbench/docs/model-selection-k-evidence/source-bytes/tests/fixtures/purge-source.mjs
T
2026-11-03 15:37:04 +08:00

21 lines
1.2 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import { PURGE_SOURCE_FILES, resolvePurgeSource, PURGE_PROMPT_KIND, PURGE_DEFAULT_PROMPT } from '../../src/core/engines/purge-strategy.mjs';
// Source-identity fixture only. Its JavaScript would throw if imported.
export function createPurgeSource(directory, version = '1.1.78') {
fs.mkdirSync(directory, { recursive: true });
for (const relative of PURGE_SOURCE_FILES) {
const file = path.join(directory, relative); fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, relative === 'package.json' ? JSON.stringify({ name: 'dsh-purge', version, dshTarget: '0.2.1-rc.2',
type: 'module', main: 'lib/index.js', license: 'Apache-2.0', scripts: { postinstall: 'throw-if-run' } })
: relative.endsWith('.js') ? 'throw new Error("Third-party Purge code must not run in this fixture.");\n' : 'Declared source identity fixture.\n');
}
return directory;
}
export function purgeInput(root, prompt = PURGE_DEFAULT_PROMPT) {
const source = resolvePurgeSource(process.cwd(), root);
if (source.status !== 'available') throw new Error(source.message);
return { kind: PURGE_PROMPT_KIND, root, sourceSha256: source.sourceSha256, prompt };
}