@wangjs-jacky/ticktick-cli 0.1.0

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 (40) hide show
  1. package/.github/workflows/npm-publish.yml +26 -0
  2. package/CLAUDE.md +34 -0
  3. package/README.md +62 -0
  4. package/README_CN.md +62 -0
  5. package/bin/cli.ts +2 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +1490 -0
  8. package/dist/index.js.map +1 -0
  9. package/docs/oauth-credential-pre-validation.md +253 -0
  10. package/docs/reference/cli-usage-guide.md +587 -0
  11. package/docs/reference/dida365-open-api-zh.md +999 -0
  12. package/docs/reference/dida365-open-api.md +999 -0
  13. package/docs/reference/project-guide.md +63 -0
  14. package/docs/superpowers/plans/2026-04-03-tt-cli-auth.md +1110 -0
  15. package/docs/superpowers/specs/2026-04-03-tt-cli-design.md +142 -0
  16. package/package.json +45 -0
  17. package/skills/tt-cli-guide/SKILL.md +152 -0
  18. package/skills/tt-cli-guide/references/intent-mapping.md +169 -0
  19. package/src/api/client.ts +61 -0
  20. package/src/api/oauth.ts +146 -0
  21. package/src/api/resources.ts +291 -0
  22. package/src/commands/auth.ts +218 -0
  23. package/src/commands/project.ts +303 -0
  24. package/src/commands/task.ts +806 -0
  25. package/src/commands/user.ts +43 -0
  26. package/src/index.ts +46 -0
  27. package/src/types.ts +211 -0
  28. package/src/utils/config.ts +88 -0
  29. package/src/utils/endpoints.ts +22 -0
  30. package/src/utils/format.ts +71 -0
  31. package/src/utils/server.ts +81 -0
  32. package/tests/config.test.ts +87 -0
  33. package/tests/format.test.ts +56 -0
  34. package/tests/oauth.test.ts +42 -0
  35. package/tests/parity-fields.test.ts +89 -0
  36. package/tests/parity-map.ts +184 -0
  37. package/tests/parity.test.ts +101 -0
  38. package/tsconfig.json +22 -0
  39. package/tsup.config.ts +12 -0
  40. package/vitest.config.ts +7 -0
