@alint-js/plugin 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +310 -0
- package/dist/index.mjs +12 -0
- package/package.json +22 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
//#region ../core/dist/types-DSvXUVZ7.d.mts
|
|
2
|
+
//#region src/core/source/types.d.ts
|
|
3
|
+
type ClassTarget = SourceTargetOfKind<'class'>;
|
|
4
|
+
type FileTarget = SourceTargetOfKind<'file'>;
|
|
5
|
+
type FunctionTarget = SourceTargetOfKind<'function'>;
|
|
6
|
+
interface LanguageContext {
|
|
7
|
+
cwd: string;
|
|
8
|
+
languageOptions: Record<string, unknown>;
|
|
9
|
+
src: SourceRuntime;
|
|
10
|
+
}
|
|
11
|
+
interface LineRange {
|
|
12
|
+
endLine: number;
|
|
13
|
+
startLine: number;
|
|
14
|
+
}
|
|
15
|
+
interface ProcessedSource {
|
|
16
|
+
identity: string;
|
|
17
|
+
language?: string;
|
|
18
|
+
origin?: ProcessedSourceOrigin;
|
|
19
|
+
path: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
interface ProcessedSourceOrigin {
|
|
23
|
+
physicalPath: string;
|
|
24
|
+
range?: SourceRange;
|
|
25
|
+
virtualPath?: string;
|
|
26
|
+
}
|
|
27
|
+
interface ProcessorContext {
|
|
28
|
+
cwd: string;
|
|
29
|
+
options: Record<string, unknown>;
|
|
30
|
+
src: SourceRuntime;
|
|
31
|
+
}
|
|
32
|
+
interface ProcessorPostprocessContext extends ProcessorContext {
|
|
33
|
+
file: SourceFile;
|
|
34
|
+
processedSources: ProcessedSource[];
|
|
35
|
+
}
|
|
36
|
+
interface SourceFile {
|
|
37
|
+
language: string;
|
|
38
|
+
lines: string[];
|
|
39
|
+
path: string;
|
|
40
|
+
text: string;
|
|
41
|
+
}
|
|
42
|
+
interface SourceLocation {
|
|
43
|
+
end: SourcePosition;
|
|
44
|
+
start: SourcePosition;
|
|
45
|
+
}
|
|
46
|
+
interface SourcePosition {
|
|
47
|
+
column: number;
|
|
48
|
+
line: number;
|
|
49
|
+
}
|
|
50
|
+
interface SourceRange {
|
|
51
|
+
end: number;
|
|
52
|
+
start: number;
|
|
53
|
+
}
|
|
54
|
+
interface SourceRuntime {
|
|
55
|
+
getText: (target: SourceFile | SourceTarget) => string;
|
|
56
|
+
readFile: (filePath: string) => Promise<SourceFile>;
|
|
57
|
+
sliceLines: (file: SourceFile, range: LineRange) => SourceText;
|
|
58
|
+
sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
|
|
59
|
+
}
|
|
60
|
+
interface SourceTarget {
|
|
61
|
+
file: SourceFile;
|
|
62
|
+
identity: string;
|
|
63
|
+
kind: SourceTargetKind;
|
|
64
|
+
language: string;
|
|
65
|
+
loc?: SourceLocation;
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
67
|
+
name?: string;
|
|
68
|
+
origin?: SourceTargetOrigin;
|
|
69
|
+
range?: SourceRange;
|
|
70
|
+
text: string;
|
|
71
|
+
}
|
|
72
|
+
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
73
|
+
type SourceTargetOfKind<Kind extends SourceTargetKind> = Omit<SourceTarget, 'kind'> & {
|
|
74
|
+
kind: Kind;
|
|
75
|
+
};
|
|
76
|
+
interface SourceTargetOrigin {
|
|
77
|
+
physicalPath: string;
|
|
78
|
+
range?: SourceRange;
|
|
79
|
+
virtualPath?: string;
|
|
80
|
+
}
|
|
81
|
+
interface SourceText {
|
|
82
|
+
filePath: string;
|
|
83
|
+
loc: SourceLocation;
|
|
84
|
+
text: string;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region ../core/dist/types-CMLoj9J9.d.mts
|
|
88
|
+
//#region src/config/types.d.ts
|
|
89
|
+
type ModelSize = 'large' | 'medium' | 'small';
|
|
90
|
+
interface RunnerCacheConfig {
|
|
91
|
+
enabled?: boolean;
|
|
92
|
+
location?: string;
|
|
93
|
+
}
|
|
94
|
+
interface RunnerConfig {
|
|
95
|
+
/** Retries after the initial attempt for replay-safe agent failures. @default 2 */
|
|
96
|
+
agentRetries?: number;
|
|
97
|
+
cache?: boolean | RunnerCacheConfig;
|
|
98
|
+
fileConcurrency?: number;
|
|
99
|
+
ruleConcurrency?: number;
|
|
100
|
+
stats?: boolean | RunnerStatsConfig;
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
}
|
|
103
|
+
interface RunnerStatsConfig {
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
location?: string;
|
|
106
|
+
retentionMonths?: number;
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/models/types.d.ts
|
|
110
|
+
interface ModelRequirement {
|
|
111
|
+
capabilities?: string[];
|
|
112
|
+
minContextWindow?: number;
|
|
113
|
+
params?: Record<string, unknown>;
|
|
114
|
+
size?: ModelSize;
|
|
115
|
+
}
|
|
116
|
+
interface ResolvedModel {
|
|
117
|
+
aliases: string[];
|
|
118
|
+
capabilities: string[];
|
|
119
|
+
contextWindow?: number;
|
|
120
|
+
id: string;
|
|
121
|
+
name: string;
|
|
122
|
+
params: Record<string, unknown>;
|
|
123
|
+
provider: ResolvedProvider;
|
|
124
|
+
size?: ModelSize;
|
|
125
|
+
}
|
|
126
|
+
interface ResolvedProvider {
|
|
127
|
+
endpoint: string;
|
|
128
|
+
headers: Record<string, string>;
|
|
129
|
+
id: string;
|
|
130
|
+
type: 'openai-compatible';
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/agent/types.d.ts
|
|
134
|
+
type AgentAdapter = (request: AgentRequest) => Promise<AgentResult>;
|
|
135
|
+
interface AgentRequest {
|
|
136
|
+
instructions: string;
|
|
137
|
+
model: ResolvedModel;
|
|
138
|
+
prompt: string;
|
|
139
|
+
signal?: AbortSignal;
|
|
140
|
+
tools: AgentTool[];
|
|
141
|
+
}
|
|
142
|
+
interface AgentResult {
|
|
143
|
+
answer: string;
|
|
144
|
+
usage?: AgentUsage;
|
|
145
|
+
}
|
|
146
|
+
/** Agent-agnostic tool definition. Each adapter translates it to its framework's tool format. */
|
|
147
|
+
interface AgentTool {
|
|
148
|
+
description: string;
|
|
149
|
+
execute: (input: unknown) => Promise<unknown> | unknown;
|
|
150
|
+
name: string;
|
|
151
|
+
parameters: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
interface AgentUsage {
|
|
154
|
+
inputTokens?: number;
|
|
155
|
+
outputTokens?: number;
|
|
156
|
+
totalTokens?: number;
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/dsl/types.d.ts
|
|
160
|
+
type AlintConfig = readonly AlintConfigInput[];
|
|
161
|
+
type AlintConfigExtends = AlintConfigInput | string;
|
|
162
|
+
type AlintConfigInput = AlintConfigItem | readonly AlintConfigInput[];
|
|
163
|
+
interface AlintConfigItem {
|
|
164
|
+
agent?: AgentAdapter;
|
|
165
|
+
basePath?: string;
|
|
166
|
+
directories?: readonly (readonly string[] | string)[];
|
|
167
|
+
extends?: readonly AlintConfigExtends[];
|
|
168
|
+
files?: readonly (readonly string[] | string)[];
|
|
169
|
+
ignore?: IgnoreConfig;
|
|
170
|
+
ignores?: readonly string[];
|
|
171
|
+
language?: string;
|
|
172
|
+
languageOptions?: Record<string, unknown>;
|
|
173
|
+
linterOptions?: AlintLinterOptions;
|
|
174
|
+
name?: string;
|
|
175
|
+
plugins?: Record<string, PluginDefinition>;
|
|
176
|
+
processor?: ProcessorDefinition | string;
|
|
177
|
+
rules?: Record<string, RuleConfigEntry>;
|
|
178
|
+
runner?: RunnerConfig;
|
|
179
|
+
settings?: Record<string, unknown>;
|
|
180
|
+
}
|
|
181
|
+
interface AlintLinterOptions {
|
|
182
|
+
noInlineConfig?: boolean;
|
|
183
|
+
reportUnusedDisableDirectives?: RuleSeverity;
|
|
184
|
+
}
|
|
185
|
+
type Awaitable<T> = Promise<T> | T;
|
|
186
|
+
interface DiagnosticDescriptor {
|
|
187
|
+
evidence?: unknown;
|
|
188
|
+
filePath?: string;
|
|
189
|
+
loc?: DiagnosticLocation;
|
|
190
|
+
message: string;
|
|
191
|
+
}
|
|
192
|
+
interface DiagnosticLocation {
|
|
193
|
+
end?: {
|
|
194
|
+
column: number;
|
|
195
|
+
line: number;
|
|
196
|
+
};
|
|
197
|
+
start: {
|
|
198
|
+
column: number;
|
|
199
|
+
line: number;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
interface DirectoryTarget {
|
|
203
|
+
kind: 'directory';
|
|
204
|
+
path: string;
|
|
205
|
+
}
|
|
206
|
+
interface EnabledRule {
|
|
207
|
+
id: string;
|
|
208
|
+
localId: string;
|
|
209
|
+
rule: RuleDefinition;
|
|
210
|
+
severity: Exclude<RuleSeverity, 'off'>;
|
|
211
|
+
}
|
|
212
|
+
interface IgnoreConfig {
|
|
213
|
+
gitignore?: boolean;
|
|
214
|
+
}
|
|
215
|
+
interface LanguageDefinition {
|
|
216
|
+
extensions?: readonly string[];
|
|
217
|
+
extract: (file: SourceFile, context: LanguageContext) => Awaitable<SourceTarget[]>;
|
|
218
|
+
name: string;
|
|
219
|
+
}
|
|
220
|
+
interface PluginDefinition {
|
|
221
|
+
configs?: Record<string, AlintConfigInput>;
|
|
222
|
+
languages?: Record<string, LanguageDefinition>;
|
|
223
|
+
processors?: Record<string, ProcessorDefinition>;
|
|
224
|
+
rules?: Record<string, RuleDefinition>;
|
|
225
|
+
}
|
|
226
|
+
interface ProcessorDefinition {
|
|
227
|
+
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
228
|
+
preprocess: (file: SourceFile, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
229
|
+
}
|
|
230
|
+
interface ProjectTarget {
|
|
231
|
+
files: SourceFile[];
|
|
232
|
+
kind: 'project';
|
|
233
|
+
root: string;
|
|
234
|
+
targets: SourceTarget[];
|
|
235
|
+
}
|
|
236
|
+
type RuleCacheConfig = boolean | {
|
|
237
|
+
level?: 'target';
|
|
238
|
+
};
|
|
239
|
+
type RuleConfigEntry = [RuleSeverity] | RuleSeverity;
|
|
240
|
+
interface RuleContext {
|
|
241
|
+
agent?: AgentAdapter;
|
|
242
|
+
cwd: string;
|
|
243
|
+
id: string;
|
|
244
|
+
localId: string;
|
|
245
|
+
logger: {
|
|
246
|
+
debug: (...args: unknown[]) => void;
|
|
247
|
+
};
|
|
248
|
+
metering: {
|
|
249
|
+
recordUsage: (usage: RuleInferenceUsageRecord) => void;
|
|
250
|
+
};
|
|
251
|
+
model: (selector?: ModelRequirement | string) => Promise<ResolvedModel>;
|
|
252
|
+
outputLanguage?: string;
|
|
253
|
+
report: (diagnostic: DiagnosticDescriptor) => void;
|
|
254
|
+
settings: Record<string, unknown>;
|
|
255
|
+
/**
|
|
256
|
+
* Cancels the run. Forward it to anything long-running a rule starts, so cancelling stops
|
|
257
|
+
* the work instead of letting it finish and bill.
|
|
258
|
+
*
|
|
259
|
+
* `ctx.agent` already injects it, and `generateStructured` accepts it as `signal`.
|
|
260
|
+
*/
|
|
261
|
+
signal?: AbortSignal;
|
|
262
|
+
src: SourceRuntime;
|
|
263
|
+
}
|
|
264
|
+
interface RuleDefinition {
|
|
265
|
+
cache?: RuleCacheConfig;
|
|
266
|
+
/** Additional stable rule inputs, such as imported prompts, that invalidate cached results when changed. */
|
|
267
|
+
cacheKey?: unknown;
|
|
268
|
+
create: (context: RuleContext) => RuleHandlers;
|
|
269
|
+
model?: ModelRequirement;
|
|
270
|
+
}
|
|
271
|
+
type RuleHandlers = RuleSpecializedHandlers | RuleWithHandler;
|
|
272
|
+
interface RuleInferenceUsageRecord {
|
|
273
|
+
filePath?: string;
|
|
274
|
+
inputTokens?: number;
|
|
275
|
+
metadata?: unknown;
|
|
276
|
+
modelId: string;
|
|
277
|
+
outputTokens?: number;
|
|
278
|
+
providerId: string;
|
|
279
|
+
ruleId?: string;
|
|
280
|
+
totalTokens?: number;
|
|
281
|
+
}
|
|
282
|
+
interface RuleRegistry {
|
|
283
|
+
enabledRules: EnabledRule[];
|
|
284
|
+
rules: Map<string, RuleDefinition>;
|
|
285
|
+
}
|
|
286
|
+
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
287
|
+
interface RuleSpecializedHandlers {
|
|
288
|
+
onTargetClass?: (target: ClassTarget) => Awaitable<void>;
|
|
289
|
+
onTargetDirectory?: (target: DirectoryTarget) => Awaitable<void>;
|
|
290
|
+
onTargetFile?: (target: FileTarget) => Awaitable<void>;
|
|
291
|
+
onTargetFunction?: (target: FunctionTarget) => Awaitable<void>;
|
|
292
|
+
onTargetProject?: (target: ProjectTarget) => Awaitable<void>;
|
|
293
|
+
onTargetWith?: never;
|
|
294
|
+
}
|
|
295
|
+
interface RuleWithHandler {
|
|
296
|
+
onTargetClass?: never;
|
|
297
|
+
onTargetDirectory?: never;
|
|
298
|
+
onTargetFile?: never;
|
|
299
|
+
onTargetFunction?: never;
|
|
300
|
+
onTargetProject?: never;
|
|
301
|
+
onTargetWith: (target: Target) => Awaitable<void>;
|
|
302
|
+
}
|
|
303
|
+
type Target = DirectoryTarget | ProjectTarget | SourceTarget;
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/index.d.ts
|
|
306
|
+
declare function defineConfig(config: readonly AlintConfigInput[]): AlintConfig;
|
|
307
|
+
declare function definePlugin(plugin: PluginDefinition): PluginDefinition;
|
|
308
|
+
declare function defineRule(rule: RuleDefinition): RuleDefinition;
|
|
309
|
+
//#endregion
|
|
310
|
+
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, type Awaitable, type ClassTarget, type DiagnosticDescriptor, type DiagnosticLocation, type DirectoryTarget, type EnabledRule, type FileTarget, type FunctionTarget, type IgnoreConfig, type LanguageContext, type LanguageDefinition, type LineRange, type ModelRequirement, type PluginDefinition, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProjectTarget, type ResolvedModel, type ResolvedProvider, type RuleCacheConfig, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleHandlers, type RuleInferenceUsageRecord, type RuleRegistry, type RuleSeverity, type RuleSpecializedHandlers, type RuleWithHandler, type SourceFile, type SourceLocation, type SourcePosition, type SourceRange, type SourceRuntime, type SourceTarget, type SourceTargetKind, type SourceTargetOfKind, type SourceTargetOrigin, type SourceText, type Target, defineConfig, definePlugin, defineRule };
|
package/dist/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alint-js/plugin",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.29",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.mts",
|
|
8
|
+
"default": "./dist/index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@alint-js/core": "0.0.29"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsdown",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
|
+
}
|
|
22
|
+
}
|