qat-cli 0.3.3 → 0.3.5

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.
package/dist/index.d.cts CHANGED
@@ -32,6 +32,11 @@ interface SourceAnalysisSummary {
32
32
  methods?: string[];
33
33
  /** computed 属性 */
34
34
  computed?: string[];
35
+ /** import 依赖的一跳签名(仅项目内依赖) */
36
+ importSignatures?: Array<{
37
+ source: string;
38
+ signatures: Record<string, string>;
39
+ }>;
35
40
  }
36
41
  /** AI 生成测试请求 */
37
42
  interface AIGenerateTestRequest {
@@ -736,6 +741,18 @@ declare class OpenAICompatibleProvider implements AIProvider {
736
741
  latencyMs?: number;
737
742
  }>;
738
743
  private chat;
744
+ /**
745
+ * 读取 SSE 流式响应,实时输出内容
746
+ */
747
+ private readStream;
748
+ /**
749
+ * 压缩源码:保留签名和关键逻辑,剔除注释、空行、样式块
750
+ * 目标:在保留准确性的前提下减少 token 消耗
751
+ * @param code 源码内容
752
+ * @param maxLength 最大长度
753
+ * @param importPathRewrites import 路径重写映射(原路径→正确路径)
754
+ */
755
+ private compressSourceCode;
739
756
  private buildGenerateTestSystemPrompt;
740
757
  private buildGenerateTestUserPrompt;
741
758
  /**
@@ -743,9 +760,15 @@ declare class OpenAICompatibleProvider implements AIProvider {
743
760
  */
744
761
  private computeTestImportPath;
745
762
  /**
746
- * 获取测试输出目录
763
+ * 构建 import 路径重写映射
764
+ * 将源码中可能引用自身的各种写法,映射到测试文件中正确的导入路径
747
765
  */
748
- private getTestOutputDir;
766
+ private buildImportPathRewrites;
767
+ /**
768
+ * 重写源码中的 import 路径
769
+ * 将 from 'oldPath' / from "oldPath" 替换为正确的路径
770
+ */
771
+ private rewriteImportPaths;
749
772
  private parseGenerateTestResponse;
750
773
  private buildReviewTestSystemPrompt;
751
774
  private buildReviewTestUserPrompt;
@@ -961,12 +984,34 @@ interface APICallInfo {
961
984
  /** 来源文件 */
962
985
  sourceFile: string;
963
986
  }
987
+ /** import 语句信息 */
988
+ interface ImportInfo {
989
+ /** 导入的名称列表 */
990
+ names: string[];
991
+ /** 来源模块路径 */
992
+ source: string;
993
+ /** 是否是默认导入 */
994
+ isDefault: boolean;
995
+ /** 是否是命名空间导入 (import * as) */
996
+ isNamespace: boolean;
997
+ }
998
+ /** import 依赖的一跳签名摘要 */
999
+ interface ImportSignature {
1000
+ /** 来源模块路径 */
1001
+ source: string;
1002
+ /** 导入名称 → 签名(类型/参数等) */
1003
+ signatures: Record<string, string>;
1004
+ }
964
1005
  /** TS/JS 文件分析结果 */
965
1006
  interface ModuleAnalysis {
966
1007
  /** 文件路径 */
967
1008
  filePath: string;
968
1009
  /** 导出项列表 */
969
1010
  exports: ExportInfo[];
1011
+ /** import 语句列表 */
1012
+ imports: ImportInfo[];
1013
+ /** import 依赖的一跳签名摘要 */
1014
+ importSignatures: ImportSignature[];
970
1015
  /** Vue 组件分析(仅 .vue 文件) */
971
1016
  vueAnalysis?: VueComponentAnalysis;
972
1017
  /** 发现的 API 调用 */
@@ -999,4 +1044,4 @@ interface MockRouteCandidate {
999
1044
  sourceFile: string;
1000
1045
  }
1001
1046
 
1002
- export { type AIAnalyzeResultRequest, type AIAnalyzeResultResponse, type AICapability, type AIConfig, type AIGenerateTestRequest, type AIGenerateTestResponse, type AIPresetProvider, type AIProvider, type AIProviderConstructor, AI_PRESET_PROVIDERS, type APICallInfo, type ComponentTestSetup, type CoverageResult, type CreateOptions, DEFAULT_CONFIG, type DetectContext, type DiffResult, type EmitInfo, type ExportInfo, type ExportKind, type FrameworkDefinition, type FrameworkDetectResult, type FrameworkType, type GlobalOptions, type InitOptions, type LighthouseRunnerOptions, type LoadExternalFrameworksResult, type MockOptions, type MockRoute, type MockRouteCandidate, type MockServerState, type ModuleAnalysis, type MonorepoType, NoopAIProvider, OpenAICompatibleProvider, type PerformanceMetrics, type PlaywrightRunnerOptions, type ProjectInfo, type PropInfo, type QATConfig, type ReportData, type ReportOptions, type RunOptions, type SetupOptions, type SourceAnalysisSummary, type TemplateContext, type TestCaseResult, type TestError, type TestRunResult, type TestStatus, type TestSuiteResult, type TestType, type UILibrary, type VisualOptions, type VitestRunnerOptions, type VueComponentAnalysis, aggregateResults, analyzeFile, analyzeFiles, cleanBaselines, cleanDiffs, clearConfigCache, compareDirectories, compareImages, createBaseline, createDefaultRoutes, defineConfig, detectFramework, detectMonorepo, detectProject, detectUILibrary, discoverAppDirs, discoverUtilityFiles, discoverVueComponents, generateConfigFile, generateHTMLReport, generateMockRouteTemplate, generateMockRoutesFromAPICalls, generateTestFile, getAIProvider, getMockServerState, getRegisteredFrameworks, getRegisteredProviders, initMockRoutesDir, isAIAvailable, listBaselines, listDiffs, loadConfig, loadExternalFrameworks, loadMockRoutes, registerAIProvider, registerFramework, registerTemplate, renderTemplate, resetAIProvider, resetRegistry, runLighthouse, runPlaywright, runVitest, scanAPICalls, startMockServer, stopMockServer, testAIConnection, updateAllBaselines, updateBaseline, validateConfig, writeConfigFile, writeReportToDisk };
1047
+ export { type AIAnalyzeResultRequest, type AIAnalyzeResultResponse, type AICapability, type AIConfig, type AIGenerateTestRequest, type AIGenerateTestResponse, type AIPresetProvider, type AIProvider, type AIProviderConstructor, AI_PRESET_PROVIDERS, type APICallInfo, type ComponentTestSetup, type CoverageResult, type CreateOptions, DEFAULT_CONFIG, type DetectContext, type DiffResult, type EmitInfo, type ExportInfo, type ExportKind, type FrameworkDefinition, type FrameworkDetectResult, type FrameworkType, type GlobalOptions, type ImportInfo, type ImportSignature, type InitOptions, type LighthouseRunnerOptions, type LoadExternalFrameworksResult, type MockOptions, type MockRoute, type MockRouteCandidate, type MockServerState, type ModuleAnalysis, type MonorepoType, NoopAIProvider, OpenAICompatibleProvider, type PerformanceMetrics, type PlaywrightRunnerOptions, type ProjectInfo, type PropInfo, type QATConfig, type ReportData, type ReportOptions, type RunOptions, type SetupOptions, type SourceAnalysisSummary, type TemplateContext, type TestCaseResult, type TestError, type TestRunResult, type TestStatus, type TestSuiteResult, type TestType, type UILibrary, type VisualOptions, type VitestRunnerOptions, type VueComponentAnalysis, aggregateResults, analyzeFile, analyzeFiles, cleanBaselines, cleanDiffs, clearConfigCache, compareDirectories, compareImages, createBaseline, createDefaultRoutes, defineConfig, detectFramework, detectMonorepo, detectProject, detectUILibrary, discoverAppDirs, discoverUtilityFiles, discoverVueComponents, generateConfigFile, generateHTMLReport, generateMockRouteTemplate, generateMockRoutesFromAPICalls, generateTestFile, getAIProvider, getMockServerState, getRegisteredFrameworks, getRegisteredProviders, initMockRoutesDir, isAIAvailable, listBaselines, listDiffs, loadConfig, loadExternalFrameworks, loadMockRoutes, registerAIProvider, registerFramework, registerTemplate, renderTemplate, resetAIProvider, resetRegistry, runLighthouse, runPlaywright, runVitest, scanAPICalls, startMockServer, stopMockServer, testAIConnection, updateAllBaselines, updateBaseline, validateConfig, writeConfigFile, writeReportToDisk };
package/dist/index.d.ts CHANGED
@@ -32,6 +32,11 @@ interface SourceAnalysisSummary {
32
32
  methods?: string[];
33
33
  /** computed 属性 */
34
34
  computed?: string[];
35
+ /** import 依赖的一跳签名(仅项目内依赖) */
36
+ importSignatures?: Array<{
37
+ source: string;
38
+ signatures: Record<string, string>;
39
+ }>;
35
40
  }
36
41
  /** AI 生成测试请求 */
37
42
  interface AIGenerateTestRequest {
@@ -736,6 +741,18 @@ declare class OpenAICompatibleProvider implements AIProvider {
736
741
  latencyMs?: number;
737
742
  }>;
738
743
  private chat;
744
+ /**
745
+ * 读取 SSE 流式响应,实时输出内容
746
+ */
747
+ private readStream;
748
+ /**
749
+ * 压缩源码:保留签名和关键逻辑,剔除注释、空行、样式块
750
+ * 目标:在保留准确性的前提下减少 token 消耗
751
+ * @param code 源码内容
752
+ * @param maxLength 最大长度
753
+ * @param importPathRewrites import 路径重写映射(原路径→正确路径)
754
+ */
755
+ private compressSourceCode;
739
756
  private buildGenerateTestSystemPrompt;
740
757
  private buildGenerateTestUserPrompt;
741
758
  /**
@@ -743,9 +760,15 @@ declare class OpenAICompatibleProvider implements AIProvider {
743
760
  */
744
761
  private computeTestImportPath;
745
762
  /**
746
- * 获取测试输出目录
763
+ * 构建 import 路径重写映射
764
+ * 将源码中可能引用自身的各种写法,映射到测试文件中正确的导入路径
747
765
  */
748
- private getTestOutputDir;
766
+ private buildImportPathRewrites;
767
+ /**
768
+ * 重写源码中的 import 路径
769
+ * 将 from 'oldPath' / from "oldPath" 替换为正确的路径
770
+ */
771
+ private rewriteImportPaths;
749
772
  private parseGenerateTestResponse;
750
773
  private buildReviewTestSystemPrompt;
751
774
  private buildReviewTestUserPrompt;
@@ -961,12 +984,34 @@ interface APICallInfo {
961
984
  /** 来源文件 */
962
985
  sourceFile: string;
963
986
  }
987
+ /** import 语句信息 */
988
+ interface ImportInfo {
989
+ /** 导入的名称列表 */
990
+ names: string[];
991
+ /** 来源模块路径 */
992
+ source: string;
993
+ /** 是否是默认导入 */
994
+ isDefault: boolean;
995
+ /** 是否是命名空间导入 (import * as) */
996
+ isNamespace: boolean;
997
+ }
998
+ /** import 依赖的一跳签名摘要 */
999
+ interface ImportSignature {
1000
+ /** 来源模块路径 */
1001
+ source: string;
1002
+ /** 导入名称 → 签名(类型/参数等) */
1003
+ signatures: Record<string, string>;
1004
+ }
964
1005
  /** TS/JS 文件分析结果 */
965
1006
  interface ModuleAnalysis {
966
1007
  /** 文件路径 */
967
1008
  filePath: string;
968
1009
  /** 导出项列表 */
969
1010
  exports: ExportInfo[];
1011
+ /** import 语句列表 */
1012
+ imports: ImportInfo[];
1013
+ /** import 依赖的一跳签名摘要 */
1014
+ importSignatures: ImportSignature[];
970
1015
  /** Vue 组件分析(仅 .vue 文件) */
971
1016
  vueAnalysis?: VueComponentAnalysis;
972
1017
  /** 发现的 API 调用 */
@@ -999,4 +1044,4 @@ interface MockRouteCandidate {
999
1044
  sourceFile: string;
1000
1045
  }
1001
1046
 
1002
- export { type AIAnalyzeResultRequest, type AIAnalyzeResultResponse, type AICapability, type AIConfig, type AIGenerateTestRequest, type AIGenerateTestResponse, type AIPresetProvider, type AIProvider, type AIProviderConstructor, AI_PRESET_PROVIDERS, type APICallInfo, type ComponentTestSetup, type CoverageResult, type CreateOptions, DEFAULT_CONFIG, type DetectContext, type DiffResult, type EmitInfo, type ExportInfo, type ExportKind, type FrameworkDefinition, type FrameworkDetectResult, type FrameworkType, type GlobalOptions, type InitOptions, type LighthouseRunnerOptions, type LoadExternalFrameworksResult, type MockOptions, type MockRoute, type MockRouteCandidate, type MockServerState, type ModuleAnalysis, type MonorepoType, NoopAIProvider, OpenAICompatibleProvider, type PerformanceMetrics, type PlaywrightRunnerOptions, type ProjectInfo, type PropInfo, type QATConfig, type ReportData, type ReportOptions, type RunOptions, type SetupOptions, type SourceAnalysisSummary, type TemplateContext, type TestCaseResult, type TestError, type TestRunResult, type TestStatus, type TestSuiteResult, type TestType, type UILibrary, type VisualOptions, type VitestRunnerOptions, type VueComponentAnalysis, aggregateResults, analyzeFile, analyzeFiles, cleanBaselines, cleanDiffs, clearConfigCache, compareDirectories, compareImages, createBaseline, createDefaultRoutes, defineConfig, detectFramework, detectMonorepo, detectProject, detectUILibrary, discoverAppDirs, discoverUtilityFiles, discoverVueComponents, generateConfigFile, generateHTMLReport, generateMockRouteTemplate, generateMockRoutesFromAPICalls, generateTestFile, getAIProvider, getMockServerState, getRegisteredFrameworks, getRegisteredProviders, initMockRoutesDir, isAIAvailable, listBaselines, listDiffs, loadConfig, loadExternalFrameworks, loadMockRoutes, registerAIProvider, registerFramework, registerTemplate, renderTemplate, resetAIProvider, resetRegistry, runLighthouse, runPlaywright, runVitest, scanAPICalls, startMockServer, stopMockServer, testAIConnection, updateAllBaselines, updateBaseline, validateConfig, writeConfigFile, writeReportToDisk };
1047
+ export { type AIAnalyzeResultRequest, type AIAnalyzeResultResponse, type AICapability, type AIConfig, type AIGenerateTestRequest, type AIGenerateTestResponse, type AIPresetProvider, type AIProvider, type AIProviderConstructor, AI_PRESET_PROVIDERS, type APICallInfo, type ComponentTestSetup, type CoverageResult, type CreateOptions, DEFAULT_CONFIG, type DetectContext, type DiffResult, type EmitInfo, type ExportInfo, type ExportKind, type FrameworkDefinition, type FrameworkDetectResult, type FrameworkType, type GlobalOptions, type ImportInfo, type ImportSignature, type InitOptions, type LighthouseRunnerOptions, type LoadExternalFrameworksResult, type MockOptions, type MockRoute, type MockRouteCandidate, type MockServerState, type ModuleAnalysis, type MonorepoType, NoopAIProvider, OpenAICompatibleProvider, type PerformanceMetrics, type PlaywrightRunnerOptions, type ProjectInfo, type PropInfo, type QATConfig, type ReportData, type ReportOptions, type RunOptions, type SetupOptions, type SourceAnalysisSummary, type TemplateContext, type TestCaseResult, type TestError, type TestRunResult, type TestStatus, type TestSuiteResult, type TestType, type UILibrary, type VisualOptions, type VitestRunnerOptions, type VueComponentAnalysis, aggregateResults, analyzeFile, analyzeFiles, cleanBaselines, cleanDiffs, clearConfigCache, compareDirectories, compareImages, createBaseline, createDefaultRoutes, defineConfig, detectFramework, detectMonorepo, detectProject, detectUILibrary, discoverAppDirs, discoverUtilityFiles, discoverVueComponents, generateConfigFile, generateHTMLReport, generateMockRouteTemplate, generateMockRoutesFromAPICalls, generateTestFile, getAIProvider, getMockServerState, getRegisteredFrameworks, getRegisteredProviders, initMockRoutesDir, isAIAvailable, listBaselines, listDiffs, loadConfig, loadExternalFrameworks, loadMockRoutes, registerAIProvider, registerFramework, registerTemplate, renderTemplate, resetAIProvider, resetRegistry, runLighthouse, runPlaywright, runVitest, scanAPICalls, startMockServer, stopMockServer, testAIConnection, updateAllBaselines, updateBaseline, validateConfig, writeConfigFile, writeReportToDisk };