@chengzhao-dev/dsh-cpp-workflow 0.7.1 → 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 (88) 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 +2 -2
  5. package/lib/index.js +45 -37
  6. package/lib/workspace.js +10 -17
  7. package/package.json +1 -1
  8. package/skills/building-cpp/SKILL.md +3 -3
  9. package/skills/building-cpp/assets/templates/projects/common/running-build.sh +0 -0
  10. package/skills/building-cpp/references/environment.md +1 -1
  11. package/skills/building-cpp/scripts/checking-environment.mjs +11 -13
  12. package/skills/building-cpp/steps/01-build.md +3 -2
  13. package/skills/building-cpp/steps/02-tooling.md +2 -2
  14. package/skills/developing-cpp/SKILL.md +10 -7
  15. package/skills/developing-cpp/references/comments/comment-rules.md +56 -42
  16. package/skills/developing-cpp/references/comments/comment-style.md +8 -12
  17. package/skills/developing-cpp/references/comments/examples/declaration-class.md +15 -16
  18. package/skills/developing-cpp/references/comments/examples/declaration-constructor.md +1 -1
  19. package/skills/developing-cpp/references/comments/examples/declaration-enum.md +17 -17
  20. package/skills/developing-cpp/references/comments/examples/declaration-file.md +3 -3
  21. package/skills/developing-cpp/references/comments/examples/declaration-function.md +30 -22
  22. package/skills/developing-cpp/references/comments/examples/declaration-member.md +3 -3
  23. package/skills/developing-cpp/references/comments/examples/declaration-predicate.md +1 -1
  24. package/skills/developing-cpp/references/comments/examples/declaration-struct.md +3 -3
  25. package/skills/developing-cpp/references/comments/examples/implementation-body.md +34 -17
  26. package/skills/developing-cpp/references/comments/glossary/comment-terms.md +30 -31
  27. package/skills/developing-cpp/references/design/examples/coordinate-table.md +3 -3
  28. package/skills/developing-cpp/references/design/examples/header-place.md +1 -1
  29. package/skills/developing-cpp/references/design/examples/move-result.md +31 -22
  30. package/skills/developing-cpp/references/design/examples/preview-read.md +6 -10
  31. package/skills/developing-cpp/references/design/project-design.md +17 -14
  32. package/skills/developing-cpp/references/editing/01-edit-operations.md +1 -1
  33. package/skills/developing-cpp/references/exceptions/examples/throw-build-mode.md +4 -4
  34. package/skills/developing-cpp/references/exceptions/examples/throw-message.md +8 -0
  35. package/skills/developing-cpp/references/exceptions/throw-rules.md +62 -59
  36. package/skills/developing-cpp/references/language/language-basics/01-objects.md +1 -1
  37. package/skills/developing-cpp/references/language/language-basics/02-initialization.md +1 -1
  38. package/skills/developing-cpp/references/language/language-basics/04-const.md +4 -4
  39. package/skills/developing-cpp/references/language/language-basics/05-expressions.md +8 -3
  40. package/skills/developing-cpp/references/language/language-basics/06-functions.md +2 -0
  41. package/skills/developing-cpp/references/language/standard-library/02-access.md +1 -1
  42. package/skills/developing-cpp/references/language/standard-library/06-format.md +13 -5
  43. package/skills/developing-cpp/references/language/value-types/04-enum.md +1 -1
  44. package/skills/developing-cpp/references/language/value-types/07-nodiscard.md +1 -1
  45. package/skills/developing-cpp/references/language/value-types/08-comparison.md +1 -1
  46. package/skills/developing-cpp/references/layout/01-source-layout.md +2 -3
  47. package/skills/developing-cpp/references/layout/02-file-template.md +7 -7
  48. package/skills/developing-cpp/references/layout/03-declaration-order.md +12 -9
  49. package/skills/developing-cpp/references/naming/examples/naming-accessor.md +11 -0
  50. package/skills/developing-cpp/references/naming/examples/naming-local.md +45 -0
  51. package/skills/developing-cpp/references/naming/examples/naming-lookup.md +1 -1
  52. package/skills/developing-cpp/references/naming/examples/naming-lower-layer.md +20 -13
  53. package/skills/developing-cpp/references/naming/examples/naming-player-value.md +4 -5
  54. package/skills/developing-cpp/references/naming/examples/naming-predicate.md +1 -1
  55. package/skills/developing-cpp/references/naming/examples/naming-role.md +1 -1
  56. package/skills/developing-cpp/references/naming/examples/naming-state-change.md +38 -25
  57. package/skills/developing-cpp/references/naming/glossary/naming-terms.md +23 -0
  58. package/skills/developing-cpp/references/naming/glossary/position.md +23 -0
  59. package/skills/developing-cpp/references/naming/glossary/square.md +47 -0
  60. package/skills/developing-cpp/references/naming/identifier-names.md +24 -19
  61. package/skills/developing-cpp/references/style/google-cpp-style.md +4 -4
  62. package/skills/developing-cpp/scripts/checking-comments.mjs +9 -1
  63. package/skills/developing-cpp/scripts/checking-declaration-order.mjs +27 -1
  64. package/skills/developing-cpp/steps/03-declaration.md +4 -4
  65. package/skills/developing-cpp/steps/04-implementation.md +8 -8
  66. package/skills/engineering/SKILL.md +7 -7
  67. package/skills/engineering/references/cmake/linking/03-undefined-reference.md +1 -1
  68. package/skills/engineering/references/cmake/modules/functions.md +1 -1
  69. package/skills/engineering/references/cmake/{standard/standards → standards}/README.md +10 -10
  70. package/skills/engineering/references/cmake/{standard/standards → standards}/c++23/README.md +3 -3
  71. package/skills/engineering/references/cmake/{standard → standards}/cxx-standard.md +3 -3
  72. package/skills/engineering/references/cmake/targets/examples/target.md +1 -1
  73. package/skills/engineering/references/cmake/targets/rules.md +1 -1
  74. package/skills/engineering/references/cmake/testing/ctest.md +1 -1
  75. package/skills/engineering/references/formatting/02-clang-format.md +1 -1
  76. package/skills/engineering/references/formatting/scripts/checking-encoding.mjs +6 -7
  77. package/skills/engineering/steps/01-targets.md +7 -6
  78. package/skills/engineering/steps/03-check.md +3 -2
  79. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++11/README.md +0 -0
  80. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++11/cmake-snippet.cmake +0 -0
  81. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++14/README.md +0 -0
  82. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++14/cmake-snippet.cmake +0 -0
  83. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++17/README.md +0 -0
  84. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++17/cmake-snippet.cmake +0 -0
  85. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++20/README.md +0 -0
  86. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++20/cmake-snippet.cmake +0 -0
  87. /package/skills/engineering/references/cmake/{standard/standards → standards}/c++23/cmake-snippet.cmake +0 -0
  88. /package/skills/engineering/references/cmake/{standard → standards}/examples/standard.md +0 -0
