Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/automacoescomerciaisintegradas_xyzaios.json

1 line
37 KiB
JSON

{"repo": "automacoescomerciaisintegradas/xyzaios", "files": {"tests/integration/llm-routing/llm-routing.test.js": {"3811edb0ff77b8568352810167d053399f64654a": {"t": 1785746687.2294166, "n": 8424, "h": "d9759b1c0092f5b9", "c": "/**\n * LLM Routing Integration Tests\n *\n * Story 6.7: LLM Routing Migration\n *\n * Tests installation, command creation, and cross-platform compatibility.\n */\n\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\n\n// Module under test\nconst {\n installLLMRouting,\n isLLMRoutingInstalled,\n getInstallDir,\n getInstallationSummary,\n LLM_ROUTING_VERSION,\n} = require('../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing');\n\ndescribe('LLM Routing Module', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates',\n );\n\n describe('Module Exports', () => {\n test('should export all required functions', () => {\n expect(typeof installLLMRouting).toBe('function');\n expect(typeof isLLMRoutingInstalled).toBe('function');\n expect(typeof getInstallDir).toBe('function');\n expect(typeof getInstallationSummary).toBe('function');\n expect(typeof LLM_ROUTING_VERSION).toBe('string');\n });\n\n test('should have valid version format', () => {\n expect(LLM_ROUTING_VERSION).toMatch(/^\\d+\\.\\d+\\.\\d+$/);\n });\n });\n\n describe('getInstallDir()', () => {\n test('should return a valid directory path', () => {\n const installDir = getInstallDir();\n expect(typeof installDir).toBe('string');\n expect(installDir.length).toBeGreaterThan(0);\n });\n\n test('should return platform-appropriate path', () => {\n const installDir = getInstallDir();\n\n if (isWindows) {\n // Windows: should be npm global or user profile\n expect(\n installDir.includes('npm') ||\n installDir.includes('Users') ||\n installDir.includes('USERPROFILE'),\n ).toBe(true);\n } else {\n // Unix: should be /usr/local/bin or ~/bin\n expect(installDir.includes('/usr/local/bin') || installDir.includes('/bin')).toBe(true);\n }\n });\n });\n\n describe('Template Files', () => {\n test('should have templates directory', () => {\n expect(fs.existsSync(testTemplatesDir)).toBe(true);\n });\n\n test('should have Windows templates', () => {\n const claudeFreeCmd = path.join(testTemplatesDir, 'claude-free.cmd');\n const claudeMaxCmd = path.join(testTemplatesDir, 'claude-max.cmd');\n\n expect(fs.existsSync(claudeFreeCmd)).toBe(true);\n expect(fs.existsSync(claudeMaxCmd)).toBe(true);\n });\n\n test('should have Unix templates', () => {\n const claudeFreeSh = path.join(testTemplatesDir, 'claude-free.sh');\n const claudeMaxSh = path.join(testTemplatesDir, 'claude-max.sh');\n\n expect(fs.existsSync(claudeFreeSh)).toBe(true);\n expect(fs.existsSync(claudeMaxSh)).toBe(true);\n });\n\n test('claude-free template should reference DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('deepseek');\n expect(content).toContain('DEEPSEEK_API_KEY');\n });\n\n test('claude-max template should clear alternative providers', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-max${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('ANTHROPIC_BASE_URL');\n // Should unset/clear the URL\n if (isWindows) {\n expect(content).toMatch(/set\\s+[\"']?ANTHROPIC_BASE_URL=[\"']?\\s*$/m);\n } else {\n expect(content).toContain('unset ANTHROPIC_BASE_URL');\n }\n });\n });\n\n describe('installLLMRouting()', () => {\n test('should fail gracefully with missing templates directory', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n const result = installLLMRouting({\n templatesDir: '/nonexistent/templates',\n onProgress: mockProgress,\n onError: mockError,\n });\n\n expect(result.success).toBe(false);\n expect(result.errors.length).toBeGreaterThan(0);\n expect(mockError).toHaveBeenCalled();\n });\n\n test('should return proper result structure', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n // Use actual templates dir\n const result = installLLMRouting({\n templatesDir: testTemplatesDir,\n onProgress: mockProgress,\n onError: mockError,\n });\n\n // Should have expected properties\n expect(result).toHaveProperty('success');\n expect(result).toHaveProperty('installDir');\n expect(result).toHaveProperty('filesInstalled');\n expect(result).toHaveProperty('errors');\n expect(Array.isArray(result.filesInstalled)).toBe(true);\n expect(Array.isArray(result.errors)).toBe(true);\n });\n });\n\n describe('getInstallationSummary()', () => {\n test('should return array of strings', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n\n expect(Array.isArray(summary)).toBe(true);\n summary.forEach((line) => {\n expect(typeof line).toBe('string');\n });\n });\n\n test('should include success message for successful install', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('Complete');\n expect(joined).toContain('claude-max');\n expect(joined).toContain('claude-free');\n });\n\n test('should include error messages for failed install', () => {\n const mockResult = {\n success: false,\n installDir: '/test/dir',\n filesInstalled: [],\n envCreated: false,\n errors: ['Test error 1', 'Test error 2'],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('error');\n expect(joined).toContain('Test error 1');\n expect(joined).toContain('Test error 2');\n });\n });\n\n describe('Cross-Platform Path Handling', () => {\n test('should use path.join for cross-platform compatibility', () => {\n // The install script should use path.join() not string concatenation\n const installScript = fs.readFileSync(\n path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js',\n ),\n 'utf8',\n );\n\n expect(installScript).toContain('path.join');\n // Should use path.join for constructing file paths (not string concatenation)\n // Allow legitimate path constants like '/usr/local/bin'\n expect(installScript).not.toMatch(/path\\s*\\+\\s*['\"][\\\\/]/); // No path + '/...'\n expect(installScript).not.toMatch(/['\"][\\\\/]\\s*\\+\\s*path/); // No '/...' + path\n });\n });\n});\n\ndescribe('Environment Variable Handling', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates',\n );\n\n test('claude-free should look for .env file', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('.env');\n });\n\n test('claude-free should set ANTHROPIC_BASE_URL to DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('api.deepseek.com');\n });\n\n test('claude-free should set API_TIMEOUT_MS', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('API_TIMEOUT_MS');\n });\n});\n"}, "c9b2e517e6ae7ae03810d4a46a3259a9b9c109f4": {"t": 1785766852.360209, "n": 8424, "h": "d9759b1c0092f5b9", "c": "/**\n * LLM Routing Integration Tests\n *\n * Story 6.7: LLM Routing Migration\n *\n * Tests installation, command creation, and cross-platform compatibility.\n */\n\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\n\n// Module under test\nconst {\n installLLMRouting,\n isLLMRoutingInstalled,\n getInstallDir,\n getInstallationSummary,\n LLM_ROUTING_VERSION,\n} = require('../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing');\n\ndescribe('LLM Routing Module', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates',\n );\n\n describe('Module Exports', () => {\n test('should export all required functions', () => {\n expect(typeof installLLMRouting).toBe('function');\n expect(typeof isLLMRoutingInstalled).toBe('function');\n expect(typeof getInstallDir).toBe('function');\n expect(typeof getInstallationSummary).toBe('function');\n expect(typeof LLM_ROUTING_VERSION).toBe('string');\n });\n\n test('should have valid version format', () => {\n expect(LLM_ROUTING_VERSION).toMatch(/^\\d+\\.\\d+\\.\\d+$/);\n });\n });\n\n describe('getInstallDir()', () => {\n test('should return a valid directory path', () => {\n const installDir = getInstallDir();\n expect(typeof installDir).toBe('string');\n expect(installDir.length).toBeGreaterThan(0);\n });\n\n test('should return platform-appropriate path', () => {\n const installDir = getInstallDir();\n\n if (isWindows) {\n // Windows: should be npm global or user profile\n expect(\n installDir.includes('npm') ||\n installDir.includes('Users') ||\n installDir.includes('USERPROFILE'),\n ).toBe(true);\n } else {\n // Unix: should be /usr/local/bin or ~/bin\n expect(installDir.includes('/usr/local/bin') || installDir.includes('/bin')).toBe(true);\n }\n });\n });\n\n describe('Template Files', () => {\n test('should have templates directory', () => {\n expect(fs.existsSync(testTemplatesDir)).toBe(true);\n });\n\n test('should have Windows templates', () => {\n const claudeFreeCmd = path.join(testTemplatesDir, 'claude-free.cmd');\n const claudeMaxCmd = path.join(testTemplatesDir, 'claude-max.cmd');\n\n expect(fs.existsSync(claudeFreeCmd)).toBe(true);\n expect(fs.existsSync(claudeMaxCmd)).toBe(true);\n });\n\n test('should have Unix templates', () => {\n const claudeFreeSh = path.join(testTemplatesDir, 'claude-free.sh');\n const claudeMaxSh = path.join(testTemplatesDir, 'claude-max.sh');\n\n expect(fs.existsSync(claudeFreeSh)).toBe(true);\n expect(fs.existsSync(claudeMaxSh)).toBe(true);\n });\n\n test('claude-free template should reference DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('deepseek');\n expect(content).toContain('DEEPSEEK_API_KEY');\n });\n\n test('claude-max template should clear alternative providers', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-max${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('ANTHROPIC_BASE_URL');\n // Should unset/clear the URL\n if (isWindows) {\n expect(content).toMatch(/set\\s+[\"']?ANTHROPIC_BASE_URL=[\"']?\\s*$/m);\n } else {\n expect(content).toContain('unset ANTHROPIC_BASE_URL');\n }\n });\n });\n\n describe('installLLMRouting()', () => {\n test('should fail gracefully with missing templates directory', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n const result = installLLMRouting({\n templatesDir: '/nonexistent/templates',\n onProgress: mockProgress,\n onError: mockError,\n });\n\n expect(result.success).toBe(false);\n expect(result.errors.length).toBeGreaterThan(0);\n expect(mockError).toHaveBeenCalled();\n });\n\n test('should return proper result structure', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n // Use actual templates dir\n const result = installLLMRouting({\n templatesDir: testTemplatesDir,\n onProgress: mockProgress,\n onError: mockError,\n });\n\n // Should have expected properties\n expect(result).toHaveProperty('success');\n expect(result).toHaveProperty('installDir');\n expect(result).toHaveProperty('filesInstalled');\n expect(result).toHaveProperty('errors');\n expect(Array.isArray(result.filesInstalled)).toBe(true);\n expect(Array.isArray(result.errors)).toBe(true);\n });\n });\n\n describe('getInstallationSummary()', () => {\n test('should return array of strings', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n\n expect(Array.isArray(summary)).toBe(true);\n summary.forEach((line) => {\n expect(typeof line).toBe('string');\n });\n });\n\n test('should include success message for successful install', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('Complete');\n expect(joined).toContain('claude-max');\n expect(joined).toContain('claude-free');\n });\n\n test('should include error messages for failed install', () => {\n const mockResult = {\n success: false,\n installDir: '/test/dir',\n filesInstalled: [],\n envCreated: false,\n errors: ['Test error 1', 'Test error 2'],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('error');\n expect(joined).toContain('Test error 1');\n expect(joined).toContain('Test error 2');\n });\n });\n\n describe('Cross-Platform Path Handling', () => {\n test('should use path.join for cross-platform compatibility', () => {\n // The install script should use path.join() not string concatenation\n const installScript = fs.readFileSync(\n path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js',\n ),\n 'utf8',\n );\n\n expect(installScript).toContain('path.join');\n // Should use path.join for constructing file paths (not string concatenation)\n // Allow legitimate path constants like '/usr/local/bin'\n expect(installScript).not.toMatch(/path\\s*\\+\\s*['\"][\\\\/]/); // No path + '/...'\n expect(installScript).not.toMatch(/['\"][\\\\/]\\s*\\+\\s*path/); // No '/...' + path\n });\n });\n});\n\ndescribe('Environment Variable Handling', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates',\n );\n\n test('claude-free should look for .env file', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('.env');\n });\n\n test('claude-free should set ANTHROPIC_BASE_URL to DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('api.deepseek.com');\n });\n\n test('claude-free should set API_TIMEOUT_MS', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('API_TIMEOUT_MS');\n });\n});\n"}, "30cec6b89f582416c2e2a06dd196ebf28c2e7aad": {"t": 1785766854.054497, "n": 8419, "h": "54b899bc9a5e8ea5", "c": "/**\n * LLM Routing Integration Tests\n *\n * Story 6.7: LLM Routing Migration\n *\n * Tests installation, command creation, and cross-platform compatibility.\n */\n\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\n\n// Module under test\nconst {\n installLLMRouting,\n isLLMRoutingInstalled,\n getInstallDir,\n getInstallationSummary,\n LLM_ROUTING_VERSION,\n} = require('../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing');\n\ndescribe('LLM Routing Module', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates'\n );\n\n describe('Module Exports', () => {\n test('should export all required functions', () => {\n expect(typeof installLLMRouting).toBe('function');\n expect(typeof isLLMRoutingInstalled).toBe('function');\n expect(typeof getInstallDir).toBe('function');\n expect(typeof getInstallationSummary).toBe('function');\n expect(typeof LLM_ROUTING_VERSION).toBe('string');\n });\n\n test('should have valid version format', () => {\n expect(LLM_ROUTING_VERSION).toMatch(/^\\d+\\.\\d+\\.\\d+$/);\n });\n });\n\n describe('getInstallDir()', () => {\n test('should return a valid directory path', () => {\n const installDir = getInstallDir();\n expect(typeof installDir).toBe('string');\n expect(installDir.length).toBeGreaterThan(0);\n });\n\n test('should return platform-appropriate path', () => {\n const installDir = getInstallDir();\n\n if (isWindows) {\n // Windows: should be npm global or user profile\n expect(\n installDir.includes('npm') ||\n installDir.includes('Users') ||\n installDir.includes('USERPROFILE')\n ).toBe(true);\n } else {\n // Unix: should be /usr/local/bin or ~/bin\n expect(installDir.includes('/usr/local/bin') || installDir.includes('/bin')).toBe(true);\n }\n });\n });\n\n describe('Template Files', () => {\n test('should have templates directory', () => {\n expect(fs.existsSync(testTemplatesDir)).toBe(true);\n });\n\n test('should have Windows templates', () => {\n const claudeFreeCmd = path.join(testTemplatesDir, 'claude-free.cmd');\n const claudeMaxCmd = path.join(testTemplatesDir, 'claude-max.cmd');\n\n expect(fs.existsSync(claudeFreeCmd)).toBe(true);\n expect(fs.existsSync(claudeMaxCmd)).toBe(true);\n });\n\n test('should have Unix templates', () => {\n const claudeFreeSh = path.join(testTemplatesDir, 'claude-free.sh');\n const claudeMaxSh = path.join(testTemplatesDir, 'claude-max.sh');\n\n expect(fs.existsSync(claudeFreeSh)).toBe(true);\n expect(fs.existsSync(claudeMaxSh)).toBe(true);\n });\n\n test('claude-free template should reference DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('deepseek');\n expect(content).toContain('DEEPSEEK_API_KEY');\n });\n\n test('claude-max template should clear alternative providers', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-max${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('ANTHROPIC_BASE_URL');\n // Should unset/clear the URL\n if (isWindows) {\n expect(content).toMatch(/set\\s+[\"']?ANTHROPIC_BASE_URL=[\"']?\\s*$/m);\n } else {\n expect(content).toContain('unset ANTHROPIC_BASE_URL');\n }\n });\n });\n\n describe('installLLMRouting()', () => {\n test('should fail gracefully with missing templates directory', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n const result = installLLMRouting({\n templatesDir: '/nonexistent/templates',\n onProgress: mockProgress,\n onError: mockError,\n });\n\n expect(result.success).toBe(false);\n expect(result.errors.length).toBeGreaterThan(0);\n expect(mockError).toHaveBeenCalled();\n });\n\n test('should return proper result structure', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n // Use actual templates dir\n const result = installLLMRouting({\n templatesDir: testTemplatesDir,\n onProgress: mockProgress,\n onError: mockError,\n });\n\n // Should have expected properties\n expect(result).toHaveProperty('success');\n expect(result).toHaveProperty('installDir');\n expect(result).toHaveProperty('filesInstalled');\n expect(result).toHaveProperty('errors');\n expect(Array.isArray(result.filesInstalled)).toBe(true);\n expect(Array.isArray(result.errors)).toBe(true);\n });\n });\n\n describe('getInstallationSummary()', () => {\n test('should return array of strings', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n\n expect(Array.isArray(summary)).toBe(true);\n summary.forEach((line) => {\n expect(typeof line).toBe('string');\n });\n });\n\n test('should include success message for successful install', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: [],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('Complete');\n expect(joined).toContain('claude-max');\n expect(joined).toContain('claude-free');\n });\n\n test('should include error messages for failed install', () => {\n const mockResult = {\n success: false,\n installDir: '/test/dir',\n filesInstalled: [],\n envCreated: false,\n errors: ['Test error 1', 'Test error 2'],\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('error');\n expect(joined).toContain('Test error 1');\n expect(joined).toContain('Test error 2');\n });\n });\n\n describe('Cross-Platform Path Handling', () => {\n test('should use path.join for cross-platform compatibility', () => {\n // The install script should use path.join() not string concatenation\n const installScript = fs.readFileSync(\n path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js'\n ),\n 'utf8'\n );\n\n expect(installScript).toContain('path.join');\n // Should use path.join for constructing file paths (not string concatenation)\n // Allow legitimate path constants like '/usr/local/bin'\n expect(installScript).not.toMatch(/path\\s*\\+\\s*['\"][\\\\/]/); // No path + '/...'\n expect(installScript).not.toMatch(/['\"][\\\\/]\\s*\\+\\s*path/); // No '/...' + path\n });\n });\n});\n\ndescribe('Environment Variable Handling', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(\n __dirname,\n '../../../.aios-core/infrastructure/scripts/llm-routing/templates'\n );\n\n test('claude-free should look for .env file', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('.env');\n });\n\n test('claude-free should set ANTHROPIC_BASE_URL to DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('api.deepseek.com');\n });\n\n test('claude-free should set API_TIMEOUT_MS', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('API_TIMEOUT_MS');\n });\n});\n"}, "4344ef3431e454fec8030ef4758153e2a63d18a5": {"t": 1785766856.2901042, "n": 8383, "h": "4dbd44cbcf76151c", "c": "/**\n * LLM Routing Integration Tests\n *\n * Story 6.7: LLM Routing Migration\n *\n * Tests installation, command creation, and cross-platform compatibility.\n */\n\nconst path = require('path');\nconst fs = require('fs');\nconst os = require('os');\n\n// Module under test\nconst {\n installLLMRouting,\n isLLMRoutingInstalled,\n getInstallDir,\n getInstallationSummary,\n LLM_ROUTING_VERSION\n} = require('../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing');\n\ndescribe('LLM Routing Module', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(__dirname, '../../../.aios-core/infrastructure/scripts/llm-routing/templates');\n\n describe('Module Exports', () => {\n test('should export all required functions', () => {\n expect(typeof installLLMRouting).toBe('function');\n expect(typeof isLLMRoutingInstalled).toBe('function');\n expect(typeof getInstallDir).toBe('function');\n expect(typeof getInstallationSummary).toBe('function');\n expect(typeof LLM_ROUTING_VERSION).toBe('string');\n });\n\n test('should have valid version format', () => {\n expect(LLM_ROUTING_VERSION).toMatch(/^\\d+\\.\\d+\\.\\d+$/);\n });\n });\n\n describe('getInstallDir()', () => {\n test('should return a valid directory path', () => {\n const installDir = getInstallDir();\n expect(typeof installDir).toBe('string');\n expect(installDir.length).toBeGreaterThan(0);\n });\n\n test('should return platform-appropriate path', () => {\n const installDir = getInstallDir();\n\n if (isWindows) {\n // Windows: should be npm global or user profile\n expect(\n installDir.includes('npm') ||\n installDir.includes('Users') ||\n installDir.includes('USERPROFILE')\n ).toBe(true);\n } else {\n // Unix: should be /usr/local/bin or ~/bin\n expect(\n installDir.includes('/usr/local/bin') ||\n installDir.includes('/bin')\n ).toBe(true);\n }\n });\n });\n\n describe('Template Files', () => {\n test('should have templates directory', () => {\n expect(fs.existsSync(testTemplatesDir)).toBe(true);\n });\n\n test('should have Windows templates', () => {\n const claudeFreeCmd = path.join(testTemplatesDir, 'claude-free.cmd');\n const claudeMaxCmd = path.join(testTemplatesDir, 'claude-max.cmd');\n\n expect(fs.existsSync(claudeFreeCmd)).toBe(true);\n expect(fs.existsSync(claudeMaxCmd)).toBe(true);\n });\n\n test('should have Unix templates', () => {\n const claudeFreeSh = path.join(testTemplatesDir, 'claude-free.sh');\n const claudeMaxSh = path.join(testTemplatesDir, 'claude-max.sh');\n\n expect(fs.existsSync(claudeFreeSh)).toBe(true);\n expect(fs.existsSync(claudeMaxSh)).toBe(true);\n });\n\n test('claude-free template should reference DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('deepseek');\n expect(content).toContain('DEEPSEEK_API_KEY');\n });\n\n test('claude-max template should clear alternative providers', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-max${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('ANTHROPIC_BASE_URL');\n // Should unset/clear the URL\n if (isWindows) {\n expect(content).toMatch(/set\\s+[\"']?ANTHROPIC_BASE_URL=[\"']?\\s*$/m);\n } else {\n expect(content).toContain('unset ANTHROPIC_BASE_URL');\n }\n });\n });\n\n describe('installLLMRouting()', () => {\n test('should fail gracefully with missing templates directory', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n const result = installLLMRouting({\n templatesDir: '/nonexistent/templates',\n onProgress: mockProgress,\n onError: mockError\n });\n\n expect(result.success).toBe(false);\n expect(result.errors.length).toBeGreaterThan(0);\n expect(mockError).toHaveBeenCalled();\n });\n\n test('should return proper result structure', () => {\n const mockProgress = jest.fn();\n const mockError = jest.fn();\n\n // Use actual templates dir\n const result = installLLMRouting({\n templatesDir: testTemplatesDir,\n onProgress: mockProgress,\n onError: mockError\n });\n\n // Should have expected properties\n expect(result).toHaveProperty('success');\n expect(result).toHaveProperty('installDir');\n expect(result).toHaveProperty('filesInstalled');\n expect(result).toHaveProperty('errors');\n expect(Array.isArray(result.filesInstalled)).toBe(true);\n expect(Array.isArray(result.errors)).toBe(true);\n });\n });\n\n describe('getInstallationSummary()', () => {\n test('should return array of strings', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: []\n };\n\n const summary = getInstallationSummary(mockResult);\n\n expect(Array.isArray(summary)).toBe(true);\n summary.forEach(line => {\n expect(typeof line).toBe('string');\n });\n });\n\n test('should include success message for successful install', () => {\n const mockResult = {\n success: true,\n installDir: '/test/dir',\n filesInstalled: ['claude-free', 'claude-max'],\n envCreated: false,\n errors: []\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('Complete');\n expect(joined).toContain('claude-max');\n expect(joined).toContain('claude-free');\n });\n\n test('should include error messages for failed install', () => {\n const mockResult = {\n success: false,\n installDir: '/test/dir',\n filesInstalled: [],\n envCreated: false,\n errors: ['Test error 1', 'Test error 2']\n };\n\n const summary = getInstallationSummary(mockResult);\n const joined = summary.join('\\n');\n\n expect(joined).toContain('error');\n expect(joined).toContain('Test error 1');\n expect(joined).toContain('Test error 2');\n });\n });\n\n describe('Cross-Platform Path Handling', () => {\n test('should use path.join for cross-platform compatibility', () => {\n // The install script should use path.join() not string concatenation\n const installScript = fs.readFileSync(\n path.join(__dirname, '../../../.aios-core/infrastructure/scripts/llm-routing/install-llm-routing.js'),\n 'utf8'\n );\n\n expect(installScript).toContain('path.join');\n // Should use path.join for constructing file paths (not string concatenation)\n // Allow legitimate path constants like '/usr/local/bin'\n expect(installScript).not.toMatch(/path\\s*\\+\\s*['\"][\\\\/]/); // No path + '/...'\n expect(installScript).not.toMatch(/['\"][\\\\/]\\s*\\+\\s*path/); // No '/...' + path\n });\n });\n});\n\ndescribe('Environment Variable Handling', () => {\n const isWindows = os.platform() === 'win32';\n const testTemplatesDir = path.join(__dirname, '../../../.aios-core/infrastructure/scripts/llm-routing/templates');\n\n test('claude-free should look for .env file', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('.env');\n });\n\n test('claude-free should set ANTHROPIC_BASE_URL to DeepSeek', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('api.deepseek.com');\n });\n\n test('claude-free should set API_TIMEOUT_MS', () => {\n const templateExt = isWindows ? '.cmd' : '.sh';\n const templatePath = path.join(testTemplatesDir, `claude-free${templateExt}`);\n const content = fs.readFileSync(templatePath, 'utf8');\n\n expect(content).toContain('API_TIMEOUT_MS');\n });\n});\n"}}, ".docker/llm-routing/docker-compose.yml": {"3811edb0ff77b8568352810167d053399f64654a": {"t": 1785747417.1533816, "n": 1089, "h": "aaf9b9e2b3f1d5b7", "c": "# Docker Compose for AIOS LLM Routing\n# Version: 1.0.0\n# Usage: docker compose up -d\n\nservices:\n litellm-proxy:\n # Pin to stable version for reproducible builds\n image: ghcr.io/berriai/litellm:v1.55.10-stable\n container_name: aios-litellm-proxy\n ports:\n - \"4000:4000\"\n volumes:\n - ./config.yaml:/app/config.yaml:ro\n environment:\n # API Keys (from .env file)\n - OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}\n - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}\n - GROQ_API_KEY=${GROQ_API_KEY:-}\n\n # LiteLLM Settings\n - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-aios-litellm-default}\n - LITELLM_DROP_PARAMS=true\n\n # Logging\n - LITELLM_LOG_LEVEL=${LITELLM_LOG_LEVEL:-INFO}\n command: [\"--config\", \"/app/config.yaml\", \"--port\", \"4000\", \"--host\", \"0.0.0.0\"]\n healthcheck:\n test: [\"CMD\", \"curl\", \"-f\", \"http://localhost:4000/health\"]\n interval: 30s\n timeout: 10s\n retries: 3\n start_period: 10s\n restart: unless-stopped\n networks:\n - aios-network\n\nnetworks:\n aios-network:\n driver: bridge\n"}, "4344ef3431e454fec8030ef4758153e2a63d18a5": {"t": 1785766850.126566, "n": 1089, "h": "aaf9b9e2b3f1d5b7", "c": "# Docker Compose for AIOS LLM Routing\n# Version: 1.0.0\n# Usage: docker compose up -d\n\nservices:\n litellm-proxy:\n # Pin to stable version for reproducible builds\n image: ghcr.io/berriai/litellm:v1.55.10-stable\n container_name: aios-litellm-proxy\n ports:\n - \"4000:4000\"\n volumes:\n - ./config.yaml:/app/config.yaml:ro\n environment:\n # API Keys (from .env file)\n - OPENROUTER_API_KEY=${OPENROUTER_API_KEY:-}\n - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-}\n - GROQ_API_KEY=${GROQ_API_KEY:-}\n\n # LiteLLM Settings\n - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-aios-litellm-default}\n - LITELLM_DROP_PARAMS=true\n\n # Logging\n - LITELLM_LOG_LEVEL=${LITELLM_LOG_LEVEL:-INFO}\n command: [\"--config\", \"/app/config.yaml\", \"--port\", \"4000\", \"--host\", \"0.0.0.0\"]\n healthcheck:\n test: [\"CMD\", \"curl\", \"-f\", \"http://localhost:4000/health\"]\n interval: 30s\n timeout: 10s\n retries: 3\n start_period: 10s\n restart: unless-stopped\n networks:\n - aios-network\n\nnetworks:\n aios-network:\n driver: bridge\n"}}}}