Repository navigation
fix(cli): strip terminal controls from Claw project reports - #180625
wangmiao0668000666 wants to merge 2 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR sanitizes project paths and identities in human-readable Claw reports while preserving raw JSON output. Example: Validate a project containing a file named payload\u001b[2J\u0007\n.bin.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current terminal-rendering defect with a focused change and sufficient packaged-CLI proof; the previous Windows finding is resolved, and no introduced correctness defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Claw CLI invokes project creation, validation, building, and preview owners, then renders their results as human-readable reports or JSON. flowchart TD
A[Claw CLI commands] --> B[Project lifecycle owners]
B --> C[Result values]
C --> D[Terminal text sanitizer]
D --> E[Human report]
C --> F[Raw JSON output]
Technical reviewBest possible solution: Retain the focused sanitization at the existing human-report boundary and land after the required exact-head checks pass. Do we have a high-confidence way to reproduce the issue? Current-main interpolation exposes filesystem-derived control characters, and the contributor supplies matching baseline-versus-head packaged-CLI output; this review ran no target code. Is this the best way to solve the issue? Reusing the canonical sanitizer at human-output interpolation is the smallest complete fix for the reported fields, preserves JSON bytes, and introduces no competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d2c70ddbf19f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +9, Tests +28. Total +37 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 22, 2026, 1:07 PM ET / 17:07 UTC (Revision 2). |
…w report Co-Authored-By: Claude Code <[email protected]>
17be788 to
d672ae3
Compare
|
@clawsweeper re-review Revision 2 (head
|
|
🦞👀 Re-review progress:
|
What Problem This Solves
openclaw claws create|validate|build|devwrite values taken from the project being inspected straight into the human report. In particular,openclaw claws validate <project>prints every entry it excludes:A checked-out Claw project can contain file and directory names with terminal control bytes, so validating a third-party project can clear the screen (
ESC [2J), ring the terminal (BEL), or forge an extra report line with an embedded newline. The requested project root, thePackage: <name>@<version>/Built Claw: <name>@<version>lines, and theClaw dev previewagent/workspace lines are written through the same boundary.Precedent: #174989 (same module, same
sanitizeTerminalTexthelper).Why This Change Was Made
The human report in
src/cli/claws-cli.project.tsis a terminal rendering boundary, andsanitizeTerminalTextinpackages/terminal-core/src/safe-text.tsis the canonical filter for it.src/cli/claws-cli-output.tsalready imports that helper for diagnostics, so this reuses the owner that is already in place instead of adding a validator, option, or output format.The interpolated report lines now pass their value through the helper: the project root (
create,validate), the package name and version (create,validate,build,dev), each excluded path (validate), and the dev preview's agent id and workspace path. The--jsonbranches are untouched.Packagename/version are additionally constrained by the canonical ClawHub-name and exact-semver checks insrc/claws/reader.ts, so the control bytes reachable today come from the project root, excluded file names, and the preview workspace path; the identity lines are wrapped at the same boundary so the report does not depend on an upstream validator staying control-free.Classification:
behavior-completingUser Impact
Operators can validate, build, or preview a Claw project without its directory or file names driving the terminal: ESC/BEL are removed and a newline renders as the two characters
\n, so each report line stays on one line. Values without control bytes, including the package identity and ordinary excluded paths, print exactly as before.--jsoncallers receive the original bytes.Evidence (real behavior proof, 2026-10-22 UTC)
Packaged-CLI RED→GREEN on the supported runtime: both builds produced with the repo's own
scripts/tsdown-build.mts+runtime-postbuildchain on Node 24.22.1 (satisfiesengines.node >=24.22.1 <25), run asnode dist/index.js claws …subprocesses in an isolated Linux container withOPENCLAW_STATE_DIR/OPENCLAW_WORKSPACE_DIRpointed at throwaway dirs. No Gateway, session, token, or real config touched.d672ae35b7ae8dc1c377eab85e744aa2765cebaf(exact PR head)ae40e1864ba6ea2a8d0f37362933c6bbf59b2cff(currentmain, the rebase target)The fixture: project directory
author<ESC>[2J<BEL>plus an excluded file namedpayload<ESC>[2J<BEL>.bin.<ESC>is the raw byte0x1b,<BEL>is0x07; output below is shown throughcat -v(^[= ESC,^G= BEL).RED —
maindist, human reports:GREEN — exact-head dist, same commands:
JSON preservation (both revisions,
--json):rootandexcludedPathscarry the original bytes (4\u001bescapes present in the payload), so machine consumers are unaffected. Legal control:Package: [email protected]and the artifact integritysha256:5f2af05a…are byte-identical across revisions.Regression test
src/cli/claws-cli.project.test.tsdrivesrunClawsCreateCommand/runClawsValidateCommand/runClawsDevCommandagainst real files on disk and asserts the human report contains no control characters while the JSON payload preserves them. The control-character filesystem fixture is guarded to POSIX (it.skipIf(process.platform === "win32")), because Windows rejects those bytes in file names and would fail in fixture setup instead of exercising the sanitizer.Revision 2 changes
main(ae40e1864b), which also clears the inheritedcheck-test-types-core-4red (that failure was main's ownsessions-patch.test.ts/PatchFixtureskew, fixed upstream in test(gateway): use current fixture for session appearance checks #180628).Claw dev previewhuman report (build.claw.name/version,plan.agent.finalId,plan.agent.workspace), and the regression exercises it.Scope and risk
+19/-6net across create/validate/build/dev human-report lines; 2 files, no new filessanitizeTerminalText, the helper already imported bysrc/cli/claws-cli-output.tsper fix(cli): strip terminal controls from the inspected Claw agent name #174989; no new validator, option, config, or output format