UNPKG

gaunt-sloth-assistant

Version:

[![Tests and Lint](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/Galvanized-Pukeko/gaunt-sloth-assistant/actions/workflows/unit-tests.yml) [![Integration Tests](https://github.co

42 lines 1.91 kB
import { initConfig } from '#src/config.js'; import { getStringFromStdin } from '#src/utils/systemUtils.js'; import { readBackstory, readGuidelines, readSystemPrompt, wrapContent, } from '#src/utils/llmUtils.js'; import { readMultipleFilesFromProjectDir } from '#src/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 systemPrompt = readSystemPrompt(config); const preamble = [readBackstory(config), readGuidelines(config)]; if (systemPrompt) { preamble.push(systemPrompt); } 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('#src/modules/questionAnsweringModule.js'); await askQuestion('ASK', preamble.join('\n'), content.join('\n'), config); }); } //# sourceMappingURL=askCommand.js.map