jinzd-ai-cli 0.1.37 → 0.1.38
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/CLAUDE.md
CHANGED
|
@@ -42,6 +42,7 @@ src/
|
|
|
42
42
|
├── repl/
|
|
43
43
|
│ ├── repl.ts # 主 REPL 循环(MAX_TOOL_ROUNDS=20,handleChatWithTools agentic loop)
|
|
44
44
|
│ ├── renderer.ts # 终端输出(renderStream / renderResponse 均不加前置 \n)
|
|
45
|
+
│ ├── theme.ts # 集中式主题系统(dark/light/custom 主题 + 语义色槽 Proxy 导出)
|
|
45
46
|
│ ├── dev-state.ts # 开发状态交接(provider/model 切换时快照生成、save/load/clear)
|
|
46
47
|
│ ├── setup-wizard.ts # @inquirer/prompts 首次运行交互式设置
|
|
47
48
|
│ └── commands/
|
|
@@ -333,6 +334,10 @@ const stdinLines = Array.isArray(rawStdin) ? rawStdin.map(String)
|
|
|
333
334
|
- [x] **Checkpointing**(2026-02-28):`/checkpoint save/restore/list/delete`,检查点元数据随 session JSON 持久化
|
|
334
335
|
- [x] **`/review` 代码审查**(2026-02-28):读取 git diff + 上下文,AI 生成结构化审查意见(`--staged`/`--detailed`)
|
|
335
336
|
- [x] **Custom Commands**(2026-02-28):`~/.aicli/commands/*.md` 用户自定义命令,YAML frontmatter + `{{input}}/{{git-diff}}/{{git-context}}/{{file:path}}` 模板变量
|
|
337
|
+
- [x] **项目级 `.mcp.json`**(2026-03-05):项目根目录 `.mcp.json` 自动发现,与全局 `config.json` 的 `mcpServers` 合并(项目覆盖同名),`/mcp` 显示 `[global]`/`[project]` 来源标签
|
|
338
|
+
- [x] **`--resume <id>` 启动参数**(2026-03-05):命令行直接恢复指定会话(前缀匹配),找不到时显示最近 5 个 session 提示
|
|
339
|
+
- [x] **Word wrap 配置**(2026-03-05):`config.ui.wordWrap`,0=自动(终端宽度),>0=固定列宽。ANSI 转义码感知折行
|
|
340
|
+
- [x] **主题/颜色自定义**(2026-03-05):`src/repl/theme.ts` 集中式主题系统,dark/light/custom 三主题 + 10 语义色槽 + Proxy 全局导出
|
|
336
341
|
|
|
337
342
|
## 已知待改进项
|
|
338
343
|
|
|
@@ -343,6 +348,79 @@ const stdinLines = Array.isArray(rawStdin) ? rawStdin.map(String)
|
|
|
343
348
|
- [x] **web_fetch DNS 解析时 SSRF 防护**(v0.1.25):新增 `resolveAndCheck()` 函数,用 `dns.promises.lookup()` 预解析域名,检查结果 IP 是否为私有地址。初始 URL 和 redirect 目标均校验。
|
|
344
349
|
- [ ] **`persistentCwd` 全局状态**:bash 工具的当前工作目录是模块级全局变量,多 session 并发时可能串扰。现阶段单 session REPL 无影响,GUI 多会话扩展时需重构为 per-session 状态。
|
|
345
350
|
|
|
351
|
+
## 本轮开发完成记录(2026-03-05,v0.1.36 → v0.1.37)
|
|
352
|
+
|
|
353
|
+
### P2 四项功能全部实现
|
|
354
|
+
|
|
355
|
+
**Feature 1:项目级 `.mcp.json`**(`src/repl/repl.ts` + `src/repl/commands/index.ts` + `src/core/constants.ts`)
|
|
356
|
+
- `src/core/constants.ts`:新增 `MCP_PROJECT_CONFIG_NAME = '.mcp.json'`
|
|
357
|
+
- `src/repl/repl.ts`:
|
|
358
|
+
- 新增私有属性 `mcpServerSources = new Map<string, 'global' | 'project'>()`
|
|
359
|
+
- 新增 `loadProjectMcpConfig()` 方法:`getGitRoot(cwd)` 查找项目根 → 读取 `<root>/.mcp.json` → 基础校验(每个 server 须有 `command` 字段)→ 解析失败 stderr 警告不中断启动
|
|
360
|
+
- `start()` 中 MCP 初始化重构:先获取全局 `mcpServers`,再获取项目 `.mcp.json`,合并(项目覆盖全局同名),记录来源到 `mcpServerSources`
|
|
361
|
+
- CommandContext 注入 `getMcpServerSource`
|
|
362
|
+
- `src/repl/commands/index.ts`:`/mcp` 命令显示每个服务器的 `[global]`/`[project]` 来源标签
|
|
363
|
+
|
|
364
|
+
**Feature 2:`--resume <id>` 启动参数**(`src/index.ts` + `src/repl/repl.ts`)
|
|
365
|
+
- `src/index.ts`:新增 `--resume <id>` CLI 选项 + `startRepl` 参数传入
|
|
366
|
+
- `src/repl/repl.ts`:
|
|
367
|
+
- constructor options 扩展 `resumeSessionId?: string`
|
|
368
|
+
- `start()` 有 `resumeSessionId` 时:`listSessions()` 前缀匹配 → 未找到显示最近 5 个 session + exit(1) → 找到则 `loadSession()` 恢复
|
|
369
|
+
- welcome 后显示 `📂 Resumed session: <id> (<N> messages, "<title>")`
|
|
370
|
+
|
|
371
|
+
**Feature 3:Word wrap 配置**(`src/config/schema.ts` + `src/repl/renderer.ts` + `src/repl/repl.ts`)
|
|
372
|
+
- `src/config/schema.ts`:`ui` 对象新增 `wordWrap: z.number().int().min(0).default(0)`(0=自动,>0=固定列宽)
|
|
373
|
+
- `src/repl/renderer.ts`:
|
|
374
|
+
- 新增 `stripAnsi(s: string): string` — 去除 ANSI 转义码(正则匹配 ESC 序列)
|
|
375
|
+
- 新增 `wrapText(text: string, width: number | undefined): string` — 逐行处理,按单词边界折行,ANSI 码不计入宽度
|
|
376
|
+
- Renderer constructor 扩展 `options?: { wrapWidth?: number }`
|
|
377
|
+
- `renderResponse()` 对内容应用 `wrapText()`(流式模式不折行,由终端自然处理)
|
|
378
|
+
|
|
379
|
+
**Feature 4:主题/颜色自定义**(`src/repl/theme.ts` + `src/config/schema.ts` + 多文件迁移)
|
|
380
|
+
- `src/config/schema.ts`:`ui` 对象新增 `theme: z.enum(['dark', 'light', 'custom']).default('dark')` + `colors` 对象(10 个可选色槽)
|
|
381
|
+
- **新文件** `src/repl/theme.ts`:
|
|
382
|
+
- `ThemeColors` 接口:10 个语义色槽(prompt/info/warning/error/success/dim/accent/toolCall/toolResult/heading)→ `ChalkInstance`
|
|
383
|
+
- `DARK_THEME`:精确匹配 v0.1.36 硬编码颜色(green/cyan/yellow/red/dim/magenta 等),确保零变化升级
|
|
384
|
+
- `LIGHT_THEME`:浅色终端优化(blue/blueBright/gray 等)
|
|
385
|
+
- `resolveColor(name: string)`:支持 chalk 颜色名 + `#hex` + `bold.cyan` 组合样式
|
|
386
|
+
- `buildCustomTheme(base, overrides)`:以 base 主题为底 + 自定义覆盖
|
|
387
|
+
- `initTheme(themeId, customColors?)`:设置全局主题
|
|
388
|
+
- `theme`:Proxy 导出,始终指向当前活跃主题
|
|
389
|
+
- 迁移覆盖:
|
|
390
|
+
- `src/repl/renderer.ts`:`printWelcome`(heading/prompt/dim)、`printPrompt`(prompt)、`renderStream`(accent)、`renderResponse`(accent)、`renderError`(error)、`printInfo`(warning)、`printSuccess`(success)
|
|
391
|
+
- `src/tools/executor.ts`:`printToolCall`(toolCall/accent/dim)、`printToolResult`(error/toolResult/warning)
|
|
392
|
+
- `src/repl/repl.ts`:constructor 中调用 `initTheme()`,传入 `wrapWidth` 给 Renderer
|
|
393
|
+
|
|
394
|
+
### 版本与收尾
|
|
395
|
+
- `src/core/constants.ts`:VERSION `0.1.36` → `0.1.37`
|
|
396
|
+
- `package.json`:version 同步
|
|
397
|
+
- `src/repl/renderer.ts`:`/about` 新增 4 条特性条目(项目级 .mcp.json / --resume / Word wrap / 主题系统)
|
|
398
|
+
- 构建验证:`npm run build` 零错误
|
|
399
|
+
- 发布:`npm publish` → `jinzd-ai-cli@0.1.37`
|
|
400
|
+
|
|
401
|
+
### 本轮变更文件汇总
|
|
402
|
+
|
|
403
|
+
| 文件 | 变更类型 | 说明 |
|
|
404
|
+
|------|---------|------|
|
|
405
|
+
| `src/core/constants.ts` | 修改 | VERSION 0.1.36 → 0.1.37,新增 MCP_PROJECT_CONFIG_NAME |
|
|
406
|
+
| `src/config/schema.ts` | 修改 | `ui.wordWrap` + `ui.theme` + `ui.colors` 三个新字段 |
|
|
407
|
+
| `src/repl/theme.ts` | 新增 | 集中式主题系统(ThemeColors + DARK/LIGHT + Proxy) |
|
|
408
|
+
| `src/repl/repl.ts` | 修改 | .mcp.json 加载 + --resume + theme 初始化 + mcpServerSources |
|
|
409
|
+
| `src/repl/renderer.ts` | 修改 | stripAnsi/wrapText 辅助函数 + theme 迁移 + /about 更新 |
|
|
410
|
+
| `src/tools/executor.ts` | 修改 | theme 迁移(printToolCall/printToolResult) |
|
|
411
|
+
| `src/repl/commands/index.ts` | 修改 | getMcpServerSource + /mcp 来源标签 |
|
|
412
|
+
| `src/index.ts` | 修改 | --resume CLI 选项 |
|
|
413
|
+
| `package.json` | 修改 | version 0.1.36 → 0.1.37 |
|
|
414
|
+
|
|
415
|
+
### 下一步建议
|
|
416
|
+
1. **Extended Thinking**:Claude 3.7 深度推理模式集成
|
|
417
|
+
2. **theme 迁移扩展**:`commands/index.ts` 中 ~115 个 chalk 调用增量迁移为 theme 调用
|
|
418
|
+
3. **L1 低危**:`run-tests.ts` 的 `JSON.parse(package.json)` 细粒度错误处理
|
|
419
|
+
4. **IDE 集成**:VS Code 扩展(架构已准备就绪)
|
|
420
|
+
5. **OAuth/浏览器登录**:无需手动填 API Key
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
346
424
|
## 本轮开发完成记录(2026-03-05,v0.1.34 → v0.1.36)
|
|
347
425
|
|
|
348
426
|
### v0.1.35 — P0 功能缺口 + P1 前三项
|
|
@@ -423,10 +501,10 @@ const stdinLines = Array.isArray(rawStdin) ? rawStdin.map(String)
|
|
|
423
501
|
| `USAGE.md` | 新增 | 21 章节完整用户使用说明文档 |
|
|
424
502
|
|
|
425
503
|
### 下一步建议(P2 优先)
|
|
426
|
-
1.
|
|
427
|
-
2.
|
|
428
|
-
3.
|
|
429
|
-
4.
|
|
504
|
+
1. ~~**项目级 `.mcp.json`**~~:✅ 已在 v0.1.37 实现
|
|
505
|
+
2. ~~**`--resume <id>` 启动参数**~~:✅ 已在 v0.1.37 实现
|
|
506
|
+
3. ~~**Word wrap 配置**~~:✅ 已在 v0.1.37 实现
|
|
507
|
+
4. ~~**主题/颜色自定义**~~:✅ 已在 v0.1.37 实现
|
|
430
508
|
5. **L1 低危**:`run-tests.ts` 的 `JSON.parse(package.json)` 细粒度错误处理
|
|
431
509
|
|
|
432
510
|
---
|
|
@@ -1106,6 +1184,8 @@ const stdinLines = Array.isArray(rawStdin) ? rawStdin.map(String)
|
|
|
1106
1184
|
- Dev State 开发状态交接
|
|
1107
1185
|
- Agent Skills 系统
|
|
1108
1186
|
- 企业级权限规则 + Hooks 系统
|
|
1187
|
+
- 主题/颜色自定义系统(dark/light/custom + 10 语义色槽)
|
|
1188
|
+
- 项目级 MCP 配置(`.mcp.json` + 全局合并 + 来源追踪)
|
|
1109
1189
|
|
|
1110
1190
|
### ❌ 缺失功能路线图(新增)
|
|
1111
1191
|
|
|
@@ -1124,11 +1204,11 @@ const stdinLines = Array.isArray(rawStdin) ? rawStdin.map(String)
|
|
|
1124
1204
|
- [x] **`--allowed-tools` / `--blocked-tools` 启动参数**(v0.1.35):启动时白名单/黑名单限制 AI 可用工具
|
|
1125
1205
|
- [x] **流式 JSON 输出**(v0.1.36):`--output-format streaming-json`,NDJSON 每 chunk 一行 `{"type":"delta","text":"..."}` + 最终 `{"type":"done",...}`
|
|
1126
1206
|
|
|
1127
|
-
#### P2 —
|
|
1128
|
-
- [
|
|
1207
|
+
#### P2 — 体验增强(v0.1.37 完成 4 项)
|
|
1208
|
+
- [x] **项目级 `.mcp.json`**(v0.1.37):项目根目录 `.mcp.json` 自动发现,与全局合并(项目覆盖同名),`/mcp` 显示来源标签
|
|
1209
|
+
- [x] **`--resume <id>` 启动参数**(v0.1.37):命令行直接恢复指定会话(前缀匹配),找不到时显示最近 5 个 session
|
|
1210
|
+
- [x] **Word wrap 配置**(v0.1.37):`config.ui.wordWrap`,ANSI 转义码感知折行
|
|
1211
|
+
- [x] **主题/颜色自定义**(v0.1.37):dark/light/custom 三主题 + 10 语义色槽 + Proxy 全局导出
|
|
1129
1212
|
- [ ] **IDE 集成**:VS Code / JetBrains 扩展(架构已准备就绪)
|
|
1130
1213
|
- [ ] **OAuth/浏览器登录**:无需手动填 API Key
|
|
1131
|
-
- [ ]
|
|
1132
|
-
- [ ] **Extended Thinking**:Claude 3.7 深度推理模式集成
|
|
1133
|
-
- [ ] **Word wrap 配置**:终端输出折行宽度可配置
|
|
1134
|
-
- [ ] **主题/颜色自定义**:dark/light/custom 主题
|
|
1214
|
+
- [ ] **Extended Thinking**:Claude 深度推理模式集成
|