@@ -0,0 +1,26 @@
1
+ name: 发布到 npm
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ registry-url: https://registry.npmjs.org
19
+
20
+ - run: npm ci
21
+
22
+ - run: npm test
23
+
24
+ - run: npm publish
25
+ env:
26
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CLAUDE.md ADDED
@@ -0,0 +1,34 @@
1
+ # tt-cli
2
+
3
+ 滴答清单(TickTick)命令行工具。
4
+
5
+ ## 开发约定
6
+
7
+ - TypeScript strict 模式
8
+ - 注释和输出文案使用中文
9
+ - npm 包名:`@wangjs-jacky/ticktick-cli`
10
+ - ESM only,target node18
11
+
12
+ ## 架构要点
13
+
14
+ - **OAuth2 流程**:本地 HTTP 服务器监听回调 → 浏览器打开授权页 → code 换 token
15
+ - **Token 自动刷新**:`apiRequest` 发请求前检查有效性,过期自动刷新
16
+ - **CSRF 防护**:授权请求携带随机 state 参数,回调时校验
17
+
18
+ ## 调试经验
19
+
20
+ - **"无输出"≠"无报错"**:命令静默退出时,优先排查命令注册/匹配问题
21
+ - **401 先验端点再验 token**:用 `fetch` 直接测试不同 API 端点,比猜测 token 过期更快定位
22
+ - **验证轮次要克制**:确认 bug 后立即转向修复,不要反复验证同一结论
23
+ - **日期格式**:TickTick API 要求 `"2026-04-04T19:00:00.000+0800"`(有毫秒,时区无冒号)。`utils/format.ts` 的 `normalizeTickTickDate()` 已自动转换
24
+
25
+ ## cac 子命令约束
26
+
27
+ `cac` v7 不支持空格分隔的子命令名,必须用连字符(`task-list`)。`index.ts` 中 `SUBCOMMAND_GROUPS` 做了预处理,用户可输入 `tt task list`。**新增子命令时必须同时更新命令注册和 `SUBCOMMAND_GROUPS`**。
28
+
29
+ ## 参考文档
30
+
31
+ - [项目开发指南](docs/reference/project-guide.md):技术栈、常用命令、项目结构、配置存储、区域系统
32
+ - [CLI 操作手册](docs/reference/cli-usage-guide.md):所有已实现命令的完整用法
33
+ - [OAuth 2.0 认证架构设计](docs/oauth-credential-pre-validation.md):授权码模式完整流程
34
+ - [滴答清单 Open API(中文)](docs/reference/dida365-open-api-zh.md) / [英文](docs/reference/dida365-open-api.md)
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # tt-cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@wangjs-jacky/ticktick-cli.svg)](https://www.npmjs.com/package/@wangjs-jacky/ticktick-cli) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ English | [中文](./README_CN.md)
6
+
7
+ A command-line tool for TickTick (滴答清单), supporting both China region (dida365.com) and Global region (ticktick.com).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install -g @wangjs-jacky/ticktick-cli
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### First-time Login
18
+
19
+ ```bash
20
+ tt login
21
+ ```
22
+
23
+ You'll be prompted for Client ID and Client Secret. Register your app at [TickTick Developer Platform](https://developer.ticktick.com/app) first.
24
+
25
+ Set Redirect URI to: `http://localhost:3000/callback`
26
+
27
+ ### Switch Region
28
+
29
+ ```bash
30
+ tt config --region cn # China region (dida365.com)
31
+ tt config --region global # Global region (ticktick.com)
32
+ ```
33
+
34
+ ### Daily Use
35
+
36
+ ```bash
37
+ tt whoami # Check login status
38
+ tt logout # Log out
39
+ tt config # View configuration
40
+ ```
41
+
42
+ ## Development
43
+
44
+ ```bash
45
+ npm install # Install dependencies
46
+ npm run build # Build
47
+ npm test # Run tests
48
+ npm run dev # Watch mode
49
+ ```
50
+
51
+ ## Tech Stack
52
+
53
+ | Category | Choice |
54
+ |----------|--------|
55
+ | CLI Framework | `cac` |
56
+ | Terminal UI | `@clack/prompts` + `picocolors` |
57
+ | Build | `tsup` (ESM only) |
58
+ | Test | `vitest` |
59
+
60
+ ## License
61
+
62
+ MIT
package/README_CN.md ADDED
@@ -0,0 +1,62 @@
1
+ # tt-cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@wangjs-jacky/ticktick-cli.svg)](https://www.npmjs.com/package/@wangjs-jacky/ticktick-cli) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ [English](./README.md) | 中文
6
+
7
+ 滴答清单(TickTick)命令行工具,支持国内版(dida365.com)和国际版(ticktick.com)双区域。
8
+
9
+ ## 安装
10
+
11
+ ```bash
12
+ npm install -g @wangjs-jacky/ticktick-cli
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ ### 首次登录
18
+
19
+ ```bash
20
+ tt login
21
+ ```
22
+
23
+ 首次使用会提示输入 Client ID 和 Client Secret,需要先到 [TickTick 开发者平台](https://developer.ticktick.com/app) 注册应用。
24
+
25
+ 注册时 Redirect URI 设置为:`http://localhost:3000/callback`
26
+
27
+ ### 区域切换
28
+
29
+ ```bash
30
+ tt config --region cn # 切换到国内版(dida365.com)
31
+ tt config --region global # 切换到国际版(ticktick.com)
32
+ ```
33
+
34
+ ### 日常使用
35
+
36
+ ```bash
37
+ tt whoami # 查看登录状态
38
+ tt logout # 登出
39
+ tt config # 查看配置
40
+ ```
41
+
42
+ ## 开发
43
+
44
+ ```bash
45
+ npm install # 安装依赖
46
+ npm run build # 构建
47
+ npm test # 运行测试
48
+ npm run dev # 监听模式开发
49
+ ```
50
+
51
+ ## 技术栈
52
+
53
+ | 类别 | 方案 |
54
+ |------|------|
55
+ | CLI 框架 | `cac` |
56
+ | 终端 UI | `@clack/prompts` + `picocolors` |
57
+ | 构建 | `tsup`(ESM only) |
58
+ | 测试 | `vitest` |
59
+
60
+ ## License
61
+
62
+ MIT
package/bin/cli.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
@@ -0,0 +1,2 @@
1
+
2
+ export { }