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

Function readInstalled

packages/agent-core/src/plugin/store.ts:31–52  ·  view source on GitHub ↗
(kimiHomeDir: string)

Source from the content-addressed store, hash-verified

29const EMPTY: InstalledFile = { version: 1, plugins: [] };
30
31export async function readInstalled(kimiHomeDir: string): Promise<InstalledFile> {
32 const filePath = path.join(kimiHomeDir, INSTALLED_REL);
33 let text: string;
34 try {
35 text = await readFile(filePath, 'utf8');
36 } catch (error) {
37 if ((error as NodeJS.ErrnoException).code === 'ENOENT') return EMPTY;
38 throw error;
39 }
40 try {
41 const parsed = JSON.parse(text) as InstalledFile;
42 if (typeof parsed !== 'object' || parsed === null || !Array.isArray(parsed.plugins)) {
43 throw new Error('installed.json is not a valid InstalledFile object');
44 }
45 return parsed;
46 } catch (error) {
47 throw new Error(
48 `Failed to parse ${filePath}: ${(error as Error).message}`,
49 { cause: error },
50 );
51 }
52}
53
54export async function writeInstalled(
55 kimiHomeDir: string,

Callers 3

store.test.tsFile · 0.90
loadMethod · 0.90
reloadMethod · 0.90

Calls 1

readFileFunction · 0.50

Tested by

no test coverage detected