@cacinie/cace-timer 1.0.0 → 1.1.1

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -333
  3. package/dist/index.js +22 -16
  4. package/package.json +23 -6
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CacinieP
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,333 +1,192 @@
1
- # CACE TIMER
2
-
3
- 一个极简的时间记录 CLI 工具,配有可爱的短发小女孩动画吉祥物。
4
-
5
- ## 安装
6
-
7
- ```bash
8
- cd timekeeper
9
- npm link
10
- ```
11
-
12
- 安装后全局命令 `tk` 即可使用。
13
-
14
- ## 快速开始
15
-
16
- ```bash
17
- # 开始一个任务
18
- tk start "写周报" --tag work --estimate 30
19
-
20
- # 记录进度节点
21
- tk mark "完成数据分析"
22
-
23
- # 查看当前状态
24
- tk status
25
-
26
- # 结束任务(显示效率评分)
27
- tk stop
28
- ```
29
-
30
- ## 命令一览
31
-
32
- ### tk start
33
-
34
- 开始新任务。
35
-
36
- ```bash
37
- tk start <任务名> [选项]
38
-
39
- 选项:
40
- --tag <标签> 添加标签
41
- --estimate <分钟> 预估时长(用于计算效率分)
42
- ```
43
-
44
- 示例:
45
- ```bash
46
- tk start "开发登录功能" --tag coding --estimate 60
47
- ```
48
-
49
- ### tk mark
50
-
51
- 记录时间节点。
52
-
53
- ```bash
54
- tk mark <备注>
55
- ```
56
-
57
- 示例:
58
- ```bash
59
- tk mark "完成API接口"
60
- tk mark "开始写测试"
61
- ```
62
-
63
- ### tk stop
64
-
65
- 结束当前任务,显示总结和效率评分。
66
-
67
- ```bash
68
- tk stop
69
- ```
70
-
71
- 效率评分规则:
72
- - 实际时长 预估时长 100%(🏆 优秀)
73
- - 实际时长稍超预估 → 80-99%(💪 良好)
74
- - 实际时长远超预估 <50%(💀 需改进)
75
-
76
- ### tk status
77
-
78
- 查看当前进行中的任务状态。
79
-
80
- ```bash
81
- tk status
82
- ```
83
-
84
- ### tk list
85
-
86
- 查看历史记录。
87
-
88
- ```bash
89
- tk list [选项]
90
-
91
- 选项:
92
- --today 仅显示今天
93
- --tag <标签> 按标签筛选
94
- --limit <数量> 限制显示数量(默认10)
95
- ```
96
-
97
- 示例:
98
- ```bash
99
- tk list --today
100
- tk list --tag coding --limit 20
101
- ```
102
-
103
- ### tk search
104
-
105
- 搜索历史记录。
106
-
107
- ```bash
108
- tk search <关键词>
109
- ```
110
-
111
- 会搜索任务名、标签、标记备注。
112
-
113
- ```bash
114
- tk search "登录"
115
- tk search "coding"
116
- ```
117
-
118
- ### tk sync
119
-
120
- 设置同步文件路径,实现跨设备同步。
121
-
122
- ```bash
123
- tk sync <文件路径>
124
- ```
125
-
126
- 建议将同步文件放在云盘目录:
127
- ```bash
128
- tk sync ~/Dropbox/cace-timer.json
129
- tk sync ~/OneDrive/cace-timer.json
130
- ```
131
-
132
- ## 数据同步指南
133
-
134
- ### 工作原理
135
-
136
- CACE TIMER 采用**单文件同步**策略:
137
-
138
- ```
139
- ┌─────────────┐ ┌─────────────┐
140
- │ 设备 A │ │ 设备 B │
141
- ~/(本地) │ │ ~/(本地) │
142
- │ .cace-timer │ │ .cace-timer │
143
- │ .json │ │ .json │
144
- └──────┬──────┘ └──────┬──────┘
145
- │ │
146
- ▼ ▼
147
- ┌─────────────────────────────────────┐
148
- │ 云盘同步目录 │
149
- │ Dropbox / iCloud / OneDrive │
150
- │ cace-timer.json │
151
- └─────────────────────────────────────┘
152
- ```
153
-
154
- 每次执行 `tk` 命令时:
155
- 1. 写入本地 `~/.cace-timer.json`
156
- 2. 同时写入配置的 `syncPath`(如果设置了)
157
-
158
- ### 设置步骤
159
-
160
- #### Dropbox
161
-
162
- ```bash
163
- # macOS / Linux
164
- tk sync ~/Dropbox/cace-timer.json
165
-
166
- # Windows
167
- tk sync "%USERPROFILE%\Dropbox\cace-timer.json"
168
- ```
169
-
170
- #### iCloud
171
-
172
- ```bash
173
- # macOS
174
- tk sync ~/Library/Mobile\ Documents/com~apple~CloudDocs/cace-timer.json
175
- ```
176
-
177
- #### OneDrive
178
-
179
- ```bash
180
- # macOS
181
- tk sync ~/OneDrive/cace-timer.json
182
-
183
- # Windows
184
- tk sync "%USERPROFILE%\OneDrive\cace-timer.json"
185
- ```
186
-
187
- #### 自建同步 (Syncthing / Resilio)
188
-
189
- ```bash
190
- tk sync ~/Sync/cace-timer.json
191
- ```
192
-
193
- ### 多设备使用
194
-
195
- **首次在设备 B 使用:**
196
-
197
- ```bash
198
- # 1. 安装 CACE TIMER
199
- cd timekeeper && npm link
200
-
201
- # 2. 设置同步路径(指向云盘已同步的文件)
202
- tk sync ~/Dropbox/cace-timer.json
203
-
204
- # 3. 查看同步的数据
205
- tk list
206
- ```
207
-
208
- **注意:** 新设备需要先设置 `tk sync`,然后才能读取云盘数据。
209
-
210
- ### 同步冲突处理
211
-
212
- 由于采用单文件策略,建议:
213
-
214
- | 场景 | 建议 |
215
- |------|------|
216
- | 多设备同时使用 | 避免同时在多个设备操作 |
217
- | 云盘同步延迟 | 操作后等待几秒再切换设备 |
218
- | 冲突文件 | 手动合并 JSON,保留需要的记录 |
219
-
220
- ### 手动备份
221
-
222
- ```bash
223
- # 导出备份
224
- cp ~/.cace-timer.json ~/backup/cace-timer-$(date +%Y%m%d).json
225
-
226
- # 恢复备份
227
- cp ~/backup/cace-timer-20240302.json ~/.cace-timer.json
228
- ```
229
-
230
- ### 数据格式
231
-
232
- 同步文件为标准 JSON 格式:
233
-
234
- ```json
235
- {
236
- "syncPath": "/Users/you/Dropbox/cace-timer.json",
237
- "current": null,
238
- "history": [
239
- {
240
- "id": "lq3x9k2",
241
- "task": "开发功能",
242
- "start": "2024-03-02T10:00:00.000Z",
243
- "end": "2024-03-02T11:30:00.000Z",
244
- "tags": ["coding"],
245
- "marks": [
246
- { "time": "2024-03-02T10:30:00.000Z", "note": "完成API" }
247
- ],
248
- "estimatedMinutes": 60
249
- }
250
- ]
251
- }
252
- ```
253
-
254
- ### 取消同步
255
-
256
- 编辑 `~/.cace-timer.json`,删除 `syncPath` 字段即可。
257
-
258
- ---
259
-
260
- ### tk help
261
-
262
- 显示帮助信息。
263
-
264
- ```bash
265
- tk help
266
- ```
267
-
268
- ## CACE 吉祥物
269
-
270
- CACE 是一个可爱的短发小女孩头像:
271
-
272
- ```
273
- ▄▄▄▄▄▄▄▄▄▄▄
274
- █░░░░░░░░░░░█ ← 刘海
275
- █░▄▄▄▄▄▄▄▄▄░█
276
- █░│ ● ● │░█ ← 大眼睛
277
- █░│ ▽ │░█ ← 小鼻子
278
- █░│ ─── │░█ ← 嘴巴
279
- ╰───────────╯
280
- ```
281
-
282
- **动画表情:**
283
-
284
- | 状态 | 眼睛 | 嘴巴 | 触发场景 |
285
- |------|------|------|----------|
286
- | 正常 | ● ● | ─── | 默认状态 |
287
- | 开心 | ★ ★ | ◡◡◡ | 完成任务 |
288
- | 眨眼 | ─ ─ | ─── | 动画帧 |
289
- | 超开心 | ◉ ◉ | ▽△▽ | 动画帧 |
290
- | 困倦 | ─ ─ | ─── | 无任务时 |
291
-
292
- 动画循环:正常 → 眨眼 → 开心 → 超开心(循环2次)
293
-
294
- ## 数据存储
295
-
296
- 数据保存在 `~/.cace-timer.json`:
297
-
298
- ```json
299
- {
300
- "syncPath": "~/Dropbox/cace-timer.json",
301
- "current": null,
302
- "history": [
303
- {
304
- "id": "xxx",
305
- "task": "写周报",
306
- "start": "2024-03-02T10:00:00Z",
307
- "end": "2024-03-02T10:30:00Z",
308
- "tags": ["work"],
309
- "marks": [
310
- { "time": "2024-03-02T10:15:00Z", "note": "完成数据分析" }
311
- ],
312
- "estimatedMinutes": 30
313
- }
314
- ]
315
- }
316
- ```
317
-
318
- ## 使用场景
319
-
320
- - **编程开发**:记录编码时间,评估效率
321
- - **学习复习**:跟踪学习时长和进度
322
- - **项目管理**:标记关键节点,回顾时间分配
323
- - **自由职业**:为客户项目计时
324
-
325
- ## 卸载
326
-
327
- ```bash
328
- npm unlink -g cace-timer
329
- ```
330
-
331
- ## License
332
-
333
- MIT
1
+ # cace-timer
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@cacinie/cace-timer.svg)](https://www.npmjs.com/package/@cacinie/cace-timer)
4
+ [![license](https://img.shields.io/npm/l/@cacinie/cace-timer.svg)](https://github.com/CacinieP/cace-timer/blob/main/LICENSE)
5
+
6
+ A minimal time tracking CLI with cute anime girl mascot.
7
+
8
+ ```
9
+ npm install -g @cacinie/cace-timer
10
+ ```
11
+
12
+ ```
13
+ ▄▄▄▄▄▄▄▄▄▄▄▄
14
+ █░░░░░░░░░░░░█
15
+ █░▄▄▄▄▄▄▄▄▄░█
16
+ █░│ ● ● │░█
17
+ █░│ ▽ │░█
18
+ █░│ ─── │░█
19
+ ╰────────────╯
20
+ CACE TIMER
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```bash
26
+ # Start a task
27
+ tk start "写周报" --tag work --estimate 30
28
+
29
+ # Mark progress
30
+ tk mark "完成数据分析"
31
+
32
+ # Check status
33
+ tk status
34
+
35
+ # Stop and get efficiency score
36
+ tk stop
37
+ ```
38
+
39
+ ## Commands
40
+
41
+ ### `tk start <task> [options]`
42
+
43
+ Start a new task.
44
+
45
+ | Option | Description |
46
+ |--------|-------------|
47
+ | `--tag <tag>` | Add a tag |
48
+ | `--estimate <minutes>` | Estimated duration (for efficiency score) |
49
+
50
+ ```bash
51
+ tk start "开发登录功能" --tag coding --estimate 60
52
+ ```
53
+
54
+ ### `tk mark <note>`
55
+
56
+ Record a time checkpoint.
57
+
58
+ ```bash
59
+ tk mark "完成API接口"
60
+ tk mark "开始写测试"
61
+ ```
62
+
63
+ ### `tk stop`
64
+
65
+ Stop current task, show summary and efficiency score.
66
+
67
+ | Score | Emoji | Meaning |
68
+ |-------|-------|---------|
69
+ | 100% | 🏆 | Actual ≤ Estimate |
70
+ | 80-99% | ⭐ | Slightly over or on target |
71
+ | 50-79% | 💪 | Moderately over estimate |
72
+ | <50% | 💀 | Far over estimate |
73
+
74
+ Efficiency score is only shown when `--estimate` was set at task start.
75
+
76
+ ### `tk status`
77
+
78
+ Show current running task.
79
+
80
+ ### `tk list [options]`
81
+
82
+ View history.
83
+
84
+ | Option | Description |
85
+ |--------|-------------|
86
+ | `--today` | Today only |
87
+ | `--tag <tag>` | Filter by tag |
88
+ | `--limit <n>` | Limit count (default 10) |
89
+
90
+ ```bash
91
+ tk list --today
92
+ tk list --tag coding --limit 20
93
+ ```
94
+
95
+ ### `tk search <keyword>`
96
+
97
+ Search across task names, tags, and mark notes.
98
+
99
+ ```bash
100
+ tk search "登录"
101
+ ```
102
+
103
+ ### `tk sync <path>`
104
+
105
+ Set sync file path for cross-device sync (Dropbox / iCloud / OneDrive).
106
+
107
+ ```bash
108
+ # macOS / Linux
109
+ tk sync ~/Dropbox/cace-timer.json
110
+ tk sync ~/OneDrive/cace-timer.json
111
+
112
+ # Windows
113
+ tk sync "%USERPROFILE%\Dropbox\cace-timer.json"
114
+ tk sync "%USERPROFILE%\OneDrive\cace-timer.json"
115
+ ```
116
+
117
+ ### `tk help`
118
+
119
+ Show help.
120
+
121
+ ## CACE Mascot
122
+
123
+ CACE reacts to what you do:
124
+
125
+ | State | Eyes | Mouth | When |
126
+ |-------|------|-------|------|
127
+ | Normal | ● ● | ─── | Default |
128
+ | Happy | ★ ★ | ◡◡◡ | Task completed |
129
+ | Super Happy | ◉ ◉ | ▽△▽ | Animation frame |
130
+ | Sleepy | ─ ─ | ─── | No active task |
131
+ | Blink | ─ ─ | ─── | Animation frame |
132
+
133
+ ## Data
134
+
135
+ All data is stored in `~/.cace-timer.json`. Single JSON file, easy to backup and sync.
136
+
137
+ ```json
138
+ {
139
+ "syncPath": "~/Dropbox/cace-timer.json",
140
+ "current": null,
141
+ "history": [
142
+ {
143
+ "id": "lq3x9k2",
144
+ "task": "写周报",
145
+ "start": "2024-03-02T10:00:00.000Z",
146
+ "end": "2024-03-02T10:30:00.000Z",
147
+ "tags": ["work"],
148
+ "marks": [{ "time": "...", "note": "完成数据分析" }],
149
+ "estimatedMinutes": 30
150
+ }
151
+ ]
152
+ }
153
+ ```
154
+
155
+ ## Uninstall
156
+
157
+ ```bash
158
+ npm uninstall -g @cacinie/cace-timer
159
+ ```
160
+
161
+ ## Changelog
162
+
163
+ ### v1.1.1
164
+
165
+ - Added `prepare` script (fixes git-based installs)
166
+ - Added `types` field for TypeScript consumers
167
+ - Fixed efficiency score display when no estimate was set
168
+ - Fixed efficiency score table mismatch in README
169
+ - Fixed `--limit 0` falsy-zero bug
170
+ - Fixed `--estimate` NaN handling
171
+ - Added Super Happy mascot state and Windows sync paths to README
172
+ - Added uninstall instructions and data format to README
173
+
174
+ ### v1.1.0
175
+
176
+ - Restructured repo layout (flat structure, no nested `timekeeper/`)
177
+ - Fixed `.gitignore` (dist/ was not properly ignored)
178
+ - Fixed CI workflow (was running in wrong directory)
179
+ - Added Node 18/20/22 matrix in CI
180
+ - Added `engines` field in package.json
181
+
182
+ ### v1.0.0
183
+
184
+ - Initial release
185
+ - start / mark / stop / status / list / search / sync commands
186
+ - CACE mascot animation
187
+ - Efficiency scoring
188
+ - Cloud sync support
189
+
190
+ ## License
191
+
192
+ MIT
package/dist/index.js CHANGED
@@ -264,8 +264,9 @@ async function cmdStop() {
264
264
  const duration = new Date(session.end).getTime() - new Date(session.start).getTime();
265
265
  const durationMinutes = duration / 60000;
266
266
  // Calculate efficiency score
267
- let efficiency = 100;
268
- if (session.estimatedMinutes && session.estimatedMinutes > 0) {
267
+ const hasEstimate = session.estimatedMinutes && session.estimatedMinutes > 0;
268
+ let efficiency = -1;
269
+ if (hasEstimate) {
269
270
  efficiency = Math.min(100, Math.round((session.estimatedMinutes / durationMinutes) * 100));
270
271
  }
271
272
  data.history.unshift(session);
@@ -287,20 +288,25 @@ async function cmdStop() {
287
288
  console.log(` 📍 标记: ${session.marks.length} 个`);
288
289
  }
289
290
  // Efficiency display
290
- let effEmoji = '⭐';
291
- let effColor = '\x1b[32m';
292
- if (efficiency < 50) {
293
- effEmoji = '💀';
294
- effColor = '\x1b[31m';
295
- }
296
- else if (efficiency < 80) {
297
- effEmoji = '💪';
298
- effColor = '\x1b[33m';
291
+ if (hasEstimate) {
292
+ let effEmoji = '';
293
+ let effColor = '\x1b[32m';
294
+ if (efficiency < 50) {
295
+ effEmoji = '💀';
296
+ effColor = '\x1b[31m';
297
+ }
298
+ else if (efficiency < 80) {
299
+ effEmoji = '💪';
300
+ effColor = '\x1b[33m';
301
+ }
302
+ else if (efficiency >= 100) {
303
+ effEmoji = '🏆';
304
+ }
305
+ console.log(` ${effEmoji} 效率分: ${effColor}${efficiency}%\x1b[0m`);
299
306
  }
300
- else if (efficiency >= 100) {
301
- effEmoji = '🏆';
307
+ else {
308
+ console.log(' ⏱ 未设置预估时长,无法计算效率分');
302
309
  }
303
- console.log(` ${effEmoji} 效率分: ${effColor}${efficiency}%\x1b[0m`);
304
310
  console.log();
305
311
  }
306
312
  function cmdStatus() {
@@ -345,7 +351,7 @@ function cmdList(options) {
345
351
  sessions = sessions.filter(s => s.tags.includes(options.tag));
346
352
  }
347
353
  // Limit
348
- const limit = options.limit || 10;
354
+ const limit = options.limit ?? 10;
349
355
  sessions = sessions.slice(0, limit);
350
356
  console.log();
351
357
  showCaceSmall('历史记录');
@@ -481,7 +487,7 @@ async function main() {
481
487
  case 'start':
482
488
  await cmdStart(positional[0] || '', {
483
489
  tag: options.tag,
484
- estimate: options.estimate ? parseInt(options.estimate) : undefined
490
+ estimate: options.estimate ? (Number(options.estimate) > 0 ? parseInt(options.estimate) : undefined) : undefined
485
491
  });
486
492
  break;
487
493
  case 'mark':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cacinie/cace-timer",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "A minimal time tracking CLI with cute anime girl mascot",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -11,10 +11,23 @@
11
11
  "build": "tsc",
12
12
  "dev": "ts-node src/index.ts",
13
13
  "start": "node dist/index.js",
14
- "prepublishOnly": "npm run build"
14
+ "prepublishOnly": "npm run build",
15
+ "prepare": "npm run build"
15
16
  },
16
- "files": ["dist", "README.md", "LICENSE"],
17
- "keywords": ["time", "tracker", "cli", "timer", "productivity", "anime", "mascot"],
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "keywords": [
23
+ "time",
24
+ "tracker",
25
+ "cli",
26
+ "timer",
27
+ "productivity",
28
+ "anime",
29
+ "mascot"
30
+ ],
18
31
  "author": "CacinieP <cacinie@gmail.com>",
19
32
  "license": "MIT",
20
33
  "repository": {
@@ -25,6 +38,9 @@
25
38
  "url": "https://github.com/CacinieP/cace-timer/issues"
26
39
  },
27
40
  "homepage": "https://github.com/CacinieP/cace-timer#readme",
41
+ "engines": {
42
+ "node": ">=18"
43
+ },
28
44
  "publishConfig": {
29
45
  "access": "public"
30
46
  },
@@ -32,5 +48,6 @@
32
48
  "@types/node": "^20.10.0",
33
49
  "ts-node": "^10.9.2",
34
50
  "typescript": "^5.3.0"
35
- }
36
- }
51
+ },
52
+ "types": "dist/index.d.ts"
53
+ }