Skip to content

Commit aa79fd1

Browse files
committed
chore: release v2.1.2
- 优化初始化流程,移除文档更新的特殊处理 - 优化 MCP 服务选择界面,使用 inquirer 原生全选功能 - 提取公共方法减少代码重复 - 简化配置步骤,提升用户体验
1 parent 2429658 commit aa79fd1

7 files changed

Lines changed: 93 additions & 60 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# MCP 配置优化任务
2+
3+
## 任务概述
4+
优化 MCP 配置选择界面:
5+
1. 移除 ALL 选项
6+
2. 在提示中添加 "a全选" 说明
7+
3. 去除重复的描述文字
8+
4. 提取公共方法避免重复实现
9+
10+
## 执行计划
11+
1. ✅ 创建 `mcp-selector.ts` 公共方法文件
12+
2. ✅ 更新 `constants.ts` 添加新的提示文字常量
13+
3. ✅ 修改 `init.ts` 使用新的公共方法
14+
4. ✅ 修改 `features.ts` 使用新的公共方法
15+
5. ✅ 运行类型检查确保代码正确
16+
17+
## 实施结果
18+
- 成功创建了 `mcp-selector.ts` 统一管理 MCP 选择逻辑
19+
- 在常量中添加了清晰的提示文字,包含 "a全选" 说明
20+
- 移除了 ALL 选项,使用 inquirer 原生的全选功能
21+
- 两处 MCP 选择逻辑已统一,代码复用性提高
22+
- 类型检查通过,代码正确性得到验证
23+
24+
## 技术细节
25+
- 利用 inquirer checkbox 的原生全选功能(按 a 键)
26+
- 统一 MCP 选择逻辑到一个公共函数
27+
- 清晰的提示文字,避免重复描述

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 2.1.2
4+
5+
### Patch Changes
6+
7+
- ## 优化
8+
9+
- 优化初始化流程,移除文档更新的特殊处理
10+
- 简化配置步骤,提升用户体验
11+
- 减少不必要的代码复杂度
12+
13+
## Optimization
14+
15+
- Optimize initialization process and remove special handling for document updates
16+
- Simplify configuration steps to improve user experience
17+
- Reduce unnecessary code complexity
18+
319
## 2.1.1
420

521
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zcf",
33
"type": "module",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"packageManager": "pnpm@9.15.9",
66
"description": "Zero-Config Claude-Code Flow - One-click configuration tool for Claude Code",
77
"license": "MIT",

src/commands/init.ts

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { isWindows, isTermux } from '../utils/platform';
3434
import { resolveAiOutputLanguage, selectScriptLanguage } from '../utils/prompts';
3535
import { formatApiKeyDisplay } from '../utils/validator';
3636
import { readZcfConfig, updateZcfConfig } from '../utils/zcf-config';
37+
import { selectMcpServices } from '../utils/mcp-selector';
3738

3839
export interface InitOptions {
3940
lang?: SupportedLang;
@@ -291,39 +292,13 @@ export async function init(options: InitOptions = {}) {
291292
);
292293
}
293294

