ccg-ros2-workflow 2.2.1 → 3.0.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/README.md +211 -96
- package/README.zh-CN.md +256 -0
- package/dist/cli.mjs +15 -15
- package/dist/index.d.mts +61 -34
- package/dist/index.d.ts +61 -34
- package/dist/index.mjs +4 -4
- package/dist/shared/ccg-ros2-workflow.Bhm8c7P1.mjs +5154 -0
- package/package.json +31 -12
- package/templates/codex/AGENTS.md +348 -0
- package/templates/codex/agents/ccg-implement.toml +73 -0
- package/templates/codex/agents/ccg-research.toml +73 -0
- package/templates/codex/agents/ccg-review.toml +82 -0
- package/templates/codex/config.toml +21 -0
- package/templates/codex/hooks/ccg-workflow.py +253 -0
- package/templates/codex/hooks.json +15 -0
- package/templates/commands/agents/planner.md +97 -122
- package/templates/commands/agents/system-integrator.md +2 -2
- package/templates/commands/agents/team-architect.md +97 -0
- package/templates/commands/agents/team-qa.md +121 -0
- package/templates/commands/agents/team-reviewer.md +112 -0
- package/templates/commands/commit.md +30 -1
- package/templates/commands/context.md +332 -0
- package/templates/commands/go.md +206 -0
- package/templates/commands/init.md +1 -1
- package/templates/commands/spec-impl.md +41 -21
- package/templates/commands/spec-init.md +21 -27
- package/templates/commands/spec-plan.md +54 -21
- package/templates/commands/spec-research.md +78 -26
- package/templates/commands/spec-review.md +20 -16
- package/templates/{commands → commands-legacy}/analyze.md +1 -1
- package/templates/commands-legacy/backend.md +224 -0
- package/templates/commands-legacy/codex-exec.md +411 -0
- package/templates/{commands → commands-legacy}/debug.md +1 -1
- package/templates/commands-legacy/enhance.md +55 -0
- package/templates/{commands → commands-legacy}/feat.md +2 -2
- package/templates/commands-legacy/frontend.md +213 -0
- package/templates/{commands → commands-legacy}/optimize.md +1 -1
- package/templates/{commands → commands-legacy}/plan.md +1 -15
- package/templates/{commands → commands-legacy}/team-plan.md +1 -1
- package/templates/commands-legacy/team.md +475 -0
- package/templates/{commands → commands-legacy}/test.md +1 -1
- package/templates/commands-legacy/workflow.md +283 -0
- package/templates/engine/model-router.md +123 -0
- package/templates/engine/phase-guide.md +207 -0
- package/templates/engine/strategies/debug-investigate.md +169 -0
- package/templates/engine/strategies/deep-research.md +141 -0
- package/templates/engine/strategies/direct-fix.md +108 -0
- package/templates/engine/strategies/full-collaborate.md +389 -0
- package/templates/engine/strategies/git-action.md +43 -0
- package/templates/engine/strategies/guided-develop.md +282 -0
- package/templates/engine/strategies/optimize-measure.md +103 -0
- package/templates/engine/strategies/quick-implement.md +96 -0
- package/templates/engine/strategies/refactor-safely.md +180 -0
- package/templates/engine/strategies/review-audit.md +123 -0
- package/templates/hooks/session-start.js +100 -0
- package/templates/hooks/skill-router.js +144 -0
- package/templates/hooks/subagent-context.js +161 -0
- package/templates/hooks/task-utils.js +190 -0
- package/templates/hooks/workflow-state.js +55 -0
- package/templates/output-styles/abyss-command.md +56 -0
- package/templates/output-styles/abyss-concise.md +89 -0
- package/templates/output-styles/abyss-ritual.md +70 -0
- package/templates/output-styles/engineer-professional.md +20 -3
- package/templates/output-styles/laowang-engineer.md +2 -2
- package/templates/prompts/antigravity/analyzer.md +59 -0
- package/templates/prompts/antigravity/architect.md +55 -0
- package/templates/prompts/antigravity/builder.md +52 -0
- package/templates/prompts/antigravity/debugger.md +48 -0
- package/templates/prompts/antigravity/frontend.md +50 -0
- package/templates/prompts/antigravity/optimizer.md +40 -0
- package/templates/prompts/antigravity/reviewer.md +67 -0
- package/templates/prompts/antigravity/tester.md +39 -0
- package/templates/prompts/claude/debugger.md +1 -1
- package/templates/prompts/claude/reviewer.md +1 -1
- package/templates/prompts/codex/analyzer.md +8 -0
- package/templates/prompts/codex/architect.md +9 -1
- package/templates/prompts/codex/builder.md +61 -0
- package/templates/prompts/codex/debugger.md +9 -1
- package/templates/prompts/codex/optimizer.md +7 -0
- package/templates/prompts/codex/reviewer.md +7 -0
- package/templates/prompts/codex/tester.md +8 -1
- package/templates/prompts/gemini/analyzer.md +11 -3
- package/templates/prompts/gemini/architect.md +10 -2
- package/templates/prompts/gemini/debugger.md +8 -0
- package/templates/prompts/gemini/frontend.md +10 -2
- package/templates/prompts/gemini/optimizer.md +9 -2
- package/templates/prompts/gemini/reviewer.md +7 -0
- package/templates/prompts/gemini/tester.md +8 -1
- package/templates/rules/ccg-skill-routing.md +91 -0
- package/templates/rules/ccg-skills.md +65 -0
- package/templates/skills/SKILL.md +92 -0
- package/templates/skills/domains/ai/SKILL.md +34 -0
- package/templates/skills/domains/ai/agent-dev.md +242 -0
- package/templates/skills/domains/ai/llm-security.md +288 -0
- package/templates/skills/domains/ai/prompt-and-eval.md +279 -0
- package/templates/skills/domains/ai/rag-system.md +542 -0
- package/templates/skills/domains/architecture/SKILL.md +42 -0
- package/templates/skills/domains/architecture/api-design.md +225 -0
- package/templates/skills/domains/architecture/caching.md +299 -0
- package/templates/skills/domains/architecture/cloud-native.md +285 -0
- package/templates/skills/domains/architecture/message-queue.md +329 -0
- package/templates/skills/domains/architecture/security-arch.md +297 -0
- package/templates/skills/domains/data-engineering/SKILL.md +207 -0
- package/templates/skills/domains/development/SKILL.md +46 -0
- package/templates/skills/domains/development/cpp.md +369 -0
- package/templates/skills/domains/development/go.md +323 -0
- package/templates/skills/domains/development/java.md +277 -0
- package/templates/skills/domains/development/python.md +487 -0
- package/templates/skills/domains/development/rust.md +313 -0
- package/templates/skills/domains/development/shell.md +313 -0
- package/templates/skills/domains/development/typescript.md +277 -0
- package/templates/skills/domains/devops/SKILL.md +39 -0
- package/templates/skills/domains/devops/cost-optimization.md +272 -0
- package/templates/skills/domains/devops/database.md +217 -0
- package/templates/skills/domains/devops/devsecops.md +198 -0
- package/templates/skills/domains/devops/git-workflow.md +181 -0
- package/templates/skills/domains/devops/observability.md +280 -0
- package/templates/skills/domains/devops/performance.md +336 -0
- package/templates/skills/domains/devops/testing.md +283 -0
- package/templates/skills/domains/infrastructure/SKILL.md +200 -0
- package/templates/skills/domains/mobile/SKILL.md +224 -0
- package/templates/skills/domains/orchestration/SKILL.md +29 -0
- package/templates/skills/domains/orchestration/multi-agent.md +263 -0
- package/templates/skills/domains/ros2-control/SKILL.md +206 -0
- package/templates/skills/domains/ros2-hardware/SKILL.md +277 -0
- package/templates/skills/domains/ros2-manipulation/SKILL.md +237 -0
- package/templates/skills/domains/ros2-navigation/SKILL.md +196 -0
- package/templates/skills/domains/ros2-perception/SKILL.md +166 -0
- package/templates/skills/domains/ros2-upper-app/SKILL.md +50 -0
- package/templates/skills/domains/ros2-upper-app/launch-files.md +224 -0
- package/templates/skills/domains/ros2-upper-app/parameters.md +192 -0
- package/templates/skills/domains/ros2-upper-app/python-nodes.md +249 -0
- package/templates/skills/domains/ros2-upper-app/rviz-config.md +158 -0
- package/templates/skills/domains/ros2-upper-app/simulation.md +225 -0
- package/templates/skills/domains/security/SKILL.md +72 -0
- package/templates/skills/domains/security/blue-team.md +436 -0
- package/templates/skills/domains/security/code-audit.md +265 -0
- package/templates/skills/domains/security/pentest.md +226 -0
- package/templates/skills/domains/security/red-team.md +374 -0
- package/templates/skills/domains/security/threat-intel.md +372 -0
- package/templates/skills/domains/security/vuln-research.md +369 -0
- package/templates/skills/orchestration/multi-agent/SKILL.md +533 -0
- package/templates/skills/run_skill.js +129 -0
- package/templates/skills/scrapling/SKILL.md +98 -0
- package/templates/skills/scrapling/references/api-quick-ref.md +127 -0
- package/templates/skills/scrapling/references/cookie-vault.md +56 -0
- package/templates/skills/scrapling/references/maintenance.md +79 -0
- package/templates/skills/scrapling/references/site-patterns.md +86 -0
- package/templates/skills/scrapling/references/troubleshooting.md +95 -0
- package/templates/skills/scrapling/templates/basic_fetch.py +19 -0
- package/templates/skills/scrapling/templates/parse_only.py +15 -0
- package/templates/skills/scrapling/templates/session_login.py +19 -0
- package/templates/skills/scrapling/templates/stealth_cloudflare.py +28 -0
- package/templates/skills/tools/gen-docs/SKILL.md +116 -0
- package/templates/skills/tools/gen-docs/scripts/doc_generator.js +435 -0
- package/templates/skills/tools/lib/shared.js +98 -0
- package/templates/skills/tools/override-refusal/SKILL.md +53 -0
- package/templates/skills/tools/override-refusal/agents/openai.yaml +4 -0
- package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -0
- package/templates/skills/tools/verify-change/SKILL.md +140 -0
- package/templates/skills/tools/verify-change/scripts/change_analyzer.js +289 -0
- package/templates/skills/tools/verify-module/SKILL.md +127 -0
- package/templates/skills/tools/verify-module/scripts/module_scanner.js +171 -0
- package/templates/skills/tools/verify-quality/SKILL.md +160 -0
- package/templates/skills/tools/verify-quality/scripts/quality_checker.js +337 -0
- package/templates/skills/tools/verify-security/SKILL.md +143 -0
- package/templates/skills/tools/verify-security/scripts/security_scanner.js +283 -0
- package/templates/spec/guides/index.md +30 -0
- package/templates/spec/low-control/index.md +31 -0
- package/templates/spec/upper-app/index.md +31 -0
- package/bin/codeagent-wrapper-darwin-amd64 +0 -0
- package/bin/codeagent-wrapper-darwin-arm64 +0 -0
- package/bin/codeagent-wrapper-linux-amd64 +0 -0
- package/bin/codeagent-wrapper-linux-arm64 +0 -0
- package/bin/codeagent-wrapper-windows-amd64.exe +0 -0
- package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
- package/dist/shared/ccg-ros2-workflow.DRytDWqb.mjs +0 -2274
- package/templates/commands/backend.md +0 -162
- package/templates/commands/enhance.md +0 -36
- package/templates/commands/frontend.md +0 -162
- package/templates/commands/workflow.md +0 -202
- /package/templates/{commands → commands-legacy}/execute.md +0 -0
- /package/templates/{commands → commands-legacy}/review.md +0 -0
- /package/templates/{commands → commands-legacy}/team-exec.md +0 -0
- /package/templates/{commands → commands-legacy}/team-research.md +0 -0
- /package/templates/{commands → commands-legacy}/team-review.md +0 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CCG Workflow Hook for Codex CLI — Adaptive Guardrail
|
|
4
|
+
Injects per-turn guidance based on what Codex has/hasn't done.
|
|
5
|
+
Not a rigid state machine — adapts to task complexity and progress.
|
|
6
|
+
|
|
7
|
+
Hook type: UserPromptSubmit
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
import glob
|
|
14
|
+
import subprocess
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def find_project_root():
|
|
20
|
+
"""Walk up to find .ccg/ or .git/"""
|
|
21
|
+
d = os.environ.get("CODEX_PROJECT_DIR", os.getcwd())
|
|
22
|
+
for _ in range(20):
|
|
23
|
+
if os.path.isdir(os.path.join(d, ".ccg")) or os.path.isdir(os.path.join(d, ".git")):
|
|
24
|
+
return d
|
|
25
|
+
parent = os.path.dirname(d)
|
|
26
|
+
if parent == d:
|
|
27
|
+
break
|
|
28
|
+
d = parent
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_active_task(root):
|
|
33
|
+
"""Find the most recent in_progress task."""
|
|
34
|
+
tasks_dir = os.path.join(root, ".ccg", "tasks")
|
|
35
|
+
if not os.path.isdir(tasks_dir):
|
|
36
|
+
return None
|
|
37
|
+
for name in sorted(os.listdir(tasks_dir), reverse=True):
|
|
38
|
+
if name == "archive":
|
|
39
|
+
continue
|
|
40
|
+
task_file = os.path.join(tasks_dir, name, "task.json")
|
|
41
|
+
if not os.path.isfile(task_file):
|
|
42
|
+
continue
|
|
43
|
+
try:
|
|
44
|
+
with open(task_file) as f:
|
|
45
|
+
task = json.load(f)
|
|
46
|
+
if task.get("status") not in ("completed", "archived"):
|
|
47
|
+
task["_dir"] = os.path.join(tasks_dir, name)
|
|
48
|
+
task["_name"] = name
|
|
49
|
+
return task
|
|
50
|
+
except Exception:
|
|
51
|
+
continue
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def detect_progress(root):
|
|
56
|
+
"""Detect what Codex has done so far in this session."""
|
|
57
|
+
signals = {
|
|
58
|
+
"has_dirty_files": False,
|
|
59
|
+
"dirty_count": 0,
|
|
60
|
+
"changed_lines": 0,
|
|
61
|
+
"has_test_output": False,
|
|
62
|
+
"high_risk_files": False,
|
|
63
|
+
}
|
|
64
|
+
try:
|
|
65
|
+
status = subprocess.run(
|
|
66
|
+
["git", "status", "--porcelain"],
|
|
67
|
+
cwd=root, capture_output=True, text=True, timeout=5
|
|
68
|
+
)
|
|
69
|
+
lines = [l for l in status.stdout.strip().split("\n") if l.strip()]
|
|
70
|
+
signals["dirty_count"] = len(lines)
|
|
71
|
+
signals["has_dirty_files"] = len(lines) > 0
|
|
72
|
+
|
|
73
|
+
risk_patterns = ["auth", "login", "password", "token", "secret", "crypto",
|
|
74
|
+
"encrypt", "migration", "schema", "permission", "admin"]
|
|
75
|
+
for line in lines:
|
|
76
|
+
fname = line[3:].strip().lower()
|
|
77
|
+
if any(p in fname for p in risk_patterns):
|
|
78
|
+
signals["high_risk_files"] = True
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
if signals["has_dirty_files"]:
|
|
82
|
+
diff = subprocess.run(
|
|
83
|
+
["git", "diff", "--stat"],
|
|
84
|
+
cwd=root, capture_output=True, text=True, timeout=5
|
|
85
|
+
)
|
|
86
|
+
for dline in diff.stdout.strip().split("\n"):
|
|
87
|
+
if "insertion" in dline or "deletion" in dline:
|
|
88
|
+
parts = dline.split(",")
|
|
89
|
+
for p in parts:
|
|
90
|
+
p = p.strip()
|
|
91
|
+
if "insertion" in p:
|
|
92
|
+
signals["changed_lines"] += int(p.split()[0])
|
|
93
|
+
elif "deletion" in p:
|
|
94
|
+
signals["changed_lines"] += int(p.split()[0])
|
|
95
|
+
except Exception:
|
|
96
|
+
pass
|
|
97
|
+
return signals
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def assess_complexity(task):
|
|
101
|
+
"""Get complexity from task.json or default to M."""
|
|
102
|
+
if not task:
|
|
103
|
+
return "M"
|
|
104
|
+
return task.get("complexity", "M")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def build_guidance(task, progress, root):
|
|
108
|
+
"""Build adaptive guidance based on task state + progress."""
|
|
109
|
+
parts = []
|
|
110
|
+
complexity = assess_complexity(task)
|
|
111
|
+
phase = task.get("currentPhase", "unknown") if task else "no_task"
|
|
112
|
+
|
|
113
|
+
# --- Task state breadcrumb ---
|
|
114
|
+
if task:
|
|
115
|
+
parts.append(f"Task: {task.get('title', task.get('id', '?'))} ({task.get('status', '?')})")
|
|
116
|
+
parts.append(f"Complexity: {complexity} | Risk: {task.get('risk', '?')} | Phase: {phase}")
|
|
117
|
+
if task.get("nextAction"):
|
|
118
|
+
parts.append(f"Next: {task['nextAction']}")
|
|
119
|
+
else:
|
|
120
|
+
parts.append("No active task. Create one in .ccg/tasks/ before starting work.")
|
|
121
|
+
parts.append("Even small fixes need a task.json for tracking.")
|
|
122
|
+
return parts
|
|
123
|
+
|
|
124
|
+
# --- Adaptive guidance based on phase × progress ---
|
|
125
|
+
|
|
126
|
+
# Phase: analysis — haven't started coding yet
|
|
127
|
+
if phase == "analysis":
|
|
128
|
+
if complexity in ("M", "L", "XL"):
|
|
129
|
+
parts.append("")
|
|
130
|
+
parts.append(f"⛔ {complexity} complexity: you MUST call BOTH Gemini AND Claude for parallel analysis before coding.")
|
|
131
|
+
parts.append("Use the dual-model parallel template in AGENTS.md: --backend gemini & --backend claude with & + wait.")
|
|
132
|
+
|
|
133
|
+
# Phase: implementation — coding in progress
|
|
134
|
+
elif phase == "implementation":
|
|
135
|
+
if progress["dirty_count"] == 0:
|
|
136
|
+
parts.append("")
|
|
137
|
+
parts.append("Implementation phase started but no files changed yet. Start coding.")
|
|
138
|
+
|
|
139
|
+
# Phase: review — code is written, need review
|
|
140
|
+
elif phase == "review":
|
|
141
|
+
parts.append("")
|
|
142
|
+
parts.append("Review phase. Call external models for review, write results to review.md.")
|
|
143
|
+
|
|
144
|
+
# --- Cross-phase guardrails ---
|
|
145
|
+
|
|
146
|
+
# Big changes without review
|
|
147
|
+
if progress["changed_lines"] > 30 and phase != "review":
|
|
148
|
+
parts.append("")
|
|
149
|
+
parts.append(f"⚠️ {progress['changed_lines']} lines changed. When done coding, you MUST call BOTH Gemini AND Claude for dual-model review. Not just one — both.")
|
|
150
|
+
|
|
151
|
+
# Review phase: enforce dual model
|
|
152
|
+
if phase == "review":
|
|
153
|
+
parts.append("")
|
|
154
|
+
parts.append("⛔ Review phase: call BOTH Gemini (--backend gemini) AND Claude (--backend claude) with reviewer role. Two models, not one.")
|
|
155
|
+
|
|
156
|
+
# High-risk files detected
|
|
157
|
+
if progress["high_risk_files"] and phase not in ("review", "completed"):
|
|
158
|
+
parts.append("")
|
|
159
|
+
parts.append("⚠️ High-risk files detected (auth/db/crypto). External model security review is REQUIRED before delivery.")
|
|
160
|
+
|
|
161
|
+
# Has dirty files but hasn't run tests
|
|
162
|
+
if progress["has_dirty_files"] and not progress["has_test_output"]:
|
|
163
|
+
if phase == "implementation" and progress["changed_lines"] > 10:
|
|
164
|
+
parts.append("")
|
|
165
|
+
parts.append("Reminder: run tests after significant changes. Don't wait until the end.")
|
|
166
|
+
|
|
167
|
+
# --- Spec reminder ---
|
|
168
|
+
spec_dir = os.path.join(root, ".ccg", "spec")
|
|
169
|
+
if os.path.isdir(spec_dir) and phase in ("analysis", "implementation"):
|
|
170
|
+
specs = []
|
|
171
|
+
for sub in ("backend", "frontend", "guides"):
|
|
172
|
+
idx = os.path.join(spec_dir, sub, "index.md")
|
|
173
|
+
if os.path.isfile(idx):
|
|
174
|
+
specs.append(f".ccg/spec/{sub}/index.md")
|
|
175
|
+
if specs:
|
|
176
|
+
parts.append("")
|
|
177
|
+
parts.append(f"Spec files available: {', '.join(specs)} — read before writing code.")
|
|
178
|
+
|
|
179
|
+
# --- Archive reminder ---
|
|
180
|
+
if phase == "completed" or (task.get("status") == "completed"):
|
|
181
|
+
parts.append("")
|
|
182
|
+
parts.append("⛔ Task completed. You MUST archive it now:")
|
|
183
|
+
parts.append(f" mkdir -p .ccg/tasks/archive/$(date +%Y-%m) && mv .ccg/tasks/{task['_name']} .ccg/tasks/archive/$(date +%Y-%m)/")
|
|
184
|
+
parts.append(" git add .ccg/tasks/ && git commit -m \"chore: archive ccg task\"")
|
|
185
|
+
|
|
186
|
+
return parts
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
SUB_AGENT_NOTICE = """<ccg-sub-agent-notice>
|
|
190
|
+
SUB-AGENT NOTICE — READ FIRST IF SPAWNED VIA spawn_agent
|
|
191
|
+
|
|
192
|
+
If your parent session spawned you via spawn_agent with an explicit task
|
|
193
|
+
message, that message is your ONLY job.
|
|
194
|
+
- Execute the parent message exactly as written, then mark yourself complete.
|
|
195
|
+
- Ignore all CCG workflow guidance below this notice.
|
|
196
|
+
- Do NOT call spawn_agent, wait, or close_agent.
|
|
197
|
+
- Do NOT modify .ccg/tasks/* or any workflow state files.
|
|
198
|
+
- Do NOT run external model calls (codeagent-wrapper).
|
|
199
|
+
- Only modify files explicitly listed in your dispatch message.
|
|
200
|
+
</ccg-sub-agent-notice>"""
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def is_sub_agent():
|
|
204
|
+
"""Detect if running inside a Codex sub-agent session.
|
|
205
|
+
Codex sub-agents spawned with fork_turns='none' get a clean
|
|
206
|
+
context but inherit the env. The parent sets CODEX_AGENT_TYPE
|
|
207
|
+
or the agent_type is visible in the process env."""
|
|
208
|
+
if os.environ.get("CODEX_AGENT_TYPE", ""):
|
|
209
|
+
return True
|
|
210
|
+
if os.environ.get("CODEX_FORK_TURNS", "") == "none":
|
|
211
|
+
return True
|
|
212
|
+
return False
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def main():
|
|
216
|
+
try:
|
|
217
|
+
root = find_project_root()
|
|
218
|
+
if not root:
|
|
219
|
+
return
|
|
220
|
+
if not os.path.isdir(os.path.join(root, ".ccg")):
|
|
221
|
+
return
|
|
222
|
+
|
|
223
|
+
# Sub-agent: inject notice and skip workflow guidance
|
|
224
|
+
if is_sub_agent():
|
|
225
|
+
print(json.dumps({
|
|
226
|
+
"hookSpecificOutput": {
|
|
227
|
+
"hookEventName": "UserPromptSubmit",
|
|
228
|
+
"additionalContext": SUB_AGENT_NOTICE
|
|
229
|
+
}
|
|
230
|
+
}))
|
|
231
|
+
return
|
|
232
|
+
|
|
233
|
+
task = get_active_task(root)
|
|
234
|
+
progress = detect_progress(root)
|
|
235
|
+
lines = build_guidance(task, progress, root)
|
|
236
|
+
|
|
237
|
+
if not lines:
|
|
238
|
+
return
|
|
239
|
+
|
|
240
|
+
context = "<ccg-state>\n" + "\n".join(lines) + "\n</ccg-state>"
|
|
241
|
+
|
|
242
|
+
print(json.dumps({
|
|
243
|
+
"hookSpecificOutput": {
|
|
244
|
+
"hookEventName": "UserPromptSubmit",
|
|
245
|
+
"additionalContext": context
|
|
246
|
+
}
|
|
247
|
+
}))
|
|
248
|
+
except Exception:
|
|
249
|
+
pass
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
if __name__ == "__main__":
|
|
253
|
+
main()
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: planner
|
|
3
|
-
description: 📋
|
|
4
|
-
tools: Read, Write,
|
|
3
|
+
description: 📋 任务规划师 - 使用 WBS 方法论分解功能需求为可执行任务
|
|
4
|
+
tools: Read, Write, {{MCP_SEARCH_TOOL}}
|
|
5
5
|
color: blue
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
你是一位资深的项目规划师,擅长使用 WBS(工作分解结构)方法论将复杂功能需求分解为清晰的任务清单。
|
|
9
9
|
|
|
10
10
|
## 核心职责
|
|
11
11
|
|
|
12
12
|
1. **需求分析**:理解功能目标、范围、约束条件
|
|
13
|
-
2. **任务分解**:功能 → 模块 →
|
|
13
|
+
2. **任务分解**:功能 → 模块 → 文件 → 具体步骤
|
|
14
14
|
3. **依赖识别**:标注任务间的前后依赖关系
|
|
15
15
|
4. **工作量估算**:使用"任务点"为单位(1点 ≈ 1-2小时)
|
|
16
16
|
|
|
@@ -19,8 +19,8 @@ color: blue
|
|
|
19
19
|
### 步骤 1:理解需求
|
|
20
20
|
|
|
21
21
|
分析用户需求,明确:
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- 功能目标是什么?
|
|
23
|
+
- 涉及哪些模块(上层应用/底层控制/数据库)?
|
|
24
24
|
- 有哪些技术约束?
|
|
25
25
|
- 是否有现有代码需要修改?
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ color: blue
|
|
|
29
29
|
如果需要了解现有实现,使用 ace-tool 检索:
|
|
30
30
|
|
|
31
31
|
```
|
|
32
|
-
|
|
32
|
+
{{MCP_SEARCH_TOOL}} {
|
|
33
33
|
"project_root_path": "{{项目路径}}",
|
|
34
34
|
"query": "{{相关功能关键词}}"
|
|
35
35
|
}
|
|
@@ -41,9 +41,9 @@ mcp__ace-tool__search_context {
|
|
|
41
41
|
|
|
42
42
|
**Level 1: 功能**(顶层目标)
|
|
43
43
|
↓
|
|
44
|
-
**Level 2:
|
|
44
|
+
**Level 2: 模块**(上层应用/底层控制/数据库)
|
|
45
45
|
↓
|
|
46
|
-
**Level 3:
|
|
46
|
+
**Level 3: 文件/组件**(具体代码文件)
|
|
47
47
|
↓
|
|
48
48
|
**Level 4: 任务步骤**(可执行的具体动作)
|
|
49
49
|
|
|
@@ -58,14 +58,13 @@ mcp__ace-tool__search_context {
|
|
|
58
58
|
|
|
59
59
|
**规划时间**:{{当前时间}}
|
|
60
60
|
**预估工作量**:{{总任务点}} 任务点
|
|
61
|
-
**目标平台**:ROS2 Humble / 物理机器人
|
|
62
61
|
|
|
63
62
|
---
|
|
64
63
|
|
|
65
64
|
## 1. 功能概述
|
|
66
65
|
|
|
67
66
|
### 1.1 目标
|
|
68
|
-
{{
|
|
67
|
+
{{功能要达成的业务目标}}
|
|
69
68
|
|
|
70
69
|
### 1.2 范围
|
|
71
70
|
**包含**:
|
|
@@ -76,9 +75,9 @@ mcp__ace-tool__search_context {
|
|
|
76
75
|
- {{明确不做的内容}}
|
|
77
76
|
|
|
78
77
|
### 1.3 技术约束
|
|
79
|
-
- {{
|
|
80
|
-
- {{
|
|
81
|
-
- {{
|
|
78
|
+
- {{技术栈限制}}
|
|
79
|
+
- {{性能要求}}
|
|
80
|
+
- {{兼容性要求}}
|
|
82
81
|
|
|
83
82
|
---
|
|
84
83
|
|
|
@@ -88,26 +87,25 @@ mcp__ace-tool__search_context {
|
|
|
88
87
|
|
|
89
88
|
```mermaid
|
|
90
89
|
graph TD
|
|
91
|
-
A[{{功能名称}}] --> B[
|
|
92
|
-
A --> C[
|
|
93
|
-
A --> D[
|
|
90
|
+
A[{{功能名称}}] --> B[上层应用模块]
|
|
91
|
+
A --> C[底层控制模块]
|
|
92
|
+
A --> D[数据库模块]
|
|
94
93
|
|
|
95
|
-
B --> B1[
|
|
96
|
-
B --> B2[
|
|
97
|
-
B --> B3[可视化节点]
|
|
94
|
+
B --> B1[页面/组件 1]
|
|
95
|
+
B --> B2[页面/组件 2]
|
|
98
96
|
|
|
99
|
-
C --> C1[
|
|
100
|
-
C --> C2[
|
|
97
|
+
C --> C1[API 接口 1]
|
|
98
|
+
C --> C2[API 接口 2]
|
|
101
99
|
|
|
102
|
-
D --> D1[
|
|
103
|
-
D --> D2[
|
|
100
|
+
D --> D1[数据模型]
|
|
101
|
+
D --> D2[迁移脚本]
|
|
104
102
|
```
|
|
105
103
|
|
|
106
104
|
### 2.2 任务清单
|
|
107
105
|
|
|
108
|
-
#### 模块 A
|
|
106
|
+
#### 模块 A:{{模块名}}({{任务点}} 任务点)
|
|
109
107
|
|
|
110
|
-
|
|
108
|
+
**文件**: `{{文件路径}}`
|
|
111
109
|
|
|
112
110
|
- [ ] **任务 A.1**:{{任务描述}}({{任务点}} 点)
|
|
113
111
|
- **输入**:{{需要的数据/依赖}}
|
|
@@ -123,15 +121,7 @@ graph TD
|
|
|
123
121
|
1. {{步骤 1}}
|
|
124
122
|
2. {{步骤 2}}
|
|
125
123
|
|
|
126
|
-
#### 模块 B
|
|
127
|
-
|
|
128
|
-
**包名**: `{{package_name}}`
|
|
129
|
-
|
|
130
|
-
{{重复上述结构}}
|
|
131
|
-
|
|
132
|
-
#### 模块 C:消息定义({{任务点}} 任务点)
|
|
133
|
-
|
|
134
|
-
**包名**: `{{package_name}}_msgs`
|
|
124
|
+
#### 模块 B:{{模块名}}({{任务点}} 任务点)
|
|
135
125
|
|
|
136
126
|
{{重复上述结构}}
|
|
137
127
|
|
|
@@ -143,23 +133,23 @@ graph TD
|
|
|
143
133
|
|
|
144
134
|
```mermaid
|
|
145
135
|
graph LR
|
|
146
|
-
T1[
|
|
147
|
-
T2 --> T3[
|
|
148
|
-
T1 --> T4[
|
|
136
|
+
T1[任务 A.1] --> T2[任务 B.1]
|
|
137
|
+
T2 --> T3[任务 C.1]
|
|
138
|
+
T1 --> T4[任务 B.2]
|
|
149
139
|
```
|
|
150
140
|
|
|
151
141
|
### 3.2 依赖说明
|
|
152
142
|
|
|
153
143
|
| 任务 | 依赖于 | 原因 |
|
|
154
144
|
|------|--------|------|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
145
|
+
| 任务 B.1 | 任务 A.1 | 需要上层应用组件完成后才能集成 API |
|
|
146
|
+
| 任务 C.1 | 任务 B.1 | 数据库 schema 需先定义 |
|
|
157
147
|
|
|
158
148
|
### 3.3 并行任务
|
|
159
149
|
|
|
160
150
|
以下任务可以并行开发:
|
|
161
|
-
-
|
|
162
|
-
-
|
|
151
|
+
- 任务 A.1 ∥ 任务 D.1
|
|
152
|
+
- 任务 B.2 ∥ 任务 C.2
|
|
163
153
|
|
|
164
154
|
---
|
|
165
155
|
|
|
@@ -169,23 +159,19 @@ graph LR
|
|
|
169
159
|
|
|
170
160
|
| 需求 | 推荐方案 | 理由 |
|
|
171
161
|
|------|----------|------|
|
|
172
|
-
|
|
|
173
|
-
| 导航 | Nav2 | 成熟的导航栈 |
|
|
174
|
-
| 仿真 | Gazebo | 支持 ROS2 集成 |
|
|
162
|
+
| {{技术需求}} | {{方案}} | {{选型理由}} |
|
|
175
163
|
|
|
176
164
|
### 4.2 潜在风险
|
|
177
165
|
|
|
178
166
|
| 风险 | 影响 | 缓解措施 |
|
|
179
167
|
|------|------|----------|
|
|
180
|
-
|
|
|
181
|
-
| 硬件兼容性 | 中 | 提前测试硬件驱动 |
|
|
168
|
+
| {{风险描述}} | 高/中/低 | {{应对方案}} |
|
|
182
169
|
|
|
183
170
|
### 4.3 测试策略
|
|
184
171
|
|
|
185
|
-
-
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
- **硬件测试**:在物理机器人上验证
|
|
172
|
+
- **单元测试**:{{哪些模块需要单测}}
|
|
173
|
+
- **集成测试**:{{哪些接口需要集成测试}}
|
|
174
|
+
- **E2E 测试**:{{关键用户流程}}
|
|
189
175
|
|
|
190
176
|
---
|
|
191
177
|
|
|
@@ -194,8 +180,7 @@ graph LR
|
|
|
194
180
|
功能完成需满足以下条件:
|
|
195
181
|
|
|
196
182
|
- [ ] 所有任务清单完成
|
|
197
|
-
- [ ]
|
|
198
|
-
- [ ] 仿真测试通过
|
|
183
|
+
- [ ] 单元测试覆盖率 ≥ 80%
|
|
199
184
|
- [ ] 代码审查通过
|
|
200
185
|
- [ ] 无高优先级 Bug
|
|
201
186
|
- [ ] 文档更新完成
|
|
@@ -226,109 +211,99 @@ Phase 2 可考虑的增强:
|
|
|
226
211
|
### 输入示例
|
|
227
212
|
|
|
228
213
|
```
|
|
229
|
-
|
|
214
|
+
用户需求:实现用户登录功能
|
|
230
215
|
|
|
231
216
|
项目上下文:
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
235
|
-
- 需要支持参数动态调节
|
|
217
|
+
- Next.js 14 (App Router)
|
|
218
|
+
- PostgreSQL + Prisma
|
|
219
|
+
- 已有用户注册功能
|
|
236
220
|
```
|
|
237
221
|
|
|
238
222
|
### 输出示例(简化版)
|
|
239
223
|
|
|
240
224
|
```markdown
|
|
241
|
-
#
|
|
225
|
+
# 功能规划:用户登录功能
|
|
242
226
|
|
|
243
|
-
**预估工作量**:
|
|
244
|
-
**目标平台**:ROS2 Humble / 物理机器人
|
|
227
|
+
**预估工作量**:12 任务点
|
|
245
228
|
|
|
246
229
|
## 1. 功能概述
|
|
247
|
-
|
|
248
|
-
实现一个 PID 速度控制器节点,订阅目标速度,发布电机控制指令。
|
|
230
|
+
实现用户通过邮箱和密码登录系统的功能。
|
|
249
231
|
|
|
250
232
|
## 2. WBS 任务分解
|
|
251
233
|
|
|
252
|
-
#### 模块 A
|
|
234
|
+
#### 模块 A:上层应用登录页面(4 任务点)
|
|
253
235
|
|
|
254
|
-
|
|
236
|
+
**文件**: `app/login/page.tsx`
|
|
255
237
|
|
|
256
|
-
- [ ] **任务 A.1
|
|
257
|
-
- **输入**:
|
|
258
|
-
- **输出**:
|
|
238
|
+
- [ ] **任务 A.1**:创建登录页面和表单组件(2 点)
|
|
239
|
+
- **输入**:UI 设计规范
|
|
240
|
+
- **输出**:LoginForm 组件
|
|
259
241
|
- **关键步骤**:
|
|
260
|
-
1.
|
|
261
|
-
2. 实现
|
|
262
|
-
3.
|
|
242
|
+
1. 创建 page.tsx 路由
|
|
243
|
+
2. 实现 LoginForm 组件(邮箱、密码输入框)
|
|
244
|
+
3. 添加客户端表单验证(react-hook-form)
|
|
263
245
|
|
|
264
|
-
- [ ] **任务 A.2
|
|
265
|
-
-
|
|
266
|
-
-
|
|
246
|
+
- [ ] **任务 A.2**:集成登录 API 调用(2 点)
|
|
247
|
+
- **输入**:底层控制 API 接口(任务 B.1)
|
|
248
|
+
- **输出**:完整登录流程
|
|
267
249
|
- **关键步骤**:
|
|
268
|
-
1.
|
|
269
|
-
2.
|
|
270
|
-
3.
|
|
250
|
+
1. 使用 fetch 调用 /api/auth/login
|
|
251
|
+
2. 处理成功/失败响应
|
|
252
|
+
3. 登录成功后跳转到首页
|
|
271
253
|
|
|
272
|
-
|
|
273
|
-
- **输入**:ROS2 参数系统
|
|
274
|
-
- **输出**:支持 ros2 param set
|
|
275
|
-
- **关键步骤**:
|
|
276
|
-
1. 声明 Kp, Ki, Kd 参数
|
|
277
|
-
2. 注册参数回调
|
|
278
|
-
3. 实时更新 PID 参数
|
|
279
|
-
|
|
280
|
-
#### 模块 B:上层应用 - 配置和可视化(3 任务点)- Gemini 主导
|
|
254
|
+
#### 模块 B:底层控制认证接口(5 任务点)
|
|
281
255
|
|
|
282
|
-
|
|
256
|
+
**文件**: `app/api/auth/login/route.ts`
|
|
283
257
|
|
|
284
|
-
- [ ] **任务 B.1
|
|
285
|
-
-
|
|
286
|
-
- **输出**:
|
|
258
|
+
- [ ] **任务 B.1**:实现 POST /api/auth/login(3 点)
|
|
259
|
+
- **输入**:用户邮箱、密码
|
|
260
|
+
- **输出**:JWT token
|
|
287
261
|
- **关键步骤**:
|
|
288
|
-
1.
|
|
289
|
-
2.
|
|
290
|
-
3.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
-
|
|
262
|
+
1. 验证请求体格式(Zod)
|
|
263
|
+
2. 查询数据库验证用户存在
|
|
264
|
+
3. 使用 bcrypt 验证密码
|
|
265
|
+
4. 生成 JWT token 并返回
|
|
266
|
+
|
|
267
|
+
- [ ] **任务 B.2**:实现 Session 中间件(2 点)
|
|
268
|
+
- **输入**:JWT token
|
|
269
|
+
- **输出**:用户会话对象
|
|
295
270
|
- **关键步骤**:
|
|
296
|
-
1.
|
|
297
|
-
2.
|
|
298
|
-
3.
|
|
271
|
+
1. 创建 middleware.ts 验证 token
|
|
272
|
+
2. 将用户信息注入 request context
|
|
273
|
+
3. 处理 token 过期情况
|
|
299
274
|
|
|
300
|
-
|
|
301
|
-
- **输入**:控制器状态
|
|
302
|
-
- **输出**:RViz 配置
|
|
303
|
-
- **关键步骤**:
|
|
304
|
-
1. 发布 /pid_debug 话题
|
|
305
|
-
2. 创建 RViz 配置文件
|
|
275
|
+
#### 模块 C:数据库(3 任务点)
|
|
306
276
|
|
|
307
|
-
|
|
277
|
+
**文件**: `prisma/schema.prisma`
|
|
308
278
|
|
|
309
|
-
|
|
279
|
+
- [ ] **任务 C.1**:扩展 User 模型(1 点)
|
|
280
|
+
- **输入**:现有 User schema
|
|
281
|
+
- **输出**:支持登录的 User 模型
|
|
282
|
+
- **关键步骤**:
|
|
283
|
+
1. 添加 lastLoginAt 字段
|
|
284
|
+
2. 添加 loginAttempts 字段(防暴力破解)
|
|
310
285
|
|
|
311
|
-
- [ ] **任务 C.
|
|
312
|
-
-
|
|
313
|
-
- **输出**:
|
|
286
|
+
- [ ] **任务 C.2**:创建 Session 模型(2 点)
|
|
287
|
+
- **输入**:Session 需求
|
|
288
|
+
- **输出**:Session schema
|
|
314
289
|
- **关键步骤**:
|
|
315
|
-
1. 定义
|
|
316
|
-
2.
|
|
290
|
+
1. 定义 Session 表结构
|
|
291
|
+
2. 关联 User 外键
|
|
292
|
+
3. 运行 migration
|
|
317
293
|
|
|
318
294
|
## 3. 依赖关系
|
|
319
295
|
|
|
320
296
|
| 任务 | 依赖于 | 原因 |
|
|
321
297
|
|------|--------|------|
|
|
322
|
-
| A.2
|
|
323
|
-
| B.1
|
|
324
|
-
| A.2 节点封装 | C.1 消息 | 需要 PIDState 消息类型 |
|
|
298
|
+
| A.2 | B.1 | 上层应用需要底层控制 API 完成 |
|
|
299
|
+
| B.1 | C.1 | API 需要数据库字段 |
|
|
325
300
|
|
|
326
301
|
## 4. 验收标准
|
|
327
302
|
|
|
328
|
-
- [ ]
|
|
329
|
-
- [ ]
|
|
330
|
-
- [ ]
|
|
331
|
-
- [ ]
|
|
303
|
+
- [ ] 用户可以使用正确的邮箱密码登录
|
|
304
|
+
- [ ] 错误密码返回明确错误提示
|
|
305
|
+
- [ ] 登录成功后跳转到首页
|
|
306
|
+
- [ ] 单元测试覆盖 API 逻辑
|
|
332
307
|
```
|
|
333
308
|
|
|
334
309
|
---
|
|
@@ -339,7 +314,7 @@ Phase 2 可考虑的增强:
|
|
|
339
314
|
|
|
340
315
|
1. **用户需求**:完整的功能描述
|
|
341
316
|
2. **项目路径**:用于 ace-tool 检索上下文
|
|
342
|
-
3.
|
|
343
|
-
4.
|
|
317
|
+
3. **技术栈信息**:框架、数据库、已有模块
|
|
318
|
+
4. **特殊约束**:性能要求、兼容性、安全要求
|
|
344
319
|
|
|
345
320
|
本 agent 将返回详细的 Markdown 规划文档,可直接保存到 `.claude/plan/功能名.md`。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: system-integrator
|
|
3
3
|
description: 🤖 ROS2 系统集成设计师 - 为 ROS2 功能生成节点架构、Topic/Service 设计和消息流程
|
|
4
|
-
tools: Read, Write,
|
|
4
|
+
tools: Read, Write, {{MCP_SEARCH_TOOL}}
|
|
5
5
|
color: magenta
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ color: magenta
|
|
|
30
30
|
如果项目已有节点或消息定义,使用 ace-tool 检索:
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
|
|
33
|
+
{{MCP_SEARCH_TOOL}} {
|
|
34
34
|
"project_root_path": "{{项目路径}}",
|
|
35
35
|
"query": "ROS2 节点、Topic 订阅、消息类型、launch 文件"
|
|
36
36
|
}
|