Skip to content

Add custom CLI commands feature #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged

Conversation

bhouston
Copy link
Member

Custom CLI Commands Feature

This PR implements the custom CLI commands feature requested in issue #251. It allows users to define custom commands in their mycoder.config.js file.

Features

  • Define custom CLI commands in mycoder.config.js
  • Commands can have required and optional arguments
  • Commands execute JavaScript functions that return prompts
  • Documentation added in docs/custom-commands.md
  • Example configuration in mycoder.config.js (commented out)

Implementation

  • Extended the Config type to include custom commands
  • Created a custom command handler in packages/cli/src/commands/custom.ts
  • Refactored the default command handler for reuse
  • Added validation for custom commands
  • Updated the main index.ts to register custom commands

Example Usage

// mycoder.config.js
export default {
  // ... other config options
  
  // Custom commands
  commands: {
    "search": {
      description: "Search for a term in the codebase",
      args: [
        { name: "term", description: "Search term", required: true }
      ],
      execute: (args) => {
        return `Find all instances of ${args.term} in the codebase and suggest improvements`;
      }
    }
  }
};

Then users can run:

mycoder search "deprecated API"

Notes

As requested, this implementation only includes the JavaScript function-based command executor and not the string template version.

Closes #251

@bhouston bhouston merged commit 278a3c3 into main Mar 13, 2025
1 check passed
Copy link

sentry-io bot commented Mar 14, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ Error: Anthropic API key is required new AnthropicProvider(anthropic.ts) View Issue
  • ‼️ Error: OpenAI API key is required new OpenAIProvider(openai.ts) View Issue
  • ‼️ Error: Error calling OpenAI API: 400 Invalid 'content' field OpenAIProvider.generateText(openai.ts) View Issue
  • ‼️ TypeError: Cannot set property stdout of # which has only a getter initInteractiveInput(interactiveInput.ts) View Issue
  • ‼️ ReferenceError: require is not defined createMcpTool(mcp.ts) View Issue

Did you find this useful? React with a 👍 or 👎

Copy link

🎉 This PR is included in version mycoder-v1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom cli commands to be defined
1 participant