Skip to content

Commit

Permalink
fix: update docs and order of commands
Browse files Browse the repository at this point in the history
  • Loading branch information
gmickel committed Aug 9, 2024
1 parent c7242f8 commit 934ab3d
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 100 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ npm install -g codewhisper
# Navigate to your project directory
cd /path/to/your/project

# Generate an AI-friendly prompt using interactive mode
codewhisper interactive

# List available models
codewhisper list-models

# Start an AI-assisted coding task
# CodeWhisper will prompt you to select a model from the list of available models
codewhisper task
Expand Down Expand Up @@ -189,6 +183,13 @@ codewhisper task --undo
# To redo the last task with the option to change the model, file selection or plan, use the --redo option.
# Note: CodeWhisper saves the plan, instructions, model and selected files from the last task. Other options (such as --dry-run) need to be specified again.
codewhisper task --redo

# Generate an AI-friendly prompt using interactive mode
codewhisper interactive

# List available models
codewhisper list-models

```

> Note: If you are using CodeWhisper's LLM integration with `codewhisper task`, you will need to set the respective environment variable for the model you want to use (e.g., `export ANTHROPIC_API_KEY=your_api_key` or `export OPENAI_API_KEY=your_api_key` or `export GROQ_API_KEY=your_api_key` or `export DEEPSEEK_API_KEY=your_api_key` ).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "codewhisper",
"type": "module",
"version": "1.14.1",
"description": "A powerful tool for converting repository code to AI-friendly prompts",
"description": "AI-Powered End-to-End Task Implementation & blazingly fast Codebase-to-LLM Context Bridge",
"author": "Gordon Mickel <[email protected]>",
"license": "MIT",
"funding": "https://github.com/sponsors/gmickel",
Expand Down
188 changes: 95 additions & 93 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,11 @@ export function cli(_args: string[]) {
);
program
.name('codewhisper')
.description('A powerful tool for converting code to AI-friendly prompts')
.description(
'AI-Powered End-to-End Task Implementation & blazingly fast Codebase-to-LLM Context Bridge',
)
.version(packageJson.version);

program
.command('list-models')
.description('List available AI models')
.action(() => {
const models = getModelNames();
console.log('Available AI models:');
for (const modelId of models) {
const config = getModelConfig(modelId);
if (config) {
console.log(`- ${config.modelName} (${chalk.cyan(modelId)})`);
console.log(
` Context window: ${config.contextWindow}, Max output: ${config.maxOutput}`,
);
console.log(
` Pricing: $${config.pricing.inputCost}/1M tokens (input), $${config.pricing.outputCost}/1M tokens (output)`,
);
}
}
});

program
.command('apply-task <file>')
.description('Apply an AI-generated task from a file')
.option('--auto-commit', 'Automatically commit changes', false)
.action(async (file) => {
try {
await applyTask(file);
} catch (error) {
console.error(chalk.red('Error applying task:'), error);
process.exit(1);
}
});

program
.command('task')
.description('Start an AI-assisted coding task')
Expand Down Expand Up @@ -201,6 +170,98 @@ Note: see "query parameters" at https://docs.github.com/en/rest/issues/issues?ap
}
});

program
.command('list-models')
.description('List available AI models')
.action(() => {
const models = getModelNames();
console.log('Available AI models:');
for (const modelId of models) {
const config = getModelConfig(modelId);
if (config) {
console.log(`- ${config.modelName} (${chalk.cyan(modelId)})`);
console.log(
` Context window: ${config.contextWindow}, Max output: ${config.maxOutput}`,
);
console.log(
` Pricing: $${config.pricing.inputCost}/1M tokens (input), $${config.pricing.outputCost}/1M tokens (output)`,
);
}
}
});

program
.command('apply-task <file>')
.description('Apply an AI-generated task from a file')
.option('--auto-commit', 'Automatically commit changes', false)
.action(async (file) => {
try {
await applyTask(file);
} catch (error) {
console.error(chalk.red('Error applying task:'), error);
process.exit(1);
}
});

program
.command('interactive')
.description('Start interactive mode')
.option('-p, --path <path>', 'Path to the codebase', '.')
.option(
'-pr, --prompt <prompt>',
'Custom prompt to append to the output',
(value) => value,
)
.option('-t, --template <template>', 'Template to use')
.option('-g, --gitignore <path>', 'Path to .gitignore file', '.gitignore')
.option(
'-f, --filter <patterns...>',
'File patterns to include (use glob patterns, e.g., "src/**/*.js")',
)
.option(
'-e, --exclude <patterns...>',
'File patterns to exclude (use glob patterns, e.g., "**/*.test.js")',
)
.option(
'-E, --open-editor',
'Open the result in your default editor',
false,
)
.option('-s, --suppress-comments', 'Strip comments from the code', false)
.option('-l, --line-numbers', 'Add line numbers to code blocks', false)
.option('--case-sensitive', 'Use case-sensitive pattern matching', false)
.option(
'--no-codeblock',
'Disable wrapping code inside markdown code blocks',
false,
)
.option(
'--custom-data <json>',
'Custom data to pass to the template (JSON string)',
)
.option('--custom-template <path>', 'Path to a custom Handlebars template')
.option('--custom-ignores <patterns...>', 'Additional patterns to ignore')
.option(
'--cache-path <path>',
'Custom path for the cache file',
DEFAULT_CACHE_PATH,
)
.option('--respect-gitignore', 'Respect entries in .gitignore', true)
.option(
'--no-respect-gitignore',
'Do not respect entries in .gitignore',
false,
)
.option('--invert', 'Selected files will be excluded', false)
.action(async (options) => {
try {
await runInteractiveMode(options);
} catch (error) {
console.error(chalk.red('Error in interactive mode:'), error);
process.exit(1);
}
});

program
.command('generate')
.description('Generate a markdown file from your codebase')
Expand Down Expand Up @@ -307,65 +368,6 @@ Note: see "query parameters" at https://docs.github.com/en/rest/issues/issues?ap
}
});

program
.command('interactive')
.description('Start interactive mode')
.option('-p, --path <path>', 'Path to the codebase', '.')
.option(
'-pr, --prompt <prompt>',
'Custom prompt to append to the output',
(value) => value,
)
.option('-t, --template <template>', 'Template to use')
.option('-g, --gitignore <path>', 'Path to .gitignore file', '.gitignore')
.option(
'-f, --filter <patterns...>',
'File patterns to include (use glob patterns, e.g., "src/**/*.js")',
)
.option(
'-e, --exclude <patterns...>',
'File patterns to exclude (use glob patterns, e.g., "**/*.test.js")',
)
.option(
'-E, --open-editor',
'Open the result in your default editor',
false,
)
.option('-s, --suppress-comments', 'Strip comments from the code', false)
.option('-l, --line-numbers', 'Add line numbers to code blocks', false)
.option('--case-sensitive', 'Use case-sensitive pattern matching', false)
.option(
'--no-codeblock',
'Disable wrapping code inside markdown code blocks',
false,
)
.option(
'--custom-data <json>',
'Custom data to pass to the template (JSON string)',
)
.option('--custom-template <path>', 'Path to a custom Handlebars template')
.option('--custom-ignores <patterns...>', 'Additional patterns to ignore')
.option(
'--cache-path <path>',
'Custom path for the cache file',
DEFAULT_CACHE_PATH,
)
.option('--respect-gitignore', 'Respect entries in .gitignore', true)
.option(
'--no-respect-gitignore',
'Do not respect entries in .gitignore',
false,
)
.option('--invert', 'Selected files will be excluded', false)
.action(async (options) => {
try {
await runInteractiveMode(options);
} catch (error) {
console.error(chalk.red('Error in interactive mode:'), error);
process.exit(1);
}
});

program
.command('clear-cache')
.description('Clear the cache')
Expand Down

0 comments on commit 934ab3d

Please sign in to comment.