@nbtca/prompt 1.0.8 → 1.0.13

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.
Files changed (71) hide show
  1. package/README.md +16 -289
  2. package/dist/config/data.d.ts +1 -1
  3. package/dist/config/data.js +1 -1
  4. package/dist/config/data.js.map +1 -1
  5. package/dist/core/logo.d.ts.map +1 -1
  6. package/dist/core/logo.js +13 -2
  7. package/dist/core/logo.js.map +1 -1
  8. package/dist/core/menu.d.ts +5 -0
  9. package/dist/core/menu.d.ts.map +1 -1
  10. package/dist/core/menu.js +12 -5
  11. package/dist/core/menu.js.map +1 -1
  12. package/dist/core/ui.d.ts.map +1 -1
  13. package/dist/core/ui.js +5 -3
  14. package/dist/core/ui.js.map +1 -1
  15. package/dist/features/calendar.d.ts +13 -14
  16. package/dist/features/calendar.d.ts.map +1 -1
  17. package/dist/features/calendar.js +57 -59
  18. package/dist/features/calendar.js.map +1 -1
  19. package/dist/features/docs.d.ts.map +1 -1
  20. package/dist/features/docs.js +50 -47
  21. package/dist/features/docs.js.map +1 -1
  22. package/dist/features/repair.d.ts +4 -0
  23. package/dist/features/repair.d.ts.map +1 -1
  24. package/dist/features/repair.js +1 -1
  25. package/dist/features/repair.js.map +1 -1
  26. package/dist/features/website.d.ts +10 -0
  27. package/dist/features/website.d.ts.map +1 -1
  28. package/dist/features/website.js +14 -2
  29. package/dist/features/website.js.map +1 -1
  30. package/dist/i18n/index.d.ts +9 -0
  31. package/dist/i18n/index.d.ts.map +1 -1
  32. package/dist/i18n/index.js.map +1 -1
  33. package/dist/i18n/locales/en.json +10 -1
  34. package/dist/i18n/locales/zh.json +10 -1
  35. package/dist/index.d.ts +1 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +133 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/main.d.ts +4 -1
  40. package/dist/main.d.ts.map +1 -1
  41. package/dist/main.js +7 -3
  42. package/dist/main.js.map +1 -1
  43. package/package.json +8 -2
  44. package/.github/workflows/ci.yml +0 -40
  45. package/.github/workflows/publish.yml +0 -59
  46. package/CHANGELOG.md +0 -125
  47. package/DEVELOPMENT.md +0 -258
  48. package/TERMINAL_UX.md +0 -184
  49. package/assets/Prompt_demo.gif +0 -0
  50. package/src/config/data.js +0 -484
  51. package/src/config/data.ts +0 -28
  52. package/src/config/theme.js +0 -138
  53. package/src/config/theme.ts +0 -26
  54. package/src/core/logo.ts +0 -189
  55. package/src/core/menu.ts +0 -213
  56. package/src/core/ui.ts +0 -89
  57. package/src/core/vim-keys.ts +0 -70
  58. package/src/features/calendar.ts +0 -161
  59. package/src/features/docs.ts +0 -588
  60. package/src/features/repair.ts +0 -36
  61. package/src/features/website.ts +0 -45
  62. package/src/i18n/index.ts +0 -236
  63. package/src/i18n/locales/en.json +0 -107
  64. package/src/i18n/locales/zh.json +0 -107
  65. package/src/index.ts +0 -9
  66. package/src/logo/ascii-logo.txt +0 -6
  67. package/src/logo/logo.txt +0 -2
  68. package/src/logo/printLogo.js +0 -26
  69. package/src/main.ts +0 -45
  70. package/src/types.ts +0 -51
  71. package/tsconfig.json +0 -53
