-
Notifications
You must be signed in to change notification settings - Fork 35
Add debug logging and extract glob pattern helper module for repo-memory validation #8242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add debug logging to show file glob filter configuration - Add detailed pattern matching logs for each file - Add enhanced error messages with regex patterns and test results - Add new tests for debug logging functionality - Add tests for root-level file matching (daily-code-metrics use case) Co-authored-by: pelikhan <[email protected]>
| .replace(/\*\*/g, "<!DOUBLESTAR>") // Temporarily replace ** | ||
| .replace(/\*/g, "[^/]*") // Single * matches non-slash chars | ||
| .replace(/<!DOUBLESTAR>/g, ".*"); // ** matches everything including / | ||
| return new RegExp(`^${regexPattern}$`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot move pattern to regex helper to separate function and add tests to validate behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 1e498c4. Extracted globPatternToRegex() as a standalone function with full JSDoc documentation and added 20 comprehensive test cases covering:
- Basic patterns (exact, *, **)
- Special character escaping
- Real-world scenarios (*.jsonl, metrics/**, campaigns)
- Edge cases (empty, complex nested patterns)
- Regex output validation
All 50 tests passing ✓
- Log FILE_GLOB_FILTER environment variable value and length - Log MEMORY_ID, MAX_FILE_SIZE, MAX_FILE_COUNT for debugging - Add summary of files found after scanning - Show first 10 files or all files if <= 10 found Co-authored-by: pelikhan <[email protected]>
- Move glob-to-regex conversion logic to standalone function - Export globPatternToRegex for testing and reusability - Add 20 new test cases covering: - Basic pattern matching (exact, *, **) - Special character escaping (dots, backslashes) - Real-world patterns (*.jsonl, metrics/**, campaigns) - Edge cases (empty, wildcards only, complex nested) - Regex output format validation - All 50 tests passing Co-authored-by: pelikhan <[email protected]>
| * - . is escaped to match literal dots | ||
| * - \ is escaped properly | ||
| */ | ||
| function globPatternToRegex(pattern) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot move to separate file, add more tests, update setup.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in commit 9be23c5. Created separate glob_pattern_helpers.cjs module with:
- 3 exported functions:
globPatternToRegex(),parseGlobPatterns(),matchesGlobPattern() - 37 comprehensive tests covering patterns, escaping, edge cases, security, and integration
- Updated
push_repo_memory.cjsto import from the helper - All 87 tests passing ✓
Setup.sh automatically copies all .cjs files, so the new module will be available at runtime without changes to setup.sh.
- Created glob_pattern_helpers.cjs with 3 exported functions: - globPatternToRegex: Convert glob pattern to RegExp - parseGlobPatterns: Parse space-separated patterns - matchesGlobPattern: Check if file matches any pattern - Added 37 comprehensive tests in glob_pattern_helpers.test.cjs: - Basic pattern matching (exact, *, **) - Special character escaping - Real-world patterns (daily-code-metrics, campaigns) - Edge cases and security tests - Integration tests with push_repo_memory - Updated push_repo_memory.cjs to import from helper module - Updated push_repo_memory.test.cjs to import from helper module - All 87 tests passing (50 push_repo_memory + 37 glob_pattern_helpers) Co-authored-by: pelikhan <[email protected]>
|
@copilot Lint js |
All JavaScript files pass linting ✓
|
The
push_repo_memoryjob failed with "File does not match allowed patterns: history.jsonl" despite the glob filter["*.json", "*.jsonl", "*.csv", "*.md"]being configured. Pattern matching logic is correct (*.jsonl→^[^/]*\.jsonl$matcheshistory.jsonl), suggesting the failure stems from environment variable propagation, path formatting, or timing issues.Changes
Environment diagnostics
FILE_GLOB_FILTERvalue, length, and pattern count at startupMEMORY_ID,MAX_FILE_SIZE,MAX_FILE_COUNT)Pattern matching visibility
Code refactoring
glob_pattern_helpers.cjsmodule with three exported functions:globPatternToRegex(pattern): Convert glob pattern to RegExpparseGlobPatterns(fileGlobFilter): Parse space-separated glob patternsmatchesGlobPattern(filePath, fileGlobFilter): Check if file matches any patternpush_repo_memory.cjsto import from the helper modulesetup.sh(copies all .cjs files)Test coverage
glob_pattern_helpers.test.cjs:*,**)*.jsonl,metrics/**, campaign-specific patterns)Example output
When a file fails validation, the error now shows:
Debug logs for each file:
Next workflow run will immediately reveal the root cause.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.