@namewta/speculo 1.0.19 → 1.0.21

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 (194) hide show
  1. package/README.md +8 -7
  2. package/THIRD-PARTY-NOTICES.md +33 -0
  3. package/dist/src/agent-files.js +2 -2
  4. package/dist/src/agent-files.js.map +1 -1
  5. package/dist/src/agent-skills.d.ts +81 -0
  6. package/dist/src/agent-skills.js +530 -0
  7. package/dist/src/agent-skills.js.map +1 -0
  8. package/dist/src/cli.js +11 -3
  9. package/dist/src/cli.js.map +1 -1
  10. package/dist/src/config.js +5 -3
  11. package/dist/src/config.js.map +1 -1
  12. package/dist/src/doctor.js +7 -2
  13. package/dist/src/doctor.js.map +1 -1
  14. package/dist/src/index.d.ts +8 -0
  15. package/dist/src/index.js +23 -3
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/manifest.d.ts +9 -0
  18. package/dist/src/manifest.js +45 -7
  19. package/dist/src/manifest.js.map +1 -1
  20. package/dist/src/refresh.js +40 -0
  21. package/dist/src/refresh.js.map +1 -1
  22. package/dist/src/structured.js +15 -4
  23. package/dist/src/structured.js.map +1 -1
  24. package/dist/src/transaction.d.ts +24 -3
  25. package/dist/src/transaction.js +191 -12
  26. package/dist/src/transaction.js.map +1 -1
  27. package/package.json +7 -4
  28. package/scripts/validate-skills.mjs +56 -0
  29. package/template/AGENTS.md +1 -1
  30. package/template/CLAUDE.md +1 -1
  31. package/template/canonical/canonical-specdev-goal-plan.md +156 -28
  32. package/template/canonical/canonical-specdev-grill-with-docs.md +153 -31
  33. package/template/canonical/canonical-specdev-spec.md +153 -27
  34. package/template/canonical/canonical-specdev-tickets.md +153 -27
  35. package/template/canonical/canonical-specdev-wayfinder.md +142 -27
  36. package/template/commands/retro.md +11 -9
  37. package/template/skills/archive-and-consolidate/SKILL.md +163 -7
  38. package/template/skills/archive-and-consolidate/references/cleanup-rules.md +1 -1
  39. package/template/skills/docs-sync/references/agents/claude-redirect.md +8 -8
  40. package/template/skills/docs-sync/references/agents/content-contract.md +1 -1
  41. package/template/skills/docs-sync/references/agents/manifest-discovery.md +7 -7
  42. package/template/skills/docs-sync/references/agents/role-classification.md +4 -4
  43. package/template/skills/docs-sync/references/agents-contract.md +1 -1
  44. package/template/skills/engineering-standards-builder/SKILL.md +149 -9
  45. package/template/skills/engineering-standards-builder/agents/openai.yaml +2 -0
  46. package/template/skills/engineering-standards-builder/manifest.txt +2 -1
  47. package/template/skills/engineering-standards-builder/references/rules/09-mechanical-guardrails.md +9 -0
  48. package/template/skills/engineering-standards-builder/scripts/validate-builder.mjs +4 -7
  49. package/template/skills/git-history-squash/SKILL.md +87 -11
  50. package/template/skills/git-history-squash/agents/openai.yaml +2 -0
  51. package/template/skills/optimize-codex-config/SKILL.md +71 -11
  52. package/template/skills/{speculo-retro/references/entry-procedure.md → retrospective/SKILL.md} +12 -8
  53. package/template/skills/{speculo-retro → retrospective}/references/friction-taxonomy.md +22 -13
  54. package/template/skills/{speculo-retro → retrospective}/references/issue-drafting-sop.md +10 -20
  55. package/template/skills/source-code-zip/SKILL.md +44 -8
  56. package/template/skills/source-code-zip/references/{entry-procedure.md → cli-reference.md} +0 -43
  57. package/template/skills/upstream-fork-sync/SKILL.md +71 -8
  58. package/template/skills/{writing-great-skills → writing-for-agents}/GLOSSARY.md +1 -1
  59. package/template/skills/writing-for-agents/SKILL.md +22 -0
  60. package/template/skills/writing-for-agents/agents/openai.yaml +2 -0
  61. package/template/skills/{writing-great-skills/references/entry-procedure.md → writing-for-agents/references/authoring-principles.md} +2 -9
  62. package/template/workflows/ops/D-project-deploy/D-project-deploy.md +1 -1
  63. package/template/workflows/ops/H-host-manage/H-host-manage.md +4 -0
  64. package/template/workflows/ops/H-host-manage/references/host-profiles.md +4 -0
  65. package/template/workflows/ops/I-initialize/I-initialize.md +1 -1
  66. package/template/workflows/ops/INDEX.md +2 -0
  67. package/template/workflows/ops/README.md +7 -3
  68. package/template/workflows/ops/S-server-connect/S-server-connect.md +5 -5
  69. package/template/workflows/ops/V-inventory-view/V-inventory-view.md +2 -0
  70. package/template/workflows/ops/common/CAPABILITIES.md +2 -0
  71. package/template/workflows/ops/common/USAGE.md +5 -5
  72. package/template/workflows/ops/common/WORKSPACE-USAGE.md +29 -2
  73. package/template/workflows/ops/common/examples/README.md +1 -1
  74. package/template/workflows/ops/common/examples/register.example.json +7 -3
  75. package/template/workflows/ops/common/examples/server-connection.example.json +11 -0
  76. package/template/workflows/ops/common/rules/deployment-layout.md +1 -1
  77. package/template/workflows/ops/common/rules/host-root-and-onboarding.md +47 -0
  78. package/template/workflows/ops/common/rules/persistence-and-secrets.md +1 -1
  79. package/template/workflows/ops/common/rules/research-and-decisions.md +8 -0
  80. package/template/workflows/ops/common/rules/server-onboarding.md +3 -3
  81. package/template/workflows/ops/common/rules/workspace-and-authorization.md +2 -2
  82. package/template/workflows/ops/common/schemas/fleet-view.schema.json +64 -0
  83. package/template/workflows/ops/common/schemas/host.schema.json +19 -0
  84. package/template/workflows/ops/common/schemas/plan.schema.json +57 -0
  85. package/template/workflows/ops/common/schemas/root-confirmation.schema.json +118 -0
  86. package/template/workflows/ops/common/schemas/server-connection.schema.json +67 -0
  87. package/template/workflows/ops/common/schemas/server-discovery.schema.json +171 -0
  88. package/template/workflows/ops/common/schemas/spec.schema.json +19 -0
  89. package/template/workflows/ops/common/schemas/status.schema.json +19 -0
  90. package/template/workflows/ops/common/templates/FLEET.html +1 -1
  91. package/template/workflows/ops/common/templates/HOST-README.md +3 -1
  92. package/template/workflows/ops/common/tests/test_ops.mjs +8 -11
  93. package/template/workflows/ops/common/tests/test_ops_bootstrap.mjs +101 -16
  94. package/template/workflows/ops/common/tests/test_ops_onboarding.mjs +225 -0
  95. package/template/workflows/ops/common/tests/test_ops_workspace.mjs +17 -8
  96. package/template/workflows/ops/common/tools/demo-local.mjs +4 -0
  97. package/template/workflows/ops/common/tools/opslib/agent.mjs +26 -0
  98. package/template/workflows/ops/common/tools/opslib/bootstrap.mjs +52 -26
  99. package/template/workflows/ops/common/tools/opslib/cli.mjs +1 -0
  100. package/template/workflows/ops/common/tools/opslib/core.mjs +1 -1
  101. package/template/workflows/ops/common/tools/opslib/docs.mjs +1 -0
  102. package/template/workflows/ops/common/tools/opslib/execution.mjs +4 -0
  103. package/template/workflows/ops/common/tools/opslib/fleet.mjs +26 -4
  104. package/template/workflows/ops/common/tools/opslib/host_recipes.mjs +34 -0
  105. package/template/workflows/ops/common/tools/opslib/model.mjs +6 -0
  106. package/template/workflows/ops/common/tools/opslib/onboarding.mjs +215 -0
  107. package/template/workflows/ops/common/tools/opslib/planner.mjs +3 -0
  108. package/template/workflows/ops/common/tools/opslib/transport.mjs +10 -6
  109. package/template/workflows/ops/common/tools/opslib/workspace_cli.mjs +20 -1
  110. package/template/workflows/ops/common/tools/server-discover.sh +65 -0
  111. package/template/workflows/ops/common/tools/validate-ops.mjs +1 -1
  112. package/template/workflows/ops/manifest.json +12 -5
  113. package/template/workflows/specdev/A-archive-and-consolidate/consolidation-interview.md +3 -3
  114. package/template/workflows/specdev/C-code-review/C-code-review.md +1 -1
  115. package/template/workflows/specdev/D-diagnose-bugs/D-diagnose-bugs.md +6 -0
  116. package/template/workflows/specdev/G-grill-with-docs/references/interview-procedure.md +6 -6
  117. package/template/workflows/specdev/I-implement/references/implementation-procedure.md +1 -1
  118. package/template/workflows/specdev/I-implement/tdd-rules.md +4 -0
  119. package/template/workflows/specdev/I-init-setup/config-template.json +5 -1
  120. package/template/workflows/specdev/INDEX.md +2 -2
  121. package/template/workflows/specdev/P-goal-plan/planning-modes.md +1 -1
  122. package/template/workflows/specdev/P-prototype/P-prototype.md +7 -3
  123. package/template/workflows/specdev/P-prototype/logic-protocol.md +11 -0
  124. package/template/workflows/specdev/P-prototype/logic-template.md +27 -0
  125. package/template/workflows/specdev/P-prototype/project-preview-protocol.md +9 -0
  126. package/template/workflows/specdev/R-retro/R-retro.md +26 -0
  127. package/template/workflows/specdev/R-retro/retro-template.md +27 -0
  128. package/template/workflows/specdev/R-review-architecture/references/selected-design.md +1 -1
  129. package/template/workflows/specdev/README.md +13 -2
  130. package/template/workflows/specdev/S-spec/S-spec.md +4 -0
  131. package/template/workflows/specdev/T-tickets/T-tickets.md +4 -0
  132. package/template/workflows/specdev/T-triage/T-triage.md +31 -25
  133. package/template/workflows/specdev/T-triage/capture-protocol.md +1 -1
  134. package/template/workflows/specdev/T-triage/ci-security-protocol.md +11 -0
  135. package/template/workflows/specdev/T-triage/intake-protocol.md +10 -4
  136. package/template/workflows/specdev/T-triage/pr-delivery-protocol.md +13 -0
  137. package/template/workflows/specdev/T-triage/pr-record-template.md +39 -0
  138. package/template/workflows/specdev/T-triage/publish-protocol.md +1 -1
  139. package/template/workflows/specdev/T-triage/queue-protocol.md +7 -0
  140. package/template/workflows/specdev/T-triage/reconcile-protocol.md +1 -1
  141. package/template/workflows/specdev/T-triage/references/issue-pr-policy.md +23 -0
  142. package/template/workflows/specdev/T-triage/references/release-authentication.md +9 -0
  143. package/template/workflows/specdev/T-triage/references/release-notes-injection.md +21 -0
  144. package/template/workflows/specdev/T-triage/references/workflow-yaml-reference.md +37 -0
  145. package/template/workflows/specdev/T-triage/release-preflight.md +13 -0
  146. package/template/workflows/specdev/T-triage/release-protocol.md +12 -0
  147. package/template/workflows/specdev/T-triage/release-recovery.md +18 -0
  148. package/template/workflows/specdev/T-triage/remote-operations.md +25 -0
  149. package/template/workflows/specdev/T-triage/scripts/github-transport.mjs +208 -0
  150. package/template/workflows/specdev/T-triage/source-template.md +7 -0
  151. package/template/workflows/specdev/T-triage/triage-run-template.md +34 -0
  152. package/template/workflows/specdev/T-triage/triage-template.md +4 -1
  153. package/template/workflows/specdev/common/rules/artifact-contract.md +7 -0
  154. package/template/workflows/specdev/common/rules/change-completion.md +6 -0
  155. package/template/workflows/specdev/common/rules/workflow-routing.md +6 -0
  156. package/template/workflows/specdev/common/rules/workflow-state-and-lifecycle.md +1 -1
  157. package/template/workflows/specdev/common/schemas/config.schema.json +137 -26
  158. package/template/workflows/specdev/common/schemas/logic-prototype.schema.json +62 -0
  159. package/template/workflows/specdev/common/schemas/pull-request.schema.json +90 -0
  160. package/template/workflows/specdev/common/schemas/retrospective.schema.json +58 -0
  161. package/template/workflows/specdev/common/schemas/triage-run.schema.json +149 -0
  162. package/template/workflows/specdev/common/schemas/triage.schema.json +117 -15
  163. package/template/workflows/specdev/common/tools/delivery-artifacts.mjs +95 -0
  164. package/template/workflows/specdev/common/tools/validate-specdev.mjs +60 -19
  165. package/template/workflows/specdev/runtime-contract.json +4 -2
  166. package/template/skills/archive-and-consolidate/references/entry-procedure.md +0 -178
  167. package/template/skills/docs-sync/references/entry-procedure.md +0 -3
  168. package/template/skills/engineering-standards-builder/references/entry-procedure.md +0 -154
  169. package/template/skills/git-history-squash/references/entry-procedure.md +0 -94
  170. package/template/skills/github-npm-ops/SKILL.md +0 -19
  171. package/template/skills/github-npm-ops/references/ci-and-security-ops.md +0 -178
  172. package/template/skills/github-npm-ops/references/entry-procedure.md +0 -25
  173. package/template/skills/github-npm-ops/references/failure-recovery.md +0 -123
  174. package/template/skills/github-npm-ops/references/issue-pr-triage.md +0 -227
  175. package/template/skills/github-npm-ops/references/issue-transport.md +0 -26
  176. package/template/skills/github-npm-ops/references/package-json-checklist.md +0 -171
  177. package/template/skills/github-npm-ops/references/preflight-checklist.md +0 -39
  178. package/template/skills/github-npm-ops/references/publish-detection.md +0 -68
  179. package/template/skills/github-npm-ops/references/release-notes-injection.md +0 -238
  180. package/template/skills/github-npm-ops/references/release-pipeline.md +0 -108
  181. package/template/skills/github-npm-ops/references/setup-npm-token.md +0 -63
  182. package/template/skills/github-npm-ops/references/troubleshooting-playbook.md +0 -293
  183. package/template/skills/github-npm-ops/references/version-bump-flow.md +0 -217
  184. package/template/skills/github-npm-ops/references/workflow-yaml-reference.md +0 -268
  185. package/template/skills/github-npm-ops/scripts/issue-transport.mjs +0 -227
  186. package/template/skills/optimize-codex-config/references/entry-procedure.md +0 -78
  187. package/template/skills/speculo-retro/SKILL.md +0 -19
  188. package/template/skills/upstream-fork-sync/references/entry-procedure.md +0 -78
  189. package/template/skills/writing-great-skills/SKILL.md +0 -23
  190. /package/template/skills/{writing-great-skills → writing-for-agents}/references/document-contract.md +0 -0
  191. /package/template/workflows/specdev/{G-grill-with-docs → common/rules}/adr-format.md +0 -0
  192. /package/template/workflows/specdev/{G-grill-with-docs → common/rules}/context-format.md +0 -0
  193. /package/template/workflows/specdev/{I-implement → common/rules}/design-it-twice.md +0 -0
  194. /package/template/workflows/specdev/{G-grill-with-docs/domain-modeling-rules.md → common/rules/domain-modeling.md} +0 -0
