MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / loadLinks

Function loadLinks

src/config/links.ts:68–87  ·  view source on GitHub ↗
(cwd = process.cwd())

Source from the content-addressed store, hash-verified

66 * `path` by resolving the input when it's missing.
67 */
68export function loadLinks(cwd = process.cwd()): LinkedRepo[] {
69 try {
70 const parsed = JSON.parse(fs.readFileSync(linksFilePath(cwd), "utf8")) as {
71 links?: Array<Partial<LinkedRepo>>
72 }
73 if (!Array.isArray(parsed.links)) return []
74 const out: LinkedRepo[] = []
75 for (const raw of parsed.links) {
76 if (!raw) continue
77 const input = typeof raw.input === "string" ? raw.input : typeof raw.path === "string" ? raw.path : undefined
78 if (!input) continue
79 const resolved = typeof raw.path === "string" ? raw.path : resolveLinkTarget(input)
80 if (!resolved) continue
81 out.push({ input, path: resolved })
82 }
83 return out
84 } catch {
85 return []
86 }
87}
88
89function saveLinks(cwd: string, links: LinkedRepo[]): void {
90 const file = linksFilePath(cwd)

Callers 4

AppFunction · 0.85
addLinkFunction · 0.85
removeLinkFunction · 0.85
renderLinkedReposSectionFunction · 0.85

Calls 2

linksFilePathFunction · 0.85
resolveLinkTargetFunction · 0.85

Tested by

no test coverage detected