@nbtca/prompt 1.0.1 → 1.0.4

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/CHANGELOG.md CHANGED
@@ -1,164 +1,77 @@
1
- # NBTCA Prompt - UI 重构完成 ✨
2
-
3
- ## 🎨 设计更新
4
-
5
- ### 1. 新的标语
6
- - 更换为英文标语:**"To be at the intersection of technology and liberal arts."**
7
- - 移除居中显示,采用左对齐布局
8
-
9
- ### 2. 渐变彩色效果
10
- - 使用 `gradient-string` 实现蓝色主调渐变
11
- - 颜色方案:深蓝 (#1e3a8a) 天蓝 (#0ea5e9) 青色 (#06b6d4)
12
- - 添加动画效果,启动时标语会有流动的渐变动画(0.8秒)
13
- - ✅ ASCII Logo 也使用蓝色渐变渲染
14
-
15
- ### 3. 极简 UI设计
16
- - 参考 Claude Code CLI 的简洁风格
17
- - 移除冗余装饰元素
18
- - 统一使用 dim 样式营造层次感
19
- - 更清晰的信息结构
20
-
21
- ### 4. Vim 键位支持
22
- - 支持 `j` 向下导航
23
- - 支持 `k` 向上导航
24
- - 支持 `g` 跳到顶部
25
- - 支持 `G` (Shift+g) 跳到底部
26
- - 同时保留标准的 `↑` `↓` 箭头键
27
- - ✅ 通过拦截 stdin 的 keypress 事件实现,无需修改 Inquirer
28
-
29
- ## 性能优化
30
-
31
- ### 启动速度优化
32
- - ✅ 动画时长优化:从 1.5秒 降至 0.8秒
33
- - ✅ 动画帧数优化:从 15帧 降至 8帧
34
- - 渐变预计算:避免重复创建渐变对象
35
- - 移除未使用的代码和文件
36
-
37
- ### 代码精简
38
- - 删除 `DATA_MANAGEMENT.md` 无用文档
39
- - 删除测试文件
40
- - 删除临时文档
41
- - 简化 UI 组件,移除未使用的函数
42
-
43
- ## 📦 依赖更新
44
-
45
- 新增依赖:
46
- ```json
47
- {
48
- "gradient-string": "^3.0.0",
49
- "@types/gradient-string": "^1.1.6",
50
- "@inquirer/prompts": "^8.0.3"
51
- }
52
- ```
53
-
54
- ## 🚀 使用方法
55
-
56
- ```bash
57
- # 安装依赖
58
- npm install
59
-
60
- # 构建项目
61
- npm run build
62
-
63
- # 运行
64
- npm start
65
-
66
- # 或者直接使用 npx(未来发布后)
67
- npx @nbtca/prompt
68
- ```
69
-
70
- ## 🎯 界面预览
71
-
72
- ```
73
- [ASCII Art Logo 以蓝色渐变显示]
74
-
75
- To be at the intersection of technology and liberal arts.
76
- [流动的蓝色渐变动画 - 0.8秒]
77
-
78
- v1.0.0
79
-
80
- ↑↓ / jk 导航 • ⏎ 选择 • g 顶部 • G 底部
81
-
82
- › 选择功能
83
- 近期活动 查看最近30天的社团活动
84
- ❯ 维修服务 电脑维修、软件安装
85
- 知识库 技术文档、教程资源
86
- 官方网站 访问NBTCA主页
87
- GitHub 开源项目与代码
88
- 关于 项目信息与帮助
89
-
90
- 退出
91
- ```
92
-
93
- ## ✨ 亮点特性
94
-
95
- 1. **真正的 Vim 键位** - j/k/g/G 完整支持,对 vim 用户极其友好
96
- 2. **视觉吸引力** - 蓝色渐变动画让启动时更有科技感
97
- 3. **快速启动** - 优化后动画仅需0.8秒,不影响使用体验
98
- 4. **现代简洁** - 参考行业标杆 Claude Code 的设计语言
99
- 5. **清晰易读** - 统一的层次结构和配色方案
100
-
101
- ## 📝 技术细节
102
-
103
- ### Vim 键位实现
104
- ```typescript
105
- // 通过拦截 stdin 的 keypress 事件来实现
106
- export function enableVimKeys() {
107
- const stdin = process.stdin;
108
- const originalEmit = stdin.emit.bind(stdin);
109
-
110
- (stdin.emit as any) = function (event: string, ...args: any[]) {
111
- if (event === 'keypress') {
112
- const [, key] = args;
113
-
114
- // j -> down, k -> up, g -> home, G -> end
115
- if (key.name === 'j') return originalEmit('keypress', null, { name: 'down' });
116
- if (key.name === 'k') return originalEmit('keypress', null, { name: 'up' });
117
- if (key.name === 'g' && !key.shift) return originalEmit('keypress', null, { name: 'home' });
118
- if (key.name === 'g' && key.shift) return originalEmit('keypress', null, { name: 'end' });
119
- }
120
- return originalEmit(event, ...args);
121
- };
122
- }
123
- ```
124
-
125
- ### 渐变实现
126
- ```typescript
127
- // 创建蓝色主调渐变
128
- const blueGradient = gradient([
129
- { color: '#1e3a8a', pos: 0 }, // 深蓝
130
- { color: '#0ea5e9', pos: 0.5 }, // 天蓝
131
- { color: '#06b6d4', pos: 1 } // 青色
132
- ]);
133
-
134
- // 应用到文本
135
- console.log(blueGradient('To be at the intersection of technology and liberal arts.'));
136
- ```
137
-
138
- ### 动画循环
139
- ```typescript
140
- // 使用3种颜色组合创造流动效果
141
- const gradients = [
142
- gradient('#1e3a8a', '#0ea5e9', '#06b6d4'),
143
- gradient('#0ea5e9', '#06b6d4', '#1e3a8a'),
144
- gradient('#06b6d4', '#1e3a8a', '#0ea5e9'),
145
- ];
146
-
147
- // 循环显示 8 帧,每帧 100ms
148
- for (let i = 0; i < 8; i++) {
149
- const frameGradient = gradients[i % 3];
150
- process.stdout.write('\r' + frameGradient(text));
151
- await delay(100);
152
- }
153
- ```
154
-
155
- ## 🔧 后续优化建议
156
-
157
- 1. ✨ 添加 `--no-animation` 参数跳过动画
158
- 2. 🎨 支持自定义主题色
159
- 3. ⚡ 考虑懒加载非必要模块
160
- 4. 📦 使用 esbuild 打包减小体积
161
-
162
- ---
163
-
164
- **最佳实践**:现代 CLI 工具应该兼顾美观性和性能,0.8秒的动画是一个很好的平衡点,既不会让用户感到等待,又能提供愉悦的视觉体验。同时,真正的 Vim 键位支持让工具对开发者更加友好。
1
+ # CHANGELOG
2
+
3
+ ## [1.0.2] - 2025-11-27
4
+
5
+ ### Added
6
+ - **Terminal Documentation Viewer**: Browse and read Markdown documentation from nbtca/documents repository directly in terminal
7
+ - GitHub API integration for fetching directory structure and file contents
8
+ - Recursive directory navigation with [DIR] and [MD] indicators
9
+ - VitePress syntax cleaning (frontmatter, containers, [[toc]], HTML comments)
10
+ - Terminal Markdown rendering using marked-terminal
11
+ - Browser fallback on network errors or user preference
12
+ - Retry mechanism for failed network requests
13
+
14
+ ### Changed
15
+ - **ASCII-Only Interface**: Removed all emoji icons for maximum terminal compatibility
16
+ - Replaced emoji with ASCII symbols: [*], [?], [x], [..], [DIR], [MD], [ <], [ ^], [ *]
17
+ - Works on all terminal emulators, SSH sessions, tmux, and legacy systems
18
+ - Follows Unix/Linux terminal conventions
19
+ - Professional, minimalist design
20
+
21
+ ### Improved
22
+ - **Terminal UX Enhancements**:
23
+ - Added keybinding hints to main menu: "Navigation: j/k or ↑/↓ | Jump: g/G | Quit: q or Ctrl+C"
24
+ - Added ESC key infrastructure for future back navigation and operation cancellation
25
+ - Standardized navigation symbols across all menus
26
+ - Better vim-keys.ts documentation with clearer comments
27
+
28
+ ### Fixed
29
+ - **Development Workflow**: Fixed `pnpm run dev` auto-restart issue
30
+ - Split dev command: `dev` (no watch, for interactive CLI) and `dev:watch` (with watch mode)
31
+ - Proper exit behavior for interactive CLI testing
32
+
33
+ ### Documentation
34
+ - Added DEVELOPMENT.md: Comprehensive development guide with workflows, testing methods, and common issues
35
+ - Added TERMINAL_UX.md: Terminal UX improvements and compatibility documentation
36
+ - Updated README.md: Professional, concise documentation without decorative elements
37
+
38
+ ### Technical Details
39
+ - Enhanced docs.ts with GitHub repository integration
40
+ - Improved menu.ts with ASCII symbols and keybinding hints
41
+ - Enhanced vim-keys.ts with ESC support and better documentation
42
+ - Better package.json scripts for development workflow
43
+
44
+ ## [1.0.1] - 2025-11-21
45
+
46
+ ### Added
47
+ - New English tagline with smooth blue gradient animation
48
+ - Full Vim keybindings support (j/k/g/G/q)
49
+ - Minimalist UI design inspired by Claude Code CLI
50
+
51
+ ### Improved
52
+ - Smoother gradient animation (24 frames, 1.2s duration)
53
+ - Removed keyboard instruction text for cleaner interface
54
+ - Blue color scheme throughout (deep blue → sky blue → cyan)
55
+
56
+ ### Changed
57
+ - q key now exits the application
58
+ - Removed Chinese tagline
59
+ - Simplified menu layout
60
+
61
+ ### Removed
62
+ - Unused DATA_MANAGEMENT.md documentation
63
+
64
+ ### Dependencies
65
+ - Updated gradient-string to ^3.0.0
66
+ - Updated @inquirer/prompts to ^8.0.3
67
+
68
+ ## [1.0.0] - 2025-11-21
69
+
70
+ ### Added
71
+ - Initial release of NBTCA Prompt CLI tool
72
+ - Interactive terminal menu system
73
+ - Event calendar integration
74
+ - Repair service information
75
+ - Knowledge base access
76
+ - Quick links to official website and GitHub
77
+ - About section with project information
package/DEVELOPMENT.md ADDED
@@ -0,0 +1,258 @@
1
+ # 开发指南
2
+
3
+ ## 🚀 快速开始
4
+
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
+ - [ ] 导航流畅