Read a single instruction file via the given reader, returning structured info.
( reader: FileReader, directory: string, filename: string, scope: InstructionScope, isLocal: boolean, projectName: string | undefined, muxOnly: boolean )
| 69 | |
| 70 | /** Read a single instruction file via the given reader, returning structured info. */ |
| 71 | async function readSingleFile( |
| 72 | reader: FileReader, |
| 73 | directory: string, |
| 74 | filename: string, |
| 75 | scope: InstructionScope, |
| 76 | isLocal: boolean, |
| 77 | projectName: string | undefined, |
| 78 | muxOnly: boolean |
| 79 | ): Promise<ReadInstructionFileResult> { |
| 80 | let raw: string; |
| 81 | try { |
| 82 | raw = await reader.readFile(path.join(directory, filename)); |
| 83 | } catch { |
| 84 | return { exists: false }; |
| 85 | } |
| 86 | const sanitized = stripMarkdownComments(raw); |
| 87 | if (sanitized.length === 0) return { exists: true, file: null }; |
| 88 | return { |
| 89 | exists: true, |
| 90 | file: { |
| 91 | path: path.join(directory, filename), |
| 92 | filename, |
| 93 | isLocal, |
| 94 | muxOnly, |
| 95 | scope, |
| 96 | projectName: projectName ?? null, |
| 97 | content: sanitized, |
| 98 | bytes: Buffer.byteLength(sanitized, "utf-8"), |
| 99 | tokens: null, |
| 100 | }, |
| 101 | }; |
| 102 | } |
| 103 | |
| 104 | /** Try each base filename in priority order; return the first that exists. */ |
| 105 | async function readBaseInstructionFile( |
no test coverage detected