conductor-4-all 0.0.12 → 0.0.14
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/dist/index.cjs +50 -6
- package/dist/index.js +50 -6
- package/dist/templates/GEMINI.md +41 -0
- package/dist/templates/templates/code_styleguides/cpp.md +113 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -176,11 +176,13 @@ var opencodeConfig = {
|
|
|
176
176
|
agentType: "opencode",
|
|
177
177
|
agentDir: ".opencode",
|
|
178
178
|
commandsDir: "commands",
|
|
179
|
-
displayName: "OpenCode"
|
|
179
|
+
displayName: "OpenCode",
|
|
180
|
+
protocolFilename: "AGENTS.md"
|
|
180
181
|
};
|
|
181
182
|
|
|
182
183
|
// src/generators/ConfigurableGenerator.ts
|
|
183
184
|
var import_path3 = require("path");
|
|
185
|
+
var import_select2 = __toESM(require("@inquirer/select"), 1);
|
|
184
186
|
var import_fs_extra2 = __toESM(require("fs-extra"), 1);
|
|
185
187
|
var { existsSync, ensureDir, writeFile: writeFile2, copy } = import_fs_extra2.default;
|
|
186
188
|
var ConfigurableGenerator = class {
|
|
@@ -217,6 +219,30 @@ var ConfigurableGenerator = class {
|
|
|
217
219
|
} catch (e) {
|
|
218
220
|
console.warn("Failed to copy templates directory:", e);
|
|
219
221
|
}
|
|
222
|
+
const { protocolFilename } = this.config;
|
|
223
|
+
if (protocolFilename) {
|
|
224
|
+
try {
|
|
225
|
+
const protocolSource = (0, import_path3.join)(templateRoot, "GEMINI.md");
|
|
226
|
+
const protocolDest = (0, import_path3.join)(targetDir, protocolFilename);
|
|
227
|
+
if (existsSync(protocolSource)) {
|
|
228
|
+
let shouldCopy = true;
|
|
229
|
+
if (existsSync(protocolDest)) {
|
|
230
|
+
shouldCopy = await (0, import_select2.default)({
|
|
231
|
+
message: `The protocol file '${protocolFilename}' already exists. Do you want to overwrite it?`,
|
|
232
|
+
choices: [
|
|
233
|
+
{ value: true, name: "Overwrite" },
|
|
234
|
+
{ value: false, name: "Skip" }
|
|
235
|
+
]
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (shouldCopy) {
|
|
239
|
+
await copy(protocolSource, protocolDest);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
} catch (e) {
|
|
243
|
+
console.warn("Failed to handle protocol file:", e);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
220
246
|
const commands = ["setup", "newTrack", "implement", "status", "revert"];
|
|
221
247
|
const extension = this.config.extension || ".md";
|
|
222
248
|
const fixedAgent = this.config.fixedAgent;
|
|
@@ -269,7 +295,8 @@ var claudeCodeConfig = {
|
|
|
269
295
|
agentType: "claude-code",
|
|
270
296
|
agentDir: ".claude",
|
|
271
297
|
commandsDir: "commands",
|
|
272
|
-
displayName: "Claude Code"
|
|
298
|
+
displayName: "Claude Code",
|
|
299
|
+
protocolFilename: "CLAUDE.md"
|
|
273
300
|
};
|
|
274
301
|
|
|
275
302
|
// src/generators/claude-code/generator.ts
|
|
@@ -288,7 +315,8 @@ var antigravityConfig = {
|
|
|
288
315
|
agentType: "antigravity",
|
|
289
316
|
agentDir: ".agent",
|
|
290
317
|
commandsDir: "workflows",
|
|
291
|
-
displayName: "Antigravity"
|
|
318
|
+
displayName: "Antigravity",
|
|
319
|
+
protocolFilename: "GEMINI.md"
|
|
292
320
|
};
|
|
293
321
|
|
|
294
322
|
// src/generators/antigravity/generator.ts
|
|
@@ -307,7 +335,8 @@ var cursorConfig = {
|
|
|
307
335
|
agentType: "cursor",
|
|
308
336
|
agentDir: ".cursor",
|
|
309
337
|
commandsDir: "commands",
|
|
310
|
-
displayName: "Cursor"
|
|
338
|
+
displayName: "Cursor",
|
|
339
|
+
protocolFilename: "AGENTS.md"
|
|
311
340
|
};
|
|
312
341
|
|
|
313
342
|
// src/generators/cursor/generator.ts
|
|
@@ -348,6 +377,7 @@ var vscodeCopilotConfig = {
|
|
|
348
377
|
agentDir: ".github",
|
|
349
378
|
commandsDir: "prompts",
|
|
350
379
|
displayName: "VS Code Copilot",
|
|
380
|
+
protocolFilename: "AGENTS.md",
|
|
351
381
|
extension: ".prompt.md",
|
|
352
382
|
fixedAgent: "agent",
|
|
353
383
|
strategy: {
|
|
@@ -372,6 +402,7 @@ var codexConfig = {
|
|
|
372
402
|
agentDir: ".codex",
|
|
373
403
|
commandsDir: "prompts",
|
|
374
404
|
displayName: "Codex",
|
|
405
|
+
protocolFilename: "AGENTS.md",
|
|
375
406
|
extension: ".md"
|
|
376
407
|
};
|
|
377
408
|
|
|
@@ -398,7 +429,8 @@ var windsurfConfig = {
|
|
|
398
429
|
agentType: "windsurf",
|
|
399
430
|
agentDir: ".windsurf",
|
|
400
431
|
commandsDir: "workflows",
|
|
401
|
-
displayName: "Windsurf"
|
|
432
|
+
displayName: "Windsurf",
|
|
433
|
+
protocolFilename: "AGENTS.md"
|
|
402
434
|
};
|
|
403
435
|
|
|
404
436
|
// src/generators/windsurf/generator.ts
|
|
@@ -436,6 +468,7 @@ var clineConfig = {
|
|
|
436
468
|
agentDir: ".clinerules",
|
|
437
469
|
commandsDir: "workflows",
|
|
438
470
|
displayName: "Cline",
|
|
471
|
+
protocolFilename: "AGENTS.md",
|
|
439
472
|
strategy: {
|
|
440
473
|
content: clineContentStrategy
|
|
441
474
|
}
|
|
@@ -484,6 +517,7 @@ var geminiConfig = {
|
|
|
484
517
|
agentDir: ".gemini",
|
|
485
518
|
commandsDir: "commands/conductor",
|
|
486
519
|
displayName: "Gemini CLI",
|
|
520
|
+
protocolFilename: "GEMINI.md",
|
|
487
521
|
extension: ".toml",
|
|
488
522
|
strategy: {
|
|
489
523
|
content: geminiContentStrategy,
|
|
@@ -577,7 +611,17 @@ var cli = (0, import_yargs.default)((0, import_helpers.hideBin)(process.argv)).s
|
|
|
577
611
|
alias: "a",
|
|
578
612
|
describe: "Specify the coding agent",
|
|
579
613
|
type: "string",
|
|
580
|
-
choices: [
|
|
614
|
+
choices: [
|
|
615
|
+
"opencode",
|
|
616
|
+
"claude-code",
|
|
617
|
+
"antigravity",
|
|
618
|
+
"cursor",
|
|
619
|
+
"vscode-copilot",
|
|
620
|
+
"codex",
|
|
621
|
+
"windsurf",
|
|
622
|
+
"cline",
|
|
623
|
+
"gemini"
|
|
624
|
+
]
|
|
581
625
|
});
|
|
582
626
|
},
|
|
583
627
|
installHandler
|
package/dist/index.js
CHANGED
|
@@ -149,11 +149,13 @@ var opencodeConfig = {
|
|
|
149
149
|
agentType: "opencode",
|
|
150
150
|
agentDir: ".opencode",
|
|
151
151
|
commandsDir: "commands",
|
|
152
|
-
displayName: "OpenCode"
|
|
152
|
+
displayName: "OpenCode",
|
|
153
|
+
protocolFilename: "AGENTS.md"
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
// src/generators/ConfigurableGenerator.ts
|
|
156
157
|
import { join as join3 } from "path";
|
|
158
|
+
import select2 from "@inquirer/select";
|
|
157
159
|
import fs2 from "fs-extra";
|
|
158
160
|
var { existsSync, ensureDir, writeFile: writeFile2, copy } = fs2;
|
|
159
161
|
var ConfigurableGenerator = class {
|
|
@@ -190,6 +192,30 @@ var ConfigurableGenerator = class {
|
|
|
190
192
|
} catch (e) {
|
|
191
193
|
console.warn("Failed to copy templates directory:", e);
|
|
192
194
|
}
|
|
195
|
+
const { protocolFilename } = this.config;
|
|
196
|
+
if (protocolFilename) {
|
|
197
|
+
try {
|
|
198
|
+
const protocolSource = join3(templateRoot, "GEMINI.md");
|
|
199
|
+
const protocolDest = join3(targetDir, protocolFilename);
|
|
200
|
+
if (existsSync(protocolSource)) {
|
|
201
|
+
let shouldCopy = true;
|
|
202
|
+
if (existsSync(protocolDest)) {
|
|
203
|
+
shouldCopy = await select2({
|
|
204
|
+
message: `The protocol file '${protocolFilename}' already exists. Do you want to overwrite it?`,
|
|
205
|
+
choices: [
|
|
206
|
+
{ value: true, name: "Overwrite" },
|
|
207
|
+
{ value: false, name: "Skip" }
|
|
208
|
+
]
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (shouldCopy) {
|
|
212
|
+
await copy(protocolSource, protocolDest);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (e) {
|
|
216
|
+
console.warn("Failed to handle protocol file:", e);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
193
219
|
const commands = ["setup", "newTrack", "implement", "status", "revert"];
|
|
194
220
|
const extension = this.config.extension || ".md";
|
|
195
221
|
const fixedAgent = this.config.fixedAgent;
|
|
@@ -242,7 +268,8 @@ var claudeCodeConfig = {
|
|
|
242
268
|
agentType: "claude-code",
|
|
243
269
|
agentDir: ".claude",
|
|
244
270
|
commandsDir: "commands",
|
|
245
|
-
displayName: "Claude Code"
|
|
271
|
+
displayName: "Claude Code",
|
|
272
|
+
protocolFilename: "CLAUDE.md"
|
|
246
273
|
};
|
|
247
274
|
|
|
248
275
|
// src/generators/claude-code/generator.ts
|
|
@@ -261,7 +288,8 @@ var antigravityConfig = {
|
|
|
261
288
|
agentType: "antigravity",
|
|
262
289
|
agentDir: ".agent",
|
|
263
290
|
commandsDir: "workflows",
|
|
264
|
-
displayName: "Antigravity"
|
|
291
|
+
displayName: "Antigravity",
|
|
292
|
+
protocolFilename: "GEMINI.md"
|
|
265
293
|
};
|
|
266
294
|
|
|
267
295
|
// src/generators/antigravity/generator.ts
|
|
@@ -280,7 +308,8 @@ var cursorConfig = {
|
|
|
280
308
|
agentType: "cursor",
|
|
281
309
|
agentDir: ".cursor",
|
|
282
310
|
commandsDir: "commands",
|
|
283
|
-
displayName: "Cursor"
|
|
311
|
+
displayName: "Cursor",
|
|
312
|
+
protocolFilename: "AGENTS.md"
|
|
284
313
|
};
|
|
285
314
|
|
|
286
315
|
// src/generators/cursor/generator.ts
|
|
@@ -321,6 +350,7 @@ var vscodeCopilotConfig = {
|
|
|
321
350
|
agentDir: ".github",
|
|
322
351
|
commandsDir: "prompts",
|
|
323
352
|
displayName: "VS Code Copilot",
|
|
353
|
+
protocolFilename: "AGENTS.md",
|
|
324
354
|
extension: ".prompt.md",
|
|
325
355
|
fixedAgent: "agent",
|
|
326
356
|
strategy: {
|
|
@@ -345,6 +375,7 @@ var codexConfig = {
|
|
|
345
375
|
agentDir: ".codex",
|
|
346
376
|
commandsDir: "prompts",
|
|
347
377
|
displayName: "Codex",
|
|
378
|
+
protocolFilename: "AGENTS.md",
|
|
348
379
|
extension: ".md"
|
|
349
380
|
};
|
|
350
381
|
|
|
@@ -371,7 +402,8 @@ var windsurfConfig = {
|
|
|
371
402
|
agentType: "windsurf",
|
|
372
403
|
agentDir: ".windsurf",
|
|
373
404
|
commandsDir: "workflows",
|
|
374
|
-
displayName: "Windsurf"
|
|
405
|
+
displayName: "Windsurf",
|
|
406
|
+
protocolFilename: "AGENTS.md"
|
|
375
407
|
};
|
|
376
408
|
|
|
377
409
|
// src/generators/windsurf/generator.ts
|
|
@@ -409,6 +441,7 @@ var clineConfig = {
|
|
|
409
441
|
agentDir: ".clinerules",
|
|
410
442
|
commandsDir: "workflows",
|
|
411
443
|
displayName: "Cline",
|
|
444
|
+
protocolFilename: "AGENTS.md",
|
|
412
445
|
strategy: {
|
|
413
446
|
content: clineContentStrategy
|
|
414
447
|
}
|
|
@@ -457,6 +490,7 @@ var geminiConfig = {
|
|
|
457
490
|
agentDir: ".gemini",
|
|
458
491
|
commandsDir: "commands/conductor",
|
|
459
492
|
displayName: "Gemini CLI",
|
|
493
|
+
protocolFilename: "GEMINI.md",
|
|
460
494
|
extension: ".toml",
|
|
461
495
|
strategy: {
|
|
462
496
|
content: geminiContentStrategy,
|
|
@@ -550,7 +584,17 @@ var cli = yargs(hideBin(process.argv)).scriptName("conductor").usage("$0 <cmd> [
|
|
|
550
584
|
alias: "a",
|
|
551
585
|
describe: "Specify the coding agent",
|
|
552
586
|
type: "string",
|
|
553
|
-
choices: [
|
|
587
|
+
choices: [
|
|
588
|
+
"opencode",
|
|
589
|
+
"claude-code",
|
|
590
|
+
"antigravity",
|
|
591
|
+
"cursor",
|
|
592
|
+
"vscode-copilot",
|
|
593
|
+
"codex",
|
|
594
|
+
"windsurf",
|
|
595
|
+
"cline",
|
|
596
|
+
"gemini"
|
|
597
|
+
]
|
|
554
598
|
});
|
|
555
599
|
},
|
|
556
600
|
installHandler
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Conductor Context
|
|
2
|
+
|
|
3
|
+
If a user mentions a "plan" or asks about the plan, and they have used the conductor extension in the current session, they are likely referring to the `conductor/tracks.md` file or one of the track plans (`conductor/tracks/<track_id>/plan.md`).
|
|
4
|
+
|
|
5
|
+
## Universal File Resolution Protocol
|
|
6
|
+
|
|
7
|
+
**PROTOCOL: How to locate files.**
|
|
8
|
+
To find a file (e.g., "**Product Definition**") within a specific context (Project Root or a specific Track):
|
|
9
|
+
|
|
10
|
+
1. **Identify Index:** Determine the relevant index file:
|
|
11
|
+
- **Project Context:** `conductor/index.md`
|
|
12
|
+
- **Track Context:**
|
|
13
|
+
a. Resolve and read the **Tracks Registry** (via Project Context).
|
|
14
|
+
b. Find the entry for the specific `<track_id>`.
|
|
15
|
+
c. Follow the link provided in the registry to locate the track's folder. The index file is `<track_folder>/index.md`.
|
|
16
|
+
d. **Fallback:** If the track is not yet registered (e.g., during creation) or the link is broken:
|
|
17
|
+
1. Resolve the **Tracks Directory** (via Project Context).
|
|
18
|
+
2. The index file is `<Tracks Directory>/<track_id>/index.md`.
|
|
19
|
+
|
|
20
|
+
2. **Check Index:** Read the index file and look for a link with a matching or semantically similar label.
|
|
21
|
+
|
|
22
|
+
3. **Resolve Path:** If a link is found, resolve its path **relative to the directory containing the `index.md` file**.
|
|
23
|
+
- *Example:* If `conductor/index.md` links to `./workflow.md`, the full path is `conductor/workflow.md`.
|
|
24
|
+
|
|
25
|
+
4. **Fallback:** If the index file is missing or the link is absent, use the **Default Path** keys below.
|
|
26
|
+
|
|
27
|
+
5. **Verify:** You MUST verify the resolved file actually exists on the disk.
|
|
28
|
+
|
|
29
|
+
**Standard Default Paths (Project):**
|
|
30
|
+
- **Product Definition**: `conductor/product.md`
|
|
31
|
+
- **Tech Stack**: `conductor/tech-stack.md`
|
|
32
|
+
- **Workflow**: `conductor/workflow.md`
|
|
33
|
+
- **Product Guidelines**: `conductor/product-guidelines.md`
|
|
34
|
+
- **Tracks Registry**: `conductor/tracks.md`
|
|
35
|
+
- **Tracks Directory**: `conductor/tracks/`
|
|
36
|
+
|
|
37
|
+
**Standard Default Paths (Track):**
|
|
38
|
+
- **Specification**: `conductor/tracks/<track_id>/spec.md`
|
|
39
|
+
- **Implementation Plan**: `conductor/tracks/<track_id>/plan.md`
|
|
40
|
+
- **Metadata**: `conductor/tracks/<track_id>/metadata.json`
|
|
41
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Google C++ Style Guide Summary
|
|
2
|
+
|
|
3
|
+
## 1. Naming
|
|
4
|
+
- **General:** Optimize for readability. Be descriptive but concise. Use inclusive language.
|
|
5
|
+
- **Files:** `.h` (headers), `.cc` (source). Lowercase with underscores (`_`) or dashes (`-`). Be consistent.
|
|
6
|
+
- **Types:** PascalCase (`MyClass`, `MyEnum`). Use `int` by default; use `<cstdint>` (`int32_t`) if size matters.
|
|
7
|
+
- **Concepts:** PascalCase (`MyConcept`).
|
|
8
|
+
- **Variables:** snake_case (`my_var`). Class members end with underscore (`my_member_`), struct members do not.
|
|
9
|
+
- **Constants/Enumerators:** `k` + PascalCase (`kDays`, `kOk`).
|
|
10
|
+
- **Template Parameters:** PascalCase for types (`T`, `MyType`), snake_case/kPascalCase for non-types (`N`, `kLimit`).
|
|
11
|
+
- **Functions:** PascalCase (`GetValue()`).
|
|
12
|
+
- **Accessors/Mutators:** snake_case. `count()` (not `GetCount`), `set_count(v)`.
|
|
13
|
+
- **Namespaces:** lowercase (`web_search`).
|
|
14
|
+
- **Macros:** ALL_CAPS (`MY_MACRO`).
|
|
15
|
+
|
|
16
|
+
## 2. Header Files
|
|
17
|
+
- **General:** Every `.cc` usually has a `.h`. Headers must be self-contained.
|
|
18
|
+
- **Guards:** Use `#define <PROJECT>_<PATH>_<FILE>_H_`.
|
|
19
|
+
- **IWYU:** Direct includes only. Do not rely on transitive includes.
|
|
20
|
+
- **Forward Decls:** Avoid. Include headers instead. **Never** forward declare `std::` symbols.
|
|
21
|
+
- **Inline Definitions:** Only short functions (<10 lines) in headers. Must be ODR-safe (`inline` or templates).
|
|
22
|
+
- **Include Order:**
|
|
23
|
+
1. Related header (`foo.h`)
|
|
24
|
+
2. C system (`<unistd.h>`)
|
|
25
|
+
3. C++ standard (`<vector>`)
|
|
26
|
+
4. Other libraries (`<Python.h>`)
|
|
27
|
+
5. Project headers (`"base/logging.h"`)
|
|
28
|
+
*Separate groups with blank lines. Alphabetical within groups.*
|
|
29
|
+
|
|
30
|
+
## 3. Formatting
|
|
31
|
+
- **Indentation:** 2 spaces. **Line Length:** 80 chars.
|
|
32
|
+
- **Non-ASCII:** Rare, use UTF-8. Avoid `u8` prefix if possible.
|
|
33
|
+
- **Braces:** `if (cond) { ... }`. **Exception:** Function definition open brace goes on the **next line**.
|
|
34
|
+
- **Switch:** Always include `default`. Use `[[fallthrough]]` for explicit fallthrough.
|
|
35
|
+
- **Literals:** Floating-point must have radix point (`1.0f`).
|
|
36
|
+
- **Calls:** Wrap arguments at paren or 4-space indent.
|
|
37
|
+
- **Init Lists:** Colon on new line, indent 4 spaces.
|
|
38
|
+
- **Namespaces:** No indentation.
|
|
39
|
+
- **Vertical Whitespace:** Use sparingly. Separate related chunks, not code blocks.
|
|
40
|
+
- **Loops/Branching:** Use braces (optional if single line). No space after `(`, space before `{`.
|
|
41
|
+
- **Return:** No parens `return result;`.
|
|
42
|
+
- **Preprocessor:** `#` always at line start.
|
|
43
|
+
- **Pointers:** `char* c` (attached to type).
|
|
44
|
+
- **Templates:** No spaces inside `< >` (`vector<int>`).
|
|
45
|
+
- **Operators:** Space around assignment/binary, no space for unary.
|
|
46
|
+
- **Class Order:** `public`, `protected`, `private`.
|
|
47
|
+
- **Parameter Wrapping:** Wrap parameter lists that don't fit. Use 4-space indent for wrapped parameters.
|
|
48
|
+
|
|
49
|
+
## 4. Classes
|
|
50
|
+
- **Constructors:** `explicit` for single-arg and conversion operators. **Exception:** `std::initializer_list`. No virtual calls in ctors. Use factories for fallible init.
|
|
51
|
+
- **Structs:** Only for passive data. Prefer `struct` over `std::pair` or `std::tuple`.
|
|
52
|
+
- **Copy/Move:** Explicitly `= default` or `= delete`. **Rule of 5:** If defining one, declare all.
|
|
53
|
+
- **Inheritance:** `public` only. Composition > Inheritance. Use `override` (omit `virtual`). No multiple implementation inheritance.
|
|
54
|
+
- **Operator Overloading:** Judicious use only. Binary ops as non-members. Never overload `&&`, `||`, `,`, or unary `&`. No User-Defined Literals.
|
|
55
|
+
- **Access:** Data members `private` (except structs/constants).
|
|
56
|
+
- **Declaration Order:** `public` before `protected` before `private`. Within sections: Types, Constants, Factory, Constructors, Destructor, Methods, Data Members.
|
|
57
|
+
|
|
58
|
+
## 5. Functions
|
|
59
|
+
- **Params:** Inputs (`const T&`, `std::string_view`, `std::span` or value) first, then outputs. **Ordering:** Inputs before outputs.
|
|
60
|
+
- **Outputs:** Prefer return values/`std::optional`. For non-optional outputs, use references. For optional outputs, use pointers.
|
|
61
|
+
- **Optional Inputs:** Use `std::optional` for by-value, `const T*` for reference.
|
|
62
|
+
- **Nonmember vs Static:** Prefer nonmember functions in namespaces over static member functions.
|
|
63
|
+
- **Length:** Prefer small (<40 lines).
|
|
64
|
+
- **Overloading:** Use only when behavior is obvious. Document overload sets with a single umbrella comment.
|
|
65
|
+
- **Default Args:** Allowed on non-virtual functions only (value must be fixed/constant).
|
|
66
|
+
- **Trailing Return:** Only when necessary (lambdas).
|
|
67
|
+
|
|
68
|
+
## 6. Scoping
|
|
69
|
+
- **Namespaces:** No `using namespace`. Use `using std::string`. Never add to `namespace std`.
|
|
70
|
+
- **Internal:** Use anonymous namespaces or `static` in `.cc` files. Avoid in headers.
|
|
71
|
+
- **Locals:** Narrowest scope. Initialize at declaration. **Exception:** Declare complex objects outside loops.
|
|
72
|
+
- **Static/Global:** Must be **trivially destructible** (e.g., `constexpr`, raw pointers, arrays). No global `std::string`, `std::map`, smart pointers. Dynamic initialization allowed only for function-static variables.
|
|
73
|
+
- **Thread Local:** `thread_local` must be `constinit` if global. Prefer `thread_local` over other mechanisms.
|
|
74
|
+
|
|
75
|
+
## 7. Modern C++ Features
|
|
76
|
+
- **Version:** Target **C++20**. Do not use C++23. Consider portability for C++17/20 features. No non-standard extensions.
|
|
77
|
+
- **Modules:** Do not use C++20 Modules.
|
|
78
|
+
- **Coroutines:** Use approved libraries only. Do not roll your own promise or awaitable types.
|
|
79
|
+
- **Concepts:** Prefer C++20 Concepts (`requires`) over `std::enable_if`. Use `requires(Concept<T>)`, not `template<Concept T>`.
|
|
80
|
+
- **R-Value References:** Use only for move ctors/assignment, perfect forwarding, or consuming `*this`.
|
|
81
|
+
- **Smart Pointers:** `std::unique_ptr` (exclusive), `std::shared_ptr` (shared). No `std::auto_ptr`.
|
|
82
|
+
- **Auto:** Use when type is obvious (`make_unique`, iterators). Avoid for public APIs.
|
|
83
|
+
- **CTAD:** Use only if explicitly supported (deduction guides exist).
|
|
84
|
+
- **Structured Bindings:** Use for pairs/tuples. Comment aliased field names.
|
|
85
|
+
- **Nullptr:** Use `nullptr`, never `NULL` or `0`.
|
|
86
|
+
- **Constexpr:** Use `constexpr`/`consteval` for constants/functions whenever possible. Use `constinit` for static initialization.
|
|
87
|
+
- **Noexcept:** Specify when useful/correct. Prefer unconditional `noexcept` if exceptions are disabled.
|
|
88
|
+
- **Lambdas:** Prefer explicit captures (`[&x]`) if escaping scope. Avoid `std::bind`.
|
|
89
|
+
- **Initialization:** Prefer brace init. **Designated Initializers:** Allowed (C++20 ordered form only).
|
|
90
|
+
- **Casts:** Use C++ casts (`static_cast`). Use `std::bit_cast` for type punning.
|
|
91
|
+
- **Loops:** Prefer range-based `for`.
|
|
92
|
+
|
|
93
|
+
## 8. Best Practices
|
|
94
|
+
- **Const:** Mark methods/variables `const` whenever possible. `const` methods must be thread-safe.
|
|
95
|
+
- **Exceptions:** **Forbidden**.
|
|
96
|
+
- **RTTI:** Avoid `dynamic_cast`/`typeid`. Allowed in unit tests. Do not hand-implement workarounds.
|
|
97
|
+
- **Macros:** Avoid. Use `constexpr`/`inline`. If needed, define close to use and `#undef` immediately. Do not define in headers.
|
|
98
|
+
- **0 and nullptr:** Use `nullptr` for pointers, `\0` for chars, not `0`.
|
|
99
|
+
- **Streams:** Use streams primarily for logging. Prefer printf-style formatting or absl::StrCat.
|
|
100
|
+
- **Types:** Avoid `unsigned` for non-negativity. No `long double`.
|
|
101
|
+
- **Pre-increment:** Prefer `++i` over `i++`.
|
|
102
|
+
- **Sizeof:** Prefer `sizeof(varname)` over `sizeof(type)`.
|
|
103
|
+
- **Friends:** Allowed, usually defined in the same file.
|
|
104
|
+
- **Boost:** Use only approved libraries (e.g., Call Traits, Compressed Pair, BGL, Property Map, Iterator, etc.).
|
|
105
|
+
- **Aliases:** Use `using` instead of `typedef`. Public aliases must be documented.
|
|
106
|
+
- **Ownership:** Single fixed owner. Transfer via smart pointers.
|
|
107
|
+
- **Aliases:** Document intent. Don't use in public API for convenience. `using` > `typedef`.
|
|
108
|
+
- **Switch:** Always include `default`. Use `[[fallthrough]]` for explicit fallthrough.
|
|
109
|
+
- **Comments:** Document File, Class, Function (params/return). Use `//` or `/* */`. Implementation comments for tricky code. `TODO(user):` format.
|
|
110
|
+
|
|
111
|
+
**BE CONSISTENT.** Follow existing code style.
|
|
112
|
+
|
|
113
|
+
*Source: [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)*
|