MCPcopy Create free account
hub / github.com/Noumena-Network/code / findNearestInstructionFile

Function findNearestInstructionFile

src/cli/up.ts:42–66  ·  view source on GitHub ↗
(startDir: string)

Source from the content-addressed store, hash-verified

40}
41
42async function findNearestInstructionFile(startDir: string): Promise<string | null> {
43 let currentDir = startDir
44
45 while (true) {
46 const candidates = [
47 `${currentDir}/AGENTS.md`,
48 `${currentDir}/NCODE.md`,
49 `${currentDir}/CLAUDE.md`,
50 `${currentDir}/.ncode/NCODE.md`,
51 `${currentDir}/.claude/CLAUDE.md`,
52 ]
53
54 for (const candidate of candidates) {
55 if (await fileExists(candidate)) {
56 return candidate
57 }
58 }
59
60 const parentDir = dirname(currentDir)
61 if (parentDir === currentDir) {
62 return null
63 }
64 currentDir = parentDir
65 }
66}
67
68function extractUpSection(markdown: string): Section | null {
69 const lines = markdown.split(/\r?\n/)

Callers 1

upFunction · 0.85

Calls 1

fileExistsFunction · 0.70

Tested by

no test coverage detected