294-
// Create choices array with "All" option first
295-
const choices = [
296-
{
297-
title: ansis.bold(i18n.allServices),
298-
value: 'ALL',
299-
selected: false,
300-
},
301-
...MCP_SERVICES.map((service) => ({
302-
title: `${service.name[scriptLang]} - ${ansis.gray(service.description[scriptLang])}`,
303-
value: service.id,
304-
selected: false,
305-
})),
306-
];
307-
308-
const { services } = await inquirer.prompt<{ services: string[] }>({
309-
type: 'checkbox',
310-
name: 'services',
311-
message: i18n.selectMcpServices + ' ' + ansis.gray(i18n.spaceToSelectReturn),
312-
choices,
313-
});
314-
315-
if (services === undefined) {
316-
console.log(ansis.yellow(i18n.cancelled));
295+
// Use common MCP selector
296+
const selectedServices = await selectMcpServices(scriptLang);
297+
298+
if (selectedServices === undefined) {
317299
process.exit(0);
318300
}
319301

320-
let selectedServices = services || [];
321-
322-
// If "ALL" is selected, select all services
323-
if (selectedServices.includes('ALL')) {
324-
selectedServices = MCP_SERVICES.map((s) => s.id);
325-
}
326-
327302
if (selectedServices.length > 0) {
328303
// Backup existing MCP config if exists
329304
const mcpBackupPath = backupMcpConfig();

src/constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const I18N = {
8181
configSuccess: '配置文件已复制到',
8282
apiConfigSuccess: 'API 配置完成',
8383
mcpConfigSuccess: 'MCP 服务已配置',
84-
selectMcpServices: '选择要安装的 MCP 服务(空格选择,回车确认)',
84+
selectMcpServices: '选择要安装的 MCP 服务(空格选择,a全选,i反选,回车确认)',
8585
allServices: '全部安装',
8686
mcpServiceInstalled: '已选择的 MCP 服务',
8787
enterExaApiKey: '请输入 Exa API Key(可从 https://dashboard.exa.ai/api-keys 获取)',
@@ -256,7 +256,8 @@ export const I18N = {
256256
configSuccess: 'Config files copied to',
257257
apiConfigSuccess: 'API configured',
258258
mcpConfigSuccess: 'MCP services configured',
259-
selectMcpServices: 'Select MCP services to install (space to select, enter to confirm)',
259+
selectMcpServices:
260+
'Select MCP services to install (space to select, a to select all, i to deselect, enter to confirm)',
260261
allServices: 'Install all',
261262
mcpServiceInstalled: 'Selected MCP services',
262263
enterExaApiKey: 'Enter Exa API Key (get from https://dashboard.exa.ai/api-keys)',

src/utils/features.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { readZcfConfig, updateZcfConfig } from './zcf-config';
2424
import { validateApiKey, formatApiKeyDisplay } from './validator';
2525
import { configureAiPersonality } from './ai-personality';
2626
import { modifyApiConfigPartially } from './config-operations';
27+
import { selectMcpServices } from './mcp-selector';
2728

2829
// Helper function to handle cancelled operations
2930
function handleCancellation(scriptLang: SupportedLang): void {
@@ -175,36 +176,13 @@ export async function configureMcpFeature(scriptLang: SupportedLang) {
175176
}
176177
}
177178

178-
// Show MCP services selection
179-
const choices = [
180-
{
181-
title: ansis.bold(i18n.allServices),
182-
value: 'ALL',
183-
selected: false,
184-
},
185-
...MCP_SERVICES.map((service) => ({
186-
title: `${service.name[scriptLang]} - ${ansis.gray(service.description[scriptLang])}`,
187-
value: service.id,
188-
selected: false,
189-
})),
190-
];
191-
192-
const { services } = await inquirer.prompt<{ services: string[] }>({
193-
type: 'checkbox',
194-
name: 'services',
195-
message: i18n.selectMcpServices + ' ' + ansis.gray(i18n.spaceToSelectReturn),
196-
choices,
197-
});
198-
199-
if (!services) {
179+
// Use common MCP selector
180+
const selectedServices = await selectMcpServices(scriptLang);
181+
182+
if (!selectedServices) {
200183
return;
201184
}
202185

203-
let selectedServices = services || [];
204-
if (selectedServices.includes('ALL')) {
205-
selectedServices = MCP_SERVICES.map((s) => s.id);
206-
}
207-
208186
if (selectedServices.length > 0) {
209187
const mcpBackupPath = backupMcpConfig();
210188
if (mcpBackupPath) {

src/utils/mcp-selector.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import inquirer from 'inquirer';
2+
import ansis from 'ansis';
3+
import type { SupportedLang } from '../constants';
4+
import { I18N, MCP_SERVICES } from '../constants';
5+
6+
/**
7+
* Common function to select MCP services
8+
* @param scriptLang Current script language
9+
* @returns Array of selected service IDs, or undefined if cancelled
10+
*/
11+
export async function selectMcpServices(scriptLang: SupportedLang): Promise<string[] | undefined> {
12+
const i18n = I18N[scriptLang];
13+
14+
// Build choices without ALL option
15+
const choices = MCP_SERVICES.map((service) => ({
16+
name: `${service.name[scriptLang]} - ${ansis.gray(service.description[scriptLang])}`,
17+
value: service.id,
18+
selected: false,
19+
}));
20+
21+
const { services } = await inquirer.prompt<{ services: string[] }>({
22+
type: 'checkbox',
23+
name: 'services',
24+
message: i18n.selectMcpServices,
25+
choices,
26+
});
27+
28+
// Return undefined if cancelled (user pressed Ctrl+C or similar)
29+
if (services === undefined) {
30+
console.log(ansis.yellow(i18n.cancelled));
31+
return undefined;
32+
}
33+
34+
// Return the selected services (could be empty array)
35+
return services;
36+
}

0 commit comments

Comments
 (0)