@jspg-ai/coding-bb 0.0.1 → 0.0.2-beta.22
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/cbb/bin/cbb.js +6 -0
- package/cbb/bin/cbbm.js +6 -0
- package/cbb/dev-standards/rules/cbb-ai-behavior.md +103 -103
- package/cbb/dev-standards/rules/cbb-priority.md +55 -55
- package/cbb/lib/install/claude-code.js +2 -0
- package/cbb/lib/install/init.js +496 -290
- package/cbb/lib/install/opencode.js +31 -0
- package/cbb/lib/install/qoder.js +2 -0
- package/cbb/lib/install/workspaces.js +53 -13
- package/cbb/lib/openspec/index.js +3 -3
- package/cbb/lib/superpowers/index.js +1 -1
- package/cbb/lib/utils/check-update.js +16 -14
- package/cbb/lib/utils/gitignore.js +2 -1
- package/cbb/lib/utils/output.js +92 -4
- package/cbb/lib/utils/version.js +2 -31
- package/cbb/lib/wiki/cli.js +25 -25
- package/cbb/lib/wiki/index.js +16 -16
- package/cbb/tools/cbb-design-to-wiki/SKILL.md +14 -14
- package/cbb/tools/cbb-wiki-ops/SKILL.md +22 -22
- package/cbb/worktrees/_shared/scripts/find-target-worktree.js +2 -2
- package/cbb/worktrees/_shared/scripts/find-workspace-root.js +7 -7
- package/cbb/worktrees/_shared/scripts/push-core.js +18 -0
- package/cbb/worktrees/commands/{close.md → worktree-close.md} +8 -8
- package/cbb/worktrees/commands/{init.md → worktree-init.md} +9 -9
- package/cbb/worktrees/commands/{push.md → worktree-push.md} +3 -3
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/SKILL.md +20 -20
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-env.js +4 -4
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-unarchived.js +1 -1
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/delete-branches.js +3 -3
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/discover-apps.js +6 -6
- package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-close}/scripts/find-target-worktree.js +2 -2
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-close}/scripts/find-workspace-root.js +7 -7
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/remove-worktrees.js +4 -4
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/safety-check.js +4 -4
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/SKILL.md +81 -107
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/auto-open.js +1 -1
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env-deep.js +4 -4
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-env.js +6 -6
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/check-repos.js +4 -4
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-branches.js +4 -4
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/create-worktrees.js +8 -7
- package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-init}/scripts/find-workspace-root.js +7 -7
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/install-ai.js +33 -33
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/parse-config.js +7 -7
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/push-branches.js +9 -7
- package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/push-core.js +18 -0
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/sync-repos.js +10 -12
- package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-init}/scripts/update-gitignore.js +19 -6
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/SKILL.md +16 -16
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/commit-worktrees.js +2 -2
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/find-target-worktree.js +2 -2
- package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-push}/scripts/find-workspace-root.js +7 -7
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-core.js +18 -0
- package/cbb/worktrees/skills/{openspec-push-worktrees → cbb-worktree-push}/scripts/push-worktrees.js +7 -5
- package/config/workspace-config.sample.json +18 -0
- package/config/workspaces.json +11 -6
- package/openspec/.version +6 -6
- package/openspec/commands/apply.md +7 -7
- package/openspec/commands/archive.md +7 -7
- package/openspec/commands/bulk-archive.md +7 -7
- package/openspec/commands/continue.md +7 -7
- package/openspec/commands/explore.md +7 -7
- package/openspec/commands/ff.md +7 -7
- package/openspec/commands/new.md +7 -7
- package/openspec/commands/onboard.md +7 -7
- package/openspec/commands/propose.md +7 -7
- package/openspec/commands/sync.md +7 -7
- package/openspec/commands/update.md +7 -7
- package/openspec/commands/verify.md +7 -7
- package/openspec/skills/openspec-apply-change/SKILL.md +187 -187
- package/openspec/skills/openspec-archive-change/SKILL.md +181 -181
- package/openspec/skills/openspec-bulk-archive-change/SKILL.md +338 -338
- package/openspec/skills/openspec-continue-change/SKILL.md +117 -117
- package/openspec/skills/openspec-explore/SKILL.md +342 -342
- package/openspec/skills/openspec-ff-change/SKILL.md +116 -116
- package/openspec/skills/openspec-new-change/SKILL.md +76 -76
- package/openspec/skills/openspec-onboard/SKILL.md +560 -560
- package/openspec/skills/openspec-propose/SKILL.md +162 -162
- package/openspec/skills/openspec-sync-specs/SKILL.md +261 -261
- package/openspec/skills/openspec-update-change/SKILL.md +90 -90
- package/openspec/skills/openspec-verify-change/SKILL.md +174 -174
- package/package.json +4 -3
- package/superpowers/.version +6 -6
- package/superpowers/skills/brainstorming/SKILL.md +250 -250
- package/superpowers/skills/brainstorming/scripts/helper.js +167 -167
- package/superpowers/skills/brainstorming/scripts/start-server.sh +209 -209
- package/superpowers/skills/brainstorming/scripts/stop-server.sh +120 -120
- package/superpowers/skills/brainstorming/spec-document-reviewer-prompt.md +49 -49
- package/superpowers/skills/brainstorming/visual-companion.md +299 -299
- package/superpowers/skills/dispatching-parallel-agents/SKILL.md +167 -167
- package/superpowers/skills/executing-plans/SKILL.md +64 -64
- package/superpowers/skills/finishing-a-development-branch/SKILL.md +225 -225
- package/superpowers/skills/receiving-code-review/SKILL.md +205 -205
- package/superpowers/skills/requesting-code-review/SKILL.md +95 -95
- package/superpowers/skills/requesting-code-review/code-reviewer.md +181 -181
- package/superpowers/skills/subagent-driven-development/SKILL.md +568 -568
- package/superpowers/skills/subagent-driven-development/implementer-prompt.md +154 -154
- package/superpowers/skills/subagent-driven-development/re-review-prompt.md +115 -115
- package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +207 -207
- package/superpowers/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/superpowers/skills/systematic-debugging/SKILL.md +283 -283
- package/superpowers/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/superpowers/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/superpowers/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/superpowers/skills/systematic-debugging/find-polluter.sh +72 -72
- package/superpowers/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/superpowers/skills/systematic-debugging/test-academic.md +14 -14
- package/superpowers/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/superpowers/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/superpowers/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/superpowers/skills/test-driven-development/SKILL.md +320 -320
- package/superpowers/skills/test-driven-development/writing-good-tests.md +198 -198
- package/superpowers/skills/using-git-worktrees/SKILL.md +167 -167
- package/superpowers/skills/using-superpowers/SKILL.md +63 -63
- package/superpowers/skills/using-superpowers/references/antigravity-tools.md +23 -23
- package/superpowers/skills/using-superpowers/references/codex-tools.md +108 -108
- package/superpowers/skills/using-superpowers/references/gemini-tools.md +63 -63
- package/superpowers/skills/using-superpowers/references/hermes-tools.md +56 -56
- package/superpowers/skills/using-superpowers/references/pi-tools.md +16 -16
- package/superpowers/skills/verification-before-completion/SKILL.md +120 -120
- package/superpowers/skills/writing-plans/SKILL.md +171 -171
- package/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +49 -49
- package/superpowers/skills/writing-skills/SKILL.md +679 -679
- package/superpowers/skills/writing-skills/anthropic-best-practices.md +1150 -1150
- package/superpowers/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -189
- package/superpowers/skills/writing-skills/persuasion-principles.md +187 -187
- package/superpowers/skills/writing-skills/render-graphs.js +169 -169
- package/superpowers/skills/writing-skills/testing-skills-with-subagents.md +384 -384
- package/cbb/worktrees/commands/extend.md +0 -65
- package/cbb/worktrees/skills/openspec-close-worktree/scripts/find-target-worktree.js +0 -96
- package/cbb/worktrees/skills/openspec-extend-worktree/SKILL.md +0 -390
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-env.js +0 -95
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/check-repos.js +0 -98
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/create-branches-and-worktrees.js +0 -135
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/install-ai.js +0 -150
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/list-available-apps.js +0 -88
- package/cbb/worktrees/skills/openspec-extend-worktree/scripts/sync-repos.js +0 -93
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/find-workspace-root.js +0 -67
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/generate-app-options.js +0 -93
- package/cbb/worktrees/skills/openspec-init-worktree/scripts/push-core.js +0 -136
- package/cbb/worktrees/skills/openspec-push-worktrees/scripts/silence-popup.js +0 -23
- package/config/config.sample.json +0 -16
- /package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/silence-popup.js +0 -0
- /package/cbb/worktrees/skills/{openspec-extend-worktree → cbb-worktree-init}/scripts/silence-popup.js +0 -0
- /package/cbb/worktrees/skills/{openspec-init-worktree → cbb-worktree-push}/scripts/silence-popup.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
description: "关闭/清理/删除需求工作空间的 worktree 和分支。触发:用户明确说关闭/清理/删除 worktree、结束隔离开发、合并完要清理。禁止在
|
|
2
|
+
name: cbb-worktree-close
|
|
3
|
+
description: "关闭/清理/删除需求工作空间的 worktree 和分支。触发:用户明确说关闭/清理/删除 worktree、结束隔离开发、合并完要清理。禁止在 cbb-worktree-init 执行后自动调用——只有用户主动要求关闭时才触发。"
|
|
4
4
|
license: MIT
|
|
5
5
|
compatibility: Requires git (>=2.30) and Node.js (>=16.7.0). All commands are pure Node.js scripts under `scripts/`, fully cross-platform (Windows / macOS / Linux, bash / PowerShell / Git Bash).
|
|
6
6
|
metadata:
|
|
@@ -11,17 +11,17 @@ metadata:
|
|
|
11
11
|
|
|
12
12
|
# Close Worktree(跨平台脚本化版本 v2.0)
|
|
13
13
|
|
|
14
|
-
关闭一个由 `
|
|
14
|
+
关闭一个由 `cbb-worktree-init` 创建的多仓库联动隔离环境:移除 workspace worktree 及所有关联应用 worktree,并默认保留特性分支(按需手动清理)。当你需要结束一次跨多仓库的隔离开发、把环境打扫干净时,本技能一次性完成 worktree 移除与会话收尾。
|
|
15
15
|
|
|
16
|
-
**启动时声明:** "我正在使用
|
|
16
|
+
**启动时声明:** "我正在使用 cbb-worktree-close 技能来关闭多仓库联动的隔离 worktree 环境。"
|
|
17
17
|
|
|
18
18
|
## 核心原则
|
|
19
19
|
|
|
20
20
|
- 本技能的所有原子操作封装为 `scripts/*.js` Node.js 脚本,**跨平台执行**
|
|
21
|
-
- 本技能是 `
|
|
21
|
+
- 本技能是 `cbb-worktree-init` 的逆操作:共用 `workspace-config.json`、共用 `.worktrees/worktree-<需求名>/` 物理直聚命名、共用统一的分支名(不加前缀)
|
|
22
22
|
- App worktree **物理嵌套**在 workspace worktree 内(`.worktrees/worktree-<需求名>/<应用名>/`),但 git 上属于各自仓库的独立 worktree
|
|
23
23
|
- 只操作 `.worktrees/worktree-<需求名>` 这一类精确路径,**绝不碰其它 worktree**(如 IDE/工具自动创建的 `~/.qoder/worktree/...` 会话 worktree)
|
|
24
|
-
- 通过检查 `.worktrees/worktree-<需求名>/<应用名>/` **是否实际存在**来确定关联应用——创建时用户可能只关联了 `
|
|
24
|
+
- 通过检查 `.worktrees/worktree-<需求名>/<应用名>/` **是否实际存在**来确定关联应用——创建时用户可能只关联了 `workspace-config.json` 中的部分应用,不能假设全部应用都关联
|
|
25
25
|
- **顺序硬约束:先移除所有 worktree,再删除分支。** 目标分支当前正检出于 worktree 中,先删分支会报 `error: Cannot delete branch '<分支>' checked out at '<worktree 路径>'`
|
|
26
26
|
- **破坏性操作必须先报告、经用户确认才执行**:未提交修改、未合并/未推送的提交,绝不静默 `--force` 或 `-D` 丢弃
|
|
27
27
|
- 软性检查失败时报告详情,询问用户是否继续
|
|
@@ -34,7 +34,7 @@ metadata:
|
|
|
34
34
|
### 0.1 环境健康探活
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
37
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/check-env.js"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
**解读输出**:
|
|
@@ -45,16 +45,16 @@ node "D:/workspace/<ws_root>/.qoder/skills/openspec-close-worktree/scripts/check
|
|
|
45
45
|
### 0.2 定位工作空间根目录
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
48
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/find-workspace-root.js"
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
**解读输出**:
|
|
52
52
|
- 退出码 0 + 末行(纯路径) → WS_ROOT 绝对路径
|
|
53
53
|
- 退出码 1 → 未找到工作空间根目录,**终止流程**
|
|
54
54
|
|
|
55
|
-
> ⓘ **为什么不用
|
|
55
|
+
> ⓘ **为什么不用 workspace-config.json 存在性判断**:init-worktree 会把 workspace-config.json 提交到主分支,`git worktree add` 会自动 checkout 副本到 worktree 目录中。若用 workspace-config.json 存在性判断,在 worktree 内执行时会错误地把 worktree 目录当作 WS_ROOT。使用 `git worktree list` 的第一行(git 契约上始终为主仓库绝对路径)则不受该问题影响。
|
|
56
56
|
|
|
57
|
-
> close-worktree 是 init-worktree 的逆操作,但本步骤的 WS_ROOT 定位逻辑与 init-worktree 不同:init-worktree 强制根目录执行(不需要处理 worktree 场景),close-worktree 支持 worktree 内执行(需要绕开
|
|
57
|
+
> close-worktree 是 init-worktree 的逆操作,但本步骤的 WS_ROOT 定位逻辑与 init-worktree 不同:init-worktree 强制根目录执行(不需要处理 worktree 场景),close-worktree 支持 worktree 内执行(需要绕开 workspace-config.json 副本陷阱)。
|
|
58
58
|
|
|
59
59
|
---
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ node "D:/workspace/<ws_root>/.qoder/skills/openspec-close-worktree/scripts/find-
|
|
|
69
69
|
3. AI agent 列出 `.worktrees/` 下的所有 worktree:
|
|
70
70
|
|
|
71
71
|
```bash
|
|
72
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
72
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/find-target-worktree.js "<ws_root>"
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
> 注:本技能支持工作空间根目录或 worktree 内执行,find-target-worktree 自动从 cwd 反推或列出。
|
|
@@ -84,10 +84,10 @@ node "D:/workspace/<ws_root>/.qoder/skills/openspec-close-worktree/scripts/find-
|
|
|
84
84
|
### 1.2 发现关联应用 worktree
|
|
85
85
|
|
|
86
86
|
```bash
|
|
87
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
87
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/discover-apps.js "<ws_root>" "<branch>"
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
脚本自动从 `
|
|
90
|
+
脚本自动从 `workspace-config.json` 读取应用列表,扫描 `.worktrees/worktree-<branch>/<应用名>/` 实际存在的子目录。
|
|
91
91
|
|
|
92
92
|
**解读末行 `DISCOVER_RESULT`**:
|
|
93
93
|
- `workspace` 字段:workspace worktree 绝对路径(AI agent 记录供后续命令使用)
|
|
@@ -98,7 +98,7 @@ node "D:/workspace/<ws_root>/.qoder/skills/openspec-close-worktree/scripts/disco
|
|
|
98
98
|
### 1.3 检查未归档 change
|
|
99
99
|
|
|
100
100
|
```bash
|
|
101
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
101
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/check-unarchived.js "<ws_root>"
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
脚本扫描 `openspec/changes/` 目录,筛选出非 `archive/` 子目录的 change 名称列表。
|
|
@@ -117,7 +117,7 @@ node "D:/workspace/<ws_root>/.qoder/skills/openspec-close-worktree/scripts/check
|
|
|
117
117
|
对 workspace worktree 和每个关联应用 worktree,依次执行三项检查并汇总成安全状态表。**这是破坏性操作前的必经环节,结果将驱动 Step 3 的用户决策。**
|
|
118
118
|
|
|
119
119
|
```bash
|
|
120
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
120
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/safety-check.js "<ws_root>" "<branch>"
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
脚本内部对每个仓库自动执行:
|
|
@@ -243,7 +243,7 @@ node "<skill>/scripts/delete-branches.js" "<ws_root>" "<branch>" local_remote
|
|
|
243
243
|
### 3.4 未推送 commit 处理(仅当 2.4 任一 worktree `unpushed_count > 0` 时出现)
|
|
244
244
|
|
|
245
245
|
**场景**:
|
|
246
|
-
- 用户在 worktree 中做了 commit,但**没有调** `
|
|
246
|
+
- 用户在 worktree 中做了 commit,但**没有调** `cbb-worktree-push` 推送
|
|
247
247
|
- 本地有 ahead 提交未推送到 origin
|
|
248
248
|
- 一旦 close worktree + 后续走 `local` / `local_remote` 删分支,ahead 提交可能永久丢失(取决于上游 `delete-branches.js` 行为)
|
|
249
249
|
|
|
@@ -255,12 +255,12 @@ node "<skill>/scripts/delete-branches.js" "<ws_root>" "<branch>" local_remote
|
|
|
255
255
|
- ep-baz-app: 2 个 commit
|
|
256
256
|
|
|
257
257
|
请选择处理方式:
|
|
258
|
-
[先推送](推荐)调
|
|
258
|
+
[先推送](推荐)调 cbb-worktree-push 推送所有 ahead 提交
|
|
259
259
|
[接受丢失] 继续关闭,ahead 提交在删分支后永久丢失
|
|
260
260
|
[中止] 终止流程,我先手动处理
|
|
261
261
|
```
|
|
262
262
|
|
|
263
|
-
- 用户选择「先推送」→ AI 引导用户执行 `
|
|
263
|
+
- 用户选择「先推送」→ AI 引导用户执行 `cbb-worktree-push`(或 `/cbb:worktree-push`),完成后**重新跑** Step 2 safety-check 确认 `unpushed_count = 0` 再回到本步骤
|
|
264
264
|
- 用户选择「接受丢失」→ 必须二次确认(ahead 提交真的会丢),确认后继续 Step 4
|
|
265
265
|
- 用户选择「中止」→ 终止流程
|
|
266
266
|
|
|
@@ -289,7 +289,7 @@ node "<skill>/scripts/delete-branches.js" "<ws_root>" "<branch>" local_remote
|
|
|
289
289
|
**顺序:先移除各应用 worktree,再移除 workspace worktree**(逆序于创建;也为后续删分支扫清"分支仍被检出"的障碍)。
|
|
290
290
|
|
|
291
291
|
```bash
|
|
292
|
-
node "D:/workspace/<ws_root>/.qoder/skills/
|
|
292
|
+
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-close/scripts/remove-worktrees.js "<ws_root>" "<branch>" "<force>"
|
|
293
293
|
```
|
|
294
294
|
|
|
295
295
|
**三层降级策略**:`git worktree remove` 实际包含两个动作——①清理 git 元数据(`.git/worktrees/`)②删除物理目录。当 IDE 占用目录时 ② 会被 Windows 文件锁阻塞,但 ① 永远不受影响。脚本将这两个动作解耦:
|
|
@@ -418,7 +418,7 @@ git -C "<ws_root>" worktree list
|
|
|
418
418
|
|
|
419
419
|
### 必须执行
|
|
420
420
|
|
|
421
|
-
- 读 `
|
|
421
|
+
- 读 `workspace-config.json` 取应用名列表;以 `.worktrees/worktree-<需求名>/<应用名>/` 实际存在性确定关联清单
|
|
422
422
|
- 移除/删除前执行安全评估(未提交修改 / 是否合并 / 是否推远程)并报告
|
|
423
423
|
- 严格按 Step 4.2(移除 worktree)→ Step 4.4(删分支)顺序
|
|
424
424
|
- 移除 workspace worktree 前先把会话移出(`cd "<WS_ROOT>" &&` 或 `git -C` 绝对路径)
|
package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/check-env.js
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
require('./silence-popup');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cbb-worktree-close 环境健康探活
|
|
5
5
|
*
|
|
6
|
-
* close-worktree 必须在工作空间根目录或 worktree 内执行,且需找到
|
|
7
|
-
* 与 init/extend 探活同构,但额外校验
|
|
6
|
+
* close-worktree 必须在工作空间根目录或 worktree 内执行,且需找到 workspace-config.json。
|
|
7
|
+
* 与 init/extend 探活同构,但额外校验 workspace-config.json 存在性。
|
|
8
8
|
*
|
|
9
9
|
* 退出码:
|
|
10
10
|
* 0 - 探活通过
|
|
11
11
|
* 1 - 致命错误(git 不可用)
|
|
12
12
|
* 2 - 当前不在 git 仓库
|
|
13
|
-
* 3 - 未找到
|
|
13
|
+
* 3 - 未找到 workspace-config.json
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
const { execSync } = require('child_process');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
require('./silence-popup');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cbb-worktree-close 删除分支 (按用户选择)
|
|
5
5
|
*/
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
7
|
const fs = require('fs');
|
|
@@ -116,7 +116,7 @@ function deleteBranch(repoPath, name) {
|
|
|
116
116
|
return true;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
const configPath = path.join(wsRoot, '
|
|
119
|
+
const configPath = path.join(wsRoot, 'workspace-config.json');
|
|
120
120
|
let config = {};
|
|
121
121
|
try { config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); } catch (e) {}
|
|
122
122
|
|
|
@@ -127,7 +127,7 @@ deleteBranch(wsRoot, 'workspace');
|
|
|
127
127
|
|
|
128
128
|
console.log('=== Delete App Branches ===');
|
|
129
129
|
for (const app of apps) {
|
|
130
|
-
const appPath = path.join(wsRoot, '.
|
|
130
|
+
const appPath = path.join(wsRoot, '.codespace', app.name);
|
|
131
131
|
deleteBranch(appPath, app.name);
|
|
132
132
|
}
|
|
133
133
|
|
package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/discover-apps.js
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
require('./silence-popup');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cbb-worktree-close 发现关联应用 worktree
|
|
5
5
|
*
|
|
6
6
|
* 用法:node discover-apps.js <ws_root> <branch>
|
|
7
7
|
*
|
|
8
|
-
* 从
|
|
8
|
+
* 从 workspace-config.json 读取应用列表,扫描 .worktrees/worktree-<branch>/ 实际存在的子目录。
|
|
9
9
|
*
|
|
10
10
|
* 输出末行:DISCOVER_RESULT { workspace: <wt_path>, apps: [{name, repo, side, wt_path}] }
|
|
11
11
|
*
|
|
@@ -26,9 +26,9 @@ if (!wsRoot || !branch) {
|
|
|
26
26
|
process.exit(1);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const configPath = path.join(wsRoot, '
|
|
29
|
+
const configPath = path.join(wsRoot, 'workspace-config.json');
|
|
30
30
|
if (!fs.existsSync(configPath)) {
|
|
31
|
-
console.error('❌
|
|
31
|
+
console.error('❌ workspace-config.json 不存在:' + configPath);
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ let config;
|
|
|
36
36
|
try {
|
|
37
37
|
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
38
38
|
} catch (e) {
|
|
39
|
-
console.error('❌
|
|
39
|
+
console.error('❌ workspace-config.json 解析失败:' + e.message);
|
|
40
40
|
process.exit(1);
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -60,7 +60,7 @@ for (const app of apps) {
|
|
|
60
60
|
repo: app.repo,
|
|
61
61
|
side: app.side || 'back',
|
|
62
62
|
wt_path: appWt,
|
|
63
|
-
app_path: path.join(wsRoot, '.
|
|
63
|
+
app_path: path.join(wsRoot, '.codespace', app.name),
|
|
64
64
|
});
|
|
65
65
|
} else {
|
|
66
66
|
console.log('⏭️ ' + app.name + ':无关联 worktree,跳过');
|
|
@@ -47,7 +47,7 @@ if (cwdMatch) {
|
|
|
47
47
|
const worktreesDir = path.join(wsRoot, '.worktrees');
|
|
48
48
|
if (!fs.existsSync(worktreesDir)) {
|
|
49
49
|
console.error('❌ .worktrees 目录不存在:' + worktreesDir);
|
|
50
|
-
console.error(' 请先执行
|
|
50
|
+
console.error(' 请先执行 cbb-worktree-init 创建 worktree');
|
|
51
51
|
console.log('---');
|
|
52
52
|
console.log('NO_WORKTREE');
|
|
53
53
|
process.exit(2);
|
|
@@ -65,7 +65,7 @@ const entries = fs.readdirSync(worktreesDir, { withFileTypes: true })
|
|
|
65
65
|
|
|
66
66
|
if (entries.length === 0) {
|
|
67
67
|
console.error('❌ 未找到任何 worktree');
|
|
68
|
-
console.error(' 请先执行
|
|
68
|
+
console.error(' 请先执行 cbb-worktree-init 创建 worktree');
|
|
69
69
|
console.log('---');
|
|
70
70
|
console.log('NO_WORKTREE');
|
|
71
71
|
process.exit(2);
|
|
@@ -5,8 +5,8 @@ require('./silence-popup');
|
|
|
5
5
|
* 唯一真源:cbb/worktrees/_shared/scripts/find-workspace-root.js
|
|
6
6
|
* 由 scripts/sync-shared.js 展开到各 skill 的 scripts/ 下(init / extend / close / push)。
|
|
7
7
|
*
|
|
8
|
-
* 优先:git worktree list 第一行(主仓库根目录,不受 worktree 内
|
|
9
|
-
* 兜底:当前目录含
|
|
8
|
+
* 优先:git worktree list 第一行(主仓库根目录,不受 worktree 内 workspace-config.json 副本干扰)
|
|
9
|
+
* 兜底:当前目录含 workspace-config.json
|
|
10
10
|
*
|
|
11
11
|
* 退出码:
|
|
12
12
|
* 0 - 定位成功,输出 WS_ROOT 绝对路径
|
|
@@ -44,19 +44,19 @@ if (worktreeList.ok) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// 兜底:当前目录含
|
|
47
|
+
// 兜底:当前目录含 workspace-config.json
|
|
48
48
|
if (!wsRoot) {
|
|
49
49
|
const cwd = process.cwd();
|
|
50
|
-
if (fs.existsSync(path.join(cwd, '
|
|
50
|
+
if (fs.existsSync(path.join(cwd, 'workspace-config.json'))) {
|
|
51
51
|
wsRoot = cwd;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// 校验
|
|
56
|
-
if (!wsRoot || !fs.existsSync(path.join(wsRoot, '
|
|
56
|
+
if (!wsRoot || !fs.existsSync(path.join(wsRoot, 'workspace-config.json'))) {
|
|
57
57
|
console.error('❌ 未找到工作空间根目录');
|
|
58
|
-
console.error(' 原因:git worktree list 失败且当前目录无
|
|
59
|
-
console.error(' 请在业务工作空间根目录(由 cbb setup 初始化、包含
|
|
58
|
+
console.error(' 原因:git worktree list 失败且当前目录无 workspace-config.json');
|
|
59
|
+
console.error(' 请在业务工作空间根目录(由 cbb setup 初始化、包含 workspace-config.json)下执行本技能');
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
require('./silence-popup');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cbb-worktree-close 移除 Worktree(三层降级)
|
|
5
5
|
*
|
|
6
6
|
* 用法:node remove-worktrees.js <ws_root> <branch> <force>
|
|
7
7
|
* force: "true" 启用 --force,"false" 不启用
|
|
@@ -83,7 +83,7 @@ function removeWt(repoPath, wtPath, name) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// 1. 应用 worktrees
|
|
86
|
-
const configPath = path.join(wsRoot, '
|
|
86
|
+
const configPath = path.join(wsRoot, 'workspace-config.json');
|
|
87
87
|
let config = {};
|
|
88
88
|
try { config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); } catch (e) {}
|
|
89
89
|
|
|
@@ -91,7 +91,7 @@ const apps = config.apps || [];
|
|
|
91
91
|
console.log('=== 移除应用 Worktrees ===');
|
|
92
92
|
for (const app of apps) {
|
|
93
93
|
const appWt = path.join(wtDir, app.name);
|
|
94
|
-
const appPath = path.join(wsRoot, '.
|
|
94
|
+
const appPath = path.join(wsRoot, '.codespace', app.name);
|
|
95
95
|
removeWt(appPath, appWt, app.name);
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -101,7 +101,7 @@ removeWt(wsRoot, wtDir, 'workspace');
|
|
|
101
101
|
|
|
102
102
|
// 3. 兜底:清理所有仓库的陈旧 worktree 元数据
|
|
103
103
|
for (const app of apps) {
|
|
104
|
-
run('git worktree prune', path.join(wsRoot, '.
|
|
104
|
+
run('git worktree prune', path.join(wsRoot, '.codespace', app.name));
|
|
105
105
|
}
|
|
106
106
|
run('git worktree prune', wsRoot);
|
|
107
107
|
|
package/cbb/worktrees/skills/{openspec-close-worktree → cbb-worktree-close}/scripts/safety-check.js
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
require('./silence-popup');
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* cbb-worktree-close 安全检查 (合并判定 + 未提交修改 + 远程推送状态)
|
|
5
5
|
*/
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
7
|
const fs = require('fs');
|
|
@@ -144,7 +144,7 @@ function checkRepo(name, repoPath, wtPath) {
|
|
|
144
144
|
} else {
|
|
145
145
|
// @{u} 不存在(本地分支没建立 upstream)
|
|
146
146
|
unpushedCount = -1;
|
|
147
|
-
console.log('WARN no upstream tracking branch (run
|
|
147
|
+
console.log('WARN no upstream tracking branch (run cbb-worktree-push to set up)');
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
console.log('');
|
|
@@ -152,7 +152,7 @@ function checkRepo(name, repoPath, wtPath) {
|
|
|
152
152
|
return { name, wt: wtPath, fetch_ok: fetchOk, dirty_files: dirtyFiles, merged, main, remote_exists: remoteExists, remote: remoteName, unpushed_count: unpushedCount };
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
const configPath = path.join(wsRoot, '
|
|
155
|
+
const configPath = path.join(wsRoot, 'workspace-config.json');
|
|
156
156
|
let config = {};
|
|
157
157
|
try { config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); } catch (e) {}
|
|
158
158
|
|
|
@@ -165,7 +165,7 @@ results.push(checkRepo('workspace', wsRoot, wtDir));
|
|
|
165
165
|
|
|
166
166
|
for (const app of apps) {
|
|
167
167
|
const appWt = path.join(wtDir, app.name);
|
|
168
|
-
const appPath = path.join(wsRoot, '.
|
|
168
|
+
const appPath = path.join(wsRoot, '.codespace', app.name);
|
|
169
169
|
results.push(checkRepo(app.name, appPath, appWt));
|
|
170
170
|
}
|
|
171
171
|
|