@chengzhao-dev/dsh-cpp-workflow 0.7.1 → 0.7.4

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 (175) hide show
  1. package/README.en.md +16 -10
  2. package/README.md +16 -10
  3. package/cordis.patch.yml +6 -6
  4. package/lib/client.js +3 -3
  5. package/lib/comment-policy.js +1 -1
  6. package/lib/index.js +45 -37
  7. package/lib/workspace.js +10 -17
  8. package/package.json +9 -3
  9. package/skills/building-cpp/SKILL.md +17 -17
  10. package/skills/building-cpp/assets/templates/projects/common/running-build.sh +0 -0
  11. package/skills/building-cpp/examples/environment.md +4 -3
  12. package/skills/building-cpp/references/{build-script.md → 01-build-script.md} +4 -3
  13. package/skills/building-cpp/references/{environment.md → 02-environment.md} +3 -2
  14. package/skills/building-cpp/scripts/checking-environment.mjs +11 -13
  15. package/skills/building-cpp/steps/01-build.md +4 -3
  16. package/skills/building-cpp/steps/02-tooling.md +12 -12
  17. package/skills/building-cpp/steps/03-check.md +5 -5
  18. package/skills/building-cpp/{project/vscode/02-settings.md → steps/04-vscode.md} +24 -6
  19. package/skills/developing-cpp/SKILL.md +21 -18
  20. package/skills/developing-cpp/references/comments/{comment-rules.md → 01-comment-rules.md} +81 -64
  21. package/skills/developing-cpp/references/comments/{comment-style.md → 02-style.md} +16 -18
  22. package/skills/developing-cpp/references/comments/examples/{declaration-class.md → 01-declaration-class.md} +16 -16
  23. package/skills/developing-cpp/references/comments/examples/{declaration-constructor.md → 02-declaration-constructor.md} +3 -2
  24. package/skills/developing-cpp/references/comments/examples/03-declaration-enum.md +48 -0
  25. package/skills/developing-cpp/references/comments/examples/{declaration-file.md → 04-declaration-file.md} +6 -5
  26. package/skills/developing-cpp/references/comments/examples/05-declaration-function.md +116 -0
  27. package/skills/developing-cpp/references/comments/examples/{declaration-member.md → 06-declaration-member.md} +4 -3
  28. package/skills/developing-cpp/references/comments/examples/07-declaration-predicate.md +15 -0
  29. package/skills/developing-cpp/references/comments/examples/{declaration-struct.md → 08-declaration-struct.md} +4 -3
  30. package/skills/developing-cpp/references/comments/examples/09-implementation-body.md +95 -0
  31. package/skills/developing-cpp/references/comments/examples/10-implementation-todo.md +17 -0
  32. package/skills/developing-cpp/references/comments/glossary/01-comment-terms.md +93 -0
  33. package/skills/developing-cpp/references/design/{project-design.md → 01-project-design.md} +21 -17
  34. package/skills/developing-cpp/references/design/examples/{behavior-sentence.md → 01-behavior-sentence.md} +1 -0
  35. package/skills/developing-cpp/references/design/examples/{coordinate-table.md → 02-coordinate-table.md} +4 -3
  36. package/skills/developing-cpp/references/design/examples/{header-place.md → 03-header-place.md} +2 -1
  37. package/skills/developing-cpp/references/design/examples/{library-boundary.md → 04-library-boundary.md} +1 -0
  38. package/skills/developing-cpp/references/design/examples/{library-split.md → 05-library-split.md} +1 -0
  39. package/skills/developing-cpp/references/design/examples/06-move-result.md +42 -0
  40. package/skills/developing-cpp/references/design/examples/07-preview-read.md +37 -0
  41. package/skills/developing-cpp/references/design/session-layer.md +89 -0
  42. package/skills/developing-cpp/references/exceptions/{throw-rules.md → 01-exception-rules.md} +56 -61
  43. package/skills/developing-cpp/references/exceptions/examples/{throw-boundary.md → 01-throw-boundary.md} +1 -0
  44. package/skills/developing-cpp/references/exceptions/examples/{throw-build-mode.md → 02-throw-build-mode.md} +5 -4
  45. package/skills/developing-cpp/references/exceptions/examples/{throw-catch.md → 03-throw-catch.md} +1 -0
  46. package/skills/developing-cpp/references/exceptions/examples/{throw-destructor.md → 04-throw-destructor.md} +1 -0
  47. package/skills/developing-cpp/references/exceptions/examples/{throw-format.md → 05-throw-format.md} +1 -0
  48. package/skills/developing-cpp/references/exceptions/examples/{throw-message.md → 06-throw-message.md} +10 -1
  49. package/skills/developing-cpp/references/exceptions/examples/{throw-when.md → 07-throw-when.md} +1 -0
  50. package/skills/developing-cpp/references/index.md +132 -0
  51. package/skills/developing-cpp/references/language/glossary/{language-terms.md → 01-language-terms.md} +3 -2
  52. package/skills/developing-cpp/references/language/language-basics/01-objects.md +2 -1
  53. package/skills/developing-cpp/references/language/language-basics/02-initialization.md +2 -1
  54. package/skills/developing-cpp/references/language/language-basics/03-deduction.md +1 -0
  55. package/skills/developing-cpp/references/language/language-basics/04-const.md +5 -4
  56. package/skills/developing-cpp/references/language/language-basics/05-expressions.md +13 -4
  57. package/skills/developing-cpp/references/language/language-basics/06-functions.md +4 -1
  58. package/skills/developing-cpp/references/language/language-basics/07-classes.md +1 -0
  59. package/skills/developing-cpp/references/language/language-basics/08-raii.md +1 -0
  60. package/skills/developing-cpp/references/language/language-basics/09-templates.md +1 -0
  61. package/skills/developing-cpp/references/language/language-basics/{10-checklist.md → 10-language-checklist.md} +2 -0
  62. package/skills/developing-cpp/references/language/performance/01-measure.md +1 -0
  63. package/skills/developing-cpp/references/language/performance/02-complexity.md +1 -0
  64. package/skills/developing-cpp/references/language/performance/03-memory.md +1 -0
  65. package/skills/developing-cpp/references/language/performance/04-undefined-behavior.md +1 -0
  66. package/skills/developing-cpp/references/language/performance/05-pitfalls.md +1 -0
  67. package/skills/developing-cpp/references/language/performance/06-false-optimizations.md +1 -0
  68. package/skills/developing-cpp/references/language/performance/07-checklist.md +1 -0
  69. package/skills/developing-cpp/references/language/standard-library/01-containers.md +1 -0
  70. package/skills/developing-cpp/references/language/standard-library/02-access.md +2 -1
  71. package/skills/developing-cpp/references/language/standard-library/03-iteration.md +1 -0
  72. package/skills/developing-cpp/references/language/standard-library/04-algorithms.md +1 -0
  73. package/skills/developing-cpp/references/language/standard-library/05-string.md +1 -0
  74. package/skills/developing-cpp/references/language/standard-library/06-format.md +17 -6
  75. package/skills/developing-cpp/references/language/standard-library/07-time.md +1 -0
  76. package/skills/developing-cpp/references/language/standard-library/08-random.md +2 -0
  77. package/skills/developing-cpp/references/language/standard-library/09-files.md +1 -0
  78. package/skills/developing-cpp/references/language/standard-library/{10-checklist.md → 10-library-checklist.md} +1 -0
  79. package/skills/developing-cpp/references/language/value-types/01-width.md +1 -0
  80. package/skills/developing-cpp/references/language/value-types/02-signed.md +1 -0
  81. package/skills/developing-cpp/references/language/value-types/03-integer-roles.md +1 -0
  82. package/skills/developing-cpp/references/language/value-types/04-enum.md +3 -2
  83. package/skills/developing-cpp/references/language/value-types/05-strong-type.md +1 -0
  84. package/skills/developing-cpp/references/language/value-types/06-const-method.md +1 -0
  85. package/skills/developing-cpp/references/language/value-types/07-nodiscard.md +2 -1
  86. package/skills/developing-cpp/references/language/value-types/08-comparison.md +2 -1
  87. package/skills/developing-cpp/references/language/value-types/09-subscript.md +2 -1
  88. package/skills/developing-cpp/references/language/value-types/10-float-bool.md +1 -0
  89. package/skills/developing-cpp/references/language/value-types/11-checklist.md +1 -0
  90. package/skills/developing-cpp/references/layout/01-source-layout.md +3 -3
  91. package/skills/developing-cpp/references/layout/02-file-template.md +10 -9
  92. package/skills/developing-cpp/references/layout/03-declaration-order.md +25 -12
  93. package/skills/developing-cpp/references/naming/01-identifier-names.md +128 -0
  94. package/skills/developing-cpp/references/naming/examples/01-naming-accessor.md +29 -0
  95. package/skills/developing-cpp/references/naming/examples/02-naming-basic.md +4 -0
  96. package/skills/developing-cpp/references/naming/examples/{naming-current-prefix.md → 03-naming-current-prefix.md} +1 -0
  97. package/skills/developing-cpp/references/naming/examples/04-naming-local.md +46 -0
  98. package/skills/developing-cpp/references/naming/examples/{naming-lookup.md → 05-naming-lookup.md} +2 -1
  99. package/skills/developing-cpp/references/naming/examples/06-naming-lower-layer.md +46 -0
  100. package/skills/developing-cpp/references/naming/examples/{naming-multiple-return.md → 07-naming-multiple-return.md} +1 -0
  101. package/skills/developing-cpp/references/naming/examples/08-naming-player-value.md +16 -0
  102. package/skills/developing-cpp/references/naming/examples/09-naming-predicate.md +19 -0
  103. package/skills/developing-cpp/references/naming/examples/{naming-rename.md → 10-naming-rename.md} +1 -0
  104. package/skills/developing-cpp/references/naming/examples/{naming-responsibility.md → 11-naming-responsibility.md} +1 -0
  105. package/skills/developing-cpp/references/naming/examples/{naming-role.md → 12-naming-role.md} +2 -1
  106. package/skills/developing-cpp/references/naming/examples/13-naming-state-change.md +70 -0
  107. package/skills/developing-cpp/references/naming/glossary/01-naming-terms.md +27 -0
  108. package/skills/developing-cpp/references/naming/glossary/02-position.md +24 -0
  109. package/skills/developing-cpp/references/naming/glossary/03-selection.md +23 -0
  110. package/skills/developing-cpp/references/naming/glossary/04-square.md +48 -0
  111. package/skills/developing-cpp/references/naming/glossary/05-scoring.md +27 -0
  112. package/skills/developing-cpp/references/naming/glossary/06-difficulty.md +26 -0
  113. package/skills/developing-cpp/references/style/{google-cpp-style.md → 01-google-cpp-style.md} +16 -9
  114. package/skills/developing-cpp/scripts/checking-comments.mjs +116 -9
  115. package/skills/developing-cpp/scripts/checking-declaration-order.mjs +27 -1
  116. package/skills/developing-cpp/steps/01-behavior.md +5 -5
  117. package/skills/developing-cpp/steps/02-boundary.md +6 -6
  118. package/skills/developing-cpp/steps/03-declaration.md +7 -7
  119. package/skills/developing-cpp/steps/04-implementation.md +16 -16
  120. package/skills/engineering/SKILL.md +19 -19
  121. package/skills/engineering/references/cmake/linking/01-libraries.md +7 -4
  122. package/skills/engineering/references/cmake/linking/02-rpath.md +1 -0
  123. package/skills/engineering/references/cmake/linking/03-undefined-reference.md +3 -2
  124. package/skills/engineering/references/cmake/linking/04-inspect.md +1 -1
  125. package/skills/engineering/references/cmake/modules/{functions.md → 01-functions.md} +4 -3
  126. package/skills/engineering/references/cmake/{standard/cxx-standard.md → standards/01-cxx-standard.md} +2 -1
  127. package/skills/engineering/references/cmake/{standard/examples/standard.md → standards/examples/01-standard.md} +2 -1
  128. package/skills/engineering/references/cmake/{standard/standards/README.md → standards/index.md} +22 -21
  129. package/skills/engineering/references/cmake/standards/versions.md +44 -0
  130. package/skills/engineering/references/cmake/targets/{rules.md → 01-target-rules.md} +34 -5
  131. package/skills/engineering/references/cmake/targets/examples/{rpath.md → 01-rpath.md} +1 -0
  132. package/skills/engineering/references/cmake/testing/{ctest.md → 01-ctest.md} +4 -3
  133. package/skills/engineering/references/formatting/01-encoding.md +2 -1
  134. package/skills/engineering/references/formatting/02-clang-format.md +4 -3
  135. package/skills/engineering/references/formatting/03-clang-tidy.md +3 -2
  136. package/skills/engineering/references/formatting/04-clangd.md +2 -0
  137. package/skills/engineering/references/formatting/examples/{clang-format.md → 01-clang-format.md} +2 -1
  138. package/skills/engineering/references/formatting/examples/{clang-tidy.md → 02-clang-tidy.md} +1 -0
  139. package/skills/engineering/references/formatting/examples/{clangd.md → 03-clangd.md} +1 -0
  140. package/skills/engineering/references/index.md +32 -0
  141. package/skills/engineering/{references/formatting/scripts → scripts}/checking-encoding.mjs +6 -7
  142. package/skills/engineering/steps/01-targets.md +5 -4
  143. package/skills/engineering/steps/02-modules.md +3 -3
  144. package/skills/engineering/steps/03-check.md +3 -2
  145. package/skills/shared/budget.md +20 -0
  146. package/skills/{developing-cpp/references/editing/01-edit-operations.md → shared/operations.md} +8 -4
  147. package/skills/{developing-cpp/references/editing/02-rule-priority.md → shared/rule-priority.md} +2 -1
  148. package/skills/building-cpp/project/vscode/01-extensions.md +0 -28
  149. package/skills/developing-cpp/references/comments/examples/declaration-enum.md +0 -48
  150. package/skills/developing-cpp/references/comments/examples/declaration-function.md +0 -127
  151. package/skills/developing-cpp/references/comments/examples/declaration-predicate.md +0 -14
  152. package/skills/developing-cpp/references/comments/examples/implementation-body.md +0 -64
  153. package/skills/developing-cpp/references/comments/examples/implementation-todo.md +0 -16
  154. package/skills/developing-cpp/references/comments/glossary/comment-terms.md +0 -93
  155. package/skills/developing-cpp/references/design/examples/move-result.md +0 -39
  156. package/skills/developing-cpp/references/design/examples/preview-read.md +0 -40
  157. package/skills/developing-cpp/references/naming/examples/naming-accessor.md +0 -17
  158. package/skills/developing-cpp/references/naming/examples/naming-basic.md +0 -3
  159. package/skills/developing-cpp/references/naming/examples/naming-lower-layer.md +0 -39
  160. package/skills/developing-cpp/references/naming/examples/naming-player-value.md +0 -16
  161. package/skills/developing-cpp/references/naming/examples/naming-predicate.md +0 -18
  162. package/skills/developing-cpp/references/naming/examples/naming-state-change.md +0 -57
  163. package/skills/developing-cpp/references/naming/identifier-names.md +0 -104
  164. package/skills/engineering/references/cmake/standard/standards/c++11/README.md +0 -50
  165. package/skills/engineering/references/cmake/standard/standards/c++14/README.md +0 -48
  166. package/skills/engineering/references/cmake/standard/standards/c++17/README.md +0 -50
  167. package/skills/engineering/references/cmake/standard/standards/c++20/README.md +0 -50
  168. package/skills/engineering/references/cmake/standard/standards/c++23/README.md +0 -50
  169. package/skills/engineering/references/cmake/targets/examples/glob.md +0 -22
  170. package/skills/engineering/references/cmake/targets/examples/target.md +0 -156
  171. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++11/cmake-snippet.cmake +0 -0
  172. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++14/cmake-snippet.cmake +0 -0
  173. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++17/cmake-snippet.cmake +0 -0
  174. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++20/cmake-snippet.cmake +0 -0
  175. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++23/cmake-snippet.cmake +0 -0
