Skip to content

feat: generate Copilot coding agent files on openspec init (github-copilot)#858

Open
NicoAvanzDev wants to merge 2 commits intoFission-AI:mainfrom
NicoAvanzDev:feat/github-copilot-cloud-agent-init
Open

feat: generate Copilot coding agent files on openspec init (github-copilot)#858
NicoAvanzDev wants to merge 2 commits intoFission-AI:mainfrom
NicoAvanzDev:feat/github-copilot-cloud-agent-init

Conversation

@NicoAvanzDev
Copy link

@NicoAvanzDev NicoAvanzDev commented Mar 19, 2026

Summary

When a user runs openspec init (or openspec 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.yml

A Copilot setup steps workflow that pre-installs the OpenSpec CLI in the agent's ephemeral GitHub Actions environment:

  • Checks out the repo
  • Installs @fission-ai/openspec globally via npm
  • Verifies the CLI is available (openspec --version)

This file must be on the default branch to be picked up by Copilot coding agent.

2. .github/agents/openspec.agent.md

A custom agent that teaches the Copilot coding agent how to use the OpenSpec CLI:

  • Full reference of agent-compatible CLI commands (list, show, validate, status, instructions, templates, schemas, archive) with --json guidance
  • Workflow patterns (check state → follow instructions → validate)
  • Key directory structure
  • Best practices for programmatic use

Behavior

  • Files are only written if they don't already exist — user customizations are preserved
  • Generation is non-fatal — if writing fails, init/update still completes
  • Applies to both openspec init and openspec update when github-copilot is in the selected tools

Why

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

File Change
src/core/github-copilot/cloud-agent.ts New module: file generation logic
src/core/init.ts Hook: generate cloud files after github-copilot setup
src/core/update.ts Hook: generate cloud files during update
test/core/github-copilot-cloud-agent.test.ts Unit tests (6 passing)

Testing

npx vitest run test/core/github-copilot-cloud-agent.test.ts
# ✓ 6 tests passed

Build passes with npm run build.

Summary by CodeRabbit

  • New Features

    • Added GitHub Copilot Cloud Agent support: the toolchain now creates supporting CI workflow and agent configuration files when Copilot is selected during project init or update. Files are created only if absent (or when forced), and are removed automatically if Copilot is no longer configured. Failures in file creation/removal are non-fatal and won't block init/update flows.
  • Tests

    • Added tests covering Copilot cloud-agent utilities and generated content verification.

…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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b662a2d-c8db-4732-a251-609e2ca5f485

📥 Commits

Reviewing files that changed from the base of the PR and between 49fa505 and 3756d65.

📒 Files selected for processing (1)
  • src/core/update.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/update.ts

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
GitHub Copilot Cloud Agent
src/core/github-copilot/cloud-agent.ts
New module: defines github-copilot tool id, includesGitHubCopilot, generators generateCopilotSetupSteps & generateCopilotAgentFile, COPILOT_CLOUD_FILES, writeCopilotCloudFiles, and removeCopilotCloudFiles (writes files only if absent unless forced; deletes existing files).
Init flow integration
src/core/init.ts
Imports includesGitHubCopilot and writeCopilotCloudFiles; after tool setup, attempts to write Copilot cloud files inside a try/catch (errors swallowed).
Update flow integration
src/core/update.ts
Imports includesGitHubCopilot, writeCopilotCloudFiles, removeCopilotCloudFiles; on update, writes files when Copilot is selected and removes them when Copilot is no longer configured; both operations wrapped in try/catch and non-fatal.
Tests
test/core/github-copilot-cloud-agent.test.ts
New Vitest suite validating includesGitHubCopilot, generated workflow and agent contents, and COPILOT_CLOUD_FILES paths.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • TabishB

Poem

🐰 I hop and clack on keys of light,
I craft two files to set things right,
A workflow hums, an agent sings,
Errors caught with careful springs,
Copilot's garden blooms tonight. 🌿✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding GitHub Copilot cloud agent file generation during openspec init and openspec update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@NicoAvanzDev NicoAvanzDev marked this pull request as ready for review March 19, 2026 09:08
@NicoAvanzDev NicoAvanzDev requested a review from TabishB as a code owner March 19, 2026 09:08
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/core/github-copilot-cloud-agent.test.ts (1)

1-54: Consider adding tests for writeCopilotCloudFiles and removeCopilotCloudFiles.

The current tests cover the pure utility functions (includesGitHubCopilot, content generators, and path constants), which is good. However, writeCopilotCloudFiles and removeCopilotCloudFiles contain 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 directories
  • removeCopilotCloudFiles: removes only existing files, returns correct count

Would 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

📥 Commits

Reviewing files that changed from the base of the PR and between afdca0d and 49fa505.

📒 Files selected for processing (4)
  • src/core/github-copilot/cloud-agent.ts
  • src/core/init.ts
  • src/core/update.ts
  • test/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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant