@alint-js/core 0.0.28 → 0.0.30

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.
@@ -0,0 +1,5 @@
1
+ import { h as SourceTarget, u as SourceFile } from "./types-DSvXUVZ7.mjs";
2
+ //#region src/core/languages/js/extract.d.ts
3
+ declare function extractJsSourceTargets(file: SourceFile): SourceTarget[];
4
+ //#endregion
5
+ export { extractJsSourceTargets };
@@ -0,0 +1,2 @@
1
+ import { t as extractJsSourceTargets } from "./extract-CIWssxNK.mjs";
2
+ export { extractJsSourceTargets };
@@ -1,4 +1,4 @@
1
- import { $ as ResolvedModel, v as RuleContext } from "./types-BM_nUu_Z.mjs";
1
+ import { P as ResolvedModel, v as RuleContext } from "./types-CR_Grd6q.mjs";
2
2
  import { GenericSchema, InferOutput } from "valibot";
3
3
  import { JsonSchema } from "@valibot/to-json-schema";
4
4
  import { Message } from "@xsai/shared-chat";
@@ -1,6 +1,6 @@
1
- import { errorMessageFrom } from "@moeru/std/error";
2
1
  import { getDescription, parse } from "valibot";
3
- import { setTimeout } from "node:timers/promises";
2
+ import { errorMessageFrom } from "@moeru/std/error";
3
+ import { sleepWithAbort } from "@moeru/std/sleep";
4
4
  import { toJsonSchema } from "@valibot/to-json-schema";
5
5
  import { generateText } from "@xsai/generate-text";
6
6
  import { rawTool } from "@xsai/tool";
