Skip to content

fix(skills): stop executing escape sequences embedded in SKILL.md descriptions - #175601

Closed
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/skills-list-terminal-controls
Closed

wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/skills-list-terminal-controls

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw skills list prints each skill's description and source verbatim, so a workspace skill whose SKILL.md frontmatter carries ESC/BEL sequences changes the operator's terminal while they list skills.

User Impact

User impact: the skills table renders skill text as text and no longer interprets escapes embedded in a workspace SKILL.md; skills list --json keeps the raw values for scripts.

Why This Change Was Made

The single-skill report in the same module already sanitizes the same fields (skills info passes name, description, source, and homepage through sanitizeForLog), while the list row builder handed them to the table raw. The row builder now sanitizes description, source, and the verbose missing-requirements summary before theming.

One existing case changes meaning: skills-cli.formatting.test.ts previously asserted that a C1 sequence stayed in the description cell ("left right", i.e. the escape was still delivered and only its layout effect was measured). The cell now carries only printable text, so the case asserts "leftright" and that the report contains no C1 byte — same fixture, escape removed instead of forwarded.

Evidence

  • Base 711eb843136, head 97d9379f732; secretless Linux container, Node 24.18.0, isolated HOME/OPENCLAW_STATE_DIR.
  • Fixture: a workspace skill at <state>/workspace/skills/evil/SKILL.md whose frontmatter description is Evil \x1b[31mRED\x1b[0m \x1b[2Kbell\x07 cr\r end.
  • Real entry, identical command on both revisions (node --import ./scripts/tsx.mjs src/entry.ts skills list), counting raw C0/C1 bytes:
base this head
description cell Evil ^[[31mRED^[[0m ^[[2Kbell^G cr end Evil RED bell cr end
ESC / BEL / CSI bytes in the report 3 / 1 / 3 0 / 0 / 0

Focused regression, red on base and green on head:

base  × strips C1 terminal escapes from table descriptions
      → expected 'left right' to be 'leftright'
base  × strips terminal control sequences from table descriptions and sources
      → expected 'Evil \u001b[31mRED\u001b[0m\u0007 tail' to be 'Evil RED tail'
head    Test Files 1 passed | Tests 3 passed

Command: node_modules/.bin/vitest run --config vitest.config.ts src/cli/skills-cli.formatting.test.ts --maxWorkers=1. Oxfmt and Oxlint clean on the changed files.

@clawsweeper

clawsweeper Bot commented Oct 17, 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 cli CLI command changes size: XS labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR filters terminal controls from skill-list descriptions, sources, and verbose requirements while preserving layout whitespace.

Example: Run openclaw skills list with a workspace description containing color escapes and BEL around RED.

  • Before: The table forwards embedded terminal controls.
  • After: The table displays RED without those controls and preserves ordinary word spacing.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused boundary fix with supplied production-entry proof, preserved whitespace contracts, and the previous finding resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The contributor supplies base/head output through the real skills-list CLI entry with isolated Linux state and a workspace SKILL.md fixture; the reviewed revision removes embedded ESC/BEL/CSI bytes while preserving readable text.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Listing workspace skills can interpret terminal controls embedded in skill descriptions.
Reason: The change extends established terminal sanitization and preserves documented spacing without adding settings, APIs, or persisted state.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current terminal-control defect, resolves the previous whitespace finding, and has no actionable introduced defects.

Priority: P2
Reviewed head: 482ceb2f037c1c5d4d5200b63eca984e7ef30202

Before merge

None.

Findings

None.

Agent review details

How this fits together

Skill discovery supplies metadata to the CLI formatter, which produces styled terminal tables or filtered JSON.

flowchart LR
  A[Workspace skill files] --> B[Skill discovery]
  B --> C[Skill status report]
  C --> D[CLI formatter]
  D --> E[Control filtering and table layout]
  E --> F[Terminal output]
  D --> G[JSON serialization]
Loading

Technical review

Best possible solution:

Land whitespace-preserving filtering at the existing skill-list rendering boundary while coordinating the overlapping descriptor-hardening work.

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

Current-main source exposes the reported controls, and supplied base/head CLI output confirms the mechanism; this review executed no target code.

Is this the best way to solve the issue?

Reusing the existing whitespace-preserving filter before trusted styling fixes the rendering boundary without changing discovery metadata or existing JSON filtering.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8cfa2ec42441.

Provenance checked

  • Skills table metadata rendering changes intended behavior with a stated reason (4bf68b9: The CLI consolidation carried existing row values into a shared renderer without intended behavior changes; it does not establish the defect's introduction.)
  • JSON control filtering and whitespace keeps the original intent (bfcf106: Preserve tabs and line endings for JSON escaping while retaining ANSI/C1 cleanup; the renamed filter keeps that algorithm.)
  • C1 tab-spacing regression keeps the original intent (31c21b3: Render table tabs as the single spaces used for measurement; the revision retains that expectation and additionally rejects raw C1 controls.)
  • Human-readable skill sanitization keeps the original intent (cb58e45: Earlier hardening sanitized skill names and single-skill report fields against terminal escape injection.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit b6d8374 adds src/cli/skills-cli.format.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b6d83749c865; files: src/cli/skills-cli.format.ts)

PR surface

Source +6, Tests +24. Total +30 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 15 9 +6
Tests 1 25 1 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 40 10 +30

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Workspace skill descriptions can inject terminal controls during skill inspection, with the demonstrated impact limited to CLI reports.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T14:40:12.310Z sha 97d9379f732315cec40021e1e61b3256ae9ffcdc :: needs changes before merge. :: [P2] Preserve description whitespace while removing terminal escapes

Reviewed October 17, 2026, 10:59 AM ET / 14:59 UTC (Revision 2).

@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Revision 482ceb2f037 addresses the P2 finding: the table now uses the same whitespace-preserving control filter the JSON path already used (stripAnsi + drop C0/C1/DEL except tab and line endings), so First\nSecond\tcolumn keeps its spacing while ESC/BEL/C1 never reach the terminal.

Base vs this head, real entry, same workspace-skill fixture (description = "Evil \x1b[31mRED\x1b[0m \x1b[2Kbell\x07 cr\r end", node --import ./scripts/tsx.mjs src/entry.ts skills list):

base this head
description cell Evil ^[[31mRED^[[0m ^[[2Kbell^G cr end Evil RED bell cr end
ESC / BEL / CSI bytes 3 / 1 / 3 0 / 0 / 0

The pre-existing spaced-word case is back to its original expectation and now also asserts no C1 byte:

✓ keeps C1 tab-separated descriptions in their table cell   (cell stays "left right")
✓ strips terminal control sequences from table descriptions and sources
✓ preserves description and path whitespace in skills JSON output

node_modules/.bin/vitest run --config vitest.config.ts src/cli/skills-cli.formatting.test.ts --maxWorkers=1; Oxfmt and Oxlint clean on the changed files.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
…criptions

The skills table passed workspace-owned SKILL.md description and source straight
to the terminal, while the single-skill report already sanitized the same fields.
sanitizeForLog also removed tabs and line endings, which the skills table renders
as spacing. Reuse the whitespace-preserving control filter the JSON path already
used, and restore the spaced-word table expectation.
@wangmiao0668000666
wangmiao0668000666 force-pushed the fix/skills-list-terminal-controls branch from 482ceb2 to e21aca0 Compare October 21, 2026 14:59
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (0a5bb404). #178778 rebuilt the list rows (status/emoji/name locals) in skills-cli.format.ts; the sanitizer is applied inside that new structure, and the whitespace-preserving helper replaces the JSON-only name. The "not found" path keeps sanitizePreservingWhitespace(sanitizeForLog(...)).

Local proof: pnpm exec vitest run src/cli/skills-cli.formatting.test.ts --maxWorkers=1 → 3/3 passed; oxlint + format clean. CI is running on e21aca03.

@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666. #172872 (merged as 1d4ef25) now fixes this on main: human skill and hook reports pass names, descriptions and paths through the shared terminal-safe text owner, so escape sequences from SKILL.md descriptions are no longer printed. A built-CLI check showed main printing them and the fix printing none, with JSON output unchanged. Closing as superseded; your report helped confirm the scope.

@obviyus obviyus closed this Oct 23, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus — confirmed on main: skills-cli.format.ts now routes names, descriptions, and paths through sanitizeCliDescriptorText/sanitizeTerminalText, so the SKILL.md escape-sequence case is fully covered with JSON output unchanged. Fully agree with unifying on the shared terminal-safe text owner rather than a per-table filter. Happy the report helped confirm the scope. 🙏

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

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

2 participants