Repository navigation
fix(cli): route skills list output to stdout when --json is active - #60914
Conversation
runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes #57599
Greptile SummaryThis PR fixes The production-code change is a single line in
Confidence Score: 5/5Safe to merge — a minimal, well-tested stdout routing fix with no behavior changes to non-JSON output paths. The production change is a single-line swap of No files require special attention beyond the style note on the test fixture duplication in Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/cli/skills-cli.commands.test.ts
Line: 10-67
Comment:
**Dead factory function — skill fixture duplicated twice**
`createSkillStatusReport()` is defined inside `vi.hoisted()` and wired into `buildWorkspaceSkillStatusMock`'s initial `vi.fn()` implementation, but every test immediately calls `buildWorkspaceSkillStatusMock.mockReset()` followed by `buildWorkspaceSkillStatusMock.mockReturnValue({...})` in `beforeEach`, which completely replaces the implementation before any test body runs. As a result, the factory is never actually invoked during the test suite — its body is dead code.
The same fixture data is then written out a second time inline inside the `beforeEach` block (lines 158–193), doubling the maintenance surface.
Consider removing `createSkillStatusReport` and hoisting the shared fixture to a module-level constant instead:
```ts
// top of file, outside vi.hoisted
const CALENDAR_SKILL_FIXTURE = {
name: "calendar",
description: "Calendar helpers",
// … rest of the object
};
const SKILL_STATUS_REPORT_FIXTURE = {
workspaceDir: "/tmp/workspace",
managedSkillsDir: "/tmp/workspace/skills",
skills: [CALENDAR_SKILL_FIXTURE],
};
```
Then both the initial `vi.fn()` implementation and the `beforeEach` `.mockReturnValue(...)` can reference the same constant.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "test(cli): add skills JSON stdout regres..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR fixes a CLI regression where openclaw skills <action> --json emitted its JSON payload via console.log (and therefore stderr when --json routing is active), by switching the shared runSkillsAction() output path to write directly to stdout. It also adds regression tests to ensure the skills JSON output is routed via stdout.
Changes:
- Update
runSkillsAction()to emit rendered output usingdefaultRuntime.writeStdout(...)instead ofdefaultRuntime.log(...). - Add regression coverage for
skills list/info/check --jsonand a non-JSONskills listpath, including stdout-vs-log expectations. - Extend the test runtime capture to separately track stdout output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/cli/skills-cli.ts | Routes skills command output through writeStdout to avoid stderr redirection in --json mode. |
| src/cli/skills-cli.commands.test.ts | Adds regression tests and a stdout capture path to validate JSON output is emitted via stdout. |
|
@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. |
|
@Aftabbs yes plese, there are some valid comments from Codex. |
The skillStatusReportFixture was defined inside vi.hoisted() and also returned from it so beforeEach could call mockReturnValue(). This created two maintenance surfaces for the same data. Move the fixture to a module-level constant (SKILL_STATUS_FIXTURE) so it is defined once and referenced from both vi.hoisted() and beforeEach. Remove the dead initial implementation from buildWorkspaceSkillStatusMock — mockReset() in beforeEach replaced it before any test ran anyway. Addresses Codex feedback on openclaw#60914.
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
…penclaw#60914) * fix(cli): route skills list output to stdout when --json is active runSkillsAction used defaultRuntime.log() which goes through console.log. The --json preAction hook calls routeLogsToStderr(), redirecting console.log to stderr. Switch to defaultRuntime.writeStdout() which writes directly to process.stdout, consistent with how other --json commands (e.g. skills search) already emit their output. Fixes openclaw#57599 * test(cli): add skills JSON stdout regression coverage * test(cli): refine skills CLI stream coverage * fix(cli): add changelog entry for skills JSON stdout fix --------- Co-authored-by: Aftabbs <[email protected]>
Summary
Replacement for closed PR #57611.
openclaw skills list --json(andskills info --json,skills check --json) was writing JSON output to stderr instead of stdout, breaking tooling that captures stdout.This branch includes:
runSkillsAction()now usesdefaultRuntime.writeStdout(...)src/cli/skills-cli.commands.test.tsfor:skills list --jsonskills info <name> --jsonskills check --jsonskills listpathFixes #57599.
Validation
pnpm exec vitest run --config vitest.config.ts src/cli/skills-cli.commands.test.tsskills list --jsonwriting the JSON payload to stdoutNotes
PR #57611 was closed after its fork branch head was accidentally moved to the wrong commit. This PR is the clean replacement from the corrected rebased branch.