Files
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

737 lines
22 KiB
TypeScript

/**
* @claude-flow/codex - Migration Tests
*
* Tests for Claude Code to Codex migration functions
*/
import { describe, it, expect } from 'vitest';
import {
analyzeClaudeMd,
migrateFromClaudeCode,
convertSkillSyntax,
convertSettingsToToml,
generateMigrationReport,
FEATURE_MAPPINGS,
} from '../src/migrations/index.js';
import type { MigrationResult } from '../src/types.js';
// =============================================================================
// Sample CLAUDE.md Content for Testing
// =============================================================================
const SAMPLE_CLAUDE_MD = `# Claude Flow V3 Project
## Behavioral Rules (Always Enforced)
- Do what has been asked; nothing more, nothing less
- NEVER create files unless they're absolutely necessary
- ALWAYS prefer editing an existing file to creating a new one
- NEVER proactively create documentation files
## File Organization
- Use \`/src\` for source code files
- Use \`/tests\` for test files
- Use \`/docs\` for documentation
## Swarm Orchestration
Use /swarm-init to initialize the swarm.
Run /security-scan for security checks.
The /memory-store command stores patterns.
## Hooks
Use pre-task hooks before starting work.
Use post-task hooks after completion.
The session-start hook initializes context.
## Advanced
Run \`claude -p "analyze code"\` for headless analysis.
Use TodoWrite for task tracking.
EnterPlanMode for planning complex tasks.
`;
const SAMPLE_CLAUDE_MD_WITH_SKILLS = `# Skill Project
## Skills
- /code-review - Review code changes
- /test-generation - Generate tests
- /performance-analysis - Analyze performance
- /security-audit - Security checks
## Commands
Run /deploy for deployment.
Use /rollback if needed.
`;
// =============================================================================
// analyzeClaudeMd Tests
// =============================================================================
describe('analyzeClaudeMd', () => {
describe('section extraction', () => {
it('should extract all level-2 sections', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.sections).toContain('Behavioral Rules (Always Enforced)');
expect(result.sections).toContain('File Organization');
expect(result.sections).toContain('Swarm Orchestration');
expect(result.sections).toContain('Hooks');
expect(result.sections).toContain('Advanced');
});
it('should handle CLAUDE.md with no level-2 sections', async () => {
const content = `# Simple Project
Just a description with no level-2 sections.
`;
const result = await analyzeClaudeMd(content);
// The sections array should be empty or not contain level-2 section titles
// Since there are no ## headings, we should have no sections or only the H1
expect(result.sections.length).toBeLessThanOrEqual(1);
});
});
describe('skill extraction', () => {
it('should extract skill references', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.skills).toContain('swarm-init');
expect(result.skills).toContain('security-scan');
expect(result.skills).toContain('memory-store');
});
it('should extract multiple skills without duplicates', async () => {
const content = `# Project
Use /skill-a and /skill-b.
Also run /skill-a again.
Then /skill-c.
`;
const result = await analyzeClaudeMd(content);
expect(result.skills).toContain('skill-a');
expect(result.skills).toContain('skill-b');
expect(result.skills).toContain('skill-c');
expect(result.skills.filter(s => s === 'skill-a')).toHaveLength(1);
});
it('should extract skills from skill-heavy document', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD_WITH_SKILLS);
expect(result.skills).toContain('code-review');
expect(result.skills).toContain('test-generation');
expect(result.skills).toContain('performance-analysis');
expect(result.skills).toContain('security-audit');
expect(result.skills).toContain('deploy');
expect(result.skills).toContain('rollback');
});
});
describe('hook extraction', () => {
it('should detect referenced hooks', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.hooks).toContain('pre-task');
expect(result.hooks).toContain('post-task');
expect(result.hooks).toContain('session-start');
});
it('should handle document with no hooks', async () => {
const content = `# No Hooks Project
Just a simple project with no hook references.
`;
const result = await analyzeClaudeMd(content);
expect(result.hooks).toHaveLength(0);
});
it('should detect all hook types', async () => {
const content = `# All Hooks
Use pre-task before work.
Use post-task after work.
Use pre-edit before editing.
Use post-edit after editing.
Use session-start at startup.
Use session-end at shutdown.
`;
const result = await analyzeClaudeMd(content);
expect(result.hooks).toContain('pre-task');
expect(result.hooks).toContain('post-task');
expect(result.hooks).toContain('pre-edit');
expect(result.hooks).toContain('post-edit');
expect(result.hooks).toContain('session-start');
expect(result.hooks).toContain('session-end');
});
});
describe('custom instructions extraction', () => {
it('should extract behavioral rules', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.customInstructions).toContain(
'Do what has been asked; nothing more, nothing less'
);
expect(result.customInstructions).toContain(
'NEVER create files unless they\'re absolutely necessary'
);
});
it('should handle document without Behavioral Rules section', async () => {
const content = `# Simple Project
## Quick Start
npm install
`;
const result = await analyzeClaudeMd(content);
expect(result.customInstructions).toHaveLength(0);
});
});
describe('warnings generation', () => {
it('should warn about EnterPlanMode usage', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.warnings.some(w => w.includes('EnterPlanMode'))).toBe(true);
});
it('should warn about claude -p usage', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.warnings.some(w => w.includes('claude -p'))).toBe(true);
});
it('should warn about TodoWrite usage', async () => {
const result = await analyzeClaudeMd(SAMPLE_CLAUDE_MD);
expect(result.warnings.some(w => w.includes('TodoWrite'))).toBe(true);
});
it('should not generate warnings for clean CLAUDE.md', async () => {
const content = `# Clean Project
## Setup
npm install
## Code Standards
- Keep files small
- Use typed interfaces
`;
const result = await analyzeClaudeMd(content);
expect(result.warnings).toHaveLength(0);
});
});
});
// =============================================================================
// migrateFromClaudeCode Tests
// =============================================================================
describe('migrateFromClaudeCode', () => {
describe('successful migration', () => {
it('should return success result', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
});
expect(result.success).toBe(true);
});
it('should generate AGENTS.md path', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
});
expect(result.agentsMdPath).toBe('/project/AGENTS.md');
});
it('should generate config.toml path', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
});
expect(result.configTomlPath).toBe('/project/.agents/config.toml');
});
it('should create default skills when generateSkills is true', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
generateSkills: true,
});
expect(result.skillsCreated).toContain('swarm-orchestration');
expect(result.skillsCreated).toContain('memory-management');
expect(result.skillsCreated).toContain('security-audit');
});
it('should not create skills when generateSkills is false', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
generateSkills: false,
});
expect(result.skillsCreated).toHaveLength(0);
});
it('should include feature mappings', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
});
expect(result.mappings).toBeDefined();
expect(result.mappings!.length).toBeGreaterThan(0);
});
it('should include migration warnings', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
});
expect(result.warnings).toBeDefined();
expect(result.warnings!.some(w => w.includes('skill invocation syntax'))).toBe(true);
});
});
describe('migration options', () => {
it('should respect preserveComments option', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/project/CLAUDE.md',
targetPath: '/project',
preserveComments: true,
});
expect(result.success).toBe(true);
});
it('should use custom target path', async () => {
const result = await migrateFromClaudeCode({
sourcePath: '/old/CLAUDE.md',
targetPath: '/new/project',
});
expect(result.agentsMdPath).toBe('/new/project/AGENTS.md');
expect(result.configTomlPath).toBe('/new/project/.agents/config.toml');
});
});
});
// =============================================================================
// convertSkillSyntax Tests
// =============================================================================
describe('convertSkillSyntax', () => {
it('should convert /skill-name to $skill-name', () => {
const content = 'Use /swarm-init to start.';
const result = convertSkillSyntax(content);
expect(result).toBe('Use $swarm-init to start.');
});
it('should convert multiple skill references', () => {
const content = 'Run /skill-a then /skill-b and finally /skill-c.';
const result = convertSkillSyntax(content);
expect(result).toBe('Run $skill-a then $skill-b and finally $skill-c.');
});
it('should preserve URLs (improved regex)', () => {
const content = 'Visit https://example.com/path for more info.';
const result = convertSkillSyntax(content);
// The improved regex should not convert paths within URLs
// as it excludes patterns preceded by alphanumeric/underscore/dot/slash chars
expect(result).toBe(content);
});
it('should handle complex skill names', () => {
const content = '/multi-word-skill-name and /a1b2c3';
const result = convertSkillSyntax(content);
expect(result).toBe('$multi-word-skill-name and $a1b2c3');
});
it('should preserve surrounding text', () => {
const content = 'Before /skill after';
const result = convertSkillSyntax(content);
expect(result).toBe('Before $skill after');
});
it('should handle content with no skills', () => {
const content = 'No skills here, just regular text.';
const result = convertSkillSyntax(content);
expect(result).toBe('No skills here, just regular text.');
});
it('should convert skills at line start', () => {
const content = '/skill-at-start\nMore text';
const result = convertSkillSyntax(content);
expect(result).toBe('$skill-at-start\nMore text');
});
it('should convert skills at line end', () => {
const content = 'Run the command /skill-at-end';
const result = convertSkillSyntax(content);
expect(result).toBe('Run the command $skill-at-end');
});
});
// =============================================================================
// convertSettingsToToml Tests
// =============================================================================
describe('convertSettingsToToml', () => {
it('should include migration header', () => {
const result = convertSettingsToToml({});
expect(result).toContain('# Migrated from settings.json');
});
it('should convert model setting', () => {
const settings = {
model: 'claude-3-opus',
};
const result = convertSettingsToToml(settings);
expect(result).toContain('model = "claude-3-opus"');
});
it('should convert autoApprove true to never policy', () => {
const settings = {
permissions: {
autoApprove: true,
},
};
const result = convertSettingsToToml(settings);
expect(result).toContain('approval_policy = "never"');
});
it('should convert autoApprove read-only', () => {
const settings = {
permissions: {
autoApprove: 'read-only',
},
};
const result = convertSettingsToToml(settings);
expect(result).toContain('approval_policy = "on-request"');
expect(result).toContain('sandbox_mode = "read-only"');
});
it('should use on-request as default approval policy', () => {
const settings = {
permissions: {
autoApprove: false,
},
};
const result = convertSettingsToToml(settings);
expect(result).toContain('approval_policy = "on-request"');
});
it('should convert MCP servers', () => {
const settings = {
mcpServers: {
'claude-flow': {
command: 'npx',
args: ['-y', '@claude-flow/cli'],
},
'custom-server': {
command: 'node',
args: ['./server.js', '--port', '3000'],
},
},
};
const result = convertSettingsToToml(settings);
expect(result).toContain('[mcp_servers.claude-flow]');
expect(result).toContain('command = "npx"');
expect(result).toContain('args = ["-y", "@claude-flow/cli"]');
expect(result).toContain('[mcp_servers.custom-server]');
expect(result).toContain('command = "node"');
});
it('should add default ruflo server when no mcpServers', () => {
const settings = {
model: 'gpt-4',
};
const result = convertSettingsToToml(settings);
// The implementation adds a default ruflo server when none specified
expect(result).toContain('[mcp_servers.ruflo]');
expect(result).toContain('command = "npx"');
});
it('should handle empty settings', () => {
const result = convertSettingsToToml({});
expect(result).toContain('# Migrated from settings.json');
expect(result.split('\n').length).toBeGreaterThan(1);
});
});
// =============================================================================
// generateMigrationReport Tests
// =============================================================================
describe('generateMigrationReport', () => {
describe('successful migration report', () => {
it('should show success status', () => {
const result: MigrationResult = {
success: true,
agentsMdPath: '/project/AGENTS.md',
configTomlPath: '/project/.agents/config.toml',
skillsCreated: ['swarm-orchestration', 'memory-management'],
mappings: FEATURE_MAPPINGS,
warnings: ['Check skill syntax'],
};
const report = generateMigrationReport(result);
expect(report).toContain('# Migration Report');
expect(report).toContain('**Status**: Success');
});
it('should list generated files', () => {
const result: MigrationResult = {
success: true,
agentsMdPath: '/project/AGENTS.md',
configTomlPath: '/project/.agents/config.toml',
};
const report = generateMigrationReport(result);
expect(report).toContain('## Generated Files');
expect(report).toContain('AGENTS.md:');
expect(report).toContain('/project/AGENTS.md');
expect(report).toContain('config.toml:');
expect(report).toContain('/project/.agents/config.toml');
});
it('should list created skills', () => {
const result: MigrationResult = {
success: true,
skillsCreated: ['skill-a', 'skill-b', 'skill-c'],
};
const report = generateMigrationReport(result);
expect(report).toContain('## Skills Created');
// Skills are formatted with $ prefix in backticks
expect(report).toContain('$skill-a');
expect(report).toContain('$skill-b');
expect(report).toContain('$skill-c');
});
it('should include feature mappings table', () => {
const result: MigrationResult = {
success: true,
mappings: [
{ claudeCode: 'CLAUDE.md', codex: 'AGENTS.md', status: 'mapped', notes: 'Main file' },
{ claudeCode: '/skill', codex: '$skill', status: 'mapped', notes: 'Syntax change' },
],
};
const report = generateMigrationReport(result);
expect(report).toContain('## Feature Mappings');
// Table now includes Notes column
expect(report).toContain('| Claude Code | Codex | Status | Notes |');
expect(report).toContain('CLAUDE.md');
expect(report).toContain('AGENTS.md');
expect(report).toContain('mapped');
});
it('should include warnings', () => {
const result: MigrationResult = {
success: true,
warnings: ['Warning 1', 'Warning 2'],
};
const report = generateMigrationReport(result);
expect(report).toContain('## Warnings');
expect(report).toContain('- Warning 1');
expect(report).toContain('- Warning 2');
});
});
describe('failed migration report', () => {
it('should show failed status', () => {
const result: MigrationResult = {
success: false,
warnings: ['Migration failed: File not found'],
};
const report = generateMigrationReport(result);
expect(report).toContain('**Status**: Failed');
});
it('should include error warnings', () => {
const result: MigrationResult = {
success: false,
warnings: ['Error: Could not read source file'],
};
const report = generateMigrationReport(result);
expect(report).toContain('## Warnings');
expect(report).toContain('Error: Could not read source file');
});
});
describe('minimal report', () => {
it('should handle minimal result', () => {
const result: MigrationResult = {
success: true,
};
const report = generateMigrationReport(result);
expect(report).toContain('# Migration Report');
expect(report).toContain('**Status**: Success');
expect(report).not.toContain('## Generated Files');
expect(report).not.toContain('## Skills Created');
});
});
});
// =============================================================================
// FEATURE_MAPPINGS Tests
// =============================================================================
describe('FEATURE_MAPPINGS', () => {
it('should contain CLAUDE.md to AGENTS.md mapping', () => {
const mapping = FEATURE_MAPPINGS.find(m => m.claudeCode === 'CLAUDE.md');
expect(mapping).toBeDefined();
expect(mapping!.codex).toBe('AGENTS.md');
expect(mapping!.status).toBe('mapped');
});
it('should contain skill invocation syntax mapping', () => {
const mapping = FEATURE_MAPPINGS.find(m => m.claudeCode === '/skill-name');
expect(mapping).toBeDefined();
expect(mapping!.codex).toBe('$skill-name');
expect(mapping!.status).toBe('mapped');
});
it('should contain MCP servers mapping', () => {
const mapping = FEATURE_MAPPINGS.find(m => m.claudeCode === 'MCP servers');
expect(mapping).toBeDefined();
expect(mapping!.codex).toBe('[mcp_servers]');
expect(mapping!.status).toBe('mapped');
});
it('should mark EnterPlanMode as unsupported', () => {
const mapping = FEATURE_MAPPINGS.find(m => m.claudeCode === 'EnterPlanMode');
expect(mapping).toBeDefined();
expect(mapping!.status).toBe('unsupported');
});
it('should mark hooks as partial', () => {
const mapping = FEATURE_MAPPINGS.find(m => m.claudeCode === 'hooks system');
expect(mapping).toBeDefined();
expect(mapping!.status).toBe('partial');
});
it('should include notes for all mappings', () => {
for (const mapping of FEATURE_MAPPINGS) {
expect(mapping.notes).toBeDefined();
expect(mapping.notes!.length).toBeGreaterThan(0);
}
});
it('should have at least 8 mappings', () => {
expect(FEATURE_MAPPINGS.length).toBeGreaterThanOrEqual(8);
});
});
// =============================================================================
// Integration Tests
// =============================================================================
describe('migration integration', () => {
it('should analyze and migrate consistently', async () => {
const content = `# Test Project
## Behavioral Rules
- Rule one
- Rule two
## Skills
Use /skill-a and /skill-b.
## Hooks
Use pre-task hooks.
`;
const analysis = await analyzeClaudeMd(content);
const migration = await migrateFromClaudeCode({
sourcePath: '/test/CLAUDE.md',
targetPath: '/test',
});
expect(analysis.skills).toContain('skill-a');
expect(analysis.skills).toContain('skill-b');
expect(analysis.hooks).toContain('pre-task');
expect(migration.success).toBe(true);
});
it('should convert analyzed content correctly', async () => {
const content = 'Use /swarm-orchestration and /memory-management.';
const converted = convertSkillSyntax(content);
const analysis = await analyzeClaudeMd(content);
expect(converted).toContain('$swarm-orchestration');
expect(converted).toContain('$memory-management');
expect(analysis.skills).toContain('swarm-orchestration');
expect(analysis.skills).toContain('memory-management');
});
});