@duckcodeailabs/dql-cli 1.0.3 → 1.2.0
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/args.d.ts +1 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +4 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/index-Cscl1A2H.js +628 -0
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/app.d.ts +3 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +191 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +30 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/diff.d.ts +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +38 -9
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/fmt.d.ts.map +1 -1
- package/dist/commands/fmt.js +27 -8
- package/dist/commands/fmt.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.d.ts +7 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +16 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate.d.ts +1 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +86 -0
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/schedule.d.ts +3 -0
- package/dist/commands/schedule.d.ts.map +1 -0
- package/dist/commands/schedule.js +132 -0
- package/dist/commands/schedule.js.map +1 -0
- package/dist/digest.d.ts +10 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +83 -0
- package/dist/digest.js.map +1 -0
- package/dist/git-service.d.ts +17 -0
- package/dist/git-service.d.ts.map +1 -0
- package/dist/git-service.js +54 -0
- package/dist/git-service.js.map +1 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/llm/claude-agent-sdk.d.ts +3 -0
- package/dist/llm/claude-agent-sdk.d.ts.map +1 -0
- package/dist/llm/claude-agent-sdk.js +174 -0
- package/dist/llm/claude-agent-sdk.js.map +1 -0
- package/dist/llm/claude-code.d.ts +8 -0
- package/dist/llm/claude-code.d.ts.map +1 -0
- package/dist/llm/claude-code.js +171 -0
- package/dist/llm/claude-code.js.map +1 -0
- package/dist/llm/index.d.ts +4 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +10 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/tools.d.ts +9 -0
- package/dist/llm/tools.d.ts.map +1 -0
- package/dist/llm/tools.js +112 -0
- package/dist/llm/tools.js.map +1 -0
- package/dist/llm/types.d.ts +64 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/local-runtime.d.ts +6 -0
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +124 -8
- package/dist/local-runtime.js.map +1 -1
- package/dist/schedule/alerts.d.ts +5 -0
- package/dist/schedule/alerts.d.ts.map +1 -0
- package/dist/schedule/alerts.js +54 -0
- package/dist/schedule/alerts.js.map +1 -0
- package/dist/schedule/discovery.d.ts +4 -0
- package/dist/schedule/discovery.d.ts.map +1 -0
- package/dist/schedule/discovery.js +36 -0
- package/dist/schedule/discovery.js.map +1 -0
- package/dist/schedule/notifiers/email.d.ts +3 -0
- package/dist/schedule/notifiers/email.d.ts.map +1 -0
- package/dist/schedule/notifiers/email.js +76 -0
- package/dist/schedule/notifiers/email.js.map +1 -0
- package/dist/schedule/notifiers/file.d.ts +3 -0
- package/dist/schedule/notifiers/file.d.ts.map +1 -0
- package/dist/schedule/notifiers/file.js +50 -0
- package/dist/schedule/notifiers/file.js.map +1 -0
- package/dist/schedule/notifiers/index.d.ts +10 -0
- package/dist/schedule/notifiers/index.d.ts.map +1 -0
- package/dist/schedule/notifiers/index.js +33 -0
- package/dist/schedule/notifiers/index.js.map +1 -0
- package/dist/schedule/notifiers/slack.d.ts +3 -0
- package/dist/schedule/notifiers/slack.d.ts.map +1 -0
- package/dist/schedule/notifiers/slack.js +58 -0
- package/dist/schedule/notifiers/slack.js.map +1 -0
- package/dist/schedule/runner.d.ts +11 -0
- package/dist/schedule/runner.d.ts.map +1 -0
- package/dist/schedule/runner.js +109 -0
- package/dist/schedule/runner.js.map +1 -0
- package/dist/schedule/runs.d.ts +5 -0
- package/dist/schedule/runs.d.ts.map +1 -0
- package/dist/schedule/runs.js +40 -0
- package/dist/schedule/runs.js.map +1 -0
- package/dist/schedule/service.d.ts +12 -0
- package/dist/schedule/service.d.ts.map +1 -0
- package/dist/schedule/service.js +49 -0
- package/dist/schedule/service.js.map +1 -0
- package/dist/schedule/types.d.ts +64 -0
- package/dist/schedule/types.d.ts.map +1 -0
- package/dist/schedule/types.js +2 -0
- package/dist/schedule/types.js.map +1 -0
- package/package.json +17 -10
- package/dist/assets/dql-notebook/assets/index-BJbWzCsK.js +0 -622
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAUtF,OAAO,EAcL,KAAK,aAAa,EAClB,KAAK,2BAA2B,
|
|
1
|
+
{"version":3,"file":"local-runtime.d.ts","sourceRoot":"","sources":["../src/local-runtime.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAUtF,OAAO,EAcL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAUjC,MAAM,0BAA0B,CAAC;AAalC,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;IACrC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,MAAM,CAAA;KAAE,CAAC;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACA;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CA2C1D;AAqcD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6CD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/local-runtime.js
CHANGED
|
@@ -3,8 +3,9 @@ import { createServer } from 'node:http';
|
|
|
3
3
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, watch, writeFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, extname, join, normalize, relative, resolve } from 'node:path';
|
|
5
5
|
import { buildExecutionPlan, createWelcomeNotebook, deserializeNotebook, getConnectorFormSchemas, hasSemanticRefs, resolveSemanticRefs, } from '@duckcodeailabs/dql-notebook';
|
|
6
|
-
import { loadSemanticLayerFromDir, resolveSemanticLayerAsync, Parser, buildLineageGraph, buildManifest, analyzeImpact, buildTrustChain, detectDomainFlows, getDomainTrustOverview, queryLineage, queryCompleteLineagePaths, LineageGraph, canonicalize, } from '@duckcodeailabs/dql-core';
|
|
6
|
+
import { loadSemanticLayerFromDir, resolveSemanticLayerAsync, Parser, buildLineageGraph, buildManifest, analyzeImpact, buildTrustChain, detectDomainFlows, getDomainTrustOverview, queryLineage, queryCompleteLineagePaths, LineageGraph, canonicalize, canonicalizeNotebook, diffDQL, diffNotebook, } from '@duckcodeailabs/dql-core';
|
|
7
7
|
import { listBlockTemplates } from './block-templates.js';
|
|
8
|
+
import { getRunner as getLLMRunner } from './llm/index.js';
|
|
8
9
|
import { buildSemanticObjectDetail, buildSemanticTree, computeSyncDiff, loadSemanticImportManifest, performSemanticImport, previewSemanticImport, syncSemanticImport, } from './semantic-import.js';
|
|
9
10
|
export async function startLocalServer(opts) {
|
|
10
11
|
const { rootDir, executor, connection: rawConnection, preferredPort, projectRoot = process.cwd() } = opts;
|
|
@@ -220,7 +221,11 @@ export async function startLocalServer(opts) {
|
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
223
|
mkdirSync(dirname(absPath), { recursive: true });
|
|
223
|
-
const toWrite = absPath.endsWith('.dql')
|
|
224
|
+
const toWrite = absPath.endsWith('.dql')
|
|
225
|
+
? canonicalizeSafe(content)
|
|
226
|
+
: absPath.endsWith('.dqlnb')
|
|
227
|
+
? canonicalizeNotebookSafe(content)
|
|
228
|
+
: content;
|
|
224
229
|
writeFileSync(absPath, toWrite, 'utf-8');
|
|
225
230
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
226
231
|
res.end(serializeJSON({ ok: true }));
|
|
@@ -340,7 +345,7 @@ export async function startLocalServer(opts) {
|
|
|
340
345
|
if (req.method === 'POST' && path === '/api/blocks/save-from-cell') {
|
|
341
346
|
try {
|
|
342
347
|
const body = await readJSON(req);
|
|
343
|
-
const { name, domain, owner, content, description, tags, metricRefs, template, } = body;
|
|
348
|
+
const { name, domain, owner, content, description, tags, metricRefs, template, llmContext, examples, invariants, } = body;
|
|
344
349
|
if (!name || typeof name !== 'string' || !content || typeof content !== 'string') {
|
|
345
350
|
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
346
351
|
res.end(serializeJSON({ error: 'name and content are required' }));
|
|
@@ -370,6 +375,9 @@ export async function startLocalServer(opts) {
|
|
|
370
375
|
tags,
|
|
371
376
|
metricRefs,
|
|
372
377
|
template,
|
|
378
|
+
llmContext,
|
|
379
|
+
examples,
|
|
380
|
+
invariants,
|
|
373
381
|
gitMetadata: readGitMetadata(projectRoot),
|
|
374
382
|
});
|
|
375
383
|
res.writeHead(201, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
@@ -1289,6 +1297,42 @@ export async function startLocalServer(opts) {
|
|
|
1289
1297
|
}
|
|
1290
1298
|
return;
|
|
1291
1299
|
}
|
|
1300
|
+
if (req.method === 'POST' && path === '/api/llm/run') {
|
|
1301
|
+
const body = await readJSON(req).catch(() => null);
|
|
1302
|
+
if (!body || typeof body !== 'object') {
|
|
1303
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1304
|
+
res.end(serializeJSON({ error: 'Invalid JSON body' }));
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const { provider, messages, upstream } = body;
|
|
1308
|
+
const runner = provider === 'claude-agent-sdk' || provider === 'claude-code' ? getLLMRunner(provider) : null;
|
|
1309
|
+
if (!runner) {
|
|
1310
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1311
|
+
res.end(serializeJSON({ error: `Unknown provider: ${provider}` }));
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
1315
|
+
res.writeHead(400, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
1316
|
+
res.end(serializeJSON({ error: 'messages[] required' }));
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
res.writeHead(200, {
|
|
1320
|
+
'Content-Type': 'text/event-stream',
|
|
1321
|
+
'Cache-Control': 'no-cache, no-transform',
|
|
1322
|
+
Connection: 'keep-alive',
|
|
1323
|
+
});
|
|
1324
|
+
const controller = new AbortController();
|
|
1325
|
+
req.on('close', () => controller.abort());
|
|
1326
|
+
const emit = (turn) => { res.write(`data: ${JSON.stringify(turn)}\n\n`); };
|
|
1327
|
+
try {
|
|
1328
|
+
await runner.run({ provider: provider, messages, upstream, projectRoot }, emit, controller.signal);
|
|
1329
|
+
}
|
|
1330
|
+
catch (err) {
|
|
1331
|
+
emit({ kind: 'error', message: err instanceof Error ? err.message : String(err) });
|
|
1332
|
+
}
|
|
1333
|
+
res.end();
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1292
1336
|
if (req.method === 'POST' && path === '/api/query') {
|
|
1293
1337
|
try {
|
|
1294
1338
|
const body = await readJSON(req);
|
|
@@ -2771,6 +2815,14 @@ function canonicalizeSafe(source) {
|
|
|
2771
2815
|
return source;
|
|
2772
2816
|
}
|
|
2773
2817
|
}
|
|
2818
|
+
function canonicalizeNotebookSafe(source) {
|
|
2819
|
+
try {
|
|
2820
|
+
return canonicalizeNotebook(source);
|
|
2821
|
+
}
|
|
2822
|
+
catch {
|
|
2823
|
+
return source;
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2774
2826
|
export function readGitMetadata(projectRoot) {
|
|
2775
2827
|
const run = (cmd) => execSync(cmd, { cwd: projectRoot, encoding: 'utf-8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
|
|
2776
2828
|
try {
|
|
@@ -2814,6 +2866,9 @@ export function createBlockArtifacts(projectRoot, options) {
|
|
|
2814
2866
|
owner: options.owner,
|
|
2815
2867
|
description: options.description,
|
|
2816
2868
|
tags: options.tags,
|
|
2869
|
+
llmContext: options.llmContext,
|
|
2870
|
+
examples: options.examples,
|
|
2871
|
+
invariants: options.invariants,
|
|
2817
2872
|
content: options.content?.trim() || templateContent,
|
|
2818
2873
|
}));
|
|
2819
2874
|
writeFileSync(blockPath, fileContent, 'utf-8');
|
|
@@ -3057,6 +3112,9 @@ function normalizeBlockStudioContent(options) {
|
|
|
3057
3112
|
owner: options.owner,
|
|
3058
3113
|
description: options.description,
|
|
3059
3114
|
tags: options.tags,
|
|
3115
|
+
llmContext: options.llmContext,
|
|
3116
|
+
examples: options.examples,
|
|
3117
|
+
invariants: options.invariants,
|
|
3060
3118
|
sql: content || 'SELECT 1 AS value',
|
|
3061
3119
|
});
|
|
3062
3120
|
}
|
|
@@ -3069,6 +3127,28 @@ function buildBlankBlockContent(options) {
|
|
|
3069
3127
|
` owner = "${escapeDqlString(options.owner?.trim() ?? '')}"`,
|
|
3070
3128
|
];
|
|
3071
3129
|
lines.push(` tags = [${(options.tags ?? []).map((tag) => `"${escapeDqlString(tag)}"`).join(', ')}]`);
|
|
3130
|
+
if (options.llmContext && options.llmContext.trim()) {
|
|
3131
|
+
lines.push(` llmContext = "${escapeDqlString(options.llmContext.trim())}"`);
|
|
3132
|
+
}
|
|
3133
|
+
if (options.invariants && options.invariants.length > 0) {
|
|
3134
|
+
lines.push(` invariants = [${options.invariants
|
|
3135
|
+
.filter((inv) => inv && inv.trim())
|
|
3136
|
+
.map((inv) => `"${escapeDqlString(inv.trim())}"`)
|
|
3137
|
+
.join(', ')}]`);
|
|
3138
|
+
}
|
|
3139
|
+
if (options.examples && options.examples.length > 0) {
|
|
3140
|
+
const items = options.examples.filter((ex) => ex.question && ex.question.trim());
|
|
3141
|
+
if (items.length > 0) {
|
|
3142
|
+
lines.push(' examples = [');
|
|
3143
|
+
for (const ex of items) {
|
|
3144
|
+
const parts = [`question = "${escapeDqlString(ex.question.trim())}"`];
|
|
3145
|
+
if (ex.sql && ex.sql.trim())
|
|
3146
|
+
parts.push(`sql = "${escapeDqlString(ex.sql.trim())}"`);
|
|
3147
|
+
lines.push(` { ${parts.join(', ')} },`);
|
|
3148
|
+
}
|
|
3149
|
+
lines.push(' ]');
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3072
3152
|
lines.push('');
|
|
3073
3153
|
lines.push(' query = """');
|
|
3074
3154
|
lines.push(...indentBlock(options.sql.trim(), 8).split('\n'));
|
|
@@ -3342,13 +3422,49 @@ function ensureGitignoreEntry(projectRoot, pattern) {
|
|
|
3342
3422
|
}
|
|
3343
3423
|
async function readGitDiff(cwd, filePath) {
|
|
3344
3424
|
const isRepo = await execGit(cwd, ['rev-parse', '--is-inside-work-tree']);
|
|
3345
|
-
if (isRepo.code !== 0)
|
|
3346
|
-
return { inRepo: false, diff: '' };
|
|
3425
|
+
if (isRepo.code !== 0) {
|
|
3426
|
+
return { inRepo: false, diff: '', before: null, after: null, diffReport: null };
|
|
3427
|
+
}
|
|
3347
3428
|
if (!filePath) {
|
|
3348
3429
|
const res = await execGit(cwd, ['diff', '--no-color']);
|
|
3349
|
-
return { inRepo: true, diff: res.stdout };
|
|
3430
|
+
return { inRepo: true, diff: res.stdout, before: null, after: null, diffReport: null };
|
|
3431
|
+
}
|
|
3432
|
+
const isSemantic = filePath.endsWith('.dql') || filePath.endsWith('.dqlnb');
|
|
3433
|
+
const [diffRes, before, after] = await Promise.all([
|
|
3434
|
+
execGit(cwd, ['diff', '--no-color', '--', filePath]),
|
|
3435
|
+
isSemantic ? readHeadBlob(cwd, filePath) : Promise.resolve(null),
|
|
3436
|
+
isSemantic ? readWorkingCopy(join(cwd, filePath)) : Promise.resolve(null),
|
|
3437
|
+
]);
|
|
3438
|
+
const diffReport = isSemantic ? computeSemanticDiff(filePath, before, after) : null;
|
|
3439
|
+
return { inRepo: true, diff: diffRes.stdout, before, after, diffReport };
|
|
3440
|
+
}
|
|
3441
|
+
async function readHeadBlob(cwd, filePath) {
|
|
3442
|
+
try {
|
|
3443
|
+
const res = await execGit(cwd, ['show', `HEAD:${filePath}`]);
|
|
3444
|
+
return res.code === 0 ? res.stdout : null;
|
|
3445
|
+
}
|
|
3446
|
+
catch {
|
|
3447
|
+
return null;
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
async function readWorkingCopy(absPath) {
|
|
3451
|
+
try {
|
|
3452
|
+
return readFileSync(absPath, 'utf-8');
|
|
3453
|
+
}
|
|
3454
|
+
catch {
|
|
3455
|
+
return null;
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
function computeSemanticDiff(filePath, before, after) {
|
|
3459
|
+
if (before === after)
|
|
3460
|
+
return null;
|
|
3461
|
+
try {
|
|
3462
|
+
return filePath.endsWith('.dqlnb')
|
|
3463
|
+
? diffNotebook(before, after)
|
|
3464
|
+
: diffDQL(before ?? '', after ?? '');
|
|
3465
|
+
}
|
|
3466
|
+
catch {
|
|
3467
|
+
return null;
|
|
3350
3468
|
}
|
|
3351
|
-
const res = await execGit(cwd, ['diff', '--no-color', '--', filePath]);
|
|
3352
|
-
return { inRepo: true, diff: res.stdout };
|
|
3353
3469
|
}
|
|
3354
3470
|
//# sourceMappingURL=local-runtime.js.map
|