Skip to content

Commit 29d6b05

Browse files
authored
feat: replace inquirer with @clack/prompts for modern TUI (#13)
* fix: align Node.js engine requirement with runtime dependencies * feat: improve terminal UX with command mode and docs loop * feat: add roadmap shortcut in menu and command mode * feat: polish terminal UX with unix-style command mode * chore: migrate docs to wiki and prepare v1.0.10 release * chore: reduce npm package payload with files whitelist * chore: release v1.0.11 with publish diagnostics * chore: release v1.0.12 * chore: release v1.0.13 * feat: replace inquirer with @clack/prompts for modern TUI Replaces the entire inquirer stack with @clack/prompts, bringing the terminal experience in line with modern CLIs (Claude Code, Gemini CLI). Changes: - Drop inquirer, @inquirer/prompts, @types/inquirer (-87 packages) - Add @clack/prompts (+4 packages) - ui.ts: delegate success/error/info/warn to clack log.*; add createSpinner() that returns a real async-bound SpinnerResult - menu.ts: select() with emoji labels + hint text; isCancel + outro for graceful Ctrl+C exit; showAbout() now uses note() info box - main.ts: printHeader() replaced by intro() session frame - calendar.ts: real spinner bound to fetchEvents(); Unicode box-drawing table (┌─┬─┐) replaces dashed ASCII output - repair.ts, website.ts: spinner wraps open() instead of fake timer - docs.ts: all inquirer prompts replaced with select()/confirm(); doc category labels updated with emoji icons - i18n: add eventsFound key (zh + en); add field to Translations type Backward compatibility: src/index.ts script mode is untouched. All non-interactive commands (--json, --help, lang) continue to work.
1 parent 8e1a924 commit 29d6b05

22 files changed

Lines changed: 673 additions & 2555 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18, 20]
15+
node-version: [20, 22]
1616

1717
steps:
1818
- name: 🛎️ Checkout code

.github/workflows/publish.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,21 @@ jobs:
4949
echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT
5050
5151
- name: 🚀 Publish to npm
52-
run: npm publish --access public --provenance
52+
run: |
53+
set +e
54+
PUBLISH_OUTPUT=$(npm publish --access public --provenance 2>&1)
55+
PUBLISH_EXIT=$?
56+
set -e
57+
echo "$PUBLISH_OUTPUT"
58+
if [ "$PUBLISH_EXIT" -ne 0 ]; then
59+
if echo "$PUBLISH_OUTPUT" | grep -q "EOTP"; then
60+
echo "::error::npm publish failed with EOTP. Use an npm automation token for NPM_TOKEN or disable OTP requirement for token-based publish."
61+
fi
62+
exit "$PUBLISH_EXIT"
63+
fi
5364
env:
5465
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5566

5667
- name: ✅ Success notification
5768
run: |
5869
echo "🎉 Successfully published @nbtca/prompt@${{ steps.version.outputs.version }} to npm"
59-

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.12.0

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
# CHANGELOG
22

3+
Release notes are maintained in Wiki:
4+
5+
- https://github.com/nbtca/Prompt/wiki/Release-Notes
6+
7+
## [Unreleased]
8+
9+
## [1.0.13] - 2026-03-01
10+
11+
### Changed
12+
- Re-triggered release after rotating to npm classic automation token.
13+
14+
## [1.0.12] - 2026-03-01
15+
16+
### Changed
17+
- Triggered re-release after rotating npm automation token.
18+
19+
## [1.0.11] - 2026-03-01
20+
21+
### Changed
22+
- Improved npm publish workflow diagnostics for OTP-related failures (`EOTP`).
23+
- Reduced npm package payload via `files` whitelist in `package.json`.
24+
25+
## [1.0.10] - 2026-03-01
26+
27+
### Added
28+
- Command mode flags:
29+
- `--open` for explicit browser side effects on URL commands
30+
- `--json` for machine-readable event output
31+
- `--plain` for non-colored terminal output
32+
- `--no-logo` to skip startup logo in interactive mode
33+
- Roadmap shortcut support in both menu and command mode
34+
35+
### Changed
36+
- URL commands (`repair`, `website`, `github`, `roadmap`) now print URL by default in command mode
37+
- Main menu now includes quick command-mode hint
38+
- Docs menu keeps user in docs flow for repeated operations
39+
40+
### Improved
41+
- Better non-TTY behavior: startup logo animation is skipped outside interactive terminals
42+
- Error/warning messages consistently go to `stderr`
43+
- Terminal UX documentation rewritten with explicit output contract
44+
345
## [1.0.5] - 2025-12-10
446

547
### Fixed

DEVELOPMENT.md

Lines changed: 3 additions & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -1,258 +1,5 @@
1-
# 开发指南
1+
# Development Guide
22

3-
## 🚀 快速开始
3+
Moved to Wiki:
44

