@alint-js/cli 0.0.1 → 0.0.4

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 CHANGED
@@ -1,58 +1,13 @@
1
- //#region src/config/paths.d.ts
2
- interface GlobalSetupConfigPathOptions {
3
- isMacOS?: boolean;
4
- xdgConfig?: string;
5
- }
6
- declare function getGlobalSetupConfigPath(env?: NodeJS.ProcessEnv, options?: GlobalSetupConfigPathOptions): string;
7
- declare function getProjectSetupConfigPath(cwd: string): string;
8
- //#endregion
9
- //#region src/config/types.d.ts
10
- type ModelSize = 'large' | 'medium' | 'small';
11
- interface ProviderDefinition {
12
- endpoint: string;
13
- headers?: Record<string, string>;
14
- id: string;
15
- models: SetupModelDefinition[];
16
- type: ProviderType;
17
- }
18
- type ProviderType = 'openai-compatible';
19
- interface RunnerConfig {
20
- fileConcurrency?: number;
21
- ruleConcurrency?: number;
22
- timeoutMs?: number;
23
- }
24
- interface SetupConfig {
25
- providers: ProviderDefinition[];
26
- runner?: RunnerConfig;
27
- version: 1;
28
- }
29
- interface SetupModelDefinition {
30
- aliases?: string[];
31
- capabilities?: string[];
32
- contextWindow?: number;
33
- defaultParams?: Record<string, unknown>;
34
- id: string;
35
- name?: string;
36
- size?: ModelSize;
37
- }
38
- //#endregion
39
- //#region src/config/setup-load.d.ts
40
- declare const emptySetupConfig: SetupConfig;
41
- declare function loadSetupConfig(filePath: string): Promise<SetupConfig>;
42
- declare function mergeSetupConfigs(...configs: SetupConfig[]): SetupConfig;
43
- //#endregion
44
- //#region src/config/setup-toml.d.ts
45
- declare function parseSetupConfigToml(toml: string): SetupConfig;
46
- declare function stringifySetupConfigToml(config: SetupConfig): string;
47
- //#endregion
48
- //#region src/config/setup-write.d.ts
49
- declare function writeSetupConfig(filePath: string, config: SetupConfig): Promise<void>;
50
- //#endregion
1
+ import { Diagnostic, RunResult } from "@alint-js/core";
2
+
51
3
  //#region src/cli/cli.d.ts
52
4
  interface CliIo {
53
5
  cwd: string;
54
6
  env?: NodeJS.ProcessEnv;
55
7
  stderr: CliWritable;
8
+ stdin?: {
9
+ isTTY?: boolean;
10
+ };
56
11
  stdout: CliWritable;
57
12
  }
