( dir: string, targetPath: string, processedPaths: Set<string>, )
| 1247 | * @returns Array of MemoryFileInfo objects |
| 1248 | */ |
| 1249 | export async function getMemoryFilesForNestedDirectory( |
| 1250 | dir: string, |
| 1251 | targetPath: string, |
| 1252 | processedPaths: Set<string>, |
| 1253 | ): Promise<MemoryFileInfo[]> { |
| 1254 | const result: MemoryFileInfo[] = [] |
| 1255 | |
| 1256 | // Process project memory files (CLAUDE.md and .claude/CLAUDE.md) |
| 1257 | if (isSettingSourceEnabled('projectSettings')) { |
| 1258 | const projectPath = join(dir, 'CLAUDE.md') |
| 1259 | result.push( |
| 1260 | ...(await processMemoryFile( |
| 1261 | projectPath, |
| 1262 | 'Project', |
| 1263 | processedPaths, |
| 1264 | false, |
| 1265 | )), |
| 1266 | ) |
| 1267 | const dotClaudePath = join(dir, '.claude', 'CLAUDE.md') |
| 1268 | result.push( |
| 1269 | ...(await processMemoryFile( |
| 1270 | dotClaudePath, |
| 1271 | 'Project', |
| 1272 | processedPaths, |
| 1273 | false, |
| 1274 | )), |
| 1275 | ) |
| 1276 | } |
| 1277 | |
| 1278 | // Process local memory file (CLAUDE.local.md) |
| 1279 | if (isSettingSourceEnabled('localSettings')) { |
| 1280 | const localPath = join(dir, 'CLAUDE.local.md') |
| 1281 | result.push( |
| 1282 | ...(await processMemoryFile(localPath, 'Local', processedPaths, false)), |
| 1283 | ) |
| 1284 | } |
| 1285 | |
| 1286 | const rulesDir = join(dir, '.claude', 'rules') |
| 1287 | |
| 1288 | // Process project unconditional .claude/rules/*.md files, which were not eagerly loaded |
| 1289 | // Use a separate processedPaths set to avoid marking conditional rule files as processed |
| 1290 | const unconditionalProcessedPaths = new Set(processedPaths) |
| 1291 | result.push( |
| 1292 | ...(await processMdRules({ |
| 1293 | rulesDir, |
| 1294 | type: 'Project', |
| 1295 | processedPaths: unconditionalProcessedPaths, |
| 1296 | includeExternal: false, |
| 1297 | conditionalRule: false, |
| 1298 | })), |
| 1299 | ) |
| 1300 | |
| 1301 | // Process project conditional .claude/rules/*.md files |
| 1302 | result.push( |
| 1303 | ...(await processConditionedMdRules( |
| 1304 | targetPath, |
| 1305 | rulesDir, |
| 1306 | 'Project', |
no test coverage detected