@lexq/cli 0.2.0 → 0.3.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/index.js CHANGED
@@ -13,11 +13,19 @@ import { stdin, stdout } from "process";
13
13
  import dedent from "dedent";
14
14
 
15
15
  // src/lib/config.ts
16
- import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
16
+ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
17
17
  import { homedir } from "os";
18
18
  import { join } from "path";
19
19
  var CONFIG_DIR = join(homedir(), ".lexq");
20
20
  var CONFIG_FILE = join(CONFIG_DIR, "config.json");
21
+ var DIR_MODE = 448;
22
+ var FILE_MODE = 384;
23
+ function restrict(target, mode) {
24
+ try {
25
+ chmodSync(target, mode);
26
+ } catch {
27
+ }
28
+ }
21
29
  var DEFAULT_CONFIG = {
22
30
  baseUrl: "https://api.lexq.io/api/v1/partners",
23
31
  format: "json"
@@ -33,11 +41,16 @@ function loadConfig() {
33
41
  }
34
42
  function saveConfig(config) {
35
43
  if (!existsSync(CONFIG_DIR)) {
36
- mkdirSync(CONFIG_DIR, { recursive: true });
44
+ mkdirSync(CONFIG_DIR, { recursive: true, mode: DIR_MODE });
37
45
  }
46
+ restrict(CONFIG_DIR, DIR_MODE);
38
47
  const current = loadConfig();
39
48
  const merged = { ...current, ...config };
40
- writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2), "utf-8");
49
+ writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2), {
50
+ encoding: "utf-8",
51
+ mode: FILE_MODE
52
+ });
53
+ restrict(CONFIG_FILE, FILE_MODE);
41
54
  }
42
55
  function deleteConfig() {
43
56
  if (existsSync(CONFIG_FILE)) {
@@ -3317,7 +3330,7 @@ import dedent17 from "dedent";
3317
3330
  import { readFileSync as readFileSync3 } from "fs";
3318
3331
  import { dirname, join as join2 } from "path";
3319
3332
  import { fileURLToPath } from "url";
3320
- import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
3333
+ import { serveStdio } from "@modelcontextprotocol/server/stdio";
3321
3334
  import { McpServer } from "@modelcontextprotocol/server";
3322
3335
 
3323
3336
  // src/mcp/tools/_shared.ts
@@ -4782,15 +4795,24 @@ function getVersion() {
4782
4795
  return "0.1.0";
4783
4796
  }
4784
4797
  }
4785
- async function startMcpServer() {
4786
- const server = new McpServer({
4787
- name: "lexq",
4788
- version: getVersion()
4789
- });
4798
+ function startMcpServer() {
4799
+ const version = getVersion();
4790
4800
  const callApi = createCallApiFromConfig();
4791
- registerAllTools(server, callApi);
4792
- const transport = new StdioServerTransport();
4793
- await server.connect(transport);
4801
+ serveStdio(
4802
+ () => {
4803
+ const server = new McpServer({ name: "lexq", version });
4804
+ registerAllTools(server, callApi);
4805
+ return server;
4806
+ },
4807
+ {
4808
+ /* stdout carries the protocol. Anything written there that is not a JSON-RPC message
4809
+ breaks the client's parser, so this goes to stderr — the only channel a stdio server
4810
+ can report on. Without it a transport that fails to start does so silently. */
4811
+ onerror: (error) => {
4812
+ console.error("[lexq mcp]", error.message);
4813
+ }
4814
+ }
4815
+ );
4794
4816
  }
4795
4817
 
4796
4818
  // src/commands/serve.ts
@@ -4815,14 +4837,14 @@ function registerServeCommand(program) {
4815
4837
  }
4816
4838
  }
4817
4839
  `
4818
- ).action(async (opts) => {
4840
+ ).action((opts) => {
4819
4841
  if (!opts.mcp) {
4820
4842
  console.error(
4821
4843
  "Error: --mcp flag is required.\nUsage: lexq serve --mcp\n\nStarts a stdio MCP server for Claude Desktop, Claude.ai, Gemini, etc."
4822
4844
  );
4823
4845
  process.exit(1);
4824
4846
  }
4825
- await startMcpServer();
4847
+ startMcpServer();
4826
4848
  });
4827
4849
  }
4828
4850
 
@@ -177,7 +177,7 @@ function registerGroupTools(server, callApi) {
177
177
  import { z as z3 } from "zod";
178
178
 
179
179
  // src/lib/config.ts
180
- import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
180
+ import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
181
181
  import { homedir } from "os";
182
182
  import { join } from "path";
183
183
  var CONFIG_DIR = join(homedir(), ".lexq");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexq/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "LexQ CLI — manage policies, simulate rules, and deploy from the terminal. Built for humans and AI agents.",
5
5
  "type": "module",
6
6
  "bin": {