jinzd-ai-cli 0.4.83 → 0.4.84

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.
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ConfigManager
4
- } from "./chunk-AQDUA2NT.js";
4
+ } from "./chunk-V6ZENAVD.js";
5
5
  import "./chunk-2ZD3YTVM.js";
6
- import "./chunk-MNL53XPD.js";
6
+ import "./chunk-3BLU2654.js";
7
7
 
8
8
  // src/cli/batch.ts
9
9
  import Anthropic from "@anthropic-ai/sdk";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/core/constants.ts
4
- var VERSION = "0.4.83";
4
+ var VERSION = "0.4.84";
5
5
  var APP_NAME = "ai-cli";
6
6
  var CONFIG_DIR_NAME = ".aicli";
7
7
  var CONFIG_FILE_NAME = "config.json";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  TEST_TIMEOUT
4
- } from "./chunk-MNL53XPD.js";
4
+ } from "./chunk-3BLU2654.js";
5
5
 
6
6
  // src/tools/builtin/run-tests.ts
7
7
  import { execSync } from "child_process";
@@ -6,7 +6,7 @@ import { platform } from "os";
6
6
  import chalk from "chalk";
7
7
 
8
8
  // src/core/constants.ts
9
- var VERSION = "0.4.83";
9
+ var VERSION = "0.4.84";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -19,7 +19,7 @@ import {
19
19
  } from "./chunk-6VRJGH25.js";
20
20
  import {
21
21
  runTestsTool
22
- } from "./chunk-BXN2BJAI.js";
22
+ } from "./chunk-6WKHRV3J.js";
23
23
  import {
24
24
  CONFIG_DIR_NAME,
25
25
  DEFAULT_MAX_TOOL_OUTPUT_CHARS_CAP,
@@ -27,7 +27,56 @@ import {
27
27
  SUBAGENT_ALLOWED_TOOLS,
28
28
  SUBAGENT_DEFAULT_MAX_ROUNDS,
29
29
  SUBAGENT_MAX_ROUNDS_LIMIT
30
- } from "./chunk-MNL53XPD.js";
30
+ } from "./chunk-3BLU2654.js";
31
+
32
+ // src/tools/types.ts
33
+ function isFileWriteTool(name) {
34
+ return name === "write_file" || name === "edit_file" || name === "notebook_edit";
35
+ }
36
+ function getDangerLevel(toolName, args) {
37
+ if (toolName.startsWith("mcp__")) return "safe";
38
+ if (toolName === "bash") {
39
+ const cmd = String(args["command"] ?? "");
40
+ if (/\brm\s+[^\n]*(?:-\w*[rRfF]\w*|--recursive|--force)\b/.test(cmd)) return "destructive";
41
+ if (/\brm\s+\S/.test(cmd)) return "destructive";
42
+ if (/\brmdir\b|\bformat\b|\bmkfs\b/.test(cmd)) return "destructive";
43
+ if (/\bRemove-Item\b.*(?:-Recurse|-Force)|\bri\s+.*-(?:Recurse|Force)\b|\brd\s+\/s\b|\brmdir\s+\/s\b/i.test(cmd)) return "destructive";
44
+ if (/\bdel\s+\S/.test(cmd)) return "destructive";
45
+ if (/\becho\b.*>>?|\btee\b|\bcp\b|\bmv\b/.test(cmd)) return "write";
46
+ if (/\bSet-Content\b|\bOut-File\b|\bAdd-Content\b|\bCopy-Item\b|\bMove-Item\b/i.test(cmd)) return "write";
47
+ return "safe";
48
+ }
49
+ if (toolName === "write_file") return "write";
50
+ if (toolName === "edit_file") return "write";
51
+ if (toolName === "save_last_response") return "write";
52
+ if (toolName === "run_interactive") {
53
+ const exe = String(args["executable"] ?? "").toLowerCase();
54
+ if (/\b(rm|rmdir|del|format|mkfs|Remove-Item)\b/i.test(exe)) return "destructive";
55
+ if (/\b(bash|sh|zsh|cmd|powershell|pwsh|python|node|ruby|perl)\b/i.test(exe)) return "write";
56
+ return "write";
57
+ }
58
+ if (toolName === "task_create" || toolName === "task_stop") return "write";
59
+ if (toolName === "task_list") return "safe";
60
+ if (toolName === "git_commit") return "write";
61
+ if (toolName === "git_status" || toolName === "git_diff" || toolName === "git_log") return "safe";
62
+ if (toolName === "notebook_edit") return "write";
63
+ if (toolName === "read_file" || toolName === "list_dir" || toolName === "grep_files" || toolName === "glob_files" || toolName === "web_fetch" || toolName === "save_memory" || toolName === "ask_user" || toolName === "write_todos" || toolName === "google_search" || toolName === "spawn_agent" || toolName === "run_tests") return "safe";
64
+ return "write";
65
+ }
66
+ function schemaToJsonSchema(schema) {
67
+ const result = {
68
+ type: schema.type,
69
+ description: schema.description
70
+ };
71
+ if (schema.enum) result["enum"] = schema.enum;
72
+ if (schema.items) result["items"] = schemaToJsonSchema(schema.items);
73
+ if (schema.properties) {
74
+ result["properties"] = Object.fromEntries(
75
+ Object.entries(schema.properties).map(([k, v]) => [k, schemaToJsonSchema(v)])
76
+ );
77
+ }
78
+ return result;
79
+ }
31
80
 
