Airul is a tool that generates context for AI agents from documentation files. It uses glob patterns to find and process files. The core functionality is in src/generator.ts
, which handles finding files and generating AI rules from them.
The glob pattern handling is not working correctly in the workflow tests. Specifically:
-
Test Failure:
- Test:
test/workflow.test.ts
- Pattern:
docs/*.md
- Expected: Should find
docs/guide.md
- Actual: File is not being found/included in the output
- Test:
-
Test Setup:
// Files created in test: await writeFile('README.md', readmeContent); await createDir('docs'); await writeFile(join('docs', 'guide.md'), docsContent); // Config used: const updatedConfig = { sources: [ 'README.md', 'docs/*.md', 'non-existent.md' ], output: { cursor: true } };
-
Using
cwd
option in glob:const matches = await glob(normalizedPattern, { cwd: baseDir, nodir: true, dot: true, follow: true, absolute: false });
Result: Files still not found
-
Normalizing paths:
const normalized = path.normalize(file); if (!seen.has(normalized)) { seen.add(normalized); result.push(normalized); fileStatuses.set(normalized, { included: true }); }
Result: Paths normalized but files still not found
-
Modifying file tracking:
const allFiles = new Set([...result, ...sources]); for (const file of Array.from(allFiles).sort()) { const status = fileStatuses.get(file); if (status) { const mark = status.included ? '✓' : '✗'; console.log(`${mark} ${file}${status.error ? ` (${status.error})` : ''}`); } }
Result: Better output but core issue remains
-
The test environment:
- Tests run in a temporary directory (
test/__test_outputs__/workflow/multi-step
) - Files are created using relative paths
- Process working directory is changed to test directory
- Tests run in a temporary directory (
-
File Path Handling:
- Paths in config are relative (
docs/*.md
) - Files are created with relative paths
baseDir
is set to the test directory- Multiple path normalization steps may be interfering
- Paths in config are relative (
-
Glob Behavior:
- Glob seems to work for top-level files (
README.md
) - Issues specifically with subdirectory patterns (
docs/*.md
) - Pattern normalization may be affecting subdirectory matching
- Glob seems to work for top-level files (
-
Debug Path Resolution:
- Add logging to print absolute paths at each step
- Verify
process.cwd()
matches expected test directory - Check if
baseDir
is correctly passed through
-
Test Glob Patterns Directly:
- Create a simple test case just for glob pattern matching
- Try different glob pattern formats (
**/docs/*.md
,./docs/*.md
) - Test with absolute vs relative paths
-
Consider Alternative Approaches:
- Try using different glob implementation (globby, fast-glob)
- Consider recursive directory scanning instead of glob
- Look into using path.resolve() before glob matching
-
Test Environment:
- Verify test directory structure after creation
- Check file permissions
- Consider platform-specific path issues (Windows vs Unix)
-
Main Implementation:
src/generator.ts
: Contains glob pattern handlingsrc/cli.ts
: CLI command handlingsrc/types.ts
: Type definitions
-
Tests:
test/workflow.test.ts
: Main failing testtest/generator.test.ts
: Generator-specific teststest/constants.ts
: Test constants and paths
The code is in a state where it correctly handles top-level files but fails to properly handle subdirectory glob patterns. The file tracking and output formatting work, but the core glob pattern matching needs to be fixed.