VOOZH about

URL: https://deepwiki.com/invokable/laravel-boost-copilot-cli/4-core-architecture

⇱ Core Architecture | invokable/laravel-boost-copilot-cli | DeepWiki


Loading...
Last indexed: 7 March 2026 (397730)
Menu

Core Architecture

This document explains the internal architecture of the revolution/laravel-boost-copilot-cli package and how its components integrate with Laravel Boost to enable GitHub Copilot CLI communication with Laravel applications via the Model Context Protocol (MCP).

For installation and setup procedures, see Getting Started. For detailed configuration options, see Configuration System. For development and testing procedures, see Development Guide.


System Overview

The package consists of two primary components that work together to integrate GitHub Copilot CLI with Laravel Boost:

ComponentFilePurpose
CopilotClisrc/CopilotCli.phpCore agent implementation extending Agent base class and implementing SupportsGuidelines, SupportsMcp, and SupportsSkills interfaces
CopilotCliServiceProvidersrc/CopilotCliServiceProvider.phpLaravel service provider registering CopilotCli with Laravel Boost's agent registry and handling Testbench-specific path adjustments

Component Integration Diagram


Sources: src/CopilotCli.php1-150 src/CopilotCliServiceProvider.php1-43 .github/copilot-instructions.md24-36


CopilotCli Class Implementation

The CopilotCli class src/CopilotCli.php14 extends Laravel\Boost\Install\Agents\Agent and implements three interfaces:

  1. Laravel\Boost\Contracts\SupportsGuidelines - Provides paths for AI guidelines and skills
  2. Laravel\Boost\Contracts\SupportsMcp - Provides MCP server configuration
  3. Laravel\Boost\Contracts\SupportsSkills - Provides skills directory path

Class Declaration and Properties


The class maintains two static properties for testing:

Sources: src/CopilotCli.php1-18

Agent Base Class Methods

The CopilotCli class inherits from the Agent base class and provides agent-specific implementations:

Agent Identification

MethodReturn ValuePurpose
name()'copilot-cli'Internal identifier used by Laravel Boost's agent registry
displayName()'GitHub Copilot CLI'User-facing name displayed in installation prompts

Sources: src/CopilotCli.php20-28

System-Wide Detection

The systemDetectionConfig() method src/CopilotCli.php35-46 returns platform-specific shell commands to detect GitHub Copilot CLI installation:

PlatformDetection CommandPurpose
Platform::Darwin (macOS)command -v copilotChecks if copilot exists in PATH
Platform::Linuxcommand -v copilotChecks if copilot exists in PATH
Platform::Windowswhere copilot 2>nulWindows-specific command existence check

The method uses a match expression to return the appropriate detection configuration based on the platform.

Sources: src/CopilotCli.php35-46

Project-Specific Detection

The projectDetectionConfig() method src/CopilotCli.php54-59 checks for the presence of .github/copilot-instructions.md:


This file indicates that the project has been configured for GitHub Copilot CLI integration.

Sources: src/CopilotCli.php54-59

SupportsGuidelines Interface Implementation

The SupportsGuidelines interface implementation provides paths for AI-related configuration files:

Guidelines Path

The guidelinesPath() method src/CopilotCli.php66-69 returns the file path where AI guidelines should be written:


This path is configurable via config/boost.php, defaulting to .github/instructions/laravel-boost.instructions.md.

Sources: src/CopilotCli.php66-69

Skills Path

The skillsPath() method src/CopilotCli.php74-77 returns the directory path where agent skills should be written:


Skills are specialized AI capabilities that activate in specific contexts. The default path is .github/skills/.

Sources: src/CopilotCli.php74-77

SupportsMcp Interface Implementation

The SupportsMcp interface implementation provides MCP server configuration for GitHub Copilot CLI:

MCP Configuration File Path

The mcpConfigPath() method src/CopilotCli.php79-82 specifies where the MCP configuration file should be written:


This file contains the server configuration that GitHub Copilot CLI uses to connect to Laravel Boost's MCP server.

Sources: src/CopilotCli.php79-82

MCP Server Configuration Generation

The mcpServerConfig() method src/CopilotCli.php91-103 generates the MCP server configuration payload:

MCP Configuration Generation Flow


The generated configuration structure:


Configuration element purposes:

KeyValuePurpose
type'local'Indicates a locally-spawned MCP server process
commandEnvironment-adaptedConverted via convertCommandToPhpPath() to match execution environment
argsConditional array['boost:mcp'] for Testbench, ['artisan', 'boost:mcp'] otherwise
envPassthroughEnvironment variables passed from caller
tools['*']Enables all available Laravel Boost MCP tools

Sources: src/CopilotCli.php91-103

Environment Detection and Command Conversion

Testbench Detection

The isRunningInTestbench() method src/CopilotCli.php133-140 detects if the code is running within Orchestra Testbench:


