@chengzhao-dev/dsh-cpp-workflow 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +107 -0
- package/README.md +106 -2
- package/cordis.patch.yml +14 -0
- package/icon.svg +7 -0
- package/lib/index.js +203 -0
- package/lib/workspace.js +168 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +81 -4
- package/skills/building-cpp/SKILL.md +44 -0
- package/skills/building-cpp/assets/cmake/applying-warnings.cmake +10 -0
- package/skills/building-cpp/assets/cmake/fetching-googletest.cmake +15 -0
- package/skills/building-cpp/assets/cmake/setting-rpath.cmake +8 -0
- package/skills/building-cpp/assets/config/.clang-format +40 -0
- package/skills/building-cpp/assets/config/.clang-tidy +92 -0
- package/skills/building-cpp/assets/config/.clangd +12 -0
- package/skills/building-cpp/assets/config/.vscode/extensions.json +6 -0
- package/skills/building-cpp/assets/config/.vscode/settings.json +34 -0
- package/skills/building-cpp/assets/templates/projects/common/running-build.sh +152 -0
- package/skills/building-cpp/assets/templates/projects/multi/CMakeLists.txt +18 -0
- package/skills/building-cpp/assets/templates/projects/multi/include/greeting.h +10 -0
- package/skills/building-cpp/assets/templates/projects/multi/src/greeting.cpp +13 -0
- package/skills/building-cpp/assets/templates/projects/multi/src/main.cpp +8 -0
- package/skills/building-cpp/assets/templates/projects/shared-library/CMakeLists.txt +24 -0
- package/skills/building-cpp/assets/templates/projects/shared-library/greeting/CMakeLists.txt +5 -0
- package/skills/building-cpp/assets/templates/projects/shared-library/greeting/include/greeting.h +10 -0
- package/skills/building-cpp/assets/templates/projects/shared-library/greeting/src/greeting.cpp +13 -0
- package/skills/building-cpp/assets/templates/projects/shared-library/src/main.cpp +8 -0
- package/skills/building-cpp/assets/templates/projects/single/CMakeLists.txt +14 -0
- package/skills/building-cpp/assets/templates/projects/single/src/main.cpp +9 -0
- package/skills/building-cpp/assets/templates/projects/static-library/CMakeLists.txt +18 -0
- package/skills/building-cpp/assets/templates/projects/static-library/greeting/CMakeLists.txt +5 -0
- package/skills/building-cpp/assets/templates/projects/static-library/greeting/include/greeting.h +10 -0
- package/skills/building-cpp/assets/templates/projects/static-library/greeting/src/greeting.cpp +13 -0
- package/skills/building-cpp/assets/templates/projects/static-library/src/main.cpp +8 -0
- package/skills/building-cpp/examples/cmake.md +150 -0
- package/skills/building-cpp/examples/environment.md +125 -0
- package/skills/building-cpp/examples/tooling.md +155 -0
- package/skills/building-cpp/references/build-script.md +63 -0
- package/skills/building-cpp/references/cmake.md +168 -0
- package/skills/building-cpp/references/environment.md +104 -0
- package/skills/building-cpp/references/linking.md +101 -0
- package/skills/building-cpp/references/static-analysis.md +136 -0
- package/skills/building-cpp/scripts/checking-environment.mjs +498 -0
- package/skills/building-cpp/steps/01-build.md +76 -0
- package/skills/building-cpp/steps/02-tooling.md +41 -0
- package/skills/building-cpp/steps/03-check.md +60 -0
- package/skills/developing-cpp/SKILL.md +42 -0
- package/skills/developing-cpp/examples/comments.md +231 -0
- package/skills/developing-cpp/examples/exceptions.md +134 -0
- package/skills/developing-cpp/examples/naming.md +157 -0
- package/skills/developing-cpp/examples/structure.md +79 -0
- package/skills/developing-cpp/references/comments.md +123 -0
- package/skills/developing-cpp/references/declaration-order.md +97 -0
- package/skills/developing-cpp/references/exceptions.md +79 -0
- package/skills/developing-cpp/references/glossary.md +88 -0
- package/skills/developing-cpp/references/google-cpp-style.md +109 -0
- package/skills/developing-cpp/references/language.md +119 -0
- package/skills/developing-cpp/references/layout.md +73 -0
- package/skills/developing-cpp/references/naming.md +62 -0
- package/skills/developing-cpp/references/performance.md +82 -0
- package/skills/developing-cpp/references/project-design.md +79 -0
- package/skills/developing-cpp/references/standard-library.md +100 -0
- package/skills/developing-cpp/references/types.md +147 -0
- package/skills/developing-cpp/steps/01-behavior.md +36 -0
- package/skills/developing-cpp/steps/02-boundary.md +40 -0
- package/skills/developing-cpp/steps/03-declaration.md +32 -0
- package/skills/developing-cpp/steps/04-implementation.md +33 -0
- package/templates/cpp-workflow-project/SKILL.md +49 -0
- package/templates/cpp-workflow-project/environment.json +5 -0
- package/templates/cpp-workflow-project/stages/stage-table.md +4 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 第 4 步:定实现
|
|
2
|
+
|
|
3
|
+
## 产出
|
|
4
|
+
|
|
5
|
+
`.cpp` 中的函数体、操作顺序、分组空白和实现注释。实现只兑现第 1 步的行为和第 3 步的声明,不新增公共接口。
|
|
6
|
+
|
|
7
|
+
## 通用情况
|
|
8
|
+
|
|
9
|
+
- 函数保持短小;一个函数只做一件事。超过约 40 行时先找可以命名的中间步骤,不要用注释把长函数切成几段。
|
|
10
|
+
- 按「准备 → 操作 → 收尾」排列语句,用空行分组;组与组之间的空行表达阶段,不用大段叙述。
|
|
11
|
+
- `.cpp` 第一个 include 是自己的配对头,然后直接包含本文件用到的标准库头;不要依赖公共头替本文件转发声明。若所用 clang-tidy 版本带 `misc-include-cleaner`,这类缺失会被报出来。
|
|
12
|
+
- 实现注释只写「为什么这样做」「这里的边界条件」「这样排序的代价」,不复述代码。
|
|
13
|
+
- 错误处理:可预期失败返回结果类型;合同违反抛异常。捕获异常时按 `const` 引用捕获,只处理能处理的类型,其余继续抛。
|
|
14
|
+
- 组合输出用 `std::format`,再写入 `std::cout` / `std::cerr`;不要在库实现里直接打印。C++20 没有 `std::print`。
|
|
15
|
+
- 不写 C 风格强制转换;用 `static_cast` / `std::bit_cast` 等具名转换。
|
|
16
|
+
- 所有权用 `std::unique_ptr`;没有共享所有权的理由时不用 `std::shared_ptr`。
|
|
17
|
+
- 只改注释时,不改可观察行为;只改实现时,不改公共声明。两者同时需要时,先改声明,再改实现。
|
|
18
|
+
|
|
19
|
+
## 情况
|
|
20
|
+
|
|
21
|
+
**新实现**:先写最短的直路,让第 1 步的验收通过;重复出现两次以上再抽函数。不要预埋未使用的抽象。
|
|
22
|
+
|
|
23
|
+
**修缺陷**:先加一个能复现的测试或最小输入,再改实现;修完删掉临时调试输出,保留测试。
|
|
24
|
+
|
|
25
|
+
**重构**:一次只动一种东西(改名、抽函数、换容器)。每步都让测试保持绿色;行为句不变。
|
|
26
|
+
|
|
27
|
+
**异常边界**:库内部可以让合同异常向上传播;程序入口捕获 `std::exception`,用 `std::format("错误: {}", error.what())` 打印,返回非零退出码。不要吞掉异常后继续用无效状态。
|
|
28
|
+
|
|
29
|
+
## 正反例指针
|
|
30
|
+
|
|
31
|
+
- 实现注释复述代码、分组混乱:`examples/comments.md`「实现注释」。
|
|
32
|
+
- 合同异常与结果类型混用:`examples/exceptions.md`「抛还是返回」。
|
|
33
|
+
- `std::format` 与流输出混用得当:`examples/exceptions.md`「消息格式」。
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cpp-workflow-project
|
|
3
|
+
description: 当前 C++ 工程的本地事实:工程与组件名、库和程序的边界、入口命令、阶段表、术语增补。开始任何 C++ 任务前先读;这里只写本工程特有的、无法从源码推断的内容。
|
|
4
|
+
metadata:
|
|
5
|
+
short-description: 当前 C++ 工程事实
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# cpp-workflow-project
|
|
9
|
+
|
|
10
|
+
这是项目模板,不是插件;复制整个目录到目标仓库的 `.agents/skills/` 下,目录名保持 `cpp-workflow-project`,再把下面的空位换成该工程的真实值。目标已有同名文件时只补缺失文件,不覆盖源码、`CMakeLists.txt` 或 `.clang-*`。一个仓库只保留一份 `environment.json`。
|
|
11
|
+
|
|
12
|
+
## 工程与组件
|
|
13
|
+
|
|
14
|
+
| 项 | 值 |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| 工程名 | `<project-name>` |
|
|
17
|
+
| 一句话职责 | `<程序用一句话说明做什么>` |
|
|
18
|
+
| 组件名 | `<component-name>` |
|
|
19
|
+
| 源码根 | `<src-root>` |
|
|
20
|
+
|
|
21
|
+
同目录的 `environment.json` 三个轴必须填本工程的真实组合;留空时技能仍可能出现,但定构建会停。
|
|
22
|
+
|
|
23
|
+
## 库与程序的边界
|
|
24
|
+
|
|
25
|
+
- 库负责:`<领域规则;没有单独库时写“无”>`
|
|
26
|
+
- 程序负责:`<终端输入输出与装配>`
|
|
27
|
+
- 公共头位置:`<component>/include/`
|
|
28
|
+
- 依赖方向:`<程序依赖库;库不依赖终端、GUI 或脚本>`
|
|
29
|
+
|
|
30
|
+
## 入口命令
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
<entry-command>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
从仓库根可直接运行;构建、格式化、静态检查、测试和运行都由它串起来。
|
|
37
|
+
|
|
38
|
+
## 阶段表
|
|
39
|
+
|
|
40
|
+
- 路径:`stages/stage-table.md`
|
|
41
|
+
- 一个阶段一行,只写可观察行为;没有可观察行为的不进表。
|
|
42
|
+
|
|
43
|
+
## 术语增补
|
|
44
|
+
|
|
45
|
+
- `<domain term>`:`<meaning>`
|
|
46
|
+
|
|
47
|
+
## 可选约定
|
|
48
|
+
|
|
49
|
+
- 两个具体工程之前不抽共享库。
|