@jspg-ai/coding-bb 0.0.3-beta.9 → 0.0.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +1 -0
  2. package/cbb/dev-standards/rules/cbb-ai-behavior.md +0 -15
  3. package/cbb/dev-standards/rules/cbb-workspace-discipline.md +38 -0
  4. package/cbb/lib/external/index.js +228 -0
  5. package/cbb/lib/install/agents-nav.js +92 -0
  6. package/cbb/lib/install/claude-code.js +8 -1
  7. package/cbb/lib/install/command-skill.js +105 -0
  8. package/cbb/lib/install/init.js +399 -129
  9. package/cbb/lib/install/minimax.js +60 -0
  10. package/cbb/lib/install/rule-rewrite.js +1 -1
  11. package/cbb/lib/install/setup-decision.js +92 -0
  12. package/cbb/lib/install/tool-selection.js +23 -0
  13. package/cbb/lib/install/trae.js +18 -8
  14. package/cbb/lib/install/workbuddy.js +36 -0
  15. package/cbb/lib/install/workspaces.js +15 -61
  16. package/cbb/lib/utils/check-update.js +13 -5
  17. package/cbb/lib/utils/githook.js +230 -0
  18. package/cbb/lib/utils/gitignore.js +17 -4
  19. package/cbb/lib/utils/plugin-hook.js +92 -0
  20. package/cbb/worktrees/_shared/scripts/check-local-state.js +114 -0
  21. package/cbb/worktrees/_shared/scripts/check-unarchived.js +77 -0
  22. package/cbb/worktrees/_shared/scripts/delete-branches.js +147 -0
  23. package/cbb/worktrees/_shared/scripts/deprecate-branches.js +119 -0
  24. package/cbb/worktrees/_shared/scripts/find-target-worktree.js +148 -96
  25. package/cbb/worktrees/_shared/scripts/find-workspace-root.js +8 -8
  26. package/cbb/worktrees/_shared/scripts/install-git-hook.js +70 -0
  27. package/cbb/worktrees/_shared/scripts/junction-ai-config.js +192 -0
  28. package/cbb/worktrees/_shared/scripts/merge-branches.js +580 -0
  29. package/cbb/worktrees/_shared/scripts/push-core.js +1 -1
  30. package/cbb/worktrees/_shared/scripts/silence-popup.js +1 -1
  31. package/cbb/worktrees/_shared/scripts/start-local.js +180 -0
  32. package/cbb/worktrees/skills/cbb-local-mode/SKILL.md +194 -0
  33. package/cbb/worktrees/skills/cbb-local-mode/scripts/check-local-state.js +114 -0
  34. package/cbb/worktrees/skills/cbb-local-mode/scripts/delete-branches.js +147 -0
  35. package/cbb/worktrees/skills/cbb-local-mode/scripts/deprecate-branches.js +119 -0
  36. package/cbb/worktrees/skills/cbb-local-mode/scripts/install-git-hook.js +70 -0
  37. package/cbb/worktrees/skills/cbb-local-mode/scripts/merge-branches.js +580 -0
  38. package/cbb/worktrees/skills/cbb-local-mode/scripts/silence-popup.js +23 -0
  39. package/cbb/worktrees/skills/cbb-local-mode/scripts/start-local.js +180 -0
  40. package/cbb/worktrees/skills/cbb-worktree-close/SKILL.md +134 -81
  41. package/cbb/worktrees/skills/cbb-worktree-close/scripts/check-env.js +3 -3
  42. package/cbb/worktrees/skills/cbb-worktree-close/scripts/check-unarchived.js +77 -48
  43. package/cbb/worktrees/skills/cbb-worktree-close/scripts/delete-branches.js +147 -136
  44. package/cbb/worktrees/skills/cbb-worktree-close/scripts/deprecate-branches.js +119 -0
  45. package/cbb/worktrees/skills/cbb-worktree-close/scripts/discover-apps.js +14 -5
  46. package/cbb/worktrees/skills/cbb-worktree-close/scripts/find-target-worktree.js +148 -96
  47. package/cbb/worktrees/skills/cbb-worktree-close/scripts/find-workspace-root.js +8 -8
  48. package/cbb/worktrees/skills/cbb-worktree-close/scripts/junction-ai-config.js +192 -0
  49. package/cbb/worktrees/skills/cbb-worktree-close/scripts/merge-branches.js +580 -0
  50. package/cbb/worktrees/skills/cbb-worktree-close/scripts/remove-worktrees.js +44 -9
  51. package/cbb/worktrees/skills/cbb-worktree-close/scripts/safety-check.js +15 -4
  52. package/cbb/worktrees/skills/cbb-worktree-close/scripts/silence-popup.js +1 -1
  53. package/cbb/worktrees/skills/cbb-worktree-init/SKILL.md +131 -120
  54. package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-env.js +1 -1
  55. package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-repos.js +2 -2
  56. package/cbb/worktrees/skills/cbb-worktree-init/scripts/create-branches.js +33 -8
  57. package/cbb/worktrees/skills/cbb-worktree-init/scripts/create-worktrees.js +60 -46
  58. package/cbb/worktrees/skills/cbb-worktree-init/scripts/install-git-hook.js +70 -0
  59. package/cbb/worktrees/skills/cbb-worktree-init/scripts/junction-ai-config.js +192 -0
  60. package/cbb/worktrees/skills/cbb-worktree-init/scripts/parse-config.js +7 -7
  61. package/cbb/worktrees/skills/cbb-worktree-init/scripts/push-branches.js +3 -3
  62. package/cbb/worktrees/skills/cbb-worktree-init/scripts/push-core.js +1 -1
  63. package/cbb/worktrees/skills/cbb-worktree-init/scripts/silence-popup.js +1 -1
  64. package/cbb/worktrees/skills/cbb-worktree-init/scripts/sync-repos.js +11 -7
  65. package/cbb/worktrees/skills/cbb-worktree-init/scripts/update-gitignore.js +17 -5
  66. package/cbb/worktrees/skills/cbb-worktree-push/SKILL.md +213 -56
  67. package/cbb/worktrees/skills/cbb-worktree-push/scripts/check-unarchived.js +77 -0
  68. package/cbb/worktrees/skills/cbb-worktree-push/scripts/commit-worktrees.js +70 -12
  69. package/cbb/worktrees/skills/cbb-worktree-push/scripts/find-target-worktree.js +148 -96
  70. package/cbb/worktrees/skills/cbb-worktree-push/scripts/find-workspace-root.js +8 -8
  71. package/cbb/worktrees/skills/cbb-worktree-push/scripts/make-mr-urls.js +211 -0
  72. package/cbb/worktrees/skills/cbb-worktree-push/scripts/merge-branches.js +580 -0
  73. package/cbb/worktrees/skills/cbb-worktree-push/scripts/push-core.js +1 -1
  74. package/cbb/worktrees/skills/cbb-worktree-push/scripts/push-worktrees.js +67 -20
  75. package/cbb/worktrees/skills/cbb-worktree-push/scripts/silence-popup.js +1 -1
  76. package/config/{workspace-config.sample.json → CBB-WORKSPACE.sample.json} +1 -1
  77. package/config/openspec/schemas/spec-driven/schema.yaml +20 -0
  78. package/config/upstream-mirrors.json +5 -0
  79. package/external/frontend-design/.version +6 -0
  80. package/external/frontend-design/LICENSE.txt +177 -0
  81. package/external/frontend-design/SKILL.md +71 -0
  82. package/openspec/.version +2 -2
  83. package/openspec/commands/archive.md +15 -8
  84. package/openspec/commands/bulk-archive.md +13 -6
  85. package/openspec/commands/continue.md +0 -1
  86. package/openspec/commands/explore.md +1 -1
  87. package/openspec/commands/ff.md +1 -1
  88. package/openspec/commands/onboard.md +9 -4
  89. package/openspec/commands/update.md +11 -5
  90. package/openspec/commands/verify.md +57 -26
  91. package/openspec/skills/openspec-apply-change/SKILL.md +1 -1
  92. package/openspec/skills/openspec-archive-change/SKILL.md +16 -9
  93. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +14 -7
  94. package/openspec/skills/openspec-continue-change/SKILL.md +1 -2
  95. package/openspec/skills/openspec-explore/SKILL.md +2 -2
  96. package/openspec/skills/openspec-ff-change/SKILL.md +2 -2
  97. package/openspec/skills/openspec-new-change/SKILL.md +1 -1
  98. package/openspec/skills/openspec-onboard/SKILL.md +10 -5
  99. package/openspec/skills/openspec-propose/SKILL.md +1 -1
  100. package/openspec/skills/openspec-sync-specs/SKILL.md +1 -1
  101. package/openspec/skills/openspec-update-change/SKILL.md +12 -6
  102. package/openspec/skills/openspec-verify-change/SKILL.md +59 -27
  103. package/package.json +3 -2
  104. package/superpowers/.version +3 -3
  105. package/superpowers/skills/writing-plans/SKILL.md +32 -20
  106. package/cbb/lib/install/codebuddy.js +0 -30
  107. package/cbb/worktrees/skills/cbb-worktree-init/scripts/find-workspace-root.js +0 -67
  108. package/config/workspace-agents.sample.md +0 -41
  109. package/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +0 -49
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env node
2
+ require('./silence-popup');
3
+ /**
4
+ * 收尾合并门禁 —— 废弃分支出口(ADR 0007)
5
+ *
6
+ * 用户在门禁处确认"分支废弃、不再交付"后,把各参与仓库远端的需求分支重命名为
7
+ * <branch>-deprecated(保留历史、去掉占用中的旧名),**不删除任何提交**。
8
+ * 本地分支保持原名不动;未推送的仓库(远端无该分支)跳过。
9
+ *
10
+ * 用法:
11
+ * node deprecate-branches.js <ws_root> <branch> [--apps a,b]
12
+ *
13
+ * 退出码:0 全部成功(含 skipped)/ 1 参数错误 / 2 存在失败
14
+ * 末行:DEPRECATE_RESULT [...]
15
+ */
16
+
17
+ const { execSync } = require('child_process');
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+
21
+ function run(cmd, cwd) {
22
+ try {
23
+ return {
24
+ ok: true,
25
+ out: execSync(cmd, {
26
+ cwd,
27
+ encoding: 'utf-8',
28
+ stdio: ['ignore', 'pipe', 'pipe'],
29
+ timeout: 120000,
30
+ env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
31
+ }).trim(),
32
+ };
33
+ } catch (e) {
34
+ return { ok: false, err: (e.stderr || e.message || String(e)).trim() };
35
+ }
36
+ }
37
+
38
+ function loadApps(wsRoot) {
39
+ try {
40
+ const config = JSON.parse(fs.readFileSync(path.join(wsRoot, 'CBB-WORKSPACE.json'), 'utf-8'));
41
+ return Array.isArray(config.apps) ? config.apps : [];
42
+ } catch (e) {
43
+ return [];
44
+ }
45
+ }
46
+
47
+ /** 对单个仓库执行废弃重命名 */
48
+ function deprecateRepo(name, repo, branch) {
49
+ const newName = branch + '-deprecated';
50
+ const rec = { name, status: 'skipped', detail: null };
51
+ if (!fs.existsSync(path.join(repo, '.git'))) {
52
+ rec.detail = 'no-repo';
53
+ return rec;
54
+ }
55
+ const remote = run('git remote', repo);
56
+ if (!remote.ok || !remote.out) {
57
+ rec.detail = 'no-remote';
58
+ return rec;
59
+ }
60
+ const r = remote.out.split(/\r?\n/)[0];
61
+ // 仅重命名远端确实存在的分支
62
+ const exists = run('git ls-remote --heads "' + r + '" "refs/heads/' + branch + '"', repo);
63
+ if (!exists.ok || !exists.out) {
64
+ rec.detail = 'remote-has-no-branch';
65
+ return rec;
66
+ }
67
+ const pushNew = run('git push "' + r + '" "refs/heads/' + branch + ':refs/heads/' + newName + '"', repo);
68
+ if (!pushNew.ok) {
69
+ rec.status = 'failed';
70
+ rec.detail = 'push-new-failed: ' + (pushNew.err || '').split(/\r?\n/)[0];
71
+ return rec;
72
+ }
73
+ const delOld = run('git push "' + r + '" --delete "' + branch + '"', repo);
74
+ if (!delOld.ok) {
75
+ rec.status = 'failed';
76
+ rec.detail = 'delete-old-failed: ' + (delOld.err || '').split(/\r?\n/)[0];
77
+ return rec;
78
+ }
79
+ rec.status = 'deprecated';
80
+ rec.detail = 'remote ' + branch + ' → ' + newName;
81
+ return rec;
82
+ }
83
+
84
+ function main() {
85
+ const args = process.argv.slice(2);
86
+ const wsRoot = args[0];
87
+ const branch = args[1];
88
+
89
+ if (!wsRoot || !branch || branch.indexOf('--') === 0) {
90
+ console.error('Usage: node deprecate-branches.js <ws_root> <branch> [--apps a,b]');
91
+ process.exit(1);
92
+ }
93
+
94
+ const appsIdx = args.indexOf('--apps');
95
+ const appFilter = appsIdx >= 0
96
+ ? new Set((args[appsIdx + 1] || '').split(',').map(s => s.trim()).filter(Boolean))
97
+ : null;
98
+
99
+ const repos = [{ name: 'workspace', repo: wsRoot }];
100
+ for (const app of loadApps(wsRoot)) {
101
+ if (appFilter && !appFilter.has(app.name)) continue;
102
+ repos.push({ name: app.name, repo: path.join(wsRoot, '.codespace', app.name) });
103
+ }
104
+
105
+ const results = repos.map(rp => deprecateRepo(rp.name, rp.repo, branch));
106
+
107
+ results.forEach(r => {
108
+ console.log(r.status.toUpperCase() + ' ' + r.name + (r.detail ? ' — ' + r.detail : ''));
109
+ });
110
+
111
+ const ok = results.every(r => r.status !== 'failed');
112
+ console.log('---');
113
+ console.log('DEPRECATE_RESULT', JSON.stringify({ branch, new_name: branch + '-deprecated', results }));
114
+ process.exit(ok ? 0 : 2);
115
+ }
116
+
117
+ if (require.main === module) main();
118
+
119
+ module.exports = { run, loadApps, deprecateRepo };
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 向指定 git 仓库安装分支感知 pre-commit hook(ADR 0002)。
4
+ *
5
+ * 真源:cbb/lib/utils/githook.js 的 PRE_COMMIT_SOURCE(本文件为部署到业务空间的自包含副本,
6
+ * 改动必须两处同步——本仓库内改真源后同步本文件,勿只改其一)。
7
+ *
8
+ * 用法(二选一):
9
+ * CLI:node install-git-hook.js <repoPath...> —— 对每个仓库安装,输出 HOOK_RESULT
10
+ * require:installTo(repoPath) → 'installed' | 'updated' | 'skipped-not-git'
11
+ *
12
+ * 供 cbb-worktree-init 的 sync-repos.js 兜底 clone 后调用(cbb setup 已装过,此处幂等补齐)。
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const path = require('path');
17
+
18
+ const HOOK_MARKER = 'managed-by-cbb';
19
+ const HOOK_FILE = 'pre-commit';
20
+ const BACKUP_SUFFIX = '.cbb-backup';
21
+
22
+ // 与 cbb/lib/utils/githook.js 的 buildPreCommitSource() 输出完全一致(构建时注入)
23
+ const PRE_COMMIT_SOURCE = "#!/usr/bin/env node\n// managed-by-cbb v1 —— 分支感知提交防线(ADR 0002)\n// main 上:workspace 只放行控制面白名单,应用全拦(merge 提交除外);非 main 一律放行。\n// 绕过逃生口仅限用户显式 git commit --no-verify。\nconst { execSync } = require('child_process');\nconst fs = require('fs');\nfunction run(cmd) {\n try { return execSync(cmd, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim(); }\n catch (e) { return null; }\n}\nconst branch = run('git branch --show-current') || '';\n// 主干名:优先远端 HEAD 指向;探测失败按本地 main/master 存在性回退\nlet main = null;\nconst remotes = run('git remote');\nif (remotes) {\n const r = remotes.split(/\\r?\\n/)[0];\n const sym = run('git symbolic-ref \"refs/remotes/' + r + '/HEAD\"');\n if (sym) main = sym.replace('refs/remotes/' + r + '/', '');\n}\nif (!main) {\n if (run('git rev-parse --verify --quiet refs/heads/main')) main = 'main';\n else if (run('git rev-parse --verify --quiet refs/heads/master')) main = 'master';\n}\n// 非主干(含 detached / 探测失败)→ 放行\nif (!main || branch !== main) process.exit(0);\n\n// merge 进行中(MERGE_HEAD 存在)→ 显式人工合并提交,放行(ADR 0007 合并门禁)\nif (run('git rev-parse --verify --quiet MERGE_HEAD')) process.exit(0);\n\n// 主干上的提交:收集 staged 变更(空提交放行)\nconst staged = run('git diff --cached --name-only') || '';\nconst files = staged.split(/\\r?\\n/).filter(Boolean);\nif (files.length === 0) process.exit(0);\n\n// 仓库类型:workspace 仓库 = 检出含 CBB-WORKSPACE.json(或旧名,改名过渡期识别)\nconst isWorkspace = fs.existsSync('CBB-WORKSPACE.json') || fs.existsSync('workspace-config.json');\n\nfunction deny(bad) {\n console.error('[cbb-guard] 主干上拦截载荷提交(ADR 0002):');\n bad.forEach(f => console.error(' ' + f));\n console.error('需求载荷须在需求分支上提交:本地模式先 git checkout -b <需求名>;worktree 模式在 .worktrees/ 工作树内提交。');\n console.error('控制面白名单:CBB-WORKSPACE.json / .gitignore / AGENTS.md / openspec/config.yaml / openspec/schemas/** / .cbb/**');\n console.error('如确需在主干提交,须由用户显式 git commit --no-verify。');\n process.exit(1);\n}\n\nif (isWorkspace) {\n // 旧名仅放行删除条目:更名迁移提交(git mv)会产生旧名删除 + 新名新增两条\n const EXACT = new Set(['CBB-WORKSPACE.json', 'workspace-config.json', '.gitignore', 'AGENTS.md', 'openspec/config.yaml']);\n const PREFIXES = ['openspec/schemas/', '.cbb/'];\n const bad = files.filter(f => !EXACT.has(f) && !PREFIXES.some(p => f.indexOf(p) === 0));\n if (bad.length) deny(bad);\n} else {\n deny(files);\n}\nprocess.exit(0);\n";
24
+
25
+ function isCbbHookContent(content) {
26
+ return typeof content === 'string' && content.includes(HOOK_MARKER);
27
+ }
28
+
29
+ function resolveHooksDir(repoPath) {
30
+ const gitDir = path.join(repoPath, '.git');
31
+ if (!fs.existsSync(gitDir)) return null;
32
+ const st = fs.statSync(gitDir);
33
+ if (!st.isDirectory()) return null; // worktree 检出(.git 为文件):hook 由主仓库承担
34
+ return path.join(gitDir, 'hooks');
35
+ }
36
+
37
+ function installTo(repoPath) {
38
+ const dir = resolveHooksDir(repoPath);
39
+ if (!dir) return 'skipped-not-git';
40
+
41
+ const hookPath = path.join(dir, HOOK_FILE);
42
+ fs.mkdirSync(dir, { recursive: true });
43
+
44
+ if (fs.existsSync(hookPath)) {
45
+ const prev = fs.readFileSync(hookPath, 'utf-8');
46
+ if (isCbbHookContent(prev)) {
47
+ if (prev !== PRE_COMMIT_SOURCE) fs.writeFileSync(hookPath, PRE_COMMIT_SOURCE);
48
+ return 'updated';
49
+ }
50
+ fs.writeFileSync(hookPath + BACKUP_SUFFIX, prev); // 用户自有 hook:备份后接管
51
+ }
52
+ fs.writeFileSync(hookPath, PRE_COMMIT_SOURCE);
53
+ try { fs.chmodSync(hookPath, 0o755); } catch (_) { /* Windows 无压力 */ }
54
+ return 'installed';
55
+ }
56
+
57
+ module.exports = { installTo, isCbbHookContent, PRE_COMMIT_SOURCE };
58
+
59
+ // CLI 形式:node install-git-hook.js <repoPath...>
60
+ if (require.main === module) {
61
+ const targets = process.argv.slice(2);
62
+ if (targets.length === 0) {
63
+ console.error('Usage: node install-git-hook.js <repoPath...>');
64
+ process.exit(1);
65
+ }
66
+ const results = targets.map(p => ({ path: p, status: installTo(p) }));
67
+ results.forEach(r => console.log((r.status === 'skipped-not-git' ? '⚠️ ' : '✅ ') + r.path + ' → ' + r.status));
68
+ console.log('HOOK_RESULT', JSON.stringify(results));
69
+ process.exit(0);
70
+ }