UNPKG

gaunt-sloth-assistant

Version:

> ⚠️ **`gaunt-sloth-assistant` has been renamed to [`gaunt-sloth`](https://www.npmjs.com/package/gaunt-sloth).** > The `1.5.x` series is the final release under the old name — active development continues under > the new package. To switch: > > ```bash >

39 lines 1.91 kB
import { initConfig } from '@gaunt-sloth/core/config.js'; import { getAskSystemPrompt } from '#src/commands/commandIntrospection.js'; import { getStringFromStdin } from '@gaunt-sloth/core/utils/systemUtils.js'; import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js'; import { readMultipleFilesFromProjectDir } from '@gaunt-sloth/review/utils/fileUtils.js'; /** * Adds the ask command to the program * @param program - The commander program * @param commandLineConfigOverrides - command line config overrides */ export function askCommand(program, commandLineConfigOverrides) { program .command('ask') .description('Ask a question') .argument('[message]', 'A message') .option('-f, --file [files...]', 'Input files. Content of these files will be added BEFORE the message') .action(async (message, options) => { const config = await initConfig(commandLineConfigOverrides); const content = []; if (options.file) { content.push(readMultipleFilesFromProjectDir(options.file)); } const stringFromStdin = getStringFromStdin(); if (stringFromStdin) { content.push(wrapContent(stringFromStdin, 'stdin-content')); } if (message) { content.push(wrapContent(message, 'message', 'user message')); } // Validate that at least one input source is provided if (content.length === 0) { throw new Error('At least one of the following is required: file, stdin, or message'); } const { askQuestion } = await import('@gaunt-sloth/review/modules/questionAnsweringModule.js'); const { createResolvers } = await import('@gaunt-sloth/api/resolvers.js'); await askQuestion('ASK', getAskSystemPrompt(config), content.join('\n'), config, createResolvers()); }); } //# sourceMappingURL=askCommand.js.map