flavor-code 1.2.13 → 1.2.14
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 +3 -0
- package/README.zh-CN.md +3 -0
- package/dist/{app-Z3YWFIBB.js → app-UJAGMKD5.js} +2 -2
- package/dist/astgraph/db.mjs +237 -237
- package/dist/astgraph/extract.mjs +239 -239
- package/dist/astgraph/flavor-plugin.json +25 -25
- package/dist/astgraph/grammars.mjs +68 -68
- package/dist/astgraph/index.js +301 -301
- package/dist/astgraph/indexer.mjs +175 -175
- package/dist/astgraph/query.mjs +165 -165
- package/dist/astgraph/resolve.mjs +93 -93
- package/dist/astgraph/vendor/tree-sitter.js +3980 -3980
- package/dist/astgraph/vendor/zod/LICENSE +21 -21
- package/dist/astgraph/vendor/zod/index.js +4 -4
- package/dist/astgraph/vendor/zod/locales/index.js +1 -1
- package/dist/astgraph/vendor/zod/locales/package.json +7 -7
- package/dist/astgraph/vendor/zod/package.json +135 -135
- package/dist/astgraph/vendor/zod/v4/classic/checks.js +1 -1
- package/dist/astgraph/vendor/zod/v4/classic/coerce.js +17 -17
- package/dist/astgraph/vendor/zod/v4/classic/compat.js +31 -31
- package/dist/astgraph/vendor/zod/v4/classic/errors.js +48 -48
- package/dist/astgraph/vendor/zod/v4/classic/external.js +20 -20
- package/dist/astgraph/vendor/zod/v4/classic/from-json-schema.js +599 -599
- package/dist/astgraph/vendor/zod/v4/classic/index.js +4 -4
- package/dist/astgraph/vendor/zod/v4/classic/iso.js +30 -30
- package/dist/astgraph/vendor/zod/v4/classic/package.json +7 -7
- package/dist/astgraph/vendor/zod/v4/classic/parse.js +15 -15
- package/dist/astgraph/vendor/zod/v4/classic/schemas.js +1395 -1395
- package/dist/astgraph/vendor/zod/v4/core/api.js +1087 -1087
- package/dist/astgraph/vendor/zod/v4/core/checks.js +575 -575
- package/dist/astgraph/vendor/zod/v4/core/core.js +78 -78
- package/dist/astgraph/vendor/zod/v4/core/doc.js +35 -35
- package/dist/astgraph/vendor/zod/v4/core/errors.js +185 -185
- package/dist/astgraph/vendor/zod/v4/core/index.js +16 -16
- package/dist/astgraph/vendor/zod/v4/core/json-schema-generator.js +95 -95
- package/dist/astgraph/vendor/zod/v4/core/json-schema-processors.js +601 -601
- package/dist/astgraph/vendor/zod/v4/core/json-schema.js +1 -1
- package/dist/astgraph/vendor/zod/v4/core/package.json +7 -7
- package/dist/astgraph/vendor/zod/v4/core/parse.js +93 -93
- package/dist/astgraph/vendor/zod/v4/core/regexes.js +139 -139
- package/dist/astgraph/vendor/zod/v4/core/registries.js +51 -51
- package/dist/astgraph/vendor/zod/v4/core/schemas.js +2239 -2239
- package/dist/astgraph/vendor/zod/v4/core/standard-schema.js +1 -1
- package/dist/astgraph/vendor/zod/v4/core/to-json-schema.js +448 -448
- package/dist/astgraph/vendor/zod/v4/core/util.js +674 -674
- package/dist/astgraph/vendor/zod/v4/core/versions.js +5 -5
- package/dist/astgraph/vendor/zod/v4/index.js +3 -3
- package/dist/astgraph/vendor/zod/v4/locales/ar.js +106 -106
- package/dist/astgraph/vendor/zod/v4/locales/az.js +105 -105
- package/dist/astgraph/vendor/zod/v4/locales/be.js +156 -156
- package/dist/astgraph/vendor/zod/v4/locales/bg.js +120 -120
- package/dist/astgraph/vendor/zod/v4/locales/ca.js +107 -107
- package/dist/astgraph/vendor/zod/v4/locales/cs.js +111 -111
- package/dist/astgraph/vendor/zod/v4/locales/da.js +115 -115
- package/dist/astgraph/vendor/zod/v4/locales/de.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/el.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/en.js +113 -113
- package/dist/astgraph/vendor/zod/v4/locales/eo.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/es.js +132 -132
- package/dist/astgraph/vendor/zod/v4/locales/fa.js +114 -114
- package/dist/astgraph/vendor/zod/v4/locales/fi.js +112 -112
- package/dist/astgraph/vendor/zod/v4/locales/fr-CA.js +107 -107
- package/dist/astgraph/vendor/zod/v4/locales/fr.js +125 -125
- package/dist/astgraph/vendor/zod/v4/locales/he.js +214 -214
- package/dist/astgraph/vendor/zod/v4/locales/hr.js +122 -122
- package/dist/astgraph/vendor/zod/v4/locales/hu.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/hy.js +147 -147
- package/dist/astgraph/vendor/zod/v4/locales/id.js +106 -106
- package/dist/astgraph/vendor/zod/v4/locales/index.js +52 -52
- package/dist/astgraph/vendor/zod/v4/locales/is.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/it.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/ja.js +107 -107
- package/dist/astgraph/vendor/zod/v4/locales/ka.js +112 -112
- package/dist/astgraph/vendor/zod/v4/locales/kh.js +5 -5
- package/dist/astgraph/vendor/zod/v4/locales/km.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/ko.js +111 -111
- package/dist/astgraph/vendor/zod/v4/locales/lt.js +203 -203
- package/dist/astgraph/vendor/zod/v4/locales/mk.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/ms.js +107 -107
- package/dist/astgraph/vendor/zod/v4/locales/nl.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/no.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/ota.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/package.json +7 -7
- package/dist/astgraph/vendor/zod/v4/locales/pl.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/ps.js +114 -114
- package/dist/astgraph/vendor/zod/v4/locales/pt.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/ro.js +119 -119
- package/dist/astgraph/vendor/zod/v4/locales/ru.js +156 -156
- package/dist/astgraph/vendor/zod/v4/locales/sl.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/sv.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/ta.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/th.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/tr.js +105 -105
- package/dist/astgraph/vendor/zod/v4/locales/ua.js +5 -5
- package/dist/astgraph/vendor/zod/v4/locales/uk.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/ur.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/uz.js +110 -110
- package/dist/astgraph/vendor/zod/v4/locales/vi.js +108 -108
- package/dist/astgraph/vendor/zod/v4/locales/yo.js +107 -107
- package/dist/astgraph/vendor/zod/v4/locales/zh-CN.js +109 -109
- package/dist/astgraph/vendor/zod/v4/locales/zh-TW.js +107 -107
- package/dist/astgraph/vendor/zod/v4/mini/checks.js +1 -1
- package/dist/astgraph/vendor/zod/v4/mini/coerce.js +22 -22
- package/dist/astgraph/vendor/zod/v4/mini/external.js +14 -14
- package/dist/astgraph/vendor/zod/v4/mini/index.js +3 -3
- package/dist/astgraph/vendor/zod/v4/mini/iso.js +34 -34
- package/dist/astgraph/vendor/zod/v4/mini/package.json +7 -7
- package/dist/astgraph/vendor/zod/v4/mini/parse.js +1 -1
- package/dist/astgraph/vendor/zod/v4/mini/schemas.js +961 -961
- package/dist/astgraph/vendor/zod/v4/package.json +7 -7
- package/dist/{chunk-Y5MZDG7I.js → chunk-4YXDGGIC.js} +4611 -3754
- package/dist/{chunk-XFCJXRJ2.js → chunk-IG4Z23CL.js} +6 -0
- package/dist/{chunk-G6Q2Y2A7.js → chunk-KL6TR2KG.js} +1 -1
- package/dist/cli.js +5 -5
- package/dist/config/schema.d.ts +6 -0
- package/dist/desktop/main.js +4900 -4038
- package/dist/desktop-renderer/assets/{index-CCnSpff0.js → index-CcD0D6x0.js} +1 -1
- package/dist/desktop-renderer/index.html +1 -1
- package/dist/evolve/loader.d.ts +21 -0
- package/dist/evolve/service.d.ts +37 -0
- package/dist/evolve/store.d.ts +91 -0
- package/dist/hooks/types.d.ts +5 -1
- package/dist/{load-6ZMEBHSG.js → load-GKA7P6RJ.js} +1 -1
- package/dist/plugins/host.d.ts +9 -0
- package/dist/plugins/types.d.ts +1 -0
- package/dist/sdk/index.js +3 -3
- package/dist/tools/shell.d.ts +13 -0
- package/dist/ui/commands.d.ts +5 -2
- package/dist/ui/session.d.ts +1 -0
- package/package.json +1 -1
- package//346/212/200/346/234/257/346/226/271/346/241/210/346/212/245/345/221/212.md +303 -1
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
// astgraph grammar loading — web-tree-sitter WASM runtime, vendored under ./vendor.
|
|
2
|
-
// Resolves the vendor directory relative to this module so it works both from the
|
|
3
|
-
// source tree (src/init/astgraph) and the copied plugin root (.flavor/plugins/astgraph).
|
|
4
|
-
|
|
5
|
-
import { dirname, join } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
|
|
8
|
-
import { Language, Parser } from "./vendor/tree-sitter.js";
|
|
9
|
-
|
|
10
|
-
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
export const VENDOR_DIR = join(MODULE_DIR, "vendor");
|
|
12
|
-
|
|
13
|
-
const GRAMMAR_FILES = {
|
|
14
|
-
typescript: "tree-sitter-typescript.wasm",
|
|
15
|
-
tsx: "tree-sitter-tsx.wasm",
|
|
16
|
-
javascript: "tree-sitter-javascript.wasm",
|
|
17
|
-
jsx: "tree-sitter-javascript.wasm",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const SUPPORTED_LANGUAGES = Object.keys(GRAMMAR_FILES);
|
|
21
|
-
|
|
22
|
-
export function languageForFile(path) {
|
|
23
|
-
const lower = path.toLowerCase();
|
|
24
|
-
if (lower.endsWith(".tsx")) return "tsx";
|
|
25
|
-
if (lower.endsWith(".ts") || lower.endsWith(".mts") || lower.endsWith(".cts")) return "typescript";
|
|
26
|
-
if (lower.endsWith(".jsx")) return "jsx";
|
|
27
|
-
if (lower.endsWith(".js") || lower.endsWith(".mjs") || lower.endsWith(".cjs")) return "javascript";
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let initialized = false;
|
|
32
|
-
let initPromise;
|
|
33
|
-
const languageCache = new Map();
|
|
34
|
-
const parserCache = new Map();
|
|
35
|
-
|
|
36
|
-
/** Initialize the WASM runtime once. Safe to call repeatedly. */
|
|
37
|
-
export async function initGrammars() {
|
|
38
|
-
if (initialized) return;
|
|
39
|
-
initPromise ??= Parser.init({ locateFile: (name) => join(VENDOR_DIR, name) }).then(() => {
|
|
40
|
-
initialized = true;
|
|
41
|
-
});
|
|
42
|
-
await initPromise;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** Load (and cache) a grammar for one of the supported languages. */
|
|
46
|
-
export async function loadLanguage(language) {
|
|
47
|
-
const file = GRAMMAR_FILES[language];
|
|
48
|
-
if (file === undefined) throw new Error(`astgraph: unsupported language "${language}"`);
|
|
49
|
-
await initGrammars();
|
|
50
|
-
let languageInstance = languageCache.get(language);
|
|
51
|
-
if (languageInstance === undefined) {
|
|
52
|
-
languageInstance = await Language.load(join(VENDOR_DIR, file));
|
|
53
|
-
languageCache.set(language, languageInstance);
|
|
54
|
-
}
|
|
55
|
-
return languageInstance;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Parse source text and return the syntax tree. */
|
|
59
|
-
export async function parseSource(source, language) {
|
|
60
|
-
const languageInstance = await loadLanguage(language);
|
|
61
|
-
let parser = parserCache.get(language);
|
|
62
|
-
if (parser === undefined) {
|
|
63
|
-
parser = new Parser();
|
|
64
|
-
parser.setLanguage(languageInstance);
|
|
65
|
-
parserCache.set(language, parser);
|
|
66
|
-
}
|
|
67
|
-
return parser.parse(source);
|
|
68
|
-
}
|
|
1
|
+
// astgraph grammar loading — web-tree-sitter WASM runtime, vendored under ./vendor.
|
|
2
|
+
// Resolves the vendor directory relative to this module so it works both from the
|
|
3
|
+
// source tree (src/init/astgraph) and the copied plugin root (.flavor/plugins/astgraph).
|
|
4
|
+
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
import { Language, Parser } from "./vendor/tree-sitter.js";
|
|
9
|
+
|
|
10
|
+
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
export const VENDOR_DIR = join(MODULE_DIR, "vendor");
|
|
12
|
+
|
|
13
|
+
const GRAMMAR_FILES = {
|
|
14
|
+
typescript: "tree-sitter-typescript.wasm",
|
|
15
|
+
tsx: "tree-sitter-tsx.wasm",
|
|
16
|
+
javascript: "tree-sitter-javascript.wasm",
|
|
17
|
+
jsx: "tree-sitter-javascript.wasm",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const SUPPORTED_LANGUAGES = Object.keys(GRAMMAR_FILES);
|
|
21
|
+
|
|
22
|
+
export function languageForFile(path) {
|
|
23
|
+
const lower = path.toLowerCase();
|
|
24
|
+
if (lower.endsWith(".tsx")) return "tsx";
|
|
25
|
+
if (lower.endsWith(".ts") || lower.endsWith(".mts") || lower.endsWith(".cts")) return "typescript";
|
|
26
|
+
if (lower.endsWith(".jsx")) return "jsx";
|
|
27
|
+
if (lower.endsWith(".js") || lower.endsWith(".mjs") || lower.endsWith(".cjs")) return "javascript";
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let initialized = false;
|
|
32
|
+
let initPromise;
|
|
33
|
+
const languageCache = new Map();
|
|
34
|
+
const parserCache = new Map();
|
|
35
|
+
|
|
36
|
+
/** Initialize the WASM runtime once. Safe to call repeatedly. */
|
|
37
|
+
export async function initGrammars() {
|
|
38
|
+
if (initialized) return;
|
|
39
|
+
initPromise ??= Parser.init({ locateFile: (name) => join(VENDOR_DIR, name) }).then(() => {
|
|
40
|
+
initialized = true;
|
|
41
|
+
});
|
|
42
|
+
await initPromise;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Load (and cache) a grammar for one of the supported languages. */
|
|
46
|
+
export async function loadLanguage(language) {
|
|
47
|
+
const file = GRAMMAR_FILES[language];
|
|
48
|
+
if (file === undefined) throw new Error(`astgraph: unsupported language "${language}"`);
|
|
49
|
+
await initGrammars();
|
|
50
|
+
let languageInstance = languageCache.get(language);
|
|
51
|
+
if (languageInstance === undefined) {
|
|
52
|
+
languageInstance = await Language.load(join(VENDOR_DIR, file));
|
|
53
|
+
languageCache.set(language, languageInstance);
|
|
54
|
+
}
|
|
55
|
+
return languageInstance;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Parse source text and return the syntax tree. */
|
|
59
|
+
export async function parseSource(source, language) {
|
|
60
|
+
const languageInstance = await loadLanguage(language);
|
|
61
|
+
let parser = parserCache.get(language);
|
|
62
|
+
if (parser === undefined) {
|
|
63
|
+
parser = new Parser();
|
|
64
|
+
parser.setLanguage(languageInstance);
|
|
65
|
+
parserCache.set(language, parser);
|
|
66
|
+
}
|
|
67
|
+
return parser.parse(source);
|
|
68
|
+
}
|