package/README.en.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [中文](README.md)
4
4
 
5
- Three skills for C++11–C++23 source, CMake, and build work; new projects default to C++23. The plugin registers a skill provider and a settings form; it does not register tools, compile, download a toolchain, or write project files.
5
+ Three skills for C++11–C++23 source, CMake, and build work; new projects default to C++23. The plugin registers a skill provider and a settings form; it does not register tools, compile, download a toolchain, or write project files; it keeps no runtime cache and writes no temporary files, and the host persists settings.
6
6
 
7
7
  ## What it provides
8
8
 
@@ -22,27 +22,33 @@ Fixed-version npm install:
22
22
  dsh plugin --profile <profile> add npm:@chengzhao-dev/dsh-cpp-workflow@0.7.1
23
23
  ```
24
24
 
25
- The matching Git tag:
25
+ The latest published version is `0.7.1`; `0.7.3` exists only in the working tree and is not published yet, so use `0.7.1` above until it is released. After the working-tree version is published, switch the npm command to:
26
26
 
27
27
  ```bash
28
- dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.1
28
+ dsh plugin --profile <profile> add npm:@chengzhao-dev/dsh-cpp-workflow@0.7.3
29
+ ```
30
+
31
+ GitHub tag installs require the matching tag; once `v0.7.3` is created, the version in the address matches the tag:
32
+
33
+ ```bash
34
+ dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.3
29
35
  ```
30
36
 
31
37
  Replace `--profile` with the profile you actually run. The desktop app always runs the `desktop` profile, and that profile is owned by the app; if the command-line `add` is rejected, add the plugin in the app settings and use the same pinned npm version. A Git tag install uses the prebuilt `lib/` committed in the repository and runs no build on the target machine; the package has no install script that needs approval.
32
38
 
33
39
  ### Settings
34
40
 
35
- The plugin page's "C++ Workflow" card is the only entry point and manages file-header tags only: `@file` is always the file name, and every file-header, type, and declaration tag is on by default except the fixed `//` body symbol; empty values are skipped. `@param` is required for every parameter; `@return` may be omitted when the condition is self-evident; `@throws` only when the function throws; `@pre`, `@post`, `@retval`, `@tparam`, `@note`, and `@see` are on by default and can be switched off individually. The preview follows the switches, saving takes effect on the next skill read, and existing sources are never rewritten. The settings page no longer duplicates navigation.
41
+ The plugin page's "C++ Workflow" card is the only entry point and manages the comment symbol and file-header tags: the symbol is `///` or `/** ... */`, `@file` is always the file name, and every file-header, type, and declaration tag is on by default except the fixed `//` body symbol; empty values are skipped. `@param` is required for every parameter; `@return` may be omitted when the condition is self-evident; `@throws` only when the function throws; `@pre`, `@post`, `@retval`, `@tparam`, `@note`, and `@see` are on by default and can be switched off individually. The preview follows the switches, saving takes effect on the next skill read, and existing sources are never rewritten. The plugin page no longer duplicates navigation.
36
42
 
37
- If the page still reports that it is not connected to a configuration form after an upgrade, the window is still running the previous client bundle: restart DeepSeek Harness or select "Reload page" on the plugin page. The page retries the connection while open and switches to the editable form as soon as the host serves it; reinstalling is unnecessary. Discard changes, Restore defaults and Save are separate: discard returns to the last value read from the host, restore fills the draft, and only Save writes it.
43
+ If the page still reports that it is not connected to a configuration form after an upgrade, the window is still running the previous client bundle: restart DeepSeek Harness or select "Reload page" on the plugin page. The page retries the connection while open and switches to the editable form as soon as the host serves it; reinstalling is unnecessary. After a successful save, the status line shows the written `~/.dsh/profiles/<profile>/cordis.patch.yml`. Discard changes, Restore defaults and Save are separate: discard returns to the last value read from the host, restore fills the draft, and only Save writes it.
38
44
 
