@jspg-ai/coding-bb 0.0.2-beta.29 → 0.0.3-beta.2
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/cbbm.js +1 -1
- package/cbb/dev-standards/rules/cbb-ai-behavior.md +13 -0
- package/cbb/lib/install/init.js +78 -199
- package/cbb/lib/install/workspaces.js +24 -0
- package/cbb/lib/utils/check-update.js +1 -1
- package/cbb/worktrees/commands/worktree-close.md +1 -1
- package/cbb/worktrees/commands/worktree-init.md +6 -10
- package/cbb/worktrees/skills/cbb-worktree-close/SKILL.md +1 -1
- package/cbb/worktrees/skills/cbb-worktree-close/scripts/check-env.js +4 -4
- package/cbb/worktrees/skills/cbb-worktree-init/SKILL.md +26 -51
- package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-env-deep.js +3 -33
- package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-env.js +5 -14
- package/cbb/worktrees/skills/cbb-worktree-push/SKILL.md +2 -2
- package/config/workspace-agents.sample.md +39 -37
- package/config/workspaces.json +5 -0
- package/package.json +2 -2
- package/cbb/worktrees/skills/cbb-worktree-init/scripts/auto-open.js +0 -136
- package/cbb/worktrees/skills/cbb-worktree-init/scripts/install-ai.js +0 -177
|
@@ -28,7 +28,7 @@ metadata:
|
|
|
28
28
|
|
|
29
29
|
## 调用脚本的统一方式
|
|
30
30
|
|
|
31
|
-
**重要**:所有脚本必须用**绝对路径**调用。`./scripts/...` 相对路径在
|
|
31
|
+
**重要**:所有脚本必须用**绝对路径**调用。`./scripts/...` 相对路径在 Agent 运行环境中不适用(AI agent 的 cwd 不一定是技能目录)。
|
|
32
32
|
|
|
33
33
|
调用方式(推荐用绝对路径):
|
|
34
34
|
```
|
|
@@ -59,12 +59,12 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/check-env.j
|
|
|
59
59
|
|
|
60
60
|
**解读输出**:
|
|
61
61
|
- 退出码 0 + 末行 `ENV_OK {...}` → 探活通过,继续
|
|
62
|
-
- 退出码 1 → git
|
|
62
|
+
- 退出码 1 → git 不可用(运行环境 DLL 问题),**终止流程,提示用户到系统终端重试**
|
|
63
63
|
- 退出码 2 → 当前不在 git 仓库,**终止流程,提示用户到工作空间根目录**
|
|
64
64
|
|
|
65
65
|
### 0.1.5 环境健康自检(check-env-deep)
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
提前检测权限/版本问题,把可能在后续步骤暴露的失败前移到流程最开始:
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/check-env-deep.js"
|
|
@@ -76,8 +76,6 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/check-env-d
|
|
|
76
76
|
|
|
77
77
|
**检测项**:
|
|
78
78
|
- Node.js >= 16.7.0
|
|
79
|
-
- npm 官方源可达(`https://registry.npmjs.org`)
|
|
80
|
-
- cbb 是否已安装(未安装仅警告,由 Step 4 自动安装)
|
|
81
79
|
- `.worktrees/` 目录可写
|
|
82
80
|
|
|
83
81
|
### 0.2 读取并校验 workspace-config.json
|
|
@@ -298,7 +296,7 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/create-work
|
|
|
298
296
|
3. **app worktree 创建**(物理嵌套在 workspace worktree 内)
|
|
299
297
|
|
|
300
298
|
**解读输出**:
|
|
301
|
-
- 退出码 0 + 末行 `WT_PATH <绝对路径>` → 全部成功,AI 解析出 worktree 绝对路径供后续 Step 4
|
|
299
|
+
- 退出码 0 + 末行 `WT_PATH <绝对路径>` → 全部成功,AI 解析出 worktree 绝对路径供后续 Step 4 使用
|
|
302
300
|
- 退出码 2 → workspace worktree 创建失败(分支已检出/权限不足),**终止流程**
|
|
303
301
|
- 退出码 3 → 部分 app worktree 创建失败,**报告已创建/失败详情,用户需手动清理**
|
|
304
302
|
|
|
@@ -313,52 +311,31 @@ WT_PATH d:\workspace\xxx\.worktrees\worktree-feature-login
|
|
|
313
311
|
|
|
314
312
|
> ⓘ **tracked 内容自动 checkout**:workspace 主分支 tracked 的所有内容(openspec/、cbb/ 等)在 workspace 工作树创建时**自动从 git 对象库 checkout**——**不需要 `cp`、`git clone` 或任何“带过来”动作**。各应用 worktree 同理。
|
|
315
313
|
|
|
316
|
-
> ⓘ **AI 配置目录(.claude/、.qoder/
|
|
314
|
+
> ⓘ **AI 配置目录(.claude/、.qoder/、.opencode/ 等)**:统一安装在业务空间根(`cbb setup` / `cbb update`),**worktree 内不安装**;AI 会话始终以空间根为基础,开发动作指向本 worktree 路径。
|
|
317
315
|
|
|
318
316
|
---
|
|
319
317
|
|
|
320
|
-
## Step 4
|
|
318
|
+
## Step 4:收尾与交接(必要步骤)
|
|
321
319
|
|
|
322
|
-
|
|
323
|
-
**本步骤在 worktree 内执行 `cbbm init --yes` 是必要步骤**——缺失 AI 配置会导致后续
|
|
324
|
-
openspec-propose/apply/verify/ff 等技能全部不可用,worktree 将处于"半残"状态。
|
|
320
|
+
不执行脚本。AI agent 向用户输出最终报告(格式见「最终报告」),并完成以下交接声明:
|
|
325
321
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/install-ai.js "<wt_path>"
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
**解读输出**:
|
|
333
|
-
- 退出码 0 + 末行 `AI_INIT_OK` → 成功,继续 Step 5
|
|
334
|
-
- 退出码 1 → 参数错误(脚本 bug)
|
|
335
|
-
- 退出码 2 + 末行 `AI_INIT_FAILED` → cbbm init 执行失败,**init-worktree 中断**,
|
|
336
|
-
按错误提示手动执行 `cd "<wt_path>" && cbbm init --yes` 后重跑
|
|
337
|
-
|
|
338
|
-
> `-y` 表示非交互模式:默认选中所有适配器、前置依赖未安装时自动继续,适合 skill 自动化执行。
|
|
322
|
+
1. **继续在当前会话开发**:本技能不打开新窗口;需求工作目录为 `<wt_path>`
|
|
323
|
+
2. **目录纪律**:本会话后续所有产生写操作的命令(git commit / openspec / 构建 / 测试等)必须以 `<wt_path>`(或其应用子目录)为工作目录(显式 `cd` 或绝对路径);**禁止在空间根(主分支)执行任何写操作**
|
|
324
|
+
3. 不自动安装依赖:各仓库技术栈不一(Maven 依赖本机 `~/.m2` 全局共享、无需初始化;Node/Python 等由你进入 worktree 后执行正确的命令,如 `npm ci` / `pnpm`)
|
|
339
325
|
|
|
340
326
|
---
|
|
341
327
|
|
|
342
|
-
##
|
|
328
|
+
## 最终报告
|
|
343
329
|
|
|
344
|
-
|
|
330
|
+
最终报告格式:
|
|
345
331
|
|
|
346
|
-
```
|
|
347
|
-
|
|
332
|
+
```
|
|
333
|
+
✅ worktree 已创建:<wt_path>
|
|
334
|
+
关联应用:<应用名 → 嵌套路径> 列表
|
|
335
|
+
📌 继续在当前会话开发:后续写操作命令一律以上述目录为工作目录
|
|
348
336
|
```
|
|
349
337
|
|
|
350
|
-
|
|
351
|
-
- `ENV=QODER_GUI` / `CURSOR_GUI` / `VSCODE_GUI` / `JETBRAINS_GUI` → GUI 模式(已在新窗口打开 IDE)
|
|
352
|
-
- `ENV=CLI` → CLI 模式(AI agent 自行 cd 到 wt_path)
|
|
353
|
-
- `OPEN_FAILED` → 自动打开失败,提示用户手动操作
|
|
354
|
-
|
|
355
|
-
---
|
|
356
|
-
|
|
357
|
-
## 最终报告
|
|
358
|
-
|
|
359
|
-
最终报告由 AI agent 根据 `auto-open.js` 的末行输出生成,格式同 v1(GUI / CLI / OPEN_FAILED 三种)。
|
|
360
|
-
|
|
361
|
-
> 不自动安装依赖:各仓库技术栈不一(Maven 依赖本机 `~/.m2` 全局共享、无需初始化;Node/Python 等由你进入 worktree 后执行正确的命令,如 `npm ci` / `pnpm`)。猜测安装命令易出错,故不在本步骤处理。
|
|
338
|
+
> 若 Step 3.5 为部分失败(退出码 3),报告必须列出已创建/失败详情与回滚清理命令。
|
|
362
339
|
|
|
363
340
|
---
|
|
364
341
|
|
|
@@ -381,14 +358,14 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/auto-open.j
|
|
|
381
358
|
| 场景 | 处理方式 |
|
|
382
359
|
|------|----------|
|
|
383
360
|
| `.worktrees/` 或 `.codespace/` 未在 `.gitignore` | workspace 仓库自动添加并提交(在 Step 3.2) |
|
|
384
|
-
| `git worktree add` 权限被拒 |
|
|
361
|
+
| `git worktree add` 权限被拒 | 运行环境降级,中断并告知用户 |
|
|
385
362
|
| 状态检查任一失败 | 终止并报告所有问题 |
|
|
386
363
|
| 部分应用 worktree 创建失败 | 提示已创建的回滚清理命令 |
|
|
387
364
|
| workspace 主分支 tracked 内容(openspec/、cbb/ 等) | 自动 checkout 到工作树,无需额外动作(cp/clone 都是多余的) |
|
|
388
|
-
| AI 配置目录(.claude/、.qoder/ 等) |
|
|
365
|
+
| AI 配置目录(.claude/、.qoder/、.opencode/ 等) | 统一安装在空间根(`cbb setup` / `cbb update`);worktree 内不安装、也不需要 |
|
|
389
366
|
| 需求名(同时作分支名和工作树目录名) | 用户在对话中纯文本输入,参考 Step 3.1 命名规则(kebab-case,禁 `..`、路径分隔符、空格) |
|
|
390
367
|
| 关联应用范围 | 固定为 `workspace-config.json` 全量 apps(无勾选);增减应用后重跑本技能(幂等) |
|
|
391
|
-
|
|
|
368
|
+
| 运行环境 node 不可用 | 脚本 fail-fast 并提示用户到系统终端重试 |
|
|
392
369
|
| push 失败(SSH/HTTPS/网络/保护) | push-branches.js 退出码 2,AI 阻塞并询问用户三选项(修复后重试/跳过失败仓库/完全终止) |
|
|
393
370
|
| 远程分支已存在 | push-branches.js 输出 metadata,AI 展示 commit 元信息后询问两选项(关联/终止+重新创建) |
|
|
394
371
|
| 开发过程中推送所有 worktree | Step 3.4 仅覆盖创建时的空 commit;开发过程中产生的提交必须调 `/cbb:worktree-push` 或 `cbb-worktree-push` skill 推送(详见该 skill) |
|
|
@@ -462,10 +439,10 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/auto-open.j
|
|
|
462
439
|
- **问题:** 试图在 Bash 调用中嵌套 Node 脚本与 shell 变量,导致变量解析失败
|
|
463
440
|
- **修复:** 所有脚本参数(`<ws_root>`、`<branch>`)由 AI agent 在对话上下文中维护,**作为字符串参数传入脚本**,不要在 Bash 命令中拼 shell 变量
|
|
464
441
|
|
|
465
|
-
###
|
|
442
|
+
### 在空间根执行写操作命令
|
|
466
443
|
|
|
467
|
-
- **问题:**
|
|
468
|
-
- **修复:** Step 4
|
|
444
|
+
- **问题:** worktree 创建成功后,会话仍在空间根运行 git commit / openspec / 构建命令,污染主分支或把变更产物生成在主分支上
|
|
445
|
+
- **修复:** Step 4 交接已声明需求工作目录 `<wt_path>`;所有写操作命令必须显式 `cd` 或用绝对路径指向 worktree
|
|
469
446
|
|
|
470
447
|
---
|
|
471
448
|
|
|
@@ -479,11 +456,11 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/auto-open.j
|
|
|
479
456
|
- workspace 仓库创建工作树前不验证 `.worktrees/` 和 `.codespace/` 在 `.gitignore`
|
|
480
457
|
- 用 `git checkout -b` 切分支后再建 worktree(分支检出冲突)
|
|
481
458
|
- 用 `AskUserQuestion` 收集自由文本(需求名 / 分支选项等)
|
|
482
|
-
-
|
|
459
|
+
- 运行环境 node 不可用时强行继续 → 改为 fail-fast 提示用户
|
|
483
460
|
- **Step 3.4 推送失败后跳过失败仓库直接继续** → 必须阻塞并询问用户决策
|
|
484
461
|
- **远程分支已存在时脚本自动 set-upstream-to** → 必须由用户决策,避免关联到他人的同名分支
|
|
485
462
|
- **AI 询问关联选项前不输出 commit 元信息** → 必须先在 AskUserQuestion 之前输出远程 hash/author/date/message + 本地 hash
|
|
486
|
-
-
|
|
463
|
+
- **在空间根执行 git/openspec/构建等写操作命令** → 必须显式指定需求工作树路径(`<wt_path>` 或其应用子目录)
|
|
487
464
|
|
|
488
465
|
**必须执行**
|
|
489
466
|
|
|
@@ -507,7 +484,5 @@ node "D:/workspace/<ws_root>/.qoder/skills/cbb-worktree-init/scripts/auto-open.j
|
|
|
507
484
|
| `update-gitignore.js` | 安全更新 .gitignore | ws_root, branch | 0/1/2 |
|
|
508
485
|
| `create-branches.js` | 创建分支 | ws_root, branch | 0/1/2 |
|
|
509
486
|
| `create-worktrees.js` | 创建 worktree(含自愈清理) | ws_root, branch | 0/1/2/3 |
|
|
510
|
-
| `install-ai.js` | 安装 AI 配置(**必要步骤**) | wt_path | 0/1/2 |
|
|
511
487
|
| `push-branches.js` | 推送并建立 upstream(已一致则 skipped;带错误归类 + 元信息采集) | ws_root, branch | 0/1/2 |
|
|
512
|
-
| `check-env-deep.js` | 环境健康自检(Node 版本 /
|
|
513
|
-
| `auto-open.js` | 环境感知自动打开(**新窗口**) | wt_path | 0(始终) |
|
|
488
|
+
| `check-env-deep.js` | 环境健康自检(Node 版本 / 权限) | 无 | 0/2 |
|
|
@@ -7,26 +7,15 @@ require('./silence-popup');
|
|
|
7
7
|
*
|
|
8
8
|
* 检测项:
|
|
9
9
|
* 1. Node.js 版本(>= 16.7.0)
|
|
10
|
-
* 2.
|
|
11
|
-
* 3. cbb 是否已安装(未安装视为软警告,由 Step 4 自动安装)
|
|
12
|
-
* 4. .worktrees/ 目录可写性
|
|
10
|
+
* 2. .worktrees/ 目录可写性
|
|
13
11
|
*
|
|
14
12
|
* 退出码:
|
|
15
13
|
* 0 - 全部通过(DOCTOR_OK)
|
|
16
|
-
* 2 - 致命问题(Node 版本 /
|
|
14
|
+
* 2 - 致命问题(Node 版本 / 权限),必须修复后重试
|
|
17
15
|
*/
|
|
18
|
-
const { execSync } = require('child_process');
|
|
19
16
|
const fs = require('fs');
|
|
20
17
|
const path = require('path');
|
|
21
18
|
|
|
22
|
-
function run(cmd) {
|
|
23
|
-
try {
|
|
24
|
-
return { ok: true, out: execSync(cmd, { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim() };
|
|
25
|
-
} catch (e) {
|
|
26
|
-
return { ok: false, err: (e.stderr || e.message || String(e)).trim() };
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
19
|
let hasFatal = false;
|
|
31
20
|
|
|
32
21
|
// ── 1. Node.js 版本 ──
|
|
@@ -40,26 +29,7 @@ if (nodeMajor < 16 || (nodeMajor === 16 && parseInt(nodeVersion.split('.')[1], 1
|
|
|
40
29
|
console.log('✅ Node.js: ' + nodeVersion);
|
|
41
30
|
}
|
|
42
31
|
|
|
43
|
-
// ── 2.
|
|
44
|
-
const npmPing = run('npm ping --registry=https://registry.npmjs.org');
|
|
45
|
-
if (!npmPing.ok) {
|
|
46
|
-
console.error('❌ npm 内部源不可达:' + npmPing.err);
|
|
47
|
-
console.error(' → 检查代理设置:npm config get registry');
|
|
48
|
-
console.error(' → 检查网络是否能访问 https://registry.npmjs.org');
|
|
49
|
-
hasFatal = true;
|
|
50
|
-
} else {
|
|
51
|
-
console.log('✅ npm 官方源可达(https://registry.npmjs.org)');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ── 3. cbbm 检测(软警告) ──
|
|
55
|
-
const cbbInfo = run('cbbm --version');
|
|
56
|
-
if (cbbInfo.ok) {
|
|
57
|
-
console.log('✅ cbbm 已安装:' + cbbInfo.out);
|
|
58
|
-
} else {
|
|
59
|
-
console.log('⚠️ cbbm 未安装(Step 4 install-ai 会自动安装,软警告不阻塞)');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// ── 4. .worktrees 目录可写性 ──
|
|
32
|
+
// ── 2. .worktrees 目录可写性 ──
|
|
63
33
|
const wsRoot = process.cwd();
|
|
64
34
|
const wtDir = path.join(wsRoot, '.worktrees');
|
|
65
35
|
try {
|
|
@@ -3,7 +3,7 @@ require('./silence-popup');
|
|
|
3
3
|
/**
|
|
4
4
|
* cbb-worktree-init 环境健康探活
|
|
5
5
|
*
|
|
6
|
-
* 提前发现
|
|
6
|
+
* 提前发现 Agent 运行环境 DLL 问题(0xc0000142)以及其他子进程启动失败。
|
|
7
7
|
* 失败时输出明确错误信息并以非零退出码终止,AI agent 据此决定是否继续。
|
|
8
8
|
*
|
|
9
9
|
* 跨平台:
|
|
@@ -38,7 +38,7 @@ const checks = {};
|
|
|
38
38
|
checks.git = tryExec('git --version');
|
|
39
39
|
if (!checks.git.ok) {
|
|
40
40
|
console.error('❌ git 启动失败');
|
|
41
|
-
|
|
41
|
+
console.error(' 可能是 Agent 运行环境 DLL 问题(0xc0000142)');
|
|
42
42
|
console.error(' 解决方案:到系统终端(非 Qoder AI 终端)重新执行本技能');
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
@@ -61,27 +61,18 @@ if (!checks.node.ok) {
|
|
|
61
61
|
console.log('✅ node OK:', checks.node.out);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// ──
|
|
65
|
-
checks.cbbInfo = tryExec('cbbm --version');
|
|
66
|
-
if (!checks.cbbInfo.ok) {
|
|
67
|
-
console.log('ℹ️ cbbm 未全局安装(Step 5 会兜底自动安装)');
|
|
68
|
-
} else {
|
|
69
|
-
console.log('✅ cbbm OK:', checks.cbbInfo.out);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// ── 沙箱检测 ─────────────────────────────────────────
|
|
64
|
+
// ── 运行环境检测 ───────────────────────────────────────
|
|
73
65
|
const inWorktree = !!(process.env.QODER_AGENT || process.env.QODER_WORKTREE);
|
|
74
66
|
if (inWorktree) {
|
|
75
|
-
console.log('🛡️ Qoder
|
|
67
|
+
console.log('🛡️ Qoder Agent 运行环境:若后续 node/git DLL 错误,请到系统终端重试');
|
|
76
68
|
} else {
|
|
77
|
-
console.log('✅
|
|
69
|
+
console.log('✅ 系统终端环境:所有子进程以默认 PATH 运行');
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
// 输出机器可读摘要(AI agent 可解析)
|
|
81
73
|
const summary = {
|
|
82
74
|
git: checks.git.ok,
|
|
83
75
|
node: checks.node.ok,
|
|
84
|
-
cbbInfo: checks.cbbInfo.ok,
|
|
85
76
|
inWorktree,
|
|
86
77
|
ok: true,
|
|
87
78
|
};
|
|
@@ -30,7 +30,7 @@ metadata:
|
|
|
30
30
|
|
|
31
31
|
## 调用脚本的统一方式
|
|
32
32
|
|
|
33
|
-
**所有脚本必须用绝对路径调用**(
|
|
33
|
+
**所有脚本必须用绝对路径调用**(Agent 运行环境中 AI agent 的 cwd 不一定是技能目录)。
|
|
34
34
|
|
|
35
35
|
```
|
|
36
36
|
node "<ws_root>/.qoder/skills/cbb-worktree-push/scripts/<name>.js" <参数>
|
|
@@ -282,7 +282,7 @@ node "..." "<ws_root>/.worktrees/worktree-<branch>"
|
|
|
282
282
|
- push 失败后跳过失败仓库直接继续
|
|
283
283
|
- 远程分支已存在时脚本自动 set-upstream-to
|
|
284
284
|
- AI 询问关联选项前不输出 commit 元信息
|
|
285
|
-
-
|
|
285
|
+
- 运行环境 node 不可用时强行继续 → 改为 fail-fast 提示用户
|
|
286
286
|
|
|
287
287
|
**必须执行**
|
|
288
288
|
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
# 业务空间使用说明(AI Agent 导航)
|
|
2
|
-
|
|
3
|
-
本目录是由 `@jspg-ai/coding-bb` 初始化的**多仓库联动开发业务空间**。
|
|
4
|
-
进入本目录工作时,请先按本文件理解目录职责与协作约定,再动手。
|
|
5
|
-
|
|
6
|
-
## 核心约定
|
|
7
|
-
|
|
8
|
-
1. **本目录不做需求开发**。本目录(业务空间主分支)只负责组织与调度;所有需求开发都在 `.worktrees/worktree-<需求名>/` 隔离目录内进行。
|
|
9
|
-
2.
|
|
10
|
-
3.
|
|
11
|
-
4.
|
|
12
|
-
5.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
|
20
|
-
| `.
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
| `.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
→
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
# 业务空间使用说明(AI Agent 导航)
|
|
2
|
+
|
|
3
|
+
本目录是由 `@jspg-ai/coding-bb` 初始化的**多仓库联动开发业务空间**。
|
|
4
|
+
进入本目录工作时,请先按本文件理解目录职责与协作约定,再动手。
|
|
5
|
+
|
|
6
|
+
## 核心约定
|
|
7
|
+
|
|
8
|
+
1. **本目录不做需求开发**。本目录(业务空间主分支)只负责组织与调度;所有需求开发都在 `.worktrees/worktree-<需求名>/` 隔离目录内进行。
|
|
9
|
+
2. **AI 配置安装在空间根**:编码规范、OpenSpec 命令、worktree 管理技能都装在本目录(`cbb setup` / `cbb update` 安装);worktree 内**不安装** AI 配置,AI 会话始终以空间根为基础。
|
|
10
|
+
3. **接到新需求先建 worktree**:在本目录执行 `/cbb:worktree-init <需求名>`(opencode 写法:`/cbb-worktree-init`)。它会为 `workspace-config.json` 中的全量关联应用同步创建同名 worktree。
|
|
11
|
+
4. **开发命令在本会话执行,写操作指向 worktree**:需求提案 / 实现 / 验证 / 归档(`/opsx:propose` → `/opsx:apply` → `/opsx:verify` → `/opsx:archive`)在空间根会话执行;但所有产生写操作的命令(git commit / openspec / 构建 / 测试 / 文件修改)必须以 `.worktrees/worktree-<需求名>/`(或其应用子目录)为工作目录(显式 `cd` 或绝对路径);**禁止在空间根(主分支)执行写操作**。
|
|
12
|
+
5. **关联应用增减只改配置**:编辑 `workspace-config.json` 的 `apps` 数组(`name` / `repo` / `side` / `desc`),然后用同一需求名重跑 worktree 初始化即幂等补齐;不要手工 `git clone` 应用仓库。
|
|
13
|
+
6. **不要绕过 worktree 直接修改 `.codespace/` 或本目录的代码**。`.codespace/` 是工具维护的基准代码,不是开发区。
|
|
14
|
+
|
|
15
|
+
## 目录结构与职责
|
|
16
|
+
|
|
17
|
+
| 路径 | 职责 | 维护方式 |
|
|
18
|
+
|------|----------|----------|
|
|
19
|
+
| `workspace-config.json` | 关联应用清单,所有应用联动的唯一数据源 | 人工编辑 |
|
|
20
|
+
| `.codespace/` | 各关联应用的基准代码(每个应用一个子目录) | `cbb setup` 与 worktree 流程自动 clone / fetch;**勿手动编辑**;已 gitignore,不提交 |
|
|
21
|
+
| `.worktrees/` | 需求隔离开发区(每个需求一个 `worktree-<需求名>/` 目录) | worktree 命令自动创建 / 清理;不提交(首次执行 worktree 流程时自动加入 .gitignore) |
|
|
22
|
+
| `openspec/` | OpenSpec 工作流配置(`config.yaml` + `schemas/`) | 由 cbb 安装;需求变更产物(`openspec/changes/` 等)在**需求工作树内**生成,随需求分支提交 |
|
|
23
|
+
| `.claude/` `.qoder/` `.opencode/` | AI 工具适配目录:编码规范规则、OpenSpec 命令、worktree 管理技能与命令 | 由 cbb 按 setup 时选择的工具安装;已 gitignore,不提交,勿手动改 |
|
|
24
|
+
| `.cbb/` | cbb 安装清单,记录本包管理的全部路径 | 由 cbb 管理;**勿手动编辑** |
|
|
25
|
+
|
|
26
|
+
## 典型流程
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
本目录:/cbb:worktree-init <需求名>
|
|
30
|
+
→ 继续在当前会话开发:写操作命令以 .worktrees/worktree-<需求名>/ 为工作目录
|
|
31
|
+
(/opsx:propose → /opsx:apply → /opsx:verify → /opsx:archive)
|
|
32
|
+
→ /cbb:worktree-push 推送 → 合并后 /cbb:worktree-close 关闭
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> 命令写法因 AI 工具而异:Claude Code / Qoder 为 `/cbb:worktree-init`,opencode 为 `/cbb-worktree-init`;`/opsx:*` 同理(opencode 为 `/opsx-*`)。
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
本文件由 `@jspg-ai/coding-bb` 生成(仅缺失时写入,之后不会覆盖或删除,可自由增补团队约定)。
|
package/config/workspaces.json
CHANGED
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"name": "数据标注平台-AI开发工作空间",
|
|
16
16
|
"repo": "http://git.portjs.cn/jspg-ai/ai-workspace/jspg-data-labeling-aiws.git",
|
|
17
17
|
"businessLine": "yzg-ai"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "集团EDI一体化-AI开发工作空间",
|
|
21
|
+
"repo": "http://git.portjs.cn/jspg-ai/ai-workspace/jspg-edi-yth-aiws.git",
|
|
22
|
+
"businessLine": "yth"
|
|
18
23
|
}
|
|
19
24
|
]
|
|
20
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jspg-ai/coding-bb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-beta.2",
|
|
4
4
|
"description": "整合业界热门且高价值的工具、框架与技能,为 AI CODING AGENT 提供统一的行为准则与工作流,辅助开发者将需求高效落地为符合规范的代码",
|
|
5
5
|
"main": "cbb/lib/install/init.js",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"sync:shared": "node scripts/sync-shared.js",
|
|
21
21
|
"pretest": "node scripts/sync-shared.js --check",
|
|
22
|
-
"test": "node test/lib/install/cleanup.test.js && node test/lib/utils/settings.test.js && node test/lib/utils/gitignore.test.js && node test/lib/utils/version.test.js && node test/lib/install/workspaces.test.js && node test/lib/utils/checkbox.test.js && node test/lib/utils/output.test.js && node test/lib/install/cli-help.test.js && node test/lib/wiki/wiki-publish.test.js && node test/lib/wiki/wiki-parse-args.test.js && node test/lib/wiki/wiki-split.test.js && node test/lib/superpowers/superpowers.test.js && node test/worktrees/push-branches.test.js && node test/worktrees/commit-worktrees.test.js && node test/worktrees/push-worktrees.test.js && node test/worktrees/
|
|
22
|
+
"test": "node test/lib/install/cleanup.test.js && node test/lib/utils/settings.test.js && node test/lib/utils/gitignore.test.js && node test/lib/utils/version.test.js && node test/lib/install/workspaces.test.js && node test/lib/utils/checkbox.test.js && node test/lib/utils/output.test.js && node test/lib/install/cli-help.test.js && node test/lib/wiki/wiki-publish.test.js && node test/lib/wiki/wiki-parse-args.test.js && node test/lib/wiki/wiki-split.test.js && node test/lib/superpowers/superpowers.test.js && node test/worktrees/push-branches.test.js && node test/worktrees/commit-worktrees.test.js && node test/worktrees/push-worktrees.test.js && node test/worktrees/check-env-deep.test.js && node test/lib/openspec/openspec-render.test.js"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|
|
25
25
|
"cbb",
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
require('./silence-popup');
|
|
3
|
-
/**
|
|
4
|
-
* cbb-worktree-init 环境感知 + 自动打开 IDE/CLI
|
|
5
|
-
*
|
|
6
|
-
* 用法:node auto-open.js <wt_path>
|
|
7
|
-
*
|
|
8
|
-
* 检测当前运行环境并自动在新窗口打开 worktree:
|
|
9
|
-
* - Qoder GUI → qoder --new-window
|
|
10
|
-
* - Cursor GUI → cursor --new-window
|
|
11
|
-
* - VS Code GUI → code --new-window
|
|
12
|
-
* - JetBrains → 通过 Windows 注册表 / macOS open -a / Linux command -v 查找(launcher 默认开新窗口)
|
|
13
|
-
* - CLI 模式 → 仅切换 cwd,输出 ENV=CLI
|
|
14
|
-
*
|
|
15
|
-
* 输出末行:
|
|
16
|
-
* ENV=QODER_GUI / CURSOR_GUI / VSCODE_GUI / JETBRAINS_GUI / CLI
|
|
17
|
-
* 或 OPEN_FAILED
|
|
18
|
-
*
|
|
19
|
-
* 退出码:始终 0(失败也返回,由末行判断)
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
const { execSync } = require('child_process');
|
|
23
|
-
const fs = require('fs');
|
|
24
|
-
const os = require('os');
|
|
25
|
-
const path = require('path');
|
|
26
|
-
|
|
27
|
-
const wtPath = process.argv[2];
|
|
28
|
-
|
|
29
|
-
if (!wtPath) {
|
|
30
|
-
console.error('❌ 用法:node auto-open.js <wt_path>');
|
|
31
|
-
process.error = 'USAGE_ERROR';
|
|
32
|
-
process.exit(0);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!fs.existsSync(wtPath)) {
|
|
36
|
-
console.error('❌ worktree 路径不存在:' + wtPath);
|
|
37
|
-
console.log('---');
|
|
38
|
-
console.log('OPEN_FAILED');
|
|
39
|
-
process.exit(0);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function run(cmd, opts) {
|
|
43
|
-
try {
|
|
44
|
-
return { ok: true, out: execSync(cmd, { encoding: 'utf-8', stdio: ['ignore', 'pipe', 'pipe'], ...opts }).trim() };
|
|
45
|
-
} catch (e) {
|
|
46
|
-
return { ok: false };
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const qoderAgent = process.env.QODER_AGENT === 'true';
|
|
51
|
-
const vscodePid = process.env.VSCODE_PID;
|
|
52
|
-
const vscodeBrand = process.env.VSCODE_BRAND;
|
|
53
|
-
const termEmu = process.env.TERMINAL_EMULATOR || '';
|
|
54
|
-
|
|
55
|
-
// Qoder GUI
|
|
56
|
-
if (qoderAgent && vscodePid) {
|
|
57
|
-
const r = run('qoder --new-window "' + wtPath + '"');
|
|
58
|
-
if (r.ok) {
|
|
59
|
-
console.log('ENV=QODER_GUI');
|
|
60
|
-
} else {
|
|
61
|
-
console.log('OPEN_FAILED');
|
|
62
|
-
}
|
|
63
|
-
process.exit(0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Cursor GUI
|
|
67
|
-
if (vscodePid && vscodeBrand === 'Cursor') {
|
|
68
|
-
const r = run('cursor --new-window "' + wtPath + '"');
|
|
69
|
-
if (r.ok) {
|
|
70
|
-
console.log('ENV=CURSOR_GUI');
|
|
71
|
-
} else {
|
|
72
|
-
console.log('OPEN_FAILED');
|
|
73
|
-
}
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 其他 VS Code 分支
|
|
78
|
-
if (vscodePid) {
|
|
79
|
-
const r = run('code --new-window "' + wtPath + '"');
|
|
80
|
-
if (r.ok) {
|
|
81
|
-
console.log('ENV=VSCODE_GUI');
|
|
82
|
-
} else {
|
|
83
|
-
console.log('OPEN_FAILED');
|
|
84
|
-
}
|
|
85
|
-
process.exit(0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// JetBrains
|
|
89
|
-
if (/jetbrains/i.test(termEmu)) {
|
|
90
|
-
const platform = os.platform();
|
|
91
|
-
let launcher = '';
|
|
92
|
-
|
|
93
|
-
if (platform === 'win32') {
|
|
94
|
-
// Windows:通过 PowerShell 查注册表
|
|
95
|
-
const psCmd = 'powershell -NoProfile -Command "Get-ItemProperty \'HKLM:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*\',\'HKLM:\\Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*\',\'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*\' -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -match \'IntelliJ|WebStorm|PyCharm|GoLand|PhpStorm|Rider|CLion|RubyMine|DataGrip\' } | Select-Object -First 1 -ExpandProperty DisplayIcon"';
|
|
96
|
-
const r = run(psCmd);
|
|
97
|
-
if (r.ok && r.out) launcher = r.out;
|
|
98
|
-
} else if (platform === 'darwin') {
|
|
99
|
-
// macOS:通过 open -Ra 查找
|
|
100
|
-
const apps = ['IntelliJ IDEA', 'WebStorm', 'PyCharm', 'GoLand', 'PhpStorm', 'Rider', 'CLion', 'RubyMine', 'DataGrip'];
|
|
101
|
-
for (const app of apps) {
|
|
102
|
-
const check = run('open -Ra "' + app + '"');
|
|
103
|
-
if (check.ok) {
|
|
104
|
-
const open = run('open -a "' + app + '" "' + wtPath + '"');
|
|
105
|
-
if (open.ok) {
|
|
106
|
-
console.log('ENV=JETBRAINS_GUI');
|
|
107
|
-
process.exit(0);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
// Linux:通过 command -v 查找
|
|
113
|
-
const cmds = ['idea64', 'idea', 'webstorm64', 'webstorm', 'pycharm64', 'pycharm', 'goland64', 'goland'];
|
|
114
|
-
for (const c of cmds) {
|
|
115
|
-
const which = run('command -v "' + c + '"');
|
|
116
|
-
if (which.ok && which.out) {
|
|
117
|
-
launcher = which.out;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (launcher) {
|
|
124
|
-
const r = run('"' + launcher + '" "' + wtPath + '"');
|
|
125
|
-
if (r.ok) {
|
|
126
|
-
console.log('ENV=JETBRAINS_GUI');
|
|
127
|
-
process.exit(0);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
console.log('ENV=CLI');
|
|
131
|
-
process.exit(0);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// CLI 模式
|
|
135
|
-
console.log('ENV=CLI');
|
|
136
|
-
process.exit(0);
|