{"record":{"id":"999a60e512b5e651","repo":"affaan-m/ECC","slug":"reporoot-is-required-to-plan-kimi-mcp-configuration","errorCode":null,"errorMessage":"repoRoot is required to plan Kimi MCP configuration","messagePattern":"repoRoot is required to plan Kimi MCP configuration","errorType":"exception","errorClass":null,"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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/install-targets/kimi-project.js#L9-L45","documentation":"createMcpMergeOperation in the Kimi install target requires a resolved repoRoot to locate the source .mcp.json that will be merged into the Kimi client's MCP configuration. When repoRoot is falsy, the planner cannot build a valid source path, so it throws immediately instead of producing a broken or empty merge plan. This is a fail-fast guard for a missing required planning argument.","triggerScenarios":"Calling createMcpMergeOperation(moduleId, repoRoot, targetRoot) with repoRoot === undefined/null/'' — typically when the adapter's planOperations pipeline is invoked with a planning input whose repoRoot was never resolved or was explicitly set to null in tests.","commonSituations":"Custom scripts calling the installer planner without passing repoRoot in options; test harnesses stubbing planning inputs; a refactor renaming repoRoot to another option name so the value arrives undefined.","solutions":["Resolve and pass repoRoot explicitly: createMcpMergeOperation(moduleId, process.cwd(), targetRoot) or the detected repository root.","If calling the higher-level planner, ensure the repoRoot option is included in the planning input object.","Guard in tests: provide a tmp directory as repoRoot so the .mcp.json existence check runs.","Check for a recent rename of the option (repoRoot vs repositoryRoot) in the adapter API."],"exampleFix":"// before\nconst op = createMcpMergeOperation('kimi', null, targetRoot);\n// after\nconst op = createMcpMergeOperation('kimi', path.resolve(repoRoot), targetRoot);","handlingStrategy":"validation","validationCode":"if (typeof repoRoot !== 'string' || repoRoot.length === 0) {\n  throw new Error('repoRoot must be resolved before planning Kimi MCP configuration');\n}","typeGuard":"const hasRepoRoot = (v) => typeof v === 'string' && v.length > 0;","tryCatchPattern":null,"preventionTips":["Always derive repoRoot from process.cwd() or a repo-detection helper at the entry point of installer scripts.","Validate planning inputs (repoRoot, targetRoot) once at the top of the pipeline before adapter calls.","In tests, pass a temp directory as repoRoot instead of omitting it."],"tags":["config","mcp","installer"],"backgroundTag":"missing-required-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}