@@ -1,3 +1,4 @@
1
+ <!-- 读取时机:配环境或检查工具时;读完能回答:环境组合;预算:一次只开这一份(115 行),不自动串联。 -->
1
2
  # 环境组合
2
3
 
3
4
  环境是**声明**,不是探测结果。项目技能 `cpp-workflow-project` 的 `environment.json` 写清楚三个环境轴和一个语言标准;构建规则、工具配置和检查都按这个声明执行。声明为空或组合非法时,先修声明,不要靠猜。
@@ -57,7 +58,7 @@
57
58
 
58
59
  ## 版本与能力
59
60
 
60
- - **标准**:新工程默认 C++23,可声明 `c++11`–`c++23`;编译器必须支持对应的 `-std=c++NN`。CMake ≥ 3.20;C++11/14 的 `cxx_std_*` 需要 CMake ≥ 3.8,但本工作流统一按 3.20 起步。`CXX_STANDARD_REQUIRED ON` 防止标准 decay;C++23 的库设施(如 `std::print`)以实际编译器/标准库为准。
61
+ - **标准**:新工程默认 C++23,可声明 `c++11`–`c++23`;编译器必须支持对应的 `-std=c++NN`。CMake ≥ 3.20;C++11/14 的 `cxx_std_*` 需要 CMake ≥ 3.1,但本工作流统一按 3.20 起步。`CXX_STANDARD_REQUIRED ON` 防止标准 decay;C++23 的库设施(如 `std::print`)以实际编译器/标准库为准。
61
62
  - **clang-format / clang-tidy**:≥ 16。这是本工作流的工具基线;低于该版本时检查器报告具体角色和版本。
