@vaultgradient/pipequery-cli 0.13.2 → 0.14.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.
@@ -213,8 +213,7 @@ describe('createEventLogger — JSONL file output', () => {
213
213
  ];
214
214
  for (const e of events) logger.log(e);
215
215
 
216
- // Give appendFile a tick to flush.
217
- await new Promise((r) => setTimeout(r, 50));
216
+ await logger.flush();
218
217
  const content = await readFile(file, 'utf8');
219
218
  const lines = content.trim().split('\n');
220
219
  expect(lines).toHaveLength(3);
@@ -258,7 +257,7 @@ describe('createEventLogger — JSONL file output', () => {
258
257
  now: () => FIXED_TS,
259
258
  });
260
259
  logger.log({ kind: 'command', user: { id: 1 }, cmd: '/help', outcome: 'success', latencyMs: 1 });
261
- await new Promise((r) => setTimeout(r, 50));
260
+ await logger.flush();
262
261
  const obj = JSON.parse((await readFile(file, 'utf8')).trim()) as Record<string, unknown>;
263
262
  expect(obj.rowCount).toBeUndefined();
264
263
  expect(obj.error).toBeUndefined();
package/dist/index.js CHANGED
@@ -4573,6 +4573,95 @@ async function createServer(config, configPath, cwd) {
4573
4573
 
4574
4574
  // src/utils/banner.ts
4575
4575
  import chalk3 from "chalk";
4576
+
4577
+ // package.json
4578
+ var package_default = {
4579
+ name: "@andreadito/pq",
4580
+ version: "0.14.0",
4581
+ description: "CLI for PipeQuery \u2014 data sources, aggregations, APIs, and terminal dashboards",
4582
+ type: "module",
4583
+ bin: {
4584
+ pq: "./dist/index.js"
4585
+ },
4586
+ exports: {
4587
+ ".": "./dist/index.js",
4588
+ "./engine": {
4589
+ types: "./dist/engine.d.ts",
4590
+ default: "./dist/engine.js"
4591
+ },
4592
+ "./sources": {
4593
+ types: "./dist/sources/manager.d.ts",
4594
+ default: "./dist/sources/manager.js"
4595
+ }
4596
+ },
4597
+ scripts: {
4598
+ build: "tsup",
4599
+ dev: "tsup --watch",
4600
+ typecheck: "tsc",
4601
+ test: "vitest run",
4602
+ "test:watch": "vitest"
4603
+ },
4604
+ dependencies: {
4605
+ "@anthropic-ai/sdk": "^0.91.1",
4606
+ "@clickhouse/client": "^1.18.3",
4607
+ "@fastify/cors": "^11.2.0",
4608
+ "@modelcontextprotocol/sdk": "^1.31.0",
4609
+ "better-sqlite3": "^12.9.0",
4610
+ chalk: "^5.6.2",
4611
+ chokidar: "^5.0.0",
4612
+ commander: "^14.0.3",
4613
+ "csv-parse": "^7.0.2",
4614
+ fastify: "^5.12.5",
4615
+ grammy: "^1.42.0",
4616
+ ink: "^7.0.1",
4617
+ kafkajs: "^2.2.4",
4618
+ mongodb: "^7.2.0",
4619
+ mysql2: "^3.23.1",
4620
+ ora: "^9.3.0",
4621
+ pg: "^8.20.0",
4622
+ react: "^19.2.5",
4623
+ "snowflake-sdk": "^3.4.0",
4624
+ ws: "^8.21.0",
4625
+ yaml: "^2.8.3",
4626
+ zod: "^4.3.6"
4627
+ },
4628
+ devDependencies: {
4629
+ "@types/better-sqlite3": "^7.6.13",
4630
+ "@types/node": "^25.6.0",
4631
+ "@types/pg": "^8.20.0",
4632
+ "@types/react": "^19.2.14",
4633
+ "@types/ws": "^8.18.1",
4634
+ tsup: "^8.5.1",
4635
+ typescript: "~6.0.0",
4636
+ vitest: "^4.1.11"
4637
+ },
4638
+ overrides: {
4639
+ "gcp-metadata": "^8.0.0",
4640
+ esbuild: "^0.28.1",
4641
+ axios: "^1.20.0",
4642
+ "fast-uri": "^3.1.8",
4643
+ "proxy-addr": "^2.0.8",
4644
+ "source-map-js": "^1.2.2",
4645
+ "@azure/msal-node": "^5.6.0"
4646
+ },
4647
+ repository: {
4648
+ type: "git",
4649
+ url: "https://github.com/andreadito/pipequery.git",
4650
+ directory: "cli"
4651
+ },
4652
+ publishConfig: {
4653
+ access: "public",
4654
+ registry: "https://npm.pkg.github.com"
4655
+ },
4656
+ author: "andreadito",
4657
+ license: "MIT",
4658
+ engines: {
4659
+ node: ">=24"
4660
+ }
4661
+ };
4662
+
4663
+ // src/utils/banner.ts
4664
+ var { version } = package_default;
4576
4665
  var LOGO = [
4577
4666
  " \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557",
4578
4667
  " \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D",
@@ -4602,7 +4691,7 @@ function printBanner() {
4602
4691
  console.log(applyGradient(line, i));
4603
4692
  });
4604
4693
  console.log();
4605
- console.log(chalk3.dim(` v0.1.0 \u2014 data sources, aggregations, APIs, and terminal dashboards`));
4694
+ console.log(chalk3.dim(` v${version} \u2014 data sources, aggregations, APIs, and terminal dashboards`));
4606
4695
  console.log();
4607
4696
  }
4608
4697
  function printCompactBanner() {
@@ -6372,9 +6461,10 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
6372
6461
  // src/mcp/server.ts
6373
6462
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6374
6463
  import { z } from "zod";
6464
+ var { version: version2 } = package_default;
6375
6465
  var DEFAULT_INFO = {
6376
6466
  name: "pipequery",
6377
- version: "0.1.0"
6467
+ version: version2
6378
6468
  };
6379
6469
  function createMcpServer(provider, info2 = DEFAULT_INFO) {
6380
6470
  const mcp2 = new McpServer(info2);
@@ -6622,6 +6712,7 @@ async function readJsonBody(req) {
6622
6712
  // src/commands/mcp.ts
6623
6713
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
6624
6714
  import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
6715
+ var { version: version3 } = package_default;
6625
6716
  async function mcpServeCommand(opts) {
6626
6717
  const provider = await buildProvider(opts.attach);
6627
6718
  const isStdio = !opts.http;
@@ -6649,7 +6740,7 @@ async function mcpInspectCommand(opts) {
6649
6740
  const mcp2 = createMcpServer(provider);
6650
6741
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
6651
6742
  await mcp2.connect(serverTransport);
6652
- const client = new Client({ name: "pq-mcp-inspect", version: "0.1.0" });
6743
+ const client = new Client({ name: "pq-mcp-inspect", version: version3 });
6653
6744
  await client.connect(clientTransport);
6654
6745
  try {
6655
6746
  const { tools } = await client.listTools();
@@ -7328,13 +7419,17 @@ function createEventLogger(opts = {}) {
7328
7419
  const writeStderr = opts.writeStderr ?? ((line) => process.stderr.write(line));
7329
7420
  const now = opts.now ?? (() => /* @__PURE__ */ new Date());
7330
7421
  const filePath = opts.filePath;
7422
+ let chain = Promise.resolve();
7331
7423
  return {
7332
7424
  log(event) {
7333
7425
  const ts = now();
7334
7426
  writeStderr(formatPretty(event, ts) + "\n");
7335
7427
  if (filePath) {
7336
7428
  const json = JSON.stringify({ ts: ts.toISOString(), ...flattenForJson(event) });
7337
- void appendFile(filePath, json + "\n").catch((err) => {
7429
+ chain = chain.then(
7430
+ () => appendFile(filePath, json + "\n"),
7431
+ () => appendFile(filePath, json + "\n")
7432
+ ).catch((err) => {
7338
7433
  writeStderr(
7339
7434
  chalk7.hex("#ef4444")(" \u2717") + " [pipequery-telegram] log-file write failed: " + (err instanceof Error ? err.message : String(err)) + "\n"
7340
7435
  );
@@ -7342,6 +7437,7 @@ function createEventLogger(opts = {}) {
7342
7437
  }
7343
7438
  },
7344
7439
  async flush() {
7440
+ await chain;
7345
7441
  }
7346
7442
  };
7347
7443
  }
@@ -7971,9 +8067,10 @@ async function fetchAndPrint(serverUrl, path, key) {
7971
8067
  }
7972
8068
 
7973
8069
  // src/index.ts
8070
+ var { version: version4 } = package_default;
7974
8071
  var collectRepeated = (value, acc) => [...acc, value];
7975
8072
  var program = new Command();
7976
- program.name("pq").description("PipeQuery CLI \u2014 data sources, aggregations, APIs, and terminal dashboards").version("0.1.0").addHelpText("beforeAll", () => {
8073
+ program.name("pq").description("PipeQuery CLI \u2014 data sources, aggregations, APIs, and terminal dashboards").version(version4).addHelpText("beforeAll", () => {
7977
8074
  printBanner();
7978
8075
  return "";
7979
8076
  }).configureHelp({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaultgradient/pipequery-cli",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "description": "CLI for PipeQuery — data sources, aggregations, APIs, and terminal dashboards",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,6 +6,8 @@ import { runHttp } from '../mcp/http.js';
6
6
  import { createMcpServer } from '../mcp/server.js';
7
7
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
8
8
  import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
9
+ import pkg from '../../package.json' with { type: 'json' };
10
+ const { version } = pkg;
9
11
 
10
12
  interface McpServeOptions {
11
13
  http?: boolean;
@@ -53,7 +55,7 @@ export async function mcpInspectCommand(opts: { attach?: string }): Promise<void
53
55
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
54
56
  await mcp.connect(serverTransport);
55
57
 
56
- const client = new Client({ name: 'pq-mcp-inspect', version: '0.1.0' });
58
+ const client = new Client({ name: 'pq-mcp-inspect', version });
57
59
  await client.connect(clientTransport);
58
60
 
59
61
  try {
package/src/index.ts CHANGED
@@ -15,6 +15,8 @@ import { completionCommand } from './commands/completion.js';
15
15
  import { stopCommand } from './commands/stop.js';
16
16
  import { startRepl } from './commands/repl.js';
17
17
  import { printBanner } from './utils/banner.js';
18
+ import pkg from '../package.json' with { type: 'json' };
19
+ const { version } = pkg;
18
20
 
19
21
  // Commander helper: accumulate `--allow-user @a --allow-user @b` into an array.
20
22
  const collectRepeated = (value: string, acc: string[]): string[] => [...acc, value];
@@ -24,7 +26,7 @@ const program = new Command();
24
26
  program
25
27
  .name('pq')
26
28
  .description('PipeQuery CLI — data sources, aggregations, APIs, and terminal dashboards')
27
- .version('0.1.0')
29
+ .version(version)
28
30
  .addHelpText('beforeAll', () => {
29
31
  printBanner();
30
32
  return '';
package/src/mcp/server.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { z } from 'zod';
3
3
  import type { Provider } from './provider.js';
4
+ import pkg from '../../package.json' with { type: 'json' };
5
+ const { version } = pkg;
4
6
 
5
7
  export interface McpServerInfo {
6
8
  name: string;
@@ -9,7 +11,7 @@ export interface McpServerInfo {
9
11
 
10
12
  const DEFAULT_INFO: McpServerInfo = {
11
13
  name: 'pipequery',
12
- version: '0.1.0',
14
+ version,
13
15
  };
14
16
 
15
17
  /**
@@ -83,6 +83,8 @@ export function createEventLogger(opts: EventLoggerOptions = {}): EventLogger {
83
83
  const writeStderr = opts.writeStderr ?? ((line) => process.stderr.write(line));
84
84
  const now = opts.now ?? (() => new Date());
85
85
  const filePath = opts.filePath;
86
+ // Chain writes sequentially so they land on disk in log-order.
87
+ let chain: Promise<void> = Promise.resolve();
86
88
 
87
89
  return {
88
90
  log(event: BotEvent): void {
@@ -90,10 +92,13 @@ export function createEventLogger(opts: EventLoggerOptions = {}): EventLogger {
90
92
  writeStderr(formatPretty(event, ts) + '\n');
91
93
  if (filePath) {
92
94
  const json = JSON.stringify({ ts: ts.toISOString(), ...flattenForJson(event) });
93
- // Fire-and-forget write; the bot doesn't await this so a slow disk
94
- // doesn't back-pressure incoming Telegram messages. Errors surface
95
- // on stderr so a misconfigured path is visible.
96
- void appendFile(filePath, json + '\n').catch((err) => {
95
+ // Chain each append onto the previous one so ordering is preserved.
96
+ // The bot doesn't await the chain — a slow disk won't back-pressure
97
+ // incoming Telegram messages. Errors surface on stderr.
98
+ chain = chain.then(
99
+ () => appendFile(filePath, json + '\n'),
100
+ () => appendFile(filePath, json + '\n'),
101
+ ).catch((err) => {
97
102
  writeStderr(
98
103
  chalk.hex('#ef4444')(' ✗') +
99
104
  ' [pipequery-telegram] log-file write failed: ' +
@@ -104,7 +109,7 @@ export function createEventLogger(opts: EventLoggerOptions = {}): EventLogger {
104
109
  }
105
110
  },
106
111
  async flush(): Promise<void> {
107
- // Reserved for future buffering. appendFile already awaits internally.
112
+ await chain;
108
113
  },
109
114
  };
110
115
  }
@@ -1,4 +1,6 @@
1
1
  import chalk from 'chalk';
2
+ import pkg from '../../package.json' with { type: 'json' };
3
+ const { version } = pkg;
2
4
 
3
5
  const LOGO = [
4
6
  ' ██████╗ ██╗ ██████╗ ███████╗ ██████╗ ██╗ ██╗ ███████╗ ██████╗ ██╗ ██╗',
@@ -30,7 +32,7 @@ export function printBanner() {
30
32
  console.log(applyGradient(line, i));
31
33
  });
32
34
  console.log();
33
- console.log(chalk.dim(` v0.1.0 — data sources, aggregations, APIs, and terminal dashboards`));
35
+ console.log(chalk.dim(` v${version} — data sources, aggregations, APIs, and terminal dashboards`));
34
36
  console.log();
35
37
  }
36
38