39
45
  ## Workspace gate
40
46
 
41
- Only one condition must hold before either skill appears: walking up from the current directory to the Git root, the path contains `.agents/skills/cpp-workflow-project/SKILL.md`.
47
+ Only one condition must hold before any of the three skills appears: walking up from the current directory to the Git root, the path contains `.agents/skills/cpp-workflow-project/SKILL.md`.
42
48
 
43
49
  The project skill marker is the repository's opt-in declaration. The plugin no longer requires a first-party `CMakeLists.txt` or C++ source file in the same repository: a docs-only repository, a repository that only copied the template, or a repository with no source files yet still matches; with an empty environment axis, the four source steps still work but build setup stops. Without the marker the list is empty, even when the repository contains CMake or `.cpp` files. Scan limits and boundary cases are in [docs/plugin-boundaries.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-boundaries.md).
44
50
 
45
- The packaged skills use rank 550. A project `.agents/skills` skill uses rank 200 and overrides a plugin skill with the same name; do not copy `developing-cpp`, `engineering`, or `building-cpp` into a project.
51
+ The packaged skills use rank 550. A project `.agents/skills` skill uses rank 200 and a user-level skill uses rank 500; both override a plugin skill with the same name, so do not copy `developing-cpp`, `engineering`, or `building-cpp` into either location.
46
52
 
47
53
  ## Project conventions
48
54
 
@@ -64,7 +70,7 @@ Keep one `environment.json` per repository. Its first three environment axes are
64
70
  | `compiler` | `clang`, `gcc` | One compiler per configuration |
65
71
  | `standard` | `c++11`, `c++14`, `c++17`, `c++20`, `c++23` | New projects default to `c++23`; one standard per project |
66
72
 
67
- The standard lives in `environment.json` as `standard` and must match the CMake target and compile database; on the CMake side, prefer `engineering`'s `CompileSettings_SetCxxStandard` function. New projects default to C++23; for C++11–C++20, lower `standard`, `cxx_std_*`, `CXX_STANDARD`, and the `.clang-format` parsing level together, not one at a time. Per-standard facilities, tooling, and downgrade tables are in the [standard directory](skills/engineering/references/cmake/standard/standards/README.md); the CMake two-layer declaration is in [cxx-standard.md](skills/engineering/references/cmake/standard/cxx-standard.md).
73
+ The standard lives in `environment.json` as `standard` and must match the CMake target and compile database; on the CMake side, prefer `engineering`'s `CompileSettings_SetCxxStandard` function. New projects default to C++23; for C++11–C++20, lower `standard`, `cxx_std_*`, `CXX_STANDARD`, and the `.clang-format` parsing level together, not one at a time. Per-standard facilities, tooling, and downgrade tables are in the [standard directory](skills/engineering/references/cmake/standards/README.md); the CMake two-layer declaration is in [cxx-standard.md](skills/engineering/references/cmake/standards/cxx-standard.md).
68
74
 
69
75
  The generator is always Ninja. Build directories are `build/clang/` and `build/gcc/`; they are never shared. Analysis tools are always `clang-format`, `clang-tidy`, and `clangd`; GCC mode does not switch to another analyzer.
70
76
 
@@ -83,7 +89,7 @@ The project root carries only `.vscode/extensions.json` and `settings.json`: cla
83
89
 
84
90
  The runtime closure is `lib/`, `skills/`, `templates/`, `locale/`, `cordis.patch.yml`, both READMEs, `LICENSE`, and `icon.svg`. The repository also keeps `src/`, `scripts/`, `tests/`, and `docs/` for development and review; they are not published. The authoritative whitelist and per-directory map live in [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md).
85
91
 
86
- Maintenance notes: flow and gate in [docs/plugin-flow.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-flow.md), skill layers and data flow in [docs/architecture.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/architecture.md), trigger matrix in [docs/triggering.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/triggering.md), directory and npm whitelist in [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md), version rules in [docs/versioning.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/versioning.md).
92
+ Maintenance notes: flow and gate in [docs/plugin-flow.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-flow.md), skill layers and data flow in [docs/architecture.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/architecture.md), trigger matrix in [docs/triggering.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/triggering.md), directory and npm whitelist in [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md), runtime disk and cache boundaries in [docs/plugin-storage.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-storage.md), version rules in [docs/versioning.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/versioning.md).
87
93
 
88
94
  ## Local development
89
95
 
@@ -91,7 +97,7 @@ Requires Node.js 22 or newer.
91
97
 
