@code-sentinel-cli/code-sentinel-cli 3.0.2
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 +14 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +33751 -0
- package/dist/index.d.ts +2249 -0
- package/dist/index.js +33779 -0
- package/node_modules/react-devtools-core/index.js +1 -0
- package/node_modules/react-devtools-core/package.json +6 -0
- package/package.json +73 -0
- package/templates/ci/github-actions.yml +76 -0
- package/templates/ci/gitlab-ci.yml +57 -0
- package/templates/hooks/pre-commit +30 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2249 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { CliApiClient } from '@code-sentinel/contracts';
|
|
4
|
+
import { AiGatePolicy, AiSkipGatePolicy, IParser, IRuleLoader, IAIClient, IAiExecutionTracker, IClusterAssembler, IClusterTreeBuilder, SourceFile, IAstDependencyGraphBuilder, ITaintAnalyzer, ITemplateComponentLinker, IReviewStore, ICacheStore, IReporter, Severity } from '@code-sentinel/core';
|
|
5
|
+
import { Instance } from 'ink';
|
|
6
|
+
import { TransactionBoundaryFact } from '@code-sentinel/ai-engine';
|
|
7
|
+
import { AiRuleExecutorCallback } from '@code-sentinel/rule-engine';
|
|
8
|
+
import { Logger, Clock, Result, ConfigInvalidError, IOError } from '@code-sentinel/shared';
|
|
9
|
+
import { DbHandle } from '@code-sentinel/storage';
|
|
10
|
+
import { Server } from 'node:http';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* commander setup. Wires CLI verbs to command handlers.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare const buildProgram: () => Command;
|
|
17
|
+
declare const main: (argv: readonly string[]) => Promise<number>;
|
|
18
|
+
|
|
19
|
+
interface CliBuildMetadata {
|
|
20
|
+
readonly version: string;
|
|
21
|
+
readonly gitSha: string;
|
|
22
|
+
readonly buildTimestamp: string;
|
|
23
|
+
readonly configSchemaRange: string;
|
|
24
|
+
}
|
|
25
|
+
/** Values are embedded by tsup, with deterministic safe defaults for source tests. */
|
|
26
|
+
declare const getCliBuildMetadata: (version: string) => CliBuildMetadata;
|
|
27
|
+
|
|
28
|
+
interface StoredCredential {
|
|
29
|
+
readonly serverUrl: string;
|
|
30
|
+
readonly subject: string;
|
|
31
|
+
readonly accessToken: string;
|
|
32
|
+
readonly refreshToken?: string;
|
|
33
|
+
readonly expiresAt: string | null;
|
|
34
|
+
}
|
|
35
|
+
/** Secrets belong only in a platform credential store, never in CLI YAML/state. */
|
|
36
|
+
interface ICredentialStore {
|
|
37
|
+
read(serverUrl: string): Promise<StoredCredential | null>;
|
|
38
|
+
write(credential: StoredCredential): Promise<void>;
|
|
39
|
+
remove(serverUrl: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** Minimal key/value API implemented by each operating system's secure secret store. */
|
|
42
|
+
interface ISecretStore {
|
|
43
|
+
read(service: string, account: string): Promise<string | null>;
|
|
44
|
+
write(service: string, account: string, value: string): Promise<void>;
|
|
45
|
+
remove(service: string, account: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** Stores login sessions in an OS secret store; no credential is written to CLI config or state. */
|
|
48
|
+
declare class SecretBackedCredentialStore implements ICredentialStore {
|
|
49
|
+
private readonly secrets;
|
|
50
|
+
constructor(secrets: ISecretStore);
|
|
51
|
+
read(serverUrl: string): Promise<StoredCredential | null>;
|
|
52
|
+
write(credential: StoredCredential): Promise<void>;
|
|
53
|
+
remove(serverUrl: string): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/** Key material for encrypted retry metadata stays in the same OS secret store as the session. */
|
|
56
|
+
declare class SecretBackedRetryKeyProvider {
|
|
57
|
+
private readonly secrets;
|
|
58
|
+
constructor(secrets: ISecretStore);
|
|
59
|
+
getOrCreate(serverUrl: string, subject: string): Promise<Buffer>;
|
|
60
|
+
}
|
|
61
|
+
declare class InMemoryCredentialStore implements ICredentialStore {
|
|
62
|
+
#private;
|
|
63
|
+
read(serverUrl: string): Promise<StoredCredential | null>;
|
|
64
|
+
write(credential: StoredCredential): Promise<void>;
|
|
65
|
+
remove(serverUrl: string): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface DeviceAuthorizationStart {
|
|
69
|
+
readonly deviceCode: string;
|
|
70
|
+
readonly userCode: string;
|
|
71
|
+
readonly verificationUri: string;
|
|
72
|
+
readonly expiresIn: number;
|
|
73
|
+
readonly interval: number;
|
|
74
|
+
}
|
|
75
|
+
type DeviceAuthorizationPoll = {
|
|
76
|
+
readonly status: 'pending' | 'slow_down';
|
|
77
|
+
readonly interval: number;
|
|
78
|
+
} | {
|
|
79
|
+
readonly status: 'approved';
|
|
80
|
+
readonly accessToken: string;
|
|
81
|
+
readonly subject: string;
|
|
82
|
+
readonly expiresIn: number;
|
|
83
|
+
} | {
|
|
84
|
+
readonly status: 'expired';
|
|
85
|
+
};
|
|
86
|
+
declare const startDeviceAuthorization: (serverUrl: string, fetchFn?: typeof fetch) => Promise<DeviceAuthorizationStart>;
|
|
87
|
+
declare const pollDeviceAuthorization: (serverUrl: string, deviceCode: string, fetchFn?: typeof fetch) => Promise<DeviceAuthorizationPoll>;
|
|
88
|
+
declare const revokeDeviceCredential: (serverUrl: string, accessToken: string, fetchFn?: typeof fetch) => Promise<void>;
|
|
89
|
+
|
|
90
|
+
interface AuthCommandDependencies {
|
|
91
|
+
readonly store: ICredentialStore;
|
|
92
|
+
readonly start: typeof startDeviceAuthorization;
|
|
93
|
+
readonly poll: typeof pollDeviceAuthorization;
|
|
94
|
+
readonly revoke: typeof revokeDeviceCredential;
|
|
95
|
+
readonly openBrowser: (url: string) => Promise<void>;
|
|
96
|
+
readonly sleep: (milliseconds: number) => Promise<void>;
|
|
97
|
+
readonly now: () => number;
|
|
98
|
+
}
|
|
99
|
+
interface AuthLoginOptions {
|
|
100
|
+
readonly server: string;
|
|
101
|
+
readonly browser?: boolean;
|
|
102
|
+
readonly dependencies?: AuthCommandDependencies;
|
|
103
|
+
readonly write?: (line: string) => void;
|
|
104
|
+
readonly writeError?: (line: string) => void;
|
|
105
|
+
}
|
|
106
|
+
declare const runAuthLogin: (options: AuthLoginOptions) => Promise<number>;
|
|
107
|
+
declare const runAuthStatus: (input: {
|
|
108
|
+
readonly server: string;
|
|
109
|
+
readonly dependencies?: Pick<AuthCommandDependencies, "store" | "now">;
|
|
110
|
+
readonly write?: (line: string) => void;
|
|
111
|
+
}) => Promise<number>;
|
|
112
|
+
declare const runAuthLogout: (input: {
|
|
113
|
+
readonly server: string;
|
|
114
|
+
readonly path?: string;
|
|
115
|
+
readonly dependencies?: Pick<AuthCommandDependencies, "store" | "revoke">;
|
|
116
|
+
readonly write?: (line: string) => void;
|
|
117
|
+
}) => Promise<number>;
|
|
118
|
+
|
|
119
|
+
/** Compatibility exports for integrations that explicitly request macOS Keychain. */
|
|
120
|
+
declare class MacOsKeychainCredentialStore extends SecretBackedCredentialStore {
|
|
121
|
+
constructor();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface SecretCommandRunner {
|
|
125
|
+
run(command: string, args: readonly string[], input?: string): Promise<string>;
|
|
126
|
+
}
|
|
127
|
+
/** Linux adapter backed by the freedesktop.org Secret Service via libsecret's `secret-tool`. */
|
|
128
|
+
declare class LinuxSecretServiceStore implements ISecretStore {
|
|
129
|
+
private readonly commands;
|
|
130
|
+
constructor(commands?: SecretCommandRunner);
|
|
131
|
+
read(service: string, account: string): Promise<string | null>;
|
|
132
|
+
write(service: string, account: string, value: string): Promise<void>;
|
|
133
|
+
remove(service: string, account: string): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
/** Windows adapter backed by the built-in Windows Credential Manager (CredRead/CredWrite). */
|
|
136
|
+
declare class WindowsCredentialManagerStore implements ISecretStore {
|
|
137
|
+
private readonly commands;
|
|
138
|
+
constructor(commands?: SecretCommandRunner);
|
|
139
|
+
private run;
|
|
140
|
+
read(service: string, account: string): Promise<string | null>;
|
|
141
|
+
write(service: string, account: string, value: string): Promise<void>;
|
|
142
|
+
remove(service: string, account: string): Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
declare const createPlatformSecretStore: (platform?: NodeJS.Platform) => ISecretStore;
|
|
145
|
+
declare const createPlatformCredentialStore: (platform?: NodeJS.Platform) => ICredentialStore;
|
|
146
|
+
declare const createPlatformRetryKeyProvider: (platform?: NodeJS.Platform) => SecretBackedRetryKeyProvider;
|
|
147
|
+
|
|
148
|
+
interface PendingPushRetry {
|
|
149
|
+
readonly schemaVersion: 1;
|
|
150
|
+
readonly runId: string;
|
|
151
|
+
readonly serverUrl: string;
|
|
152
|
+
readonly subject: string;
|
|
153
|
+
readonly projectId: string;
|
|
154
|
+
readonly codebaseId: string;
|
|
155
|
+
readonly effectiveConfigHash: string;
|
|
156
|
+
readonly expiresAt: string;
|
|
157
|
+
}
|
|
158
|
+
interface IRetryKeyProvider {
|
|
159
|
+
getOrCreate(serverUrl: string, subject: string): Promise<Buffer>;
|
|
160
|
+
}
|
|
161
|
+
/** Encrypted, workspace-local retry metadata. It deliberately contains no bearer token. */
|
|
162
|
+
declare class FileProtectedRetryStore {
|
|
163
|
+
#private;
|
|
164
|
+
private readonly keys;
|
|
165
|
+
constructor(root: string, keys: IRetryKeyProvider);
|
|
166
|
+
enqueue(input: Omit<PendingPushRetry, 'schemaVersion' | 'expiresAt'>): Promise<void>;
|
|
167
|
+
list(serverUrl: string, subject: string): Promise<readonly PendingPushRetry[]>;
|
|
168
|
+
removeIdentity(serverUrl: string, subject: string): Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
declare class InMemoryRetryKeyProvider implements IRetryKeyProvider {
|
|
171
|
+
#private;
|
|
172
|
+
getOrCreate(serverUrl: string, subject: string): Promise<Buffer>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface WorkspaceLinkStore {
|
|
176
|
+
read(): Promise<WorkspaceLinkState | null>;
|
|
177
|
+
write(link: WorkspaceLinkState): Promise<void>;
|
|
178
|
+
remove(): Promise<void>;
|
|
179
|
+
}
|
|
180
|
+
interface WorkspaceLinkState {
|
|
181
|
+
readonly schemaVersion: 1;
|
|
182
|
+
readonly serverUrl: string;
|
|
183
|
+
readonly projectId: string;
|
|
184
|
+
readonly codebaseId: string;
|
|
185
|
+
readonly fingerprint: string;
|
|
186
|
+
readonly canonicalRemote: string;
|
|
187
|
+
readonly subdirectory: string;
|
|
188
|
+
readonly providerRepositoryId?: string;
|
|
189
|
+
readonly configCache?: {
|
|
190
|
+
readonly expiresAt: string;
|
|
191
|
+
readonly effectiveConfigHash: string;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
declare class FileWorkspaceLinkStore implements WorkspaceLinkStore {
|
|
195
|
+
#private;
|
|
196
|
+
constructor(root?: string);
|
|
197
|
+
read(): Promise<WorkspaceLinkState | null>;
|
|
198
|
+
write(link: WorkspaceLinkState): Promise<void>;
|
|
199
|
+
remove(): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* `cs init` — scaffold a default `.code-sentinel/codereviewrc.yaml` in the current directory.
|
|
204
|
+
*
|
|
205
|
+
* Refuses to overwrite an existing config unless `--force` is passed.
|
|
206
|
+
*/
|
|
207
|
+
interface InitOptions {
|
|
208
|
+
readonly cwd?: string;
|
|
209
|
+
readonly force?: boolean;
|
|
210
|
+
readonly config?: Record<string, unknown>;
|
|
211
|
+
}
|
|
212
|
+
declare const runInit: (options?: InitOptions) => Promise<number>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Zod schema for Code Sentinel local config files.
|
|
216
|
+
*
|
|
217
|
+
* Mirrors the shape documented in USAGE.md §Configuration.
|
|
218
|
+
* Cosmiconfig resolution order applies LAST-wins overrides; this schema
|
|
219
|
+
* validates the *final merged* config.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
declare const codeReviewConfigSchema: z.ZodObject<{
|
|
223
|
+
mode: z.ZodDefault<z.ZodEnum<["auto", "economy", "balanced", "performance"]>>;
|
|
224
|
+
include: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
225
|
+
exclude: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
226
|
+
rules: z.ZodDefault<z.ZodObject<{
|
|
227
|
+
enabled: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
228
|
+
disabled: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
229
|
+
/**
|
|
230
|
+
* Active rule packs BEYOND the always-on `core` pack. A "pack" is a
|
|
231
|
+
* provenance label orthogonal to a rule's `scope` (see `Rule.pack`):
|
|
232
|
+
* `core` = universal best-practice rules; any other value is an
|
|
233
|
+
* organization/project-specific pack that is **opt-in**.
|
|
234
|
+
*
|
|
235
|
+
* Default `[]` ⇒ only `core` rules run, so organization packs never
|
|
236
|
+
* fire unless a project explicitly enables them. Example — turn on
|
|
237
|
+
* the Viettel `@VauthzCheck` coverage rule(s):
|
|
238
|
+
*
|
|
239
|
+
* rules:
|
|
240
|
+
* packs: ['vauthz']
|
|
241
|
+
*/
|
|
242
|
+
packs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
243
|
+
/** Explicit trust grant for executable project-local TypeScript rules. */
|
|
244
|
+
projectCustomExecution: z.ZodDefault<z.ZodArray<z.ZodEnum<["local", "ci"]>, "many">>;
|
|
245
|
+
/**
|
|
246
|
+
* Per-rule overrides keyed by rule id. Each field is optional and
|
|
247
|
+
* shallow-merged onto the rule's built-in metadata at composition
|
|
248
|
+
* time. See ADR-0008 + USAGE.md "Tuning rules".
|
|
249
|
+
*
|
|
250
|
+
* - `enabled: false` drops the rule from the run (same effect as
|
|
251
|
+
* listing the id in `rules.disabled`, but discoverable when
|
|
252
|
+
* reading the override block).
|
|
253
|
+
* - `severity` re-maps how the rule's findings are classified.
|
|
254
|
+
* Useful for downgrading a noisy warning to info during cleanup.
|
|
255
|
+
* - `confidence` overrides the rule's `baseConfidence`. Findings
|
|
256
|
+
* without an explicit per-finding confidence pick this up.
|
|
257
|
+
* - `options` is shallow-merged with the rule's `defaultOptions`
|
|
258
|
+
* and forwarded to the rule's check fn via `ctx.options`. For
|
|
259
|
+
* static-yaml rules without options support, the value is
|
|
260
|
+
* ignored (warned in logs).
|
|
261
|
+
*/
|
|
262
|
+
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
263
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
264
|
+
severity: z.ZodOptional<z.ZodEnum<["info", "warning", "error", "blocker"]>>;
|
|
265
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
266
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
options?: Record<string, unknown> | undefined;
|
|
269
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
270
|
+
confidence?: number | undefined;
|
|
271
|
+
enabled?: boolean | undefined;
|
|
272
|
+
}, {
|
|
273
|
+
options?: Record<string, unknown> | undefined;
|
|
274
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
275
|
+
confidence?: number | undefined;
|
|
276
|
+
enabled?: boolean | undefined;
|
|
277
|
+
}>>>;
|
|
278
|
+
/**
|
|
279
|
+
* Per-path override blocks (Phase 12.5). Each entry binds a glob
|
|
280
|
+
* (or list of globs) to a rule patch that applies ONLY to findings
|
|
281
|
+
* whose source file matches. Entries are evaluated in declaration
|
|
282
|
+
* order; later entries layer on top of earlier ones.
|
|
283
|
+
*
|
|
284
|
+
* Use cases (driven by Viettel rollout feedback):
|
|
285
|
+
* - silence noisy rules across legacy directories without
|
|
286
|
+
* touching the global config: `paths: ['src/legacy/**']`
|
|
287
|
+
* + `disabled: ['general/no-magic-number']`
|
|
288
|
+
* - downgrade a rule's severity for test code without losing
|
|
289
|
+
* the warning entirely.
|
|
290
|
+
*
|
|
291
|
+
* The override shape mirrors `rules.overrides` (severity, confidence,
|
|
292
|
+
* enabled) minus `options` — options are owned by the rule's static
|
|
293
|
+
* configuration and applied uniformly per run, not per file. Path
|
|
294
|
+
* globs use POSIX `/` separators; Windows paths are normalized to
|
|
295
|
+
* the same shape before matching. See [`match-glob.ts`](../match-glob.ts).
|
|
296
|
+
*/
|
|
297
|
+
pathOverrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
298
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
299
|
+
disabled: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
300
|
+
overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
301
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
302
|
+
severity: z.ZodOptional<z.ZodEnum<["info", "warning", "error", "blocker"]>>;
|
|
303
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
304
|
+
}, "strip", z.ZodTypeAny, {
|
|
305
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
306
|
+
confidence?: number | undefined;
|
|
307
|
+
enabled?: boolean | undefined;
|
|
308
|
+
}, {
|
|
309
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
310
|
+
confidence?: number | undefined;
|
|
311
|
+
enabled?: boolean | undefined;
|
|
312
|
+
}>>>;
|
|
313
|
+
}, "strip", z.ZodTypeAny, {
|
|
314
|
+
paths: string[];
|
|
315
|
+
disabled?: string[] | undefined;
|
|
316
|
+
overrides?: Record<string, {
|
|
317
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
318
|
+
confidence?: number | undefined;
|
|
319
|
+
enabled?: boolean | undefined;
|
|
320
|
+
}> | undefined;
|
|
321
|
+
}, {
|
|
322
|
+
paths: string[];
|
|
323
|
+
disabled?: string[] | undefined;
|
|
324
|
+
overrides?: Record<string, {
|
|
325
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
326
|
+
confidence?: number | undefined;
|
|
327
|
+
enabled?: boolean | undefined;
|
|
328
|
+
}> | undefined;
|
|
329
|
+
}>, "many">>;
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
enabled: string[];
|
|
332
|
+
disabled: string[];
|
|
333
|
+
packs: string[];
|
|
334
|
+
projectCustomExecution: ("local" | "ci")[];
|
|
335
|
+
overrides: Record<string, {
|
|
336
|
+
options?: Record<string, unknown> | undefined;
|
|
337
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
338
|
+
confidence?: number | undefined;
|
|
339
|
+
enabled?: boolean | undefined;
|
|
340
|
+
}>;
|
|
341
|
+
pathOverrides: {
|
|
342
|
+
paths: string[];
|
|
343
|
+
disabled?: string[] | undefined;
|
|
344
|
+
overrides?: Record<string, {
|
|
345
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
346
|
+
confidence?: number | undefined;
|
|
347
|
+
enabled?: boolean | undefined;
|
|
348
|
+
}> | undefined;
|
|
349
|
+
}[];
|
|
350
|
+
}, {
|
|
351
|
+
enabled?: string[] | undefined;
|
|
352
|
+
disabled?: string[] | undefined;
|
|
353
|
+
packs?: string[] | undefined;
|
|
354
|
+
projectCustomExecution?: ("local" | "ci")[] | undefined;
|
|
355
|
+
overrides?: Record<string, {
|
|
356
|
+
options?: Record<string, unknown> | undefined;
|
|
357
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
358
|
+
confidence?: number | undefined;
|
|
359
|
+
enabled?: boolean | undefined;
|
|
360
|
+
}> | undefined;
|
|
361
|
+
pathOverrides?: {
|
|
362
|
+
paths: string[];
|
|
363
|
+
disabled?: string[] | undefined;
|
|
364
|
+
overrides?: Record<string, {
|
|
365
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
366
|
+
confidence?: number | undefined;
|
|
367
|
+
enabled?: boolean | undefined;
|
|
368
|
+
}> | undefined;
|
|
369
|
+
}[] | undefined;
|
|
370
|
+
}>>;
|
|
371
|
+
ai: z.ZodDefault<z.ZodObject<{
|
|
372
|
+
/**
|
|
373
|
+
* Active AI provider. `none` disables AI rules entirely. Other
|
|
374
|
+
* values map 1:1 to `AiSdkProviderType` in `@code-sentinel/ai-engine`.
|
|
375
|
+
*
|
|
376
|
+
* 1.2.0 (Phase 12.2): added `viettel-netmind` (Viettel internal AI
|
|
377
|
+
* gateway) and `openai-compatible` (escape hatch for any URL +
|
|
378
|
+
* optional Bearer auth). Underlying impl is the Vercel AI SDK; see
|
|
379
|
+
* ADR-0011.
|
|
380
|
+
*/
|
|
381
|
+
provider: z.ZodDefault<z.ZodEnum<["ollama", "gemini", "groq", "viettel-netmind", "opencode-go", "freemodel", "openai-compatible", "none"]>>;
|
|
382
|
+
fallback: z.ZodDefault<z.ZodArray<z.ZodEnum<["ollama", "gemini", "groq", "viettel-netmind", "opencode-go", "freemodel", "openai-compatible"]>, "many">>;
|
|
383
|
+
temperature: z.ZodDefault<z.ZodNumber>;
|
|
384
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
385
|
+
tokenBudgetWarn: z.ZodDefault<z.ZodNumber>;
|
|
386
|
+
clusterTokenBudget: z.ZodDefault<z.ZodNumber>;
|
|
387
|
+
/**
|
|
388
|
+
* AI-resilience re-run ([ADR-0029]). After the main pass, AI rules whose
|
|
389
|
+
* invocations were skipped for a RETRYABLE reason (provider down / parse
|
|
390
|
+
* failure) are re-run up to `maxPasses` times, `delayMs` apart. The AI
|
|
391
|
+
* cache means already-succeeded calls hit the cache (cheap) — only the
|
|
392
|
+
* previously-failed ones re-hit the provider, so a provider that recovers
|
|
393
|
+
* mid-run recovers the missing findings. `maxPasses: 0` disables re-run
|
|
394
|
+
* (skips then rely purely on the coverage gate). No skips → no re-run
|
|
395
|
+
* (a healthy run pays nothing).
|
|
396
|
+
*/
|
|
397
|
+
skipRerun: z.ZodDefault<z.ZodObject<{
|
|
398
|
+
maxPasses: z.ZodDefault<z.ZodNumber>;
|
|
399
|
+
delayMs: z.ZodDefault<z.ZodNumber>;
|
|
400
|
+
}, "strip", z.ZodTypeAny, {
|
|
401
|
+
maxPasses: number;
|
|
402
|
+
delayMs: number;
|
|
403
|
+
}, {
|
|
404
|
+
maxPasses?: number | undefined;
|
|
405
|
+
delayMs?: number | undefined;
|
|
406
|
+
}>>;
|
|
407
|
+
ollama: z.ZodDefault<z.ZodObject<{
|
|
408
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
409
|
+
model: z.ZodDefault<z.ZodString>;
|
|
410
|
+
temperature: z.ZodDefault<z.ZodNumber>;
|
|
411
|
+
}, "strip", z.ZodTypeAny, {
|
|
412
|
+
model: string;
|
|
413
|
+
temperature: number;
|
|
414
|
+
baseUrl: string;
|
|
415
|
+
}, {
|
|
416
|
+
model?: string | undefined;
|
|
417
|
+
temperature?: number | undefined;
|
|
418
|
+
baseUrl?: string | undefined;
|
|
419
|
+
}>>;
|
|
420
|
+
gemini: z.ZodDefault<z.ZodObject<{
|
|
421
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
422
|
+
model: z.ZodDefault<z.ZodString>;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
model: string;
|
|
425
|
+
apiKey?: string | undefined;
|
|
426
|
+
}, {
|
|
427
|
+
model?: string | undefined;
|
|
428
|
+
apiKey?: string | undefined;
|
|
429
|
+
}>>;
|
|
430
|
+
groq: z.ZodDefault<z.ZodObject<{
|
|
431
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
432
|
+
model: z.ZodDefault<z.ZodString>;
|
|
433
|
+
}, "strip", z.ZodTypeAny, {
|
|
434
|
+
model: string;
|
|
435
|
+
apiKey?: string | undefined;
|
|
436
|
+
}, {
|
|
437
|
+
model?: string | undefined;
|
|
438
|
+
apiKey?: string | undefined;
|
|
439
|
+
}>>;
|
|
440
|
+
/**
|
|
441
|
+
* Viettel internal AI gateway. OpenAI-compatible endpoint. Default
|
|
442
|
+
* baseUrl + model match the live netmind deployment. As of 2026-08-04
|
|
443
|
+
* the gateway exposes `MiniMax/MiniMax-M3`, `MiniMax/MiniMax-M2.7`,
|
|
444
|
+
* and `zai-org/GLM-4.7-cc`. Keep GLM-4.7-cc as the quality-first
|
|
445
|
+
* default until M3 passes the repository's finding-quality gate.
|
|
446
|
+
*/
|
|
447
|
+
viettelNetmind: z.ZodDefault<z.ZodObject<{
|
|
448
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
449
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
450
|
+
model: z.ZodDefault<z.ZodString>;
|
|
451
|
+
}, "strip", z.ZodTypeAny, {
|
|
452
|
+
model: string;
|
|
453
|
+
baseUrl: string;
|
|
454
|
+
apiKey?: string | undefined;
|
|
455
|
+
}, {
|
|
456
|
+
model?: string | undefined;
|
|
457
|
+
baseUrl?: string | undefined;
|
|
458
|
+
apiKey?: string | undefined;
|
|
459
|
+
}>>;
|
|
460
|
+
opencodeGo: z.ZodDefault<z.ZodObject<{
|
|
461
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
462
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
463
|
+
model: z.ZodDefault<z.ZodString>;
|
|
464
|
+
}, "strip", z.ZodTypeAny, {
|
|
465
|
+
model: string;
|
|
466
|
+
baseUrl: string;
|
|
467
|
+
apiKey?: string | undefined;
|
|
468
|
+
}, {
|
|
469
|
+
model?: string | undefined;
|
|
470
|
+
baseUrl?: string | undefined;
|
|
471
|
+
apiKey?: string | undefined;
|
|
472
|
+
}>>;
|
|
473
|
+
freemodel: z.ZodDefault<z.ZodObject<{
|
|
474
|
+
baseUrl: z.ZodDefault<z.ZodString>;
|
|
475
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
476
|
+
model: z.ZodDefault<z.ZodString>;
|
|
477
|
+
}, "strip", z.ZodTypeAny, {
|
|
478
|
+
model: string;
|
|
479
|
+
baseUrl: string;
|
|
480
|
+
apiKey?: string | undefined;
|
|
481
|
+
}, {
|
|
482
|
+
model?: string | undefined;
|
|
483
|
+
baseUrl?: string | undefined;
|
|
484
|
+
apiKey?: string | undefined;
|
|
485
|
+
}>>;
|
|
486
|
+
/**
|
|
487
|
+
* Generic OpenAI-compatible escape hatch (LM Studio, vLLM, custom
|
|
488
|
+
* self-hosted gateways, OpenRouter, Together, Anyscale, ...).
|
|
489
|
+
* Caller must provide `baseUrl` + `model`; `apiKey` optional.
|
|
490
|
+
* `name` is shown in logs and reports — defaults to "openai-compatible".
|
|
491
|
+
*/
|
|
492
|
+
openaiCompatible: z.ZodDefault<z.ZodObject<{
|
|
493
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
494
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
495
|
+
model: z.ZodOptional<z.ZodString>;
|
|
496
|
+
name: z.ZodDefault<z.ZodString>;
|
|
497
|
+
}, "strip", z.ZodTypeAny, {
|
|
498
|
+
name: string;
|
|
499
|
+
model?: string | undefined;
|
|
500
|
+
baseUrl?: string | undefined;
|
|
501
|
+
apiKey?: string | undefined;
|
|
502
|
+
}, {
|
|
503
|
+
model?: string | undefined;
|
|
504
|
+
baseUrl?: string | undefined;
|
|
505
|
+
apiKey?: string | undefined;
|
|
506
|
+
name?: string | undefined;
|
|
507
|
+
}>>;
|
|
508
|
+
}, "strip", z.ZodTypeAny, {
|
|
509
|
+
ollama: {
|
|
510
|
+
model: string;
|
|
511
|
+
temperature: number;
|
|
512
|
+
baseUrl: string;
|
|
513
|
+
};
|
|
514
|
+
gemini: {
|
|
515
|
+
model: string;
|
|
516
|
+
apiKey?: string | undefined;
|
|
517
|
+
};
|
|
518
|
+
groq: {
|
|
519
|
+
model: string;
|
|
520
|
+
apiKey?: string | undefined;
|
|
521
|
+
};
|
|
522
|
+
freemodel: {
|
|
523
|
+
model: string;
|
|
524
|
+
baseUrl: string;
|
|
525
|
+
apiKey?: string | undefined;
|
|
526
|
+
};
|
|
527
|
+
provider: "ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible" | "none";
|
|
528
|
+
fallback: ("ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible")[];
|
|
529
|
+
temperature: number;
|
|
530
|
+
timeoutMs: number;
|
|
531
|
+
tokenBudgetWarn: number;
|
|
532
|
+
clusterTokenBudget: number;
|
|
533
|
+
skipRerun: {
|
|
534
|
+
maxPasses: number;
|
|
535
|
+
delayMs: number;
|
|
536
|
+
};
|
|
537
|
+
viettelNetmind: {
|
|
538
|
+
model: string;
|
|
539
|
+
baseUrl: string;
|
|
540
|
+
apiKey?: string | undefined;
|
|
541
|
+
};
|
|
542
|
+
opencodeGo: {
|
|
543
|
+
model: string;
|
|
544
|
+
baseUrl: string;
|
|
545
|
+
apiKey?: string | undefined;
|
|
546
|
+
};
|
|
547
|
+
openaiCompatible: {
|
|
548
|
+
name: string;
|
|
549
|
+
model?: string | undefined;
|
|
550
|
+
baseUrl?: string | undefined;
|
|
551
|
+
apiKey?: string | undefined;
|
|
552
|
+
};
|
|
553
|
+
}, {
|
|
554
|
+
ollama?: {
|
|
555
|
+
model?: string | undefined;
|
|
556
|
+
temperature?: number | undefined;
|
|
557
|
+
baseUrl?: string | undefined;
|
|
558
|
+
} | undefined;
|
|
559
|
+
gemini?: {
|
|
560
|
+
model?: string | undefined;
|
|
561
|
+
apiKey?: string | undefined;
|
|
562
|
+
} | undefined;
|
|
563
|
+
groq?: {
|
|
564
|
+
model?: string | undefined;
|
|
565
|
+
apiKey?: string | undefined;
|
|
566
|
+
} | undefined;
|
|
567
|
+
freemodel?: {
|
|
568
|
+
model?: string | undefined;
|
|
569
|
+
baseUrl?: string | undefined;
|
|
570
|
+
apiKey?: string | undefined;
|
|
571
|
+
} | undefined;
|
|
572
|
+
provider?: "ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible" | "none" | undefined;
|
|
573
|
+
fallback?: ("ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible")[] | undefined;
|
|
574
|
+
temperature?: number | undefined;
|
|
575
|
+
timeoutMs?: number | undefined;
|
|
576
|
+
tokenBudgetWarn?: number | undefined;
|
|
577
|
+
clusterTokenBudget?: number | undefined;
|
|
578
|
+
skipRerun?: {
|
|
579
|
+
maxPasses?: number | undefined;
|
|
580
|
+
delayMs?: number | undefined;
|
|
581
|
+
} | undefined;
|
|
582
|
+
viettelNetmind?: {
|
|
583
|
+
model?: string | undefined;
|
|
584
|
+
baseUrl?: string | undefined;
|
|
585
|
+
apiKey?: string | undefined;
|
|
586
|
+
} | undefined;
|
|
587
|
+
opencodeGo?: {
|
|
588
|
+
model?: string | undefined;
|
|
589
|
+
baseUrl?: string | undefined;
|
|
590
|
+
apiKey?: string | undefined;
|
|
591
|
+
} | undefined;
|
|
592
|
+
openaiCompatible?: {
|
|
593
|
+
model?: string | undefined;
|
|
594
|
+
baseUrl?: string | undefined;
|
|
595
|
+
apiKey?: string | undefined;
|
|
596
|
+
name?: string | undefined;
|
|
597
|
+
} | undefined;
|
|
598
|
+
}>>;
|
|
599
|
+
report: z.ZodDefault<z.ZodObject<{
|
|
600
|
+
/**
|
|
601
|
+
* Default flipped to `markdown-compact` in 1.2.0 — most users found
|
|
602
|
+
* the per-finding full format overwhelming on real projects (6 500
|
|
603
|
+
* lines on a 650-finding run). Override to `markdown` for the full
|
|
604
|
+
* format, or pass `--full` on the CLI for a one-off run.
|
|
605
|
+
*/
|
|
606
|
+
format: z.ZodDefault<z.ZodEnum<["markdown", "markdown-compact", "json", "sarif"]>>;
|
|
607
|
+
output: z.ZodDefault<z.ZodString>;
|
|
608
|
+
groupBy: z.ZodDefault<z.ZodEnum<["severity", "file", "rule", "category"]>>;
|
|
609
|
+
includeSnippets: z.ZodDefault<z.ZodBoolean>;
|
|
610
|
+
}, "strip", z.ZodTypeAny, {
|
|
611
|
+
format: "markdown" | "markdown-compact" | "json" | "sarif";
|
|
612
|
+
output: string;
|
|
613
|
+
groupBy: "file" | "severity" | "category" | "rule";
|
|
614
|
+
includeSnippets: boolean;
|
|
615
|
+
}, {
|
|
616
|
+
format?: "markdown" | "markdown-compact" | "json" | "sarif" | undefined;
|
|
617
|
+
output?: string | undefined;
|
|
618
|
+
groupBy?: "file" | "severity" | "category" | "rule" | undefined;
|
|
619
|
+
includeSnippets?: boolean | undefined;
|
|
620
|
+
}>>;
|
|
621
|
+
review: z.ZodDefault<z.ZodObject<{
|
|
622
|
+
minSeverity: z.ZodDefault<z.ZodEnum<["info", "warning", "error", "blocker"]>>;
|
|
623
|
+
baseline: z.ZodDefault<z.ZodEnum<["apply", "ignore"]>>;
|
|
624
|
+
extraInstructions: z.ZodDefault<z.ZodString>;
|
|
625
|
+
/**
|
|
626
|
+
* Phase 07 profile contract. This is deliberately separate from machine
|
|
627
|
+
* `mode`: profile defines work/coverage, while mode only tunes the
|
|
628
|
+
* concurrency of work that the profile already permits.
|
|
629
|
+
*/
|
|
630
|
+
profile: z.ZodDefault<z.ZodEffects<z.ZodObject<{
|
|
631
|
+
name: z.ZodDefault<z.ZodEnum<["fast", "deep"]>>;
|
|
632
|
+
ai: z.ZodDefault<z.ZodEnum<["disabled", "advisory", "blocking"]>>;
|
|
633
|
+
maxBudgetMs: z.ZodOptional<z.ZodNumber>;
|
|
634
|
+
}, "strip", z.ZodTypeAny, {
|
|
635
|
+
name: "fast" | "deep";
|
|
636
|
+
ai: "disabled" | "advisory" | "blocking";
|
|
637
|
+
maxBudgetMs?: number | undefined;
|
|
638
|
+
}, {
|
|
639
|
+
name?: "fast" | "deep" | undefined;
|
|
640
|
+
ai?: "disabled" | "advisory" | "blocking" | undefined;
|
|
641
|
+
maxBudgetMs?: number | undefined;
|
|
642
|
+
}>, {
|
|
643
|
+
name: "fast" | "deep";
|
|
644
|
+
ai: "disabled" | "advisory" | "blocking";
|
|
645
|
+
maxBudgetMs?: number | undefined;
|
|
646
|
+
}, {
|
|
647
|
+
name?: "fast" | "deep" | undefined;
|
|
648
|
+
ai?: "disabled" | "advisory" | "blocking" | undefined;
|
|
649
|
+
maxBudgetMs?: number | undefined;
|
|
650
|
+
}>>;
|
|
651
|
+
/**
|
|
652
|
+
* Merge-gate policy (Quality Roadmap C3, [ADR-0028]). Controls how a
|
|
653
|
+
* finding's SOURCE affects the exit code. Deterministic sources (static
|
|
654
|
+
* rules incl. taint) ALWAYS gate at `error`+; this block governs only
|
|
655
|
+
* AI-sourced (`kind: 'ai'`) findings, whose non-determinism would
|
|
656
|
+
* otherwise make the gate flaky.
|
|
657
|
+
*
|
|
658
|
+
* - `aiPolicy: 'advisory'` (default) — AI findings never change the exit
|
|
659
|
+
* code; the gate is purely deterministic. Safest / most stable.
|
|
660
|
+
* - `'high-confidence'` — an AI finding gates only when `error`+ AND its
|
|
661
|
+
* confidence ≥ `aiMinConfidence`.
|
|
662
|
+
* - `'blocking'` — AI findings gate at `error`+ regardless of confidence
|
|
663
|
+
* (pre-C3 behavior).
|
|
664
|
+
*
|
|
665
|
+
* `aiSkipPolicy` (AI-resilience, [ADR-0029]) is a SEPARATE axis: it
|
|
666
|
+
* governs how INCOMPLETE AI coverage (recall-risk skips — provider down /
|
|
667
|
+
* parse failure / prompt-load) affects the gate, independent of whether
|
|
668
|
+
* AI findings gate. `'warn'` (default) surfaces loudly but keeps the exit
|
|
669
|
+
* code finding-driven; `'fail'` forces a non-zero exit when a recall-risk
|
|
670
|
+
* skip remains after the re-run pass; `'ignore'` is the pre-ADR-0029
|
|
671
|
+
* behavior. This is what makes a green gate honestly mean "AI ran".
|
|
672
|
+
*
|
|
673
|
+
* [ADR-0028]: ../../../docs/DECISIONS/0028-ai-gate-policy-blocking-advisory.md
|
|
674
|
+
* [ADR-0029]: ../../../docs/DECISIONS/0029-ai-coverage-resilience.md
|
|
675
|
+
*/
|
|
676
|
+
gate: z.ZodDefault<z.ZodObject<{
|
|
677
|
+
aiPolicy: z.ZodDefault<z.ZodEnum<["advisory", "high-confidence", "blocking"]>>;
|
|
678
|
+
aiMinConfidence: z.ZodDefault<z.ZodNumber>;
|
|
679
|
+
aiSkipPolicy: z.ZodDefault<z.ZodEnum<["ignore", "warn", "fail"]>>;
|
|
680
|
+
}, "strip", z.ZodTypeAny, {
|
|
681
|
+
aiPolicy: "advisory" | "blocking" | "high-confidence";
|
|
682
|
+
aiMinConfidence: number;
|
|
683
|
+
aiSkipPolicy: "ignore" | "warn" | "fail";
|
|
684
|
+
}, {
|
|
685
|
+
aiPolicy?: "advisory" | "blocking" | "high-confidence" | undefined;
|
|
686
|
+
aiMinConfidence?: number | undefined;
|
|
687
|
+
aiSkipPolicy?: "ignore" | "warn" | "fail" | undefined;
|
|
688
|
+
}>>;
|
|
689
|
+
}, "strip", z.ZodTypeAny, {
|
|
690
|
+
minSeverity: "error" | "info" | "warning" | "blocker";
|
|
691
|
+
baseline: "ignore" | "apply";
|
|
692
|
+
extraInstructions: string;
|
|
693
|
+
profile: {
|
|
694
|
+
name: "fast" | "deep";
|
|
695
|
+
ai: "disabled" | "advisory" | "blocking";
|
|
696
|
+
maxBudgetMs?: number | undefined;
|
|
697
|
+
};
|
|
698
|
+
gate: {
|
|
699
|
+
aiPolicy: "advisory" | "blocking" | "high-confidence";
|
|
700
|
+
aiMinConfidence: number;
|
|
701
|
+
aiSkipPolicy: "ignore" | "warn" | "fail";
|
|
702
|
+
};
|
|
703
|
+
}, {
|
|
704
|
+
minSeverity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
705
|
+
baseline?: "ignore" | "apply" | undefined;
|
|
706
|
+
extraInstructions?: string | undefined;
|
|
707
|
+
profile?: {
|
|
708
|
+
name?: "fast" | "deep" | undefined;
|
|
709
|
+
ai?: "disabled" | "advisory" | "blocking" | undefined;
|
|
710
|
+
maxBudgetMs?: number | undefined;
|
|
711
|
+
} | undefined;
|
|
712
|
+
gate?: {
|
|
713
|
+
aiPolicy?: "advisory" | "blocking" | "high-confidence" | undefined;
|
|
714
|
+
aiMinConfidence?: number | undefined;
|
|
715
|
+
aiSkipPolicy?: "ignore" | "warn" | "fail" | undefined;
|
|
716
|
+
} | undefined;
|
|
717
|
+
}>>;
|
|
718
|
+
prReview: z.ZodDefault<z.ZodObject<{
|
|
719
|
+
maxInlineComments: z.ZodDefault<z.ZodNumber>;
|
|
720
|
+
minSeverity: z.ZodDefault<z.ZodEnum<["info", "warning", "error", "blocker"]>>;
|
|
721
|
+
minConfidence: z.ZodDefault<z.ZodNumber>;
|
|
722
|
+
applyBaseline: z.ZodDefault<z.ZodBoolean>;
|
|
723
|
+
aiStrategy: z.ZodDefault<z.ZodEnum<["adaptive", "diff-only", "grouped", "specialized", "targeted"]>>;
|
|
724
|
+
diffReview: z.ZodDefault<z.ZodObject<{
|
|
725
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
726
|
+
maxChunkCalls: z.ZodDefault<z.ZodNumber>;
|
|
727
|
+
}, "strip", z.ZodTypeAny, {
|
|
728
|
+
enabled: boolean;
|
|
729
|
+
maxChunkCalls: number;
|
|
730
|
+
}, {
|
|
731
|
+
enabled?: boolean | undefined;
|
|
732
|
+
maxChunkCalls?: number | undefined;
|
|
733
|
+
}>>;
|
|
734
|
+
primarySelection: z.ZodDefault<z.ZodObject<{
|
|
735
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
736
|
+
maxPrimaryFiles: z.ZodDefault<z.ZodNumber>;
|
|
737
|
+
minRiskScore: z.ZodDefault<z.ZodNumber>;
|
|
738
|
+
includeLayers: z.ZodDefault<z.ZodArray<z.ZodEnum<["controller", "service", "repository", "dto", "entity", "mapper", "component", "ng-service", "module", "directive", "pipe", "model", "test", "config", "generated", "entry", "unknown"]>, "many">>;
|
|
739
|
+
excludePatterns: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
740
|
+
}, "strip", z.ZodTypeAny, {
|
|
741
|
+
enabled: boolean;
|
|
742
|
+
maxPrimaryFiles: number;
|
|
743
|
+
minRiskScore: number;
|
|
744
|
+
includeLayers: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[];
|
|
745
|
+
excludePatterns: string[];
|
|
746
|
+
}, {
|
|
747
|
+
enabled?: boolean | undefined;
|
|
748
|
+
maxPrimaryFiles?: number | undefined;
|
|
749
|
+
minRiskScore?: number | undefined;
|
|
750
|
+
includeLayers?: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[] | undefined;
|
|
751
|
+
excludePatterns?: string[] | undefined;
|
|
752
|
+
}>>;
|
|
753
|
+
groupedRules: z.ZodDefault<z.ZodObject<{
|
|
754
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
755
|
+
maxGroupsPerFile: z.ZodDefault<z.ZodNumber>;
|
|
756
|
+
maxRulesPerGroup: z.ZodDefault<z.ZodNumber>;
|
|
757
|
+
}, "strip", z.ZodTypeAny, {
|
|
758
|
+
enabled: boolean;
|
|
759
|
+
maxGroupsPerFile: number;
|
|
760
|
+
maxRulesPerGroup: number;
|
|
761
|
+
}, {
|
|
762
|
+
enabled?: boolean | undefined;
|
|
763
|
+
maxGroupsPerFile?: number | undefined;
|
|
764
|
+
maxRulesPerGroup?: number | undefined;
|
|
765
|
+
}>>;
|
|
766
|
+
specializedRules: z.ZodDefault<z.ZodObject<{
|
|
767
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
768
|
+
maxCalls: z.ZodDefault<z.ZodNumber>;
|
|
769
|
+
}, "strip", z.ZodTypeAny, {
|
|
770
|
+
enabled: boolean;
|
|
771
|
+
maxCalls: number;
|
|
772
|
+
}, {
|
|
773
|
+
enabled?: boolean | undefined;
|
|
774
|
+
maxCalls?: number | undefined;
|
|
775
|
+
}>>;
|
|
776
|
+
riskScoring: z.ZodDefault<z.ZodObject<{
|
|
777
|
+
layer: z.ZodDefault<z.ZodRecord<z.ZodEnum<["controller", "service", "repository", "dto", "entity", "mapper", "component", "ng-service", "module", "directive", "pipe", "model", "test", "config", "generated", "entry", "unknown"]>, z.ZodNumber>>;
|
|
778
|
+
signals: z.ZodDefault<z.ZodObject<{
|
|
779
|
+
hasTransactional: z.ZodDefault<z.ZodNumber>;
|
|
780
|
+
hasDbWrite: z.ZodDefault<z.ZodNumber>;
|
|
781
|
+
hasLoopWithDbCall: z.ZodDefault<z.ZodNumber>;
|
|
782
|
+
hasUserIdOrTenantId: z.ZodDefault<z.ZodNumber>;
|
|
783
|
+
hasPermissionCheck: z.ZodDefault<z.ZodNumber>;
|
|
784
|
+
hasExternalIO: z.ZodDefault<z.ZodNumber>;
|
|
785
|
+
hasExceptionHandlingChange: z.ZodDefault<z.ZodNumber>;
|
|
786
|
+
hasMoneyOrStatusLogic: z.ZodDefault<z.ZodNumber>;
|
|
787
|
+
hasDiffReviewFinding: z.ZodDefault<z.ZodNumber>;
|
|
788
|
+
}, "strip", z.ZodTypeAny, {
|
|
789
|
+
hasTransactional: number;
|
|
790
|
+
hasDbWrite: number;
|
|
791
|
+
hasLoopWithDbCall: number;
|
|
792
|
+
hasUserIdOrTenantId: number;
|
|
793
|
+
hasPermissionCheck: number;
|
|
794
|
+
hasExternalIO: number;
|
|
795
|
+
hasExceptionHandlingChange: number;
|
|
796
|
+
hasMoneyOrStatusLogic: number;
|
|
797
|
+
hasDiffReviewFinding: number;
|
|
798
|
+
}, {
|
|
799
|
+
hasTransactional?: number | undefined;
|
|
800
|
+
hasDbWrite?: number | undefined;
|
|
801
|
+
hasLoopWithDbCall?: number | undefined;
|
|
802
|
+
hasUserIdOrTenantId?: number | undefined;
|
|
803
|
+
hasPermissionCheck?: number | undefined;
|
|
804
|
+
hasExternalIO?: number | undefined;
|
|
805
|
+
hasExceptionHandlingChange?: number | undefined;
|
|
806
|
+
hasMoneyOrStatusLogic?: number | undefined;
|
|
807
|
+
hasDiffReviewFinding?: number | undefined;
|
|
808
|
+
}>>;
|
|
809
|
+
}, "strip", z.ZodTypeAny, {
|
|
810
|
+
layer: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>>;
|
|
811
|
+
signals: {
|
|
812
|
+
hasTransactional: number;
|
|
813
|
+
hasDbWrite: number;
|
|
814
|
+
hasLoopWithDbCall: number;
|
|
815
|
+
hasUserIdOrTenantId: number;
|
|
816
|
+
hasPermissionCheck: number;
|
|
817
|
+
hasExternalIO: number;
|
|
818
|
+
hasExceptionHandlingChange: number;
|
|
819
|
+
hasMoneyOrStatusLogic: number;
|
|
820
|
+
hasDiffReviewFinding: number;
|
|
821
|
+
};
|
|
822
|
+
}, {
|
|
823
|
+
layer?: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>> | undefined;
|
|
824
|
+
signals?: {
|
|
825
|
+
hasTransactional?: number | undefined;
|
|
826
|
+
hasDbWrite?: number | undefined;
|
|
827
|
+
hasLoopWithDbCall?: number | undefined;
|
|
828
|
+
hasUserIdOrTenantId?: number | undefined;
|
|
829
|
+
hasPermissionCheck?: number | undefined;
|
|
830
|
+
hasExternalIO?: number | undefined;
|
|
831
|
+
hasExceptionHandlingChange?: number | undefined;
|
|
832
|
+
hasMoneyOrStatusLogic?: number | undefined;
|
|
833
|
+
hasDiffReviewFinding?: number | undefined;
|
|
834
|
+
} | undefined;
|
|
835
|
+
}>>;
|
|
836
|
+
/**
|
|
837
|
+
* Legacy PR AI toggles. `aiStrategy: specialized` preserves the old
|
|
838
|
+
* per-file/per-rule AI scan behavior. `adaptive`, `grouped`, and
|
|
839
|
+
* `diff-only` use the routed AI pipeline instead.
|
|
840
|
+
*/
|
|
841
|
+
aiRules: z.ZodDefault<z.ZodBoolean>;
|
|
842
|
+
aiDiffReview: z.ZodDefault<z.ZodBoolean>;
|
|
843
|
+
maxSupportFiles: z.ZodDefault<z.ZodNumber>;
|
|
844
|
+
diffChunkTokenBudget: z.ZodDefault<z.ZodNumber>;
|
|
845
|
+
maxAiCalls: z.ZodDefault<z.ZodNumber>;
|
|
846
|
+
codeQualityOutput: z.ZodDefault<z.ZodString>;
|
|
847
|
+
gitlabTokenEnv: z.ZodDefault<z.ZodString>;
|
|
848
|
+
cleanupExistingComments: z.ZodDefault<z.ZodBoolean>;
|
|
849
|
+
excludes: z.ZodDefault<z.ZodObject<{
|
|
850
|
+
generated: z.ZodDefault<z.ZodBoolean>;
|
|
851
|
+
lockfiles: z.ZodDefault<z.ZodBoolean>;
|
|
852
|
+
minified: z.ZodDefault<z.ZodBoolean>;
|
|
853
|
+
}, "strip", z.ZodTypeAny, {
|
|
854
|
+
generated: boolean;
|
|
855
|
+
lockfiles: boolean;
|
|
856
|
+
minified: boolean;
|
|
857
|
+
}, {
|
|
858
|
+
generated?: boolean | undefined;
|
|
859
|
+
lockfiles?: boolean | undefined;
|
|
860
|
+
minified?: boolean | undefined;
|
|
861
|
+
}>>;
|
|
862
|
+
}, "strip", z.ZodTypeAny, {
|
|
863
|
+
minSeverity: "error" | "info" | "warning" | "blocker";
|
|
864
|
+
maxInlineComments: number;
|
|
865
|
+
minConfidence: number;
|
|
866
|
+
applyBaseline: boolean;
|
|
867
|
+
aiStrategy: "adaptive" | "diff-only" | "grouped" | "specialized" | "targeted";
|
|
868
|
+
diffReview: {
|
|
869
|
+
enabled: boolean;
|
|
870
|
+
maxChunkCalls: number;
|
|
871
|
+
};
|
|
872
|
+
primarySelection: {
|
|
873
|
+
enabled: boolean;
|
|
874
|
+
maxPrimaryFiles: number;
|
|
875
|
+
minRiskScore: number;
|
|
876
|
+
includeLayers: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[];
|
|
877
|
+
excludePatterns: string[];
|
|
878
|
+
};
|
|
879
|
+
groupedRules: {
|
|
880
|
+
enabled: boolean;
|
|
881
|
+
maxGroupsPerFile: number;
|
|
882
|
+
maxRulesPerGroup: number;
|
|
883
|
+
};
|
|
884
|
+
specializedRules: {
|
|
885
|
+
enabled: boolean;
|
|
886
|
+
maxCalls: number;
|
|
887
|
+
};
|
|
888
|
+
riskScoring: {
|
|
889
|
+
layer: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>>;
|
|
890
|
+
signals: {
|
|
891
|
+
hasTransactional: number;
|
|
892
|
+
hasDbWrite: number;
|
|
893
|
+
hasLoopWithDbCall: number;
|
|
894
|
+
hasUserIdOrTenantId: number;
|
|
895
|
+
hasPermissionCheck: number;
|
|
896
|
+
hasExternalIO: number;
|
|
897
|
+
hasExceptionHandlingChange: number;
|
|
898
|
+
hasMoneyOrStatusLogic: number;
|
|
899
|
+
hasDiffReviewFinding: number;
|
|
900
|
+
};
|
|
901
|
+
};
|
|
902
|
+
aiRules: boolean;
|
|
903
|
+
aiDiffReview: boolean;
|
|
904
|
+
maxSupportFiles: number;
|
|
905
|
+
diffChunkTokenBudget: number;
|
|
906
|
+
maxAiCalls: number;
|
|
907
|
+
codeQualityOutput: string;
|
|
908
|
+
gitlabTokenEnv: string;
|
|
909
|
+
cleanupExistingComments: boolean;
|
|
910
|
+
excludes: {
|
|
911
|
+
generated: boolean;
|
|
912
|
+
lockfiles: boolean;
|
|
913
|
+
minified: boolean;
|
|
914
|
+
};
|
|
915
|
+
}, {
|
|
916
|
+
minSeverity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
917
|
+
maxInlineComments?: number | undefined;
|
|
918
|
+
minConfidence?: number | undefined;
|
|
919
|
+
applyBaseline?: boolean | undefined;
|
|
920
|
+
aiStrategy?: "adaptive" | "diff-only" | "grouped" | "specialized" | "targeted" | undefined;
|
|
921
|
+
diffReview?: {
|
|
922
|
+
enabled?: boolean | undefined;
|
|
923
|
+
maxChunkCalls?: number | undefined;
|
|
924
|
+
} | undefined;
|
|
925
|
+
primarySelection?: {
|
|
926
|
+
enabled?: boolean | undefined;
|
|
927
|
+
maxPrimaryFiles?: number | undefined;
|
|
928
|
+
minRiskScore?: number | undefined;
|
|
929
|
+
includeLayers?: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[] | undefined;
|
|
930
|
+
excludePatterns?: string[] | undefined;
|
|
931
|
+
} | undefined;
|
|
932
|
+
groupedRules?: {
|
|
933
|
+
enabled?: boolean | undefined;
|
|
934
|
+
maxGroupsPerFile?: number | undefined;
|
|
935
|
+
maxRulesPerGroup?: number | undefined;
|
|
936
|
+
} | undefined;
|
|
937
|
+
specializedRules?: {
|
|
938
|
+
enabled?: boolean | undefined;
|
|
939
|
+
maxCalls?: number | undefined;
|
|
940
|
+
} | undefined;
|
|
941
|
+
riskScoring?: {
|
|
942
|
+
layer?: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>> | undefined;
|
|
943
|
+
signals?: {
|
|
944
|
+
hasTransactional?: number | undefined;
|
|
945
|
+
hasDbWrite?: number | undefined;
|
|
946
|
+
hasLoopWithDbCall?: number | undefined;
|
|
947
|
+
hasUserIdOrTenantId?: number | undefined;
|
|
948
|
+
hasPermissionCheck?: number | undefined;
|
|
949
|
+
hasExternalIO?: number | undefined;
|
|
950
|
+
hasExceptionHandlingChange?: number | undefined;
|
|
951
|
+
hasMoneyOrStatusLogic?: number | undefined;
|
|
952
|
+
hasDiffReviewFinding?: number | undefined;
|
|
953
|
+
} | undefined;
|
|
954
|
+
} | undefined;
|
|
955
|
+
aiRules?: boolean | undefined;
|
|
956
|
+
aiDiffReview?: boolean | undefined;
|
|
957
|
+
maxSupportFiles?: number | undefined;
|
|
958
|
+
diffChunkTokenBudget?: number | undefined;
|
|
959
|
+
maxAiCalls?: number | undefined;
|
|
960
|
+
codeQualityOutput?: string | undefined;
|
|
961
|
+
gitlabTokenEnv?: string | undefined;
|
|
962
|
+
cleanupExistingComments?: boolean | undefined;
|
|
963
|
+
excludes?: {
|
|
964
|
+
generated?: boolean | undefined;
|
|
965
|
+
lockfiles?: boolean | undefined;
|
|
966
|
+
minified?: boolean | undefined;
|
|
967
|
+
} | undefined;
|
|
968
|
+
}>>;
|
|
969
|
+
storage: z.ZodDefault<z.ZodObject<{
|
|
970
|
+
dbPath: z.ZodDefault<z.ZodString>;
|
|
971
|
+
retainRuns: z.ZodDefault<z.ZodNumber>;
|
|
972
|
+
}, "strip", z.ZodTypeAny, {
|
|
973
|
+
dbPath: string;
|
|
974
|
+
retainRuns: number;
|
|
975
|
+
}, {
|
|
976
|
+
dbPath?: string | undefined;
|
|
977
|
+
retainRuns?: number | undefined;
|
|
978
|
+
}>>;
|
|
979
|
+
/**
|
|
980
|
+
* Centralized dashboard (ADR-0026). Where `cs push` sends a finished run.
|
|
981
|
+
* Optional — when unset, `cs push` requires `--server` on the CLI. Use
|
|
982
|
+
* `${ENV_VAR}` interpolation for the token so secrets stay out of the file.
|
|
983
|
+
*/
|
|
984
|
+
dashboard: z.ZodDefault<z.ZodObject<{
|
|
985
|
+
/** Base URL of the @code-sentinel/server instance, e.g. `https://codesentinel.vtscloud.vn`. */
|
|
986
|
+
serverUrl: z.ZodOptional<z.ZodString>;
|
|
987
|
+
/** Project-scoped bearer token for `POST /api/runs`. */
|
|
988
|
+
token: z.ZodOptional<z.ZodString>;
|
|
989
|
+
/** Stable project id used by the dashboard for project-scoped access and filtering. */
|
|
990
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
991
|
+
}, "strip", z.ZodTypeAny, {
|
|
992
|
+
serverUrl?: string | undefined;
|
|
993
|
+
projectId?: string | undefined;
|
|
994
|
+
token?: string | undefined;
|
|
995
|
+
}, {
|
|
996
|
+
serverUrl?: string | undefined;
|
|
997
|
+
projectId?: string | undefined;
|
|
998
|
+
token?: string | undefined;
|
|
999
|
+
}>>;
|
|
1000
|
+
}, "strip", z.ZodTypeAny, {
|
|
1001
|
+
mode: "economy" | "balanced" | "performance" | "auto";
|
|
1002
|
+
include: string[];
|
|
1003
|
+
exclude: string[];
|
|
1004
|
+
rules: {
|
|
1005
|
+
enabled: string[];
|
|
1006
|
+
disabled: string[];
|
|
1007
|
+
packs: string[];
|
|
1008
|
+
projectCustomExecution: ("local" | "ci")[];
|
|
1009
|
+
overrides: Record<string, {
|
|
1010
|
+
options?: Record<string, unknown> | undefined;
|
|
1011
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1012
|
+
confidence?: number | undefined;
|
|
1013
|
+
enabled?: boolean | undefined;
|
|
1014
|
+
}>;
|
|
1015
|
+
pathOverrides: {
|
|
1016
|
+
paths: string[];
|
|
1017
|
+
disabled?: string[] | undefined;
|
|
1018
|
+
overrides?: Record<string, {
|
|
1019
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1020
|
+
confidence?: number | undefined;
|
|
1021
|
+
enabled?: boolean | undefined;
|
|
1022
|
+
}> | undefined;
|
|
1023
|
+
}[];
|
|
1024
|
+
};
|
|
1025
|
+
ai: {
|
|
1026
|
+
ollama: {
|
|
1027
|
+
model: string;
|
|
1028
|
+
temperature: number;
|
|
1029
|
+
baseUrl: string;
|
|
1030
|
+
};
|
|
1031
|
+
gemini: {
|
|
1032
|
+
model: string;
|
|
1033
|
+
apiKey?: string | undefined;
|
|
1034
|
+
};
|
|
1035
|
+
groq: {
|
|
1036
|
+
model: string;
|
|
1037
|
+
apiKey?: string | undefined;
|
|
1038
|
+
};
|
|
1039
|
+
freemodel: {
|
|
1040
|
+
model: string;
|
|
1041
|
+
baseUrl: string;
|
|
1042
|
+
apiKey?: string | undefined;
|
|
1043
|
+
};
|
|
1044
|
+
provider: "ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible" | "none";
|
|
1045
|
+
fallback: ("ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible")[];
|
|
1046
|
+
temperature: number;
|
|
1047
|
+
timeoutMs: number;
|
|
1048
|
+
tokenBudgetWarn: number;
|
|
1049
|
+
clusterTokenBudget: number;
|
|
1050
|
+
skipRerun: {
|
|
1051
|
+
maxPasses: number;
|
|
1052
|
+
delayMs: number;
|
|
1053
|
+
};
|
|
1054
|
+
viettelNetmind: {
|
|
1055
|
+
model: string;
|
|
1056
|
+
baseUrl: string;
|
|
1057
|
+
apiKey?: string | undefined;
|
|
1058
|
+
};
|
|
1059
|
+
opencodeGo: {
|
|
1060
|
+
model: string;
|
|
1061
|
+
baseUrl: string;
|
|
1062
|
+
apiKey?: string | undefined;
|
|
1063
|
+
};
|
|
1064
|
+
openaiCompatible: {
|
|
1065
|
+
name: string;
|
|
1066
|
+
model?: string | undefined;
|
|
1067
|
+
baseUrl?: string | undefined;
|
|
1068
|
+
apiKey?: string | undefined;
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1071
|
+
report: {
|
|
1072
|
+
format: "markdown" | "markdown-compact" | "json" | "sarif";
|
|
1073
|
+
output: string;
|
|
1074
|
+
groupBy: "file" | "severity" | "category" | "rule";
|
|
1075
|
+
includeSnippets: boolean;
|
|
1076
|
+
};
|
|
1077
|
+
review: {
|
|
1078
|
+
minSeverity: "error" | "info" | "warning" | "blocker";
|
|
1079
|
+
baseline: "ignore" | "apply";
|
|
1080
|
+
extraInstructions: string;
|
|
1081
|
+
profile: {
|
|
1082
|
+
name: "fast" | "deep";
|
|
1083
|
+
ai: "disabled" | "advisory" | "blocking";
|
|
1084
|
+
maxBudgetMs?: number | undefined;
|
|
1085
|
+
};
|
|
1086
|
+
gate: {
|
|
1087
|
+
aiPolicy: "advisory" | "blocking" | "high-confidence";
|
|
1088
|
+
aiMinConfidence: number;
|
|
1089
|
+
aiSkipPolicy: "ignore" | "warn" | "fail";
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
prReview: {
|
|
1093
|
+
minSeverity: "error" | "info" | "warning" | "blocker";
|
|
1094
|
+
maxInlineComments: number;
|
|
1095
|
+
minConfidence: number;
|
|
1096
|
+
applyBaseline: boolean;
|
|
1097
|
+
aiStrategy: "adaptive" | "diff-only" | "grouped" | "specialized" | "targeted";
|
|
1098
|
+
diffReview: {
|
|
1099
|
+
enabled: boolean;
|
|
1100
|
+
maxChunkCalls: number;
|
|
1101
|
+
};
|
|
1102
|
+
primarySelection: {
|
|
1103
|
+
enabled: boolean;
|
|
1104
|
+
maxPrimaryFiles: number;
|
|
1105
|
+
minRiskScore: number;
|
|
1106
|
+
includeLayers: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[];
|
|
1107
|
+
excludePatterns: string[];
|
|
1108
|
+
};
|
|
1109
|
+
groupedRules: {
|
|
1110
|
+
enabled: boolean;
|
|
1111
|
+
maxGroupsPerFile: number;
|
|
1112
|
+
maxRulesPerGroup: number;
|
|
1113
|
+
};
|
|
1114
|
+
specializedRules: {
|
|
1115
|
+
enabled: boolean;
|
|
1116
|
+
maxCalls: number;
|
|
1117
|
+
};
|
|
1118
|
+
riskScoring: {
|
|
1119
|
+
layer: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>>;
|
|
1120
|
+
signals: {
|
|
1121
|
+
hasTransactional: number;
|
|
1122
|
+
hasDbWrite: number;
|
|
1123
|
+
hasLoopWithDbCall: number;
|
|
1124
|
+
hasUserIdOrTenantId: number;
|
|
1125
|
+
hasPermissionCheck: number;
|
|
1126
|
+
hasExternalIO: number;
|
|
1127
|
+
hasExceptionHandlingChange: number;
|
|
1128
|
+
hasMoneyOrStatusLogic: number;
|
|
1129
|
+
hasDiffReviewFinding: number;
|
|
1130
|
+
};
|
|
1131
|
+
};
|
|
1132
|
+
aiRules: boolean;
|
|
1133
|
+
aiDiffReview: boolean;
|
|
1134
|
+
maxSupportFiles: number;
|
|
1135
|
+
diffChunkTokenBudget: number;
|
|
1136
|
+
maxAiCalls: number;
|
|
1137
|
+
codeQualityOutput: string;
|
|
1138
|
+
gitlabTokenEnv: string;
|
|
1139
|
+
cleanupExistingComments: boolean;
|
|
1140
|
+
excludes: {
|
|
1141
|
+
generated: boolean;
|
|
1142
|
+
lockfiles: boolean;
|
|
1143
|
+
minified: boolean;
|
|
1144
|
+
};
|
|
1145
|
+
};
|
|
1146
|
+
storage: {
|
|
1147
|
+
dbPath: string;
|
|
1148
|
+
retainRuns: number;
|
|
1149
|
+
};
|
|
1150
|
+
dashboard: {
|
|
1151
|
+
serverUrl?: string | undefined;
|
|
1152
|
+
projectId?: string | undefined;
|
|
1153
|
+
token?: string | undefined;
|
|
1154
|
+
};
|
|
1155
|
+
}, {
|
|
1156
|
+
mode?: "economy" | "balanced" | "performance" | "auto" | undefined;
|
|
1157
|
+
include?: string[] | undefined;
|
|
1158
|
+
exclude?: string[] | undefined;
|
|
1159
|
+
rules?: {
|
|
1160
|
+
enabled?: string[] | undefined;
|
|
1161
|
+
disabled?: string[] | undefined;
|
|
1162
|
+
packs?: string[] | undefined;
|
|
1163
|
+
projectCustomExecution?: ("local" | "ci")[] | undefined;
|
|
1164
|
+
overrides?: Record<string, {
|
|
1165
|
+
options?: Record<string, unknown> | undefined;
|
|
1166
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1167
|
+
confidence?: number | undefined;
|
|
1168
|
+
enabled?: boolean | undefined;
|
|
1169
|
+
}> | undefined;
|
|
1170
|
+
pathOverrides?: {
|
|
1171
|
+
paths: string[];
|
|
1172
|
+
disabled?: string[] | undefined;
|
|
1173
|
+
overrides?: Record<string, {
|
|
1174
|
+
severity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1175
|
+
confidence?: number | undefined;
|
|
1176
|
+
enabled?: boolean | undefined;
|
|
1177
|
+
}> | undefined;
|
|
1178
|
+
}[] | undefined;
|
|
1179
|
+
} | undefined;
|
|
1180
|
+
ai?: {
|
|
1181
|
+
ollama?: {
|
|
1182
|
+
model?: string | undefined;
|
|
1183
|
+
temperature?: number | undefined;
|
|
1184
|
+
baseUrl?: string | undefined;
|
|
1185
|
+
} | undefined;
|
|
1186
|
+
gemini?: {
|
|
1187
|
+
model?: string | undefined;
|
|
1188
|
+
apiKey?: string | undefined;
|
|
1189
|
+
} | undefined;
|
|
1190
|
+
groq?: {
|
|
1191
|
+
model?: string | undefined;
|
|
1192
|
+
apiKey?: string | undefined;
|
|
1193
|
+
} | undefined;
|
|
1194
|
+
freemodel?: {
|
|
1195
|
+
model?: string | undefined;
|
|
1196
|
+
baseUrl?: string | undefined;
|
|
1197
|
+
apiKey?: string | undefined;
|
|
1198
|
+
} | undefined;
|
|
1199
|
+
provider?: "ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible" | "none" | undefined;
|
|
1200
|
+
fallback?: ("ollama" | "gemini" | "groq" | "viettel-netmind" | "opencode-go" | "freemodel" | "openai-compatible")[] | undefined;
|
|
1201
|
+
temperature?: number | undefined;
|
|
1202
|
+
timeoutMs?: number | undefined;
|
|
1203
|
+
tokenBudgetWarn?: number | undefined;
|
|
1204
|
+
clusterTokenBudget?: number | undefined;
|
|
1205
|
+
skipRerun?: {
|
|
1206
|
+
maxPasses?: number | undefined;
|
|
1207
|
+
delayMs?: number | undefined;
|
|
1208
|
+
} | undefined;
|
|
1209
|
+
viettelNetmind?: {
|
|
1210
|
+
model?: string | undefined;
|
|
1211
|
+
baseUrl?: string | undefined;
|
|
1212
|
+
apiKey?: string | undefined;
|
|
1213
|
+
} | undefined;
|
|
1214
|
+
opencodeGo?: {
|
|
1215
|
+
model?: string | undefined;
|
|
1216
|
+
baseUrl?: string | undefined;
|
|
1217
|
+
apiKey?: string | undefined;
|
|
1218
|
+
} | undefined;
|
|
1219
|
+
openaiCompatible?: {
|
|
1220
|
+
model?: string | undefined;
|
|
1221
|
+
baseUrl?: string | undefined;
|
|
1222
|
+
apiKey?: string | undefined;
|
|
1223
|
+
name?: string | undefined;
|
|
1224
|
+
} | undefined;
|
|
1225
|
+
} | undefined;
|
|
1226
|
+
report?: {
|
|
1227
|
+
format?: "markdown" | "markdown-compact" | "json" | "sarif" | undefined;
|
|
1228
|
+
output?: string | undefined;
|
|
1229
|
+
groupBy?: "file" | "severity" | "category" | "rule" | undefined;
|
|
1230
|
+
includeSnippets?: boolean | undefined;
|
|
1231
|
+
} | undefined;
|
|
1232
|
+
review?: {
|
|
1233
|
+
minSeverity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1234
|
+
baseline?: "ignore" | "apply" | undefined;
|
|
1235
|
+
extraInstructions?: string | undefined;
|
|
1236
|
+
profile?: {
|
|
1237
|
+
name?: "fast" | "deep" | undefined;
|
|
1238
|
+
ai?: "disabled" | "advisory" | "blocking" | undefined;
|
|
1239
|
+
maxBudgetMs?: number | undefined;
|
|
1240
|
+
} | undefined;
|
|
1241
|
+
gate?: {
|
|
1242
|
+
aiPolicy?: "advisory" | "blocking" | "high-confidence" | undefined;
|
|
1243
|
+
aiMinConfidence?: number | undefined;
|
|
1244
|
+
aiSkipPolicy?: "ignore" | "warn" | "fail" | undefined;
|
|
1245
|
+
} | undefined;
|
|
1246
|
+
} | undefined;
|
|
1247
|
+
prReview?: {
|
|
1248
|
+
minSeverity?: "error" | "info" | "warning" | "blocker" | undefined;
|
|
1249
|
+
maxInlineComments?: number | undefined;
|
|
1250
|
+
minConfidence?: number | undefined;
|
|
1251
|
+
applyBaseline?: boolean | undefined;
|
|
1252
|
+
aiStrategy?: "adaptive" | "diff-only" | "grouped" | "specialized" | "targeted" | undefined;
|
|
1253
|
+
diffReview?: {
|
|
1254
|
+
enabled?: boolean | undefined;
|
|
1255
|
+
maxChunkCalls?: number | undefined;
|
|
1256
|
+
} | undefined;
|
|
1257
|
+
primarySelection?: {
|
|
1258
|
+
enabled?: boolean | undefined;
|
|
1259
|
+
maxPrimaryFiles?: number | undefined;
|
|
1260
|
+
minRiskScore?: number | undefined;
|
|
1261
|
+
includeLayers?: ("unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry")[] | undefined;
|
|
1262
|
+
excludePatterns?: string[] | undefined;
|
|
1263
|
+
} | undefined;
|
|
1264
|
+
groupedRules?: {
|
|
1265
|
+
enabled?: boolean | undefined;
|
|
1266
|
+
maxGroupsPerFile?: number | undefined;
|
|
1267
|
+
maxRulesPerGroup?: number | undefined;
|
|
1268
|
+
} | undefined;
|
|
1269
|
+
specializedRules?: {
|
|
1270
|
+
enabled?: boolean | undefined;
|
|
1271
|
+
maxCalls?: number | undefined;
|
|
1272
|
+
} | undefined;
|
|
1273
|
+
riskScoring?: {
|
|
1274
|
+
layer?: Partial<Record<"unknown" | "service" | "pipe" | "controller" | "repository" | "dto" | "entity" | "mapper" | "component" | "ng-service" | "module" | "directive" | "model" | "test" | "config" | "generated" | "entry", number>> | undefined;
|
|
1275
|
+
signals?: {
|
|
1276
|
+
hasTransactional?: number | undefined;
|
|
1277
|
+
hasDbWrite?: number | undefined;
|
|
1278
|
+
hasLoopWithDbCall?: number | undefined;
|
|
1279
|
+
hasUserIdOrTenantId?: number | undefined;
|
|
1280
|
+
hasPermissionCheck?: number | undefined;
|
|
1281
|
+
hasExternalIO?: number | undefined;
|
|
1282
|
+
hasExceptionHandlingChange?: number | undefined;
|
|
1283
|
+
hasMoneyOrStatusLogic?: number | undefined;
|
|
1284
|
+
hasDiffReviewFinding?: number | undefined;
|
|
1285
|
+
} | undefined;
|
|
1286
|
+
} | undefined;
|
|
1287
|
+
aiRules?: boolean | undefined;
|
|
1288
|
+
aiDiffReview?: boolean | undefined;
|
|
1289
|
+
maxSupportFiles?: number | undefined;
|
|
1290
|
+
diffChunkTokenBudget?: number | undefined;
|
|
1291
|
+
maxAiCalls?: number | undefined;
|
|
1292
|
+
codeQualityOutput?: string | undefined;
|
|
1293
|
+
gitlabTokenEnv?: string | undefined;
|
|
1294
|
+
cleanupExistingComments?: boolean | undefined;
|
|
1295
|
+
excludes?: {
|
|
1296
|
+
generated?: boolean | undefined;
|
|
1297
|
+
lockfiles?: boolean | undefined;
|
|
1298
|
+
minified?: boolean | undefined;
|
|
1299
|
+
} | undefined;
|
|
1300
|
+
} | undefined;
|
|
1301
|
+
storage?: {
|
|
1302
|
+
dbPath?: string | undefined;
|
|
1303
|
+
retainRuns?: number | undefined;
|
|
1304
|
+
} | undefined;
|
|
1305
|
+
dashboard?: {
|
|
1306
|
+
serverUrl?: string | undefined;
|
|
1307
|
+
projectId?: string | undefined;
|
|
1308
|
+
token?: string | undefined;
|
|
1309
|
+
} | undefined;
|
|
1310
|
+
}>;
|
|
1311
|
+
type CodeReviewConfig = z.infer<typeof codeReviewConfigSchema>;
|
|
1312
|
+
|
|
1313
|
+
interface LocalEffectiveConfig {
|
|
1314
|
+
readonly schemaVersion: 1;
|
|
1315
|
+
readonly resolutionSource: 'local-unvalidated';
|
|
1316
|
+
readonly serverValidation: 'required';
|
|
1317
|
+
readonly sourcePath: string | null;
|
|
1318
|
+
readonly effectiveConfig: Record<string, unknown>;
|
|
1319
|
+
readonly effectiveConfigHash: string;
|
|
1320
|
+
readonly repositoryConfigHash: string;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Only repository-portable, non-secret settings may participate in the Phase
|
|
1324
|
+
* 03 config contract. Runtime credentials, AI provider setup, dashboard
|
|
1325
|
+
* tokens, and local storage locations are deliberately excluded.
|
|
1326
|
+
*/
|
|
1327
|
+
declare const repositoryConfigFromLocalConfig: (config: CodeReviewConfig) => Record<string, unknown>;
|
|
1328
|
+
declare const getLocalEffectiveConfig: (input: {
|
|
1329
|
+
readonly path?: string;
|
|
1330
|
+
readonly configPath?: string;
|
|
1331
|
+
}) => Promise<{
|
|
1332
|
+
readonly value: LocalEffectiveConfig;
|
|
1333
|
+
} | {
|
|
1334
|
+
readonly error: string;
|
|
1335
|
+
}>;
|
|
1336
|
+
interface ConfigEffectiveOptions {
|
|
1337
|
+
readonly path?: string;
|
|
1338
|
+
readonly configPath?: string;
|
|
1339
|
+
readonly json?: boolean;
|
|
1340
|
+
readonly online?: boolean;
|
|
1341
|
+
readonly write?: (line: string) => void;
|
|
1342
|
+
readonly writeError?: (line: string) => void;
|
|
1343
|
+
}
|
|
1344
|
+
declare const runConfigEffective: (options?: ConfigEffectiveOptions) => Promise<number>;
|
|
1345
|
+
|
|
1346
|
+
interface ProjectStatus {
|
|
1347
|
+
readonly schemaVersion: 1;
|
|
1348
|
+
readonly linked: boolean;
|
|
1349
|
+
readonly workspace?: {
|
|
1350
|
+
readonly serverUrl: string;
|
|
1351
|
+
readonly projectId: string;
|
|
1352
|
+
readonly codebaseId: string;
|
|
1353
|
+
readonly canonicalRemote: string;
|
|
1354
|
+
readonly subdirectory: string;
|
|
1355
|
+
};
|
|
1356
|
+
readonly git: {
|
|
1357
|
+
readonly repositoryDetected: boolean;
|
|
1358
|
+
readonly remoteMatchesLink: boolean | null;
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
interface ProjectStatusDependencies {
|
|
1362
|
+
readonly readLink: () => Promise<WorkspaceLinkState | null>;
|
|
1363
|
+
readonly readOriginRemote: () => Promise<string | null>;
|
|
1364
|
+
}
|
|
1365
|
+
declare const getLocalProjectStatus: (root?: string) => Promise<ProjectStatus>;
|
|
1366
|
+
/**
|
|
1367
|
+
* Inspects only local metadata and Git's origin remote. It never reaches the
|
|
1368
|
+
* server or reads credentials, so it remains useful before IdP/OIDC is wired.
|
|
1369
|
+
*/
|
|
1370
|
+
declare const getProjectStatus: (dependencies: ProjectStatusDependencies) => Promise<ProjectStatus>;
|
|
1371
|
+
interface ProjectStatusOptions {
|
|
1372
|
+
readonly path?: string;
|
|
1373
|
+
readonly json?: boolean;
|
|
1374
|
+
readonly dependencies?: ProjectStatusDependencies;
|
|
1375
|
+
readonly write?: (line: string) => void;
|
|
1376
|
+
}
|
|
1377
|
+
declare const runProjectStatus: (options?: ProjectStatusOptions) => Promise<number>;
|
|
1378
|
+
interface ProjectListOptions {
|
|
1379
|
+
readonly server: string;
|
|
1380
|
+
readonly json?: boolean;
|
|
1381
|
+
readonly store?: ICredentialStore;
|
|
1382
|
+
readonly write?: (line: string) => void;
|
|
1383
|
+
readonly writeError?: (line: string) => void;
|
|
1384
|
+
}
|
|
1385
|
+
declare const runProjectList: (options: ProjectListOptions) => Promise<number>;
|
|
1386
|
+
interface ProjectLinkOptions {
|
|
1387
|
+
readonly server: string;
|
|
1388
|
+
readonly projectId?: string;
|
|
1389
|
+
readonly codebaseId?: string;
|
|
1390
|
+
readonly interactive?: boolean;
|
|
1391
|
+
readonly path?: string;
|
|
1392
|
+
readonly store?: ICredentialStore;
|
|
1393
|
+
readonly client?: CliApiClient;
|
|
1394
|
+
readonly prompts?: ProjectLinkPrompts;
|
|
1395
|
+
readonly write?: (line: string) => void;
|
|
1396
|
+
readonly writeError?: (line: string) => void;
|
|
1397
|
+
}
|
|
1398
|
+
interface ProjectLinkPrompts {
|
|
1399
|
+
readonly select: (input: {
|
|
1400
|
+
readonly message: string;
|
|
1401
|
+
readonly choices: readonly {
|
|
1402
|
+
readonly name: string;
|
|
1403
|
+
readonly value: string;
|
|
1404
|
+
}[];
|
|
1405
|
+
}) => Promise<string>;
|
|
1406
|
+
}
|
|
1407
|
+
declare const runProjectLink: (options: ProjectLinkOptions) => Promise<number>;
|
|
1408
|
+
interface ProjectConfigShowOptions {
|
|
1409
|
+
readonly server: string;
|
|
1410
|
+
readonly path?: string;
|
|
1411
|
+
readonly projectId?: string;
|
|
1412
|
+
readonly store?: ICredentialStore;
|
|
1413
|
+
readonly client?: CliApiClient;
|
|
1414
|
+
readonly write?: (line: string) => void;
|
|
1415
|
+
readonly writeError?: (line: string) => void;
|
|
1416
|
+
}
|
|
1417
|
+
declare const runProjectConfigShow: (options: ProjectConfigShowOptions) => Promise<number>;
|
|
1418
|
+
interface ProjectConfigPullOptions extends ProjectConfigShowOptions {
|
|
1419
|
+
readonly file?: string;
|
|
1420
|
+
readonly force?: boolean;
|
|
1421
|
+
}
|
|
1422
|
+
declare const runProjectConfigPull: (options: ProjectConfigPullOptions) => Promise<number>;
|
|
1423
|
+
interface ProjectConfigApplyOptions extends ProjectConfigShowOptions {
|
|
1424
|
+
readonly file: string;
|
|
1425
|
+
readonly yes?: boolean;
|
|
1426
|
+
readonly confirm?: (input: {
|
|
1427
|
+
message: string;
|
|
1428
|
+
default: boolean;
|
|
1429
|
+
}) => Promise<boolean>;
|
|
1430
|
+
}
|
|
1431
|
+
declare const runProjectConfigApply: (options: ProjectConfigApplyOptions) => Promise<number>;
|
|
1432
|
+
interface ProjectSetupPrompts {
|
|
1433
|
+
readonly select: (input: {
|
|
1434
|
+
readonly message: string;
|
|
1435
|
+
readonly choices: readonly {
|
|
1436
|
+
readonly name: string;
|
|
1437
|
+
readonly value: string;
|
|
1438
|
+
}[];
|
|
1439
|
+
}) => Promise<string>;
|
|
1440
|
+
readonly input: (input: {
|
|
1441
|
+
readonly message: string;
|
|
1442
|
+
readonly default?: string;
|
|
1443
|
+
}) => Promise<string>;
|
|
1444
|
+
readonly confirm: (input: {
|
|
1445
|
+
readonly message: string;
|
|
1446
|
+
readonly default: boolean;
|
|
1447
|
+
}) => Promise<boolean>;
|
|
1448
|
+
}
|
|
1449
|
+
interface ProjectSetupOptions {
|
|
1450
|
+
readonly server: string;
|
|
1451
|
+
readonly path?: string;
|
|
1452
|
+
readonly store?: ICredentialStore;
|
|
1453
|
+
readonly client?: CliApiClient;
|
|
1454
|
+
readonly prompts?: ProjectSetupPrompts;
|
|
1455
|
+
readonly write?: (line: string) => void;
|
|
1456
|
+
readonly writeError?: (line: string) => void;
|
|
1457
|
+
}
|
|
1458
|
+
/**
|
|
1459
|
+
* One interactive entrypoint for a repository that is not yet linked. It keeps
|
|
1460
|
+
* project provisioning explicit, previews the inferred Git remote, and links
|
|
1461
|
+
* only after the server confirms the new or selected codebase.
|
|
1462
|
+
*/
|
|
1463
|
+
declare const runProjectSetup: (options: ProjectSetupOptions) => Promise<number>;
|
|
1464
|
+
interface ProjectUnlinkOptions {
|
|
1465
|
+
readonly path?: string;
|
|
1466
|
+
/** Skip the interactive confirmation; intended for scripts and CI cleanup. */
|
|
1467
|
+
readonly yes?: boolean;
|
|
1468
|
+
readonly linkStore?: WorkspaceLinkStore;
|
|
1469
|
+
readonly confirm?: (input: {
|
|
1470
|
+
message: string;
|
|
1471
|
+
default: boolean;
|
|
1472
|
+
}) => Promise<boolean>;
|
|
1473
|
+
readonly write?: (line: string) => void;
|
|
1474
|
+
readonly writeError?: (line: string) => void;
|
|
1475
|
+
}
|
|
1476
|
+
/** Removes only the local workspace-to-codebase association. It never changes the Dashboard project. */
|
|
1477
|
+
declare const runProjectUnlink: (options?: ProjectUnlinkOptions) => Promise<number>;
|
|
1478
|
+
|
|
1479
|
+
type ReadinessLevel = 'pass' | 'warn' | 'fail';
|
|
1480
|
+
interface LocalReadinessCheck {
|
|
1481
|
+
readonly id: 'git-repository' | 'workspace-link' | 'remote-parity' | 'config' | 'policy' | 'pending-push';
|
|
1482
|
+
readonly level: ReadinessLevel;
|
|
1483
|
+
readonly message: string;
|
|
1484
|
+
}
|
|
1485
|
+
interface LocalReadiness {
|
|
1486
|
+
readonly schemaVersion: 1;
|
|
1487
|
+
readonly readyForLocalReview: boolean;
|
|
1488
|
+
readonly checks: readonly LocalReadinessCheck[];
|
|
1489
|
+
readonly project: ProjectStatus;
|
|
1490
|
+
readonly effectiveConfigHash?: string;
|
|
1491
|
+
}
|
|
1492
|
+
declare const getLocalReadiness: (input?: {
|
|
1493
|
+
readonly path?: string;
|
|
1494
|
+
readonly configPath?: string;
|
|
1495
|
+
readonly projectStatus?: () => Promise<ProjectStatus>;
|
|
1496
|
+
readonly gitRepository?: () => Promise<boolean>;
|
|
1497
|
+
}) => Promise<LocalReadiness>;
|
|
1498
|
+
interface LocalReadinessOptions {
|
|
1499
|
+
readonly path?: string;
|
|
1500
|
+
readonly configPath?: string;
|
|
1501
|
+
readonly json?: boolean;
|
|
1502
|
+
readonly write?: (line: string) => void;
|
|
1503
|
+
/** Test seam; production callers use the local observation implementation. */
|
|
1504
|
+
readonly readiness?: () => Promise<LocalReadiness>;
|
|
1505
|
+
}
|
|
1506
|
+
declare const runDoctor: (options?: LocalReadinessOptions) => Promise<number>;
|
|
1507
|
+
declare const runQuickstart: (options?: LocalReadinessOptions) => Promise<number>;
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* Adaptive perf mode — picks tuning parameters based on machine RAM.
|
|
1511
|
+
*
|
|
1512
|
+
* Modes:
|
|
1513
|
+
* - economy: <12 GB RAM. Conservative defaults; avoids OOM on
|
|
1514
|
+
* small dev machines or CI runners.
|
|
1515
|
+
* - balanced: 12–24 GB RAM. Default for most laptops.
|
|
1516
|
+
* - performance: ≥24 GB RAM. Larger workloads + parallel AI calls.
|
|
1517
|
+
*
|
|
1518
|
+
* Returns a config object the review pipeline can consume. Today only
|
|
1519
|
+
* `aiConcurrency` is wired (AI rule dispatch parallelism within a file
|
|
1520
|
+
* via Promise.allSettled). `workers` is informational — kept for the
|
|
1521
|
+
* future Piscina worker-pool integration, deliberately deferred until
|
|
1522
|
+
* dogfood data justifies the complexity (see JOURNAL Phase 9.3 entry).
|
|
1523
|
+
*/
|
|
1524
|
+
type Mode = 'economy' | 'balanced' | 'performance';
|
|
1525
|
+
|
|
1526
|
+
type ApiKeyAiProvider = 'gemini' | 'groq' | 'viettel-netmind' | 'opencode-go' | 'freemodel';
|
|
1527
|
+
interface MissingAiCredential {
|
|
1528
|
+
readonly provider: ApiKeyAiProvider;
|
|
1529
|
+
readonly displayName: string;
|
|
1530
|
+
readonly envName: string;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* Git-aware file filtering for `--changed` / `--staged` / `--since <ref>`.
|
|
1535
|
+
*
|
|
1536
|
+
* Spawns `git` directly via `execFile` (no shell — avoids injection +
|
|
1537
|
+
* works on Windows when git is on PATH). All git output uses `-z` for
|
|
1538
|
+
* NUL-separated paths so pathnames with newlines / spaces are handled
|
|
1539
|
+
* correctly.
|
|
1540
|
+
*
|
|
1541
|
+
* Returns a Set<absolutePath> that the review pipeline can intersect
|
|
1542
|
+
* with the result of file discovery (`findFiles`). Files not in the
|
|
1543
|
+
* git filter set are skipped from the review.
|
|
1544
|
+
*
|
|
1545
|
+
* Modes:
|
|
1546
|
+
* - 'staged': files currently in the git index (= `git diff --cached`).
|
|
1547
|
+
* Useful for pre-commit hooks.
|
|
1548
|
+
* - 'changed': working-tree changes — tracked-modified + untracked.
|
|
1549
|
+
* Useful for "review what I'm about to commit".
|
|
1550
|
+
* - 'since': files different between `<ref>` and the working tree
|
|
1551
|
+
* (includes uncommitted changes). Useful for PR review:
|
|
1552
|
+
* `--since origin/main` shows everything in the branch.
|
|
1553
|
+
*/
|
|
1554
|
+
|
|
1555
|
+
type GitFilterMode = 'staged' | 'changed' | 'since';
|
|
1556
|
+
|
|
1557
|
+
type ReviewProfileName = 'fast' | 'deep';
|
|
1558
|
+
|
|
1559
|
+
type ReviewScope = 'auto' | 'angular' | 'spring-boot' | 'flutter' | 'both';
|
|
1560
|
+
|
|
1561
|
+
/**
|
|
1562
|
+
* Shared types for the Ink-based live review UI (Phase 14.1).
|
|
1563
|
+
*
|
|
1564
|
+
* All UI components in `./ui/ink/` are PURE: they accept a slice of
|
|
1565
|
+
* ReviewProgressState as props and render. The state itself is owned
|
|
1566
|
+
* and mutated by the wiring layer ([14.1.2] composition root + [14.1.3]
|
|
1567
|
+
* finding stream). Keeping data flow one-way (state → render only)
|
|
1568
|
+
* means tests can construct any progress shape without driving an
|
|
1569
|
+
* actual review.
|
|
1570
|
+
*
|
|
1571
|
+
* The lifecycle of a typical review render:
|
|
1572
|
+
* 1. Mount with `done: false`, counts all 0, completedFiles empty.
|
|
1573
|
+
* 2. Parent ticks `now` (epoch ms) every ~250ms so StatusFooter's
|
|
1574
|
+
* elapsed time advances smoothly.
|
|
1575
|
+
* 3. As files complete, parent APPENDS to `completedFiles` (never
|
|
1576
|
+
* dropped) and increments `filesDone`. `<ReviewProgress>` feeds
|
|
1577
|
+
* that append-only list to Ink's `<Static>`, which prints each
|
|
1578
|
+
* row ONCE into permanent scrollback above the live footer — so
|
|
1579
|
+
* a long run keeps its full history instead of erasing it on
|
|
1580
|
+
* every rerender (D1, Quality Roadmap Trục D).
|
|
1581
|
+
* 4. As findings emit, parent increments `counts[severity]`.
|
|
1582
|
+
* 5. On completion, parent sets `done: true` — components swap
|
|
1583
|
+
* spinner for a final "✓ Done" line.
|
|
1584
|
+
*/
|
|
1585
|
+
|
|
1586
|
+
interface SeverityCounts {
|
|
1587
|
+
readonly blocker: number;
|
|
1588
|
+
readonly error: number;
|
|
1589
|
+
readonly warning: number;
|
|
1590
|
+
readonly info: number;
|
|
1591
|
+
}
|
|
1592
|
+
interface FindingSourceCounts {
|
|
1593
|
+
readonly static: number;
|
|
1594
|
+
readonly ai: number;
|
|
1595
|
+
}
|
|
1596
|
+
type FileStatus = 'running' | 'done' | 'error';
|
|
1597
|
+
interface FileEntry {
|
|
1598
|
+
readonly path: string;
|
|
1599
|
+
readonly status: FileStatus;
|
|
1600
|
+
/** Findings produced by this file. 0 when status === 'running'. */
|
|
1601
|
+
readonly findings: number;
|
|
1602
|
+
/** Wall-clock millis spent on the file. 0 when status === 'running'. */
|
|
1603
|
+
readonly durationMs: number;
|
|
1604
|
+
}
|
|
1605
|
+
interface ReviewProgressState {
|
|
1606
|
+
/** Absolute path being reviewed; rendered in the header. */
|
|
1607
|
+
readonly target: string;
|
|
1608
|
+
/** Resolved performance mode (mirrors `cs review --mode`). */
|
|
1609
|
+
readonly mode: Mode;
|
|
1610
|
+
/** AI provider name (e.g. "groq"); null when --ai-off or no AI rules. */
|
|
1611
|
+
readonly aiProvider: string | null;
|
|
1612
|
+
/** True when the user explicitly passed --ai-off. */
|
|
1613
|
+
readonly aiOff: boolean;
|
|
1614
|
+
/** Epoch millis when the review started. Set once at mount. */
|
|
1615
|
+
readonly startedAt: number;
|
|
1616
|
+
/** Epoch millis "now" — parent ticks this so elapsed time updates. */
|
|
1617
|
+
readonly now: number;
|
|
1618
|
+
/** Total source files discovered. 0 means we don't know yet. */
|
|
1619
|
+
readonly filesTotal: number;
|
|
1620
|
+
/** Source files completed (status: done | error). */
|
|
1621
|
+
readonly filesDone: number;
|
|
1622
|
+
/** Active rule count after disable/glob filtering. */
|
|
1623
|
+
readonly rulesCount: number;
|
|
1624
|
+
/**
|
|
1625
|
+
* All completed files, oldest → newest, APPEND-ONLY (never trimmed).
|
|
1626
|
+
* Fed to Ink's `<Static>` so each row is written once into permanent
|
|
1627
|
+
* scrollback; the array only ever grows, so `<Static>` renders just
|
|
1628
|
+
* the newly-appended tail on each frame.
|
|
1629
|
+
*/
|
|
1630
|
+
readonly completedFiles: readonly FileEntry[];
|
|
1631
|
+
/** Severity tallies. */
|
|
1632
|
+
readonly counts: SeverityCounts;
|
|
1633
|
+
/** Finding tallies split by rule execution source. */
|
|
1634
|
+
readonly findingSources: FindingSourceCounts;
|
|
1635
|
+
/** Optional current pipeline phase, e.g. "Static scan" or "PR AI grouped review". */
|
|
1636
|
+
readonly phase?: string | undefined;
|
|
1637
|
+
/** Optional detail for the current phase, usually a file path or chunk counter. */
|
|
1638
|
+
readonly phaseDetail?: string | undefined;
|
|
1639
|
+
/** Optional completed work units for the current phase. */
|
|
1640
|
+
readonly phaseDone?: number | undefined;
|
|
1641
|
+
/** Optional total work units for the current phase. */
|
|
1642
|
+
readonly phaseTotal?: number | undefined;
|
|
1643
|
+
/** True after the review finishes (success or error). Disables the spinner. */
|
|
1644
|
+
readonly done: boolean;
|
|
1645
|
+
/** Optional terminal error message rendered in red when done. */
|
|
1646
|
+
readonly error?: string;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Ink renderer controller — the wiring shim between the pure
|
|
1651
|
+
* `<ReviewProgress>` component (14.1.1) and the rest of the CLI
|
|
1652
|
+
* pipeline (14.1.2 calls this from `review.command.ts`).
|
|
1653
|
+
*
|
|
1654
|
+
* The controller owns the React `Instance` returned by Ink's `render`
|
|
1655
|
+
* and exposes a tiny imperative API:
|
|
1656
|
+
* - `update(state)` swaps the state slice via `instance.rerender`.
|
|
1657
|
+
* - `unmount()` tears down Ink's stdout patching and waits for the
|
|
1658
|
+
* final flush so the surrounding code's `console.log` lines don't
|
|
1659
|
+
* race the panel's last frame.
|
|
1660
|
+
*
|
|
1661
|
+
* Why not React state hooks: the rest of the codebase is plain async
|
|
1662
|
+
* functions + closures, not React. Forcing a useState/useReducer
|
|
1663
|
+
* boundary at this seam would mean the executor's AsyncIterable
|
|
1664
|
+
* (14.1.3) has to dispatch into a React scheduler, which complicates
|
|
1665
|
+
* testing without buying anything. The "rerender on every state push"
|
|
1666
|
+
* model lets us throttle in the wiring layer cheaply.
|
|
1667
|
+
*
|
|
1668
|
+
* Stdout/stderr/exit hooks are pluggable so tests can pipe Ink's
|
|
1669
|
+
* output to an in-memory `PassThrough` and assert without an actual
|
|
1670
|
+
* TTY.
|
|
1671
|
+
*/
|
|
1672
|
+
|
|
1673
|
+
interface InkProgressRenderer {
|
|
1674
|
+
/** Push a new state slice. Cheap — Ink diffs frames internally. */
|
|
1675
|
+
update(state: ReviewProgressState): void;
|
|
1676
|
+
/**
|
|
1677
|
+
* Tear down. Resolves AFTER the final frame has been flushed and
|
|
1678
|
+
* Ink's stdout patching released, so any subsequent `console.log`
|
|
1679
|
+
* from the caller appears below the panel (not interleaved).
|
|
1680
|
+
*/
|
|
1681
|
+
unmount(): Promise<void>;
|
|
1682
|
+
/** Test seam — exposes Ink's Instance for fine-grained assertions. */
|
|
1683
|
+
readonly instance: Instance;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* `cs review <path>` — the main review pipeline.
|
|
1688
|
+
*
|
|
1689
|
+
* Phase 7 MVP: sequential pipeline without listr2 progress UI (deferred
|
|
1690
|
+
* to Phase 9 when we add per-file parallel display). Plain console log
|
|
1691
|
+
* for each major step.
|
|
1692
|
+
*/
|
|
1693
|
+
|
|
1694
|
+
interface ReviewOptions {
|
|
1695
|
+
/** Target path (file or dir). Defaults to current dir. */
|
|
1696
|
+
readonly path?: string;
|
|
1697
|
+
/** Dashboard delivery mode. Bare `--push` maps to `always` at the CLI boundary. */
|
|
1698
|
+
readonly push?: 'never' | 'auto' | 'always';
|
|
1699
|
+
/** Explicit config file. When set, skips user-global/project config discovery. */
|
|
1700
|
+
readonly configPath?: string;
|
|
1701
|
+
/** Skip AI rules entirely. */
|
|
1702
|
+
readonly aiOff?: boolean;
|
|
1703
|
+
/** Test seam for the interactive missing-AI-key prompt. */
|
|
1704
|
+
readonly aiKeyPrompt?: (credential: MissingAiCredential) => Promise<string>;
|
|
1705
|
+
/** Phase 07: explicit execution/coverage profile. */
|
|
1706
|
+
readonly profile?: ReviewProfileName;
|
|
1707
|
+
/** Drop findings below this severity (info|warning|error|blocker). */
|
|
1708
|
+
readonly minSeverity?: 'info' | 'warning' | 'error' | 'blocker';
|
|
1709
|
+
/** Path to report output. Overrides config. */
|
|
1710
|
+
readonly output?: string;
|
|
1711
|
+
/** One-off report output mode. Undefined preserves config.report.format. */
|
|
1712
|
+
readonly reportFormat?: 'md' | 'json' | 'sarif' | 'both';
|
|
1713
|
+
/** Silent mode — no progress logs; only summary + report file. */
|
|
1714
|
+
readonly silent?: boolean;
|
|
1715
|
+
/**
|
|
1716
|
+
* Git-aware file filtering. When set, intersect discovered files with
|
|
1717
|
+
* the git filter result. Only one mode allowed per run (CLI layer
|
|
1718
|
+
* enforces mutual exclusivity).
|
|
1719
|
+
*/
|
|
1720
|
+
readonly gitFilter?: {
|
|
1721
|
+
readonly mode: GitFilterMode;
|
|
1722
|
+
/** Required when mode === 'since'. */
|
|
1723
|
+
readonly sinceRef?: string;
|
|
1724
|
+
};
|
|
1725
|
+
/**
|
|
1726
|
+
* Performance mode override. `undefined` → use config / auto-detect.
|
|
1727
|
+
* 'auto' explicitly requests RAM-based detection (ignoring config).
|
|
1728
|
+
*/
|
|
1729
|
+
readonly mode?: Mode | 'auto';
|
|
1730
|
+
/** Wizard-selected project scope. PR mode uses this to override include/layer routing. */
|
|
1731
|
+
readonly scope?: ReviewScope;
|
|
1732
|
+
/**
|
|
1733
|
+
* Drop findings with confidence below this threshold (0-100). Useful
|
|
1734
|
+
* for filtering out heuristic / AI-generated findings while keeping
|
|
1735
|
+
* high-precision pattern matches.
|
|
1736
|
+
*/
|
|
1737
|
+
readonly minConfidence?: number;
|
|
1738
|
+
/**
|
|
1739
|
+
* When true, force the compact reporter regardless of `report.format`
|
|
1740
|
+
* in config. The compact view groups by rule, shows message + suggestion
|
|
1741
|
+
* once, and collapses large file lists in a `<details>` element.
|
|
1742
|
+
*
|
|
1743
|
+
* Note: starting 1.2.0 the default `report.format` is `markdown-compact`,
|
|
1744
|
+
* so this flag is a no-op when config wasn't customized. Still useful
|
|
1745
|
+
* when project config sets `format: markdown` for archival but you want
|
|
1746
|
+
* a one-off compact run.
|
|
1747
|
+
*/
|
|
1748
|
+
readonly compact?: boolean;
|
|
1749
|
+
/**
|
|
1750
|
+
* When true, force the FULL markdown reporter (one section per finding).
|
|
1751
|
+
* Opt-out from the 1.2.0 default. Mutually exclusive with `compact` —
|
|
1752
|
+
* the CLI enforces at parse time.
|
|
1753
|
+
*/
|
|
1754
|
+
readonly full?: boolean;
|
|
1755
|
+
/**
|
|
1756
|
+
* Skip auto-applying the project baseline (`.code-sentinel/baseline.json`)
|
|
1757
|
+
* if one exists. Phase 12.5. Useful for one-off "show me the entire
|
|
1758
|
+
* inventory" runs without permanently deleting the baseline.
|
|
1759
|
+
*/
|
|
1760
|
+
readonly noBaseline?: boolean;
|
|
1761
|
+
/**
|
|
1762
|
+
* "Capture" mode: instead of writing the markdown report, write the
|
|
1763
|
+
* current findings to `.code-sentinel/baseline.json`. Implies
|
|
1764
|
+
* `noBaseline` (existing baseline is not applied) so the snapshot
|
|
1765
|
+
* reflects current truth. Used by `cs baseline create`.
|
|
1766
|
+
*
|
|
1767
|
+
* The post-filters from `rules.pathOverrides` + inline suppressions
|
|
1768
|
+
* still apply — anything those would silence stays out of the baseline
|
|
1769
|
+
* (they're already permanently silenced).
|
|
1770
|
+
*/
|
|
1771
|
+
readonly captureBaseline?: boolean;
|
|
1772
|
+
/**
|
|
1773
|
+
* Phase 13.0 — extra reviewer instructions appended to every AI prompt
|
|
1774
|
+
* for this run. Surfaced via `cs review --extra-instructions "<text>"`.
|
|
1775
|
+
* No-op when AI is off / no AI rules apply.
|
|
1776
|
+
*/
|
|
1777
|
+
readonly extraInstructions?: string;
|
|
1778
|
+
/**
|
|
1779
|
+
* Phase 13.0 — cap on AI findings per invocation. Stricter of (this,
|
|
1780
|
+
* per-rule `aiConfig.numMaxFindings`) wins. Defaults to unlimited.
|
|
1781
|
+
*/
|
|
1782
|
+
readonly numMaxFindings?: number;
|
|
1783
|
+
/** One-off AI request timeout override in milliseconds. Wizard accepts seconds. */
|
|
1784
|
+
readonly aiTimeoutMs?: number;
|
|
1785
|
+
/**
|
|
1786
|
+
* Phase 14.5 — restrict the rule set to ids matching ANY of these globs.
|
|
1787
|
+
* `disabled` (via `rules.disabled` or `rules.overrides[id].enabled=false`)
|
|
1788
|
+
* still wins — this flag only NARROWS the active set, never re-enables a
|
|
1789
|
+
* disabled rule. Empty / unset = no filter.
|
|
1790
|
+
*
|
|
1791
|
+
* Examples: `["angular/*"]`, `["general/no-console-log"]`,
|
|
1792
|
+
* `["angular/*", "general/no-*"]`. Glob syntax = match-glob subset
|
|
1793
|
+
* (`*`, `**`, `?`); same matcher used by `rules.pathOverrides[].paths`.
|
|
1794
|
+
*/
|
|
1795
|
+
readonly rules?: readonly string[];
|
|
1796
|
+
/**
|
|
1797
|
+
* Phase 14.1.2 — force-disable the Ink live progress UI. By default
|
|
1798
|
+
* the UI auto-engages on TTY (non-CI, non-silent, output-to-file).
|
|
1799
|
+
* `--no-ui` is the escape hatch for log scrapers, screen readers,
|
|
1800
|
+
* and tests that want the legacy plain-log behavior.
|
|
1801
|
+
*/
|
|
1802
|
+
readonly noUi?: boolean;
|
|
1803
|
+
/**
|
|
1804
|
+
* Phase 14.2 — when true, run the initial review then keep the
|
|
1805
|
+
* process alive watching project files for changes. Each batch of
|
|
1806
|
+
* changes triggers another `runReview` pass scoped to just the
|
|
1807
|
+
* changed files (via `filesFilter`). Ctrl+C exits cleanly.
|
|
1808
|
+
*/
|
|
1809
|
+
readonly watch?: boolean;
|
|
1810
|
+
/**
|
|
1811
|
+
* Phase 14.2 — opt back IN to AI rules during watch re-reviews.
|
|
1812
|
+
* Watch defaults to `--ai-off` semantics on re-runs (the initial
|
|
1813
|
+
* pass still respects the user's flag) so a save burst doesn't
|
|
1814
|
+
* blow the AI provider's rate limit / spend. `--watch-ai` is the
|
|
1815
|
+
* escape hatch for users on free local providers (Ollama).
|
|
1816
|
+
*/
|
|
1817
|
+
readonly watchAi?: boolean;
|
|
1818
|
+
/**
|
|
1819
|
+
* Phase 16 — review a GitLab merge request instead of a local file scan.
|
|
1820
|
+
* Value is either a GitLab MR URL or `auto` in GitLab CI.
|
|
1821
|
+
*/
|
|
1822
|
+
readonly pr?: string;
|
|
1823
|
+
/** Phase 16 — write summary/inline discussions to GitLab. Dry-run by default. */
|
|
1824
|
+
readonly post?: boolean;
|
|
1825
|
+
/** Phase 16 — cap inline GitLab discussions for this run. */
|
|
1826
|
+
readonly maxInlineComments?: number;
|
|
1827
|
+
/** Phase 16 — post/render only the summary, no inline discussions. */
|
|
1828
|
+
readonly summaryOnly?: boolean;
|
|
1829
|
+
/** Phase 16 — override PR workspace root. */
|
|
1830
|
+
readonly prWorkspace?: string;
|
|
1831
|
+
/** Phase 16 — one-off PR AI routing strategy override from wizard/CLI. */
|
|
1832
|
+
readonly prAiStrategy?: CodeReviewConfig['prReview']['aiStrategy'];
|
|
1833
|
+
/**
|
|
1834
|
+
* Internal — when set, sourceFiles produced by discovery are
|
|
1835
|
+
* filtered to the intersection with this set (comparing
|
|
1836
|
+
* `SourceFile.absolutePath`). Used by the watch loop to scope each
|
|
1837
|
+
* re-review to JUST the files that just changed. Not exposed on
|
|
1838
|
+
* the CLI surface; the watch loop populates it.
|
|
1839
|
+
*/
|
|
1840
|
+
readonly filesFilter?: ReadonlySet<string>;
|
|
1841
|
+
/**
|
|
1842
|
+
* Phase 15.3 / ADR-0015 — opt OUT of the persisted AST graph cache.
|
|
1843
|
+
* Default is `false`: `cs review` wraps the ts-morph graph builder with
|
|
1844
|
+
* `createIncrementalAstGraphBuilder` so subsequent runs (especially in
|
|
1845
|
+
* `--watch` mode) skip the reparse when no TS file changed. Passing
|
|
1846
|
+
* `--no-graph-cache` forces a full rebuild for this invocation. Useful
|
|
1847
|
+
* when debugging false positives in graph-backed rules
|
|
1848
|
+
* (`no-circular-import`, `no-unresolved-import-symbol`, `no-unused-export`)
|
|
1849
|
+
* — a permanent safety hatch mirroring `--no-baseline` from Phase 12.5.
|
|
1850
|
+
*/
|
|
1851
|
+
readonly noGraphCache?: boolean;
|
|
1852
|
+
/**
|
|
1853
|
+
* Quality Roadmap C3 / [ADR-0028] — one-off merge-gate policy override for
|
|
1854
|
+
* AI-sourced findings. Overrides `config.review.gate.aiPolicy` for THIS run
|
|
1855
|
+
* only (via `--ai-gate <advisory|high-confidence|blocking>`). Deterministic
|
|
1856
|
+
* findings always gate at `error`+ regardless; this knob only affects
|
|
1857
|
+
* `kind: 'ai'` findings. `aiMinConfidence` stays config-only.
|
|
1858
|
+
*/
|
|
1859
|
+
readonly aiGatePolicy?: AiGatePolicy;
|
|
1860
|
+
/**
|
|
1861
|
+
* AI-resilience / [ADR-0029] — one-off override for how INCOMPLETE AI
|
|
1862
|
+
* coverage (recall-risk skips) affects the gate, via
|
|
1863
|
+
* `--ai-skip-gate <ignore|warn|fail>`. Overrides
|
|
1864
|
+
* `config.review.gate.aiSkipPolicy` for THIS run only. Independent of
|
|
1865
|
+
* `aiGatePolicy` (which governs AI FINDINGS, not AI coverage).
|
|
1866
|
+
*/
|
|
1867
|
+
readonly aiSkipGatePolicy?: AiSkipGatePolicy;
|
|
1868
|
+
/**
|
|
1869
|
+
* Internal — watch mode shares one Ink renderer across the initial
|
|
1870
|
+
* pass and later re-review passes. This keeps the live panel stable
|
|
1871
|
+
* instead of mounting/unmounting between batches.
|
|
1872
|
+
*/
|
|
1873
|
+
readonly progressSession?: ReviewProgressSession;
|
|
1874
|
+
/** Internal — true when the caller owns progressSession lifecycle. */
|
|
1875
|
+
readonly keepProgressMounted?: boolean;
|
|
1876
|
+
}
|
|
1877
|
+
interface ReviewProgressSession {
|
|
1878
|
+
renderer: InkProgressRenderer | null;
|
|
1879
|
+
state: ReviewProgressState | null;
|
|
1880
|
+
}
|
|
1881
|
+
declare const runReview: (options?: ReviewOptions) => Promise<number>;
|
|
1882
|
+
|
|
1883
|
+
interface ResultsOptions {
|
|
1884
|
+
readonly path?: string;
|
|
1885
|
+
readonly projectId?: string;
|
|
1886
|
+
readonly server?: string;
|
|
1887
|
+
readonly json?: boolean;
|
|
1888
|
+
readonly write?: (line: string) => void;
|
|
1889
|
+
readonly writeError?: (line: string) => void;
|
|
1890
|
+
readonly client?: CliApiClient;
|
|
1891
|
+
}
|
|
1892
|
+
declare const runResults: (options?: ResultsOptions) => Promise<number>;
|
|
1893
|
+
interface ResultsShowOptions extends ResultsOptions {
|
|
1894
|
+
readonly runId: string;
|
|
1895
|
+
}
|
|
1896
|
+
declare const runResultsShow: (options: ResultsShowOptions) => Promise<number>;
|
|
1897
|
+
interface ResultsExportOptions extends ResultsOptions {
|
|
1898
|
+
readonly runId: string;
|
|
1899
|
+
readonly format: 'markdown' | 'markdown-compact' | 'json' | 'sarif' | 'csv';
|
|
1900
|
+
readonly output?: string;
|
|
1901
|
+
}
|
|
1902
|
+
declare const runResultsExport: (options: ResultsExportOptions) => Promise<number>;
|
|
1903
|
+
|
|
1904
|
+
interface AutomationTokenOptions {
|
|
1905
|
+
readonly server: string;
|
|
1906
|
+
readonly path?: string;
|
|
1907
|
+
readonly projectId?: string;
|
|
1908
|
+
readonly store?: ICredentialStore;
|
|
1909
|
+
readonly client?: CliApiClient;
|
|
1910
|
+
readonly write?: (line: string) => void;
|
|
1911
|
+
readonly writeError?: (line: string) => void;
|
|
1912
|
+
}
|
|
1913
|
+
declare const runAutomationTokenList: (options: AutomationTokenOptions) => Promise<number>;
|
|
1914
|
+
interface AutomationTokenCreateOptions extends AutomationTokenOptions {
|
|
1915
|
+
readonly name: string;
|
|
1916
|
+
readonly expiresAt?: string;
|
|
1917
|
+
readonly yes?: boolean;
|
|
1918
|
+
readonly confirm?: (input: {
|
|
1919
|
+
message: string;
|
|
1920
|
+
default: boolean;
|
|
1921
|
+
}) => Promise<boolean>;
|
|
1922
|
+
}
|
|
1923
|
+
declare const runAutomationTokenCreate: (options: AutomationTokenCreateOptions) => Promise<number>;
|
|
1924
|
+
interface AutomationTokenRevokeOptions extends AutomationTokenOptions {
|
|
1925
|
+
readonly hash: string;
|
|
1926
|
+
readonly yes?: boolean;
|
|
1927
|
+
readonly confirm?: (input: {
|
|
1928
|
+
message: string;
|
|
1929
|
+
default: boolean;
|
|
1930
|
+
}) => Promise<boolean>;
|
|
1931
|
+
}
|
|
1932
|
+
declare const runAutomationTokenRevoke: (options: AutomationTokenRevokeOptions) => Promise<number>;
|
|
1933
|
+
|
|
1934
|
+
/**
|
|
1935
|
+
* `cs rule <list|enable|disable>` — manage built-in + user rules.
|
|
1936
|
+
*
|
|
1937
|
+
* - list: print every loaded rule with its effective severity +
|
|
1938
|
+
* baseConfidence after applying `rules.overrides`.
|
|
1939
|
+
* - enable: remove a rule id from `rules.disabled` AND clear any
|
|
1940
|
+
* `overrides[id].enabled: false`. Validates the id exists.
|
|
1941
|
+
* - disable: append the rule id to `rules.disabled` (idempotent).
|
|
1942
|
+
* Validates the id exists.
|
|
1943
|
+
*/
|
|
1944
|
+
interface RuleListOptions {
|
|
1945
|
+
readonly path?: string;
|
|
1946
|
+
/** Explicit config file. When set, skips user-global/project config discovery. */
|
|
1947
|
+
readonly configPath?: string;
|
|
1948
|
+
/** Filter rules by scope (angular | spring-boot | general). */
|
|
1949
|
+
readonly scope?: string;
|
|
1950
|
+
}
|
|
1951
|
+
declare const runRuleList: (options?: RuleListOptions) => Promise<number>;
|
|
1952
|
+
|
|
1953
|
+
/**
|
|
1954
|
+
* `cs history` — list past review runs.
|
|
1955
|
+
* `cs history diff <a> <b>` — compare two runs.
|
|
1956
|
+
*
|
|
1957
|
+
* Reads directly from the SQLite review-store.
|
|
1958
|
+
*/
|
|
1959
|
+
interface HistoryListOptions {
|
|
1960
|
+
readonly path?: string;
|
|
1961
|
+
/** Explicit config file. When set, skips user-global/project config discovery. */
|
|
1962
|
+
readonly configPath?: string;
|
|
1963
|
+
readonly limit?: number;
|
|
1964
|
+
}
|
|
1965
|
+
interface HistoryDiffOptions {
|
|
1966
|
+
readonly path?: string;
|
|
1967
|
+
/** Explicit config file. When set, skips user-global/project config discovery. */
|
|
1968
|
+
readonly configPath?: string;
|
|
1969
|
+
readonly base: string;
|
|
1970
|
+
readonly head: string;
|
|
1971
|
+
}
|
|
1972
|
+
declare const runHistoryList: (options?: HistoryListOptions) => Promise<number>;
|
|
1973
|
+
declare const runHistoryDiff: (options: HistoryDiffOptions) => Promise<number>;
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Composition root — the ONLY place that imports from every package.
|
|
1977
|
+
*
|
|
1978
|
+
* Builds the dependency graph from a loaded config + a logger, returns
|
|
1979
|
+
* a typed `Container` that commands invoke. Tests can build a container
|
|
1980
|
+
* with fakes to test commands in isolation.
|
|
1981
|
+
*/
|
|
1982
|
+
|
|
1983
|
+
interface Container {
|
|
1984
|
+
readonly parser: IParser;
|
|
1985
|
+
readonly ruleLoader: IRuleLoader;
|
|
1986
|
+
readonly aiClient: IAIClient | null;
|
|
1987
|
+
readonly aiExecutor: AiRuleExecutorCallback | undefined;
|
|
1988
|
+
/**
|
|
1989
|
+
* AI execution tracker, populated whenever `aiExecutor !== undefined`.
|
|
1990
|
+
* `reviewProject` snapshots it after the run; reporters read
|
|
1991
|
+
* `run.aiStats`. Null when AI rules are disabled (`provider: none`)
|
|
1992
|
+
* or no provider succeeded the credential check. Phase 12.3.
|
|
1993
|
+
*/
|
|
1994
|
+
readonly aiTracker: IAiExecutionTracker | null;
|
|
1995
|
+
/**
|
|
1996
|
+
* Heuristic Review Graph assembler (Phase 13.2). Always non-null
|
|
1997
|
+
* because the assembler is pure (no I/O, no network). Wired into
|
|
1998
|
+
* `createStaticExecutor` so per-cluster AI rules can run.
|
|
1999
|
+
*/
|
|
2000
|
+
readonly clusterAssembler: IClusterAssembler;
|
|
2001
|
+
/**
|
|
2002
|
+
* Hierarchical cluster-tree builder (Phase 15.5.0 / ADR-0016). Always
|
|
2003
|
+
* non-null — pure composition over `clusterAssembler` + the AST graph,
|
|
2004
|
+
* no I/O at construction. Wired into `createStaticExecutor` so AI
|
|
2005
|
+
* rules with `contextScope: 'per-module'` can dispatch in pass 2.
|
|
2006
|
+
* Slice 15.5.1+ consumers walk this tree; the existing per-cluster
|
|
2007
|
+
* dispatch path continues to consume `clusterAssembler` directly so
|
|
2008
|
+
* the 14 production per-cluster rules ship unchanged.
|
|
2009
|
+
*/
|
|
2010
|
+
readonly clusterTreeBuilder: IClusterTreeBuilder;
|
|
2011
|
+
/**
|
|
2012
|
+
* `@Transactional` boundary extractor (Phase 15.5.3 / ADR-0018). Pure
|
|
2013
|
+
* Java content scan; wired into `createStaticExecutor` so per-module
|
|
2014
|
+
* Spring rules receive transaction-boundary facts in their evidence
|
|
2015
|
+
* pack. Always non-null (the function is stateless).
|
|
2016
|
+
*/
|
|
2017
|
+
readonly transactionBoundaryExtractor: (files: readonly SourceFile[]) => readonly TransactionBoundaryFact[];
|
|
2018
|
+
readonly astGraphBuilder: IAstDependencyGraphBuilder;
|
|
2019
|
+
/**
|
|
2020
|
+
* Phase 15.4 — Tier-1 TS intra-procedural taint analyzer (ADR-0019).
|
|
2021
|
+
* Always non-null; the factory is a pure closure. Wired into
|
|
2022
|
+
* `createStaticExecutor` so any rule that declares `usesTaint: true`
|
|
2023
|
+
* receives `ctx.taintFindings`. Java intra-procedural arrives in 15.4.2.b
|
|
2024
|
+
* — this container slot already accepts a future composite analyzer
|
|
2025
|
+
* (TS + Java) via the same `ITaintAnalyzer` port.
|
|
2026
|
+
*/
|
|
2027
|
+
readonly taintAnalyzer: ITaintAnalyzer;
|
|
2028
|
+
/**
|
|
2029
|
+
* Phase 16.3.x — template→component linker (ADR-0023). Always non-null; the
|
|
2030
|
+
* factory is a pure ts-morph closure. Wired into `createStaticExecutor` so
|
|
2031
|
+
* any rule that declares `usesTemplateComponent: true` (Angular `.html`
|
|
2032
|
+
* template rules) receives `ctx.templateComponent` — the resolved owning
|
|
2033
|
+
* component + its member value-origin map.
|
|
2034
|
+
*/
|
|
2035
|
+
readonly templateComponentLinker: ITemplateComponentLinker;
|
|
2036
|
+
readonly store: IReviewStore;
|
|
2037
|
+
readonly cache: ICacheStore;
|
|
2038
|
+
readonly reporter: IReporter;
|
|
2039
|
+
readonly clock: Clock;
|
|
2040
|
+
readonly logger: Logger;
|
|
2041
|
+
readonly db: DbHandle;
|
|
2042
|
+
/** Tear down all resources (DB connections, etc.). Idempotent. */
|
|
2043
|
+
close(): Promise<void>;
|
|
2044
|
+
}
|
|
2045
|
+
interface BuildContainerOptions {
|
|
2046
|
+
readonly projectPath: string;
|
|
2047
|
+
readonly config: CodeReviewConfig;
|
|
2048
|
+
readonly logger: Logger;
|
|
2049
|
+
/** Override clock for tests. */
|
|
2050
|
+
readonly clock?: Clock;
|
|
2051
|
+
/**
|
|
2052
|
+
* Phase 13.0 — per-run AI executor knobs forwarded from the CLI's
|
|
2053
|
+
* `--extra-instructions` / `--num-max-findings` flags. Empty / undefined
|
|
2054
|
+
* leaves the executor at its defaults.
|
|
2055
|
+
*/
|
|
2056
|
+
readonly aiOverrides?: {
|
|
2057
|
+
readonly extraInstructions?: string;
|
|
2058
|
+
readonly numMaxFindings?: number;
|
|
2059
|
+
};
|
|
2060
|
+
/**
|
|
2061
|
+
* Phase 15.3 — opt OUT of the persisted AST graph cache for this
|
|
2062
|
+
* container. Default is ON (composition wraps the inner ts-morph builder
|
|
2063
|
+
* with `createIncrementalAstGraphBuilder` against the project DB). Set to
|
|
2064
|
+
* `true` to force a pure full rebuild — useful when debugging false
|
|
2065
|
+
* positives in graph-backed rules. Mirrored on `cs review --no-graph-cache`.
|
|
2066
|
+
*/
|
|
2067
|
+
readonly noGraphCache?: boolean;
|
|
2068
|
+
}
|
|
2069
|
+
declare const buildContainer: (options: BuildContainerOptions) => Promise<Container>;
|
|
2070
|
+
|
|
2071
|
+
/**
|
|
2072
|
+
* Config loader via cosmiconfig.
|
|
2073
|
+
*
|
|
2074
|
+
* Search order (LAST-wins on key conflict):
|
|
2075
|
+
* 1. Schema defaults
|
|
2076
|
+
* 2. ~/.codereviewrc.{yaml,json,js,cjs} (user-global)
|
|
2077
|
+
* 3. <project>/.code-sentinel/codereviewrc.{yaml,yml}
|
|
2078
|
+
* 4. <project>/.codereviewrc.{yaml,json,js,cjs} (legacy)
|
|
2079
|
+
* 5. <project>/package.json#codeSentinel
|
|
2080
|
+
*
|
|
2081
|
+
* When `configPath` is supplied, it replaces steps 2-4: schema defaults are
|
|
2082
|
+
* layered with exactly that YAML/JSON file and no discovered config is merged.
|
|
2083
|
+
*
|
|
2084
|
+
* Env-var interpolation: any string value containing `${ENV_VAR}` is
|
|
2085
|
+
* replaced with `process.env.ENV_VAR` BEFORE Zod validation. Missing
|
|
2086
|
+
* env vars are collected and reported as a single ConfigInvalidError
|
|
2087
|
+
* (fail-fast) — silently substituting empty string used to mask
|
|
2088
|
+
* "provider=gemini but forgot GEMINI_API_KEY" until much deeper in the
|
|
2089
|
+
* pipeline. Use literal empty (omit the placeholder) if you actually
|
|
2090
|
+
* want an empty value.
|
|
2091
|
+
*/
|
|
2092
|
+
|
|
2093
|
+
interface LoadConfigOptions {
|
|
2094
|
+
/** Search dir; defaults to process.cwd(). */
|
|
2095
|
+
readonly cwd?: string;
|
|
2096
|
+
/**
|
|
2097
|
+
* Explicit config file to load instead of user-global/project discovery.
|
|
2098
|
+
* Relative paths are resolved from the invocation cwd.
|
|
2099
|
+
*/
|
|
2100
|
+
readonly configPath?: string;
|
|
2101
|
+
/** Skip the user-global ~/.codereviewrc lookup. */
|
|
2102
|
+
readonly noUserConfig?: boolean;
|
|
2103
|
+
}
|
|
2104
|
+
interface LoadedConfig {
|
|
2105
|
+
readonly config: CodeReviewConfig;
|
|
2106
|
+
/** Absolute path of the config file used, or null if only defaults applied. */
|
|
2107
|
+
readonly sourcePath: string | null;
|
|
2108
|
+
}
|
|
2109
|
+
declare const loadConfig: (options?: LoadConfigOptions) => Promise<Result<LoadedConfig, ConfigInvalidError | IOError>>;
|
|
2110
|
+
|
|
2111
|
+
/** Creates the shared Phase 02 client without exposing its bearer value in logs/errors. */
|
|
2112
|
+
declare const createRemoteConfigClient: (input: {
|
|
2113
|
+
readonly serverUrl: string;
|
|
2114
|
+
readonly token?: string;
|
|
2115
|
+
}) => CliApiClient;
|
|
2116
|
+
|
|
2117
|
+
/**
|
|
2118
|
+
* Discover source files to review.
|
|
2119
|
+
*
|
|
2120
|
+
* Honors include + exclude globs from config. Reads file content, computes
|
|
2121
|
+
* sha256, builds SourceFile objects.
|
|
2122
|
+
*
|
|
2123
|
+
* Phase 7 is sequential. Phase 9 will add parallel read via Piscina.
|
|
2124
|
+
*/
|
|
2125
|
+
|
|
2126
|
+
interface FindFilesOptions {
|
|
2127
|
+
/** Absolute project root. */
|
|
2128
|
+
readonly projectRoot: string;
|
|
2129
|
+
readonly include: readonly string[];
|
|
2130
|
+
readonly exclude: readonly string[];
|
|
2131
|
+
/** Cap on file size (bytes). Default 1 MB. Larger files are skipped + logged. */
|
|
2132
|
+
readonly maxFileBytes?: number;
|
|
2133
|
+
readonly logger?: Logger;
|
|
2134
|
+
}
|
|
2135
|
+
declare const findFiles: (options: FindFilesOptions) => Promise<Result<SourceFile[], IOError>>;
|
|
2136
|
+
|
|
2137
|
+
/**
|
|
2138
|
+
* CLI exit codes — documented in USAGE.md.
|
|
2139
|
+
*
|
|
2140
|
+
* CI pipelines should fail when exit code >= 3.
|
|
2141
|
+
*/
|
|
2142
|
+
declare const EXIT: {
|
|
2143
|
+
/** Success — no findings of severity 'error' or 'blocker'. */
|
|
2144
|
+
readonly SUCCESS: 0;
|
|
2145
|
+
/** Bad CLI arguments or missing required config. */
|
|
2146
|
+
readonly USAGE: 1;
|
|
2147
|
+
/** Runtime error (parser crash, AI down with no fallback, IO error). */
|
|
2148
|
+
readonly RUNTIME: 2;
|
|
2149
|
+
/** Review completed; findings of severity 'error' present. */
|
|
2150
|
+
readonly FINDINGS_ERROR: 3;
|
|
2151
|
+
/** Review completed; findings of severity 'blocker' present. */
|
|
2152
|
+
readonly FINDINGS_BLOCKER: 4;
|
|
2153
|
+
};
|
|
2154
|
+
type ExitCode = (typeof EXIT)[keyof typeof EXIT];
|
|
2155
|
+
|
|
2156
|
+
interface GitLabMrTarget {
|
|
2157
|
+
readonly baseUrl: string;
|
|
2158
|
+
readonly projectPath: string;
|
|
2159
|
+
readonly iid: number;
|
|
2160
|
+
readonly webUrl?: string;
|
|
2161
|
+
}
|
|
2162
|
+
interface PrReviewRuntimeOptions {
|
|
2163
|
+
readonly invocationRoot: string;
|
|
2164
|
+
readonly configPath?: string;
|
|
2165
|
+
readonly pr: string;
|
|
2166
|
+
readonly post: boolean;
|
|
2167
|
+
readonly maxInlineComments?: number;
|
|
2168
|
+
readonly summaryOnly: boolean;
|
|
2169
|
+
readonly prWorkspace?: string;
|
|
2170
|
+
readonly prAiStrategy?: CodeReviewConfig['prReview']['aiStrategy'];
|
|
2171
|
+
readonly aiOff: boolean;
|
|
2172
|
+
readonly mode?: Mode | 'auto';
|
|
2173
|
+
readonly scope?: ReviewScope;
|
|
2174
|
+
readonly minSeverity?: Severity;
|
|
2175
|
+
readonly minConfidence?: number;
|
|
2176
|
+
readonly reportFormat?: 'md' | 'json' | 'both';
|
|
2177
|
+
readonly output?: string;
|
|
2178
|
+
readonly silent: boolean;
|
|
2179
|
+
readonly noUi?: boolean;
|
|
2180
|
+
readonly compact?: boolean;
|
|
2181
|
+
readonly full?: boolean;
|
|
2182
|
+
readonly noBaseline?: boolean;
|
|
2183
|
+
readonly extraInstructions?: string;
|
|
2184
|
+
readonly numMaxFindings?: number;
|
|
2185
|
+
readonly aiTimeoutMs?: number;
|
|
2186
|
+
readonly rules?: readonly string[];
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
type PrReviewRunner = (options: PrReviewRuntimeOptions) => Promise<number>;
|
|
2190
|
+
interface GitLabWebhookJob {
|
|
2191
|
+
readonly key: string;
|
|
2192
|
+
readonly mrUrl: string;
|
|
2193
|
+
readonly target: GitLabMrTarget;
|
|
2194
|
+
readonly eventId: string;
|
|
2195
|
+
}
|
|
2196
|
+
type GitLabWebhookParseResult = {
|
|
2197
|
+
readonly kind: 'accepted';
|
|
2198
|
+
readonly job: GitLabWebhookJob;
|
|
2199
|
+
} | {
|
|
2200
|
+
readonly kind: 'ignored';
|
|
2201
|
+
readonly reason: string;
|
|
2202
|
+
} | {
|
|
2203
|
+
readonly kind: 'invalid';
|
|
2204
|
+
readonly reason: string;
|
|
2205
|
+
};
|
|
2206
|
+
type GitLabWebhookQueueStatus = 'started' | 'queued' | 'deduped';
|
|
2207
|
+
interface GitLabWebhookQueueEnqueueResult {
|
|
2208
|
+
readonly status: GitLabWebhookQueueStatus;
|
|
2209
|
+
readonly key: string;
|
|
2210
|
+
}
|
|
2211
|
+
interface GitLabWebhookQueue {
|
|
2212
|
+
enqueue(job: GitLabWebhookJob): GitLabWebhookQueueEnqueueResult;
|
|
2213
|
+
onIdle(): Promise<void>;
|
|
2214
|
+
}
|
|
2215
|
+
interface CreateGitLabWebhookQueueOptions {
|
|
2216
|
+
readonly reviewRoot: string;
|
|
2217
|
+
readonly runner?: PrReviewRunner;
|
|
2218
|
+
readonly post: boolean;
|
|
2219
|
+
readonly aiOff?: boolean;
|
|
2220
|
+
readonly minSeverity?: Severity;
|
|
2221
|
+
readonly minConfidence?: number;
|
|
2222
|
+
readonly reportFormat?: 'md' | 'json' | 'both';
|
|
2223
|
+
readonly outputRoot?: string;
|
|
2224
|
+
}
|
|
2225
|
+
interface CreateGitLabWebhookServerOptions {
|
|
2226
|
+
readonly path: string;
|
|
2227
|
+
readonly secret: string;
|
|
2228
|
+
readonly queue: GitLabWebhookQueue;
|
|
2229
|
+
readonly allowNoteCommand?: boolean;
|
|
2230
|
+
}
|
|
2231
|
+
interface RunGitLabWebhookOptions {
|
|
2232
|
+
readonly host?: string;
|
|
2233
|
+
readonly port?: number;
|
|
2234
|
+
readonly path?: string;
|
|
2235
|
+
readonly reviewRoot?: string;
|
|
2236
|
+
readonly secretEnv?: string;
|
|
2237
|
+
readonly allowNoteCommand?: boolean;
|
|
2238
|
+
readonly post?: boolean;
|
|
2239
|
+
readonly aiOff?: boolean;
|
|
2240
|
+
readonly minSeverity?: Severity;
|
|
2241
|
+
readonly minConfidence?: number;
|
|
2242
|
+
readonly reportFormat?: 'md' | 'json' | 'both';
|
|
2243
|
+
}
|
|
2244
|
+
declare const createGitLabWebhookQueue: (options: CreateGitLabWebhookQueueOptions) => GitLabWebhookQueue;
|
|
2245
|
+
declare const parseGitLabMergeRequestWebhook: (payload: unknown, eventId: string) => GitLabWebhookParseResult;
|
|
2246
|
+
declare const createGitLabWebhookServer: (options: CreateGitLabWebhookServerOptions) => Server;
|
|
2247
|
+
declare const runGitLabWebhook: (options?: RunGitLabWebhookOptions) => Promise<number>;
|
|
2248
|
+
|
|
2249
|
+
export { type AuthLoginOptions, type AutomationTokenCreateOptions, type AutomationTokenOptions, type AutomationTokenRevokeOptions, type BuildContainerOptions, type CliBuildMetadata, type CodeReviewConfig, type ConfigEffectiveOptions, type Container, EXIT, type ExitCode, FileProtectedRetryStore, FileWorkspaceLinkStore, type FindFilesOptions, type GitLabWebhookJob, type GitLabWebhookQueue, type HistoryDiffOptions, type HistoryListOptions, type ICredentialStore, InMemoryCredentialStore, InMemoryRetryKeyProvider, type InitOptions, LinuxSecretServiceStore, type LoadedConfig, type LocalEffectiveConfig, type LocalReadiness, type LocalReadinessCheck, MacOsKeychainCredentialStore, type PendingPushRetry, type ProjectConfigApplyOptions, type ProjectConfigShowOptions, type ProjectSetupOptions, type ProjectSetupPrompts, type ProjectStatus, type ProjectStatusOptions, type ProjectUnlinkOptions, type ResultsExportOptions, type ResultsOptions, type ResultsShowOptions, type ReviewOptions, type RuleListOptions, type RunGitLabWebhookOptions, type StoredCredential, WindowsCredentialManagerStore, type WorkspaceLinkState, buildContainer, buildProgram, codeReviewConfigSchema, createGitLabWebhookQueue, createGitLabWebhookServer, createPlatformCredentialStore, createPlatformRetryKeyProvider, createPlatformSecretStore, createRemoteConfigClient, findFiles, getCliBuildMetadata, getLocalEffectiveConfig, getLocalProjectStatus, getLocalReadiness, getProjectStatus, loadConfig, main, parseGitLabMergeRequestWebhook, repositoryConfigFromLocalConfig, runAuthLogin, runAuthLogout, runAuthStatus, runAutomationTokenCreate, runAutomationTokenList, runAutomationTokenRevoke, runConfigEffective, runDoctor, runGitLabWebhook, runHistoryDiff, runHistoryList, runInit, runProjectConfigApply, runProjectConfigPull, runProjectConfigShow, runProjectLink, runProjectList, runProjectSetup, runProjectStatus, runProjectUnlink, runQuickstart, runResults, runResultsExport, runResultsShow, runReview, runRuleList };
|