@alint-js/core 0.1.3 → 0.1.5

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,6 +1,6 @@
1
- import { A as RuleWithHandler, B as ResolvedProvider, C as RuleInferenceUsageRecord, D as RuleRegistry, G as RunnerStatsConfig, H as ProviderDefinition, K as SetupConfig, L as ModelRequirement, O as RuleSeverity, R as ResolveModelOptions, S as RuleHandlers, U as ProviderType, V as ModelSize, W as RunnerConfig, _ as ProjectTargetEntry, a as AlintLinterOptions, b as RuleContext, c as DiagnosticLocation, d as IgnoreConfig, f as LanguageDefinition, g as ProjectTarget, h as ProjectFileEntry, i as AlintConfigItem, j as Target, k as RuleSpecializedHandlers, l as DirectoryTarget, m as ProcessorDefinition, n as AlintConfigExtends, o as Awaitable, p as PluginDefinition, q as SetupModelDefinition, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as EnabledRule, v as RuleCacheConfig, x as RuleDefinition, y as RuleConfigEntry, z as ResolvedModel } from "./types-DKylUrAn.mjs";
2
- import { _ as SourceTargetOfKind, a as LineRange, c as ProcessorContext, d as SourceLocation, f as SourcePosition, g as SourceTargetKind, h as SourceTarget, i as LanguageContext, l as ProcessorPostprocessContext, m as SourceRuntime, n as FileTarget, o as ProcessedSource, p as SourceRange, r as FunctionTarget, s as ProcessedSourceOrigin, t as ClassTarget, u as SourceFile, v as SourceTargetOrigin, y as SourceText } from "./types-DSvXUVZ7.mjs";
3
- import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-8BzWDcPs.mjs";
1
+ import { A as RuleWithHandler, B as ResolvedProvider, C as RuleInferenceUsageRecord, D as RuleRegistry, G as RunnerStatsConfig, H as ProviderDefinition, K as SetupConfig, L as ModelRequirement, O as RuleSeverity, R as ResolveModelOptions, S as RuleHandlers, U as ProviderType, V as ModelSize, W as RunnerConfig, _ as ProjectTargetEntry, a as AlintLinterOptions, b as RuleContext, c as DiagnosticLocation, d as IgnoreConfig, f as LanguageDefinition, g as ProjectTarget, h as ProjectFileEntry, i as AlintConfigItem, j as Target, k as RuleSpecializedHandlers, l as DirectoryTarget, m as ProcessorDefinition, n as AlintConfigExtends, o as Awaitable, p as PluginDefinition, q as SetupModelDefinition, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as EnabledRule, v as RuleCacheConfig, x as RuleDefinition, y as RuleConfigEntry, z as ResolvedModel } from "./types-deBCDA4_.mjs";
2
+ import { C as SourceTarget, D as SourceTargetOrigin, E as SourceTargetOfKind, O as SourceText, S as SourceRuntime, T as SourceTargetMetadata, _ as SourceLocation, a as FunctionInfo, b as SourcePosition, c as LineRange, d as ProcessedSource, f as ProcessedSourceOrigin, g as SourceFile, h as SourceExtractOptions, i as FileTarget, l as PlannedSourceTarget, m as ProcessorPostprocessContext, n as CallSite, o as FunctionTarget, p as ProcessorContext, r as ClassTarget, s as LanguageContext, t as BaseSourceFile, u as PlannedSourceTargetOfKind, v as SourceMetadataObject, w as SourceTargetKind, x as SourceRange, y as SourceMetadataValue } from "./types-DM4idR4w.mjs";
3
+ import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-CJ2QJPZ8.mjs";
4
4
  //#region src/config/config-array.d.ts
