@duckcodeailabs/dql-cli 1.6.5 → 1.6.6
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/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +59 -9
- package/dist/apps-api.js.map +1 -1
- package/dist/args.d.ts +11 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +21 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/{index-L-zyCapt.js → index-D_tpetmE.js} +346 -192
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/commands/agent.d.ts +2 -2
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +78 -13
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +3 -2
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/compile.d.ts +2 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +33 -1
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +17 -3
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +113 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +222 -8
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/promote-from-draft.d.ts +4 -4
- package/dist/promote-from-draft.js +8 -8
- package/dist/promote-from-draft.js.map +1 -1
- package/package.json +11 -11
package/dist/apps-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps-api.d.ts","sourceRoot":"","sources":["../src/apps-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE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YAAY,CAAC;IAC5C,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC,CA2BD;AAED,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9F;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAyBlH;AAED,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAwD/E;AA0TD,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC"}
|
package/dist/apps-api.js
CHANGED
|
@@ -48,6 +48,7 @@ export async function handleAppsApi(ctx) {
|
|
|
48
48
|
sendJson(res, 400, { error: result.error });
|
|
49
49
|
return true;
|
|
50
50
|
}
|
|
51
|
+
await refreshGeneratedMetadata(projectRoot);
|
|
51
52
|
sendJson(res, 201, result);
|
|
52
53
|
}
|
|
53
54
|
catch (err) {
|
|
@@ -689,7 +690,7 @@ export async function generateAppPackage(projectRoot, input) {
|
|
|
689
690
|
if (!prompt)
|
|
690
691
|
return { ok: false, error: 'prompt is required' };
|
|
691
692
|
const selectedBlockIds = unique((input.selectedBlockIds ?? []).map(cleanString).filter(Boolean));
|
|
692
|
-
const { KGStore, defaultKgPath, generateAppFromPlan, planAppFromPrompt, reindexProject, validateAppPlan, } = await import('@duckcodeailabs/dql-agent');
|
|
693
|
+
const { KGStore, defaultKgPath, generateAppFromPlan, ensureMetadataCatalogFresh, planAppFromPrompt, reindexProject, validateAppPlan, } = await import('@duckcodeailabs/dql-agent');
|
|
693
694
|
const kgPath = defaultKgPath(projectRoot);
|
|
694
695
|
await reindexProject(projectRoot, { kgPath });
|
|
695
696
|
const kg = new KGStore(kgPath);
|
|
@@ -705,6 +706,7 @@ export async function generateAppPackage(projectRoot, input) {
|
|
|
705
706
|
const generated = generateAppFromPlan(projectRoot, plan, kg, {
|
|
706
707
|
overwrite: Boolean(input.force),
|
|
707
708
|
});
|
|
709
|
+
await ensureMetadataCatalogFresh(projectRoot, { force: true });
|
|
708
710
|
const app = collectAppsList(projectRoot).find((entry) => entry.id === plan.appId) ?? null;
|
|
709
711
|
return {
|
|
710
712
|
ok: true,
|
|
@@ -1063,9 +1065,13 @@ async function runAppInvestigation(ctx, storage, investigation, input = {}) {
|
|
|
1063
1065
|
const previews = buildContextPreviews(selected);
|
|
1064
1066
|
let metricSnapshot = buildMetricSnapshot(selected);
|
|
1065
1067
|
let driverCards = buildDriverCards(selected, intent);
|
|
1068
|
+
const baselineGap = intent === 'diagnose_change' && hasSelectedRows(selected) && !hasComparableTimeBaseline(selected);
|
|
1069
|
+
const metadataOnly = intent === 'trust_gap_review';
|
|
1070
|
+
if (metadataOnly)
|
|
1071
|
+
generatedSql = '';
|
|
1066
1072
|
const sourceTileId = investigation.sourceTileId ?? selectedContextString(context, 'tileId');
|
|
1067
1073
|
const sourceBlockId = investigation.sourceBlockId ?? selectedContextString(context, 'blockId');
|
|
1068
|
-
const deterministicGeneration = generatedSql
|
|
1074
|
+
const deterministicGeneration = generatedSql || baselineGap || metadataOnly
|
|
1069
1075
|
? undefined
|
|
1070
1076
|
: buildDeterministicInvestigationSql(ctx.projectRoot, {
|
|
1071
1077
|
question,
|
|
@@ -1074,7 +1080,7 @@ async function runAppInvestigation(ctx, storage, investigation, input = {}) {
|
|
|
1074
1080
|
sourceBlockId,
|
|
1075
1081
|
});
|
|
1076
1082
|
generatedSql = generatedSql || deterministicGeneration?.sql;
|
|
1077
|
-
const agentGeneration = generatedSql
|
|
1083
|
+
const agentGeneration = generatedSql || baselineGap || metadataOnly
|
|
1078
1084
|
? undefined
|
|
1079
1085
|
: await generateInvestigationSql(ctx, {
|
|
1080
1086
|
appId: investigation.appId,
|
|
@@ -1090,7 +1096,7 @@ async function runAppInvestigation(ctx, storage, investigation, input = {}) {
|
|
|
1090
1096
|
const generationError = cleanString(agentGeneration?.executionError);
|
|
1091
1097
|
const sqlEvidence = agentGeneration?.result
|
|
1092
1098
|
? { preview: buildGeneratedSqlPreview(agentGeneration.result, generatedSql), error: generationError || undefined }
|
|
1093
|
-
: await runGeneratedSqlPreview(ctx, generatedSql);
|
|
1099
|
+
: metadataOnly ? {} : await runGeneratedSqlPreview(ctx, generatedSql);
|
|
1094
1100
|
const sqlError = sqlEvidence.error ?? generationError;
|
|
1095
1101
|
if (sqlEvidence.preview) {
|
|
1096
1102
|
previews.unshift(sqlEvidence.preview);
|
|
@@ -1106,7 +1112,8 @@ async function runAppInvestigation(ctx, storage, investigation, input = {}) {
|
|
|
1106
1112
|
generatedSql: generatedSql || undefined,
|
|
1107
1113
|
sqlExecuted: Boolean(sqlEvidence.preview),
|
|
1108
1114
|
sqlError,
|
|
1109
|
-
generationSource: deterministicGeneration ? 'selected_block_metadata' : agentGeneration?.providerUsed ? 'ai_provider' : generatedSql ? 'provided_sql' : 'context_only',
|
|
1115
|
+
generationSource: baselineGap ? 'missing_baseline' : deterministicGeneration ? 'selected_block_metadata' : agentGeneration?.providerUsed ? 'ai_provider' : generatedSql ? 'provided_sql' : 'context_only',
|
|
1116
|
+
baselineGap,
|
|
1110
1117
|
sourceBlockPath: deterministicGeneration?.sourceBlockPath,
|
|
1111
1118
|
sourceBlockName: deterministicGeneration?.sourceBlockName,
|
|
1112
1119
|
providerUsed: agentGeneration?.providerUsed,
|
|
@@ -1121,14 +1128,21 @@ async function runAppInvestigation(ctx, storage, investigation, input = {}) {
|
|
|
1121
1128
|
sourceBlockPath: deterministicGeneration?.sourceBlockPath ?? selectedString(selected, 'blockPath'),
|
|
1122
1129
|
certificationStatus: selectedString(selected, 'certificationStatus'),
|
|
1123
1130
|
},
|
|
1124
|
-
assumptions:
|
|
1131
|
+
assumptions: [
|
|
1132
|
+
...investigationAssumptions(intent, selected, generatedSql, sqlError),
|
|
1133
|
+
...(baselineGap ? ['The selected tile sample does not include at least two comparable time values, so DQL did not invent a change query from an unrelated table.'] : []),
|
|
1134
|
+
],
|
|
1125
1135
|
context,
|
|
1126
1136
|
agentEvidence: agentGeneration?.evidence,
|
|
1127
1137
|
analysisPlan: agentGeneration?.analysisPlan,
|
|
1128
1138
|
citations: agentGeneration?.citations,
|
|
1129
1139
|
};
|
|
1130
|
-
const summary = cleanString(agentGeneration?.answer) ||
|
|
1131
|
-
|
|
1140
|
+
const summary = cleanString(agentGeneration?.answer) || (baselineGap
|
|
1141
|
+
? buildMissingBaselineSummary(question, selected)
|
|
1142
|
+
: buildInvestigationSummary(intent, question, selected, metricSnapshot, driverCards));
|
|
1143
|
+
const recommendation = baselineGap
|
|
1144
|
+
? buildMissingBaselineRecommendation(selected)
|
|
1145
|
+
: buildInvestigationRecommendation(intent, selected, sqlError);
|
|
1132
1146
|
return storage.updateAppInvestigation(investigation.id, {
|
|
1133
1147
|
title: cleanString(input.question) ? titleFromInvestigation(question, selected) : investigation.title,
|
|
1134
1148
|
question,
|
|
@@ -1248,6 +1262,24 @@ function buildMetricSnapshot(selected) {
|
|
|
1248
1262
|
context: selectedString(selected, 'title') ?? 'Selected dashboard tile',
|
|
1249
1263
|
};
|
|
1250
1264
|
}
|
|
1265
|
+
function hasSelectedRows(selected) {
|
|
1266
|
+
return selectedRows(selected).length > 0;
|
|
1267
|
+
}
|
|
1268
|
+
function hasComparableTimeBaseline(selected) {
|
|
1269
|
+
const rows = selectedRows(selected);
|
|
1270
|
+
if (rows.length < 2)
|
|
1271
|
+
return false;
|
|
1272
|
+
const columns = selectedColumns(selected, rows);
|
|
1273
|
+
const profile = profileResultColumns(columns, rows);
|
|
1274
|
+
const timeDimension = chooseTimeDimension(profile);
|
|
1275
|
+
if (!timeDimension)
|
|
1276
|
+
return false;
|
|
1277
|
+
const values = new Set(rows
|
|
1278
|
+
.map((row) => row[timeDimension.name])
|
|
1279
|
+
.filter((value) => value !== null && value !== undefined && String(value).trim())
|
|
1280
|
+
.map((value) => String(value)));
|
|
1281
|
+
return values.size >= 2;
|
|
1282
|
+
}
|
|
1251
1283
|
function buildDriverCards(selected, intent) {
|
|
1252
1284
|
const rows = selectedRows(selected);
|
|
1253
1285
|
const columns = selectedColumns(selected, rows);
|
|
@@ -1408,7 +1440,7 @@ function buildDeterministicInvestigationSql(projectRoot, input) {
|
|
|
1408
1440
|
sourceBlockName: block.name,
|
|
1409
1441
|
};
|
|
1410
1442
|
}
|
|
1411
|
-
if (input.intent === 'anomaly_investigation') {
|
|
1443
|
+
if (input.intent === 'anomaly_investigation' || input.intent === 'diagnose_change') {
|
|
1412
1444
|
const timeDimension = chooseTimeDimension(profile) ?? dimension;
|
|
1413
1445
|
const rankExpr = `${measureAgg(measure)}(${quoteSqlIdentifier(measure.name)})`;
|
|
1414
1446
|
if (timeDimension) {
|
|
@@ -1747,6 +1779,14 @@ function buildInvestigationSummary(intent, question, selected, metrics, drivers)
|
|
|
1747
1779
|
const driver = drivers[0]?.title ? ` Top visible driver in the current evidence is ${drivers[0].title}.` : '';
|
|
1748
1780
|
return `DQL opened a review-required investigation for ${target}: ${question}.${delta}${driver}`;
|
|
1749
1781
|
}
|
|
1782
|
+
function buildMissingBaselineSummary(question, selected) {
|
|
1783
|
+
const target = selectedString(selected, 'title') ?? 'the selected tile';
|
|
1784
|
+
return `DQL opened a review-required investigation for ${target}: ${question}. The selected tile shows the current certified result, but its sample does not include a comparable prior period or historical snapshot, so DQL cannot calculate what changed without guessing.`;
|
|
1785
|
+
}
|
|
1786
|
+
function buildMissingBaselineRecommendation(selected) {
|
|
1787
|
+
const target = selectedString(selected, 'title') ?? 'this tile';
|
|
1788
|
+
return `Use ${target} as current-state evidence. To explain change, add or select a block with a time grain, snapshot date, or prior-period baseline, then rerun the investigation.`;
|
|
1789
|
+
}
|
|
1750
1790
|
function buildInvestigationRecommendation(intent, selected, sqlError) {
|
|
1751
1791
|
if (sqlError)
|
|
1752
1792
|
return 'Review the generated SQL or add a certified drilldown block before promoting this result.';
|
|
@@ -2451,6 +2491,16 @@ function activatePersona(projectRoot, userId, appId) {
|
|
|
2451
2491
|
return null;
|
|
2452
2492
|
}
|
|
2453
2493
|
// ---- IO utilities ----
|
|
2494
|
+
async function refreshGeneratedMetadata(projectRoot) {
|
|
2495
|
+
try {
|
|
2496
|
+
const { ensureMetadataCatalogFresh } = await import('@duckcodeailabs/dql-agent');
|
|
2497
|
+
await ensureMetadataCatalogFresh(projectRoot, { force: true });
|
|
2498
|
+
}
|
|
2499
|
+
catch {
|
|
2500
|
+
// App files remain the source of truth; the local catalog refreshes again
|
|
2501
|
+
// on the next agent/MCP call if this best-effort update fails.
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2454
2504
|
function sendJson(res, status, body) {
|
|
2455
2505
|
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8' });
|
|
2456
2506
|
res.end(JSON.stringify(body));
|