@lexq/cli 0.1.5 → 0.1.7
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/index.js +93 -46
- package/dist/index.js.map +1 -1
- package/dist/mcp/register.d.ts +32 -0
- package/dist/mcp/register.js +960 -0
- package/dist/mcp/register.js.map +1 -0
- package/package.json +8 -1
package/dist/index.js
CHANGED
|
@@ -1315,6 +1315,7 @@ function registerAnalyticsCommands(program) {
|
|
|
1315
1315
|
sim.command("status").description("Get simulation status and results").requiredOption("--id <simulationId>", "Simulation ID").action(async (opts) => {
|
|
1316
1316
|
try {
|
|
1317
1317
|
const globalOpts = program.opts();
|
|
1318
|
+
const format = globalOpts.format ?? "json";
|
|
1318
1319
|
const data = await apiRequest(
|
|
1319
1320
|
"GET",
|
|
1320
1321
|
`analytics/simulations/${opts.id}`,
|
|
@@ -1325,7 +1326,48 @@ function registerAnalyticsCommands(program) {
|
|
|
1325
1326
|
verbose: globalOpts.verbose
|
|
1326
1327
|
}
|
|
1327
1328
|
);
|
|
1328
|
-
|
|
1329
|
+
if (format === "table") {
|
|
1330
|
+
console.log(`Status: ${data.status}`);
|
|
1331
|
+
console.log(`Progress: ${data.progress}%`);
|
|
1332
|
+
if (data.summary) {
|
|
1333
|
+
console.log(`
|
|
1334
|
+
\u2500\u2500 Summary \u2500\u2500`);
|
|
1335
|
+
console.log(`Records: ${data.summary.totalRecords.toLocaleString()}`);
|
|
1336
|
+
console.log(`Matched: ${data.summary.matchedRecords.toLocaleString()}`);
|
|
1337
|
+
console.log(`Match Rate: ${data.summary.matchRate.toFixed(1)}%`);
|
|
1338
|
+
console.log(`Time: ${data.summary.executionTimeMs.toLocaleString()}ms`);
|
|
1339
|
+
}
|
|
1340
|
+
if (data.metricSummary) {
|
|
1341
|
+
console.log(`
|
|
1342
|
+
\u2500\u2500 Metric: ${data.metricSummary.targetVariable} (${data.metricSummary.aggregationType}) \u2500\u2500`);
|
|
1343
|
+
console.log(`Baseline: ${data.metricSummary.baselineValue.toLocaleString()}`);
|
|
1344
|
+
console.log(`Simulated: ${data.metricSummary.simulatedValue.toLocaleString()}`);
|
|
1345
|
+
console.log(`Delta: ${data.metricSummary.delta > 0 ? "+" : ""}${data.metricSummary.delta.toLocaleString()}`);
|
|
1346
|
+
console.log(`Change: ${data.metricSummary.deltaPercentage > 0 ? "+" : ""}${data.metricSummary.deltaPercentage.toFixed(1)}%`);
|
|
1347
|
+
}
|
|
1348
|
+
if (data.policyImpact?.comparison) {
|
|
1349
|
+
const diff = data.policyImpact.comparison.difference;
|
|
1350
|
+
console.log(`
|
|
1351
|
+
\u2500\u2500 Impact \u2500\u2500`);
|
|
1352
|
+
console.log(`Matched \u0394: ${diff.matchedCountDelta > 0 ? "+" : ""}${diff.matchedCountDelta}`);
|
|
1353
|
+
console.log(`Rate \u0394: ${diff.matchedRateDelta > 0 ? "+" : ""}${diff.matchedRateDelta.toFixed(1)}%`);
|
|
1354
|
+
console.log(`Metric \u0394: ${diff.metricValueDelta > 0 ? "+" : ""}${diff.metricValueDelta.toLocaleString()}`);
|
|
1355
|
+
}
|
|
1356
|
+
if (data.ruleStats?.length) {
|
|
1357
|
+
console.log("");
|
|
1358
|
+
printTable(
|
|
1359
|
+
["Rule", "Matched", "Metric"],
|
|
1360
|
+
data.ruleStats.map((r) => [
|
|
1361
|
+
r.ruleName,
|
|
1362
|
+
r.matchedCount.toLocaleString(),
|
|
1363
|
+
r.metricValue.toLocaleString()
|
|
1364
|
+
]),
|
|
1365
|
+
{ truncate: 30 }
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
} else {
|
|
1369
|
+
printJson(data);
|
|
1370
|
+
}
|
|
1329
1371
|
} catch (error) {
|
|
1330
1372
|
printError(error);
|
|
1331
1373
|
process.exit(1);
|
|
@@ -1361,7 +1403,7 @@ function registerAnalyticsCommands(program) {
|
|
|
1361
1403
|
s.policyGroupName,
|
|
1362
1404
|
s.targetVersionName ?? "\u2013",
|
|
1363
1405
|
s.status,
|
|
1364
|
-
`${
|
|
1406
|
+
`${s.matchRate.toFixed(1)}%`,
|
|
1365
1407
|
String(s.totalRecords),
|
|
1366
1408
|
s.createdAt.substring(0, 16)
|
|
1367
1409
|
]),
|
|
@@ -1843,32 +1885,31 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
1843
1885
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1844
1886
|
|
|
1845
1887
|
// src/mcp/tools/_shared.ts
|
|
1846
|
-
function
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1888
|
+
function createCallApiFromConfig() {
|
|
1889
|
+
return async (method, path, opts) => {
|
|
1890
|
+
try {
|
|
1891
|
+
const config = loadConfig();
|
|
1892
|
+
const clientOpts = {
|
|
1893
|
+
apiKey: config.apiKey,
|
|
1894
|
+
baseUrl: config.baseUrl
|
|
1895
|
+
};
|
|
1896
|
+
const data = await apiRequest(method, path, {
|
|
1897
|
+
...clientOpts,
|
|
1898
|
+
body: opts?.body,
|
|
1899
|
+
params: opts?.params
|
|
1900
|
+
});
|
|
1901
|
+
return {
|
|
1902
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
1903
|
+
};
|
|
1904
|
+
} catch (error) {
|
|
1905
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1906
|
+
return {
|
|
1907
|
+
content: [{ type: "text", text: JSON.stringify({ error: message }) }],
|
|
1908
|
+
isError: true
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1851
1911
|
};
|
|
1852
1912
|
}
|
|
1853
|
-
async function callApi(method, path, opts) {
|
|
1854
|
-
try {
|
|
1855
|
-
const clientOpts = getMcpClientOptions();
|
|
1856
|
-
const data = await apiRequest(method, path, {
|
|
1857
|
-
...clientOpts,
|
|
1858
|
-
body: opts?.body,
|
|
1859
|
-
params: opts?.params
|
|
1860
|
-
});
|
|
1861
|
-
return {
|
|
1862
|
-
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
1863
|
-
};
|
|
1864
|
-
} catch (error) {
|
|
1865
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1866
|
-
return {
|
|
1867
|
-
content: [{ type: "text", text: JSON.stringify({ error: message }) }],
|
|
1868
|
-
isError: true
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
1913
|
function paginationParams(page, size) {
|
|
1873
1914
|
const params = {};
|
|
1874
1915
|
if (page !== void 0) params.page = String(page);
|
|
@@ -1877,7 +1918,7 @@ function paginationParams(page, size) {
|
|
|
1877
1918
|
}
|
|
1878
1919
|
|
|
1879
1920
|
// src/mcp/tools/status.ts
|
|
1880
|
-
function registerStatusTools(server) {
|
|
1921
|
+
function registerStatusTools(server, callApi) {
|
|
1881
1922
|
server.registerTool(
|
|
1882
1923
|
"lexq_whoami",
|
|
1883
1924
|
{
|
|
@@ -1891,7 +1932,7 @@ function registerStatusTools(server) {
|
|
|
1891
1932
|
|
|
1892
1933
|
// src/mcp/tools/groups.ts
|
|
1893
1934
|
import { z } from "zod";
|
|
1894
|
-
function registerGroupTools(server) {
|
|
1935
|
+
function registerGroupTools(server, callApi) {
|
|
1895
1936
|
server.registerTool(
|
|
1896
1937
|
"lexq_groups_list",
|
|
1897
1938
|
{
|
|
@@ -2026,7 +2067,7 @@ function registerGroupTools(server) {
|
|
|
2026
2067
|
|
|
2027
2068
|
// src/mcp/tools/versions.ts
|
|
2028
2069
|
import { z as z2 } from "zod";
|
|
2029
|
-
function registerVersionTools(server) {
|
|
2070
|
+
function registerVersionTools(server, callApi) {
|
|
2030
2071
|
server.registerTool(
|
|
2031
2072
|
"lexq_versions_list",
|
|
2032
2073
|
{
|
|
@@ -2118,7 +2159,7 @@ function registerVersionTools(server) {
|
|
|
2118
2159
|
|
|
2119
2160
|
// src/mcp/tools/rules.ts
|
|
2120
2161
|
import { z as z3 } from "zod";
|
|
2121
|
-
function registerRuleTools(server) {
|
|
2162
|
+
function registerRuleTools(server, callApi) {
|
|
2122
2163
|
server.registerTool(
|
|
2123
2164
|
"lexq_rules_list",
|
|
2124
2165
|
{
|
|
@@ -2270,7 +2311,7 @@ Types: DISCOUNT, POINT, COUPON_ISSUE, BLOCK, NOTIFICATION, WEBHOOK, SET_FACT, AD
|
|
|
2270
2311
|
|
|
2271
2312
|
// src/mcp/tools/facts.ts
|
|
2272
2313
|
import { z as z4 } from "zod";
|
|
2273
|
-
function registerFactTools(server) {
|
|
2314
|
+
function registerFactTools(server, callApi) {
|
|
2274
2315
|
server.registerTool(
|
|
2275
2316
|
"lexq_facts_list",
|
|
2276
2317
|
{
|
|
@@ -2332,7 +2373,7 @@ function registerFactTools(server) {
|
|
|
2332
2373
|
|
|
2333
2374
|
// src/mcp/tools/deploy.ts
|
|
2334
2375
|
import { z as z5 } from "zod";
|
|
2335
|
-
function registerDeployTools(server) {
|
|
2376
|
+
function registerDeployTools(server, callApi) {
|
|
2336
2377
|
server.registerTool(
|
|
2337
2378
|
"lexq_deploy_publish",
|
|
2338
2379
|
{
|
|
@@ -2436,7 +2477,7 @@ function registerDeployTools(server) {
|
|
|
2436
2477
|
|
|
2437
2478
|
// src/mcp/tools/analytics.ts
|
|
2438
2479
|
import { z as z6 } from "zod";
|
|
2439
|
-
function registerAnalyticsTools(server) {
|
|
2480
|
+
function registerAnalyticsTools(server, callApi) {
|
|
2440
2481
|
server.registerTool(
|
|
2441
2482
|
"lexq_dry_run",
|
|
2442
2483
|
{
|
|
@@ -2575,7 +2616,7 @@ Example body:
|
|
|
2575
2616
|
|
|
2576
2617
|
// src/mcp/tools/history.ts
|
|
2577
2618
|
import { z as z7 } from "zod";
|
|
2578
|
-
function registerHistoryTools(server) {
|
|
2619
|
+
function registerHistoryTools(server, callApi) {
|
|
2579
2620
|
server.registerTool(
|
|
2580
2621
|
"lexq_history_list",
|
|
2581
2622
|
{
|
|
@@ -2637,7 +2678,7 @@ function registerHistoryTools(server) {
|
|
|
2637
2678
|
|
|
2638
2679
|
// src/mcp/tools/integrations.ts
|
|
2639
2680
|
import { z as z8 } from "zod";
|
|
2640
|
-
function registerIntegrationTools(server) {
|
|
2681
|
+
function registerIntegrationTools(server, callApi) {
|
|
2641
2682
|
server.registerTool(
|
|
2642
2683
|
"lexq_integrations_list",
|
|
2643
2684
|
{
|
|
@@ -2710,7 +2751,7 @@ function registerIntegrationTools(server) {
|
|
|
2710
2751
|
|
|
2711
2752
|
// src/mcp/tools/logs.ts
|
|
2712
2753
|
import { z as z9 } from "zod";
|
|
2713
|
-
function registerLogTools(server) {
|
|
2754
|
+
function registerLogTools(server, callApi) {
|
|
2714
2755
|
server.registerTool(
|
|
2715
2756
|
"lexq_logs_list",
|
|
2716
2757
|
{
|
|
@@ -2779,6 +2820,20 @@ function registerLogTools(server) {
|
|
|
2779
2820
|
);
|
|
2780
2821
|
}
|
|
2781
2822
|
|
|
2823
|
+
// src/mcp/register.ts
|
|
2824
|
+
function registerAllTools(server, callApi) {
|
|
2825
|
+
registerStatusTools(server, callApi);
|
|
2826
|
+
registerGroupTools(server, callApi);
|
|
2827
|
+
registerVersionTools(server, callApi);
|
|
2828
|
+
registerRuleTools(server, callApi);
|
|
2829
|
+
registerFactTools(server, callApi);
|
|
2830
|
+
registerDeployTools(server, callApi);
|
|
2831
|
+
registerAnalyticsTools(server, callApi);
|
|
2832
|
+
registerHistoryTools(server, callApi);
|
|
2833
|
+
registerIntegrationTools(server, callApi);
|
|
2834
|
+
registerLogTools(server, callApi);
|
|
2835
|
+
}
|
|
2836
|
+
|
|
2782
2837
|
// src/mcp/server.ts
|
|
2783
2838
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
2784
2839
|
function getVersion() {
|
|
@@ -2796,16 +2851,8 @@ async function startMcpServer() {
|
|
|
2796
2851
|
name: "lexq",
|
|
2797
2852
|
version: getVersion()
|
|
2798
2853
|
});
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
registerVersionTools(server);
|
|
2802
|
-
registerRuleTools(server);
|
|
2803
|
-
registerFactTools(server);
|
|
2804
|
-
registerDeployTools(server);
|
|
2805
|
-
registerAnalyticsTools(server);
|
|
2806
|
-
registerHistoryTools(server);
|
|
2807
|
-
registerIntegrationTools(server);
|
|
2808
|
-
registerLogTools(server);
|
|
2854
|
+
const callApi = createCallApiFromConfig();
|
|
2855
|
+
registerAllTools(server, callApi);
|
|
2809
2856
|
const transport = new StdioServerTransport();
|
|
2810
2857
|
await server.connect(transport);
|
|
2811
2858
|
}
|