Spawn GitHub Copilot for GitHub-integrated workflows with tool permission controls and automatic fallback to Sonnet
Spawn GitHub Copilot for GitHub-integrated workflows with fine-grained tool permissions and automatic fallback to Sonnet. Use for tasks requiring GitHub operations (repos, issues, PRs) with restricted tool access or when testing Copilot's capabilities against Claude's.
/plugin marketplace add Shakes-tzd/htmlgraph/plugin install htmlgraph@htmlgraphSpawn GitHub Copilot for GitHub-integrated workflows with tool permission controls and automatic fallback to Sonnet.
Delegate GitHub-centric tasks to GitHub Copilot via HeadlessSpawner with fine-grained tool permissions and automatic fallback to Sonnet if Copilot CLI fails.
Activate this spawner when:
Copilot provides fine-grained tool control:
result = spawner.spawn_copilot(
prompt="Create GitHub issue for bug",
allow_tools=["shell(git)", "github(*)"] # Only git + GitHub tools
)
result = spawner.spawn_copilot(
prompt="Full automation workflow",
allow_all_tools=True # No restrictions
)
result = spawner.spawn_copilot(
prompt="Analyze code without writes",
deny_tools=["write(*)", "shell(rm)"] # Block destructive operations
)
result = spawner.spawn_copilot(
prompt="GitHub workflow with restrictions",
allow_tools=["github(*)", "shell(git)"],
deny_tools=["shell(rm)", "write(/etc/*)"] # Allow GitHub, deny dangerous ops
)
from htmlgraph.orchestration import HeadlessSpawner
spawner = HeadlessSpawner()
result = spawner.spawn_copilot(
prompt="Create GitHub issue for feature request: Add dark mode",
allow_tools=["github(*)"] # Only GitHub operations
)
if result.success:
print(f"Issue created: {result.response}")
else:
# Fallback to Sonnet with gh CLI
Task(
prompt="Create GitHub issue using gh CLI",
subagent_type="sonnet"
)
result = spawner.spawn_copilot(
prompt="Create feature branch, commit changes, push to remote",
allow_tools=["shell(git)"] # Only git commands
)
result = spawner.spawn_copilot(
prompt="Review PR #42 and suggest improvements",
allow_tools=["github(*)", "read(*.py)"] # GitHub + read-only code access
)
from htmlgraph.orchestration import HeadlessSpawner
spawner = HeadlessSpawner()
# Spawn Copilot with tool permissions
result = spawner.spawn_copilot(
prompt="Your task description here",
allow_tools=["shell(git)", "github(*)"], # Tool allowlist
allow_all_tools=False, # Or allow everything
deny_tools=["write(/etc/*)", "shell(rm)"], # Tool denylist
timeout=120 # Seconds
)
# Check result - IMPORTANT: Detect empty responses!
is_empty_response = result.success and not result.response
if result.success and not is_empty_response:
print(f"Response: {result.response}")
print(f"Tokens: {result.tokens_used or 'estimated'}")
# Access raw output
print(f"Full output:\n{result.raw_output}")
else:
# Handle both explicit failures and empty responses
if is_empty_response:
error_msg = "Empty response (likely quota exceeded or timeout)"
print(f"⚠️ Silent failure: {error_msg}")
else:
error_msg = result.error
print(f"Error: {error_msg}")
# Fallback strategy
Task(
prompt=f"""
Task: Same task but with Sonnet fallback
Reason: Copilot {error_msg}
""",
subagent_type="sonnet"
)
Common errors and solutions:
Error: "Copilot CLI not found. Install from: https://docs.github.com/..."
Solution: Install Copilot CLI or fallback to Sonnet
Error: "Timed out after 120 seconds"
Solution: Increase timeout or split into smaller tasks
Error: "Tool not allowed: write(/etc/hosts)"
Solution: Adjust allow_tools or deny_tools permissions
Tool patterns support glob-style matching:
# Exact match
allow_tools=["shell(git status)"]
# Wildcard commands
allow_tools=["shell(git *)"]
# Wildcard tools
allow_tools=["github(*)"]
# File patterns
allow_tools=["write(*.py)", "read(src/*)"]
# Multiple patterns
allow_tools=["shell(git)", "github(*)", "read(*.md)"]
deny_tools=["write(/etc/*)", "shell(rm *)", "shell(sudo *)"]
Copilot excels at GitHub workflows:
result = spawner.spawn_copilot(
prompt="Create issue: Implement OAuth authentication",
allow_tools=["github(*)"]
)
result = spawner.spawn_copilot(
prompt="Review open PRs and comment on code quality",
allow_tools=["github(*)", "read(*)"]
)
result = spawner.spawn_copilot(
prompt="Trigger workflow run for deployment",
allow_tools=["github(*)"]
)
If Copilot spawn fails, automatically fallback to Sonnet:
result = spawner.spawn_copilot(
prompt="Task",
allow_tools=["github(*)"]
)
if not result.success:
# Log Copilot failure
print(f"Copilot failed: {result.error}")
# Fallback to Sonnet (with gh CLI if needed)
Task(
prompt=f"""
Task: {prompt}
Note: Attempted Copilot but failed, using Sonnet fallback.
Use gh CLI for GitHub operations if needed.
""",
subagent_type="sonnet"
)
Track spawner usage and tool permissions:
from htmlgraph import SDK
sdk = SDK(agent="copilot-spawner")
spike = sdk.spikes.create(
title="Copilot: GitHub Workflow Results",
findings=f"""
## Task
{prompt}
## Results
{result.response}
## Tool Permissions
- Allowed: {allow_tools or 'all'}
- Denied: {deny_tools or 'none'}
- All tools: {allow_all_tools}
## Performance
- Tokens: {result.tokens_used or 'estimated'}
- Fallback used: {not result.success}
"""
).save()
This spawner succeeds when:
Designs feature architectures by analyzing existing codebase patterns and conventions, then providing comprehensive implementation blueprints with specific files to create/modify, component designs, data flows, and build sequences