@chengzhao-dev/dsh-cpp-workflow 0.6.20 → 0.7.3

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 (189) hide show
  1. package/README.en.md +23 -32
  2. package/README.md +24 -33
  3. package/cordis.patch.yml +6 -6
  4. package/lib/client.js +35 -23
  5. package/lib/comment-policy.js +15 -6
  6. package/lib/index.js +45 -37
  7. package/lib/workspace.js +10 -32
  8. package/package.json +7 -7
  9. package/skills/building-cpp/SKILL.md +24 -24
  10. package/skills/building-cpp/assets/templates/projects/common/running-build.sh +5 -1
  11. package/skills/building-cpp/project/vscode/01-extensions.md +6 -0
  12. package/skills/building-cpp/project/vscode/02-settings.md +7 -1
  13. package/skills/building-cpp/references/build-script.md +10 -3
  14. package/skills/building-cpp/references/environment.md +8 -1
  15. package/skills/building-cpp/scripts/checking-environment.mjs +11 -13
  16. package/skills/building-cpp/steps/01-build.md +5 -4
  17. package/skills/building-cpp/steps/02-tooling.md +10 -10
  18. package/skills/building-cpp/steps/03-check.md +13 -11
  19. package/skills/developing-cpp/SKILL.md +39 -40
  20. package/skills/developing-cpp/references/comments/comment-rules.md +195 -0
  21. package/skills/developing-cpp/references/comments/comment-style.md +76 -0
  22. package/skills/developing-cpp/references/comments/examples/declaration-class.md +65 -0
  23. package/skills/developing-cpp/references/comments/examples/declaration-constructor.md +22 -0
  24. package/skills/developing-cpp/references/comments/examples/declaration-enum.md +48 -0
  25. package/skills/developing-cpp/{source/07-comments → references/comments}/examples/declaration-file.md +5 -5
  26. package/skills/developing-cpp/references/comments/examples/declaration-function.md +135 -0
  27. package/skills/developing-cpp/references/comments/examples/declaration-member.md +23 -0
  28. package/skills/developing-cpp/{source/07-comments → references/comments}/examples/declaration-predicate.md +3 -2
  29. package/skills/developing-cpp/references/comments/examples/declaration-struct.md +18 -0
  30. package/skills/developing-cpp/references/comments/examples/implementation-body.md +81 -0
  31. package/skills/developing-cpp/references/comments/glossary/comment-terms.md +92 -0
  32. package/skills/developing-cpp/{source/03-design → references/design}/examples/coordinate-table.md +3 -3
  33. package/skills/developing-cpp/{source/03-design → references/design}/examples/header-place.md +1 -1
  34. package/skills/developing-cpp/references/design/examples/move-result.md +48 -0
  35. package/skills/developing-cpp/references/design/examples/preview-read.md +36 -0
  36. package/skills/developing-cpp/references/design/project-design.md +160 -0
  37. package/skills/developing-cpp/{source/01-editing → references/editing}/01-edit-operations.md +5 -3
  38. package/skills/developing-cpp/{source/01-editing → references/editing}/02-rule-priority.md +2 -2
  39. package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-build-mode.md +4 -4
  40. package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-message.md +10 -3
  41. package/skills/developing-cpp/references/exceptions/throw-rules.md +216 -0
  42. package/skills/developing-cpp/{source/05-language → references/language}/glossary/language-terms.md +2 -2
  43. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/01-objects.md +8 -2
  44. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/02-initialization.md +8 -1
  45. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/03-deduction.md +6 -0
  46. package/skills/developing-cpp/references/language/language-basics/04-const.md +25 -0
  47. package/skills/developing-cpp/references/language/language-basics/05-expressions.md +28 -0
  48. package/skills/developing-cpp/references/language/language-basics/06-functions.md +17 -0
  49. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/07-classes.md +7 -1
  50. package/skills/developing-cpp/references/language/language-basics/08-raii.md +15 -0
  51. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/09-templates.md +6 -0
  52. package/skills/developing-cpp/{source/05-language/01-language-basics → references/language/language-basics}/10-checklist.md +2 -1
  53. package/skills/developing-cpp/references/language/performance/01-measure.md +22 -0
  54. package/skills/developing-cpp/{source/05-language/04-performance → references/language/performance}/02-complexity.md +6 -0
  55. package/skills/developing-cpp/{source/05-language/04-performance → references/language/performance}/03-memory.md +7 -1
  56. package/skills/developing-cpp/{source/05-language/04-performance → references/language/performance}/04-undefined-behavior.md +9 -1
  57. package/skills/developing-cpp/{source/05-language/04-performance → references/language/performance}/05-pitfalls.md +6 -0
  58. package/skills/developing-cpp/references/language/performance/06-false-optimizations.md +13 -0
  59. package/skills/developing-cpp/{source/05-language/03-standard-library → references/language/standard-library}/01-containers.md +6 -0
  60. package/skills/developing-cpp/references/language/standard-library/02-access.md +14 -0
  61. package/skills/developing-cpp/{source/05-language/03-standard-library → references/language/standard-library}/03-iteration.md +6 -0
  62. package/skills/developing-cpp/{source/05-language/03-standard-library → references/language/standard-library}/04-algorithms.md +6 -0
  63. package/skills/developing-cpp/{source/05-language/03-standard-library → references/language/standard-library}/05-string.md +6 -0
  64. package/skills/developing-cpp/references/language/standard-library/06-format.md +114 -0
  65. package/skills/developing-cpp/references/language/standard-library/07-time.md +13 -0
  66. package/skills/developing-cpp/references/language/standard-library/08-random.md +13 -0
  67. package/skills/developing-cpp/references/language/standard-library/09-files.md +14 -0
  68. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/01-width.md +6 -0
  69. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/02-signed.md +7 -1
  70. package/skills/developing-cpp/references/language/value-types/03-integer-roles.md +38 -0
  71. package/skills/developing-cpp/references/language/value-types/04-enum.md +24 -0
  72. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/06-const-method.md +5 -0
  73. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/07-nodiscard.md +6 -0
  74. package/skills/developing-cpp/references/language/value-types/08-comparison.md +10 -0
  75. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/09-subscript.md +2 -1
  76. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/10-float-bool.md +6 -0
  77. package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/11-checklist.md +1 -1
  78. package/skills/developing-cpp/{source/04-layout → references/layout}/01-source-layout.md +8 -3
  79. package/skills/developing-cpp/{source/04-layout → references/layout}/02-file-template.md +14 -8
  80. package/skills/developing-cpp/references/layout/03-declaration-order.md +141 -0
  81. package/skills/developing-cpp/references/naming/examples/naming-accessor.md +28 -0
  82. package/skills/developing-cpp/references/naming/examples/naming-basic.md +3 -0
  83. package/skills/developing-cpp/references/naming/examples/naming-local.md +45 -0
  84. package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-lookup.md +1 -1
  85. package/skills/developing-cpp/references/naming/examples/naming-lower-layer.md +46 -0
  86. package/skills/developing-cpp/references/naming/examples/naming-player-value.md +15 -0
  87. package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-predicate.md +1 -1
  88. package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-role.md +1 -1
  89. package/skills/developing-cpp/references/naming/examples/naming-state-change.md +70 -0
  90. package/skills/developing-cpp/references/naming/glossary/naming-terms.md +23 -0
  91. package/skills/developing-cpp/references/naming/glossary/position.md +23 -0
  92. package/skills/developing-cpp/references/naming/glossary/square.md +47 -0
  93. package/skills/developing-cpp/references/naming/identifier-names.md +109 -0
  94. package/skills/developing-cpp/{source/02-style/01-google-cpp-style.md → references/style/google-cpp-style.md} +14 -13
  95. package/skills/developing-cpp/scripts/checking-comments.mjs +80 -15
  96. package/skills/developing-cpp/scripts/checking-declaration-order.mjs +383 -0
  97. package/skills/developing-cpp/steps/01-behavior.md +5 -5
  98. package/skills/developing-cpp/steps/02-boundary.md +9 -9
  99. package/skills/developing-cpp/steps/03-declaration.md +16 -14
  100. package/skills/developing-cpp/steps/04-implementation.md +22 -18
  101. package/skills/engineering/SKILL.md +43 -40
  102. package/skills/engineering/{cmake → references/cmake}/assets/CompileSettings.cmake +2 -0
  103. package/skills/engineering/{cmake → references/cmake}/linking/01-libraries.md +6 -0
  104. package/skills/engineering/references/cmake/linking/02-rpath.md +25 -0
  105. package/skills/engineering/{cmake → references/cmake}/linking/03-undefined-reference.md +7 -1
  106. package/skills/engineering/{cmake → references/cmake}/linking/04-inspect.md +6 -0
  107. package/skills/engineering/{cmake/02-modules/01-functions.md → references/cmake/modules/functions.md} +8 -5
  108. package/skills/engineering/{cmake/03-standard → references/cmake}/standards/README.md +12 -12
  109. package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++23/README.md +3 -3
  110. package/skills/engineering/{cmake/03-standard/01-cxx-standard.md → references/cmake/standards/cxx-standard.md} +8 -7
  111. package/skills/engineering/{cmake/01-targets → references/cmake/targets}/examples/target.md +2 -2
  112. package/skills/engineering/{cmake/01-targets/01-rules.md → references/cmake/targets/rules.md} +18 -11
  113. package/skills/engineering/{cmake → references/cmake}/testing/ctest.md +10 -3
  114. package/skills/engineering/{formatting → references/formatting}/01-encoding.md +1 -1
  115. package/skills/engineering/{formatting → references/formatting}/02-clang-format.md +7 -1
  116. package/skills/engineering/{formatting → references/formatting}/03-clang-tidy.md +7 -0
  117. package/skills/engineering/{formatting → references/formatting}/04-clangd.md +7 -0
  118. package/skills/engineering/references/formatting/examples/clang-format.md +38 -0
  119. package/skills/engineering/{formatting → references/formatting}/examples/clang-tidy.md +0 -21
  120. package/skills/engineering/{formatting → references/formatting}/scripts/checking-encoding.mjs +6 -7
  121. package/skills/engineering/{cmake/steps → steps}/01-targets.md +10 -9
  122. package/skills/engineering/{cmake/steps → steps}/02-modules.md +4 -4
  123. package/skills/engineering/{cmake/steps → steps}/03-check.md +5 -3
  124. package/skills/developing-cpp/source/03-design/01-project-design.md +0 -105
  125. package/skills/developing-cpp/source/03-design/examples/move-result.md +0 -39
  126. package/skills/developing-cpp/source/03-design/examples/preview-read.md +0 -40
  127. package/skills/developing-cpp/source/04-layout/03-declaration-order.md +0 -118
  128. package/skills/developing-cpp/source/05-language/01-language-basics/04-const.md +0 -15
  129. package/skills/developing-cpp/source/05-language/01-language-basics/05-expressions.md +0 -8
  130. package/skills/developing-cpp/source/05-language/01-language-basics/06-functions.md +0 -9
  131. package/skills/developing-cpp/source/05-language/01-language-basics/08-raii.md +0 -9
  132. package/skills/developing-cpp/source/05-language/02-value-types/03-integer-roles.md +0 -23
  133. package/skills/developing-cpp/source/05-language/02-value-types/04-enum.md +0 -17
  134. package/skills/developing-cpp/source/05-language/02-value-types/08-comparison.md +0 -4
  135. package/skills/developing-cpp/source/05-language/03-standard-library/02-access.md +0 -8
  136. package/skills/developing-cpp/source/05-language/03-standard-library/06-format.md +0 -44
  137. package/skills/developing-cpp/source/05-language/03-standard-library/07-time.md +0 -3
  138. package/skills/developing-cpp/source/05-language/03-standard-library/08-random.md +0 -3
  139. package/skills/developing-cpp/source/05-language/03-standard-library/09-files.md +0 -4
  140. package/skills/developing-cpp/source/05-language/04-performance/01-measure.md +0 -15
  141. package/skills/developing-cpp/source/05-language/04-performance/06-false-optimizations.md +0 -6
  142. package/skills/developing-cpp/source/06-naming/01-identifier-names.md +0 -78
  143. package/skills/developing-cpp/source/06-naming/examples/naming-accessor.md +0 -17
  144. package/skills/developing-cpp/source/06-naming/examples/naming-basic.md +0 -3
  145. package/skills/developing-cpp/source/06-naming/examples/naming-lower-layer.md +0 -39
  146. package/skills/developing-cpp/source/06-naming/examples/naming-player-mark.md +0 -17
  147. package/skills/developing-cpp/source/06-naming/examples/naming-state-change.md +0 -57
  148. package/skills/developing-cpp/source/07-comments/01-comment-rules.md +0 -239
  149. package/skills/developing-cpp/source/07-comments/examples/declaration-class.md +0 -44
  150. package/skills/developing-cpp/source/07-comments/examples/declaration-constructor.md +0 -22
  151. package/skills/developing-cpp/source/07-comments/examples/declaration-enum.md +0 -24
  152. package/skills/developing-cpp/source/07-comments/examples/declaration-function.md +0 -100
  153. package/skills/developing-cpp/source/07-comments/examples/declaration-member.md +0 -25
  154. package/skills/developing-cpp/source/07-comments/examples/declaration-struct.md +0 -18
  155. package/skills/developing-cpp/source/07-comments/examples/implementation-body.md +0 -42
  156. package/skills/developing-cpp/source/07-comments/glossary/comment-terms.md +0 -75
  157. package/skills/developing-cpp/source/08-exceptions/01-throw-rules.md +0 -160
  158. package/skills/engineering/cmake/linking/02-rpath.md +0 -17
  159. package/skills/engineering/formatting/examples/clang-format.md +0 -17
  160. /package/skills/developing-cpp/{source/07-comments → references/comments}/examples/implementation-todo.md +0 -0
  161. /package/skills/developing-cpp/{source/03-design → references/design}/examples/behavior-sentence.md +0 -0
  162. /package/skills/developing-cpp/{source/03-design → references/design}/examples/library-boundary.md +0 -0
  163. /package/skills/developing-cpp/{source/03-design → references/design}/examples/library-split.md +0 -0
  164. /package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-boundary.md +0 -0
  165. /package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-catch.md +0 -0
  166. /package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-destructor.md +0 -0
  167. /package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-format.md +0 -0
  168. /package/skills/developing-cpp/{source/08-exceptions → references/exceptions}/examples/throw-when.md +0 -0
  169. /package/skills/developing-cpp/{source/05-language/04-performance → references/language/performance}/07-checklist.md +0 -0
  170. /package/skills/developing-cpp/{source/05-language/03-standard-library → references/language/standard-library}/10-checklist.md +0 -0
  171. /package/skills/developing-cpp/{source/05-language/02-value-types → references/language/value-types}/05-strong-type.md +0 -0
  172. /package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-current-prefix.md +0 -0
  173. /package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-multiple-return.md +0 -0
  174. /package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-rename.md +0 -0
  175. /package/skills/developing-cpp/{source/06-naming → references/naming}/examples/naming-responsibility.md +0 -0
  176. /package/skills/engineering/{cmake → references/cmake}/assets/LinkSettings.cmake +0 -0
  177. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++11/README.md +0 -0
  178. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++11/cmake-snippet.cmake +0 -0
  179. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++14/README.md +0 -0
  180. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++14/cmake-snippet.cmake +0 -0
  181. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++17/README.md +0 -0
  182. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++17/cmake-snippet.cmake +0 -0
  183. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++20/README.md +0 -0
  184. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++20/cmake-snippet.cmake +0 -0
  185. /package/skills/engineering/{cmake/03-standard → references/cmake}/standards/c++23/cmake-snippet.cmake +0 -0
  186. /package/skills/engineering/{cmake/03-standard → references/cmake/standards}/examples/standard.md +0 -0
  187. /package/skills/engineering/{cmake/01-targets → references/cmake/targets}/examples/glob.md +0 -0
  188. /package/skills/engineering/{cmake/01-targets → references/cmake/targets}/examples/rpath.md +0 -0
  189. /package/skills/engineering/{formatting → references/formatting}/examples/clangd.md +0 -0