@@ -44,6 +44,7 @@ async function generateStructured(options) {
44
44
  options.signal?.throwIfAborted();
45
45
  let response;
46
46
  try {
47
+ options.signal?.throwIfAborted();
47
48
  response = await generateText({
48
49
  abortSignal: options.signal,
49
50
  baseURL: options.model.provider.endpoint,
@@ -64,7 +65,7 @@ async function generateStructured(options) {
64
65
  previousError = isRetriableHttpError(error) ? void 0 : callError;
65
66
  options.logger?.debug(`${options.operation} attempt ${attempt} failed while calling the model: ${callError}`);
66
67
  if (!isRetriableCallError(error) || attempt === maxAttempts) throw error;
67
- await setTimeout(retryDelay(attempt), void 0, { signal: options.signal });
68
+ await sleepWithAbort(retryDelay(attempt), options.signal);
68
69
  continue;
69
70
  }
70
71
  recordAttemptUsage(options, response);
@@ -73,7 +74,7 @@ async function generateStructured(options) {
73
74
  previousError = result.error;
74
75
  options.logger?.debug(`${options.operation} attempt ${attempt} returned an invalid structured result: ${previousError}`);
75
76
  if (!result.retriable || attempt === maxAttempts) throw new InvalidStructuredOutputError(`Invalid structured model response: ${previousError}`);
76
- await setTimeout(retryDelay(attempt), void 0, { signal: options.signal });
77
+ await sleepWithAbort(retryDelay(attempt), options.signal);
77
78
  }
78
79
  throw new InvalidStructuredOutputError("Model did not return a valid structured result");
79
80
  }
@@ -1,3 +1,4 @@
1
+ import { c as ProcessorContext, h as SourceTarget, i as LanguageContext, l as ProcessorPostprocessContext, m as SourceRuntime, n as FileTarget, o as ProcessedSource, r as FunctionTarget, t as ClassTarget, u as SourceFile } from "./types-DSvXUVZ7.mjs";
1
2
  //#region src/config/types.d.ts
2
3
  type ModelSize = 'large' | 'medium' | 'small';
3
4
  interface ProviderDefinition {
@@ -16,7 +17,6 @@ interface RunnerConfig {
16
17
  /** Retries after the initial attempt for replay-safe agent failures. @default 2 */
17
18
  agentRetries?: number;
18
19
  cache?: boolean | RunnerCacheConfig;
19
- fileConcurrency?: number;
20
20
  ruleConcurrency?: number;
21
21
  stats?: boolean | RunnerStatsConfig;
22
22
  timeoutMs?: number;
@@ -96,91 +96,6 @@ interface AgentUsage {
96
96
  totalTokens?: number;
97
97
  }
98
98
  //#endregion
99
- //#region src/core/source/types.d.ts
100
- type ClassTarget = SourceTargetOfKind<'class'>;
101
- type FileTarget = SourceTargetOfKind<'file'>;
102
- type FunctionTarget = SourceTargetOfKind<'function'>;
103
- interface LanguageContext {
104
- cwd: string;
105
- languageOptions: Record<string, unknown>;
106
- src: SourceRuntime;
107
- }
108
- interface LineRange {
109
- endLine: number;
110
- startLine: number;
111
- }
112
- interface ProcessedSource {
113
- identity: string;
114
- language?: string;
115
- origin?: ProcessedSourceOrigin;
116
- path: string;
117
- text: string;
118
- }
119
- interface ProcessedSourceOrigin {
120
- physicalPath: string;
121
- range?: SourceRange;
122
- virtualPath?: string;
123
- }
124
- interface ProcessorContext {
125
- cwd: string;
126
- options: Record<string, unknown>;
127
- src: SourceRuntime;
128
- }
129
- interface ProcessorPostprocessContext extends ProcessorContext {
130
- file: SourceFile;
131
- processedSources: ProcessedSource[];
132
- }
133
- interface SourceFile {
134
- language: string;
135
- lines: string[];
136
- path: string;
137
- text: string;
138
- }
139
- interface SourceLocation {
140
- end: SourcePosition;
141
- start: SourcePosition;
142
- }
143
- interface SourcePosition {
144
- column: number;
145
- line: number;
146
- }
147
- interface SourceRange {
148
- end: number;
149
- start: number;
150
- }
151
- interface SourceRuntime {
152
- getText: (target: SourceFile | SourceTarget) => string;
153
- readFile: (filePath: string) => Promise<SourceFile>;
154
- sliceLines: (file: SourceFile, range: LineRange) => SourceText;
155
- sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
156
- }
157
- interface SourceTarget {
158
- file: SourceFile;
159
- identity: string;
160
- kind: SourceTargetKind;
161
- language: string;
162
- loc?: SourceLocation;
163
- metadata?: Record<string, unknown>;
164
- name?: string;
165
- origin?: SourceTargetOrigin;
166
- range?: SourceRange;
167
- text: string;
168
- }
169
- type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
170
- type SourceTargetOfKind<Kind extends SourceTargetKind> = Omit<SourceTarget, 'kind'> & {
171
- kind: Kind;
172
- };
173
- interface SourceTargetOrigin {
174
- physicalPath: string;
175
- range?: SourceRange;
176
- virtualPath?: string;
177
- }
178
- interface SourceText {
179
- filePath: string;
180
- loc: SourceLocation;
181
- text: string;
182
- }
183
- //#endregion
184
99
  //#region src/dsl/types.d.ts
185
100
  type AlintConfig = readonly AlintConfigInput[];
186
101
  type AlintConfigExtends = AlintConfigInput | string;
@@ -327,4 +242,4 @@ interface RuleWithHandler {
327
242
  }
328
243
  type Target = DirectoryTarget | ProjectTarget | SourceTarget;
329
244
  //#endregion
330
- export { ResolvedModel as $, LanguageContext as A, SourceRuntime as B, RuleSeverity as C, ClassTarget as D, Target as E, ProcessorPostprocessContext as F, SourceText as G, SourceTargetKind as H, SourceFile as I, AgentResult as J, AgentAdapter as K, SourceLocation as L, ProcessedSource as M, ProcessedSourceOrigin as N, FileTarget as O, ProcessorContext as P, ResolveModelOptions as Q, SourcePosition as R, RuleRegistry as S, RuleWithHandler as T, SourceTargetOfKind as U, SourceTarget as V, SourceTargetOrigin as W, AgentUsage as X, AgentTool as Y, ModelRequirement as Z, RuleConfigEntry as _, AlintLinterOptions as a, RunnerStatsConfig as at, RuleHandlers as b, DiagnosticLocation as c, IgnoreConfig as d, ResolvedProvider as et, LanguageDefinition as f, RuleCacheConfig as g, ProjectTarget as h, AlintConfigItem as i, RunnerConfig as it, LineRange as j, FunctionTarget as k, DirectoryTarget as l, ProcessorDefinition as m, AlintConfigExtends as n, ProviderDefinition as nt, Awaitable as o, SetupConfig as ot, PluginDefinition as p, AgentRequest as q, AlintConfigInput as r, ProviderType as rt, DiagnosticDescriptor as s, SetupModelDefinition as st, AlintConfig as t, ModelSize as tt, EnabledRule as u, RuleContext as v, RuleSpecializedHandlers as w, RuleInferenceUsageRecord as x, RuleDefinition as y, SourceRange as z };
245
+ export { AgentTool as A, RunnerStatsConfig as B, RuleSeverity as C, AgentAdapter as D, Target as E, ResolvedProvider as F, SetupModelDefinition as H, ModelSize as I, ProviderDefinition as L, ModelRequirement as M, ResolveModelOptions as N, AgentRequest as O, ResolvedModel as P, ProviderType as R, RuleRegistry as S, RuleWithHandler as T, SetupConfig as V, RuleConfigEntry as _, AlintLinterOptions as a, RuleHandlers as b, DiagnosticLocation as c, IgnoreConfig as d, LanguageDefinition as f, RuleCacheConfig as g, ProjectTarget as h, AlintConfigItem as i, AgentUsage as j, AgentResult as k, DirectoryTarget as l, ProcessorDefinition as m, AlintConfigExtends as n, Awaitable as o, PluginDefinition as p, AlintConfigInput as r, DiagnosticDescriptor as s, AlintConfig as t, EnabledRule as u, RuleContext as v, RuleSpecializedHandlers as w, RuleInferenceUsageRecord as x, RuleDefinition as y, RunnerConfig as z };
@@ -0,0 +1,86 @@
1
+ //#region src/core/source/types.d.ts
2
+ type ClassTarget = SourceTargetOfKind<'class'>;
3
+ type FileTarget = SourceTargetOfKind<'file'>;
4
+ type FunctionTarget = SourceTargetOfKind<'function'>;
5
+ interface LanguageContext {
6
+ cwd: string;
7
+ languageOptions: Record<string, unknown>;
8
+ src: SourceRuntime;
9
+ }
10
+ interface LineRange {
11
+ endLine: number;
12
+ startLine: number;
13
+ }
14
+ interface ProcessedSource {
15
+ identity: string;
16
+ language?: string;
17
+ origin?: ProcessedSourceOrigin;
18
+ path: string;
19
+ text: string;
20
+ }
21
+ interface ProcessedSourceOrigin {
22
+ physicalPath: string;
23
+ range?: SourceRange;
24
+ virtualPath?: string;
25
+ }
26
+ interface ProcessorContext {
27
+ cwd: string;
28
+ options: Record<string, unknown>;
29
+ src: SourceRuntime;
30
+ }
31
+ interface ProcessorPostprocessContext extends ProcessorContext {
32
+ file: SourceFile;
33
+ processedSources: ProcessedSource[];
34
+ }
35
+ interface SourceFile {
36
+ language: string;
37
+ lines: string[];
38
+ path: string;
39
+ text: string;
40
+ }
41
+ interface SourceLocation {
42
+ end: SourcePosition;
43
+ start: SourcePosition;
44
+ }
45
+ interface SourcePosition {
46
+ column: number;
47
+ line: number;
48
+ }
49
+ interface SourceRange {
50
+ end: number;
51
+ start: number;
52
+ }
53
+ interface SourceRuntime {
54
+ getText: (target: SourceFile | SourceTarget) => string;
55
+ readFile: (filePath: string) => Promise<SourceFile>;
56
+ sliceLines: (file: SourceFile, range: LineRange) => SourceText;
57
+ sliceRange: (file: SourceFile, range: SourceRange) => SourceText;
58
+ }
59
+ interface SourceTarget {
60
+ file: SourceFile;
61
+ identity: string;
62
+ kind: SourceTargetKind;
63
+ language: string;
64
+ loc?: SourceLocation;
65
+ metadata?: Record<string, unknown>;
66
+ name?: string;
67
+ origin?: SourceTargetOrigin;
68
+ range?: SourceRange;
69
+ text: string;
70
+ }
71
+ type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
72
+ type SourceTargetOfKind<Kind extends SourceTargetKind> = Omit<SourceTarget, 'kind'> & {
73
+ kind: Kind;
74
+ };
75
+ interface SourceTargetOrigin {
76
+ physicalPath: string;
77
+ range?: SourceRange;
78
+ virtualPath?: string;
79
+ }
80
+ interface SourceText {
81
+ filePath: string;
82
+ loc: SourceLocation;
83
+ text: string;
84
+ }
85
+ //#endregion
86
+ export { SourceTargetOfKind as _, LineRange as a, ProcessorContext as c, SourceLocation as d, SourcePosition as f, SourceTargetKind as g, SourceTarget as h, LanguageContext as i, ProcessorPostprocessContext as l, SourceRuntime as m, FileTarget as n, ProcessedSource as o, SourceRange as p, FunctionTarget as r, ProcessedSourceOrigin as s, ClassTarget as t, SourceFile as u, SourceTargetOrigin as v, SourceText as y };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/core",
3
3
  "type": "module",
4
- "version": "0.0.28",
4
+ "version": "0.0.30",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",
@@ -15,13 +15,17 @@
15
15
  "types": "./dist/structured-output.d.mts",
16
16
  "default": "./dist/structured-output.mjs"
17
17
  },
18
+ "./languages/js": {
19
+ "types": "./dist/languages-js.d.mts",
20
+ "default": "./dist/languages-js.mjs"
21
+ },
18
22
  "./package.json": "./package.json"
19
23
  },
20
24
  "files": [
21
25
  "dist"
22
26
  ],
23
27
  "dependencies": {
24
- "@moeru/std": "^0.1.0-beta.18",
28
+ "@moeru/std": "^0.1.0-beta.20",
25
29
  "@valibot/to-json-schema": "^1.7.1",
26
30
  "@xsai/generate-text": "^0.5.0-beta.7",
27
31
  "@xsai/shared-chat": "^0.5.0-beta.7",