5
5
  interface EffectiveAlintConfig {
6
6
  agent?: AlintConfigItem['agent'];
@@ -60,7 +60,7 @@ interface AlintFileFailure {
60
60
  }
61
61
  interface AlintRuleFailure {
62
62
  job: ProgressJobRef;
63
- kind: 'cache-replay' | 'handler' | 'timeout';
63
+ kind: 'cache-replay' | 'handler' | 'source-changed' | 'timeout';
64
64
  message: string;
65
65
  }
66
66
  type AlintRunFailure = AlintFileFailure | AlintRuleFailure;
@@ -158,6 +158,7 @@ interface ProgressReporter {
158
158
  onJobQueued?: (payload: JobQueuedPayload) => void;
159
159
  onJobRetry?: (payload: JobRetryPayload) => void;
160
160
  onJobStart?: (payload: JobStartPayload) => void;
161
+ onPlanningEnd?: (payload: ExecutionProgressPayload) => void;
161
162
  onPrepareEnd?: (payload: PrepareEndPayload) => void;
162
163
  onPrepareStart?: (payload: PrepareStartPayload) => void;
163
164
  onRunEnd?: (payload: RunEndPayload) => void;
@@ -165,11 +166,12 @@ interface ProgressReporter {
165
166
  }
166
167
  interface ProgressSnapshot {
167
168
  execution: ExecutionCounts;
169
+ filesPlanned: number;
168
170
  filesTotal: number;
169
- final: boolean;
170
171
  jobsCompleted: number;
171
172
  jobsStarted: number;
172
173
  jobsTotal: number;
174
+ planningComplete: boolean;
173
175
  }
174
176
  type ProgressTargetKind = SourceTargetKind;
175
177
  interface RunEndPayload {
@@ -236,6 +238,21 @@ interface UsageProgressPayload {
236
238
  record: InferenceUsageRecord;
237
239
  }
238
240
  //#endregion
241
+ //#region src/core/preparation.d.ts
242
+ /**
243
+ * The `ctx.src.extract` a run hands to rules, for parsing files it was never asked to lint, which
244
+ * an index builder sweeping the workspace needs.
245
+ *
246
+ * It resolves each file's OWN config rather than a caller's, because the language a file resolves to
247
+ * is a config decision and two config groups may register different plugins. It extracts on demand
248
+ * and holds nothing: source planning releases rich extractor values after compact jobs are admitted,
249
+ * and a run-wide parse memo here would put that retention back. A caller keeps only what it derives.
250
+ *
251
+ * `getSrc` defers reading the runtime because the runtime is built around this closure. It is assigned
252
+ * before any rule runs, so by the first call it is present.
253
+ */
254
+ declare function createSourceExtractor(cwd: string, config: AlintConfig, getSrc: () => SourceRuntime): SourceRuntime['extract'];
255
+ //#endregion
239
256
  //#region src/core/run.d.ts
240
257
  declare class AlintRunCancelledError extends Error {
241
258
  readonly result: RunResult;
@@ -257,11 +274,42 @@ declare class AlintRunError extends Error {
257
274
  }
258
275
  declare function runAlint(options?: RunOptions): Promise<RunResult>;
259
276
  //#endregion
277
+ //#region src/core/source/identity.d.ts
278
+ /** A target's identity from its position. */
279
+ declare function targetIdentity(kind: SourceTargetKind, name: string | undefined, range: SourceRange): string;
280
+ /**
281
+ * Swaps a target's positional identity for its name, where that name is unique among these targets.
282
+ *
283
+ * Identities key caches, so a function that only moved should keep the identity it had. Two targets
284
+ * sharing a name cannot be told apart that way, so both keep the positional form.
285
+ *
286
+ * Run every function and class target through this. Skip it in one producer and the same function
287
+ * ends up with a different identity depending on which language read it.
288
+ */
289
+ declare function withStableIdentities(targets: readonly SourceTarget[]): SourceTarget[];
290
+ //#endregion
260
291
  //#region src/core/source/runtime.d.ts
292
+ interface SourceRuntimeOptions {
293
+ /**
294
+ * Extraction for arbitrary files, injected by the run.
295
+ *
296
+ * The runtime cannot do this itself: extraction resolves the file's own config, and importing
297
+ * config resolution here would point the source module back at the layers built on top of it.
298
+ * `runAlint` has the config in scope before it builds the runtime, so it passes the closure down.
299
+ */
300
+ extract?: SourceRuntime['extract'];
301
+ /**
302
+ * Replaces the complete source read operation, including descriptor validation. The other
303
+ * members need no override: `getText` and the slicers are pure functions over whatever
304
+ * `readFile` returned, and `extract` already defaults to a throwing stub outside a run.
305
+ */
306
+ readFile?: SourceRuntime['readFile'];
307
+ }
261
308
  declare function createSourceFile(path: string, text: string): SourceFile;
262
- declare function createSourceRuntime(): SourceRuntime;
309
+ declare function createSourceRuntime(options?: SourceRuntimeOptions): SourceRuntime;
263
310
  declare function sliceLines(file: SourceFile, range: LineRange): SourceText;
264
311
  declare function sliceRange(file: SourceFile, range: SourceRange): SourceText;
312
+ declare function withLanguage(file: SourceFile, language: string): SourceFile;
265
313
  //#endregion
266
314
  //#region src/dsl/registry.d.ts
267
315
  type RuleRegistryConfig = Pick<EffectiveAlintConfig, 'plugins'> & {
@@ -269,7 +317,61 @@ type RuleRegistryConfig = Pick<EffectiveAlintConfig, 'plugins'> & {
269
317
  };
270
318
  declare function buildRuleRegistry(config: RuleRegistryConfig): RuleRegistry;
271
319
  //#endregion
320
+ //#region src/models/benchmark.d.ts
321
+ interface BenchmarkModelsOptions {
322
+ onProgress?: (progress: ModelBenchmarkProgress) => void;
323
+ providerConcurrency?: Readonly<Record<string, number>>;
324
+ request?: (request: ModelBenchmarkRequest) => Promise<ModelBenchmarkMeasurement>;
325
+ sampleCount?: number;
326
+ seed?: number;
327
+ timeoutMs?: number;
328
+ }
329
+ interface ModelBenchmarkActive {
330
+ modelId: string;
331
+ modelIndex: number;
332
+ phase: 'non-repeat' | 'repeat';
333
+ providerId: string;
334
+ sample: number;
335
+ samples: number;
336
+ success: ModelBenchmarkResult['success'];
337
+ warmup: boolean;
338
+ }
339
+ interface ModelBenchmarkMeasurement {
340
+ durationMs: number;
341
+ firstOutputMs?: number;
342
+ outputTokens?: number;
343
+ }
344
+ interface ModelBenchmarkProgress {
345
+ active: readonly ModelBenchmarkActive[];
346
+ modelsTotal: number;
347
+ results: readonly (ModelBenchmarkResult | undefined)[];
348
+ }
349
+ interface ModelBenchmarkRequest {
350
+ model: ResolvedModel;
351
+ prompt: string;
352
+ signal: AbortSignal;
353
+ }
354
+ interface ModelBenchmarkResult {
355
+ error?: string;
356
+ modelId: string;
357
+ nonRepeatMs?: number;
358
+ providerId: string;
359
+ repeatMs?: number;
360
+ success: {
361
+ attempted: number;
362
+ completed: number;
363
+ };
364
+ throughput?: number;
365
+ }
366
+ /**
367
+ * Benchmarks model jobs concurrently within independent provider limits.
368
+ *
369
+ * Each model's repeat warm-up, measured repeats, and non-repeats remain serial so concurrent samples cannot
370
+ * distort that model's cache behavior. Non-repeat prompts put their nonce before the shared corpus.
371
+ */
372
+ declare function benchmarkModels(config: SetupConfig, options?: BenchmarkModelsOptions): Promise<ModelBenchmarkResult[]>;
373
+ //#endregion
272
374
  //#region src/models/resolve.d.ts
273
375
  declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
274
376
  //#endregion
275
- export { AlintAbortError, type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintFileFailure, type AlintLinterOptions, type AlintRuleFailure, AlintRunCancelledError, AlintRunError, type AlintRunFailure, type Awaitable, type ClassTarget, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type DirectoryTarget, type EffectiveAlintConfig, type EnabledRule, type ExecutionCounts, type ExecutionProgressPayload, type FileReadyPayload, type FileTarget, type FunctionTarget, type IgnoreConfig, type InferenceUsageRecord, type JobEndPayload, type JobQueuedPayload, type JobRetryPayload, type JobStartPayload, type LanguageContext, type LanguageDefinition, type LanguageRegistry, type LineRange, type ModelRequirement, type ModelSize, type PluginDefinition, type PrepareEndPayload, type PrepareStartPayload, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProgressJobRef, type ProgressReporter, type ProgressSnapshot, type ProgressTargetKind, type ProjectFileEntry, type ProjectTarget, type ProjectTargetEntry, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, 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 RunEndPayload, type RunExecution, type RunOptions, type RunResult, type RunUsage, type RunUsageTotals, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type SourceFile, type SourceLocation, type SourcePosition, type SourceRange, type SourceRuntime, type SourceTarget, type SourceTargetKind, type SourceTargetOfKind, type SourceTargetOrigin, type SourceText, type Target, type UsageProgressPayload, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForDirectory, resolveConfigForFile, resolveConfigForProject, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange };
377
+ export { AlintAbortError, type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintFileFailure, type AlintLinterOptions, type AlintRuleFailure, AlintRunCancelledError, AlintRunError, type AlintRunFailure, type Awaitable, type BaseSourceFile, type BenchmarkModelsOptions, type CallSite, type ClassTarget, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type DirectoryTarget, type EffectiveAlintConfig, type EnabledRule, type ExecutionCounts, type ExecutionProgressPayload, type FileReadyPayload, type FileTarget, type FunctionInfo, type FunctionTarget, type IgnoreConfig, type InferenceUsageRecord, type JobEndPayload, type JobQueuedPayload, type JobRetryPayload, type JobStartPayload, type LanguageContext, type LanguageDefinition, type LanguageRegistry, type LineRange, type ModelBenchmarkActive, type ModelBenchmarkMeasurement, type ModelBenchmarkProgress, type ModelBenchmarkRequest, type ModelBenchmarkResult, type ModelRequirement, type ModelSize, type PlannedSourceTarget, type PlannedSourceTargetOfKind, type PluginDefinition, type PrepareEndPayload, type PrepareStartPayload, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProgressJobRef, type ProgressReporter, type ProgressSnapshot, type ProgressTargetKind, type ProjectFileEntry, type ProjectTarget, type ProjectTargetEntry, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, 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 RunEndPayload, type RunExecution, type RunOptions, type RunResult, type RunUsage, type RunUsageTotals, type RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type SourceExtractOptions, type SourceFile, type SourceLocation, type SourceMetadataObject, type SourceMetadataValue, type SourcePosition, type SourceRange, type SourceRuntime, type SourceRuntimeOptions, type SourceTarget, type SourceTargetKind, type SourceTargetMetadata, type SourceTargetOfKind, type SourceTargetOrigin, type SourceText, type Target, type UsageProgressPayload, benchmarkModels, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceExtractor, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForDirectory, resolveConfigForFile, resolveConfigForProject, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange, targetIdentity, withLanguage, withStableIdentities };