5-
### 安装依赖
6-
7-
```bash
8-
pnpm install
9-
```
10-
11-
## 🧪 本地测试方法
12-
13-
### ✅ 方法 1: 快速测试(推荐)
14-
15-
```bash
16-
pnpm run dev
17-
```
18-
19-
- ✅ 直接运行 TypeScript 源码
20-
- ✅ 不会自动重启
21-
- ✅ 适合交互式 CLI 测试
22-
- ✅ 程序退出后命令才结束
23-
- ✅ 可以正常使用 Ctrl+C 退出
24-
25-
**使用场景**: 日常开发和功能测试
26-
27-
### 📦 方法 2: 生产环境测试
28-
29-
```bash
30-
# 步骤 1: 构建
31-
pnpm run build
32-
33-
# 步骤 2: 运行
34-
pnpm start
35-
```
36-
37-
- ✅ 测试编译后的代码
38-
- ✅ 最接近生产环境
39-
- ⚠️ 修改代码后需要重新构建
40-
41-
**使用场景**: 发布前最终测试
42-
43-
### 🔗 方法 3: 全局命令测试
44-
45-
```bash
46-
# 步骤 1: 构建并链接到全局
47-
pnpm run build
48-
npm link
49-
50-
# 步骤 2: 在任何目录测试
51-
nbtca
52-
53-
# 步骤 3: 测试完成后清理
54-
npm unlink -g @nbtca/prompt
55-
```
56-
57-
**使用场景**: 测试全局安装体验
58-
59-
### ⚠️ 方法 4: 监听模式(不推荐用于交互式测试)
60-
61-
```bash
62-
pnpm run dev:watch
63-
```
64-
65-
- ⚠️ 文件变化时自动重启
66-
- ❌ 不适合交互式 CLI 测试
67-
- ❌ 会频繁中断交互
68-
- ✅ 仅适合纯函数/工具类开发
69-
70-
**使用场景**: 仅用于调试非交互式代码
71-
72-
## 🎯 测试新功能(知识库模块)
73-
74-
### 测试步骤
75-
76-
1. **启动程序**
77-
```bash
78-
pnpm run dev
79-
```
80-
81-
2. **选择 "知识库" 选项**
82-
- 使用方向键或 Vim 键位 (j/k) 导航
83-
- 按 Enter 确认
84-
85-
3. **浏览文档分类**
86-
- 📚 教程 (Tutorial)
87-
- 🔧 维修日
88-
- 🎉 相关活动举办
89-
- 📋 流程文档 (Process)
90-
- 🛠️ 维修相关 (Repair)
91-
- 📦 归档文档 (Archived)
92-
- 📖 README
93-
94-
4. **测试功能点**
95-
- [ ] 进入目录
96-
- [ ] 返回上级目录
97-
- [ ] 查看 Markdown 文件
98-
- [ ] 终端渲染是否正常
99-
- [ ] 在浏览器中打开
100-
- [ ] 网络错误处理
101-
102-
### 预期行为
103-
104-
**正常流程**:
105-
1. 从 GitHub 获取文档列表
106-
2. 显示目录树
107-
3. 选择文件后在终端渲染 Markdown
108-
4. 提供返回或浏览器打开选项
109-
110-
**错误处理**:
111-
1. GitHub API 失败时提示重试
112-
2. 文件加载失败时建议浏览器打开
113-
3. 网络超时友好提示
114-
115-
## 🔧 常见问题
116-
117-
### Q1: 为什么 `pnpm run dev``pnpm run dev:watch` 好?
118-
119-
**A**: 对于交互式 CLI 应用:
120-
121-
- `pnpm run dev` (tsx src/index.ts)
122-
- ✅ 运行一次,等待程序退出
123-
- ✅ 用户可以正常交互
124-
- ✅ Ctrl+C 正常工作
125-
126-
- `pnpm run dev:watch` (tsx watch src/index.ts)
127-
- ❌ 监听文件变化,自动重启
128-
- ❌ 用户操作会被中断
129-
- ❌ Ctrl+C 只能退出 tsx,不能优雅退出程序
130-
131-
### Q2: 如何退出正在运行的程序?
132-
133-
**A**:
134-
- **正常退出**: 在菜单中选择 "退出" 选项
135-
- **强制退出**: 按 `Ctrl+C`
136-
- 如果卡住: 按 `Ctrl+C` 两次
137-
138-
### Q3: 修改代码后看不到变化?
139-
140-
**A**: 取决于你的测试方法:
141-
- `pnpm run dev`: 重新运行命令即可
142-
- `pnpm start`: 需要先 `pnpm run build`
143-
- `npm link`: 需要 `pnpm run build` 后重新测试
144-
145-
### Q4: TypeScript 编译错误怎么办?
146-
147-
**A**:
148-
```bash
149-
# 检查类型错误
150-
pnpm run build
151-
152-
# 如果有错误,根据提示修复
153-
# 常见错误:
154-
# - 导入路径缺少 .js 后缀
155-
# - 类型定义不匹配
156-
# - 未使用的变量
157-
```
158-
159-
## 📝 开发工作流
160-
161-
### 日常开发
162-
163-
```bash
164-
# 1. 修改代码
165-
vim src/features/docs.ts
166-
167-
# 2. 测试
168-
pnpm run dev
169-
170-
# 3. 重复 1-2 直到功能完成
171-
```
172-
173-
### 提交前检查
174-
175-
```bash
176-
# 1. 确保构建通过
177-
pnpm run build
178-
179-
# 2. 测试编译后的代码
180-
pnpm start
181-
182-
# 3. 提交
183-
git add .
184-
git commit -m "feat: add terminal docs viewer"
185-
```
186-
187-
### 发布前测试
188-
189-
```bash
190-
# 1. 构建
191-
pnpm run build
192-
193-
# 2. 全局测试
194-
npm link
195-
nbtca
196-
197-
# 3. 清理
198-
npm unlink -g @nbtca/prompt
199-
```
200-
201-
## 🎨 代码规范
202-
203-
- 使用 TypeScript 严格模式
204-
- 函数添加 JSDoc 注释
205-
- 导入模块使用 `.js` 后缀(即使是 `.ts` 文件)
206-
- 保持代码简洁,避免过度抽象
207-
208-
## 📂 项目结构
209-
210-
```
211-
src/
212-
├── config/ # 配置常量
213-
│ ├── data.ts # URL、应用信息
214-
│ └── theme.ts # 颜色主题
215-
216-
├── core/ # 核心功能
217-
│ ├── logo.ts # Logo 显示
218-
│ ├── menu.ts # 主菜单
219-
│ ├── ui.ts # UI 组件
220-
│ └── vim-keys.ts # Vim 键位支持
221-
222-
├── features/ # 功能模块
223-
│ ├── calendar.ts # 活动日历
224-
│ ├── docs.ts # 知识库 ⭐ 新功能
225-
│ ├── repair.ts # 维修服务
226-
│ └── website.ts # 网站访问
227-
228-
├── logo/ # Logo 资源
229-
├── index.ts # 入口
230-
├── main.ts # 主逻辑
231-
└── types.ts # 类型定义
232-
```
233-
234-
## 🌟 新功能说明
235-
236-
### 知识库终端查看器
237-
238-
**文件**: `src/features/docs.ts`
239-
240-
**核心功能**:
241-
1. `fetchGitHubDirectory()` - 从 GitHub API 获取目录
242-
2. `fetchGitHubRawContent()` - 获取文件原始内容
243-
3. `browseDirectory()` - 交互式目录浏览
244-
4. `viewMarkdownFile()` - 终端渲染 Markdown
245-
5. `showDocsMenu()` - 主菜单入口
246-
247-
**依赖**:
248-
- `axios` - HTTP 请求
249-
- `marked` + `marked-terminal` - Markdown 渲染
250-
- `inquirer` - 交互式选择
251-
- `chalk` - 终端颜色
252-
253-
**测试要点**:
254-
- [ ] GitHub API 正常调用
255-
- [ ] 目录树正确显示
256-
- [ ] Markdown 渲染美观
257-
- [ ] 错误处理友好
258-
- [ ] 导航流畅
5+
- https://github.com/nbtca/Prompt/wiki/Development-Guide

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,22 @@ Or run directly:
1717
npx @nbtca/prompt
1818
```
1919

20-
## Usage
21-
22-
```bash
23-
nbtca
24-
```
25-
26-
Navigate with arrow keys or vim bindings (j/k/g/G).
27-
2820
## Documentation
2921

30-
See the [Wiki](https://github.com/nbtca/Prompt/wiki) for:
22+
Project documentation has been moved to the GitHub Wiki.
3123

32-
- [Development Guide](https://github.com/nbtca/Prompt/wiki/Development)
24+
- [Home](https://github.com/nbtca/Prompt/wiki)
25+
- [Getting Started](https://github.com/nbtca/Prompt/wiki/Getting-Started)
26+
- [Development Guide](https://github.com/nbtca/Prompt/wiki/Development-Guide)
27+
- [Terminal UX](https://github.com/nbtca/Prompt/wiki/Terminal-UX)
28+
- [Release Notes](https://github.com/nbtca/Prompt/wiki/Release-Notes)
3329
- [Features](https://github.com/nbtca/Prompt/wiki/Features)
3430
- [Terminal Compatibility](https://github.com/nbtca/Prompt/wiki/Terminal-Compatibility)
3531
- [FAQ](https://github.com/nbtca/Prompt/wiki/FAQ)
36-
- [Changelog](https://github.com/nbtca/Prompt/wiki/Changelog)
3732

3833
## Requirements
3934

40-
- Node.js >= 16.0.0
35+
- Node.js >= 20.12.0
4136

4237
## License
4338

0 commit comments

Comments
 (0)