@benbenwu/zcf 3.6.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/LICENSE +21 -0
- package/README.md +193 -0
- package/bin/zcf.mjs +2 -0
- package/dist/chunks/api-providers.mjs +137 -0
- package/dist/chunks/claude-code-config-manager.mjs +731 -0
- package/dist/chunks/claude-code-incremental-manager.mjs +601 -0
- package/dist/chunks/codex-config-switch.mjs +394 -0
- package/dist/chunks/codex-provider-manager.mjs +197 -0
- package/dist/chunks/codex-uninstaller.mjs +422 -0
- package/dist/chunks/commands.mjs +118 -0
- package/dist/chunks/features.mjs +632 -0
- package/dist/chunks/simple-config.mjs +7904 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.mjs +2013 -0
- package/dist/i18n/locales/en/api.json +53 -0
- package/dist/i18n/locales/en/ccr.json +65 -0
- package/dist/i18n/locales/en/cli.json +55 -0
- package/dist/i18n/locales/en/codex.json +123 -0
- package/dist/i18n/locales/en/cometix.json +29 -0
- package/dist/i18n/locales/en/common.json +20 -0
- package/dist/i18n/locales/en/configuration.json +85 -0
- package/dist/i18n/locales/en/errors.json +26 -0
- package/dist/i18n/locales/en/installation.json +80 -0
- package/dist/i18n/locales/en/language.json +19 -0
- package/dist/i18n/locales/en/mcp.json +24 -0
- package/dist/i18n/locales/en/menu.json +51 -0
- package/dist/i18n/locales/en/multi-config.json +79 -0
- package/dist/i18n/locales/en/tools.json +15 -0
- package/dist/i18n/locales/en/uninstall.json +56 -0
- package/dist/i18n/locales/en/updater.json +25 -0
- package/dist/i18n/locales/en/workflow.json +23 -0
- package/dist/i18n/locales/zh-CN/api.json +53 -0
- package/dist/i18n/locales/zh-CN/ccr.json +65 -0
- package/dist/i18n/locales/zh-CN/cli.json +55 -0
- package/dist/i18n/locales/zh-CN/codex.json +123 -0
- package/dist/i18n/locales/zh-CN/cometix.json +29 -0
- package/dist/i18n/locales/zh-CN/common.json +20 -0
- package/dist/i18n/locales/zh-CN/configuration.json +85 -0
- package/dist/i18n/locales/zh-CN/errors.json +26 -0
- package/dist/i18n/locales/zh-CN/installation.json +80 -0
- package/dist/i18n/locales/zh-CN/language.json +19 -0
- package/dist/i18n/locales/zh-CN/mcp.json +24 -0
- package/dist/i18n/locales/zh-CN/menu.json +51 -0
- package/dist/i18n/locales/zh-CN/multi-config.json +79 -0
- package/dist/i18n/locales/zh-CN/tools.json +15 -0
- package/dist/i18n/locales/zh-CN/uninstall.json +56 -0
- package/dist/i18n/locales/zh-CN/updater.json +25 -0
- package/dist/i18n/locales/zh-CN/workflow.json +23 -0
- package/dist/index.d.mts +324 -0
- package/dist/index.d.ts +324 -0
- package/dist/index.mjs +19 -0
- package/dist/shared/zcf.DGjQxTq_.mjs +34 -0
- package/package.json +117 -0
- package/templates/CLAUDE.md +221 -0
- package/templates/claude-code/CLAUDE.md +250 -0
- package/templates/claude-code/common/settings.json +48 -0
- package/templates/claude-code/en/workflow/bmad/commands/bmad-init.md +275 -0
- package/templates/claude-code/en/workflow/common/agents/get-current-datetime.md +29 -0
- package/templates/claude-code/en/workflow/common/agents/init-architect.md +114 -0
- package/templates/claude-code/en/workflow/common/commands/init-project.md +53 -0
- package/templates/claude-code/en/workflow/plan/agents/planner.md +116 -0
- package/templates/claude-code/en/workflow/plan/agents/ui-ux-designer.md +91 -0
- package/templates/claude-code/en/workflow/plan/commands/feat.md +105 -0
- package/templates/claude-code/zh-CN/workflow/bmad/commands/bmad-init.md +275 -0
- package/templates/claude-code/zh-CN/workflow/common/agents/get-current-datetime.md +29 -0
- package/templates/claude-code/zh-CN/workflow/common/agents/init-architect.md +114 -0
- package/templates/claude-code/zh-CN/workflow/common/commands/init-project.md +53 -0
- package/templates/claude-code/zh-CN/workflow/plan/agents/planner.md +116 -0
- package/templates/claude-code/zh-CN/workflow/plan/agents/ui-ux-designer.md +91 -0
- package/templates/claude-code/zh-CN/workflow/plan/commands/feat.md +105 -0
- package/templates/codex/common/config.toml +0 -0
- package/templates/common/output-styles/en/engineer-professional.md +88 -0
- package/templates/common/output-styles/en/laowang-engineer.md +127 -0
- package/templates/common/output-styles/en/leibus-engineer.md +251 -0
- package/templates/common/output-styles/en/nekomata-engineer.md +120 -0
- package/templates/common/output-styles/en/ojousama-engineer.md +121 -0
- package/templates/common/output-styles/en/rem-engineer.md +173 -0
- package/templates/common/output-styles/zh-CN/engineer-professional.md +89 -0
- package/templates/common/output-styles/zh-CN/laowang-engineer.md +127 -0
- package/templates/common/output-styles/zh-CN/leibus-engineer.md +251 -0
- package/templates/common/output-styles/zh-CN/nekomata-engineer.md +120 -0
- package/templates/common/output-styles/zh-CN/ojousama-engineer.md +121 -0
- package/templates/common/output-styles/zh-CN/rem-engineer.md +179 -0
- package/templates/common/workflow/git/en/git-cleanBranches.md +102 -0
- package/templates/common/workflow/git/en/git-commit.md +205 -0
- package/templates/common/workflow/git/en/git-rollback.md +90 -0
- package/templates/common/workflow/git/en/git-worktree.md +276 -0
- package/templates/common/workflow/git/zh-CN/git-cleanBranches.md +102 -0
- package/templates/common/workflow/git/zh-CN/git-commit.md +205 -0
- package/templates/common/workflow/git/zh-CN/git-rollback.md +90 -0
- package/templates/common/workflow/git/zh-CN/git-worktree.md +276 -0
- package/templates/common/workflow/sixStep/en/workflow.md +251 -0
- package/templates/common/workflow/sixStep/zh-CN/workflow.md +215 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 交互式回滚 Git 分支到历史版本;列分支、列版本、二次确认后执行 reset / revert
|
|
3
|
+
allowed-tools: Read(**), Exec(git fetch, git branch, git tag, git log, git reflog, git checkout, git reset, git revert, git switch), Write()
|
|
4
|
+
argument-hint: [--branch <branch>] [--target <rev>] [--mode reset|revert] [--depth <n>] [--dry-run] [--yes]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-rollback # 全交互模式,dry‑run
|
|
7
|
+
# - /git-rollback --branch dev # 直接选 dev,其他交互
|
|
8
|
+
# - /git-rollback --branch dev --target v1.2.0 --mode reset --yes
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Claude Command: Git Rollback
|
|
12
|
+
|
|
13
|
+
**目的**:安全、可视地将指定分支回滚到旧版本。
|
|
14
|
+
默认处于 **只读预览 (`--dry-run`)**;真正执行需加 `--yes` 或在交互中确认。
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# 纯交互:列出分支 → 选分支 → 列最近 20 个版本 → 选目标 → 选择 reset 或 revert → 二次确认
|
|
22
|
+
/git-rollback
|
|
23
|
+
|
|
24
|
+
# 指定分支,其他交互
|
|
25
|
+
/git-rollback --branch feature/calculator
|
|
26
|
+
|
|
27
|
+
# 指定分支与目标 commit,并用 hard‑reset 一键执行(危险)
|
|
28
|
+
/git-rollback --branch main --target 1a2b3c4d --mode reset --yes
|
|
29
|
+
|
|
30
|
+
# 只想生成 revert 提交(非破坏式回滚),预览即可
|
|
31
|
+
/git-rollback --branch release/v2.1 --target v2.0.5 --mode revert --dry-run
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Options
|
|
35
|
+
|
|
36
|
+
| 选项 | 说明 |
|
|
37
|
+
| ---------------------- | ---------------------------------------------------------------------------------- |
|
|
38
|
+
| `--branch <branch>` | 要回滚的分支;缺省时交互选择。 |
|
|
39
|
+
| `--target <rev>` | 目标版本(commit Hash、Tag、reflog 引用都行);缺省时交互选择近 `--depth` 条记录。 |
|
|
40
|
+
| `--mode reset\|revert` | `reset`:硬回滚历史;`revert`:生成反向提交保持历史完整。默认询问。 |
|
|
41
|
+
| `--depth <n>` | 在交互模式下列出最近 n 个版本(默认 20)。 |
|
|
42
|
+
| `--dry-run` | **默认开启**,只预览即将执行的命令。 |
|
|
43
|
+
| `--yes` | 跳过所有确认直接执行,适合 CI/CD 脚本。 |
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 交互流程
|
|
48
|
+
|
|
49
|
+
1. **同步远端** → `git fetch --all --prune`
|
|
50
|
+
2. **列分支** → `git branch -a`(本地+远端,过滤受保护分支)
|
|
51
|
+
3. **选分支** → 用户输入或传参
|
|
52
|
+
4. **列版本** → `git log --oneline -n <depth>` + `git tag --merged` + `git reflog -n <depth>`
|
|
53
|
+
5. **选目标** → 用户输入 commit hash / tag
|
|
54
|
+
6. **选模式** → `reset` 或 `revert`
|
|
55
|
+
7. **最终确认** (除非 `--yes`)
|
|
56
|
+
8. **执行回滚**
|
|
57
|
+
- `reset`:`git switch <branch> && git reset --hard <target>`
|
|
58
|
+
- `revert`:`git switch <branch> && git revert --no-edit <target>..HEAD`
|
|
59
|
+
9. **推送建议** → 提示是否 `git push --force-with-lease`(reset)或普通 `git push`(revert)
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 安全护栏
|
|
64
|
+
|
|
65
|
+
- **备份**:执行前自动在 reflog 中记录当前 HEAD,可用 `git switch -c backup/<timestamp>` 恢复。
|
|
66
|
+
- **保护分支**:如检测到 `main` / `master` / `production` 等受保护分支且开启 `reset` 模式,将要求额外确认。
|
|
67
|
+
- **--dry-run 默认开启**:防止误操作。
|
|
68
|
+
- **--force 禁止**:不提供 `--force`;如需强推,请手动输入 `git push --force-with-lease`。
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 适用场景示例
|
|
73
|
+
|
|
74
|
+
| 场景 | 调用示例 |
|
|
75
|
+
| ----------------------------------------------- | ---------------------------------------------------------------- |
|
|
76
|
+
| 热修补丁上线后发现 bug,需要回到 Tag `v1.2.0` | `/git-rollback --branch release/v1 --target v1.2.0 --mode reset` |
|
|
77
|
+
| 运维同事误推了 debug 日志提交,需要生成反向提交 | `/git-rollback --branch main --target 3f2e7c9 --mode revert` |
|
|
78
|
+
| 调研历史 bug,引导新人浏览分支历史 | `/git-rollback` (全交互,dry‑run) |
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 注意
|
|
83
|
+
|
|
84
|
+
1. **reset vs revert**
|
|
85
|
+
- **reset** 会改变历史,需要强推并可能影响其他协作者,谨慎使用。
|
|
86
|
+
- **revert** 更安全,生成新提交保留历史,但会增加一次记录。
|
|
87
|
+
2. **嵌入式仓库** 常有大体积二进制文件;回滚前请确保 LFS/子模块状态一致。
|
|
88
|
+
3. 若仓库启用了 CI 强制校验,回滚后可能自动触发流水线;确认管控策略以免误部署旧版本。
|
|
89
|
+
|
|
90
|
+
---
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 管理 Git worktree,在项目平级的 ../.zcf/项目名/ 目录下创建,支持智能默认、IDE 集成和内容迁移
|
|
3
|
+
allowed-tools: Read(**), Exec(git worktree add, git worktree list, git worktree remove, git worktree prune, git branch, git checkout, git rev-parse, git stash, git cp, detect-ide, open-ide, which, command, basename, dirname)
|
|
4
|
+
argument-hint: <add|list|remove|prune|migrate> [path] [-b <branch>] [-o|--open] [--track] [--guess-remote] [--detach] [--checkout] [--lock] [--migrate-from <source-path>] [--migrate-stash]
|
|
5
|
+
# examples:
|
|
6
|
+
# - /git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
7
|
+
# - /git-worktree add feature-ui -o # 创建 worktree 并直接用 IDE 打开
|
|
8
|
+
# - /git-worktree add hotfix -b fix/login -o # 创建新分支 'fix/login',路径为 'hotfix'
|
|
9
|
+
# - /git-worktree migrate feature-ui --from main # 将主分支未提交内容迁移到 feature-ui
|
|
10
|
+
# - /git-worktree migrate feature-ui --stash # 将当前 stash 迁移到 feature-ui
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Claude Command: Git Worktree
|
|
14
|
+
|
|
15
|
+
管理 Git worktree,支持智能默认、IDE 集成和内容迁移,使用结构化的 `../.zcf/项目名/` 路径。
|
|
16
|
+
|
|
17
|
+
直接执行命令并提供简洁结果。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 基本操作
|
|
25
|
+
/git-worktree add <path> # 从 main/master 创建名为 <path> 的新分支
|
|
26
|
+
/git-worktree add <path> -b <branch> # 创建指定名称的新分支
|
|
27
|
+
/git-worktree add <path> -o # 创建并直接用 IDE 打开
|
|
28
|
+
/git-worktree list # 显示所有 worktree 状态
|
|
29
|
+
/git-worktree remove <path> # 删除指定的 worktree
|
|
30
|
+
/git-worktree prune # 清理无效 worktree 记录
|
|
31
|
+
|
|
32
|
+
# 内容迁移
|
|
33
|
+
/git-worktree migrate <target> --from <source> # 迁移未提交内容
|
|
34
|
+
/git-worktree migrate <target> --stash # 迁移 stash 内容
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Options
|
|
38
|
+
|
|
39
|
+
| 选项 | 说明 |
|
|
40
|
+
| ------------------ | -------------------------------------------- |
|
|
41
|
+
| `add [<path>]` | 在 `../.zcf/项目名/<path>` 添加新的 worktree |
|
|
42
|
+
| `migrate <target>` | 迁移内容到指定 worktree |
|
|
43
|
+
| `list` | 列出所有 worktree 及其状态 |
|
|
44
|
+
| `remove <path>` | 删除指定路径的 worktree |
|
|
45
|
+
| `prune` | 清理无效的 worktree 引用 |
|
|
46
|
+
| `-b <branch>` | 创建新分支并检出到 worktree |
|
|
47
|
+
| `-o, --open` | 创建成功后直接用 IDE 打开(跳过询问) |
|
|
48
|
+
| `--from <source>` | 指定迁移源路径(migrate 专用) |
|
|
49
|
+
| `--stash` | 迁移当前 stash 内容(migrate 专用) |
|
|
50
|
+
| `--track` | 设置新分支跟踪对应的远程分支 |
|
|
51
|
+
| `--guess-remote` | 自动猜测远程分支进行跟踪 |
|
|
52
|
+
| `--detach` | 创建分离 HEAD 的 worktree |
|
|
53
|
+
| `--checkout` | 创建后立即检出(默认行为) |
|
|
54
|
+
| `--lock` | 创建后锁定 worktree |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## What This Command Does
|
|
59
|
+
|
|
60
|
+
1. **环境检查**
|
|
61
|
+
- 通过 `git rev-parse --is-inside-work-tree` 验证 Git 仓库
|
|
62
|
+
- 检测是否在主仓库或现有 worktree 中,进行智能路径计算
|
|
63
|
+
|
|
64
|
+
2. **智能路径管理**
|
|
65
|
+
- 使用 worktree 检测自动从主仓库路径计算项目名
|
|
66
|
+
- 在结构化的 `../.zcf/项目名/<path>` 目录创建 worktree
|
|
67
|
+
- 正确处理主仓库和 worktree 执行上下文
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# worktree 检测的核心路径计算逻辑
|
|
71
|
+
get_main_repo_path() {
|
|
72
|
+
local git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
|
|
73
|
+
local current_toplevel=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
74
|
+
|
|
75
|
+
# 检测是否在 worktree 中
|
|
76
|
+
if [[ "$git_common_dir" != "$current_toplevel/.git" ]]; then
|
|
77
|
+
# 在 worktree 中,从 git-common-dir 推导主仓库路径
|
|
78
|
+
dirname "$git_common_dir"
|
|
79
|
+
else
|
|
80
|
+
# 在主仓库中
|
|
81
|
+
echo "$current_toplevel"
|
|
82
|
+
fi
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
MAIN_REPO_PATH=$(get_main_repo_path)
|
|
86
|
+
PROJECT_NAME=$(basename "$MAIN_REPO_PATH")
|
|
87
|
+
WORKTREE_BASE="$MAIN_REPO_PATH/../.zcf/$PROJECT_NAME"
|
|
88
|
+
|
|
89
|
+
# 始终使用绝对路径防止嵌套问题
|
|
90
|
+
ABSOLUTE_WORKTREE_PATH="$WORKTREE_BASE/<path>"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**关键修复**: 在现有 worktree 内创建新 worktree 时,始终使用绝对路径以防止出现类似 `../.zcf/project/.zcf/project/path` 的路径嵌套问题。
|
|
94
|
+
|
|
95
|
+
3. **Worktree 操作**
|
|
96
|
+
- **add**: 使用智能分支/路径默认创建新 worktree
|
|
97
|
+
- **list**: 显示所有 worktree 的分支和状态
|
|
98
|
+
- **remove**: 安全删除 worktree 并清理引用
|
|
99
|
+
- **prune**: 清理孤立的 worktree 记录
|
|
100
|
+
|
|
101
|
+
4. **智能默认**
|
|
102
|
+
- **分支创建**: 未指定 `-b` 时,使用路径名创建新分支
|
|
103
|
+
- **基础分支**: 新分支从 main/master 分支创建
|
|
104
|
+
- **路径解析**: 未指定路径时使用分支名作为路径
|
|
105
|
+
- **IDE 集成**: 自动检测并提示 IDE 打开
|
|
106
|
+
|
|
107
|
+
5. **内容迁移**
|
|
108
|
+
- 在 worktree 之间迁移未提交改动
|
|
109
|
+
- 将 stash 内容应用到目标 worktree
|
|
110
|
+
- 安全检查防止冲突
|
|
111
|
+
|
|
112
|
+
6. **安全特性**
|
|
113
|
+
- **路径冲突防护**: 创建前检查目录是否已存在
|
|
114
|
+
- **分支检出验证**: 确保分支未被其他地方使用
|
|
115
|
+
- **绝对路径强制**: 防止在 worktree 内创建嵌套的 `.zcf` 目录
|
|
116
|
+
- **删除时自动清理**: 同时清理目录和 git 引用
|
|
117
|
+
- **清晰的状态报告**: 显示 worktree 位置和分支状态
|
|
118
|
+
|
|
119
|
+
7. **环境文件处理**
|
|
120
|
+
- **自动检测**: 扫描 `.gitignore` 文件中的环境变量文件模式
|
|
121
|
+
- **智能复制**: 复制 `.gitignore` 中列出的 `.env` 和 `.env.*` 文件
|
|
122
|
+
- **排除逻辑**: 跳过 `.env.example` 等模板文件
|
|
123
|
+
- **权限保护**: 保持原始文件权限和时间戳
|
|
124
|
+
- **用户反馈**: 提供已复制环境文件的清晰状态信息
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# 环境文件复制实现
|
|
128
|
+
copy_environment_files() {
|
|
129
|
+
local main_repo="$MAIN_REPO_PATH"
|
|
130
|
+
local target_worktree="$ABSOLUTE_WORKTREE_PATH"
|
|
131
|
+
local gitignore_file="$main_repo/.gitignore"
|
|
132
|
+
|
|
133
|
+
# 检查 .gitignore 是否存在
|
|
134
|
+
if [[ ! -f "$gitignore_file" ]]; then
|
|
135
|
+
return 0
|
|
136
|
+
fi
|
|
137
|
+
|
|
138
|
+
local copied_count=0
|
|
139
|
+
|
|
140
|
+
# 检测 .env 文件
|
|
141
|
+
if [[ -f "$main_repo/.env" ]] && grep -q "^\.env$" "$gitignore_file"; then
|
|
142
|
+
cp "$main_repo/.env" "$target_worktree/.env"
|
|
143
|
+
echo "✅ 已复制 .env"
|
|
144
|
+
((copied_count++))
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
# 检测 .env.* 模式文件(排除 .env.example)
|
|
148
|
+
for env_file in "$main_repo"/.env.*; do
|
|
149
|
+
if [[ -f "$env_file" ]] && [[ "$(basename "$env_file")" != ".env.example" ]]; then
|
|
150
|
+
local filename=$(basename "$env_file")
|
|
151
|
+
if grep -q "^\.env\.\*$" "$gitignore_file"; then
|
|
152
|
+
cp "$env_file" "$target_worktree/$filename"
|
|
153
|
+
echo "✅ 已复制 $filename"
|
|
154
|
+
((copied_count++))
|
|
155
|
+
fi
|
|
156
|
+
fi
|
|
157
|
+
done
|
|
158
|
+
|
|
159
|
+
if [[ $copied_count -gt 0 ]]; then
|
|
160
|
+
echo "📋 已从 .gitignore 复制 $copied_count 个环境文件"
|
|
161
|
+
fi
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Enhanced Features
|
|
168
|
+
|
|
169
|
+
### IDE 集成
|
|
170
|
+
|
|
171
|
+
- **自动检测**: VS Code → Cursor → WebStorm → Sublime Text → Vim
|
|
172
|
+
- **智能提示**: 创建 worktree 后询问是否在 IDE 中打开
|
|
173
|
+
- **直接打开**: 使用 `-o` 标志跳过提示直接打开
|
|
174
|
+
- **自定义配置**: 通过 git config 配置
|
|
175
|
+
|
|
176
|
+
### 内容迁移系统
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# 迁移未提交改动
|
|
180
|
+
/git-worktree migrate feature-ui --from main
|
|
181
|
+
/git-worktree migrate hotfix --from ../other-worktree
|
|
182
|
+
|
|
183
|
+
# 迁移 stash 内容
|
|
184
|
+
/git-worktree migrate feature-ui --stash
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**迁移流程**:
|
|
188
|
+
|
|
189
|
+
1. 验证源有未提交内容
|
|
190
|
+
2. 确保目标 worktree 干净
|
|
191
|
+
3. 显示即将迁移的改动
|
|
192
|
+
4. 使用 git 命令安全迁移
|
|
193
|
+
5. 确认结果并建议后续步骤
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# 基本用法
|
|
201
|
+
/git-worktree add feature-ui # 从 main/master 创建新分支 'feature-ui'
|
|
202
|
+
/git-worktree add feature-ui -b my-feature # 创建新分支 'my-feature',路径为 'feature-ui'
|
|
203
|
+
/git-worktree add feature-ui -o # 创建并直接用 IDE 打开
|
|
204
|
+
|
|
205
|
+
# 内容迁移场景
|
|
206
|
+
/git-worktree add feature-ui -b feature/new-ui # 创建新功能 worktree
|
|
207
|
+
/git-worktree migrate feature-ui --from main # 迁移未提交改动
|
|
208
|
+
/git-worktree migrate hotfix --stash # 迁移 stash 内容
|
|
209
|
+
|
|
210
|
+
# 管理操作
|
|
211
|
+
/git-worktree list # 查看所有 worktree
|
|
212
|
+
/git-worktree remove feature-ui # 删除不需要的 worktree
|
|
213
|
+
/git-worktree prune # 清理无效引用
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**示例输出**:
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
✅ Worktree created at ../.zcf/项目名/feature-ui
|
|
220
|
+
✅ 已复制 .env
|
|
221
|
+
✅ 已复制 .env.local
|
|
222
|
+
📋 已从 .gitignore 复制 2 个环境文件
|
|
223
|
+
🖥️ 是否在 IDE 中打开 ../.zcf/项目名/feature-ui?[y/n]: y
|
|
224
|
+
🚀 正在用 VS Code 打开 ../.zcf/项目名/feature-ui...
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Directory Structure
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
parent-directory/
|
|
233
|
+
├── your-project/ # 主项目
|
|
234
|
+
│ ├── .git/
|
|
235
|
+
│ └── src/
|
|
236
|
+
└── .zcf/ # worktree 管理
|
|
237
|
+
└── your-project/ # 项目 worktree
|
|
238
|
+
├── feature-ui/ # 功能分支
|
|
239
|
+
├── hotfix/ # 修复分支
|
|
240
|
+
└── debug/ # 调试 worktree
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Configuration
|
|
246
|
+
|
|
247
|
+
### IDE 配置
|
|
248
|
+
|
|
249
|
+
- 支持 VS Code、Cursor、WebStorm、Sublime Text、Vim
|
|
250
|
+
- 通过 git config 配置自定义 IDE
|
|
251
|
+
- 基于优先级的自动检测选择
|
|
252
|
+
|
|
253
|
+
### 自定义 IDE 设置
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# 配置自定义 IDE
|
|
257
|
+
git config worktree.ide.custom.sublime "subl %s"
|
|
258
|
+
git config worktree.ide.preferred "sublime"
|
|
259
|
+
|
|
260
|
+
# 控制自动检测
|
|
261
|
+
git config worktree.ide.autodetect true # 默认
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Notes
|
|
267
|
+
|
|
268
|
+
- **性能**: worktree 共享 `.git` 目录,节省磁盘空间
|
|
269
|
+
- **安全**: 路径冲突防护和分支检出验证
|
|
270
|
+
- **迁移**: 仅限未提交改动;已提交内容需使用 `git cherry-pick`
|
|
271
|
+
- **IDE 要求**: 命令行工具必须在 PATH 中
|
|
272
|
+
- **跨平台**: 支持 Windows、macOS、Linux
|
|
273
|
+
- **环境文件**: 自动复制 `.gitignore` 中列出的环境文件到新 worktree
|
|
274
|
+
- **文件排除**: 模板文件如 `.env.example` 仅保留在主仓库中
|
|
275
|
+
|
|
276
|
+
---
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Professional AI programming assistant with structured workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) for developers'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Workflow - Professional Development Assistant
|
|
6
|
+
|
|
7
|
+
Execute structured development workflow with quality gates and MCP service integration.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/zcf:workflow <TASK_DESCRIPTION>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Context
|
|
16
|
+
|
|
17
|
+
- Task to develop: $ARGUMENTS
|
|
18
|
+
- Structured 6-phase workflow with quality gates
|
|
19
|
+
- Professional developer-focused interaction
|
|
20
|
+
- MCP service integration for enhanced capabilities
|
|
21
|
+
|
|
22
|
+
## Your Role
|
|
23
|
+
|
|
24
|
+
You are a professional AI programming assistant following a structured core workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) to assist users. Designed for professional programmers with concise, professional interactions avoiding unnecessary explanations.
|
|
25
|
+
|
|
26
|
+
## Communication Guidelines
|
|
27
|
+
|
|
28
|
+
1. Responses start with mode tag `[Mode: X]`, initially `[Mode: Research]`
|
|
29
|
+
2. Core workflow strictly follows `Research -> Ideate -> Plan -> Execute -> Optimize -> Review` sequence, users can command jumps
|
|
30
|
+
|
|
31
|
+
## Core Workflow Details
|
|
32
|
+
|
|
33
|
+
### 1. `[Mode: Research]` - Requirement Understanding
|
|
34
|
+
|
|
35
|
+
- Analyze and understand user requirements
|
|
36
|
+
- Evaluate requirement completeness (0-10 score), actively request key information when below 7
|
|
37
|
+
- Gather necessary context and constraints
|
|
38
|
+
- Identify key objectives and success criteria
|
|
39
|
+
|
|
40
|
+
### 2. `[Mode: Ideate]` - Solution Design
|
|
41
|
+
|
|
42
|
+
- Provide at least two feasible solutions with evaluation (e.g., `Solution 1: Description`)
|
|
43
|
+
- Compare pros/cons of each approach
|
|
44
|
+
- Recommend optimal solution based on requirements
|
|
45
|
+
|
|
46
|
+
### 3. `[Mode: Plan]` - Detailed Planning
|
|
47
|
+
|
|
48
|
+
- Break down selected solution into detailed, ordered, executable step list
|
|
49
|
+
- Include atomic operations: files, functions/classes, logic overview
|
|
50
|
+
- Define expected results for each step
|
|
51
|
+
- Use `Context7` for new library queries
|
|
52
|
+
- Do not write complete code at this stage
|
|
53
|
+
- Request user approval after completion
|
|
54
|
+
|
|
55
|
+
### 4. `[Mode: Execute]` - Implementation
|
|
56
|
+
|
|
57
|
+
- Store plan summary (with context and plan) in project root directory `.zcf/plan/current/task-name.md`
|
|
58
|
+
- Must have user approval before execution
|
|
59
|
+
- Strictly follow the plan for coding implementation
|
|
60
|
+
- Request user feedback after key steps and completion
|
|
61
|
+
|
|
62
|
+
### 5. `[Mode: Optimize]` - Code Optimization
|
|
63
|
+
|
|
64
|
+
- Automatically enter this mode after `[Mode: Execute]` completion
|
|
65
|
+
- Automatically check and analyze implemented code (only code generated in current conversation)
|
|
66
|
+
- Focus on redundant, inefficient, garbage code
|
|
67
|
+
- Provide specific optimization suggestions (with reasons and expected benefits)
|
|
68
|
+
- Execute optimization after user confirmation
|
|
69
|
+
|
|
70
|
+
### 6. `[Mode: Review]` - Quality Assessment
|
|
71
|
+
|
|
72
|
+
- Evaluate execution results against the plan
|
|
73
|
+
- Report issues and suggestions
|
|
74
|
+
- Request user confirmation after completion
|
|
75
|
+
|
|
76
|
+
## Timestamp Acquisition Rules
|
|
77
|
+
|
|
78
|
+
During workflow execution, any scenario requiring current timestamp must obtain accurate time via bash command. Guessing or fabricating time is prohibited.
|
|
79
|
+
|
|
80
|
+
Basic Commands:
|
|
81
|
+
- Default format: `date +'%Y-%m-%d %H:%M:%S'`
|
|
82
|
+
- Filename format: `date +'%Y-%m-%d_%H%M%S'`
|
|
83
|
+
- Readable format: `date +'%Y-%m-%d %H:%M:%S %Z'`
|
|
84
|
+
- ISO format: `date +'%Y-%m-%dT%H:%M:%S%z'`
|
|
85
|
+
|
|
86
|
+
Typical Use Cases:
|
|
87
|
+
- Updating timestamp fields in documents
|
|
88
|
+
- Naming task plan documents during archiving (when moving from `.zcf/plan/current/` to `.zcf/plan/history/`)
|
|
89
|
+
- Any other scenario requiring current time recording
|
|
90
|
+
|
|
91
|
+
## Interactive Feedback & MCP Services
|
|
92
|
+
|
|
93
|
+
### Interactive Feedback Rules
|
|
94
|
+
|
|
95
|
+
1. During any process, task, or conversation, whether asking, replying, or completing phased tasks, must request user confirmation
|
|
96
|
+
2. When receiving user feedback, if feedback content is not empty, must request user confirmation again and adjust behavior based on feedback
|
|
97
|
+
3. Only when user explicitly indicates "end" or "no more interaction needed" can stop requesting user confirmation, process is considered complete
|
|
98
|
+
4. Unless receiving termination instructions, all steps must repeatedly request user confirmation
|
|
99
|
+
5. Before completing tasks, must request user confirmation and ask for user feedback
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Execute Workflow
|
|
104
|
+
|
|
105
|
+
**Task Description**: $ARGUMENTS
|
|
106
|
+
|
|
107
|
+
Starting structured development workflow with quality gates...
|
|
108
|
+
|
|
109
|
+
### 🔍 Phase 1: Research & Analysis
|
|
110
|
+
|
|
111
|
+
[Mode: Research] - Understanding requirements and gathering context:
|
|
112
|
+
|
|
113
|
+
#### Requirement Completeness Scoring (0-10 points)
|
|
114
|
+
|
|
115
|
+
Scoring Dimensions:
|
|
116
|
+
|
|
117
|
+
- **Goal Clarity** (0-3 points): Are task objectives clear and specific, what problem to solve?
|
|
118
|
+
- **Expected Results** (0-3 points): Are success criteria and deliverables clearly defined?
|
|
119
|
+
- **Scope Boundaries** (0-2 points): Are task scope and boundaries clear?
|
|
120
|
+
- **Constraints** (0-2 points): Are time, performance, business limits specified?
|
|
121
|
+
|
|
122
|
+
Note: Technical stack, framework versions will be identified from project automatically, not included in scoring
|
|
123
|
+
|
|
124
|
+
**Scoring Rules**:
|
|
125
|
+
|
|
126
|
+
- 9-10 points: Requirements very complete, can proceed directly
|
|
127
|
+
- 7-8 points: Requirements basically complete, suggest adding minor details
|
|
128
|
+
- 5-6 points: Requirements have significant gaps, must supplement key information
|
|
129
|
+
- 0-4 points: Requirements too vague, needs redescription
|
|
130
|
+
|
|
131
|
+
**When score is below 7, proactively ask supplementary questions**:
|
|
132
|
+
|
|
133
|
+
- Identify missing key information dimensions
|
|
134
|
+
- Ask 1-2 specific questions for each missing dimension
|
|
135
|
+
- Provide examples to help users understand needed information
|
|
136
|
+
- Re-score after user supplements information
|
|
137
|
+
|
|
138
|
+
**Scoring Example**:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
User Request: "Help me optimize code"
|
|
142
|
+
Scoring Analysis:
|
|
143
|
+
- Goal Clarity: 0/3 points (doesn't specify what code or what problem)
|
|
144
|
+
- Expected Results: 0/3 points (no success criteria or expected effect defined)
|
|
145
|
+
- Scope Boundaries: 1/2 points (only knows code optimization, but scope unclear)
|
|
146
|
+
- Constraints: 0/2 points (no performance metrics or time limits)
|
|
147
|
+
Total Score: 1/10 - Requires significant information
|
|
148
|
+
|
|
149
|
+
Questions to Ask:
|
|
150
|
+
1. Which file or module's code do you want to optimize?
|
|
151
|
+
2. What specific problem needs optimization?
|
|
152
|
+
3. What effect do you expect after optimization (e.g., response time improvement, code reduction)?
|
|
153
|
+
4. Are there specific performance metrics or time requirements?
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Common Supplementary Question Templates**:
|
|
157
|
+
|
|
158
|
+
- Goal: "What specific functionality/effect do you want?" "What's the current problem?"
|
|
159
|
+
- Results: "How to determine task success?" "What's the expected output/effect?"
|
|
160
|
+
- Scope: "Which specific files/modules to handle?" "What should be excluded?"
|
|
161
|
+
- Constraints: "What are the time requirements?" "Any business limitations or performance requirements?"
|
|
162
|
+
|
|
163
|
+
**Auto-detected Project Information** (no need to ask):
|
|
164
|
+
|
|
165
|
+
- Tech stack (from AGENTS.md, CLAUDE.md, package.json, requirements.txt, etc.)
|
|
166
|
+
- Framework versions (from AGENTS.md, CLAUDE.md, config files)
|
|
167
|
+
- Project structure (from file system)
|
|
168
|
+
- Existing code conventions (from AGENTS.md, CLAUDE.md, config files and existing code)
|
|
169
|
+
- Development commands (from AGENTS.md, CLAUDE.md, such as build, test, typecheck)
|
|
170
|
+
|
|
171
|
+
#### Execution Steps
|
|
172
|
+
|
|
173
|
+
- Analyze task requirements and constraints
|
|
174
|
+
- Perform requirement completeness scoring (show specific scores)
|
|
175
|
+
- Identify key objectives and success criteria
|
|
176
|
+
- Gather necessary technical context
|
|
177
|
+
- Use MCP services for additional information if needed
|
|
178
|
+
|
|
179
|
+
### 💡 Phase 2: Solution Ideation
|
|
180
|
+
|
|
181
|
+
[Mode: Ideate] - Designing solution approaches:
|
|
182
|
+
|
|
183
|
+
- Generate multiple feasible solutions
|
|
184
|
+
- Evaluate pros and cons of each approach
|
|
185
|
+
- Provide detailed comparison and recommendation
|
|
186
|
+
- Consider technical constraints and best practices
|
|
187
|
+
- Request user approval before proceeding
|
|
188
|
+
|
|
189
|
+
### 📋 Phase 3: Detailed Planning
|
|
190
|
+
|
|
191
|
+
[Mode: Plan] - Creating execution roadmap:
|
|
192
|
+
|
|
193
|
+
- Break down solution into atomic, executable steps
|
|
194
|
+
- Define file structure, functions/classes, and logic overview
|
|
195
|
+
- Specify expected results for each step
|
|
196
|
+
- Query new libraries using Context7 if needed
|
|
197
|
+
- Request user approval before proceeding
|
|
198
|
+
|
|
199
|
+
### ⚡ Phase 4: Implementation
|
|
200
|
+
|
|
201
|
+
[Mode: Execute] - Code development:
|
|
202
|
+
|
|
203
|
+
- Store execution plan in project root directory `.zcf/plan/current/task-name.md`
|
|
204
|
+
- Implement according to approved plan
|
|
205
|
+
- Follow development best practices
|
|
206
|
+
- Add usage methods before import statements (critical rule)
|
|
207
|
+
- Request feedback at key milestones
|
|
208
|
+
|
|
209
|
+
### 🚀 Phase 5: Code Optimization
|
|
210
|
+
|
|
211
|
+
[Mode: Optimize] - Quality improvement:
|
|
212
|
+
|
|
213
|
+
- Automatically analyze implemented code
|
|
214
|
+
- Identify redundant, inefficient, or problematic code
|
|
215
|
+
- Provide specific optimization recommendations
|
|
216
|
+
- Execute improvements after user confirmation
|
|
217
|
+
|
|
218
|
+
### ✅ Phase 6: Quality Review
|
|
219
|
+
|
|
220
|
+
[Mode: Review] - Final assessment:
|
|
221
|
+
|
|
222
|
+
- Compare results against original plan
|
|
223
|
+
- Identify any remaining issues or improvements
|
|
224
|
+
- Provide completion summary and recommendations
|
|
225
|
+
- Request final user confirmation
|
|
226
|
+
- After task completion, move plan file from `.zcf/plan/current/` to `.zcf/plan/history/` for archiving
|
|
227
|
+
- Rename to `[Finish Time]task-name.md` during archiving for tracking, Finish Time format is `YYYY-MM-DD_HHMMSS`
|
|
228
|
+
|
|
229
|
+
## Expected Output Structure
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
project/ # Project root directory
|
|
233
|
+
├── .zcf/
|
|
234
|
+
│ └── plan/
|
|
235
|
+
│ ├── current/ # Current ongoing tasks
|
|
236
|
+
│ │ └── task-name.md # Execution plan and context
|
|
237
|
+
│ └── history/ # Completed historical tasks
|
|
238
|
+
│ └── [Finish Time]task-name.md # Archived task records
|
|
239
|
+
├── src/
|
|
240
|
+
│ ├── components/
|
|
241
|
+
│ ├── services/
|
|
242
|
+
│ ├── utils/
|
|
243
|
+
│ └── types/
|
|
244
|
+
├── tests/
|
|
245
|
+
│ ├── unit/
|
|
246
|
+
│ ├── integration/
|
|
247
|
+
│ └── e2e/
|
|
248
|
+
└── README.md
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Begin execution with the provided task description and report progress after each phase completion.**
|