tools-cc 1.0.11 → 1.0.12
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/AGENTS.md +111 -103
- package/CHANGELOG.md +5 -0
- package/dist/commands/use.js +2 -1
- package/package.json +1 -1
- package/skills/releasing/SKILL.md +217 -0
- package/src/commands/use.ts +2 -1
package/AGENTS.md
CHANGED
|
@@ -1,93 +1,116 @@
|
|
|
1
|
-
# tools-cc
|
|
1
|
+
# tools-cc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CLI 工具,用于统一管理多个 AI 编程工具(iflow、claude、codebuddy、opencode、codex 等)的 skills/commands/agents/rules 配置。通过符号链接机制,避免在多个工具间重复配置。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 快速命令
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
# 安装依赖
|
|
9
|
+
npm install
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
# 开发模式运行
|
|
12
|
+
npm run dev
|
|
13
|
+
|
|
14
|
+
# 编译 TypeScript
|
|
15
|
+
npm run build
|
|
16
|
+
|
|
17
|
+
# 运行测试
|
|
18
|
+
npm run test:run
|
|
19
|
+
```
|
|
16
20
|
|
|
17
21
|
## 项目结构
|
|
18
22
|
|
|
19
23
|
```
|
|
20
|
-
|
|
21
|
-
├──
|
|
22
|
-
|
|
23
|
-
│ ├──
|
|
24
|
-
│
|
|
25
|
-
│
|
|
26
|
-
│
|
|
27
|
-
│
|
|
28
|
-
│
|
|
29
|
-
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
│
|
|
33
|
-
│
|
|
34
|
-
│ ├──
|
|
35
|
-
│
|
|
36
|
-
|
|
37
|
-
│
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
│ └── fixtures/ # 测试固件
|
|
41
|
-
└── dist/ # 编译输出
|
|
24
|
+
src/
|
|
25
|
+
├── index.ts # CLI 入口,Commander.js 命令注册
|
|
26
|
+
├── commands/ # 命令处理器
|
|
27
|
+
│ ├── config.ts # 配置管理命令
|
|
28
|
+
│ ├── source.ts # 源管理命令
|
|
29
|
+
│ ├── use.ts # 项目使用命令
|
|
30
|
+
│ ├── template.ts # 模板管理命令
|
|
31
|
+
│ ├── export.ts # 导出命令
|
|
32
|
+
│ └── help.ts # 帮助信息
|
|
33
|
+
├── core/ # 核心业务逻辑
|
|
34
|
+
│ ├── config.ts # 配置读写
|
|
35
|
+
│ ├── manifest.ts # manifest.json 解析
|
|
36
|
+
│ ├── project.ts # 项目管理
|
|
37
|
+
│ ├── source.ts # 源管理
|
|
38
|
+
│ ├── symlink.ts # 符号链接创建
|
|
39
|
+
│ └── template.ts # 模板管理
|
|
40
|
+
├── types/
|
|
41
|
+
│ └── config.ts # TypeScript 类型定义
|
|
42
|
+
└── utils/
|
|
43
|
+
└── path.ts # 路径工具函数
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
##
|
|
46
|
+
## 架构设计
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
# 安装依赖
|
|
48
|
-
npm install
|
|
48
|
+
### 数据流
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
1. **全局配置** (`~/.tools-cc/config.json`) → 存储配置源位置和源列表
|
|
51
|
+
2. **源存储** (`~/.tools-cc/sources/`) → 存储克隆/引用的配置源
|
|
52
|
+
3. **项目配置** (`项目/.toolscc/config.json`) → 记录项目中启用的源和选择
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
npm run build
|
|
54
|
+
### 核心模块
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
- **config**: 读写全局配置,管理 sourcesDir
|
|
57
|
+
- **source**: 添加/移除/更新配置源,支持 git clone 和本地路径
|
|
58
|
+
- **project**: 项目初始化,使用/移除源,符号链接管理
|
|
59
|
+
- **manifest**: 解析源的 manifest.json,支持自动扫描目录结构
|
|
60
|
+
- **template**: 模板保存和应用
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
npm test
|
|
62
|
+
### 配置文件
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
| 作用域 | 路径 | 说明 |
|
|
65
|
+
|--------|------|------|
|
|
66
|
+
| 全局 | `~/.tools-cc/config.json` | 源目录和源列表 |
|
|
67
|
+
| 项目 | `.toolscc/config.json` | 启用的源和链接 |
|
|
68
|
+
| 模板 | `~/.tools-cc/templates/` | 保存的项目配置 |
|
|
69
|
+
|
|
70
|
+
## 命令速查
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
### 源管理 (全局)
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
tools-cc -s add <name> <path-or-url> # 添加源
|
|
76
|
+
tools-cc -s list # 列出源
|
|
77
|
+
tools-cc -s remove <name> # 移除源
|
|
78
|
+
tools-cc -s update [name] # git pull 更新
|
|
79
|
+
tools-cc -s scan # 扫描目录发现源
|
|
67
80
|
```
|
|
68
81
|
|
|
69
|
-
|
|
82
|
+
### 项目命令
|
|
70
83
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
```bash
|
|
85
|
+
tools-cc use [sources...] # 启用源(支持部分导入)
|
|
86
|
+
tools-cc use my-skills -p iflow claude # 指定工具链接
|
|
87
|
+
tools-cc use source:skills/xxx # 部分导入
|
|
88
|
+
tools-cc use -c config.json # 从文件导入
|
|
89
|
+
tools-cc update [sources...] # 同步源内容
|
|
90
|
+
tools-cc list # 列出已启用源
|
|
91
|
+
tools-cc rm <source> # 移除源
|
|
92
|
+
tools-cc status # 查看项目状态
|
|
93
|
+
```
|
|
77
94
|
|
|
78
|
-
###
|
|
79
|
-
- `tools-cc use [sources...] [-p tools...]` - 启用配置源并创建符号链接
|
|
80
|
-
- `tools-cc update [sources...]` - 同步源内容到项目
|
|
81
|
-
- `tools-cc list` - 列出已启用的配置源
|
|
82
|
-
- `tools-cc rm <source>` - 禁用配置源
|
|
83
|
-
- `tools-cc status` - 查看项目状态
|
|
95
|
+
### 模板命令
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
```bash
|
|
98
|
+
tools-cc template save [-n <name>] # 保存为模板
|
|
99
|
+
tools-cc template list # 列出模板
|
|
100
|
+
tools-cc template rm <name> # 删除模板
|
|
101
|
+
tools-cc template use [name] # 应用模板
|
|
102
|
+
tools-cc template use -p iflow # 应用并指定工具
|
|
103
|
+
```
|
|
89
104
|
|
|
90
|
-
|
|
105
|
+
### 配置命令
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
tools-cc -c set <key> <value> # 设置配置
|
|
109
|
+
tools-cc -c get <key> # 获取配置
|
|
110
|
+
tools-cc config list # 查看全局配置
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## 支持的工具
|
|
91
114
|
|
|
92
115
|
| 工具 | 链接名称 |
|
|
93
116
|
|------|----------|
|
|
@@ -95,14 +118,10 @@ npm link
|
|
|
95
118
|
| claude | `.claude` |
|
|
96
119
|
| codebuddy | `.codebuddy` |
|
|
97
120
|
| opencode | `.opencode` |
|
|
121
|
+
| codex | `.codex` |
|
|
122
|
+
| qoder | `.qoder` |
|
|
98
123
|
|
|
99
|
-
##
|
|
100
|
-
|
|
101
|
-
- **全局配置**: `~/.tools-cc/config.json`
|
|
102
|
-
- **项目配置**: `项目/.toolscc/config.json`
|
|
103
|
-
- **源存储目录**: `~/.tools-cc/sources`(可配置)
|
|
104
|
-
|
|
105
|
-
## 核心类型
|
|
124
|
+
## 类型定义
|
|
106
125
|
|
|
107
126
|
```typescript
|
|
108
127
|
// 源配置
|
|
@@ -112,53 +131,42 @@ interface SourceConfig {
|
|
|
112
131
|
path?: string;
|
|
113
132
|
}
|
|
114
133
|
|
|
115
|
-
//
|
|
116
|
-
interface
|
|
117
|
-
|
|
118
|
-
|
|
134
|
+
// 源选择配置
|
|
135
|
+
interface SourceSelection {
|
|
136
|
+
skills: string[]; // ['*'] 或 ['skill-a', 'skill-b']
|
|
137
|
+
commands: string[];
|
|
138
|
+
agents: string[];
|
|
139
|
+
rules: string[];
|
|
119
140
|
}
|
|
120
141
|
|
|
121
142
|
// 项目配置
|
|
122
143
|
interface ProjectConfig {
|
|
123
|
-
sources: string
|
|
144
|
+
sources: Record<string, SourceSelection>;
|
|
124
145
|
links: string[];
|
|
125
146
|
}
|
|
126
147
|
|
|
127
|
-
// Manifest
|
|
148
|
+
// Manifest
|
|
128
149
|
interface Manifest {
|
|
129
150
|
name: string;
|
|
130
151
|
version: string;
|
|
131
152
|
skills?: string[];
|
|
132
153
|
commands?: string[];
|
|
133
154
|
agents?: string[];
|
|
155
|
+
rules?: string[];
|
|
134
156
|
}
|
|
135
157
|
```
|
|
136
158
|
|
|
137
159
|
## 开发约定
|
|
138
160
|
|
|
139
|
-
|
|
140
|
-
- 使用
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
|
|
145
|
-
### 测试
|
|
146
|
-
- 测试文件放在 `tests/` 目录,镜像 `src/` 结构
|
|
147
|
-
- 使用 vitest 框架
|
|
148
|
-
- 测试固件放在 `tests/fixtures/`
|
|
149
|
-
|
|
150
|
-
### 命令添加
|
|
151
|
-
1. 在 `src/commands/` 创建或修改命令处理文件
|
|
152
|
-
2. 在 `src/index.ts` 注册新命令
|
|
153
|
-
3. 添加相应的测试
|
|
154
|
-
|
|
155
|
-
### 文档更新 [CHANGELOG.md](CHANGELOG.md)[README.md](README.md)
|
|
156
|
-
- 更新文档时,请确保命令描述清晰、准确,并使用一致的格式
|
|
157
|
-
- 添加新命令时,请更新命令列表和描述
|
|
158
|
-
- 修改现有命令时,请更新相关命令的描述
|
|
161
|
+
- **TypeScript**: ES2020 target, CommonJS, strict mode
|
|
162
|
+
- **异步**: 使用 async/await
|
|
163
|
+
- **文件操作**: fs-extra
|
|
164
|
+
- **CLI**: Commander.js
|
|
165
|
+
- **测试**: vitest
|
|
166
|
+
- **命令处理**: `handle*` 命名约定
|
|
159
167
|
|
|
160
168
|
## 注意事项
|
|
161
169
|
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
170
|
+
- 运行在 Windows,注意路径分隔符兼容性
|
|
171
|
+
- Windows 上使用 junction 创建符号链接(不需要管理员权限)
|
|
172
|
+
- 全局配置目录: `~/.tools-cc`
|
package/CHANGELOG.md
CHANGED
package/dist/commands/use.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: releasing
|
|
3
|
+
description: Use when preparing a new version release for npm packages with GitHub releases. Handles version bump, changelog updates, git tags, npm publish, and GitHub release creation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Releasing
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
版本发布助手,自动化 npm 包发布流程:版本号更新 → 文档同步 → Git Tag → GitHub Release → 提醒用户 npm 发布。
|
|
11
|
+
|
|
12
|
+
**核心原则:每个步骤必须验证成功,失败立即停止。**
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- 准备发布新版本时
|
|
17
|
+
- 需要更新 CHANGELOG 时
|
|
18
|
+
- 需要 npm publish 时
|
|
19
|
+
- 需要 GitHub release 时
|
|
20
|
+
|
|
21
|
+
**NOT for:**
|
|
22
|
+
- Hot fix 紧急修复(需要特殊流程)
|
|
23
|
+
- 私有包发布
|
|
24
|
+
- 非 npm 项目
|
|
25
|
+
|
|
26
|
+
## Release Workflow
|
|
27
|
+
|
|
28
|
+
```dot
|
|
29
|
+
digraph release {
|
|
30
|
+
rankdir=TB;
|
|
31
|
+
|
|
32
|
+
"Start" [shape=ellipse];
|
|
33
|
+
"Git Status Clean?" [shape=diamond];
|
|
34
|
+
"Tests Pass?" [shape=diamond];
|
|
35
|
+
"Choose Version" [shape=box];
|
|
36
|
+
"Update package.json" [shape=box];
|
|
37
|
+
"Update CHANGELOG" [shape=box];
|
|
38
|
+
"Update README" [shape=box];
|
|
39
|
+
"Build" [shape=box];
|
|
40
|
+
"Git Commit" [shape=box];
|
|
41
|
+
"Git Pull" [shape=box];
|
|
42
|
+
"Git Tag" [shape=box];
|
|
43
|
+
"Push Tag" [shape=box];
|
|
44
|
+
"gh release" [shape=box];
|
|
45
|
+
"Done (remind npm publish)" [shape=ellipse];
|
|
46
|
+
"STOP: Fix Issues" [shape=box style=filled fillcolor=red];
|
|
47
|
+
|
|
48
|
+
"Start" -> "Git Status Clean?";
|
|
49
|
+
"Git Status Clean?" -> "Tests Pass?" [label="yes"];
|
|
50
|
+
"Git Status Clean?" -> "STOP: Fix Issues" [label="no"];
|
|
51
|
+
"Tests Pass?" -> "Choose Version" [label="yes"];
|
|
52
|
+
"Tests Pass?" -> "STOP: Fix Issues" [label="no"];
|
|
53
|
+
"Choose Version" -> "Update package.json";
|
|
54
|
+
"Update package.json" -> "Update CHANGELOG";
|
|
55
|
+
"Update CHANGELOG" -> "Update README";
|
|
56
|
+
"Update README" -> "Build";
|
|
57
|
+
"Build" -> "Git Commit";
|
|
58
|
+
"Git Commit" -> "Git Pull";
|
|
59
|
+
"Git Pull" -> "Git Tag";
|
|
60
|
+
"Git Tag" -> "Push Tag";
|
|
61
|
+
"Push Tag" -> "gh release";
|
|
62
|
+
"gh release" -> "Done (remind npm publish)";
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Version Selection
|
|
67
|
+
|
|
68
|
+
| Type | Example | When to Use |
|
|
69
|
+
|------|---------|-------------|
|
|
70
|
+
| major | 1.0.0 → 2.0.0 | Breaking changes, incompatible API |
|
|
71
|
+
| minor | 1.0.0 → 1.1.0 | New features, backwards compatible |
|
|
72
|
+
| patch | 1.0.0 → 1.0.1 | Bug fixes, backwards compatible |
|
|
73
|
+
|
|
74
|
+
## Step Details
|
|
75
|
+
|
|
76
|
+
### 1. Pre-flight Checks
|
|
77
|
+
|
|
78
|
+
**MUST verify before starting:**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# 检查 git 状态
|
|
82
|
+
git status --porcelain
|
|
83
|
+
# 如果有输出,必须先处理
|
|
84
|
+
|
|
85
|
+
# 检查测试
|
|
86
|
+
npm test
|
|
87
|
+
# 必须全部通过
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 2. Version Bump
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 方式一:npm version 命令(自动 git commit + tag)
|
|
94
|
+
npm version patch|minor|major
|
|
95
|
+
|
|
96
|
+
# 方式二:手动更新 package.json(需要手动 commit)
|
|
97
|
+
# 编辑 package.json 中的 version 字段
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 3. Update CHANGELOG
|
|
101
|
+
|
|
102
|
+
添加新版本条目到 CHANGELOG.md 和 CHANGELOG_en.md:
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
## [X.Y.Z] - YYYY-MM-DD
|
|
106
|
+
|
|
107
|
+
### Added
|
|
108
|
+
- 新增功能描述
|
|
109
|
+
|
|
110
|
+
### Changed
|
|
111
|
+
- 变更描述
|
|
112
|
+
|
|
113
|
+
### Fixed
|
|
114
|
+
- 修复描述
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 4. Update README
|
|
118
|
+
|
|
119
|
+
检查 README.md 和 README_en.md 中是否有版本相关内容需要更新:
|
|
120
|
+
- 安装命令中的版本号
|
|
121
|
+
- 更新日志链接
|
|
122
|
+
- 其他版本引用
|
|
123
|
+
|
|
124
|
+
### 5. Build & Commit
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm run build
|
|
128
|
+
git add .
|
|
129
|
+
git commit -m "chore: release v$VERSION"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### 6. Sync & Tag
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# 先 pull 最新代码
|
|
136
|
+
git pull
|
|
137
|
+
|
|
138
|
+
# 创建 tag
|
|
139
|
+
git tag v$VERSION
|
|
140
|
+
|
|
141
|
+
# push commit 和 tag(使用实际分支名,如 master/main)
|
|
142
|
+
git push github <branch>
|
|
143
|
+
git push github v$VERSION
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 7. GitHub Release
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
gh release create v$VERSION --title v$VERSION --generate-notes
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 8. npm Publish (最后提醒用户)
|
|
153
|
+
|
|
154
|
+
**完成所有自动化步骤后,在最终消息中提醒用户手动执行 npm publish。**
|
|
155
|
+
|
|
156
|
+
**不要使用 ask_user_question 工具询问,直接在完成消息中提示即可。**
|
|
157
|
+
|
|
158
|
+
提示格式:
|
|
159
|
+
```
|
|
160
|
+
**发布完成!请手动执行 `npm publish` 完成 npm 发布。**
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**用户执行前确认:**
|
|
164
|
+
- 已登录 npm (`npm whoami`)
|
|
165
|
+
- 有发布权限
|
|
166
|
+
- 网络连接正常
|
|
167
|
+
|
|
168
|
+
## Common Mistakes
|
|
169
|
+
|
|
170
|
+
| Mistake | Consequence | Prevention |
|
|
171
|
+
|---------|-------------|------------|
|
|
172
|
+
| 跳过 git status 检查 | 发布错误代码 | 必须检查,有输出就停止 |
|
|
173
|
+
| 跳过测试 | 发布有 bug 的版本 | 测试必须通过 |
|
|
174
|
+
| 忘记更新 CHANGELOG | 用户不知道变更内容 | 更新后必须验证格式 |
|
|
175
|
+
| 忘记 build | 发布旧代码 | build 后检查 dist 目录 |
|
|
176
|
+
| 忘记 git pull | tag 冲突或覆盖他人提交 | 创建 tag 前必须 pull |
|
|
177
|
+
| 先 npm publish 再 tag/gh release | 无法回退 | 严格遵守顺序:先 tag 和 gh release,最后提醒 npm publish |
|
|
178
|
+
| 版本号格式错误 | tag 创建失败 | 使用 semver 格式 |
|
|
179
|
+
|
|
180
|
+
## Red Flags - STOP and Fix
|
|
181
|
+
|
|
182
|
+
- 有未提交的更改
|
|
183
|
+
- 测试失败
|
|
184
|
+
- CHANGELOG 未更新
|
|
185
|
+
- 版本号已存在
|
|
186
|
+
- npm 未登录
|
|
187
|
+
- 网络连接问题
|
|
188
|
+
|
|
189
|
+
**任何步骤失败,立即停止,不要继续。**
|
|
190
|
+
|
|
191
|
+
## Rationalization Table
|
|
192
|
+
|
|
193
|
+
| Excuse | Reality |
|
|
194
|
+
|--------|---------|
|
|
195
|
+
| "测试之前跑过,肯定没问题" | 代码变了,测试必须重跑 |
|
|
196
|
+
| "简单版本,不需要更新 CHANGELOG" | 用户需要知道变更内容 |
|
|
197
|
+
| "先发布再说,文档后面补" | 忘记补的概率 99% |
|
|
198
|
+
| "跳过 pull,本地肯定是最新的" | 远程可能有其他提交 |
|
|
199
|
+
| "手动测试过了,不需要跑测试" | 手动测试覆盖不全 |
|
|
200
|
+
| "npm version 命令会自动处理" | 不会自动更新 CHANGELOG/README |
|
|
201
|
+
| "先 npm publish,tag 后面补" | 发布失败无法回退,顺序应为 tag → gh release → npm publish |
|
|
202
|
+
|
|
203
|
+
## Quick Reference
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# 完整发布流程
|
|
207
|
+
git status --porcelain # 1. 检查状态
|
|
208
|
+
npm test # 2. 运行测试
|
|
209
|
+
# 更新版本号、CHANGELOG、README
|
|
210
|
+
npm run build # 3. 构建
|
|
211
|
+
git add . && git commit -m "chore: release vX.Y.Z"
|
|
212
|
+
git pull # 4. 同步远程
|
|
213
|
+
git tag vX.Y.Z # 5. 创建 tag
|
|
214
|
+
git push github master && git push github vX.Y.Z
|
|
215
|
+
gh release create vX.Y.Z --title vX.Y.Z --generate-notes # 6. GitHub release
|
|
216
|
+
# 7. 在完成消息中提醒用户: 请手动执行 npm publish
|
|
217
|
+
```
|