Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Addresses review feedback from #318 to externalize large prompt template strings that were bloating the extension bundle.

Changes

Resource Files

  • Created resources/prompts/ with 5 markdown template files (~30KB total)
  • Templates: find-query, aggregate-query, count-query, cross-collection-query, single-collection-query

Template Loading

  • Added PromptTemplateLoader utility with lazy loading and in-memory caching
  • Replaced string constants with async getter functions in promptTemplates.ts
  • Updated PromptTemplateService to handle async template loading

Impact

  • Reduced promptTemplates.ts from 517 to 166 lines (-393 lines)
  • Templates no longer compiled into bundle, loaded on-demand from disk
  • Zero breaking changes: async functions replace constants at call sites

Example

Before:

export const FIND_QUERY_PROMPT_TEMPLATE = `
You are an expert MongoDB assistant...
[400+ lines of template content]
`;

After:

export async function getFindQueryPromptTemplate(): Promise<string> {
    return promptTemplateLoader.loadTemplate('find-query-prompt-template.md');
}

Usage in promptTemplateService.ts:

// Now async
private static async getBuiltInQueryGenerationTemplate(type: QueryGenerationType): Promise<string> {
    switch (type) {
        case QueryGenerationType.CrossCollection:
            return getCrossCollectionQueryPromptTemplate();
        // ...
    }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Move constants to resource files based on review feedback Move LLM prompt templates from embedded constants to resource files Oct 29, 2025
Copilot AI requested a review from tnaum-ms October 29, 2025 10:06
Base automatically changed from dev/xingfan/querygenerationintegration to next October 31, 2025 10:09
@tnaum-ms tnaum-ms changed the title Move LLM prompt templates from embedded constants to resource files [On-Hold] Move LLM prompt templates from embedded constants to resource files Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants