@aipanel/core 1.3.4 → 1.3.6

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.
@@ -1,8 +1,9 @@
1
+ import { type DiagnosticsPhase, type DiagnosticsPolicy } from "../common/diagnostics";
1
2
  /** 是否为可诊断的源码文件(供宿主钩子过滤 edit/write 目标) */
2
3
  export declare function isJsFile(filePath: string): boolean;
3
4
  /**
4
5
  * run_diagnostics 工具描述(单一来源,供 opencode / dsh 两侧插件引用):
5
- * 只声明能力与支持的文件类型,不涉及内部使用的检查工具。
6
+ * 只声明能力与支持的文件类型,不涉及内部使用的检查工具(检查来源由用户配置,可能是项目命令)。
6
7
  */
7
8
  export declare const DIAGNOSTICS_TOOL_DESCRIPTION: string;
8
9
  /** LSP 风格诊断项(供宿主写入 metadata.diagnostics 等结构化输出) */
@@ -33,18 +34,7 @@ export interface TscResult {
33
34
  export interface EslintOutput {
34
35
  text?: string;
35
36
  diagnostics?: DiagnosticItem[];
36
- /** 实际运行的 lint 引擎("ESLint" / "oxlint");缺省视为 ESLint(兼容旧调用方) */
37
- engines?: string[];
38
37
  }
39
- export interface DiagnosticsResult {
40
- eslintOutput: EslintOutput;
41
- tscOutput: TscResult;
42
- }
43
- /**
44
- * ESLint 检查,接受文件路径或 glob 模式。
45
- * 结果按 error / warning 分级格式化;warnings 数量超限时截断并注明。
46
- */
47
- export declare function lintFiles(pattern: string, cwd: string, warnLimit?: number): Promise<EslintOutput>;
48
38
  /** 从文件路径向上查找最近的 tsconfig.json 所在目录 */
49
39
  export declare function findTsconfigDir(filePath: string): string | null;
50
40
  /** 在工作区子目录中查找 tsconfig.json(不包括根目录;调用方已处理根目录场景) */
@@ -58,34 +48,62 @@ export declare function runTypeCheck(filePath: string | undefined, cwd: string):
58
48
  * 一次编辑批次里的 N 个文件因此从 N 次项目构建降到 1 次。
59
49
  */
60
50
  export declare function runTypeChecksForFiles(files: string[], cwd: string): Promise<Map<string, TscResult>>;
61
- /** 并行运行 ESLint + 类型检查(单文件或 glob) */
62
- export declare function runAllChecks(pattern: string, cwd: string): Promise<DiagnosticsResult>;
63
- /**
64
- * 批量运行 ESLint + 类型检查:Lint 逐文件(ESLint 进程内、oxlint 单次 CLI),
65
- * 类型检查按 tsconfig 项目合并为一次(见 runTypeChecksForFiles)。
66
- * 返回"文件绝对路径 → 诊断结果",供 step 边界的一次性收尾诊断使用。
67
- */
68
- export declare function runAllChecksForFiles(files: string[], cwd: string): Promise<Map<string, DiagnosticsResult>>;
69
- /**
70
- * 全量项目诊断:优先从根 tsconfig 运行一次类型检查 --build,
71
- * 根无 tsconfig 时回退到逐个子目录 build;ESLint 以 "." 全量扫描。
72
- */
73
- export declare function runProjectDiagnostics(workspace: string): Promise<DiagnosticsResult>;
51
+ /** 诊断分区:一个检查在一段目标上的产出 */
52
+ export interface DiagnosticsSection {
53
+ /** 分区标题:check 的 name,或内置引擎标题(ESLint + oxlint / vue-tsc) */
54
+ name: string;
55
+ /** 所属目标文件(相对项目根);仅编辑后自动诊断按文件拆分时存在 */
56
+ target?: string;
57
+ /** 模型可见正文;无内容时缺省(自动诊断据此跳过该分区) */
58
+ text?: string;
59
+ /** LSP 坐标结构化条目(0-based),供 canonical 输出与诊断卡片使用 */
60
+ diagnostics: DiagnosticItem[];
61
+ }
62
+ /** 诊断结果:有序分区列表(历史上是写死的 { eslintOutput, tscOutput },现已泛化) */
63
+ export interface DiagnosticsResult {
64
+ sections: DiagnosticsSection[];
65
+ }
66
+ /** 诊断目标:agent 调工具(单文件 / 全量)或编辑后自动诊断(本步编辑过的文件) */
67
+ export type DiagnosticsTarget = {
68
+ kind: "file";
69
+ file: string;
70
+ cwd: string;
71
+ } | {
72
+ kind: "project";
73
+ cwd: string;
74
+ } | {
75
+ kind: "edited";
76
+ files: string[];
77
+ cwd: string;
78
+ };
79
+ /** 渲染选项 */
80
+ export interface RenderDiagnosticsOptions {
81
+ /** 只输出有发现的分区(编辑后自动诊断;全空返回空串) */
82
+ onlyFindings?: boolean;
83
+ /** 每个分区的发现条数上限(超出折叠成一行提示) */
84
+ maxFindingsPerSection?: number;
85
+ }
86
+ /** 类型检查分区标题(单一来源:跟随实际引擎 tsc / vue-tsc) */
74
87
  /** 类型检查分区标题(单一来源:跟随实际引擎 tsc / vue-tsc) */
75
88
  export declare function tscSectionTitle(tscOutput: TscResult): string;
76
- /** Lint 分区标题(单一来源:跟随实际运行的引擎组合,如 "ESLint + oxlint") */
77
- export declare function lintSectionTitle(lintOutput: EslintOutput): string;
78
89
  /** 分区发现被条数上限折叠时的提示(自动诊断摘要与 run_diagnostics 完整输出的分界) */
79
90
  export declare function omittedFindingsHint(omitted: number): string;
80
91
  /**
81
- * 组装统一的分区诊断文本(Lint / 类型检查)。
82
- * 默认保留空分区的占位文案(run_diagnostics 要正面回答"有没有问题");
92
+ * 诊断深入口:按策略与阶段执行配置的检查,返回有序分区。
93
+ *
94
+ * 三类检查:`typecheck`(引擎级内置)、内置 linter 预设(展开成 CommandCheck)、
95
+ * 用户自定义检查——后两类走**完全同一条**执行与适配逻辑。
96
+ * 检查按声明顺序串行执行,输出顺序确定、进程数可控;
97
+ * `severity` 门槛在分区归一化处生效,文本与结构化条目一起收紧。
98
+ */
99
+ export declare function runDiagnostics(target: DiagnosticsTarget, policy: DiagnosticsPolicy, phase: DiagnosticsPhase): Promise<DiagnosticsResult>;
100
+ /** 汇总结构化条目(canonical 输出 / 诊断卡片用) */
101
+ export declare function collectDiagnostics(result: DiagnosticsResult): DiagnosticItem[];
102
+ /**
103
+ * 把分区结果渲染成模型可见文本。
83
104
  * `onlyFindings: true` 只输出有发现的分区、全空返回空串(编辑后自动诊断不刷占位噪音);
84
105
  * `maxFindingsPerSection` 把每个分区的发现折叠成有界摘要——编辑后自动诊断每个 step 都会投递,
85
106
  * 因此用条数上限控制重复成本,完整结果仍由不带上限的 run_diagnostics 给出。
86
- * `title` 允许为空串,此时直接返回分区正文(追加式投递场景无需标题)。
107
+ * 编辑后自动诊断(分区带 target)保留 `### 文件` 结构。
87
108
  */
88
- export declare function formatDiagnosticsSections(title: string, eslintOutput: EslintOutput, tscOutput: TscResult, options?: {
89
- onlyFindings?: boolean;
90
- maxFindingsPerSection?: number;
91
- }): string;
109
+ export declare function renderDiagnostics(result: DiagnosticsResult, options?: RenderDiagnosticsOptions): string;
package/lib/node.cjs CHANGED
@@ -15,6 +15,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
15
  var node_exports = {};
16
16
  module.exports = __toCommonJS(node_exports);
17
17
  __reExport(node_exports, require("./common/constants.cjs"), module.exports);
18
+ __reExport(node_exports, require("./common/diagnostics.cjs"), module.exports);
18
19
  __reExport(node_exports, require("./common/logger-core.cjs"), module.exports);
19
20
  __reExport(node_exports, require("./node/node-logger.cjs"), module.exports);
20
21
  __reExport(node_exports, require("./node/process-logger.cjs"), module.exports);
@@ -24,6 +25,7 @@ __reExport(node_exports, require("./node/diagnostics.cjs"), module.exports);
24
25
  // Annotate the CommonJS export names for ESM import in node:
25
26
  0 && (module.exports = {
26
27
  ...require("./common/constants.cjs"),
28
+ ...require("./common/diagnostics.cjs"),
27
29
  ...require("./common/logger-core.cjs"),
28
30
  ...require("./node/node-logger.cjs"),
29
31
  ...require("./node/process-logger.cjs"),
package/lib/node.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./common/constants";
2
+ export * from "./common/diagnostics";
2
3
  export * from "./common/logger-core";
3
4
  export * from "./node/node-logger";
4
5
  export * from "./node/process-logger";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/core",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "main": "lib/index.cjs",