πŸ“„ index.ts  β€’  2426 bytes
/**
 * CmdCode V0.5 - ιͺŒθ―η³»η»Ÿ
 * Phase 3: 代码ιͺŒθ―
 */

// ε―Όε‡Ίη±»εž‹
export type { 
  VerificationType,
  VerificationStatus,
  VerificationIssue,
  VerificationResult,
  VerificationReport,
  VerificationOptions 
} from './types'

// ε―Όε‡ΊιͺŒθ―ε™¨
export {
  checkSyntax,
  checkTypes,
  runTests,
  checkSecurity,
  checkConsistency,
  getVerifiersForFile,
} from './checker'

// ε―Όε‡ΊζŠ₯ε‘Šη”Ÿζˆ
export {
  createReport,
  addResult,
  formatReport,
  formatSummary,
  getFailedIssues,
  shouldFail,
} from './reporter'

// 导出常量
export { 
  DEFAULT_VERIFICATION_OPTIONS,
  STATUS_LABELS,
  TYPE_LABELS,
} from './types'

// ε―Όε…₯εΈΈι‡δΎ›ζœ¬εœ°δ½Ώη”¨
import { 
  DEFAULT_VERIFICATION_OPTIONS,
  STATUS_LABELS,
  TYPE_LABELS,
} from './types'

// ε―Όε…₯ζœ¬εœ°ε‡½ζ•°
import { createReport, addResult } from './reporter'
import { getVerifiersForFile } from './checker'

/** 
 * δΈ»ιͺŒθ―ε‡½ζ•°
 */
export async function verify(
  file: string,
  options: Partial<VerificationOptions> = {},
  verbose: boolean = true
): Promise<VerificationReport> {
  const opts = { ...DEFAULT_VERIFICATION_OPTIONS, ...options }
  
  if (verbose) {
    console.log('')
    console.log(`  \x1b[38;5;220mπŸ” εΌ€ε§‹ιͺŒθ―: ${file}\x1b[0m`)
    console.log(`  \x1b[38;5;240m════════════════════════════════\x1b[0m`)
  }
  
  // εˆ›ε»ΊζŠ₯ε‘Š
  const report = createReport(file)
  
  // θŽ·ε–ι€‚η”¨ηš„ιͺŒθ―ε™¨
  const verifiers = getVerifiersForFile(file, opts)
  
  if (verifiers.length === 0) {
    if (verbose) {
      console.log(`  \x1b[38;5;240mζ— ι€‚η”¨ηš„ιͺŒθ―ε™¨οΌŒθ·³θΏ‡\x1b[0m`)
    }
    return report
  }
  
  // 运葌ιͺŒθ―
  for (const verifier of verifiers) {
    if (verbose) {
      console.log(`  \x1b[38;5;240m  ${TYPE_LABELS[verifier.type]}...\x1b[0m`)
    }
    
    const result = await verifier.fn()
    addResult(report, result)
    
    if (verbose) {
      const icon = result.passed ? '\x1b[38;5;208mβœ…\x1b[0m' : '\x1b[38;5;196m❌\x1b[0m'
      console.log(`    ${icon} ${STATUS_LABELS[result.status]} (${result.duration}ms)`)
    }
  }
  
  if (verbose) {
    console.log('')
    console.log(`  ${report.overallPassed ? '\x1b[38;5;208mβœ…\x1b[0m' : '\x1b[38;5;196m❌\x1b[0m'} ιͺŒθ―${report.overallPassed ? 'ι€šθΏ‡' : 'ε€±θ΄₯'}`)
  }
  
  return report
}

/** η‰ˆζœ¬δΏ‘ζ― */
export const VERIFIER_VERSION = '0.6.0-phase3'