@hunyed15/codecgc 0.1.7 → 0.1.9

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 (71) hide show
  1. package/.claude/hooks/route-edit.ps1 +58 -57
  2. package/INSTALLATION.md +122 -484
  3. package/README.md +124 -149
  4. package/bin/cgc-external-status.js +4 -0
  5. package/bin/cgc-start.js +4 -0
  6. package/bin/codecgc.js +141 -20
  7. package/codecgc/compound/codecgc-capability-matrix.md +37 -0
  8. package/codecgc/reference/README.md +69 -0
  9. package/codecgc/reference/execution-model.md +3 -1
  10. package/codecgc/reference/maintainer-guide.md +93 -0
  11. package/codecgc/reference/mcp-tool-surface.md +112 -0
  12. package/codecgc/reference/onboarding.md +69 -0
  13. package/codecgc/reference/operation-guide.md +29 -23
  14. package/codecgc/reference/path-contract.md +53 -0
  15. package/codecgc/reference/policy-routing.md +58 -0
  16. package/codecgc/reference/project-structure.md +87 -0
  17. package/codecgc/reference/quickstart.md +110 -0
  18. package/codecgc/reference/real-workflow-loop.md +123 -0
  19. package/codecgc/reference/recovery-loop.md +109 -0
  20. package/codecgc/reference/release-maintenance-playbook.md +4 -1
  21. package/codecgc/reference/troubleshooting.md +114 -0
  22. package/codecgc/roadmap/codecgc-release-maintenance/delivery-plan.md +49 -0
  23. package/codecgc/roadmap/codecgc-release-maintenance/overview.md +41 -0
  24. package/codecgc/roadmap/codecgc-release-maintenance/phases.md +84 -0
  25. package/codecgc/templates/claude/settings.local.json +27 -0
  26. package/codecgc/templates/codex/codecgcrc.json +22 -0
  27. package/codecgc/templates/gemini/codecgc-policy.toml +47 -0
  28. package/codecgcmcp/README.md +57 -11
  29. package/codecgcmcp/src/codecgcmcp/server.py +164 -26
  30. package/codexmcp/src/codexmcp/server.py +45 -0
  31. package/geminimcp/src/geminimcp/server.py +106 -24
  32. package/model-routing.yaml +31 -6
  33. package/package.json +12 -4
  34. package/scripts/audit_codecgc_external_capabilities.py +83 -4
  35. package/scripts/audit_codecgc_historical_audits.py +42 -2
  36. package/scripts/audit_codecgc_package_runtime.py +76 -4
  37. package/scripts/audit_codecgc_release_readiness.py +55 -3
  38. package/scripts/audit_codecgc_workflow_history.py +8 -5
  39. package/scripts/build_codecgc_task.py +69 -45
  40. package/scripts/codecgc_artifact_roots.py +8 -40
  41. package/scripts/codecgc_console_io.py +3 -45
  42. package/scripts/codecgc_executor_registry.py +4 -54
  43. package/scripts/codecgc_path_contract.py +7 -0
  44. package/scripts/codecgc_policy.py +447 -0
  45. package/scripts/codecgc_routing_paths.py +3 -16
  46. package/scripts/codecgc_routing_template.py +11 -135
  47. package/scripts/codecgc_runtime/__init__.py +1 -0
  48. package/scripts/codecgc_runtime/artifacts.py +42 -0
  49. package/scripts/codecgc_runtime/console.py +45 -0
  50. package/scripts/codecgc_runtime/executor_registry.py +55 -0
  51. package/scripts/codecgc_runtime/mcp_config.py +72 -0
  52. package/scripts/codecgc_runtime/path_contract.py +123 -0
  53. package/scripts/codecgc_runtime/paths.py +22 -0
  54. package/scripts/codecgc_runtime/routing_paths.py +16 -0
  55. package/scripts/codecgc_runtime/routing_template.py +171 -0
  56. package/scripts/codecgc_runtime/workflow_runtime.py +72 -0
  57. package/scripts/codecgc_runtime_paths.py +3 -22
  58. package/scripts/codecgc_step_control.py +3 -2
  59. package/scripts/codecgc_workflow_runtime.py +3 -71
  60. package/scripts/entry_codecgc_workflow.py +4 -0
  61. package/scripts/install_codecgc.py +560 -32
  62. package/scripts/normalize_codecgc_audits.py +5 -3
  63. package/scripts/postinstall_codecgc.js +6 -56
  64. package/scripts/review_codecgc_workflow.py +6 -3
  65. package/scripts/route_codecgc_workflow.py +67 -36
  66. package/scripts/run_codecgc_build.py +28 -0
  67. package/scripts/run_codecgc_fix.py +28 -0
  68. package/scripts/run_codecgc_task.py +5 -2
  69. package/scripts/run_codecgc_test.py +28 -0
  70. package/scripts/sync_codecgc_mcp_config.py +4 -54
  71. package/scripts/write_codecgc_review.py +7 -3