62
63
  - **clang 模式同版本**:`clang++`、`clang-format`、`clang-tidy`、`clangd` 必须是同一 LLVM 主版本。混装 17 的 clangd 与 18 的 clang-format 会出现诊断与格式化不一致。Apple Clang 也按这条核对;若工具版本对不上,报告的是具体角色和版本,不要为了通过而改声明。
63
64
  - **gcc 模式**:检查器不拿 GCC 的主版本去比 Clang 工具;`clang-format` / `clang-tidy` 仍要 ≥ 16,`clangd` 只要求可用。`g++` 必须是真的 GCC,不能是 Apple clang 的别名。GCC 需要自带 C++23 `<print>` / `std::expected` 的标准库;版本过旧时先升级工具链,或把项目标准降到实际可用的档位,不要改检查器绕过。
@@ -105,7 +106,7 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live
105
106
  | 3 | 活动校验失败:不在声明的 build host、角色缺失、版本不符 |
106
107
  | 1 | 脚本自身错误:参数错误或内部异常 |
107
108
 
108
- 各标准对应的编译器、库设施和工具档位见 [../../engineering/references/cmake/standard/standards/README.md](../../engineering/references/cmake/standard/standards/README.md)。
109
+ 各标准对应的编译器、库设施和工具档位见 [../../engineering/references/cmake/standards/index.md](../../engineering/references/cmake/standards/index.md)。
109
110
 
110
111
  ## 依据
111
112
 
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
- // Read-only environment checker for the cpp-workflow project skill.
2
+ // cpp-workflow 项目技能的只读环境检查。
3
3
  //
4
- // Static mode validates `.agents/skills/cpp-workflow-project/environment.json`
5
- // without touching PATH. `--live` additionally verifies the current build host,
6
- // the declared tool roles and version compatibility.
4
+ // 静态模式校验 `.agents/skills/cpp-workflow-project/environment.json`,不碰 PATH。
5
+ // `--live` 另查当前构建主机、声明的工具角色与版本兼容性。
7
6
  //
8
- // It never installs, downloads, edits PATH or writes into the project.
7
+ // 不安装、不下载、不改 PATH,也不向工程写入。
9
8
  import { accessSync, constants, existsSync, readFileSync } from 'node:fs'
10
9
  import { access, readFile } from 'node:fs/promises'
11
10
  import { spawnSync } from 'node:child_process'
@@ -36,8 +35,8 @@ function normalize(value) {
36
35
  }
37
36
 
38
37
  /**
39
- * Validate the three environment axes, the language standard, and their combination.
40
- * Pure: no filesystem or PATH.
38
+ * 校验三个环境轴、语言标准以及它们的组合。
39
+ * 纯函数:不读文件系统,也不看 PATH。
41
40
  * @returns {{ok: boolean, issues: string[], notes: string[], axes: {host?: string, build_host?: string, compiler?: string, standard?: string}}}
42
41
  */
