Files
Elydora-Open-Source/sdks/node/test-support/kirocli-test-helpers.mjs
T
雷电芽衣 bc6983a62e chore(oss): audit the server package and resync the SDK mirrors
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
2026-09-03 20:48:20 -04:00

81 lines
2.2 KiB
JavaScript

import path from 'node:path';
import {
createFixtureRoot,
distUrl,
installConfig as baseInstallConfig,
runPlugin as basePlugin,
runProcess as baseProcess,
writeOptionalJson,
} from './harness.mjs';
export {
VALID_PRIVATE_KEY,
cliPath,
homeEnvironment as environment,
readJson,
registryModuleUrl,
runNode,
runShell,
startApiServer,
} from './harness.mjs';
export const pluginModuleUrl = distUrl('plugins/kirocli.js');
export const contractModuleUrl = distUrl('plugins/kirocli-contract.js');
export const installationModuleUrl = distUrl('plugins/kirocli-installation.js');
export const ioModuleUrl = distUrl('plugins/kirocli-io.js');
export const kiroV1ModuleUrl = distUrl('plugins/kiroide-contract.js');
const PLUGIN = { exportName: 'kirocliPlugin', moduleUrl: pluginModuleUrl };
export function runProcess(command, args, env, cwd, input = '', shell = false) {
return baseProcess(command, args, env, cwd, input, { shell });
}
export function installConfig(fixture, overrides = {}) {
return baseInstallConfig('kirocli', fixture, overrides);
}
export function runPlugin(fixture, method, argument) {
return basePlugin(PLUGIN, fixture, method, argument);
}
export function managedV2Document(overrides = {}) {
return {
name: 'elydora-audit',
description: 'Kiro CLI with Elydora audit and freeze enforcement',
tools: ['*'],
includeMcpJson: true,
hooks: {},
...overrides,
};
}
export async function createFixture({
agentId = 'agent-1',
baseUrl = 'http://127.0.0.1:9',
existingV2,
existingV3,
} = {}) {
const base = await createFixtureRoot(
'elydora-kirocli-',
"home with spaces and 'quote %KIRO%",
{ agentId, projectName: 'workspace with spaces', createHome: true },
);
const v2Path = path.join(base.homeDir, '.kiro', 'agents', 'elydora-audit.json');
const v3Path = path.join(base.homeDir, '.kiro', 'hooks', 'elydora-audit.json');
await writeOptionalJson(v2Path, existingV2);
await writeOptionalJson(v3Path, existingV3);
return {
...base,
baseUrl,
v2Path,
v3Path,
install(overrides = {}) {
return runPlugin(this, 'install', installConfig(this, overrides));
},
};
}
export function findV3Hook(document, name) {
return document.hooks.find((hook) => hook.name === name);
}