@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.
- package/.claude/hooks/route-edit.ps1 +58 -57
- package/INSTALLATION.md +122 -484
- package/README.md +124 -149
- 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/execution-model.md +3 -1
- 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 +58 -0
- package/codecgc/reference/project-structure.md +87 -0
- package/codecgc/reference/quickstart.md +110 -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 +114 -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/codecgc/templates/claude/settings.local.json +27 -0
- package/codecgc/templates/codex/codecgcrc.json +22 -0
- package/codecgc/templates/gemini/codecgc-policy.toml +47 -0
- package/codecgcmcp/README.md +57 -11
- package/codecgcmcp/src/codecgcmcp/server.py +164 -26
- package/codexmcp/src/codexmcp/server.py +45 -0
- package/geminimcp/src/geminimcp/server.py +106 -24
- package/model-routing.yaml +31 -6
- package/package.json +12 -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 +76 -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 +69 -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 +447 -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 +171 -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 +560 -32
- 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,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"owner": "CodeCGC",
|
|
4
|
+
"scope": "project",
|
|
5
|
+
"executor": "codex",
|
|
6
|
+
"role": "backend implementation and backend tests",
|
|
7
|
+
"enforcement": {
|
|
8
|
+
"primary": "CodeCGC MCP backend path validation",
|
|
9
|
+
"codex_cli": "sandbox and approval flags supplied by codexmcp",
|
|
10
|
+
"routing_policy": "model-routing.yaml"
|
|
11
|
+
},
|
|
12
|
+
"allowed_path_kinds": [
|
|
13
|
+
"backend"
|
|
14
|
+
],
|
|
15
|
+
"denied_path_kinds": [
|
|
16
|
+
"frontend"
|
|
17
|
+
],
|
|
18
|
+
"notes": [
|
|
19
|
+
"Codex CLI project execpolicy discovery is version dependent; CodeCGC treats this file as the project-local policy contract used by its MCP wrapper and status checks.",
|
|
20
|
+
"Do not edit frontend files, styling files, UI components, or mixed shared paths without a split plan."
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# CodeCGC project-local Gemini policy.
|
|
2
|
+
#
|
|
3
|
+
# This file is passed explicitly by GeminiMCP through `gemini --policy`.
|
|
4
|
+
# It is intentionally project-local so each repository can review and tune it.
|
|
5
|
+
|
|
6
|
+
[[rule]]
|
|
7
|
+
toolName = "run_shell_command"
|
|
8
|
+
commandPrefix = [
|
|
9
|
+
"rm -rf",
|
|
10
|
+
"del ",
|
|
11
|
+
"rmdir ",
|
|
12
|
+
"Remove-Item",
|
|
13
|
+
"git reset --hard",
|
|
14
|
+
"git clean"
|
|
15
|
+
]
|
|
16
|
+
decision = "deny"
|
|
17
|
+
priority = 900
|
|
18
|
+
denyMessage = "CodeCGC blocks destructive shell commands in Gemini executor sessions."
|
|
19
|
+
|
|
20
|
+
[[rule]]
|
|
21
|
+
toolName = [
|
|
22
|
+
"write_file",
|
|
23
|
+
"replace"
|
|
24
|
+
]
|
|
25
|
+
decision = "allow"
|
|
26
|
+
priority = 500
|
|
27
|
+
modes = ["autoEdit"]
|
|
28
|
+
|
|
29
|
+
[rule.safety_checker]
|
|
30
|
+
type = "in-process"
|
|
31
|
+
name = "allowed-path"
|
|
32
|
+
required_context = ["environment"]
|
|
33
|
+
|
|
34
|
+
[[rule]]
|
|
35
|
+
toolName = "run_shell_command"
|
|
36
|
+
commandPrefix = [
|
|
37
|
+
"npm test",
|
|
38
|
+
"npm run test",
|
|
39
|
+
"pnpm test",
|
|
40
|
+
"pnpm run test",
|
|
41
|
+
"yarn test",
|
|
42
|
+
"git diff",
|
|
43
|
+
"git status"
|
|
44
|
+
]
|
|
45
|
+
decision = "allow"
|
|
46
|
+
priority = 300
|
|
47
|
+
modes = ["autoEdit"]
|
package/codecgcmcp/README.md
CHANGED
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
# CodeCGC MCP Server
|
|
2
2
|
|
|
3
|
-
This package contains the
|
|
3
|
+
This package contains the CodeCGC orchestrator MCP server.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The server is the preferred Claude-facing capability layer. The CLI remains available for fallback, CI, and local debugging.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
7
|
+
## Current Tool Surface
|
|
8
|
+
|
|
9
|
+
- `codecgc.install`
|
|
10
|
+
- `codecgc.start`
|
|
11
|
+
- `codecgc.status`
|
|
12
|
+
- `codecgc.doctor`
|
|
13
|
+
- `codecgc.entry`
|
|
14
|
+
- `codecgc.continue`
|
|
15
|
+
- `codecgc.explain`
|
|
16
|
+
- `codecgc.review`
|
|
17
|
+
- `codecgc.history`
|
|
18
|
+
- `codecgc.route`
|
|
19
|
+
- `codecgc.plan`
|
|
20
|
+
- `codecgc.build`
|
|
21
|
+
- `codecgc.fix`
|
|
22
|
+
- `codecgc.test`
|
|
23
|
+
- `codecgc.package_audit`
|
|
24
|
+
- `codecgc.external_audit`
|
|
25
|
+
- `codecgc.external_status`
|
|
26
|
+
- `codecgc.release_readiness`
|
|
27
|
+
- `codecgc.lifecycle`
|
|
28
|
+
|
|
29
|
+
## Runtime Boundary
|
|
16
30
|
|
|
17
31
|
This server currently reuses the existing CodeCGC runtime scripts rather than replacing them.
|
|
32
|
+
|
|
33
|
+
The contract is:
|
|
34
|
+
|
|
35
|
+
- MCP tools expose product capabilities to Claude.
|
|
36
|
+
- Runtime scripts own workflow behavior.
|
|
37
|
+
- CLI commands stay as compatibility and maintainer surfaces.
|
|
38
|
+
- MCP responses should be machine-readable JSON payloads.
|
|
39
|
+
- `codecgc.external_status` is the concise panel view; `codecgc.external_audit` is the deeper consistency check.
|
|
40
|
+
|
|
41
|
+
## Response Contract
|
|
42
|
+
|
|
43
|
+
Every tool returns a stable envelope:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"success": true,
|
|
48
|
+
"tool": "codecgc.status",
|
|
49
|
+
"payload": {},
|
|
50
|
+
"error": null,
|
|
51
|
+
"meta": {
|
|
52
|
+
"contract_version": "1.0",
|
|
53
|
+
"payload_success": true,
|
|
54
|
+
"response_shape": "codecgc.mcp.tool_result"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The raw runtime response remains available under `payload`.
|
|
60
|
+
|
|
61
|
+
See `codecgc/reference/mcp-tool-surface.md` for the full contract.
|
|
62
|
+
|
|
63
|
+
Errors include a stable `error.category` field so Claude can distinguish runtime failures, invalid JSON, permission issues, missing scripts, and MCP wrapper exceptions without parsing text.
|
|
@@ -15,6 +15,16 @@ from codecgc_workflow_runtime import run_json_script
|
|
|
15
15
|
|
|
16
16
|
mcp = FastMCP("CodeCGC MCP Server")
|
|
17
17
|
|
|
18
|
+
MCP_CONTRACT_VERSION = "1.0"
|
|
19
|
+
|
|
20
|
+
EXCEPTION_ERROR_CATEGORIES = {
|
|
21
|
+
"JSONDecodeError": "runtime-json-invalid",
|
|
22
|
+
"ValueError": "runtime-json-invalid",
|
|
23
|
+
"TimeoutExpired": "runtime-timeout",
|
|
24
|
+
"FileNotFoundError": "runtime-script-missing",
|
|
25
|
+
"PermissionError": "runtime-permission-denied",
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
|
|
19
29
|
def _append_repeated_flag(args: list[str], flag: str, values: list[str]) -> None:
|
|
20
30
|
for value in values:
|
|
@@ -27,18 +37,106 @@ def _normalize_workspace(workspace: str) -> str:
|
|
|
27
37
|
return str(Path(workspace).expanduser().resolve()) if str(workspace).strip() else ""
|
|
28
38
|
|
|
29
39
|
|
|
30
|
-
def
|
|
40
|
+
def _payload_success(payload: dict[str, Any]) -> bool:
|
|
41
|
+
return bool(payload.get("success", True))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _runtime_error_category(payload: dict[str, Any]) -> str:
|
|
45
|
+
raw_category = str(payload.get("error_category") or payload.get("failure_category") or "").strip()
|
|
46
|
+
if raw_category:
|
|
47
|
+
return raw_category
|
|
48
|
+
returncode = payload.get("returncode")
|
|
49
|
+
if returncode is not None:
|
|
50
|
+
return "runtime-script-failed"
|
|
51
|
+
return "runtime-payload-failed"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _payload_error(tool_name: str, script_name: str, args: tuple[str, ...], payload: dict[str, Any]) -> dict[str, Any] | None:
|
|
55
|
+
if _payload_success(payload):
|
|
56
|
+
return None
|
|
57
|
+
summary = payload.get("summary", {}) if isinstance(payload.get("summary"), dict) else {}
|
|
58
|
+
message = str(
|
|
59
|
+
payload.get("error")
|
|
60
|
+
or summary.get("human_summary")
|
|
61
|
+
or summary.get("recommended_next_action")
|
|
62
|
+
or "Runtime script reported failure."
|
|
63
|
+
)
|
|
64
|
+
return {
|
|
65
|
+
"type": str(payload.get("error_type") or "RuntimeScriptError"),
|
|
66
|
+
"category": _runtime_error_category(payload),
|
|
67
|
+
"message": message,
|
|
68
|
+
"tool": tool_name,
|
|
69
|
+
"script": script_name,
|
|
70
|
+
"args": list(args),
|
|
71
|
+
"returncode": payload.get("returncode"),
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _exception_category(error: Exception) -> str:
|
|
76
|
+
return EXCEPTION_ERROR_CATEGORIES.get(error.__class__.__name__, "mcp-wrapper-exception")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _exception_payload(tool_name: str, script_name: str, args: tuple[str, ...], error: Exception) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
80
|
+
normalized_error = {
|
|
81
|
+
"type": error.__class__.__name__,
|
|
82
|
+
"category": _exception_category(error),
|
|
83
|
+
"message": str(error),
|
|
84
|
+
"tool": tool_name,
|
|
85
|
+
"script": script_name,
|
|
86
|
+
"args": list(args),
|
|
87
|
+
"returncode": None,
|
|
88
|
+
}
|
|
89
|
+
payload = {
|
|
90
|
+
"success": False,
|
|
91
|
+
"mode": "mcp-runtime-call",
|
|
92
|
+
"summary": {
|
|
93
|
+
"ready": False,
|
|
94
|
+
"human_summary": "CodeCGC MCP tool failed before a runtime JSON payload was produced.",
|
|
95
|
+
"recommended_next_action": "Check the runtime script output and MCP server logs.",
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
return payload, normalized_error
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _build_tool_envelope(tool_name: str, payload: dict[str, Any], error: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
102
|
+
success = _payload_success(payload) and error is None
|
|
103
|
+
return {
|
|
104
|
+
"success": success,
|
|
105
|
+
"tool": tool_name,
|
|
106
|
+
"payload": payload,
|
|
107
|
+
"error": error,
|
|
108
|
+
"meta": {
|
|
109
|
+
"contract_version": MCP_CONTRACT_VERSION,
|
|
110
|
+
"payload_success": _payload_success(payload),
|
|
111
|
+
"response_shape": "codecgc.mcp.tool_result",
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _as_tool_result(tool_name: str, payload: dict[str, Any], error: dict[str, Any] | None = None) -> CallToolResult:
|
|
117
|
+
envelope = _build_tool_envelope(tool_name, payload, error)
|
|
31
118
|
return CallToolResult(
|
|
32
119
|
content=[
|
|
33
120
|
TextContent(
|
|
34
121
|
type="text",
|
|
35
|
-
text=json.dumps(
|
|
122
|
+
text=json.dumps(envelope, ensure_ascii=False, indent=2),
|
|
36
123
|
)
|
|
37
124
|
],
|
|
38
|
-
isError=not bool(
|
|
125
|
+
isError=not bool(envelope.get("success", True)),
|
|
39
126
|
)
|
|
40
127
|
|
|
41
128
|
|
|
129
|
+
def _call_runtime_tool(tool_name: str, script_name: str, *args: str, requested_format: str = "") -> CallToolResult:
|
|
130
|
+
try:
|
|
131
|
+
payload = run_json_script(script_name, *args)
|
|
132
|
+
if requested_format:
|
|
133
|
+
payload.setdefault("requested_format", requested_format)
|
|
134
|
+
return _as_tool_result(tool_name, payload, _payload_error(tool_name, script_name, args, payload))
|
|
135
|
+
except Exception as error:
|
|
136
|
+
payload, normalized_error = _exception_payload(tool_name, script_name, args, error)
|
|
137
|
+
return _as_tool_result(tool_name, payload, normalized_error)
|
|
138
|
+
|
|
139
|
+
|
|
42
140
|
@mcp.tool(
|
|
43
141
|
name="codecgc.install",
|
|
44
142
|
description="Install or sync CodeCGC integration for the current project or Claude user profile.",
|
|
@@ -51,7 +149,7 @@ async def codecgc_install(
|
|
|
51
149
|
] = "local",
|
|
52
150
|
format: Annotated[
|
|
53
151
|
Literal["summary", "json"],
|
|
54
|
-
Field(description="
|
|
152
|
+
Field(description="Presentation hint. MCP responses are always returned as JSON payloads."),
|
|
55
153
|
] = "summary",
|
|
56
154
|
workspace: Annotated[
|
|
57
155
|
str,
|
|
@@ -62,13 +160,14 @@ async def codecgc_install(
|
|
|
62
160
|
Field(description="Optional explicit Claude user root for user/user-dry-run modes."),
|
|
63
161
|
] = "",
|
|
64
162
|
) -> CallToolResult:
|
|
65
|
-
|
|
163
|
+
# The MCP surface must always receive machine-readable JSON from the script.
|
|
164
|
+
args = ["--mode", mode, "--format", "json"]
|
|
66
165
|
normalized_workspace = _normalize_workspace(workspace)
|
|
67
166
|
if normalized_workspace:
|
|
68
167
|
args.extend(["--workspace", normalized_workspace])
|
|
69
168
|
if str(user_root).strip():
|
|
70
169
|
args.extend(["--user-root", str(user_root).strip()])
|
|
71
|
-
return
|
|
170
|
+
return _call_runtime_tool("codecgc.install", "install_codecgc.py", *args, requested_format=format)
|
|
72
171
|
|
|
73
172
|
|
|
74
173
|
@mcp.tool(
|
|
@@ -86,7 +185,25 @@ async def codecgc_status(
|
|
|
86
185
|
normalized_workspace = _normalize_workspace(workspace)
|
|
87
186
|
if normalized_workspace:
|
|
88
187
|
args.extend(["--workspace", normalized_workspace])
|
|
89
|
-
return
|
|
188
|
+
return _call_runtime_tool("codecgc.status", "install_codecgc.py", *args)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
@mcp.tool(
|
|
192
|
+
name="codecgc.start",
|
|
193
|
+
description="Show the project-local CodeCGC first-run guide and recommended next actions.",
|
|
194
|
+
meta={"version": "0.1.0", "author": "CodeCGC"},
|
|
195
|
+
)
|
|
196
|
+
async def codecgc_start(
|
|
197
|
+
workspace: Annotated[
|
|
198
|
+
str,
|
|
199
|
+
Field(description="Optional target workspace root."),
|
|
200
|
+
] = "",
|
|
201
|
+
) -> CallToolResult:
|
|
202
|
+
args = ["--mode", "start", "--format", "json"]
|
|
203
|
+
normalized_workspace = _normalize_workspace(workspace)
|
|
204
|
+
if normalized_workspace:
|
|
205
|
+
args.extend(["--workspace", normalized_workspace])
|
|
206
|
+
return _call_runtime_tool("codecgc.start", "install_codecgc.py", *args)
|
|
90
207
|
|
|
91
208
|
|
|
92
209
|
@mcp.tool(
|
|
@@ -104,7 +221,7 @@ async def codecgc_doctor(
|
|
|
104
221
|
normalized_workspace = _normalize_workspace(workspace)
|
|
105
222
|
if normalized_workspace:
|
|
106
223
|
args.extend(["--workspace", normalized_workspace])
|
|
107
|
-
return
|
|
224
|
+
return _call_runtime_tool("codecgc.doctor", "install_codecgc.py", *args)
|
|
108
225
|
|
|
109
226
|
|
|
110
227
|
@mcp.tool(
|
|
@@ -152,7 +269,7 @@ async def codecgc_entry(
|
|
|
152
269
|
args.extend(["--audit-file", str(audit_file).strip()])
|
|
153
270
|
if decision:
|
|
154
271
|
args.extend(["--decision", decision])
|
|
155
|
-
return
|
|
272
|
+
return _call_runtime_tool("codecgc.entry", "entry_codecgc_workflow.py", *args)
|
|
156
273
|
|
|
157
274
|
|
|
158
275
|
@mcp.tool(
|
|
@@ -185,7 +302,7 @@ async def codecgc_continue(
|
|
|
185
302
|
args.append("--auto-dispatch")
|
|
186
303
|
if dry_run:
|
|
187
304
|
args.append("--dry-run")
|
|
188
|
-
return
|
|
305
|
+
return _call_runtime_tool("codecgc.continue", "entry_codecgc_workflow.py", *args)
|
|
189
306
|
|
|
190
307
|
|
|
191
308
|
@mcp.tool(
|
|
@@ -212,7 +329,7 @@ async def codecgc_explain(
|
|
|
212
329
|
args.append("--latest")
|
|
213
330
|
if include_fixtures:
|
|
214
331
|
args.append("--include-fixtures")
|
|
215
|
-
return
|
|
332
|
+
return _call_runtime_tool("codecgc.explain", "entry_codecgc_workflow.py", *args)
|
|
216
333
|
|
|
217
334
|
|
|
218
335
|
@mcp.tool(
|
|
@@ -236,7 +353,7 @@ async def codecgc_review(
|
|
|
236
353
|
args.extend(["--next-step", str(next_step).strip()])
|
|
237
354
|
if force:
|
|
238
355
|
args.append("--force")
|
|
239
|
-
return
|
|
356
|
+
return _call_runtime_tool("codecgc.review", "review_codecgc_workflow.py", *args)
|
|
240
357
|
|
|
241
358
|
|
|
242
359
|
@mcp.tool(
|
|
@@ -256,7 +373,7 @@ async def codecgc_history(
|
|
|
256
373
|
args = ["--flow", flow, "--status", str(status).strip() or "all", "--last", str(int(last)), "--format", "json"]
|
|
257
374
|
if include_fixtures:
|
|
258
375
|
args.append("--include-fixtures")
|
|
259
|
-
return
|
|
376
|
+
return _call_runtime_tool("codecgc.history", "audit_codecgc_workflow_history.py", *args)
|
|
260
377
|
|
|
261
378
|
|
|
262
379
|
@mcp.tool(
|
|
@@ -271,7 +388,7 @@ async def codecgc_route(
|
|
|
271
388
|
],
|
|
272
389
|
slug: Annotated[str, "Workflow slug."],
|
|
273
390
|
) -> CallToolResult:
|
|
274
|
-
return
|
|
391
|
+
return _call_runtime_tool("codecgc.route", "route_codecgc_workflow.py", "--flow", flow, "--slug", str(slug).strip())
|
|
275
392
|
|
|
276
393
|
|
|
277
394
|
@mcp.tool(
|
|
@@ -354,7 +471,7 @@ async def codecgc_plan(
|
|
|
354
471
|
args.extend(["--artifact-class", artifact_class])
|
|
355
472
|
if force:
|
|
356
473
|
args.append("--force")
|
|
357
|
-
return
|
|
474
|
+
return _call_runtime_tool("codecgc.plan", "plan_codecgc_workflow.py", *args)
|
|
358
475
|
|
|
359
476
|
|
|
360
477
|
@mcp.tool(
|
|
@@ -385,7 +502,7 @@ async def codecgc_build(
|
|
|
385
502
|
args.append("--dry-run")
|
|
386
503
|
if return_all_messages:
|
|
387
504
|
args.append("--return-all-messages")
|
|
388
|
-
return
|
|
505
|
+
return _call_runtime_tool("codecgc.build", "run_codecgc_build.py", *args)
|
|
389
506
|
|
|
390
507
|
|
|
391
508
|
@mcp.tool(
|
|
@@ -416,7 +533,7 @@ async def codecgc_fix(
|
|
|
416
533
|
args.append("--dry-run")
|
|
417
534
|
if return_all_messages:
|
|
418
535
|
args.append("--return-all-messages")
|
|
419
|
-
return
|
|
536
|
+
return _call_runtime_tool("codecgc.fix", "run_codecgc_fix.py", *args)
|
|
420
537
|
|
|
421
538
|
|
|
422
539
|
@mcp.tool(
|
|
@@ -451,7 +568,7 @@ async def codecgc_test(
|
|
|
451
568
|
args.append("--dry-run")
|
|
452
569
|
if return_all_messages:
|
|
453
570
|
args.append("--return-all-messages")
|
|
454
|
-
return
|
|
571
|
+
return _call_runtime_tool("codecgc.test", "run_codecgc_test.py", *args)
|
|
455
572
|
|
|
456
573
|
|
|
457
574
|
@mcp.tool(
|
|
@@ -465,7 +582,15 @@ async def codecgc_package_audit(
|
|
|
465
582
|
Field(description="Output format."),
|
|
466
583
|
] = "json",
|
|
467
584
|
) -> CallToolResult:
|
|
468
|
-
return
|
|
585
|
+
return _call_runtime_tool("codecgc.package_audit", "audit_codecgc_package_runtime.py", "--format", format)
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
def _external_capability_runtime_args(view: str, workspace: str, format: str) -> list[str]:
|
|
589
|
+
args = ["--view", view, "--format", format]
|
|
590
|
+
normalized_workspace = _normalize_workspace(workspace)
|
|
591
|
+
if normalized_workspace:
|
|
592
|
+
args.extend(["--workspace", normalized_workspace])
|
|
593
|
+
return args
|
|
469
594
|
|
|
470
595
|
|
|
471
596
|
@mcp.tool(
|
|
@@ -480,11 +605,24 @@ async def codecgc_external_audit(
|
|
|
480
605
|
Field(description="Output format."),
|
|
481
606
|
] = "json",
|
|
482
607
|
) -> CallToolResult:
|
|
483
|
-
args =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
608
|
+
args = _external_capability_runtime_args("audit", workspace, format)
|
|
609
|
+
return _call_runtime_tool("codecgc.external_audit", "audit_codecgc_external_capabilities.py", *args)
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
@mcp.tool(
|
|
613
|
+
name="codecgc.external_status",
|
|
614
|
+
description="Render the concise external capability status panel for day-to-day checks.",
|
|
615
|
+
meta={"version": "0.1.0", "author": "CodeCGC"},
|
|
616
|
+
)
|
|
617
|
+
async def codecgc_external_status(
|
|
618
|
+
workspace: Annotated[str, "Optional target workspace root."] = "",
|
|
619
|
+
format: Annotated[
|
|
620
|
+
Literal["summary", "json"],
|
|
621
|
+
Field(description="Output format."),
|
|
622
|
+
] = "summary",
|
|
623
|
+
) -> CallToolResult:
|
|
624
|
+
args = _external_capability_runtime_args("status", workspace, format)
|
|
625
|
+
return _call_runtime_tool("codecgc.external_status", "audit_codecgc_external_capabilities.py", *args)
|
|
488
626
|
|
|
489
627
|
|
|
490
628
|
@mcp.tool(
|
|
@@ -503,7 +641,7 @@ async def codecgc_release_readiness(
|
|
|
503
641
|
normalized_workspace = _normalize_workspace(workspace)
|
|
504
642
|
if normalized_workspace:
|
|
505
643
|
args.extend(["--workspace", normalized_workspace])
|
|
506
|
-
return
|
|
644
|
+
return _call_runtime_tool("codecgc.release_readiness", "audit_codecgc_release_readiness.py", *args)
|
|
507
645
|
|
|
508
646
|
|
|
509
647
|
@mcp.tool(
|
|
@@ -517,7 +655,7 @@ async def codecgc_lifecycle(
|
|
|
517
655
|
Field(description="Output format."),
|
|
518
656
|
] = "json",
|
|
519
657
|
) -> CallToolResult:
|
|
520
|
-
return
|
|
658
|
+
return _call_runtime_tool("codecgc.lifecycle", "audit_codecgc_lifecycle.py", "--format", format)
|
|
521
659
|
|
|
522
660
|
|
|
523
661
|
def run() -> None:
|
|
@@ -51,6 +51,8 @@ FRONTEND_FILE_SUFFIXES = (
|
|
|
51
51
|
".svelte",
|
|
52
52
|
)
|
|
53
53
|
|
|
54
|
+
PROJECT_CODEX_POLICY_RELATIVE_PATH = Path(".codex") / "codecgcrc.json"
|
|
55
|
+
|
|
54
56
|
|
|
55
57
|
def _empty_str_to_none(value: str | None) -> str | None:
|
|
56
58
|
"""Convert empty strings to None for optional UUID parameters."""
|
|
@@ -64,6 +66,45 @@ def _normalize_path_text(path_value: Path | str) -> str:
|
|
|
64
66
|
return str(path_value).replace("\\", "/").strip()
|
|
65
67
|
|
|
66
68
|
|
|
69
|
+
def _load_project_codex_policy_context(cd: Path) -> str:
|
|
70
|
+
"""Load the CodeCGC project-local Codex policy contract as prompt context."""
|
|
71
|
+
policy_path = cd / PROJECT_CODEX_POLICY_RELATIVE_PATH
|
|
72
|
+
if not policy_path.is_file():
|
|
73
|
+
return ""
|
|
74
|
+
|
|
75
|
+
try:
|
|
76
|
+
payload = json.loads(policy_path.read_text(encoding="utf-8"))
|
|
77
|
+
except Exception:
|
|
78
|
+
return ""
|
|
79
|
+
|
|
80
|
+
if not isinstance(payload, dict):
|
|
81
|
+
return ""
|
|
82
|
+
|
|
83
|
+
enforcement = payload.get("enforcement")
|
|
84
|
+
if not isinstance(enforcement, dict):
|
|
85
|
+
enforcement = {}
|
|
86
|
+
|
|
87
|
+
allowed_path_kinds = payload.get("allowed_path_kinds")
|
|
88
|
+
denied_path_kinds = payload.get("denied_path_kinds")
|
|
89
|
+
notes = payload.get("notes")
|
|
90
|
+
|
|
91
|
+
lines = [
|
|
92
|
+
"Project CodeCGC Codex policy contract:",
|
|
93
|
+
f"- Role: {payload.get('role', 'backend implementation and backend tests')}",
|
|
94
|
+
f"- Routing policy: {enforcement.get('routing_policy', 'model-routing.yaml')}",
|
|
95
|
+
f"- Primary enforcement: {enforcement.get('primary', 'CodeCGC MCP backend path validation')}",
|
|
96
|
+
f"- Codex CLI guardrail: {enforcement.get('codex_cli', 'sandbox and approval flags supplied by codexmcp')}",
|
|
97
|
+
]
|
|
98
|
+
if isinstance(allowed_path_kinds, list):
|
|
99
|
+
lines.append("- Allowed path kinds: " + ", ".join(str(item) for item in allowed_path_kinds))
|
|
100
|
+
if isinstance(denied_path_kinds, list):
|
|
101
|
+
lines.append("- Denied path kinds: " + ", ".join(str(item) for item in denied_path_kinds))
|
|
102
|
+
if isinstance(notes, list):
|
|
103
|
+
lines.extend(f"- {str(item)}" for item in notes if str(item).strip())
|
|
104
|
+
lines.append("Follow this project policy before making any code change.")
|
|
105
|
+
return "\n".join(lines).strip()
|
|
106
|
+
|
|
107
|
+
|
|
67
108
|
def _is_probably_frontend_path(path_value: Path | str) -> bool:
|
|
68
109
|
"""Best-effort check to keep backend-only Codex tasks away from frontend files."""
|
|
69
110
|
normalized = _normalize_path_text(path_value).lower().lstrip("./")
|
|
@@ -255,6 +296,10 @@ def _execute_codex_session(
|
|
|
255
296
|
if session_id:
|
|
256
297
|
cmd.extend(["resume", str(session_id)])
|
|
257
298
|
|
|
299
|
+
policy_context = _load_project_codex_policy_context(cd)
|
|
300
|
+
if policy_context:
|
|
301
|
+
prompt = f"{policy_context}\n\nUser task:\n{prompt}"
|
|
302
|
+
|
|
258
303
|
if os.name == "nt":
|
|
259
304
|
prompt = windows_escape(prompt)
|
|
260
305
|
cmd += ["--", prompt]
|