mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 02:29:33 +01:00
chore: remove backend code nothing references
Found with knip (exports, types, class members) and confirmed by a text search of src, test, scripts and packages before each removal. - Per-CLI get<Cli>NotFoundMessage() (nine of them) with their message constants: missingCliMessage() builds that text from the registry now. - Registry leftovers: renderCliCommand, asCliId, cliIds, isCliRunnable, createCliResolverForTest, profileExists, and two name lists that only repeated schema enums. - A task-description cache in Session that was written on every chunk of terminal output (one regex pass per line) and never read since the subagent watcher takes descriptions from transcripts. The cache module, its pattern and both parse methods go with it. - Session.parentAgentId / childAgentIds: never set by anything, so the two optional SessionState fields were never on the wire. - Unreferenced methods on TmuxManager (pipe-pane pair, syncMouseMode), RespawnController, StateStore.recoverFromBackup (load() already falls back to the .bak file), TeamWatcher, SseStreamManager and the AI checkers' getErrorVerdict. - updateCaseEnvVars: the settings.local.json env path that envOverrides replaced. - Re-exports in the utils, cli-registry, routes and prompts barrels that no importer used, and unused test helpers (MockStateStore, the mobile throttle helpers and others). Eight mobile tests imported the WebServer type from a path that does not exist (../src instead of ../../src); type-only, so nothing failed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
60f1900081
commit
f604deba3e
57 files changed
+36
-963
No files matched your search
@@ -37,7 +37,6 @@ import {
|
||||
resolveStatusLineCliCommand,
|
||||
settingsWriteBlocker,
|
||||
stripCaseEnvKeys,
|
||||
updateCaseEnvVars,
|
||||
updateCaseModel,
|
||||
writeHooksConfig,
|
||||
} from '../src/hooks-config.js';
|
||||
@@ -296,7 +295,6 @@ describe('writeHooksConfig', () => {
|
||||
await ensureCodemanHooks(caseDir);
|
||||
await refreshStaleCodemanHooks(caseDir);
|
||||
await updateCaseModel(caseDir, 'opus');
|
||||
await updateCaseEnvVars(caseDir, { CLAUDE_CODE_NEW: 'value' });
|
||||
await stripCaseEnvKeys(caseDir, ['CLAUDE_CODE_KEEP']);
|
||||
await applyStatusLineConfig(caseDir, true);
|
||||
await applyStatusLineConfig(caseDir, false);
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
assertZoomNotDisabled, getCSSProperty,
|
||||
} from './helpers/assertions.js';
|
||||
import { REPRESENTATIVE_DEVICES } from './devices.js';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
|
||||
let baseUrl: string;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Ephemeral port - Cross-device parametric tests
|
||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
||||
import type { BrowserContext, Page } from 'playwright';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
import { createTestServer, stopTestServer } from './helpers/server.js';
|
||||
import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { SELECTORS, BREAKPOINTS, BODY_CLASSES } from './helpers/constants.js';
|
||||
|
||||
@@ -321,13 +321,6 @@ export const SMALL_TABLETS: DeviceEntry[] = DEVICE_REGISTRY.filter((d) => d.cate
|
||||
export const STANDARD_TABLETS: DeviceEntry[] = DEVICE_REGISTRY.filter((d) => d.category === 'standard-tablet');
|
||||
export const LARGE_TABLETS: DeviceEntry[] = DEVICE_REGISTRY.filter((d) => d.category === 'large-tablet');
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Platform exports
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const IOS_DEVICES: DeviceEntry[] = DEVICE_REGISTRY.filter((d) => d.isIOS);
|
||||
export const ANDROID_DEVICES: DeviceEntry[] = DEVICE_REGISTRY.filter((d) => !d.isIOS);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Representative devices — one per category for quick smoke tests
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -156,21 +156,6 @@ export async function assertNotHasClass(page: Page, selector: string, className:
|
||||
expect(has).toBe(false);
|
||||
}
|
||||
|
||||
/** Assert element's computed transform includes a translateY value */
|
||||
export async function assertTranslateY(
|
||||
page: Page,
|
||||
selector: string,
|
||||
expectedY: number,
|
||||
tolerance: number = 2,
|
||||
): Promise<void> {
|
||||
const transform = await getCSSProperty(page, selector, 'transform');
|
||||
// transform is a matrix(...) string; extract translateY
|
||||
// matrix(a, b, c, d, tx, ty) — ty is the 6th value
|
||||
const match = transform.match(/matrix\([^,]+,[^,]+,[^,]+,[^,]+,[^,]+,\s*([^)]+)\)/);
|
||||
const ty = match ? parseFloat(match[1]) : 0;
|
||||
expect(Math.abs(ty - expectedY)).toBeLessThanOrEqual(tolerance);
|
||||
}
|
||||
|
||||
/** Check viewport meta tag doesn't disable zoom */
|
||||
export async function assertZoomNotDisabled(page: Page): Promise<void> {
|
||||
const meta = await page.evaluate(() => {
|
||||
|
||||
@@ -60,6 +60,3 @@ export async function closeAllBrowsers(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export function isChromium(engine: 'chromium' | 'webkit'): boolean {
|
||||
return engine === 'chromium';
|
||||
}
|
||||
@@ -39,38 +39,3 @@ export async function dispatchTouchEvent(
|
||||
});
|
||||
}
|
||||
|
||||
/** Throttle CPU to simulate mobile hardware (rate = slowdown factor, e.g. 4 = 4x slower) */
|
||||
export async function setCPUThrottle(cdp: CDPSession, rate: number): Promise<void> {
|
||||
await cdp.send('Emulation.setCPUThrottlingRate', { rate });
|
||||
}
|
||||
|
||||
/** Clear CPU throttling */
|
||||
export async function clearCPUThrottle(cdp: CDPSession): Promise<void> {
|
||||
await cdp.send('Emulation.setCPUThrottlingRate', { rate: 1 });
|
||||
}
|
||||
|
||||
/** Emulate network conditions */
|
||||
export async function setNetworkThrottle(
|
||||
cdp: CDPSession,
|
||||
downloadKbps: number,
|
||||
uploadKbps: number,
|
||||
latencyMs: number,
|
||||
): Promise<void> {
|
||||
await cdp.send('Network.enable');
|
||||
await cdp.send('Network.emulateNetworkConditions', {
|
||||
offline: false,
|
||||
downloadThroughput: (downloadKbps * 1024) / 8,
|
||||
uploadThroughput: (uploadKbps * 1024) / 8,
|
||||
latency: latencyMs,
|
||||
});
|
||||
}
|
||||
|
||||
/** Clear network throttling */
|
||||
export async function clearNetworkThrottle(cdp: CDPSession): Promise<void> {
|
||||
await cdp.send('Network.emulateNetworkConditions', {
|
||||
offline: false,
|
||||
downloadThroughput: -1,
|
||||
uploadThroughput: -1,
|
||||
latency: 0,
|
||||
});
|
||||
}
|
||||
@@ -1,23 +1,13 @@
|
||||
import { WebServer } from '../../../src/web/server.js';
|
||||
|
||||
const servers = new Set<WebServer>();
|
||||
|
||||
/** A test server on an ephemeral port; read the port from `server.boundPort` once this resolves. */
|
||||
export async function createTestServer(): Promise<WebServer> {
|
||||
const server = new WebServer(0, false, true); // testMode = true
|
||||
await server.start();
|
||||
servers.add(server);
|
||||
return server;
|
||||
}
|
||||
|
||||
export async function stopTestServer(server: WebServer): Promise<void> {
|
||||
await server.stop();
|
||||
servers.delete(server);
|
||||
}
|
||||
|
||||
export async function stopAllTestServers(): Promise<void> {
|
||||
for (const server of servers) {
|
||||
await server.stop();
|
||||
}
|
||||
servers.clear();
|
||||
}
|
||||
@@ -243,19 +243,3 @@ export async function tapViaSynthetic(page: Page, selector: string): Promise<voi
|
||||
}, selector);
|
||||
}
|
||||
|
||||
/** Tap using the best available method */
|
||||
export async function tap(
|
||||
page: Page,
|
||||
selector: string,
|
||||
options: { isChromium?: boolean } = {},
|
||||
): Promise<void> {
|
||||
if (options.isChromium !== false) {
|
||||
try {
|
||||
await tapViaCDP(page, selector);
|
||||
return;
|
||||
} catch {
|
||||
// Fall through
|
||||
}
|
||||
}
|
||||
await tapViaSynthetic(page, selector);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
getCSSProperty,
|
||||
} from './helpers/assertions.js';
|
||||
import { REPRESENTATIVE_DEVICES } from './devices.js';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
|
||||
let baseUrl: string;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Ephemeral port - General mobile layout tests
|
||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
||||
import type { BrowserContext, Page } from 'playwright';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
import { createTestServer, stopTestServer } from './helpers/server.js';
|
||||
import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { SELECTORS, BREAKPOINTS, BODY_CLASSES, WAIT, MIN_TOUCH_TARGET } from './helpers/constants.js';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { showKeyboard, hideKeyboard } from './helpers/keyboard-sim.js';
|
||||
import { assertVisible, assertHidden, getCSSProperty, getCSSNumericValue } from './helpers/assertions.js';
|
||||
import { DEVICE_REGISTRY, REPRESENTATIVE_DEVICES } from './devices.js';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
|
||||
let baseUrl: string;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { showKeyboard, hideKeyboard } from './helpers/keyboard-sim.js';
|
||||
import { getCSSProperty, getCSSNumericValue } from './helpers/assertions.js';
|
||||
import { REPRESENTATIVE_DEVICES } from './devices.js';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
|
||||
let baseUrl: string;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { swipe, swipeViaCDP, swipeViaSynthetic } from './helpers/touch-sim.js';
|
||||
import { assertHidden, assertVisible, getCSSProperty, getCSSNumericValue } from './helpers/assertions.js';
|
||||
import { REPRESENTATIVE_DEVICES } from './devices.js';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
|
||||
let baseUrl: string;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Ephemeral port - Screenshot comparison tests
|
||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
||||
import type { BrowserContext, Page } from 'playwright';
|
||||
import type { WebServer } from '../src/web/server.js';
|
||||
import type { WebServer } from '../../src/web/server.js';
|
||||
import { createTestServer, stopTestServer } from './helpers/server.js';
|
||||
import { createDevicePage, closeAllBrowsers } from './helpers/browser.js';
|
||||
import { SELECTORS, VISUAL, VISUAL_BREAKPOINTS, WAIT } from './helpers/constants.js';
|
||||
|
||||
+2
-5
@@ -2,14 +2,11 @@
|
||||
* Shared test mocks — import from here instead of defining inline.
|
||||
*
|
||||
* @example
|
||||
* import { MockSession, MockStateStore, terminalOutputs } from './mocks/index.js';
|
||||
* import { MockSession, createMockRouteContext } from './mocks/index.js';
|
||||
*/
|
||||
|
||||
export { MockSession, createMockSession, terminalOutputs } from './mock-session.js';
|
||||
export { MockStateStore } from './mock-state-store.js';
|
||||
export { MockSession, createMockSession } from './mock-session.js';
|
||||
export {
|
||||
waitForEvent,
|
||||
createDeferred,
|
||||
safeRmHomeTree,
|
||||
isUnderTestHome,
|
||||
isSandboxedHome,
|
||||
|
||||
@@ -534,55 +534,6 @@ export class MockSession extends EventEmitter {
|
||||
getMessages = vi.fn(() => []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate realistic terminal output for testing.
|
||||
* Must match the patterns used in MockSession's simulate* methods.
|
||||
*/
|
||||
export const terminalOutputs = {
|
||||
/** Standard completion message */
|
||||
completion(duration: string = '2m 46s'): string {
|
||||
return `\n\u273b Worked for ${duration}\n 123.4k tokens used\n`;
|
||||
},
|
||||
|
||||
/** Working spinner output */
|
||||
working(activity: string = 'Thinking'): string {
|
||||
return `${activity}... \u280b`;
|
||||
},
|
||||
|
||||
/** Plan mode prompt */
|
||||
planMode(question: string = 'Would you like to proceed?'): string {
|
||||
return [`\n${question}\n`, '\u276f 1. Yes\n', ' 2. No\n', ' 3. Type your own\n'].join('');
|
||||
},
|
||||
|
||||
/** Prompt character */
|
||||
prompt(): string {
|
||||
return '\n\u276f ';
|
||||
},
|
||||
|
||||
/** Token count display */
|
||||
tokens(count: number): string {
|
||||
const formatted =
|
||||
count >= 1000000
|
||||
? `${(count / 1000000).toFixed(1)}M`
|
||||
: count >= 1000
|
||||
? `${(count / 1000).toFixed(1)}k`
|
||||
: String(count);
|
||||
return ` ${formatted} tokens\n`;
|
||||
},
|
||||
|
||||
/** Large output for buffer testing */
|
||||
largeOutput(sizeKb: number = 100): string {
|
||||
const baseText = 'Lorem ipsum dolor sit amet. '.repeat(100);
|
||||
const repetitions = Math.ceil((sizeKb * 1024) / baseText.length);
|
||||
return baseText.repeat(repetitions).slice(0, sizeKb * 1024);
|
||||
},
|
||||
|
||||
/** ANSI colored output */
|
||||
ansiColored(text: string): string {
|
||||
return `\x1b[32m${text}\x1b[0m`;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Convenience factory.
|
||||
*/
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Shared MockStateStore for tests.
|
||||
*
|
||||
* Includes methods for both session management and Ralph loop testing.
|
||||
* All methods are vi.fn() spies — tests can override return values as needed.
|
||||
*
|
||||
* NOTE: This is for direct instantiation in new tests. Existing tests that
|
||||
* use vi.mock('../src/state-store.js') keep their inline definitions.
|
||||
*/
|
||||
import { vi } from 'vitest';
|
||||
|
||||
export class MockStateStore {
|
||||
state: Record<string, unknown> = {
|
||||
sessions: {} as Record<string, unknown>,
|
||||
config: { maxConcurrentSessions: 5 },
|
||||
ralphLoop: { status: 'stopped' },
|
||||
tasks: {} as Record<string, unknown>,
|
||||
};
|
||||
|
||||
// Session methods
|
||||
getConfig = vi.fn(() => this.state.config);
|
||||
getSessions = vi.fn(() => this.state.sessions as Record<string, unknown>);
|
||||
getSession = vi.fn((id: string) => (this.state.sessions as Record<string, unknown>)[id]);
|
||||
setSession = vi.fn((id: string, state: unknown) => {
|
||||
(this.state.sessions as Record<string, unknown>)[id] = state;
|
||||
});
|
||||
removeSession = vi.fn((id: string) => {
|
||||
delete (this.state.sessions as Record<string, unknown>)[id];
|
||||
});
|
||||
|
||||
// Ralph state methods
|
||||
getRalphLoopState = vi.fn(() => this.state.ralphLoop);
|
||||
setRalphLoopState = vi.fn((update: Record<string, unknown>) => {
|
||||
this.state.ralphLoop = { ...(this.state.ralphLoop as Record<string, unknown>), ...update };
|
||||
});
|
||||
|
||||
// Task methods
|
||||
getTasks = vi.fn(() => this.state.tasks);
|
||||
setTask = vi.fn();
|
||||
removeTask = vi.fn();
|
||||
|
||||
// Settings methods
|
||||
getSettings = vi.fn(() => ({}));
|
||||
setSettings = vi.fn();
|
||||
|
||||
// Generic persistence
|
||||
save = vi.fn();
|
||||
load = vi.fn();
|
||||
|
||||
/** Reset all state and mocks for clean test isolation */
|
||||
reset(): void {
|
||||
this.state = {
|
||||
sessions: {},
|
||||
config: { maxConcurrentSessions: 5 },
|
||||
ralphLoop: { status: 'stopped' },
|
||||
tasks: {},
|
||||
};
|
||||
vi.clearAllMocks();
|
||||
}
|
||||
}
|
||||
@@ -1,43 +1,10 @@
|
||||
/**
|
||||
* Reusable async test helpers.
|
||||
* Guards for tests that delete under the throwaway HOME.
|
||||
*/
|
||||
|
||||
import { rmSync } from 'node:fs';
|
||||
import { basename, resolve } from 'node:path';
|
||||
|
||||
/** Wait for an EventEmitter to emit a specific event, with timeout */
|
||||
export function waitForEvent(
|
||||
emitter: { once: (event: string, listener: (...args: unknown[]) => void) => void },
|
||||
event: string,
|
||||
timeoutMs = 5000
|
||||
): Promise<unknown> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const timer = setTimeout(
|
||||
() => reject(new Error(`Timed out waiting for event "${event}" after ${timeoutMs}ms`)),
|
||||
timeoutMs
|
||||
);
|
||||
emitter.once(event, (...args: unknown[]) => {
|
||||
clearTimeout(timer);
|
||||
resolve(args.length === 1 ? args[0] : args);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Create a deferred promise with external resolve/reject */
|
||||
export function createDeferred<T = void>(): {
|
||||
promise: Promise<T>;
|
||||
resolve: (value: T) => void;
|
||||
reject: (reason?: unknown) => void;
|
||||
} {
|
||||
let resolve!: (value: T) => void;
|
||||
let reject!: (reason?: unknown) => void;
|
||||
const promise = new Promise<T>((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
return { promise, resolve, reject };
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix of the throwaway HOME `test/setup.ts` creates (`mkdtempSync(join(tmpdir(), 'codeman-vitest-'))`).
|
||||
* Pinned by test/test-env-isolation.test.ts, so renaming one without the other fails there.
|
||||
|
||||
Reference in new issue
Block a user