@alint-js/core 0.0.8 → 0.0.9
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/agent.d.mts +3 -28
- package/dist/agent.mjs +5 -1
- package/dist/index.d.mts +3 -190
- package/dist/index.mjs +4 -1
- package/dist/types-DQfoxG8J.d.mts +287 -0
- package/package.json +1 -1
- package/dist/types-BPiUTLXT.d.mts +0 -65
package/dist/agent.d.mts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as AgentTool, L as AgentAdapter, R as AgentRequest, V as AgentUsage, g as RuleContext, z as AgentResult } from "./types-DQfoxG8J.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/agent/types.d.ts
|
|
4
|
-
type AgentAdapter = (request: AgentRequest) => Promise<AgentResult>;
|
|
5
|
-
interface AgentRequest {
|
|
6
|
-
instructions: string;
|
|
7
|
-
model: ResolvedModel;
|
|
8
|
-
prompt: string;
|
|
9
|
-
signal?: AbortSignal;
|
|
10
|
-
tools: AgentTool[];
|
|
11
|
-
}
|
|
12
|
-
interface AgentResult {
|
|
13
|
-
answer: string;
|
|
14
|
-
usage?: AgentUsage;
|
|
15
|
-
}
|
|
16
|
-
/** Agent-agnostic tool definition. Each adapter translates it to its framework's tool format. */
|
|
17
|
-
interface AgentTool {
|
|
18
|
-
description: string;
|
|
19
|
-
execute: (input: unknown) => Promise<unknown> | unknown;
|
|
20
|
-
name: string;
|
|
21
|
-
parameters: Record<string, unknown>;
|
|
22
|
-
}
|
|
23
|
-
interface AgentUsage {
|
|
24
|
-
inputTokens?: number;
|
|
25
|
-
outputTokens?: number;
|
|
26
|
-
totalTokens?: number;
|
|
27
|
-
}
|
|
28
|
-
//#endregion
|
|
29
3
|
//#region src/agent/index.d.ts
|
|
30
4
|
declare function defineTool(tool: AgentTool): AgentTool;
|
|
5
|
+
declare function requireAgent(context: Pick<RuleContext, 'agent' | 'id'>): AgentAdapter;
|
|
31
6
|
//#endregion
|
|
32
|
-
export { type AgentAdapter, type AgentRequest, type AgentResult, type AgentTool, type AgentUsage, defineTool };
|
|
7
|
+
export { type AgentAdapter, type AgentRequest, type AgentResult, type AgentTool, type AgentUsage, defineTool, requireAgent };
|
package/dist/agent.mjs
CHANGED
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
function defineTool(tool) {
|
|
3
3
|
return tool;
|
|
4
4
|
}
|
|
5
|
+
function requireAgent(context) {
|
|
6
|
+
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()).`);
|
|
7
|
+
return context.agent;
|
|
8
|
+
}
|
|
5
9
|
//#endregion
|
|
6
|
-
export { defineTool };
|
|
10
|
+
export { defineTool, requireAgent };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,195 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as SourcePosition, C as LineRange, D as ProcessorPostprocessContext, E as ProcessorContext, F as SourceTargetOrigin, G as ResolvedProvider, H as ModelRequirement, I as SourceText, J as ProviderType, K as ModelSize, M as SourceRuntime, N as SourceTarget, O as SourceFile, P as SourceTargetKind, Q as SetupModelDefinition, S as LanguageContext, T as ProcessedSourceOrigin, U as ResolveModelOptions, W as ResolvedModel, X as RunnerStatsConfig, Y as RunnerConfig, Z as SetupConfig, _ as RuleDefinition, a as AlintLinterOptions, b as RuleRegistry, c as DiagnosticLocation, d as LanguageDefinition, f as PluginDefinition, g as RuleContext, h as RuleConfigEntry, i as AlintConfigItem, j as SourceRange, k as SourceLocation, l as EnabledRule, m as RuleCacheConfig, n as AlintConfigExtends, o as Awaitable, p as ProcessorDefinition, q as ProviderDefinition, r as AlintConfigInput, s as DiagnosticDescriptor, t as AlintConfig, u as IgnoreConfig, v as RuleHandlers, w as ProcessedSource, x as RuleSeverity, y as RuleInferenceUsageRecord } from "./types-DQfoxG8J.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/core/source/types.d.ts
|
|
4
|
-
interface LanguageContext {
|
|
5
|
-
cwd: string;
|
|
6
|
-
languageOptions: Record<string, unknown>;
|
|
7
|
-
src: SourceRuntime;
|
|
8
|
-
}
|
|
9
|
-
interface LineRange {
|
|
10
|
-
endLine: number;
|
|
11
|
-
startLine: number;
|
|
12
|
-
}
|
|
13
|
-
interface ProcessedSource {
|
|
14
|
-
identity: string;
|
|
15
|
-
language?: string;
|
|
16
|
-
origin?: ProcessedSourceOrigin;
|
|
17
|
-
path: string;
|
|
18
|
-
text: string;
|
|
19
|
-
}
|
|
20
|
-
interface ProcessedSourceOrigin {
|
|
21
|
-
physicalPath: string;
|
|
22
|
-
range?: SourceRange;
|
|
23
|
-
virtualPath?: string;
|
|
24
|
-
}
|
|
25
|
-
interface ProcessorContext {
|
|
26
|
-
cwd: string;
|
|
27
|
-
options: Record<string, unknown>;
|
|
28
|
-
src: SourceRuntime;
|
|
29
|
-
}
|
|
30
|
-
interface ProcessorPostprocessContext extends ProcessorContext {
|
|
31
|
-
file: SourceFile;
|
|
32
|
-
processedSources: ProcessedSource[];
|
|
33
|
-
}
|
|
34
|
-
interface SourceFile {
|
|
35
|
-
language: string;
|
|
36
|
-
lines: string[];
|
|
37
|
-
path: string;
|
|
38
|
-
text: string;
|
|
39
|
-
}
|
|
40
|
-
interface SourceLocation {
|
|
41
|
-
end: SourcePosition;
|
|
42
|
-
start: SourcePosition;
|
|
43
|
-
}
|
|
44
|
-
interface SourcePosition {
|
|
45
|
-
column: number;
|
|
46
|
-
line: number;
|
|
47
|
-
}
|
|
48
|
-
interface SourceRange {
|
|
49
|
-
end: number;
|
|
50
|
-
start: number;
|
|
51
|
-
}
|
|
52
|
-
interface SourceRuntime {
|
|
53
|
-
getText: (target: SourceFile | SourceTarget) => string;
|
|
54
|
-
readFile: (filePath: string) => Promise<SourceFile>;
|
|
55
|
-
sliceLines: (file: SourceFile, range: LineRange) => SourceText;
|
|
56
|
-
sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
|
|
57
|
-
}
|
|
58
|
-
interface SourceTarget {
|
|
59
|
-
file: SourceFile;
|
|
60
|
-
identity: string;
|
|
61
|
-
kind: SourceTargetKind;
|
|
62
|
-
language: string;
|
|
63
|
-
loc?: SourceLocation;
|
|
64
|
-
metadata?: Record<string, unknown>;
|
|
65
|
-
name?: string;
|
|
66
|
-
origin?: SourceTargetOrigin;
|
|
67
|
-
range?: SourceRange;
|
|
68
|
-
text: string;
|
|
69
|
-
}
|
|
70
|
-
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
71
|
-
interface SourceTargetOrigin {
|
|
72
|
-
physicalPath: string;
|
|
73
|
-
range?: SourceRange;
|
|
74
|
-
virtualPath?: string;
|
|
75
|
-
}
|
|
76
|
-
interface SourceText {
|
|
77
|
-
filePath: string;
|
|
78
|
-
loc: SourceLocation;
|
|
79
|
-
text: string;
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/dsl/types.d.ts
|
|
83
|
-
type AlintConfig = readonly AlintConfigInput[];
|
|
84
|
-
type AlintConfigExtends = AlintConfigInput | string;
|
|
85
|
-
type AlintConfigInput = AlintConfigItem | readonly AlintConfigInput[];
|
|
86
|
-
interface AlintConfigItem {
|
|
87
|
-
basePath?: string;
|
|
88
|
-
extends?: readonly AlintConfigExtends[];
|
|
89
|
-
files?: readonly (readonly string[] | string)[];
|
|
90
|
-
ignore?: IgnoreConfig;
|
|
91
|
-
ignores?: readonly string[];
|
|
92
|
-
language?: string;
|
|
93
|
-
languageOptions?: Record<string, unknown>;
|
|
94
|
-
linterOptions?: AlintLinterOptions;
|
|
95
|
-
name?: string;
|
|
96
|
-
plugins?: Record<string, PluginDefinition>;
|
|
97
|
-
processor?: ProcessorDefinition | string;
|
|
98
|
-
rules?: Record<string, RuleConfigEntry>;
|
|
99
|
-
runner?: RunnerConfig;
|
|
100
|
-
settings?: Record<string, unknown>;
|
|
101
|
-
}
|
|
102
|
-
interface AlintLinterOptions {
|
|
103
|
-
noInlineConfig?: boolean;
|
|
104
|
-
reportUnusedDisableDirectives?: RuleSeverity;
|
|
105
|
-
}
|
|
106
|
-
type Awaitable<T> = Promise<T> | T;
|
|
107
|
-
interface DiagnosticDescriptor {
|
|
108
|
-
evidence?: unknown;
|
|
109
|
-
filePath?: string;
|
|
110
|
-
loc?: DiagnosticLocation;
|
|
111
|
-
message: string;
|
|
112
|
-
}
|
|
113
|
-
interface DiagnosticLocation {
|
|
114
|
-
end?: {
|
|
115
|
-
column: number;
|
|
116
|
-
line: number;
|
|
117
|
-
};
|
|
118
|
-
start: {
|
|
119
|
-
column: number;
|
|
120
|
-
line: number;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
interface EnabledRule {
|
|
124
|
-
id: string;
|
|
125
|
-
localId: string;
|
|
126
|
-
rule: RuleDefinition;
|
|
127
|
-
severity: Exclude<RuleSeverity, 'off'>;
|
|
128
|
-
}
|
|
129
|
-
interface IgnoreConfig {
|
|
130
|
-
gitignore?: boolean;
|
|
131
|
-
}
|
|
132
|
-
interface LanguageDefinition {
|
|
133
|
-
extensions?: readonly string[];
|
|
134
|
-
extract: (file: SourceFile, context: LanguageContext) => Awaitable<SourceTarget[]>;
|
|
135
|
-
name: string;
|
|
136
|
-
}
|
|
137
|
-
interface PluginDefinition {
|
|
138
|
-
configs?: Record<string, AlintConfigInput>;
|
|
139
|
-
languages?: Record<string, LanguageDefinition>;
|
|
140
|
-
processors?: Record<string, ProcessorDefinition>;
|
|
141
|
-
rules?: Record<string, RuleDefinition>;
|
|
142
|
-
}
|
|
143
|
-
interface ProcessorDefinition {
|
|
144
|
-
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
145
|
-
preprocess: (file: SourceFile, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
146
|
-
}
|
|
147
|
-
type RuleCacheConfig = boolean | {
|
|
148
|
-
level?: 'target';
|
|
149
|
-
};
|
|
150
|
-
type RuleConfigEntry = [RuleSeverity] | RuleSeverity;
|
|
151
|
-
interface RuleContext {
|
|
152
|
-
cwd: string;
|
|
153
|
-
id: string;
|
|
154
|
-
localId: string;
|
|
155
|
-
logger: {
|
|
156
|
-
debug: (...args: unknown[]) => void;
|
|
157
|
-
};
|
|
158
|
-
metering: {
|
|
159
|
-
recordUsage: (usage: RuleInferenceUsageRecord) => void;
|
|
160
|
-
};
|
|
161
|
-
model: (selector?: ModelRequirement | string) => Promise<ResolvedModel>;
|
|
162
|
-
outputLanguage?: string;
|
|
163
|
-
report: (diagnostic: DiagnosticDescriptor) => void;
|
|
164
|
-
settings: Record<string, unknown>;
|
|
165
|
-
src: SourceRuntime;
|
|
166
|
-
}
|
|
167
|
-
interface RuleDefinition {
|
|
168
|
-
cache?: RuleCacheConfig;
|
|
169
|
-
create: (context: RuleContext) => RuleHandlers;
|
|
170
|
-
model?: ModelRequirement;
|
|
171
|
-
}
|
|
172
|
-
interface RuleHandlers {
|
|
173
|
-
onTarget?: (target: SourceTarget) => Awaitable<void>;
|
|
174
|
-
}
|
|
175
|
-
interface RuleInferenceUsageRecord {
|
|
176
|
-
filePath?: string;
|
|
177
|
-
inputTokens?: number;
|
|
178
|
-
metadata?: unknown;
|
|
179
|
-
modelId: string;
|
|
180
|
-
outputTokens?: number;
|
|
181
|
-
providerId: string;
|
|
182
|
-
ruleId?: string;
|
|
183
|
-
totalTokens?: number;
|
|
184
|
-
}
|
|
185
|
-
interface RuleRegistry {
|
|
186
|
-
enabledRules: EnabledRule[];
|
|
187
|
-
rules: Map<string, RuleDefinition>;
|
|
188
|
-
}
|
|
189
|
-
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
190
|
-
//#endregion
|
|
191
3
|
//#region src/config/config-array.d.ts
|
|
192
4
|
interface EffectiveAlintConfig {
|
|
5
|
+
agent?: AlintConfigItem['agent'];
|
|
193
6
|
language?: string;
|
|
194
7
|
languageOptions: Record<string, unknown>;
|
|
195
8
|
linterOptions: Record<string, unknown>;
|
|
@@ -395,4 +208,4 @@ declare function buildRuleRegistry(config: Pick<EffectiveAlintConfig, 'plugins'
|
|
|
395
208
|
//#region src/models/resolve.d.ts
|
|
396
209
|
declare function resolveModel(registry: SetupConfig, options?: ResolveModelOptions): ResolvedModel;
|
|
397
210
|
//#endregion
|
|
398
|
-
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, AlintRunError, type Awaitable, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type EffectiveAlintConfig, type EnabledRule, type FileProgressPayload, type IgnoreConfig, type InferenceUsageRecord, 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 ProgressFilePath, type ProgressPath, type ProgressReporter, type ProgressTargetKind, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, type ResolvedModel, type ResolvedProvider, type RuleCacheConfig, 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 RunnerConfig, type SetupConfig, type SetupModelDefinition, type SourceFile, type SourceLocation, type SourcePosition, type SourceRange, type SourceRuntime, type SourceTarget, type SourceTargetKind, type SourceTargetOrigin, type SourceText, type TargetProgressPayload, type UsageProgressPayload, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, extractJsSourceTargets, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForFile, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange };
|
|
211
|
+
export { type AlintConfig, type AlintConfigExtends, type AlintConfigInput, type AlintConfigItem, type AlintLinterOptions, AlintRunError, type Awaitable, type Diagnostic, type DiagnosticDescriptor, type DiagnosticLocation, type DiagnosticProgressPayload, type EffectiveAlintConfig, type EnabledRule, type FileProgressPayload, type IgnoreConfig, type InferenceUsageRecord, 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 ProgressFilePath, type ProgressPath, type ProgressReporter, type ProgressTargetKind, type ProviderDefinition, type ProviderType, type ResolveConfigResult, type ResolveLanguageOptions, type ResolveModelOptions, type ResolvedModel, type ResolvedProvider, type RuleCacheConfig, 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 RunnerConfig, type RunnerStatsConfig, type SetupConfig, type SetupModelDefinition, type SourceFile, type SourceLocation, type SourcePosition, type SourceRange, type SourceRuntime, type SourceTarget, type SourceTargetKind, type SourceTargetOrigin, type SourceText, type TargetProgressPayload, type UsageProgressPayload, buildRuleRegistry, createBuiltInLanguageRegistry, createSourceFile, createSourceRuntime, defineConfig, definePlugin, defineRule, extractJsSourceTargets, hasDiscoveryFilePatterns, matchesDiscoveryFile, normalizeConfig, registerLanguage, resolveConfigForFile, resolveLanguage, resolveModel, runAlint, sliceLines, sliceRange };
|
package/dist/index.mjs
CHANGED
|
@@ -180,6 +180,7 @@ function mergeConfig(config, item) {
|
|
|
180
180
|
Object.assign(config.settings, item.settings);
|
|
181
181
|
Object.assign(config.languageOptions, item.languageOptions);
|
|
182
182
|
Object.assign(config.linterOptions, item.linterOptions);
|
|
183
|
+
if (item.agent !== void 0) config.agent = item.agent;
|
|
183
184
|
if (item.language !== void 0) config.language = item.language;
|
|
184
185
|
if (item.processor !== void 0) config.processor = item.processor;
|
|
185
186
|
if (item.runner !== void 0) config.runner = {
|
|
@@ -647,7 +648,7 @@ function createBuiltInLanguageRegistry() {
|
|
|
647
648
|
}
|
|
648
649
|
//#endregion
|
|
649
650
|
//#region package.json
|
|
650
|
-
var version = "0.0.
|
|
651
|
+
var version = "0.0.9";
|
|
651
652
|
//#endregion
|
|
652
653
|
//#region src/dsl/registry.ts
|
|
653
654
|
function buildRuleRegistry(config) {
|
|
@@ -979,6 +980,7 @@ async function runAlint(options = {}) {
|
|
|
979
980
|
const ruleRuntimes = createRuleRuntimes({
|
|
980
981
|
cwd: cwd$1,
|
|
981
982
|
diagnostics,
|
|
983
|
+
effectiveAgent: effectiveConfig.agent,
|
|
982
984
|
effectiveSettings: effectiveConfig.settings,
|
|
983
985
|
options,
|
|
984
986
|
registry,
|
|
@@ -1176,6 +1178,7 @@ function createRuleRuntimes(options) {
|
|
|
1176
1178
|
return options.registry.enabledRules.map((enabledRule) => {
|
|
1177
1179
|
const executionState = new AsyncLocalStorage();
|
|
1178
1180
|
const context = {
|
|
1181
|
+
agent: options.effectiveAgent,
|
|
1179
1182
|
cwd: options.cwd,
|
|
1180
1183
|
id: enabledRule.id,
|
|
1181
1184
|
localId: enabledRule.localId,
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
//#region src/config/types.d.ts
|
|
2
|
+
type ModelSize = 'large' | 'medium' | 'small';
|
|
3
|
+
interface ProviderDefinition {
|
|
4
|
+
endpoint: string;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
id: string;
|
|
7
|
+
models: SetupModelDefinition[];
|
|
8
|
+
type: ProviderType;
|
|
9
|
+
}
|
|
10
|
+
type ProviderType = 'openai-compatible';
|
|
11
|
+
interface RunnerCacheConfig {
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
location?: string;
|
|
14
|
+
}
|
|
15
|
+
interface RunnerConfig {
|
|
16
|
+
cache?: boolean | RunnerCacheConfig;
|
|
17
|
+
fileConcurrency?: number;
|
|
18
|
+
ruleConcurrency?: number;
|
|
19
|
+
stats?: boolean | RunnerStatsConfig;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
interface RunnerStatsConfig {
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
location?: string;
|
|
25
|
+
retentionMonths?: number;
|
|
26
|
+
}
|
|
27
|
+
interface SetupConfig {
|
|
28
|
+
providers: ProviderDefinition[];
|
|
29
|
+
runner?: RunnerConfig;
|
|
30
|
+
version: 1;
|
|
31
|
+
}
|
|
32
|
+
interface SetupModelDefinition {
|
|
33
|
+
aliases?: string[];
|
|
34
|
+
capabilities?: string[];
|
|
35
|
+
contextWindow?: number;
|
|
36
|
+
defaultParams?: Record<string, unknown>;
|
|
37
|
+
id: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
size?: ModelSize;
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/models/types.d.ts
|
|
43
|
+
interface ModelRequirement {
|
|
44
|
+
capabilities?: string[];
|
|
45
|
+
minContextWindow?: number;
|
|
46
|
+
params?: Record<string, unknown>;
|
|
47
|
+
size?: ModelSize;
|
|
48
|
+
}
|
|
49
|
+
interface ResolvedModel {
|
|
50
|
+
aliases: string[];
|
|
51
|
+
capabilities: string[];
|
|
52
|
+
contextWindow?: number;
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
params: Record<string, unknown>;
|
|
56
|
+
provider: ResolvedProvider;
|
|
57
|
+
size?: ModelSize;
|
|
58
|
+
}
|
|
59
|
+
interface ResolvedProvider {
|
|
60
|
+
endpoint: string;
|
|
61
|
+
headers: Record<string, string>;
|
|
62
|
+
id: string;
|
|
63
|
+
type: 'openai-compatible';
|
|
64
|
+
}
|
|
65
|
+
interface ResolveModelOptions {
|
|
66
|
+
request?: string;
|
|
67
|
+
requirement?: ModelRequirement;
|
|
68
|
+
ruleId?: string;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/agent/types.d.ts
|
|
72
|
+
type AgentAdapter = (request: AgentRequest) => Promise<AgentResult>;
|
|
73
|
+
interface AgentRequest {
|
|
74
|
+
instructions: string;
|
|
75
|
+
model: ResolvedModel;
|
|
76
|
+
prompt: string;
|
|
77
|
+
signal?: AbortSignal;
|
|
78
|
+
tools: AgentTool[];
|
|
79
|
+
}
|
|
80
|
+
interface AgentResult {
|
|
81
|
+
answer: string;
|
|
82
|
+
usage?: AgentUsage;
|
|
83
|
+
}
|
|
84
|
+
/** Agent-agnostic tool definition. Each adapter translates it to its framework's tool format. */
|
|
85
|
+
interface AgentTool {
|
|
86
|
+
description: string;
|
|
87
|
+
execute: (input: unknown) => Promise<unknown> | unknown;
|
|
88
|
+
name: string;
|
|
89
|
+
parameters: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
interface AgentUsage {
|
|
92
|
+
inputTokens?: number;
|
|
93
|
+
outputTokens?: number;
|
|
94
|
+
totalTokens?: number;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/core/source/types.d.ts
|
|
98
|
+
interface LanguageContext {
|
|
99
|
+
cwd: string;
|
|
100
|
+
languageOptions: Record<string, unknown>;
|
|
101
|
+
src: SourceRuntime;
|
|
102
|
+
}
|
|
103
|
+
interface LineRange {
|
|
104
|
+
endLine: number;
|
|
105
|
+
startLine: number;
|
|
106
|
+
}
|
|
107
|
+
interface ProcessedSource {
|
|
108
|
+
identity: string;
|
|
109
|
+
language?: string;
|
|
110
|
+
origin?: ProcessedSourceOrigin;
|
|
111
|
+
path: string;
|
|
112
|
+
text: string;
|
|
113
|
+
}
|
|
114
|
+
interface ProcessedSourceOrigin {
|
|
115
|
+
physicalPath: string;
|
|
116
|
+
range?: SourceRange;
|
|
117
|
+
virtualPath?: string;
|
|
118
|
+
}
|
|
119
|
+
interface ProcessorContext {
|
|
120
|
+
cwd: string;
|
|
121
|
+
options: Record<string, unknown>;
|
|
122
|
+
src: SourceRuntime;
|
|
123
|
+
}
|
|
124
|
+
interface ProcessorPostprocessContext extends ProcessorContext {
|
|
125
|
+
file: SourceFile;
|
|
126
|
+
processedSources: ProcessedSource[];
|
|
127
|
+
}
|
|
128
|
+
interface SourceFile {
|
|
129
|
+
language: string;
|
|
130
|
+
lines: string[];
|
|
131
|
+
path: string;
|
|
132
|
+
text: string;
|
|
133
|
+
}
|
|
134
|
+
interface SourceLocation {
|
|
135
|
+
end: SourcePosition;
|
|
136
|
+
start: SourcePosition;
|
|
137
|
+
}
|
|
138
|
+
interface SourcePosition {
|
|
139
|
+
column: number;
|
|
140
|
+
line: number;
|
|
141
|
+
}
|
|
142
|
+
interface SourceRange {
|
|
143
|
+
end: number;
|
|
144
|
+
start: number;
|
|
145
|
+
}
|
|
146
|
+
interface SourceRuntime {
|
|
147
|
+
getText: (target: SourceFile | SourceTarget) => string;
|
|
148
|
+
readFile: (filePath: string) => Promise<SourceFile>;
|
|
149
|
+
sliceLines: (file: SourceFile, range: LineRange) => SourceText;
|
|
150
|
+
sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
|
|
151
|
+
}
|
|
152
|
+
interface SourceTarget {
|
|
153
|
+
file: SourceFile;
|
|
154
|
+
identity: string;
|
|
155
|
+
kind: SourceTargetKind;
|
|
156
|
+
language: string;
|
|
157
|
+
loc?: SourceLocation;
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
name?: string;
|
|
160
|
+
origin?: SourceTargetOrigin;
|
|
161
|
+
range?: SourceRange;
|
|
162
|
+
text: string;
|
|
163
|
+
}
|
|
164
|
+
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
165
|
+
interface SourceTargetOrigin {
|
|
166
|
+
physicalPath: string;
|
|
167
|
+
range?: SourceRange;
|
|
168
|
+
virtualPath?: string;
|
|
169
|
+
}
|
|
170
|
+
interface SourceText {
|
|
171
|
+
filePath: string;
|
|
172
|
+
loc: SourceLocation;
|
|
173
|
+
text: string;
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/dsl/types.d.ts
|
|
177
|
+
type AlintConfig = readonly AlintConfigInput[];
|
|
178
|
+
type AlintConfigExtends = AlintConfigInput | string;
|
|
179
|
+
type AlintConfigInput = AlintConfigItem | readonly AlintConfigInput[];
|
|
180
|
+
interface AlintConfigItem {
|
|
181
|
+
agent?: AgentAdapter;
|
|
182
|
+
basePath?: string;
|
|
183
|
+
extends?: readonly AlintConfigExtends[];
|
|
184
|
+
files?: readonly (readonly string[] | string)[];
|
|
185
|
+
ignore?: IgnoreConfig;
|
|
186
|
+
ignores?: readonly string[];
|
|
187
|
+
language?: string;
|
|
188
|
+
languageOptions?: Record<string, unknown>;
|
|
189
|
+
linterOptions?: AlintLinterOptions;
|
|
190
|
+
name?: string;
|
|
191
|
+
plugins?: Record<string, PluginDefinition>;
|
|
192
|
+
processor?: ProcessorDefinition | string;
|
|
193
|
+
rules?: Record<string, RuleConfigEntry>;
|
|
194
|
+
runner?: RunnerConfig;
|
|
195
|
+
settings?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
interface AlintLinterOptions {
|
|
198
|
+
noInlineConfig?: boolean;
|
|
199
|
+
reportUnusedDisableDirectives?: RuleSeverity;
|
|
200
|
+
}
|
|
201
|
+
type Awaitable<T> = Promise<T> | T;
|
|
202
|
+
interface DiagnosticDescriptor {
|
|
203
|
+
evidence?: unknown;
|
|
204
|
+
filePath?: string;
|
|
205
|
+
loc?: DiagnosticLocation;
|
|
206
|
+
message: string;
|
|
207
|
+
}
|
|
208
|
+
interface DiagnosticLocation {
|
|
209
|
+
end?: {
|
|
210
|
+
column: number;
|
|
211
|
+
line: number;
|
|
212
|
+
};
|
|
213
|
+
start: {
|
|
214
|
+
column: number;
|
|
215
|
+
line: number;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
interface EnabledRule {
|
|
219
|
+
id: string;
|
|
220
|
+
localId: string;
|
|
221
|
+
rule: RuleDefinition;
|
|
222
|
+
severity: Exclude<RuleSeverity, 'off'>;
|
|
223
|
+
}
|
|
224
|
+
interface IgnoreConfig {
|
|
225
|
+
gitignore?: boolean;
|
|
226
|
+
}
|
|
227
|
+
interface LanguageDefinition {
|
|
228
|
+
extensions?: readonly string[];
|
|
229
|
+
extract: (file: SourceFile, context: LanguageContext) => Awaitable<SourceTarget[]>;
|
|
230
|
+
name: string;
|
|
231
|
+
}
|
|
232
|
+
interface PluginDefinition {
|
|
233
|
+
configs?: Record<string, AlintConfigInput>;
|
|
234
|
+
languages?: Record<string, LanguageDefinition>;
|
|
235
|
+
processors?: Record<string, ProcessorDefinition>;
|
|
236
|
+
rules?: Record<string, RuleDefinition>;
|
|
237
|
+
}
|
|
238
|
+
interface ProcessorDefinition {
|
|
239
|
+
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
240
|
+
preprocess: (file: SourceFile, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
241
|
+
}
|
|
242
|
+
type RuleCacheConfig = boolean | {
|
|
243
|
+
level?: 'target';
|
|
244
|
+
};
|
|
245
|
+
type RuleConfigEntry = [RuleSeverity] | RuleSeverity;
|
|
246
|
+
interface RuleContext {
|
|
247
|
+
agent?: AgentAdapter;
|
|
248
|
+
cwd: string;
|
|
249
|
+
id: string;
|
|
250
|
+
localId: string;
|
|
251
|
+
logger: {
|
|
252
|
+
debug: (...args: unknown[]) => void;
|
|
253
|
+
};
|
|
254
|
+
metering: {
|
|
255
|
+
recordUsage: (usage: RuleInferenceUsageRecord) => void;
|
|
256
|
+
};
|
|
257
|
+
model: (selector?: ModelRequirement | string) => Promise<ResolvedModel>;
|
|
258
|
+
outputLanguage?: string;
|
|
259
|
+
report: (diagnostic: DiagnosticDescriptor) => void;
|
|
260
|
+
settings: Record<string, unknown>;
|
|
261
|
+
src: SourceRuntime;
|
|
262
|
+
}
|
|
263
|
+
interface RuleDefinition {
|
|
264
|
+
cache?: RuleCacheConfig;
|
|
265
|
+
create: (context: RuleContext) => RuleHandlers;
|
|
266
|
+
model?: ModelRequirement;
|
|
267
|
+
}
|
|
268
|
+
interface RuleHandlers {
|
|
269
|
+
onTarget?: (target: SourceTarget) => Awaitable<void>;
|
|
270
|
+
}
|
|
271
|
+
interface RuleInferenceUsageRecord {
|
|
272
|
+
filePath?: string;
|
|
273
|
+
inputTokens?: number;
|
|
274
|
+
metadata?: unknown;
|
|
275
|
+
modelId: string;
|
|
276
|
+
outputTokens?: number;
|
|
277
|
+
providerId: string;
|
|
278
|
+
ruleId?: string;
|
|
279
|
+
totalTokens?: number;
|
|
280
|
+
}
|
|
281
|
+
interface RuleRegistry {
|
|
282
|
+
enabledRules: EnabledRule[];
|
|
283
|
+
rules: Map<string, RuleDefinition>;
|
|
284
|
+
}
|
|
285
|
+
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
286
|
+
//#endregion
|
|
287
|
+
export { SourcePosition as A, AgentTool as B, LineRange as C, ProcessorPostprocessContext as D, ProcessorContext as E, SourceTargetOrigin as F, ResolvedProvider as G, ModelRequirement as H, SourceText as I, ProviderType as J, ModelSize as K, AgentAdapter as L, SourceRuntime as M, SourceTarget as N, SourceFile as O, SourceTargetKind as P, SetupModelDefinition as Q, AgentRequest as R, LanguageContext as S, ProcessedSourceOrigin as T, ResolveModelOptions as U, AgentUsage as V, ResolvedModel as W, RunnerStatsConfig as X, RunnerConfig as Y, SetupConfig as Z, RuleDefinition as _, AlintLinterOptions as a, RuleRegistry as b, DiagnosticLocation as c, LanguageDefinition as d, PluginDefinition as f, RuleContext as g, RuleConfigEntry as h, AlintConfigItem as i, SourceRange as j, SourceLocation as k, EnabledRule as l, RuleCacheConfig as m, AlintConfigExtends as n, Awaitable as o, ProcessorDefinition as p, ProviderDefinition as q, AlintConfigInput as r, DiagnosticDescriptor as s, AlintConfig as t, IgnoreConfig as u, RuleHandlers as v, ProcessedSource as w, RuleSeverity as x, RuleInferenceUsageRecord as y, AgentResult as z };
|
package/package.json
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
//#region src/config/types.d.ts
|
|
2
|
-
type ModelSize = 'large' | 'medium' | 'small';
|
|
3
|
-
interface ProviderDefinition {
|
|
4
|
-
endpoint: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
id: string;
|
|
7
|
-
models: SetupModelDefinition[];
|
|
8
|
-
type: ProviderType;
|
|
9
|
-
}
|
|
10
|
-
type ProviderType = 'openai-compatible';
|
|
11
|
-
interface RunnerCacheConfig {
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
location?: string;
|
|
14
|
-
}
|
|
15
|
-
interface RunnerConfig {
|
|
16
|
-
cache?: boolean | RunnerCacheConfig;
|
|
17
|
-
fileConcurrency?: number;
|
|
18
|
-
ruleConcurrency?: number;
|
|
19
|
-
timeoutMs?: number;
|
|
20
|
-
}
|
|
21
|
-
interface SetupConfig {
|
|
22
|
-
providers: ProviderDefinition[];
|
|
23
|
-
runner?: RunnerConfig;
|
|
24
|
-
version: 1;
|
|
25
|
-
}
|
|
26
|
-
interface SetupModelDefinition {
|
|
27
|
-
aliases?: string[];
|
|
28
|
-
capabilities?: string[];
|
|
29
|
-
contextWindow?: number;
|
|
30
|
-
defaultParams?: Record<string, unknown>;
|
|
31
|
-
id: string;
|
|
32
|
-
name?: string;
|
|
33
|
-
size?: ModelSize;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/models/types.d.ts
|
|
37
|
-
interface ModelRequirement {
|
|
38
|
-
capabilities?: string[];
|
|
39
|
-
minContextWindow?: number;
|
|
40
|
-
params?: Record<string, unknown>;
|
|
41
|
-
size?: ModelSize;
|
|
42
|
-
}
|
|
43
|
-
interface ResolvedModel {
|
|
44
|
-
aliases: string[];
|
|
45
|
-
capabilities: string[];
|
|
46
|
-
contextWindow?: number;
|
|
47
|
-
id: string;
|
|
48
|
-
name: string;
|
|
49
|
-
params: Record<string, unknown>;
|
|
50
|
-
provider: ResolvedProvider;
|
|
51
|
-
size?: ModelSize;
|
|
52
|
-
}
|
|
53
|
-
interface ResolvedProvider {
|
|
54
|
-
endpoint: string;
|
|
55
|
-
headers: Record<string, string>;
|
|
56
|
-
id: string;
|
|
57
|
-
type: 'openai-compatible';
|
|
58
|
-
}
|
|
59
|
-
interface ResolveModelOptions {
|
|
60
|
-
request?: string;
|
|
61
|
-
requirement?: ModelRequirement;
|
|
62
|
-
ruleId?: string;
|
|
63
|
-
}
|
|
64
|
-
//#endregion
|
|
65
|
-
export { ModelSize as a, RunnerConfig as c, ResolvedProvider as i, SetupConfig as l, ResolveModelOptions as n, ProviderDefinition as o, ResolvedModel as r, ProviderType as s, ModelRequirement as t, SetupModelDefinition as u };
|