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 >

49 lines 2.31 kB
import { displayError } from '@gaunt-sloth/core/utils/consoleUtils.js'; import { wrapContent } from '@gaunt-sloth/core/utils/llmUtils.js'; /** * Requirements providers. Aliases are mapped to actual package paths. */ export const REQUIREMENTS_PROVIDERS = { 'jira-legacy': '@gaunt-sloth/review/sources/jiraIssueLegacySource.js', jira: '@gaunt-sloth/review/sources/jiraIssueSource.js', github: '@gaunt-sloth/review/sources/ghIssueSource.js', text: '@gaunt-sloth/review/sources/textSource.js', file: '@gaunt-sloth/review/sources/fileSource.js', }; /** * Content providers. Aliases are mapped to actual package paths. */ export const CONTENT_PROVIDERS = { github: '@gaunt-sloth/review/sources/ghPrDiffSource.js', text: '@gaunt-sloth/review/sources/textSource.js', file: '@gaunt-sloth/review/sources/fileSource.js', }; export async function getRequirementsFromProvider(requirementsProvider, requirementsId, config) { const requirements = await getFromProvider(requirementsProvider, requirementsId, (config?.requirementsProviderConfig ?? {})[requirementsProvider], REQUIREMENTS_PROVIDERS); return wrapContent(requirements, requirementsProvider, 'requirements'); } export async function getContentFromProvider(contentProvider, contentId, config) { const content = await getFromProvider(contentProvider, contentId, (config?.contentProviderConfig ?? {})[contentProvider], CONTENT_PROVIDERS); return wrapContent(content, contentProvider, contentProvider === 'github' ? 'GitHub diff' : 'content'); } async function getFromProvider(provider, id, // eslint-disable-next-line @typescript-eslint/no-explicit-any config, legitPredefinedProviders) { if (typeof provider === 'string') { // Use one of the predefined providers if (legitPredefinedProviders[provider]) { const providerPath = legitPredefinedProviders[provider]; const { get } = await import(providerPath); return await get(config, id); } else { displayError(`Unknown provider: ${provider}. Continuing without it.`); } } else if (typeof provider === 'function') { // Type assertion to handle function call return await provider(id); } return ''; } //# sourceMappingURL=commandUtils.js.map