@chengzhao-dev/dsh-cpp-workflow 0.7.12 → 0.7.13
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/README.en.md +4 -4
- package/README.md +4 -4
- package/package.json +1 -1
- package/skills/building-cpp/references/02-environment.md +2 -2
- package/skills/building-cpp/steps/04-vscode.md +1 -1
- package/skills/developing-cpp/SKILL.md +1 -1
- package/skills/developing-cpp/references/comments/01-comment-rules.md +16 -16
- package/skills/developing-cpp/references/comments/02-style.md +23 -6
- package/skills/developing-cpp/references/comments/examples/01-declaration-class.md +11 -9
- package/skills/developing-cpp/references/comments/examples/03-declaration-enum.md +5 -5
- package/skills/developing-cpp/references/comments/examples/04-declaration-file.md +13 -17
- package/skills/developing-cpp/references/comments/examples/05-declaration-function.md +16 -1
- package/skills/developing-cpp/references/comments/examples/06-declaration-member.md +11 -4
- package/skills/developing-cpp/references/comments/examples/07-declaration-predicate.md +16 -7
- package/skills/developing-cpp/references/comments/examples/08-declaration-struct.md +1 -1
- package/skills/developing-cpp/references/comments/examples/09-implementation-body.md +19 -1
- package/skills/developing-cpp/references/comments/examples/11-declaration-constant.md +5 -5
- package/skills/developing-cpp/references/comments/glossary/01-comment-terms.md +20 -16
- package/skills/developing-cpp/references/design/01-project-design.md +2 -2
- package/skills/developing-cpp/references/design/examples/02-coordinate-table.md +3 -3
- package/skills/developing-cpp/references/design/examples/09-option-menu.md +3 -3
- package/skills/developing-cpp/references/exceptions/01-exception-rules.md +3 -3
- package/skills/developing-cpp/references/exceptions/examples/02-throw-build-mode.md +1 -1
- package/skills/developing-cpp/references/index.md +11 -11
- package/skills/developing-cpp/references/language/glossary/01-language-terms.md +2 -2
- package/skills/developing-cpp/references/language/language-basics/02-initialization.md +3 -3
- package/skills/developing-cpp/references/language/language-basics/04-const.md +1 -1
- package/skills/developing-cpp/references/language/language-basics/05-expressions.md +9 -8
- package/skills/developing-cpp/references/language/language-basics/10-language-checklist.md +1 -1
- package/skills/developing-cpp/references/language/standard-library/03-iteration.md +1 -1
- package/skills/developing-cpp/references/language/standard-library/04-algorithms.md +15 -7
- package/skills/developing-cpp/references/language/standard-library/11-library-checklist.md +1 -1
- package/skills/developing-cpp/references/language/value-types/03-integer-roles.md +8 -8
- package/skills/developing-cpp/references/layout/02-file-template.md +1 -1
- package/skills/developing-cpp/references/layout/03-declaration-order.md +11 -7
- package/skills/developing-cpp/references/naming/01-identifier-names.md +3 -3
- package/skills/developing-cpp/references/naming/glossary/04-square.md +1 -1
- package/skills/developing-cpp/references/style/01-google-cpp-style.md +2 -2
- package/skills/developing-cpp/scripts/checking-comments.mjs +26 -7
- package/skills/engineering/references/cmake/standards/index.md +1 -1
- package/skills/engineering/references/formatting/04-clangd.md +1 -1
- package/templates/cpp-workflow-project/SKILL.md +3 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- 读取时机:排声明顺序时;读完能回答:声明顺序与定义签名;预算:一次只开这一份(
|
|
1
|
+
<!-- 读取时机:排声明顺序时;读完能回答:声明顺序与定义签名;预算:一次只开这一份(202 行),不自动串联。 -->
|
|
2
2
|
# 声明顺序
|
|
3
3
|
|
|
4
4
|
顺序的作用是让读者先看类型和契约,再看数据。`clang-format` 不管顺序,靠人工和 review 维持。
|
|
@@ -12,7 +12,7 @@ public:
|
|
|
12
12
|
using Tasks = std::array<TaskState, 16>;
|
|
13
13
|
|
|
14
14
|
// 2. 静态常量
|
|
15
|
-
static constexpr int kTaskCount
|
|
15
|
+
static constexpr int kTaskCount{16};
|
|
16
16
|
|
|
17
17
|
// 3. 工厂
|
|
18
18
|
static TaskTable CreateEmpty();
|
|
@@ -74,8 +74,8 @@ Google、LLVM、OpenCV 都没有规定这一组内部的次序;本工作流补
|
|
|
74
74
|
```cpp
|
|
75
75
|
class Board {
|
|
76
76
|
public:
|
|
77
|
-
static constexpr std::size_t
|
|
78
|
-
static constexpr std::size_t
|
|
77
|
+
static constexpr std::size_t kRowCount{3};
|
|
78
|
+
static constexpr std::size_t kColumnCount{kRowCount};
|
|
79
79
|
|
|
80
80
|
[[nodiscard]] static bool IsInRange(const Position& position) noexcept;
|
|
81
81
|
static void CheckInRange(const Position& position);
|
|
@@ -106,7 +106,7 @@ public:
|
|
|
106
106
|
|
|
107
107
|
namespace taskflow {
|
|
108
108
|
|
|
109
|
-
inline constexpr int kTaskCount
|
|
109
|
+
inline constexpr int kTaskCount{16};
|
|
110
110
|
|
|
111
111
|
enum class TaskState : std::uint8_t { kPending, kActive, kDone };
|
|
112
112
|
|
|
@@ -133,7 +133,7 @@ private:
|
|
|
133
133
|
## `.cpp` 的定义顺序
|
|
134
134
|
|
|
135
135
|
- 本工作流约定:与头文件声明同序,先类型和常量,再自由函数,再成员函数;成员函数按类内声明顺序。Google、LLVM 与 C++ Core Guidelines 都没有规定 `.cpp` 成员定义的次序;这里选同序,是为了让读者能在头文件与实现之间逐项对照。
|
|
136
|
-
- 文件头注释之后先放本文件的 `namespace taskflow {
|
|
136
|
+
- 文件头注释之后先放本文件的 `namespace taskflow {`,再放公共定义;常量仍排在命名空间作用域内、成员函数之前;放具名还是匿名命名空间按 `references/style/01-google-cpp-style.md`,本文不复述。
|
|
137
137
|
- 构造函数、析构函数、拷贝/移动定义通常放在成员函数组最前;如果头文件把某个成员声明在构造函数之前,仍按头文件声明顺序,不把构造函数硬提到前面。校验对就是这种情况:`IsInRange`、`CheckInRange` 定义在 `GetSquareValue` 之前,跟头文件一致。`= default` 的定义放 `.cpp` 时紧跟声明顺序。
|
|
138
138
|
- 不要为了「先编译」重排定义;C++ 不要求定义顺序,读者顺序优先。
|
|
139
139
|
|
|
@@ -169,12 +169,15 @@ private:
|
|
|
169
169
|
| `private:` 之前 | 1 行 |
|
|
170
170
|
| 命名空间内顶层实体之间 | 1 行 |
|
|
171
171
|
| 函数体内逻辑组之间 | 1 行,最多 1 行 |
|
|
172
|
+
| 函数体内:检查调用与其后依赖它的赋值 / `return` | 0 行 |
|
|
172
173
|
|
|
173
174
|
连续两个空行视为格式缺陷;`clang-format` 的 `MaxEmptyLinesToKeep: 1` 会压掉,但不要依赖它。
|
|
174
175
|
|
|
175
176
|
### 函数体内的空行
|
|
176
177
|
|
|
177
|
-
- 每个以 `return` / `throw`
|
|
178
|
+
- 每个以 `return` / `throw` 结束的 `if` 守卫各自成组,守卫组之间空 1 行;同一次检查拆成取值、判断与返回多条语句时组内不空行;守卫组与后续处理之间空 1 行。
|
|
179
|
+
- `CheckInRange(position);` 这类单条检查调用不算独立守卫:它和紧随其后、依赖它的赋值或 `return` 同属一组,组内不空行。
|
|
180
|
+
- `if` 守卫的对照见 `references/exceptions/01-exception-rules.md` 的 `Game::Place`:守卫之间、守卫与后续处理之间各空 1 行。
|
|
178
181
|
- 取回一个结果并按结果分支的语句连成一组(声明、`if`、`throw` / `return`),组内不空行;这一组与收尾(记录这一步、轮到对方、返回成功)之间空 1 行。
|
|
179
182
|
- 同一组语句不拆:三个校验之后的赋值与 `return` 之间不空行。
|
|
180
183
|
- 只有次序依赖的一对 `if`(`GetWinner`、`JudgeAfterPlace`)之间空 1 行。
|
|
@@ -194,6 +197,7 @@ private:
|
|
|
194
197
|
- [Google C++ Style Guide: Declaration Order](https://google.github.io/styleguide/cppguide.html#Declaration_Order):类内先 public、再 protected、最后 private;同节内类型、常量、函数、数据成员的先后。
|
|
195
198
|
- [Google C++ Style Guide: Vertical Whitespace](https://google.github.io/styleguide/cppguide.html#Vertical_Whitespace):垂直留白越少越好;空行用来分隔逻辑分组,函数体首尾不留空行,函数体内不随意加空行。
|
|
196
199
|
- [C++ Core Guidelines: NL.16](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#rl-order):类型、构造/赋值/析构、函数、数据成员的传统次序。
|
|
200
|
+
- [OpenCV Coding Style Guide](https://github.com/opencv/opencv/wiki/Coding_Style_Guide):只要求单个文件风格一致;OpenCV 的 `CV_Assert` 与 Abseil 的 `assert` 后直接 `return`,不插空行,作为主流写法的参考。
|
|
197
201
|
- [cppreference: 构造函数](https://en.cppreference.com/w/cpp/language/constructor):非静态数据成员按声明顺序初始化,与 mem-initializer 列表顺序无关。
|
|
198
202
|
- [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html):只要求每个 `.cpp` 先包含定义其接口的头文件,没有规定成员定义的先后;上一条「与头文件声明同序」因此是本工作流约定,不冒充外部标准。
|
|
199
203
|
- 本工作流在「校验对的位置」上偏离第一条与第三条:把 `static` 的 `Is*` / `Check*` 校验对提到构造函数之前,其余 `static` 函数仍按上两条放在构造函数之后;偏离理由与边界见该节。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| 变量 / 参数 | snake_case | `task_count`, `order` | `TaskCount`, `o` |
|
|
13
13
|
| 类成员 | snake_case + `_` | `tasks_`, `orders_` | `m_tasks`, `tasks` |
|
|
14
14
|
| 结构体成员 | snake_case,无尾随 `_` | `name`, `priority` | `name_`, `priority_` |
|
|
15
|
-
| 编译期常量 / 枚举子 | `k` + PascalCase | `
|
|
15
|
+
| 编译期常量 / 枚举子 | `k` + PascalCase | `kRowCount`, `kSquareCount`, `Order::kDraft` | `TASK_COUNT`, `Draft` |
|
|
16
16
|
| 命名空间 | snake_case | `taskflow`, `warehouse` | `Taskflow`, `Warehouse` |
|
|
17
17
|
| 宏 | 全大写 + 项目前缀,尽量不用 | `CPP_WORKFLOW_ASSERT` | `ASSERT` |
|
|
18
18
|
| 模板类型参数 | PascalCase | `T`, `Item` | `t`, `item_t` |
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
|
|
35
35
|
- 函数名用「动词 + 对象」:`ChooseRandomPosition`、`PlaceAt`、`GetCurrentPlayer`;不要只写动词(`Choose`)或只写对象(`RandomPosition`)。算法、数学或协议的既有专名保留原词,不拆成动词 + 对象,例如 `Minimax`。
|
|
36
36
|
- 容器用复数,并把元素写进名字:`empty_positions`、`moves`;不要写 `empties` 这类省略元素的缩写。
|
|
37
|
-
-
|
|
38
|
-
-
|
|
37
|
+
- 运行期计数带对象:`empty_count`、`move_count`;不要只写 `count`。
|
|
38
|
+
- 常量按同一套词根成组:行数、列数与方格数用 Count 结尾,写 `kRowCount`、`kColumnCount`、`kSquareCount`,三个名字并排就能读出 3 × 3 = 9;容器仍用复数(`squares_`、`moves`),运行期计数用单数 + `_count`(`move_count`),同一个复数后缀不同时承担数量与容器两种角色。
|
|
39
39
|
- 不删字母缩写:`distribution` 不写 `dist`;`position` 的写法见上一条与 [glossary/02-position.md](glossary/02-position.md)。
|
|
40
40
|
- 可能选不中时返回 `std::optional`:`ChoosePosition`、`ChooseRandomPosition`、`ChooseBestPosition` 没有合法选择时返回 `std::nullopt`,不返回哨兵位置。
|
|
41
41
|
- 共享资源访问器用名词短语(`RandomEngine`),不写 `GetRandomEngine`;`Get` 留给类里直接返回成员的查询。
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
- 英文棋类资料把 `Square` 当坐标或位置:CPW 的 `Squares`、Stockfish 的 `enum Square`、chess.hpp、python-chess、Chess.com 都这样用;`Square` 只表示「哪一格」,不表示「格中是什么」。
|
|
20
20
|
- 井字棋英文资料更常用 `mark`:Exploratorium 写「putting their marks in empty squares」,SciMigo 的 `enum class Mark { Empty, X, O }` 也是直接先例。`Mark` 比 `SquareValue` 短,也不会把容器名重复进值类型。
|
|
21
21
|
- `SquareValue` 也有先例:LucHermitte 的 C++ 井字棋用 `enum class SquareValue` 与 `Square::value()`;Rust 的 tictacrustle 用 `SquareValue` 与 `set_value`;React 井字棋用 `value`。它和 `Square` 配对,读作「方格的值」。
|
|
22
|
-
- 风险在 `Value` 的歧义:Stockfish 的 `using Value = int` 是搜索分值;中文项目的 `Value[3][3]` 是点位评估分。`SquareValue`
|
|
22
|
+
- 风险在 `Value` 的歧义:Stockfish 的 `using Value = int` 是搜索分值;中文项目的 `Value[3][3]` 是点位评估分。`SquareValue` 有被读成「分值」的可能,所以类型注释的句式见 [注释术语表](../../comments/glossary/01-comment-terms.md),不在这里重复;取值也可由枚举行的 `///<` 表达,不另起枚举项清单;函数名见 [01-identifier-names.md](../01-identifier-names.md) 的「谓词与查询命名」。
|
|
23
23
|
- 本项目按用户裁决使用 `SquareValue`,与插件规则、代码和书稿统一;`Mark` 只在英文资料的取舍说明里出现,不作为代码名。
|
|
24
24
|
- 中文用词:`Square` 写「方格」,`SquareValue` 写「方格的值」;`格子` 更泛(汉典「方形的空栏或框子」),`棋格` 是「下棋的技艺水平」(汉典),都不能替代「方格」;`棋盘` 是整块盘面。`值` 用「方格的值」「空」「X」「O」;`标记` 不再用于这个类型。
|
|
25
25
|
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
- 类内声明顺序见 `references/layout/03-declaration-order.md`;特殊成员 `= default` / `= delete` 的位置见 `references/layout/02-file-template.md`。
|
|
40
40
|
- 查询成员的尾部 `const` 与结果对象的 `[[nodiscard]]` 见 `references/language/value-types/06-const-method.md`、`07-nodiscard.md`。
|
|
41
41
|
- 所有权与裸 `new` / `delete` 见 `references/language/language-basics/08-raii.md`;四种 `*_cast` 与禁止 C 风格转换见 `references/language/value-types/02-signed.md`。
|
|
42
|
-
- `.cpp` 里不需要外部引用的 `constexpr`
|
|
42
|
+
- `.cpp` 里不需要外部引用的 `constexpr` 放在命名空间作用域,具名或匿名命名空间都可以:普通 `.cpp` 里非 `inline` 的两种写法都已有内部链接,命名空间作用域不再加 `static`。仅一个函数使用、且不是文件级表的常量,才用函数内 `static constexpr`;函数和类型仍放匿名命名空间。
|
|
43
43
|
- 一个 `.cpp` 只写一个匿名命名空间,公开函数的定义放在它后面。
|
|
44
44
|
- 只给本翻译单元用的函数和类型放唯一的匿名命名空间,不用文件作用域 `static` 隐藏函数:LLVM 与 Mozilla 的规范偏好 `static`,Chromium、C++ Core Guidelines SF.22、MISRA C++:2023 6.5.2 与 Abseil Tip 186 用匿名命名空间,本工作流跟后面这一组。
|
|
45
45
|
- 类的 `static` 成员函数没有内部链接,不能用来隐藏实现;函数内 `static` 对象只表示静态存储期,不表示内部链接。
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
## 表达式与整数
|
|
59
59
|
|
|
60
60
|
- 比较不写 Yoda 形式:`x == 0`、`task == TaskState::kPending`;不要写 `0 == x`、`nullptr == p`。
|
|
61
|
-
-
|
|
61
|
+
- 半开区间写成 `0 <= id && id < kTaskCount`:下界常量在左,上界变量在左;`0 <=` 是区间写法,不是 Yoda 条件,等值比较仍写 `x == 0`,不写 `0 == x`。
|
|
62
62
|
- 混合优先级算术加显式括号,让读代码的人不必先还原优先级;默认 Checks 不含 `readability-math-missing-parentheses`,这条靠评审。
|
|
63
63
|
- 内建整数默认用 `int`;需要确定宽度时用 `<cstdint>` 的 `std::int32_t`、`std::int64_t` 等(可省略 `std::` 前缀),可能到 2^31 的值用 64 位;`std::size_t` / `std::ptrdiff_t` 只用于大小和指针差。不要用无符号类型表达「这个值不会为负」。
|
|
64
64
|
- 封闭状态码用 `enum class`;本项目默认写 `: std::uint8_t`(见 `references/language/value-types/04-enum.md`,有意偏离 Google 的默认 `int`),确需其他 ABI 宽度时写明理由,普通枚举用默认底层类型。枚举值只在必要时显式指定;默认的连续值有利于 `switch` 的实现,也能避免因手写数值而出错(C++ Core Guidelines Enum.8)。枚举值总是带作用域:`OrderResult::kSuccess`。
|
|
@@ -48,10 +48,10 @@ const TYPE_SYSTEM = /值语义|自由拷贝/
|
|
|
48
48
|
const NEGATED_BOUNDARY = /只保存|不拥有|不含/
|
|
49
49
|
const NEGATIVE_SCOPE = /不(?:检查|校验|验证|负责|判断)/
|
|
50
50
|
const ESCAPE_SEQUENCE = /\\033|\\x1[bB]|\\e(?![A-Za-z0-9])/
|
|
51
|
-
const STRING_SEQUENCE_CONSTANT = /^(?:static\s+)?(?:inline\s+)?constexpr\s+(?:std::string_view|(?:const\s+)?char\s*(?:const\s*)?\*)\s+([A-Za-z_]\w*)\s
|
|
52
|
-
const CHAR_SEQUENCE_CONSTANT = /^(?:static\s+)?(?:inline\s+)?constexpr\s+char\s+([A-Za-z_]\w*)\s
|
|
51
|
+
const STRING_SEQUENCE_CONSTANT = /^(?:static\s+)?(?:inline\s+)?constexpr\s+(?:std::string_view|(?:const\s+)?char\s*(?:const\s*)?\*)\s+([A-Za-z_]\w*)\s*(?:=\s*"((?:[^"\\]|\\.)*)"|\{\s*"((?:[^"\\]|\\.)*)"\s*\})\s*;/
|
|
52
|
+
const CHAR_SEQUENCE_CONSTANT = /^(?:static\s+)?(?:inline\s+)?constexpr\s+char\s+([A-Za-z_]\w*)\s*(?:=\s*'(\\033|\\x1[bB]|\\e)'|\{\s*'(\\033|\\x1[bB]|\\e)'\s*\})\s*;/
|
|
53
53
|
const SEQUENCE_FIRST = /的(?:控制|转义)序列(?::.+)?。$/
|
|
54
|
-
const DOMAIN_SIZE =
|
|
54
|
+
const DOMAIN_SIZE = /(?:\d+|[一二三四五六七八九十百]+)\s*[×xX]\s*(?:\d+|[一二三四五六七八九十百]+)|(?:\d+|[一二三四五六七八九十百]+)\s*行\s*(?:\d+|[一二三四五六七八九十百]+)\s*列|九个?方?格|边长/
|
|
55
55
|
const SPECIAL_MEMBER_VAGUE = /创建对象|建立初始状态|初始化成员/
|
|
56
56
|
const PREDICATE_DECL = /^(?:\[\[nodiscard\]\]\s*)?(?:static\s+)?bool\s+(?:Is|Has|Can|Completes|Would)[A-Za-z0-9_]*\s*\(|operator==/
|
|
57
57
|
const PREDICATE_BANNED_PREFIX = /^(?:检查|判断|校验|验证)/
|
|
@@ -431,6 +431,22 @@ function bodyRange(lines, index) {
|
|
|
431
431
|
return { start, end: lines.length - 1 }
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/** 类型体是否声明固定尺寸数组成员:固定尺寸容器(如棋盘)可以在类型注释写领域尺寸。 */
|
|
435
|
+
function hasFixedArrayMember(lines, start) {
|
|
436
|
+
const body = bodyRange(lines, start)
|
|
437
|
+
if (!body) return false
|
|
438
|
+
let depth = 0
|
|
439
|
+
for (let cursor = body.start; cursor <= body.end; cursor += 1) {
|
|
440
|
+
const trimmed = lines[cursor].trim()
|
|
441
|
+
if (depth === 1 && trimmed !== '' && !trimmed.startsWith('//') && !trimmed.startsWith('/*') && !trimmed.startsWith('*')) {
|
|
442
|
+
if (trimmed.includes('std::array<') && !trimmed.includes('(')) return true
|
|
443
|
+
if (!trimmed.includes('(') && /\[[^\]]+\]\s*(?:[;=])/.test(trimmed)) return true
|
|
444
|
+
}
|
|
445
|
+
depth += braceDelta(lines[cursor])
|
|
446
|
+
}
|
|
447
|
+
return false
|
|
448
|
+
}
|
|
449
|
+
|
|
434
450
|
/** 检查 .cpp 定义处的注释落点:函数体内用 // 写实现注释,头文件已声明的定义不写 ///,只在 .cpp 出现的函数写完整契约。 */
|
|
435
451
|
export function checkDefinitionDocs(text, headerNames = new Set(), options = {}) {
|
|
436
452
|
const issues = []
|
|
@@ -486,7 +502,10 @@ export function checkDefinitionDocs(text, headerNames = new Set(), options = {})
|
|
|
486
502
|
function escapedControlConstant(declaration) {
|
|
487
503
|
const text = declaration.trim()
|
|
488
504
|
const string = STRING_SEQUENCE_CONSTANT.exec(text)
|
|
489
|
-
if (string
|
|
505
|
+
if (string) {
|
|
506
|
+
const literal = string[2] !== undefined ? string[2] : string[3]
|
|
507
|
+
if (ESCAPE_SEQUENCE.test(literal)) return string[1]
|
|
508
|
+
}
|
|
490
509
|
const character = CHAR_SEQUENCE_CONSTANT.exec(text)
|
|
491
510
|
return character ? character[1] : undefined
|
|
492
511
|
}
|
|
@@ -861,8 +880,8 @@ export function checkText(text, options = {}) {
|
|
|
861
880
|
if (NEGATIVE_SCOPE.test(block)) {
|
|
862
881
|
add(start + 1, 'negative-scope', '注释用「不检查/不校验/不负责/不判断」写能力边界:改成正向限定,前置条件写「调用方保证…」或 @pre')
|
|
863
882
|
}
|
|
864
|
-
if (isType && DOMAIN_SIZE.test(block)) {
|
|
865
|
-
add(start + 1, 'domain-size', '
|
|
883
|
+
if (isType && DOMAIN_SIZE.test(block) && !hasFixedArrayMember(lines, next)) {
|
|
884
|
+
add(start + 1, 'domain-size', '类型注释在写领域尺寸:只有固定尺寸容器(如棋盘)可以写尺寸;方格等值类型不写')
|
|
866
885
|
}
|
|
867
886
|
const firstDocLine = lines[start].trim().replace(/^\/\/\/\s*/, '')
|
|
868
887
|
if (!isType && PREDICATE_DECL.test(declaration) && !isPredicateFirstOk(declaration, firstDocLine)) {
|
|
@@ -917,7 +936,7 @@ export function checkText(text, options = {}) {
|
|
|
917
936
|
if (isType && TYPE_SYSTEM.test(block)) add(doc.start + 1, 'type-system', '类型注释在复述类型系统已表达的性质:可拷贝与 const 查询由声明给出,删掉这句')
|
|
918
937
|
if (isType && NEGATED_BOUNDARY.test(block)) add(doc.start + 1, 'negated-boundary', '类型注释用「只保存/不拥有/不含」写否定式边界:改成名词短语,边界交给成员类型表达')
|
|
919
938
|
if (NEGATIVE_SCOPE.test(block)) add(doc.start + 1, 'negative-scope', '注释用「不检查/不校验/不负责/不判断」写能力边界:改成正向限定,前置条件写「调用方保证…」或 @pre')
|
|
920
|
-
if (isType && DOMAIN_SIZE.test(block)) add(doc.start + 1, 'domain-size', '
|
|
939
|
+
if (isType && DOMAIN_SIZE.test(block) && !hasFixedArrayMember(lines, next)) add(doc.start + 1, 'domain-size', '类型注释在写领域尺寸:只有固定尺寸容器(如棋盘)可以写尺寸;方格等值类型不写')
|
|
921
940
|
const firstDocLine = doc.contents[0] ?? ''
|
|
922
941
|
if (!isType && PREDICATE_DECL.test(declaration) && !isPredicateFirstOk(declaration, firstDocLine)) {
|
|
923
942
|
add(doc.start + 1, 'predicate-first', '布尔查询的第一句应写「…是否…」,句首不用「检查/判断/校验/验证」;operator== 写「相等运算符」')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- 读取时机:配 CMake 或工具链时;读完能回答:语言标准档案;预算:一次只开这一份(144 行),不自动串联。 -->
|
|
2
2
|
# 语言标准档案
|
|
3
3
|
|
|
4
|
-
本工作流默认 **C++23**,但一个工程只选一个 `standard`,不为同一份源码承诺“同时兼容 C++11–C++23
|
|
4
|
+
本工作流默认 **C++23**,但一个工程只选一个 `standard`,不为同一份源码承诺“同时兼容 C++11–C++23”。标准是项目级事实,写在项目技能目录的 `environment.json`(目录名也接受 `cpp_workflow_project`)。
|
|
5
5
|
|
|
6
6
|
各档的编译器下限、能用/不能假设、降档要改什么集中在 [versions.md](versions.md);`c++11/`–`c++23/` 只保留这一档的 `cmake-snippet.cmake`。模板仍然只有一套公共骨架,靠 `__cplusplus` 条件选择实现,不复制五份模板。
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ Diagnostics:
|
|
|
13
13
|
- pp_file_not_found
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
- `CompilationDatabase` 指向当前编译器目录;GCC 模式改 `build/gcc
|
|
16
|
+
- `CompilationDatabase` 指向当前编译器目录;GCC 模式改 `build/gcc`。项目技能声明单一构建目录时指向该目录,不再按编译器分目录。目录必须与 `environment.json` 的 `compiler` 一致,切换编译器时两处同改。
|
|
17
17
|
- 不要在 `.clangd` 写 `-std`:它会覆盖 `compile_commands.json`,把 C++23 工程降成旧标准。标准只由构建声明和编译数据库决定。
|
|
18
18
|
- 静态检查规则只在 `.clang-tidy` 里维护;clangd 读取同一份配置,不要在这里复制检查列表。
|
|
19
19
|
- `Suppress` 只放确实无法避免的解析噪声(如 `pp_file_not_found`),并写理由。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cpp-workflow-project
|
|
3
|
-
description: 当前 C++ 工程的本地事实与通用工作流约定:工程与组件名、程序 target
|
|
3
|
+
description: 当前 C++ 工程的本地事实与通用工作流约定:工程与组件名、程序 target、构建目录、库和程序的边界、入口命令、阶段表。开始任何 C++ 任务前先读;工程特有的值写在这里,通用条文由插件三个技能维护。
|
|
4
4
|
metadata:
|
|
5
5
|
short-description: 当前 C++ 工程事实与通用约定
|
|
6
6
|
---
|
|
@@ -9,7 +9,7 @@ metadata:
|
|
|
9
9
|
|
|
10
10
|
这是项目模板,不是插件;复制整个目录到目标仓库的 `.agents/skills/` 下,目录名保持 `cpp-workflow-project`,再把下面的空位换成该工程的真实值。目标已有同名文件时只补缺失文件,不覆盖源码、`CMakeLists.txt` 或 `.clang-*`。一个仓库只保留一份 `environment.json`。
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
本文件只写工程自己的值与通用约定;通用源码、CMake、构建、编辑器和检查条文由三个插件技能维护。不要在项目技能里复制三份技能的正文。
|
|
13
13
|
|
|
14
14
|
## 工程与组件
|
|
15
15
|
|
|
@@ -34,7 +34,7 @@ metadata:
|
|
|
34
34
|
|
|
35
35
|
## 通用工作流约定
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
以下约定不随工程变化。
|
|
38
38
|
|
|
39
39
|
- 环境以 `environment.json` 为唯一来源;新工程默认 C++23,不猜轴、不猜编译器。
|
|
40
40
|
- `.clang-format`、`.clang-tidy`、`.clangd`、`.vscode/` 随工程存放(工程根=含 `CMakeLists.txt` 的目录);三件 clang 工具会从文件所在目录向上查找配置,工程根必须自带这三份,不依赖仓库根、书根或用户主目录的那份;`.vscode/` 只对打开为工作区的那个目录生效,不开在仓库根或书根。
|
|
@@ -60,10 +60,6 @@ metadata:
|
|
|
60
60
|
- 路径:`stages/stage-table.md`
|
|
61
61
|
- 一个阶段一行,只写可观察行为;没有可观察行为的不进表。
|
|
62
62
|
|
|
63
|
-
## 术语增补
|
|
64
|
-
|
|
65
|
-
- `<domain term>`:`<meaning>`
|
|
66
|
-
|
|
67
63
|
## 编辑器补全
|
|
68
64
|
|
|
69
65
|
- clangd 提供补全、跳转和诊断;`.clangd` 指向项目技能声明的构建目录:单一目录写该目录,多编译器写 `build/<compiler>`;不写 `-std`。
|
|
@@ -78,7 +74,3 @@ metadata:
|
|
|
78
74
|
- [ ] 阶段表、代码目录与文档章节的实际状态一致。
|
|
79
75
|
- [ ] 有文档检查时,项目声明的检查命令通过;跨域改动也跑同一条。
|
|
80
76
|
- [ ] `git status --porcelain` 只剩本轮有意改动的文件;检查命令只写终端,需要留证据时写已忽略的 `temp/`。
|
|
81
|
-
|
|
82
|
-
## 可选约定
|
|
83
|
-
|
|
84
|
-
- 两个具体工程之前不抽共享库;领域术语、平台差异和本工程的偏离写在这里。
|