32
81
  // src/tools/builtin/bash.ts
33
82
  import { execSync } from "child_process";
@@ -760,55 +809,6 @@ function rlInternal(rl) {
760
809
  return rl;
761
810
  }
762
811
 
763
- // src/tools/types.ts
764
- function isFileWriteTool(name) {
765
- return name === "write_file" || name === "edit_file" || name === "notebook_edit";
766
- }
767
- function getDangerLevel(toolName, args) {
768
- if (toolName.startsWith("mcp__")) return "safe";
769
- if (toolName === "bash") {
770
- const cmd = String(args["command"] ?? "");
771
- if (/\brm\s+[^\n]*(?:-\w*[rRfF]\w*|--recursive|--force)\b/.test(cmd)) return "destructive";
772
- if (/\brm\s+\S/.test(cmd)) return "destructive";
773
- if (/\brmdir\b|\bformat\b|\bmkfs\b/.test(cmd)) return "destructive";
774
- if (/\bRemove-Item\b.*(?:-Recurse|-Force)|\bri\s+.*-(?:Recurse|Force)\b|\brd\s+\/s\b|\brmdir\s+\/s\b/i.test(cmd)) return "destructive";
775
- if (/\bdel\s+\S/.test(cmd)) return "destructive";
776
- if (/\becho\b.*>>?|\btee\b|\bcp\b|\bmv\b/.test(cmd)) return "write";
777
- if (/\bSet-Content\b|\bOut-File\b|\bAdd-Content\b|\bCopy-Item\b|\bMove-Item\b/i.test(cmd)) return "write";
778
- return "safe";
779
- }
780
- if (toolName === "write_file") return "write";
781
- if (toolName === "edit_file") return "write";
782
- if (toolName === "save_last_response") return "write";
783
- if (toolName === "run_interactive") {
784
- const exe = String(args["executable"] ?? "").toLowerCase();
785
- if (/\b(rm|rmdir|del|format|mkfs|Remove-Item)\b/i.test(exe)) return "destructive";
786
- if (/\b(bash|sh|zsh|cmd|powershell|pwsh|python|node|ruby|perl)\b/i.test(exe)) return "write";
787
- return "write";
788
- }
789
- if (toolName === "task_create" || toolName === "task_stop") return "write";
790
- if (toolName === "task_list") return "safe";
791
- if (toolName === "git_commit") return "write";
792
- if (toolName === "git_status" || toolName === "git_diff" || toolName === "git_log") return "safe";
793
- if (toolName === "notebook_edit") return "write";
794
- if (toolName === "read_file" || toolName === "list_dir" || toolName === "grep_files" || toolName === "glob_files" || toolName === "web_fetch" || toolName === "save_memory" || toolName === "ask_user" || toolName === "write_todos" || toolName === "google_search" || toolName === "spawn_agent" || toolName === "run_tests") return "safe";
795
- return "write";
796
- }
797
- function schemaToJsonSchema(schema) {
798
- const result = {
799
- type: schema.type,
800
- description: schema.description
801
- };
802
- if (schema.enum) result["enum"] = schema.enum;
803
- if (schema.items) result["items"] = schemaToJsonSchema(schema.items);
804
- if (schema.properties) {
805
- result["properties"] = Object.fromEntries(
806
- Object.entries(schema.properties).map(([k, v]) => [k, schemaToJsonSchema(v)])
807
- );
808
- }
809
- return result;
810
- }
811
-
812
812
  // src/tools/executor-phases.ts
