Skip to content

[#279] ✨ - Introduce the new Copilot agent - #282

Merged
efraespada merged 66 commits into
developfrom
feature/279-introduce-the-new-copilot-agent
Feb 9, 2026
Merged

[#279] ✨ - Introduce the new Copilot agent#282
efraespada merged 66 commits into
developfrom
feature/279-introduce-the-new-copilot-agent

Conversation

@efraespada

@efraespada efraespada commented Feb 9, 2026

Copy link
Copy Markdown
Member

📌 Summary

This PR introduces a new Copilot agent system powered by OpenCode to enable intelligent code analysis, progress tracking, error detection, and PR description generation. The new agent integrates seamlessly with the existing Git Board Flow workflow, providing an "interactive assistant" experience within CI workflows.

Key goals:

  • Replace the previous OpenRouter-based AI integration with OpenCode (supporting 75+ LLM providers)
  • Centralize reasoning and editing capabilities through a unified Copilot agent architecture
  • Add intent classification to route user requests to appropriate agent capabilities
  • Remove legacy components (Supabase, MCP, vector indexing) in favor of OpenCode's built-in capabilities

🎯 Related Issues / Tickets


🧩 Scope of Changes

  • Added:

    • New Copilot agent with intent classification system (src/agent/reasoning/copilot/, src/agent/reasoning/intent_classifier/)
    • OpenCode server integration with auto-start capability (opencode-start-server input)
    • New CLI commands: think, copilot, detect-errors, recommend-steps
    • Integration testing documentation (docs/integration-testing-agent-workflows.md)
    • Cursor IDE project context rules (.cursor/rules/project-context.mdc)
    • Pull request template (.github/pull_request_template.md)
    • Contributing guidelines (CONTRIBUTING.md)
    • ESLint configuration (eslint.config.mjs)
  • Updated:

    • Replaced OpenRouter with OpenCode (new inputs: opencode-server-url, opencode-model, opencode-start-server)
    • Simplified AI configuration (removed 9 OpenRouter-specific inputs)
    • All workflow files to use new OpenCode configuration
    • README with OpenCode documentation and CLI usage
    • AI repository to use OpenCode API (ask(), askAgent())
    • check_progress_use_case to use OpenCode Plan agent
    • think_use_case refactored for OpenCode integration
  • Removed:

    • Supabase integration (URL/key inputs, repository, caching)
    • MCP (Model Context Protocol) configuration and tooling
    • Vector indexing and AI knowledge workflows
    • Legacy error detector and progress detector implementations
    • Session data files (.agent-sessions/)
    • Outdated documentation (docs/THINK_AS_CLAUDE_USECASE.md, docs/ai-container-system.md, etc.)
  • Refactored:

    • Progress detection to use OpenCode Plan agent instead of custom implementation
    • Error detection moved to use-case layer with OpenCode integration
    • Built-in tools updated for new agent architecture

🛠️ Technical Details

  • OpenCode Migration: Replaced OpenRouter API with OpenCode server integration. OpenCode supports 75+ providers (OpenAI, Anthropic, Gemini, local models) through a unified interface.
  • Agent Architecture: New modular agent system with:
    • Intent classifier to route requests (copilot, progress check, error detection, etc.)
    • Copilot agent with subagent handling for complex tasks
    • File partitioning and system prompt building utilities
  • Server Management: Added opencode_server.ts utility to start/stop OpenCode server within GitHub Actions jobs when opencode-start-server: true
  • Removed Dependencies: Eliminated Supabase client, MCP tooling, and vector embedding infrastructure
  • Testing: Added comprehensive unit tests for new use cases and utilities

🔍 How to Test

  1. Commit workflow (progress detection):

    • Push to a branch linked to an issue (e.g., feature/123-title)
    • Verify progress labels (e.g., 25%, 50%) are applied to the issue
  2. Pull request workflow (AI description):

    • Enable ai-pull-request-description: true in the workflow
    • Open a PR from a branch linked to an issue
    • Verify PR description is auto-generated from issue and diff
  3. CLI commands:

    npm run build
    node build/cli/index.js check-progress -i <issue-number> -t <PAT>
    node build/cli/index.js think -q "Analyze src/cli.ts" -t <PAT>
  4. With OpenCode server:

    • Set opencode-start-server: true and provide OPENAI_API_KEY or ANTHROPIC_API_KEY
    • Run any workflow and verify OpenCode starts/stops correctly

🧪 Test Coverage

  • Unit tests added for new use cases (check_progress_use_case, detect_errors_use_case, recommend_steps_use_case, etc.)
  • Tests for utility functions (content_utils, file_utils, label_utils, etc.)
  • Manual testing validated via validate_agent_workflows.yml

⚠️ Breaking Changes

  • OpenRouter configuration removed: The following inputs are no longer supported:
    • openrouter-api-key, openrouter-model, openrouter-provider-*
    • Migration: Use opencode-server-url, opencode-model, and opencode-start-server instead
  • Supabase integration removed: Inputs supabase-url and supabase-key are no longer used
  • MCP configuration removed: .mcp.json configuration files are no longer supported

🚀 Deployment Notes

  • Requires environment variable changes
    • Remove: SUPABASE_URL, SUPABASE_KEY, OPENROUTER_API_KEY
    • Add: OPENCODE_SERVER_URL, OPENCODE_MODEL (or use opencode-start-server: true with provider keys)
  • No database migration (Supabase removed)

Details:

  • Update workflow files to use new OpenCode inputs
  • Configure provider API keys (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY) as secrets when using opencode-start-server: true

🔒 Security Considerations

  • Input validation changes
    • New OpenCode configuration inputs validated
  • Sensitive data handling changes
    • API keys now passed via environment variables to OpenCode server, not stored in action
    • Removed Supabase key storage

📈 Performance Impact

  • No performance impact
    • OpenCode server startup adds ~10-30 seconds when opencode-start-server: true
    • Otherwise same performance characteristics

📝 Notes for Reviewers

  • Focus on the new OpenCode integration in src/data/repository/ai_repository.ts
  • Review the intent classifier routing logic in src/agent/reasoning/intent_classifier/
  • Check that removed Supabase/MCP code doesn't have lingering references
  • The build/ directory changes are auto-generated from ncc compilation

✅ Checklist

  • I have self-reviewed my code
  • Code follows project standards and conventions
  • Tests have been added or updated
  • Documentation has been updated (README, docs/, CONTRIBUTING.md)
  • No new warnings or lint errors
  • Breaking changes are documented

📚 Additional Context

  • OpenCode Documentation: docs.page/landamessenger/git-board-flow/opencode-integration
  • Integration Testing Guide: See docs/integration-testing-agent-workflows.md for validation checklist
  • The Copilot agent is designed as a general-purpose development assistant, centralizing reasoning and editing capabilities that were previously dispersed across multiple systems.

…d for advanced code analysis and manipulation in CLI

Added a new 'copilot' command to the CLI, enabling users to interact with the Copilot agent for code analysis and modification. This includes options for prompts, branch selection, debugging, and output formatting. Enhanced error handling and user feedback for required parameters, ensuring a smoother user experience. The command processes prompts and provides detailed responses, including changes made and performance metrics.
…nctionality: Implement virtual codebase management and improved file handling

This update introduces a virtual codebase for the Copilot agent, allowing for better management of proposed changes. The `applyChange` method now checks if files are within the working directory before writing to disk, ensuring safer file operations. Additionally, error handling has been enhanced to log issues when applying changes. The `extractChanges` method has been updated to utilize tool results for more accurate change tracking. Tests have been updated to reflect these changes, ensuring robust functionality.
…and execute_command tools for enhanced code management

This update introduces the `apply_changes` tool, allowing the Copilot agent to write proposed changes from the virtual codebase to the actual file system, ensuring safer file operations within the working directory. Additionally, the `execute_command` tool has been added to enable the execution of shell commands for verification of code changes. The `propose_change` tool has been updated to clarify that changes are only applied in memory until explicitly written to disk. Documentation and tests have been enhanced to reflect these new functionalities and ensure robust performance.
…pilot_dummy directory and update system_prompt_builder.ts and execute_command_tool.ts to clarify critical workflow rules and command execution guidelines. Emphasize the importance of using the working directory for file operations and command execution to prevent unintended changes to the main project.
… propose_change tool documentation: Update system_prompt_builder.ts to clarify the critical workflow for code changes, emphasizing the mandatory sequence of proposing, applying, and verifying changes. Enhance the propose_change_tool.ts description to stress that changes are only stored in memory until applied, ensuring users understand the importance of using apply_changes for file creation and modification.
…lder.ts to clarify the workflow for code changes, emphasizing the distinction between exploration and execution. Enhance propose_change_tool.ts to specify its use for exploratory scenarios only, reinforcing the necessity of apply_changes for actual file creation and modification.
…s for subagents on applying changes to ensure correct workflow. Emphasize the critical sequence of proposing and applying changes to guarantee files are written to disk before executing commands.
…ctionality for proposed changes in the Copilot agent. This update adds the ability to automatically write changes to disk when using the propose_change tool with the auto_apply flag, enhancing the workflow for file creation and modification. The system prompt and related documentation have been updated to reflect this new feature, clarifying the process for users.
…nctionality: Introduce user prompt handling for auto-apply detection and improve command execution. This update adds the ability to automatically detect if a user prompt is an order or a question, enabling the `propose_change` tool to auto-apply changes accordingly. Additionally, the `execute_command` tool now automatically prepends the `cd` command to ensure correct execution within the specified working directory. Documentation has been updated to reflect these changes and clarify the workflow for users.
…irectory from 'copilot_dummy' to the current directory across multiple files. This change enhances flexibility and aligns the documentation with the new behavior, ensuring users operate within their intended context. Adjustments made in CLI options, agent initialization, command execution, and system prompts to reflect this update.
…ubagent usage. The default behavior for using subagents is now enabled, with an additional option to disable them using `--no-use-subagents`. This change clarifies the command-line interface and enhances user flexibility in managing parallel processing.
…default to using subagents for improved performance. Adjustments made to the system prompt and propose_change tool to clarify the workflow for code changes. Enhanced tests to verify default behaviors and ensure correct handling of user prompts for auto-apply functionality. Documentation updated to reflect these changes and provide clearer guidance for users.
…ization by resolving relative paths based on the working directory. This update ensures correct handling of file paths, improving the reliability of the auto-apply feature when working with different directory structures.
…nctionality by introducing intent classification for user prompts. This update allows the agent to determine whether changes should be applied based on the user's intent, improving the auto-apply feature. Additionally, the propose_change tool has been updated to handle various change types and includes new options for managing TODO items. Documentation has been revised to reflect these enhancements and clarify the workflow for users.
…ager and related tools to utilize the new TodoStatus enum for improved clarity and consistency in managing TODO items. Adjustments made to the create and update methods to ensure proper status handling. Documentation and examples have been revised to reflect these changes, enhancing the overall user experience and understanding of the TODO management workflow.
… across multiple modules to streamline output and improve readability.
…proach for handling prompts, separating analysis and execution. Phase 1 allows subagents to analyze files in read-only mode and propose changes without applying them. Phase 2 executes the proposed changes sequentially, improving conflict management. Additionally, new ChangePlan interface added to structure proposed changes. Documentation updated to reflect these enhancements.
…nCode parameters in action.yml, updating descriptions and defaults for improved clarity. Update README to reflect the integration of OpenCode for AI operations, emphasizing support for multiple LLM providers. Remove obsolete CLI files and definitions to streamline the codebase.
…tion.yml for automatic server management. Update documentation to reflect new configuration options and improve clarity on AI features. Remove outdated documents related to agent SDK comparisons and examples to streamline the codebase.
…action.yml and update documentation to reflect the changes. Eliminate references to AI cache actions in README and other files, streamlining the codebase and focusing on OpenCode functionalities. Clean up unused session files and adjust related types and interfaces accordingly.
…w linting scripts in package.json. Update README to include linting instructions and configuration details. Refactor variable declarations across multiple files for consistency, changing `let` to `const` where applicable. Remove obsolete codebase analysis schema and related types to streamline the codebase.
…tured imports for consistency across tools. Update execute method signatures to use `Record<string, unknown>` instead of `Record<string, any>` for improved type safety. Enhance ESLint configuration for test files to allow `require()` imports for better mock handling.
…or detecting potential errors and recommending implementation steps in the CLI. Introduce new actions and update the AI repository to support these functionalities. Enhance the SingleAction model to include new action types and integrate them into the use case flow for improved issue management.
… identify when a branch is being renamed and conditionally update the parent branch configuration. This enhancement improves the handling of branch switches and ensures accurate branch management during operations.
… for pushed issues: Introduce logic to identify branch renaming in the BranchRepository, conditionally updating the parent branch configuration. Additionally, add functionality to comment on issues during push events when a valid issue number is present, improving interaction with issue tracking.
@efraespada
efraespada force-pushed the feature/279-introduce-the-new-copilot-agent branch from 5794c71 to c0c70e1 Compare February 9, 2026 03:04
@elisalopez elisalopez added the size: XXL Indicates an extremely large task or issue that requires significant time and effort to complete. label Feb 9, 2026
@elisalopez

Copy link
Copy Markdown
Contributor

✨ Feature Actions

  1. Size and progress labels copied from issue ✨🧑‍💻 - Introduce the new Copilot agent #279 to this PR.
  2. The description has been updated with AI-generated content (OpenCode Plan agent).

image

🚀 Happy coding!

@elisalopez elisalopez added 95% Progress: 95% and removed 85% Progress: 85% labels Feb 9, 2026
…he structure of the summary message to improve clarity and presentation. Enhance the formatting of sections for remaining tasks and reasoning, incorporating headings and emojis for better user engagement.
…ne the summary message structure by removing unnecessary line breaks and adding headings with emojis for improved clarity and user engagement.
… repository: Introduce a JSON schema for translation responses, ensuring required fields and optional reasoning for failures. Update the translation logic to utilize the new schema, enhancing error handling and response clarity in comment translations.
@efraespada
efraespada force-pushed the feature/279-introduce-the-new-copilot-agent branch from d6d9269 to b071e6f Compare February 9, 2026 03:27
@elisalopez

Copy link
Copy Markdown
Contributor

✨ Feature Actions

  1. Size and progress labels copied from issue ✨🧑‍💻 - Introduce the new Copilot agent #279 to this PR.
  2. The description has been updated with AI-generated content (OpenCode Plan agent).

image

🚀 Happy coding!

@elisalopez elisalopez added 40% Progress: 40% and removed 95% Progress: 95% labels Feb 9, 2026
…date the ThinkUseCase class to utilize AiRepository for AI interactions instead of FileRepository. Modify the invoke method to enhance comment handling and context retrieval, improving the overall functionality and clarity of the AI response process. Remove the ReasoningVisualizer class and its related tests to streamline the codebase.
@efraespada
efraespada force-pushed the feature/279-introduce-the-new-copilot-agent branch from 4ff119d to b7279b4 Compare February 9, 2026 03:46
@elisalopez elisalopez added 85% Progress: 85% and removed 40% Progress: 40% labels Feb 9, 2026
@elisalopez

Copy link
Copy Markdown
Contributor

✨ Feature Actions

  1. Size and progress labels copied from issue ✨🧑‍💻 - Introduce the new Copilot agent #279 to this PR.
  2. The description has been updated with AI-generated content (OpenCode Plan agent).

image

🚀 Happy coding!

… heading level for the reasoning section from ### to ## to enhance clarity and consistency in the summary message structure.
…ls: Modify the .gitignore file to ensure package-lock.json is tracked in version control, enhancing consistency for npm installations.
…on, .mcp.json.example, and related test server files to clean up the project structure and eliminate unused resources. Additionally, remove unnecessary .DS_Store files and related .gitignore entries for a cleaner repository.
@efraespada
efraespada force-pushed the feature/279-introduce-the-new-copilot-agent branch from 0a36c48 to ce10e68 Compare February 9, 2026 03:55
@elisalopez elisalopez added 100% Progress: 100% and removed 85% Progress: 85% labels Feb 9, 2026
@elisalopez

Copy link
Copy Markdown
Contributor

✨ Feature Actions

  1. Size and progress labels copied from issue ✨🧑‍💻 - Introduce the new Copilot agent #279 to this PR.
  2. The description has been updated with AI-generated content (OpenCode Plan agent).

image

🚀 Happy coding!

@efraespada
efraespada merged commit ecb8416 into develop Feb 9, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in vypdev Feb 9, 2026
@elisalopez

Copy link
Copy Markdown
Contributor

✨ Feature Actions

  1. ✨🧑‍💻 - Introduce the new Copilot agent #279 was automatically closed after merging this pull request.

image

🚀 Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

100% Progress: 100% branched Indicates that a branch has been created for this issue. enhancement New feature or request feature Label to manage feature branches priority: low Not urgent, can be addressed later. size: XXL Indicates an extremely large task or issue that requires significant time and effort to complete.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

✨🧑‍💻 - Introduce the new Copilot agent

2 participants