ccg-ros2-workflow 1.4.0 → 2.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.
Files changed (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +128 -241
  3. package/bin/ccg.mjs +2 -0
  4. package/bin/codeagent-wrapper-darwin-amd64 +0 -0
  5. package/bin/codeagent-wrapper-darwin-arm64 +0 -0
  6. package/bin/codeagent-wrapper-linux-amd64 +0 -0
  7. package/bin/codeagent-wrapper-linux-arm64 +0 -0
  8. package/bin/codeagent-wrapper-windows-amd64.exe +0 -0
  9. package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
  10. package/dist/cli.d.mts +1 -0
  11. package/dist/cli.d.ts +1 -0
  12. package/dist/cli.mjs +173 -0
  13. package/dist/index.d.mts +229 -0
  14. package/dist/index.d.ts +229 -0
  15. package/dist/index.mjs +12 -0
  16. package/dist/shared/ccg-ros2-workflow.CpLJvcLP.mjs +2274 -0
  17. package/package.json +85 -22
  18. package/templates/commands/agents/planner.md +345 -0
  19. package/templates/commands/agents/system-integrator.md +397 -0
  20. package/{src/commands/ccg → templates/commands}/analyze.md +17 -17
  21. package/{src/commands/ccg → templates/commands}/backend.md +25 -25
  22. package/{src/commands/ccg → templates/commands}/debug.md +12 -12
  23. package/{src/commands/ccg → templates/commands}/execute.md +24 -23
  24. package/{src/commands/ccg → templates/commands}/feat.md +21 -21
  25. package/{src/commands/ccg → templates/commands}/frontend.md +26 -26
  26. package/{src/commands/ccg → templates/commands}/optimize.md +24 -24
  27. package/{src/commands/ccg → templates/commands}/plan.md +20 -19
  28. package/{src/commands/ccg → templates/commands}/review.md +9 -9
  29. package/templates/commands/spec-impl.md +123 -0
  30. package/templates/commands/spec-init.md +91 -0
  31. package/templates/commands/spec-plan.md +109 -0
  32. package/templates/commands/spec-research.md +104 -0
  33. package/templates/commands/spec-review.md +120 -0
  34. package/{src/commands/ccg → templates/commands}/test.md +23 -23
  35. package/templates/commands/workflow.md +193 -0
  36. package/{src/commands/ccg → templates/commands}/worktree.md +8 -8
  37. package/templates/prompts/claude/analyzer.md +59 -0
  38. package/templates/prompts/claude/architect.md +54 -0
  39. package/templates/prompts/claude/debugger.md +71 -0
  40. package/templates/prompts/claude/optimizer.md +73 -0
  41. package/templates/prompts/claude/reviewer.md +63 -0
  42. package/templates/prompts/claude/tester.md +69 -0
  43. package/templates/prompts/codex/analyzer.md +50 -0
  44. package/templates/prompts/codex/architect.md +46 -0
  45. package/templates/prompts/codex/debugger.md +66 -0
  46. package/templates/prompts/codex/optimizer.md +74 -0
  47. package/templates/prompts/codex/reviewer.md +66 -0
  48. package/templates/prompts/codex/tester.md +55 -0
  49. package/templates/prompts/gemini/analyzer.md +53 -0
  50. package/templates/prompts/gemini/architect.md +47 -0
  51. package/templates/prompts/gemini/debugger.md +70 -0
  52. package/templates/prompts/gemini/frontend.md +56 -0
  53. package/templates/prompts/gemini/optimizer.md +77 -0
  54. package/templates/prompts/gemini/reviewer.md +73 -0
  55. package/templates/prompts/gemini/tester.md +61 -0
  56. package/bin/cli.js +0 -903
  57. package/src/agents/ccg/planner.md +0 -358
  58. package/src/agents/ccg/system-integrator.md +0 -627
  59. package/src/codeagent-wrapper.sh +0 -86
  60. package/src/commands/ccg/workflow.md +0 -212
  61. package/src/config.toml +0 -36
  62. package/src/prompts/claude/analyzer.md +0 -25
  63. package/src/prompts/claude/architect.md +0 -25
  64. package/src/prompts/claude/debugger.md +0 -24
  65. package/src/prompts/claude/optimizer.md +0 -25
  66. package/src/prompts/claude/reviewer.md +0 -26
  67. package/src/prompts/claude/tester.md +0 -24
  68. package/src/prompts/codex/analyzer.md +0 -32
  69. package/src/prompts/codex/architect.md +0 -42
  70. package/src/prompts/codex/debugger.md +0 -24
  71. package/src/prompts/codex/optimizer.md +0 -25
  72. package/src/prompts/codex/reviewer.md +0 -32
  73. package/src/prompts/codex/tester.md +0 -24
  74. package/src/prompts/gemini/analyzer.md +0 -32
  75. package/src/prompts/gemini/architect.md +0 -34
  76. package/src/prompts/gemini/debugger.md +0 -24
  77. package/src/prompts/gemini/frontend.md +0 -25
  78. package/src/prompts/gemini/optimizer.md +0 -25
  79. package/src/prompts/gemini/reviewer.md +0 -32
  80. package/src/prompts/gemini/tester.md +0 -24
  81. /package/{src/agents/ccg → templates/commands/agents}/get-current-datetime.md +0 -0
  82. /package/{src/agents/ccg → templates/commands/agents}/init-architect.md +0 -0
  83. /package/{src/commands/ccg → templates/commands}/clean-branches.md +0 -0
  84. /package/{src/commands/ccg → templates/commands}/commit.md +0 -0
  85. /package/{src/commands/ccg → templates/commands}/enhance.md +0 -0
  86. /package/{src/commands/ccg → templates/commands}/init.md +0 -0
  87. /package/{src/commands/ccg → templates/commands}/rollback.md +0 -0
@@ -0,0 +1,123 @@
1
+ ---
2
+ description: '按规范执行 + 多模型协作 + 归档'
3
+ ---
4
+ <!-- CCG:SPEC:IMPL:START -->
5
+ **Core Philosophy**
6
+ - Implementation is pure mechanical execution—all decisions were made in Plan phase.
7
+ - External model outputs are prototypes only; must be rewritten to production-grade code.
8
+ - Keep changes tightly scoped; enforce side-effect review before any modification.
9
+ - Minimize documentation—prefer self-explanatory code over comments.
10
+
11
+ **Guardrails**
12
+ - **NEVER** apply Codex/Gemini prototypes directly—all outputs are reference only.
13
+ - **MANDATORY**: Request `unified diff patch` format from external models; they have zero write permission.
14
+ - Keep implementation strictly within `tasks.md` scope—no scope creep.
15
+ - Refer to `openspec/config.yaml` for conventions.
16
+
17
+ **Steps**
18
+ 1. **Select Change**
19
+ - Run `/opsx:list` to inspect Active Changes.
20
+ - Confirm with user which change ID to implement.
21
+ - Run `/opsx:show <change_id>` to review tasks.
22
+
23
+ 2. **Apply OPSX Change**
24
+ - Use `/ccg:spec-impl` (which uses OpenSpec skills internally) to enter implementation mode.
25
+ - This skill will guide you through the tasks defined in `tasks.md`.
26
+
27
+ 3. **Identify Minimal Verifiable Phase**
28
+ - Review `tasks.md` and identify the **smallest verifiable phase**.
29
+ - Do NOT complete all tasks at once—control context window.
30
+ - Announce: "Implementing Phase X: [task group name]"
31
+
32
+ 4. **Route Tasks to Appropriate Model**
33
+ - **Route A: Gemini** — Frontend/UI/styling (CSS, React, Vue, HTML, components)
34
+ - **Route B: Codex** — Backend/logic/algorithm (API, data processing, business logic)
35
+
36
+ For each task:
37
+ ```
38
+ codeagent-wrapper --backend <codex|gemini> - "$PWD" <<'EOF'
39
+ TASK: <task description from tasks.md>
40
+ CONTEXT: <relevant code context>
41
+ CONSTRAINTS: <constraints from spec>
42
+ OUTPUT: Unified Diff Patch format ONLY
43
+ EOF
44
+ ```
45
+
46
+ 5. **Rewrite Prototype to Production Code**
47
+ Upon receiving diff patch, **NEVER apply directly**. Rewrite by:
48
+ - Removing redundancy
49
+ - Ensuring clear naming and simple structure
50
+ - Aligning with project style
51
+ - Eliminating unnecessary comments
52
+ - Verifying no new dependencies introduced
53
+
54
+ 6. **Side-Effect Review** (Mandatory before apply)
55
+ Verify the change:
56
+ - [ ] Does not exceed `tasks.md` scope
57
+ - [ ] Does not affect unrelated modules
58
+ - [ ] Does not introduce new dependencies
59
+ - [ ] Does not break existing interfaces
60
+
61
+ If issues found, make targeted corrections.
62
+
63
+ 7. **Multi-Model Review (PARALLEL)**
64
+ - **CRITICAL**: You MUST launch BOTH Codex AND Gemini in a SINGLE message with TWO Bash tool calls.
65
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
66
+
67
+ **Step 7.1**: In ONE message, make TWO parallel Bash calls:
68
+
69
+ **FIRST Bash call (Codex)**:
70
+ ```
71
+ Bash({
72
+ command: "~/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF'\nReview the implementation changes:\n- Correctness: logic errors, edge cases\n- Security: injection, auth issues\n- Spec compliance: constraints satisfied\nOUTPUT: JSON with findings\nEOF",
73
+ run_in_background: true,
74
+ timeout: 300000,
75
+ description: "Codex: correctness/security review"
76
+ })
77
+ ```
78
+
79
+ **SECOND Bash call (Gemini) - IN THE SAME MESSAGE**:
80
+ ```
81
+ Bash({
82
+ command: "~/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF'\nReview the implementation changes:\n- Maintainability: readability, complexity\n- Patterns: consistency with project style\n- Integration: cross-module impacts\nOUTPUT: JSON with findings\nEOF",
83
+ run_in_background: true,
84
+ timeout: 300000,
85
+ description: "Gemini: maintainability/patterns review"
86
+ })
87
+ ```
88
+
89
+ **Step 7.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
90
+ ```
91
+ TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
92
+ TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })
93
+ ```
94
+
95
+ Address any critical findings before proceeding.
96
+
97
+ 8. **Update Task Status**
98
+ - Mark completed task in `tasks.md`: `- [x] Task description`
99
+ - Commit changes if appropriate.
100
+
101
+ 9. **Context Checkpoint**
102
+ - After completing a phase, report context usage.
103
+ - If below 80K: Ask user "Continue to next phase?"
104
+ - If approaching 80K: Suggest "Run `/clear` and resume with `/ccg:spec:impl`"
105
+
106
+ 10. **Archive on Completion**
107
+ - When ALL tasks in `tasks.md` are marked `[x]`:
108
+ - The agent will use OpenSpec skills to archive the change.
109
+ - This merges spec deltas to `openspec/specs/` and moves change to archive.
110
+
111
+ **Reference**
112
+ - Check task status: `/opsx:show <id>`
113
+ - Validate before archive: `/opsx:validate <id>`
114
+ - View active changes: `/opsx:list`
115
+ - Search existing patterns: `rg -n "function|class" <file>`
116
+
117
+ **Exit Criteria**
118
+ Implementation is complete when:
119
+ - [ ] All tasks in `tasks.md` marked `[x]`
120
+ - [ ] All multi-model reviews passed
121
+ - [ ] Side-effect review confirmed no regressions
122
+ - [ ] Change archived successfully
123
+ <!-- CCG:SPEC:IMPL:END -->
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: '初始化 OpenSpec (OPSX) 环境 + 验证多模型 MCP 工具'
3
+ ---
4
+ <!-- CCG:SPEC:INIT:START -->
5
+ **Core Philosophy**
6
+ - OPSX provides the specification framework; CCG adds multi-model collaboration.
7
+ - This phase ensures all tools are ready before any development work begins.
8
+ - Fail fast: detect missing dependencies early rather than mid-workflow.
9
+
10
+ **Guardrails**
11
+ - Detect OS (Linux/macOS/Windows) and adapt commands accordingly.
12
+ - Do not proceed to next step until current step completes successfully.
13
+ - Provide clear, actionable error messages when a step fails.
14
+ - Respect user's existing configurations; avoid overwriting without confirmation.
15
+
16
+ **Steps**
17
+ 1. **Detect Operating System**
18
+ - Identify OS using `uname -s` (Unix) or environment variables (Windows).
19
+ - Inform user which OS was detected.
20
+
21
+ 2. **Check and Install OpenSpec (OPSX)**
22
+ - Verify if OPSX commands are available: `/opsx:version`
23
+ - If not installed or not found:
24
+ ```bash
25
+ npm install -g @fission-ai/openspec@latest
26
+ ```
27
+ - **Path Verification**:
28
+ - If `/opsx:version` command is not found after installation:
29
+ 1. Ensure Claude Code commands are properly loaded
30
+ 2. Restart Claude Code session if needed
31
+ 3. Check if OPSX skills are installed in `.claude/skills/`
32
+ - Confirm installation success by running `/opsx:version` again.
33
+
34
+ 3. **Initialize OPSX for Current Project**
35
+ - Run:
36
+ ```bash
37
+ /opsx:init --tools claude
38
+ ```
39
+ - Verify `openspec/` directory structure is created.
40
+ - Verify `.claude/skills/` contains `opsx-*` skills.
41
+ - Report any errors with remediation steps.
42
+
43
+ 4. **Validate Multi-Model MCP Tools**
44
+ - Check `codeagent-wrapper` availability: `~/.claude/bin/codeagent-wrapper --version`
45
+ - Test Codex backend:
46
+ ```bash
47
+ ~/.claude/bin/codeagent-wrapper --backend codex - "$PWD" <<< "echo test"
48
+ ```
49
+ - Test Gemini backend:
50
+ ```bash
51
+ ~/.claude/bin/codeagent-wrapper --backend gemini - "$PWD" <<< "echo test"
52
+ ```
53
+ - For each unavailable tool, display warning with installation instructions.
54
+
55
+ 5. **Validate Context Retrieval MCP** (Optional)
56
+ - **Check Active Tool**: Is `mcp__ace-tool__search_context` available in the current session?
57
+ - **Check Configuration**: If tool is missing, check `~/.claude.json` (or `%APPDATA%\Claude\claude.json` on Windows) for `"ace-tool"` or `"ace-tool-rs"` in `mcpServers`.
58
+ - **Diagnosis**:
59
+ - If tool available: Mark as "✓ Active".
60
+ - If config exists but tool missing: Mark as "⚠️ Configured but inactive (Try restarting Claude)".
61
+ - If neither: Mark as "○ Not installed (Optional)".
62
+ - If not installed/configured, suggest: "Run `npx ccg-workflow` and select ace-tool MCP option."
63
+
64
+ 6. **Summary Report**
65
+ Display status table:
66
+ ```
67
+ Component Status
68
+ ─────────────────────────────────
69
+ OpenSpec (OPSX) CLI ✓/✗
70
+ Project initialized ✓/✗
71
+ OPSX Skills ✓/✗
72
+ codeagent-wrapper ✓/✗
73
+ Codex backend ✓/✗
74
+ Gemini backend ✓/✗
75
+ ace-tool MCP ✓/✗ (optional)
76
+ ```
77
+
78
+ **Next Steps (Use CCG Encapsulated Commands)**
79
+ 1. Start Research: `/ccg:spec-research "description"`
80
+ 2. Plan & Design: `/ccg:spec-plan`
81
+ 3. Implement: `/ccg:spec-impl` (Includes auto-review & archive)
82
+
83
+ **Standalone Tools (Available Anytime)**
84
+ - Code Review: `/ccg:spec-review` (Independent dual-model review)
85
+
86
+ **Reference**
87
+ - OpenSpec (OPSX) CLI: `/opsx:help`
88
+ - CCG Workflow: `npx ccg-workflow`
89
+ - Codex/Gemini MCP: Bundled with codeagent-wrapper
90
+ - Node.js >= 18.x required for OpenSpec
91
+ <!-- CCG:SPEC:INIT:END -->
@@ -0,0 +1,109 @@
1
+ ---
2
+ description: '多模型分析 → 消除歧义 → 零决策可执行计划'
3
+ ---
4
+ <!-- CCG:SPEC:PLAN:START -->
5
+ **Core Philosophy**
6
+ - The goal is to eliminate ALL decision points—implementation should be pure mechanical execution.
7
+ - Every ambiguity must be resolved into explicit constraints before proceeding.
8
+ - Multi-model collaboration surfaces blind spots and conflicting assumptions.
9
+ - Every requirement must have Property-Based Testing (PBT) properties—focus on invariants.
10
+
11
+ **Guardrails**
12
+ - Do not proceed to implementation until every ambiguity is resolved.
13
+ - Multi-model collaboration is **mandatory**: use both Codex and Gemini.
14
+ - If constraints cannot be fully specified, escalate to user or return to research phase.
15
+ - Refer to `openspec/config.yaml` for project conventions.
16
+
17
+ **Steps**
18
+ 1. **Select Change**
19
+ - Run `/opsx:list` to display Active Changes.
20
+ - Confirm with user which change ID to refine.
21
+ - Run `/opsx:status <change_id>` to review current state.
22
+
23
+ 2. **Multi-Model Implementation Analysis (PARALLEL)**
24
+ - **CRITICAL**: You MUST launch BOTH Codex AND Gemini in a SINGLE message with TWO Bash tool calls.
25
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
26
+
27
+ **Step 2.1**: In ONE message, make TWO parallel Bash calls:
28
+
29
+ **FIRST Bash call (Codex)**:
30
+ ```
31
+ Bash({
32
+ command: "~/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF'\nAnalyze change <change_id> from backend perspective:\n- Implementation approach\n- Technical risks\n- Alternative architectures\n- Edge cases and failure modes\nOUTPUT: JSON with analysis\nEOF",
33
+ run_in_background: true,
34
+ timeout: 300000,
35
+ description: "Codex: backend analysis"
36
+ })
37
+ ```
38
+
39
+ **SECOND Bash call (Gemini) - IN THE SAME MESSAGE**:
40
+ ```
41
+ Bash({
42
+ command: "~/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF'\nAnalyze change <change_id> from frontend/integration perspective:\n- Maintainability assessment\n- Scalability considerations\n- Integration conflicts\nOUTPUT: JSON with analysis\nEOF",
43
+ run_in_background: true,
44
+ timeout: 300000,
45
+ description: "Gemini: frontend analysis"
46
+ })
47
+ ```
48
+
49
+ **Step 2.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
50
+ ```
51
+ TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
52
+ TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })
53
+ ```
54
+
55
+ - Synthesize responses and present consolidated options to user.
56
+
57
+ 3. **Uncertainty Elimination Audit**
58
+ - **Codex**: "Review proposal for unspecified decision points. List each as: [AMBIGUITY] → [REQUIRED CONSTRAINT]"
59
+ - **Gemini**: "Identify implicit assumptions. Specify: [ASSUMPTION] → [EXPLICIT CONSTRAINT NEEDED]"
60
+
61
+ **Anti-Pattern Detection** (flag and reject):
62
+ - Information collection without decision boundaries
63
+ - Technical comparisons without selection criteria
64
+ - Deferred decisions marked "to be determined during implementation"
65
+
66
+ **Target Pattern** (required for approval):
67
+ - Explicit technology choices with parameters (e.g., "JWT with TTL=15min")
68
+ - Concrete algorithm selections with configs (e.g., "bcrypt cost=12")
69
+ - Precise behavioral rules (e.g., "Lock account 30min after 5 failed attempts")
70
+
71
+ Iterate with user until ALL ambiguities resolved.
72
+
73
+ 4. **PBT Property Extraction**
74
+ - **Codex**: "Extract PBT properties. For each requirement: [INVARIANT] → [FALSIFICATION STRATEGY]"
75
+ - **Gemini**: "Define system properties: [PROPERTY] | [DEFINITION] | [BOUNDARY CONDITIONS] | [COUNTEREXAMPLE GENERATION]"
76
+
77
+ **Property Categories**:
78
+ - **Commutativity/Associativity**: Order-independent operations
79
+ - **Idempotency**: Repeated operations yield same result
80
+ - **Round-trip**: Encode→Decode returns original
81
+ - **Invariant Preservation**: State constraints maintained
82
+ - **Monotonicity**: Ordering guarantees (e.g., timestamps increase)
83
+ - **Bounds**: Value ranges, size limits, rate constraints
84
+
85
+ 5. **Update OPSX Artifacts**
86
+ - The agent will use OpenSpec skills to generate/update:
87
+ * specs (Requirements + PBT)
88
+ * design (Technical decisions)
89
+ * tasks (Zero-decision implementation plan)
90
+ - Ensure all resolved constraints and PBT properties are included in the generated artifacts.
91
+
92
+ 6. **Context Checkpoint**
93
+ - Report current context usage.
94
+ - If approaching 80K tokens, suggest: "Run `/clear` and continue with `/ccg:spec-impl`"
95
+
96
+ **Exit Criteria**
97
+ A change is ready for implementation only when:
98
+ - [ ] All multi-model analyses completed and synthesized
99
+ - [ ] Zero ambiguities remain (verified by step 3 audit)
100
+ - [ ] All PBT properties documented with falsification strategies
101
+ - [ ] Artifacts (specs, design, tasks) generated via OpenSpec skills
102
+ - [ ] User has explicitly approved all constraint decisions
103
+
104
+ **Reference**
105
+ - Inspect change: `/opsx:status <id>`
106
+ - Check conflicts: `/opsx:schemas`
107
+ - Search patterns: `rg -n "INVARIANT:|PROPERTY:" openspec/`
108
+ - Use `AskUserQuestion` for ANY ambiguity—never assume
109
+ <!-- CCG:SPEC:PLAN:END -->
@@ -0,0 +1,104 @@
1
+ ---
2
+ description: '需求 → 约束集(并行探索 + OPSX 提案)'
3
+ ---
4
+ <!-- CCG:SPEC:RESEARCH:START -->
5
+ **Core Philosophy**
6
+ - Research produces **constraint sets**, not information dumps. Each constraint narrows the solution space.
7
+ - Constraints tell subsequent stages "don't consider this direction," enabling mechanical execution without decisions.
8
+ - Output: 约束集合 + 可验证的成功判据 (constraint sets + verifiable success criteria).
9
+ - Strictly adhere to OPSX rules when writing spec-structured documents.
10
+
11
+ **Guardrails**
12
+ - **STOP! BEFORE ANY OTHER ACTION**: You MUST call `mcp__ace-tool__enhance_prompt` FIRST. This is NON-NEGOTIABLE.
13
+ - **NEVER** divide subagent tasks by roles (e.g., "架构师agent", "安全专家agent").
14
+ - **ALWAYS** divide by context boundaries (e.g., "user-related code", "authentication logic").
15
+ - Each subagent context must be self-contained with independent output.
16
+ - Use `mcp__ace-tool__search_context` to minimize grep/find operations.
17
+ - Do not make architectural decisions—surface constraints that guide decisions.
18
+
19
+ **Steps**
20
+ 0. **MANDATORY: Enhance Requirement FIRST**
21
+ - **DO THIS IMMEDIATELY. DO NOT SKIP. DO NOT CALL ANY OTHER TOOL FIRST.**
22
+ - Call:
23
+ ```
24
+ mcp__ace-tool__enhance_prompt({
25
+ prompt: "$ARGUMENTS",
26
+ conversation_history: "<recent conversation>",
27
+ project_root_path: "$PWD"
28
+ })
29
+ ```
30
+ - Wait for enhanced prompt result.
31
+ - Use enhanced prompt for ALL subsequent steps.
32
+
33
+ 1. **Generate OPSX Change**
34
+ - Create a new change using OPSX command:
35
+ ```bash
36
+ /opsx:new "<brief-descriptive-name>"
37
+ ```
38
+ - This scaffolds `openspec/changes/<name>/` with proposal.md.
39
+ - If change already exists, use `/opsx:list` to find it and continue.
40
+
41
+ 2. **Initial Codebase Assessment**
42
+ - Use `mcp__ace-tool__search_context` to scan codebase.
43
+ - Determine project scale: single vs multi-directory structure.
44
+ - **Decision**: If multi-directory → enable parallel Explore subagents.
45
+
46
+ 3. **Define Exploration Boundaries (Context-Based)**
47
+ - Identify natural context boundaries (NOT functional roles):
48
+ * Subagent 1: User domain code (models, services, UI)
49
+ * Subagent 2: Auth & authorization (middleware, session, tokens)
50
+ * Subagent 3: Infrastructure (configs, deployments, builds)
51
+ - Each boundary should be self-contained: no cross-communication needed.
52
+
53
+ 4. **Parallel Multi-Model Exploration**
54
+ - Dispatch Explore subagents with unified output template:
55
+ ```json
56
+ {
57
+ "module_name": "context boundary explored",
58
+ "existing_structures": ["key patterns found"],
59
+ "existing_conventions": ["standards in use"],
60
+ "constraints_discovered": ["hard constraints limiting solution space"],
61
+ "open_questions": ["ambiguities requiring user input"],
62
+ "dependencies": ["cross-module dependencies"],
63
+ "risks": ["potential blockers"],
64
+ "success_criteria_hints": ["observable success behaviors"]
65
+ }
66
+ ```
67
+ - Run Codex for backend boundaries, Gemini for frontend boundaries.
68
+
69
+ 5. **Aggregate and Synthesize**
70
+ - Collect all subagent outputs.
71
+ - Merge into unified constraint sets:
72
+ * **Hard constraints**: Technical limitations, patterns that cannot be violated
73
+ * **Soft constraints**: Conventions, preferences, style guides
74
+ * **Dependencies**: Cross-module relationships affecting implementation order
75
+ * **Risks**: Blockers needing mitigation
76
+
77
+ 6. **User Interaction for Ambiguity Resolution**
78
+ - Compile prioritized list of open questions.
79
+ - Use `AskUserQuestion` tool to present systematically:
80
+ * Group related questions
81
+ * Provide context for each
82
+ * Suggest defaults when applicable
83
+ - Capture responses as additional constraints.
84
+
85
+ 7. **Finalize OPSX Proposal**
86
+ - Transform constraint sets into OPSX format:
87
+ * **Context**: User need + discovered constraints
88
+ * **Requirements**: Each constraint becomes requirement with scenario
89
+ * **Success Criteria**: Derived from hints and user confirmations
90
+ - Ensure proposal includes:
91
+ * All discovered constraints as requirements
92
+ * Verifiable scenarios for each requirement
93
+ * Clear dependencies and sequencing
94
+ * Risk mitigation strategies
95
+
96
+ 8. **Context Checkpoint**
97
+ - Report current context usage.
98
+ - If approaching 80K tokens, suggest: "Run `/clear` and continue with `/ccg:spec-plan`"
99
+
100
+ **Reference**
101
+ - OPSX CLI: `/opsx:status`, `/opsx:show`
102
+ - Check prior research: `ls openspec/changes/*/`
103
+ - Use `AskUserQuestion` for ANY ambiguity—never assume or guess
104
+ <!-- CCG:SPEC:RESEARCH:END -->
@@ -0,0 +1,120 @@
1
+ ---
2
+ description: '双模型交叉审查(独立工具,随时可用)'
3
+ ---
4
+ <!-- CCG:SPEC:REVIEW:START -->
5
+ **Core Philosophy**
6
+ - Dual-model cross-validation catches blind spots single-model review would miss.
7
+ - Critical findings SHOULD be addressed before proceeding.
8
+ - Review validates implementation against spec constraints and code quality.
9
+ - This is an independent review tool—can be used anytime, not tied to archive workflow.
10
+
11
+ **Guardrails**
12
+ - **MANDATORY**: Both Codex AND Gemini must complete review before synthesis.
13
+ - Review scope is strictly limited to the proposal's changes—no scope creep.
14
+ - Refer to `openspec/AGENTS.md` for spec conventions if reviewing OpenSpec proposals.
15
+
16
+ **Steps**
17
+ 1. **Select Proposal**
18
+ - Run `/opsx:list` to display Active Changes.
19
+ - Confirm with user which proposal ID to review.
20
+ - Run `/opsx:show <proposal_id>` to load spec and tasks.
21
+
22
+ 2. **Collect Implementation Artifacts**
23
+ - Identify all files modified by this proposal.
24
+ - Use `git diff` or `/opsx:diff <proposal_id>` to get change summary.
25
+ - Load relevant spec constraints and PBT properties from `openspec/changes/<id>/specs/`.
26
+
27
+ 3. **Multi-Model Review (PARALLEL)**
28
+ - **CRITICAL**: You MUST launch BOTH Codex AND Gemini in a SINGLE message with TWO Bash tool calls.
29
+ - **DO NOT** call one model first and wait. Launch BOTH simultaneously with `run_in_background: true`.
30
+
31
+ **Step 3.1**: In ONE message, make TWO parallel Bash calls:
32
+
33
+ **FIRST Bash call (Codex)**:
34
+ ```
35
+ Bash({
36
+ command: "~/.claude/bin/codeagent-wrapper --backend codex - \"$PWD\" <<'EOF'\nReview proposal <proposal_id> implementation:\n\n## Codex Review Dimensions\n1. **Spec Compliance**: Verify ALL constraints from spec are satisfied\n2. **PBT Properties**: Check invariants, idempotency, bounds are correctly implemented\n3. **Logic Correctness**: Edge cases, error handling, algorithm correctness\n4. **Backend Security**: Injection vulnerabilities, auth checks, input validation\n5. **Regression Risk**: Interface compatibility, type safety, breaking changes\n\n## Output Format (JSON)\n{\n \"findings\": [\n {\n \"severity\": \"Critical|Warning|Info\",\n \"dimension\": \"spec_compliance|pbt|logic|security|regression\",\n \"file\": \"path/to/file.ts\",\n \"line\": 42,\n \"description\": \"What is wrong\",\n \"constraint_violated\": \"Constraint ID from spec (if applicable)\",\n \"fix_suggestion\": \"How to fix\"\n }\n ],\n \"passed_checks\": [\"List of verified constraints/properties\"],\n \"summary\": \"Overall assessment\"\n}\nEOF",
37
+ run_in_background: true,
38
+ timeout: 300000,
39
+ description: "Codex: backend/logic review"
40
+ })
41
+ ```
42
+
43
+ **SECOND Bash call (Gemini) - IN THE SAME MESSAGE**:
44
+ ```
45
+ Bash({
46
+ command: "~/.claude/bin/codeagent-wrapper --backend gemini - \"$PWD\" <<'EOF'\nReview proposal <proposal_id> implementation:\n\n## Gemini Review Dimensions\n1. **Pattern Consistency**: Naming conventions, code style, project patterns\n2. **Maintainability**: Readability, complexity, documentation adequacy\n3. **Integration Risk**: Dependency changes, cross-module impacts\n4. **Frontend Security**: XSS, CSRF, sensitive data exposure\n5. **Spec Alignment**: Implementation matches spec intent (not just letter)\n\n## Output Format (JSON)\n{\n \"findings\": [\n {\n \"severity\": \"Critical|Warning|Info\",\n \"dimension\": \"patterns|maintainability|integration|security|alignment\",\n \"file\": \"path/to/file.ts\",\n \"line\": 42,\n \"description\": \"What is wrong\",\n \"spec_reference\": \"Spec section (if applicable)\",\n \"fix_suggestion\": \"How to fix\"\n }\n ],\n \"passed_checks\": [\"List of verified aspects\"],\n \"summary\": \"Overall assessment\"\n}\nEOF",
47
+ run_in_background: true,
48
+ timeout: 300000,
49
+ description: "Gemini: patterns/integration review"
50
+ })
51
+ ```
52
+
53
+ **Step 3.2**: After BOTH Bash calls return task IDs, wait for results with TWO TaskOutput calls:
54
+ ```
55
+ TaskOutput({ task_id: "<codex_task_id>", block: true, timeout: 600000 })
56
+ TaskOutput({ task_id: "<gemini_task_id>", block: true, timeout: 600000 })
57
+ ```
58
+
59
+ 4. **Synthesize Findings**
60
+ - Merge findings from both models.
61
+ - Deduplicate overlapping issues.
62
+ - Classify by severity:
63
+ * **Critical**: Spec violation, security vulnerability, breaking change → MUST fix
64
+ * **Warning**: Pattern deviation, maintainability concern → SHOULD fix
65
+ * **Info**: Minor improvement suggestion → MAY fix
66
+
67
+ 5. **Present Review Report**
68
+ - Display findings grouped by severity:
69
+ ```
70
+ ## Review Report: <proposal_id>
71
+
72
+ ### Critical (X issues) - MUST FIX
73
+ - [ ] [SPEC] file.ts:42 - Constraint X violated: description
74
+ - [ ] [SEC] api.ts:15 - SQL injection vulnerability
75
+
76
+ ### Warning (Y issues) - SHOULD FIX
77
+ - [ ] [PATTERN] utils.ts:88 - Inconsistent naming convention
78
+
79
+ ### Info (Z issues) - MAY FIX
80
+ - [ ] [MAINT] helper.ts:20 - Consider extracting to separate function
81
+
82
+ ### Passed Checks
83
+ - ✅ PBT: Idempotency property verified
84
+ - ✅ Security: No XSS vulnerabilities found
85
+ ```
86
+
87
+ 6. **Decision Gate**
88
+ - **If Critical > 0**:
89
+ * Present findings to user.
90
+ * Ask: "Fix now or return to `/ccg:spec-impl` to address?"
91
+ * Do NOT allow archiving.
92
+
93
+ - **If Critical = 0**:
94
+ * Ask user: "All critical checks passed. Proceed to archive?"
95
+ * If Warning > 0, recommend addressing before archive.
96
+
97
+ 7. **Optional: Inline Fix Mode**
98
+ - If user chooses "Fix now" for Critical issues:
99
+ * Route each fix to appropriate model (backend→Codex, frontend→Gemini).
100
+ * Apply fix using unified diff patch pattern.
101
+ * Re-run affected review dimension.
102
+ * Repeat until Critical = 0.
103
+
104
+ 8. **Context Checkpoint**
105
+ - Report current context usage.
106
+ - If approaching 80K tokens, suggest: "Run `/clear` and continue with `/ccg:spec-review` or `/ccg:spec-impl`"
107
+
108
+ **Exit Criteria**
109
+ Review is complete when:
110
+ - [ ] Both Codex and Gemini reviews completed
111
+ - [ ] All findings synthesized and classified
112
+ - [ ] Zero Critical issues remain (fixed or user-acknowledged)
113
+ - [ ] User decision captured (archive / return to impl / defer)
114
+
115
+ **Reference**
116
+ - View proposal: `/opsx:show <id>`
117
+ - Check spec constraints: `rg -n "CONSTRAINT:|MUST|INVARIANT:" openspec/changes/<id>/specs/`
118
+ - View implementation diff: `/opsx:diff <id>` or `git diff`
119
+ - Archive (after passing): `/ccg:spec-impl` → Step 10
120
+ <!-- CCG:SPEC:REVIEW:END -->
@@ -1,28 +1,28 @@
1
1
  ---
2
- description: '多模型测试生成:智能路由 Codex 底层单元测试 / Gemini 上层集成测试'
2
+ description: 'ROS2 多模型测试生成:智能路由 Codex 单元测试 / Gemini 集成测试'
3
3
  ---
4
4
 
5
- # Test - 多模型测试生成
5
+ # Test - ROS2 多模型测试生成
6
6
 
7
- 根据代码类型智能路由,生成高质量测试用例。
7
+ 根据 ROS2 代码类型智能路由,生成高质量测试用例。
8
8
 
9
9
  ## 使用方法
10
10
 
11
11
  ```bash
12
- /test <测试目标>
12
+ /test <ROS2测试目标>
13
13
  ```
14
14
 
15
15
  ## 上下文
16
16
 
17
17
  - 测试目标:$ARGUMENTS
18
- - 智能路由:底层控制 → Codex,上层应用 → Gemini,全栈 → 并行
19
- - 遵循项目现有测试框架和风格
18
+ - 智能路由:底层控制 → Codex(gtest/pytest),上层应用 → Gemini(launch_testing)
19
+ - 遵循 ROS2 测试框架和最佳实践
20
20
 
21
21
  ## 你的角色
22
22
 
23
- 你是**测试工程师**,编排测试生成流程:
24
- - **Codex** – 底层控制测试生成(**C++/实时/硬件权威**)
25
- - **Gemini** – 上层应用测试生成(**Python/Launch/集成权威**)
23
+ 你是**ROS2 测试工程师**,编排测试生成流程:
24
+ - **Codex** – 底层控制测试:gtest/pytest 单元测试(**底层权威**)
25
+ - **Gemini** – 上层应用测试:launch_testing 集成测试(**上层权威**)
26
26
  - **Claude (自己)** – 整合测试、验证运行
27
27
 
28
28
  ---
@@ -33,7 +33,7 @@ description: '多模型测试生成:智能路由 Codex 底层单元测试 / Ge
33
33
 
34
34
  ```
35
35
  Bash({
36
- command: "$HOME/.claude/bin/codeagent-wrapper --lite --backend <codex|gemini> - \"$PWD\" <<'EOF'
36
+ command: "~/.claude/bin/codeagent-wrapper {{LITE_MODE_FLAG}}--backend <codex|gemini> - \"$PWD\" <<'EOF'
37
37
  ROLE_FILE: <角色提示词路径>
38
38
  <TASK>
39
39
  需求:为以下代码生成测试
@@ -55,15 +55,15 @@ EOF",
55
55
 
56
56
  | 模型 | 提示词 |
57
57
  |------|--------|
58
- | Codex | `$HOME/.claude/.ccg/prompts/codex/tester.md` |
59
- | Gemini | `$HOME/.claude/.ccg/prompts/gemini/tester.md` |
58
+ | Codex | `~/.claude/.ccg/prompts/codex/tester.md` |
59
+ | Gemini | `~/.claude/.ccg/prompts/gemini/tester.md` |
60
60
 
61
61
  **智能路由**:
62
62
 
63
63
  | 代码类型 | 路由 |
64
64
  |---------|------|
65
- | 底层控制 | Codex |
66
- | 上层应用 | Gemini |
65
+ | 底层控制(C++节点/算法) | Codex (gtest) |
66
+ | 上层应用(Launch/Python) | Gemini (launch_testing) |
67
67
  | 全栈 | 并行执行两者 |
68
68
 
69
69
  **并行调用**:使用 `run_in_background: true` 启动,用 `TaskOutput` 等待结果。**必须等所有模型返回后才能进入下一阶段**。
@@ -105,14 +105,14 @@ TaskOutput({ task_id: "<task_id>", block: true, timeout: 600000 })
105
105
  **⚠️ 根据代码类型必须调用对应模型**(参照上方调用规范):
106
106
 
107
107
  - **底层控制代码** → `Bash({ command: "...--backend codex...", run_in_background: false })`
108
- - ROLE_FILE: `$HOME/.claude/.ccg/prompts/codex/tester.md`
108
+ - ROLE_FILE: `~/.claude/.ccg/prompts/codex/tester.md`
109
109
  - **上层应用代码** → `Bash({ command: "...--backend gemini...", run_in_background: false })`
110
- - ROLE_FILE: `$HOME/.claude/.ccg/prompts/gemini/tester.md`
110
+ - ROLE_FILE: `~/.claude/.ccg/prompts/gemini/tester.md`
111
111
  - **全栈代码** → 并行调用两者:
112
112
  1. `Bash({ command: "...--backend codex...", run_in_background: true })`
113
- - ROLE_FILE: `$HOME/.claude/.ccg/prompts/codex/tester.md`
113
+ - ROLE_FILE: `~/.claude/.ccg/prompts/codex/tester.md`
114
114
  2. `Bash({ command: "...--backend gemini...", run_in_background: true })`
115
- - ROLE_FILE: `$HOME/.claude/.ccg/prompts/gemini/tester.md`
115
+ - ROLE_FILE: `~/.claude/.ccg/prompts/gemini/tester.md`
116
116
  用 `TaskOutput` 等待结果
117
117
 
118
118
  OUTPUT:完整测试代码(使用项目现有测试框架,覆盖正常路径、边界条件、异常处理)
@@ -156,12 +156,12 @@ OUTPUT:完整测试代码(使用项目现有测试框架,覆盖正常路
156
156
  - 失败:<如有,列出原因>
157
157
  ```
158
158
 
159
- ## 测试策略金字塔
159
+ ## ROS2 测试策略金字塔
160
160
 
161
161
  ```
162
- /\ E2E (10%)
163
- /--\ Integration (20%)
164
- /----\ Unit (70%)
162
+ /\ Simulation (10%) - Gazebo 完整功能测试
163
+ /--\ Integration (20%) - launch_testing 节点通信测试
164
+ /----\ Unit (70%) - gtest/pytest 算法和逻辑测试
165
165
  ```
166
166
 
167
167
  ---
@@ -170,5 +170,5 @@ OUTPUT:完整测试代码(使用项目现有测试框架,覆盖正常路
170
170
 
171
171
  1. **测试行为,不测试实现** – 关注输入输出
172
172
  2. **智能路由** – 底层控制测试用 Codex,上层应用测试用 Gemini
173
- 3. **复用现有模式** – 遵循项目已有的测试风格
173
+ 3. **复用现有模式** – 遵循 ROS2 已有的测试风格
174
174
  4. 外部模型对文件系统**零写入权限**