Split the 657-line operation service into eor, submit, and verify modules, add the AGENT_REVOKED and KEY_RETIRED codes the Backend already emits, and condense every multi-line comment. Mirror Node, Python, and Go at 2.1.0 with the deep-health 503, non-idempotent retry, rotation grace, and path-encoding fixes. Document which routes and response fields the self-hosted server does not provide. Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
74 lines
2.2 KiB
JavaScript
74 lines
2.2 KiB
JavaScript
import { mkdir, writeFile } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import {
|
|
createFixtureRoot,
|
|
distUrl,
|
|
homeEnvironment,
|
|
installConfig as baseInstallConfig,
|
|
runPlugin as basePlugin,
|
|
} from './harness.mjs';
|
|
|
|
export {
|
|
VALID_PRIVATE_KEY,
|
|
cliPath,
|
|
readJson,
|
|
registryModuleUrl,
|
|
runNode,
|
|
runProcess,
|
|
startApiServer,
|
|
} from './harness.mjs';
|
|
|
|
export const pluginModuleUrl = distUrl('plugins/cline.js');
|
|
export const contractModuleUrl = distUrl('plugins/cline-contract.js');
|
|
export const ioModuleUrl = distUrl('plugins/cline-io.js');
|
|
export const installationModuleUrl = distUrl('plugins/cline-installation.js');
|
|
const PLUGIN = { exportName: 'clinePlugin', moduleUrl: pluginModuleUrl };
|
|
|
|
export function environment(fixture, clineDir = fixture.clineDir) {
|
|
return { ...homeEnvironment(fixture), CLINE_DIR: clineDir === null ? undefined : clineDir };
|
|
}
|
|
|
|
export function installConfig(fixture, overrides = {}) {
|
|
return baseInstallConfig('cline', fixture, overrides);
|
|
}
|
|
|
|
export function runPlugin(fixture, method, argument, clineDir = fixture.clineDir) {
|
|
return basePlugin(PLUGIN, fixture, method, argument, { env: environment(fixture, clineDir) });
|
|
}
|
|
|
|
async function writeOptional(filePath, contents) {
|
|
if (contents === undefined) return;
|
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
await writeFile(filePath, contents, { mode: 0o600 });
|
|
}
|
|
|
|
export async function createFixture({
|
|
agentId = 'agent-1',
|
|
baseUrl = 'http://127.0.0.1:9',
|
|
existingAudit,
|
|
existingGuard,
|
|
} = {}) {
|
|
const base = await createFixtureRoot(
|
|
'elydora-cline-',
|
|
"home with spaces and 'quote %CLINE%",
|
|
{ agentId },
|
|
);
|
|
const clineDir = path.join(base.rootDir, 'custom-cline-home');
|
|
const hooksDir = path.join(clineDir, 'hooks');
|
|
const guardWrapperPath = path.join(hooksDir, 'PreToolUse.mjs');
|
|
const auditWrapperPath = path.join(hooksDir, 'PostToolUse.mjs');
|
|
await writeOptional(guardWrapperPath, existingGuard);
|
|
await writeOptional(auditWrapperPath, existingAudit);
|
|
return {
|
|
...base,
|
|
auditWrapperPath,
|
|
baseUrl,
|
|
clineDir,
|
|
guardWrapperPath,
|
|
hooksDir,
|
|
install(overrides = {}, clineDirOverride = this.clineDir) {
|
|
return runPlugin(this, 'install', installConfig(this, overrides), clineDirOverride);
|
|
},
|
|
};
|
|
}
|