MCPcopy Create free account
hub / github.com/dyoshikawa/rulesync / readOpencodeConfig

Function readOpencodeConfig

src/features/opencode-config.ts:35–57  ·  view source on GitHub ↗
({
  outputRoot,
  global = false,
}: {
  outputRoot: string;
  global?: boolean;
})

Source from the content-addressed store, hash-verified

33}
34
35export async function readOpencodeConfig({
36 outputRoot,
37 global = false,
38}: {
39 outputRoot: string;
40 global?: boolean;
41}): Promise<Record<string, unknown>> {
42 const configDir = getOpencodeConfigDir({ outputRoot, global });
43
44 const fileContent =
45 (await readFileContentOrNull(join(configDir, OPENCODE_JSONC_FILE_NAME))) ??
46 (await readFileContentOrNull(join(configDir, OPENCODE_JSON_FILE_NAME)));
47
48 if (!fileContent) {
49 return {};
50 }
51
52 const parsed = parseJsonc(fileContent) as unknown;
53 if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
54 return {};
55 }
56 return parsed as Record<string, unknown>;
57}
58
59/**
60 * Narrows an unknown value to a plain record of entries keyed by name, as used

Callers 3

Calls 2

getOpencodeConfigDirFunction · 0.85
readFileContentOrNullFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…