@@ -1,63 +0,0 @@
1
- # 配置 npm Token 与 GitHub Secret
2
-
3
- npm 现在强制要求发布时通过 2FA 或等效机制。Classic token 在多数账号设置下会返回 `E403`,必须改用 **Granular Access Token**。
4
-
5
- ## 生成 Granular Access Token
6
-
7
- 1. 登录 [npmjs.com](https://www.npmjs.com),点头像 → **Access Tokens**
8
- 2. 点 **Generate New Token** → 选择 **Granular Access Token**
9
- 3. 关键字段:
10
-
11
- | 字段 | 推荐值 |
12
- | ----------------------- | ------------------------------------------------------------------------------------------ |
13
- | Token name | `<package>-ci-release`(可识别用途) |
14
- | Expiration | 90–365 天;设提醒到期前轮换 |
15
- | Packages and scopes | 选 `Only select packages and scopes`,勾选目标包或整个 scope(如 `@scope`) |
16
- | Permissions | **Read and write** |
17
- | Allowed organizations | 如果在组织下发布,勾选对应组织 |
18
- | Bypass two-factor auth | 勾选(CI 无法交互完成 2FA) |
19
- | Allowed IP ranges | 留空(GitHub Actions runner IP 不固定) |
20
-
21
- 4. 点 **Generate**,**立刻复制** token,关掉页面就再也看不到了
22
-
23
- ## 配置到 GitHub Secret
24
-
25
- 1. 仓库 → **Settings** → **Secrets and variables** → **Actions**
26
- 2. 点 **New repository secret**
27
- 3. `Name: NPM_TOKEN`,`Value: <粘贴 token>`
28
- 4. 点 **Add secret**
29
-
30
- ## 在 workflow 中引用
31
-
32
- ```yaml
33
- - name: Publish to npm
34
- run: npm publish --provenance --access public
35
- env:
36
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
37
- ```
38
-
39
- 重点:变量名必须是 `NODE_AUTH_TOKEN`(`actions/setup-node` 约定),不是 `NPM_TOKEN`。Secret 的名字可以是 `NPM_TOKEN`,但要映射过来。
40
-
41
- ## 验证 token 生效
42
-
43
- 本地不需要这个 token,它只在 CI 使用。如果想本地预演:
44
-
45
- ```bash
46
- echo "//registry.npmjs.org/:_authToken=<token>" >> ~/.npmrc
47
- npm whoami # 应返回你的 npm 用户名
48
- npm publish --dry-run --access public
49
- ```
50
-
51
- 预演完记得把 `.npmrc` 里的这行删掉。
52
-
53
- ## 轮换策略
54
-
55
- - Token 到期前 7 天收到邮件提醒
56
- - 轮换步骤:生成新 token → 更新 GitHub Secret → 在 npm 上 revoke 旧 token
57
- - 如果怀疑泄露:立即在 npm Access Tokens 页面点 **Revoke**,workflow 会在下次运行时失败,再补生成新 token
58
-
59
- ## 常见误区
60
-
61
- - **不要用 Classic Token 的 `Automation` 类型** — 某些账号策略下仍会触发 2FA 检查
62
- - **不要把 token 写进 `.npmrc` 提交** — 只能走 `secrets`
63
- - **不要与个人 publish token 混用** — CI 用专用 token,出问题可独立撤销
@@ -1,293 +0,0 @@
1
- # Release 故障排查手册
2
-
3
- 基于真实失败记录的排查流程。遇到问题先按这个顺序走。
4
-
5
- ## 统一诊断流程
6
-
7
- ```bash
8
- # 1. 找到失败的 run
9
- gh run list --workflow release.yml --limit 5 \
10
- --json databaseId,conclusion,displayTitle
11
-
12
- # 2. 查看失败步骤的日志
13
- gh run view <databaseId> --log-failed 2>&1 \
14
- | grep -E "npm error|npm warn publish|##\[error\]|Error:" \
15
- | head -30
16
-
17
- # 3. 按下面的错误表对应修复
18
- ```
19
-
20
- ## 错误分类与修复
21
-
22
- ### 1. `E404 Not Found - PUT /<pkg>`
23
-
24
- ```
25
- npm error code E404
26
- npm error 404 Not Found - PUT https://registry.npmjs.org/my-cli
27
- npm error 404 The requested resource 'my-cli@0.0.2' could not be found
28
- or you do not have permission to access it.
29
- ```
30
-
31
- **两种原因:**
32
-
33
- - **包名被占用**:别人已注册这个名字,你没权限写入
34
- - **私有包但未创建 scope/org**:scope 不存在
35
-
36
- **诊断:**
37
-
38
- ```bash
39
- npm view <pkg-name> # 有内容说明被占
40
- npm owner ls <pkg-name> # 看当前 owner
41
- ```
42
-
43
- **修复:**
44
-
45
- - 改用 scoped 包名:`@yourname/pkg-name`
46
- - 同步更新 `package.json` 的 `name` 字段
47
- - 若要用现有名字:联系当前 owner 做 transfer,或走 `npm support`
48
-
49
- ### 2. `E403 Two-factor authentication required`
50
-
51
- ```
52
- npm error code E403
53
- npm error 403 403 Forbidden - PUT https://registry.npmjs.org/@scope%2fmy-cli
54
- - Two-factor authentication or granular access token
55
- with bypass 2fa enabled is required to publish packages.
56
- ```
57
-
58
- **原因:** 使用了 Classic Token 或未开启 2FA bypass 的 Granular Token。
59
-
60
- **修复:**
61
-
62
- 1. npm → Access Tokens → **Generate New Token** → **Granular Access Token**
63
- 2. 勾选 **Bypass two-factor authentication**
64
- 3. 选择目标包或 scope,permission 为 **Read and write**
65
- 4. 复制新 token,更新 GitHub Secret `NPM_TOKEN`
66
- 5. 重新触发 workflow(删旧 tag 重推)
67
-
68
- 详见 [setup-npm-token.md](./setup-npm-token.md)。
69
-
70
- ### 3. `EUSAGE Can't generate provenance for new or private package`
71
-
72
- ```
73
- npm error code EUSAGE
74
- npm error Can't generate provenance for new or private package,
75
- you must set `access` to public.
76
- ```
77
-
78
- **原因:** Scoped 包默认 private,首次发布未加 `--access public`。
79
-
80
- **修复:**
81
-
82
- ```yaml
83
- - run: npm publish --provenance --access public
84
- ```
85
-
86
- ### 4. `E422 Error verifying sigstore provenance bundle`
87
-
88
- ```
89
- npm error code E422
90
- npm error 422 Unprocessable Entity - PUT https://registry.npmjs.org/@scope%2fmy-cli
91
- - Error verifying sigstore provenance bundle:
92
- Failed to validate repository information:
93
- package.json: "repository.url" is "", expected to match
94
- "https://github.com/owner/my-cli" from provenance
95
- ```
96
-
97
- **原因:** `package.json` 缺 `repository.url`,或值与实际 GitHub 仓库不匹配。
98
-
99
- **修复:**
100
-
101
- ```json
102
- {
103
- "repository": {
104
- "type": "git",
105
- "url": "https://github.com/owner/my-cli"
106
- }
107
- }
108
- ```
109
-
110
- - URL 不要带 `.git` 后缀也能通过(npm 会归一化)
111
- - 注意大小写:虽然 GitHub 不区分,但 provenance 严格校验,保持与 workflow 运行环境一致
112
-
113
- ### 5. `Tag version does not match package.json version`
114
-
115
- ```
116
- Tag version (0.0.2) does not match package.json version (0.0.1)
117
- ```
118
-
119
- **原因:** 打 tag 前忘记 bump `package.json`,或 bump 后没 commit。
120
-
121
- **修复:**
122
-
123
- ```bash
124
- # 删除错误 tag
125
- git tag -d v0.0.2
126
- git push origin :refs/tags/v0.0.2
127
-
128
- # 修复 package.json
129
- npm version 0.0.2 --no-git-tag-version # 只改文件,不打 tag
130
- git add package.json && git commit -m "chore: bump version to 0.0.2"
131
- git push origin main
132
-
133
- # 重新打 tag
134
- git tag v0.0.2
135
- git push origin v0.0.2
136
- ```
137
-
138
- ### 6. `npm warn publish "bin[name]" script name ... was invalid and removed`
139
-
140
- ```
141
- npm warn publish "bin[my-cli]" script name dist/cli/index.js was invalid and removed
142
- ```
143
-
144
- **原因:** `bin` 路径没有 `./` 前缀,或 npm 版本对该路径格式敏感。
145
-
146
- **修复:** 确认 `package.json` 已经是 `"./dist/cli/index.js"`。如果已经正确但警告仍在,可能是 npm 的误报——检查 npm publish 最终有没有返回 `+ @scope/pkg@version`,有就成功了。
147
-
148
- ### 7. Workflow 根本没触发
149
-
150
- **诊断:**
151
-
152
- ```bash
153
- gh run list --workflow release.yml --limit 3
154
- # 如果最新的那个不在列表里,就是没触发
155
- ```
156
-
157
- **原因:**
158
-
159
- - Tag 名不匹配 `v*` 模式
160
- - Tag 已存在,再次 push 被 Git 拒绝
161
- - 仓库关闭了 Actions
162
-
163
- **修复:**
164
-
165
- ```bash
166
- # 确认 tag 推到远端了
167
- git ls-remote --tags origin | grep v0.0.2
168
-
169
- # 如果旧 tag 残留,先删
170
- git tag -d v0.0.2
171
- git push origin :refs/tags/v0.0.2
172
-
173
- # 重新打
174
- git tag v0.0.2
175
- git push origin v0.0.2
176
- ```
177
-
178
- ### 8. 安装 pnpm 或 Node 失败
179
-
180
- ```
181
- Error: Unable to find 'pnpm' executable
182
- ```
183
-
184
- **修复:** 在 setup 里加:
185
-
186
- ```yaml
187
- - uses: pnpm/action-setup@v2
188
- with:
189
- version: 9 # 匹配 packageManager 字段或 lockfile 格式
190
- ```
191
-
192
- 如果 `package.json` 里写了 `packageManager: "pnpm@9.x.x"`,`pnpm/action-setup` 可不传 `version`,它会自动读取。
193
-
194
- ### 9. `npm ERR! 403 Forbidden - PUT` 但 token 正常
195
-
196
- 可能是包名大小写问题。npm 内部是小写,但 `package.json` 里写了大写:
197
-
198
- ```json
199
- { "name": "MyCli" } // ❌
200
- { "name": "my-cli" } // ✅
201
- ```
202
-
203
- ### 10. GitHub Release 正文为空 / 仅一行 `Full Changelog`
204
-
205
- ```
206
- Release v0.0.10 (Latest)
207
- Full Changelog: v0.0.9...v0.0.10
208
- [Source code (zip)] [Source code (tar.gz)]
209
- ```
210
-
211
- **原因**:`softprops/action-gh-release@v2` 只设了 `generate_release_notes: true`,而 GitHub 自动生成器从 PR 标题 + label 抽取 changelog。直 push main 的仓库没有 PR 流量,生成器只剩 compare 链接可写。
212
-
213
- **修复(workflow 改造)**:在 Create GitHub Release 之前加一步从 `CHANGELOG.md` 抽取段落,再用 `body_path` 注入。完整 YAML 见 [workflow-yaml-reference.md](workflow-yaml-reference.md) 的 `Extract release notes from CHANGELOG.md` 步骤;模式说明见 [release-notes-injection.md](release-notes-injection.md)。
214
-
215
- **修复(事后回填历史 Release,无需重发版)**:按 [release-notes-injection.md](release-notes-injection.md) 抽取 CHANGELOG 段落,再 `gh release edit "v$VERSION" --notes-file "$notes_file"`。
216
-
217
- **诊断**:
218
-
219
- ```bash
220
- # Release body 长度过短就是出问题了
221
- gh release view v0.0.10 --json body --jq '.body | length'
222
-
223
- # workflow 里 Extract release notes 步骤是否存在并 success
224
- gh run view <run-id> --json jobs \
225
- --jq '.jobs[].steps[] | select(.name | test("Extract|Release"))'
226
- ```
227
-
228
- ### 11. `Extract release notes` 步骤报 "release-notes.md is empty"
229
-
230
- **根因**:CHANGELOG 段落标题与 tag 不匹配,awk 抽空。
231
-
232
- **自查**:
233
-
234
- ```bash
235
- # 实际 CHANGELOG 标题
236
- grep '^## \[' CHANGELOG.md | head -5
237
-
238
- # 当前 tag 应当对应的标题
239
- echo "## [${GITHUB_REF_NAME#v}]"
240
- ```
241
-
242
- 常见问题:
243
-
244
- - 全角中括号 `【0.0.10】` 而非半角 `[0.0.10]`
245
- - 版本号有 `v` 前缀(`## [v0.0.10]`)— awk 期望去前缀的纯数字
246
- - 段落写错位置(`[Unreleased]` 段还没迁移到正式版本段)
247
-
248
- ## 发布成功但找不到包
249
-
250
- 典型场景:workflow 显示绿色,但 `npm view @scope/pkg` 返回 404。
251
-
252
- - **传播延迟**:npm CDN 有 30–60 秒缓存延迟,等一下再查
253
- - **日志确认**:`gh run view <id> --log | grep "+ @scope"`——有 `+ @scope/pkg@version` 才算真的成功
254
- - **provenance 页面**:https://search.sigstore.dev/ 能查到签名日志
255
-
256
- ```bash
257
- # 等待 + 轮询
258
- for i in {1..10}; do
259
- npm view @scope/my-cli version 2>/dev/null && break
260
- sleep 10
261
- done
262
- ```
263
-
264
- ## 已发布但需要撤回
265
-
266
- npm **24 小时内**可以 `unpublish`(仅限无依赖项):
267
-
268
- ```bash
269
- npm unpublish @scope/my-cli@0.0.2
270
- ```
271
-
272
- 超过 24 小时或有依赖者只能 `deprecate`:
273
-
274
- ```bash
275
- npm deprecate @scope/my-cli@0.0.2 "Security issue, use 0.0.3+"
276
- ```
277
-
278
- **npm 不允许重发同一个 version**——即使 unpublish 过了。必须 bump 版本号。
279
-
280
- ## 排查 checklist
281
-
282
- 按顺序检查,90% 的问题在前三项:
283
-
284
- 1. [ ] `NPM_TOKEN` 是 Granular Token、bypass 2FA、包含目标 scope 的 read+write
285
- 2. [ ] `package.json` 有 `repository.url` 且匹配 GitHub repo
286
- 3. [ ] Workflow 含 `permissions: id-token: write` 和 `--access public`
287
- 4. [ ] Tag 版本与 `package.json` version 字符一致
288
- 5. [ ] Publish step 在 Release step 之前
289
- 6. [ ] Workflow 触发器是 `on.push.tags: ['v*']`,没写 branches
290
- 7. [ ] `bin` 路径以 `./` 开头
291
- 8. [ ] `files` 字段不排除构建产物
292
- 9. [ ] **Workflow 包含 `Extract release notes from CHANGELOG.md` 步骤,且 `Create GitHub Release` 设了 `body_path: release-notes.md`**
293
- 10. [ ] **CHANGELOG.md 顶部有当前版本对应的 `## [X.Y.Z]` 段落(半角中括号)**
@@ -1,217 +0,0 @@
1
- # 版本 bump → release commit → tag → push 端到端 SOP
2
-
3
- 把"想发个新版本"翻译成可复现的几条命令。本文档假设仓库已有 `release.yml`(`v*` tag 触发,含 release-notes 注入)。
4
-
5
- ## 0. 前置检查
6
-
7
- ```bash
8
- # 1. main 干净,没有未提交改动
9
- git status
10
-
11
- # 2. 当前 HEAD 与 origin/main 的关系
12
- git log origin/main..HEAD --oneline
13
-
14
- # 3. 上一次发布的 tag
15
- git tag --sort=-version:refname | head -3
16
-
17
- # 4. CHANGELOG 顶部 [Unreleased] 段落已写好本次内容
18
- head -30 CHANGELOG.md
19
- ```
20
-
21
- 任意一项异常先解决再发版:工作区不干净 → 先提交,或调用 docs-sync 按其清洁契约处理;`[Unreleased]` 为空 → 先做 docs-sync。禁止用 stash 隐藏待发布改动。
22
-
23
- ## 1. 维护 CHANGELOG
24
-
25
- `CHANGELOG.md` 顶部必须始终保留 `[Unreleased]` 段落。新版本发布时:
26
-
27
- 1. 把 `[Unreleased]` 内容**整段迁移**到新建的 `## [X.Y.Z] — YYYY-MM-DD` 标题下
28
- 2. 重新插入空的 `[Unreleased]` 段落
29
- 3. 在文件末尾的"版本链接"段更新 compare 链接
30
-
31
- ```diff
32
- ## [Unreleased]
33
- +
34
- +---
35
- +
36
- +## [0.0.10] — 2026-05-17
37
-
38
- ### Changed
39
- - ...
40
- ```
41
-
42
- ```diff
43
- -- [Unreleased](https://github.com/owner/repo/compare/v0.0.9...HEAD)
44
- +- [Unreleased](https://github.com/owner/repo/compare/v0.0.10...HEAD)
45
- +- [0.0.10](https://github.com/owner/repo/releases/tag/v0.0.10)
46
- - [0.0.9](https://github.com/owner/repo/releases/tag/v0.0.9)
47
- ```
48
-
49
- 完整 CHANGELOG 契约见 `<Path>{roots.skills}/docs-sync/references/changelog-contract.md</Path>`。
50
-
51
- ## 2. bump package.json
52
-
53
- **用 `npm version` 还是手改?**
54
-
55
- | 场景 | 推荐 |
56
- |------|------|
57
- | 单一 package.json,简单 bump | `npm version <major\|minor\|patch> --no-git-tag-version` |
58
- | Monorepo / 多文件版本号要同步 | 手改 + `pnpm -r`(或脚本) |
59
- | 已写好 CHANGELOG,只想改 package.json 一处 | 手改 |
60
-
61
- `--no-git-tag-version` 的关键作用:**只改文件,不自动打 tag**。我们要把 tag 打在 release commit 上,不是在 bump 这一刻。
62
-
63
- ```bash
64
- # 等价于手改 package.json 的 version 字段
65
- npm version 0.0.10 --no-git-tag-version
66
- ```
67
-
68
- ## 3. release commit(原子提交)
69
-
70
- 把 `package.json` + `CHANGELOG.md` 一并提交,使用 Conventional Commits 的 `chore(release):` 前缀。
71
-
72
- ```bash
73
- git add package.json CHANGELOG.md
74
- git commit -m "chore(release): v0.0.10" \
75
- -m "迁移 [Unreleased] 段落到 0.0.10:<一两句关键变更摘要>"
76
- ```
77
-
78
- **为什么必须是同一个 commit**:
79
- - tag 要精确指向这个 commit
80
- - workflow 的 `Verify tag matches package version` 步骤会校验该 commit 上的 `package.json` 版本与 tag 一致
81
- - 利于后续 `git revert` 一键回滚发布
82
-
83
- ## 4. push main
84
-
85
- ```bash
86
- git push origin main
87
- ```
88
-
89
- push **必须先于** tag,否则远端 tag 会指向 origin 看不到的 commit,GitHub Release 创建时会找不到对应 commit 树。
90
-
91
- ## 5. 打 tag 并精确指向 release commit
92
-
93
- ```bash
94
- # 显式指定 commit SHA,避免 HEAD 已经向前移动
95
- RELEASE_COMMIT=$(git log -1 --format=%H --grep="^chore(release): v0.0.10")
96
-
97
- git tag v0.0.10 "$RELEASE_COMMIT"
98
- git push origin v0.0.10
99
- ```
100
-
101
- **为什么要指定 SHA 而不是直接 `git tag v0.0.10`**:
102
-
103
- 如果 release commit 之后又做了几笔 docs / state 推进 commit,`HEAD` 不再是 release commit。直接 `git tag` 会把 tag 打在 docs commit 上,导致:
104
-
105
- - `Verify tag matches package version` 仍然通过(版本号对得上)
106
- - 但 `gh release view --json targetCommitish` 指向 docs commit
107
- - 长远看 release tag 与"真正的发布动作"脱钩
108
-
109
- 简单场景下(release commit 就是 HEAD)直接 `git tag v0.0.10` 也对,但养成显式 SHA 的习惯更稳。
110
-
111
- ## 6. 监控 workflow
112
-
113
- ```bash
114
- # 实时跟踪
115
- gh run watch
116
-
117
- # 或周期性查询
118
- gh run list --workflow release.yml --limit 3 \
119
- --json databaseId,status,conclusion,displayTitle,headBranch
120
- ```
121
-
122
- 预期顺序(11 步,缺一不可):
123
-
124
- 1. Set up job
125
- 2. Checkout
126
- 3. Setup environment
127
- 4. **Verify tag matches package version**
128
- 5. Run lint
129
- 6. Run tests
130
- 7. Build
131
- 8. **Verify bin entry**
132
- 9. **Extract release notes from CHANGELOG.md** ← v1.1.0 新增
133
- 10. **Publish to npm**
134
- 11. **Create GitHub Release**
135
-
136
- ## 7. 三端验证
137
-
138
- 完整命令与判定见 [release-pipeline.md](release-pipeline.md) Phase 5(`npm view` / `gh release view` / `gh run view`)。任一缺失视为发布残次品;Release 正文为空时按 [release-notes-injection.md](release-notes-injection.md) 事后修复。
139
-
140
- ## 8. 失败回滚
141
-
142
- ### 8.1 publish 前任意步骤失败
143
-
144
- 最干净:删 tag 重打。
145
-
146
- ```bash
147
- git tag -d v0.0.10
148
- git push origin :refs/tags/v0.0.10
149
-
150
- # 修问题 → 重新 commit(若 release commit 也要改,用 amend)
151
- git commit --amend
152
- git push origin main --force-with-lease # 仅当 amend 了已 push 的 commit 时
153
-
154
- # 重新打
155
- git tag v0.0.10 <commit-sha>
156
- git push origin v0.0.10
157
- ```
158
-
159
- ### 8.2 publish 已成功但后续步骤失败
160
-
161
- npm 已上线 → **不要**改版本号,只补后续动作。
162
-
163
- 下面的 `notes_file` 只是一次性传给 `gh --notes-file` 的中间文件;若需要保留发布摘要或 release notes,由调用方写入 `<Path>{roots.state}/commands/{command}/{date}-{scope}-{topic}[-NN].md</Path>`。
164
-
165
- ```bash
166
- notes_file="$(mktemp -t speculo-release-notes.XXXXXX)"
167
- trap 'rm -f "$notes_file"' EXIT
168
-
169
- # 抽取 CHANGELOG 段落
170
- awk -v v="0.0.10" '...' CHANGELOG.md > "$notes_file"
171
-
172
- # 手动创建 GitHub Release
173
- gh release create v0.0.10 --notes-file "$notes_file" --latest
174
-
175
- # 或编辑已有 Release(如果 action 半成品创建过空 Release)
176
- gh release edit v0.0.10 --notes-file "$notes_file"
177
- ```
178
-
179
- ### 8.3 publish 失败但 npm 上其实有了(罕见)
180
-
181
- ```bash
182
- # 确认状态
183
- npm view @scope/pkg@0.0.10 version
184
-
185
- # 如果有,说明上传完但 npm 返回失败码,直接当作 8.2 处理(已发,只补 Release)
186
- # 如果无,按 8.1 处理(重打 tag)
187
- ```
188
-
189
- ### 8.4 npm 不允许重发同一 version
190
-
191
- 铁律:即使 `npm unpublish` 过,**24h 内同一版本号也不能再发**。若 publish 真上传成功但需要修代码:
192
-
193
- ```bash
194
- # bump 到下一个补丁
195
- npm version 0.0.11 --no-git-tag-version
196
- git add package.json CHANGELOG.md
197
- git commit -m "chore(release): v0.0.11"
198
- git push origin main
199
- git tag v0.0.11
200
- git push origin v0.0.11
201
- ```
202
-
203
- ## 9. CHECKLIST
204
-
205
- 发版前过一遍:
206
-
207
- - [ ] `git status` 干净
208
- - [ ] CHANGELOG 顶部已迁移 `[Unreleased]` 到新版本段
209
- - [ ] 底部 compare 链接已更新
210
- - [ ] `package.json` version 与即将打的 tag 严格一致(去掉 `v` 前缀)
211
- - [ ] `pnpm check` 本地通过(lint + test + build)
212
- - [ ] `pnpm build:check-bin` 通过(若是 CLI 包)
213
- - [ ] release commit 已 push 到 origin/main
214
- - [ ] tag 指向 release commit(不是 docs commit / HEAD 漂移后的 commit)
215
- - [ ] tag 已 push,`gh run list` 看到 workflow 触发
216
- - [ ] workflow 11 步全 success
217
- - [ ] 三端验证齐全:npm 有 / Release body 非空 / workflow success