mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
feat(omp): rebase OMP backend onto master (merge Pi + OMP modes)
This commit is contained in:
@@ -433,6 +433,7 @@ describe('mobile overview run picker (CLI availability gating)', () => {
|
||||
'pi',
|
||||
'grok',
|
||||
'deepseek',
|
||||
'omp',
|
||||
'shell',
|
||||
]);
|
||||
});
|
||||
@@ -447,7 +448,7 @@ describe('mobile overview run picker (CLI availability gating)', () => {
|
||||
src.indexOf('];', src.indexOf('const MOBILE_OVERVIEW_RUN_MODES')) + 2
|
||||
);
|
||||
const offered = [...modesBlock.matchAll(/mode: '([^']+)'/g)].map((m) => m[1]);
|
||||
expect(offered).toContain('antigravity');
|
||||
expect(offered).toContain('omp');
|
||||
const fn = src.slice(src.indexOf('_buildMobileOverviewRunMenu() {'));
|
||||
const gate = fn.slice(0, fn.indexOf('const header'));
|
||||
expect(gate).toContain('isCliAvailable');
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { CreateSessionSchema, QuickStartSchema } from '../src/web/schemas.js';
|
||||
import { buildSpawnCommand } from '../src/tmux-manager.js';
|
||||
import { defaultDockerCommandForMode } from '../src/docker-hosts.js';
|
||||
import { defaultRemoteCommandForMode } from '../src/remote-hosts.js';
|
||||
import { isExternalCliMode, isAltScreenStripMode } from '../src/session.js';
|
||||
|
||||
describe('OMP mode schemas', () => {
|
||||
it('accepts OMP session creation config', () => {
|
||||
const parsed = CreateSessionSchema.parse({
|
||||
workingDir: '/tmp',
|
||||
mode: 'omp',
|
||||
ompConfig: {
|
||||
model: 'crof/glm-5.2',
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.mode).toBe('omp');
|
||||
expect(parsed.ompConfig).toEqual({
|
||||
model: 'crof/glm-5.2',
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts OMP quick-start config', () => {
|
||||
const parsed = QuickStartSchema.parse({
|
||||
caseName: 'omp-case',
|
||||
mode: 'omp',
|
||||
ompConfig: {
|
||||
resumeSessionId: 'session-1234abcd',
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.mode).toBe('omp');
|
||||
expect(parsed.ompConfig?.resumeSessionId).toBe('session-1234abcd');
|
||||
});
|
||||
|
||||
it('rejects unsafe OMP model strings', () => {
|
||||
expect(() =>
|
||||
CreateSessionSchema.parse({
|
||||
workingDir: '/tmp',
|
||||
mode: 'omp',
|
||||
ompConfig: { model: 'omp; rm -rf /' },
|
||||
})
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('allows OMP_* env overrides and still rejects unknown prefixes', () => {
|
||||
const parsed = CreateSessionSchema.parse({
|
||||
workingDir: '/tmp',
|
||||
mode: 'omp',
|
||||
envOverrides: { OMP_PROFILE: 'work' },
|
||||
});
|
||||
expect(parsed.envOverrides).toEqual({ OMP_PROFILE: 'work' });
|
||||
|
||||
expect(() =>
|
||||
CreateSessionSchema.parse({
|
||||
workingDir: '/tmp',
|
||||
envOverrides: { RANDOM_PREFIX_KEY: 'x' },
|
||||
})
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('OMP spawn command', () => {
|
||||
it('builds a bare omp command when no config is sent', () => {
|
||||
const cmd = buildSpawnCommand({ mode: 'omp', sessionId: 'abc12345' });
|
||||
expect(cmd).toBe('omp');
|
||||
});
|
||||
|
||||
it('passes --model and --resume, and drops unsafe ids', () => {
|
||||
expect(
|
||||
buildSpawnCommand({
|
||||
mode: 'omp',
|
||||
sessionId: 'abc12345',
|
||||
ompConfig: { model: 'crof/glm-5.2', resumeSessionId: 'session-99' },
|
||||
})
|
||||
).toBe('omp --model crof/glm-5.2 --resume session-99');
|
||||
|
||||
expect(
|
||||
buildSpawnCommand({
|
||||
mode: 'omp',
|
||||
sessionId: 'abc12345',
|
||||
ompConfig: { resumeSessionId: 'x; rm -rf /' },
|
||||
})
|
||||
).toBe('omp');
|
||||
});
|
||||
|
||||
it('drops unsafe model strings from the spawn command', () => {
|
||||
expect(
|
||||
buildSpawnCommand({
|
||||
mode: 'omp',
|
||||
sessionId: 'abc12345',
|
||||
ompConfig: { model: 'a`b' },
|
||||
})
|
||||
).toBe('omp');
|
||||
});
|
||||
});
|
||||
|
||||
describe('OMP mode gates', () => {
|
||||
it('is an external CLI mode (readiness/ralph/respawn gating)', () => {
|
||||
expect(isExternalCliMode('omp')).toBe(true);
|
||||
});
|
||||
|
||||
it('is NOT an alt-screen strip mode (unverified TUI, like opencode/antigravity)', () => {
|
||||
expect(isAltScreenStripMode('omp')).toBe(false);
|
||||
});
|
||||
|
||||
it('has docker/remote default commands', () => {
|
||||
expect(defaultDockerCommandForMode('omp')).toBe('exec omp');
|
||||
// Routed through an interactive login shell so per-user PATH entries resolve —
|
||||
// same fix as the other remote agent CLIs (see defaultRemoteCommandForMode).
|
||||
expect(defaultRemoteCommandForMode('omp')).toBe('exec "${SHELL:-/bin/sh}" -i -l -c \'omp\'');
|
||||
});
|
||||
});
|
||||
@@ -81,6 +81,16 @@ describe('run mode UI', () => {
|
||||
expect(app.runMode).toBe('antigravity');
|
||||
expect(runBtnLabel.textContent).toBe('Run AG');
|
||||
});
|
||||
|
||||
it('accepts OMP mode from server sync and updates the run button label', async () => {
|
||||
const { app, storage, runBtnLabel } = loadRunModeHarness();
|
||||
|
||||
storage.set('codeman_runMode', 'claude');
|
||||
await app.loadAppSettingsFromServer(Promise.resolve({ runMode: 'omp' }));
|
||||
|
||||
expect(app.runMode).toBe('omp');
|
||||
expect(runBtnLabel.textContent).toBe('Run OMP');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Run launch synchronization', () => {
|
||||
@@ -367,12 +377,13 @@ describe('Codex quick start settings', () => {
|
||||
'welcomeGeminiBtn',
|
||||
'welcomePiBtn',
|
||||
'welcomeGrokBtn',
|
||||
'welcomeOmpBtn',
|
||||
'welcomeTunnelBtn',
|
||||
]) {
|
||||
welcomeBtns[id] = { style: { display: 'PRISTINE' } };
|
||||
}
|
||||
const modeBtns: Record<string, { style: { display: string } }> = {};
|
||||
for (const mode of ['claude', 'opencode', 'codex', 'gemini', 'antigravity', 'pi', 'grok', 'shell']) {
|
||||
for (const mode of ['claude', 'opencode', 'codex', 'gemini', 'antigravity', 'pi', 'grok', 'omp', 'shell']) {
|
||||
modeBtns[mode] = { style: { display: 'PRISTINE' } };
|
||||
}
|
||||
const menu = {
|
||||
@@ -405,6 +416,7 @@ describe('Codex quick start settings', () => {
|
||||
antigravity: false,
|
||||
pi: false,
|
||||
grok: false,
|
||||
omp: false,
|
||||
cloudflared: false,
|
||||
};
|
||||
|
||||
@@ -442,16 +454,23 @@ describe('Codex quick start settings', () => {
|
||||
withAgy.app.applyWelcomeCliVisibility();
|
||||
expect(withAgy.welcomeBtns.welcomeAntigravityBtn.style.display).toBe('flex');
|
||||
expect(withAgy.welcomeBtns.welcomeClaudeBtn.style.display).toBe('none');
|
||||
|
||||
// OMP is a first-class welcome action, gated on `omp` like the rest.
|
||||
const withOmp = loadUi({ ...ALL_OFF, omp: true });
|
||||
withOmp.app.applyWelcomeCliVisibility();
|
||||
expect(withOmp.welcomeBtns.welcomeOmpBtn.style.display).toBe('flex');
|
||||
expect(withOmp.welcomeBtns.welcomeClaudeBtn.style.display).toBe('none');
|
||||
});
|
||||
|
||||
it('gates every run mode in the dropdown, antigravity included, and never shell', () => {
|
||||
const { app, modeBtns, menu } = loadUi({ ...ALL_OFF, claude: true, antigravity: true });
|
||||
const { app, modeBtns, menu } = loadUi({ ...ALL_OFF, claude: true, antigravity: true, omp: true });
|
||||
app._refreshRunModeAvailability(menu);
|
||||
expect(modeBtns.claude.style.display).toBe('flex');
|
||||
expect(modeBtns.antigravity.style.display).toBe('flex');
|
||||
expect(modeBtns.opencode.style.display).toBe('none');
|
||||
expect(modeBtns.codex.style.display).toBe('none');
|
||||
expect(modeBtns.gemini.style.display).toBe('none');
|
||||
expect(modeBtns.omp.style.display).toBe('flex');
|
||||
// Shell needs no external CLI, and leaving it alone is what guarantees the
|
||||
// menu is never empty on a box with nothing installed.
|
||||
expect(modeBtns.shell.style.display).toBe('PRISTINE');
|
||||
@@ -468,6 +487,7 @@ describe('Codex quick start settings', () => {
|
||||
expect(offered).toContain('antigravity');
|
||||
expect(offered).toContain('pi');
|
||||
expect(offered).toContain('grok');
|
||||
expect(offered).toContain('omp');
|
||||
const src = readFileSync(resolve(import.meta.dirname, '../src/web/public/session-ui.js'), 'utf8');
|
||||
// Anchor on the DEFINITION, not the earlier call site in toggleRunModeMenu.
|
||||
const fn = src.slice(src.indexOf('_refreshRunModeAvailability(menu) {'));
|
||||
|
||||
Reference in New Issue
Block a user