VOOZH about

URL: https://deepwiki.com/invokable/laravel-boost-copilot-cli/4.2-copilotcli-agent-class

⇱ CopilotCli Agent Class | invokable/laravel-boost-copilot-cli | DeepWiki


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

CopilotCli Agent Class

This page documents the CopilotCli class in detail: its inheritance hierarchy, the interfaces it implements, every public method, and the runtime environment detection logic that shapes the MCP server configuration it produces.

For background on how CopilotCli is registered with the Boost framework, see the service provider page 4.3. For how the MCP configuration payload it produces is consumed at runtime, see 4.4.


Class Identity

CopilotCli lives in src/CopilotCli.php and is the single PHP class this package contributes to the Laravel Boost agent system.

PropertyValue
NamespaceRevolution\Laravel\Boost
ExtendsLaravel\Boost\Install\Agents\Agent
ImplementsSupportsGuidelines, SupportsMcp, SupportsSkills
Agent keycopilot-cli

Class declaration src/CopilotCli.php14

CopilotCli extends Agent implements SupportsGuidelines, SupportsMcp, SupportsSkills

The three interfaces each require a distinct subset of methods, mapping to three concerns: writing AI instruction files, writing MCP server configuration, and writing agent skill files.


Inheritance and Interface Map

Diagram: Class structure and interface obligations


Sources: src/CopilotCli.php1-14


Public Methods Reference

Identification Methods

MethodReturn valueNotes
name()'copilot-cli'Used as the registry key when Boost::registerAgent() is called
displayName()'GitHub Copilot CLI'Human-readable label shown in install prompts

src/CopilotCli.php20-28


Detection Methods

Detection drives two questions: is the copilot binary installed system-wide, and does this project look like it already uses Copilot CLI?

systemDetectionConfig(Platform $platform)

Returns a shell command to check whether copilot is on the system PATH.

PlatformStrategyCommand
Platform::Darwin (macOS)shell commandcommand -v copilot
Platform::Linuxshell commandcommand -v copilot
Platform::Windowsshell commandwhere copilot 2>nul

src/CopilotCli.php35-47

projectDetectionConfig()

Returns a file presence check. If .github/copilot-instructions.md exists in the project root, the project is considered already configured for Copilot CLI.

['files' => ['.github/copilot-instructions.md']]

src/CopilotCli.php54-59


File Path Methods

These methods tell the Boost installer where to write the generated files.

MethodDefault pathConfig key override
guidelinesPath().github/instructions/laravel-boost.instructions.mdboost.agents.copilot_cli.guidelines_path
skillsPath().github/skillsboost.agents.copilot_cli.skills_path
mcpConfigPath().github/mcp-config.json(hardcoded, no override)

src/CopilotCli.php66-83


MCP Configuration Methods

mcpInstallationStrategy()

Inherited from Agent. Returns McpInstallationStrategy::FILE, meaning the MCP server definition is written to a JSON file (.github/mcp-config.json) rather than being registered in a system-level config store.

tests/Feature/CopilotCliTest.php49-55

mcpServerConfig(string $command, array $args = [], array $env = [])

Builds the MCP server payload that is written into .github/mcp-config.json. The command parameter is the PHP executable path or equivalent detected at install time by the Boost framework.

The returned array always has this shape:

KeyValue
type'local'
commandResult of convertCommandToPhpPath($command)
args['artisan', 'boost:mcp'] normally; ['boost:mcp'] in Testbench
envPassed-through $env array
tools['*'] (all tools)

The args array omits 'artisan' when running in Testbench because vendor/bin/testbench already routes to Artisan. src/CopilotCli.php91-103


Environment Detection and convertCommandToPhpPath

convertCommandToPhpPath is the most complex method in the class. It takes the raw command string (e.g., 'php', './vendor/bin/sail') and returns the command that should actually appear in mcp-config.json.

Diagram: convertCommandToPhpPath decision flow


Sources: src/CopilotCli.php108-122

Branch explanation

EnvironmentDetectionResolved commandArgs
Orchestra TestbenchTESTBENCH_CORE constant defined, or $fake_testbench./vendor/bin/testbench['boost:mcp']
WSLWSL_DISTRO_NAME or IS_WSL env var set, or $fake_wslphp (via getPhpPath())['artisan', 'boost:mcp']
Laravel SailCommand path ends with sail./vendor/bin/sail['artisan', 'boost:mcp']
StandardNone of the aboveCommand as passed in['artisan', 'boost:mcp']

The Testbench branch is checked first and takes precedence over all other branches. The WSL branch is checked second. The Sail detection uses Str::afterLast($command, '/') so both ./vendor/bin/sail and an absolute path like /home/user/project/vendor/bin/sail are caught.

src/CopilotCli.php108-131 tests/Feature/CopilotCliTest.php71-97


Environment Detection Internals

isRunningInTestbench()

Public method. Returns true if the TESTBENCH_CORE PHP constant is defined (which Orchestra Testbench sets automatically), or if the $fake_testbench static flag has been set via fake().

src/CopilotCli.php133-140

isRunningInsideWsl()

Protected method. Reads the WSL_DISTRO_NAME and IS_WSL environment variables via getenv(). Either being non-empty is sufficient to return true. Also returns true when $fake_wsl is set.

src/CopilotCli.php124-131


Static Testing Seam: fake()

CopilotCli provides a static fake() method specifically for test isolation. Because Testbench and WSL detection depend on environment constants and variables that are difficult to control in unit tests, fake() sets two static boolean flags that override the real detection logic.

public static function fake(bool $testbench = true, bool $wsl = true): void

Both parameters default to true. To simulate only WSL without Testbench, call CopilotCli::fake(testbench: false, wsl: true).

Important: Because the flags are static, they persist across test cases. The test suite always resets them explicitly after use:

tests/Feature/CopilotCliTest.php71-81


Diagram: fake() state machine and affected methods


Sources: src/CopilotCli.php16-18 src/CopilotCli.php145-149 tests/Feature/CopilotCliTest.php99-135


Complete Method Summary

MethodVisibilityInterfaceReturns
name()publicAgentstring'copilot-cli'
displayName()publicAgentstring'GitHub Copilot CLI'
systemDetectionConfig(Platform)publicAgentarray{command: string}
projectDetectionConfig()publicAgentarray{files: string[]}
guidelinesPath()publicSupportsGuidelinesstring
skillsPath()publicSupportsSkillsstring
mcpConfigPath()publicSupportsMcpstring'.github/mcp-config.json'
mcpServerConfig(command, args, env)publicSupportsMcparray<string, mixed>
convertCommandToPhpPath(command)public(own)string
isRunningInTestbench()public(own)bool
isRunningInsideWsl()protected(own)bool
fake(testbench, wsl)public static(own)void

Sources: src/CopilotCli.php1-150