43
42
  export function validateEnvironment(value) {
@@ -112,7 +111,7 @@ export function validateEnvironment(value) {
112
111
  return { ok: issues.length === 0, issues, notes, axes }
113
112
  }
114
113
 
115
- /** Read and parse environment.json, returning a declaration or a structured error. */
114
+ /** 读取并解析 environment.json;成功给声明,失败给结构化错误。 */
116
115
  export async function readEnvironmentFile(file) {
117
116
  let text
118
117
  try {
@@ -129,7 +128,7 @@ export async function readEnvironmentFile(file) {
129
128
  return { ok: true, file, value }
130
129
  }
131
130
 
132
- /** Walk from startDir to the git root (or filesystem root) for environment.json. */
131
+ /** 从 startDir 向上走到 git 根(或文件系统根),找 environment.json。 */
133
132
  export async function findProjectEnvironment(startDir) {
134
133
  let cursor
135
134
  try {
@@ -138,7 +137,7 @@ export async function findProjectEnvironment(startDir) {
138
137
  return undefined
139
138
  }
140
139
 
141
- // Allow pointing directly at the project skill directory.
140
+ // 允许直接指向项目技能目录。
142
141
  if (path.basename(cursor) === 'cpp-workflow-project') {
143
142
  const direct = path.join(cursor, 'environment.json')
144
143
  if (await exists(direct)) return direct
@@ -175,7 +174,7 @@ function findExecutable(command, pathValue = process.env.PATH ?? '') {
175
174
  accessSync(candidate, constants.X_OK)
176
175
  return candidate
177
176
  } catch {
178
- // keep looking
177
+ // 继续向上找
179
178
  }
180
179
  }
181
180
  return undefined
@@ -241,8 +240,7 @@ function isWsl(env = process.env) {
241
240
  }
242
241
 
243
242
  /**
244
- * Live check. Dependencies are injectable so tests can exercise the host and
245
- * PATH branches without invoking a compiler.
243
+ * 实时检查。依赖可注入,测试不必真的调用编译器就能走主机与 PATH 分支。
246
244
  */
247
245
  export function checkLive(declaration, options = {}) {
248
246
  const platform = options.platform ?? process.platform
@@ -15,7 +15,7 @@ build/
15
15
 
16
16
  ## 前置
17
17
 
18
- 先读项目技能与 `environment.json`,再确认 `engineering` 已经把 target 图、公共 include、语言标准和输出目录写进 CMake。target 缺失、标准不对、include 或链接边界没写时,停止本步,转 `engineering` 的定 target 与标准;不要在这里用全局变量或临时 `-std` 绕过。 只在需要核对时打开 `../../engineering/references/cmake/targets/rules.md` 或 `../../engineering/references/cmake/standard/cxx-standard.md` 被点名的一份;CMake 的写改仍由 `engineering` 落笔。
18
+ 先读项目技能与 `environment.json`,再确认 `engineering` 已经把 target 图、公共 include、语言标准和输出目录写进 CMake。target 缺失、标准不对、include 或链接边界没写时,停止本步,转 `engineering` 的定 target 与标准;不要在这里用全局变量或临时 `-std` 绕过。 只在需要核对时打开 `../../engineering/references/cmake/targets/01-target-rules.md` 或 `../../engineering/references/cmake/standards/01-cxx-standard.md` 被点名的一份;CMake 的写改仍由 `engineering` 落笔。
19
19
 
20
20
  ## 环境
21
21
 
@@ -43,6 +43,7 @@ build/
43
43
  ```bash
44
44
  cmake -S . -B build/clang -G Ninja \
45
45
  -DCMAKE_BUILD_TYPE=Debug \
46
+ -DCMAKE_C_COMPILER=clang \
46
47
  -DCMAKE_CXX_COMPILER=clang++ \
47
48
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
48
49
  cmake --build build/clang
@@ -50,7 +51,7 @@ rm -f build/compile_commands.json
50
51
  ln -s clang/compile_commands.json build/compile_commands.json
51
52
  ```
52
53
 
53
- GCC 模式把目录和编译器换成 `build/gcc`、`g++`。每次构建都重新 configure;不要依赖上一次缓存。确有 C 源时,再补 `-DCMAKE_C_COMPILER=clang`(GCC 模式 `gcc`),不要只换 C++ 驱动。
54
+ GCC 模式把目录和编译器换成 `build/gcc`、`g++`(C 驱动换成 `gcc`)。每次构建都重新 configure;不要依赖上一次缓存。C 与 C++ 驱动一起换,不要只换 C++ 驱动。
54
55
 
55
56
  ## 情况
56
57
 
@@ -58,7 +59,7 @@ GCC 模式把目录和编译器换成 `build/gcc`、`g++`。每次构建都重
58
59
 
59
60
  **已有工程**:先读现有 `CMakeLists.txt`,只核对 target、标准与输出目录;不改与当前任务无关的 target,大改前先让现有构建跑通。
60
61
 
61
- **测试**:`enable_testing()` 与 `add_subdirectory(tests)` 的顺序由 `engineering` 定;本步只跑 CTest,不在没有测试时加空测试。
62
+ **测试**:`enable_testing()` 与 `add_subdirectory(tests)` 的顺序由 `engineering` 定;本步不跑 CTest,CTest 在通过检查里跑;不在没有测试时加空测试。
62
63
 
63
64
  **CMakePresets**:如果项目使用 preset,名称固定 `clang` / `gcc`,与构建目录一致;没有 preset 时直接用上面的命令。
64
65
 
@@ -9,30 +9,30 @@
9
9
  - 工程拥有配置:`.clang-format`、`.clang-tidy`、`.clangd`、`.vscode/` 放在工程根;不要依赖用户主目录或插件目录里的同名文件。
10
10
  - 只复制缺失的文件。已有配置先读再改,不覆盖;需要合并时逐项说明理由。
11
11
  - 工具角色固定:`clang-format` 管排版,`clang-tidy` 管静态诊断,`clangd` 管补全/跳转/诊断;无论 `compiler` 是 clang 还是 gcc,这三件都用 Clang 工具链。
12
- - 版本要求见 `../references/environment.md`:Clang 模式要求 `clang++`、`clang-format`、`clang-tidy`、`clangd` 同一 LLVM 主版本;GCC 模式要求 `clang-format` / `clang-tidy` ≥ 16,`clangd` 只要求可用。
12
+ - 版本要求见 `../references/02-environment.md`:Clang 模式要求 `clang++`、`clang-format`、`clang-tidy`、`clangd` 同一 LLVM 主版本;GCC 模式要求 `clang-format` / `clang-tidy` ≥ 16,`clangd` 只要求可用。
13
13
  - `.clangd` 的 `CompilationDatabase` 指向 `build/<compiler>`;切换编译器时同步改,不能留旧目录。**不要写 `-std`**:它会覆盖 `compile_commands.json`,把 C++23 工程降成旧标准;标准只由构建声明和编译数据库决定。
14
14
  - `--query-driver` 是 clangd 的命令行参数,写在 `.vscode/settings.json` 的 `clangd.arguments` 里,不是 `.clangd` 的 YAML 键。它告诉 clangd 允许执行哪个编译器驱动来取系统头路径;路径写绝对路径,并与 `environment.json` 的编译器一致。
15
15
  - 首次复制时按轴替换三处:`compiler=clang` 用 `CompilationDatabase: build/clang`、`--query-driver=/usr/bin/clang++` 和 `cmake.debugConfig` 的 `MIMode: lldb` / `miDebuggerPath: /usr/bin/lldb`;`compiler=gcc` 用 `build/gcc`、`/usr/bin/g++` 和 `MIMode: gdb` / `/usr/bin/gdb`。只复制模板而不改这三处,GCC 模式会指向错误的数据库、驱动或调试器。原工程已有的 `.clangd` 不覆盖;要改先征得同意。
16
- - `.clang-format` 保留 `Language: Cpp`、`BasedOnStyle: Google`、`Standard` 和 `LineEnding: LF`:模板资产写 `Latest`;工程按 `environment.json` 声明 C++11–C++20 时,把 `Standard` 改成 `c++NN`(映射见 `../../engineering/references/cmake/standard/standards/README.md`)。clang-format 21/22 的 `Standard` 不接受 `c++23`,所以 C++23 工程仍写 `Latest`。列宽、缩进与包含顺序以工程根 `.clang-format` 为准;工程显式写 `ColumnLimit` 时按工程值执行,模板资产不写 `ColumnLimit`。需要新规则时先改 `../../developing-cpp/references/style/google-cpp-style.md` 并说明理由。
16
+ - `.clang-format` 保留 `Language: Cpp`、`BasedOnStyle: Google`、`Standard` 和 `LineEnding: LF`:模板资产写 `Latest`;工程按 `environment.json` 声明 C++11–C++20 时,把 `Standard` 改成 `c++NN`(映射见 `../../engineering/references/cmake/standards/index.md`)。clang-format 21/22 的 `Standard` 不接受 `c++23`,23 起才接受;为兼容旧工具,C++23 工程仍写 `Latest`。列宽、缩进与包含顺序以工程根 `.clang-format` 为准;工程显式写 `ColumnLimit` 时按工程值执行,模板资产不写 `ColumnLimit`。需要新规则时先改 `../../developing-cpp/references/style/01-google-cpp-style.md` 并说明理由。
17
17
  - `.clang-tidy` 用 `Checks: '-*, google-*, portability-avoid-pragma-once, readability-identifier-naming'`,保留 `WarningsAsErrors: '*'` 和 `FormatStyle: file`。`google-*` 覆盖 Google 风格能静态检查的部分;`readability-identifier-naming` 只配项目确实统一的命名项:类型/枚举/别名/模板参数 PascalCase,变量/参数/成员 snake_case,类成员尾随 `_`,结构体成员不尾随,常量 `k` + PascalCase。不要设 `FunctionCase`,Google 允许 `count()` / `set_count()` 这类访问器;`portability-avoid-pragma-once` 要打开,因为工程统一用路径式守卫;不要重新打开 `cppcoreguidelines-*` 整包。
18
18
  - `.clang-tidy` 关闭项和例外必须写理由;不要借 `-*` 之后再打开 `cppcoreguidelines-*` 这类非 Google 整族检查。
19
19
  - `.vscode/extensions.json` 推荐 clangd、CMake Tools 与 C/C++ 扩展;`.vscode/settings.json` 固定 clangd 参数、CMake 构建目录和 `cmake.debugConfig`。配置、构建、运行和调试只从 CMake Tools 进入,不写 `tasks.json` 或 `launch.json`;C/C++ 扩展只作为 CMake 快速调试的后端,IntelliSense 关闭,避免和 clangd 并行。配置注释用 JSONC 的 `//`,贴在被解释的键上方。
20
20
  - 配置注释写「为什么这样设」,不写「这一项是什么」;不写策略头、不指向文档路径。
21
- - 格式化与静态检查只扫描项目源码:`src/`、`include/`、`apps/`、`tests/` 等实际存在的源码根;不扫描 `build/`、第三方目录、生成文件。
21
+ - 格式化与静态检查只扫描项目源码:`src/`、`include/`、`app/`、`tests/` 等实际存在的源码根;不扫描 `build/`、第三方目录、生成文件。
22
22
  - `clang-tidy` 用 `-p build/<compiler>` 读取编译数据库,`--header-filter` 只列项目根下的顶层目录,避免把第三方头纳入;不要加 `--system-headers`,也不要用 clang-tidy 19 才加入、16 没有的 `--exclude-header-filter`。
23
- - 格式化用 `--dry-run --Werror` 做检查;需要自动修复时单独运行 `-i`,不要让构建脚本悄悄改源码。`clang-format` 只排版,不会把行尾注释搬到上一行;数据成员注释位置按 `../../developing-cpp/references/comments/comment-rules.md` 检查。
23
+ - 格式化用 `--dry-run --Werror` 做检查;需要自动修复时单独运行 `-i`,不要让构建脚本悄悄改源码。`clang-format` 只排版,不会把行尾注释搬到上一行;数据成员注释位置按 `../../developing-cpp/references/comments/01-comment-rules.md` 检查。
24
24
  - 工程模板里不预置 `compile_commands.json`;它由定构建的 configure 生成,是构建产物。
25
25
 
26
26
  ## 编辑器接线
27
27
 
28
- - 只在工程根(当前目录到 git 根)已经有 `.vscode/` 时读 `../project/vscode/01-extensions.md` 或 `../project/vscode/02-settings.md`;没有 `.vscode/` 时不打开,也不新建目录。
28
+ - 只在工程根(当前目录到 git 根)已经有 `.vscode/` 时读 `04-vscode.md`;没有 `.vscode/` 时不打开,也不新建目录。
29
29
  - 顺序:先定 `.clang-format`、`.clang-tidy`、`.clangd`,再对照现有 `.vscode/extensions.json` 与 `settings.json` 只补缺、只改与 `environment.json` 冲突的项。
30
- - 一次只读 `../project/vscode/` 里被点名的一页;扩展与设置不要同时展开。工具条文一次只开 `../../engineering/references/formatting/` 里被点名的一份,其余留到下一次激活。
30
+ - 一次只读 `04-vscode.md`;扩展与设置不要同时展开。工具条文一次只开 `../../engineering/references/formatting/` 里被点名的一份,其余留到下一次激活。
31
31
  - 不写 `tasks.json` 或 `launch.json`,构建与运行仍走 `running-build.sh`。
32
32
 
33
33
  ## 情况
34
34
 
35
- **新工程**:从 `../assets/config/` 复制 `.clang-format`、`.clang-tidy`、`.clangd` 和 `.vscode/` 下的 `extensions.json`、`settings.json`,按编译器的映射改 `.clangd` 的编译数据库目录、`.vscode/settings.json` 的 `--query-driver` 路径和 `cmake.debugConfig` 的调试后端。新工程模板自带 `.vscode/` 时按 `../project/vscode/` 两页接线;已有工程没有 `.vscode/` 时不新建。不要复制 `build/`。
35
+ **新工程**:从 `../assets/config/` 复制 `.clang-format`、`.clang-tidy`、`.clangd` 和 `.vscode/` 下的 `extensions.json`、`settings.json`,按编译器的映射改 `.clangd` 的编译数据库目录、`.vscode/settings.json` 的 `--query-driver` 路径和 `cmake.debugConfig` 的调试后端。新工程模板自带 `.vscode/` 时按 `04-vscode.md` 接线;已有工程没有 `.vscode/` 时不新建。不要复制 `build/`。
36
36
 
37
37
  **已有工程**:新工程默认 C++23;已有工程按 `environment.json` 的 `standard` 对齐 CMake target 与 `.clang-format`,不要只改一处。先跑一次 `clang-format --dry-run --Werror` 和 `clang-tidy`,看现有配置实际报什么;只改导致当前失败或与声明环境冲突的项。不要借机重排全工程格式。
38
38
 
@@ -40,12 +40,12 @@
40
40
 
41
41
  **GCC 模式**:`clangd` 仍可工作,但系统头来自 GCC;`--query-driver` 指向 `g++`。`clang-format` / `clang-tidy` 仍是 Clang 工具,版本要求不因编译器是 GCC 而降低。
42
42
 
43
- **共享库**:静态检查不因链接方式改变;运行时库路径由 `engineering` 的 target 设置负责,见 `../../engineering/references/cmake/targets/rules.md` 的「共享库运行时路径」,不写进 clang 配置。
43
+ **共享库**:静态检查不因链接方式改变;运行时库路径由 `engineering` 的 target 设置负责,见 `../../engineering/references/cmake/targets/01-target-rules.md` 的「共享库运行时路径」,不写进 clang 配置。
44
44
 
45
45
  ## 正反例指针
46
46
 
47
- - `.clangd` 指错编译数据库、`query-driver` 写进 YAML:`../../engineering/references/formatting/examples/clangd.md`。
48
- - 配置文件堆策略头、关闭检查不写理由:`../../engineering/references/formatting/examples/clang-tidy.md`「配置注释」。
47
+ - `.clangd` 指错编译数据库、`query-driver` 写进 YAML:`../../engineering/references/formatting/examples/03-clangd.md`。
48
+ - 配置文件堆策略头、整族关闭检查:`../../engineering/references/formatting/examples/01-clang-format.md` 与 `../../engineering/references/formatting/examples/02-clang-tidy.md`。
49
49
  - 工具调用与头文件过滤:`../../engineering/references/formatting/03-clang-tidy.md`。
50
- - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/references/cmake/standard/standards/README.md`。
51
- - 编辑器扩展与设置:`../project/vscode/01-extensions.md`、`../project/vscode/02-settings.md`。
50
+ - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/references/cmake/standards/index.md`。
51
+ - 编辑器扩展与设置:`04-vscode.md`。
@@ -11,14 +11,14 @@
11
11
  1. **校验编码与行尾**:在仓库根跑编码检查。默认 UTF-8 无 BOM、LF;MSVC 原生工程加 `--profile msvc`。有问题先按 `../../engineering/references/formatting/01-encoding.md` 修正,不带着 BOM 或混用行尾继续;脚本退出码为 0 后再跑 `git diff --check`,有空白错误同样停在这里。
12
12
  2. **校验环境声明(不带 `--live`)**:读 `environment.json`,检查三个环境轴、`standard` 和组合是否合法。三个环境轴为空、`standard` 取值不在 `c++11`–`c++23` 内或组合非法时,停在这里,不找可执行文件;`standard` 缺失或为空时按默认 `c++23` 继续并提示声明升级。
13
13
  3. **活动校验**:在声明的 build host 上跑 `--live`,核对 PATH 中的角色和版本。`windows` + `native` 在声明校验阶段就返回失败,不会进入这一步。
14
- 4. **跑项目入口命令**:项目技能里写的入口命令(如 `./running-build.sh clang`)。入口命令仍是 `<entry-command>` 或空白时,停在这里,不要猜命令;是真实命令才跑。入口内部依次 configure → build → ctest → run;每一步失败都保留原始输出。有 `tests/` 目录时,脚本里的 ctest 必须带 `--output-on-failure --no-tests=error`;缺参数时按 `ctest --test-dir build/<compiler> --output-on-failure --no-tests=error` 补跑,并以补跑的退出码为准;没有测试目录时按「没有测试」情形处理,不补 `--no-tests=error`。入口通过后,再对项目源码跑 `clang-format --dry-run --Werror` 与 `clang-tidy -p build/<compiler> --header-filter="^$(pwd -P)/(include|src|apps|tests)/" --warnings-as-errors='*'`;任一非零即失败,命令细节见 `../../engineering/references/formatting/02-clang-format.md` 与 `03-clang-tidy.md`。
14
+ 4. **跑项目入口命令**:项目技能里写的入口命令(如 `./running-build.sh clang`)。入口命令仍是 `<entry-command>` 或空白时,停在这里,不要猜命令;是真实命令才跑。入口内部依次 configure → build → ctest → run;每一步失败都保留原始输出。有 `tests/` 目录时,脚本里的 ctest 必须带 `--output-on-failure --no-tests=error`;缺参数时按 `ctest --test-dir build/<compiler> --output-on-failure --no-tests=error` 补跑,并以补跑的退出码为准;没有测试目录时按「没有测试」情形处理,不补 `--no-tests=error`。入口通过后,再对项目源码跑 `clang-format --dry-run --Werror` 与 `clang-tidy -p build/<compiler> --header-filter="^$(pwd -P)/(include|src|app|tests)/" --warnings-as-errors='*'`;任一非零即失败,命令细节见 `../../engineering/references/formatting/02-clang-format.md` 与 `03-clang-tidy.md`。
15
15
  5. **核对产物**:`build/<compiler>/compile_commands.json` 存在;`build/compile_commands.json` 指向当前编译器;`app` 可执行文件在 `build/<compiler>/bin`。对 `app` 跑 `file` 与 `ldd`(macOS 用 `otool -L`),`ldd` 不得出现 `not found`,并做一次最小启动;见 `../../engineering/references/cmake/linking/04-inspect.md`。
16
16
  6. **记录结果**:通过时记录编译器版本、构建目录、测试数量;失败时记录命令、退出码、第一条根因诊断。
17
17
 
18
18
  编码检查与环境校验脚本(`<skill-dir>` 换成插件里 `building-cpp` 的实际目录):
19
19
 
20
20
  ```bash
21
- node "<skill-dir>/../engineering/references/formatting/scripts/checking-encoding.mjs" --profile portable # UTF-8 无 BOM、LF
21
+ node "<skill-dir>/../engineering/scripts/checking-encoding.mjs" --profile portable # UTF-8 无 BOM、LF
22
22
  node "<skill-dir>/scripts/checking-environment.mjs" --project . # 声明校验
23
23
  node "<skill-dir>/scripts/checking-environment.mjs" --project . --live # 活动校验
24
24
  ```
@@ -45,11 +45,11 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live # 活
45
45
 
46
46
  **只改源码**:仍跑完整入口命令;CTest 可能暴露声明层问题,不要只看编译通过。
47
47
 
48
- **改过 C++ 源码**:再按 `../../engineering/references/cmake/testing/ctest.md` 的运行顺序第 4 条,用 `-fsanitize=address,undefined -fno-omit-frame-pointer` 重新 configure 并跑一轮 CTest;报告按第一条栈帧定位,不靠猜。
48
+ **改过 C++ 源码**:再按 `../../engineering/references/cmake/testing/01-ctest.md` 的运行顺序第 4 条,用 `-fsanitize=address,undefined -fno-omit-frame-pointer` 重新 configure 并跑一轮 CTest;报告按第一条栈帧定位,不靠猜。
49
49
 
50
50
  **只改配置**:至少跑一次完整构建 + CTest;配置错误常常在链接或测试阶段才暴露。
51
51
 
52
- **没有测试**:项目确实还没有测试时,CTest 显示 0 条不算构建失败;不要为了「全绿」造空测试。已有公开行为却没有任何用例时,按 `../../engineering/references/cmake/testing/ctest.md` 的「先决定测什么」补成功与拒绝各一条,再跑 `--no-tests=error` 确认它真的被注册。
52
+ **没有测试**:项目确实还没有测试时,CTest 显示 0 条不算构建失败;不要为了「全绿」造空测试。已有公开行为却没有任何用例时,按 `../../engineering/references/cmake/testing/01-ctest.md` 的「先决定测什么」补成功与拒绝各一条,再跑 `--no-tests=error` 确认它真的被注册。
53
53
 
54
54
  **Windows 原生**:本版本不支持 `host=windows` + `build_host=native`。声明校验会返回 `ok: false`,`issues` 只有一句「本版本不能在 Windows 原生壳里构建」。停在这里,不要伪造 PowerShell 脚本,不要建议改 WSL 来绕过,也不要让代理改 `environment.json` 过关。
55
55
 
@@ -58,5 +58,5 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live # 活
58
58
  ## 正反例指针
59
59
 
60
60
  - 环境组合与 `--live` 输出:`../examples/environment.md`。
61
- - 失败分诊的具体命令:`../references/build-script.md`「失败分诊」。
61
+ - 失败分诊的具体命令:`../references/01-build-script.md`「失败分诊」。
62
62
  - 工具调用细节:`../../engineering/references/formatting/03-clang-tidy.md`。
@@ -1,8 +1,23 @@
1
- # 设置接线
1
+ # 第 4 步:VS Code 接线
2
2
 
3
- ## 什么时候打开
3
+ 只在工程已经有 `.vscode/` 时读本页;从当前目录向上到 git 根都没有 `.vscode/` 时,不打开本页,也不新建目录。新工程从 `../assets/config/.vscode/` 复制时除外。
4
4
 
5
- 工程已经有 `.vscode/` 时,格式、静态检查与 clangd 的选择落定后再读本页;没有 `.vscode/` 时不打开,也不新建。模板在 `../../assets/config/.vscode/settings.json`。
5
+ ## 三个角色
6
+
7
+ | 扩展 | 负责 | 不负责 |
8
+ | --- | --- | --- |
9
+ | `llvm-vs-code-extensions.vscode-clangd` | 补全、跳转、诊断、格式化 | 配置与构建 |
10
+ | `ms-vscode.cmake-tools` | 配置、构建、运行、调试入口 | 语言服务 |
11
+ | `ms-vscode.cpptools` | 只作为 `CMake: Debug` 的调试后端 | IntelliSense 与格式化(关闭) |
12
+
13
+ 不要同时开两套语言服务;C/C++ 扩展的 IntelliSense 必须关闭,否则会和 clangd 抢编译数据库。
14
+
15
+ ## 对照现有文件
16
+
17
+ 1. 读工程根 `.vscode/extensions.json`;已有推荐只补缺,不重排、不删除。
18
+ 2. 旧工程只写了 C/C++ 扩展时,加 clangd 与 CMake Tools,并在设置里关掉 IntelliSense,理由写在提交说明里。
19
+ 3. 不写 `tasks.json` 或 `launch.json`;配置、构建、运行和调试都从 CMake Tools 进入,构建命令仍以 `running-build.sh` 为准。
20
+ 4. 模板在 `../assets/config/.vscode/extensions.json`,只作为新工程的起点;工程已有文件时不复制整份覆盖。
6
21
 
7
22
  ## 复制后改三处
8
23
 
@@ -12,7 +27,7 @@
12
27
  | `clangd.arguments` 的 `--query-driver` | `/usr/bin/clang++` | `/usr/bin/g++` |
13
28
  | `cmake.debugConfig` | `MIMode: lldb`、`miDebuggerPath: /usr/bin/lldb` | `MIMode: gdb`、`miDebuggerPath: /usr/bin/gdb` |
14
29
 
15
- 只改与 `environment.json` 冲突的键;其余保持工程原值。`.clangd` 的 `CompilationDatabase` 也随编译器改,见 `../../../engineering/references/formatting/04-clangd.md`。
30
+ 只改与 `environment.json` 冲突的键;其余保持工程原值。`.clangd` 的 `CompilationDatabase` 也随编译器改,见 `../../engineering/references/formatting/04-clangd.md`。
16
31
 
17
32
  ## 各键分工
18
33
 
@@ -30,10 +45,13 @@
30
45
  - 不在设置里堆 `-I` / `-D` 或系统头路径;这些从 `compile_commands.json` 来。
31
46
  - 注释用 JSONC 的 `//`,只写为什么这样设。
32
47
 
33
- 下一步:设置与扩展对齐后,回到 [定工具配置](../../steps/02-tooling.md) 收尾,再进 [通过检查](../../steps/03-check.md)。
34
-
35
48
  ## 依据
36
49
 
50
+ - [clangd: Editor Plugins](https://clangd.llvm.org/installation#editor-plugins):VS Code 的 clangd 扩展与语言服务。
51
+ - [CMake Tools for VS Code](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/README.md):配置、构建、调试入口。
52
+ - [VS Code: Extension Recommendations](https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions):`extensions.json` 的 `recommendations`。
37
53
  - [clangd: Configuration](https://clangd.llvm.org/config):`.clangd` 与 `clangd.arguments`。
38
54
  - [CMake Tools: Settings](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md):`cmake.buildDirectory`、`cmake.generator`、`cmake.exportCompileCommandsFile`。
39
55
  - [VS Code: Debugging](https://code.visualstudio.com/docs/debugtest/debugging):`cppdbg` 调试配置与 `miDebuggerPath`。
56
+
57
+ 下一步:扩展与设置对齐后,回到 [定工具配置](02-tooling.md) 收尾,再进 [通过检查](03-check.md)。
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: developing-cpp
3
- description: 编写或修改 C++11–C++23 源码、头文件、命名、异常与源码注释时使用,新工程默认 C++23;一次改动同时碰到源码和构建文件时先打开本技能。不用于只改文档、Python、CMake、构建脚本或与 C++ 无关的文件。
3
+ description: 编写或修改 C++11–C++23 源码、头文件、命名、异常与源码注释时使用,新工程默认 C++23;编译错误、未定义行为、注释改写、类型或函数重新设计都从这里进。一次改动同时碰到源码和构建文件时先打开本技能。不用于只改文档、Python、CMake、构建脚本或与 C++ 无关的文件。
4
4
  metadata:
5
5
  short-description: C++11–C++23 源码四步
6
6
  ---
7
7
 
8
8
  # developing-cpp
9
9
 
10
- 本技能处理换一台机器也不会改的源码内容:可观察行为、库与程序的边界、声明、命名、异常与源码注释。文件槽位以 `references/layout/02-file-template.md` 为准,排版以 `references/style/google-cpp-style.md` 的 Google 基线为准,命名以 `references/naming/identifier-names.md` 为准。
10
+ 本技能处理换一台机器也不会改的源码内容:可观察行为、库与程序的边界、声明、命名、异常与源码注释。文件槽位以 `references/layout/02-file-template.md` 为准,排版以 `references/style/01-google-cpp-style.md` 的 Google 基线为准,命名以 `references/naming/01-identifier-names.md` 为准。加载顺序与层表见 [budget.md](../shared/budget.md)。
11
11
 
12
12
  ## 适用场景
13
13
 
@@ -15,11 +15,11 @@ metadata:
15
15
  - **不负责**:`CMakeLists.txt` 与 `cmake/` 开 `engineering`;`running-build.sh`、`.clang-*`、`.vscode/`、`environment.json` 开 `building-cpp`,本技能只读其中的 `standard`;`.qmd`、仓库 README、Python 与其他文档不打开本技能。
16
16
  - **交接**:一次改动跨域时按「源码 → engineering → building-cpp」逐段进入,前一段结论落下再开下一段。只改函数体、命名、异常或注释且入口命令可运行时,第 4 步后只开 `building-cpp` 的通过检查;新增或移动源文件、改库与程序的边界、补测试 target 时,完成前必须开 `engineering` 把文件写进 CMake。
17
17
  - **前置**:存在项目技能 `cpp-workflow-project` 时先读它的 `SKILL.md`:工程名、库与程序的边界、阶段表、术语增补、入口命令与语言档位。项目技能没写档位才读 `environment.json` 的 `standard`,两者都没有时才用新工程默认 C++23;声明 C++20 的工程里不写 C++23 才有的设施。没有项目技能时门禁不会放出本技能,不猜项目约定。
18
- - **编码**:源码与构建文件的编码以 `engineering` 的 `references/formatting/01-encoding.md` 为准;行尾与 `.clang-format` 的 `LineEnding` 跟仓库根 `.gitattributes` 与 `.editorconfig`。
18
+ - **编码**:源码与构建文件的编码以 `../engineering/references/formatting/01-encoding.md` 为准;行尾与 `.clang-format` 的 `LineEnding` 跟仓库根 `.gitattributes` 与 `.editorconfig`。
19
19
 
20
20
  ## 三种操作
21
21
 
22
- 一次只选一种,范围(单点、整段)是任务属性;判据、边界与交接见 `references/editing/01-edit-operations.md`。四类改动是域,不是操作。
22
+ 一次只选一种,范围(单点、整段)是任务属性;判据、边界与交接见共用入口 [operations.md](../shared/operations.md)。四类改动是域,不是操作。
23
23
 
24
24
  | 操作 | 什么时候用 | 从哪步进 |
25
25
  | --- | --- | --- |
@@ -41,7 +41,7 @@ metadata:
41
41
  | 3 | 定声明 | `steps/03-declaration.md` | 写命名、声明顺序、头文件契约和声明注释 |
42
42
  | 4 | 定实现 | `steps/04-implementation.md` | 写 `.cpp` 函数体的操作顺序、分组和实现注释 |
43
43
 
44
- 每步只打开同号的一个步骤文件;判不准才打开与该步对应的案例,完整条文只在排错、整目录重构,或步骤里明确指向某一条时打开。
44
+ 每步只打开同号的一个步骤文件;步骤里的 `references/…` 是出处和排错入口,不是必读清单;只有判不准、规则冲突,或该步明说「打开」某一份时才打开它。
45
45
 
46
46
  ## 入口表
47
47
 
@@ -49,27 +49,30 @@ metadata:
49
49
 
50
50
  | 改什么 | 从哪一份进 |
51
51
  | --- | --- |
52
+ | 不知道开哪一份条文 | `references/index.md` |
52
53
  | 行为、库与程序的边界 | `steps/01-behavior.md`、`steps/02-boundary.md`;案例在 `references/design/examples/` |
54
+ | 会话层、选着与程序边界 | `references/design/session-layer.md`;领域规则见 `references/design/01-project-design.md` |
53
55
  | 文件槽位、包含守卫、声明顺序 | `references/layout/02-file-template.md`、`references/layout/03-declaration-order.md` |
54
- | 命名与改名 | `references/naming/identifier-names.md`;案例在 `references/naming/examples/` |
55
- | 声明注释与实现注释 | `references/comments/comment-rules.md`(写什么)与 `comment-style.md`(结构、版式、措辞);案例在 `references/comments/examples/` |
56
- | 异常规则与异常案例 | `references/exceptions/throw-rules.md`;案例在 `references/exceptions/examples/` |
57
- | 结果类型、语言细节、标准库、性能 | `references/language/` 下按四类选一份:`value-types/`(宽度、符号、整数角色、枚举、强类型、const 成员、`[[nodiscard]]`、比较、下标、float/bool)、`language-basics/`(对象、初始化、推导、const、表达式、函数、类、RAII、模板)、`standard-library/`(容器、访问、迭代、算法、string、format、time、random、files)、`performance/`(测量、复杂度、内存、未定义行为、陷阱、伪优化);每类末尾读完成清单(`standard-library/10-checklist.md`、`value-types/11-checklist.md`、`language-basics/10-checklist.md`、`performance/07-checklist.md`) |
58
- | 操作判不准、规则冲突 | `references/editing/01-edit-operations.md`、`references/editing/02-rule-priority.md` |
56
+ | 命名与改名 | `references/naming/01-identifier-names.md`;案例在 `references/naming/examples/`;术语在 `references/naming/glossary/` |
57
+ | 声明注释与实现注释 | `references/comments/01-comment-rules.md`(写什么)与 `references/comments/02-style.md`(结构、版式、措辞);案例在 `references/comments/examples/` |
58
+ | 异常规则与异常案例 | `references/exceptions/01-exception-rules.md`;案例在 `references/exceptions/examples/` |
59
+ | 结果类型与值类型 | `references/language/value-types/`:宽度、符号、整数角色、枚举、强类型、const 成员、`[[nodiscard]]`、比较、下标、float/bool |
60
+ | 语言基础 | `references/language/language-basics/`:对象、初始化、推导、const、表达式、函数、类、RAII、模板 |
61
+ | 标准库 | `references/language/standard-library/`:容器、访问、迭代、算法、string、format、time、random、files |
62
+ | 性能与陷阱 | `references/language/performance/`:测量、复杂度、内存、未定义行为、陷阱、伪优化 |
63
+ | 操作判不准、规则冲突 | `../shared/operations.md`、`../shared/rule-priority.md` |
59
64
 
60
- 案例目录里没有数字前缀的文件按语义选;数字前缀只表示同一主题内的阅读顺序,不是案例编号。
65
+ 进入 `references/` 前先读 `references/index.md`,再按主题或语义选一份;数字前缀只表示同一主题内的阅读顺序,不是案例编号;每类末尾的完成清单在该类改完后读。
61
66
 
62
67
  ## 加载预算
63
68
 
64
- - 只开当前步对应的一个步骤文件;同一改动域内不同时展开两个技能的步骤。
65
- - 条文只开该步点名的一份;同号案例留到下一次激活。
66
- - 标准档只打开项目技能声明的那一档,没有声明时用本技能已有的新工程默认,不把其余标准档读进来。
69
+ 加载预算见 [budget.md](../shared/budget.md)。
67
70
 
68
71
  项目技能列出了检查命令时先跑它;无论有没有项目命令,都再跑本技能的 `scripts/checking-declaration-order.mjs`(定义顺序)与 `scripts/checking-comments.mjs`(注释);两者退出码为 0 后停在这一步,不再继续走没有失败的步骤。
69
72
 
70
73
  ## 四类改动
71
74
 
72
- 四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 `references/editing/01-edit-operations.md`;一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
75
+ 四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 [operations.md](../shared/operations.md);一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
73
76
 
74
77
  | 类型 | 典型请求 | 入口步骤 |
75
78
  | --- | --- | --- |
@@ -78,14 +81,14 @@ metadata:
78
81
  | 版式 | 只改缩进、行宽、包含顺序或注释符号 | `steps/03-declaration.md` |
79
82
  | 措辞 | 只改命名、只改注释措辞 | `steps/03-declaration.md` |
80
83
 
81
- 只改格式时不动行为,只改注释时不动签名;条文由入口步骤按需打开。同一处命中多条规则时,按 `references/editing/02-rule-priority.md` 的五级次序判:行为与契约 > 结构 > 清晰 > 一致 > 形式;高层未解决,不先做低层润色。
84
+ 只改格式时不动行为,只改注释时不动签名;条文由入口步骤按需打开。同一处命中多条规则时,按 `../shared/rule-priority.md` 的五级次序判:行为与契约 > 结构 > 清晰 > 一致 > 形式;高层未解决,不先做低层润色。
82
85
 
83
86
  ## 完成判据
84
87
 
85
88
  - [ ] 第 1 步的行为句能被用户或测试验收;有阶段表时只覆盖对应行,没有时只覆盖用户点名的行为。
86
89
  - [ ] 第 2 步的库 target 不依赖终端、GUI 或脚本;程序 target 只做装配和输入输出;共享抽象有第二个真实使用方。
87
- - [ ] 第 3 步的公共头文件自包含,命名、声明顺序和异常声明符合 `references/` 的条文。
90
+ - [ ] 第 3 步的公共头文件自包含,命名、声明顺序和异常声明符合 `references/` 的条文;类型注释只写本类型,纯值容器一句,初始状态归默认构造函数。
88
91
  - [ ] 第 4 步的实现只兑现声明;`.cpp` 定义顺序与头文件声明同序;同一文件里的函数按同一套分段约定,需要分阶段的都有阶段注释与空行;资源由 RAII 管理;失败是正常结果时用返回值,函数无法完成任务时抛异常,不拿异常做正常分支。
89
92
  - [ ] `.cpp` 定义顺序检查通过:`node "<skill-dir>/scripts/checking-declaration-order.mjs" --root <项目根>` 退出码为 0;有乱序先修,不能跳过。
90
- - [ ] 源码注释符合 `references/comments/comment-rules.md` 与 `comment-style.md` 的规范,`node "<skill-dir>/scripts/checking-comments.mjs" --root <项目根>` 退出码为 0,末行是「注释检查通过:N 个文件。」。
93
+ - [ ] 源码注释符合 `references/comments/01-comment-rules.md` 与 `02-style.md` 的规范,`node "<skill-dir>/scripts/checking-comments.mjs" --root <项目根>` 退出码为 0,末行是「注释检查通过:N 个文件。」。
91
94
  - [ ] 没有改 `CMakeLists.txt`、`.clang-*`、构建脚本,也没有把外部资料路径或项目专属类名写进通用条文。