Detection logic:

  1. Check the static $fake_testbench flag (for testing purposes)
  2. Check if the TESTBENCH_CORE constant is defined (set by Orchestra Testbench)

Sources: src/CopilotCli.php133-140

WSL Detection

The isRunningInsideWsl() method src/CopilotCli.php124-131 detects if the code is running inside Windows Subsystem for Linux:


Detection logic:

  1. Check the static $fake_wsl flag (for testing purposes)
  2. Check for WSL_DISTRO_NAME environment variable (set by WSL 2)
  3. Check for IS_WSL environment variable (alternative WSL indicator)

Sources: src/CopilotCli.php124-131

Command Path Conversion

The convertCommandToPhpPath() method src/CopilotCli.php108-122 adapts the PHP command based on execution environment:

Command Conversion Logic


Environment-specific command mapping:

ConditionInput CommandOutput CommandRationale
isRunningInTestbench()Any./vendor/bin/testbenchTestbench wrapper script required
isRunningInsideWsl()AnygetPhpPath()WSL needs proper PHP path resolution
Command ends with sail*/sail./vendor/bin/sailLaravel Sail wrapper script required
DefaultAnyUnchangedStandard PHP command (typically php)

Sources: src/CopilotCli.php108-122

Testing Support

The fake() static method src/CopilotCli.php145-149 enables test mode simulation:


This method allows tests to simulate environment-specific behavior:

  • $testbench - Controls isRunningInTestbench() return value
  • $wsl - Controls isRunningInsideWsl() return value

This enables testing of environment-specific code paths without requiring actual environment setup.

Sources: src/CopilotCli.php145-149


Service Provider Integration

The CopilotCliServiceProvider class src/CopilotCliServiceProvider.php14 handles Laravel integration and agent registration.

Service Provider Structure

Service Provider Flow Diagram


Sources: src/CopilotCliServiceProvider.php16-42

Agent Registration

The boot() method src/CopilotCliServiceProvider.php16-23 performs two key operations:

  1. Registration with Laravel Boost's Agent Registry:

This registers the CopilotCli class with the identifier 'copilot-cli' in Laravel Boost's agent registry. The agent becomes available during php artisan boost:install when users select their AI agent.

  1. Testbench-Specific Configuration:

If running in Orchestra Testbench (detected via the TESTBENCH_CORE constant), additional path adjustments are applied to ensure correct file operations during installation.

Sources: src/CopilotCliServiceProvider.php16-23

Testbench Path Adjustments

The testbench() method src/CopilotCliServiceProvider.php28-42 corrects path resolution issues specific to Orchestra Testbench:


Testbench Path Resolution

Path Resolution Flow


Path correction purposes:

Path TypeIssueResolutionMethod Call
Base PathPoints to Testbench skeleton directory instead of package rootSet to current working directorysetBasePath(getcwd())
Storage PathMissing storage directory for file operationsUse Testbench default skeleton storageuseStoragePath(default_skeleton_path('storage'))
App PathMissing app directory for application structureUse Testbench default skeleton appuseAppPath(default_skeleton_path('app'))

These adjustments ensure that when php artisan boost:install runs in a package development environment, configuration files are written to the correct locations relative to the package root, not the Testbench skeleton directory.

Sources: src/CopilotCliServiceProvider.php28-42


MCP Protocol Integration

The Model Context Protocol (MCP) integration enables communication between GitHub Copilot CLI and the Laravel Boost MCP server.

MCP Configuration Flow


Sources: src/CopilotCli.php69-93 src/CopilotCli.php64-67

Generated Configuration Structure

The .github/mcp-config.json file structure generated by mcpServerConfig() varies by environment. The complete file includes the mcpServers wrapper:

Standard Laravel Application


Orchestra Testbench


Laravel Sail


WSL Environment


Environment-specific differences:

Environmentcommand Valueargs ValueNotes
Standard Laravelphp["artisan", "boost:mcp"]Direct PHP execution
Testbench./vendor/bin/testbench["boost:mcp"]No artisan prefix needed
Laravel Sail./vendor/bin/sail["artisan", "boost:mcp"]Sail wrapper script
WSLphp["artisan", "boost:mcp"]Resolved via getPhpPath()

Sources: src/CopilotCli.php91-103 src/CopilotCli.php108-122 .github/copilot-instructions.md38-90

MCP Server Lifecycle


The MCP server remains active for the duration of the Copilot CLI session, providing continuous access to Laravel application context.

Sources: src/CopilotCli.php81-93


Architecture Constraints

The package enforces several architectural constraints through its implementation:

Interface Contracts

The CopilotCli class must implement:

  1. Agent Interface Methods:

  2. McpClient Interface Methods:

Environment Adaptability Requirements

The class must:

Service Provider Requirements

The service provider must:

Sources: src/CopilotCli.php13-127 src/CopilotCliServiceProvider.php14-43

Refresh this wiki

On this page