@dependfix/engine 0.3.0 → 0.4.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.
- package/README.md +3 -0
- package/dist/auth-provider.d.mts +82 -0
- package/dist/auth.d.mts +184 -0
- package/dist/auth.mjs +3 -0
- package/dist/auth2.mjs +361 -0
- package/dist/auth2.mjs.map +1 -0
- package/dist/index.d.mts +306 -184
- package/dist/index.mjs +372 -206
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { i as FromPatParams, n as AuthProviderOptions, r as FromAppParams, t as AuthProvider } from "./auth-provider.mjs";
|
|
1
2
|
import { Octokit } from "@octokit/rest";
|
|
2
3
|
import { AlertClass, AlertSeverity, AlertSourceKind, AppError, FixAction, FixError, Logger, NormalizedSecurityAlert, RepositoryResult, RunResult, RunSummary, SeverityThreshold, createEmptyRunSummary } from "@dependfix/core";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
//#region src/github/client.d.ts
|
|
5
|
-
interface RetryPolicyOptions {
|
|
6
|
+
export interface RetryPolicyOptions {
|
|
6
7
|
/** 最大重试次数(默认 3;0 = 不重试) */
|
|
7
8
|
maxRetries?: number;
|
|
8
9
|
/** 指数退避基数毫秒(默认 1000;测试时可调小) */
|
|
@@ -13,9 +14,25 @@ interface RetryPolicyOptions {
|
|
|
13
14
|
*/
|
|
14
15
|
maxBackoffMs?: number;
|
|
15
16
|
}
|
|
16
|
-
interface OctokitClientOptions {
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
export interface OctokitClientOptions {
|
|
18
|
+
/**
|
|
19
|
+
* 认证抽象层(M18.1 实施后唯一推荐入口)。
|
|
20
|
+
*
|
|
21
|
+
* 调用方应通过 `fromPat(token)` 或 `fromApp(params)` 构造;
|
|
22
|
+
* 优先使用此字段,新代码不得使用 deprecated 的 `token` 字段。
|
|
23
|
+
*
|
|
24
|
+
* @see {@link ../auth/auth-provider} AuthProvider 接口定义
|
|
25
|
+
* @see [C22 PAT 无感升级评估 §4.2 AuthProvider 接口设计](../../../../docs/design/governance/c22-pat-backward-compat.md)
|
|
26
|
+
*/
|
|
27
|
+
auth?: AuthProvider;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated 使用 `auth` 替代。
|
|
30
|
+
*
|
|
31
|
+
* 保留作为低层入口;`token` 路径与 `auth: fromPat(token)` 行为等价
|
|
32
|
+
* (共享同一 retry policy 与限流重试 hook)。
|
|
33
|
+
* 计划在 M19+ 评估移除。
|
|
34
|
+
*/
|
|
35
|
+
token?: string;
|
|
19
36
|
/**
|
|
20
37
|
* API 基地址。
|
|
21
38
|
* 默认 `https://api.github.com`。
|
|
@@ -27,6 +44,10 @@ interface OctokitClientOptions {
|
|
|
27
44
|
* 默认 maxRetries=3。对 429、primary rate limit(403 + x-ratelimit-remaining: 0)、
|
|
28
45
|
* secondary rate limit(403/429 带 secondary/abuse/retry 特征)自动退避重试;
|
|
29
46
|
* 权限类 403 不重试。
|
|
47
|
+
*
|
|
48
|
+
* 行为由具体 AuthProvider 实现决定:
|
|
49
|
+
* - `PatAuthProvider` 委托给本函数(`createGitHubClient({ token, retry })`)—— retry 字段透传生效
|
|
50
|
+
* - `AppAuthProvider` 自管 retry(commit 4 实施)
|
|
30
51
|
*/
|
|
31
52
|
retry?: RetryPolicyOptions;
|
|
32
53
|
}
|
|
@@ -41,6 +62,11 @@ interface OctokitClientOptions {
|
|
|
41
62
|
*
|
|
42
63
|
* @example
|
|
43
64
|
* ```typescript
|
|
65
|
+
* // 推荐:使用 auth 抽象层(M18.1 实施后)
|
|
66
|
+
* import { fromPat } from '@dependfix/engine/auth'
|
|
67
|
+
* const octokit = createGitHubClient({ auth: fromPat('ghp_xxxx') })
|
|
68
|
+
*
|
|
69
|
+
* // 向后兼容:使用 token 字段(deprecated)
|
|
44
70
|
* const octokit = createGitHubClient({ token: 'ghp_xxxx' })
|
|
45
71
|
*
|
|
46
72
|
* // 仓库信息
|
|
@@ -53,7 +79,7 @@ interface OctokitClientOptions {
|
|
|
53
79
|
* )
|
|
54
80
|
* ```
|
|
55
81
|
*/
|
|
56
|
-
declare function createGitHubClient(options: OctokitClientOptions): Octokit;
|
|
82
|
+
export declare function createGitHubClient(options: OctokitClientOptions): Octokit;
|
|
57
83
|
/**
|
|
58
84
|
* 计算限流重试等待时间(纯函数,可单测)。
|
|
59
85
|
*
|
|
@@ -73,10 +99,10 @@ declare function createGitHubClient(options: OctokitClientOptions): Octokit;
|
|
|
73
99
|
* - 权限类 403(无限流特征)
|
|
74
100
|
* - 其他状态码
|
|
75
101
|
*/
|
|
76
|
-
declare function computeRetryDelayMs(error: unknown, attempt: number, baseDelayMs?: number, maxBackoffMs?: number): number | null;
|
|
102
|
+
export declare function computeRetryDelayMs(error: unknown, attempt: number, baseDelayMs?: number, maxBackoffMs?: number): number | null;
|
|
77
103
|
//#endregion
|
|
78
104
|
//#region src/github/code-quality-fetcher.d.ts
|
|
79
|
-
interface FetchCodeQualityFindingsParams {
|
|
105
|
+
export interface FetchCodeQualityFindingsParams {
|
|
80
106
|
/** 仓库所属组织或用户 */
|
|
81
107
|
owner: string;
|
|
82
108
|
/** 仓库名称 */
|
|
@@ -104,7 +130,7 @@ interface FetchCodeQualityFindingsParams {
|
|
|
104
130
|
* @param params - 仓库标识与过滤参数
|
|
105
131
|
* @returns 标准化告警列表
|
|
106
132
|
*/
|
|
107
|
-
declare function fetchCodeQualityFindings(client: Octokit, params: FetchCodeQualityFindingsParams): Promise<NormalizedSecurityAlert[]>;
|
|
133
|
+
export declare function fetchCodeQualityFindings(client: Octokit, params: FetchCodeQualityFindingsParams): Promise<NormalizedSecurityAlert[]>;
|
|
108
134
|
/**
|
|
109
135
|
* 映射 Code Quality severity:
|
|
110
136
|
* - `error` → `high`(语义对齐 code-scanning 映射:error 表示需立即关注)
|
|
@@ -115,10 +141,10 @@ declare function fetchCodeQualityFindings(client: Octokit, params: FetchCodeQual
|
|
|
115
141
|
* 与 code-scanning 共用 `error/warning/note` 值域(GitHub CodeQL 规则同源),
|
|
116
142
|
* 映射口径与 `mapCodeScanningSeverity` 对齐(避免新源不一致)。
|
|
117
143
|
*/
|
|
118
|
-
declare function mapCodeQualitySeverity(severity: string | null | undefined): AlertSeverity;
|
|
144
|
+
export declare function mapCodeQualitySeverity(severity: string | null | undefined): AlertSeverity;
|
|
119
145
|
//#endregion
|
|
120
146
|
//#region src/github/code-scanning-fetcher.d.ts
|
|
121
|
-
interface FetchCodeScanningAlertsParams {
|
|
147
|
+
export interface FetchCodeScanningAlertsParams {
|
|
122
148
|
/** 仓库所属组织或用户 */
|
|
123
149
|
owner: string;
|
|
124
150
|
/** 仓库名称 */
|
|
@@ -147,10 +173,10 @@ interface FetchCodeScanningAlertsParams {
|
|
|
147
173
|
* @param params - 仓库标识与过滤参数
|
|
148
174
|
* @returns 标准化告警列表
|
|
149
175
|
*/
|
|
150
|
-
declare function fetchCodeScanningAlerts(client: Octokit, params: FetchCodeScanningAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
176
|
+
export declare function fetchCodeScanningAlerts(client: Octokit, params: FetchCodeScanningAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
151
177
|
//#endregion
|
|
152
178
|
//#region src/github/dependabot-fetcher.d.ts
|
|
153
|
-
interface FetchDependabotAlertsParams {
|
|
179
|
+
export interface FetchDependabotAlertsParams {
|
|
154
180
|
/** 仓库所属组织或用户 */
|
|
155
181
|
owner: string;
|
|
156
182
|
/** 仓库名称 */
|
|
@@ -177,11 +203,16 @@ interface FetchDependabotAlertsParams {
|
|
|
177
203
|
*
|
|
178
204
|
* @example
|
|
179
205
|
* ```typescript
|
|
180
|
-
*
|
|
206
|
+
* // 推荐:使用 auth 抽象层(M18.1 实施后)
|
|
207
|
+
* import { fromPat } from '@dependfix/engine/auth'
|
|
208
|
+
* const octokit = createGitHubClient({ auth: fromPat('ghp_xxxx') })
|
|
181
209
|
* const alerts = await fetchDependabotAlerts(octokit, { owner: 'foo', repo: 'bar' })
|
|
210
|
+
*
|
|
211
|
+
* // 向后兼容:使用 token 字段(deprecated)
|
|
212
|
+
* const octokit = createGitHubClient({ token: 'ghp_xxxx' })
|
|
182
213
|
* ```
|
|
183
214
|
*/
|
|
184
|
-
declare function fetchDependabotAlerts(client: Octokit, params: FetchDependabotAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
215
|
+
export declare function fetchDependabotAlerts(client: Octokit, params: FetchDependabotAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
185
216
|
//#endregion
|
|
186
217
|
//#region src/github/errors.d.ts
|
|
187
218
|
/**
|
|
@@ -190,10 +221,10 @@ declare function fetchDependabotAlerts(client: Octokit, params: FetchDependabotA
|
|
|
190
221
|
* @param error - 原始错误(`RequestError` 或网络异常)
|
|
191
222
|
* @param context - 调用上下文描述(如 `'fetch repo info for foo/bar'`),会附加到错误消息中
|
|
192
223
|
*/
|
|
193
|
-
declare function mapGitHubError(error: unknown, context: string): AppError;
|
|
224
|
+
export declare function mapGitHubError(error: unknown, context: string): AppError;
|
|
194
225
|
//#endregion
|
|
195
226
|
//#region src/github/pr-creator.d.ts
|
|
196
|
-
interface CreatePullRequestParams {
|
|
227
|
+
export interface CreatePullRequestParams {
|
|
197
228
|
/** 已认证的 Octokit 实例 */
|
|
198
229
|
octokit: Octokit;
|
|
199
230
|
/** 仓库 owner */
|
|
@@ -209,20 +240,20 @@ interface CreatePullRequestParams {
|
|
|
209
240
|
/** PR 内容(Markdown) */
|
|
210
241
|
body: string;
|
|
211
242
|
}
|
|
212
|
-
interface PullRequestResult {
|
|
243
|
+
export interface PullRequestResult {
|
|
213
244
|
/** PR 编号 */
|
|
214
245
|
number: number;
|
|
215
246
|
/** PR HTML URL */
|
|
216
247
|
htmlUrl: string;
|
|
217
248
|
}
|
|
218
|
-
interface FixBranchResult {
|
|
249
|
+
export interface FixBranchResult {
|
|
219
250
|
/** 分支名 */
|
|
220
251
|
branchName: string;
|
|
221
252
|
/** 是否为新创建 */
|
|
222
253
|
created: boolean;
|
|
223
254
|
}
|
|
224
255
|
/** dependfix 自动修复 PR 的公开信息(用于查重/取代判定) */
|
|
225
|
-
interface DependfixOpenPR {
|
|
256
|
+
export interface DependfixOpenPR {
|
|
226
257
|
/** PR 编号 */
|
|
227
258
|
number: number;
|
|
228
259
|
/** PR HTML URL */
|
|
@@ -245,15 +276,15 @@ interface DependfixOpenPR {
|
|
|
245
276
|
* 不用 diff hash 是因为 pnpm 版本等非确定性因素会使锁文件内容漂移,
|
|
246
277
|
* 导致"告警没变但指纹变"。
|
|
247
278
|
*/
|
|
248
|
-
declare function computeFixFingerprint(actions: FixAction[]): string;
|
|
279
|
+
export declare function computeFixFingerprint(actions: FixAction[]): string;
|
|
249
280
|
/**
|
|
250
281
|
* 从分支名提取内容指纹(`dependfix/auto-fix-{fp8}` → `{fp8}`)。
|
|
251
282
|
* 指纹格式为 8 位 hex;分支名不含 `-` 后的内容、前缀不匹配或格式不合法时返回 null
|
|
252
283
|
* (如旧版 runId 分支,会被 supersede)。
|
|
253
284
|
*/
|
|
254
|
-
declare function extractFingerprintFromBranch(branchName: string): string | null;
|
|
285
|
+
export declare function extractFingerprintFromBranch(branchName: string): string | null;
|
|
255
286
|
/** fix-and-pr 去重决策结果 */
|
|
256
|
-
interface FixAndPrPlan {
|
|
287
|
+
export interface FixAndPrPlan {
|
|
257
288
|
/** skip = 已有同内容 PR,不重复提交;create = 需要新建 PR */
|
|
258
289
|
action: 'skip' | 'create';
|
|
259
290
|
/** action=skip 时命中的同内容 PR */
|
|
@@ -266,7 +297,7 @@ interface FixAndPrPlan {
|
|
|
266
297
|
* - 存在同指纹 open PR → skip(仅需关闭其余异指纹 PR)
|
|
267
298
|
* - 否则 → create(关闭全部旧 PR,先建新后关旧由调用方保证)
|
|
268
299
|
*/
|
|
269
|
-
declare function computeFixAndPrPlan(existingPRs: DependfixOpenPR[], fingerprint: string): FixAndPrPlan;
|
|
300
|
+
export declare function computeFixAndPrPlan(existingPRs: DependfixOpenPR[], fingerprint: string): FixAndPrPlan;
|
|
270
301
|
/**
|
|
271
302
|
* 在工作目录创建修复分支。
|
|
272
303
|
*
|
|
@@ -275,18 +306,27 @@ declare function computeFixAndPrPlan(existingPRs: DependfixOpenPR[], fingerprint
|
|
|
275
306
|
*
|
|
276
307
|
* @returns 分支名和是否为新创建
|
|
277
308
|
*/
|
|
278
|
-
declare function createFixBranch(branchName: string, workDir: string): FixBranchResult;
|
|
309
|
+
export declare function createFixBranch(branchName: string, workDir: string): FixBranchResult;
|
|
279
310
|
/**
|
|
280
311
|
* 暂存所有变更并提交。
|
|
281
312
|
* 自动设置 git user.name / user.email(如未设置)。
|
|
282
313
|
* 使用 `execFileSync` 参数数组形式(不经 shell),保证多行 commit message
|
|
283
314
|
* 与 UTF-8 字符(如 →)在 Windows/Linux 双平台传递一致。
|
|
315
|
+
*
|
|
316
|
+
* W3 修复(M18.4 audit round 2):显式传 `-c user.name=X -c user.email=Y` 强制 commit author
|
|
317
|
+
* 使用传入值,不受 host 全局 `user.name`(如 CaoMeiYouRen)污染——`git commit` 走 lookup order
|
|
318
|
+
* (env → `-c` config → local → global → system),显式 `-c` 在 lookup order 中最高优先。
|
|
319
|
+
*
|
|
320
|
+
* @param author - 可选 commit author 信息;不传时使用 PAT 默认值(保持现有 PAT 路径行为零变化)。
|
|
321
|
+
* M18.2 之后 GitHub App 路径会传入动态生成的 `{app_id}+{bot_login}[bot]` author。
|
|
322
|
+
*
|
|
323
|
+
* @see [C22 PAT 无感升级评估 §5.1 兼容性](../../../../docs/design/governance/c22-pat-backward-compat.md)
|
|
284
324
|
*/
|
|
285
|
-
declare function stageAndCommit(message: string, workDir: string
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
declare function pushBranch(branchName: string, workDir: string): void;
|
|
325
|
+
export declare function stageAndCommit(message: string, workDir: string, author?: {
|
|
326
|
+
name: string;
|
|
327
|
+
email: string;
|
|
328
|
+
}): void;
|
|
329
|
+
export declare function pushBranch(branchName: string, workDir: string): void;
|
|
290
330
|
/**
|
|
291
331
|
* 查找目标仓库中所有 open 状态的 dependfix 自动修复 PR。
|
|
292
332
|
*
|
|
@@ -294,17 +334,35 @@ declare function pushBranch(branchName: string, workDir: string): void;
|
|
|
294
334
|
* 按 head 分支前缀 `dependfix/auto-fix-` 过滤。假设 PR 数量不多(单页 100 足够),
|
|
295
335
|
* 未来 PR 数量增大时可引入 label 索引(backlog 已登记演进项)。
|
|
296
336
|
*/
|
|
297
|
-
declare function findDependfixOpenPR(octokit: Octokit, owner: string, repo: string): Promise<DependfixOpenPR[]>;
|
|
337
|
+
export declare function findDependfixOpenPR(octokit: Octokit, owner: string, repo: string): Promise<DependfixOpenPR[]>;
|
|
298
338
|
/**
|
|
299
339
|
* 关闭 Pull Request(用于 supersede 旧 PR)。
|
|
300
340
|
*/
|
|
301
|
-
declare function closePullRequest(octokit: Octokit, owner: string, repo: string, pullNumber: number): Promise<void>;
|
|
341
|
+
export declare function closePullRequest(octokit: Octokit, owner: string, repo: string, pullNumber: number): Promise<void>;
|
|
342
|
+
/**
|
|
343
|
+
* 在 Pull Request 上添加评论。
|
|
344
|
+
*
|
|
345
|
+
* 使用 `issues.createComment` 端点(GitHub PR 评论复用 issue comment API),
|
|
346
|
+
* 需要 token 具备 `issues: write` 权限(比 `pull-requests: write` 宽)。
|
|
347
|
+
*
|
|
348
|
+
* 用于在新 PR 上评论指向被取代的旧 PR,避免用户手动排查重复 PR。
|
|
349
|
+
*/
|
|
350
|
+
export declare function commentOnPullRequest(octokit: Octokit, owner: string, repo: string, pullNumber: number, body: string): Promise<void>;
|
|
351
|
+
/**
|
|
352
|
+
* 在 Pull Request 上添加 label。
|
|
353
|
+
*
|
|
354
|
+
* 使用 `issues.addLabels` 端点(GitHub PR label 复用 issue label API),
|
|
355
|
+
* 需要 token 具备 `issues: write` 权限。
|
|
356
|
+
*
|
|
357
|
+
* 用于标记重复 PR(如 `duplicate` label),便于用户过滤和管理。
|
|
358
|
+
*/
|
|
359
|
+
export declare function addLabelToPullRequest(octokit: Octokit, owner: string, repo: string, pullNumber: number, labels: string[]): Promise<void>;
|
|
302
360
|
/**
|
|
303
361
|
* 通过 GitHub API 创建 Pull Request。
|
|
304
362
|
*/
|
|
305
|
-
declare function createPullRequest(params: CreatePullRequestParams): Promise<PullRequestResult>;
|
|
363
|
+
export declare function createPullRequest(params: CreatePullRequestParams): Promise<PullRequestResult>;
|
|
306
364
|
/** 分支清理状态(用于 cleanup-branches 清单分类) */
|
|
307
|
-
interface DependfixBranchStatus {
|
|
365
|
+
export interface DependfixBranchStatus {
|
|
308
366
|
/** 分支名 */
|
|
309
367
|
branch: string;
|
|
310
368
|
/** 关联 PR 编号(无 PR 记录时为 null) */
|
|
@@ -317,19 +375,19 @@ interface DependfixBranchStatus {
|
|
|
317
375
|
/**
|
|
318
376
|
* 列出远端所有 `dependfix/` 前缀分支(git.listMatchingRefs 精确前缀匹配)。
|
|
319
377
|
*/
|
|
320
|
-
declare function listDependfixBranches(octokit: Octokit, owner: string, repo: string): Promise<string[]>;
|
|
378
|
+
export declare function listDependfixBranches(octokit: Octokit, owner: string, repo: string): Promise<string[]>;
|
|
321
379
|
/**
|
|
322
380
|
* 查询分支对应的最近 PR 状态(pulls.list head 精确匹配,按最近更新取 1 条)。
|
|
323
381
|
*/
|
|
324
|
-
declare function getBranchPrStatus(octokit: Octokit, owner: string, repo: string, branch: string): Promise<DependfixBranchStatus>;
|
|
382
|
+
export declare function getBranchPrStatus(octokit: Octokit, owner: string, repo: string, branch: string): Promise<DependfixBranchStatus>;
|
|
325
383
|
/**
|
|
326
384
|
* 删除远端分支(git ref delete)。失败(分支保护、不存在)由调用方捕获处理。
|
|
327
385
|
*/
|
|
328
|
-
declare function deleteRemoteBranch(octokit: Octokit, owner: string, repo: string, branch: string): Promise<void>;
|
|
386
|
+
export declare function deleteRemoteBranch(octokit: Octokit, owner: string, repo: string, branch: string): Promise<void>;
|
|
329
387
|
/**
|
|
330
388
|
* 判定交互确认回答是否为"是"(y/yes,大小写不敏感;空输入默认拒绝)。
|
|
331
389
|
*/
|
|
332
|
-
declare function isConfirmAnswer(answer: string): boolean;
|
|
390
|
+
export declare function isConfirmAnswer(answer: string): boolean;
|
|
333
391
|
/**
|
|
334
392
|
* 从 RunResult 生成 PR body(Markdown)。
|
|
335
393
|
*
|
|
@@ -341,11 +399,11 @@ declare function isConfirmAnswer(answer: string): boolean;
|
|
|
341
399
|
*
|
|
342
400
|
* @param supersededNumbers 被本 PR 取代并已关闭的旧 PR 编号列表(用于 Supersedes 声明)
|
|
343
401
|
*/
|
|
344
|
-
declare function generatePRBody(result: RunResult, supersededNumbers?: number[]): string;
|
|
402
|
+
export declare function generatePRBody(result: RunResult, supersededNumbers?: number[]): string;
|
|
345
403
|
//#endregion
|
|
346
404
|
//#region src/github/repo-policy.d.ts
|
|
347
405
|
/** 单条 glob 模式长度上限(加固:防止超长模式引入匹配开销;受信配置 + 短输入) */
|
|
348
|
-
declare const MAX_GLOB_PATTERN_LENGTH = 200;
|
|
406
|
+
export declare const MAX_GLOB_PATTERN_LENGTH = 200;
|
|
349
407
|
/**
|
|
350
408
|
* 将仓库 glob 模式转正则(`owner/*`、`owner/pkg-*`)。
|
|
351
409
|
*
|
|
@@ -359,10 +417,10 @@ declare const MAX_GLOB_PATTERN_LENGTH = 200;
|
|
|
359
417
|
* 多通配符模式存在理论 O(n^k) 回溯面(`[^/]*` 单层字符类、输入 ≤ ~140 字符,风险低);
|
|
360
418
|
* 正则引擎演进时需专项 ReDoS 审计。
|
|
361
419
|
*/
|
|
362
|
-
declare function repoGlobToRegExp(pattern: string): RegExp;
|
|
420
|
+
export declare function repoGlobToRegExp(pattern: string): RegExp;
|
|
363
421
|
/** glob 模式匹配 `owner/repo`(完整匹配)。 */
|
|
364
|
-
declare function matchesRepoGlob(pattern: string, fullName: string): boolean;
|
|
365
|
-
interface RepoPolicy {
|
|
422
|
+
export declare function matchesRepoGlob(pattern: string, fullName: string): boolean;
|
|
423
|
+
export interface RepoPolicy {
|
|
366
424
|
/** 白名单 glob(仅作用于发现结果;显式列表不受影响) */
|
|
367
425
|
include?: string[];
|
|
368
426
|
/** 黑名单 glob(显式列表 + 发现结果均受约束;与 include 冲突时胜出) */
|
|
@@ -371,30 +429,30 @@ interface RepoPolicy {
|
|
|
371
429
|
topicsExclude?: string[];
|
|
372
430
|
}
|
|
373
431
|
/** 是否命中任一 exclude 模式(黑名单)。 */
|
|
374
|
-
declare function matchesRepoExclude(policy: RepoPolicy, fullName: string): boolean;
|
|
432
|
+
export declare function matchesRepoExclude(policy: RepoPolicy, fullName: string): boolean;
|
|
375
433
|
/** 是否通过 include 白名单(include 为空 = 不限制;非空 = 必须命中任一模式)。 */
|
|
376
|
-
declare function matchesRepoInclude(policy: RepoPolicy, fullName: string): boolean;
|
|
434
|
+
export declare function matchesRepoInclude(policy: RepoPolicy, fullName: string): boolean;
|
|
377
435
|
/** topic 黑名单:仓库 topics 含任一指定 topic 即排除(大小写归一化后比较)。 */
|
|
378
|
-
declare function matchesTopicsExclude(policy: RepoPolicy, topics: string[]): boolean;
|
|
436
|
+
export declare function matchesTopicsExclude(policy: RepoPolicy, topics: string[]): boolean;
|
|
379
437
|
/**
|
|
380
438
|
* 过滤显式仓库列表:仅受 exclude 约束(白名单 include 不适用于显式列表,
|
|
381
439
|
* 设计要点:显式优先,用户显式指定的仓库不应被 include 静默剔除)。
|
|
382
440
|
*/
|
|
383
|
-
declare function filterExplicitRepositories(policy: RepoPolicy, repositories: string[]): string[];
|
|
441
|
+
export declare function filterExplicitRepositories(policy: RepoPolicy, repositories: string[]): string[];
|
|
384
442
|
//#endregion
|
|
385
443
|
//#region src/github/repo-selector.d.ts
|
|
386
444
|
/**
|
|
387
445
|
* 从文件读取仓库列表(每行一个 `owner/repo`)。
|
|
388
446
|
* 空行和 `#` 开头的注释行会被跳过。
|
|
389
447
|
*/
|
|
390
|
-
declare function readReposFile(filePath: string): string[];
|
|
448
|
+
export declare function readReposFile(filePath: string): string[];
|
|
391
449
|
/**
|
|
392
450
|
* 合并 CLI 传入仓库列表与文件中的仓库列表,去重并校验。
|
|
393
451
|
*/
|
|
394
|
-
declare function resolveRepoList(cliRepos: string[], reposFilePath?: string): string[];
|
|
452
|
+
export declare function resolveRepoList(cliRepos: string[], reposFilePath?: string): string[];
|
|
395
453
|
//#endregion
|
|
396
454
|
//#region src/github/repository-discovery.d.ts
|
|
397
|
-
interface RepositoryDiscoveryOptions {
|
|
455
|
+
export interface RepositoryDiscoveryOptions {
|
|
398
456
|
/** 已认证的 Octokit 实例 */
|
|
399
457
|
client: Octokit;
|
|
400
458
|
/** owner / org 列表(分别拉取后合并) */
|
|
@@ -418,8 +476,14 @@ interface RepositoryDiscoveryOptions {
|
|
|
418
476
|
probeDependabot?: boolean;
|
|
419
477
|
/** dependabot.yml 探测并发上限(默认 5,避免一次性打爆 API) */
|
|
420
478
|
probeConcurrency?: number;
|
|
479
|
+
/**
|
|
480
|
+
* 发现规模上限:最多保留的仓库数(按 fullName 字典序排序后截断)。
|
|
481
|
+
* 默认 100;设为 0 或负数表示不限制。
|
|
482
|
+
* 大 org 场景下防止一次性全量发现导致 API 配额不可控消耗和超时。
|
|
483
|
+
*/
|
|
484
|
+
maxRepos?: number;
|
|
421
485
|
}
|
|
422
|
-
interface DiscoveredRepository {
|
|
486
|
+
export interface DiscoveredRepository {
|
|
423
487
|
/** `owner/repo` 格式 */
|
|
424
488
|
fullName: string;
|
|
425
489
|
defaultBranch: string;
|
|
@@ -435,20 +499,21 @@ interface DiscoveredRepository {
|
|
|
435
499
|
* 2. topic 过滤(`--repo-topics`,AND 语义)
|
|
436
500
|
* 3. 名单策略过滤(include / exclude / topicsExclude,探测前应用)
|
|
437
501
|
* 4. dependabot.yml 探测(仅候选仓库触达 contents API;404 视为不支持,不剔除)
|
|
502
|
+
* 5. 规模上限截断(`maxRepos`,按 fullName 字典序排序后截断)
|
|
438
503
|
*
|
|
439
504
|
* 结果按 `fullName` 字典序排序,保证同输入多次运行结果一致
|
|
440
505
|
* (runId / 指纹稳定性前提)。
|
|
441
506
|
*
|
|
442
507
|
* @throws AppError(mapGitHubError 转换;token 权限、网络等全局性问题 fail-fast)
|
|
443
508
|
*/
|
|
444
|
-
declare function discoverRepositories(options: RepositoryDiscoveryOptions): Promise<DiscoveredRepository[]>;
|
|
509
|
+
export declare function discoverRepositories(options: RepositoryDiscoveryOptions): Promise<DiscoveredRepository[]>;
|
|
445
510
|
/**
|
|
446
511
|
* 合并显式仓库列表与发现结果:
|
|
447
512
|
* - 显式优先:显式列表保持原顺序且在前
|
|
448
513
|
* - 发现结果仅补充未出现的项(去重;大小写不敏感——GitHub full_name 恒小写,
|
|
449
514
|
* 显式 `Owner/Repo` 与发现 `owner/repo` 视为同一仓库)
|
|
450
515
|
*/
|
|
451
|
-
declare function mergeRepositories(explicit: string[], discovered: string[]): string[];
|
|
516
|
+
export declare function mergeRepositories(explicit: string[], discovered: string[]): string[];
|
|
452
517
|
//#endregion
|
|
453
518
|
//#region src/github/token-scope.d.ts
|
|
454
519
|
/**
|
|
@@ -465,11 +530,11 @@ declare function mergeRepositories(explicit: string[], discovered: string[]): st
|
|
|
465
530
|
* 依赖脚本窃取即可接管所有可见仓库(威胁链 B 路径的最终防线是凭据权限面)。
|
|
466
531
|
* 检查为 best-effort:网络失败 / 无 token / 无法判定时静默跳过,不阻断运行。
|
|
467
532
|
*/
|
|
468
|
-
interface TokenScopeWarning {
|
|
533
|
+
export interface TokenScopeWarning {
|
|
469
534
|
code: 'CLASSIC_REPO_SCOPE' | 'MISSING_SECURITY_EVENTS';
|
|
470
535
|
message: string;
|
|
471
536
|
}
|
|
472
|
-
interface TokenScopeAnalysis {
|
|
537
|
+
export interface TokenScopeAnalysis {
|
|
473
538
|
/** classic PAT 的 scopes(x-oauth-scopes 解析结果) */
|
|
474
539
|
scopes?: string[];
|
|
475
540
|
/** fine-grained PAT 的 accepted permissions(x-accepted-github-permissions 解析结果) */
|
|
@@ -477,7 +542,7 @@ interface TokenScopeAnalysis {
|
|
|
477
542
|
/** 需要提示用户的权限问题(空 = 无问题) */
|
|
478
543
|
warnings: TokenScopeWarning[];
|
|
479
544
|
}
|
|
480
|
-
interface TokenScopeCheckResult extends TokenScopeAnalysis {
|
|
545
|
+
export interface TokenScopeCheckResult extends TokenScopeAnalysis {
|
|
481
546
|
/** 探测是否成功(鉴权/网络失败为 false,调用方静默跳过) */
|
|
482
547
|
ok: boolean;
|
|
483
548
|
/** 认证用户登录名(探测成功时填充) */
|
|
@@ -490,14 +555,14 @@ interface TokenScopeCheckResult extends TokenScopeAnalysis {
|
|
|
490
555
|
* @param acceptedHeader `GET /user` 响应的 `x-accepted-github-permissions` 头(fine-grained / 内置 token 才有值)
|
|
491
556
|
* @param options.codeScanningEnabled 是否开启 Code Scanning 源(开启时校验 security-events 权限)
|
|
492
557
|
*/
|
|
493
|
-
declare function analyzeTokenScope(scopeHeader: string | undefined, acceptedHeader: string | undefined, options?: {
|
|
558
|
+
export declare function analyzeTokenScope(scopeHeader: string | undefined, acceptedHeader: string | undefined, options?: {
|
|
494
559
|
codeScanningEnabled?: boolean;
|
|
495
560
|
}): TokenScopeAnalysis;
|
|
496
561
|
/**
|
|
497
562
|
* 探测 token 权限面(网络调用,best-effort)。
|
|
498
563
|
* 任何失败(鉴权 401 / 网络错误 / 超时)均静默返回 `ok: false`,不抛错。
|
|
499
564
|
*/
|
|
500
|
-
declare function checkTokenPermissions(client: Octokit, options?: {
|
|
565
|
+
export declare function checkTokenPermissions(client: Octokit, options?: {
|
|
501
566
|
codeScanningEnabled?: boolean;
|
|
502
567
|
}): Promise<TokenScopeCheckResult>;
|
|
503
568
|
//#endregion
|
|
@@ -522,7 +587,7 @@ declare function checkTokenPermissions(client: Octokit, options?: {
|
|
|
522
587
|
* 纯格式规则(eol-last 等)实际出现频率低;此处先建立机制,
|
|
523
588
|
* 规则命中与否不影响分层正确性。
|
|
524
589
|
*/
|
|
525
|
-
declare const AUTO_FIXABLE_RULES: ReadonlySet<string>;
|
|
590
|
+
export declare const AUTO_FIXABLE_RULES: ReadonlySet<string>;
|
|
526
591
|
/**
|
|
527
592
|
* B 类建议规则默认列表(默认值常量;测试 disjointness 不变量用)。
|
|
528
593
|
*
|
|
@@ -537,7 +602,7 @@ declare const AUTO_FIXABLE_RULES: ReadonlySet<string>;
|
|
|
537
602
|
* 其余语言(go/ruby/csharp/cpp 等)与未收录变体(如 js/reflected-xss)落 C 类兜底;
|
|
538
603
|
* 真实仓库 API 样本核对(rule id 格式与变体分布)登记为演进项。
|
|
539
604
|
*/
|
|
540
|
-
declare const SUGGESTED_RULES: Set<string>;
|
|
605
|
+
export declare const SUGGESTED_RULES: Set<string>;
|
|
541
606
|
/**
|
|
542
607
|
* 规则分类:
|
|
543
608
|
* - A 类白名单 → `'auto-fixable'`
|
|
@@ -547,16 +612,16 @@ declare const SUGGESTED_RULES: Set<string>;
|
|
|
547
612
|
* 读取自当前生效配置(`getActiveRulesConfig()`);首次调用前需通过
|
|
548
613
|
* `setActiveRulesConfig` 替换或保持默认。
|
|
549
614
|
*/
|
|
550
|
-
declare function classifyRule(ruleId: string | null | undefined): AlertClass;
|
|
615
|
+
export declare function classifyRule(ruleId: string | null | undefined): AlertClass;
|
|
551
616
|
/**
|
|
552
617
|
* B 类建议规则的人工修复方向(报告/PR body 建议区块展示)。
|
|
553
618
|
* 读取自当前生效配置(`getActiveRulesConfig().suggested`);未收录规则返回通用建议(C 类兜底,不静默)。
|
|
554
619
|
*/
|
|
555
|
-
declare function suggestionFor(ruleId: string | null | undefined): string;
|
|
620
|
+
export declare function suggestionFor(ruleId: string | null | undefined): string;
|
|
556
621
|
//#endregion
|
|
557
622
|
//#region src/code-scanning/rule-config.d.ts
|
|
558
|
-
type RuleClass = 'auto-fixable' | 'suggested' | 'report-only';
|
|
559
|
-
interface RuleConfigEntry {
|
|
623
|
+
export type RuleClass = 'auto-fixable' | 'suggested' | 'report-only';
|
|
624
|
+
export interface RuleConfigEntry {
|
|
560
625
|
/** 规则 id(如 `js/sql-injection`,trim 后用于匹配;空串非法) */
|
|
561
626
|
id: string;
|
|
562
627
|
/** 分类 */
|
|
@@ -564,16 +629,16 @@ interface RuleConfigEntry {
|
|
|
564
629
|
/** B 类建议文本(A/C 类可省略) */
|
|
565
630
|
suggestion?: string;
|
|
566
631
|
}
|
|
567
|
-
interface RulesConfigFile {
|
|
632
|
+
export interface RulesConfigFile {
|
|
568
633
|
rules: RuleConfigEntry[];
|
|
569
634
|
}
|
|
570
635
|
/** 编译后的内部表示:高性能查找(A 类 Set / B 类 Map) */
|
|
571
|
-
interface CompiledRulesConfig {
|
|
636
|
+
export interface CompiledRulesConfig {
|
|
572
637
|
autoFixable: ReadonlySet<string>;
|
|
573
638
|
suggested: ReadonlyMap<string, string>;
|
|
574
639
|
}
|
|
575
640
|
/** 默认规则配置(编译后;与既有常量表等价,单点声明保持向后兼容) */
|
|
576
|
-
declare const DEFAULT_RULES_CONFIG: CompiledRulesConfig;
|
|
641
|
+
export declare const DEFAULT_RULES_CONFIG: CompiledRulesConfig;
|
|
577
642
|
/**
|
|
578
643
|
* 解析 JSON 配置输入为编译后配置。
|
|
579
644
|
*
|
|
@@ -585,13 +650,13 @@ declare const DEFAULT_RULES_CONFIG: CompiledRulesConfig;
|
|
|
585
650
|
*
|
|
586
651
|
* @returns 解析成功 → 编译后配置;失败 → null(调用方降级)
|
|
587
652
|
*/
|
|
588
|
-
declare function parseRulesConfig(input: unknown): CompiledRulesConfig | null;
|
|
653
|
+
export declare function parseRulesConfig(input: unknown): CompiledRulesConfig | null;
|
|
589
654
|
/**
|
|
590
655
|
* 从 JSON 文件路径加载并编译。读取失败 / 解析失败 / 校验失败 → 返回 null(调用方降级)。
|
|
591
656
|
*/
|
|
592
|
-
declare function loadRulesConfigFromFile(configPath: string): CompiledRulesConfig | null;
|
|
657
|
+
export declare function loadRulesConfigFromFile(configPath: string): CompiledRulesConfig | null;
|
|
593
658
|
/** 环境变量名:Code Scanning 规则分类配置文件路径 */
|
|
594
|
-
declare const RULE_CONFIG_ENV = "CODE_SCANNING_RULES_CONFIG_PATH";
|
|
659
|
+
export declare const RULE_CONFIG_ENV = "CODE_SCANNING_RULES_CONFIG_PATH";
|
|
595
660
|
/**
|
|
596
661
|
* 从 env 读取 `RULE_CONFIG_ENV` 并尝试加载。
|
|
597
662
|
*
|
|
@@ -599,9 +664,9 @@ declare const RULE_CONFIG_ENV = "CODE_SCANNING_RULES_CONFIG_PATH";
|
|
|
599
664
|
* - 路径不存在 → 返回 null
|
|
600
665
|
* - 加载失败 → 返回 null(错误已写入 stderr)
|
|
601
666
|
*/
|
|
602
|
-
declare function loadRulesConfigFromEnv(env: NodeJS.ProcessEnv): CompiledRulesConfig | null;
|
|
667
|
+
export declare function loadRulesConfigFromEnv(env: NodeJS.ProcessEnv): CompiledRulesConfig | null;
|
|
603
668
|
/** 获取当前生效的配置(classifyRule / suggestionFor 内部使用) */
|
|
604
|
-
declare function getActiveRulesConfig(): CompiledRulesConfig;
|
|
669
|
+
export declare function getActiveRulesConfig(): CompiledRulesConfig;
|
|
605
670
|
/**
|
|
606
671
|
* 替换为自定义配置。
|
|
607
672
|
*
|
|
@@ -609,18 +674,18 @@ declare function getActiveRulesConfig(): CompiledRulesConfig;
|
|
|
609
674
|
* 测试可临时覆盖后通过 `resetActiveRulesConfig` 恢复。频繁切换会破坏
|
|
610
675
|
* `code-scanning-fetcher` 的可预测行为(同一规则在不同 fetch 中分类不同)。
|
|
611
676
|
*/
|
|
612
|
-
declare function setActiveRulesConfig(config: CompiledRulesConfig): void;
|
|
677
|
+
export declare function setActiveRulesConfig(config: CompiledRulesConfig): void;
|
|
613
678
|
/** 重置为默认配置(测试 cleanup + 运行时 fallback) */
|
|
614
|
-
declare function resetActiveRulesConfig(): void;
|
|
679
|
+
export declare function resetActiveRulesConfig(): void;
|
|
615
680
|
//#endregion
|
|
616
681
|
//#region src/code-scanning/templates.d.ts
|
|
617
|
-
interface TemplateApplyResult {
|
|
682
|
+
export interface TemplateApplyResult {
|
|
618
683
|
/** 修改后的文件内容 */
|
|
619
684
|
content: string;
|
|
620
685
|
/** 是否实际产生修改(false = 文件已合规,无需改动) */
|
|
621
686
|
changed: boolean;
|
|
622
687
|
}
|
|
623
|
-
interface CodeScanningFixTemplate {
|
|
688
|
+
export interface CodeScanningFixTemplate {
|
|
624
689
|
/** 对应规则 id(A 类白名单成员) */
|
|
625
690
|
ruleId: string;
|
|
626
691
|
/**
|
|
@@ -633,10 +698,10 @@ interface CodeScanningFixTemplate {
|
|
|
633
698
|
describe(filePath: string, changed: boolean, alert: NormalizedSecurityAlert): string;
|
|
634
699
|
}
|
|
635
700
|
/** 获取规则对应的修复模板;无模板返回 undefined(调用方回退建议模式)。 */
|
|
636
|
-
declare function getCodeScanningFixTemplate(ruleId: string): CodeScanningFixTemplate | undefined;
|
|
701
|
+
export declare function getCodeScanningFixTemplate(ruleId: string): CodeScanningFixTemplate | undefined;
|
|
637
702
|
//#endregion
|
|
638
703
|
//#region src/fixers/dependency/index.d.ts
|
|
639
|
-
interface UpgradeDependencyParams {
|
|
704
|
+
export interface UpgradeDependencyParams {
|
|
640
705
|
/** 包名(如 `'lodash'`, `'@babel/traverse'`) */
|
|
641
706
|
packageName: string;
|
|
642
707
|
/** 目标精确版本(如 `'4.17.21'`) */
|
|
@@ -651,7 +716,7 @@ interface UpgradeDependencyParams {
|
|
|
651
716
|
*/
|
|
652
717
|
manifestDir?: string;
|
|
653
718
|
}
|
|
654
|
-
interface DependencyFixResult {
|
|
719
|
+
export interface DependencyFixResult {
|
|
655
720
|
packageName: string;
|
|
656
721
|
/** 升级前版本声明(保留原始 range 格式,如 `^4.17.20`) */
|
|
657
722
|
fromVersion: string;
|
|
@@ -666,7 +731,7 @@ interface DependencyFixResult {
|
|
|
666
731
|
/** 成功但存在需要用户注意的附加信息(如 overrides 写入位置可能被 pnpm 忽略) */
|
|
667
732
|
warning?: string;
|
|
668
733
|
}
|
|
669
|
-
interface PackageJson {
|
|
734
|
+
export interface PackageJson {
|
|
670
735
|
name?: string;
|
|
671
736
|
dependencies?: Record<string, string>;
|
|
672
737
|
devDependencies?: Record<string, string>;
|
|
@@ -697,7 +762,7 @@ interface DependencyInfo {
|
|
|
697
762
|
* @param params - 包名、目标版本、工作目录、可选成员目录
|
|
698
763
|
* @returns 修复结果
|
|
699
764
|
*/
|
|
700
|
-
declare function upgradeDependency(params: UpgradeDependencyParams): Promise<DependencyFixResult>;
|
|
765
|
+
export declare function upgradeDependency(params: UpgradeDependencyParams): Promise<DependencyFixResult>;
|
|
701
766
|
/**
|
|
702
767
|
* 通过 pnpm `overrides` 升级间接(transitive)依赖。
|
|
703
768
|
*
|
|
@@ -712,7 +777,7 @@ declare function upgradeDependency(params: UpgradeDependencyParams): Promise<Dep
|
|
|
712
777
|
* @param params - 包名、目标版本、工作目录
|
|
713
778
|
* @returns 修复结果
|
|
714
779
|
*/
|
|
715
|
-
declare function overrideTransitiveDependency(params: UpgradeDependencyParams): Promise<DependencyFixResult>;
|
|
780
|
+
export declare function overrideTransitiveDependency(params: UpgradeDependencyParams): Promise<DependencyFixResult>;
|
|
716
781
|
/**
|
|
717
782
|
* 通过 pnpm `overrides` **批量**写入覆盖条目并执行 install(多版本共存 / 单 major 统一入口)。
|
|
718
783
|
*
|
|
@@ -735,7 +800,7 @@ declare function overrideTransitiveDependency(params: UpgradeDependencyParams):
|
|
|
735
800
|
* @param params - 包名、overrides 映射(`pkg@major` 或 `pkg` → `^target`)、工作目录
|
|
736
801
|
* @returns 修复结果(fromVersion 为空字符串,表示多实例无单一来源版本)
|
|
737
802
|
*/
|
|
738
|
-
declare function applyVersionedOverrides(params: {
|
|
803
|
+
export declare function applyVersionedOverrides(params: {
|
|
739
804
|
packageName: string;
|
|
740
805
|
versionedOverrides: Record<string, string>;
|
|
741
806
|
workDir: string;
|
|
@@ -749,7 +814,7 @@ declare function applyVersionedOverrides(params: {
|
|
|
749
814
|
* extractPrefix('4.17.20') // ''
|
|
750
815
|
* extractPrefix('*') // '^' (默认)
|
|
751
816
|
*/
|
|
752
|
-
declare function extractPrefix(version: string): string;
|
|
817
|
+
export declare function extractPrefix(version: string): string;
|
|
753
818
|
/**
|
|
754
819
|
* 检测版本声明是否包含包管理器协议前缀
|
|
755
820
|
* (`workspace:` / `catalog:` / `link:` / `file:` / `npm:` / `github:` /
|
|
@@ -769,7 +834,7 @@ declare function extractPrefix(version: string): string;
|
|
|
769
834
|
* isNonSemverDeclaration('gitlab:...') // true
|
|
770
835
|
* isNonSemverDeclaration('https://...tgz') // true
|
|
771
836
|
*/
|
|
772
|
-
declare function isNonSemverDeclaration(version: string): boolean;
|
|
837
|
+
export declare function isNonSemverDeclaration(version: string): boolean;
|
|
773
838
|
/**
|
|
774
839
|
* 从版本声明中提取主版本号(major)。
|
|
775
840
|
* 去除前缀后匹配第一个 semver 段。
|
|
@@ -780,7 +845,7 @@ declare function isNonSemverDeclaration(version: string): boolean;
|
|
|
780
845
|
* parseMajorVersion('1.2.3') // 1
|
|
781
846
|
* parseMajorVersion('*') // -1
|
|
782
847
|
*/
|
|
783
|
-
declare function parseMajorVersion(version: string): number;
|
|
848
|
+
export declare function parseMajorVersion(version: string): number;
|
|
784
849
|
/**
|
|
785
850
|
* 比较两个语义化版本(`x.y.z`,可选 pre-release 后缀)。
|
|
786
851
|
*
|
|
@@ -793,16 +858,16 @@ declare function parseMajorVersion(version: string): number;
|
|
|
793
858
|
* compareSemver('5.4.20', '6.4.3') // -1
|
|
794
859
|
* compareSemver('1.2.3', '1.2.3') // 0
|
|
795
860
|
*/
|
|
796
|
-
declare function compareSemver(a: string, b: string): number;
|
|
861
|
+
export declare function compareSemver(a: string, b: string): number;
|
|
797
862
|
/**
|
|
798
863
|
* 在 `package.json` 的 `dependencies` / `devDependencies` / `optionalDependencies` 中按顺序查找包。
|
|
799
864
|
*/
|
|
800
|
-
declare function findDependencyVersion(pkg: PackageJson, packageName: string): DependencyInfo | null;
|
|
865
|
+
export declare function findDependencyVersion(pkg: PackageJson, packageName: string): DependencyInfo | null;
|
|
801
866
|
/**
|
|
802
867
|
* 确保 `package.json` 中存在 `pnpm.overrides` 对象,若不存在则创建。
|
|
803
868
|
* 返回 `overrides` 对象的引用,调用方可直接写入。
|
|
804
869
|
*/
|
|
805
|
-
declare function ensurePnpmOverrides(pkg: PackageJson): Record<string, string>;
|
|
870
|
+
export declare function ensurePnpmOverrides(pkg: PackageJson): Record<string, string>;
|
|
806
871
|
/**
|
|
807
872
|
* 从 `pnpm-lock.yaml` 中读取指定包的**所有**锁定版本实例。
|
|
808
873
|
*
|
|
@@ -816,7 +881,7 @@ declare function ensurePnpmOverrides(pkg: PackageJson): Record<string, string>;
|
|
|
816
881
|
*
|
|
817
882
|
* @returns 去重后的版本列表(如 `['5.4.14', '8.2.0']`),未找到返回 `[]`
|
|
818
883
|
*/
|
|
819
|
-
declare function readLockfileVersions(lockfilePath: string, packageName: string): string[];
|
|
884
|
+
export declare function readLockfileVersions(lockfilePath: string, packageName: string): string[];
|
|
820
885
|
/**
|
|
821
886
|
* 从 `pnpm-lock.yaml` 中读取指定包的当前锁定版本。
|
|
822
887
|
*
|
|
@@ -825,7 +890,7 @@ declare function readLockfileVersions(lockfilePath: string, packageName: string)
|
|
|
825
890
|
*
|
|
826
891
|
* @returns 锁定版本字符串(如 `'5.0.0'`),未找到返回 `null`
|
|
827
892
|
*/
|
|
828
|
-
declare function readLockfileVersion(lockfilePath: string, packageName: string): string | null;
|
|
893
|
+
export declare function readLockfileVersion(lockfilePath: string, packageName: string): string | null;
|
|
829
894
|
/**
|
|
830
895
|
* 读取当前已生效的 pnpm overrides 映射(与写入位置保持一致):
|
|
831
896
|
* - 存在 `pnpm-workspace.yaml` → 读取其中 `overrides` 字段(pnpm v10+ 推荐位置)
|
|
@@ -837,13 +902,13 @@ declare function readLockfileVersion(lockfilePath: string, packageName: string):
|
|
|
837
902
|
*
|
|
838
903
|
* @returns 已有 overrides 映射(key → 版本声明);无配置或解析失败返回 {}
|
|
839
904
|
*/
|
|
840
|
-
declare function readExistingOverrides(workDir: string): Record<string, string>;
|
|
905
|
+
export declare function readExistingOverrides(workDir: string): Record<string, string>;
|
|
841
906
|
/**
|
|
842
907
|
* 探测当前 pnpm 大版本(pnpm v10+ 对无 `pnpm-workspace.yaml` 的项目
|
|
843
908
|
* 可能不读取 `package.json#pnpm.overrides`,写入会"假成功")。
|
|
844
909
|
* 探测失败(pnpm 不可用 / 输出异常)返回 null,调用方降级为不告警。
|
|
845
910
|
*/
|
|
846
|
-
declare function detectPnpmMajor(workDir: string): number | null;
|
|
911
|
+
export declare function detectPnpmMajor(workDir: string): number | null;
|
|
847
912
|
/**
|
|
848
913
|
* 跨线修复判定(2026-08-06 复盘 PR #28)。
|
|
849
914
|
*
|
|
@@ -857,12 +922,12 @@ declare function detectPnpmMajor(workDir: string): number | null;
|
|
|
857
922
|
* lockfile 中无该包实例(versions 为空)时返回 false——"无实例"场景由
|
|
858
923
|
* partitionSubmanifestAlerts 的常规跳过逻辑处理,避免重复计数。
|
|
859
924
|
*/
|
|
860
|
-
declare function isCrossMajorFixRequired(lockfilePath: string, alert: NormalizedSecurityAlert): boolean;
|
|
925
|
+
export declare function isCrossMajorFixRequired(lockfilePath: string, alert: NormalizedSecurityAlert): boolean;
|
|
861
926
|
//#endregion
|
|
862
927
|
//#region src/fixers/pnpm/index.d.ts
|
|
863
|
-
type LockfileFailureCategory = 'LOCKFILE_NOT_FOUND' | 'MANIFEST_MISMATCH' | 'LOCKFILE_VERSION_MISMATCH' | 'CORRUPTED_LOCKFILE' | 'CREDENTIAL_ERROR' | 'RESOLVE_ERROR' | 'MINIMUM_RELEASE_AGE' | 'UNKNOWN';
|
|
864
|
-
type RepairStrategy = 'REGENERATE' | 'FIX_ENTRIES' | 'PIN_TOOLCHAIN' | 'REINSTALL' | 'SKIP';
|
|
865
|
-
interface RepairLockfileParams {
|
|
928
|
+
export type LockfileFailureCategory = 'LOCKFILE_NOT_FOUND' | 'MANIFEST_MISMATCH' | 'LOCKFILE_VERSION_MISMATCH' | 'CORRUPTED_LOCKFILE' | 'CREDENTIAL_ERROR' | 'RESOLVE_ERROR' | 'MINIMUM_RELEASE_AGE' | 'UNKNOWN';
|
|
929
|
+
export type RepairStrategy = 'REGENERATE' | 'FIX_ENTRIES' | 'PIN_TOOLCHAIN' | 'REINSTALL' | 'SKIP';
|
|
930
|
+
export interface RepairLockfileParams {
|
|
866
931
|
/** 工作目录(必须包含 package.json 和 pnpm-lock.yaml) */
|
|
867
932
|
workDir: string;
|
|
868
933
|
/** 可选:期望的 pnpm 版本(优先于 packageManager 字段) */
|
|
@@ -870,7 +935,7 @@ interface RepairLockfileParams {
|
|
|
870
935
|
pnpmVersion?: string;
|
|
871
936
|
};
|
|
872
937
|
}
|
|
873
|
-
interface LockfileDiff {
|
|
938
|
+
export interface LockfileDiff {
|
|
874
939
|
/** lockfile 行数变化(正=增加) */
|
|
875
940
|
linesChanged: number;
|
|
876
941
|
/** packages 条数变化(正=增加) */
|
|
@@ -878,14 +943,14 @@ interface LockfileDiff {
|
|
|
878
943
|
/** 简要文字摘要 */
|
|
879
944
|
summary: string;
|
|
880
945
|
}
|
|
881
|
-
interface RepairAttempt {
|
|
946
|
+
export interface RepairAttempt {
|
|
882
947
|
strategy: RepairStrategy;
|
|
883
948
|
command: string;
|
|
884
949
|
success: boolean;
|
|
885
950
|
error?: string;
|
|
886
951
|
durationMs: number;
|
|
887
952
|
}
|
|
888
|
-
interface LockfileRepairResult {
|
|
953
|
+
export interface LockfileRepairResult {
|
|
889
954
|
success: boolean;
|
|
890
955
|
failureCategory?: LockfileFailureCategory;
|
|
891
956
|
failureDetail?: string;
|
|
@@ -906,21 +971,21 @@ interface ClassificationResult {
|
|
|
906
971
|
* 执行 `pnpm i --frozen-lockfile` 并解析失败分类。
|
|
907
972
|
* 成功时返回 { ok: true }。
|
|
908
973
|
*/
|
|
909
|
-
declare function classifyLockfileFailure(workDir: string): ClassificationResult;
|
|
974
|
+
export declare function classifyLockfileFailure(workDir: string): ClassificationResult;
|
|
910
975
|
/** 从 lockfile 内容提取 `lockfileVersion` 字段值(如 `9.0`);缺失返回 null。 */
|
|
911
|
-
declare function extractLockfileVersion(content: string): string | null;
|
|
976
|
+
export declare function extractLockfileVersion(content: string): string | null;
|
|
912
977
|
/**
|
|
913
978
|
* 比较修复前后 lockfile,返回行数与包数量变化摘要。
|
|
914
979
|
*/
|
|
915
|
-
declare function computeLockfileDiff(beforePath: string, afterPath: string): LockfileDiff;
|
|
980
|
+
export declare function computeLockfileDiff(beforePath: string, afterPath: string): LockfileDiff;
|
|
916
981
|
/** 校验 pnpm 版本格式是否合法(非法返回 false,调用方回退裸命令/报错)。 */
|
|
917
|
-
declare function isValidPnpmVersion(version: string | undefined | null): version is string;
|
|
982
|
+
export declare function isValidPnpmVersion(version: string | undefined | null): version is string;
|
|
918
983
|
/**
|
|
919
984
|
* 从 package.json 的 `packageManager` 字段解析 pnpm 版本。
|
|
920
985
|
* 优先级: toolchain.pnpmVersion > packageManager > null
|
|
921
986
|
* 非法 toolchain 版本 → 回退 packageManager;两者都非法/缺失 → null(裸命令兜底)。
|
|
922
987
|
*/
|
|
923
|
-
declare function resolvePnpmVersion(workDir: string, toolchain?: {
|
|
988
|
+
export declare function resolvePnpmVersion(workDir: string, toolchain?: {
|
|
924
989
|
pnpmVersion?: string;
|
|
925
990
|
}): string | null;
|
|
926
991
|
/**
|
|
@@ -936,10 +1001,10 @@ declare function resolvePnpmVersion(workDir: string, toolchain?: {
|
|
|
936
1001
|
* - 验证失败 → 继续下一个策略
|
|
937
1002
|
* 5. 所有策略失败 → 回滚 lockfile、返回失败结果
|
|
938
1003
|
*/
|
|
939
|
-
declare function repairLockfile(params: RepairLockfileParams): LockfileRepairResult;
|
|
1004
|
+
export declare function repairLockfile(params: RepairLockfileParams): LockfileRepairResult;
|
|
940
1005
|
//#endregion
|
|
941
1006
|
//#region src/fixers/code-scanning/index.d.ts
|
|
942
|
-
interface ApplyCodeScanningFixParams {
|
|
1007
|
+
export interface ApplyCodeScanningFixParams {
|
|
943
1008
|
/** 工作目录(告警 manifestPath 为相对路径,resolve 后读取) */
|
|
944
1009
|
workDir: string;
|
|
945
1010
|
alert: NormalizedSecurityAlert;
|
|
@@ -952,8 +1017,8 @@ interface ApplyCodeScanningFixParams {
|
|
|
952
1017
|
* 仅处理 `source === 'code-scanning'` 且 `alertClass === 'auto-fixable'` 的告警;
|
|
953
1018
|
* 其余返回 `null`(调用方不生成动作记录)。
|
|
954
1019
|
*/
|
|
955
|
-
declare function applyCodeScanningFix(params: ApplyCodeScanningFixParams): FixAction | null;
|
|
956
|
-
interface SourceFileSnapshot {
|
|
1020
|
+
export declare function applyCodeScanningFix(params: ApplyCodeScanningFixParams): FixAction | null;
|
|
1021
|
+
export interface SourceFileSnapshot {
|
|
957
1022
|
/** 相对路径(告警 manifestPath) */
|
|
958
1023
|
path: string;
|
|
959
1024
|
/** 快照时文件是否存在 */
|
|
@@ -965,12 +1030,12 @@ interface SourceFileSnapshot {
|
|
|
965
1030
|
* 快照单个源码文件(修复前调用;文件不存在时记录 existed:false)。
|
|
966
1031
|
* 路径越界返回 null;读取失败返回 null(调用方按失败处理,不中断主流程)。
|
|
967
1032
|
*/
|
|
968
|
-
declare function snapshotSourceFile(workDir: string, relativePath: string): SourceFileSnapshot | null;
|
|
1033
|
+
export declare function snapshotSourceFile(workDir: string, relativePath: string): SourceFileSnapshot | null;
|
|
969
1034
|
/**
|
|
970
1035
|
* 恢复源码文件(验证失败回滚;原不存在的文件将被删除)。
|
|
971
1036
|
* 返回是否恢复成功(写回/删除失败返回 false,调用方在 action.error 记录"可能残留")。
|
|
972
1037
|
*/
|
|
973
|
-
declare function restoreSourceFile(workDir: string, snapshot: SourceFileSnapshot): boolean;
|
|
1038
|
+
export declare function restoreSourceFile(workDir: string, snapshot: SourceFileSnapshot): boolean;
|
|
974
1039
|
/**
|
|
975
1040
|
* 将相对路径解析到工作目录内(防 `../` 与绝对路径逃逸;防符号链接逃逸)。
|
|
976
1041
|
* 返回 null 表示越界(调用方拒绝处理)。
|
|
@@ -981,25 +1046,25 @@ declare function restoreSourceFile(workDir: string, snapshot: SourceFileSnapshot
|
|
|
981
1046
|
* realpath 内;不存在 → 逐级向上对最近存在的父目录做 realpath 校验。
|
|
982
1047
|
* 返回**真实路径**(后续读写走真实路径,避免再次经过 symlink)。
|
|
983
1048
|
*/
|
|
984
|
-
declare function resolveWithinWorkDir(workDir: string, relativePath: string): string | null;
|
|
1049
|
+
export declare function resolveWithinWorkDir(workDir: string, relativePath: string): string | null;
|
|
985
1050
|
//#endregion
|
|
986
1051
|
//#region src/config/index.d.ts
|
|
987
|
-
declare const RUNTIME_MODES: readonly ["report-only", "fix", "fix-and-pr", "cleanup-branches"];
|
|
988
|
-
declare const SEVERITY_THRESHOLDS: readonly ["critical", "high", "medium", "all"];
|
|
989
|
-
declare const ALERT_SOURCES: readonly AlertSourceKind[];
|
|
1052
|
+
export declare const RUNTIME_MODES: readonly ["report-only", "fix", "fix-and-pr", "cleanup-branches"];
|
|
1053
|
+
export declare const SEVERITY_THRESHOLDS: readonly ["critical", "high", "medium", "all"];
|
|
1054
|
+
export declare const ALERT_SOURCES: readonly AlertSourceKind[];
|
|
990
1055
|
/**
|
|
991
1056
|
* 环境变量统一前缀(v0.2 起替代旧项目名遗留的 `AUTO_FIX_GITHUB_SECURITY_`)。
|
|
992
1057
|
* 所有环境变量读取必须经由 {@link readEnv},禁止散落硬编码,防止改名漏网。
|
|
993
1058
|
*/
|
|
994
|
-
declare const ENV_PREFIX = "DEPENDFIX_";
|
|
1059
|
+
export declare const ENV_PREFIX = "DEPENDFIX_";
|
|
995
1060
|
/**
|
|
996
1061
|
* 从统一前缀读取环境变量。
|
|
997
1062
|
* @param env 进程环境
|
|
998
1063
|
* @param name 变量名(不含前缀),如 `'MODE'` → `DEPENDFIX_MODE`
|
|
999
1064
|
*/
|
|
1000
|
-
declare function readEnv(env: NodeJS.ProcessEnv, name: string): string | undefined;
|
|
1001
|
-
type RuntimeMode = typeof RUNTIME_MODES[number];
|
|
1002
|
-
interface RuntimeConfig {
|
|
1065
|
+
export declare function readEnv(env: NodeJS.ProcessEnv, name: string): string | undefined;
|
|
1066
|
+
export type RuntimeMode = typeof RUNTIME_MODES[number];
|
|
1067
|
+
export interface RuntimeConfig {
|
|
1003
1068
|
mode: RuntimeMode;
|
|
1004
1069
|
severityThreshold: SeverityThreshold;
|
|
1005
1070
|
repositories: string[];
|
|
@@ -1109,6 +1174,11 @@ interface RuntimeConfig {
|
|
|
1109
1174
|
* (由策略链 REGENERATE/REINSTALL 兜底)。
|
|
1110
1175
|
*/
|
|
1111
1176
|
toolchainPnpmVersion?: string;
|
|
1177
|
+
/**
|
|
1178
|
+
* 发现规模上限(`--max-repos` / `DEPENDFIX_MAX_REPOS`):最多保留的仓库数。
|
|
1179
|
+
* 默认 100;设为 0 或负数表示不限制。大 org 场景下防止一次性全量发现。
|
|
1180
|
+
*/
|
|
1181
|
+
maxRepos: number;
|
|
1112
1182
|
/**
|
|
1113
1183
|
* AI 研判配置(`--ai` 系列参数 / `DEPENDFIX_AI_*` env)。
|
|
1114
1184
|
* 默认关闭(opt-in);开启后依赖升级验证失败或 major 升级时触发
|
|
@@ -1123,8 +1193,8 @@ interface RuntimeConfig {
|
|
|
1123
1193
|
* - `major`:仅 major 升级时触发
|
|
1124
1194
|
* - `both`(默认):验证失败 或 major 升级均触发
|
|
1125
1195
|
*/
|
|
1126
|
-
type AiTriggerKind = 'failure' | 'major' | 'both';
|
|
1127
|
-
interface AiOptions {
|
|
1196
|
+
export type AiTriggerKind = 'failure' | 'major' | 'both';
|
|
1197
|
+
export interface AiOptions {
|
|
1128
1198
|
/** AI 研判总开关(默认 false,opt-in;dry-run 下不触发) */
|
|
1129
1199
|
enabled: boolean;
|
|
1130
1200
|
/** 提供商:openai-compatible(默认,DeepSeek 等指定 baseUrl)/ anthropic */
|
|
@@ -1149,7 +1219,7 @@ interface AiOptions {
|
|
|
1149
1219
|
/** 触发范围(默认 both) */
|
|
1150
1220
|
trigger: AiTriggerKind;
|
|
1151
1221
|
}
|
|
1152
|
-
interface CliConfigOverrides {
|
|
1222
|
+
export interface CliConfigOverrides {
|
|
1153
1223
|
mode?: RuntimeMode;
|
|
1154
1224
|
severityThreshold?: SeverityThreshold;
|
|
1155
1225
|
repositories?: string[];
|
|
@@ -1197,6 +1267,11 @@ interface CliConfigOverrides {
|
|
|
1197
1267
|
upgradeGroups?: Record<string, string[]>;
|
|
1198
1268
|
/** lockfile 修复用的 pnpm 版本(工具链固定;缺省从 packageManager 解析) */
|
|
1199
1269
|
toolchainPnpmVersion?: string;
|
|
1270
|
+
/**
|
|
1271
|
+
* 发现规模上限(`--max-repos` / `DEPENDFIX_MAX_REPOS`):最多保留的仓库数。
|
|
1272
|
+
* 默认 100;设为 0 或负数表示不限制。大 org 场景下防止一次性全量发现。
|
|
1273
|
+
*/
|
|
1274
|
+
maxRepos?: number;
|
|
1200
1275
|
/** AI 研判总开关(`--ai`) */
|
|
1201
1276
|
aiEnabled?: boolean;
|
|
1202
1277
|
/** AI 提供商(`--ai-provider`:openai-compatible / anthropic) */
|
|
@@ -1221,15 +1296,15 @@ interface CliConfigOverrides {
|
|
|
1221
1296
|
*/
|
|
1222
1297
|
history?: string;
|
|
1223
1298
|
}
|
|
1224
|
-
interface ResolveRuntimeConfigOptions {
|
|
1299
|
+
export interface ResolveRuntimeConfigOptions {
|
|
1225
1300
|
env?: NodeJS.ProcessEnv;
|
|
1226
1301
|
cliOverrides?: CliConfigOverrides;
|
|
1227
1302
|
/** 工作目录,用于从 git remote 推断仓库名(默认 `process.cwd()`) */
|
|
1228
1303
|
workDir?: string;
|
|
1229
1304
|
}
|
|
1230
|
-
declare const DEFAULT_RUNTIME_CONFIG: Omit<RuntimeConfig, 'githubToken' | 'repositories' | 'dryRun' | 'createPullRequest' | 'commit' | 'cleanupBranches' | 'cleanupBranchesAuto'>;
|
|
1231
|
-
declare function readEnvConfig(env?: NodeJS.ProcessEnv): CliConfigOverrides;
|
|
1232
|
-
declare function resolveRuntimeConfig(options?: ResolveRuntimeConfigOptions): RuntimeConfig;
|
|
1305
|
+
export declare const DEFAULT_RUNTIME_CONFIG: Omit<RuntimeConfig, 'githubToken' | 'repositories' | 'dryRun' | 'createPullRequest' | 'commit' | 'cleanupBranches' | 'cleanupBranchesAuto'>;
|
|
1306
|
+
export declare function readEnvConfig(env?: NodeJS.ProcessEnv): CliConfigOverrides;
|
|
1307
|
+
export declare function resolveRuntimeConfig(options?: ResolveRuntimeConfigOptions): RuntimeConfig;
|
|
1233
1308
|
/**
|
|
1234
1309
|
* 从 git remote origin 推断 owner/repo。
|
|
1235
1310
|
*
|
|
@@ -1240,10 +1315,10 @@ declare function resolveRuntimeConfig(options?: ResolveRuntimeConfigOptions): Ru
|
|
|
1240
1315
|
*
|
|
1241
1316
|
* @returns `owner/repo` 或 `null`(非 GitHub / 无 origin)
|
|
1242
1317
|
*/
|
|
1243
|
-
declare function inferRepoFromGitRemote(workDir: string): string | null;
|
|
1318
|
+
export declare function inferRepoFromGitRemote(workDir: string): string | null;
|
|
1244
1319
|
//#endregion
|
|
1245
1320
|
//#region src/report/archiver.d.ts
|
|
1246
|
-
interface ArchiveRepoStats {
|
|
1321
|
+
export interface ArchiveRepoStats {
|
|
1247
1322
|
repository: string;
|
|
1248
1323
|
alertsCount: number;
|
|
1249
1324
|
fixable: number;
|
|
@@ -1253,7 +1328,7 @@ interface ArchiveRepoStats {
|
|
|
1253
1328
|
durationMs: number;
|
|
1254
1329
|
}
|
|
1255
1330
|
/** index.json 单条趋势记录(字段与 RunSummary/RepositoryResult 口径一致)。 */
|
|
1256
|
-
interface ArchiveRunEntry {
|
|
1331
|
+
export interface ArchiveRunEntry {
|
|
1257
1332
|
runId: string;
|
|
1258
1333
|
startedAt: string;
|
|
1259
1334
|
/** 本次运行总时长(finishedAt - startedAt,毫秒) */
|
|
@@ -1264,10 +1339,10 @@ interface ArchiveRunEntry {
|
|
|
1264
1339
|
/** 按仓库统计(趋势基础字段) */
|
|
1265
1340
|
repoStats: ArchiveRepoStats[];
|
|
1266
1341
|
}
|
|
1267
|
-
interface ArchiveIndex {
|
|
1342
|
+
export interface ArchiveIndex {
|
|
1268
1343
|
runs: ArchiveRunEntry[];
|
|
1269
1344
|
}
|
|
1270
|
-
interface ArchiveResult {
|
|
1345
|
+
export interface ArchiveResult {
|
|
1271
1346
|
/** 汇总 json 路径 */
|
|
1272
1347
|
summaryJsonPath: string;
|
|
1273
1348
|
/** 单仓库报告文件路径列表 */
|
|
@@ -1286,14 +1361,14 @@ interface ArchiveResult {
|
|
|
1286
1361
|
* 可靠性:index.json 采用临时文件 + 原子 rename 写入(并发/中断安全);
|
|
1287
1362
|
* 解析失败的损坏索引先备份为 `index.json.corrupt-{ts}.bak` 再重建,历史不静默丢失。
|
|
1288
1363
|
*/
|
|
1289
|
-
declare function writeArchive(runResult: RunResult, outputDir?: string): ArchiveResult;
|
|
1364
|
+
export declare function writeArchive(runResult: RunResult, outputDir?: string): ArchiveResult;
|
|
1290
1365
|
/** 读取归档索引(不存在时返回空索引;条目级字段兜底防旧版/手写索引形状异常)。 */
|
|
1291
|
-
declare function readArchiveIndex(outputDir?: string): ArchiveIndex;
|
|
1366
|
+
export declare function readArchiveIndex(outputDir?: string): ArchiveIndex;
|
|
1292
1367
|
/**
|
|
1293
1368
|
* 查询某仓库的历史运行摘要(倒序时间:最新在前)。
|
|
1294
1369
|
* 仅返回包含该仓库的运行;无结果返回 []。
|
|
1295
1370
|
*/
|
|
1296
|
-
declare function queryRepoHistory(repo: string, outputDir?: string): ArchiveRunEntry[];
|
|
1371
|
+
export declare function queryRepoHistory(repo: string, outputDir?: string): ArchiveRunEntry[];
|
|
1297
1372
|
//#endregion
|
|
1298
1373
|
//#region src/report/history.d.ts
|
|
1299
1374
|
/**
|
|
@@ -1305,14 +1380,14 @@ declare function queryRepoHistory(repo: string, outputDir?: string): ArchiveRunE
|
|
|
1305
1380
|
* 行格式:`YYYY-MM-DD HH:mm:ss 告警 N / 修复 N / 失败 N 时长 Xs runId=...`
|
|
1306
1381
|
* 无历史时返回提示行(非空,调用方直接打印)。
|
|
1307
1382
|
*/
|
|
1308
|
-
declare function formatHistory(entries: ArchiveRunEntry[], repo: string): string;
|
|
1383
|
+
export declare function formatHistory(entries: ArchiveRunEntry[], repo: string): string;
|
|
1309
1384
|
//#endregion
|
|
1310
1385
|
//#region src/multirepo/scheduler.d.ts
|
|
1311
1386
|
/** 并发上限(1-16,配置校验范围) */
|
|
1312
|
-
declare const MAX_CONCURRENCY_LIMIT = 16;
|
|
1387
|
+
export declare const MAX_CONCURRENCY_LIMIT = 16;
|
|
1313
1388
|
/** 默认并发(保守:行为与现状一致,逐仓库串行) */
|
|
1314
|
-
declare const DEFAULT_CONCURRENCY = 1;
|
|
1315
|
-
interface ConcurrencySchedulerOptions<T> {
|
|
1389
|
+
export declare const DEFAULT_CONCURRENCY = 1;
|
|
1390
|
+
export interface ConcurrencySchedulerOptions<T> {
|
|
1316
1391
|
items: T[];
|
|
1317
1392
|
/** 并发窗口(1-16) */
|
|
1318
1393
|
concurrency: number;
|
|
@@ -1334,9 +1409,16 @@ interface ConcurrencySchedulerOptions<T> {
|
|
|
1334
1409
|
* onError 兜底,保证"单仓库失败不中断整体")
|
|
1335
1410
|
* - 任务完成顺序不保证(并发下与输入顺序无关),但每个任务都会被调度
|
|
1336
1411
|
*/
|
|
1337
|
-
declare function runWithConcurrency<T>(options: ConcurrencySchedulerOptions<T>): Promise<void>;
|
|
1412
|
+
export declare function runWithConcurrency<T>(options: ConcurrencySchedulerOptions<T>): Promise<void>;
|
|
1338
1413
|
/** 校验并发值是否在 1-16 范围内(config 层调用,抛 AppError)。 */
|
|
1339
|
-
declare function isValidConcurrency(value: number): boolean;
|
|
1414
|
+
export declare function isValidConcurrency(value: number): boolean;
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/app/branch-cleanup.d.ts
|
|
1417
|
+
/**
|
|
1418
|
+
* 关闭被取代的旧 PR 并回收其 head 分支(supersede 流程)。
|
|
1419
|
+
* 关闭失败记录错误;分支删除失败仅 warn(家务活 best-effort,不触发非零退出)。
|
|
1420
|
+
*/
|
|
1421
|
+
export declare function closeSupersededPRs(ctx: Pick<AppContext, 'logger' | 'allErrors'>, client: Octokit, owner: string, repo: string, supersedePRs: DependfixOpenPR[]): Promise<void>;
|
|
1340
1422
|
//#endregion
|
|
1341
1423
|
//#region src/ai/usage.d.ts
|
|
1342
1424
|
interface AiUsage {
|
|
@@ -1352,9 +1434,9 @@ interface AiUsage {
|
|
|
1352
1434
|
* 估算单次调用成本(USD)。
|
|
1353
1435
|
* 模型不在单价表返回 undefined(不估算,避免误导)。
|
|
1354
1436
|
*/
|
|
1355
|
-
declare function estimateCostUsd(model: string, inputTokens: number, outputTokens: number): number | undefined;
|
|
1437
|
+
export declare function estimateCostUsd(model: string, inputTokens: number, outputTokens: number): number | undefined;
|
|
1356
1438
|
/** 聚合多次 AI 调用的 token 消耗(run 级)。 */
|
|
1357
|
-
declare class AiUsageTracker {
|
|
1439
|
+
export declare class AiUsageTracker {
|
|
1358
1440
|
private calls;
|
|
1359
1441
|
private inputTokens;
|
|
1360
1442
|
private outputTokens;
|
|
@@ -1393,7 +1475,7 @@ interface AppContext {
|
|
|
1393
1475
|
* - ⚠️ 不变式:`upgrades = alertsFixed - codeFixes` 依赖 computeSummary 与
|
|
1394
1476
|
* codeFixes 过滤条件一致(均 success && !noOp);任一侧口径变更必须同步。
|
|
1395
1477
|
*/
|
|
1396
|
-
declare function buildPrTitle(summary: Pick<RunSummary, 'alertsFixed'>, actions: FixAction[]): string;
|
|
1478
|
+
export declare function buildPrTitle(summary: Pick<RunSummary, 'alertsFixed'>, actions: FixAction[]): string;
|
|
1397
1479
|
//#endregion
|
|
1398
1480
|
//#region src/helpers/index.d.ts
|
|
1399
1481
|
/**
|
|
@@ -1406,7 +1488,7 @@ declare function buildPrTitle(summary: Pick<RunSummary, 'alertsFixed'>, actions:
|
|
|
1406
1488
|
* @param alerts 已过滤出 fixable && recommendedVersion 非空的告警
|
|
1407
1489
|
* @returns 每包仅一条的代表告警
|
|
1408
1490
|
*/
|
|
1409
|
-
declare function dedupeFixableAlerts(alerts: NormalizedSecurityAlert[]): NormalizedSecurityAlert[];
|
|
1491
|
+
export declare function dedupeFixableAlerts(alerts: NormalizedSecurityAlert[]): NormalizedSecurityAlert[];
|
|
1410
1492
|
/**
|
|
1411
1493
|
* 读取修复涉及的关键文件快照(逐包回滚基线)。
|
|
1412
1494
|
*
|
|
@@ -1415,23 +1497,27 @@ declare function dedupeFixableAlerts(alerts: NormalizedSecurityAlert[]): Normali
|
|
|
1415
1497
|
* 用于成员级修复将成员 manifest 纳入回滚基线。
|
|
1416
1498
|
* 用于逐包升级验证失败时精确回滚该包产生的改动,而不影响此前已成功的包。
|
|
1417
1499
|
*/
|
|
1418
|
-
declare function snapshotTrackedFiles(workDir: string, extraPaths?: string[]): Record<string, string | null>;
|
|
1500
|
+
export declare function snapshotTrackedFiles(workDir: string, extraPaths?: string[]): Record<string, string | null>;
|
|
1419
1501
|
/**
|
|
1420
1502
|
* 恢复文件快照(逐包回滚)。原不存在的文件将被删除。
|
|
1421
1503
|
*/
|
|
1422
|
-
declare function restoreTrackedFiles(workDir: string, snapshot: Record<string, string | null>): void;
|
|
1504
|
+
export declare function restoreTrackedFiles(workDir: string, snapshot: Record<string, string | null>): void;
|
|
1423
1505
|
/**
|
|
1424
|
-
*
|
|
1506
|
+
* 快速验证(逐包):运行验证命令序列。
|
|
1507
|
+
*
|
|
1508
|
+
* 有自定义命令时执行完整序列(含 install + setup + lint + build),
|
|
1509
|
+
* 否则仅运行 `pnpm lint`(脚本存在时)。
|
|
1425
1510
|
*
|
|
1426
|
-
*
|
|
1427
|
-
* lint
|
|
1428
|
-
*
|
|
1511
|
+
* 设计决策(run 33946113272 复盘):旧版仅跑 `pnpm lint`,但 Nuxt 等框架
|
|
1512
|
+
* 项目 lint 依赖 `nuxt prepare` 生成的 `.nuxt/tsconfig.json`——无 prepare
|
|
1513
|
+
* 步骤会导致 ESLint OOM。自定义命令已含 prepare,走完整序列可避免此问题;
|
|
1514
|
+
* `pnpm install` 在 node_modules 已就绪时近乎空操作,性能影响可忽略。
|
|
1429
1515
|
*/
|
|
1430
|
-
declare function quickVerifyProject(ctx: Pick<AppContext, 'logger' | 'workDir'>, repo: string): Promise<boolean>;
|
|
1516
|
+
export declare function quickVerifyProject(ctx: Pick<AppContext, 'logger' | 'workDir' | 'customCommands'>, repo: string): Promise<boolean>;
|
|
1431
1517
|
/**
|
|
1432
1518
|
* 成员级可修复告警条目:告警 + 所属成员目录(相对 workDir,如 `packages/web`)。
|
|
1433
1519
|
*/
|
|
1434
|
-
interface MemberManifestAlert {
|
|
1520
|
+
export interface MemberManifestAlert {
|
|
1435
1521
|
alert: NormalizedSecurityAlert;
|
|
1436
1522
|
/** 成员目录(相对 workDir,如 `packages/web`) */
|
|
1437
1523
|
manifestDir: string;
|
|
@@ -1439,7 +1525,7 @@ interface MemberManifestAlert {
|
|
|
1439
1525
|
/**
|
|
1440
1526
|
* 告警分区结果:根 manifest / 成员 manifest(可自动修复)/ 其他(人工)。
|
|
1441
1527
|
*/
|
|
1442
|
-
interface SubmanifestPartition {
|
|
1528
|
+
export interface SubmanifestPartition {
|
|
1443
1529
|
root: NormalizedSecurityAlert[];
|
|
1444
1530
|
member: MemberManifestAlert[];
|
|
1445
1531
|
sub: NormalizedSecurityAlert[];
|
|
@@ -1471,7 +1557,7 @@ interface SubmanifestPartition {
|
|
|
1471
1557
|
* - 其余 → sub(单根模型无法安全修 / 多版本共存 / 降级风险 / 跨线 / 非成员路径,
|
|
1472
1558
|
* 需人工处理)
|
|
1473
1559
|
*/
|
|
1474
|
-
declare function partitionSubmanifestAlerts(alerts: NormalizedSecurityAlert[], workDir: string): SubmanifestPartition;
|
|
1560
|
+
export declare function partitionSubmanifestAlerts(alerts: NormalizedSecurityAlert[], workDir: string): SubmanifestPartition;
|
|
1475
1561
|
/**
|
|
1476
1562
|
* 判断包是否为**根** `package.json` 的直接依赖(仅查根声明的
|
|
1477
1563
|
* dependencies / devDependencies / optionalDependencies)。
|
|
@@ -1480,19 +1566,19 @@ declare function partitionSubmanifestAlerts(alerts: NormalizedSecurityAlert[], w
|
|
|
1480
1566
|
* 根 manifest,跨线升级准入必须与修复器能力对齐——仅成员声明的包(root 未声明)
|
|
1481
1567
|
* 进入跨线链路必然失败,维持人工处理。
|
|
1482
1568
|
*/
|
|
1483
|
-
declare function isRootDirectDependency(workDir: string, packageName: string): boolean;
|
|
1569
|
+
export declare function isRootDirectDependency(workDir: string, packageName: string): boolean;
|
|
1484
1570
|
//#endregion
|
|
1485
1571
|
//#region src/grouping/index.d.ts
|
|
1486
1572
|
/** 分组来源(决定分组优先级与命名语义) */
|
|
1487
|
-
type GroupSource = 'explicit' | 'dependabot' | 'types' | 'scope' | 'prefix' | 'single';
|
|
1488
|
-
interface DependencyGroup {
|
|
1573
|
+
export type GroupSource = 'explicit' | 'dependabot' | 'types' | 'scope' | 'prefix' | 'single';
|
|
1574
|
+
export interface DependencyGroup {
|
|
1489
1575
|
/** 组名(日志与统计用) */
|
|
1490
1576
|
name: string;
|
|
1491
1577
|
/** 组内包名(保持输入顺序) */
|
|
1492
1578
|
packages: string[];
|
|
1493
1579
|
source: GroupSource;
|
|
1494
1580
|
}
|
|
1495
|
-
interface GroupingResult {
|
|
1581
|
+
export interface GroupingResult {
|
|
1496
1582
|
/** 有序分组(处理顺序即升级执行顺序) */
|
|
1497
1583
|
groups: DependencyGroup[];
|
|
1498
1584
|
/**
|
|
@@ -1501,7 +1587,7 @@ interface GroupingResult {
|
|
|
1501
1587
|
*/
|
|
1502
1588
|
cleanupCandidates: string[];
|
|
1503
1589
|
}
|
|
1504
|
-
interface GroupingOptions {
|
|
1590
|
+
export interface GroupingOptions {
|
|
1505
1591
|
/** 工作目录(读取 package.json / pnpm-lock.yaml / .github/dependabot.yml) */
|
|
1506
1592
|
workDir: string;
|
|
1507
1593
|
/** 用户显式分组:组名 -> 包列表(最高优先级,覆盖自动分组) */
|
|
@@ -1532,7 +1618,7 @@ interface PackageJsonLike {
|
|
|
1532
1618
|
* 裸 `*`(全匹配)视为不匹配,防止误分组(设计稿 §3)。
|
|
1533
1619
|
* 中间通配(`foo*bar`)不支持。
|
|
1534
1620
|
*/
|
|
1535
|
-
declare function matchesPattern(packageName: string, pattern: string): boolean;
|
|
1621
|
+
export declare function matchesPattern(packageName: string, pattern: string): boolean;
|
|
1536
1622
|
/**
|
|
1537
1623
|
* 解析 `.github/dependabot.yml`(或 `.yaml` 变体)中 npm ecosystem 的 `groups` → patterns。
|
|
1538
1624
|
*
|
|
@@ -1540,7 +1626,7 @@ declare function matchesPattern(packageName: string, pattern: string): boolean;
|
|
|
1540
1626
|
* 解析为 dependabot 语法子集:仅 `groups.<name>.patterns`;`exclude-patterns` /
|
|
1541
1627
|
* `dependency-type` / `update-types` 忽略(设计稿 §3)。
|
|
1542
1628
|
*/
|
|
1543
|
-
declare function parseDependabotGroups(workDir: string): Record<string, string[]>;
|
|
1629
|
+
export declare function parseDependabotGroups(workDir: string): Record<string, string[]>;
|
|
1544
1630
|
/**
|
|
1545
1631
|
* 从 `@types/x` 提取主包名。
|
|
1546
1632
|
*
|
|
@@ -1551,14 +1637,14 @@ declare function parseDependabotGroups(workDir: string): Record<string, string[]
|
|
|
1551
1637
|
*
|
|
1552
1638
|
* 非 @types 包返回 `null`。
|
|
1553
1639
|
*/
|
|
1554
|
-
declare function extractMainPackage(packageName: string): string | null;
|
|
1640
|
+
export declare function extractMainPackage(packageName: string): string | null;
|
|
1555
1641
|
/**
|
|
1556
1642
|
* 判定 @types 的主包是否仍然存在(任一命中即存在):
|
|
1557
1643
|
* 1. package.json 直接依赖(dependencies / devDependencies / optionalDependencies)
|
|
1558
1644
|
* 2. pnpm.overrides(间接依赖修复场景)
|
|
1559
1645
|
* 3. lockfile 中存在(间接依赖场景)
|
|
1560
1646
|
*/
|
|
1561
|
-
declare function isMainPackagePresent(pkg: PackageJsonLike, lockfilePath: string, mainPackage: string): boolean;
|
|
1647
|
+
export declare function isMainPackagePresent(pkg: PackageJsonLike, lockfilePath: string, mainPackage: string): boolean;
|
|
1562
1648
|
/**
|
|
1563
1649
|
* 构建升级分组(主入口)。
|
|
1564
1650
|
*
|
|
@@ -1572,7 +1658,7 @@ declare function isMainPackagePresent(pkg: PackageJsonLike, lockfilePath: string
|
|
|
1572
1658
|
* 4. 非 @types 单包组
|
|
1573
1659
|
* 5. @types 归并(主包有告警并入其组)/ 独立组 / 清理候选(主包已不存在)
|
|
1574
1660
|
*/
|
|
1575
|
-
declare function buildUpgradeGroups(alerts: NormalizedSecurityAlert[], options: GroupingOptions): GroupingResult;
|
|
1661
|
+
export declare function buildUpgradeGroups(alerts: NormalizedSecurityAlert[], options: GroupingOptions): GroupingResult;
|
|
1576
1662
|
//#endregion
|
|
1577
1663
|
//#region src/runners/network-audit.d.ts
|
|
1578
1664
|
/**
|
|
@@ -1609,7 +1695,7 @@ interface NetworkAuditEntry {
|
|
|
1609
1695
|
/**
|
|
1610
1696
|
* 单条命令的执行结果
|
|
1611
1697
|
*/
|
|
1612
|
-
interface CommandResult {
|
|
1698
|
+
export interface CommandResult {
|
|
1613
1699
|
/** 执行的命令文本 */
|
|
1614
1700
|
command: string;
|
|
1615
1701
|
/** 退出码(0 = 成功;-1 = 启动失败或超时被杀) */
|
|
@@ -1626,7 +1712,7 @@ interface CommandResult {
|
|
|
1626
1712
|
/**
|
|
1627
1713
|
* 验证执行参数
|
|
1628
1714
|
*/
|
|
1629
|
-
interface VerificationParams {
|
|
1715
|
+
export interface VerificationParams {
|
|
1630
1716
|
/** 工作目录 */
|
|
1631
1717
|
workDir: string;
|
|
1632
1718
|
/**
|
|
@@ -1649,7 +1735,7 @@ interface VerificationParams {
|
|
|
1649
1735
|
/**
|
|
1650
1736
|
* 验证执行结果
|
|
1651
1737
|
*/
|
|
1652
|
-
interface VerificationResult {
|
|
1738
|
+
export interface VerificationResult {
|
|
1653
1739
|
/** 所有命令是否全部成功 */
|
|
1654
1740
|
success: boolean;
|
|
1655
1741
|
/** 每条命令的详细结果 */
|
|
@@ -1667,13 +1753,13 @@ interface VerificationResult {
|
|
|
1667
1753
|
* 压缩验证命令输出为报告可读的摘要(首尾各取若干行,超长中间省略)。
|
|
1668
1754
|
* 完整输出由日志承载;报告保持紧凑,避免 error 字段失控膨胀。
|
|
1669
1755
|
*/
|
|
1670
|
-
declare function summarizeVerificationOutput(output: string): string;
|
|
1756
|
+
export declare function summarizeVerificationOutput(output: string): string;
|
|
1671
1757
|
/**
|
|
1672
1758
|
* 构造失败验证命令的 error 描述:`exit code N — <stdout/stderr 摘要>`。
|
|
1673
1759
|
* 无输出时退化为裸 `exit code N`;超时命令归类为 `timed out after Xms`。
|
|
1674
1760
|
* stdout/stderr 已在 execCommand 中脱敏、截断 200 行。
|
|
1675
1761
|
*/
|
|
1676
|
-
declare function formatVerificationError(cr: CommandResult): string;
|
|
1762
|
+
export declare function formatVerificationError(cr: CommandResult): string;
|
|
1677
1763
|
/**
|
|
1678
1764
|
* 按顺序在工作目录执行命令序列,任一命令失败则停止。
|
|
1679
1765
|
*
|
|
@@ -1685,11 +1771,11 @@ declare function formatVerificationError(cr: CommandResult): string;
|
|
|
1685
1771
|
* }
|
|
1686
1772
|
* ```
|
|
1687
1773
|
*/
|
|
1688
|
-
declare function runVerification(params: VerificationParams): Promise<VerificationResult>;
|
|
1774
|
+
export declare function runVerification(params: VerificationParams): Promise<VerificationResult>;
|
|
1689
1775
|
/**
|
|
1690
1776
|
* 对外暴露以支持单独测试
|
|
1691
1777
|
*/
|
|
1692
|
-
declare function sanitizeOutput(output: string): string;
|
|
1778
|
+
export declare function sanitizeOutput(output: string): string;
|
|
1693
1779
|
//#endregion
|
|
1694
1780
|
//#region src/alerts/pnpm-audit-fetcher.d.ts
|
|
1695
1781
|
/**
|
|
@@ -1702,7 +1788,7 @@ declare function sanitizeOutput(output: string): string;
|
|
|
1702
1788
|
* - repository 由调用方注入(显式 --repo → git remote → local 兜底)
|
|
1703
1789
|
* - audit 自身失败(无 lockfile / pnpm 不可用 / JSON 解析失败)→ 硬失败,绝不静默空跑
|
|
1704
1790
|
*/
|
|
1705
|
-
interface FetchPnpmAuditAlertsParams {
|
|
1791
|
+
export interface FetchPnpmAuditAlertsParams {
|
|
1706
1792
|
/** 扫描工作目录(lockfile 所在目录) */
|
|
1707
1793
|
workDir: string;
|
|
1708
1794
|
/** 注入的仓库标识(owner/repo 或 local 兜底) */
|
|
@@ -1713,7 +1799,7 @@ interface FetchPnpmAuditAlertsParams {
|
|
|
1713
1799
|
*
|
|
1714
1800
|
* @throws AppError('AUDIT_FAILED') — pnpm 不可用 / 无 lockfile / JSON 解析失败
|
|
1715
1801
|
*/
|
|
1716
|
-
declare function fetchPnpmAuditAlerts(params: FetchPnpmAuditAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
1802
|
+
export declare function fetchPnpmAuditAlerts(params: FetchPnpmAuditAlertsParams): Promise<NormalizedSecurityAlert[]>;
|
|
1717
1803
|
interface RiskRecord {
|
|
1718
1804
|
advisoryId: string;
|
|
1719
1805
|
packageName: string;
|
|
@@ -1721,18 +1807,26 @@ interface RiskRecord {
|
|
|
1721
1807
|
title: string;
|
|
1722
1808
|
htmlUrl: string;
|
|
1723
1809
|
patchedVersion: string | null;
|
|
1810
|
+
/** GitHub Advisory ID(pnpm audit `advisory.github_advisory_id`,GitHub Advisory Database 收录时) */
|
|
1811
|
+
ghsaId?: string;
|
|
1812
|
+
/** CVE ID 列表(pnpm audit `advisory.cves[]` 字符串数组) */
|
|
1813
|
+
cveIds?: string[];
|
|
1724
1814
|
}
|
|
1725
1815
|
/**
|
|
1726
1816
|
* 解析 pnpm audit 报告(legacy + modern 双格式),按
|
|
1727
1817
|
* `packageName:advisoryId:severity` 去重(保留首个,advisoryId 优先补全)。
|
|
1728
1818
|
*/
|
|
1729
|
-
declare function parseAuditReport(report: unknown): RiskRecord[];
|
|
1819
|
+
export declare function parseAuditReport(report: unknown): RiskRecord[];
|
|
1730
1820
|
/**
|
|
1731
|
-
* advisoryId
|
|
1821
|
+
* advisoryId 的稳定数字哈希(M20 之前使用,M20 后保留以维持向后兼容 `NormalizedSecurityAlert.id: number`)。
|
|
1822
|
+
*
|
|
1732
1823
|
* 取 sha256 前 4 字节完整 uint32(非设计稿的 `% 2^31`:uint32 语义更自然,
|
|
1733
1824
|
* 碰撞概率 ~2^-32/对,12 条告警场景生日界 ~1.6e-8,可忽略)。
|
|
1825
|
+
*
|
|
1826
|
+
* M20 弃用:唯一去重键改为 `upstreamId`,详见 [`normalizeUpstreamId`](../../../core/src/alerts/upstream-id.ts)。
|
|
1827
|
+
* 本函数保留仅为兼容现有 `NormalizedSecurityAlert.id: number` 字段,**不是**平台去重键。
|
|
1734
1828
|
*/
|
|
1735
|
-
declare function hashAdvisoryId(packageName: string, advisoryId: string): number;
|
|
1829
|
+
export declare function hashAdvisoryId(packageName: string, advisoryId: string): number;
|
|
1736
1830
|
//#endregion
|
|
1737
1831
|
//#region src/ai/provider.d.ts
|
|
1738
1832
|
interface AiConfig {
|
|
@@ -1840,10 +1934,10 @@ interface AssessmentContextInput {
|
|
|
1840
1934
|
* maskSecrets('call failed with key sk-abc12345xyz', ['sk-abc12345xyz'])
|
|
1841
1935
|
* // → 'call failed with key sk-a****yz'
|
|
1842
1936
|
*/
|
|
1843
|
-
declare function maskSecrets(text: string, secrets: string[]): string;
|
|
1937
|
+
export declare function maskSecrets(text: string, secrets: string[]): string;
|
|
1844
1938
|
//#endregion
|
|
1845
1939
|
//#region src/ai/index.d.ts
|
|
1846
|
-
interface AssessResult {
|
|
1940
|
+
export interface AssessResult {
|
|
1847
1941
|
/** 结构化研判(降级时为 null,走建议模式) */
|
|
1848
1942
|
assessment: AiAssessment | null;
|
|
1849
1943
|
/**
|
|
@@ -1856,7 +1950,7 @@ interface AssessResult {
|
|
|
1856
1950
|
/** 降级原因(脱敏后的错误消息;成功时为 undefined) */
|
|
1857
1951
|
error?: string;
|
|
1858
1952
|
}
|
|
1859
|
-
interface AssessOptions {
|
|
1953
|
+
export interface AssessOptions {
|
|
1860
1954
|
config: AiConfig;
|
|
1861
1955
|
context: AssessmentContextInput;
|
|
1862
1956
|
/** 注入请求函数(默认全局 fetch;测试用 vi.fn) */
|
|
@@ -1875,7 +1969,7 @@ interface AssessOptions {
|
|
|
1875
1969
|
*
|
|
1876
1970
|
* 降级语义:调用方走建议模式(报告输出人工建议),不静默、可审计。
|
|
1877
1971
|
*/
|
|
1878
|
-
declare function assessBreakingChange(options: AssessOptions): Promise<AssessResult>;
|
|
1972
|
+
export declare function assessBreakingChange(options: AssessOptions): Promise<AssessResult>;
|
|
1879
1973
|
//#endregion
|
|
1880
1974
|
//#region src/app/repo-alerts.d.ts
|
|
1881
1975
|
/**
|
|
@@ -1883,10 +1977,10 @@ declare function assessBreakingChange(options: AssessOptions): Promise<AssessRes
|
|
|
1883
1977
|
* pnpm-audit 模式 client 为 null → 返回 ''(报告显示 local)。
|
|
1884
1978
|
* 失败时返回 `'unknown'`(不阻塞主流程)。
|
|
1885
1979
|
*/
|
|
1886
|
-
declare function fetchDefaultBranch(client: Octokit | null, owner: string, repo: string): Promise<string>;
|
|
1980
|
+
export declare function fetchDefaultBranch(client: Octokit | null, owner: string, repo: string): Promise<string>;
|
|
1887
1981
|
//#endregion
|
|
1888
1982
|
//#region src/app/index.d.ts
|
|
1889
|
-
interface DependfixAppOptions {
|
|
1983
|
+
export interface DependfixAppOptions {
|
|
1890
1984
|
/** 已解析的运行时配置 */
|
|
1891
1985
|
config: RuntimeConfig;
|
|
1892
1986
|
/** 工作目录(默认 `process.cwd()`) */
|
|
@@ -1903,14 +1997,32 @@ interface DependfixAppOptions {
|
|
|
1903
1997
|
* 不触发本地模式不可信代码风险警告。
|
|
1904
1998
|
*/
|
|
1905
1999
|
executionEnvironment?: 'local' | 'container';
|
|
2000
|
+
/**
|
|
2001
|
+
* 自定义 Logger(平台层注入 MemoryLogger 用于捕获执行日志)。
|
|
2002
|
+
* 未提供时使用内部 createLogger(输出到 console)。
|
|
2003
|
+
*/
|
|
2004
|
+
logger?: Logger;
|
|
1906
2005
|
}
|
|
1907
|
-
interface DependfixRunResult {
|
|
2006
|
+
export interface DependfixRunResult {
|
|
1908
2007
|
/** 结构化运行结果(用于报告生成) */
|
|
1909
2008
|
result: RunResult;
|
|
1910
2009
|
/** 进程退出码:0=全部成功, 1=部分失败, 2=全部失败 */
|
|
1911
2010
|
exitCode: number;
|
|
1912
2011
|
}
|
|
1913
|
-
|
|
2012
|
+
/**
|
|
2013
|
+
* 输出"部分源拉取失败"汇总(todo.md §M19.5 C8 per-source 错误隔离)。
|
|
2014
|
+
*
|
|
2015
|
+
* 触发条件(必须全部满足,避免与"全部源失败"语义重叠):
|
|
2016
|
+
* 1. allErrors 至少包含一个 `stage='fetch' + category='FETCH_FAILED'` 错误(per-source 失败)
|
|
2017
|
+
* 2. **至少一个仓库成功拉取了部分告警**(isAnyRepoSuccessful = true)——
|
|
2018
|
+
* 否则就是"全部源失败"语义,已由 processRepoForReport catch + logger.error 单独处理,
|
|
2019
|
+
* 本函数聚焦"warn + 保留成功源"场景的汇总输出,避免重复提示。
|
|
2020
|
+
*
|
|
2021
|
+
* 汇总按 source 分组('dependabot' / 'code-scanning' / 'code-quality' / 'pnpm-audit'),
|
|
2022
|
+
* 列出每个源失败的仓库数 + 示例错误消息,便于用户快速定位是 token 权限还是网络问题。
|
|
2023
|
+
*/
|
|
2024
|
+
export declare function logPartialSourceFailureSummary(allErrors: FixError[], logger: Logger, isAnyRepoSuccessful: boolean): void;
|
|
2025
|
+
export declare class DependfixApp {
|
|
1914
2026
|
private readonly config;
|
|
1915
2027
|
private readonly workDir;
|
|
1916
2028
|
private readonly reportOutputDir;
|
|
@@ -1966,6 +2078,16 @@ declare class DependfixApp {
|
|
|
1966
2078
|
* - dry-run 模式仅列清单并打印 "would delete",不执行删除
|
|
1967
2079
|
*/
|
|
1968
2080
|
private executeCleanupBranchesMode;
|
|
2081
|
+
/**
|
|
2082
|
+
* 重复 PR 处理:在新 PR 上添加评论指向被取代的旧 PR + 添加 `duplicate` label。
|
|
2083
|
+
*
|
|
2084
|
+
* 失败仅记录 warning(家务活 best-effort),不阻断主流程:
|
|
2085
|
+
* - 新 PR 已创建成功,用户已可访问
|
|
2086
|
+
* - 评论失败不影响 PR 本身的可用性
|
|
2087
|
+
* - 但需要 `issues: write` token scope(比 `pull-requests: write` 宽);
|
|
2088
|
+
* 若 token 权限不足,error 会被记录但不阻塞
|
|
2089
|
+
*/
|
|
2090
|
+
private handleDuplicatePRs;
|
|
1969
2091
|
/**
|
|
1970
2092
|
* 多仓库并发执行管线。
|
|
1971
2093
|
*
|
|
@@ -1991,5 +2113,5 @@ declare class DependfixApp {
|
|
|
1991
2113
|
private createClient;
|
|
1992
2114
|
}
|
|
1993
2115
|
//#endregion
|
|
1994
|
-
export {
|
|
2116
|
+
export type { AiAssessment, AiChatResult, AiConfig, AiFileChange, AiReplaceBlock, AiUsage, AlertClass, AlertSourceKind, AssessmentContextInput, AuthProvider, AuthProviderOptions, FromAppParams, FromPatParams, SeverityThreshold };
|
|
1995
2117
|
//# sourceMappingURL=index.d.mts.map
|