92
98
  ```bash
93
99
  npm ci
94
- npm test # build, three-skill structural check, gate/environment/schema/comment tests
100
+ npm test # build, structural/encoding/workflow checks, and 11 unit-test files
95
101
  npm run test:matrix # real build matrix: 4 templates x 5 standards
96
102
  npm run pack:check # inspect the npm package contents
97
103
  npm run ci # replay the Ubuntu CI job: install, test, package check
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.en.md)
4
4
 
5
- 把 C++11–C++23 的源码、CMake 与构建工作整理成三个技能,新工程默认 C++23。插件注册技能 provider 与设置面,不注册工具、不编译、不下载工具链、不写项目文件。
5
+ 把 C++11–C++23 的源码、CMake 与构建工作整理成三个技能,新工程默认 C++23。插件注册技能 provider 与设置面,不注册工具、不编译、不下载工具链、不写项目文件;运行时不建缓存、不写临时文件,设置由宿主保存。
6
6
 
7
7
  ## 提供什么
8
8
 
@@ -22,19 +22,25 @@ npm 安装固定版本:
22
22
  dsh plugin --profile <profile> add npm:@chengzhao-dev/dsh-cpp-workflow@0.7.1
23
23
  ```
24
24
 
25
- 同版本的 Git 标签:
25
+ npm 当前最新发布是 `0.7.1`;仓库工作区里的 `0.7.3` 尚未发布,发布前请用上面的 0.7.1。工作区版本发布后,把 npm 命令换成:
26
26
 
27
27
  ```bash
28
- dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.1
28
+ dsh plugin --profile <profile> add npm:@chengzhao-dev/dsh-cpp-workflow@0.7.3
29
+ ```
30
+
31
+ GitHub 标签安装要等 `v0.7.3` 创建后再用;标签创建后,地址中的版本号与标签同号:
32
+
33
+ ```bash
34
+ dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.3
29
35
  ```
30
36
 
31
37
  `--profile` 换成你实际运行的那个 profile。桌面应用固定跑 `desktop` profile,且该 profile 由应用独占管理;命令行 `add` 被拒绝时,在应用设置里添加插件,地址填同一个 npm 版本。Git 标签安装使用仓库内已构建的 `lib/`,不在目标机器上重新构建;包内也不含需要授权执行的安装脚本。
32
38
 
33
39
  ### 设置
34
40
 
35
- 插件页的「C++ 工程流程」是唯一入口:注释符号可选 `///` 或 `/** ... */`,页面按注释符号、文件头、类型、函数声明与只读预览分块。`@file` 固定为文件名;除它和函数体 `//` 外,文件头、类型与函数声明标签的开关出厂全开,空值跳过。函数参数要求 `@param`,返回值要求 `@return`(成立条件自明时可省),会抛才要求 `@throws`;`@pre`、`@post`、`@retval` 与类型块的 `@tparam`、`@note`、`@see` 也出厂开启,需要时可逐项关掉。函数体固定用 `//`。预览随改动即时更新,保存后下一次读取技能即生效,已有源码不会被改写。设置页不再重复列一份导航。
41
+ 插件页的「C++ 工程流程」是唯一入口:注释符号可选 `///` 或 `/** ... */`,页面按注释符号、文件头、类型、函数声明与只读预览分块。`@file` 固定为文件名;除它和函数体 `//` 外,文件头、类型与函数声明标签的开关出厂全开,空值跳过。函数参数要求 `@param`,返回值要求 `@return`(成立条件自明时可省),会抛才要求 `@throws`;`@pre`、`@post`、`@retval` 与类型块的 `@tparam`、`@note`、`@see` 也出厂开启,需要时可逐项关掉。函数体固定用 `//`。预览随改动即时更新,保存后下一次读取技能即生效,已有源码不会被改写。插件页不再重复列一份导航。
36
42
 
37
- 升级插件后如果这一页暂时只显示出厂值,说明当前窗口还挂着旧的前端产物:页脚会显示写入的 `~/.dsh/profiles/<profile>/cordis.patch.yml`,并提示重载;重启 DeepSeek Harness,或在插件页点“重新载入页面”即可编辑,不需要重装插件。页面会在打开后自动重试连接,拿到表单就切换为可编辑。保存、撤销修改与恢复默认值分三个按钮:撤销只回到最近一次读到的值,恢复默认值只填草稿,点保存才写盘。
43
+ 升级插件后如果这一页暂时只显示出厂值,说明当前窗口还挂着旧的前端产物:重启 DeepSeek Harness,或在插件页点“重新载入页面”即可编辑,不需要重装插件。页面会在打开后自动重试连接,拿到表单就切换为可编辑;保存成功后,状态行会显示写入的 `~/.dsh/profiles/<profile>/cordis.patch.yml`。保存、撤销修改与恢复默认值分三个按钮:撤销只回到最近一次读到的值,恢复默认值只填草稿,点保存才写盘。
38
44
 
39
45
  ## 工作区门禁
40
46
 
@@ -42,7 +48,7 @@ dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.1
42
48
 
43
49
  项目技能标记就是仓库选择加入本工作流的声明。插件不再要求同一仓库里已经有第一方 `CMakeLists.txt` 或 C++ 源文件:纯文档仓库、只复制了模板、还没有任何源文件的仓库也会出现;环境轴为空时,源码四步仍能做,但定构建会停。没有标记就返回空列表,即使仓库里有 CMake 或 `.cpp`。扫描上限和边界情形见 [docs/plugin-boundaries.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-boundaries.md)。
44
50
 
45
- 插件技能 rank 550。项目自己的 `.agents/skills` 技能 rank 200,会以同名覆盖插件;不要在项目里复制 `developing-cpp`、`engineering` 或 `building-cpp`。
51
+ 插件技能 rank 550。项目自己的 `.agents/skills` 技能 rank 200、用户级技能 rank 500,两者都会以同名覆盖插件;不要在项目或用户目录里复制 `developing-cpp`、`engineering` 或 `building-cpp`。
46
52
 
