@alint-js/core 0.0.29 → 0.0.31
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/{retry-C4sGjSE5.mjs → agent-weXkvGkc.mjs} +20 -1
- package/dist/agent.d.mts +3 -2
- package/dist/agent.mjs +2 -15
- package/dist/index.d.mts +55 -84
- package/dist/index.mjs +433 -530
- package/dist/structured-output.d.mts +1 -1
- package/dist/structured-output.mjs +5 -4
- package/dist/{types-CMLoj9J9.d.mts → types-CR_Grd6q.d.mts} +0 -1
- package/package.json +2 -2
|
@@ -47,4 +47,23 @@ function withAgentRetry(adapter, retries = 2) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
|
|
50
|
+
//#region src/agent/index.ts
|
|
51
|
+
function combineAbortSignals(...candidates) {
|
|
52
|
+
const signals = candidates.filter((signal) => signal !== void 0);
|
|
53
|
+
if (signals.length === 0) return void 0;
|
|
54
|
+
if (signals.length === 1) return signals[0];
|
|
55
|
+
return AbortSignal.any(signals);
|
|
56
|
+
}
|
|
57
|
+
function defineTool(tool) {
|
|
58
|
+
return tool;
|
|
59
|
+
}
|
|
60
|
+
function requireAgent(context) {
|
|
61
|
+
if (!context.agent) throw new TypeError(`Rule "${context.id}" requires an agent, but none is configured. Set "agent" in alint config (e.g. agent: createApeiraAdapter()).`);
|
|
62
|
+
const agent = context.agent;
|
|
63
|
+
return async (request) => agent({
|
|
64
|
+
...request,
|
|
65
|
+
signal: request.signal ?? context.signal
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { isRetryableAgentError as a, RetryableAgentError as i, defineTool as n, withAgentRetry as o, requireAgent as r, combineAbortSignals as t };
|
package/dist/agent.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as AgentTool, D as AgentAdapter, O as AgentRequest, j as AgentUsage, k as AgentResult, v as RuleContext } from "./types-
|
|
1
|
+
import { A as AgentTool, D as AgentAdapter, O as AgentRequest, j as AgentUsage, k as AgentResult, v as RuleContext } from "./types-CR_Grd6q.mjs";
|
|
2
2
|
//#region src/agent/retry.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Declares that the complete adapter invocation can be safely replayed.
|
|
@@ -10,7 +10,8 @@ declare class RetryableAgentError extends Error {
|
|
|
10
10
|
declare function isRetryableAgentError(error: unknown): error is RetryableAgentError;
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/agent/index.d.ts
|
|
13
|
+
declare function combineAbortSignals(...candidates: Array<AbortSignal | undefined>): AbortSignal | undefined;
|
|
13
14
|
declare function defineTool(tool: AgentTool): AgentTool;
|
|
14
15
|
declare function requireAgent(context: Pick<RuleContext, 'agent' | 'id' | 'signal'>): AgentAdapter;
|
|
15
16
|
//#endregion
|
|
16
|
-
export { type AgentAdapter, type AgentRequest, type AgentResult, type AgentTool, type AgentUsage, RetryableAgentError, defineTool, isRetryableAgentError, requireAgent };
|
|
17
|
+
export { type AgentAdapter, type AgentRequest, type AgentResult, type AgentTool, type AgentUsage, RetryableAgentError, combineAbortSignals, defineTool, isRetryableAgentError, requireAgent };
|
package/dist/agent.mjs
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
function defineTool(tool) {
|
|
4
|
-
return tool;
|
|
5
|
-
}
|
|
6
|
-
function requireAgent(context) {
|
|
7
|
-
if (!context.agent) throw new TypeError(`Rule "${context.id}" requires an agent, but none is configured. Set "agent" in alint config (e.g. agent: createApeiraAdapter()).`);
|
|
8
|
-
const agent = context.agent;
|
|
9
|
-
return async (request) => agent({
|
|
10
|
-
...request,
|
|
11
|
-
signal: request.signal ?? context.signal
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { RetryableAgentError, defineTool, isRetryableAgentError, requireAgent };
|
|
1
|
+
import { a as isRetryableAgentError, i as RetryableAgentError, n as defineTool, r as requireAgent, t as combineAbortSignals } from "./agent-weXkvGkc.mjs";
|
|
2
|
+
export { RetryableAgentError, combineAbortSignals, defineTool, isRetryableAgentError, requireAgent };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as RunnerStatsConfig, C as RuleSeverity, E as Target, F as ResolvedProvider, H as SetupModelDefinition, I as ModelSize, L as ProviderDefinition, M as ModelRequirement, N as ResolveModelOptions, P as ResolvedModel, R as ProviderType, S as RuleRegistry, T as RuleWithHandler, V as SetupConfig, _ as RuleConfigEntry, a as AlintLinterOptions, b as RuleHandlers, c as DiagnosticLocation, d as IgnoreConfig, f as LanguageDefinition, g as RuleCacheConfig, h as ProjectTarget, i as AlintConfigItem, l as DirectoryTarget, m as ProcessorDefinition, n as AlintConfigExtends, o as Awaitable, p as PluginDefinition, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as EnabledRule, v as RuleContext, w as RuleSpecializedHandlers, x as RuleInferenceUsageRecord, y as RuleDefinition, z as RunnerConfig } from "./types-
|
|
1
|
+
import { B as RunnerStatsConfig, C as RuleSeverity, E as Target, F as ResolvedProvider, H as SetupModelDefinition, I as ModelSize, L as ProviderDefinition, M as ModelRequirement, N as ResolveModelOptions, P as ResolvedModel, R as ProviderType, S as RuleRegistry, T as RuleWithHandler, V as SetupConfig, _ as RuleConfigEntry, a as AlintLinterOptions, b as RuleHandlers, c as DiagnosticLocation, d as IgnoreConfig, f as LanguageDefinition, g as RuleCacheConfig, h as ProjectTarget, i as AlintConfigItem, l as DirectoryTarget, m as ProcessorDefinition, n as AlintConfigExtends, o as Awaitable, p as PluginDefinition, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as EnabledRule, v as RuleContext, w as RuleSpecializedHandlers, x as RuleInferenceUsageRecord, y as RuleDefinition, z as RunnerConfig } from "./types-CR_Grd6q.mjs";
|
|
2
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
3
|
//#region src/config/config-array.d.ts
|
|
4
4
|
interface EffectiveAlintConfig {
|
|
@@ -50,13 +50,9 @@ declare function createBuiltInLanguageRegistry(): LanguageRegistry;
|
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/core/types.d.ts
|
|
52
52
|
interface AlintRunFailure {
|
|
53
|
-
|
|
53
|
+
job: ProgressJob;
|
|
54
|
+
kind: 'cache-replay' | 'handler' | 'timeout';
|
|
54
55
|
message: string;
|
|
55
|
-
ruleId?: string;
|
|
56
|
-
target?: {
|
|
57
|
-
kind: ProgressTargetKind;
|
|
58
|
-
name?: string;
|
|
59
|
-
};
|
|
60
56
|
}
|
|
61
57
|
interface Diagnostic {
|
|
62
58
|
cached?: boolean;
|
|
@@ -74,96 +70,70 @@ interface Diagnostic {
|
|
|
74
70
|
}
|
|
75
71
|
interface DiagnosticProgressPayload {
|
|
76
72
|
diagnostic: Diagnostic;
|
|
77
|
-
|
|
78
|
-
path?: ProgressPath;
|
|
73
|
+
job: ProgressJob;
|
|
79
74
|
}
|
|
80
|
-
interface
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
interface ExecutionCounts {
|
|
76
|
+
cached: number;
|
|
77
|
+
cancelled: number;
|
|
78
|
+
completed: number;
|
|
79
|
+
failed: number;
|
|
80
|
+
planned: number;
|
|
81
|
+
queued: number;
|
|
82
|
+
running: number;
|
|
83
|
+
/** Rules left unexecuted because they missed the cache under {@link RunOptions.cacheOnly}. */
|
|
84
|
+
skipped: number;
|
|
84
85
|
}
|
|
85
86
|
type InferenceUsageRecord = Omit<RuleInferenceUsageRecord, 'ruleId'> & {
|
|
86
87
|
ruleId: string;
|
|
87
88
|
};
|
|
88
|
-
interface
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
interface JobEndPayload extends JobStartPayload {
|
|
90
|
+
cache: 'hit' | 'miss';
|
|
91
|
+
endedAt?: number;
|
|
92
|
+
failure?: AlintRunFailure;
|
|
93
|
+
state: 'cached' | 'cancelled' | 'completed' | 'failed' | 'skipped';
|
|
93
94
|
}
|
|
94
|
-
interface
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
interface JobQueuedPayload {
|
|
96
|
+
job: ProgressJob;
|
|
97
|
+
}
|
|
98
|
+
interface JobStartPayload {
|
|
99
|
+
job: ProgressJob;
|
|
100
|
+
startedAt?: number;
|
|
101
|
+
}
|
|
102
|
+
interface ProgressJob {
|
|
103
|
+
id: string;
|
|
104
|
+
index: number;
|
|
105
|
+
inputPath: string;
|
|
106
|
+
ruleId: string;
|
|
101
107
|
target: {
|
|
102
|
-
|
|
108
|
+
identity: string;
|
|
103
109
|
kind: ProgressTargetKind;
|
|
104
110
|
name?: string;
|
|
105
|
-
total: number;
|
|
106
111
|
};
|
|
112
|
+
total: number;
|
|
107
113
|
}
|
|
108
114
|
interface ProgressReporter {
|
|
109
115
|
onDiagnostic?: (payload: DiagnosticProgressPayload) => void;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
onRuleStart?: (payload: RuleStartPayload) => void;
|
|
116
|
+
onJobEnd?: (payload: JobEndPayload) => void;
|
|
117
|
+
onJobQueued?: (payload: JobQueuedPayload) => void;
|
|
118
|
+
onJobStart?: (payload: JobStartPayload) => void;
|
|
114
119
|
onRunEnd?: (payload: RunEndPayload) => void;
|
|
115
120
|
onRunStart?: (payload: RunStartPayload) => void;
|
|
116
|
-
onTargetEnd?: (payload: TargetProgressPayload) => void;
|
|
117
|
-
onTargetStart?: (payload: TargetProgressPayload) => void;
|
|
118
121
|
onUsage?: (payload: UsageProgressPayload) => void;
|
|
119
122
|
}
|
|
120
123
|
type ProgressTargetKind = SourceTargetKind;
|
|
121
|
-
interface RuleEndPayload {
|
|
122
|
-
cache: 'hit' | 'miss';
|
|
123
|
-
endedAt?: number;
|
|
124
|
-
path: ProgressPath;
|
|
125
|
-
startedAt?: number;
|
|
126
|
-
/**
|
|
127
|
-
* `skipped` only occurs under {@link RunOptions.cacheOnly}: the rule missed the cache and was
|
|
128
|
-
* never executed, so it produced no diagnostics. `cache` is still `'miss'` in that case.
|
|
129
|
-
*/
|
|
130
|
-
state: 'completed' | 'errored' | 'skipped';
|
|
131
|
-
}
|
|
132
|
-
interface RuleStartPayload {
|
|
133
|
-
path: ProgressPath;
|
|
134
|
-
startedAt?: number;
|
|
135
|
-
}
|
|
136
124
|
interface RunEndPayload {
|
|
137
|
-
cached: number;
|
|
138
|
-
completed: number;
|
|
139
125
|
diagnostics: Diagnostic[];
|
|
140
126
|
endedAt?: number;
|
|
141
|
-
|
|
142
|
-
planned: number;
|
|
143
|
-
/** Rules left unexecuted because they missed the cache under {@link RunOptions.cacheOnly}. Always 0 otherwise. */
|
|
144
|
-
skipped: number;
|
|
127
|
+
execution: ExecutionCounts;
|
|
145
128
|
startedAt?: number;
|
|
146
129
|
usage: RunUsage;
|
|
147
130
|
}
|
|
148
|
-
|
|
149
|
-
cached: number;
|
|
150
|
-
completed: number;
|
|
151
|
-
errored: number;
|
|
152
|
-
planned: number;
|
|
153
|
-
/** Rules left unexecuted because they missed the cache under {@link RunOptions.cacheOnly}. Always 0 otherwise. */
|
|
154
|
-
skipped: number;
|
|
155
|
-
}
|
|
131
|
+
type RunExecution = ExecutionCounts;
|
|
156
132
|
type RunnerOptions = RunnerConfig;
|
|
157
133
|
interface RunOptions {
|
|
158
134
|
/**
|
|
159
135
|
* Return only diagnostics that are already cached, without calling any model.
|
|
160
|
-
*
|
|
161
|
-
* Rules that miss the cache are skipped instead of executed, and the run leaves the cache
|
|
162
|
-
* file untouched. Read {@link RunExecution.skipped} to see how many rules a full run would
|
|
163
|
-
* still have to execute.
|
|
164
|
-
*
|
|
165
|
-
* Intended for callers that want to show known results for free, such as an editor
|
|
166
|
-
* displaying diagnostics on file open.
|
|
136
|
+
* Rules that miss the cache are skipped, and the cache remains read-only.
|
|
167
137
|
*/
|
|
168
138
|
cacheOnly?: boolean;
|
|
169
139
|
config?: AlintConfig;
|
|
@@ -187,14 +157,11 @@ interface RunOptions {
|
|
|
187
157
|
}
|
|
188
158
|
interface RunResult {
|
|
189
159
|
diagnostics: Diagnostic[];
|
|
190
|
-
execution
|
|
160
|
+
execution: ExecutionCounts;
|
|
191
161
|
usage: RunUsage;
|
|
192
162
|
}
|
|
193
163
|
interface RunStartPayload {
|
|
194
|
-
|
|
195
|
-
filesTotal: number;
|
|
196
|
-
planned: number;
|
|
197
|
-
rulesTotal: number;
|
|
164
|
+
jobsTotal: number;
|
|
198
165
|
startedAt?: number;
|
|
199
166
|
}
|
|
200
167
|
interface RunUsage {
|
|
@@ -210,24 +177,28 @@ interface RunUsageTotals {
|
|
|
210
177
|
records: InferenceUsageRecord[];
|
|
211
178
|
totalTokens: number;
|
|
212
179
|
}
|
|
213
|
-
interface TargetProgressPayload {
|
|
214
|
-
endedAt?: number;
|
|
215
|
-
path: ProgressPath;
|
|
216
|
-
startedAt?: number;
|
|
217
|
-
}
|
|
218
180
|
interface UsageProgressPayload {
|
|
219
|
-
|
|
181
|
+
job: ProgressJob;
|
|
220
182
|
record: InferenceUsageRecord;
|
|
221
|
-
total: RunUsage;
|
|
222
183
|
}
|
|
223
184
|
//#endregion
|
|
224
185
|
//#region src/core/run.d.ts
|
|
186
|
+
declare class AlintRunCancelledError extends Error {
|
|
187
|
+
readonly result: RunResult;
|
|
188
|
+
constructor(result: RunResult, cause?: unknown);
|
|
189
|
+
}
|
|
190
|
+
/** Cancellation error carrying the partial result gathered before the abort. */
|
|
191
|
+
declare class AlintAbortError extends AlintRunCancelledError {
|
|
192
|
+
constructor(result: RunResult, options?: {
|
|
193
|
+
cause?: unknown;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
225
196
|
declare class AlintRunError extends Error {
|
|
226
|
-
readonly
|
|
197
|
+
readonly failures: AlintRunFailure[];
|
|
227
198
|
readonly result: RunResult;
|
|
228
199
|
constructor(message: string, result: RunResult, options?: {
|
|
229
200
|
cause?: unknown;
|
|
230
|
-
|
|
201
|
+
failures?: AlintRunFailure[];
|
|
231
202
|
});
|
|
232
203
|
}
|
|
233
204
|
declare function runAlint(options?: RunOptions): Promise<RunResult>;
|
|
@@ -249,4 +220,4 @@ declare function buildRuleRegistry(config: Pick<EffectiveAlintConfig, 'plugins'
|
|
|
249
220
|
//#region src/models/resolve.d.ts
|
|
250
221
|
declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
|
|
251
222
|
//#endregion
|
|
252
|
-
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, AlintRunError, type AlintRunFailure, type Awaitable, type ClassTarget, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type DirectoryTarget, type EffectiveAlintConfig, type EnabledRule, type
|
|
223
|
+
export { AlintAbortError, type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, 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 FileTarget, type FunctionTarget, type IgnoreConfig, type InferenceUsageRecord, type JobEndPayload, type JobQueuedPayload, type JobStartPayload, type LanguageContext, type LanguageDefinition, type LanguageRegistry, type LineRange, type ModelRequirement, type ModelSize, type PluginDefinition, type ProcessedSource, type ProcessedSourceOrigin, type ProcessorContext, type ProcessorDefinition, type ProcessorPostprocessContext, type ProgressJob, type ProgressReporter, type ProgressTargetKind, type ProjectTarget, 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 RunStartPayload, 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 };
|