813
813
  function groupCallsByPhase(calls) {
814
814
  const safeParallel = [];
@@ -8,7 +8,7 @@ import {
8
8
  CONFIG_FILE_NAME,
9
9
  HISTORY_DIR_NAME,
10
10
  PLUGINS_DIR_NAME
11
- } from "./chunk-MNL53XPD.js";
11
+ } from "./chunk-3BLU2654.js";
12
12
 
13
13
  // src/config/config-manager.ts
14
14
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  schemaToJsonSchema,
4
4
  truncateForPersist
5
- } from "./chunk-H3CIS4XQ.js";
5
+ } from "./chunk-UJPR6N6O.js";
6
6
  import {
7
7
  AuthError,
8
8
  ProviderError,
@@ -18,7 +18,7 @@ import {
18
18
  MCP_PROTOCOL_VERSION,
19
19
  MCP_TOOL_PREFIX,
20
20
  VERSION
21
- } from "./chunk-MNL53XPD.js";
21
+ } from "./chunk-3BLU2654.js";
22
22
 
23
23
  // src/providers/claude.ts
24
24
  import Anthropic from "@anthropic-ai/sdk";
@@ -36,7 +36,7 @@ import {
36
36
  VERSION,
37
37
  buildUserIdentityPrompt,
38
38
  runTestsTool
39
- } from "./chunk-HF47VUGH.js";
39
+ } from "./chunk-E7G3QCMU.js";
40
40
  import {
41
41
  hasSemanticIndex,
42
42
  semanticSearch
@@ -11070,7 +11070,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
11070
11070
  case "test": {
11071
11071
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
11072
11072
  try {
11073
- const { executeTests } = await import("./run-tests-P2OZOWXA.js");
11073
+ const { executeTests } = await import("./run-tests-JFREA67C.js");
11074
11074
  const argStr = args.join(" ").trim();
11075
11075
  let testArgs = {};
11076
11076
  if (argStr) {
@@ -385,7 +385,7 @@ ${content}`);
385
385
  }
386
386
  }
387
387
  async function runTaskMode(config, providers, configManager, topic) {
388
- const { TaskOrchestrator } = await import("./task-orchestrator-TT5F2OBH.js");
388
+ const { TaskOrchestrator } = await import("./task-orchestrator-24TW64OU.js");
389
389
  const orchestrator = new TaskOrchestrator(config, providers, configManager);
390
390
  let interrupted = false;
391
391
  const onSigint = () => {
package/dist/index.js CHANGED
@@ -30,10 +30,10 @@ import {
30
30
  saveDevState,
31
31
  sessionHasMeaningfulContent,
32
32
  setupProxy
33
- } from "./chunk-SEUAEDAI.js";
33
+ } from "./chunk-YY7EPHN4.js";
34
34
  import {
35
35
  ConfigManager
36
- } from "./chunk-AQDUA2NT.js";
36
+ } from "./chunk-V6ZENAVD.js";
37
37
  import {
38
38
  ToolExecutor,
39
39
  ToolRegistry,
@@ -49,7 +49,7 @@ import {
49
49
  spawnAgentContext,
50
50
  theme,
51
51
  undoStack
52
- } from "./chunk-H3CIS4XQ.js";
52
+ } from "./chunk-UJPR6N6O.js";
53
53
  import "./chunk-2ZD3YTVM.js";
54
54
  import {
55
55
  fileCheckpoints
@@ -58,7 +58,7 @@ import "./chunk-NHNWUBXB.js";
58
58
  import "./chunk-CQQQFNND.js";
59
59
  import "./chunk-6VRJGH25.js";
60
60
  import "./chunk-PFYAAX2S.js";
61
- import "./chunk-BXN2BJAI.js";
61
+ import "./chunk-6WKHRV3J.js";
62
62
  import {
63
63
  AGENTIC_BEHAVIOR_GUIDELINE,
64
64
  AUTHOR,
@@ -80,7 +80,7 @@ import {
80
80
  SKILLS_DIR_NAME,
81
81
  VERSION,
82
82
  buildUserIdentityPrompt
83
- } from "./chunk-MNL53XPD.js";
83
+ } from "./chunk-3BLU2654.js";
84
84
 
85
85
  // src/index.ts
86
86
  import { program } from "commander";
@@ -2592,7 +2592,7 @@ ${hint}` : "")
2592
2592
  usage: "/test [command|filter]",
2593
2593
  async execute(args, ctx) {
2594
2594
  try {
2595
- const { executeTests } = await import("./run-tests-6ABISSWK.js");
2595
+ const { executeTests } = await import("./run-tests-N4PJMRDQ.js");
2596
2596
  const argStr = args.join(" ").trim();
2597
2597
  let testArgs = {};
2598
2598
  if (argStr) {
@@ -6485,7 +6485,7 @@ program.command("web").description("Start Web UI server with browser-based chat
6485
6485
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
6486
6486
  process.exit(1);
6487
6487
  }
6488
- const { startWebServer } = await import("./server-J2G6B6LP.js");
6488
+ const { startWebServer } = await import("./server-6QLOHAJJ.js");
6489
6489
  await startWebServer({ port, host: options.host });
6490
6490
  });
6491
6491
  program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
@@ -6608,7 +6608,7 @@ program.command("sessions").description("List recent conversation sessions").act
6608
6608
  });
6609
6609
  program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
6610
6610
  try {
6611
- const batch = await import("./batch-KMEDSLFU.js");
6611
+ const batch = await import("./batch-QAIJGCG3.js");
6612
6612
  switch (action) {
6613
6613
  case "submit":
6614
6614
  if (!arg) {
@@ -6650,6 +6650,14 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
6650
6650
  process.exit(1);
6651
6651
  }
6652
6652
  });
6653
+ program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow destructive tools (bash rm, etc.) \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory for tool execution (default: current directory)").action(async (options) => {
6654
+ const { startMcpServer } = await import("./server-EGK4ASC7.js");
6655
+ await startMcpServer({
6656
+ allowDestructive: !!options.allowDestructive,
6657
+ tools: options.tools ? options.tools.split(",").map((s) => s.trim()).filter(Boolean) : void 0,
6658
+ cwd: options.cwd
6659
+ });
6660
+ });
6653
6661
  program.command("help").description("Show a comprehensive guide to all aicli features and commands").action(() => {
6654
6662
  const B = "\x1B[1m";
6655
6663
  const D = "\x1B[2m";
@@ -6676,6 +6684,7 @@ program.command("help").description("Show a comprehensive guide to all aicli fea
6676
6684
  ` ${G}aicli sessions${R} List recent conversation sessions`,
6677
6685
  ` ${G}aicli user <action>${R} User management (list/create/delete)`,
6678
6686
  ` ${G}aicli batch <action>${R} Anthropic Batches API (50% off, 24h): submit/list/status/results/cancel`,
6687
+ ` ${G}aicli mcp-serve${R} MCP server over STDIO (expose tools to Claude Desktop / Cursor)`,
6679
6688
  "",
6680
6689
  `${B}${C} \u25A0 STARTUP OPTIONS${R}`,
6681
6690
  ` ${Y}--provider <name>${R} Set AI provider`,
@@ -6768,7 +6777,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
6768
6777
  }),
6769
6778
  config.get("customProviders")
6770
6779
  );
