CLI --baseline flattens JSON payloads and resolves paths differently from MCP tools

未关闭
#103 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
api, cli

调研方向

Start with the baseline handling in src/cli.ts:364-381 and compare it with the MCP handlers in src/tools/scenes.ts and src/tools/lint.ts; then read src/baseline.ts to trace how relative paths are resolved. The proposed parity test belongs in test/tools.test.ts, alongside the existing CLI shape assertion in test/cli.test.ts. Done means every listed command preserves its payload shape, CLI and MCP agree on baseline behavior, the path rule is consistent or documented, and the CHANGELOG records the JSON shape change.

由索引模型根据 Issue 内容生成。

描述

bug help wanted severity: medium

Summary

With --baseline, the CLI replaces every command's JSON payload with a generic {root, findings, count, baselined, staleBaselineEntries}. With a baseline argument, the MCP tools keep each command's own shape. Relative baseline paths also resolve differently: against the cwd in the CLI, and against the project root in MCP. Two hand-written "apply baseline" implementations have already drifted.

Where

  • src/cli.ts:364-381 (generic payload replacement)
  • src/baseline.ts:105-108, src/baseline.ts:133-141 (readBaseline uses the cwd; baselineFindings uses the root)
  • src/tools/scenes.ts:26-30, src/tools/scenes.ts:79-85, src/tools/scenes.ts:97-120; src/tools/lint.ts:62-76
  • test/cli.test.ts:147-155 (asserts the flat shape); the parity test at test/tools.test.ts:131 runs only without a baseline

Details

if (baseline) {
  const r = applyBaseline(root, res.findings, readBaseline(baseline));
  res = { root, findings: r.newFindings,
          payload: { root, findings: r.newFindings, count: r.newFindings.length,
                     baselined: r.baselined, staleBaselineEntries: r.stale } };

With a baseline:

  • gdcorrect report loses the scenes/project/registries/lint categories, registryEntries and the severity counts.
  • lint loses godotVersion, fileCount and the counts.
  • validate-registries loses entries.

MCP project_report and lint_project keep their shape and recompute the counts. MCP validate_registries keeps entries but has no count.

Impact

Scripts that parse gdcorrect ... --format json break, or read undefined, as soon as a baseline is added. The per-command JSON shapes in the docs only hold without a baseline. One baseline file cannot be referenced with the same relative path from CI and from an agent: game/.gdbaseline.json from the repo root, versus the MCP root-relative game/game/....

Suggested fix

Incremental plan:

  1. Add a parity test. For each of lint, validate-scenes, validate-project, validate-registries and report, compare CLI --baseline JSON with the matching MCP tool output given baseline.
  2. Add a severityCounts(findings) helper and replace the five hand-written copies (src/cli.ts, src/lint/project.ts, src/scenes/report.ts, src/tools/lint.ts, src/tools/scenes.ts).
  3. Move the per-command "apply baseline, keep shape, add baselined/staleBaselineEntries" logic into one shared module, used by both runCommand and the tool handlers.
  4. Delete the generic payload in cli.ts, and add count to the registries payload.
  5. Choose one resolution rule for relative baseline paths and document it. Root-relative is what MCP already documents.

Acceptance criteria

  • CLI and MCP JSON are identical for every command, with and without a baseline.
  • The resolution rule for relative baseline paths is the same in both front ends, or the difference is documented in --help and README.
  • CHANGELOG notes the CLI JSON shape change.

Filed by repo-audit/full-audit at e836036. Severity: medium. Effort: M. audit-key: bug|src/cli.ts|runCli.baseline-payload

主要语言
TypeScript
星标
0
派生
6
平均合并
1 天 21 小时
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/godot-correctness-mcp 的其他 Issue

查看 TMHSDigital/godot-correctness-mcp 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。