refactor(cliproxy): flatten module structure and colocate tests (#1135)

- Split types.ts (331 LOC) into 4 concern-based files under types/:
  platform-types, binary-types, provider-types, config-types
- Preserve backward compat via barrel re-export (types.ts → types/index)
- Reorganize 53 root-level files into 8 subdirectories:
  accounts/, ai-providers/, auth/, binary/, config/, executor/,
  management/, proxy/, quota/, routing/, services/, sync/
- Reduce src/cliproxy/ root from 65 to 8 files (target: ≤10)
- Colocate 87 unit tests from tests/unit/cliproxy/ into
  src/cliproxy/*/__tests__/ (13 colocated test directories)
- Update import paths across 40+ consumer files
- Add TDD backward-compat test for types split

Refs #1135
This commit is contained in:
Tam Nhu Tran committed 2026-04-29 17:06:39 -04:00
1 parent 561189efe6
commit 1c72b4b8d5
225 files changed
+935 -905

No files matched your search

@@ -2,7 +2,7 @@ import { describe, expect, it } from 'bun:test';
import { readFileSync } from 'fs';
import { dirname } from 'path';
import type { ImageAnalysisStatus } from '../../../../src/utils/hooks/image-analysis-backend-resolver';
import type { AuthStatus } from '../../../../src/cliproxy/auth-handler';
import type { AuthStatus } from '../../../../src/cliproxy/auth/auth-handler';
import {
ModuleKind,
ScriptTarget,
@@ -67,14 +67,14 @@ describe('image-analysis-runtime-status circular dependency regression', () => {
const module = { exports: {} as Record<string, unknown> };
const requireMap: Record<string, unknown> = {
'../../cliproxy/auth-handler': authHandlerModule,
'../../cliproxy/remote-proxy-client': {
'../../cliproxy/auth/auth-handler': authHandlerModule,
'../../cliproxy/services/remote-proxy-client': {
checkRemoteProxy: async () => ({ reachable: false, error: 'not-used' }),
},
'../../cliproxy/remote-auth-fetcher': {
'../../cliproxy/services/remote-auth-fetcher': {
fetchRemoteAuthStatus: async () => [],
},
'../../cliproxy/proxy-target-resolver': {
'../../cliproxy/proxy/proxy-target-resolver': {
getProxyTarget: () => ({
host: '127.0.0.1',
port: 8317,
@@ -86,7 +86,7 @@ describe('image-analysis-runtime-status circular dependency regression', () => {
getProviderDisplayName: () => 'GitHub Copilot (OAuth)',
isCLIProxyProvider: () => true,
},
'../../cliproxy/stats-fetcher': {
'../../cliproxy/services/stats-fetcher': {
isCliproxyRunning: async () => true,
},
'../../config/unified-config-types': {