peaks-cli 1.0.0

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 (143) hide show
  1. package/LICENSE +52 -0
  2. package/README.md +417 -0
  3. package/bin/peaks.js +2 -0
  4. package/dist/src/cli/cli-helpers.d.ts +25 -0
  5. package/dist/src/cli/cli-helpers.js +78 -0
  6. package/dist/src/cli/commands/capability-commands.d.ts +5 -0
  7. package/dist/src/cli/commands/capability-commands.js +46 -0
  8. package/dist/src/cli/commands/capability-worker-config-sc-commands.d.ts +3 -0
  9. package/dist/src/cli/commands/capability-worker-config-sc-commands.js +10 -0
  10. package/dist/src/cli/commands/config-commands.d.ts +3 -0
  11. package/dist/src/cli/commands/config-commands.js +212 -0
  12. package/dist/src/cli/commands/core-artifact-commands.d.ts +3 -0
  13. package/dist/src/cli/commands/core-artifact-commands.js +200 -0
  14. package/dist/src/cli/commands/sc-commands.d.ts +3 -0
  15. package/dist/src/cli/commands/sc-commands.js +37 -0
  16. package/dist/src/cli/commands/worker-commands.d.ts +3 -0
  17. package/dist/src/cli/commands/worker-commands.js +52 -0
  18. package/dist/src/cli/commands/workflow-commands.d.ts +3 -0
  19. package/dist/src/cli/commands/workflow-commands.js +257 -0
  20. package/dist/src/cli/index.d.ts +1 -0
  21. package/dist/src/cli/index.js +14 -0
  22. package/dist/src/cli/program.d.ts +4 -0
  23. package/dist/src/cli/program.js +13 -0
  24. package/dist/src/services/artifacts/artifact-service.d.ts +43 -0
  25. package/dist/src/services/artifacts/artifact-service.js +97 -0
  26. package/dist/src/services/artifacts/workspace-service.d.ts +33 -0
  27. package/dist/src/services/artifacts/workspace-service.js +254 -0
  28. package/dist/src/services/config/config-service.d.ts +29 -0
  29. package/dist/src/services/config/config-service.js +501 -0
  30. package/dist/src/services/config/config-types.d.ts +63 -0
  31. package/dist/src/services/config/config-types.js +16 -0
  32. package/dist/src/services/config/model-routing.d.ts +4 -0
  33. package/dist/src/services/config/model-routing.js +15 -0
  34. package/dist/src/services/doctor/doctor-service.d.ts +18 -0
  35. package/dist/src/services/doctor/doctor-service.js +68 -0
  36. package/dist/src/services/memory/project-memory-service.d.ts +79 -0
  37. package/dist/src/services/memory/project-memory-service.js +306 -0
  38. package/dist/src/services/profiles/profile-service.d.ts +6 -0
  39. package/dist/src/services/profiles/profile-service.js +19 -0
  40. package/dist/src/services/providers/minimax-provider-service.d.ts +24 -0
  41. package/dist/src/services/providers/minimax-provider-service.js +143 -0
  42. package/dist/src/services/providers/minimax-worker-service.d.ts +21 -0
  43. package/dist/src/services/providers/minimax-worker-service.js +80 -0
  44. package/dist/src/services/proxy/proxy-service.d.ts +7 -0
  45. package/dist/src/services/proxy/proxy-service.js +31 -0
  46. package/dist/src/services/rd/rd-service.d.ts +88 -0
  47. package/dist/src/services/rd/rd-service.js +370 -0
  48. package/dist/src/services/recommendations/capability-availability.d.ts +5 -0
  49. package/dist/src/services/recommendations/capability-availability.js +40 -0
  50. package/dist/src/services/recommendations/capability-map-service.d.ts +7 -0
  51. package/dist/src/services/recommendations/capability-map-service.js +131 -0
  52. package/dist/src/services/recommendations/capability-seed-items.d.ts +2 -0
  53. package/dist/src/services/recommendations/capability-seed-items.js +131 -0
  54. package/dist/src/services/recommendations/capability-seed-mappings.d.ts +2 -0
  55. package/dist/src/services/recommendations/capability-seed-mappings.js +42 -0
  56. package/dist/src/services/recommendations/capability-seed-sources.d.ts +2 -0
  57. package/dist/src/services/recommendations/capability-seed-sources.js +35 -0
  58. package/dist/src/services/recommendations/recommendation-service.d.ts +8 -0
  59. package/dist/src/services/recommendations/recommendation-service.js +106 -0
  60. package/dist/src/services/recommendations/recommendation-types.d.ts +129 -0
  61. package/dist/src/services/recommendations/recommendation-types.js +1 -0
  62. package/dist/src/services/recommendations/seed-capability-catalog.d.ts +3 -0
  63. package/dist/src/services/recommendations/seed-capability-catalog.js +3 -0
  64. package/dist/src/services/refactor/refactor-service.d.ts +9 -0
  65. package/dist/src/services/refactor/refactor-service.js +33 -0
  66. package/dist/src/services/sc/index.d.ts +1 -0
  67. package/dist/src/services/sc/index.js +1 -0
  68. package/dist/src/services/sc/sc-service.d.ts +79 -0
  69. package/dist/src/services/sc/sc-service.js +223 -0
  70. package/dist/src/services/skills/skill-registry.d.ts +17 -0
  71. package/dist/src/services/skills/skill-registry.js +40 -0
  72. package/dist/src/services/standards/project-standards-service.d.ts +82 -0
  73. package/dist/src/services/standards/project-standards-service.js +383 -0
  74. package/dist/src/services/tech/tech-service.d.ts +69 -0
  75. package/dist/src/services/tech/tech-service.js +236 -0
  76. package/dist/src/services/workflow/workflow-autonomous-service.d.ts +99 -0
  77. package/dist/src/services/workflow/workflow-autonomous-service.js +526 -0
  78. package/dist/src/services/workflow/workflow-router-service.d.ts +85 -0
  79. package/dist/src/services/workflow/workflow-router-service.js +213 -0
  80. package/dist/src/shared/change-id.d.ts +15 -0
  81. package/dist/src/shared/change-id.js +76 -0
  82. package/dist/src/shared/frontmatter.d.ts +6 -0
  83. package/dist/src/shared/frontmatter.js +47 -0
  84. package/dist/src/shared/fs-utils.d.ts +4 -0
  85. package/dist/src/shared/fs-utils.js +16 -0
  86. package/dist/src/shared/fs.d.ts +4 -0
  87. package/dist/src/shared/fs.js +26 -0
  88. package/dist/src/shared/path-utils.d.ts +13 -0
  89. package/dist/src/shared/path-utils.js +56 -0
  90. package/dist/src/shared/paths.d.ts +6 -0
  91. package/dist/src/shared/paths.js +40 -0
  92. package/dist/src/shared/planner-response.d.ts +21 -0
  93. package/dist/src/shared/planner-response.js +26 -0
  94. package/dist/src/shared/platform.d.ts +6 -0
  95. package/dist/src/shared/platform.js +11 -0
  96. package/dist/src/shared/process.d.ts +5 -0
  97. package/dist/src/shared/process.js +12 -0
  98. package/dist/src/shared/result.d.ts +13 -0
  99. package/dist/src/shared/result.js +32 -0
  100. package/package.json +49 -0
  101. package/schemas/approval-record.schema.json +14 -0
  102. package/schemas/artifact-manifest.schema.json +16 -0
  103. package/schemas/artifact-retention-report.schema.json +17 -0
  104. package/schemas/artifact-workspace.schema.json +22 -0
  105. package/schemas/capability-availability.schema.json +36 -0
  106. package/schemas/capability-item.schema.json +37 -0
  107. package/schemas/capability-source.schema.json +30 -0
  108. package/schemas/change-impact.schema.json +15 -0
  109. package/schemas/context-capsule.schema.json +16 -0
  110. package/schemas/recommendation-plan.schema.json +37 -0
  111. package/schemas/refactor-slice-spec.schema.json +19 -0
  112. package/scripts/clean-dist.mjs +8 -0
  113. package/scripts/install-skills.mjs +76 -0
  114. package/scripts/watch.mjs +389 -0
  115. package/skills/peaks-prd/SKILL.md +42 -0
  116. package/skills/peaks-prd/references/artifact-contracts.md +3 -0
  117. package/skills/peaks-prd/references/command-migration.md +3 -0
  118. package/skills/peaks-prd/references/workflow.md +11 -0
  119. package/skills/peaks-qa/SKILL.md +45 -0
  120. package/skills/peaks-qa/references/artifact-contracts.md +3 -0
  121. package/skills/peaks-qa/references/command-migration.md +3 -0
  122. package/skills/peaks-qa/references/regression-gates.md +16 -0
  123. package/skills/peaks-rd/SKILL.md +56 -0
  124. package/skills/peaks-rd/references/artifact-contracts.md +3 -0
  125. package/skills/peaks-rd/references/command-migration.md +3 -0
  126. package/skills/peaks-rd/references/refactor-workflow.md +31 -0
  127. package/skills/peaks-sc/SKILL.md +30 -0
  128. package/skills/peaks-sc/references/artifact-contracts.md +3 -0
  129. package/skills/peaks-sc/references/artifact-retention.md +14 -0
  130. package/skills/peaks-sc/references/command-migration.md +3 -0
  131. package/skills/peaks-solo/SKILL.md +63 -0
  132. package/skills/peaks-solo/references/artifact-contracts.md +3 -0
  133. package/skills/peaks-solo/references/command-migration.md +3 -0
  134. package/skills/peaks-solo/references/refactor-mode.md +22 -0
  135. package/skills/peaks-solo/references/workflow.md +14 -0
  136. package/skills/peaks-txt/SKILL.md +48 -0
  137. package/skills/peaks-txt/references/artifact-contracts.md +3 -0
  138. package/skills/peaks-txt/references/command-migration.md +3 -0
  139. package/skills/peaks-txt/references/context-capsule.md +20 -0
  140. package/skills/peaks-ui/SKILL.md +35 -0
  141. package/skills/peaks-ui/references/artifact-contracts.md +3 -0
  142. package/skills/peaks-ui/references/command-migration.md +3 -0
  143. package/skills/peaks-ui/references/workflow.md +11 -0
