@jspg-ai/coding-bb 0.0.3-beta.3 → 0.0.3-beta.30

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 (140) hide show
  1. package/cbb/dev-standards/rules/cbb-ai-behavior.md +135 -116
  2. package/cbb/lib/install/agents-nav.js +92 -0
  3. package/cbb/lib/install/claude-code.js +7 -2
  4. package/cbb/lib/install/command-skill.js +105 -0
  5. package/cbb/lib/install/init.js +435 -164
  6. package/cbb/lib/install/minimax.js +60 -0
  7. package/cbb/lib/install/opencode.js +3 -5
  8. package/cbb/lib/install/qoder.js +1 -3
  9. package/cbb/lib/install/rule-rewrite.js +27 -0
  10. package/cbb/lib/install/setup-decision.js +48 -0
  11. package/cbb/lib/install/tool-selection.js +45 -0
  12. package/cbb/lib/install/trae.js +43 -0
  13. package/cbb/lib/install/workbuddy.js +36 -0
  14. package/cbb/lib/install/workspaces.js +21 -17
  15. package/cbb/lib/openspec/index.js +337 -554
  16. package/cbb/lib/superpowers/index.js +246 -265
  17. package/cbb/lib/utils/check-update.js +17 -2
  18. package/cbb/lib/utils/githook.js +226 -0
  19. package/cbb/lib/utils/gitignore.js +16 -3
  20. package/cbb/lib/utils/plugin-hook.js +92 -0
  21. package/cbb/lib/utils/settings.js +17 -4
  22. package/cbb/lib/utils/tar.js +92 -0
  23. package/cbb/lib/utils/upstream.js +90 -0
  24. package/cbb/worktrees/_shared/scripts/check-local-state.js +114 -0
  25. package/cbb/worktrees/_shared/scripts/find-target-worktree.js +148 -96
  26. package/cbb/worktrees/_shared/scripts/find-workspace-root.js +7 -7
  27. package/cbb/worktrees/_shared/scripts/install-git-hook.js +70 -0
  28. package/cbb/worktrees/_shared/scripts/junction-ai-config.js +127 -0
  29. package/cbb/worktrees/_shared/scripts/start-local.js +180 -0
  30. package/cbb/worktrees/skills/cbb-local-mode/SKILL.md +158 -0
  31. package/cbb/worktrees/skills/cbb-local-mode/scripts/check-local-state.js +114 -0
  32. package/cbb/worktrees/skills/cbb-local-mode/scripts/install-git-hook.js +70 -0
  33. package/cbb/worktrees/skills/cbb-local-mode/scripts/silence-popup.js +23 -0
  34. package/cbb/worktrees/skills/cbb-local-mode/scripts/start-local.js +180 -0
  35. package/cbb/worktrees/skills/cbb-worktree-close/SKILL.md +60 -43
  36. package/cbb/worktrees/skills/cbb-worktree-close/scripts/check-env.js +3 -3
  37. package/cbb/worktrees/skills/cbb-worktree-close/scripts/check-unarchived.js +75 -48
  38. package/cbb/worktrees/skills/cbb-worktree-close/scripts/delete-branches.js +1 -1
  39. package/cbb/worktrees/skills/cbb-worktree-close/scripts/discover-apps.js +14 -5
  40. package/cbb/worktrees/skills/cbb-worktree-close/scripts/find-target-worktree.js +148 -96
  41. package/cbb/worktrees/skills/cbb-worktree-close/scripts/find-workspace-root.js +7 -7
  42. package/cbb/worktrees/skills/cbb-worktree-close/scripts/remove-worktrees.js +13 -4
  43. package/cbb/worktrees/skills/cbb-worktree-close/scripts/safety-check.js +11 -2
  44. package/cbb/worktrees/skills/cbb-worktree-init/SKILL.md +138 -129
  45. package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-env.js +1 -1
  46. package/cbb/worktrees/skills/cbb-worktree-init/scripts/check-repos.js +2 -2
  47. package/cbb/worktrees/skills/cbb-worktree-init/scripts/create-branches.js +33 -8
  48. package/cbb/worktrees/skills/cbb-worktree-init/scripts/create-worktrees.js +60 -46
  49. package/cbb/worktrees/skills/cbb-worktree-init/scripts/find-workspace-root.js +7 -7
  50. package/cbb/worktrees/skills/cbb-worktree-init/scripts/install-git-hook.js +70 -0
  51. package/cbb/worktrees/skills/cbb-worktree-init/scripts/junction-ai-config.js +127 -0
  52. package/cbb/worktrees/skills/cbb-worktree-init/scripts/parse-config.js +7 -7
  53. package/cbb/worktrees/skills/cbb-worktree-init/scripts/push-branches.js +3 -3
  54. package/cbb/worktrees/skills/cbb-worktree-init/scripts/sync-repos.js +11 -7
  55. package/cbb/worktrees/skills/cbb-worktree-init/scripts/update-gitignore.js +37 -9
  56. package/cbb/worktrees/skills/cbb-worktree-push/SKILL.md +113 -36
  57. package/cbb/worktrees/skills/cbb-worktree-push/scripts/commit-worktrees.js +70 -12
  58. package/cbb/worktrees/skills/cbb-worktree-push/scripts/find-target-worktree.js +148 -96
  59. package/cbb/worktrees/skills/cbb-worktree-push/scripts/find-workspace-root.js +7 -7
  60. package/cbb/worktrees/skills/cbb-worktree-push/scripts/make-mr-urls.js +211 -0
  61. package/cbb/worktrees/skills/cbb-worktree-push/scripts/push-worktrees.js +67 -20
  62. package/config/{workspace-config.sample.json → CBB-WORKSPACE.sample.json} +1 -1
  63. package/config/openspec/schemas/spec-driven/schema.yaml +40 -30
  64. package/config/openspec/schemas/spec-driven/templates/design.md +0 -18
  65. package/config/openspec/schemas/spec-driven/templates/proposal.md +4 -3
  66. package/config/upstream-mirrors.json +12 -0
  67. package/config/workspace-agents.sample.md +4 -33
  68. package/openspec/.version +2 -3
  69. package/openspec/commands/apply.md +189 -175
  70. package/openspec/commands/archive.md +237 -216
  71. package/openspec/commands/bulk-archive.md +355 -327
  72. package/openspec/commands/continue.md +116 -105
  73. package/openspec/commands/explore.md +230 -199
  74. package/openspec/commands/ff.md +115 -104
  75. package/openspec/commands/new.md +74 -63
  76. package/openspec/commands/onboard.md +557 -548
  77. package/openspec/commands/propose.md +161 -150
  78. package/openspec/commands/sync.md +277 -249
  79. package/openspec/commands/update.md +92 -80
  80. package/openspec/commands/verify.md +175 -162
  81. package/openspec/skills/openspec-apply-change/SKILL.md +20 -5
  82. package/openspec/skills/openspec-archive-change/SKILL.md +30 -8
  83. package/openspec/skills/openspec-bulk-archive-change/SKILL.md +36 -6
  84. package/openspec/skills/openspec-continue-change/SKILL.md +14 -2
  85. package/openspec/skills/openspec-explore/SKILL.md +21 -9
  86. package/openspec/skills/openspec-ff-change/SKILL.md +14 -2
  87. package/openspec/skills/openspec-new-change/SKILL.md +13 -1
  88. package/openspec/skills/openspec-onboard/SKILL.md +49 -39
  89. package/openspec/skills/openspec-propose/SKILL.md +15 -3
  90. package/openspec/skills/openspec-sync-specs/SKILL.md +31 -2
  91. package/openspec/skills/openspec-update-change/SKILL.md +27 -14
  92. package/openspec/skills/openspec-verify-change/SKILL.md +17 -3
  93. package/package.json +2 -2
  94. package/superpowers/.version +4 -4
  95. package/superpowers/skills/brainstorming/SKILL.md +47 -12
  96. package/superpowers/skills/brainstorming/scripts/frame-template.html +213 -213
  97. package/superpowers/skills/brainstorming/scripts/server.cjs +723 -723
  98. package/superpowers/skills/brainstorming/visual-companion.md +6 -6
  99. package/superpowers/skills/diagnosing-superpowers/SKILL.md +120 -0
  100. package/superpowers/skills/diagnosing-superpowers/prompts/analyst-common.md +38 -0
  101. package/superpowers/skills/diagnosing-superpowers/prompts/cost-and-time.md +28 -0
  102. package/superpowers/skills/diagnosing-superpowers/prompts/plan-adherence.md +29 -0
  103. package/superpowers/skills/diagnosing-superpowers/prompts/quality-evidence.md +26 -0
  104. package/superpowers/skills/diagnosing-superpowers/prompts/repeated-work.md +30 -0
  105. package/superpowers/skills/diagnosing-superpowers/prompts/request-conflicts.md +20 -0
  106. package/superpowers/skills/diagnosing-superpowers/prompts/scrub-audit.md +33 -0
  107. package/superpowers/skills/diagnosing-superpowers/prompts/scrub.md +29 -0
  108. package/superpowers/skills/diagnosing-superpowers/prompts/similar-session.md +38 -0
  109. package/superpowers/skills/diagnosing-superpowers/prompts/skill-timeline.md +30 -0
  110. package/superpowers/skills/diagnosing-superpowers/prompts/stumbles.md +28 -0
  111. package/superpowers/skills/diagnosing-superpowers/references/context-safety.md +22 -0
  112. package/superpowers/skills/diagnosing-superpowers/references/github-issues.md +47 -0
  113. package/superpowers/skills/diagnosing-superpowers/references/redaction-policy.md +34 -0
  114. package/superpowers/skills/diagnosing-superpowers/references/session-discovery.md +31 -0
  115. package/superpowers/skills/diagnosing-superpowers/templates/bundle-README.md +77 -0
  116. package/superpowers/skills/diagnosing-superpowers/templates/case.md +64 -0
  117. package/superpowers/skills/diagnosing-superpowers/templates/issue.md +51 -0
  118. package/superpowers/skills/diagnosing-superpowers/templates/report.md +82 -0
  119. package/superpowers/skills/executing-plans/SKILL.md +350 -41
  120. package/superpowers/skills/executing-plans/scripts/task-done +52 -0
  121. package/superpowers/skills/executing-plans/scripts/task-start +28 -0
  122. package/superpowers/skills/requesting-code-review/SKILL.md +1 -1
  123. package/superpowers/skills/requesting-code-review/code-reviewer.md +17 -0
  124. package/superpowers/skills/subagent-driven-development/SKILL.md +18 -18
  125. package/superpowers/skills/subagent-driven-development/re-review-prompt.md +1 -1
  126. package/superpowers/skills/subagent-driven-development/scripts/review-package +53 -46
  127. package/superpowers/skills/subagent-driven-development/scripts/sdd-workspace +82 -40
  128. package/superpowers/skills/subagent-driven-development/scripts/task-brief +43 -41
  129. package/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +2 -2
  130. package/superpowers/skills/systematic-debugging/root-cause-tracing.md +1 -1
  131. package/superpowers/skills/test-driven-development/SKILL.md +10 -0
  132. package/superpowers/skills/using-superpowers/SKILL.md +2 -0
  133. package/superpowers/skills/using-superpowers/references/claude-code-tools.md +29 -0
  134. package/superpowers/skills/using-superpowers/references/muse-tools.md +35 -0
  135. package/superpowers/skills/writing-plans/SKILL.md +30 -9
  136. package/superpowers/skills/writing-skills/SKILL.md +4 -2
  137. package/superpowers/skills/writing-skills/graphviz-conventions.dot +171 -171
  138. package/cbb/worktrees/commands/worktree-close.md +0 -64
  139. package/cbb/worktrees/commands/worktree-init.md +0 -51
  140. package/cbb/worktrees/commands/worktree-push.md +0 -42
