cto-ai-cli 4.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -612,6 +612,8 @@ interface FeedbackEntry {
612
612
  outcome: FeedbackOutcome;
613
613
  model?: string;
614
614
  promptTokens?: number;
615
+ sessionId?: string;
616
+ strategy?: string;
615
617
  }
616
618
  interface FeedbackOutcome {
617
619
  accepted: boolean;
@@ -633,19 +635,34 @@ interface FeedbackModel {
633
635
  includedCount: number;
634
636
  acceptedCount: number;
635
637
  acceptRate: number;
638
+ ewmaAcceptRate: number;
636
639
  avgTimeToAccept: number;
640
+ lastSeen: string;
641
+ bayesianLower: number;
637
642
  }>;
638
643
  taskTypeAcceptance: Record<string, {
639
644
  totalCount: number;
640
645
  acceptedCount: number;
641
646
  acceptRate: number;
642
647
  avgCompilable: number;
648
+ ewmaAcceptRate: number;
643
649
  }>;
644
650
  pairAcceptance: Record<string, {
645
651
  count: number;
646
652
  acceptedCount: number;
647
653
  acceptRate: number;
648
654
  }>;
655
+ sessions: Record<string, {
656
+ strategy: string;
657
+ entries: number;
658
+ acceptRate: number;
659
+ }>;
660
+ strategyComparison: Record<string, {
661
+ totalCount: number;
662
+ acceptedCount: number;
663
+ acceptRate: number;
664
+ avgTimeToAccept: number;
665
+ }>;
649
666
  insights: FeedbackInsight[];
650
667
  }
