fix(init): prevent false GitHub Copilot auto-detection from bare .github/ directory#917
fix(init): prevent false GitHub Copilot auto-detection from bare .github/ directory#917alleninnz wants to merge 1 commit intoFission-AI:mainfrom
Conversation
…hub/ directory Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes add a configurable detection mechanism for AI tools. A new optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Pull request overview
Fixes openspec init tool auto-detection so GitHub Copilot is no longer falsely detected in repositories that merely contain a standard .github/ directory, by introducing tool-specific detection signals.
Changes:
- Added an optional
detectionPaths?: string[]onAIToolOptionto support tool-specific detection signals. - Updated
getAvailableTools()to preferdetectionPaths(file/dir existence) overskillsDirdirectory checks when provided. - Updated/added tests to ensure bare
.github/does not trigger Copilot detection, while Copilot-specific signals do.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/core/config.ts |
Adds detectionPaths to the tool config type and defines Copilot-specific detection signals. |
src/core/available-tools.ts |
Implements detection using detectionPaths (when present) instead of checking only skillsDir. |
test/core/available-tools.test.ts |
Adds coverage for the new Copilot detection behavior and preserves legacy skillsDir detection for other tools. |
test/core/init.test.ts |
Updates init detection-related tests to use a Copilot-specific signal. |
test/core/update.test.ts |
Updates new-tool detection test setup to use a Copilot-specific signal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/core/available-tools.test.ts (1)
91-150: Add coverage for the remaining configured Copilot markers.Great set of detection tests overall. Consider adding explicit cases for
.github/instructionsand.github/.mcp.jsontoo, since both are indetectionPaths.📌 Suggested test additions
+ it('should detect GitHub Copilot when .github/instructions directory exists', async () => { + await fs.mkdir(path.join(testDir, '.github', 'instructions'), { recursive: true }); + + const tools = getAvailableTools(testDir); + const toolValues = tools.map((t) => t.value); + expect(toolValues).toContain('github-copilot'); + }); + + it('should detect GitHub Copilot when .github/.mcp.json exists', async () => { + await fs.mkdir(path.join(testDir, '.github'), { recursive: true }); + await fs.writeFile(path.join(testDir, '.github', '.mcp.json'), '{}'); + + const tools = getAvailableTools(testDir); + const toolValues = tools.map((t) => t.value); + expect(toolValues).toContain('github-copilot'); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/core/available-tools.test.ts` around lines 91 - 150, Add two new tests to cover the remaining GitHub Copilot detection markers: create a test that writes an empty file at path.join(testDir, '.github', 'instructions') and asserts getAvailableTools(testDir).map(t=>t.value) contains 'github-copilot', and another test that writes an empty file at path.join(testDir, '.github', '.mcp.json') and asserts the same; use the existing test pattern (getAvailableTools, testDir, mapping to toolValues and expect(...).toContain('github-copilot')) so detectionPaths for Copilot are fully covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/core/available-tools.test.ts`:
- Around line 91-150: Add two new tests to cover the remaining GitHub Copilot
detection markers: create a test that writes an empty file at path.join(testDir,
'.github', 'instructions') and asserts
getAvailableTools(testDir).map(t=>t.value) contains 'github-copilot', and
another test that writes an empty file at path.join(testDir, '.github',
'.mcp.json') and asserts the same; use the existing test pattern
(getAvailableTools, testDir, mapping to toolValues and
expect(...).toContain('github-copilot')) so detectionPaths for Copilot are fully
covered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 2150923f-0c72-4d11-bb3c-349a68429d09
📒 Files selected for processing (5)
src/core/available-tools.tssrc/core/config.tstest/core/available-tools.test.tstest/core/init.test.tstest/core/update.test.ts
Summary
openspec initfalsely auto-detects GitHub Copilot in virtually every GitHub repository because the tool detection logic checks for.github/directory existence, which is present in nearly all repos (for workflows, issue templates, etc.)detectionPathsfield toAIToolOptionthat overrides the defaultskillsDir-based detection. For GitHub Copilot, detection now requires Copilot-specific signals (e.g.,copilot-instructions.md,.github/prompts/,.github/agents/) instead of a bare.github/directory.github/no longer silently selects Copilot. In interactive first-time setup, Copilot is no longer incorrectly pre-selected. All other tools are unaffected (backward-compatible opt-in field)Detection signals for GitHub Copilot
The following Copilot-specific paths are checked (any one triggers detection):
.github/copilot-instructions.md.github/instructions/.github/workflows/copilot-setup-steps.yml.github/prompts/.github/agents/.github/skills/.github/.mcp.jsonChanges
src/core/config.tsdetectionPaths?: string[]toAIToolOption; added detection paths to GitHub Copilot entrysrc/core/available-tools.tsdetectionPathspresent, check those instead of bareskillsDirdirectorytest/core/available-tools.test.tstest/core/init.test.tstest/core/update.test.tsTest plan
.github/directory does NOT trigger Copilot detectiondetectionPathsstill useskillsDirdetection (backward compat)openspec initin temp dir with bare.github/produces no Copilot artifactsGenerated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Improvements
copilot-instructions.md,.github/prompts/,.github/agents/) rather than just folder presence, improving detection accuracy.