@@ -1,117 +1,136 @@
1
- ---
2
- trigger: always_on
3
- ---
4
-
5
- # AI 行为准则
6
-
7
- 七条行为准则,减少 AI 编码常见错误。源自 [Andrej Karpathy 对 LLM 编码缺陷的观察](https://x.com/karpathy/status/2015883857489522876)。
8
-
9
- **权衡:** 这些准则倾向于谨慎而非速度。对于简单任务(如修 typo、改文案),按常识判断即可。
10
-
11
- ## 1. 先想后写
12
-
13
- **不假设,不隐藏困惑,主动呈现权衡。**
14
-
15
- 实现前:
16
- - 明确声明假设,不确定时主动询问
17
- - 若存在多种解释,呈现出来而非自己默默选一种
18
- - 若有更简单的方案,说出来,必要时 push back
19
- - 若有不明确的地方,停下来,说出困惑,请求澄清
20
-
21
- ## 2. 简洁至上
22
-
23
- **用最少代码解决问题,不加推测性内容。**
24
-
25
- - 不实现用户未要求的功能
26
- - 不为单次使用的代码创建抽象
27
- - 不添加用户未要求的"灵活性"或"可配置性"
28
- - 不为不可能发生的场景写错误处理
29
- - 写了 200 行却发现 50 行就能搞定 → 重写
30
-
31
- 自问:"资深工程师会说过度设计吗?"如果会,简化。
32
-
33
- ## 3. 外科手术式修改
34
-
35
- **只改必须改的,只清理自己造成的烂摊子。**
36
-
37
- 编辑已有代码时:
38
- - 不顺手"改进"相邻代码、注释或格式
39
- - 不重构没坏的东西
40
- - 匹配现有风格,即使你更习惯另一种写法
41
- - 发现无关的死代码,口头提及即可,不要删除
42
-
43
- 当你的改动产生孤儿代码时:
44
- - 删除因你的改动而不再使用的 import / 变量 / 函数
45
- - 不删除已有的死代码,除非用户要求
46
-
47
- **检验标准:** 每一行改动都应该能追溯到用户的需求。
48
-
49
- ## 4. 目标驱动执行
50
-
51
- **定义成功标准,循环直到验证通过。**
52
-
53
- 将命令式任务转换为可验证的目标:
54
-
55
- | 而非… | 转换为… |
56
- |--------|---------|
57
- | "加个校验" | "先写无效输入的测试,再让测试通过" |
58
- | "修这个 bug" | "先写能复现的测试,再修到测试通过" |
59
- | "重构 X" | "确保重构前后测试全部通过" |
60
-
61
- 多步任务先给简短计划:
62
- ```
63
- 1. [步骤] → 验证: [检查项]
64
- 2. [步骤] → 验证: [检查项]
65
- 3. [步骤] → 验证: [检查项]
66
- ```
67
-
68
- 清晰的成功标准让 AI 可以独立循环验证,模糊的标准("搞一下")需要反复澄清。
69
-
70
- ## 5. 失败要大声说出来
71
-
72
- **悄悄绕过失败比直接失败更糟糕。**
73
-
74
- - 有步骤被跳过,"完成"就是错的——说出来
75
- - 有测试被跳过,"测试通过"就是错的——说出来
76
- - 不确定就直接说不确定,不假装确认
77
- - 默认暴露不确定性,不掩盖
78
-
79
- **检验标准:** 任何跳过的步骤、不确定的结论、未验证的结果,都以标记形式呈现,不悄悄带过。
80
-
81
- ## 6. 不认同也要说出来
82
-
83
- 当项目现有约定明显有问题时:
84
-
85
- - 照样遵循,保持一致——不悄悄另起炉灶
86
- - 明确提出来——指出风险,给出替代方案
87
- - 让用户做决策,不要替用户做选择
88
-
89
- **检验标准:** 你的代码放进现有代码中,读不出"换了一个人写的"。发现的问题以建议形式呈现,而非悄悄用另一种方式实现。
90
-
91
- ## 7. 先批准,后动工
92
-
93
- **任何实现动作前,先陈述方案并获得用户批准。**
94
-
95
- - 动手前说出打算怎么做(方案、涉及文件、验证方式),等用户确认
96
- - 仪式随任务缩放:小改动两三句话说清即可;大改动走 openspec 工作流(propose → specs → design)
97
- - "太简单不需要方案"是最危险的念头——简单意味着方案短,而不是没有方案
98
- - 中途发现复杂度超出预期:停下来重新说明,不要闷头扩大改动范围
99
-
100
- **检验标准:** 用户从未因"AI 直接改了代码没打招呼"而感到意外。
101
-
102
- ## 8. 业务空间目录纪律
103
-
104
- **仅当工作目录是业务空间根(存在 `workspace-config.json`)时生效:写操作命令必须落在需求工作树内。**
105
-
106
- 业务空间根(主分支)只负责组织与调度,不做需求开发。接到需求先建工作树(`/cbb:worktree-init` 或 `/cbb-worktree-init`),之后:
107
-
108
- - 一切产生写操作的命令(git commit / openspec / 构建 / 测试 / 文件修改)必须以 `.worktrees/worktree-<需求名>/`(或其应用子目录)为工作目录:显式 `cd` 或绝对路径
109
- - 禁止在空间根执行写操作:不在主分支提交代码、不在空间根创建 openspec 变更产物、不改 `.codespace/` 基准代码
110
- - 只读命令(git status / log、查看文件)在空间根执行无妨
111
- - 会话开始时确认本次需求对应的工作树路径;存在多个未完成工作树时,先与用户确认目标,不要猜
112
-
113
- **检验标准:** 空间根主分支的 `git status` 永远干净(除工具维护的配置文件外),openspec 变更产物只出现在需求工作树内。
114
-
115
- ---
116
-
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # AI 行为准则
6
+
7
+ 七条行为准则,减少 AI 编码常见错误。源自 [Andrej Karpathy 对 LLM 编码缺陷的观察](https://x.com/karpathy/status/2015883857489522876)。
8
+
9
+ **权衡:** 这些准则倾向于谨慎而非速度。对于简单任务(如修 typo、改文案),按常识判断即可。
10
+
11
+ ## 1. 先想后写
12
+
13
+ **不假设,不隐藏困惑,主动呈现权衡。**
14
+
15
+ 实现前:
16
+ - 明确声明假设,不确定时主动询问
17
+ - 若存在多种解释,呈现出来而非自己默默选一种
18
+ - 若有更简单的方案,说出来,必要时 push back
19
+ - 若有不明确的地方,停下来,说出困惑,请求澄清
20
+
21
+ ## 2. 简洁至上
22
+
23
+ **用最少代码解决问题,不加推测性内容。**
24
+
25
+ - 不实现用户未要求的功能
26
+ - 不为单次使用的代码创建抽象
27
+ - 不添加用户未要求的"灵活性"或"可配置性"
28
+ - 不为不可能发生的场景写错误处理
29
+ - 写了 200 行却发现 50 行就能搞定 → 重写
30
+
31
+ 自问:"资深工程师会说过度设计吗?"如果会,简化。
32
+
33
+ ## 3. 外科手术式修改
34
+
35
+ **只改必须改的,只清理自己造成的烂摊子。**
36
+
37
+ 编辑已有代码时:
38
+ - 不顺手"改进"相邻代码、注释或格式
39
+ - 不重构没坏的东西
40
+ - 匹配现有风格,即使你更习惯另一种写法
41
+ - 发现无关的死代码,口头提及即可,不要删除
42
+
43
+ 当你的改动产生孤儿代码时:
44
+ - 删除因你的改动而不再使用的 import / 变量 / 函数
45
+ - 不删除已有的死代码,除非用户要求
46
+
47
+ **检验标准:** 每一行改动都应该能追溯到用户的需求。
48
+
49
+ ## 4. 目标驱动执行
50
+
51
+ **定义成功标准,循环直到验证通过。**
52
+
53
+ 将命令式任务转换为可验证的目标:
54
+
55
+ | 而非… | 转换为… |
56
+ |--------|---------|
57
+ | "加个校验" | "先写无效输入的测试,再让测试通过" |
58
+ | "修这个 bug" | "先写能复现的测试,再修到测试通过" |
59
+ | "重构 X" | "确保重构前后测试全部通过" |
60
+
61
+ 多步任务先给简短计划:
62
+ ```
63
+ 1. [步骤] → 验证: [检查项]
64
+ 2. [步骤] → 验证: [检查项]
65
+ 3. [步骤] → 验证: [检查项]
66
+ ```
67
+
68
+ 清晰的成功标准让 AI 可以独立循环验证,模糊的标准("搞一下")需要反复澄清。
69
+
70
+ ## 5. 失败要大声说出来
71
+
72
+ **悄悄绕过失败比直接失败更糟糕。**
73
+
74
+ - 有步骤被跳过,"完成"就是错的——说出来
75
+ - 有测试被跳过,"测试通过"就是错的——说出来
76
+ - 不确定就直接说不确定,不假装确认
77
+ - 默认暴露不确定性,不掩盖
78
+
79
+ **检验标准:** 任何跳过的步骤、不确定的结论、未验证的结果,都以标记形式呈现,不悄悄带过。
80
+
81
+ ## 6. 不认同也要说出来
82
+
83
+ 当项目现有约定明显有问题时:
84
+
85
+ - 照样遵循,保持一致——不悄悄另起炉灶
86
+ - 明确提出来——指出风险,给出替代方案
87
+ - 让用户做决策,不要替用户做选择
88
+
89
+ **检验标准:** 你的代码放进现有代码中,读不出"换了一个人写的"。发现的问题以建议形式呈现,而非悄悄用另一种方式实现。
90
+
91
+ ## 7. 先批准,后动工
92
+
93
+ **任何实现动作前,先陈述方案并获得用户批准。**
94
+
95
+ - 动手前说出打算怎么做(方案、涉及文件、验证方式),等用户确认
96
+ - 仪式随任务缩放:小改动两三句话说清即可;大改动走 openspec 工作流(propose → specs → design)
97
+ - "太简单不需要方案"是最危险的念头——简单意味着方案短,而不是没有方案
98
+ - 中途发现复杂度超出预期:停下来重新说明,不要闷头扩大改动范围
99
+
100
+ **检验标准:** 用户从未因"AI 直接改了代码没打招呼"而感到意外。
101
+
102
+ ## 8. 业务空间开发模式(双模式,用户选择制)
103
+
104
+ **仅当工作目录是业务空间根(存在 `CBB-WORKSPACE.json` 且 `.git` 为目录)时生效。空间支持两种开发模式,能力对称(都能修改 workspace 内容与应用代码、都强制分支隔离、交付都走 MR),由用户显式选择,agent 只给推荐不代决。**
105
+
106
+ **模式一 · 本地模式(单线程快改,当前会话就地干):**
107
+
108
+ - 就地切分支:根 + 各涉及应用 `.codespace/<app>/` 同名 `checkout -b`(基线 = `origin/<main>`,经 `cbb-local-mode` 技能执行)
109
+ - 当前会话原地开发,相对路径原样生效;**一次只承载一个需求**(独占本地检出;期间并行新需求走 worktree 模式,互不干扰)
110
+ - 收尾:MR 合并后各参与仓库 `checkout main && pull && 删分支`
111
+
112
+ **模式二 · worktree 模式(并行 / 隔离):**
113
+
114
+ - `cbb-worktree-init` 建隔离 worktree(AI 配置内容子目录已 junction 就位),**开发会话开进 `.worktrees/worktree-<需求名>/`**,可多需求并行;app 检出收拢在 `<wt>/.codespace/<app>/`——**镜像空间根布局**(`.codespace/<app>/...` 相对路径两模式通用,ADR 0003)
115
+ - 根会话保留作控制面(worktree 生灭、`cbb update` 等空间级操作);**会话形态按工具定,能自动则 agent 亲自做**:OpenCode 桌面端 = agent 自动把会话切进/切出 worktree(`session_move`,上下文保留、不列入用户待办,空间根路径在案供回切);无会话搬移能力的桌面端 = 用户手动切根;CLI/TUI = 新开会话进 worktree
116
+
117
+ **基准与防线(两模式共同,ADR 0002):**
118
+
119
+ - **基准 = `origin/main`(唯一真相源);`.codespace/<app>/` 的检出 = 视图**——本地模式可暂态被需求分支占用,收尾恢复
120
+ - **严禁直接在任何 main 检出上提交载荷**:分支感知 pre-commit hook 机械拦截(workspace 仓库仅放行控制面白名单:`CBB-WORKSPACE.json` / `.gitignore` / `AGENTS.md` / `openspec/config.yaml` / `openspec/schemas/**`;应用仓库 main 全拦)——**被拦是防线生效,不是故障**;`--no-verify` 绕过仅限用户显式要求
121
+ - 远端推送唯一出口 = `cbb-worktree-push`(init 创建流程零远端操作,lazy push;空分支尸体不存在)
122
+ - **模式误判零代价**:本地模式中途要并行/隔离 → 重跑 `cbb-worktree-init`(分支已存在自动复用,提交随身带走)
123
+
124
+ **三时刻对齐(agent 必须遵守):**
125
+
126
+ 1. **开工前——状态自检**(`cbb-local-mode` 的 `check-local-state.js`):干净态零交互直接开工;**遗留态(别的需求未收尾,任一仓库检出在非主干分支)必须让用户四选一**(继续 / 先收尾 / 升级 worktree / 丢弃),不得自行决定
127
+ 2. **开工时——布局确认**:向用户展示参与仓库与分支名,确认后执行
128
+ 3. **进行中——插单归属**:用户插入非本需求的改动,先确认归属(并入 / 收尾后处理 / 转 worktree),不得静默混入
129
+
130
+ **读基准代码约定:** 本地模式进行中,工作区是开发态而非基准——要读"main 现状"先确认检出分支,或直接 `git show main:<path>` / `git diff main`;不要默认工作区即基准。
131
+
132
+ **检验标准:** 任何 main 检出上无载荷提交(hook 兜底,git log 可机械审计);本地模式收尾后全部仓库回主干且 clean;worktree 模式的变更产物只出现在需求工作树内;远端分支只经 push 技能产生。
133
+
134
+ ---
135
+
117
136
  **这些准则生效的标志:** diff 中不必要的改动减少、不会因过度设计而重写、澄清问题在实现前而非出错后提出。
@@ -0,0 +1,92 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * AGENTS.md 托管导航块(agentsNav)。
5
+ *
6
+ * MiniMax Code 不读取 .minimax/rules(源码无该逻辑),其项目级规则注入通道
7
+ * 只有工作区根 AGENTS.md(local-runtime/src/project/instructions.ts,32KB 预算)。
8
+ * 安装时在 AGENTS.md 注入一句托管导航,引导 AI 先读取规则;块形如:
9
+ *
10
+ * <!-- cbb:agents-nav:minimax begin -->
11
+ * ⚠️ 规则优先:……
12
+ * <!-- cbb:agents-nav:minimax end -->
13
+ *
14
+ * 约束:
15
+ * - 幂等:块内容随安装更新,块外用户内容永不改动;
16
+ * - 标记带适配器名,多适配器共存不互撞;
17
+ * - 卸载只摘除本包块;摘除后文件为空(本包创建的情形)则删除文件。
18
+ *
19
+ * AGENTS.md 本身不进清单(cleanup.js 的 PROTECTED_FROM_CLEANUP 同样保护它),
20
+ * 托管块的注入与摘除由 init() 安装流程 / uninstall() 按适配器显式处理。
21
+ */
22
+
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+
26
+ /** 转义正则元字符(适配器名入正则上下文) */
27
+ function escapeRe(value) {
28
+ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
29
+ }
30
+
31
+ function markersFor(adapterName) {
32
+ const safe = escapeRe(adapterName);
33
+ return {
34
+ begin: `<!-- cbb:agents-nav:${adapterName} begin -->`,
35
+ end: `<!-- cbb:agents-nav:${adapterName} end -->`,
36
+ // [\s\S]*? 非贪婪:块内可含任意内容(含 \r),遇最近的 end 标记即止
37
+ blockRe: new RegExp(`<!-- cbb:agents-nav:${safe} begin -->[\\s\\S]*?<!-- cbb:agents-nav:${safe} end -->`, 'm'),
38
+ };
39
+ }
40
+
41
+ /**
42
+ * 注入(或更新)导航块。
43
+ * @param {string} filePath 目标 AGENTS.md 绝对路径
44
+ * @param {string} adapterName 适配器名(标记命名空间)
45
+ * @param {string} text 导航句
46
+ * @returns {'created'|'updated'|'unchanged'} created = 文件原不存在或为空白
47
+ */
48
+ function inject(filePath, adapterName, text) {
49
+ const { begin, end, blockRe } = markersFor(adapterName);
50
+ const existed = fs.existsSync(filePath);
51
+ const content = existed ? fs.readFileSync(filePath, 'utf-8') : '';
52
+ // 行尾与既有文件保持一致(Windows 生成的 AGENTS.md 多为 CRLF)
53
+ const eol = content.includes('\r\n') ? '\r\n' : '\n';
54
+ const block = `${begin}${eol}${text}${eol}${end}`;
55
+
56
+ if (blockRe.test(content)) {
57
+ const next = content.replace(blockRe, block);
58
+ if (next === content) return 'unchanged';
59
+ fs.writeFileSync(filePath, next);
60
+ return 'updated';
61
+ }
62
+
63
+ const wasBlank = content.trim() === '';
64
+ const base = content.replace(/\n*$/, ''); // 收敛尾部空行,块另起段落
65
+ const next = wasBlank ? `${block}${eol}` : `${base}${eol}${eol}${block}${eol}`;
66
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
67
+ fs.writeFileSync(filePath, next);
68
+ return wasBlank && !existed ? 'created' : wasBlank ? 'updated' : 'created';
69
+ }
70
+
71
+ /**
72
+ * 精确摘除导航块(块外内容不动)。
73
+ * @returns {boolean} 是否有改动(块不存在 → false)
74
+ */
75
+ function remove(filePath, adapterName) {
76
+ if (!fs.existsSync(filePath)) return false;
77
+ const { blockRe } = markersFor(adapterName);
78
+ const content = fs.readFileSync(filePath, 'utf-8');
79
+ if (!blockRe.test(content)) return false;
80
+
81
+ // 只删块本身;随后收敛尾部空白(块移除后的残留空行)
82
+ const next = content.replace(blockRe, '').replace(/\s+$/, '');
83
+ if (next.trim() === '') {
84
+ // 文件只剩本包内容(由本包创建的情形)→ 连文件一起删除
85
+ fs.unlinkSync(filePath);
86
+ return true;
87
+ }
88
+ fs.writeFileSync(filePath, next + '\n');
89
+ return true;
90
+ }
91
+
92
+ module.exports = { inject, remove };
@@ -2,6 +2,11 @@
2
2
  * Claude Code 适配器
3
3
  *
4
4
  * 将编码规范分发到 .claude/rules/ 目录
5
+ *
6
+ * 退市(selectable: false):团队当前不使用 Claude Code,不在安装面板提供。
7
+ * 适配器代码与全部能力保留(含用户级 settings hook);先前已安装的空间按
8
+ * .last-tools 记录**粘性维护**(见 tool-selection.js),内容不被清理。
9
+ * 恢复入口:删掉 selectable 即可重新出现在面板(决策:不留参数开关)。
5
10
  */
6
11
 
7
12
  const path = require('path');
@@ -13,10 +18,10 @@ module.exports = {
13
18
  rulesDir: '.claude/rules',
14
19
  skillsDir: '.claude/skills',
15
20
  commandsDir: '.claude/commands/opsx',
16
- // worktree 管理命令(非 openspec 上游):独立命名空间 /cbb:worktree-*
17
- worktreeCommandsDir: '.claude/commands/cbb',
18
21
  // 用户级 settings,写入全局生效,不污染项目目录
19
22
  settingsFile: path.join(os.homedir(), '.claude', 'settings.json'),
20
23
  settingsFileIsUserLevel: true,
21
24
  hookEvents: ['UserPromptSubmit'],
25
+ // 退市:不在安装面板提供(代码保留,存量空间粘性维护)
26
+ selectable: false,
22
27
  };
@@ -0,0 +1,105 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * openspec 命令 → skill 形态转换(commandsAsSkills 适配器用,当前仅 MiniMax Code)。
5
+ *
6
+ * MiniMax Code 无项目级 commands 目录,skill 即其命令形态:每个 openspec 命令
7
+ * 落为 <skillsDir>/<prefix><name>/SKILL.md,目录名 = frontmatter name(Agent
8
+ * Skills 约定),/opsx-propose 斜杠照常可用。
9
+ *
10
+ * 同时承接命令 frontmatter 消毒(sanitizeCommandFrontmatter):opencode 新版
11
+ * 校验命令配置(description 必须为 string | undefined),上游个别命令
12
+ * (openspec/commands/update.md)的 description 为空值(YAML 解析为 null),
13
+ * 会拒绝加载整个项目配置。此处对部署副本回填正文首句作为描述(超过 120 字
14
+ * 截断),上游源文件不动(CLI 接管区)。
15
+ */
16
+
17
+ const path = require('path');
18
+
19
+ /**
20
+ * 命令文件 → skill 目录名(文件名基准,保证目录名稳定)。
21
+ * @param {string} fileName 如 propose.md
22
+ * @param {string} prefix 如 opsx-
23
+ * @returns {string} 如 opsx-propose
24
+ */
25
+ function skillNameFor(fileName, prefix) {
26
+ return (prefix || '') + path.basename(fileName, '.md');
27
+ }
28
+
29
+ /** 取 frontmatter(首个 --- 到闭合 --- 之间);无 frontmatter 返回 -1 */
30
+ function findFrontmatterEnd(lines) {
31
+ if ((lines[0] || '').trim() !== '---') return -1;
32
+ for (let i = 1; i < lines.length; i++) {
33
+ if ((lines[i] || '').trim() === '---') return i;
34
+ }
35
+ return -1;
36
+ }
37
+
38
+ /**
39
+ * 命令 frontmatter 消毒(见文件头注释)。无 frontmatter 或无需改动时原样返回。
40
+ */
41
+ function sanitizeCommandFrontmatter(content) {
42
+ const lines = content.split('\n');
43
+ if ((lines[0] || '').trim() !== '---') return content;
44
+ const end = findFrontmatterEnd(lines);
45
+ if (end === -1) return content;
46
+ let sentence = '';
47
+ for (let i = end + 1; i < lines.length; i++) {
48
+ const t = (lines[i] || '').trim();
49
+ if (t) { sentence = t; break; }
50
+ }
51
+ let changed = false;
52
+ for (let i = 1; i < end; i++) {
53
+ if (/^description:\s*(null|~)?\s*\r?$/.test(lines[i])) {
54
+ if (sentence) {
55
+ if (sentence.length > 120) sentence = sentence.slice(0, 117) + '...';
56
+ lines[i] = 'description: ' + JSON.stringify(sentence) + (lines[i].endsWith('\r') ? '\r' : '');
57
+ } else {
58
+ lines[i] = null; // 无正文可回填则移除(undefined 同样合法)
59
+ }
60
+ changed = true;
61
+ }
62
+ }
63
+ return changed ? lines.filter(l => l !== null).join('\n') : content;
64
+ }
65
+
66
+ /**
67
+ * 把命令内容转换为 skill 的 SKILL.md 内容:
68
+ * 1. frontmatter description 消毒(null → 回填正文首句);
69
+ * 2. frontmatter name 强制为 skillName —— 目录名 = name 是 Agent Skills 约定,
70
+ * 也规避上游标题与文件名不一致(如 ff.md 的 "OPSX: Fast Forward")。
71
+ *
72
+ * 上游 frontmatter 的其余字段(category / tags 等)原样保留。
73
+ *
74
+ * @param {string} content 命令原文(调用方已应用 contentRewrites)
75
+ * @param {string} skillName 目标 skill 名(= 目录名)
76
+ * @returns {string} SKILL.md 内容
77
+ */
78
+ function convertCommandToSkill(content, skillName) {
79
+ const sanitized = sanitizeCommandFrontmatter(content);
80
+ const lines = sanitized.split('\n');
81
+
82
+ // 无 frontmatter:补建(name 必填;description 回填正文首句)
83
+ if ((lines[0] || '').trim() !== '---') {
84
+ const sentence = (lines.find(l => l.trim()) || '').trim().slice(0, 120);
85
+ const fm = ['---', `name: "${skillName}"`];
86
+ if (sentence) fm.push(`description: ${JSON.stringify(sentence)}`);
87
+ fm.push('---', '');
88
+ return fm.concat(lines).join('\n');
89
+ }
90
+
91
+ const end = findFrontmatterEnd(lines);
92
+ if (end === -1) return sanitized; // 开了没闭合的异常 frontmatter:不动
93
+
94
+ let nameLine = -1;
95
+ for (let i = 1; i < end; i++) {
96
+ if (/^name:/.test(lines[i])) { nameLine = i; break; }
97
+ }
98
+ const nameValue = `name: "${skillName}"`;
99
+ if (nameLine === -1) lines.splice(1, 0, nameValue); // 缺 name:紧跟开标记插入
100
+ else lines[nameLine] = nameValue + (lines[nameLine].endsWith('\r') ? '\r' : '');
101
+
102
+ return lines.join('\n');
103
+ }
104
+
105
+ module.exports = { skillNameFor, sanitizeCommandFrontmatter, convertCommandToSkill };