47
53
  ## 项目级约定
48
54
 
@@ -64,7 +70,7 @@ dsh plugin --profile <profile> add github:chengzhao-dev/dsh-cpp-workflow#v0.7.1
64
70
  | `compiler` | `clang`、`gcc` | 一次配置一个编译器 |
65
71
  | `standard` | `c++11`、`c++14`、`c++17`、`c++20`、`c++23` | 新工程默认 `c++23`;一个工程一个标准 |
66
72
 
67
- 标准写在 `environment.json` 的 `standard`,并同步到 CMake target 和编译数据库;CMake 侧优先调用 `engineering` 提供的 `CompileSettings_SetCxxStandard` 函数。新工程默认 C++23;C++11–C++20 工程把 `standard`、`cxx_std_*`、`CXX_STANDARD` 和 `.clang-format` 的解析档位一起降级,不要只改一处。每档的设施、工具和降档表见 [标准目录](skills/engineering/references/cmake/standard/standards/README.md),CMake 两层声明见 [cxx-standard.md](skills/engineering/references/cmake/standard/cxx-standard.md)。
73
+ 标准写在 `environment.json` 的 `standard`,并同步到 CMake target 和编译数据库;CMake 侧优先调用 `engineering` 提供的 `CompileSettings_SetCxxStandard` 函数。新工程默认 C++23;C++11–C++20 工程把 `standard`、`cxx_std_*`、`CXX_STANDARD` 和 `.clang-format` 的解析档位一起降级,不要只改一处。每档的设施、工具和降档表见 [标准目录](skills/engineering/references/cmake/standards/README.md),CMake 两层声明见 [cxx-standard.md](skills/engineering/references/cmake/standards/cxx-standard.md)。
68
74
 
69
75
  生成器固定 Ninja,构建目录是 `build/clang/` 与 `build/gcc/`,不共用 `build/`。诊断工具固定 `clang-format`、`clang-tidy`、`clangd`;GCC 模式也不换成别的分析器。
70
76
 
@@ -83,7 +89,7 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live
83
89
 
84
90
  运行时闭包是 `lib/`、`skills/`、`templates/`、`locale/`、`cordis.patch.yml`、两个 README、`LICENSE` 与 `icon.svg`。仓库另有 `src/`、`scripts/`、`tests/` 与 `docs/`,只服务开发与评审,不进包。权威白名单与逐项目录见 [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md)。
85
91
 
