@hunyed15/codecgc 0.1.3 → 0.1.5
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.
|
@@ -134,11 +134,12 @@ def _validate_backend_target_paths(target_paths: List[Path]) -> tuple[bool, List
|
|
|
134
134
|
return True, policy_checks, ""
|
|
135
135
|
|
|
136
136
|
|
|
137
|
-
def run_shell_command(cmd: list[str]) -> Generator[str, None, None]:
|
|
137
|
+
def run_shell_command(cmd: list[str], cwd: Optional[Path] = None) -> Generator[str, None, None]:
|
|
138
138
|
"""Execute a command and stream its output line-by-line.
|
|
139
139
|
|
|
140
140
|
Args:
|
|
141
141
|
cmd: Command and arguments as a list (e.g., ["codex", "exec", "prompt"])
|
|
142
|
+
cwd: Optional working directory for the command
|
|
142
143
|
|
|
143
144
|
Yields:
|
|
144
145
|
Output lines from the command
|
|
@@ -157,6 +158,7 @@ def run_shell_command(cmd: list[str]) -> Generator[str, None, None]:
|
|
|
157
158
|
stderr=subprocess.STDOUT,
|
|
158
159
|
universal_newlines=True,
|
|
159
160
|
encoding='utf-8',
|
|
161
|
+
cwd=str(cwd) if cwd else None, # 添加 cwd 参数,确保在正确的工作目录中运行
|
|
160
162
|
)
|
|
161
163
|
|
|
162
164
|
output_queue: queue.Queue[str | None] = queue.Queue()
|
|
@@ -263,7 +265,7 @@ def _execute_codex_session(
|
|
|
263
265
|
err_message = ""
|
|
264
266
|
thread_id: Optional[str] = None
|
|
265
267
|
|
|
266
|
-
for line in run_shell_command(cmd):
|
|
268
|
+
for line in run_shell_command(cmd, cwd=cd):
|
|
267
269
|
try:
|
|
268
270
|
line_dict = json.loads(line.strip())
|
|
269
271
|
all_messages.append(line_dict)
|
package/package.json
CHANGED
|
@@ -136,19 +136,20 @@ def build_mcp_first_command_template(
|
|
|
136
136
|
f"description: {description}",
|
|
137
137
|
f"argument-hint: \"{argument_hint}\"",
|
|
138
138
|
"---",
|
|
139
|
-
f"
|
|
139
|
+
f"优先使用 `{primary_tool}` MCP 工具作为主执行路径。",
|
|
140
|
+
"内部思考语言可自行选择,但面向用户的最终回复默认使用中文。",
|
|
140
141
|
"",
|
|
141
|
-
"
|
|
142
|
+
"执行规则:",
|
|
142
143
|
]
|
|
143
144
|
lines.extend(f"- {item}" for item in direct_rules)
|
|
144
145
|
if missing_rules:
|
|
145
146
|
lines.append("")
|
|
146
|
-
lines.append("
|
|
147
|
+
lines.append("缺少参数时:")
|
|
147
148
|
lines.extend(f"- {item}" for item in missing_rules)
|
|
148
149
|
lines.append("")
|
|
149
|
-
lines.append("
|
|
150
|
-
lines.append(f"-
|
|
151
|
-
lines.append("-
|
|
150
|
+
lines.append("回退规则:")
|
|
151
|
+
lines.append(f"- 只有在 MCP 工具路径不可用,或用户明确要求走 CLI 时,才回退到 Bash + `{fallback_command}`。")
|
|
152
|
+
lines.append("- 向用户用中文简要总结结果。")
|
|
152
153
|
return filename, "\n".join(lines) + "\n"
|
|
153
154
|
|
|
154
155
|
|
|
@@ -157,190 +158,190 @@ def build_custom_command_templates(bin_dir: Path) -> dict[str, str]:
|
|
|
157
158
|
[
|
|
158
159
|
build_mcp_first_command_template(
|
|
159
160
|
filename="cgc.md",
|
|
160
|
-
description="
|
|
161
|
-
argument_hint="[
|
|
161
|
+
description="在当前项目中运行 CodeCGC",
|
|
162
|
+
argument_hint="[需求或参数]",
|
|
162
163
|
primary_tool="codecgc.entry",
|
|
163
164
|
direct_rules=[
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"
|
|
165
|
+
"如果用户提供的是自然语言需求,传给 `codecgc.entry`。",
|
|
166
|
+
"如果用户想继续最近的工作,使用 `codecgc.continue`。",
|
|
167
|
+
"如果用户想知道下一步做什么,使用 `codecgc.explain`。",
|
|
167
168
|
],
|
|
168
169
|
fallback_command="cgc",
|
|
169
170
|
),
|
|
170
171
|
build_mcp_first_command_template(
|
|
171
172
|
filename="cgc-install.md",
|
|
172
|
-
description="
|
|
173
|
-
argument_hint="[
|
|
173
|
+
description="为当前项目或 Claude 用户目录安装/同步 CodeCGC 集成",
|
|
174
|
+
argument_hint="[参数]",
|
|
174
175
|
primary_tool="codecgc.install",
|
|
175
176
|
direct_rules=[
|
|
176
|
-
"
|
|
177
|
-
"
|
|
177
|
+
"把安装参数映射到 `codecgc.install` 的 `mode`、`workspace`、`user_root` 等字段。",
|
|
178
|
+
"如果用户没有提供参数,就使用默认安装模式。",
|
|
178
179
|
],
|
|
179
180
|
fallback_command="cgc-install",
|
|
180
181
|
),
|
|
181
182
|
build_mcp_first_command_template(
|
|
182
183
|
filename="cgc-status.md",
|
|
183
|
-
description="
|
|
184
|
-
argument_hint="[
|
|
184
|
+
description="检查 CodeCGC 集成状态",
|
|
185
|
+
argument_hint="[参数]",
|
|
185
186
|
primary_tool="codecgc.status",
|
|
186
187
|
direct_rules=[
|
|
187
|
-
"
|
|
188
|
-
"
|
|
188
|
+
"使用 `codecgc.status` 检查安装与集成就绪状态。",
|
|
189
|
+
"如果用户明确给出目标项目目录,映射 `workspace`。",
|
|
189
190
|
],
|
|
190
191
|
fallback_command="cgc-status",
|
|
191
192
|
),
|
|
192
193
|
build_mcp_first_command_template(
|
|
193
194
|
filename="cgc-doctor.md",
|
|
194
|
-
description="
|
|
195
|
-
argument_hint="[
|
|
195
|
+
description="运行 CodeCGC 自检",
|
|
196
|
+
argument_hint="[参数]",
|
|
196
197
|
primary_tool="codecgc.doctor",
|
|
197
198
|
direct_rules=[
|
|
198
|
-
"
|
|
199
|
-
"
|
|
199
|
+
"使用 `codecgc.doctor` 检查运行时与集成健康状态。",
|
|
200
|
+
"如果用户明确给出目标项目目录,映射 `workspace`。",
|
|
200
201
|
],
|
|
201
202
|
fallback_command="cgc-doctor",
|
|
202
203
|
),
|
|
203
204
|
build_mcp_first_command_template(
|
|
204
205
|
filename="cgc-plan.md",
|
|
205
|
-
description="
|
|
206
|
-
argument_hint="[
|
|
206
|
+
description="规划或修复一个 CodeCGC 工作流",
|
|
207
|
+
argument_hint="[结构化规划参数]",
|
|
207
208
|
primary_tool="codecgc.plan",
|
|
208
209
|
direct_rules=[
|
|
209
|
-
"
|
|
210
|
-
"
|
|
210
|
+
"调用前提取 `flow`、`slug` 和 `summary`。",
|
|
211
|
+
"映射用户提供的 `target_paths`、`kind`,以及 `goal`、`acceptance`、`risk` 等规划字段和 issue 专属字段。",
|
|
211
212
|
],
|
|
212
213
|
missing_rules=[
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
214
|
+
"如果缺少 `flow`,询问这是 `feature` 还是 `issue` 工作流。",
|
|
215
|
+
"如果缺少 `slug`,询问稳定的工作流 slug。",
|
|
216
|
+
"如果缺少 `summary`,询问一个简短规划摘要。",
|
|
216
217
|
],
|
|
217
218
|
fallback_command="cgc-plan",
|
|
218
219
|
),
|
|
219
220
|
build_mcp_first_command_template(
|
|
220
221
|
filename="cgc-build.md",
|
|
221
|
-
description="
|
|
222
|
-
argument_hint="[
|
|
222
|
+
description="执行 CodeCGC 功能开发步骤",
|
|
223
|
+
argument_hint="[参数]",
|
|
223
224
|
primary_tool="codecgc.build",
|
|
224
225
|
direct_rules=[
|
|
225
|
-
"
|
|
226
|
-
"
|
|
226
|
+
"调用前提取 `slug`。",
|
|
227
|
+
"映射可选执行字段,如 `step_number`、`checklist_file`、`audit_root`、`timeout_seconds`、`session_id`、`dry_run`。",
|
|
227
228
|
],
|
|
228
229
|
missing_rules=[
|
|
229
|
-
"
|
|
230
|
+
"如果缺少 `slug`,询问目标功能工作流的 slug。",
|
|
230
231
|
],
|
|
231
232
|
fallback_command="cgc-build",
|
|
232
233
|
),
|
|
233
234
|
build_mcp_first_command_template(
|
|
234
235
|
filename="cgc-fix.md",
|
|
235
|
-
description="
|
|
236
|
-
argument_hint="[
|
|
236
|
+
description="执行 CodeCGC 问题修复步骤",
|
|
237
|
+
argument_hint="[参数]",
|
|
237
238
|
primary_tool="codecgc.fix",
|
|
238
239
|
direct_rules=[
|
|
239
|
-
"
|
|
240
|
-
"
|
|
240
|
+
"调用前提取 `slug`。",
|
|
241
|
+
"映射可选执行字段,如 `step_number`、`checklist_file`、`audit_root`、`timeout_seconds`、`session_id`、`dry_run`。",
|
|
241
242
|
],
|
|
242
243
|
missing_rules=[
|
|
243
|
-
"
|
|
244
|
+
"如果缺少 `slug`,询问目标问题工作流的 slug。",
|
|
244
245
|
],
|
|
245
246
|
fallback_command="cgc-fix",
|
|
246
247
|
),
|
|
247
248
|
build_mcp_first_command_template(
|
|
248
249
|
filename="cgc-test.md",
|
|
249
|
-
description="
|
|
250
|
-
argument_hint="[
|
|
250
|
+
description="执行 CodeCGC 测试步骤",
|
|
251
|
+
argument_hint="[参数]",
|
|
251
252
|
primary_tool="codecgc.test",
|
|
252
253
|
direct_rules=[
|
|
253
|
-
"
|
|
254
|
-
"
|
|
254
|
+
"调用前提取 `flow` 和 `slug`。",
|
|
255
|
+
"映射可选执行字段,如 `step_number`、`checklist_file`、`audit_root`、`timeout_seconds`、`session_id`、`dry_run`。",
|
|
255
256
|
],
|
|
256
257
|
missing_rules=[
|
|
257
|
-
"
|
|
258
|
-
"
|
|
258
|
+
"如果缺少 `flow`,询问该测试属于 `feature` 还是 `issue` 工作流。",
|
|
259
|
+
"如果缺少 `slug`,询问目标工作流 slug。",
|
|
259
260
|
],
|
|
260
261
|
fallback_command="cgc-test",
|
|
261
262
|
),
|
|
262
263
|
build_mcp_first_command_template(
|
|
263
264
|
filename="cgc-review.md",
|
|
264
|
-
description="
|
|
265
|
-
argument_hint="[
|
|
265
|
+
description="审核一份 CodeCGC 执行审计结果",
|
|
266
|
+
argument_hint="[参数]",
|
|
266
267
|
primary_tool="codecgc.review",
|
|
267
268
|
direct_rules=[
|
|
268
|
-
"
|
|
269
|
-
"
|
|
269
|
+
"调用前提取 `audit_file` 和 `decision`。",
|
|
270
|
+
"如果用户明确提供,映射可选字段 `risk`、`next_step`、`force`。",
|
|
270
271
|
],
|
|
271
272
|
missing_rules=[
|
|
272
|
-
"
|
|
273
|
-
"
|
|
273
|
+
"如果缺少 `audit_file`,询问审计 JSON 路径。",
|
|
274
|
+
"如果缺少 `decision`,询问审核结论是 `accepted` 还是 `changes-requested`。",
|
|
274
275
|
],
|
|
275
276
|
fallback_command="cgc-review",
|
|
276
277
|
),
|
|
277
278
|
build_mcp_first_command_template(
|
|
278
279
|
filename="cgc-route.md",
|
|
279
|
-
description="
|
|
280
|
-
argument_hint="[
|
|
280
|
+
description="为 CodeCGC 工作流推荐下一条命令",
|
|
281
|
+
argument_hint="[参数]",
|
|
281
282
|
primary_tool="codecgc.route",
|
|
282
283
|
direct_rules=[
|
|
283
|
-
"
|
|
284
|
-
"
|
|
284
|
+
"调用前提取 `flow` 和 `slug`。",
|
|
285
|
+
"当用户已经知道目标工作流,只想得到下一步推荐动作时,使用这个命令。",
|
|
285
286
|
],
|
|
286
287
|
missing_rules=[
|
|
287
|
-
"
|
|
288
|
-
"
|
|
288
|
+
"如果缺少 `flow`,询问工作流是 `feature` 还是 `issue`。",
|
|
289
|
+
"如果缺少 `slug`,询问工作流 slug。",
|
|
289
290
|
],
|
|
290
291
|
fallback_command="cgc-route",
|
|
291
292
|
),
|
|
292
293
|
build_mcp_first_command_template(
|
|
293
294
|
filename="cgc-history.md",
|
|
294
|
-
description="
|
|
295
|
-
argument_hint="[
|
|
295
|
+
description="查看最近的 CodeCGC 工作流历史",
|
|
296
|
+
argument_hint="[参数]",
|
|
296
297
|
primary_tool="codecgc.history",
|
|
297
298
|
direct_rules=[
|
|
298
|
-
"
|
|
299
|
-
"
|
|
299
|
+
"映射可选历史筛选字段,如 `flow`、`status`、`last`、`include_fixtures`。",
|
|
300
|
+
"如果没有提供筛选条件,就使用默认历史查询。",
|
|
300
301
|
],
|
|
301
302
|
fallback_command="cgc-history",
|
|
302
303
|
),
|
|
303
304
|
build_mcp_first_command_template(
|
|
304
305
|
filename="cgc-package-audit.md",
|
|
305
|
-
description="
|
|
306
|
-
argument_hint="[
|
|
306
|
+
description="审计 CodeCGC 发布包运行时内容",
|
|
307
|
+
argument_hint="[参数]",
|
|
307
308
|
primary_tool="codecgc.package_audit",
|
|
308
309
|
direct_rules=[
|
|
309
|
-
"
|
|
310
|
-
"
|
|
310
|
+
"当用户明确要求 `summary` 或 `json` 时,映射 `format`。",
|
|
311
|
+
"该命令用于发布包和运行时完整性检查。",
|
|
311
312
|
],
|
|
312
313
|
fallback_command="cgc-package-audit",
|
|
313
314
|
),
|
|
314
315
|
build_mcp_first_command_template(
|
|
315
316
|
filename="cgc-external-audit.md",
|
|
316
|
-
description="
|
|
317
|
-
argument_hint="[
|
|
317
|
+
description="审计外部 MCP 能力注册与接入状态",
|
|
318
|
+
argument_hint="[参数]",
|
|
318
319
|
primary_tool="codecgc.external_audit",
|
|
319
320
|
direct_rules=[
|
|
320
|
-
"
|
|
321
|
-
"
|
|
321
|
+
"映射可选字段 `workspace` 和 `format`。",
|
|
322
|
+
"该命令用于外部能力策略与注册检查。",
|
|
322
323
|
],
|
|
323
324
|
fallback_command="cgc-external-audit",
|
|
324
325
|
),
|
|
325
326
|
build_mcp_first_command_template(
|
|
326
327
|
filename="cgc-release-readiness.md",
|
|
327
|
-
description="
|
|
328
|
-
argument_hint="[
|
|
328
|
+
description="运行 CodeCGC 发布就绪检查",
|
|
329
|
+
argument_hint="[参数]",
|
|
329
330
|
primary_tool="codecgc.release_readiness",
|
|
330
331
|
direct_rules=[
|
|
331
|
-
"
|
|
332
|
-
"
|
|
332
|
+
"映射可选字段 `workspace` 和 `format`。",
|
|
333
|
+
"该命令用于联合检查发布、维护和运维就绪状态。",
|
|
333
334
|
],
|
|
334
335
|
fallback_command="cgc-release-readiness",
|
|
335
336
|
),
|
|
336
337
|
build_mcp_first_command_template(
|
|
337
338
|
filename="cgc-lifecycle.md",
|
|
338
|
-
description="
|
|
339
|
-
argument_hint="[
|
|
339
|
+
description="审计 CodeCGC 生命周期覆盖情况",
|
|
340
|
+
argument_hint="[参数]",
|
|
340
341
|
primary_tool="codecgc.lifecycle",
|
|
341
342
|
direct_rules=[
|
|
342
|
-
"
|
|
343
|
-
"
|
|
343
|
+
"当用户明确要求 `summary` 或 `json` 时,映射 `format`。",
|
|
344
|
+
"该命令用于检查 roadmap、workflow、execution 的生命周期覆盖情况。",
|
|
344
345
|
],
|
|
345
346
|
fallback_command="cgc-lifecycle",
|
|
346
347
|
),
|
|
@@ -919,6 +920,17 @@ def build_local_editable_install_command(python_command: str) -> str:
|
|
|
919
920
|
)
|
|
920
921
|
|
|
921
922
|
|
|
923
|
+
def format_bool_zh(value: Any) -> str:
|
|
924
|
+
return "是" if bool(value) else "否"
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
def format_list_zh(items: Any, empty_text: str = "无") -> str:
|
|
928
|
+
if not isinstance(items, list):
|
|
929
|
+
return empty_text
|
|
930
|
+
values = [str(item).strip() for item in items if str(item).strip()]
|
|
931
|
+
return "、".join(values) if values else empty_text
|
|
932
|
+
|
|
933
|
+
|
|
922
934
|
def classify_doctor_failures(
|
|
923
935
|
checks: list[dict[str, Any]],
|
|
924
936
|
configured_python_command: str,
|
|
@@ -1232,12 +1244,12 @@ def main() -> int:
|
|
|
1232
1244
|
lines = [
|
|
1233
1245
|
f"- 工作区: {result.get('workspace', '')}",
|
|
1234
1246
|
f"- 范围: {summary.get('scope', '')}",
|
|
1235
|
-
f"- 项目级就绪: {
|
|
1236
|
-
f"- 用户级就绪: {
|
|
1247
|
+
f"- 项目级就绪: {format_bool_zh(summary.get('project_ready'))}",
|
|
1248
|
+
f"- 用户级就绪: {format_bool_zh(summary.get('user_ready'))}",
|
|
1237
1249
|
f"- 策略: {summary.get('default_policy', '')}",
|
|
1238
1250
|
f"- 摘要: {summary.get('human_summary', '')}",
|
|
1239
|
-
f"-
|
|
1240
|
-
f"-
|
|
1251
|
+
f"- 项目级缺失项: {format_list_zh(project.get('missing_or_outdated', []))}",
|
|
1252
|
+
f"- 用户级缺失项: {format_list_zh(user.get('missing_or_outdated', []))}",
|
|
1241
1253
|
]
|
|
1242
1254
|
recommended_project = str(summary.get("recommended_project_command", "")).strip()
|
|
1243
1255
|
recommended_user = str(summary.get("recommended_user_command", "")).strip()
|
|
@@ -1252,11 +1264,11 @@ def main() -> int:
|
|
|
1252
1264
|
lines = [
|
|
1253
1265
|
f"- 工作区: {result.get('workspace', '')}",
|
|
1254
1266
|
f"- 范围: {summary.get('scope', '')}",
|
|
1255
|
-
f"- 就绪: {
|
|
1267
|
+
f"- 就绪: {format_bool_zh(summary.get('ready'))}",
|
|
1256
1268
|
f"- 摘要: {summary.get('human_summary', '')}",
|
|
1257
1269
|
]
|
|
1258
1270
|
failed_checks = summary.get("failed_checks", [])
|
|
1259
|
-
lines.append(f"- 失败检查项: {
|
|
1271
|
+
lines.append(f"- 失败检查项: {format_list_zh(failed_checks)}")
|
|
1260
1272
|
failure_categories = summary.get("failure_categories", [])
|
|
1261
1273
|
for item in failure_categories:
|
|
1262
1274
|
if not isinstance(item, dict):
|
|
@@ -1273,7 +1285,7 @@ def main() -> int:
|
|
|
1273
1285
|
fix_command = str(summary.get("recommended_fix_command", "")).strip()
|
|
1274
1286
|
runtime_fix_command = str(summary.get("recommended_runtime_fix_command", "")).strip()
|
|
1275
1287
|
next_actions = [item for item in [runtime_fix_command, fix_command] if item]
|
|
1276
|
-
print(render_summary_block("CodeCGC
|
|
1288
|
+
print(render_summary_block("CodeCGC 自检", lines, next_actions))
|
|
1277
1289
|
return 0 if result.get("success") else 1
|
|
1278
1290
|
|
|
1279
1291
|
if args.format == "summary" and args.mode in {"local", "user-dry-run", "user"}:
|