MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / ensureConfigFile

Function ensureConfigFile

packages/agent-core/src/config/toml.ts:51–63  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

49`;
50
51export async function ensureConfigFile(filePath: string): Promise<void> {
52 await mkdir(dirname(filePath), { recursive: true, mode: 0o700 });
53 let handle: Awaited<ReturnType<typeof open>> | undefined;
54 try {
55 handle = await open(filePath, 'wx', 0o600);
56 await handle.writeFile(DEFAULT_CONFIG_FILE_TEXT, 'utf-8');
57 } catch (error) {
58 if (isFileExistsError(error)) return;
59 throw error;
60 } finally {
61 await handle?.close();
62 }
63}
64
65export function readConfigFile(filePath: string): KimiConfig {
66 if (!existsSync(filePath)) {

Callers 2

ensureConfigFileMethod · 0.90
configs.test.tsFile · 0.90

Calls 3

isFileExistsErrorFunction · 0.85
closeMethod · 0.65
mkdirFunction · 0.50

Tested by

no test coverage detected