6771
- const { startHub } = await import("./hub-DZMTUFKU.js");
6780
+ const { startHub } = await import("./hub-MP66YGSM.js");
6772
6781
  await startHub(
6773
6782
  {
6774
6783
  topic: topic ?? "",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-HF47VUGH.js";
4
+ } from "./chunk-E7G3QCMU.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-BXN2BJAI.js";
6
- import "./chunk-MNL53XPD.js";
5
+ } from "./chunk-6WKHRV3J.js";
6
+ import "./chunk-3BLU2654.js";
7
7
  export {
8
8
  executeTests,
9
9
  runTestsTool
@@ -20,10 +20,10 @@ import {
20
20
  persistToolRound,
21
21
  rebuildExtraMessages,
22
22
  setupProxy
23
- } from "./chunk-SEUAEDAI.js";
23
+ } from "./chunk-YY7EPHN4.js";
24
24
  import {
25
25
  ConfigManager
26
- } from "./chunk-AQDUA2NT.js";
26
+ } from "./chunk-V6ZENAVD.js";
27
27
  import {
28
28
  ToolExecutor,
29
29
  ToolRegistry,
@@ -41,14 +41,14 @@ import {
41
41
  spawnAgentContext,
42
42
  truncateOutput,
43
43
  undoStack
44
- } from "./chunk-H3CIS4XQ.js";
44
+ } from "./chunk-UJPR6N6O.js";
45
45
  import "./chunk-2ZD3YTVM.js";
