@hunyed15/codecgc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/route-edit.ps1 +86 -0
- package/INSTALLATION.md +550 -0
- package/LICENSE +21 -0
- package/README.md +171 -0
- package/bin/cgc-build.js +4 -0
- package/bin/cgc-doctor.js +4 -0
- package/bin/cgc-entry.js +4 -0
- package/bin/cgc-external-audit.js +4 -0
- package/bin/cgc-fix.js +4 -0
- package/bin/cgc-history.js +4 -0
- package/bin/cgc-install.js +4 -0
- package/bin/cgc-lifecycle.js +4 -0
- package/bin/cgc-package-audit.js +4 -0
- package/bin/cgc-plan.js +4 -0
- package/bin/cgc-release-readiness.js +4 -0
- package/bin/cgc-review.js +4 -0
- package/bin/cgc-route.js +4 -0
- package/bin/cgc-status.js +4 -0
- package/bin/cgc-test.js +4 -0
- package/bin/cgc.js +4 -0
- package/bin/codecgc.js +1284 -0
- package/codecgc/cgc/SKILL.md +46 -0
- package/codecgc/cgc-arch/SKILL.md +61 -0
- package/codecgc/cgc-build/SKILL.md +53 -0
- package/codecgc/cgc-decide/SKILL.md +55 -0
- package/codecgc/cgc-fix/SKILL.md +47 -0
- package/codecgc/cgc-learn/SKILL.md +46 -0
- package/codecgc/cgc-onboard/SKILL.md +52 -0
- package/codecgc/cgc-plan/SKILL.md +48 -0
- package/codecgc/cgc-refactor/SKILL.md +46 -0
- package/codecgc/cgc-req/SKILL.md +61 -0
- package/codecgc/cgc-review/SKILL.md +57 -0
- package/codecgc/cgc-roadmap/SKILL.md +55 -0
- package/codecgc/cgc-test/SKILL.md +21 -0
- package/codecgc/reference/api-cgc-review-libdoc.md +13 -0
- package/codecgc/reference/artifact-class-policy.md +81 -0
- package/codecgc/reference/build-flow.md +95 -0
- package/codecgc/reference/checklist-contract.md +103 -0
- package/codecgc/reference/execution-audit.md +121 -0
- package/codecgc/reference/execution-model.md +118 -0
- package/codecgc/reference/execution-routing.md +130 -0
- package/codecgc/reference/executor-contract.md +87 -0
- package/codecgc/reference/external-capability-registry.json +104 -0
- package/codecgc/reference/fix-flow.md +94 -0
- package/codecgc/reference/fixture-governance.md +60 -0
- package/codecgc/reference/flow-execution.md +65 -0
- package/codecgc/reference/lifecycle-map.md +172 -0
- package/codecgc/reference/lifecycle-playbook.md +104 -0
- package/codecgc/reference/long-lived-artifacts.md +98 -0
- package/codecgc/reference/operation-guide.md +242 -0
- package/codecgc/reference/release-maintenance-playbook.md +150 -0
- package/codecgc/reference/review-writeback.md +141 -0
- package/codecgc/reference/role-model.md +128 -0
- package/codecgc/reference/runtime-boundary.md +72 -0
- package/codecgc/reference/shared-conventions.md +93 -0
- package/codecgc/reference/workflow-scaffold.md +57 -0
- package/codexmcp/LICENSE +21 -0
- package/codexmcp/README.md +294 -0
- package/codexmcp/pyproject.toml +37 -0
- package/codexmcp/src/codexmcp/__init__.py +4 -0
- package/codexmcp/src/codexmcp/cli.py +12 -0
- package/codexmcp/src/codexmcp/server.py +529 -0
- package/geminimcp/README.md +258 -0
- package/geminimcp/pyproject.toml +15 -0
- package/geminimcp/src/geminimcp/__init__.py +4 -0
- package/geminimcp/src/geminimcp/cli.py +12 -0
- package/geminimcp/src/geminimcp/server.py +465 -0
- package/model-routing.yaml +30 -0
- package/package.json +90 -0
- package/requirements.txt +1 -0
- package/scripts/README-codecgc-cli.md +89 -0
- package/scripts/audit_codecgc_external_capabilities.py +276 -0
- package/scripts/audit_codecgc_historical_audits.py +242 -0
- package/scripts/audit_codecgc_lifecycle.py +241 -0
- package/scripts/audit_codecgc_package_runtime.py +445 -0
- package/scripts/audit_codecgc_release_readiness.py +202 -0
- package/scripts/audit_codecgc_review_policy.py +82 -0
- package/scripts/audit_codecgc_workflow_history.py +317 -0
- package/scripts/build_codecgc_task.py +487 -0
- package/scripts/codecgc_artifact_roots.py +40 -0
- package/scripts/codecgc_cli.py +843 -0
- package/scripts/codecgc_command_surface.py +28 -0
- package/scripts/codecgc_console_io.py +45 -0
- package/scripts/codecgc_executor_registry.py +54 -0
- package/scripts/codecgc_file_evidence.py +349 -0
- package/scripts/codecgc_flow_control.py +233 -0
- package/scripts/codecgc_governance_dedupe.py +161 -0
- package/scripts/codecgc_plan_decision.py +103 -0
- package/scripts/codecgc_review_control.py +588 -0
- package/scripts/codecgc_roadmap_templates.py +149 -0
- package/scripts/codecgc_routing_paths.py +16 -0
- package/scripts/codecgc_routing_template.py +135 -0
- package/scripts/codecgc_runtime_paths.py +22 -0
- package/scripts/codecgc_session_recovery.py +44 -0
- package/scripts/codecgc_step_control.py +154 -0
- package/scripts/codecgc_workflow_runtime.py +63 -0
- package/scripts/codecgc_workflow_templates.py +437 -0
- package/scripts/entry_codecgc_workflow.py +3419 -0
- package/scripts/exercise_mcp_tools.py +109 -0
- package/scripts/expand_codecgc_roadmap.py +664 -0
- package/scripts/init_codecgc_roadmap.py +134 -0
- package/scripts/init_codecgc_workflow.py +207 -0
- package/scripts/install_codecgc.py +938 -0
- package/scripts/migrate_demo_workflows_to_fixtures.py +128 -0
- package/scripts/normalize_codecgc_audits.py +114 -0
- package/scripts/normalize_codecgc_governance_docs.py +79 -0
- package/scripts/normalize_codecgc_workflow_docs.py +269 -0
- package/scripts/plan_codecgc_workflow.py +970 -0
- package/scripts/refresh_codecgc_review_policy.py +223 -0
- package/scripts/review_codecgc_workflow.py +88 -0
- package/scripts/route_codecgc_workflow.py +671 -0
- package/scripts/run_codecgc_build.py +104 -0
- package/scripts/run_codecgc_fix.py +104 -0
- package/scripts/run_codecgc_flow_step.py +165 -0
- package/scripts/run_codecgc_task.py +410 -0
- package/scripts/run_codecgc_test.py +105 -0
- package/scripts/sync_codecgc_mcp_config.py +41 -0
- package/scripts/write_codecgc_architecture.py +78 -0
- package/scripts/write_codecgc_decision.py +83 -0
- package/scripts/write_codecgc_explore.py +118 -0
- package/scripts/write_codecgc_guide.py +141 -0
- package/scripts/write_codecgc_learning.py +87 -0
- package/scripts/write_codecgc_libdoc.py +140 -0
- package/scripts/write_codecgc_refactor.py +78 -0
- package/scripts/write_codecgc_requirement.py +78 -0
- package/scripts/write_codecgc_review.py +291 -0
- package/scripts/write_codecgc_roadmap.py +122 -0
- package/scripts/write_codecgc_trick.py +123 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from codecgc_artifact_roots import execution_root
|
|
7
|
+
from codecgc_artifact_roots import flow_root
|
|
8
|
+
from codecgc_artifact_roots import normalize_artifact_class
|
|
9
|
+
from route_codecgc_workflow import extract_review_metadata
|
|
10
|
+
from write_codecgc_review import load_json
|
|
11
|
+
from write_codecgc_review import resolve_artifact_path
|
|
12
|
+
from write_codecgc_review import write_review
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
WORKSPACE = Path(__file__).resolve().parents[1]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
description="为历史 acceptance/fix-note 产物补写缺失的 CodeCGC 审核策略字段。"
|
|
21
|
+
)
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"--artifact-class",
|
|
24
|
+
choices=["product", "fixture", "all"],
|
|
25
|
+
default="all",
|
|
26
|
+
help="要扫描的产物类别根目录。默认同时处理 product 和 fixture。",
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"--write",
|
|
30
|
+
action="store_true",
|
|
31
|
+
help="将刷新结果真正写回文件。默认仅输出预演摘要。",
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--format",
|
|
35
|
+
choices=["json", "summary"],
|
|
36
|
+
default="json",
|
|
37
|
+
help="输出格式。summary 更适合维护与发布检查。",
|
|
38
|
+
)
|
|
39
|
+
return parser
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def read_text(path: Path) -> str:
|
|
43
|
+
return path.read_text(encoding="utf-8") if path.exists() else ""
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def has_review_policy_fields(path: Path) -> bool:
|
|
47
|
+
text = read_text(path)
|
|
48
|
+
return (
|
|
49
|
+
("Review action kind:" in text or "审核动作类型:" in text)
|
|
50
|
+
and ("Review fallback stage:" in text or "审核回退阶段:" in text)
|
|
51
|
+
and ("Review policy reason:" in text or "审核策略原因:" in text)
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def has_legacy_review_text(path: Path) -> bool:
|
|
56
|
+
text = read_text(path)
|
|
57
|
+
legacy_markers = [
|
|
58
|
+
"## 5. Review Decision",
|
|
59
|
+
"## 4. Review Decision",
|
|
60
|
+
"Requested decision:",
|
|
61
|
+
"Final decision:",
|
|
62
|
+
"Outcome:",
|
|
63
|
+
"Evidence source:",
|
|
64
|
+
"Risk classes:",
|
|
65
|
+
"Execution mode:",
|
|
66
|
+
"Execution performed:",
|
|
67
|
+
"Reviewed task_id:",
|
|
68
|
+
"Reviewed step_number:",
|
|
69
|
+
"Review action kind:",
|
|
70
|
+
"Review fallback stage:",
|
|
71
|
+
"Review policy reason:",
|
|
72
|
+
"Next step:",
|
|
73
|
+
"- accepted",
|
|
74
|
+
"- changes-requested",
|
|
75
|
+
]
|
|
76
|
+
return any(marker in text for marker in legacy_markers)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def find_audit_candidates(artifact_class: str) -> list[Path]:
|
|
80
|
+
root = execution_root(artifact_class)
|
|
81
|
+
if not root.exists():
|
|
82
|
+
return []
|
|
83
|
+
return sorted(root.glob("*.json"))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def should_scan_artifact_class(value: str, artifact_class: str) -> bool:
|
|
87
|
+
if value == "all":
|
|
88
|
+
return True
|
|
89
|
+
return value == artifact_class
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def collect_refresh_candidates(scan_target: str) -> list[dict[str, Any]]:
|
|
93
|
+
candidates: list[dict[str, Any]] = []
|
|
94
|
+
for artifact_class in ("product", "fixture"):
|
|
95
|
+
if not should_scan_artifact_class(scan_target, artifact_class):
|
|
96
|
+
continue
|
|
97
|
+
|
|
98
|
+
for audit_path in find_audit_candidates(artifact_class):
|
|
99
|
+
try:
|
|
100
|
+
audit = load_json(audit_path)
|
|
101
|
+
artifact_type, artifact_path = resolve_artifact_path(audit)
|
|
102
|
+
except Exception:
|
|
103
|
+
continue
|
|
104
|
+
|
|
105
|
+
if not artifact_path.exists():
|
|
106
|
+
continue
|
|
107
|
+
|
|
108
|
+
review = extract_review_metadata(artifact_path)
|
|
109
|
+
decision = str(review.get("decision", "")).strip()
|
|
110
|
+
if decision not in {"accepted", "changes-requested"}:
|
|
111
|
+
continue
|
|
112
|
+
if has_review_policy_fields(artifact_path) and not has_legacy_review_text(artifact_path):
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
candidates.append(
|
|
116
|
+
{
|
|
117
|
+
"artifact_class": artifact_class,
|
|
118
|
+
"artifact_type": artifact_type,
|
|
119
|
+
"artifact_path": artifact_path,
|
|
120
|
+
"audit_path": audit_path,
|
|
121
|
+
"decision": decision,
|
|
122
|
+
"review": review,
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
return candidates
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def refresh_candidates(candidates: list[dict[str, Any]], write: bool) -> dict[str, Any]:
|
|
129
|
+
refreshed: list[dict[str, str]] = []
|
|
130
|
+
failed: list[dict[str, str]] = []
|
|
131
|
+
|
|
132
|
+
for item in candidates:
|
|
133
|
+
artifact_path = item["artifact_path"]
|
|
134
|
+
audit_path = item["audit_path"]
|
|
135
|
+
decision = item["decision"]
|
|
136
|
+
try:
|
|
137
|
+
if write:
|
|
138
|
+
write_review(
|
|
139
|
+
audit_path=audit_path,
|
|
140
|
+
decision=decision,
|
|
141
|
+
risks=[],
|
|
142
|
+
next_step="",
|
|
143
|
+
force=True,
|
|
144
|
+
)
|
|
145
|
+
audit = load_json(audit_path)
|
|
146
|
+
artifact_type, resolved_artifact_path = resolve_artifact_path(audit)
|
|
147
|
+
review = extract_review_metadata(artifact_path)
|
|
148
|
+
refreshed.append(
|
|
149
|
+
{
|
|
150
|
+
"artifact_class": str(item["artifact_class"]),
|
|
151
|
+
"artifact_type": artifact_type,
|
|
152
|
+
"artifact_path": str(resolved_artifact_path),
|
|
153
|
+
"audit_path": str(audit_path),
|
|
154
|
+
"decision": decision,
|
|
155
|
+
"review_action_kind": str(review.get("action_kind", "")),
|
|
156
|
+
"review_fallback_stage": str(review.get("fallback_stage", "")),
|
|
157
|
+
"review_policy_reason": str(review.get("policy_reason", "")),
|
|
158
|
+
"written": "yes" if write else "no",
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
except Exception as error:
|
|
162
|
+
failed.append(
|
|
163
|
+
{
|
|
164
|
+
"artifact_path": str(artifact_path),
|
|
165
|
+
"audit_path": str(audit_path),
|
|
166
|
+
"error": str(error),
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
"refreshed": refreshed,
|
|
172
|
+
"failed": failed,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def main() -> int:
|
|
177
|
+
parser = build_parser()
|
|
178
|
+
args = parser.parse_args()
|
|
179
|
+
|
|
180
|
+
scan_target = normalize_artifact_class(args.artifact_class) if args.artifact_class != "all" else "all"
|
|
181
|
+
candidates = collect_refresh_candidates(scan_target)
|
|
182
|
+
result = refresh_candidates(candidates, write=args.write)
|
|
183
|
+
|
|
184
|
+
output = {
|
|
185
|
+
"success": True,
|
|
186
|
+
"scan_target": args.artifact_class,
|
|
187
|
+
"write": bool(args.write),
|
|
188
|
+
"candidate_count": len(candidates),
|
|
189
|
+
"refreshed_count": len(result["refreshed"]),
|
|
190
|
+
"failed_count": len(result["failed"]),
|
|
191
|
+
"refreshed": result["refreshed"],
|
|
192
|
+
"failed": result["failed"],
|
|
193
|
+
}
|
|
194
|
+
if args.format == "summary":
|
|
195
|
+
lines = [
|
|
196
|
+
"CodeCGC Review Policy Refresh Audit",
|
|
197
|
+
f"- 范围: {args.artifact_class}",
|
|
198
|
+
f"- 写入模式: {'是' if args.write else '否'}",
|
|
199
|
+
f"- 候选数: {len(candidates)}",
|
|
200
|
+
f"- 刷新成功数: {len(result['refreshed'])}",
|
|
201
|
+
f"- 失败数: {len(result['failed'])}",
|
|
202
|
+
]
|
|
203
|
+
if result["refreshed"]:
|
|
204
|
+
for item in result["refreshed"]:
|
|
205
|
+
lines.append(
|
|
206
|
+
"- 已识别: "
|
|
207
|
+
+ f"{item.get('artifact_path', '')} "
|
|
208
|
+
+ f"[{item.get('decision', '')} / {item.get('review_action_kind', '')} / {item.get('review_fallback_stage', '')}]"
|
|
209
|
+
)
|
|
210
|
+
if result["failed"]:
|
|
211
|
+
for item in result["failed"]:
|
|
212
|
+
lines.append(
|
|
213
|
+
"- 失败: "
|
|
214
|
+
+ f"{item.get('artifact_path', '')} ({item.get('error', '')})"
|
|
215
|
+
)
|
|
216
|
+
print("\n".join(lines))
|
|
217
|
+
else:
|
|
218
|
+
print(json.dumps(output, ensure_ascii=False, indent=2))
|
|
219
|
+
return 0
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
if __name__ == "__main__":
|
|
223
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from codecgc_console_io import configure_utf8_stdio
|
|
6
|
+
from codecgc_console_io import print_json
|
|
7
|
+
from codecgc_review_control import evaluate_review
|
|
8
|
+
from write_codecgc_review import load_json
|
|
9
|
+
from write_codecgc_review import render_review_decision
|
|
10
|
+
from write_codecgc_review import write_review
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
14
|
+
parser = argparse.ArgumentParser(
|
|
15
|
+
description="CodeCGC 的高层审核入口:读取 audit、生成审核结论并回写到工作流产物。"
|
|
16
|
+
)
|
|
17
|
+
parser.add_argument("--audit-file", required=True, help="执行审计 JSON 文件路径。")
|
|
18
|
+
parser.add_argument(
|
|
19
|
+
"--decision",
|
|
20
|
+
required=True,
|
|
21
|
+
choices=["accepted", "changes-requested"],
|
|
22
|
+
help="请求的审核决策:accepted 表示希望通过,changes-requested 表示要求修改。",
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument("--risk", action="append", default=[], help="可选:补充剩余风险说明。")
|
|
25
|
+
parser.add_argument("--next-step", default="", help="可选:补充建议的下一步说明。")
|
|
26
|
+
parser.add_argument("--force", action="store_true", help="允许覆盖已有审核内容。")
|
|
27
|
+
return parser
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def main() -> int:
|
|
31
|
+
configure_utf8_stdio()
|
|
32
|
+
parser = build_parser()
|
|
33
|
+
args = parser.parse_args()
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
audit = load_json(Path(args.audit_file))
|
|
37
|
+
values = evaluate_review(audit, args.decision, args.risk, args.next_step)
|
|
38
|
+
writeback = write_review(
|
|
39
|
+
audit_path=Path(args.audit_file),
|
|
40
|
+
decision=args.decision,
|
|
41
|
+
risks=args.risk,
|
|
42
|
+
next_step=args.next_step,
|
|
43
|
+
force=args.force,
|
|
44
|
+
)
|
|
45
|
+
result = {
|
|
46
|
+
"success": True,
|
|
47
|
+
"audit_file": args.audit_file,
|
|
48
|
+
"requested_decision": args.decision,
|
|
49
|
+
"final_decision": values["final_decision"],
|
|
50
|
+
"accepted": values["accepted"],
|
|
51
|
+
"review_state": values["review_state"],
|
|
52
|
+
"recommended_command": values["recommended_command"],
|
|
53
|
+
"recommended_action_kind": values.get("recommended_action_kind", ""),
|
|
54
|
+
"fallback_stage": values.get("fallback_stage", ""),
|
|
55
|
+
"policy_reason": values.get("policy_reason", ""),
|
|
56
|
+
"risk_classes": values.get("risk_classes", []),
|
|
57
|
+
"evidence_confidence": values.get("evidence_confidence", ""),
|
|
58
|
+
"scope_check": values["scope_check"],
|
|
59
|
+
"executor_check": values["executor_check"],
|
|
60
|
+
"verification": values["verification"],
|
|
61
|
+
"remaining_risk": values["remaining_risk"],
|
|
62
|
+
"next_step": values["next_step"],
|
|
63
|
+
"failure_reasons": values["failure_reasons"],
|
|
64
|
+
"writeback": writeback,
|
|
65
|
+
}
|
|
66
|
+
result["summary"] = {
|
|
67
|
+
"human_summary": (
|
|
68
|
+
f"本次审核已完成,最终决策为{render_review_decision(str(values['final_decision']))}。"
|
|
69
|
+
if str(values["final_decision"]).strip()
|
|
70
|
+
else "本次审核已完成。"
|
|
71
|
+
),
|
|
72
|
+
"recommended_command": values["recommended_command"],
|
|
73
|
+
"next": values["next_step"],
|
|
74
|
+
"review_state": values["review_state"],
|
|
75
|
+
"recommended_action_kind": values.get("recommended_action_kind", ""),
|
|
76
|
+
"fallback_stage": values.get("fallback_stage", ""),
|
|
77
|
+
"accepted": values["accepted"],
|
|
78
|
+
}
|
|
79
|
+
except Exception as error:
|
|
80
|
+
print_json({"success": False, "error": str(error)}, file=sys.stderr)
|
|
81
|
+
return 1
|
|
82
|
+
|
|
83
|
+
print_json(result)
|
|
84
|
+
return 0
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
if __name__ == "__main__":
|
|
88
|
+
raise SystemExit(main())
|