fix(cliproxy): harden custom local port handling

This commit is contained in:
Tam Nhu Tran committed 2026-05-03 14:07:31 -04:00
1 parent a7c10be72e
commit 3862411bb7
6 files changed
+155 -8

No files matched your search

@@ -66,6 +66,57 @@ describe('cursor-profile-executor', () => {
expect(warning).toBeNull();
});
it('starts local CLIProxy on the configured lifecycle port for cursor image analysis', async () => {
let ensuredPort: number | undefined;
const { env, warning } = await resolveCursorImageAnalysisEnv(false, {
getImageAnalysisHookEnv: () => ({
CCS_CURRENT_PROVIDER: 'ghcp',
CCS_IMAGE_ANALYSIS_SKIP: '0',
}),
resolveImageAnalysisRuntimeStatus: async () => ({
enabled: true,
supported: true,
status: 'active',
backendId: 'ghcp',
backendDisplayName: 'GitHub Copilot (OAuth)',
model: 'claude-haiku-4.5',
resolutionSource: 'cursor-alias',
reason: null,
shouldPersistHook: true,
persistencePath: 'cursor.settings.json',
runtimePath: '/api/provider/ghcp',
usesCurrentTarget: true,
usesCurrentAuthToken: true,
hookInstalled: true,
sharedHookInstalled: true,
authReadiness: 'ready',
authProvider: 'ghcp',
authDisplayName: 'GitHub Copilot (OAuth)',
authReason: null,
proxyReadiness: 'stopped',
proxyReason:
'Local CLIProxy service is idle. CCS will start it automatically when image analysis is needed.',
effectiveRuntimeMode: 'cliproxy-image-analysis',
effectiveRuntimeReason: null,
}),
ensureCliproxyService: async (port: number) => {
ensuredPort = port;
return {
started: true,
alreadyRunning: false,
port,
};
},
resolveLifecyclePort: () => 9321,
});
expect(ensuredPort).toBe(9321);
expect(env.CCS_CURRENT_PROVIDER).toBe('ghcp');
expect(env.CCS_IMAGE_ANALYSIS_SKIP).toBe('0');
expect(warning).toBeNull();
});
it('fails fast when Cursor integration is disabled', async () => {
const exitCode = await executeCursorProfile({ ...BASE_CONFIG, enabled: false }, []);
expect(exitCode).toBe(1);