@@ -0,0 +1,45 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import sys
5
+ from typing import Any
6
+
7
+
8
+ def configure_utf8_stdio() -> None:
9
+ for stream_name in ("stdout", "stderr"):
10
+ stream = getattr(sys, stream_name, None)
11
+ if stream is None:
12
+ continue
13
+ reconfigure = getattr(stream, "reconfigure", None)
14
+ if callable(reconfigure):
15
+ try:
16
+ reconfigure(encoding="utf-8", errors="replace")
17
+ except Exception:
18
+ pass
19
+
20
+
21
+ def print_json(payload: dict[str, Any], *, file: Any | None = None) -> None:
22
+ target = file or sys.stdout
23
+ text = json.dumps(payload, ensure_ascii=False, indent=2)
24
+ target.write(text)
25
+ target.write("\n")
26
+
27
+
28
+ def render_summary_block(title: str, base_lines: list[str], next_actions: list[str]) -> str:
29
+ lines = [title, *base_lines]
30
+ unique_actions: list[str] = []
31
+ seen: set[str] = set()
32
+ for item in next_actions:
33
+ normalized = str(item).strip()
34
+ if not normalized or normalized in seen:
35
+ continue
36
+ seen.add(normalized)
37
+ unique_actions.append(normalized)
38
+
39
+ if unique_actions:
40
+ lines.append(f"- 下一步: {unique_actions[0]}")
41
+ for item in unique_actions[1:]:
42
+ lines.append(f"- 备选后续: {item}")
43
+ else:
44
+ lines.append("- 下一步: 无")
45
+ return "\n".join(lines)
@@ -0,0 +1,55 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import sys
5
+ from typing import Any
6
+
7
+ from .paths import PACKAGE_ROOT
8
+
9
+
10
+ WORKSPACE = PACKAGE_ROOT
11
+
12
+
13
+ def resolve_python_command() -> str:
14
+ override = os.environ.get("CODECGC_PYTHON_COMMAND", "").strip()
15
+ if override:
16
+ return override
17
+ return sys.executable
18
+
19
+
20
+ def build_executor_registry() -> dict[str, dict[str, Any]]:
21
+ python_command = resolve_python_command()
22
+ return {
23
+ "backend": {
24
+ "target": "backend",
25
+ "mcp_server_name": "codex",
26
+ "routing_executor": "codexmcp",
27
+ "tool_name": "implement_backend_task",
28
+ "python_module": "codexmcp.cli",
29
+ "pythonpath": str(WORKSPACE / "codexmcp" / "src"),
30
+ "python_command": python_command,
31
+ },
32
+ "frontend": {
33
+ "target": "frontend",
34
+ "mcp_server_name": "gemini",
35
+ "routing_executor": "geminimcp",
36
+ "tool_name": "implement_frontend_task",
37
+ "python_module": "geminimcp.cli",
38
+ "pythonpath": str(WORKSPACE / "geminimcp" / "src"),
39
+ "python_command": python_command,
40
+ },
41
+ }
42
+
43
+
44
+ def get_executor_config(target: str) -> dict[str, Any]:
45
+ registry = build_executor_registry()
46
+ if target not in registry:
47
+ raise ValueError(f"Unsupported target: {target}")
48
+ return registry[target]
49
+
50
+
51
+ def build_executor_env(target: str) -> dict[str, str]:
52
+ env = dict(os.environ)
53
+ config = get_executor_config(target)
54
+ env["PYTHONPATH"] = str(config["pythonpath"])
55
+ return env
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ from .executor_registry import build_executor_registry
9
+ from .paths import PACKAGE_ROOT
10
+
11
+
12
+ WORKSPACE = PACKAGE_ROOT
13
+ MCP_CONFIG_PATH = WORKSPACE / ".mcp.json"
14
+
15
+
16
+ def build_runtime_pythonpath(*extra_paths: Path) -> str:
17
+ paths = [str(WORKSPACE / "scripts"), *(str(path) for path in extra_paths)]
18
+ return os.pathsep.join(paths)
19
+
20
+
21
+ def _with_workspace_env(env: dict[str, str], workspace_root: Path | None) -> dict[str, str]:
22
+ if workspace_root is None:
23
+ return env
24
+ enriched = dict(env)
25
+ enriched["CODECGC_WORKSPACE_ROOT"] = str(workspace_root.expanduser().resolve())
26
+ return enriched
27
+
28
+
29
+ def build_mcp_config(workspace_root: Path | None = None) -> dict[str, Any]:
30
+ registry = build_executor_registry()
31
+ servers: dict[str, dict[str, Any]] = {}
32
+
33
+ servers["codecgc"] = {
34
+ "command": str(next(iter(registry.values()))["python_command"]),
35
+ "args": ["-m", "codecgcmcp.cli"],
36
+ "env": _with_workspace_env(
37
+ {
38
+ "PYTHONPATH": build_runtime_pythonpath(WORKSPACE / "codecgcmcp" / "src"),
39
+ },
40
+ workspace_root,
41
+ ),
42
+ }
43
+
44
+ for config in registry.values():
45
+ servers[str(config["mcp_server_name"])] = {
46
+ "command": str(config["python_command"]),
47
+ "args": ["-m", str(config["python_module"])],
48
+ "env": _with_workspace_env(
49
+ {
50
+ "PYTHONPATH": build_runtime_pythonpath(
51
+ WORKSPACE / "codecgcmcp" / "src",
52
+ Path(str(config["pythonpath"])),
53
+ ),
54
+ },
55
+ workspace_root,
56
+ ),
57
+ }
58
+
59
+ return {"mcpServers": servers}
60
+
61
+
62
+ def write_mcp_config(target_path: Path, workspace_root: Path | None = None) -> Path:
63
+ config = build_mcp_config(workspace_root)
64
+ target_path.parent.mkdir(parents=True, exist_ok=True)
65
+ target_path.write_text(json.dumps(config, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
66
+ return target_path
67
+
68
+
69
+ def main() -> int:
70
+ write_mcp_config(MCP_CONFIG_PATH, WORKSPACE)
71
+ print(json.dumps({"success": True, "path": str(MCP_CONFIG_PATH)}, ensure_ascii=False, indent=2))
72
+ return 0
@@ -0,0 +1,123 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from pathlib import Path
5
+
6
+ from .paths import PROJECT_ROOT
7
+
8
+
9
+ def normalize_path_text(path_text: str) -> str:
10
+ return str(path_text or "").replace("\\", "/").strip()
11
+
12
+
13
+ def is_project_relative_path(path_text: str) -> bool:
14
+ normalized = normalize_path_text(path_text)
15
+ if not normalized:
16
+ return False
17
+ if normalized.startswith(("/", "~")):
18
+ return False
19
+ if re.match(r"^[A-Za-z]:/", normalized):
20
+ return False
21
+ return True
22
+
23
+
24
+ def _relative_to_project(path: Path, project_root: Path) -> str | None:
25
+ try:
26
+ return path.resolve().relative_to(project_root.resolve()).as_posix()
27
+ except ValueError:
28
+ return None
29
+
30
+
31
+ def _legacy_project_suffix(path_text: str) -> str | None:
32
+ normalized = normalize_path_text(path_text)
33
+ if not normalized:
34
+ return None
35
+
36
+ for marker in ("/CodeCGC/release/", "/CodeCGC/", "/CodeCCG/release/", "/CodeCCG/"):
37
+ if marker in normalized:
38
+ return normalized.split(marker, 1)[1].lstrip("/")
39
+
40
+ if normalized.endswith(("/CodeCGC/release", "/CodeCGC", "/CodeCCG/release", "/CodeCCG")):
41
+ return "."
42
+
43
+ basename = normalized.rsplit("/", 1)[-1]
44
+ if basename == "model-routing.yaml":
45
+ return "model-routing.yaml"
46
+ return None
47
+
48
+
49
+ def to_project_relative_path(
50
+ path_value: str | Path,
51
+ project_root: Path = PROJECT_ROOT,
52
+ *,
53
+ allow_legacy_suffix: bool = True,
54
+ ) -> str:
55
+ path_text = normalize_path_text(str(path_value))
56
+ if not path_text:
57
+ return ""
58
+ if path_text == ".":
59
+ return "."
60
+
61
+ path = Path(path_text)
62
+ if path.is_absolute():
63
+ relative = _relative_to_project(path, project_root)
64
+ if relative is not None:
65
+ return relative or "."
66
+
67
+ if allow_legacy_suffix:
68
+ legacy_suffix = _legacy_project_suffix(path_text)
69
+ if legacy_suffix is not None:
70
+ return legacy_suffix or "."
71
+
72
+ return path_text
73
+
74
+ normalized = path_text
75
+ while normalized.startswith("./"):
76
+ normalized = normalized[2:]
77
+ return normalized or "."
78
+
79
+
80
+ def resolve_project_path(path_value: str | Path, project_root: Path = PROJECT_ROOT) -> Path:
81
+ path_text = normalize_path_text(str(path_value))
82
+ if not path_text or path_text == ".":
83
+ return project_root.resolve()
84
+
85
+ path = Path(path_text)
86
+ if path.is_absolute():
87
+ relative = _relative_to_project(path, project_root)
88
+ if relative is not None:
89
+ return (project_root / relative).resolve()
90
+
91
+ legacy_suffix = _legacy_project_suffix(path_text)
92
+ if legacy_suffix is not None:
93
+ return (project_root / legacy_suffix).resolve()
94
+
95
+ return path.resolve()
96
+
97
+ return (project_root / path_text).resolve()
98
+
99
+
100
+ def normalize_persisted_project_path(path_value: str | Path, project_root: Path = PROJECT_ROOT) -> str:
101
+ return to_project_relative_path(path_value, project_root)
102
+
103
+
104
+ def normalize_source_contract(source: object, project_root: Path = PROJECT_ROOT) -> object:
105
+ if not isinstance(source, dict):
106
+ return source
107
+ normalized = dict(source)
108
+ artifact_file = normalized.get("artifact_file")
109
+ if isinstance(artifact_file, str) and artifact_file.strip():
110
+ normalized["artifact_file"] = normalize_persisted_project_path(artifact_file, project_root)
111
+ return normalized
112
+
113
+
114
+ def normalize_audit_path_fields(record: dict, project_root: Path = PROJECT_ROOT) -> dict:
115
+ normalized = dict(record)
116
+ for key in ("routing_file", "cd"):
117
+ value = normalized.get(key)
118
+ if isinstance(value, str) and value.strip():
119
+ normalized[key] = normalize_persisted_project_path(value, project_root)
120
+
121
+ source = normalized.get("source")
122
+ normalized["source"] = normalize_source_contract(source, project_root)
123
+ return normalized
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+
6
+
7
+ PACKAGE_ROOT = Path(__file__).resolve().parents[2]
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()
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from .paths import PACKAGE_ROOT
6
+ from .paths import PROJECT_ROOT
7
+
8
+
9
+ PACKAGE_ROUTING_FILE = PACKAGE_ROOT / "model-routing.yaml"
10
+ PROJECT_ROUTING_FILE = PROJECT_ROOT / "model-routing.yaml"
11
+
12
+
13
+ def resolve_active_routing_file() -> Path:
14
+ if PROJECT_ROUTING_FILE.exists():
15
+ return PROJECT_ROUTING_FILE
16
+ return PACKAGE_ROUTING_FILE
@@ -0,0 +1,171 @@
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.local.json",
38
+ ".codex/codecgcrc.json",
39
+ ".gemini/policies/**",
40
+ ".mcp.json",
41
+ "model-routing.yaml",
42
+ ]
43
+
44
+ DEFAULT_DOCS_PATHS = [
45
+ "README.md",
46
+ "INSTALLATION.md",
47
+ "docs/**",
48
+ "CHANGELOG.md",
49
+ ]
50
+
51
+ DEFAULT_BACKEND_TEST_PATHS = [
52
+ "apps/api/*.test.*",
53
+ "apps/api/*.spec.*",
54
+ "apps/api/**/*.test.*",
55
+ "apps/api/**/*.spec.*",
56
+ "tests/backend/**",
57
+ ]
58
+
59
+ DEFAULT_FRONTEND_TEST_PATHS = [
60
+ "apps/web/*.test.*",
61
+ "apps/web/*.spec.*",
62
+ "apps/web/**/*.test.*",
63
+ "apps/web/**/*.spec.*",
64
+ "tests/frontend/**",
65
+ ]
66
+
67
+ DEFAULT_RULES = {
68
+ "claude_allowed_owners": ["orchestration", "docs"],
69
+ "backend_executor": "codexmcp",
70
+ "frontend_executor": "geminimcp",
71
+ "shared_policy": "split-first",
72
+ }
73
+
74
+
75
+ def _render_list_block(name: str, items: list[str]) -> list[str]:
76
+ lines = [f"{name}:"]
77
+ for item in items:
78
+ lines.append(f' - "{item}"')
79
+ return lines
80
+
81
+
82
+ def _render_nested_list_block(name: str, groups: dict[str, list[str]]) -> list[str]:
83
+ lines = [f"{name}:"]
84
+ for group_name, items in groups.items():
85
+ lines.append(f" {group_name}:")
86
+ for item in items:
87
+ lines.append(f' - "{item}"')
88
+ return lines
89
+
90
+
91
+ def _render_rules_block() -> list[str]:
92
+ lines = ["rules:"]
93
+ for key, value in DEFAULT_RULES.items():
94
+ if isinstance(value, list):
95
+ lines.append(f" {key}:")
96
+ lines.extend(f' - "{item}"' for item in value)
97
+ else:
98
+ lines.append(f' {key}: "{value}"')
99
+ return lines
100
+
101
+
102
+ def render_default_routing_yaml() -> str:
103
+ lines: list[str] = [
104
+ "version: 2",
105
+ "",
106
+ *_render_list_block("orchestration_paths", DEFAULT_ORCHESTRATION_PATHS),
107
+ "",
108
+ *_render_list_block("docs_paths", DEFAULT_DOCS_PATHS),
109
+ "",
110
+ *_render_list_block("frontend_paths", DEFAULT_FRONTEND_PATHS),
111
+ "",
112
+ *_render_list_block("backend_paths", DEFAULT_BACKEND_PATHS),
113
+ "",
114
+ *_render_nested_list_block(
115
+ "test_paths",
116
+ {
117
+ "frontend": DEFAULT_FRONTEND_TEST_PATHS,
118
+ "backend": DEFAULT_BACKEND_TEST_PATHS,
119
+ },
120
+ ),
121
+ "",
122
+ *_render_list_block("shared_paths", DEFAULT_SHARED_PATHS),
123
+ "",
124
+ *_render_rules_block(),
125
+ "",
126
+ ]
127
+ return "\n".join(lines)
128
+
129
+
130
+ def _normalize_line_endings(text: str) -> str:
131
+ return text.replace("\r\n", "\n").replace("\r", "\n")
132
+
133
+
134
+ def _extract_list_block(lines: list[str], block_name: str) -> list[str]:
135
+ items: list[str] = []
136
+ inside = False
137
+ for line in lines:
138
+ stripped = line.strip()
139
+ if not inside:
140
+ if stripped == f"{block_name}:":
141
+ inside = True
142
+ continue
143
+
144
+ if line and not line.startswith(" "):
145
+ break
146
+ if stripped.startswith("- "):
147
+ value = stripped[2:].strip()
148
+ if len(value) >= 2 and value[0] == value[-1] and value[0] in {'"', "'"}:
149
+ value = value[1:-1]
150
+ if value:
151
+ items.append(value)
152
+ return items
153
+
154
+
155
+ def merge_routing_template(existing_text: str) -> str:
156
+ if existing_text.strip():
157
+ try:
158
+ data = yaml.safe_load(existing_text)
159
+ except yaml.YAMLError:
160
+ data = None
161
+ if isinstance(data, dict) and int(data.get("version", 0) or 0) == 2:
162
+ return _normalize_line_endings(existing_text).rstrip() + "\n"
163
+ return render_default_routing_yaml()
164
+
165
+
166
+ def sync_workspace_routing_file(target_path: Path) -> Path:
167
+ existing_text = target_path.read_text(encoding="utf-8") if target_path.exists() else ""
168
+ merged_text = merge_routing_template(existing_text)
169
+ target_path.parent.mkdir(parents=True, exist_ok=True)
170
+ target_path.write_text(merged_text, encoding="utf-8")
171
+ 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 __future__ import annotations
2
-
3
- import os
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(task_id and task_summary)
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),