46
46
  import "./chunk-4BKXL7SM.js";
47
47
  import "./chunk-NHNWUBXB.js";
48
48
  import "./chunk-CQQQFNND.js";
49
49
  import "./chunk-6VRJGH25.js";
50
50
  import "./chunk-PFYAAX2S.js";
51
- import "./chunk-BXN2BJAI.js";
51
+ import "./chunk-6WKHRV3J.js";
52
52
  import {
53
53
  AGENTIC_BEHAVIOR_GUIDELINE,
54
54
  AUTHOR,
@@ -67,7 +67,7 @@ import {
67
67
  SKILLS_DIR_NAME,
68
68
  VERSION,
69
69
  buildUserIdentityPrompt
70
- } from "./chunk-MNL53XPD.js";
70
+ } from "./chunk-3BLU2654.js";
71
71
  import {
72
72
  AuthManager
73
73
  } from "./chunk-BYNY5JPB.js";
@@ -2229,7 +2229,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
2229
2229
  case "test": {
2230
2230
  this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
2231
2231
  try {
2232
- const { executeTests } = await import("./run-tests-6ABISSWK.js");
2232
+ const { executeTests } = await import("./run-tests-N4PJMRDQ.js");
2233
2233
  const argStr = args.join(" ").trim();
2234
2234
  let testArgs = {};
2235
2235
  if (argStr) {
@@ -0,0 +1,187 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ToolRegistry,
4
+ getDangerLevel,
5
+ schemaToJsonSchema
6
+ } from "./chunk-UJPR6N6O.js";
7
+ import "./chunk-2ZD3YTVM.js";
8
+ import "./chunk-4BKXL7SM.js";
9
+ import "./chunk-NHNWUBXB.js";
10
+ import "./chunk-CQQQFNND.js";
11
+ import "./chunk-6VRJGH25.js";
12
+ import "./chunk-PFYAAX2S.js";
13
+ import "./chunk-6WKHRV3J.js";
14
+ import {
15
+ VERSION
16
+ } from "./chunk-3BLU2654.js";
17
+
18
+ // src/mcp/server.ts
19
+ import { createInterface } from "readline";
20
+ var STDIN_TOOLS = /* @__PURE__ */ new Set(["ask_user", "spawn_agent"]);
21
+ var McpServer = class {
22
+ registry;
23
+ opts;
24
+ initialized = false;
25
+ constructor(registry, opts = {}) {
26
+ this.registry = registry;
27
+ this.opts = opts;
28
+ }
29
+ async start() {
30
+ if (this.opts.cwd) {
31
+ try {
32
+ process.chdir(this.opts.cwd);
33
+ } catch {
34
+ }
35
+ }
36
+ const rl = createInterface({ input: process.stdin, crlfDelay: Infinity });
37
+ rl.on("line", async (line) => {
38
+ const trimmed = line.trim();
39
+ if (!trimmed) return;
40
+ let msg;
41
+ try {
42
+ msg = JSON.parse(trimmed);
43
+ } catch {
44
+ this.sendError(null, -32700, "Parse error");
45
+ return;
46
+ }
47
+ await this.dispatch(msg);
48
+ });
49
+ rl.on("close", () => process.exit(0));
50
+ process.stdin.resume();
51
+ this.log(`aicli MCP server v${VERSION} started. Listening on STDIO.`);
52
+ }
53
+ // ── dispatcher ─────────────────────────────────────────────────────────────
54
+ async dispatch(msg) {
55
+ const id = "id" in msg ? msg["id"] : void 0;
56
+ const method = msg["method"];
57
+ const params = msg["params"] ?? {};
58
+ if (id === void 0) {
59
+ if (method === "notifications/initialized") this.initialized = true;
60
+ return;
61
+ }
62
+ if (!method) {
63
+ this.sendError(id, -32600, "Invalid request: missing method");
64
+ return;
65
+ }
66
+ try {
67
+ switch (method) {
68
+ case "initialize":
69
+ this.handleInitialize(id, params);
70
+ break;
71
+ case "tools/list":
72
+ this.handleToolsList(id);
73
+ break;
74
+ case "tools/call":
75
+ await this.handleToolCall(id, params);
76
+ break;
77
+ case "ping":
78
+ this.sendResult(id, {});
79
+ break;
80
+ default:
81
+ this.sendError(id, -32601, `Method not found: ${method}`);
82
+ }
83
+ } catch (err) {
84
+ const msg2 = err instanceof Error ? err.message : String(err);
85
+ this.sendError(id, -32603, `Internal error: ${msg2}`);
86
+ }
87
+ }
88
+ // ── handlers ───────────────────────────────────────────────────────────────
89
+ handleInitialize(id, _params) {
90
+ this.sendResult(id, {
91
+ protocolVersion: "2024-11-05",
92
+ capabilities: { tools: {} },
93
+ serverInfo: { name: "aicli", version: VERSION }
94
+ });
95
+ }
96
+ handleToolsList(id) {
97
+ const tools = this.eligibleTools();
98
+ const list = tools.map((tool) => {
99
+ const params = tool.definition.parameters;
100
+ const properties = {};
101
+ const required = [];
102
+ for (const [key, schema] of Object.entries(params)) {
103
+ properties[key] = schemaToJsonSchema(schema);
104
+ if (schema.required) required.push(key);
105
+ }
106
+ return {
107
+ name: tool.definition.name,
108
+ description: tool.definition.description,
109
+ inputSchema: {
110
+ type: "object",
111
+ properties,
112
+ ...required.length > 0 ? { required } : {}
113
+ }
114
+ };
115
+ });
116
+ this.sendResult(id, { tools: list });
117
+ }
118
+ async handleToolCall(id, params) {
119
+ const name = params["name"];
120
+ const args = params["arguments"] ?? {};
121
+ if (!name) {
122
+ this.sendError(id, -32602, "Missing required param: name");
123
+ return;
124
+ }
125
+ const tool = this.registry.get(name);
126
+ if (!tool) {
127
+ this.sendError(id, -32602, `Unknown tool: ${name}`);
128
+ return;
129
+ }
130
+ const level = getDangerLevel(name, args);
131
+ if (level === "destructive" && !this.opts.allowDestructive) {
132
+ this.sendResult(id, {
133
+ content: [{ type: "text", text: `Tool '${name}' is destructive. Restart aicli mcp-serve with --allow-destructive to enable it.` }],
134
+ isError: true
135
+ });
136
+ return;
137
+ }
138
+ try {
139
+ const output = await tool.execute(args);
140
+ this.sendResult(id, {
141
+ content: [{ type: "text", text: output }]
142
+ });
143
+ } catch (err) {
144
+ const text = err instanceof Error ? err.message : String(err);
145
+ this.sendResult(id, {
146
+ content: [{ type: "text", text }],
147
+ isError: true
148
+ });
149
+ }
150
+ }
151
+ // ── helpers ────────────────────────────────────────────────────────────────
152
+ eligibleTools() {
153
+ const all = this.registry.listAll();
154
+ return all.filter((tool) => {
155
+ const name = tool.definition.name;
156
+ if (STDIN_TOOLS.has(name)) return false;
157
+ if (this.opts.tools && this.opts.tools.length > 0) {
158
+ return this.opts.tools.includes(name);
159
+ }
160
+ return true;
161
+ });
162
+ }
163
+ // ── transport ──────────────────────────────────────────────────────────────
164
+ sendResult(id, result) {
165
+ this.write({ jsonrpc: "2.0", id, result });
166
+ }
167
+ sendError(id, code, message) {
168
+ this.write({ jsonrpc: "2.0", id, error: { code, message } });
169
+ }
170
+ write(obj) {
171
+ process.stdout.write(JSON.stringify(obj) + "\n");
172
+ }
173
+ /** MCP servers must use stderr for diagnostics so stdout stays JSON-RPC clean. */
174
+ log(msg) {
175
+ process.stderr.write(`[aicli-mcp] ${msg}
176
+ `);
177
+ }
178
+ };
179
+ async function startMcpServer(opts) {
180
+ const registry = new ToolRegistry();
181
+ const server = new McpServer(registry, opts);
182
+ await server.start();
183
+ }
184
+ export {
185
+ McpServer,
186
+ startMcpServer
187
+ };
@@ -4,17 +4,17 @@ import {
4
4
  getDangerLevel,
5
5
  googleSearchContext,
6
6
  truncateOutput
7
- } from "./chunk-H3CIS4XQ.js";
7
+ } from "./chunk-UJPR6N6O.js";
8
8
  import "./chunk-2ZD3YTVM.js";
9
9
  import "./chunk-4BKXL7SM.js";
10
10
  import "./chunk-NHNWUBXB.js";
11
11
  import "./chunk-CQQQFNND.js";
12
12
  import "./chunk-6VRJGH25.js";
13
13
  import "./chunk-PFYAAX2S.js";
14
- import "./chunk-BXN2BJAI.js";
14
+ import "./chunk-6WKHRV3J.js";
15
15
  import {
16
16
  SUBAGENT_ALLOWED_TOOLS
17
- } from "./chunk-MNL53XPD.js";
17
+ } from "./chunk-3BLU2654.js";
18
18
 
19
19
  // src/hub/task-orchestrator.ts
20
20
  import { createInterface } from "readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.4.83",
3
+ "version": "0.4.84",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",