{"record":{"id":"999a60e512b5e651","repo":"affaan-m/ECC","slug":"reporoot-is-required-to-plan-kimi-mcp-configuratio","errorCode":null,"errorMessage":"repoRoot is required to plan Kimi MCP configuration","messagePattern":"repoRoot is required to plan Kimi MCP configuration","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/install-targets/kimi-project.js","lineNumber":27,"sourceCode":"\nfunction readJsonObject(filePath, label) {\n  let parsed;\n  try {\n    parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  } catch (error) {\n    throw new Error(`Failed to parse ${label} at ${filePath}: ${error.message}`);\n  }\n\n  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n    throw new Error(`Invalid ${label} at ${filePath}: expected a JSON object`);\n  }\n\n  return parsed;\n}\n\nfunction createMcpMergeOperation(moduleId, repoRoot, targetRoot) {\n  if (!repoRoot) {\n    throw new Error('repoRoot is required to plan Kimi MCP configuration');\n  }\n\n  const sourceRelativePath = '.mcp.json';\n  const sourcePath = path.join(repoRoot, sourceRelativePath);\n  if (!fs.existsSync(sourcePath) || !fs.statSync(sourcePath).isFile()) {\n    return null;\n  }\n\n  return createManagedOperation({\n    kind: 'merge-json',\n    moduleId,\n    sourceRelativePath,\n    destinationPath: path.join(targetRoot, 'mcp.json'),\n    strategy: 'merge-json',\n    scaffoldOnly: false,\n    mergePayload: readJsonObject(sourcePath, sourceRelativePath),\n  });\n}","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/install-targets/kimi-project.js#L9-L45","documentation":"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.","triggerScenarios":"Calling planInstallTargetScaffold({ target: 'kimi', modules, projectRoot: '/dest' }) where one module's paths array contains 'mcp-configs' but options.repoRoot is unset.","commonSituations":"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.","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."],"exampleFix":"// before\nplanInstallTargetScaffold({\n  target: 'kimi',\n  modules,\n  projectRoot: '/dest',\n});\n\n// after\nplanInstallTargetScaffold({\n  target: 'kimi',\n  modules,\n  repoRoot: '/abs/path/to/ecc',\n  projectRoot: '/dest',\n});","handlingStrategy":"validation","validationCode":"function assertRepoRootForKimiMcp(options) {\n  const installsMcp = (options.modules || []).some(m =>\n    (m.paths || []).includes('mcp-configs')\n  );\n  if (installsMcp && !options.repoRoot) {\n    throw new Error('repoRoot is required when installing mcp-configs to the kimi target');\n  }\n}\nassertRepoRootForKimiMcp(options);","typeGuard":"function hasRepoRoot(input) {\n  return Boolean(input && typeof input.repoRoot === 'string' && input.repoRoot.length > 0);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["install-target","kimi","missing-argument","mcp-config"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}