Skip to content

Conversation

@marius-kilocode
Copy link
Collaborator

@marius-kilocode marius-kilocode commented Jan 13, 2026

Summary

This PR improves the CLI error message when a custom mode is not found, addressing issues #4575 and #4600.

It follows up on #4861 and resolves conflicts.

Changes

cli/src/config/customModes.ts

  • Added SearchedPath interface to track search locations
  • Added getSearchedPaths() export for error reporting
  • Added debug logging for mode loading/failures
  • Refactored loading functions to return path metadata

cli/src/index.ts

  • Replaced misleading "Invalid mode" error with informative "Mode not found" message
  • Shows exactly where CLI searched for custom modes (global and project paths)

cli/src/commands/mode.ts

  • Updated /mode slash command to use the same improved error message
  • Reuses getSearchedPaths() for consistency between --mode flag and /mode command

cli/src/config/__tests__/customModes.test.ts

  • Added 14 comprehensive unit tests

Before

Error: Invalid mode "my-mode". Valid modes are: code, architect, ask, debug, orchestrator

After

Error: Mode "my-mode" not found.

The CLI searched for custom modes in:
  • Global: ~/Library/.../custom_modes.yaml (not found)
  • Project: /workspace/.kilocodemodes (not found)

Available modes: code, architect, ask, debug, orchestrator

Testing

  • All 14 new tests pass
  • Type checking passes

Fixes #4575
Fixes #4600

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: a30a4c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@kilocode/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@marius-kilocode marius-kilocode requested a review from a team January 13, 2026 12:30
@marius-kilocode marius-kilocode enabled auto-merge (squash) January 13, 2026 12:30
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 13, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR improves the error message when a custom mode is not found in the CLI. The changes:

  1. Add SearchedPath interface and tracking - Tracks which paths were searched for custom modes (global and project) along with whether files were found and how many modes were loaded.

  2. Export getSearchedPaths() function - Allows other parts of the codebase to retrieve the searched paths for error reporting.

  3. Improve error messages - When an invalid mode is specified, the error now shows:

    • Which paths were searched
    • Whether each path was found
    • How many modes were loaded from each path
    • Available modes
  4. Add comprehensive tests - New test file cli/src/config/__tests__/customModes.test.ts with thorough coverage of the new functionality.

The implementation is clean and well-structured. The code follows existing patterns in the codebase and includes proper TypeScript types.

Files Reviewed (5 files)
  • .changeset/cli-custom-modes-error-message.md - Changeset for the patch
  • cli/src/commands/__tests__/mode.test.ts - Updated tests for mode command
  • cli/src/commands/mode.ts - Added showInvalidModeError function with searched paths
  • cli/src/config/__tests__/customModes.test.ts - New comprehensive test file
  • cli/src/config/customModes.ts - Core implementation of SearchedPath tracking
  • cli/src/index.ts - Updated CLI entry point to use new error format

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Jan 13, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR improves the error message when a custom mode is not found in the CLI. The changes:

  1. Add SearchedPath interface and tracking - Tracks which paths were searched for custom modes (global and project) along with whether files were found and how many modes were loaded.

  2. Export getSearchedPaths() function - Allows other parts of the codebase to retrieve the searched paths for error reporting.

  3. Improve error messages - When an invalid mode is specified, the error now shows:

    • Which paths were searched
    • Whether each path was found
    • How many modes were loaded from each path
    • Available modes
  4. Add comprehensive tests - New test file cli/src/config/__tests__/customModes.test.ts with thorough coverage of the new functionality.

The implementation is clean and well-structured. The code follows existing patterns in the codebase and includes proper TypeScript types.

Files Reviewed (6 files)
  • .changeset/cli-custom-modes-error-message.md - Changeset for the patch
  • cli/src/commands/__tests__/mode.test.ts - Updated tests for mode command
  • cli/src/commands/mode.ts - Added showInvalidModeError function with searched paths
  • cli/src/config/__tests__/customModes.test.ts - New comprehensive test file
  • cli/src/config/customModes.ts - Core implementation of SearchedPath tracking
  • cli/src/index.ts - Updated CLI entry point to use new error format

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.

Improve error message for custom mode not found during CLI initialization custom modes support for cli do not works

4 participants