package/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ Peaks Closed-Source Non-Commercial License
2
+ Peaks 闭源非商用许可协议
3
+
4
+ English Version
5
+
6
+ Copyright (c) 2026 Peaks contributors. All rights reserved.
7
+
8
+ 1. License Grant
9
+ You may use this software only for personal, internal evaluation, research, learning, or other non-commercial purposes authorized by the copyright holder.
10
+
11
+ 2. Commercial Use Prohibited
12
+ Commercial use is prohibited without prior written permission from the copyright holder. Commercial use includes, but is not limited to, using the software to provide paid services, support commercial operations, generate revenue, integrate into commercial products, or use within a for-profit organization for business purposes.
13
+
14
+ 3. Modification Prohibited for Commercial Purposes
15
+ You may not modify, adapt, translate, create derivative works from, or otherwise alter this software for any commercial purpose without prior written permission from the copyright holder.
16
+
17
+ 4. Redistribution Prohibited for Commercial Purposes
18
+ You may not distribute, sublicense, sell, rent, lease, publish, host, mirror, package, bundle, or otherwise make this software or modified versions available to others for any commercial purpose without prior written permission from the copyright holder.
19
+
20
+ 5. No Open-Source License
21
+ This software is closed source. No rights are granted except those expressly stated in this license. All rights not expressly granted are reserved by the copyright holder.
22
+
23
+ 6. No Warranty
24
+ This software is provided "as is", without warranty of any kind, express or implied, including but not limited to warranties of merchantability, fitness for a particular purpose, and non-infringement. The copyright holder is not liable for any claim, damages, or other liability arising from the software or its use.
25
+
26
+ 7. Additional Permission
27
+ For commercial licensing, modification, distribution, or other permissions not granted by this license, contact the copyright holder and obtain written permission before proceeding.
28
+
29
+ 中文版本
30
+
31
+ 版权所有 (c) 2026 Peaks 贡献者。保留所有权利。
32
+
33
+ 1. 授权范围
34
+ 你仅可将本软件用于个人使用、内部评估、研究、学习,或版权持有人授权的其他非商业用途。
35
+
36
+ 2. 禁止商业使用
37
+ 未经版权持有人事先书面许可,禁止将本软件用于任何商业用途。商业用途包括但不限于:使用本软件提供付费服务、支持商业运营、产生收入、集成到商业产品中,或在营利性组织内用于业务目的。
38
+
39
+ 3. 禁止商业目的的修改
40
+ 未经版权持有人事先书面许可,你不得为了任何商业目的修改、改编、翻译、创作衍生作品,或以其他方式变更本软件。
41
+
42
+ 4. 禁止商业目的的分发
43
+ 未经版权持有人事先书面许可,你不得为了任何商业目的分发、再授权、销售、出租、租赁、发布、托管、镜像、打包、捆绑,或以其他方式向他人提供本软件或其修改版本。
44
+
45
+ 5. 非开源许可
46
+ 本软件为闭源软件。除本许可明确授予的权利外,不授予任何其他权利。所有未明确授予的权利均由版权持有人保留。
47
+
48
+ 6. 无担保
49
+ 本软件按“现状”提供,不附带任何明示或默示担保,包括但不限于适销性、特定用途适用性和不侵权担保。版权持有人不对因本软件或其使用产生的任何索赔、损害或其他责任承担责任。
50
+
51
+ 7. 额外许可
52
+ 如需商业授权、修改、分发或本许可未授予的其他权限,请在行动前联系版权持有人并取得书面许可。
package/README.md ADDED
@@ -0,0 +1,417 @@
1
+ # Peaks
2
+
3
+ Peaks 是一个面向 Claude Code 的全局 CLI 工具和短技能族,用来把项目治理、工作流规划、受控执行、QA 验证、变更追踪组织成可复用的工程流程。
4
+
5
+ 如果你是使用者,把 Peaks 当成一个安装后直接运行的命令行工具即可:先配置工作区,再选择工作流,再按需要调用 skills 和受控 worker。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install -g @peaks/cli
11
+ ```
12
+
13
+ 安装后可直接使用:
14
+
15
+ ```bash
16
+ peaks --help
17
+ ```
18
+
19
+ 如果你已经从源码或本地包安装,也可以直接运行 `peaks`。
20
+
21
+ 要确认安装成功,可以执行:
22
+
23
+ ```bash
24
+ peaks -v
25
+ peaks --version
26
+ peaks --help
27
+ peaks -h
28
+ ```
29
+
30
+ `-v` / `--version` 会显示版本号,`--help` / `-h` 会列出可用的 Peaks 命令。
31
+
32
+ 全局安装时,Peaks 会把包内置的 skills 以 symlink 形式注册到全局 Claude skills 目录。安装完成后,你可以在 Claude Code 里直接用这些 skill 名称加自然语言描述来发起工作。
33
+
34
+ ## 项目全貌
35
+
36
+ Peaks 由五层组成:
37
+
38
+ - CLI 入口:`bin/peaks.js` 和 `src/cli/**`,提供所有 `peaks ...` 命令。
39
+ - 服务层:`src/services/**`,实现配置、artifact、memory、standards、workflow、RD、Tech、SC、capability、MiniMax worker 等能力。
40
+ - Skills:`skills/peaks-*`,提供 PRD、UI、RD、QA、Solo、SC、TXT 七个 Claude Code 工作流角色。
41
+ - Schemas:`schemas/*.json`,定义 artifact、recommendation、context capsule、approval、capability、change impact 等稳定数据契约。
42
+ - 验证:`tests/unit/**` 和 `tests/e2e/**` 覆盖 CLI 分支、服务边界、路径安全、安装脚本、watch 脚本和 E2E 工作流。
43
+
44
+ 核心设计是“skills 定义流程,CLI 执行副作用”。Skills 不直接改配置、不安装 MCP、不写远端仓库;这些动作必须通过 CLI 的 dry-run、JSON 输出、显式 apply/confirm 和可验证结果完成。
45
+
46
+ ## 快速开始
47
+
48
+ ### 1. 先确认环境
49
+
50
+ ```bash
51
+ peaks doctor --json
52
+ peaks skill doctor --json
53
+ ```
54
+
55
+ 这两条命令会帮助你确认 Peaks、skills、配置和 artifact 相关状态是否可用。
56
+
57
+ ### 2. 查看可用 skills
58
+
59
+ ```bash
60
+ peaks skill list --json
61
+ ```
62
+
63
+ Peaks 的 skills 主要有这些:
64
+
65
+ - `peaks-solo`:端到端编排入口
66
+ - `peaks-prd`:产品目标、非目标、验收标准
67
+ - `peaks-ui`:UI/UX、交互和视觉约束
68
+ - `peaks-rd`:研发分析、重构规划、执行契约
69
+ - `peaks-qa`:测试、覆盖率、回归和验收
70
+ - `peaks-sc`:变更追踪、commit boundary、artifact 留存
71
+ - `peaks-txt`:上下文胶囊、决策记录、知识压缩
72
+
73
+ ## 用 config.json 配置工作区
74
+
75
+ Peaks 读取两个位置的配置:
76
+
77
+ - 全局:`~/.peaks/config.json`
78
+ - 项目:`<project>/.peaks/config.json`
79
+
80
+ 项目配置优先;没有项目配置时,Peaks 回退到全局配置。工作区、当前工作区和运行时偏好都直接写进 `config.json`,后续命令会自动读取,不需要每次重复传 workspace 参数。
81
+
82
+ 项目级配置示例:
83
+
84
+ ```json
85
+ {
86
+ "currentWorkspace": "ice-cola",
87
+ "workspaces": [
88
+ {
89
+ "workspaceId": "ice-cola",
90
+ "name": "Ice Cola",
91
+ "rootPath": "C:/Users/smallMark/Desktop/peaksclaw/ice-cola",
92
+ "installedCapabilityIds": [],
93
+ "artifactRepo": {
94
+ "provider": "github",
95
+ "owner": "YOUR_ARTIFACT_REPO_OWNER",
96
+ "name": "YOUR_ARTIFACT_REPO_NAME"
97
+ }
98
+ }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ 如果你还需要用户级别的 provider 配置,把它放在全局 `~/.peaks/config.json`:
104
+
105
+ ```json
106
+ {
107
+ "providers": {
108
+ "minimax": {
109
+ "baseUrl": "https://api.minimaxi.com/anthropic",
110
+ "apiKey": "YOUR_MINIMAX_API_KEY"
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ 说明:
117
+
118
+ - `workspace.rootPath` 指向真实目标项目。
119
+ - `currentWorkspace` 决定当前启用哪一个 workspace。
120
+ - artifact repo 是中间产物仓库,不是目标代码仓库。
121
+ - 项目 `.peaks/config.json` 只放非敏感的工作区元数据;敏感凭据放全局配置。
122
+ - 中间产物不要写进目标仓库。
123
+
124
+ ## CLI 命令地图
125
+
126
+ 所有重要命令都支持 `--json`。会产生副作用的命令通常提供 `--dry-run` 预览和 `--apply` 或 `--confirm` 显式执行。
127
+
128
+ ### 健康检查、skills、profiles
129
+
130
+ ```bash
131
+ peaks doctor --json
132
+ peaks skill list --json
133
+ peaks skill doctor --json
134
+ peaks profile list --json
135
+ ```
136
+
137
+ 用途:检查 Peaks 运行环境、列出内置 skills、验证 skills 注册状态,并查看可用运行 profile。
138
+
139
+ ### 查看和验证配置
140
+
141
+ 如果你想确认 Peaks 读取到了什么,可以继续用 `doctor` 和 `config` 相关命令做检查,但配置本身直接写 `config.json` 就够了。
142
+
143
+ ```bash
144
+ peaks config get --json
145
+ peaks config get --key currentWorkspace --json
146
+ peaks config set --key language --value '"zh"' --layer user --json
147
+ peaks config workspace list --json
148
+ peaks config workspace add --id <id> --name <name> --path <project> --json
149
+ peaks config workspace switch --id <id> --json
150
+ peaks config workspace remove --id <id> --json
151
+ ```
152
+
153
+ ### MiniMax provider 与外部 worker
154
+
155
+ ```bash
156
+ export MINIMAX_API_KEY=<key>
157
+ peaks config provider minimax set --base-url <https-url> --json
158
+ peaks config provider minimax status --json
159
+ peaks config provider minimax get --json
160
+ peaks config provider minimax test --model MiniMax-M2.7 --json
161
+
162
+ peaks worker minimax \
163
+ --change-id <id> \
164
+ --goal "<目标>" \
165
+ --coding-task "<编码任务>" \
166
+ --unit-test-task "<测试任务>" \
167
+ --confirm \
168
+ --json
169
+ ```
170
+
171
+ MiniMax provider 配置只把敏感凭据写到用户层配置。Worker 是受控外部执行入口:输入必须可外发,输出默认视为不可信,需要再经过顶级模型 review。
172
+
173
+ ### Artifact workspace 与项目记忆
174
+
175
+ ```bash
176
+ peaks artifacts status --json
177
+ peaks artifacts init --provider github --name <repo> --path .peaks-artifacts --dry-run --json
178
+ peaks artifacts workspace --json
179
+ peaks artifacts sync --dry-run --json
180
+ peaks artifacts setup --step detect --json
181
+
182
+ peaks memory extract --project <project> --artifact <artifact-path> --dry-run --json
183
+ peaks memory extract --project <project> --artifact <artifact-path> --apply --json
184
+ peaks memory sync --project <project> --workspace <artifact-workspace> --dry-run --json
185
+ peaks memory sync --project <project> --workspace <artifact-workspace> --apply --json
186
+ ```
187
+
188
+ Artifact repo 用来保存 PRD、RD、QA、TXT、SC 等中间产物,不是目标代码仓库。Memory 命令只提取稳定、可复用的项目记忆,并带路径逃逸和密钥检测。
189
+
190
+ ### 用短命令产出计划
191
+
192
+ Peaks 推荐使用顶层短命令:一个动作对应一个命令,不需要记多层命令堆叠。
193
+
194
+ - `route` / `workflow route`:判断这次改动该走 solo 还是 team,输出路线图。
195
+ - `autonomous` / `workflow autonomous`:生成全自动治理链路预览。
196
+ - `tech-plan` / `tech plan`:把技术目标拆成 scan、document、review、reducer 等可审阅波次。
197
+ - `tech-status` / `tech status`:查看技术 artifact / approval 状态。
198
+ - `swarm-plan` / `swarm plan`:把 RD 范围拆成并行 worker 图、冲突组和质量门。
199
+ - `refactor`:输出 refactor gates、artifact 要求和覆盖率门槛,不直接改代码。
200
+ - `recommend`:根据 workflow 推荐外部 skills、MCP 或 Peaks 内置 fallback。
201
+ - `minimax-worker` / `worker minimax`:把明确小任务交给 MiniMax worker,并返回给顶级模型审查的交接结果。
202
+
203
+ 先写清楚目标,再让 Peaks 产出结构化结果,最后审查结果是否足够小、足够清楚、足够可验证。
204
+
205
+ ```bash
206
+ peaks route --mode solo --change-id <id> --goal "<目标>" --dry-run --json
207
+ peaks autonomous --mode solo --change-id <id> --goal "<目标>" --dry-run --json
208
+ peaks tech-plan --change-id <id> --goal "<目标>" --swarm --dry-run --json
209
+ peaks swarm-plan --change-id <id> --goal "<目标>" --dry-run --json
210
+ peaks refactor --solo --dry-run --json
211
+ peaks recommend --workflow code-refactor --language zh --json
212
+ peaks minimax-worker --change-id <id> --goal "<目标>" --coding-task "<编码任务>" --unit-test-task "<测试任务>" --confirm --json
213
+ ```
214
+
215
+
216
+ ### 项目规范 preflight
217
+
218
+ Peaks 可以为目标项目生成项目本地规范,并让 `peaks-rd`、`peaks-qa`、`peaks-solo` 在进入代码仓工作流前先检查这些规范。
219
+
220
+ ```bash
221
+ peaks standards init --project <project> --dry-run --json
222
+ peaks standards init --project <project> --apply --json
223
+ peaks standards update --project <project> --dry-run --json
224
+ peaks standards update --project <project> --apply --json
225
+ ```
226
+
227
+ 说明:
228
+
229
+ - `standards init` 用于首次创建 `CLAUDE.md` 和 `.claude/rules/**`。
230
+ - `standards update` 用于已有 `CLAUDE.md` 的项目:追加 Peaks 管理的规范索引,并只补齐缺失的 rules 文件。
231
+ - 如果已有 managed block 与当前模板不一致,命令会要求人工 review,并返回非零退出码。
232
+ - 对 `CLAUDE.md` 和 rules 的文件写入会检查项目边界,避免 symlink/path traversal 逃逸。
233
+
234
+ ### 推荐能力与能力可用性
235
+
236
+ ```bash
237
+ peaks capability status --json
238
+ peaks capability map --source all --json
239
+ peaks capabilities --source mcp-server --json
240
+
241
+ peaks recommend --workflow code-refactor --language zh --json
242
+ peaks recommend --workflow product-refactor --language zh --json
243
+ peaks recommend --workflow frontend-design --language zh --json
244
+ ```
245
+
246
+ 用途:帮助你决定是否应该调用外部 skills、MCP、hooks、agent browser、OpenSpec 等能力。Peaks 的立场是优先复用优秀外部能力;如果能力不可用,再回退到内置流程。
247
+
248
+ ### Source control 与变更追踪
249
+
250
+ ```bash
251
+ peaks sc status --json
252
+ peaks sc help
253
+
254
+ peaks sc impact \
255
+ --change-id ice-cola-marketplace \
256
+ --module admin-marketplace \
257
+ --module server-marketplace \
258
+ --file packages/admin/src/services/marketplaceApi.ts \
259
+ --file packages/server/src/marketplace/marketplace.service.ts \
260
+ --json
261
+
262
+ peaks sc retention \
263
+ --slice-id marketplace-api-contract \
264
+ --prd artifacts/prd.md \
265
+ --rd artifacts/rd.md \
266
+ --qa artifacts/qa.md \
267
+ --coverage artifacts/coverage.md \
268
+ --review artifacts/review.md \
269
+ --code packages/admin/src/services/marketplaceApi.ts \
270
+ --json
271
+
272
+ peaks sc boundary \
273
+ --slice-id marketplace-api-contract \
274
+ --artifact artifacts/prd.md \
275
+ --artifact artifacts/qa.md \
276
+ --code packages/admin/src/services/marketplaceApi.ts \
277
+ --json
278
+
279
+ peaks sc validate --slice-id marketplace-api-contract --json
280
+ ```
281
+
282
+ SC 命令负责把一次变更的影响范围、artifact 留存、代码边界和回滚点变成可审查记录。
283
+
284
+ ### 代理与网络辅助
285
+
286
+ ```bash
287
+ peaks proxy test --proxy http://127.0.0.1:7890 --target https://www.google.com --dry-run --json
288
+ ```
289
+
290
+ `proxy test` 只规划连通性测试,不直接执行网络探测。
291
+
292
+ ## 使用 skills 的方式
293
+
294
+ 如果你在 Claude Code 里工作,可以把 Peaks skills 当成角色化工作流:
295
+
296
+ - 先用 `peaks skill list --json` 看有哪些技能可用
297
+ - 最简单的用法就是在 Claude Code 里输入:`skill + 自然语言描述`
298
+ - 例如:
299
+
300
+ ```text
301
+ peaks-solo 使用全自动模式治理 C:/Users/smallMark/Desktop/peaksclaw/ice-cola
302
+ peaks-prd 为会员邀请功能整理产品目标、非目标和验收标准
303
+ peaks-rd 分析这次重构的最小实现切片和风险
304
+ peaks-qa 为这次改动设计测试和回归验证清单
305
+ ```
306
+
307
+ 按任务选择对应技能:
308
+ - `peaks-solo`:决定整体工作流模式
309
+ - `peaks-prd`:整理产品目标、非目标、验收标准
310
+ - `peaks-ui`:补充 UI/UX、交互和视觉约束
311
+ - `peaks-rd`:做工程分析、重构规划、执行契约
312
+ - `peaks-qa`:定义测试、覆盖率和回归
313
+ - `peaks-sc`:记录变更追踪、commit 边界、artifact 留存
314
+ - `peaks-txt`:压缩上下文、保留关键决策
315
+
316
+ 真实用户通常只需要知道怎么调用,不需要关心内部怎么实现。
317
+
318
+ 一个实用顺序是:
319
+
320
+ 1. 先熟悉项目
321
+ 2. 再产出 PRD / RD / QA / TXT
322
+ 3. 再生成 route / tech-plan / swarm-plan 计划
323
+ 4. 最后才进入受控执行
324
+
325
+ ## 推荐工作流
326
+
327
+ ### 既有项目重构
328
+
329
+ 1. `peaks doctor --json`
330
+ 2. `peaks config workspace list --json`
331
+ 3. `peaks artifacts workspace --json`
332
+ 4. 用 `peaks-txt` 生成上下文胶囊
333
+ 5. 用 `peaks-prd` 明确目标、非目标和验收标准
334
+ 6. 用 `peaks-rd` 熟悉项目结构、测试、脚本、关键模块和风险
335
+ 7. 用 `peaks-qa` 定义回归矩阵和覆盖率门禁
336
+ 8. UI 相关任务再引入 `peaks-ui`
337
+ 9. `peaks route --mode solo --solo-mode full-auto ... --dry-run --json`
338
+ 10. `peaks tech-plan ... --swarm --dry-run --json`
339
+ 11. `peaks swarm-plan ... --dry-run --json`
340
+ 12. 必要时使用 `peaks minimax-worker ... --confirm --json`
341
+ 13. 最后做 code review / security review / TypeScript review
342
+ 14. 用 `peaks-sc` 记录 impact、retention、boundary
343
+
344
+ ### 新增功能
345
+
346
+ 1. 先熟悉项目:README、package scripts、路由、服务层、测试、数据模型、当前 git 状态
347
+ 2. `peaks-prd` 输出功能目标、用户价值、验收标准和非目标
348
+ 3. `peaks-rd` 找到最小实现切片和受影响模块
349
+ 4. `peaks-qa` 定义新增测试和回归测试
350
+ 5. 再进入 `route` 或 `autonomous` 计划
351
+ 6. 受控执行前,确认 artifact workspace 在目标 repo 外部
352
+ 7. 实现、单测、build、review、安全检查全部完成后再进入下一步
353
+
354
+ ### 修 bug
355
+
356
+ 1. 先复现或定位 bug
357
+ 2. 熟悉相关模块、调用链、测试和已有约定
358
+ 3. `peaks-rd` 生成 root cause、修复策略和回归风险
359
+ 4. `peaks-qa` 定义失败用例和验收条件
360
+ 5. 先补失败测试,再做最小修复
361
+ 6. 跑聚焦测试和相关 build
362
+ 7. 再做 code / security / TypeScript review
363
+ 8. 用 `peaks-sc` 记录影响范围和边界
364
+
365
+ ## 开发、测试和发布包内容
366
+
367
+ 本仓库是 TypeScript + Commander + Vitest 项目。
368
+
369
+ ```bash
370
+ pnpm install
371
+ pnpm run dev -- --help
372
+ pnpm run dev:watch
373
+ pnpm run typecheck
374
+ pnpm test
375
+ pnpm run test:coverage
376
+ pnpm run build
377
+ ```
378
+
379
+ 说明:
380
+
381
+ - `scripts/install-skills.mjs` 会把 `skills/peaks-*` 以 symlink 注册到 Claude skills 目录。
382
+ - `scripts/watch.mjs` 监听 `src/`、`schemas/`、`skills/`,构建后重新安装 skills。
383
+ - npm 包包含 `bin/peaks.js`、编译后的 `dist/src/**`、`scripts/**`、`skills/**` 和 `schemas/*.json`。
384
+ - 单元测试覆盖服务逻辑、CLI 分支、路径安全、配置脱敏、MiniMax provider、artifact workspace、standards、memory、SC 和 workflow planning。
385
+ - E2E 脚本覆盖 artifact、config、SC 的核心命令链路。
386
+
387
+ ## JSON 输出
388
+
389
+ 大多数 CLI 命令都支持 `--json`。建议自动化场景总是使用它,因为输出是稳定的 envelope:
390
+
391
+ ```json
392
+ {
393
+ "ok": true,
394
+ "command": "workflow.route",
395
+ "data": {},
396
+ "warnings": [],
397
+ "nextActions": []
398
+ }
399
+ ```
400
+
401
+ ## 安全边界
402
+
403
+ - 不要把 secrets 写进 project config 或 artifacts。
404
+ - provider URL 必须使用可信 allowlist 和 HTTPS。
405
+ - 既有项目不要跳过熟悉阶段。
406
+ - 重构需要测试、覆盖率和验收面。
407
+ - 中间 artifacts 应存放在目标仓库外部。
408
+ - 修改远端、创建仓库、推送代码、改共享配置都需要显式确认。
409
+ - MiniMax worker 等外部 provider 调用必须确认输入可外发。
410
+
411
+ ## 许可
412
+
413
+ 本仓库使用闭源非商用许可,详见 [LICENSE](LICENSE)。未经版权持有人事先书面许可,禁止商业使用、禁止商业目的的修改,禁止商业目的的分发、再授权、销售、托管、打包或捆绑。
414
+
415
+ ## 设计立场
416
+
417
+ Peaks 与 cc-switch 等工具共存,不修改 cc-switch 状态。Peaks 只通过 Peaks 管理的状态、dry-run 计划、备份和可回滚 sync 来管理 Claude global skills、MCP、hooks、agents 和 profiles。
package/bin/peaks.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/src/cli/index.js';
@@ -0,0 +1,25 @@
1
+ import { Command } from 'commander';
2
+ import { getErrorMessage, ok, redactSensitiveErrorMessage, type ResultEnvelope } from '../shared/result.js';
3
+ import type { ArtifactProvider, GuidedArtifactSetup } from '../services/artifacts/artifact-service.js';
4
+ import type { ConfigLayer } from '../services/config/config-service.js';
5
+ import type { MiniMaxProviderSmokeResult } from '../services/providers/minimax-provider-service.js';
6
+ import type { MiniMaxWorkerResult } from '../services/providers/minimax-worker-service.js';
7
+ import type { RecommendationWorkflow } from '../services/recommendations/recommendation-service.js';
8
+ export type ProgramIO = {
9
+ stdout: (text: string) => void;
10
+ stderr: (text: string) => void;
11
+ };
12
+ export declare function printResult<T>(io: ProgramIO, result: ResultEnvelope<T>, asJson?: boolean): void;
13
+ export declare function addJsonOption(command: Command): Command;
14
+ export declare function failUnsupportedNonDryRun(io: ProgramIO, command: string, asJson?: boolean): void;
15
+ export declare function isRecommendationWorkflow(value: string): value is RecommendationWorkflow;
16
+ export declare function isArtifactProvider(value: string): value is ArtifactProvider;
17
+ export declare function isArtifactSetupStep(value: string): value is GuidedArtifactSetup['step'];
18
+ export declare function isArtifactRepoSegment(value: string): boolean;
19
+ export declare function isMiniMaxHttpsUrl(value: string): boolean;
20
+ export declare function parseConfigLayer(value: string | undefined): ConfigLayer | undefined | null;
21
+ export declare function printInvalidConfigLayer(io: ProgramIO, command: string, asJson?: boolean): void;
22
+ export declare function multipleOption(value: string, previous: string[]): string[];
23
+ export declare function summarizeMiniMaxSmokeResult(result: MiniMaxProviderSmokeResult): MiniMaxProviderSmokeResult;
24
+ export declare function summarizeMiniMaxWorkerResult(result: MiniMaxWorkerResult): MiniMaxWorkerResult;
25
+ export { getErrorMessage, ok, redactSensitiveErrorMessage };
@@ -0,0 +1,78 @@
1
+ import { fail, getErrorMessage, ok, redactSensitiveErrorMessage } from '../shared/result.js';
2
+ const MINIMAX_API_HOST = 'api.minimaxi.com';
3
+ export function printResult(io, result, asJson = false) {
4
+ if (asJson) {
5
+ io.stdout(JSON.stringify(result, null, 2));
6
+ return;
7
+ }
8
+ if (!result.ok) {
9
+ io.stderr(`${result.code}: ${result.message}`);
10
+ for (const action of result.nextActions) {
11
+ io.stderr(`- ${action}`);
12
+ }
13
+ return;
14
+ }
15
+ io.stdout(JSON.stringify(result.data, null, 2));
16
+ for (const warning of result.warnings) {
17
+ io.stderr(`warning: ${warning}`);
18
+ }
19
+ for (const action of result.nextActions) {
20
+ io.stdout(`next: ${action}`);
21
+ }
22
+ }
23
+ export function addJsonOption(command) {
24
+ return command.option('--json', 'print machine-readable JSON envelope');
25
+ }
26
+ export function failUnsupportedNonDryRun(io, command, asJson) {
27
+ printResult(io, fail(command, 'UNSUPPORTED_NON_DRY_RUN', 'Only dry-run planning is supported', {}, ['Rerun with --dry-run or omit --no-dry-run']), asJson);
28
+ process.exitCode = 1;
29
+ }
30
+ export function isRecommendationWorkflow(value) {
31
+ return value === 'code-refactor' || value === 'product-refactor' || value === 'frontend-design';
32
+ }
33
+ export function isArtifactProvider(value) {
34
+ return value === 'github' || value === 'gitlab';
35
+ }
36
+ export function isArtifactSetupStep(value) {
37
+ return value === 'detect' || value === 'configure' || value === 'validate' || value === 'complete';
38
+ }
39
+ export function isArtifactRepoSegment(value) {
40
+ return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(value) && !value.includes('..') && !value.endsWith('.');
41
+ }
42
+ export function isMiniMaxHttpsUrl(value) {
43
+ try {
44
+ const url = new URL(value);
45
+ return url.protocol === 'https:' && url.hostname === MINIMAX_API_HOST && url.username.length === 0 && url.password.length === 0 && url.search.length === 0 && url.hash.length === 0;
46
+ }
47
+ catch {
48
+ return false;
49
+ }
50
+ }
51
+ export function parseConfigLayer(value) {
52
+ if (value === undefined) {
53
+ return undefined;
54
+ }
55
+ return value === 'user' || value === 'project' ? value : null;
56
+ }
57
+ export function printInvalidConfigLayer(io, command, asJson) {
58
+ printResult(io, fail(command, 'INVALID_CONFIG_LAYER', 'Config layer must be user or project', {}, ['Use --layer user or --layer project']), asJson);
59
+ process.exitCode = 1;
60
+ }
61
+ export function multipleOption(value, previous) {
62
+ return [...(previous || []), value];
63
+ }
64
+ export function summarizeMiniMaxSmokeResult(result) {
65
+ return { ...result, responseText: null, summary: null };
66
+ }
67
+ export function summarizeMiniMaxWorkerResult(result) {
68
+ const provider = summarizeMiniMaxSmokeResult(result.provider);
69
+ return {
70
+ ...result,
71
+ provider,
72
+ reviewHandoff: {
73
+ model: result.reviewHandoff.model,
74
+ prompt: '[redacted]'
75
+ }
76
+ };
77
+ }
78
+ export { getErrorMessage, ok, redactSensitiveErrorMessage };
@@ -0,0 +1,5 @@
1
+ import { Command } from 'commander';
2
+ import type { PeaksConfig } from '../../services/config/config-types.js';
3
+ import { type ProgramIO } from '../cli-helpers.js';
4
+ export declare function registerCapabilityCommands(program: Command, io: ProgramIO): void;
5
+ export declare function getInstalledCapabilityIds(config: PeaksConfig): string[];
@@ -0,0 +1,46 @@
1
+ import { readConfig } from '../../services/config/config-service.js';
2
+ import { resolveCapabilityAvailability } from '../../services/recommendations/capability-availability.js';
3
+ import { createCapabilityMapPlan } from '../../services/recommendations/capability-map-service.js';
4
+ import { seedCapabilityItems, seedCapabilitySources } from '../../services/recommendations/seed-capability-catalog.js';
5
+ import { fail, ok } from '../../shared/result.js';
6
+ import { addJsonOption, printResult } from '../cli-helpers.js';
7
+ const CAPABILITY_SOURCE_FILTERS = new Set(['all', 'access-repo', 'mcp-server']);
8
+ export function registerCapabilityCommands(program, io) {
9
+ const capability = program.command('capability').description('Inspect Peaks capability catalog and runtime availability');
10
+ addJsonOption(capability.command('status').description('Show seed capability availability')).action((options) => {
11
+ const availability = resolveCapabilityAvailability(seedCapabilityItems);
12
+ printResult(io, ok('capability.status', { sources: seedCapabilitySources, items: seedCapabilityItems, availability }), options.json);
13
+ });
14
+ addCapabilityMapOptions(capability.command('map').description('Show dry-run external capability landing map')).action((options) => runCapabilityMap(io, options));
15
+ addCapabilityMapOptions(program.command('capabilities').description('Show dry-run external capability landing map')).action((options) => runCapabilityMap(io, options));
16
+ }
17
+ function addCapabilityMapOptions(command) {
18
+ return addJsonOption(command.option('--source <source>', 'Filter source group: all, access-repo, or mcp-server', 'all'));
19
+ }
20
+ function runCapabilityMap(io, options) {
21
+ const source = parseCapabilityMapSource(options.source);
22
+ if (!source) {
23
+ printResult(io, fail('capabilities.map', 'UNSUPPORTED_CAPABILITY_SOURCE', 'Supported capability sources are all, access-repo, and mcp-server', { source: options.source }, ['Rerun with --source all, --source access-repo, or --source mcp-server']), options.json);
24
+ process.exitCode = 1;
25
+ return;
26
+ }
27
+ const config = readConfig();
28
+ const installedCapabilityIds = getInstalledCapabilityIds(config);
29
+ printResult(io, ok('capabilities.map', createCapabilityMapPlan({
30
+ source,
31
+ installedCapabilityIds,
32
+ ...(config.proxy.httpProxy === undefined ? {} : { httpProxy: config.proxy.httpProxy })
33
+ })), options.json);
34
+ }
35
+ export function getInstalledCapabilityIds(config) {
36
+ const currentWorkspace = config.workspaces.find((workspace) => workspace.workspaceId === config.currentWorkspace);
37
+ if (!currentWorkspace)
38
+ return [];
39
+ return [...currentWorkspace.installedCapabilityIds];
40
+ }
41
+ function parseCapabilityMapSource(source) {
42
+ if (CAPABILITY_SOURCE_FILTERS.has(source)) {
43
+ return source;
44
+ }
45
+ return null;
46
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ import type { ProgramIO } from '../cli-helpers.js';
3
+ export declare function registerCapabilityWorkerConfigAndSCCommands(program: Command, io: ProgramIO): void;
@@ -0,0 +1,10 @@
1
+ import { registerCapabilityCommands } from './capability-commands.js';
2
+ import { registerConfigCommands } from './config-commands.js';
3
+ import { registerSCCommands } from './sc-commands.js';
4
+ import { registerWorkerCommands } from './worker-commands.js';
5
+ export function registerCapabilityWorkerConfigAndSCCommands(program, io) {
6
+ registerCapabilityCommands(program, io);
7
+ registerWorkerCommands(program, io);
8
+ registerConfigCommands(program, io);
9
+ registerSCCommands(program, io);
10
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ import { type ProgramIO } from '../cli-helpers.js';
3
+ export declare function registerConfigCommands(program: Command, io: ProgramIO): void;