86
- 边界与门禁的维护说明在 [docs/plugin-flow.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-flow.md),技能的层次与数据流在 [docs/architecture.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/architecture.md),触发矩阵在 [docs/triggering.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/triggering.md),目录和进包白名单在 [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md),版本规则在 [docs/versioning.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/versioning.md)。
92
+ 边界与门禁的维护说明在 [docs/plugin-flow.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-flow.md),技能的层次与数据流在 [docs/architecture.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/architecture.md),触发矩阵在 [docs/triggering.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/triggering.md),目录和进包白名单在 [docs/plugin-layout.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-layout.md),运行时磁盘与缓存边界在 [docs/plugin-storage.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/plugin-storage.md),版本规则在 [docs/versioning.md](https://github.com/chengzhao-dev/dsh-cpp-workflow/blob/main/docs/versioning.md)。
87
93
 
88
94
  ## 本地开发
89
95
 
@@ -91,10 +97,10 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live
91
97
 
92
98
  ```bash
93
99
  npm ci
94
- npm test # 构建、三技能结构检查、门禁/环境/schema/注释测试
100
+ npm test # 构建、结构/编码/工作流检查与 11 组单元测试
95
101
  npm run test:matrix # 四套模板 × 五档标准的真实构建矩阵
96
102
  npm run pack:check # 核对 npm 包内容
97
- npm run ci # 复现 Ubuntu CI:安装、测试、打包检查
103
+ npm run ci # 复现 Ubuntu CI:安装、测试、打包检查(不含标准矩阵)
98
104
  npm run ci:full # 在 ci 之上再跑标准矩阵,需 POSIX 宿主
99
105
  ```
100
106
 
package/cordis.patch.yml CHANGED
@@ -1,11 +1,11 @@
1
- # dsh-cpp-workflow bundle patch.
1
+ # dsh-cpp-workflow 的 bundle patch。
2
2
  #
3
- # Additive only: insert one host row. No official row is edited, disabled or
4
- # replaced. The row loads this package's `main` entry, which registers the
5
- # packaged developing-cpp, engineering and building-cpp skills through `ctx.skills`.
3
+ # 只做追加:插入一行宿主配置。不改写、不关闭、不替换任何官方行。这一行加载
4
+ # 本包的 `main` 入口,由它通过 `ctx.skills` 注册 developing-cpp、engineering 与
5
+ # building-cpp 三份技能。
6
6
  #
7
- # Install with `dsh plugin --profile <name> add <package>`. Pinned npm and Git
8
- # tag addresses are in the README's Install section.
7
+ # 用 `dsh plugin --profile <name> add <package>` 安装。固定到 npm 版本与 Git
8
+ # 标签的地址写在 README 的 Install 一节。
9
9
  - insert:
10
10
  - id: cpp-workflow
11
11
  name: "@chengzhao-dev/dsh-cpp-workflow"
package/lib/client.js CHANGED
@@ -236,8 +236,8 @@ function snapshotText(raw) {
236
236
 
237
237
 
238
238
  // 客户端半侧:插件页的配置卡片(plugins.bundle.config),只此一个入口。
239
- // 标签策略在本文件上方内联(由 scripts/building-client.mjs 从 src/comment-policy.js
240
- // 拼进来),所以预览、默认值与服务端快照永远同源;这里只做表单与外观。
239
+ // 标签策略在本文件上方内联(由 scripts/building-client.mjs 读取
240
+ // lib/comment-policy.js 后拼进来),所以预览、默认值与服务端快照永远同源;这里只做表单与外观。
241
241
  const React = require('react')
242
242
  const h = React.createElement
243
243
 
package/lib/index.js CHANGED
@@ -1,23 +1,17 @@
1
- // dsh-cpp-workflow bundle entry.
1
+ // dsh-cpp-workflow 包入口。
2
2
  //
3
- // Registers the three packaged skills as one bundle-scoped skill provider. The
4
- // provider is read-only and scans only `skills/<name>/SKILL.md`; each skill
5
- // directory becomes the resourceBase so relative steps, references, examples
6
- // and assets resolve from the installed package.
3
+ // 把打包的三份技能注册成一个技能提供方。提供方只读,只扫描
4
+ // `skills/<name>/SKILL.md`;每份技能目录作为 resourceBase,步骤、参考页、
5
+ // 示例与资产都由安装后的包内解析。
7
6
  //
8
- // The provider scopes itself to opted-in workspaces: `list()` returns nothing
9
- // unless the session cwd sits inside a git checkout that carries the explicit
10
- // `.agents/skills/cpp-workflow-project/SKILL.md` marker on the path to the git
11
- // root. C++ or CMake evidence is intentionally not part of the gate: a freshly
12
- // copied template has no sources yet, and an empty project legitimately stops
13
- // at the build step. A C++ sample outside an opted-in checkout never sees these
14
- // names; the marker lookup ignores sibling directories.
7
+ // 门禁只认显式启用的工作区:会话 cwd 到 git 根的路径上必须有
8
+ // `.agents/skills/cpp-workflow-project/SKILL.md`,否则 `list()` 返回空。
9
+ // C++ 或 CMake 证据刻意不参与:刚复制的模板还没有源码,空工程也可以停在
10
+ // 构建步骤;检出之外的 C++ 示例看不到这些技能名,标记查找也不进兄弟目录。
15
11
  //
16
- // Rank 550 is lower priority than project/user skills (project `.agents/skills`
17
- // 200, user `.agents/skills` 500) and higher priority than the bundled root
18
- // (600), so a project can override any packaged skill by name without editing
19
- // the package. The project skill itself (cpp-workflow-project, rank 200) is a
20
- // separate name and does not collide.
12
+ // 优先级 550:低于项目级(200)与用户级(500),高于包内根(600)。项目
13
+ // 可按名字覆盖任意打包技能,不必改包;项目技能 cpp-workflow-project(200)
14
+ // 是另一个名字,与此不冲突。
21
15
  import { readdir, readFile } from 'node:fs/promises';
22
16
  import path from 'node:path';
23
17
  import { fileURLToPath } from 'node:url';
@@ -62,11 +56,12 @@ const KNOWN_SKILLS = new Set(['building-cpp', 'engineering', 'developing-cpp']);
62
56
  const SKILL_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
63
57
  const PACKAGE_ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
64
58
  const SKILLS_ROOT = path.join(PACKAGE_ROOT, 'skills');
65
- /** Minimal YAML frontmatter reader for the keys SKILL.md actually uses. */
59
+ /** 读取 SKILL.md 用到的 YAML frontmatter;只支持这些键所需的最小语法。 */
66
60
  function parseFrontmatter(source) {
67
- const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(source);
61
+ const text = source.charCodeAt(0) === 0xfeff ? source.slice(1) : source;
62
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
68
63
  if (!match)
69
- return { data: {}, body: source };
64
+ return { data: {}, body: text };
70
65
  const data = {};
71
66
  const stack = [
72
67
  { indent: -1, target: data },
@@ -92,9 +87,15 @@ function parseFrontmatter(source) {
92
87
  }
93
88
  parent[key] = parseScalar(value);
94
89
  }
95
- return { data, body: source.slice(match[0].length) };
90
+ return { data, body: text.slice(match[0].length) };
96
91
  }
97
92
  function parseScalar(value) {
93
+ // 块标量、锚点与别名需要多行语法;本包只支持单行 frontmatter,遇到这些标记
94
+ // 直接判为不可解析,避免把 ">" 或 "|" 当成正文展示。
95
+ if (/^[>|&*]/.test(value))
96
+ return undefined;
97
+ if (!value.startsWith('"') && !value.startsWith("'"))
98
+ value = value.replace(/\s+#.*$/, '');
98
99
  if ((value.startsWith('"') && value.endsWith('"')) ||
99
100
  (value.startsWith("'") && value.endsWith("'"))) {
100
101
  const quote = value[0];
@@ -125,20 +126,24 @@ async function readCandidate(skillDir) {
125
126
  source = await readFile(skillFile, 'utf8');
126
127
  }
127
128
  catch {
128
- return undefined;
129
+ // 读不到正文是瞬时 IO 问题,不能把目录当成「已完整扫描」。
130
+ return { complete: false };
129
131
  }
130
132
  const { data } = parseFrontmatter(source);
131
133
  if (typeof data.name !== 'string' || !SKILL_NAME_RE.test(data.name))
132
- return undefined;
134
+ return { complete: true };
133
135
  if (!KNOWN_SKILLS.has(data.name))
134
- return undefined;
135
- if (typeof data.description !== 'string' || data.description.trim() === '')
136
- return undefined;
136
+ return { complete: true };
137
+ if (typeof data.description !== 'string')
138
+ return { complete: true };
139
+ const description = data.description.replace(/\s+/g, ' ').trim();
140
+ if (description === '')
141
+ return { complete: true };
137
142
  if (data.name !== path.basename(skillDir))
138
- return undefined;
143
+ return { complete: true };
139
144
  const candidate = {
140
145
  name: data.name,
141
- description: data.description.trim(),
146
+ description,
142
147
  invocation: { modelInvocable: true, userInvocable: true },
143
148
  source: 'bundled',
144
149
  provider: PROVIDER,
@@ -153,7 +158,7 @@ async function readCandidate(skillDir) {
153
158
  if (data.metadata && typeof data.metadata === 'object' && !Array.isArray(data.metadata)) {
154
159
  candidate.metadata = data.metadata;
155
160
  }
156
- return candidate;
161
+ return { candidate, complete: true };
157
162
  }
158
163
  async function listSkills(options = {}) {
159
164
  if (options.signal?.aborted)
@@ -167,29 +172,32 @@ async function listSkills(options = {}) {
167
172
  entries = await readdir(SKILLS_ROOT, { withFileTypes: true });
168
173
  }
169
174
  catch {
170
- return [];
175
+ // 目录暂时读不到时返回不完整观察,宿主不会把它当成完整空目录缓存。
176
+ return { candidates: [], complete: false };
171
177
  }
172
178
  const candidates = [];
179
+ let complete = true;
173
180
  for (const entry of entries) {
174
181
  if (!entry.isDirectory() || !KNOWN_SKILLS.has(entry.name))
175
182
  continue;
176
183
  if (options.signal?.aborted)
177
184
  return [];
178
- const candidate = await readCandidate(path.join(SKILLS_ROOT, entry.name));
179
- if (candidate)
180
- candidates.push(candidate);
185
+ const result = await readCandidate(path.join(SKILLS_ROOT, entry.name));
186
+ if (result.candidate)
187
+ candidates.push(result.candidate);
188
+ if (!result.complete)
189
+ complete = false;
181
190
  }
182
191
  candidates.sort((a, b) => a.name.localeCompare(b.name));
183
- return candidates;
192
+ return complete ? candidates : { candidates, complete: false };
184
193
  }
185
194
  async function getSkill(candidate, options = {}, commentConfig = undefined) {
186
195
  if (options.signal?.aborted)
187
196
  return undefined;
188
197
  if (!candidate || candidate.provider !== PROVIDER)
189
198
  return undefined;
190
- // A candidate can outlive a directory change in the same session. Re-check
191
- // only when the caller supplies a cwd; a plain `get()` keeps working for
192
- // candidates that were already discovered in this workspace.
199
+ // candidate 可能比同一会话中的目录变化活得久。只有调用方传了 cwd 时才重查门禁;
200
+ // 不带 cwd 的 get() 继续服务本工作区已发现的 candidate。
193
201
  if (options.cwd !== undefined && !(await isCppWorkflowWorkspace(options.cwd)))
194
202
  return undefined;
195
203
  if (!KNOWN_SKILLS.has(candidate.name))
package/lib/workspace.js CHANGED
@@ -1,11 +1,8 @@
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');
@@ -19,7 +16,7 @@ async function exists(target) {
19
16
  return false;
20
17
  }
21
18
  }
22
- /** Nearest enclosing git checkout, including a worktree's `.git` file. */
19
+ /** 最近的上级 git 检出;worktree 的 `.git` 文件也算。 */
23
20
  export async function findGitRoot(cwd) {
24
21
  if (typeof cwd !== 'string' || cwd.trim() === '')
25
22
  return undefined;
@@ -41,9 +38,8 @@ export async function findGitRoot(cwd) {
41
38
  return undefined;
42
39
  }
43
40
  /**
44
- * Find the nearest project-skill marker between `cwd` and the git root,
45
- * inclusive. A marker above the git root never counts. The marker's directory
46
- * is also returned for diagnostics; it is not the repository boundary.
41
+ * 在 `cwd` 与 git 根之间(含两端)找最近的项目技能标记;根之上的标记不算。
42
+ * 同时返回标记所在目录供诊断,它不是仓库边界。
47
43
  */
48
44
  export async function findProjectSkill(cwd, gitRoot) {
49
45
  if (typeof cwd !== 'string' || cwd.trim() === '')
@@ -81,13 +77,10 @@ export async function findProjectSkill(cwd, gitRoot) {
81
77
  return undefined;
82
78
  }
83
79
  /**
84
- * Session gate. The project skill must sit between `cwd` and the git root
85
- * (inclusive). First-party C++ or CMake evidence is deliberately not required:
86
- * a freshly copied template still needs the workflow, and an empty project
87
- * legitimately stops at the build step.
80
+ * 会话门禁:项目技能必须位于 `cwd` 与 git 根之间(含两端)。不要求 C++ 或
81
+ * CMake 证据:刚复制的模板仍需要工作流,空工程也可以合法地停在构建步骤。
88
82
  *
89
- * No cwd, no git checkout, a marker above the git root, or a marker only in a
90
- * sibling directory returns false.
83
+ * 没有 cwd、不在 git 检出内、标记只在 git 根之上或只在兄弟目录时返回 false。
91
84
  */
92
85
  export async function isCppWorkflowWorkspace(cwd) {
93
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.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "写 C++ 源码、配 CMake、用 Clang 构建;头文件用 /// Doxygen 文档注释,函数体用 // 分段说明,文件头标签可在设置里改。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -1,6 +1,6 @@
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
  ---
@@ -11,10 +11,10 @@ metadata:
11
11
 
12
12
  ## 适用场景
13
13
 
14
- - **负责**:环境四轴与构建入口;工具配置的选定与检查;编码、声明校验、活动校验、项目入口命令的次序。
14
+ - **负责**:环境四轴与构建入口;工具配置的复制、落地与检查(规则条文归 `engineering`);编码、声明校验、活动校验、项目入口命令的次序。
15
15
  - **不负责**:`CMakeLists.txt` 与 `cmake/` 下的 target、属性、标准与模块开 `engineering`,本技能只读它们来配置和检查,不在这一步改 target 图;函数体、类型、命名、异常与源码注释开 `developing-cpp`。
16
16
  - **交接**:一次改动同时碰到源码和构建文件时,先开 `developing-cpp` 定行为、边界与实现;需要新增或移动源文件、改库与程序的边界、补测试 target 时,转 `engineering` 把文件写进 CMake;最后回到本技能定工具配置并通过检查。只改函数体、命名、异常或注释且入口命令可运行时,定实现后只开本技能的通过检查。
17
- - **前置**:存在项目技能 `cpp-workflow-project` 时先读它的 `SKILL.md`、`environment.json` 和 `stages/stage-table.md`。三个环境轴为空、`standard` 非法或组合非法时停在定构建,不猜 WSL、Clang 或构建目录;`windows` + `native` 直接拒绝,提示「本版本不能在 Windows 原生壳里构建」,不给补 PowerShell 的路线。
17
+ - **前置**:存在项目技能 `cpp-workflow-project` 时先读它的 `SKILL.md`、`environment.json` 和 `stages/stage-table.md`。三个环境轴为空、`standard` 非法或组合非法时停在定构建,不猜 WSL、Clang 或构建目录;`standard` 缺失或为空时按默认 `c++23` 继续并提示声明升级;`windows` + `native` 直接拒绝,提示「本版本不能在 Windows 原生壳里构建」,不给补 PowerShell 的路线。
18
18
  - **分因**:编译失败时先看诊断指向哪一层。函数体问题回 `developing-cpp` 的定实现;找不到头、链接失败、target 不存在或标准不对转 `engineering` 的对应步骤;没有编译数据库、format/tidy 不在 PATH 或配置不生效留在本技能的定工具配置。
19
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
20
  - **编辑器**:工程根已有 `.vscode/` 时按 `project/vscode/` 两页接线;从当前目录向上到 git 根都没有 `.vscode/` 时不打开、也不新建。配置、构建、运行和调试都从 CMake Tools 进入,构建仍以 `running-build.sh` 为准。
@@ -105,7 +105,7 @@ node "<skill-dir>/scripts/checking-environment.mjs" --project . --live
105
105
  | 3 | 活动校验失败:不在声明的 build host、角色缺失、版本不符 |
106
106
  | 1 | 脚本自身错误:参数错误或内部异常 |
107
107
 
108
- 各标准对应的编译器、库设施和工具档位见 [../../engineering/references/cmake/standard/standards/README.md](../../engineering/references/cmake/standard/standards/README.md)。
108
+ 各标准对应的编译器、库设施和工具档位见 [../../engineering/references/cmake/standards/README.md](../../engineering/references/cmake/standards/README.md)。
109
109
 
110
110
  ## 依据
111
111
 
@@ -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/rules.md` 或 `../../engineering/references/cmake/standards/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
 
@@ -13,7 +13,7 @@
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/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 的 `//`,贴在被解释的键上方。
@@ -47,5 +47,5 @@
47
47
  - `.clangd` 指错编译数据库、`query-driver` 写进 YAML:`../../engineering/references/formatting/examples/clangd.md`。
48
48
  - 配置文件堆策略头、关闭检查不写理由:`../../engineering/references/formatting/examples/clang-tidy.md`「配置注释」。
49
49
  - 工具调用与头文件过滤:`../../engineering/references/formatting/03-clang-tidy.md`。
50
- - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/references/cmake/standard/standards/README.md`。
50
+ - 每个标准对应的 clang-format 档位与 `.clangd` 读库规则:`../../engineering/references/cmake/standards/README.md`。
51
51
  - 编辑器扩展与设置:`../project/vscode/01-extensions.md`、`../project/vscode/02-settings.md`。