@alint-js/core 0.1.0 → 0.1.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 +33 -0
- package/dist/agent.d.mts +1 -1
- package/dist/{define-CnBawoAI.d.mts → define-8BzWDcPs.d.mts} +1 -1
- package/dist/dsl.d.mts +3 -3
- package/dist/index.d.mts +59 -20
- package/dist/index.mjs +1720 -845
- package/dist/structured-output.d.mts +1 -1
- package/dist/{types-m5T_UL76.d.mts → types-DKylUrAn.d.mts} +17 -4
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -39,6 +39,28 @@ export const rule = defineRule({
|
|
|
39
39
|
})
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
Project rules receive compact file and target entries. Read source only when the rule needs it:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { defineRule } from '@alint-js/core'
|
|
46
|
+
|
|
47
|
+
export const projectRule = defineRule({
|
|
48
|
+
create: ctx => ({
|
|
49
|
+
async onTargetProject(project) {
|
|
50
|
+
for (const entry of project.files) {
|
|
51
|
+
const file = await ctx.src.readFile(entry.path)
|
|
52
|
+
if (file.text.includes('deprecated-api'))
|
|
53
|
+
ctx.report({ filePath: entry.path, message: 'deprecated API used' })
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`ProjectFileEntry` and `ProjectTargetEntry` intentionally omit source text and arbitrary
|
|
61
|
+
extractor metadata. Calls to `ctx.src.readFile()` are explicit and plugin-owned, so a project
|
|
62
|
+
rule controls which source files it loads and how long it retains them.
|
|
63
|
+
|
|
42
64
|
Use the agent contract for tool-using rules:
|
|
43
65
|
|
|
44
66
|
```ts
|
|
@@ -86,8 +108,19 @@ explore with tools before answering, because a forced tool call is a single shot
|
|
|
86
108
|
- You are adding a language processor or source extractor.
|
|
87
109
|
- You are embedding `alint` in another tool.
|
|
88
110
|
- You are implementing an `AgentAdapter`.
|
|
111
|
+
- You need project-wide analysis that can consume compact descriptors and load source lazily.
|
|
89
112
|
|
|
90
113
|
## When not to use
|
|
91
114
|
|
|
92
115
|
- Use `@alint-js/cli` for command-line usage and ordinary `alint.config.*` files.
|
|
93
116
|
- Use `@alint-js/config` for setup TOML, config loading, and config-file tooling only.
|
|
117
|
+
- A plugin that needs a persistent repository database should build and inject that database.
|
|
118
|
+
Do not retain every `SourceFile` returned by `ctx.src.readFile()` as a substitute for one.
|
|
119
|
+
|
|
120
|
+
## Memory boundaries
|
|
121
|
+
|
|
122
|
+
`alint` bounds its engine-owned source sessions. It cannot bound source files retained by plugin
|
|
123
|
+
code after `ctx.src.readFile()` returns.
|
|
124
|
+
|
|
125
|
+
A valid cache written by the same `alint` version is still read from one monolithic JSON document.
|
|
126
|
+
An extremely large cache may therefore exhaust available memory.
|
package/dist/agent.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as AgentTool, I as AgentUsage, M as AgentAdapter, N as AgentRequest, P as AgentResult, b as RuleContext } from "./types-DKylUrAn.mjs";
|
|
2
2
|
//#region src/agent/retry.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Declares that the complete adapter invocation can be safely replayed.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as RuleOptionsSchema, i as AlintConfigItem, p as PluginDefinition, t as AlintConfig, w as RuleOptionsInput, x as RuleDefinition, y as RuleConfigEntry } from "./types-DKylUrAn.mjs";
|
|
2
2
|
//#region src/dsl/define.d.ts
|
|
3
3
|
type AnyRuleDefinition = RuleDefinition<any>;
|
|
4
4
|
type ConfigItemWithPluginRules<Plugins, Rules> = Omit<AlintConfigItem, 'plugins' | 'rules'> & {
|
package/dist/dsl.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-
|
|
3
|
-
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, type Awaitable, type DiagnosticDescriptor, type DiagnosticLocation, type DirectoryTarget, type EnabledRule, type IgnoreConfig, type LanguageDefinition, type PluginDefinition, type ProcessorDefinition, type ProjectTarget, type RuleCacheConfig, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleHandlers, type RuleInferenceUsageRecord, type RuleOptionsInput, type RuleOptionsOutput, type RuleOptionsSchema, type RuleRegistry, type RuleSeverity, type RuleSpecializedHandlers, type RuleWithHandler, type Target, defineConfig, definePlugin, defineRule };
|
|
1
|
+
import { A as RuleWithHandler, C as RuleInferenceUsageRecord, D as RuleRegistry, E as RuleOptionsSchema, O as RuleSeverity, S as RuleHandlers, T as RuleOptionsOutput, _ 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, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as EnabledRule, v as RuleCacheConfig, w as RuleOptionsInput, x as RuleDefinition, y as RuleConfigEntry } from "./types-DKylUrAn.mjs";
|
|
2
|
+
import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-8BzWDcPs.mjs";
|
|
3
|
+
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, type Awaitable, type DiagnosticDescriptor, type DiagnosticLocation, type DirectoryTarget, type EnabledRule, type IgnoreConfig, type LanguageDefinition, type PluginDefinition, type ProcessorDefinition, type ProjectFileEntry, type ProjectTarget, type ProjectTargetEntry, type RuleCacheConfig, type RuleConfigEntry, type RuleContext, type RuleDefinition, type RuleHandlers, type RuleInferenceUsageRecord, type RuleOptionsInput, type RuleOptionsOutput, type RuleOptionsSchema, type RuleRegistry, type RuleSeverity, type RuleSpecializedHandlers, type RuleWithHandler, type Target, defineConfig, definePlugin, defineRule };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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
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-
|
|
3
|
+
import { n as definePlugin, r as defineRule, t as defineConfig } from "./define-8BzWDcPs.mjs";
|
|
4
4
|
//#region src/config/config-array.d.ts
|
|
5
5
|
interface EffectiveAlintConfig {
|
|
6
6
|
agent?: AlintConfigItem['agent'];
|
|
@@ -50,11 +50,20 @@ declare function resolveLanguage(file: SourceFile, registry: LanguageRegistry, o
|
|
|
50
50
|
declare function createBuiltInLanguageRegistry(): LanguageRegistry;
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/core/types.d.ts
|
|
53
|
-
interface
|
|
54
|
-
|
|
53
|
+
interface AlintFileFailure {
|
|
54
|
+
file: {
|
|
55
|
+
index: number;
|
|
56
|
+
path: string;
|
|
57
|
+
};
|
|
58
|
+
kind: 'extract' | 'read';
|
|
59
|
+
message: string;
|
|
60
|
+
}
|
|
61
|
+
interface AlintRuleFailure {
|
|
62
|
+
job: ProgressJobRef;
|
|
55
63
|
kind: 'cache-replay' | 'handler' | 'timeout';
|
|
56
64
|
message: string;
|
|
57
65
|
}
|
|
66
|
+
type AlintRunFailure = AlintFileFailure | AlintRuleFailure;
|
|
58
67
|
interface Diagnostic {
|
|
59
68
|
cached?: boolean;
|
|
60
69
|
evidence?: unknown;
|
|
@@ -71,7 +80,8 @@ interface Diagnostic {
|
|
|
71
80
|
}
|
|
72
81
|
interface DiagnosticProgressPayload {
|
|
73
82
|
diagnostic: Diagnostic;
|
|
74
|
-
job:
|
|
83
|
+
job: ProgressJobRef;
|
|
84
|
+
progress: ProgressSnapshot;
|
|
75
85
|
}
|
|
76
86
|
interface ExecutionCounts {
|
|
77
87
|
cached: number;
|
|
@@ -84,57 +94,89 @@ interface ExecutionCounts {
|
|
|
84
94
|
/** Rules left unexecuted because they missed the cache under {@link RunOptions.cacheOnly}. */
|
|
85
95
|
skipped: number;
|
|
86
96
|
}
|
|
97
|
+
interface ExecutionProgressPayload {
|
|
98
|
+
progress: ProgressSnapshot;
|
|
99
|
+
}
|
|
100
|
+
interface FileReadyPayload extends ExecutionProgressPayload {
|
|
101
|
+
fileIndex: number;
|
|
102
|
+
inputPath: string;
|
|
103
|
+
jobsAdded: number;
|
|
104
|
+
}
|
|
87
105
|
type InferenceUsageRecord = Omit<RuleInferenceUsageRecord, 'ruleId'> & {
|
|
88
106
|
ruleId: string;
|
|
89
107
|
};
|
|
90
108
|
interface JobEndPayload extends JobStartPayload {
|
|
91
109
|
cache: 'hit' | 'miss';
|
|
92
110
|
endedAt?: number;
|
|
93
|
-
failure?:
|
|
111
|
+
failure?: AlintRuleFailure;
|
|
94
112
|
state: 'cached' | 'cancelled' | 'completed' | 'failed' | 'skipped';
|
|
95
113
|
}
|
|
96
114
|
interface JobQueuedPayload {
|
|
97
|
-
job:
|
|
115
|
+
job: ProgressJobRef;
|
|
116
|
+
progress: ProgressSnapshot;
|
|
98
117
|
}
|
|
99
118
|
interface JobRetryPayload {
|
|
100
119
|
attempt: number;
|
|
101
|
-
job:
|
|
120
|
+
job: ProgressJobRef;
|
|
102
121
|
maxAttempts: number;
|
|
122
|
+
progress: ProgressSnapshot;
|
|
103
123
|
startedAt?: number;
|
|
104
124
|
}
|
|
105
125
|
interface JobStartPayload {
|
|
106
|
-
job:
|
|
126
|
+
job: ProgressJobRef;
|
|
127
|
+
progress: ProgressSnapshot;
|
|
128
|
+
startedAt?: number;
|
|
129
|
+
}
|
|
130
|
+
interface PrepareEndPayload extends PrepareStartPayload {
|
|
131
|
+
endedAt?: number;
|
|
132
|
+
filesTotal: number;
|
|
133
|
+
}
|
|
134
|
+
interface PrepareStartPayload {
|
|
107
135
|
startedAt?: number;
|
|
108
136
|
}
|
|
109
|
-
interface
|
|
137
|
+
interface ProgressJobRef {
|
|
110
138
|
id: string;
|
|
111
139
|
index: number;
|
|
112
140
|
inputPath: string;
|
|
113
141
|
ruleId: string;
|
|
114
|
-
ruleIndex: number;
|
|
115
|
-
ruleTotal: number;
|
|
116
142
|
target: {
|
|
117
143
|
identity: string;
|
|
118
144
|
kind: ProgressTargetKind;
|
|
119
145
|
name?: string;
|
|
120
146
|
};
|
|
121
|
-
total: number;
|
|
122
147
|
}
|
|
123
148
|
interface ProgressReporter {
|
|
124
149
|
onDiagnostic?: (payload: DiagnosticProgressPayload) => void;
|
|
150
|
+
onExecuteEnd?: (payload: ExecutionProgressPayload & {
|
|
151
|
+
endedAt?: number;
|
|
152
|
+
}) => void;
|
|
153
|
+
onExecuteStart?: (payload: ExecutionProgressPayload & {
|
|
154
|
+
startedAt?: number;
|
|
155
|
+
}) => void;
|
|
156
|
+
onFileReady?: (payload: FileReadyPayload) => void;
|
|
125
157
|
onJobEnd?: (payload: JobEndPayload) => void;
|
|
126
158
|
onJobQueued?: (payload: JobQueuedPayload) => void;
|
|
127
159
|
onJobRetry?: (payload: JobRetryPayload) => void;
|
|
128
160
|
onJobStart?: (payload: JobStartPayload) => void;
|
|
161
|
+
onPrepareEnd?: (payload: PrepareEndPayload) => void;
|
|
162
|
+
onPrepareStart?: (payload: PrepareStartPayload) => void;
|
|
129
163
|
onRunEnd?: (payload: RunEndPayload) => void;
|
|
130
|
-
onRunStart?: (payload: RunStartPayload) => void;
|
|
131
164
|
onUsage?: (payload: UsageProgressPayload) => void;
|
|
132
165
|
}
|
|
166
|
+
interface ProgressSnapshot {
|
|
167
|
+
execution: ExecutionCounts;
|
|
168
|
+
filesTotal: number;
|
|
169
|
+
final: boolean;
|
|
170
|
+
jobsCompleted: number;
|
|
171
|
+
jobsStarted: number;
|
|
172
|
+
jobsTotal: number;
|
|
173
|
+
}
|
|
133
174
|
type ProgressTargetKind = SourceTargetKind;
|
|
134
175
|
interface RunEndPayload {
|
|
135
176
|
diagnostics: Diagnostic[];
|
|
136
177
|
endedAt?: number;
|
|
137
178
|
execution: ExecutionCounts;
|
|
179
|
+
progress: ProgressSnapshot;
|
|
138
180
|
startedAt?: number;
|
|
139
181
|
usage: RunUsage;
|
|
140
182
|
}
|
|
@@ -175,10 +217,6 @@ interface RunResult {
|
|
|
175
217
|
execution: ExecutionCounts;
|
|
176
218
|
usage: RunUsage;
|
|
177
219
|
}
|
|
178
|
-
interface RunStartPayload {
|
|
179
|
-
jobsTotal: number;
|
|
180
|
-
startedAt?: number;
|
|
181
|
-
}
|
|
182
220
|
interface RunUsage {
|
|
183
221
|
cached?: RunUsageTotals;
|
|
184
222
|
inputTokens: number;
|
|
@@ -193,7 +231,8 @@ interface RunUsageTotals {
|
|
|
193
231
|
totalTokens: number;
|
|
194
232
|
}
|
|
195
233
|
interface UsageProgressPayload {
|
|
196
|
-
job:
|
|
234
|
+
job: ProgressJobRef;
|
|
235
|
+
progress: ProgressSnapshot;
|
|
197
236
|
record: InferenceUsageRecord;
|
|
198
237
|
}
|
|
199
238
|
//#endregion
|
|
@@ -233,4 +272,4 @@ declare function buildRuleRegistry(config: RuleRegistryConfig): RuleRegistry;
|
|
|
233
272
|
//#region src/models/resolve.d.ts
|
|
234
273
|
declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
|
|
235
274
|
//#endregion
|
|
236
|
-
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
|
|
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 };
|