Skip to content

fix(cli): preserve whitespace in skills JSON output - #140780

Merged
steipete merged 1 commit into
mainfrom
codex/qa2-02-skills-json-20260907
Sep 7, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa2-02-skills-json-20260907

Conversation

@steipete

@steipete steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Related: #140581

What Problem This Solves

Fixes an issue where users reading skills list, skills info, or skills check JSON would lose tabs and line endings in descriptions and paths. For example, a valid loaded description containing First paragraph.\nSecond\tcolumn. became First paragraph.Secondcolumn..

Why This Change Was Made

Preserve tabs, LF, and CR for JSON's normal escaping while retaining the existing ANSI/C1 cleanup. Build on the native JSON replacer already merged in #140581 by sharing serialization across list, info, check, and missing-skill errors. Main's lazy formatting of human-only error text remains intact. The earlier recursion removal belongs to #140581; this change has a net production delta of -1 line.

User Impact

Scripts can read descriptions and paths without silently losing meaningful whitespace. Human-readable table spacing and existing terminal escape cleanup remain unchanged.

Evidence

  • A regression loads a real workspace SKILL.md, confirms the loader preserves LF/CR/tab, and fails on the original formatter's collapsed JSON. It covers list/info descriptions and list/check paths.
  • All 38 tests in src/cli/skills-cli.formatting.test.ts and src/cli/skills-cli.test.ts passed, including existing ANSI/C1 cleanup, missing-skill JSON, and table spacing.
  • The owning CLI test type graph, full-file typed lint, formatting, docs index, and diff checks passed. Independent P2 review found no actionable findings.
  • These checks preceded the mechanical integration onto main containing refactor: streamline skills JSON output #140581. The integration preserves the reviewed fix, test, and docs plus main's existing lazy human-error formatting; final CI runs against the pushed head.

No Gateway or provider is needed for this formatting boundary. Production net -1 line; tests +22, docs +2.

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 7, 2026
@steipete
steipete marked this pull request as ready for review September 7, 2026 04:26
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:32 AM ET / 04:32 UTC.

ClawSweeper review

What this changes

Preserves tabs and line endings in skills JSON output through shared serialization, with regression coverage and CLI documentation.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still removes meaningful whitespace from skills JSON. This focused repair remains useful, and no actionable correctness or security findings were found.

Priority: P2
Reviewed head: d0a8f483dbf8a37bbbba05dc58fca644b1691ea6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage, matching documentation, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author classification exempts this formatter repair from the external-contributor proof gate; the workspace-loader regression and reported checks are supplemental validation, not a claimed live CLI run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author classification exempts this formatter repair from the external-contributor proof gate; the workspace-loader regression and reported checks are supplemental validation, not a claimed live CLI run.
Evidence reviewed 6 items Current main retains the defect: The fetched main revision removes every C0 character, including tab, LF, and CR, before JSON serialization. The whitespace repair is therefore still necessary.
Introduced repair preserves sanitization: The pinned introduced patch excludes only tab, LF, and CR from control removal and routes all four JSON branches through the same native JSON replacer. ANSI, remaining escape sequences, DEL, and C1 cleanup remain.
Regression protects observable values: The added test writes a workspace SKILL.md, checks the loaded description, and compares parsed list/info descriptions and list/check paths against their original values. The original main sanitizer necessarily violates these assertions.
Findings None None.
Security None None.

How this fits together

The skills CLI formats inventory obtained from the Gateway or local discovery. Its formatter produces human-readable tables or JSON consumed by scripts.

flowchart LR
  A[Gateway inventory] --> C[Skills CLI formatter]
  B[Local skill discovery] --> C
  C --> D{Output format}
  D --> E[Human-readable tables]
  D --> F[Sanitize controls and escape JSON]
  F --> G[Script-readable skill data]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1, Tests +22, Docs +2. Total +23 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 49 50 -1
Tests 1 22 0 +22
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 73 50 +23

Review metrics

None.

Technical review

Best possible solution:

Preserve semantic whitespace through JSON escaping while retaining the existing terminal-control sanitizer and human-output behavior.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: loaded descriptions or paths containing tabs, LF, or CR lose those characters through main's sanitizer. The added regression exercises that boundary; it was not executed during this review.

Is this the best way to solve the issue?

Yes. Adjusting the existing sanitizer and sharing serialization fixes the output boundary without changing discovery, configuration, or the JSON schema.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2eae7eb46e92.

Labels

Label changes:

  • add P2: Repairs silent alteration of descriptions and paths in machine-readable skills output with a limited formatter-level blast radius.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author classification exempts this formatter repair from the external-contributor proof gate; the workspace-loader regression and reported checks are supplemental validation, not a claimed live CLI run.

Label justifications:

  • P2: Repairs silent alteration of descriptions and paths in machine-readable skills output with a limited formatter-level blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author classification exempts this formatter repair from the external-contributor proof gate; the workspace-loader regression and reported checks are supplemental validation, not a claimed live CLI run.

Evidence

What I checked:

  • Current main retains the defect: The fetched main revision removes every C0 character, including tab, LF, and CR, before JSON serialization. The whitespace repair is therefore still necessary. (src/cli/skills-cli.format.ts:71, 2eae7eb46e92)
  • Introduced repair preserves sanitization: The pinned introduced patch excludes only tab, LF, and CR from control removal and routes all four JSON branches through the same native JSON replacer. ANSI, remaining escape sequences, DEL, and C1 cleanup remain. (src/cli/skills-cli.format.ts:71, d0a8f483dbf8)
  • Regression protects observable values: The added test writes a workspace SKILL.md, checks the loaded description, and compares parsed list/info descriptions and list/check paths against their original values. The original main sanitizer necessarily violates these assertions. (src/cli/skills-cli.formatting.test.ts:146, d0a8f483dbf8)
  • Human-output safety remains intact: The missing-skill human error still calls sanitizeForLog first; that helper removes all C0/C1 controls and DEL. JSON serialization escapes the newly preserved whitespace instead of emitting raw control characters. (packages/terminal-core/src/ansi.ts:168, d0a8f483dbf8)
  • Related merged work is distinct: The supplied GitHub context verifies refactor: streamline skills JSON output #140581 as merged. It optimized serialization while preserving output bytes; it did not repair whitespace loss. Current-main history also records several earlier formatter changes by Peter Steinberger. (src/cli/skills-cli.format.ts, 7ca372ab85c7)
  • Validation and inspection limits: The captured PR body reports 38 passing focused tests and static checks before mechanical integration. No tests were executed in this read-only review. Main and head source were inspected successfully; release-source and detailed historical patch/blame reads could not complete because required blobs were unavailable and GitHub DNS resolution failed. No shipped-fix or introduction attribution is claimed. (d0a8f483dbf8)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit bfcf106 into main Sep 7, 2026
218 checks passed
@steipete
steipete deleted the codex/qa2-02-skills-json-20260907 branch September 7, 2026 05:08
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant