feat: generate Copilot coding agent files on openspec init (github-copilot)#858
feat: generate Copilot coding agent files on openspec init (github-copilot)#858NicoAvanzDev wants to merge 2 commits intoFission-AI:mainfrom
openspec init (github-copilot)#858Conversation
…selected When `openspec init` or `openspec update` is run with the github-copilot tool selected, two additional files are now generated in the user's project: 1. `.github/workflows/copilot-setup-steps.yml` - A GitHub Actions workflow that pre-installs the OpenSpec CLI in the Copilot coding agent's ephemeral environment (required for the agent to use `openspec` commands). 2. `.github/agents/openspec.agent.md` - A custom agent definition that instructs the GitHub Copilot coding agent how to use the OpenSpec CLI, including all agent-compatible commands with `--json` output, workflow patterns, and best practices. These files are only written if they don't already exist (to preserve user customizations). The generation is non-fatal — if it fails, init/update still completes successfully. New module: src/core/github-copilot/cloud-agent.ts Tests: test/core/github-copilot-cloud-agent.test.ts
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new GitHub Copilot Cloud Agent module that generates two repository files (a GitHub Actions workflow and an agent markdown), plus integration into init and update flows to write or remove those files; all file operations are non-fatal and errors are swallowed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
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)
📝 Coding Plan
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/core/github-copilot-cloud-agent.test.ts (1)
1-54: Consider adding tests forwriteCopilotCloudFilesandremoveCopilotCloudFiles.The current tests cover the pure utility functions (
includesGitHubCopilot, content generators, and path constants), which is good. However,writeCopilotCloudFilesandremoveCopilotCloudFilescontain conditional logic (file existence checks, force option, iteration over files) that would benefit from test coverage.Key scenarios to consider:
writeCopilotCloudFiles: skips existing files, writes when force=true, creates directoriesremoveCopilotCloudFiles: removes only existing files, returns correct countWould you like me to help generate test cases for these functions? I can open a new issue to track this.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/core/github-copilot-cloud-agent.test.ts` around lines 1 - 54, Add unit tests for writeCopilotCloudFiles and removeCopilotCloudFiles to cover their conditional logic: create tests that (1) verify writeCopilotCloudFiles skips writing when files already exist, (2) verify writeCopilotCloudFiles overwrites when called with force=true and creates missing directories, and (3) verify removeCopilotCloudFiles deletes only existing files and returns the correct deletion count; use the COPILOT_CLOUD_FILES keys to locate target file paths and mock or use a temp fs (setup/teardown) to create existing files and assert behavior for each scenario.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/core/github-copilot/cloud-agent.ts`:
- Around line 183-196: The exported function removeCopilotCloudFiles is unused;
either wire it into the tool-selection cleanup logic or remove it. If tool
removal should delete these files, call removeCopilotCloudFiles(projectPath)
from the relevant init/update flow where tool selection changes (e.g., inside
the function that handles tool removal or the project update handler) after you
detect github-copilot was deselected, and ensure errors are handled/logged;
otherwise delete the removeCopilotCloudFiles export and its tests to avoid dead
code.
---
Nitpick comments:
In `@test/core/github-copilot-cloud-agent.test.ts`:
- Around line 1-54: Add unit tests for writeCopilotCloudFiles and
removeCopilotCloudFiles to cover their conditional logic: create tests that (1)
verify writeCopilotCloudFiles skips writing when files already exist, (2) verify
writeCopilotCloudFiles overwrites when called with force=true and creates
missing directories, and (3) verify removeCopilotCloudFiles deletes only
existing files and returns the correct deletion count; use the
COPILOT_CLOUD_FILES keys to locate target file paths and mock or use a temp fs
(setup/teardown) to create existing files and assert behavior for each scenario.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c818ba78-e83c-456c-a849-975427bf9fad
📒 Files selected for processing (4)
src/core/github-copilot/cloud-agent.tssrc/core/init.tssrc/core/update.tstest/core/github-copilot-cloud-agent.test.ts
When github-copilot is not in the configured tools during update, remove the cloud agent files (copilot-setup-steps.yml and openspec.agent.md) if they exist.
Summary
When a user runs
openspec init(oropenspec update) and selects the github-copilot tool, OpenSpec now also generates two files that enable the GitHub Copilot coding agent (cloud-based, triggered from GitHub Issues/PRs) to use the OpenSpec CLI:Generated files (in the user's project)
1.
.github/workflows/copilot-setup-steps.ymlA Copilot setup steps workflow that pre-installs the OpenSpec CLI in the agent's ephemeral GitHub Actions environment:
@fission-ai/openspecglobally via npmopenspec --version)This file must be on the default branch to be picked up by Copilot coding agent.
2.
.github/agents/openspec.agent.mdA custom agent that teaches the Copilot coding agent how to use the OpenSpec CLI:
list,show,validate,status,instructions,templates,schemas,archive) with--jsonguidanceBehavior
init/updatestill completesopenspec initandopenspec updatewhengithub-copilotis in the selected toolsWhy
OpenSpec already generates skills (
.github/skills/) and prompt files (.github/prompts/) for GitHub Copilot IDE extensions. However, the Copilot coding agent runs in an ephemeral Actions environment without the CLI. These two files close that gap, enabling fully autonomous OpenSpec workflows from GitHub Issues/PRs.Changes
src/core/github-copilot/cloud-agent.tssrc/core/init.tssrc/core/update.tstest/core/github-copilot-cloud-agent.test.tsTesting
npx vitest run test/core/github-copilot-cloud-agent.test.ts # ✓ 6 tests passedBuild passes with
npm run build.Summary by CodeRabbit
New Features
Tests