@spaxe-dev/zen-mcp 0.3.3 → 0.4.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/README.md +3 -3
- package/dist/cli.js +684 -59
- package/dist/cli.js.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -291,7 +291,7 @@ import { WebSocketServer } from "ws";
|
|
|
291
291
|
// src/shared/brand.ts
|
|
292
292
|
var BRAND = "Zen MCP";
|
|
293
293
|
var SERVER_NAME = "zen-mcp";
|
|
294
|
-
var SERVER_VERSION = "0.
|
|
294
|
+
var SERVER_VERSION = "0.4.0";
|
|
295
295
|
var BRIDGE_PROTOCOL_VERSION = 2;
|
|
296
296
|
|
|
297
297
|
// src/shared/bridge-auth.ts
|
|
@@ -6172,6 +6172,11 @@ var CLINE_SETTINGS = join7(
|
|
|
6172
6172
|
"settings",
|
|
6173
6173
|
"cline_mcp_settings.json"
|
|
6174
6174
|
);
|
|
6175
|
+
var xdgConfig = (ctx) => ctx.env.XDG_CONFIG_HOME ?? join7(ctx.home, ".config");
|
|
6176
|
+
var mcpServers = (ctx) => ({
|
|
6177
|
+
command: ctx.command,
|
|
6178
|
+
args: [...SERVER_ARGS]
|
|
6179
|
+
});
|
|
6175
6180
|
var DEFINITIONS = [
|
|
6176
6181
|
{
|
|
6177
6182
|
id: "claude-code",
|
|
@@ -6185,7 +6190,7 @@ var DEFINITIONS = [
|
|
|
6185
6190
|
join7(ctx.home, ".claude")
|
|
6186
6191
|
],
|
|
6187
6192
|
json: {
|
|
6188
|
-
|
|
6193
|
+
path: ["mcpServers"],
|
|
6189
6194
|
entry: (ctx) => ({
|
|
6190
6195
|
command: ctx.command,
|
|
6191
6196
|
args: [...SERVER_ARGS]
|
|
@@ -6203,7 +6208,7 @@ var DEFINITIONS = [
|
|
|
6203
6208
|
],
|
|
6204
6209
|
detectPaths: (ctx) => [join7(ctx.configBase, "Claude")],
|
|
6205
6210
|
json: {
|
|
6206
|
-
|
|
6211
|
+
path: ["mcpServers"],
|
|
6207
6212
|
entry: (ctx) => ({
|
|
6208
6213
|
command: ctx.command,
|
|
6209
6214
|
args: [...SERVER_ARGS]
|
|
@@ -6219,7 +6224,7 @@ var DEFINITIONS = [
|
|
|
6219
6224
|
configPaths: (ctx) => [join7(ctx.home, ".cursor", "mcp.json")],
|
|
6220
6225
|
detectPaths: (ctx) => [join7(ctx.home, ".cursor")],
|
|
6221
6226
|
json: {
|
|
6222
|
-
|
|
6227
|
+
path: ["mcpServers"],
|
|
6223
6228
|
entry: (ctx) => ({
|
|
6224
6229
|
command: ctx.command,
|
|
6225
6230
|
args: [...SERVER_ARGS]
|
|
@@ -6241,7 +6246,7 @@ var DEFINITIONS = [
|
|
|
6241
6246
|
join7(ctx.configBase, "Code - Insiders", "User")
|
|
6242
6247
|
],
|
|
6243
6248
|
json: {
|
|
6244
|
-
|
|
6249
|
+
path: ["servers"],
|
|
6245
6250
|
entry: (ctx) => ({
|
|
6246
6251
|
type: "stdio",
|
|
6247
6252
|
command: ctx.command,
|
|
@@ -6278,7 +6283,7 @@ var DEFINITIONS = [
|
|
|
6278
6283
|
configPaths: (ctx) => [join7(ctx.home, ".gemini", "settings.json")],
|
|
6279
6284
|
detectPaths: (ctx) => [join7(ctx.home, ".gemini")],
|
|
6280
6285
|
json: {
|
|
6281
|
-
|
|
6286
|
+
path: ["mcpServers"],
|
|
6282
6287
|
entry: (ctx) => ({
|
|
6283
6288
|
command: ctx.command,
|
|
6284
6289
|
args: [...SERVER_ARGS]
|
|
@@ -6296,7 +6301,7 @@ var DEFINITIONS = [
|
|
|
6296
6301
|
],
|
|
6297
6302
|
detectPaths: (ctx) => [join7(ctx.home, ".codeium", "windsurf")],
|
|
6298
6303
|
json: {
|
|
6299
|
-
|
|
6304
|
+
path: ["mcpServers"],
|
|
6300
6305
|
entry: (ctx) => ({
|
|
6301
6306
|
command: ctx.command,
|
|
6302
6307
|
args: [...SERVER_ARGS]
|
|
@@ -6320,7 +6325,7 @@ var DEFINITIONS = [
|
|
|
6320
6325
|
dirname5(join7(ctx.configBase, "Windsurf", CLINE_SETTINGS))
|
|
6321
6326
|
],
|
|
6322
6327
|
json: {
|
|
6323
|
-
|
|
6328
|
+
path: ["mcpServers"],
|
|
6324
6329
|
entry: (ctx) => ({
|
|
6325
6330
|
command: ctx.command,
|
|
6326
6331
|
args: [...SERVER_ARGS]
|
|
@@ -6340,12 +6345,341 @@ var DEFINITIONS = [
|
|
|
6340
6345
|
join7(ctx.configBase, ctx.platform === "linux" ? "zed" : "Zed")
|
|
6341
6346
|
],
|
|
6342
6347
|
json: {
|
|
6343
|
-
|
|
6348
|
+
path: ["context_servers"],
|
|
6344
6349
|
entry: (ctx) => ({
|
|
6345
6350
|
command: ctx.command,
|
|
6346
6351
|
args: [...SERVER_ARGS]
|
|
6347
6352
|
})
|
|
6348
6353
|
}
|
|
6354
|
+
},
|
|
6355
|
+
{
|
|
6356
|
+
id: "opencode",
|
|
6357
|
+
label: "OpenCode",
|
|
6358
|
+
detail: "sst terminal agent",
|
|
6359
|
+
popular: true,
|
|
6360
|
+
format: "json",
|
|
6361
|
+
configPaths: (ctx) => [
|
|
6362
|
+
join7(xdgConfig(ctx), "opencode", "opencode.json"),
|
|
6363
|
+
join7(xdgConfig(ctx), "opencode", "opencode.jsonc")
|
|
6364
|
+
],
|
|
6365
|
+
detectPaths: (ctx) => [join7(xdgConfig(ctx), "opencode")],
|
|
6366
|
+
json: {
|
|
6367
|
+
path: ["mcp", "servers"],
|
|
6368
|
+
entry: (ctx) => ({
|
|
6369
|
+
type: "local",
|
|
6370
|
+
command: [ctx.command, ...SERVER_ARGS]
|
|
6371
|
+
})
|
|
6372
|
+
}
|
|
6373
|
+
},
|
|
6374
|
+
{
|
|
6375
|
+
id: "omp",
|
|
6376
|
+
label: "oh-my-pi (omp)",
|
|
6377
|
+
detail: "can1357's terminal agent",
|
|
6378
|
+
popular: true,
|
|
6379
|
+
format: "json",
|
|
6380
|
+
configPaths: (ctx) => [
|
|
6381
|
+
join7(
|
|
6382
|
+
ctx.env.PI_CONFIG_DIR ?? join7(ctx.home, ".omp"),
|
|
6383
|
+
"agent",
|
|
6384
|
+
"mcp.json"
|
|
6385
|
+
)
|
|
6386
|
+
],
|
|
6387
|
+
detectPaths: (ctx) => [
|
|
6388
|
+
ctx.env.PI_CONFIG_DIR ?? join7(ctx.home, ".omp")
|
|
6389
|
+
],
|
|
6390
|
+
json: {
|
|
6391
|
+
path: ["mcpServers"],
|
|
6392
|
+
entry: (ctx) => ({
|
|
6393
|
+
type: "stdio",
|
|
6394
|
+
command: ctx.command,
|
|
6395
|
+
args: [...SERVER_ARGS]
|
|
6396
|
+
})
|
|
6397
|
+
}
|
|
6398
|
+
},
|
|
6399
|
+
{
|
|
6400
|
+
id: "dsh",
|
|
6401
|
+
label: "DeepSeek Harness",
|
|
6402
|
+
detail: "dsh agent framework",
|
|
6403
|
+
popular: true,
|
|
6404
|
+
format: "yaml",
|
|
6405
|
+
configPaths: (ctx) => [
|
|
6406
|
+
join7(ctx.env.DSH_HOME ?? join7(ctx.home, ".dsh"), "cordis.patch.yml")
|
|
6407
|
+
],
|
|
6408
|
+
detectPaths: (ctx) => [ctx.env.DSH_HOME ?? join7(ctx.home, ".dsh")],
|
|
6409
|
+
text: (existing, ctx) => mergeDshPatch(existing, ctx)
|
|
6410
|
+
},
|
|
6411
|
+
{
|
|
6412
|
+
id: "zcode",
|
|
6413
|
+
label: "ZCode (Z.ai)",
|
|
6414
|
+
detail: "Z.ai coding agent",
|
|
6415
|
+
popular: true,
|
|
6416
|
+
format: "json",
|
|
6417
|
+
configPaths: (ctx) => [join7(ctx.home, ".zcode", "cli", "config.json")],
|
|
6418
|
+
detectPaths: (ctx) => [join7(ctx.home, ".zcode")],
|
|
6419
|
+
json: {
|
|
6420
|
+
path: ["mcp", "servers"],
|
|
6421
|
+
entry: (ctx) => ({
|
|
6422
|
+
command: ctx.command,
|
|
6423
|
+
args: [...SERVER_ARGS],
|
|
6424
|
+
env: {}
|
|
6425
|
+
})
|
|
6426
|
+
}
|
|
6427
|
+
},
|
|
6428
|
+
{
|
|
6429
|
+
id: "roo-code",
|
|
6430
|
+
label: "Roo Code",
|
|
6431
|
+
detail: "VS Code extension",
|
|
6432
|
+
popular: false,
|
|
6433
|
+
format: "json",
|
|
6434
|
+
configPaths: (ctx) => [
|
|
6435
|
+
join7(
|
|
6436
|
+
ctx.configBase,
|
|
6437
|
+
"Code",
|
|
6438
|
+
"User",
|
|
6439
|
+
"globalStorage",
|
|
6440
|
+
"rooveterinaryinc.roo-cline",
|
|
6441
|
+
"settings",
|
|
6442
|
+
"mcp_settings.json"
|
|
6443
|
+
)
|
|
6444
|
+
],
|
|
6445
|
+
detectPaths: (ctx) => [
|
|
6446
|
+
join7(
|
|
6447
|
+
ctx.configBase,
|
|
6448
|
+
"Code",
|
|
6449
|
+
"User",
|
|
6450
|
+
"globalStorage",
|
|
6451
|
+
"rooveterinaryinc.roo-cline"
|
|
6452
|
+
)
|
|
6453
|
+
],
|
|
6454
|
+
json: {
|
|
6455
|
+
path: ["mcpServers"],
|
|
6456
|
+
entry: (ctx) => ({
|
|
6457
|
+
command: ctx.command,
|
|
6458
|
+
args: [...SERVER_ARGS],
|
|
6459
|
+
disabled: false,
|
|
6460
|
+
alwaysAllow: []
|
|
6461
|
+
})
|
|
6462
|
+
}
|
|
6463
|
+
},
|
|
6464
|
+
{
|
|
6465
|
+
id: "kilo-code",
|
|
6466
|
+
label: "Kilo Code",
|
|
6467
|
+
detail: "Kilo editor extension",
|
|
6468
|
+
popular: false,
|
|
6469
|
+
format: "json",
|
|
6470
|
+
configPaths: (ctx) => [join7(xdgConfig(ctx), "kilo", "kilo.jsonc")],
|
|
6471
|
+
detectPaths: (ctx) => [join7(xdgConfig(ctx), "kilo")],
|
|
6472
|
+
json: {
|
|
6473
|
+
path: ["mcp"],
|
|
6474
|
+
entry: (ctx) => ({
|
|
6475
|
+
type: "local",
|
|
6476
|
+
command: [ctx.command, ...SERVER_ARGS],
|
|
6477
|
+
enabled: true,
|
|
6478
|
+
timeout: 1e4
|
|
6479
|
+
})
|
|
6480
|
+
}
|
|
6481
|
+
},
|
|
6482
|
+
{
|
|
6483
|
+
id: "continue",
|
|
6484
|
+
label: "Continue",
|
|
6485
|
+
detail: "VS Code and JetBrains extension",
|
|
6486
|
+
popular: false,
|
|
6487
|
+
format: "yaml",
|
|
6488
|
+
configPaths: (ctx) => [join7(ctx.home, ".continue", "config.yaml")],
|
|
6489
|
+
detectPaths: (ctx) => [join7(ctx.home, ".continue")],
|
|
6490
|
+
text: (existing, ctx) => mergeYamlListSection(existing, "mcpServers", SERVER_ENTRY_NAME, [
|
|
6491
|
+
`name: ${SERVER_ENTRY_NAME}`,
|
|
6492
|
+
"type: stdio",
|
|
6493
|
+
`command: ${yamlScalar(ctx.command)}`,
|
|
6494
|
+
`args: ${yamlFlowArray(SERVER_ARGS)}`
|
|
6495
|
+
])
|
|
6496
|
+
},
|
|
6497
|
+
{
|
|
6498
|
+
id: "amp",
|
|
6499
|
+
label: "Amp",
|
|
6500
|
+
detail: "Sourcegraph terminal agent",
|
|
6501
|
+
popular: false,
|
|
6502
|
+
format: "json",
|
|
6503
|
+
configPaths: (ctx) => [
|
|
6504
|
+
ctx.platform === "win32" ? join7(ctx.configBase, "amp", "settings.json") : join7(xdgConfig(ctx), "amp", "settings.json")
|
|
6505
|
+
],
|
|
6506
|
+
detectPaths: (ctx) => [
|
|
6507
|
+
ctx.platform === "win32" ? join7(ctx.configBase, "amp") : join7(xdgConfig(ctx), "amp")
|
|
6508
|
+
],
|
|
6509
|
+
json: {
|
|
6510
|
+
path: ["amp.mcpServers"],
|
|
6511
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6512
|
+
}
|
|
6513
|
+
},
|
|
6514
|
+
{
|
|
6515
|
+
id: "crush",
|
|
6516
|
+
label: "Crush",
|
|
6517
|
+
detail: "Charmbracelet terminal agent",
|
|
6518
|
+
popular: false,
|
|
6519
|
+
format: "bash",
|
|
6520
|
+
configPaths: (ctx) => [
|
|
6521
|
+
ctx.env.CRUSH_GLOBAL_CONFIG ?? join7(xdgConfig(ctx), "crush", "crushrc")
|
|
6522
|
+
],
|
|
6523
|
+
detectPaths: (ctx) => [join7(xdgConfig(ctx), "crush")],
|
|
6524
|
+
text: (existing, ctx) => mergeCrushrc(existing, ctx)
|
|
6525
|
+
},
|
|
6526
|
+
{
|
|
6527
|
+
id: "qwen-code",
|
|
6528
|
+
label: "Qwen Code",
|
|
6529
|
+
detail: "Alibaba terminal agent",
|
|
6530
|
+
popular: false,
|
|
6531
|
+
format: "json",
|
|
6532
|
+
configPaths: (ctx) => [
|
|
6533
|
+
join7(ctx.env.QWEN_HOME ?? join7(ctx.home, ".qwen"), "settings.json")
|
|
6534
|
+
],
|
|
6535
|
+
detectPaths: (ctx) => [ctx.env.QWEN_HOME ?? join7(ctx.home, ".qwen")],
|
|
6536
|
+
json: {
|
|
6537
|
+
path: ["mcpServers"],
|
|
6538
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6539
|
+
}
|
|
6540
|
+
},
|
|
6541
|
+
{
|
|
6542
|
+
id: "kiro",
|
|
6543
|
+
label: "Kiro",
|
|
6544
|
+
detail: "AWS agentic IDE and CLI",
|
|
6545
|
+
popular: false,
|
|
6546
|
+
format: "json",
|
|
6547
|
+
configPaths: (ctx) => [join7(ctx.home, ".kiro", "settings", "mcp.json")],
|
|
6548
|
+
detectPaths: (ctx) => [join7(ctx.home, ".kiro")],
|
|
6549
|
+
json: {
|
|
6550
|
+
path: ["mcpServers"],
|
|
6551
|
+
entry: (ctx) => ({
|
|
6552
|
+
command: ctx.command,
|
|
6553
|
+
args: [...SERVER_ARGS],
|
|
6554
|
+
disabled: false,
|
|
6555
|
+
autoApprove: []
|
|
6556
|
+
})
|
|
6557
|
+
}
|
|
6558
|
+
},
|
|
6559
|
+
{
|
|
6560
|
+
id: "warp",
|
|
6561
|
+
label: "Warp",
|
|
6562
|
+
detail: "Warp terminal agent",
|
|
6563
|
+
popular: false,
|
|
6564
|
+
format: "json",
|
|
6565
|
+
configPaths: (ctx) => [join7(ctx.home, ".warp", ".mcp.json")],
|
|
6566
|
+
detectPaths: (ctx) => [join7(ctx.home, ".warp")],
|
|
6567
|
+
json: {
|
|
6568
|
+
path: ["mcpServers"],
|
|
6569
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6570
|
+
}
|
|
6571
|
+
},
|
|
6572
|
+
{
|
|
6573
|
+
id: "copilot-cli",
|
|
6574
|
+
label: "Copilot CLI",
|
|
6575
|
+
detail: "GitHub Copilot terminal agent",
|
|
6576
|
+
popular: false,
|
|
6577
|
+
format: "json",
|
|
6578
|
+
configPaths: (ctx) => [join7(ctx.home, ".copilot", "mcp-config.json")],
|
|
6579
|
+
detectPaths: (ctx) => [join7(ctx.home, ".copilot")],
|
|
6580
|
+
json: {
|
|
6581
|
+
path: ["mcpServers"],
|
|
6582
|
+
entry: (ctx) => ({
|
|
6583
|
+
type: "local",
|
|
6584
|
+
command: ctx.command,
|
|
6585
|
+
args: [...SERVER_ARGS],
|
|
6586
|
+
tools: ["*"]
|
|
6587
|
+
})
|
|
6588
|
+
}
|
|
6589
|
+
},
|
|
6590
|
+
{
|
|
6591
|
+
id: "droid",
|
|
6592
|
+
label: "Factory Droid",
|
|
6593
|
+
detail: "Factory terminal agent",
|
|
6594
|
+
popular: false,
|
|
6595
|
+
format: "json",
|
|
6596
|
+
configPaths: (ctx) => [join7(ctx.home, ".factory", "mcp.json")],
|
|
6597
|
+
detectPaths: (ctx) => [join7(ctx.home, ".factory")],
|
|
6598
|
+
json: {
|
|
6599
|
+
path: ["mcpServers"],
|
|
6600
|
+
entry: (ctx) => ({
|
|
6601
|
+
type: "stdio",
|
|
6602
|
+
command: ctx.command,
|
|
6603
|
+
args: [...SERVER_ARGS],
|
|
6604
|
+
disabled: false
|
|
6605
|
+
})
|
|
6606
|
+
}
|
|
6607
|
+
},
|
|
6608
|
+
{
|
|
6609
|
+
id: "amazon-q",
|
|
6610
|
+
label: "Amazon Q",
|
|
6611
|
+
detail: "Amazon Q Developer CLI",
|
|
6612
|
+
popular: false,
|
|
6613
|
+
format: "json",
|
|
6614
|
+
configPaths: (ctx) => [
|
|
6615
|
+
join7(ctx.home, ".aws", "amazonq", "mcp.json")
|
|
6616
|
+
],
|
|
6617
|
+
detectPaths: (ctx) => [join7(ctx.home, ".aws", "amazonq")],
|
|
6618
|
+
json: {
|
|
6619
|
+
path: ["mcpServers"],
|
|
6620
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6621
|
+
}
|
|
6622
|
+
},
|
|
6623
|
+
{
|
|
6624
|
+
id: "goose",
|
|
6625
|
+
label: "Goose",
|
|
6626
|
+
detail: "Block's terminal agent",
|
|
6627
|
+
popular: false,
|
|
6628
|
+
format: "yaml",
|
|
6629
|
+
configPaths: (ctx) => [
|
|
6630
|
+
ctx.platform === "win32" ? join7(ctx.configBase, "Block", "goose", "config", "config.yaml") : join7(xdgConfig(ctx), "goose", "config.yaml")
|
|
6631
|
+
],
|
|
6632
|
+
detectPaths: (ctx) => [
|
|
6633
|
+
ctx.platform === "win32" ? join7(ctx.configBase, "Block", "goose") : join7(xdgConfig(ctx), "goose")
|
|
6634
|
+
],
|
|
6635
|
+
text: (existing, ctx) => mergeYamlMappingSection(existing, "extensions", SERVER_ENTRY_NAME, [
|
|
6636
|
+
"type: stdio",
|
|
6637
|
+
`name: ${SERVER_ENTRY_NAME}`,
|
|
6638
|
+
"enabled: true",
|
|
6639
|
+
`cmd: ${yamlScalar(ctx.command)}`,
|
|
6640
|
+
`args: ${yamlFlowArray(SERVER_ARGS)}`,
|
|
6641
|
+
"envs: {}",
|
|
6642
|
+
"timeout: 300"
|
|
6643
|
+
])
|
|
6644
|
+
},
|
|
6645
|
+
{
|
|
6646
|
+
id: "lm-studio",
|
|
6647
|
+
label: "LM Studio",
|
|
6648
|
+
detail: "LM Studio desktop app",
|
|
6649
|
+
popular: false,
|
|
6650
|
+
format: "json",
|
|
6651
|
+
configPaths: (ctx) => [join7(ctx.home, ".lmstudio", "mcp.json")],
|
|
6652
|
+
detectPaths: (ctx) => [join7(ctx.home, ".lmstudio")],
|
|
6653
|
+
json: {
|
|
6654
|
+
path: ["mcpServers"],
|
|
6655
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6656
|
+
}
|
|
6657
|
+
},
|
|
6658
|
+
{
|
|
6659
|
+
id: "junie",
|
|
6660
|
+
label: "Junie",
|
|
6661
|
+
detail: "JetBrains Junie CLI",
|
|
6662
|
+
popular: false,
|
|
6663
|
+
format: "json",
|
|
6664
|
+
configPaths: (ctx) => [join7(ctx.home, ".junie", "mcp", "mcp.json")],
|
|
6665
|
+
detectPaths: (ctx) => [join7(ctx.home, ".junie")],
|
|
6666
|
+
json: {
|
|
6667
|
+
path: ["mcpServers"],
|
|
6668
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6669
|
+
}
|
|
6670
|
+
},
|
|
6671
|
+
{
|
|
6672
|
+
id: "pi",
|
|
6673
|
+
label: "Pi",
|
|
6674
|
+
detail: "pi.dev terminal agent",
|
|
6675
|
+
popular: false,
|
|
6676
|
+
format: "json",
|
|
6677
|
+
configPaths: (ctx) => [join7(ctx.home, ".pi", "agent", "mcp.json")],
|
|
6678
|
+
detectPaths: (ctx) => [join7(ctx.home, ".pi")],
|
|
6679
|
+
json: {
|
|
6680
|
+
path: ["mcpServers"],
|
|
6681
|
+
entry: (ctx) => mcpServers(ctx)
|
|
6682
|
+
}
|
|
6349
6683
|
}
|
|
6350
6684
|
];
|
|
6351
6685
|
function clientIds() {
|
|
@@ -6353,7 +6687,7 @@ function clientIds() {
|
|
|
6353
6687
|
}
|
|
6354
6688
|
function catalog(ctx = {}) {
|
|
6355
6689
|
const resolved = resolveContext(ctx);
|
|
6356
|
-
|
|
6690
|
+
const entries = DEFINITIONS.map((definition) => {
|
|
6357
6691
|
const paths = definition.configPaths(resolved);
|
|
6358
6692
|
return {
|
|
6359
6693
|
id: definition.id,
|
|
@@ -6365,6 +6699,10 @@ function catalog(ctx = {}) {
|
|
|
6365
6699
|
format: definition.format
|
|
6366
6700
|
};
|
|
6367
6701
|
});
|
|
6702
|
+
return [
|
|
6703
|
+
...entries.filter((entry) => entry.popular),
|
|
6704
|
+
...entries.filter((entry) => !entry.popular)
|
|
6705
|
+
];
|
|
6368
6706
|
}
|
|
6369
6707
|
function applyClient(id, ctx = {}) {
|
|
6370
6708
|
const definition = DEFINITIONS.find((entry) => entry.id === id);
|
|
@@ -6383,7 +6721,9 @@ function applyClient(id, ctx = {}) {
|
|
|
6383
6721
|
const existed = existsSync7(path);
|
|
6384
6722
|
try {
|
|
6385
6723
|
const existing = existed ? readFileTextBounded(path, MAX_CLIENT_CONFIG_BYTES) : void 0;
|
|
6386
|
-
if (definition.
|
|
6724
|
+
if (definition.text) {
|
|
6725
|
+
atomicWritePrivate(path, definition.text(existing, resolved));
|
|
6726
|
+
} else if (definition.format === "toml") {
|
|
6387
6727
|
const toml = definition.toml;
|
|
6388
6728
|
if (!toml) throw new Error("TOML settings are missing for this client");
|
|
6389
6729
|
const next = mergeTomlServer(
|
|
@@ -6395,7 +6735,11 @@ function applyClient(id, ctx = {}) {
|
|
|
6395
6735
|
} else {
|
|
6396
6736
|
const json = definition.json;
|
|
6397
6737
|
if (!json) throw new Error("JSON settings are missing for this client");
|
|
6398
|
-
const next =
|
|
6738
|
+
const next = mergeJsonServerPath(
|
|
6739
|
+
existing,
|
|
6740
|
+
json.path,
|
|
6741
|
+
json.entry(resolved)
|
|
6742
|
+
);
|
|
6399
6743
|
atomicWritePrivate(path, next);
|
|
6400
6744
|
}
|
|
6401
6745
|
return {
|
|
@@ -6415,11 +6759,13 @@ function applyClient(id, ctx = {}) {
|
|
|
6415
6759
|
};
|
|
6416
6760
|
}
|
|
6417
6761
|
}
|
|
6418
|
-
function
|
|
6762
|
+
function mergeJsonServerPath(existing, path, entry) {
|
|
6419
6763
|
let text = existing;
|
|
6420
6764
|
if (text && text.charCodeAt(0) === 65279) text = text.slice(1);
|
|
6421
6765
|
if (!text || !text.trim()) {
|
|
6422
|
-
|
|
6766
|
+
const root = {};
|
|
6767
|
+
placeJsonServer(root, path, entry);
|
|
6768
|
+
return `${JSON.stringify(root, null, 2)}
|
|
6423
6769
|
`;
|
|
6424
6770
|
}
|
|
6425
6771
|
let parsed;
|
|
@@ -6427,7 +6773,7 @@ function mergeJsonServer(existing, key, entry) {
|
|
|
6427
6773
|
parsed = JSON.parse(text);
|
|
6428
6774
|
} catch (error) {
|
|
6429
6775
|
try {
|
|
6430
|
-
return
|
|
6776
|
+
return mergeJsoncServerPath(text, path, entry);
|
|
6431
6777
|
} catch {
|
|
6432
6778
|
throw new Error(
|
|
6433
6779
|
`existing file is not valid JSON or JSONC (${error.message})`
|
|
@@ -6437,36 +6783,64 @@ function mergeJsonServer(existing, key, entry) {
|
|
|
6437
6783
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
6438
6784
|
throw new Error("existing file is not a JSON object");
|
|
6439
6785
|
}
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
if (current !== void 0 && (current === null || typeof current !== "object" || Array.isArray(current))) {
|
|
6443
|
-
throw new Error(`"${key}" is not a JSON object`);
|
|
6444
|
-
}
|
|
6445
|
-
root[key] = {
|
|
6446
|
-
...current ?? {},
|
|
6447
|
-
[SERVER_ENTRY_NAME]: entry
|
|
6448
|
-
};
|
|
6449
|
-
return `${JSON.stringify(root, null, 2)}
|
|
6786
|
+
placeJsonServer(parsed, path, entry);
|
|
6787
|
+
return `${JSON.stringify(parsed, null, 2)}
|
|
6450
6788
|
`;
|
|
6451
6789
|
}
|
|
6452
|
-
function
|
|
6790
|
+
function placeJsonServer(root, path, entry) {
|
|
6791
|
+
let node = root;
|
|
6792
|
+
for (const key of path) {
|
|
6793
|
+
const current = node[key];
|
|
6794
|
+
if (current === void 0) {
|
|
6795
|
+
const created = {};
|
|
6796
|
+
node[key] = created;
|
|
6797
|
+
node = created;
|
|
6798
|
+
continue;
|
|
6799
|
+
}
|
|
6800
|
+
if (current === null || typeof current !== "object" || Array.isArray(current)) {
|
|
6801
|
+
throw new Error(`"${key}" is not a JSON object`);
|
|
6802
|
+
}
|
|
6803
|
+
node = current;
|
|
6804
|
+
}
|
|
6805
|
+
node[SERVER_ENTRY_NAME] = entry;
|
|
6806
|
+
}
|
|
6807
|
+
function mergeJsoncServerPath(text, path, entry) {
|
|
6453
6808
|
const rootStart = skipJsoncTrivia(text, 0);
|
|
6454
6809
|
if (text[rootStart] !== "{") {
|
|
6455
6810
|
throw new Error("the top level is not a JSON object");
|
|
6456
6811
|
}
|
|
6457
|
-
|
|
6458
|
-
if (!
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6812
|
+
let object = scanJsoncObject(text, rootStart);
|
|
6813
|
+
if (!object) throw new Error("the file has an unterminated object");
|
|
6814
|
+
for (let index = 0; index < path.length; index += 1) {
|
|
6815
|
+
const key = path[index];
|
|
6816
|
+
const member = object.members.find((item) => item.key === key);
|
|
6817
|
+
if (!member) {
|
|
6818
|
+
return insertJsoncMember(
|
|
6819
|
+
text,
|
|
6820
|
+
object,
|
|
6821
|
+
key,
|
|
6822
|
+
nestedJsonValue(path.slice(index + 1), entry)
|
|
6823
|
+
);
|
|
6824
|
+
}
|
|
6825
|
+
if (text[member.valueStart] !== "{") {
|
|
6826
|
+
throw new Error(`"${key}" is not a JSON object`);
|
|
6827
|
+
}
|
|
6828
|
+
const child = scanJsoncObject(text, member.valueStart);
|
|
6829
|
+
if (!child) throw new Error(`"${key}" is not a complete object`);
|
|
6830
|
+
if (index === path.length - 1) {
|
|
6831
|
+
return upsertJsoncServer(text, child, entry);
|
|
6832
|
+
}
|
|
6833
|
+
object = child;
|
|
6467
6834
|
}
|
|
6468
|
-
|
|
6469
|
-
|
|
6835
|
+
throw new Error("the server path is empty");
|
|
6836
|
+
}
|
|
6837
|
+
function nestedJsonValue(keys, entry) {
|
|
6838
|
+
return keys.reduceRight(
|
|
6839
|
+
(value, key) => ({ [key]: value }),
|
|
6840
|
+
{ [SERVER_ENTRY_NAME]: entry }
|
|
6841
|
+
);
|
|
6842
|
+
}
|
|
6843
|
+
function upsertJsoncServer(text, serverMap, entry) {
|
|
6470
6844
|
const current = serverMap.members.find(
|
|
6471
6845
|
(member) => member.key === SERVER_ENTRY_NAME
|
|
6472
6846
|
);
|
|
@@ -6659,12 +7033,204 @@ function mergeTomlServer(existing, table, values) {
|
|
|
6659
7033
|
return `${lines.join("\n")}
|
|
6660
7034
|
`;
|
|
6661
7035
|
}
|
|
7036
|
+
function yamlScalar(value) {
|
|
7037
|
+
return JSON.stringify(value);
|
|
7038
|
+
}
|
|
7039
|
+
function yamlFlowArray(values) {
|
|
7040
|
+
return `[${values.map(yamlScalar).join(", ")}]`;
|
|
7041
|
+
}
|
|
7042
|
+
function findYamlSection(lines, section) {
|
|
7043
|
+
const header = new RegExp(`^${escapeRegExp(section)}:\\s*(?:#.*)?$`);
|
|
7044
|
+
const start = lines.findIndex((line) => header.test(line));
|
|
7045
|
+
if (start < 0) return null;
|
|
7046
|
+
let end = start + 1;
|
|
7047
|
+
while (end < lines.length) {
|
|
7048
|
+
const line = lines[end];
|
|
7049
|
+
if (line.trim() === "" || /^[ \t]/.test(line) || line.trimStart().startsWith("#")) {
|
|
7050
|
+
end += 1;
|
|
7051
|
+
} else {
|
|
7052
|
+
break;
|
|
7053
|
+
}
|
|
7054
|
+
}
|
|
7055
|
+
const child = lines.slice(start + 1, end).find((line) => /^[ \t]+\S/.test(line));
|
|
7056
|
+
return { start, end, indent: child?.match(/^[ \t]+/)?.[0] ?? " " };
|
|
7057
|
+
}
|
|
7058
|
+
function splitYamlLines(existing) {
|
|
7059
|
+
const lines = (existing ?? "").replace(/\r\n/g, "\n").split("\n");
|
|
7060
|
+
while (lines.length > 0 && lines[lines.length - 1] === "") lines.pop();
|
|
7061
|
+
return lines;
|
|
7062
|
+
}
|
|
7063
|
+
function mergeYamlMappingSection(existing, section, key, block) {
|
|
7064
|
+
const lines = splitYamlLines(existing);
|
|
7065
|
+
const found = findYamlSection(lines, section);
|
|
7066
|
+
if (!found) {
|
|
7067
|
+
if (lines.length > 0) lines.push("");
|
|
7068
|
+
lines.push(
|
|
7069
|
+
`${section}:`,
|
|
7070
|
+
`${key}:`,
|
|
7071
|
+
...block.map((line) => ` ${line}`)
|
|
7072
|
+
);
|
|
7073
|
+
return `${lines.join("\n")}
|
|
7074
|
+
`;
|
|
7075
|
+
}
|
|
7076
|
+
const indent = found.indent;
|
|
7077
|
+
const keyLine = `${indent}${key}:`;
|
|
7078
|
+
const keyPattern = new RegExp(
|
|
7079
|
+
`^${escapeRegExp(indent)}${escapeRegExp(key)}:\\s*(?:#.*)?$`
|
|
7080
|
+
);
|
|
7081
|
+
const index = lines.findIndex(
|
|
7082
|
+
(line, position) => position > found.start && position < found.end && keyPattern.test(line)
|
|
7083
|
+
);
|
|
7084
|
+
if (index >= 0) {
|
|
7085
|
+
let end = index + 1;
|
|
7086
|
+
while (end < found.end) {
|
|
7087
|
+
const line = lines[end];
|
|
7088
|
+
if (line.trim() === "") {
|
|
7089
|
+
end += 1;
|
|
7090
|
+
continue;
|
|
7091
|
+
}
|
|
7092
|
+
const lineIndent = line.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
7093
|
+
if (lineIndent <= indent.length) break;
|
|
7094
|
+
end += 1;
|
|
7095
|
+
}
|
|
7096
|
+
lines.splice(
|
|
7097
|
+
index,
|
|
7098
|
+
end - index,
|
|
7099
|
+
keyLine,
|
|
7100
|
+
...block.map((line) => ` ${indent}${line}`)
|
|
7101
|
+
);
|
|
7102
|
+
} else {
|
|
7103
|
+
lines.splice(
|
|
7104
|
+
found.end,
|
|
7105
|
+
0,
|
|
7106
|
+
keyLine,
|
|
7107
|
+
...block.map((line) => ` ${indent}${line}`)
|
|
7108
|
+
);
|
|
7109
|
+
}
|
|
7110
|
+
return `${lines.join("\n")}
|
|
7111
|
+
`;
|
|
7112
|
+
}
|
|
7113
|
+
function mergeYamlListSection(existing, section, name, block) {
|
|
7114
|
+
const lines = splitYamlLines(existing);
|
|
7115
|
+
const found = findYamlSection(lines, section);
|
|
7116
|
+
const item = [`- name: ${name}`, ...block.slice(1)];
|
|
7117
|
+
if (!found) {
|
|
7118
|
+
if (lines.length > 0) lines.push("");
|
|
7119
|
+
lines.push(`${section}:`, ...item.map((line) => ` ${line}`));
|
|
7120
|
+
return `${lines.join("\n")}
|
|
7121
|
+
`;
|
|
7122
|
+
}
|
|
7123
|
+
const itemIndent = lines.slice(found.start + 1, found.end).find((line) => /^[ \t]*-[ \t]+\S/.test(line))?.match(/^[ \t]*/)?.[0] ?? " ";
|
|
7124
|
+
const namePattern = new RegExp(
|
|
7125
|
+
`^${escapeRegExp(itemIndent)}-[ \\t]+name:\\s*['"]?${escapeRegExp(
|
|
7126
|
+
name
|
|
7127
|
+
)}['"]?\\s*(?:#.*)?$`
|
|
7128
|
+
);
|
|
7129
|
+
const index = lines.findIndex(
|
|
7130
|
+
(line, position) => position > found.start && position < found.end && namePattern.test(line)
|
|
7131
|
+
);
|
|
7132
|
+
if (index >= 0) {
|
|
7133
|
+
let end = index + 1;
|
|
7134
|
+
while (end < found.end) {
|
|
7135
|
+
const line = lines[end];
|
|
7136
|
+
if (line.trim() === "") {
|
|
7137
|
+
end += 1;
|
|
7138
|
+
continue;
|
|
7139
|
+
}
|
|
7140
|
+
if (new RegExp(`^${escapeRegExp(itemIndent)}-[ \\t]`).test(line)) break;
|
|
7141
|
+
if ((line.match(/^[ \t]*/)?.[0].length ?? 0) < itemIndent.length) break;
|
|
7142
|
+
end += 1;
|
|
7143
|
+
}
|
|
7144
|
+
lines.splice(
|
|
7145
|
+
index,
|
|
7146
|
+
end - index,
|
|
7147
|
+
`${itemIndent}${item[0]}`,
|
|
7148
|
+
...item.slice(1).map((line) => `${itemIndent} ${line}`)
|
|
7149
|
+
);
|
|
7150
|
+
} else {
|
|
7151
|
+
lines.splice(
|
|
7152
|
+
found.end,
|
|
7153
|
+
0,
|
|
7154
|
+
`${itemIndent}${item[0]}`,
|
|
7155
|
+
...item.slice(1).map((line) => `${itemIndent} ${line}`)
|
|
7156
|
+
);
|
|
7157
|
+
}
|
|
7158
|
+
return `${lines.join("\n")}
|
|
7159
|
+
`;
|
|
7160
|
+
}
|
|
7161
|
+
function mergeDshPatch(existing, ctx) {
|
|
7162
|
+
const lines = splitYamlLines(existing);
|
|
7163
|
+
const item = [
|
|
7164
|
+
"- id: zen-mcp",
|
|
7165
|
+
" name: '@deepseek-ai/dsh-mcp-client'",
|
|
7166
|
+
" config:",
|
|
7167
|
+
" serverName: zen_mcp",
|
|
7168
|
+
" transport: stdio",
|
|
7169
|
+
` command: ${yamlScalar(ctx.command)}`,
|
|
7170
|
+
` args: ${yamlFlowArray(SERVER_ARGS)}`
|
|
7171
|
+
];
|
|
7172
|
+
const idPattern = /^([ \t]*)-[ \t]*id:\s*['"]?zen-mcp['"]?\s*$/;
|
|
7173
|
+
const index = lines.findIndex((line) => idPattern.test(line));
|
|
7174
|
+
if (index < 0) {
|
|
7175
|
+
if (lines.length > 0) lines.push("");
|
|
7176
|
+
lines.push("- insert:", ...item.map((line) => ` ${line}`));
|
|
7177
|
+
return `${lines.join("\n")}
|
|
7178
|
+
`;
|
|
7179
|
+
}
|
|
7180
|
+
const indent = lines[index].match(idPattern)?.[1] ?? " ";
|
|
7181
|
+
let start = index;
|
|
7182
|
+
while (start > 0) {
|
|
7183
|
+
const previous = lines[start - 1];
|
|
7184
|
+
const previousIndent = previous.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
7185
|
+
if (previousIndent < indent.length) break;
|
|
7186
|
+
if (previousIndent === indent.length && /^[ \t]*-[ \t]/.test(previous)) {
|
|
7187
|
+
break;
|
|
7188
|
+
}
|
|
7189
|
+
start -= 1;
|
|
7190
|
+
}
|
|
7191
|
+
let end = index + 1;
|
|
7192
|
+
while (end < lines.length) {
|
|
7193
|
+
const line = lines[end];
|
|
7194
|
+
const lineIndent = line.match(/^[ \t]*/)?.[0].length ?? 0;
|
|
7195
|
+
if (line.trim() !== "" && lineIndent < indent.length) break;
|
|
7196
|
+
if (lineIndent === indent.length && /^[ \t]*-[ \t]/.test(line)) break;
|
|
7197
|
+
end += 1;
|
|
7198
|
+
}
|
|
7199
|
+
lines.splice(
|
|
7200
|
+
start,
|
|
7201
|
+
end - start,
|
|
7202
|
+
...item.map((line) => `${indent}${line}`)
|
|
7203
|
+
);
|
|
7204
|
+
return `${lines.join("\n")}
|
|
7205
|
+
`;
|
|
7206
|
+
}
|
|
7207
|
+
function mergeCrushrc(existing, ctx) {
|
|
7208
|
+
const lines = splitYamlLines(existing);
|
|
7209
|
+
const command = `mcp add zen-mcp --command ${shellQuote(
|
|
7210
|
+
ctx.command
|
|
7211
|
+
)} --args ${SERVER_ARGS.map(shellQuote).join(" ")}`;
|
|
7212
|
+
const index = lines.findIndex(
|
|
7213
|
+
(line) => /^\s*mcp\s+add\s+zen-mcp(?:\s|$)/.test(line)
|
|
7214
|
+
);
|
|
7215
|
+
if (index >= 0) {
|
|
7216
|
+
lines[index] = command;
|
|
7217
|
+
} else {
|
|
7218
|
+
if (lines.length > 0) lines.push("");
|
|
7219
|
+
lines.push(command);
|
|
7220
|
+
}
|
|
7221
|
+
return `${lines.join("\n")}
|
|
7222
|
+
`;
|
|
7223
|
+
}
|
|
7224
|
+
function shellQuote(value) {
|
|
7225
|
+
return /^[A-Za-z0-9_./:-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
7226
|
+
}
|
|
6662
7227
|
function agentSetupPrompt(command = "zen-mcp", ctx = {}) {
|
|
6663
7228
|
const resolved = resolveContext({ ...ctx, command });
|
|
6664
7229
|
const locations = DEFINITIONS.map((definition) => {
|
|
6665
7230
|
const path = placeholderPath(definition.configPaths(resolved)[0], resolved);
|
|
6666
7231
|
const detail = definition.id === "vscode" ? " (Insiders uses the same path under `Code - Insiders`)" : definition.id === "cline" ? " (same relative path under Cursor or Windsurf)" : "";
|
|
6667
|
-
const
|
|
7232
|
+
const jsonPath = definition.json?.path;
|
|
7233
|
+
const shape = definition.format === "toml" ? " TOML table `[mcp_servers.zen-mcp]`" : definition.format === "yaml" ? " YAML configuration, keep existing entries" : definition.format === "bash" ? " shell rc file, add it with `mcp add`" : definition.id === "vscode" ? ' top-level `servers`, entry needs `"type": "stdio"`' : jsonPath && jsonPath.length > 1 ? ` nested \`${jsonPath.join(".")}\` object` : jsonPath?.[0] === "context_servers" ? " top-level `context_servers`" : " top-level `mcpServers`";
|
|
6668
7234
|
return `- ${definition.label}: \`${path}\`${detail};${shape}.`;
|
|
6669
7235
|
}).join("\n");
|
|
6670
7236
|
return [
|
|
@@ -6886,6 +7452,15 @@ function moveCursor(options, cursor, delta) {
|
|
|
6886
7452
|
const size = options.length;
|
|
6887
7453
|
return ((cursor + delta) % size + size) % size;
|
|
6888
7454
|
}
|
|
7455
|
+
function scrollWindow(total, cursor, height, start = 0) {
|
|
7456
|
+
const size = Math.max(1, Math.min(height, total));
|
|
7457
|
+
const limit = Math.max(0, total - size);
|
|
7458
|
+
let next = Math.max(0, Math.min(start, limit));
|
|
7459
|
+
if (cursor < next) next = cursor;
|
|
7460
|
+
if (cursor >= next + size) next = cursor - size + 1;
|
|
7461
|
+
next = Math.max(0, Math.min(next, limit));
|
|
7462
|
+
return { start: next, end: Math.min(total, next + size) };
|
|
7463
|
+
}
|
|
6889
7464
|
function toggleAll(options, selected) {
|
|
6890
7465
|
return options.map(
|
|
6891
7466
|
(option) => option.other ? option : { ...option, selected }
|
|
@@ -6897,6 +7472,22 @@ function pickerResult(options) {
|
|
|
6897
7472
|
other: options.some((option) => option.other && option.selected)
|
|
6898
7473
|
};
|
|
6899
7474
|
}
|
|
7475
|
+
function buildBodyEntries(rows) {
|
|
7476
|
+
const entries = [];
|
|
7477
|
+
rows.forEach((row, index) => {
|
|
7478
|
+
if (index === 0) {
|
|
7479
|
+
entries.push({ kind: "header", text: "POPULAR" });
|
|
7480
|
+
} else if (row.other) {
|
|
7481
|
+
entries.push({ kind: "blank" });
|
|
7482
|
+
entries.push({ kind: "header", text: "OTHER" });
|
|
7483
|
+
} else if (rows[index - 1]?.popular && !row.popular) {
|
|
7484
|
+
entries.push({ kind: "blank" });
|
|
7485
|
+
entries.push({ kind: "header", text: "MORE CLIENTS" });
|
|
7486
|
+
}
|
|
7487
|
+
entries.push({ kind: "option", rowIndex: index });
|
|
7488
|
+
});
|
|
7489
|
+
return entries;
|
|
7490
|
+
}
|
|
6900
7491
|
async function pickClients(options, streams = {}) {
|
|
6901
7492
|
const input = streams.input ?? process.stdin;
|
|
6902
7493
|
const output = streams.output ?? process.stdout;
|
|
@@ -6908,10 +7499,27 @@ async function pickClients(options, streams = {}) {
|
|
|
6908
7499
|
let painted = 0;
|
|
6909
7500
|
const theme = createTheme(output);
|
|
6910
7501
|
const columns = output.columns ?? 80;
|
|
7502
|
+
const terminalRows = output.rows ?? 24;
|
|
6911
7503
|
const width = Math.max(44, Math.min(columns - 4, 64));
|
|
6912
7504
|
const showDetail = columns >= 72;
|
|
6913
7505
|
const detailLimit = Math.max(18, columns - 40);
|
|
6914
7506
|
const rule = theme.dim("\u2500".repeat(width));
|
|
7507
|
+
const headerHeight = 4;
|
|
7508
|
+
const footerHeight = rows.some((row) => row.detected) ? 3 : 4;
|
|
7509
|
+
const bodyHeight = Math.max(3, terminalRows - headerHeight - footerHeight);
|
|
7510
|
+
const body = buildBodyEntries(rows);
|
|
7511
|
+
let scrollStart = 0;
|
|
7512
|
+
let pageSize = bodyHeight;
|
|
7513
|
+
const paintRow = (row, index, final) => {
|
|
7514
|
+
const marker = final ? " " : index === cursor ? theme.cyan("\u276F") : " ";
|
|
7515
|
+
const box = row.selected ? theme.green("[\u25CF]") : theme.dim("[ ]");
|
|
7516
|
+
const padding = row.label.padEnd(20);
|
|
7517
|
+
const label = index === cursor && !final ? theme.bold(padding) : padding;
|
|
7518
|
+
const tagName = row.detected ? "detected" : row.popular ? "popular" : "";
|
|
7519
|
+
const tag = tagName ? row.detected ? theme.green(tagName.padEnd(10)) : theme.dim(tagName.padEnd(10)) : " ".repeat(10);
|
|
7520
|
+
const detail = !showDetail ? "" : row.detail.length > detailLimit ? `${row.detail.slice(0, detailLimit - 1).trimEnd()}\u2026` : row.detail;
|
|
7521
|
+
return ` ${marker} ${box} ${label} ${tag} ${theme.dim(detail)}`.trimEnd();
|
|
7522
|
+
};
|
|
6915
7523
|
const paint = (final = false) => {
|
|
6916
7524
|
const lines = [];
|
|
6917
7525
|
const count = rows.filter((row) => !row.other && row.selected).length;
|
|
@@ -6922,28 +7530,33 @@ async function pickClients(options, streams = {}) {
|
|
|
6922
7530
|
lines.push(` ${rule}`);
|
|
6923
7531
|
lines.push(` ${theme.dim("Connect Zen to the agents you use.")}`);
|
|
6924
7532
|
lines.push("");
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
lines.push(` ${theme.dim("MORE CLIENTS")}`);
|
|
6935
|
-
}
|
|
6936
|
-
const marker = final ? " " : index === cursor ? theme.cyan("\u276F") : " ";
|
|
6937
|
-
const box = row.selected ? theme.green("[\u25CF]") : theme.dim("[ ]");
|
|
6938
|
-
const padding = row.label.padEnd(20);
|
|
6939
|
-
const label = index === cursor && !final ? theme.bold(padding) : padding;
|
|
6940
|
-
const tagName = row.detected ? "detected" : row.popular ? "popular" : "";
|
|
6941
|
-
const tag = tagName ? row.detected ? theme.green(tagName.padEnd(10)) : theme.dim(tagName.padEnd(10)) : " ".repeat(10);
|
|
6942
|
-
const detail = !showDetail ? "" : row.detail.length > detailLimit ? `${row.detail.slice(0, detailLimit - 1).trimEnd()}\u2026` : row.detail;
|
|
7533
|
+
const scrolling = body.length > bodyHeight;
|
|
7534
|
+
const visible = scrolling ? Math.max(1, bodyHeight - 2) : bodyHeight;
|
|
7535
|
+
pageSize = visible;
|
|
7536
|
+
const cursorLine = body.findIndex(
|
|
7537
|
+
(entry) => entry.kind === "option" && entry.rowIndex === cursor
|
|
7538
|
+
);
|
|
7539
|
+
const window = scrollWindow(body.length, cursorLine, visible, scrollStart);
|
|
7540
|
+
scrollStart = window.start;
|
|
7541
|
+
if (scrolling) {
|
|
6943
7542
|
lines.push(
|
|
6944
|
-
` ${
|
|
7543
|
+
window.start > 0 ? ` ${theme.dim(`\u2191 ${window.start} more`)}` : ""
|
|
6945
7544
|
);
|
|
6946
|
-
}
|
|
7545
|
+
}
|
|
7546
|
+
for (let index = window.start; index < window.end; index += 1) {
|
|
7547
|
+
const entry = body[index];
|
|
7548
|
+
if (entry.kind === "option") {
|
|
7549
|
+
lines.push(paintRow(rows[entry.rowIndex], entry.rowIndex, final));
|
|
7550
|
+
} else if (entry.kind === "header") {
|
|
7551
|
+
lines.push(` ${theme.dim(entry.text)}`);
|
|
7552
|
+
} else {
|
|
7553
|
+
lines.push("");
|
|
7554
|
+
}
|
|
7555
|
+
}
|
|
7556
|
+
if (scrolling) {
|
|
7557
|
+
const below = body.length - window.end;
|
|
7558
|
+
lines.push(below > 0 ? ` ${theme.dim(`\u2193 ${below} more`)}` : "");
|
|
7559
|
+
}
|
|
6947
7560
|
lines.push("");
|
|
6948
7561
|
if (!rows.some((row) => row.detected)) {
|
|
6949
7562
|
lines.push(
|
|
@@ -7004,6 +7617,18 @@ async function pickClients(options, streams = {}) {
|
|
|
7004
7617
|
case "down":
|
|
7005
7618
|
cursor = moveCursor(rows, cursor, 1);
|
|
7006
7619
|
break;
|
|
7620
|
+
case "pageup":
|
|
7621
|
+
cursor = moveCursor(rows, cursor, -pageSize);
|
|
7622
|
+
break;
|
|
7623
|
+
case "pagedown":
|
|
7624
|
+
cursor = moveCursor(rows, cursor, pageSize);
|
|
7625
|
+
break;
|
|
7626
|
+
case "home":
|
|
7627
|
+
cursor = 0;
|
|
7628
|
+
break;
|
|
7629
|
+
case "end":
|
|
7630
|
+
cursor = rows.length - 1;
|
|
7631
|
+
break;
|
|
7007
7632
|
case "space":
|
|
7008
7633
|
case "spacebar":
|
|
7009
7634
|
rows[cursor] = { ...rows[cursor], selected: !rows[cursor].selected };
|