aiex-cli 0.0.1-beta.2 → 0.0.1-beta.20
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 +43 -7
- package/dist/cli.mjs +6721 -2562
- package/dist/completions-ygS1okck.mjs +90 -0
- package/dist/core/schema-sqlite/migrate-helper.mjs +21 -6
- package/dist/{doctor-Ddn9BjxC.mjs → doctor-B5JSikzk.mjs} +28 -15
- package/dist/index.mjs +1 -1
- package/dist/web/assets/AISettings-CZkpnRZH.js +334 -0
- package/dist/web/assets/DataBrowser-Cv_L28uJ.js +3 -0
- package/dist/web/assets/DataBrowser-DZT0kGQE.css +1 -0
- package/dist/web/assets/JsonSchemaEditor-CzFu83gU.js +929 -0
- package/dist/web/assets/api-client-D4tjF5I9.js +1 -0
- package/dist/web/assets/chunk-DtRyYLXJ.js +1 -0
- package/dist/web/assets/{cssMode-BloHqzZF.js → cssMode-BHaAN4pp.js} +1 -1
- package/dist/web/assets/dialog-D2ms6RSf.js +1034 -0
- package/dist/web/assets/{editor.api-BG499EJF.js → editor.api-DgeBt89R.js} +1 -1
- package/dist/web/assets/{editor.main-BhEWG0_P.js → editor.main-BzaWETn1.js} +2 -2
- package/dist/web/assets/{freemarker2-DOHaFATh.js → freemarker2-Dvg4gFZa.js} +1 -1
- package/dist/web/assets/{handlebars-BIFWety9.js → handlebars-4itI_hGB.js} +1 -1
- package/dist/web/assets/{html-YGaqGZNd.js → html-CWSOAdTS.js} +1 -1
- package/dist/web/assets/{htmlMode-Bu3PyHjq.js → htmlMode-0upoBPJE.js} +1 -1
- package/dist/web/assets/iconfont.1776926463538-BllfKX1O.ttf +0 -0
- package/dist/web/assets/iconfont.1776926463538-D9epzWxu.woff +0 -0
- package/dist/web/assets/index-CRcl3j1y.css +2 -0
- package/dist/web/assets/index-DOsKu0Uq.js +882 -0
- package/dist/web/assets/{javascript-N0gZqDK0.js → javascript-Ce8CZ78h.js} +1 -1
- package/dist/web/assets/{jsonMode-z5YscjcG.js → jsonMode-BLSJZHAW.js} +1 -1
- package/dist/web/assets/{liquid-BHfNNVLs.js → liquid-D5rz2UL9.js} +1 -1
- package/dist/web/assets/{mdx-Dqu2t0et.js → mdx-z1JVBQDz.js} +1 -1
- package/dist/web/assets/{monaco.contribution-ByQ3yI-W.js → monaco.contribution-CFfFGfn5.js} +2 -2
- package/dist/web/assets/overlayeventbus-CSu8Uk3d.js +80 -0
- package/dist/web/assets/{python-icfse9Ji.js → python-BPJc-4Rv.js} +1 -1
- package/dist/web/assets/{razor-DwVkryG9.js → razor-BHU9dOiw.js} +1 -1
- package/dist/web/assets/runtime-dom.esm-bundler-KKBGC_Sx.js +1 -0
- package/dist/web/assets/table-schema-48IiD6l-.js +2 -0
- package/dist/web/assets/{tsMode-CLrI3bdf.js → tsMode-Uy_NSojR.js} +1 -1
- package/dist/web/assets/{typescript-BzuZVF7m.js → typescript-BaLsBfTJ.js} +1 -1
- package/dist/web/assets/{xml-Cr85kdqA.js → xml-Dn0SxzSa.js} +1 -1
- package/dist/web/assets/{yaml-D3RbJnnO.js → yaml-Bzmyj5Wb.js} +1 -1
- package/dist/web/index.html +9 -5
- package/dist/web/logo.png +0 -0
- package/package.json +8 -2
- package/src/core/schema-sqlite/migrate-helper.ts +20 -5
- package/src/core/schema-sqlite/migration-name.ts +14 -0
- package/dist/web/assets/chunk-BEqpzyXh.js +0 -1
- package/dist/web/assets/index-Bi376XVf.css +0 -2
- package/dist/web/assets/index-c6KB-9C-.js +0 -3262
- /package/dist/web/assets/{abap-Cry0R76c.js → abap-B48h0VdJ.js} +0 -0
- /package/dist/web/assets/{apex-xqbJ58nJ.js → apex-1DPyVnhQ.js} +0 -0
- /package/dist/web/assets/{azcli-D7JTNGKs.js → azcli-BpwkVh9R.js} +0 -0
- /package/dist/web/assets/{bat-Cuq6hn0K.js → bat-BwJAl50I.js} +0 -0
- /package/dist/web/assets/{bicep-eTuQjz9F.js → bicep-B6QlbnRF.js} +0 -0
- /package/dist/web/assets/{cameligo-DKgCRl36.js → cameligo-CUPQxz1J.js} +0 -0
- /package/dist/web/assets/{clojure-B_aTBtVh.js → clojure-BlwtfO9v.js} +0 -0
- /package/dist/web/assets/{coffee-BWAYpIPu.js → coffee-BzDjX1gN.js} +0 -0
- /package/dist/web/assets/{cpp-BduBQE8d.js → cpp-CM5j04eT.js} +0 -0
- /package/dist/web/assets/{csharp-CMqOVYKK.js → csharp-BqWJjCNe.js} +0 -0
- /package/dist/web/assets/{csp-6cGliXw2.js → csp-C-n5jZKF.js} +0 -0
- /package/dist/web/assets/{css-CHnKqS9Q.js → css-BRXHjK80.js} +0 -0
- /package/dist/web/assets/{cypher-DMzZBj2L.js → cypher-Ib4R9oAB.js} +0 -0
- /package/dist/web/assets/{dart-7hYfJ1Dv.js → dart-Bmn0CjCu.js} +0 -0
- /package/dist/web/assets/{dockerfile-BflvjnJW.js → dockerfile-BJvHmfcK.js} +0 -0
- /package/dist/web/assets/{ecl-BEt6xb2p.js → ecl-C8Lr2n0s.js} +0 -0
- /package/dist/web/assets/{elixir-CnrQCt6o.js → elixir-GMkKEJvJ.js} +0 -0
- /package/dist/web/assets/{flow9-CfLCoUuB.js → flow9-BQbuvXMU.js} +0 -0
- /package/dist/web/assets/{fsharp-BQqR9uQ6.js → fsharp-CDI_AxQw.js} +0 -0
- /package/dist/web/assets/{go-C3AlMVwy.js → go-DmsC2k-Y.js} +0 -0
- /package/dist/web/assets/{graphql-O_-hDldf.js → graphql-C8hjT6Ki.js} +0 -0
- /package/dist/web/assets/{hcl-BQQD6Mtj.js → hcl-C15cAQOZ.js} +0 -0
- /package/dist/web/assets/{ini-Bf0RDfP_.js → ini-CKrAe0ag.js} +0 -0
- /package/dist/web/assets/{java-nqX2KEDD.js → java-BVhjILyl.js} +0 -0
- /package/dist/web/assets/{julia-B6P9U5er.js → julia-BzPDHDOG.js} +0 -0
- /package/dist/web/assets/{kotlin-B-LRk09-.js → kotlin-DQMAn-b6.js} +0 -0
- /package/dist/web/assets/{less-CEaIdW1f.js → less-428mfr1h.js} +0 -0
- /package/dist/web/assets/{lexon-Qv4pvFSW.js → lexon-B09dCO6A.js} +0 -0
- /package/dist/web/assets/{lua-CFpyR7YN.js → lua-CVQ0BJif.js} +0 -0
- /package/dist/web/assets/{m3-CvKhVPQn.js → m3-CiPQ1ljw.js} +0 -0
- /package/dist/web/assets/{markdown-qldG3Vc4.js → markdown--G0dqL-7.js} +0 -0
- /package/dist/web/assets/{mips-0D8PRyHq.js → mips-BaboCM3T.js} +0 -0
- /package/dist/web/assets/{msdax-DwZXSC5M.js → msdax-DUaqkqre.js} +0 -0
- /package/dist/web/assets/{mysql-BWq85KY4.js → mysql-CUE6XF4r.js} +0 -0
- /package/dist/web/assets/{objective-c-D653JUMG.js → objective-c-C4MUnzeT.js} +0 -0
- /package/dist/web/assets/{pascal-rWjRDdnR.js → pascal-CWMUMx__.js} +0 -0
- /package/dist/web/assets/{pascaligo-Db8EehaF.js → pascaligo-DLCVutek.js} +0 -0
- /package/dist/web/assets/{perl-C68oq8-D.js → perl-JYoirQpx.js} +0 -0
- /package/dist/web/assets/{pgsql-BXeHe33s.js → pgsql-BqOy7sqx.js} +0 -0
- /package/dist/web/assets/{php-CDVsAbfl.js → php-PZqsysO1.js} +0 -0
- /package/dist/web/assets/{pla-DnryFT0q.js → pla-BiwqVlg6.js} +0 -0
- /package/dist/web/assets/{postiats-CDg_4Ev-.js → postiats-COxQtXCD.js} +0 -0
- /package/dist/web/assets/{powerquery-CWPi8ROz.js → powerquery-DdXUmaWa.js} +0 -0
- /package/dist/web/assets/{powershell-C5A0QX3-.js → powershell-D05yu9sz.js} +0 -0
- /package/dist/web/assets/{preload-helper-DSXbuxSR.js → preload-helper-DzyYoeor.js} +0 -0
- /package/dist/web/assets/{protobuf-Cgt-BQbL.js → protobuf-BDsm0ZB_.js} +0 -0
- /package/dist/web/assets/{pug-RPYJC9QB.js → pug-3CmTiGoi.js} +0 -0
- /package/dist/web/assets/{qsharp-BZ3S7fu_.js → qsharp-CDUCQwQO.js} +0 -0
- /package/dist/web/assets/{r-CN875f1X.js → r-Decg_RIU.js} +0 -0
- /package/dist/web/assets/{redis-BLesvTwR.js → redis-Cl3EBA4R.js} +0 -0
- /package/dist/web/assets/{redshift-Byf_0XqD.js → redshift-5ZsNLhOp.js} +0 -0
- /package/dist/web/assets/{restructuredtext-DYg_6BiZ.js → restructuredtext-BulNNF_e.js} +0 -0
- /package/dist/web/assets/{ruby-C4OkxbC-.js → ruby-D3Axi_9w.js} +0 -0
- /package/dist/web/assets/{rust-xAoaEFMh.js → rust-Csys1Tos.js} +0 -0
- /package/dist/web/assets/{sb-C8dHOW_y.js → sb-C_iBPphi.js} +0 -0
- /package/dist/web/assets/{scala-Spx0wP1o.js → scala-Cg4p-EZ2.js} +0 -0
- /package/dist/web/assets/{scheme-D2mZlAUz.js → scheme-BlVnEL_j.js} +0 -0
- /package/dist/web/assets/{scss-DDCn3Ylu.js → scss-CmLW8ojr.js} +0 -0
- /package/dist/web/assets/{shell-M6px0EWn.js → shell-B1DV_gpl.js} +0 -0
- /package/dist/web/assets/{solidity-DUWMJi-f.js → solidity-glFpNhe3.js} +0 -0
- /package/dist/web/assets/{sophia-DwJbUG-2.js → sophia-D9j4cFkA.js} +0 -0
- /package/dist/web/assets/{sparql-ClQxbRPI.js → sparql-DV5Ux9cO.js} +0 -0
- /package/dist/web/assets/{sql-BQdjW7Vy.js → sql-K8tNKFcf.js} +0 -0
- /package/dist/web/assets/{st-BpISyZ_v.js → st-BhIdE2hj.js} +0 -0
- /package/dist/web/assets/{swift-CMbl5gM4.js → swift-B0pzSmmx.js} +0 -0
- /package/dist/web/assets/{systemverilog-jx2Xs7uO.js → systemverilog-CeBgixbN.js} +0 -0
- /package/dist/web/assets/{tcl-GIGnfs89.js → tcl-B0Ji3IbZ.js} +0 -0
- /package/dist/web/assets/{twig-Bc0mxc_m.js → twig-KUgPCP41.js} +0 -0
- /package/dist/web/assets/{typespec-CEioAsEm.js → typespec-ryrhjid6.js} +0 -0
- /package/dist/web/assets/{vb-BPk67J-d.js → vb-Z68-YtMY.js} +0 -0
- /package/dist/web/assets/{wgsl-DOnyt8_J.js → wgsl-bH-W-d_T.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region src/core/completions.ts
|
|
6
|
+
const LEADING_DASHES = /^-+/;
|
|
7
|
+
function getArgNames(cmd) {
|
|
8
|
+
if (!cmd.args) return [];
|
|
9
|
+
return Object.entries(cmd.args).flatMap(([key, arg]) => {
|
|
10
|
+
const names = [`--${key}`];
|
|
11
|
+
if (arg.alias) names.push(`-${arg.alias}`);
|
|
12
|
+
return names;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function getCommandNames(cmds) {
|
|
16
|
+
return Object.keys(cmds).filter((c) => !c.startsWith("_"));
|
|
17
|
+
}
|
|
18
|
+
function getFileCompletions(pattern) {
|
|
19
|
+
try {
|
|
20
|
+
const files = fs.readdirSync(path.dirname(pattern));
|
|
21
|
+
const ext = path.extname(pattern);
|
|
22
|
+
const prefix = path.basename(pattern).replace(ext, "");
|
|
23
|
+
return files.filter((f) => f.endsWith(ext) && f.startsWith(prefix)).map((f) => f.replace(ext, ""));
|
|
24
|
+
} catch {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function getJsonModelNames(configPath) {
|
|
29
|
+
try {
|
|
30
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
31
|
+
const config = JSON.parse(content);
|
|
32
|
+
if (config.provider?.models) return config.provider.models.map((m) => m.name);
|
|
33
|
+
} catch {}
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
function getValueCompletions(prevArg) {
|
|
37
|
+
switch (prevArg) {
|
|
38
|
+
case "--schema":
|
|
39
|
+
case "-s": {
|
|
40
|
+
const cwd = process.cwd();
|
|
41
|
+
return getFileCompletions(path.join(cwd, ".aiex/schema/*.json"));
|
|
42
|
+
}
|
|
43
|
+
case "--model":
|
|
44
|
+
case "-m": {
|
|
45
|
+
const cwd = process.cwd();
|
|
46
|
+
return getJsonModelNames(path.join(cwd, ".aiex/ai-config.json"));
|
|
47
|
+
}
|
|
48
|
+
case "--file":
|
|
49
|
+
case "-f":
|
|
50
|
+
case "--text":
|
|
51
|
+
case "-t":
|
|
52
|
+
case "--name":
|
|
53
|
+
case "--port":
|
|
54
|
+
case "-p": return [];
|
|
55
|
+
default: return [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function getCompletions(subCommands, args) {
|
|
59
|
+
const cmds = getCommandNames(subCommands);
|
|
60
|
+
if (args.length <= 1) {
|
|
61
|
+
const word = args[0] ?? "";
|
|
62
|
+
if (!word) return cmds;
|
|
63
|
+
return cmds.filter((c) => c.startsWith(word));
|
|
64
|
+
}
|
|
65
|
+
const cmdName = args[0];
|
|
66
|
+
const cmd = subCommands[cmdName];
|
|
67
|
+
const rest = args.slice(1);
|
|
68
|
+
if (!cmd) {
|
|
69
|
+
const matched = cmds.filter((c) => c.startsWith(cmdName));
|
|
70
|
+
if (matched.length > 0) return matched;
|
|
71
|
+
return cmds;
|
|
72
|
+
}
|
|
73
|
+
const current = rest[rest.length - 1] ?? "";
|
|
74
|
+
const prev = rest.length > 1 ? rest[rest.length - 2] : void 0;
|
|
75
|
+
if (current.startsWith("-")) {
|
|
76
|
+
const names = getArgNames(cmd);
|
|
77
|
+
if (!current) return names;
|
|
78
|
+
const key = current.replace(LEADING_DASHES, "");
|
|
79
|
+
if (!key) return names;
|
|
80
|
+
return names.filter((n) => n.replace(LEADING_DASHES, "").startsWith(key));
|
|
81
|
+
}
|
|
82
|
+
if (!current && prev) {
|
|
83
|
+
const values = getValueCompletions(prev);
|
|
84
|
+
if (values.length > 0) return values;
|
|
85
|
+
}
|
|
86
|
+
return getArgNames(cmd);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { getCompletions };
|
|
@@ -6,6 +6,13 @@ import fs from "node:fs/promises";
|
|
|
6
6
|
import Database from "better-sqlite3";
|
|
7
7
|
import * as esbuild from "esbuild";
|
|
8
8
|
|
|
9
|
+
//#region src/core/schema-sqlite/migration-name.ts
|
|
10
|
+
function sanitizeMigrationName(name) {
|
|
11
|
+
if (!name) return void 0;
|
|
12
|
+
return name.trim().toLowerCase().replace(/[^a-z0-9_\s-]/g, "_").replace(/[\s-]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "") || void 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
9
16
|
//#region src/core/schema-sqlite/migrate-helper.ts
|
|
10
17
|
const require = createRequire(import.meta.url);
|
|
11
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -64,7 +71,7 @@ async function loadPrevSnapshot(migrationsPath) {
|
|
|
64
71
|
return null;
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
async function saveSnapshot(migrationsPath, snapshot) {
|
|
74
|
+
async function saveSnapshot(migrationsPath, snapshot, migrationName) {
|
|
68
75
|
const metaPath = path.join(migrationsPath, "meta");
|
|
69
76
|
await fs.mkdir(metaPath, { recursive: true });
|
|
70
77
|
const journalPath = path.join(metaPath, "_journal.json");
|
|
@@ -79,7 +86,8 @@ async function saveSnapshot(migrationsPath, snapshot) {
|
|
|
79
86
|
};
|
|
80
87
|
}
|
|
81
88
|
const idx = journal.entries.length + 1;
|
|
82
|
-
const
|
|
89
|
+
const suffix = sanitizeMigrationName(migrationName) || snapshot.id.replace(/-/g, "_").substring(0, 8);
|
|
90
|
+
const tag = `${String(idx).padStart(4, "0")}_${suffix}`;
|
|
83
91
|
const snapshotPath = path.join(metaPath, `${tag}_snapshot.json`);
|
|
84
92
|
await fs.writeFile(snapshotPath, JSON.stringify(snapshot, null, 2));
|
|
85
93
|
journal.entries.push({
|
|
@@ -145,8 +153,9 @@ async function main() {
|
|
|
145
153
|
const schemaPath = args[0];
|
|
146
154
|
const migrationsPath = args[1];
|
|
147
155
|
const dbPath = args[2];
|
|
156
|
+
const migrationName = args[3];
|
|
148
157
|
if (!schemaPath || !migrationsPath || !dbPath) {
|
|
149
|
-
console.error("Usage: migrate-helper.ts <schemaPath> <migrationsPath> <dbPath>");
|
|
158
|
+
console.error("Usage: migrate-helper.ts <schemaPath> <migrationsPath> <dbPath> [migrationName]");
|
|
150
159
|
process.exit(1);
|
|
151
160
|
}
|
|
152
161
|
try {
|
|
@@ -154,7 +163,13 @@ async function main() {
|
|
|
154
163
|
await acquireLock(aiexDir);
|
|
155
164
|
try {
|
|
156
165
|
const exports = await loadSchemaExports(schemaPath);
|
|
157
|
-
|
|
166
|
+
let dbMissing = false;
|
|
167
|
+
try {
|
|
168
|
+
await fs.access(dbPath);
|
|
169
|
+
} catch {
|
|
170
|
+
dbMissing = true;
|
|
171
|
+
}
|
|
172
|
+
const prevSnapshot = dbMissing ? null : await loadPrevSnapshot(migrationsPath);
|
|
158
173
|
const currentSnapshot = await generateSQLiteDrizzleJson(exports, prevSnapshot?.id);
|
|
159
174
|
const sqlStatements = await generateSQLiteMigration(prevSnapshot || EMPTY_SNAPSHOT, currentSnapshot);
|
|
160
175
|
if (sqlStatements.length === 0) {
|
|
@@ -165,7 +180,7 @@ async function main() {
|
|
|
165
180
|
return;
|
|
166
181
|
}
|
|
167
182
|
applyMigrationWithTransaction(dbPath, sqlStatements);
|
|
168
|
-
const tag = await saveSnapshot(migrationsPath, currentSnapshot);
|
|
183
|
+
const tag = await saveSnapshot(migrationsPath, currentSnapshot, migrationName);
|
|
169
184
|
await saveMigrationFile(migrationsPath, tag, sqlStatements);
|
|
170
185
|
console.log(JSON.stringify({
|
|
171
186
|
success: true,
|
|
@@ -184,7 +199,7 @@ async function main() {
|
|
|
184
199
|
process.exit(1);
|
|
185
200
|
}
|
|
186
201
|
}
|
|
187
|
-
main();
|
|
202
|
+
if (process.argv[1] && __filename === path.resolve(process.argv[1])) main();
|
|
188
203
|
|
|
189
204
|
//#endregion
|
|
190
205
|
export { };
|
|
@@ -103,7 +103,7 @@ function generateRelationDefinitions(relations, reverseRelations) {
|
|
|
103
103
|
if (needsMany) imports.push("many");
|
|
104
104
|
const importStr = imports.join(", ");
|
|
105
105
|
const relDefs = [];
|
|
106
|
-
for (const rel of childRels) relDefs.push(` ${rel.name}: one(${rel.toTable}, {\n fields: [${rel.fromColumn}],\n references: [
|
|
106
|
+
for (const rel of childRels) relDefs.push(` ${rel.name}: one(${rel.toTable}, {\n fields: [${rel.fromTable}.${rel.fromColumn}],\n references: [${rel.toTable}.${rel.toColumn}],\n })`);
|
|
107
107
|
for (const rel of parentRels) if (rel.type === "has-many") relDefs.push(` ${rel.name}: many(${rel.toTable})`);
|
|
108
108
|
else relDefs.push(` ${rel.name}: one(${rel.toTable})`);
|
|
109
109
|
definitions.push(`export const ${tableName}Relations = relations(${tableName}, ({ ${importStr} }) => ({\n${relDefs.join(",\n")}\n}))`);
|
|
@@ -411,7 +411,7 @@ function generateDrizzleConfig() {
|
|
|
411
411
|
//#endregion
|
|
412
412
|
//#region package.json
|
|
413
413
|
var name = "aiex-cli";
|
|
414
|
-
var version = "0.0.1-beta.
|
|
414
|
+
var version = "0.0.1-beta.20";
|
|
415
415
|
var description = "JSON Schema → SQLite with AI-powered data extraction";
|
|
416
416
|
var package_default = {
|
|
417
417
|
name,
|
|
@@ -452,22 +452,27 @@ var package_default = {
|
|
|
452
452
|
files: [
|
|
453
453
|
"bin",
|
|
454
454
|
"dist",
|
|
455
|
-
"src/core/schema-sqlite/migrate-helper.ts"
|
|
455
|
+
"src/core/schema-sqlite/migrate-helper.ts",
|
|
456
|
+
"src/core/schema-sqlite/migration-name.ts"
|
|
456
457
|
],
|
|
457
458
|
scripts: {
|
|
458
459
|
"build": "tsdown && pnpm --filter aiex-web build",
|
|
459
460
|
"dev": "tsdown --watch",
|
|
460
461
|
"start": "tsx src/index.ts",
|
|
461
462
|
"test": "vitest",
|
|
463
|
+
"coverage": "vitest --coverage",
|
|
462
464
|
"typecheck": "tsc",
|
|
463
465
|
"lint": "eslint .",
|
|
464
|
-
"
|
|
465
|
-
"
|
|
466
|
+
"prepack": "cp ../../README.md .",
|
|
467
|
+
"postpack": "rm -f README.md",
|
|
468
|
+
"prepublishOnly": "pnpm run build"
|
|
466
469
|
},
|
|
467
470
|
dependencies: {
|
|
468
471
|
"@ai-sdk/openai-compatible": "catalog:",
|
|
469
472
|
"@clack/prompts": "catalog:",
|
|
470
473
|
"@hono/node-server": "catalog:",
|
|
474
|
+
"@langfuse/otel": "catalog:",
|
|
475
|
+
"@opentelemetry/sdk-trace-node": "catalog:",
|
|
471
476
|
"ai": "catalog:",
|
|
472
477
|
"better-sqlite3": "catalog:",
|
|
473
478
|
"citty": "catalog:",
|
|
@@ -482,6 +487,7 @@ var package_default = {
|
|
|
482
487
|
"hono": "catalog:",
|
|
483
488
|
"picocolors": "catalog:",
|
|
484
489
|
"tsx": "catalog:cli",
|
|
490
|
+
"unpdf": "catalog:",
|
|
485
491
|
"update-notifier": "catalog:",
|
|
486
492
|
"zod": "catalog:"
|
|
487
493
|
},
|
|
@@ -491,6 +497,7 @@ var package_default = {
|
|
|
491
497
|
"@types/better-sqlite3": "catalog:types",
|
|
492
498
|
"@types/node": "catalog:types",
|
|
493
499
|
"@types/update-notifier": "catalog:",
|
|
500
|
+
"@vitest/coverage-v8": "catalog:testing",
|
|
494
501
|
"eslint": "catalog:cli",
|
|
495
502
|
"publint": "catalog:cli",
|
|
496
503
|
"tsdown": "catalog:cli",
|
|
@@ -517,7 +524,9 @@ function seedConfig(config = createConfig()) {
|
|
|
517
524
|
//#region src/core/ai-extraction/schemas.ts
|
|
518
525
|
const ModelCapabilitiesSchema = z.object({
|
|
519
526
|
vision: z.boolean(),
|
|
520
|
-
structuredOutput: z.boolean()
|
|
527
|
+
structuredOutput: z.boolean(),
|
|
528
|
+
maxTokens: z.number().int().positive().optional(),
|
|
529
|
+
maxOutputTokens: z.number().int().positive().optional()
|
|
521
530
|
});
|
|
522
531
|
const AIModelConfigSchema = z.object({
|
|
523
532
|
name: z.string().min(1),
|
|
@@ -526,17 +535,24 @@ const AIModelConfigSchema = z.object({
|
|
|
526
535
|
const AIProviderConfigSchema = z.object({
|
|
527
536
|
baseURL: z.string().min(1),
|
|
528
537
|
apiKey: z.string(),
|
|
529
|
-
models: z.array(AIModelConfigSchema).min(1)
|
|
538
|
+
models: z.array(AIModelConfigSchema).min(1),
|
|
539
|
+
timeout: z.number().int().positive().default(300).optional()
|
|
530
540
|
});
|
|
531
541
|
const PromptConfigSchema = z.object({
|
|
532
542
|
systemTemplate: z.string().min(1),
|
|
533
543
|
userTemplate: z.string().min(1)
|
|
534
544
|
});
|
|
535
545
|
const ExtractionConfigSchema = z.object({ outputDir: z.string().min(1) });
|
|
546
|
+
const LangfuseConfigSchema = z.object({
|
|
547
|
+
publicKey: z.string(),
|
|
548
|
+
secretKey: z.string(),
|
|
549
|
+
host: z.string().optional()
|
|
550
|
+
});
|
|
536
551
|
const AIConfigSchema = z.object({
|
|
537
552
|
provider: AIProviderConfigSchema,
|
|
538
553
|
prompt: PromptConfigSchema,
|
|
539
|
-
extraction: ExtractionConfigSchema
|
|
554
|
+
extraction: ExtractionConfigSchema,
|
|
555
|
+
langfuse: LangfuseConfigSchema.optional()
|
|
540
556
|
});
|
|
541
557
|
|
|
542
558
|
//#endregion
|
|
@@ -559,10 +575,11 @@ const DEFAULT_MODELS = [{
|
|
|
559
575
|
const DEFAULT_PROVIDER_CONFIG = {
|
|
560
576
|
baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
|
|
561
577
|
apiKey: "",
|
|
562
|
-
models: [...DEFAULT_MODELS]
|
|
578
|
+
models: [...DEFAULT_MODELS],
|
|
579
|
+
timeout: 300
|
|
563
580
|
};
|
|
564
581
|
const DEFAULT_PROMPT_CONFIG = {
|
|
565
|
-
systemTemplate: `You are a professional data extraction assistant. Your task is to extract structured data from text based on the data structure definition provided below.
|
|
582
|
+
systemTemplate: `You are a professional data extraction assistant. Your task is to extract structured data from text and return a JSON object based on the data structure definition provided below.
|
|
566
583
|
|
|
567
584
|
{schema}
|
|
568
585
|
|
|
@@ -604,10 +621,6 @@ async function writeAIConfig(aiexDir, config) {
|
|
|
604
621
|
function getDefaultAIConfig() {
|
|
605
622
|
return { ...DEFAULT_AI_CONFIG };
|
|
606
623
|
}
|
|
607
|
-
function maskApiKey(apiKey) {
|
|
608
|
-
if (apiKey.length <= 4) return "****";
|
|
609
|
-
return `sk-***${apiKey.slice(-4)}`;
|
|
610
|
-
}
|
|
611
624
|
async function addToGitignore(aiexDir, fileName) {
|
|
612
625
|
const projectRoot = path.dirname(aiexDir);
|
|
613
626
|
const gitignorePath = path.join(projectRoot, GITIGNORE_FILE);
|
|
@@ -708,4 +721,4 @@ async function collectDoctorDiagnostics(options = {}) {
|
|
|
708
721
|
}
|
|
709
722
|
|
|
710
723
|
//#endregion
|
|
711
|
-
export {
|
|
724
|
+
export { formatDoctorDiagnosticsJson as C, doctorDiagnosticsTableRows as S, JsonSchemaDefinitionSchema as _, DEFAULT_PROMPT_CONFIG as a, generateDrizzleSchema as b, AIConfigSchema as c, description as d, name as f, generateDrizzleConfig as g, createMigrationConfig as h, writeAIConfig as i, createConfig as l, version as m, getDefaultAIConfig as n, PLACEHOLDER_SCHEMA as o, package_default as p, readAIConfig as r, PLACEHOLDER_TEXT as s, collectDoctorDiagnostics as t, seedConfig as u, parseJsonSchema as v, buildDoctorDiagnostics as x, toSnakeCase as y };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as formatDoctorDiagnosticsJson, S as doctorDiagnosticsTableRows, _ as JsonSchemaDefinitionSchema, b as generateDrizzleSchema, g as generateDrizzleConfig, h as createMigrationConfig, t as collectDoctorDiagnostics, v as parseJsonSchema, x as buildDoctorDiagnostics } from "./doctor-B5JSikzk.mjs";
|
|
2
2
|
|
|
3
3
|
export { JsonSchemaDefinitionSchema, buildDoctorDiagnostics, collectDoctorDiagnostics, createMigrationConfig, doctorDiagnosticsTableRows, formatDoctorDiagnosticsJson, generateDrizzleConfig, generateDrizzleSchema, parseJsonSchema };
|