651
668
  interface FeedbackInsight {
@@ -655,9 +672,33 @@ interface FeedbackInsight {
655
672
  impact: number;
656
673
  }
657
674
  declare function loadFeedbackModel(projectPath: string): Promise<FeedbackModel>;
675
+ declare function wilsonLowerBound(successes: number, total: number, z?: number): number;
658
676
  declare function recordFeedback(projectPath: string, entry: Omit<FeedbackEntry, 'id' | 'timestamp' | 'taskType'>): Promise<FeedbackModel>;
659
677
  declare function getFeedbackBoosts(projectPath: string, task: string): Promise<Map<string, number>>;
678
+ interface TeamFeedbackExport {
679
+ version: number;
680
+ exportedAt: string;
681
+ projectName: string;
682
+ model: FeedbackModel;
683
+ entrySummary: {
684
+ total: number;
685
+ accepted: number;
686
+ sessions: number;
687
+ };
688
+ }
689
+ declare function exportFeedbackForTeam(projectPath: string, projectName: string): Promise<TeamFeedbackExport>;
690
+ declare function importTeamFeedback(projectPath: string, teamExport: TeamFeedbackExport): Promise<FeedbackModel>;
660
691
  declare function renderFeedbackReport(model: FeedbackModel): string;
692
+ declare function renderCrossRepoReport(stats: {
693
+ totalProjects: number;
694
+ totalObservations: number;
695
+ archetypes: {
696
+ name: string;
697
+ projects: number;
698
+ observations: number;
699
+ }[];
700
+ universalPatterns: number;
701
+ }): string;
661
702
 
662
703
  interface SemanticFingerprint {
663
704
  filePath: string;
@@ -807,6 +848,35 @@ declare function optimizeBudget(files: AnalyzedFile[], budget: number): Promise<
807
848
  declare function pruneFile(file: AnalyzedFile, level: PruneLevel): Promise<PrunedContent>;
808
849
  declare function pruneFiles(files: AnalyzedFile[], levelFn: (file: AnalyzedFile) => PruneLevel): Promise<PrunedContent[]>;
809
850
 
851
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
852
+ interface LogEntry {
853
+ level: LogLevel;
854
+ msg: string;
855
+ ts: string;
856
+ module?: string;
857
+ [key: string]: unknown;
858
+ }
859
+ declare function setLogLevel(level: LogLevel): void;
860
+ declare function setJsonLogging(enabled: boolean): void;
861
+ declare function createLogger(module: string): {
862
+ debug: (msg: string, data?: Record<string, unknown>) => void;
863
+ info: (msg: string, data?: Record<string, unknown>) => void;
864
+ warn: (msg: string, data?: Record<string, unknown>) => void;
865
+ error: (msg: string, data?: Record<string, unknown>) => void;
866
+ };
867
+ type Logger = ReturnType<typeof createLogger>;
868
+
869
+ type CtoErrorCode = 'ANALYSIS_FAILED' | 'FILE_READ_ERROR' | 'FILE_WRITE_ERROR' | 'GRAPH_BUILD_FAILED' | 'SELECTION_FAILED' | 'PRUNING_FAILED' | 'SCORING_FAILED' | 'AUDIT_FAILED' | 'GATEWAY_ERROR' | 'CONFIG_INVALID' | 'GIT_ERROR' | 'REVIEW_FAILED' | 'PREDICTION_FAILED' | 'MONOREPO_ERROR' | 'MCP_ERROR' | 'INVALID_INPUT';
870
+ declare class CtoError extends Error {
871
+ readonly code: CtoErrorCode;
872
+ readonly module: string;
873
+ readonly context?: Record<string, unknown>;
874
+ constructor(code: CtoErrorCode, message: string, module: string, context?: Record<string, unknown>);
875
+ toJSON(): Record<string, unknown>;
876
+ }
877
+ declare function isCtoError(err: unknown): err is CtoError;
878
+ declare function wrapError(err: unknown, code: CtoErrorCode, module: string, context?: Record<string, unknown>): CtoError;
879
+
810
880
  declare function countTokensTiktoken(text: string): number;
811
881
  declare function countTokensChars4(sizeInBytes: number): number;
812
882
  declare function estimateTokens(content: string, sizeInBytes: number, method?: 'chars4' | 'tiktoken'): number;
@@ -897,4 +967,83 @@ declare function runQualityGate(score: ContextScore, analysis: ProjectAnalysis,
897
967
  severity: string;
898
968
  }[], config?: Partial<QualityGateConfig>): Promise<QualityGateResult>;
899
969
 
900
- export { type Baseline, type BenchmarkResult, type ChangeType, type ChangedFile, type CompilabilityMetrics, type CompilabilityResult, type CompileProofResult, type CompileProofStrategy, type ContextScore, type CrossPackageEdge, type CrossRepoModel, type CrossRepoPrediction, DEFAULT_GATE_CONFIG, type DimensionScore, type FeedbackEntry, type FeedbackInsight, type FeedbackModel, type FeedbackOutcome, type FileChangeEvent, type Grade, MODEL_REGISTRY, type ModelOptimization, type ModelProfile, type MonorepoAnalysis, type MonorepoTool, type MultiModelResult, type PRContextOptions, type PRContextResult, type PackageContextResult, type PackageInfo, type PredictionResult, type PredictorModel, type ProjectFingerprint, ProjectWatcher, type QualityBenchmarkResult, type QualityGateCheck, type QualityGateConfig, type QualityGateResult, type QualityMetrics, type ScoreInsight, type SelectionInput, type SemanticAnalysis, type SemanticDomain, type SemanticFingerprint, type StrategyResult, type WatcherOptions, analyzeMonorepo, analyzeProject, analyzeSemantics, bfsBidirectional, buildAdjacencyList, buildProjectGraph, calculateCoverage, classifyFileKind, computeContextScore, computeFingerprint, configureCache, countTokensChars4, countTokensTiktoken, createProject, detectMonorepoTool, detectStack, estimateFileTokens, estimateTokens, freeEncoder, generatePRContext, getActiveWatchers, getCTODir, getCacheStats, getCachedAnalysis, getConfigPath, getCrossRepoStats, getFeedbackBoosts, getModelStats, getPolicyPath, getPredictorBoosts, getPruneLevelForRisk, initProjectConfig, invalidateCache, loadBaseline, loadConfig, loadFeedbackModel, loadGlobalModel, loadModel, loadPolicyFromYAML, matchGlob, optimizeBudget, optimizeForModels, predictFromCrossRepo, predictRelevantFiles, pruneFile, pruneFiles, recordCrossRepoSelection, recordFeedback, recordSelection, renderBenchmark, renderCompilabilityBenchmark, renderCompileProof, renderContextScore, renderFeedbackReport, renderMonorepoAnalysis, renderMultiModelResult, renderPackageContext, renderQualityBenchmark, renderSemanticAnalysis, runBenchmark, runCompilabilityBenchmark, runCompileProof, runQualityBenchmark, runQualityGate, saveBaseline, saveConfig, scoreAllFiles, scoreFile, selectContext, selectPackageContext, semanticBoosts, unwatchAll, unwatchProject, walkProject, watchProject };
970
+ interface ReviewResult {
971
+ branch: string;
972
+ baseBranch: string;
973
+ isGitRepo: boolean;
974
+ changedFiles: ReviewFile[];
975
+ totalLinesChanged: number;
976
+ breakingChanges: BreakingChange[];
977
+ missingFiles: MissingFile[];
978
+ impactRadius: ImpactRadius;
979
+ reviewQuality: ReviewQuality;
980
+ reviewPrompt: string;
981
+ renderedSummary: string;
982
+ }
983
+ interface ReviewFile {
984
+ relativePath: string;
985
+ changeType: 'added' | 'modified' | 'deleted' | 'renamed';
986
+ linesAdded: number;
987
+ linesRemoved: number;
988
+ riskScore: number;
989
+ kind: string;
990
+ hunks: DiffHunk[];
991
+ hasExportChanges: boolean;
992
+ hasTypeChanges: boolean;
993
+ }
994
+ interface DiffHunk {
995
+ startLine: number;
996
+ endLine: number;
997
+ header: string;
998
+ additions: string[];
999
+ deletions: string[];
1000
+ }
1001
+ interface BreakingChange {
1002
+ file: string;
1003
+ type: 'export-removed' | 'export-renamed' | 'type-changed' | 'interface-changed' | 'function-signature' | 'enum-modified' | 'default-export-changed';
1004
+ severity: 'critical' | 'high' | 'medium';
1005
+ description: string;
1006
+ affectedFiles: string[];
1007
+ line?: number;
1008
+ }
1009
+ interface MissingFile {
1010
+ file: string;
1011
+ reason: string;
1012
+ severity: 'high' | 'medium' | 'low';
1013
+ relatedChangedFile: string;
1014
+ relationship: 'imports' | 'imported-by' | 'sibling-type' | 'test' | 'co-located';
1015
+ }
1016
+ interface ImpactRadius {
1017
+ directlyAffected: number;
1018
+ transitivelyAffected: number;
1019
+ totalAffected: number;
1020
+ affectedTests: number;
1021
+ riskScore: number;
1022
+ hotspots: {
1023
+ file: string;
1024
+ dependents: number;
1025
+ riskScore: number;
1026
+ }[];
1027
+ }
1028
+ interface ReviewQuality {
1029
+ score: number;
1030
+ grade: string;
1031
+ factors: ReviewFactor[];
1032
+ }
1033
+ interface ReviewFactor {
1034
+ name: string;
1035
+ score: number;
1036
+ weight: number;
1037
+ detail: string;
1038
+ }
1039
+ interface ReviewOptions {
1040
+ baseBranch?: string;
1041
+ depth?: number;
1042
+ includeTests?: boolean;
1043
+ maxPromptFiles?: number;
1044
+ maxPromptTokens?: number;
1045
+ }
1046
+ declare function analyzeForReview(analysis: ProjectAnalysis, options?: ReviewOptions): Promise<ReviewResult>;
1047
+ declare function renderReviewSummary(branch: string, baseBranch: string, changedFiles: ReviewFile[], breakingChanges: BreakingChange[], missingFiles: MissingFile[], impactRadius: ImpactRadius, reviewQuality: ReviewQuality): string;
1048
+
1049
+ export { type Baseline, type BenchmarkResult, type BreakingChange, type ChangeType, type ChangedFile, type CompilabilityMetrics, type CompilabilityResult, type CompileProofResult, type CompileProofStrategy, type ContextScore, type CrossPackageEdge, type CrossRepoModel, type CrossRepoPrediction, CtoError, type CtoErrorCode, DEFAULT_GATE_CONFIG, type DiffHunk, type DimensionScore, type FeedbackEntry, type FeedbackInsight, type FeedbackModel, type FeedbackOutcome, type FileChangeEvent, type Grade, type ImpactRadius, type LogEntry, type LogLevel, type Logger, MODEL_REGISTRY, type MissingFile, type ModelOptimization, type ModelProfile, type MonorepoAnalysis, type MonorepoTool, type MultiModelResult, type PRContextOptions, type PRContextResult, type PackageContextResult, type PackageInfo, type PredictionResult, type PredictorModel, type ProjectFingerprint, ProjectWatcher, type QualityBenchmarkResult, type QualityGateCheck, type QualityGateConfig, type QualityGateResult, type QualityMetrics, type ReviewFactor, type ReviewFile, type ReviewOptions, type ReviewQuality, type ReviewResult, type ScoreInsight, type SelectionInput, type SemanticAnalysis, type SemanticDomain, type SemanticFingerprint, type StrategyResult, type TeamFeedbackExport, type WatcherOptions, analyzeForReview, analyzeMonorepo, analyzeProject, analyzeSemantics, bfsBidirectional, buildAdjacencyList, buildProjectGraph, calculateCoverage, classifyFileKind, computeContextScore, computeFingerprint, configureCache, countTokensChars4, countTokensTiktoken, createLogger, createProject, detectMonorepoTool, detectStack, estimateFileTokens, estimateTokens, exportFeedbackForTeam, freeEncoder, generatePRContext, getActiveWatchers, getCTODir, getCacheStats, getCachedAnalysis, getConfigPath, getCrossRepoStats, getFeedbackBoosts, getModelStats, getPolicyPath, getPredictorBoosts, getPruneLevelForRisk, importTeamFeedback, initProjectConfig, invalidateCache, isCtoError, loadBaseline, loadConfig, loadFeedbackModel, loadGlobalModel, loadModel, loadPolicyFromYAML, matchGlob, optimizeBudget, optimizeForModels, predictFromCrossRepo, predictRelevantFiles, pruneFile, pruneFiles, recordCrossRepoSelection, recordFeedback, recordSelection, renderBenchmark, renderCompilabilityBenchmark, renderCompileProof, renderContextScore, renderCrossRepoReport, renderFeedbackReport, renderMonorepoAnalysis, renderMultiModelResult, renderPackageContext, renderQualityBenchmark, renderReviewSummary, renderSemanticAnalysis, runBenchmark, runCompilabilityBenchmark, runCompileProof, runQualityBenchmark, runQualityGate, saveBaseline, saveConfig, scoreAllFiles, scoreFile, selectContext, selectPackageContext, semanticBoosts, setJsonLogging, setLogLevel, unwatchAll, unwatchProject, walkProject, watchProject, wilsonLowerBound, wrapError };