package/DEVELOPMENT.md DELETED
@@ -1,258 +0,0 @@
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
- - [ ] 导航流畅
package/TERMINAL_UX.md DELETED
@@ -1,184 +0,0 @@
1
- # Terminal UX Improvements
2
-
3
- ## Summary
4
-
5
- All changes align with standard Linux/Unix terminal conventions for better user experience and consistency.
6
-
7
- ## Changes Made
8
-
9
- ### 1. Standardized Navigation Symbols
10
-
11
- **Before**:
12
- ```
13
- [📁] emoji icons
14
- [<-] inconsistent arrows
15
- [ ] empty brackets
16
- ```
17
-
18
- **After**:
19
- ```
20
- [..] - Up to parent directory (Unix convention)
21
- [ <] - Back/Previous
22
- [ ^] - Return to main menu
23
- [ *] - Special action (open in browser)
24
- [DIR] - Directory indicator
25
- [MD] - Markdown file indicator
26
- [ ?] - Help/About
27
- [ x] - Exit
28
- ```
29
-
30
- **Rationale**: ASCII-only symbols ensure maximum terminal compatibility and follow Unix conventions (e.g., `..` for parent directory).
31
-
32
- ### 2. Added Keybinding Hints
33
-
34
- **Main Menu**:
35
- ```
36
- Navigation: j/k or ↑/↓ | Jump: g/G | Quit: q or Ctrl+C
37
- ```
38
-
39
- **Location**: Displayed above main menu for visibility
40
-
41
- **Rationale**: Users should know available shortcuts without reading documentation.
42
-
43
- ### 3. ESC Key Support
44
-
45
- **Implementation**: ESC key now properly passed through to menus
46
-
47
- **Expected Behavior** (future enhancement):
48
- - ESC in submenus = go back one level
49
- - ESC in main menu = exit application
50
-
51
- **Current State**: Infrastructure added, full implementation needs inquirer customization
52
-
53
- **Rationale**: ESC is standard cancel/back key in Unix terminals.
54
-
55
- ### 4. Improved Documentation
56
-
57
- **Added Descriptions**:
58
- - Knowledge Base menu now shows purpose
59
- - Comments in code clarified
60
-
61
- **Rationale**: Self-documenting UI reduces user confusion.
62
-
63
- ## Navigation Symbol Reference
64
-
65
- ```
66
- Symbol | Meaning | Unix Standard
67
- --------|--------------------------|---------------
68
- [..] | Parent directory | Yes (cd ..)
69
- [DIR] | Directory entry | Common
70
- [MD] | Markdown file | N/A
71
- [ <] | Go back/previous | No (custom)
72
- [ ^] | Go to top/main menu | No (custom)
73
- [ *] | Special action | No (custom)
74
- [ ?] | Help/Information | Common (man ?)
75
- [ x] | Exit/Quit | No (custom)
76
- ```
77
-
78
- ## Keybinding Reference
79
-
80
- ```
81
- Key | Action | Standard
82
- --------|----------------------|----------
83
- ↑/↓ | Navigate up/down | Yes
84
- j/k | Navigate up/down | Vim
85
- g | Jump to first | Vim
86
- G | Jump to last | Vim
87
- q | Quit application | Vim/less/man
88
- ESC | Cancel/Go back | Yes
89
- Ctrl+C | Force quit | Yes
90
- Enter | Select/Confirm | Yes
91
- ```
92
-
93
- ## Comparison with Common Unix Tools
94
-
95
- ### less/more
96
- - j/k navigation: ✓ Supported
97
- - g/G jump: ✓ Supported
98
- - q quit: ✓ Supported
99
- - ESC: Usually not used
100
-
101
- ### man
102
- - j/k navigation: ✓ Supported
103
- - g/G jump: ✓ Supported
104
- - q quit: ✓ Supported
105
- - h for help: Not implemented (use [?] menu item)
106
-
107
- ### vim
108
- - j/k navigation: ✓ Supported
109
- - g/G jump: ✓ Supported
110
- - q quit: ✓ Supported
111
- - ESC: ✓ Infrastructure added
112
-
113
- ### fzf (fuzzy finder)
114
- - j/k navigation: ✓ Supported
115
- - Ctrl+C quit: ✓ Supported
116
- - ESC cancel: ✓ Infrastructure added
117
-
118
- ## Implementation Details
119
-
120
- ### vim-keys.ts
121
- - Maps j/k to arrow keys
122
- - Maps g/G to home/end
123
- - Maps q to Ctrl+C
124
- - Passes ESC through for menu handling
125
-
126
- ### menu.ts
127
- - Shows keybinding hints before menu
128
- - Standardized symbol usage
129
- - Consistent formatting
130
-
131
- ### docs.ts
132
- - Uses [..] for parent directory (Unix standard)
133
- - Uses [ ^] for main menu (clear intent)
134
- - Uses [ <] for back navigation
135
- - Added descriptive subtitle
136
-
137
- ## Terminal Compatibility
138
-
139
- All symbols tested and work correctly on:
140
- - iTerm2 (macOS)
141
- - Terminal.app (macOS)
142
- - GNOME Terminal (Linux)
143
- - Windows Terminal
144
- - PuTTY (SSH)
145
- - tmux/screen multiplexers
146
-
147
- ## Future Enhancements
148
-
149
- 1. **Context-aware q key**: Currently q always exits. Consider:
150
- - q in submenu = go back
151
- - Q (shift) = force quit
152
-
153
- 2. **ESC back navigation**: Full implementation requires:
154
- - Custom inquirer plugin or wrapper
155
- - State management for menu stack
156
-
157
- 3. **Help overlay**: F1 or ? key for:
158
- - Show all keybindings
159
- - Context-sensitive help
160
-
161
- 4. **Breadcrumb trail**: Show current location:
162
- ```
163
- Main > Docs > Tutorial > Getting Started
164
- ```
165
-
166
- 5. **Operation cancellation**: Allow Ctrl+C during:
167
- - Network requests
168
- - File loading
169
- - Long operations
170
-
171
- ## Migration Notes
172
-
173
- ### Breaking Changes
174
- None. All changes are additive or improve existing behavior.
175
-
176
- ### User-Facing Changes
177
- - New keybinding hints displayed
178
- - Updated navigation symbols (more intuitive)
179
- - ESC key now recognized (infrastructure)
180
-
181
- ### Developer Notes
182
- - ESC handling requires inquirer extension for full functionality
183
- - Current implementation provides foundation
184
- - Symbol constants could be extracted to config
Binary file