package/lib/workspace.js CHANGED
@@ -1,26 +1,12 @@
1
- // Workspace evidence for dsh-cpp-workflow.
1
+ // dsh-cpp-workflow 的工作区判定。
2
2
  //
3
- // A repository opts in only when it carries the project skill on the path from
4
- // the session cwd up to the git root. The marker is the opt-in declaration;
5
- // first-party C++ or CMake evidence is deliberately not part of the gate, so a
6
- // freshly copied template still sees the workflow. The git root is the
7
- // repository boundary: marker lookup ignores sibling directories and never
8
- // searches above the root.
3
+ // 仓库只有在「cwd 到 git 根的路径上带着项目技能」时才视为主动启用。标记文件
4
+ // 就是启用声明;C++ 或 CMake 证据刻意不参与,刚复制的模板照样能看到工作流。
5
+ // git 根是仓库边界:标记查找不进兄弟目录,也不向根之上继续。
9
6
  import { access } from 'node:fs/promises';
10
7
  import path from 'node:path';
11
8
  export const PROJECT_SKILL = path.join('.agents', 'skills', 'cpp-workflow-project', 'SKILL.md');
12
9
  export const MAX_ASCENT = 64;
13
- const SKIPPED_DIRS = new Set([
14
- '.git',
15
- 'node_modules',
16
- 'vendor',
17
- 'third_party',
18
- 'templates',
19
- 'build',
20
- 'temp',
21
- '.cache',
22
- ]);
23
- export const CPP_BUILD_FILES = new Set(['CMakeLists.txt']);
24
10
  async function exists(target) {
25
11
  try {
26
12
  await access(target);
@@ -30,7 +16,7 @@ async function exists(target) {
30
16
  return false;
31
17
  }
32
18
  }
33
- /** Nearest enclosing git checkout, including a worktree's `.git` file. */
19
+ /** 最近的上级 git 检出;worktree 的 `.git` 文件也算。 */
34
20
  export async function findGitRoot(cwd) {
35
21
  if (typeof cwd !== 'string' || cwd.trim() === '')
36
22
  return undefined;
@@ -52,9 +38,8 @@ export async function findGitRoot(cwd) {
52
38
  return undefined;
53
39
  }
54
40
  /**
55
- * Find the nearest project-skill marker between `cwd` and the git root,
56
- * inclusive. A marker above the git root never counts. The marker's directory
57
- * is also returned for diagnostics; it is not the repository boundary.
41
+ * 在 `cwd` 与 git 根之间(含两端)找最近的项目技能标记;根之上的标记不算。
42
+ * 同时返回标记所在目录供诊断,它不是仓库边界。
58
43
  */
59
44
  export async function findProjectSkill(cwd, gitRoot) {
60
45
  if (typeof cwd !== 'string' || cwd.trim() === '')
@@ -91,18 +76,11 @@ export async function findProjectSkill(cwd, gitRoot) {
91
76
  }
92
77
  return undefined;
93
78
  }
94
- /** Boolean form of {@link findProjectSkill}. */
95
- export async function hasProjectSkill(cwd, gitRoot) {
96
- return (await findProjectSkill(cwd, gitRoot)) !== undefined;
97
- }
98
79
  /**
99
- * Session gate. The project skill must sit between `cwd` and the git root
100
- * (inclusive). First-party C++ or CMake evidence is deliberately not required:
101
- * a freshly copied template still needs the workflow, and an empty project
102
- * legitimately stops at the build step.
80
+ * 会话门禁:项目技能必须位于 `cwd` 与 git 根之间(含两端)。不要求 C++ 或
81
+ * CMake 证据:刚复制的模板仍需要工作流,空工程也可以合法地停在构建步骤。
103
82
  *
104
- * No cwd, no git checkout, a marker above the git root, or a marker only in a
105
- * sibling directory returns false.
83
+ * 没有 cwd、不在 git 检出内、标记只在 git 根之上或只在兄弟目录时返回 false。
106
84
  */
107
85
  export async function isCppWorkflowWorkspace(cwd) {
108
86
  const gitRoot = await findGitRoot(cwd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chengzhao-dev/dsh-cpp-workflow",
3
- "version": "0.6.20",
3
+ "version": "0.7.3",
4
4
  "description": "写 C++ 源码、配 CMake、用 Clang 构建;头文件用 /// Doxygen 文档注释,函数体用 // 分段说明,文件头标签可在设置里改。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "engines": {
25
25
  "node": ">=22",
26
- "dsh": ">=0.2.0-rc.1 <0.3.0-0"
26
+ "dsh": ">=0.2.1-rc.1 <0.3.0-0"
27
27
  },
28
28
  "dsh": {
29
29
  "bundle": {
@@ -32,7 +32,7 @@
32
32
  "client": {
33
33
  "platform": "web",
34
34
  "inject": [
35
- "@deepseek-ai/dsh-client-ui-slots",
35
+ "@deepseek-ai/dsh-client-ui-renderer",
36
36
  "@deepseek-ai/dsh-client-ui-settings",
37
37
  "@deepseek-ai/dsh-client-ui-plugin-manager"
38
38
  ]
@@ -51,10 +51,10 @@
51
51
  "icon": "./icon.svg",
52
52
  "scripts": {
53
53
  "build": "tsc -p tsconfig.json && node scripts/building-client.mjs",
54
- "test": "npm run build && node scripts/building-client.mjs --check && node scripts/checking-skill-links.mjs && node skills/engineering/formatting/scripts/checking-encoding.mjs --quiet && node scripts/checking-github-workflows.mjs && node --test tests/*.test.mjs",
54
+ "test": "node scripts/building-client.mjs --check && npm run build && node scripts/checking-skill-links.mjs && node skills/engineering/references/formatting/scripts/checking-encoding.mjs --quiet && node scripts/checking-github-workflows.mjs && node --test tests/*.test.mjs",
55
55
  "ci": "npm ci && npm test && npm run pack:check",
56
56
  "ci:full": "npm run ci && npm run test:matrix",
57
- "check:encoding": "node skills/engineering/formatting/scripts/checking-encoding.mjs",
57
+ "check:encoding": "node skills/engineering/references/formatting/scripts/checking-encoding.mjs",
58
58
  "check:workflows": "node scripts/checking-github-workflows.mjs",
59
59
  "test:matrix": "bash scripts/checking-standard-matrix.sh",
60
60
  "pack:check": "npm pack --dry-run"
@@ -86,13 +86,13 @@
86
86
  "provenance": true
87
87
  },
88
88
  "peerDependencies": {
89
- "@deepseek-ai/dsh-skill": ">=0.2.0-rc.1 <0.3.0-0"
89
+ "@deepseek-ai/dsh-skill": ">=0.2.1-rc.1 <0.3.0-0"
90
90
  },
91
91
  "dependencies": {
92
92
  "@deepseek-ai/schemastery": "^3.18.5"
93
93
  },
94
94
  "devDependencies": {
95
- "@deepseek-ai/dsh-skill": ">=0.2.0-rc.1 <0.3.0-0",
95
+ "@deepseek-ai/dsh-skill": ">=0.2.1-rc.1 <0.3.0-0",
96
96
  "@types/node": "^22.20.5",
97
97
  "typescript": "^5.9.3",
98
98
  "yaml": "^2.9.1"
@@ -1,29 +1,27 @@
1
1
  ---
2
2
  name: building-cpp
3
- description: 在已写好 CMake 的 C++11–C++23 工程上配置、构建和检查时使用:Ninja、compile_commands.json、clang-format、clang-tidy、clangd、environment.json、running-build.sh 与工程内已有的 `.vscode/` 接线。不用于只改源码语义、文档、Python 或与 C++ 无关的文件。
3
+ description: 在已写好 CMake 的 C++11–C++23 工程上配置、构建和检查时使用:Ninja、compile_commands.json、CTest 失败、clang-format、clang-tidy、clangd、environment.json、running-build.sh 与工程内已有的 `.vscode/` 接线。不用于只改源码语义、文档、Python 或与 C++ 无关的文件。
4
4
  metadata:
5
5
  short-description: C++11–C++23 构建三步
6
6
  ---
7
7
 
8
8
  # building-cpp
9
9
 
10
- ## 适用场景
11
-
12
- 本技能处理环境声明、构建入口与工具配置:`environment.json`、`running-build.sh`、`.clang-format`、`.clang-tidy`、`.clangd`、`.vscode/`、构建命令、编译数据库、CTest 和运行。`CMakeLists.txt` 与 `cmake/` 下的 target、属性、标准和模块由 `engineering` 负责;本技能只读它们来配置和检查,不在这一步改 target 图。函数体、类型、命名、异常和源码注释只开 `developing-cpp`。
13
-
14
- 一次改动同时碰到源码和构建文件时,先打开 `developing-cpp` 定行为、边界与实现;需要新增或移动源文件、改库与程序的边界、补测试 target 时,转到 `engineering` 把文件写进 CMake;最后回到本技能做定工具配置与通过检查。只改函数体、命名、异常或注释且入口命令可运行时,定实现后只开本技能的「通过检查」。
15
-
16
- 存在项目技能 `cpp-workflow-project` 时先读它的 `SKILL.md`、`environment.json` 和 `stages/stage-table.md`。三个环境轴为空、`standard` 非法或组合非法时停在定构建,不猜 WSL、Clang 或构建目录;`windows` + `native` 直接拒绝,提示「本版本不能在 Windows 原生壳里构建」,不要给出补 PowerShell 的路线。
10
+ 本技能处理环境声明、构建入口与工具配置:`environment.json`、`running-build.sh`、`.clang-format`、`.clang-tidy`、`.clangd`、`.vscode/`、构建命令、编译数据库、CTest 与运行。
17
11
 
18
- 编译失败先分因:诊断指向函数体,回 `developing-cpp` 的定实现;诊断是找不到头、链接失败、target 不存在或标准不对,转 `engineering` 的对应步骤;诊断是没有编译数据库、format/tidy 不在 PATH 或配置不生效,留在本技能的定工具配置。
19
-
20
- 源码和构建文件用 UTF-8 无 BOM、检出 LF;`.bat` / `.cmd` 用 CRLF;`.clang-format` 写 `LineEnding: LF`。MSVC 原生构建优先加 `/utf-8`,不要靠 BOM 过关。完整规则见 `../engineering/formatting/01-encoding.md`,检查脚本是 `../engineering/formatting/scripts/checking-encoding.mjs`,机器规则以仓库根 `.gitattributes` 与 `.editorconfig` 为准。
12
+ ## 适用场景
21
13
 
22
- 工程根已有 `.vscode/` 时,扩展与设置按 `project/vscode/` 两页接线;从当前目录向上到 git 根都没有 `.vscode/` 时,不打开、也不新建。编辑器的配置、构建、运行和调试都从 CMake Tools 进入,构建仍以 `running-build.sh` 为准。
14
+ - **负责**:环境四轴与构建入口;工具配置的复制、落地与检查(规则条文归 `engineering`);编码、声明校验、活动校验、项目入口命令的次序。
15
+ - **不负责**:`CMakeLists.txt` 与 `cmake/` 下的 target、属性、标准与模块开 `engineering`,本技能只读它们来配置和检查,不在这一步改 target 图;函数体、类型、命名、异常与源码注释开 `developing-cpp`。
16
+ - **交接**:一次改动同时碰到源码和构建文件时,先开 `developing-cpp` 定行为、边界与实现;需要新增或移动源文件、改库与程序的边界、补测试 target 时,转 `engineering` 把文件写进 CMake;最后回到本技能定工具配置并通过检查。只改函数体、命名、异常或注释且入口命令可运行时,定实现后只开本技能的通过检查。
17
+ - **前置**:存在项目技能 `cpp-workflow-project` 时先读它的 `SKILL.md`、`environment.json` 和 `stages/stage-table.md`。三个环境轴为空、`standard` 非法或组合非法时停在定构建,不猜 WSL、Clang 或构建目录;`standard` 缺失或为空时按默认 `c++23` 继续并提示声明升级;`windows` + `native` 直接拒绝,提示「本版本不能在 Windows 原生壳里构建」,不给补 PowerShell 的路线。
18
+ - **分因**:编译失败时先看诊断指向哪一层。函数体问题回 `developing-cpp` 的定实现;找不到头、链接失败、target 不存在或标准不对转 `engineering` 的对应步骤;没有编译数据库、format/tidy 不在 PATH 或配置不生效留在本技能的定工具配置。
19
+ - **编码**:源码与构建文件用 UTF-8 无 BOM、检出 LF,`.bat` / `.cmd` 用 CRLF,`.clang-format` 写 `LineEnding: LF`;MSVC 原生构建优先加 `/utf-8`,不靠 BOM 过关。完整规则见 `../engineering/references/formatting/01-encoding.md`,机器规则以仓库根 `.gitattributes` 与 `.editorconfig` 为准。
20
+ - **编辑器**:工程根已有 `.vscode/` 时按 `project/vscode/` 两页接线;从当前目录向上到 git 根都没有 `.vscode/` 时不打开、也不新建。配置、构建、运行和调试都从 CMake Tools 进入,构建仍以 `running-build.sh` 为准。
23
21
 
24
22
  ## 三种操作
25
23
 
26
- 一次只选一种,范围(单点、整段)是任务属性。操作与域的判据、边界和交接见 `../developing-cpp/source/01-editing/01-edit-operations.md`;四类改动是域,不是操作。
24
+ 一次只选一种,范围(单点、整段)是任务属性;判据、边界与交接见 `../developing-cpp/references/editing/01-edit-operations.md`。四类改动是域,不是操作。
27
25
 
28
26
  | 操作 | 什么时候用 | 从哪步进 |
29
27
  | --- | --- | --- |
@@ -31,7 +29,9 @@ metadata:
31
29
  | 改写 | 环境轴与 target 契约不变,工具配置位置或流程顺序不对 | 从第 2 步重走,可到第 3 步 |
32
30
  | 润色 | 只改诊断措辞或失败分流说明 | 第 3 步 |
33
31
 
34
- 三种操作共用这些约束:不发明项目没有声明的环境轴、命令和 target;只改格式或配置时不改可观察行为;不覆盖已有源码、`CMakeLists.txt` 和 `.clang-*`;不安装工具链;代理侧不写 `wsl` 或 `bash -lc`。后一步发现前一步没做完,退回那一步。拿不准先用单点修正;发现环境轴、编译器、构建目录或 target 契约需要改,退回整段,并转 `engineering`。
32
+ - 不发明项目没有声明的环境轴、命令和 target;只改格式或配置时不改可观察行为。
33
+ - 不覆盖已有源码、`CMakeLists.txt` 和 `.clang-*`;不安装工具链;代理侧不写 `wsl` 或 `bash -lc`。
34
+ - 后一步发现前一步没做完,退回那一步;发现环境轴、编译器、构建目录或 target 契约需要改,整段退回并转 `engineering`。
35
35
 
36
36
  ## 步骤
37
37
 
@@ -41,31 +41,31 @@ metadata:
41
41
  | 2 | 定工具配置 | `steps/02-tooling.md` | 格式化、静态检查、clangd 各管一段,互不越界 |
42
42
  | 3 | 通过检查 | `steps/03-check.md` | 按编码 → 声明校验 → 活动校验 → 项目入口的次序跑,前一步失败就停 |
43
43
 
44
- ### 入口表
44
+ 每步只打开同号的一个步骤文件。判不准才打开 `examples/` 里与该步对应的案例;`references/` 保存完整条文,只在排错、整目录重构,或步骤里明确指向某一条时打开。
45
+
46
+ ## 入口表
45
47
 
46
48
  | 要做的事 | 打开 |
47
49
  | --- | --- |
48
50
  | 读环境轴、配置与构建 | `steps/01-build.md`;条文 `references/environment.md`;案例 `examples/environment.md` |
49
- | 配 `.clang-format`、`.clang-tidy`、`.clangd` | `steps/02-tooling.md`;条文在 `../engineering/formatting/`,一次一份 |
51
+ | 配 `.clang-format`、`.clang-tidy`、`.clangd` | `steps/02-tooling.md`;条文在 `../engineering/references/formatting/`,一次一份 |
50
52
  | 工程已有 `.vscode/`,接扩展与设置 | `project/vscode/01-extensions.md` 或 `02-settings.md`;没有 `.vscode/` 不打开也不新建 |
51
53
  | 编码、声明校验、活动校验与入口命令 | `steps/03-check.md`;条文 `references/build-script.md` |
52
54
  | 新工程模板与可复制配置 | `assets/templates/projects/`、`assets/config/` |
53
55
 
54
- 每步只打开同号的一个步骤文件。判不准才打开 `examples/` 里与该步对应的案例;`references/` 保存完整条文,只在排错、整目录重构,或步骤里明确指向某一条文时按需打开。链接、rpath 与产物布局读 `../engineering/cmake/linking/01-libraries.md`;测试设计、断言与 CTest 注册读 `../engineering/cmake/testing/ctest.md`;CMake 的 target、标准和函数写法读 `../engineering/cmake/`,可复用片段在 `../engineering/cmake/assets/`。
55
-
56
- 入口脚本只做配置、构建、CTest 与最小运行;`clang-format` 与 `clang-tidy` 的手动检查留在定工具配置,不塞进入口脚本。`environment.json` 的三个环境轴与 `standard` 是唯一来源,缺项就停。
56
+ 链接、rpath 与产物布局读 `../engineering/references/cmake/linking/01-libraries.md`;测试设计、断言与 CTest 注册读 `../engineering/references/cmake/testing/ctest.md`;CMake 的 target、标准与函数写法读 `../engineering/references/cmake/`,可复用片段在 `../engineering/references/cmake/assets/`。
57
57
 
58
- 本轮激活按三条上限走:
58
+ ## 加载预算
59
59
 
60
- - 只开当前步对应的一个步骤文件;同一改动域内不同时展开两个技能的步骤。跨域按 `源码 → engineering → building-cpp` 的顺序逐段进入,前一段结论落下再开下一段。
60
+ - 只开当前步对应的一个步骤文件;同一改动域内不同时展开两个技能的步骤。
61
61
  - 条文只开该步点名的一份;同号案例留到下一次激活。
62
62
  - 标准档只打开项目技能声明的那一档,没有声明时用本技能已有的新工程默认,不把其余标准档读进来。
63
63
 
64
- 项目技能列出了检查命令时只跑那一条,没有时跑本技能自己的 `scripts/checking-environment.mjs` 与 `../engineering/formatting/scripts/checking-encoding.mjs`;退出码为 0 后在同一轮结束 goal,不再继续走没有失败的步骤。
64
+ 项目技能列出了检查命令时只跑那一条,没有时跑本技能自己的 `scripts/checking-environment.mjs` 与 `../engineering/references/formatting/scripts/checking-encoding.mjs`;退出码为 0 后停在这一步,不再继续走没有失败的步骤。入口脚本只做配置、构建、CTest 与最小运行;`clang-format` 与 `clang-tidy` 的手动检查留在定工具配置,不塞进入口脚本。`environment.json` 的三个环境轴与 `standard` 是唯一来源,缺项就停。
65
65
 
66
- ### 四类改动
66
+ ## 四类改动
67
67
 
68
- 四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 `../developing-cpp/source/01-editing/01-edit-operations.md`;一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
68
+ 四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 `../developing-cpp/references/editing/01-edit-operations.md`;一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
69
69
 
70
70
  | 类型 | 典型请求 | 入口步骤 |
71
71
  | --- | --- | --- |
@@ -70,7 +70,11 @@ main() {
70
70
  "${BUILD_ROOT}/compile_commands.json"
71
71
 
72
72
  header "测试"
73
- ctest --test-dir "${BUILD_DIR}" --output-on-failure
73
+ if [ -d tests ]; then
74
+ ctest --test-dir "${BUILD_DIR}" --output-on-failure --no-tests=error
75
+ else
76
+ ctest --test-dir "${BUILD_DIR}" --output-on-failure
77
+ fi
74
78
 
75
79
  header "运行 ${APP_NAME}"
76
80
  (
@@ -20,3 +20,9 @@
20
20
  4. 模板在 `../../assets/config/.vscode/extensions.json`,只作为新工程的起点;工程已有文件时不复制整份覆盖。
21
21
 
22
22
  下一步:扩展对齐后,读 [02-settings.md](02-settings.md) 接线设置。
23
+
24
+ ## 依据
25
+
26
+ - [clangd: Editor Plugins](https://clangd.llvm.org/installation#editor-plugins):VS Code 的 clangd 扩展与语言服务。
27
+ - [CMake Tools for VS Code](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/README.md):配置、构建、调试入口。
28
+ - [VS Code: Extension Recommendations](https://code.visualstudio.com/docs/editor/extension-marketplace#_workspace-recommended-extensions):`extensions.json` 的 `recommendations`。
@@ -12,7 +12,7 @@
12
12
  | `clangd.arguments` 的 `--query-driver` | `/usr/bin/clang++` | `/usr/bin/g++` |
13
13
  | `cmake.debugConfig` | `MIMode: lldb`、`miDebuggerPath: /usr/bin/lldb` | `MIMode: gdb`、`miDebuggerPath: /usr/bin/gdb` |
14
14
 
15
- 只改与 `environment.json` 冲突的键;其余保持工程原值。`.clangd` 的 `CompilationDatabase` 也随编译器改,见 `../../../engineering/formatting/04-clangd.md`。
15
+ 只改与 `environment.json` 冲突的键;其余保持工程原值。`.clangd` 的 `CompilationDatabase` 也随编译器改,见 `../../../engineering/references/formatting/04-clangd.md`。
16
16
 
17
17
  ## 各键分工
18
18
 
@@ -31,3 +31,9 @@
31
31
  - 注释用 JSONC 的 `//`,只写为什么这样设。
32
32
 
33
33
  下一步:设置与扩展对齐后,回到 [定工具配置](../../steps/02-tooling.md) 收尾,再进 [通过检查](../../steps/03-check.md)。
34
+
35
+ ## 依据
36
+
37
+ - [clangd: Configuration](https://clangd.llvm.org/config):`.clangd` 与 `clangd.arguments`。
38
+ - [CMake Tools: Settings](https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md):`cmake.buildDirectory`、`cmake.generator`、`cmake.exportCompileCommandsFile`。
39
+ - [VS Code: Debugging](https://code.visualstudio.com/docs/debugtest/debugging):`cppdbg` 调试配置与 `miDebuggerPath`。
@@ -12,7 +12,7 @@
12
12
  clang-format --dry-run --Werror src/*.cpp include/*.h
13
13
  ```
14
14
 
15
- 需要修复时单独运行 `clang-format -i`,再回看 diff。`clang-format` 只排版,不会把行尾注释搬到上一行;数据成员注释位置按 `developing-cpp/source/07-comments/01-comment-rules.md` 的规则和 `checking-comments.mjs` 检查。
15
+ 需要修复时单独运行 `clang-format -i`,再回看 diff。`clang-format` 只排版,不会把行尾注释搬到上一行;数据成员注释位置按 `developing-cpp/references/comments/comment-rules.md` 的规则和 `checking-comments.mjs` 检查。
16
16
 
17
17
  ## 用法
18
18
 
@@ -34,7 +34,7 @@ clang-format --dry-run --Werror src/*.cpp include/*.h
34
34
  4. **configure**:每次运行都重新 configure,不复用缓存;传 `-G Ninja`、`-DCMAKE_BUILD_TYPE=Debug`、`-DCMAKE_C_COMPILER`、`-DCMAKE_CXX_COMPILER`、`-DCMAKE_EXPORT_COMPILE_COMMANDS=ON`。C 与 C++ 使用同一套编译器;没有 C 语言的工程会忽略 C 编译器设置。
35
35
  5. **build**:`cmake --build "$BUILD_DIR"`。
36
36
  6. **编译数据库链接**:先 `rm -f build/compile_commands.json`,再 `ln -s "${COMPILER}/compile_commands.json" build/compile_commands.json`;不用 `ln -n`,它在 BSD/macOS 上不可移植。
37
- 7. **test**:`ctest --test-dir "$BUILD_DIR" --output-on-failure`;没有测试时 CTest 成功。
37
+ 7. **test**:有 `tests/` 目录时 `ctest --test-dir "$BUILD_DIR" --output-on-failure --no-tests=error`,防止测试 discovery 失败后 0 条也算通过;没有测试目录时 `ctest --test-dir "$BUILD_DIR" --output-on-failure`,0 条不算失败。
38
38
  8. **run**:`(cd "$BUILD_DIR/bin" && "./$APP_NAME")`;共享库的运行时路径由定构建的 CMake RPATH 负责,不在脚本里设全局 `LD_LIBRARY_PATH`。
39
39
 
40
40
  最后一行是 `main "$@"`;函数定义在 `main()` 之前,`set` / `readonly` 在最前。
@@ -58,7 +58,7 @@ clang-format --dry-run --Werror src/*.cpp include/*.h
58
58
  - `Check`:两种模式都在条件不成立时打印诊断并终止。
59
59
  - `DebugCheck`:只在 Debug 生效,`NDEBUG` 后展开为空,参数不能带副作用。
60
60
 
61
- 不要写成 Debug 抛异常、Release 返回 false 的模式分支;这会把调用方逼成两套逻辑。规则详见 `developing-cpp/source/08-exceptions/01-throw-rules.md`。
61
+ 不要写成 Debug 抛异常、Release 返回 false 的模式分支;这会把调用方逼成两套逻辑。规则详见 `developing-cpp/references/exceptions/throw-rules.md`。
62
62
 
63
63
  ## 失败分诊
64
64
 
@@ -79,3 +79,10 @@ clang-format --dry-run --Werror src/*.cpp include/*.h
79
79
  - 切换编译器后 `build/compile_commands.json` 指向新数据库。
80
80
  - 调用者的 `LD_LIBRARY_PATH` 在脚本结束后不变。
81
81
  - Windows 原生:声明校验已拒绝该组合;不要伪造 PowerShell 脚本,也不要绕过声明。
82
+
83
+ ## 依据
84
+
85
+ - [CMake: `cmake(1)`](https://cmake.org/cmake/help/latest/manual/cmake.1.html):`-S`、`-B`、`--build` 与 `-G Ninja`。
86
+ - [CMake: `ctest(1)`](https://cmake.org/cmake/help/latest/manual/ctest.1.html):`--test-dir`、`--output-on-failure`、`--no-tests=error`。
87
+ - [Ninja Manual](https://ninja-build.org/manual.html):构建目录与增量构建。
88
+ - [GNU Bash Reference: `set -euo pipefail`](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html):脚本的失败即停与未定义变量检查。
@@ -105,4 +105,11 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live
105
105
  | 3 | 活动校验失败:不在声明的 build host、角色缺失、版本不符 |
106
106
  | 1 | 脚本自身错误:参数错误或内部异常 |
107
107
 
108
- 各标准对应的编译器、库设施和工具档位见 [../../engineering/cmake/03-standard/standards/README.md](../../engineering/cmake/03-standard/standards/README.md)。
108
+ 各标准对应的编译器、库设施和工具档位见 [../../engineering/references/cmake/standards/README.md](../../engineering/references/cmake/standards/README.md)。
109
+
110
+ ## 依据
111
+
112
+ - [CMake: Compilers](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html):编译器探测与 `CMAKE_<LANG>_COMPILER`。
113
+ - [CMake: `CMakePresets.json`](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html):preset 的继承、生成器与构建目录。
114
+ - [GCC: `--version`](https://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html):版本输出与 `-dumpfullversion`。
115
+ - [Clang: Command Line](https://clang.llvm.org/docs/CommandGuide/clang.html):`--version` 与目标平台输出。
@@ -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/cmake/01-targets/01-rules.md` 或 `../../engineering/cmake/03-standard/01-cxx-standard.md` 被点名的一份;CMake 的写改仍由 `engineering` 落笔。
18
+ 先读项目技能与 `environment.json`,再确认 `engineering` 已经把 target 图、公共 include、语言标准和输出目录写进 CMake。target 缺失、标准不对、include 或链接边界没写时,停止本步,转 `engineering` 的定 target 与标准;不要在这里用全局变量或临时 `-std` 绕过。 只在需要核对时打开 `../../engineering/references/cmake/targets/rules.md` 或 `../../engineering/references/cmake/standards/cxx-standard.md` 被点名的一份;CMake 的写改仍由 `engineering` 落笔。
19
19
 
20
20
  ## 环境
21
21
 
@@ -26,7 +26,7 @@ build/
26
26
  | `compiler` | `clang` / `gcc` | 用哪个编译器;一次只配一个 |
27
27
  | `standard` | `c++11`–`c++23` | 一个工程一个语言标准;新工程默认 `c++23`,已有工程按原声明 |
28
28
 
29
- 环境轴为空、`standard` 非法或组合非法时,停在定构建,先让用户把 `environment.json` 填对。不要替用户选 WSL、Clang 或构建目录。`windows` + `native` 只给一句「本版本不能在 Windows 原生壳里构建」。
29
+ 三个环境轴为空、`standard` 取值不在 `c++11`–`c++23` 内或组合非法时,停在定构建,先让用户把 `environment.json` 填对。`standard` 缺失或为空时按默认 `c++23` 继续并提示声明升级,不按非法声明停下。不要替用户选 WSL、Clang 或构建目录。`windows` + `native` 只给一句「本版本不能在 Windows 原生壳里构建」。
30
30
 
31
31
  ## 规则
32
32
 
@@ -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,11 +51,11 @@ 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;不要依赖上一次缓存。
54
+ GCC 模式把目录和编译器换成 `build/gcc`、`g++`(C 驱动换成 `gcc`)。每次构建都重新 configure;不要依赖上一次缓存。C 与 C++ 驱动一起换,不要只换 C++ 驱动。
54
55
 
55
56
  ## 情况
56
57
 
57
- **新工程**:从 `../assets/templates/projects/` 选形态;模板缺 target 时先转 `engineering`,target 齐了再 configure。
58
+ **新工程**:从 `../assets/templates/projects/` 选形态;把 `../assets/templates/projects/common/running-build.sh` 复制到工程根,`chmod +x` 并用 `bash -n` 验证语法。模板缺 target 时先转 `engineering`,target 齐了再 configure。
58
59
 
59
60
  **已有工程**:先读现有 `CMakeLists.txt`,只核对 target、标准与输出目录;不改与当前任务无关的 target,大改前先让现有构建跑通。
60
61
 
@@ -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/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`:模板资产写 `Latest`;工程按 `environment.json` 声明 C++11–C++20 时,把 `Standard` 改成 `c++NN`(映射见 `../../engineering/cmake/03-standard/standards/README.md`)。clang-format 21/22 的 `Standard` 不接受 `c++23`,所以 C++23 工程仍写 `Latest`。列宽、缩进与包含顺序以工程根 `.clang-format` 为准;工程显式写 `ColumnLimit` 时按工程值执行,模板资产不写 `ColumnLimit`。需要新规则时先改 `source/02-style/01-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/README.md`)。clang-format 21/22 的 `Standard` 不接受 `c++23`,23 起才接受;为兼容旧工具,C++23 工程仍写 `Latest`。列宽、缩进与包含顺序以工程根 `.clang-format` 为准;工程显式写 `ColumnLimit` 时按工程值执行,模板资产不写 `ColumnLimit`。需要新规则时先改 `../../developing-cpp/references/style/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
21
  - 格式化与静态检查只扫描项目源码:`src/`、`include/`、`apps/`、`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/source/07-comments/01-comment-rules.md` 检查。
23
+ - 格式化用 `--dry-run --Werror` 做检查;需要自动修复时单独运行 `-i`,不要让构建脚本悄悄改源码。`clang-format` 只排版,不会把行尾注释搬到上一行;数据成员注释位置按 `../../developing-cpp/references/comments/comment-rules.md` 检查。
24
24
  - 工程模板里不预置 `compile_commands.json`;它由定构建的 configure 生成,是构建产物。
25
25
 
26
26
  ## 编辑器接线
27
27
 
28
28
  - 只在工程根(当前目录到 git 根)已经有 `.vscode/` 时读 `../project/vscode/01-extensions.md` 或 `../project/vscode/02-settings.md`;没有 `.vscode/` 时不打开,也不新建目录。
29
29
  - 顺序:先定 `.clang-format`、`.clang-tidy`、`.clangd`,再对照现有 `.vscode/extensions.json` 与 `settings.json` 只补缺、只改与 `environment.json` 冲突的项。
30
- - 一次只读 `../project/vscode/` 里被点名的一页;扩展与设置不要同时展开。工具条文一次只开 `../../engineering/formatting/` 里被点名的一份,其余留到下一次激活。
30
+ - 一次只读 `../project/vscode/` 里被点名的一页;扩展与设置不要同时展开。工具条文一次只开 `../../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/` 时按 `../project/vscode/` 两页接线;已有工程没有 `.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 设置负责,见其 `cmake/01-targets/01-rules.md`,不写进 clang 配置。
43
+ **共享库**:静态检查不因链接方式改变;运行时库路径由 `engineering` 的 target 设置负责,见 `../../engineering/references/cmake/targets/rules.md` 的「共享库运行时路径」,不写进 clang 配置。
44
44
 
45
45
  ## 正反例指针
46
46
 
47
- - `.clangd` 指错编译数据库、`query-driver` 写进 YAML:`../../engineering/formatting/examples/clangd.md`。
48
- - 配置文件堆策略头、关闭检查不写理由:`../../engineering/formatting/examples/clang-tidy.md`「配置注释」。
49
- - 工具调用与头文件过滤:`../../engineering/formatting/03-clang-tidy.md`。
50
- - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/cmake/03-standard/standards/README.md`。
47
+ - `.clangd` 指错编译数据库、`query-driver` 写进 YAML:`../../engineering/references/formatting/examples/clangd.md`。
48
+ - 配置文件堆策略头、关闭检查不写理由:`../../engineering/references/formatting/examples/clang-tidy.md`「配置注释」。
49
+ - 工具调用与头文件过滤:`../../engineering/references/formatting/03-clang-tidy.md`。
50
+ - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/references/cmake/standards/README.md`。
51
51
  - 编辑器扩展与设置:`../project/vscode/01-extensions.md`、`../project/vscode/02-settings.md`。
@@ -8,22 +8,22 @@
8
8
 
9
9
  按固定顺序跑,前一步失败就停,不要带着失败继续:
10
10
 
11
- 1. **校验编码与行尾**:在仓库根跑编码检查。默认 UTF-8 无 BOM、LF;MSVC 原生工程加 `--profile msvc`。有问题先按 `../../engineering/formatting/01-encoding.md` 修正,不带着 BOM 或混用行尾继续。
12
- 2. **校验环境声明(不带 `--live`)**:读 `environment.json`,检查三个环境轴、`standard` 和组合是否合法。环境轴为空、`standard` 非法或组合非法时,停在这里,不找可执行文件。
11
+ 1. **校验编码与行尾**:在仓库根跑编码检查。默认 UTF-8 无 BOM、LF;MSVC 原生工程加 `--profile msvc`。有问题先按 `../../engineering/references/formatting/01-encoding.md` 修正,不带着 BOM 或混用行尾继续;脚本退出码为 0 后再跑 `git diff --check`,有空白错误同样停在这里。
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;每一步失败都保留原始输出。
15
- 5. **核对产物**:`build/<compiler>/compile_commands.json` 存在;`build/compile_commands.json` 指向当前编译器;`app` 可执行文件在 `build/<compiler>/bin`。
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`。
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>/scripts/checking-encoding.mjs" --profile portable # UTF-8 无 BOM、LF
21
+ node "<skill-dir>/../engineering/references/formatting/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
  ```
25
25
 
26
- `<skill-dir>` 换成插件里 `building-cpp` 的实际目录;不要复制脚本到项目里再改。脚本只读,不安装、不下载、不改 PATH。
26
+ 脚本只读,不安装、不下载、不改 PATH;不要复制到项目里再改。
27
27
 
28
28
  ## 失败分诊
29
29
 
@@ -45,9 +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;报告按第一条栈帧定位,不靠猜。
49
+
48
50
  **只改配置**:至少跑一次完整构建 + CTest;配置错误常常在链接或测试阶段才暴露。
49
51
 
50
- **没有测试**:项目确实还没有测试时,CTest 显示 0 条不算构建失败;不要为了「全绿」造空测试。已有公开行为却没有任何用例时,按 `../../engineering/cmake/testing/ctest.md` 的「先决定测什么」补成功与拒绝各一条,再跑 `--no-tests=error` 确认它真的被注册。
52
+ **没有测试**:项目确实还没有测试时,CTest 显示 0 条不算构建失败;不要为了「全绿」造空测试。已有公开行为却没有任何用例时,按 `../../engineering/references/cmake/testing/ctest.md` 的「先决定测什么」补成功与拒绝各一条,再跑 `--no-tests=error` 确认它真的被注册。
51
53
 
52
54
  **Windows 原生**:本版本不支持 `host=windows` + `build_host=native`。声明校验会返回 `ok: false`,`issues` 只有一句「本版本不能在 Windows 原生壳里构建」。停在这里,不要伪造 PowerShell 脚本,不要建议改 WSL 来绕过,也不要让代理改 `environment.json` 过关。
53
55
 
@@ -55,6 +57,6 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live # 活
55
57
 
56
58
  ## 正反例指针
57
59
 
58
- - 环境组合与 `--live` 输出:`examples/environment.md`。
59
- - 失败分诊的具体命令:`references/build-script.md`「失败分诊」。
60
- - 工具调用细节:`../../engineering/formatting/03-clang-tidy.md`。
60
+ - 环境组合与 `--live` 输出:`../examples/environment.md`。
61
+ - 失败分诊的具体命令:`../references/build-script.md`「失败分诊」。
62
+ - 工具调用细节:`../../engineering/references/formatting/03-clang-tidy.md`。