affaan-m/ECC · error · Error
repoRoot is required to plan Kimi MCP configuration
Error message
repoRoot is required to plan Kimi MCP configuration
What it means
Thrown by createMcpMergeOperation in scripts/lib/install-targets/kimi-project.js. It is invoked by the Kimi adapter's planOperations whenever a source module exposes the 'mcp-configs' path. It needs repoRoot to locate <repoRoot>/.mcp.json; if input.repoRoot is falsy it throws before any filesystem access. Note this is distinct from the projectRoot/repoRoot guard in resolveBaseRoot — that one fires from the helpers layer for any project-kind adapter; this one is Kimi-MCP specific.
Source
Thrown at scripts/lib/install-targets/kimi-project.js:27
function readJsonObject(filePath, label) {
let parsed;
try {
parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
} catch (error) {
throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);
}
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);
}
return parsed;
}
function createMcpMergeOperation(moduleId, repoRoot, targetRoot) {
if (!repoRoot) {
throw new Error('repoRoot is required to plan Kimi MCP configuration');
}
const sourceRelativePath = '.mcp.json';
const sourcePath = path.join(repoRoot, sourceRelativePath);
if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isFile()) {
return null;
}
return createManagedOperation({
kind: 'merge-json',
moduleId,
sourceRelativePath,
destinationPath: path.join(targetRoot, 'mcp.json'),
strategy: 'merge-json',
scaffoldOnly: false,
mergePayload: readJsonObject(sourcePath, sourceRelativePath),
});
}View on GitHub (pinned to 01e15490f0)
Solutions
- Pass repoRoot (absolute path to the ECC source repo) into planInstallTargetScaffold options.
- If you only have projectRoot, also set repoRoot to the same value before planning.
- If MCP merging is not wanted, exclude the 'mcp-configs' source path from the modules you install.
Example fix
// before
planInstallTargetScaffold({
target: 'kimi',
modules,
projectRoot: '/dest',
});
// after
planInstallTargetScaffold({
target: 'kimi',
modules,
repoRoot: '/abs/path/to/ecc',
projectRoot: '/dest',
}); Defensive patterns
Strategy: validation
Validate before calling
function assertRepoRootForKimiMcp(options) {
const installsMcp = (options.modules || []).some(m =>
(m.paths || []).includes('mcp-configs')
);
if (installsMcp && !options.repoRoot) {
throw new Error('repoRoot is required when installing mcp-configs to the kimi target');
}
}
assertRepoRootForKimiMcp(options); Type guard
function hasRepoRoot(input) {
return Boolean(input && typeof input.repoRoot === 'string' && input.repoRoot.length > 0);
} Prevention
- Treat repoRoot as a required field for any Kimi install that includes mcp-configs.
- Derive repoRoot explicitly from __dirname or process.cwd() in scripts rather than relying on env vars.
- Exclude the mcp-configs path from modules if you do not need MCP merging.
When it happens
Trigger: Calling planInstallTargetScaffold({ target: 'kimi', modules, projectRoot: '/dest' }) where one module's paths array contains 'mcp-configs' but options.repoRoot is unset.
Common situations: Programmatic use of the ECC installer that omits repoRoot; a wrapper that builds the options object from optional env vars that are all undefined; a custom CLI that forwards --repo only to projectRoot.
Related errors
- Failed to parse ${label} at ${filePath}: ${error.message}
- Invalid ${label} at ${filePath}: expected a JSON object
- Missing issue number.
- Missing --repo <owner/repo>.
- Kimi requires an explicit --profile choice in this mode.
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/999a60e512b5e651.
Report an issue: GitHub.