mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-19 04:39:33 +01:00
Merge pull request #592: feat(cli-registry): GitHub Copilot CLI as a run mode
GitHub Copilot CLI (`copilot`) becomes a run mode: Run menu, welcome screen, cron and CLI management once it is installed, tmux-backed like the other agent CLIs, working/idle and the model read off its footer, launch options through `copilotConfig` (model, resume, continue, the multi-user-clamped allowAll), Custom Model Endpoints via Copilot's BYOK variables, MCP sync of its mcp-config.json, a status probe, and the `codeman agent` verbs (spawn waits for its composer, read returns its last answer). The plan-usage quota row that earlier rounds carried was split out on review and is not part of this merge. Merge-time commits on top: the wider COPILOT_* clamp and the zh-CN README rows (maintainer), the Docker sign-in docs, divider rows inside an answer kept by `agent read`, route tests for the screen-read last-response branch, and doc drift (Past Sessions, wheelForward JSDoc, COPILOT_/OMP_ in the env prefix lists). Verified before merge on Copilot CLI 1.0.98: injected keystrokes, bracketed paste and Enter reach the TUI in tmux (github/copilot-cli#4180 does not reproduce), a shell tool call completes inside tmux (#4223 does not reproduce), and a session driven through this branch answered over send-and-wait. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
8e6abf4bfd
80 files changed
+1911
-132
No files matched your search
@@ -104,6 +104,25 @@ describe('clampExternalCliBypassForOwner — multi-user mode', () => {
|
||||
expect(out.grokConfig).toEqual({ alwaysApprove: false, model: 'grok-4.5' });
|
||||
});
|
||||
|
||||
it("forces a non-granted owner's copilot --yolo off and keeps the model", async () => {
|
||||
const out = await _clampExternalCliBypassForOwner(
|
||||
'peon',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
{ allowAll: true, model: 'claude-sonnet-5.5' }
|
||||
);
|
||||
expect(out.copilotConfig).toEqual({ allowAll: false, model: 'claude-sonnet-5.5' });
|
||||
});
|
||||
|
||||
it('leaves copilot absent when nothing was sent (a bare copilot is already Manual Approval)', async () => {
|
||||
const out = await _clampExternalCliBypassForOwner('peon', undefined, undefined, undefined, undefined, undefined);
|
||||
expect(out.copilotConfig).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps a non-granted owner's codex reasoning effort while forcing bypass off", async () => {
|
||||
// The clamp rewrites one field and must carry the rest; a clamp rebuilt from named
|
||||
// fields would drop the effort here without a word.
|
||||
|
||||
@@ -14,9 +14,11 @@
|
||||
* block without it lost the "You" badge on prompts
|
||||
* - a pane that has produced no output reports hasContext: false rather than 404ing
|
||||
* - Claude mode still takes the Claude path (regression guard)
|
||||
* - copilot (a repainting full-screen TUI) is read off the pane SCREEN via
|
||||
* capturePaneText, and falls back to the buffer only when there is no screen
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import Fastify, { type FastifyInstance } from 'fastify';
|
||||
import fastifyCookie from '@fastify/cookie';
|
||||
import { createMockRouteContext, createMockSession, type MockRouteContext } from '../mocks/index.js';
|
||||
@@ -154,6 +156,65 @@ describe('GET /api/sessions/:id/last-response — external CLI panes', () => {
|
||||
expect(body.data.hasContext).toBe(false);
|
||||
});
|
||||
|
||||
describe('copilot reads the pane screen, not the stream', () => {
|
||||
const rule = '─'.repeat(80);
|
||||
const screenOf = (answer: string) =>
|
||||
[
|
||||
' ❯ what changed 11:30',
|
||||
` ● ${answer}`,
|
||||
' /tmp/work Session: 0 AIC used',
|
||||
rule,
|
||||
'❯',
|
||||
rule,
|
||||
' ← open sidebar · Interactive · Manual Approval · / commands · ? help',
|
||||
].join('\n');
|
||||
|
||||
function stubCapture(result: string | null) {
|
||||
const capturePaneText = vi.fn((_muxName: string) => result);
|
||||
(harness.ctx.mux as unknown as { capturePaneText: typeof capturePaneText }).capturePaneText = capturePaneText;
|
||||
return capturePaneText;
|
||||
}
|
||||
|
||||
it('segments the captured screen of the session pane', async () => {
|
||||
session.mode = 'copilot';
|
||||
// What the stream looks like for a repainting TUI once escapes are stripped: rows fused
|
||||
// together, so a reader of the buffer would return this run of text.
|
||||
session.terminalBuffer = 'STREAM-ONLY fused rows that are not the answer';
|
||||
const capture = stubCapture(screenOf('The screen answer.'));
|
||||
|
||||
const { res, body } = await lastResponse();
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(capture).toHaveBeenCalledWith(session.muxName);
|
||||
expect(body.data.text).toBe('The screen answer.');
|
||||
expect(body.data.text).not.toContain('STREAM-ONLY');
|
||||
expect(body.data.hasContext).toBe(true);
|
||||
});
|
||||
|
||||
it('falls back to the buffer when the pane has no screen to capture', async () => {
|
||||
session.mode = 'copilot';
|
||||
session.terminalBuffer = screenOf('The buffer answer.');
|
||||
const capture = stubCapture(null);
|
||||
|
||||
const { res, body } = await lastResponse();
|
||||
|
||||
expect(res.statusCode).toBe(200);
|
||||
expect(capture).toHaveBeenCalledWith(session.muxName);
|
||||
expect(body.data.text).toBe('The buffer answer.');
|
||||
});
|
||||
|
||||
it('never captures the screen for a mode that streams lines', async () => {
|
||||
session.mode = 'opencode';
|
||||
session.terminalBuffer = PANE;
|
||||
const capture = stubCapture(screenOf('must not be read'));
|
||||
|
||||
const { body } = await lastResponse();
|
||||
|
||||
expect(capture).not.toHaveBeenCalled();
|
||||
expect(body.data.text).toContain('Documented the helper in docs/retry.md');
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves Claude mode on the Claude transcript path', async () => {
|
||||
// Regression guard: a claude pane must NOT be segmented off its terminal
|
||||
// buffer, or a real transcript would be shadowed by scraped pane text.
|
||||
|
||||
Reference in new issue
Block a user