58
13
  interface CliWritable {
@@ -62,283 +17,6 @@ interface CliWritable {
62
17
  }
63
18
  declare function executeCli(argv: string[], io: CliIo): Promise<number>;
64
19
  //#endregion
65
- //#region src/core/source/types.d.ts
66
- interface ClassUnit extends SourceUnit {
67
- exported: boolean;
68
- kind: 'class';
69
- }
70
- interface FunctionUnit extends SourceUnit {
71
- async: boolean;
72
- exported: boolean;
73
- kind: 'function';
74
- }
75
- interface LineRange {
76
- endLine: number;
77
- startLine: number;
78
- }
79
- interface SourceFile {
80
- language: 'javascript' | 'typescript' | 'unknown';
81
- lines: string[];
82
- path: string;
83
- text: string;
84
- }
85
- interface SourceLocation {
86
- end: SourcePosition;
87
- start: SourcePosition;
88
- }
89
- interface SourcePosition {
90
- column: number;
91
- line: number;
92
- }
93
- interface SourceRange {
94
- end: number;
95
- start: number;
96
- }
97
- interface SourceRuntime {
98
- getText: (target: SourceFile | SourceUnit) => string;
99
- readFile: (filePath: string) => Promise<SourceFile>;
100
- sliceLines: (file: SourceFile, range: LineRange) => SourceText;
101
- sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
102
- }
103
- interface SourceText {
104
- filePath: string;
105
- loc: SourceLocation;
106
- text: string;
107
- }
108
- interface SourceUnit {
109
- file: SourceFile;
110
- kind: 'class' | 'function';
111
- loc: SourceLocation;
112
- name?: string;
113
- range: SourceRange;
114
- text: string;
115
- }
116
- //#endregion
117
- //#region src/models/types.d.ts
118
- interface ModelRequirement {
119
- capabilities?: string[];
120
- minContextWindow?: number;
121
- params?: Record<string, unknown>;
122
- size?: ModelSize;
123
- }
124
- interface ResolvedModel {
125
- aliases: string[];
126
- capabilities: string[];
127
- contextWindow?: number;
128
- id: string;
129
- name: string;
130
- params: Record<string, unknown>;
131
- provider: ResolvedProvider;
132
- size?: ModelSize;
133
- }
134
- interface ResolvedProvider {
135
- endpoint: string;
136
- headers: Record<string, string>;
137
- id: string;
138
- type: 'openai-compatible';
139
- }
140
- interface ResolveModelOptions {
141
- request?: string;
142
- requirement?: ModelRequirement;
143
- ruleId?: string;
144
- }
145
- //#endregion
146
- //#region src/dsl/types.d.ts
147
- type Awaitable<T> = Promise<T> | T;
148
- interface DiagnosticDescriptor {
149
- evidence?: unknown;
150
- filePath?: string;
151
- loc?: DiagnosticLocation;
152
- message: string;
153
- }
154
- interface DiagnosticLocation {
155
- end?: {
156
- column: number;
157
- line: number;
158
- };
159
- start: {
160
- column: number;
161
- line: number;
162
- };
163
- }
164
- interface EnabledRule {
165
- id: string;
166
- localId: string;
167
- rule: RuleDefinition;
168
- scope: string;
169
- severity: Exclude<RuleSeverity, 'off'>;
170
- }
171
- interface AlintConfig {
172
- plugins?: PluginDefinition[];
173
- rules?: Record<string, RuleConfigEntry>;
174
- runner?: RunnerConfig;
175
- }
176
- interface PluginDefinition {
177
- rules: Record<string, RuleDefinition>;
178
- scope: string;
179
- }
180
- type RuleConfigEntry = [RuleSeverity] | RuleSeverity;
181
- interface RuleContext {
182
- cwd: string;
183
- id: string;
184
- localId: string;
185
- logger: {
186
- debug: (...args: unknown[]) => void;
187
- };
188
- metering: {
189
- recordUsage: (usage: RuleInferenceUsageRecord) => void;
190
- };
191
- model: (selector?: ModelRequirement | string) => Promise<ResolvedModel>;
192
- report: (diagnostic: DiagnosticDescriptor) => void;
193
- scope: string;
194
- src: SourceRuntime;
195
- }
196
- interface RuleDefinition {
197
- create: (context: RuleContext) => RuleHandlers;
198
- model?: ModelRequirement;
199
- }
200
- interface RuleHandlers {
201
- onClass?: (classNode: ClassUnit) => Awaitable<void>;
202
- onFile?: (file: SourceFile) => Awaitable<void>;
203
- onFunction?: (functionNode: FunctionUnit) => Awaitable<void>;
204
- }
205
- interface RuleInferenceUsageRecord {
206
- filePath?: string;
207
- inputTokens?: number;
208
- metadata?: unknown;
209
- modelId: string;
210
- outputTokens?: number;
211
- providerId: string;
212
- ruleId?: string;
213
- totalTokens?: number;
214
- }
215
- interface RuleRegistry {
216
- enabledRules: EnabledRule[];
217
- rules: Map<string, RuleDefinition>;
218
- }
219
- type RuleSeverity = 'error' | 'off' | 'warn';
220
- //#endregion
221
- //#region src/core/types.d.ts
222
- interface Diagnostic {
223
- evidence?: unknown;
224
- filePath: string;
225
- loc?: DiagnosticLocation;
226
- message: string;
227
- model?: {
228
- providerId: string;
229
- requested?: string;
230
- resolvedId: string;
231
- };
232
- ruleId: string;
233
- severity: 'error' | 'warn';
234
- }
235
- interface DiagnosticProgressPayload {
236
- diagnostic: Diagnostic;
237
- diagnostics: Diagnostic[];
238
- path?: ProgressPath;
239
- }
240
- interface FileProgressPayload {
241
- endedAt?: number;
242
- file: ProgressFilePath;
243
- startedAt?: number;
244
- }
245
- type InferenceUsageRecord = Omit<RuleInferenceUsageRecord, 'ruleId'> & {
246
- ruleId: string;
247
- };
248
- interface ProgressFilePath {
249
- index: number;
250
- path: string;
251
- planned?: number;
252
- total: number;
253
- }
254
- interface ProgressPath {
255
- file: ProgressFilePath;
256
- rule: {
257
- id: string;
258
- index: number;
259
- total: number;
260
- };
261
- target: {
262
- index: number;
263
- kind: ProgressTargetKind;
264
- name?: string;
265
- total: number;
266
- };
267
- }
268
- interface ProgressReporter {
269
- onDiagnostic?: (payload: DiagnosticProgressPayload) => void;
270
- onFileEnd?: (payload: FileProgressPayload) => void;
271
- onFileStart?: (payload: FileProgressPayload) => void;
272
- onRuleEnd?: (payload: RuleEndPayload) => void;
273
- onRuleStart?: (payload: RuleStartPayload) => void;
274
- onRunEnd?: (payload: RunEndPayload) => void;
275
- onRunStart?: (payload: RunStartPayload) => void;
276
- onTargetEnd?: (payload: TargetProgressPayload) => void;
277
- onTargetStart?: (payload: TargetProgressPayload) => void;
278
- onUsage?: (payload: UsageProgressPayload) => void;
279
- }
280
- type ProgressTargetKind = 'class' | 'file' | 'function';
281
- interface RuleEndPayload {
282
- cache: 'hit' | 'miss';
283
- endedAt?: number;
284
- path: ProgressPath;
285
- startedAt?: number;
286
- state: 'completed' | 'errored';
287
- }
288
- interface RuleStartPayload {
289
- path: ProgressPath;
290
- startedAt?: number;
291
- }
292
- interface RunEndPayload {
293
- cached: number;
294
- completed: number;
295
- diagnostics: Diagnostic[];
296
- endedAt?: number;
297
- errored: number;
298
- planned: number;
299
- startedAt?: number;
300
- usage: RunUsage;
301
- }
302
- interface RunnerOptions extends RunnerConfig {
303
- clock?: () => number;
304
- }
305
- interface RunOptions {
306
- config?: AlintConfig;
307
- cwd?: string;
308
- files?: string[];
309
- modelOverride?: string;
310
- progress?: ProgressReporter;
311
- runner?: RunnerOptions;
312
- setupConfig?: SetupConfig;
313
- }
314
- interface RunResult {
315
- diagnostics: Diagnostic[];
316
- usage: RunUsage;
317
- }
318
- interface RunStartPayload {
319
- files?: ProgressFilePath[];
320
- filesTotal: number;
321
- planned: number;
322
- rulesTotal: number;
323
- startedAt?: number;
324
- }
325
- interface RunUsage {
326
- inputTokens: number;
327
- outputTokens: number;
328
- records: InferenceUsageRecord[];
329
- totalTokens: number;
330
- }
331
- interface TargetProgressPayload {
332
- endedAt?: number;
333
- path: ProgressPath;
334
- startedAt?: number;
335
- }
336
- interface UsageProgressPayload {
337
- path?: ProgressPath;
338
- record: InferenceUsageRecord;
339
- total: RunUsage;
340
- }
341
- //#endregion
342
20
  //#region src/cli/reporters/index.d.ts
343
21
  interface FormatDiagnosticsOptions {
344
22
  color?: boolean;
@@ -355,34 +33,4 @@ interface StylishReporterOptions {
355
33
  }
356
34
  declare function formatStylish(input: Diagnostic[] | RunResult, options?: StylishReporterOptions): string;
357
35
  //#endregion
358
- //#region src/config/load-config.d.ts
359
- declare function loadAlintConfig(cwd: string, configFile?: string): Promise<AlintConfig>;
360
- //#endregion
361
- //#region src/core/run.d.ts
362
- declare function runAlint(options?: RunOptions): Promise<RunResult>;
363
- //#endregion
364
- //#region src/core/source/js.d.ts
365
- interface JsSourceUnits {
366
- classes: ClassUnit[];
367
- functions: FunctionUnit[];
368
- }
369
- declare function extractJsSourceUnits(file: SourceFile): JsSourceUnits;
370
- //#endregion
371
- //#region src/core/source/runtime.d.ts
372
- declare function createSourceFile(path: string, text: string): SourceFile;
373
- declare function createSourceRuntime(): SourceRuntime;
374
- declare function sliceLines(file: SourceFile, range: LineRange): SourceText;
375
- declare function sliceRange(file: SourceFile, range: SourceRange): SourceText;
376
- //#endregion
377
- //#region src/dsl/define.d.ts
378
- declare function defineConfig(config: AlintConfig): AlintConfig;
379
- declare function definePlugin(plugin: PluginDefinition): PluginDefinition;
380
- declare function defineRule(rule: RuleDefinition): RuleDefinition;
381
- //#endregion
382
- //#region src/dsl/registry.d.ts
383
- declare function buildRuleRegistry(config: AlintConfig): RuleRegistry;
384
- //#endregion
385
- //#region src/models/resolve.d.ts
386
- declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
387
- //#endregion
388
- export { type AlintConfig, type Awaitable, type ClassUnit, type CliIo, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type EnabledRule, type FileProgressPayload, type FunctionUnit, type InferenceUsageRecord, type LineRange, type ModelRequirement, type ModelSize, type PluginDefinition, type ProgressFilePath, type ProgressPath, type ProgressReporter, type ProgressTargetKind, type ProviderDefinition, type ProviderType, type ReporterName, type ResolveModelOptions, type ResolvedModel, type ResolvedProvider, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleEndPayload, type RuleHandlers, type RuleInferenceUsageRecord, type RuleRegistry, type RuleSeverity, type RuleStartPayload, type RunEndPayload, type RunOptions, type RunResult, type RunStartPayload, type RunUsage, type SetupConfig, type SetupModelDefinition, type SourceFile, type SourceLocation, type SourcePosition, type SourceRange, type SourceRuntime, type SourceText, type SourceUnit, type TargetProgressPayload, type UsageProgressPayload, buildRuleRegistry, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, emptySetupConfig, executeCli, extractJsSourceUnits, formatDiagnostics, formatJson, formatStylish, getGlobalSetupConfigPath, getProjectSetupConfigPath, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, resolveModel, runAlint, sliceLines, sliceRange, stringifySetupConfigToml, writeSetupConfig };
36
+ export { type CliIo, type ReporterName, executeCli, formatDiagnostics, formatJson, formatStylish };
package/dist/index.mjs CHANGED
@@ -1,13 +1,2 @@
1
- import { _ as mergeSetupConfigs, a as runAlint, b as getGlobalSetupConfigPath, c as createSourceRuntime, d as resolveModel, f as buildRuleRegistry, g as loadSetupConfig, h as emptySetupConfig, i as formatJson, l as sliceLines, m as writeSetupConfig, n as formatDiagnostics, o as extractJsSourceUnits, p as loadAlintConfig, r as formatStylish, s as createSourceFile, t as executeCli, u as sliceRange, v as parseSetupConfigToml, x as getProjectSetupConfigPath, y as stringifySetupConfigToml } from "./cli-BnA9jEVr.mjs";
2
- //#region src/dsl/define.ts
3
- function defineConfig(config) {
4
- return config;
5
- }
6
- function definePlugin(plugin) {
7
- return plugin;
8
- }
9
- function defineRule(rule) {
10
- return rule;
11
- }
12
- //#endregion
13
- export { buildRuleRegistry, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, emptySetupConfig, executeCli, extractJsSourceUnits, formatDiagnostics, formatJson, formatStylish, getGlobalSetupConfigPath, getProjectSetupConfigPath, loadAlintConfig, loadSetupConfig, mergeSetupConfigs, parseSetupConfigToml, resolveModel, runAlint, sliceLines, sliceRange, stringifySetupConfigToml, writeSetupConfig };
1
+ import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-CoS-NVz_.mjs";
2
+ export { executeCli, formatDiagnostics, formatJson, formatStylish };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/cli",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.4",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -16,19 +16,19 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "c12": "^3.3.0",
19
+ "@clack/prompts": "^1.6.0",
20
+ "@moeru/std": "^0.1.0-beta.18",
20
21
  "cac": "^7.0.0",
21
22
  "cli-spinners": "^3.4.0",
22
- "es-toolkit": "^1.48.1",
23
- "oxc-parser": "^0.95.0",
23
+ "gitignore-fs": "^2.2.3",
24
24
  "pathe": "^2.0.3",
25
- "smol-toml": "^1.4.2",
26
- "std-env": "^4.1.0",
27
- "tinyglobby": "^0.2.15",
25
+ "table": "^6.9.0",
28
26
  "tinyrainbow": "^3.1.0",
29
- "xdg-basedir": "^5.1.0"
27
+ "@alint-js/core": "0.0.4",
28
+ "@alint-js/config": "0.0.4"
30
29
  },
31
30
  "devDependencies": {
31
+ "@types/node": "^26.0.1",
32
32
  "tsdown": "^0.22.3",
33
33
  "typescript": "^6.0.3",
34
34
  "vitest": "^4.1.9"