Skip to content

fix: normalize --agent flag, migrate 6 commands to onboarding helpers#99

Merged
rohitg00 merged 3 commits intomainfrom
fix/audit-batch-2
Apr 7, 2026
Merged

fix: normalize --agent flag, migrate 6 commands to onboarding helpers#99
rohitg00 merged 3 commits intomainfrom
fix/audit-batch-2

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented Apr 7, 2026

Summary

Audit batch 2 — continuing from #95 and #98.

Option naming (#94)

  • generate.ts, manifest.ts: now accept --agent as primary flag (--agents still works as alias)
  • Matches install.ts which already uses --agent

Chalk→onboarding migration (#87, #88)

Migrated 6 command files from direct chalk/ora imports to onboarding helpers:

File Changes
update.ts chalk/ora → colors/spinner (first command using onboarding spinner)
translate.ts chalk → colors/warn/success
remove.ts chalk → colors/warn/success/error
enable.ts chalk → colors/warn/successLog/errorLog
scan.ts stderr.write → error()
list.ts chalk → colors/warn

Chalk imports reduced from 41 → 36 across commands (5 eliminated this batch).

Test Plan

  • pnpm build — all 13 packages pass
  • pnpm test — all 25 test suites pass
  • No behavior changes — purely styling API migration

Closes #94
Partial progress on #87, #88


Open with Devin

Summary by CodeRabbit

  • New Features

    • Added --agent as an alternative flag alongside --agents for selecting target agents; legacy --agents now emits a deprecation warning.
  • Bug Fixes & Improvements

    • Standardized CLI output, colors, and spinner behavior across commands for consistent styling and clearer hints.
    • Improved validation and error messages, missing-item handling, and summary/status reporting for more helpful feedback.

Option naming (#94):
- generate.ts, manifest.ts: accept --agent as primary (--agents as alias)

Chalk→onboarding migration (#87, #88):
- update.ts: chalk/ora → colors/spinner from onboarding
- translate.ts: chalk → colors/warn/success from onboarding
- remove.ts: chalk → colors/warn/success/error from onboarding
- enable.ts: chalk → colors/warn/successLog/errorLog from onboarding
- scan.ts: stderr.write → error() from onboarding
- list.ts: chalk → colors/warn from onboarding

Chalk imports reduced from 41 to 36 across commands.
All 13 packages build, all 25 test suites pass.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
skillkit Ignored Ignored Preview Apr 7, 2026 11:27am
skillkit-docs Ignored Ignored Preview Apr 7, 2026 11:27am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Refactors multiple CLI commands to use centralized onboarding logging/utilities (colors, warn, success, error, step, spinner) instead of direct chalk/ora usage, and standardizes agent option flags to accept both --agent and --agents (with a deprecation warning emitted when --agents is used).

Changes

Cohort / File(s) Summary
Logging utilities refactor
packages/cli/src/commands/enable.ts, packages/cli/src/commands/remove.ts, packages/cli/src/commands/translate.ts, packages/cli/src/commands/update.ts
Replaced chalk/ora usage with onboarding helpers (colors, warn, success, error, step, spinner); preserved control flow, renamed some local counters (successsuccessCount) and catch params (errorerr).
Colors / error API migration
packages/cli/src/commands/list.ts, packages/cli/src/commands/scan.ts
Replaced direct chalk/stderr writes with colors API and error() helper; validation, empty-state, and listing output now use centralized helpers.
CLI option alias normalization
packages/cli/src/commands/generate.ts, packages/cli/src/commands/manifest.ts
Updated option definitions to accept --agent,--agents,-a (adds singular --agent while keeping --agents as a deprecated alias and emitting a runtime deprecation warning); parsing of comma-separated agent lists preserved.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I swapped my chalk for helpers bright,
I hop through flags from left to right.
--agent whispers, --agents fades,
Colors cheer in tidy shades,
A rabbit grins — the CLI's light!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the two main changes: normalizing the --agent flag and migrating commands to onboarding helpers.
Linked Issues check ✅ Passed The PR successfully implements #94 requirements: --agent is primary flag in generate.ts and manifest.ts, --agents remains as deprecated alias, and deprecation warnings are emitted when --agents is used.
Out of Scope Changes check ✅ Passed All changes align with stated objectives: flag normalization in two commands and chalk-to-onboarding migration in six commands, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-batch-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines +105 to +106
console.log(colors.muted('Error: --to/-t target agent is required'));
console.log(colors.muted('Use --list to see all supported agents'));
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Translation failure reasons displayed as muted/dim text instead of error-styled text

When translateSingle fails (!result.success at line 341), the incompatible items explaining why the translation failed are displayed using colors.muted (dim text), making them nearly invisible. The old code used console.error(chalk.red(...)) which clearly highlighted these error details in red. The header on line 342 correctly calls error('Translation failed:') which renders in red, but then the actual failure details on line 344 are rendered as dim/muted — an inconsistent and misleading visual treatment for error information.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
} catch (err) {
s.stop(colors.error(`Failed to update ${skill.name}`));
error(colors.muted(err instanceof Error ? err.message : String(err)));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Double-formatted error detail: error() wrapping already-muted text in update.ts

On line 136, error(colors.muted(...)) applies dim styling first via colors.muted (pc.dim()), then the error() function wraps it again in pc.red() and adds clack's structured error log prefix. The original code (console.error(chalk.dim(...))) was a subdued detail line printed after the main error. Compare with the correct pattern in remove.ts:50: console.error(colors.muted(...)) — a plain dim detail line on stderr. Using error() here produces a full clack error log entry with conflicting ANSI codes for what should be a secondary detail message.

Suggested change
error(colors.muted(err instanceof Error ? err.message : String(err)));
console.error(colors.muted(err instanceof Error ? err.message : String(err)));
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: Commit d9142c8 ('fix: simplify review — error styling, double-wrap, aliases') fixed this. The current code at update.ts:136 now uses console.log(colors.muted(...)) instead of error(colors.muted(...)), eliminating the double-formatting issue.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/commands/generate.ts`:
- Around line 53-55: The CLI defines the option via agents =
Option.String('--agent,--agents,-a', ...) but never warns when the deprecated
alias `--agents` is used; after options are parsed in the generate command
handler, detect if the user supplied the deprecated alias (e.g., inspect
process.argv or the parser's raw args for the literal string "--agents") and
emit a deprecation warning guiding users to use `--agent` instead; add this
check immediately after parsing (where `agents` is available) and use the
existing CLI logger or console.warn to output a single-line deprecation message
mentioning `--agents` is deprecated and to use `--agent`.

In `@packages/cli/src/commands/manifest.ts`:
- Around line 150-152: The Option.String definition for agents (agents =
Option.String('--agent,--agents,-a', {...})) adds the deprecated alias but
doesn't emit a deprecation warning; update the command handling where the parsed
options are processed (the code path that reads the agents option) to detect if
the user explicitly provided the deprecated flag `--agents` and log the exact
message "Use --agent instead (--agents will be removed in v2.0)" (e.g., via the
command logger or console.warn), while still honoring the value, so users see
the warning whenever the `--agents` alias is used; reference the agents
Option.String symbol to locate the option and add the conditional deprecation
notice near the option parsing/validation logic.

In `@packages/cli/src/commands/scan.ts`:
- Line 5: ScanCommand currently calls the shared error() helper (imported from
../onboarding/index.js) for pre-scan validation messages which writes to stdout;
replace those calls inside the ScanCommand (the validation branches that call
error(...)) with this.context.stderr.write(chalk.red(<same message>)) so
messages go to stderr and keep the original text, add an import for chalk if
missing, and remove the now-unused error import; ensure usage matches other
commands (team.ts, plugin.ts) so tests and scripted callers can capture stderr
correctly.

In `@packages/cli/src/commands/translate.ts`:
- Around line 105-107: Replace console.log calls that emit error diagnostics
with console.error in the translate command error branches that return non-zero
(the branches that currently print messages like "Error: --to/-t target agent is
required" and others mentioned). Locate the error branches inside the translate
command handler (the early-returns that print guidance and then "return 1") and
change those console.log(...) invocations to console.error(...) so diagnostic
output goes to stderr; ensure every listed branch (the ones around the early
returns) is updated consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a87ef856-1142-4ae6-880d-6e0deeb677c4

📥 Commits

Reviewing files that changed from the base of the PR and between 12bba7f and 64944a1.

📒 Files selected for processing (8)
  • packages/cli/src/commands/enable.ts
  • packages/cli/src/commands/generate.ts
  • packages/cli/src/commands/list.ts
  • packages/cli/src/commands/manifest.ts
  • packages/cli/src/commands/remove.ts
  • packages/cli/src/commands/scan.ts
  • packages/cli/src/commands/translate.ts
  • packages/cli/src/commands/update.ts

Comment on lines +150 to 152
agents = Option.String('--agent,--agents,-a', {
description: 'Target agents (comma-separated)',
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add required deprecation warning for --agents.

This adds alias compatibility, but the command still doesn’t emit the required warning message when users pass --agents (Use --agent instead (--agents will be removed in v2.0)), so issue #94 acceptance criteria is incomplete.

Suggested patch
  async execute(): Promise<number> {
+    if (process.argv.includes('--agents')) {
+      warn('Use --agent instead (--agents will be removed in v2.0)');
+    }
+
     const options: { skills?: string[]; agents?: string[] } = {};
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/manifest.ts` around lines 150 - 152, The
Option.String definition for agents (agents =
Option.String('--agent,--agents,-a', {...})) adds the deprecated alias but
doesn't emit a deprecation warning; update the command handling where the parsed
options are processed (the code path that reads the agents option) to detect if
the user explicitly provided the deprecated flag `--agents` and log the exact
message "Use --agent instead (--agents will be removed in v2.0)" (e.g., via the
command logger or console.warn), while still honoring the value, so users see
the warning whenever the `--agents` alias is used; reference the agents
Option.String symbol to locate the option and add the conditional deprecation
notice near the option parsing/validation logic.

import { resolve } from 'node:path';
import { existsSync } from 'node:fs';
import { SkillScanner, formatResult, Severity } from '@skillkit/core';
import { error } from '../onboarding/index.js';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In @clack/prompts v0.11.x, does clack.log.error write directly to process streams, and is there an officially supported way to route it through custom output streams (like Clipanion this.context.stderr)?

💡 Result:

Yes—in @clack/prompts v0.11.x, log.error() writes directly to the Node process stream (specifically process.stdout.write, not process.stderr). log.error() just delegates to log.message(), and log.message() hard-codes process.stdout.write(...). [1]

No—v0.11.x does not provide an officially supported way to route clack.log.* output to custom streams (e.g. this.context.stderr in Clipanion). There’s no output/stderr option on log.* in v0.11.x; you’d have to wrap/replace it yourself (or monkey-patch process.stdout.write). [1]

(For context: newer @clack/prompts versions added an output option to log.message(...) that lets you pass a custom Writable, but that’s not present in v0.11.x.) [2]

Sources
[1] @clack/prompts@0.11.0 packages/prompts/src/index.ts (log implementation) (github.com)
[2] Current packages/prompts/src/log.ts (shows output = process.stdout option) (github.com)

Citations:


🏁 Script executed:

# First, find and examine the scan.ts file to see the context
fd -t f "scan.ts" --path "*packages/cli*"

Repository: rohitg00/skillkit

Length of output: 294


🏁 Script executed:

# Get the exact lines mentioned in the review - lines 54, 60, 70
sed -n '1,80p' packages/cli/src/commands/scan.ts | cat -n

Repository: rohitg00/skillkit

Length of output: 3301


🏁 Script executed:

# Examine the error() import source
cat -n packages/cli/src/onboarding/index.js | head -50

Repository: rohitg00/skillkit

Length of output: 129


🏁 Script executed:

# Search for what clack is and how it's used in onboarding
rg "clack|log\.error" packages/cli/src/onboarding/ -A 2 -B 2

Repository: rohitg00/skillkit

Length of output: 8204


🏁 Script executed:

# Find the onboarding index file
fd -t f "index" packages/cli/src/onboarding/

Repository: rohitg00/skillkit

Length of output: 97


🏁 Script executed:

# Check the onboarding index content
cat -n packages/cli/src/onboarding/index.ts

Repository: rohitg00/skillkit

Length of output: 7486


🏁 Script executed:

# Check package.json for clack version
rg "@clack/prompts" packages/cli/package.json

Repository: rohitg00/skillkit

Length of output: 93


🏁 Script executed:

# Search for this.context.stderr usage in the codebase
rg "this\.context\.stderr" packages/cli/

Repository: rohitg00/skillkit

Length of output: 12940


🏁 Script executed:

# Check if ScanCommand has direct access to context
rg "class ScanCommand" -A 20 packages/cli/src/commands/scan.ts

Repository: rohitg00/skillkit

Length of output: 919


Use this.context.stderr.write(...) for validation error messages in ScanCommand.

Lines 54, 60, and 70 use error() which delegates to clack.log.error(). In @clack/prompts v0.11.x, log.error() writes directly to process.stdout with no support for custom stream routing. This bypasses this.context.stderr and breaks stderr capture in tests and scripted callers.

Adopt the pattern used in other commands (e.g., team.ts, plugin.ts, methodology.ts): replace error(...) with this.context.stderr.write(chalk.red(...)) for these pre-scan validation checks.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/commands/scan.ts` at line 5, ScanCommand currently calls the
shared error() helper (imported from ../onboarding/index.js) for pre-scan
validation messages which writes to stdout; replace those calls inside the
ScanCommand (the validation branches that call error(...)) with
this.context.stderr.write(chalk.red(<same message>)) so messages go to stderr
and keep the original text, add an import for chalk if missing, and remove the
now-unused error import; ensure usage matches other commands (team.ts,
plugin.ts) so tests and scripted callers can capture stderr correctly.

rohitg00 added 2 commits April 7, 2026 12:24
- translate.ts: 7 error paths used colors.muted() (gray) instead of
  error() (red) — errors were invisible. Now properly styled.
- update.ts: error(colors.muted(...)) double-wrapped ANSI codes.
  Split into s.stop() for headline + console.log for detail.
- enable.ts: dropped successLog/errorLog aliases, renamed counters
  to successCount/failedCount (matches translate.ts pattern)
- update.ts: removed unused error import
generate.ts and manifest.ts now warn when --agents (deprecated) is
used instead of --agent. Message: "Warning: --agents is deprecated,
use --agent instead (--agents will be removed in v2.0)"

Findings 3 (scan.ts stderr) and 4 (translate.ts stderr) skipped:
error() from onboarding goes to stdout via clack — this is the
standard pattern across all migrated commands. Changing individual
commands would break consistency.
@rohitg00 rohitg00 merged commit 9fa542e into main Apr 7, 2026
8 of 9 checks passed
@rohitg00 rohitg00 deleted the fix/audit-batch-2 branch April 7, 2026 11:30
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review


if (!existsSync(targetPath)) {
this.context.stderr.write(`Path not found: ${targetPath}\n`);
error(`Path not found: ${targetPath}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Scan command error messages redirected from stderr to stdout

The scan command previously wrote validation errors to stderr via this.context.stderr.write(...) (Clipanion's stderr stream, which defaults to process.stderr). The new code uses the error() helper which calls clack.log.error(), which writes to stdout. The scan command is designed for CI/pipeline integration (supports --format sarif for GitHub Code Scanning and --format json), where the convention is that machine-readable output goes to stdout and diagnostic/error messages go to stderr. This change breaks that contract — downstream tools that check stderr for error diagnostics will no longer see them.

Affected lines in scan.ts

Lines 54, 60, and 70 all changed from this.context.stderr.write(...) to error(...) which writes to stdout.

Prompt for agents
The scan command (packages/cli/src/commands/scan.ts) is designed for CI/pipeline use and supports machine-readable output formats (json, sarif). It previously wrote error messages to stderr via this.context.stderr.write(), maintaining the Unix convention that stdout carries data and stderr carries diagnostics. The migration to the error() helper from onboarding/prompts.js routes these messages to stdout instead (via @clack/prompts log.error which writes to process.stdout). To fix, either: (1) keep using this.context.stderr.write() for the scan command's error messages (lines 54, 60, 70), or (2) create a stderrError() helper that wraps process.stderr.write with the same styling as error(). The scan command needs different behavior than interactive commands because its stdout is consumed by machines.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Audit] Normalize CLI option naming: --agent vs --agents inconsistency

1 participant