@hunyed15/codecgc 0.1.6 → 0.1.8
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 +58 -57
- package/INSTALLATION.md +117 -484
- package/README.md +118 -150
- package/bin/cgc-external-status.js +4 -0
- package/bin/cgc-start.js +4 -0
- package/bin/codecgc.js +141 -20
- package/codecgc/compound/codecgc-capability-matrix.md +37 -0
- package/codecgc/reference/README.md +69 -0
- package/codecgc/reference/maintainer-guide.md +93 -0
- package/codecgc/reference/mcp-tool-surface.md +112 -0
- package/codecgc/reference/onboarding.md +69 -0
- package/codecgc/reference/operation-guide.md +29 -23
- package/codecgc/reference/path-contract.md +53 -0
- package/codecgc/reference/policy-routing.md +57 -0
- package/codecgc/reference/project-structure.md +80 -0
- package/codecgc/reference/quickstart.md +108 -0
- package/codecgc/reference/real-workflow-loop.md +123 -0
- package/codecgc/reference/recovery-loop.md +109 -0
- package/codecgc/reference/release-maintenance-playbook.md +4 -1
- package/codecgc/reference/troubleshooting.md +112 -0
- package/codecgc/roadmap/codecgc-release-maintenance/delivery-plan.md +49 -0
- package/codecgc/roadmap/codecgc-release-maintenance/overview.md +41 -0
- package/codecgc/roadmap/codecgc-release-maintenance/phases.md +84 -0
- package/codecgcmcp/README.md +57 -11
- package/codecgcmcp/src/codecgcmcp/server.py +164 -26
- package/codexmcp/src/codexmcp/server.py +32 -26
- package/geminimcp/src/geminimcp/server.py +22 -14
- package/model-routing.yaml +31 -6
- package/package.json +11 -4
- package/scripts/audit_codecgc_external_capabilities.py +83 -4
- package/scripts/audit_codecgc_historical_audits.py +42 -2
- package/scripts/audit_codecgc_package_runtime.py +73 -4
- package/scripts/audit_codecgc_release_readiness.py +55 -3
- package/scripts/audit_codecgc_workflow_history.py +8 -5
- package/scripts/build_codecgc_task.py +62 -45
- package/scripts/codecgc_artifact_roots.py +8 -40
- package/scripts/codecgc_console_io.py +3 -45
- package/scripts/codecgc_executor_registry.py +4 -54
- package/scripts/codecgc_path_contract.py +7 -0
- package/scripts/codecgc_policy.py +275 -0
- package/scripts/codecgc_routing_paths.py +3 -16
- package/scripts/codecgc_routing_template.py +11 -135
- package/scripts/codecgc_runtime/__init__.py +1 -0
- package/scripts/codecgc_runtime/artifacts.py +42 -0
- package/scripts/codecgc_runtime/console.py +45 -0
- package/scripts/codecgc_runtime/executor_registry.py +55 -0
- package/scripts/codecgc_runtime/mcp_config.py +72 -0
- package/scripts/codecgc_runtime/path_contract.py +123 -0
- package/scripts/codecgc_runtime/paths.py +22 -0
- package/scripts/codecgc_runtime/routing_paths.py +16 -0
- package/scripts/codecgc_runtime/routing_template.py +169 -0
- package/scripts/codecgc_runtime/workflow_runtime.py +72 -0
- package/scripts/codecgc_runtime_paths.py +3 -22
- package/scripts/codecgc_step_control.py +3 -2
- package/scripts/codecgc_workflow_runtime.py +3 -71
- package/scripts/entry_codecgc_workflow.py +4 -0
- package/scripts/install_codecgc.py +490 -21
- package/scripts/normalize_codecgc_audits.py +5 -3
- package/scripts/postinstall_codecgc.js +6 -56
- package/scripts/review_codecgc_workflow.py +6 -3
- package/scripts/route_codecgc_workflow.py +67 -36
- package/scripts/run_codecgc_build.py +28 -0
- package/scripts/run_codecgc_fix.py +28 -0
- package/scripts/run_codecgc_task.py +5 -2
- package/scripts/run_codecgc_test.py +28 -0
- package/scripts/sync_codecgc_mcp_config.py +4 -54
- package/scripts/write_codecgc_review.py +7 -3
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import yaml
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
DEFAULT_FRONTEND_PATHS = [
|
|
9
|
+
"apps/web/**",
|
|
10
|
+
"src/components/**",
|
|
11
|
+
"src/pages/**",
|
|
12
|
+
"src/app/**",
|
|
13
|
+
"src/styles/**",
|
|
14
|
+
"web/**",
|
|
15
|
+
"frontend/**",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
DEFAULT_BACKEND_PATHS = [
|
|
19
|
+
"apps/api/**",
|
|
20
|
+
"server/**",
|
|
21
|
+
"src/server/**",
|
|
22
|
+
"src/services/**",
|
|
23
|
+
"src/repositories/**",
|
|
24
|
+
"backend/**",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
DEFAULT_SHARED_PATHS = [
|
|
28
|
+
"packages/shared/**",
|
|
29
|
+
"src/shared/**",
|
|
30
|
+
"src/lib/**",
|
|
31
|
+
"src/types/**",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
DEFAULT_ORCHESTRATION_PATHS = [
|
|
35
|
+
"codecgc/**",
|
|
36
|
+
".claude/commands/**",
|
|
37
|
+
".claude/settings.json",
|
|
38
|
+
".mcp.json",
|
|
39
|
+
"model-routing.yaml",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
DEFAULT_DOCS_PATHS = [
|
|
43
|
+
"README.md",
|
|
44
|
+
"INSTALLATION.md",
|
|
45
|
+
"docs/**",
|
|
46
|
+
"CHANGELOG.md",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
DEFAULT_BACKEND_TEST_PATHS = [
|
|
50
|
+
"apps/api/*.test.*",
|
|
51
|
+
"apps/api/*.spec.*",
|
|
52
|
+
"apps/api/**/*.test.*",
|
|
53
|
+
"apps/api/**/*.spec.*",
|
|
54
|
+
"tests/backend/**",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
DEFAULT_FRONTEND_TEST_PATHS = [
|
|
58
|
+
"apps/web/*.test.*",
|
|
59
|
+
"apps/web/*.spec.*",
|
|
60
|
+
"apps/web/**/*.test.*",
|
|
61
|
+
"apps/web/**/*.spec.*",
|
|
62
|
+
"tests/frontend/**",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
DEFAULT_RULES = {
|
|
66
|
+
"claude_allowed_owners": ["orchestration", "docs"],
|
|
67
|
+
"backend_executor": "codexmcp",
|
|
68
|
+
"frontend_executor": "geminimcp",
|
|
69
|
+
"shared_policy": "split-first",
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _render_list_block(name: str, items: list[str]) -> list[str]:
|
|
74
|
+
lines = [f"{name}:"]
|
|
75
|
+
for item in items:
|
|
76
|
+
lines.append(f' - "{item}"')
|
|
77
|
+
return lines
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _render_nested_list_block(name: str, groups: dict[str, list[str]]) -> list[str]:
|
|
81
|
+
lines = [f"{name}:"]
|
|
82
|
+
for group_name, items in groups.items():
|
|
83
|
+
lines.append(f" {group_name}:")
|
|
84
|
+
for item in items:
|
|
85
|
+
lines.append(f' - "{item}"')
|
|
86
|
+
return lines
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _render_rules_block() -> list[str]:
|
|
90
|
+
lines = ["rules:"]
|
|
91
|
+
for key, value in DEFAULT_RULES.items():
|
|
92
|
+
if isinstance(value, list):
|
|
93
|
+
lines.append(f" {key}:")
|
|
94
|
+
lines.extend(f' - "{item}"' for item in value)
|
|
95
|
+
else:
|
|
96
|
+
lines.append(f' {key}: "{value}"')
|
|
97
|
+
return lines
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def render_default_routing_yaml() -> str:
|
|
101
|
+
lines: list[str] = [
|
|
102
|
+
"version: 2",
|
|
103
|
+
"",
|
|
104
|
+
*_render_list_block("orchestration_paths", DEFAULT_ORCHESTRATION_PATHS),
|
|
105
|
+
"",
|
|
106
|
+
*_render_list_block("docs_paths", DEFAULT_DOCS_PATHS),
|
|
107
|
+
"",
|
|
108
|
+
*_render_list_block("frontend_paths", DEFAULT_FRONTEND_PATHS),
|
|
109
|
+
"",
|
|
110
|
+
*_render_list_block("backend_paths", DEFAULT_BACKEND_PATHS),
|
|
111
|
+
"",
|
|
112
|
+
*_render_nested_list_block(
|
|
113
|
+
"test_paths",
|
|
114
|
+
{
|
|
115
|
+
"frontend": DEFAULT_FRONTEND_TEST_PATHS,
|
|
116
|
+
"backend": DEFAULT_BACKEND_TEST_PATHS,
|
|
117
|
+
},
|
|
118
|
+
),
|
|
119
|
+
"",
|
|
120
|
+
*_render_list_block("shared_paths", DEFAULT_SHARED_PATHS),
|
|
121
|
+
"",
|
|
122
|
+
*_render_rules_block(),
|
|
123
|
+
"",
|
|
124
|
+
]
|
|
125
|
+
return "\n".join(lines)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _normalize_line_endings(text: str) -> str:
|
|
129
|
+
return text.replace("\r\n", "\n").replace("\r", "\n")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _extract_list_block(lines: list[str], block_name: str) -> list[str]:
|
|
133
|
+
items: list[str] = []
|
|
134
|
+
inside = False
|
|
135
|
+
for line in lines:
|
|
136
|
+
stripped = line.strip()
|
|
137
|
+
if not inside:
|
|
138
|
+
if stripped == f"{block_name}:":
|
|
139
|
+
inside = True
|
|
140
|
+
continue
|
|
141
|
+
|
|
142
|
+
if line and not line.startswith(" "):
|
|
143
|
+
break
|
|
144
|
+
if stripped.startswith("- "):
|
|
145
|
+
value = stripped[2:].strip()
|
|
146
|
+
if len(value) >= 2 and value[0] == value[-1] and value[0] in {'"', "'"}:
|
|
147
|
+
value = value[1:-1]
|
|
148
|
+
if value:
|
|
149
|
+
items.append(value)
|
|
150
|
+
return items
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def merge_routing_template(existing_text: str) -> str:
|
|
154
|
+
if existing_text.strip():
|
|
155
|
+
try:
|
|
156
|
+
data = yaml.safe_load(existing_text)
|
|
157
|
+
except yaml.YAMLError:
|
|
158
|
+
data = None
|
|
159
|
+
if isinstance(data, dict) and int(data.get("version", 0) or 0) == 2:
|
|
160
|
+
return _normalize_line_endings(existing_text).rstrip() + "\n"
|
|
161
|
+
return render_default_routing_yaml()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def sync_workspace_routing_file(target_path: Path) -> Path:
|
|
165
|
+
existing_text = target_path.read_text(encoding="utf-8") if target_path.exists() else ""
|
|
166
|
+
merged_text = merge_routing_template(existing_text)
|
|
167
|
+
target_path.parent.mkdir(parents=True, exist_ok=True)
|
|
168
|
+
target_path.write_text(merged_text, encoding="utf-8")
|
|
169
|
+
return target_path
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from .paths import PACKAGE_ROOT
|
|
10
|
+
from .paths import PROJECT_ROOT
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
WORKSPACE = PACKAGE_ROOT
|
|
14
|
+
PROJECT_WORKSPACE = PROJECT_ROOT
|
|
15
|
+
SCRIPTS_DIR = WORKSPACE / "scripts"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_script_command(script_name: str, *args: str) -> list[str]:
|
|
19
|
+
return [sys.executable, str(SCRIPTS_DIR / script_name), *args]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def parse_json_text(text: str) -> dict[str, Any]:
|
|
23
|
+
stripped = text.strip()
|
|
24
|
+
if not stripped:
|
|
25
|
+
raise ValueError("Command produced no JSON output.")
|
|
26
|
+
return json.loads(stripped)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def run_json_script(script_name: str, *args: str) -> dict[str, Any]:
|
|
30
|
+
command = build_script_command(script_name, *args)
|
|
31
|
+
|
|
32
|
+
env = os.environ.copy()
|
|
33
|
+
env["CODECGC_WORKSPACE_ROOT"] = str(PROJECT_WORKSPACE)
|
|
34
|
+
|
|
35
|
+
completed = subprocess.run(
|
|
36
|
+
command,
|
|
37
|
+
cwd=PROJECT_WORKSPACE,
|
|
38
|
+
stdin=subprocess.DEVNULL,
|
|
39
|
+
capture_output=True,
|
|
40
|
+
text=True,
|
|
41
|
+
encoding="utf-8",
|
|
42
|
+
errors="replace",
|
|
43
|
+
env=env,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
stdout = completed.stdout.strip()
|
|
47
|
+
stderr = completed.stderr.strip()
|
|
48
|
+
|
|
49
|
+
if completed.returncode == 0:
|
|
50
|
+
if not stdout:
|
|
51
|
+
return {"success": True}
|
|
52
|
+
return parse_json_text(stdout)
|
|
53
|
+
|
|
54
|
+
for candidate in (stdout, stderr):
|
|
55
|
+
if not candidate:
|
|
56
|
+
continue
|
|
57
|
+
try:
|
|
58
|
+
parsed = parse_json_text(candidate)
|
|
59
|
+
except Exception:
|
|
60
|
+
continue
|
|
61
|
+
if isinstance(parsed, dict):
|
|
62
|
+
parsed.setdefault("success", False)
|
|
63
|
+
parsed.setdefault("returncode", completed.returncode)
|
|
64
|
+
return parsed
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
"success": False,
|
|
68
|
+
"returncode": completed.returncode,
|
|
69
|
+
"stdout": stdout,
|
|
70
|
+
"stderr": stderr,
|
|
71
|
+
"error": f"{script_name} failed with exit code {completed.returncode}.",
|
|
72
|
+
}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
PACKAGE_ROOT = Path(__file__).resolve().parents[1]
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def resolve_workspace_root(override_workspace: str = "") -> Path:
|
|
11
|
-
explicit = str(override_workspace or "").strip()
|
|
12
|
-
if explicit:
|
|
13
|
-
return Path(explicit).expanduser().resolve()
|
|
14
|
-
|
|
15
|
-
configured = os.environ.get("CODECGC_WORKSPACE_ROOT", "").strip()
|
|
16
|
-
if configured:
|
|
17
|
-
return Path(configured).expanduser().resolve()
|
|
18
|
-
|
|
19
|
-
return Path.cwd().resolve()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
PROJECT_ROOT = resolve_workspace_root()
|
|
1
|
+
from codecgc_runtime.paths import PACKAGE_ROOT
|
|
2
|
+
from codecgc_runtime.paths import PROJECT_ROOT
|
|
3
|
+
from codecgc_runtime.paths import resolve_workspace_root
|
|
@@ -34,9 +34,8 @@ def is_executable_codecgc_block(codecgc: Any) -> bool:
|
|
|
34
34
|
if any(is_placeholder_path(path) for path in target_paths):
|
|
35
35
|
return False
|
|
36
36
|
|
|
37
|
-
task_id = str(codecgc.get("task_id", "")).strip()
|
|
38
37
|
task_summary = str(codecgc.get("task_summary", "")).strip()
|
|
39
|
-
return bool(
|
|
38
|
+
return bool(task_summary)
|
|
40
39
|
|
|
41
40
|
|
|
42
41
|
def is_test_codecgc_block(codecgc: Any) -> bool:
|
|
@@ -87,6 +86,7 @@ def select_next_executable_step(checklist_path: Path) -> dict[str, Any]:
|
|
|
87
86
|
"task_id": str(codecgc.get("task_id", "")),
|
|
88
87
|
"action": str(step.get("action", "")),
|
|
89
88
|
"kind": str(codecgc.get("kind", "")),
|
|
89
|
+
"step_type": str(codecgc.get("step_type", "")),
|
|
90
90
|
"target_paths": codecgc.get("target_paths", []),
|
|
91
91
|
"task_summary": str(codecgc.get("task_summary", "")),
|
|
92
92
|
"artifact_type": resolve_artifact_type(data),
|
|
@@ -107,6 +107,7 @@ def get_step_metadata(checklist_path: Path, step_number: int) -> dict[str, Any]:
|
|
|
107
107
|
"task_id": str(codecgc.get("task_id", "")),
|
|
108
108
|
"action": str(step.get("action", "")) if isinstance(step, dict) else "",
|
|
109
109
|
"kind": str(codecgc.get("kind", "")),
|
|
110
|
+
"step_type": str(codecgc.get("step_type", "")),
|
|
110
111
|
"target_paths": codecgc.get("target_paths", []),
|
|
111
112
|
"task_summary": str(codecgc.get("task_summary", "")),
|
|
112
113
|
"artifact_type": resolve_artifact_type(data),
|
|
@@ -1,71 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import sys
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
from typing import Any
|
|
7
|
-
|
|
8
|
-
from codecgc_runtime_paths import PACKAGE_ROOT
|
|
9
|
-
from codecgc_runtime_paths import PROJECT_ROOT
|
|
10
|
-
|
|
11
|
-
WORKSPACE = PACKAGE_ROOT
|
|
12
|
-
PROJECT_WORKSPACE = PROJECT_ROOT
|
|
13
|
-
SCRIPTS_DIR = WORKSPACE / "scripts"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def build_script_command(script_name: str, *args: str) -> list[str]:
|
|
17
|
-
return [sys.executable, str(SCRIPTS_DIR / script_name), *args]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def parse_json_text(text: str) -> dict[str, Any]:
|
|
21
|
-
stripped = text.strip()
|
|
22
|
-
if not stripped:
|
|
23
|
-
raise ValueError("Command produced no JSON output.")
|
|
24
|
-
return json.loads(stripped)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def run_json_script(script_name: str, *args: str) -> dict[str, Any]:
|
|
28
|
-
command = build_script_command(script_name, *args)
|
|
29
|
-
|
|
30
|
-
# 设置环境变量,确保子进程使用正确的工作目录
|
|
31
|
-
env = os.environ.copy()
|
|
32
|
-
env["CODECGC_WORKSPACE_ROOT"] = str(PROJECT_WORKSPACE)
|
|
33
|
-
|
|
34
|
-
completed = subprocess.run(
|
|
35
|
-
command,
|
|
36
|
-
cwd=PROJECT_WORKSPACE,
|
|
37
|
-
stdin=subprocess.DEVNULL,
|
|
38
|
-
capture_output=True,
|
|
39
|
-
text=True,
|
|
40
|
-
encoding="utf-8",
|
|
41
|
-
errors="replace",
|
|
42
|
-
env=env, # 传递环境变量
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
stdout = completed.stdout.strip()
|
|
46
|
-
stderr = completed.stderr.strip()
|
|
47
|
-
|
|
48
|
-
if completed.returncode == 0:
|
|
49
|
-
if not stdout:
|
|
50
|
-
return {"success": True}
|
|
51
|
-
return parse_json_text(stdout)
|
|
52
|
-
|
|
53
|
-
for candidate in (stdout, stderr):
|
|
54
|
-
if not candidate:
|
|
55
|
-
continue
|
|
56
|
-
try:
|
|
57
|
-
parsed = parse_json_text(candidate)
|
|
58
|
-
except Exception:
|
|
59
|
-
continue
|
|
60
|
-
if isinstance(parsed, dict):
|
|
61
|
-
parsed.setdefault("success", False)
|
|
62
|
-
parsed.setdefault("returncode", completed.returncode)
|
|
63
|
-
return parsed
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
"success": False,
|
|
67
|
-
"returncode": completed.returncode,
|
|
68
|
-
"stdout": stdout,
|
|
69
|
-
"stderr": stderr,
|
|
70
|
-
"error": f"{script_name} failed with exit code {completed.returncode}.",
|
|
71
|
-
}
|
|
1
|
+
from codecgc_runtime.workflow_runtime import build_script_command
|
|
2
|
+
from codecgc_runtime.workflow_runtime import parse_json_text
|
|
3
|
+
from codecgc_runtime.workflow_runtime import run_json_script
|
|
@@ -3033,6 +3033,10 @@ def run_existing_mode(args: argparse.Namespace, explain_only: bool) -> dict[str,
|
|
|
3033
3033
|
"dispatched": False,
|
|
3034
3034
|
"dispatch_result": None,
|
|
3035
3035
|
}
|
|
3036
|
+
if matches_command(recommended_command, "cgc-plan") and isinstance(route.get("replan_payload"), dict):
|
|
3037
|
+
merged_replan_payload = dict(replan_payload)
|
|
3038
|
+
merged_replan_payload.update(route.get("replan_payload", {}))
|
|
3039
|
+
result["replan_payload"] = merged_replan_payload
|
|
3036
3040
|
if explain_only or not effective_auto_dispatch:
|
|
3037
3041
|
result["next"] = build_user_facing_next(result)
|
|
3038
3042
|
result["human_summary"] = build_existing_mode_human_summary(result)
|