Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(provider): add GitHub Copilot CLI adapter preset (#101)

Anas Khan19a4f06833c3
diff --git a/src/main/realtimeActions.ts b/src/main/realtimeActions.ts
index dcc8ccdd..7f9fa448 100644
--- a/src/main/realtimeActions.ts
+++ b/src/main/realtimeActions.ts
@@ -101,7 +101,7 @@ const PENDING_TTL_MS = 120_000;
const PROVIDER_COMMAND: Record<string, string> = {
claude: 'claude', codex: 'codex', antigravity: 'antigravity', gemini: 'gemini',
- opencode: 'opencode', crush: 'crush', pi: 'pi', qwen: 'qwen'
+ opencode: 'opencode', crush: 'crush', pi: 'pi', qwen: 'qwen', copilot: 'copilot'
};
/** Bare affirmations that must NEVER authorize a destructive op on their own —
diff --git a/src/renderer/src/realtime/actions.ts b/src/renderer/src/realtime/actions.ts
index 5c444dfb..428088ae 100644
--- a/src/renderer/src/realtime/actions.ts
+++ b/src/renderer/src/realtime/actions.ts
@@ -187,7 +187,7 @@ export function realtimeActionTools(): ReturnType<typeof tool>[] {
parameters: {
type: 'object',
properties: {
- provider: { type: 'string', description: 'Engine: claude (default), codex, gemini, opencode, crush, pi, qwen.' },
+ provider: { type: 'string', description: 'Engine: claude (default), codex, gemini, opencode, crush, pi, qwen, copilot.' },
role: { type: 'string', description: 'Optional. The role/job for the new agent.' },
name: { type: 'string', description: 'Optional. A name for the agent.' },
cwd: { type: 'string', description: 'Optional. Working directory; defaults to the hive root.' }
diff --git a/src/renderer/src/store/config.ts b/src/renderer/src/store/config.ts
index ee045c2e..fb866a3d 100644
--- a/src/renderer/src/store/config.ts
+++ b/src/renderer/src/store/config.ts
@@ -224,6 +224,19 @@ export const PI_MODELS: ModelOption[] = [
{ id: 'local/llama3', label: 'Local · OpenAI-compatible (set base-URL)' }
];
+/** Models offered when an agent runs on GitHub Copilot (`copilot`). Copilot's
+ * `--model` takes a plain model id ('auto' lets Copilot pick); these are curated
+ * suggestions and the command field stays editable. // TODO-verify exact live ids
+ * (the /model picker is the source of truth; they drift). */
+export const COPILOT_MODELS: ModelOption[] = [
+ { id: undefined, label: 'default (Claude Sonnet 4.5)' },
+ { id: 'auto', label: 'Auto (Copilot picks)' },
+ { id: 'claude-sonnet-4.5', label: 'Claude Sonnet 4.5' },
+ { id: 'claude-sonnet-4', label: 'Claude Sonnet 4' },
+ { id: 'gpt-5.4', label: 'GPT-5.4' },
+ { id: 'gpt-5', label: 'GPT-5' }
+];
+
/** Split a command string into argv, respecting double/single quotes so a model
* value with spaces (agy's `--model "Gemini 3.1 Pro (High)"`) stays one token.
* Quotes are stripped from the result. */
@@ -243,6 +256,7 @@ export function modelsForProvider(provider: AgentProvider): ModelOption[] {
if (provider === 'opencode') return OPENCODE_MODELS;
if (provider === 'crush') return CRUSH_MODELS;
if (provider === 'pi') return PI_MODELS;
+ if (provider === 'copilot') return COPILOT_MODELS;
return AGENT_MODELS;
}
diff --git a/src/shared/agentProvider.ts b/src/shared/agentProvider.ts
index 93a8cd03..337be912 100644
--- a/src/shared/agentProvider.ts
+++ b/src/shared/agentProvider.ts
@@ -27,6 +27,7 @@ export type AgentProvider =
| 'opencode'
| 'crush'
| 'pi'
+ | 'copilot'
| 'custom';
/** Structured descriptor for how a NON-hiveAware provider gets hive lifecycle
@@ -365,6 +366,36 @@ export const AGENT_PROVIDER_PRESETS: AgentProviderPreset[] = [
installCommand: 'npm install -g --ignore-scripts @earendil-works/pi-coding-agent',
docsUrl: 'https://pi.dev/docs/latest'
},
+ {
+ // GitHub Copilot CLI (`copilot`, npm @github/copilot). Driven in print mode:
+ // `copilot -p "<prompt>" -s --allow-all-tools --no-ask-user [--model]`, the
+ // documented non-interactive shape (single prompt, clean stdout, exits when
+ // done). Non-hiveAware: it has no --append-system-prompt/--settings, so the
+ // hive identity+protocol rides in as the initial prompt via `-p`.
+ id: 'copilot',
+ label: 'Copilot',
+ defaultCommand: 'copilot',
+ commandGroups: [],
+ // Non-interactive autonomy: -s prints only the agent's final response (clean
+ // stdout), --allow-all-tools never blocks on a permission prompt (env:
+ // COPILOT_ALLOW_ALL), --no-ask-user disables the ask_user tool so it never
+ // stops to ask. Gated by the floor `config.autoMode` toggle like the rest.
+ autoModeFlag: '-s --allow-all-tools --no-ask-user',
+ autoFlag: '-s --allow-all-tools --no-ask-user',
+ supportsModel: true,
+ modelFlag: '--model', // e.g. claude-sonnet-4.5 (default), gpt-5.4, or 'auto'
+ hiveAware: false, // no --append-system-prompt/--settings; protocol rides in via -p
+ initialPromptFlag: '-p', // copilot -p "<orchestrator/worker brief>" runs it non-interactively
+ recommendedOrchestratorModel: 'claude-sonnet-4.5', // Copilot's default; user may pick gpt-5.4
+ // Copilot supports session resume by id (`--resume=<id>`); attached only when a
+ // prior session id was recorded (no hook bridge captures it yet → best-effort).
+ resumeFlag: '--resume',
+ // Print mode exits per turn and there is no hook bridge to drain on idle, so a
+ // copilot worker can't receive routed inbox mail (it bounces to the god).
+ canReceiveInbox: false,
+ installCommand: 'npm install -g @github/copilot', // trusted, hardcoded
+ docsUrl: 'https://docs.github.com/copilot/concepts/agents/about-copilot-cli'
+ },
{
id: 'custom',
label: 'Custom',
@@ -387,6 +418,7 @@ export function isAgentProvider(value: unknown): value is AgentProvider {
value === 'opencode' ||
value === 'crush' ||
value === 'pi' ||
+ value === 'copilot' ||
value === 'custom'
);
}
@@ -435,6 +467,7 @@ export function inferAgentProvider(command: string | undefined, explicit?: unkno
if (bin === 'opencode') return 'opencode';
if (bin === 'crush') return 'crush';
if (bin === 'pi') return 'pi';
+ if (bin === 'copilot') return 'copilot';
if (bin === 'claude' || !bin) return 'claude';
return 'custom';
}
diff --git a/test/agent-provider.test.cjs b/test/agent-provider.test.cjs
new file mode 100644
index 00000000..b8053e7b
--- /dev/null
+++ b/test/agent-provider.test.cjs
@@ -0,0 +1,74 @@
+'use strict';
+/**
+ * Agent-provider registry tests. Self-contained, no test framework — run with
+ * `node test/agent-provider.test.cjs` (mirrors test/kg-core.test.cjs). The
+ * registry lives in TypeScript (src/shared/agentProvider.ts), so we transpile it
+ * and its two dependency-free command-group siblings with the bundled `typescript`
+ * compiler into a temp dir and require the result. Exercises the copilot preset
+ * (GitHub Copilot CLI) end to end: registration, command inference, the print-mode
+ * flag shape, and the model/resume passthrough — alongside the pre-existing codex
+ * preset as a guard against regressions.
+ */
+
+const assert = require('node:assert');
+const fs = require('node:fs');
+const os = require('node:os');
+const path = require('node:path');
+const ts = require('typescript');
+
+const SHARED = path.join(__dirname, '..', 'src', 'shared');
+const out = fs.mkdtempSync(path.join(os.tmpdir(), 'agentprov-'));
+for (const name of ['claudeCommands', 'codexCommands', 'agentProvider']) {
+ const src = fs.readFileSync(path.join(SHARED, `${name}.ts`), 'utf8');
+ const js = ts.transpileModule(src, {
+ compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }
+ }).outputText;
+ fs.writeFileSync(path.join(out, `${name}.js`), js, 'utf8');
+}
+const ap = require(path.join(out, 'agentProvider.js'));
+
+let failures = 0;
+function test(name, fn) {
+ try { fn(); console.log(` ✓ ${name}`); }
+ catch (err) { failures++; console.log(` ✗ ${name}\n ${err && err.message}`); }
+}
+
+console.log('agent-provider registry tests');
+
+test('copilot is a recognized, selectable provider', () => {
+ assert.ok(ap.isAgentProvider('copilot'), 'isAgentProvider("copilot")');
+ assert.ok(ap.AGENT_PROVIDER_PRESETS.some((p) => p.id === 'copilot'), 'preset registered');
+});
+
+test('inferAgentProvider maps the copilot binary (with path/flags) to copilot', () => {
+ assert.strictEqual(ap.inferAgentProvider('copilot'), 'copilot');
+ assert.strictEqual(ap.inferAgentProvider('/usr/local/bin/copilot --model gpt-5.4'), 'copilot');
+});
+
+test('copilot preset builds the documented non-interactive print-mode shape', () => {
+ const p = ap.providerPreset('copilot');
+ assert.strictEqual(p.defaultCommand, 'copilot', 'default command binary');
+ assert.strictEqual(p.initialPromptFlag, '-p', 'prompt rides in via -p');
+ assert.strictEqual(ap.autoModeFlagForProvider('copilot'), '-s --allow-all-tools --no-ask-user');
+ assert.strictEqual(p.autoFlag, '-s --allow-all-tools --no-ask-user', 'autoFlag mirrors autoModeFlag');
+});
+
+test('copilot passes model + resume through, non-hiveAware, never auto-receives inbox', () => {
+ const p = ap.providerPreset('copilot');
+ assert.ok(p.supportsModel && p.modelFlag === '--model', 'model picker + --model');
+ assert.strictEqual(p.resumeFlag, '--resume', 'session resume flag');
+ assert.strictEqual(p.hiveAware, false, 'no Claude-only identity injection');
+ assert.strictEqual(ap.canReceiveInbox('copilot'), false, 'print mode exits, no drain → bounces');
+ assert.strictEqual(ap.bridgeOf('copilot'), undefined, 'no hook/proxy bridge');
+});
+
+test('codex preset still resolves (no regression)', () => {
+ assert.strictEqual(ap.inferAgentProvider('codex'), 'codex');
+ assert.strictEqual(ap.providerPreset('codex').defaultCommand, 'codex');
+});
+
+if (failures > 0) {
+ console.log(`\n${failures} test(s) failed`);
+ process.exit(1);
+}
+console.log('\nAll agent-provider tests passed');