Skip to content

fix(cli): route skills list output to stdout when --json is active - #57611

Closed
Aftabbs wants to merge 0 commit into
openclaw:mainfrom
Aftabbs:fix/skills-list-json-stdout-57599
Closed

Aftabbs wants to merge 0 commit into
openclaw:mainfrom
Aftabbs:fix/skills-list-json-stdout-57599

Conversation

@Aftabbs

@Aftabbs Aftabbs commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

openclaw skills list --json (and skills info --json, skills check --json) was writing JSON output to stderr instead of stdout since v2026.3.23, breaking any tooling that captures stdout.

Root cause: runSkillsAction used defaultRuntime.log() which calls console.log. The --json CLI preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Commands that correctly emit JSON use defaultRuntime.writeStdout() / defaultRuntime.writeJson(), which write directly to process.stdout and bypass the redirect.

Fix: Replace defaultRuntime.log(render(report)) with defaultRuntime.writeStdout(render(report)) in runSkillsAction. This is a one-line change that aligns with the existing pattern already used by skills search --json.

Affected commands (all sharing runSkillsAction)

  • skills list --json (primary reporter)
  • skills info --json
  • skills check --json

Test impact

No test changes needed. The test runtime capture (createCliRuntimeCapture) already routes writeStdout through log internally, so runtimeLogs continues to capture output in tests exactly as before.

Verification

# Before fix:
openclaw skills list --json 1>/tmp/out.txt 2>/tmp/err.txt
wc -c /tmp/out.txt /tmp/err.txt  # stdout: 0 bytes, stderr: 20000+ bytes

# After fix:
openclaw skills list --json 1>/tmp/out.txt 2>/tmp/err.txt
wc -c /tmp/out.txt /tmp/err.txt  # stdout: 20000+ bytes, stderr: 0 bytes

Fixes #57599

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Mar 30, 2026
@greptile-apps

greptile-apps Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a regression (introduced in v2026.3.23) where skills list --json, skills info --json, and skills check --json were writing JSON output to stderr instead of stdout, breaking any tooling that captures stdout.

Root cause: runSkillsAction used defaultRuntime.log() which internally calls console.log. The --json CLI preAction hook (routeLogsToStderr()) redirects console.log to stderr, so all three commands' JSON output was silently landing on the wrong stream.

Fix: A one-line change replaces defaultRuntime.log(render(report)) with defaultRuntime.writeStdout(render(report)), which writes directly to process.stdout and bypasses the redirect — exactly matching the pattern already used by skills search --json.

  • Test compatibility is maintained: createCliRuntimeCapture's writeStdout mock internally delegates to log, so runtimeLogs assertions in existing tests are unaffected.
  • The fix is minimal, targeted, and consistent with the established pattern in the same file.

Confidence Score: 5/5

Safe to merge — minimal one-line fix with no test changes needed and verified backward-compatibility with the test capture harness.

The change is a single-line swap from log to writeStdout, directly addresses the root cause described in the PR, is consistent with the existing pattern in the same file (skills search --json), and has no impact on test coverage since createCliRuntimeCapture routes writeStdout through log internally. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/skills-cli.ts One-line fix replacing defaultRuntime.log with defaultRuntime.writeStdout in runSkillsAction, correctly routing JSON output to stdout instead of stderr when --json is active.

Reviews (1): Last reviewed commit: "fix(cli): route skills list output to st..." | Re-trigger Greptile

@Aftabbs
Aftabbs force-pushed the fix/skills-list-json-stdout-57599 branch from 1cf2d0d to f2ac558 Compare April 1, 2026 08:42
@altaywtf altaywtf self-assigned this Apr 4, 2026
@altaywtf altaywtf closed this Apr 4, 2026
@altaywtf
altaywtf force-pushed the fix/skills-list-json-stdout-57599 branch from 8d4e528 to 16e7e25 Compare April 4, 2026 14:45
@altaywtf

altaywtf commented Apr 4, 2026

Copy link
Copy Markdown
Member

@Aftabbs sorry, codex messed up this branch, created another PR: #60914

attribution is also adjusted properly. 🙏

@Aftabbs

Aftabbs commented Apr 4, 2026 via email

Copy link
Copy Markdown
Contributor Author

@altaywtf

altaywtf commented Apr 4, 2026

Copy link
Copy Markdown
Member

@Aftabbs merged in 5012b52

@Aftabbs

Aftabbs commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

@altaywtf noting that #56520 addresses the same Feishu re-registration symptom with a plugin-level guard. This PR fixes the root cause (schema loads should never activate the plugin registry), which prevents the issue for all channel plugins, not just Feishu. Happy to rebase or address any concerns.

This branch was successfully deployed

1 active deployment
staging - docs — 16e7e255 Deployed Apr 4, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: skills list --json writes JSON to stderr instead of stdout since v2026.3.23

2 participants