MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / getConfigPaths

Function getConfigPaths

lib/config.ts:728–766  ·  view source on GitHub ↗
(ctx?: PluginInput)

Source from the content-addressed store, hash-verified

726}
727
728function getConfigPaths(ctx?: PluginInput): {
729 global: string | null
730 configDir: string | null
731 project: string | null
732} {
733 const global = existsSync(GLOBAL_CONFIG_PATH_JSONC)
734 ? GLOBAL_CONFIG_PATH_JSONC
735 : existsSync(GLOBAL_CONFIG_PATH_JSON)
736 ? GLOBAL_CONFIG_PATH_JSON
737 : null
738
739 let configDir: string | null = null
740 const opencodeConfigDir = process.env.OPENCODE_CONFIG_DIR
741 if (opencodeConfigDir) {
742 const configJsonc = join(opencodeConfigDir, "dcp.jsonc")
743 const configJson = join(opencodeConfigDir, "dcp.json")
744 configDir = existsSync(configJsonc)
745 ? configJsonc
746 : existsSync(configJson)
747 ? configJson
748 : null
749 }
750
751 let project: string | null = null
752 if (ctx?.directory) {
753 const opencodeDir = findOpencodeDir(ctx.directory)
754 if (opencodeDir) {
755 const projectJsonc = join(opencodeDir, "dcp.jsonc")
756 const projectJson = join(opencodeDir, "dcp.json")
757 project = existsSync(projectJsonc)
758 ? projectJsonc
759 : existsSync(projectJson)
760 ? projectJson
761 : null
762 }
763 }
764
765 return { global, configDir, project }
766}
767
768function createDefaultConfig(): void {
769 if (!existsSync(GLOBAL_CONFIG_DIR)) {

Callers 1

getConfigFunction · 0.85

Calls 1

findOpencodeDirFunction · 0.70

Tested by

no test coverage detected