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

  1. Pass repoRoot (absolute path to the ECC source repo) into planInstallTargetScaffold options.
  2. If you only have projectRoot, also set repoRoot to the same value before planning.
  3. 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

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


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/999a60e512b5e651. Report an issue: GitHub.