@alint-js/core 0.0.10 → 0.0.12

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 ADDED
@@ -0,0 +1,78 @@
1
+ # `@alint-js/core`
2
+
3
+ The public SDK and run engine for `alint`.
4
+
5
+ ## What it does
6
+
7
+ This package provides the core APIs used by configs, plugins, rules, language processors, and agent adapters:
8
+
9
+ - `defineConfig`, `definePlugin`, and `defineRule`
10
+ - rule registry and flat config normalization
11
+ - source runtime helpers
12
+ - built-in JavaScript source extraction
13
+ - model resolution by size and capability
14
+ - diagnostics and progress payload types
15
+ - `runAlint`
16
+ - framework-neutral agent contracts under `@alint-js/core/agent`
17
+
18
+ ## How to use
19
+
20
+ Define an `alint` config:
21
+
22
+ ```ts
23
+ import examplePlugin from '@alint-js/plugin-example'
24
+
25
+ import { defineConfig } from '@alint-js/core'
26
+
27
+ export default defineConfig([
28
+ {
29
+ files: ['**/*.{js,ts,jsx,tsx}'],
30
+ plugins: {
31
+ example: examplePlugin,
32
+ },
33
+ rules: {
34
+ 'example/no-redundant-jsdoc': 'warn',
35
+ },
36
+ },
37
+ ])
38
+ ```
39
+
40
+ Write a rule:
41
+
42
+ ```ts
43
+ import { defineRule } from '@alint-js/core'
44
+
45
+ export const rule = defineRule({
46
+ create: ctx => ({
47
+ async onTarget(target) {
48
+ const model = await ctx.model({ size: 'small' })
49
+
50
+ ctx.report({
51
+ filePath: target.file.path,
52
+ loc: target.loc,
53
+ message: `reviewed with ${model.id}`,
54
+ })
55
+ },
56
+ }),
57
+ })
58
+ ```
59
+
60
+ Use the agent contract for tool-using rules:
61
+
62
+ ```ts
63
+ import { requireAgent } from '@alint-js/core/agent'
64
+
65
+ const agent = requireAgent(ctx)
66
+ ```
67
+
68
+ ## When to use
69
+
70
+ - You are writing an `alint` plugin or rule package.
71
+ - You are adding a language processor or source extractor.
72
+ - You are embedding `alint` in another tool.
73
+ - You are implementing an `AgentAdapter`.
74
+
75
+ ## When not to use
76
+
77
+ - Use `@alint-js/cli` for command-line usage.
78
+ - Use `@alint-js/config` for setup TOML and config-file helpers only.
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { minimatch } from "minimatch";
2
2
  import { isAbsolute, relative, resolve } from "pathe";
3
- import { parseSync } from "oxc-parser";
4
3
  import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
5
4
  import { dirname, extname, isAbsolute as isAbsolute$1, join, relative as relative$1, resolve as resolve$1, sep } from "node:path";
6
5
  import { clamp } from "es-toolkit";
6
+ import { parseSync } from "oxc-parser";
7
7
  import { AsyncLocalStorage } from "node:async_hooks";
8
8
  import process, { cwd } from "node:process";
9
9
  import { errorCauseFrom, errorMessageFrom } from "@moeru/std/error";
@@ -309,9 +309,14 @@ function inferLanguage(path) {
309
309
  }
310
310
  }
311
311
  //#endregion
312
+ //#region src/core/languages/js/parser.ts
313
+ function parseSync$1(filename, sourceText, options) {
314
+ return parseSync(filename, sourceText, options);
315
+ }
316
+ //#endregion
312
317
  //#region src/core/languages/js/extract.ts
313
318
  function extractJsSourceTargets(file) {
314
- const result = parseSync(file.path, file.text, { sourceType: "module" });
319
+ const result = parseSync$1(file.path, file.text, { sourceType: "module" });
315
320
  const state = {
316
321
  bindingNodes: /* @__PURE__ */ new Map(),
317
322
  exportedNodes: /* @__PURE__ */ new Set(),
@@ -648,7 +653,7 @@ function createBuiltInLanguageRegistry() {
648
653
  }
649
654
  //#endregion
650
655
  //#region package.json
651
- var version = "0.0.10";
656
+ var version = "0.0.12";
652
657
  //#endregion
653
658
  //#region src/dsl/registry.ts
654
659
  function buildRuleRegistry(config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alint-js/core",
3
3
  "type": "module",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.mts",