Discover and explore top open-source AI tools and projects—updated daily.
microsoftDeclarative prompt engineering for LLM extensions
Top 98.1% on SourcePulse
<2-3 sentences summarising what the project addresses and solves, the target audience, and the benefit.>
@vscode/prompt-tsx addresses the challenges of programmatically composing LLM prompts by introducing a declarative TSX-based component model. It targets VS Code extension developers, offering a more maintainable, flexible, and context-aware approach to prompt engineering, especially for complex interactions like those in Copilot Chat. The library enables prompts to dynamically adapt to model context window constraints, improving developer experience and prompt robustness.
How It Works
Prompts are structured as a tree of TSX components, which are then flattened into ChatMessage objects. Each component has an associated priority. When the total token count exceeds the model's context window, the renderer prunes lower-priority messages, preserving essential information. This system allows developers to safely include large contextual data, such as conversation history or codebase snippets, by managing their priority.
Quick Start & Requirements
npm install --save @vscode/prompt-tsxtsconfig.json updates for JSX: "jsx": "react", "jsxFactory": "vscpp", "jsxFragmentFactory": "vscppf".types configuration in tsconfig.json.Highlighted Details
flexGrow, flexReserve, and flexBasis enable fine-grained token budget allocation.TokenLimit enforces hard token caps, while Expandable fills remaining budget.useKeepWith ensures related prompt elements are kept or pruned together; IfEmpty provides fallback content.HTMLTracer visualizes prompt rendering and token budget distribution.renderElementJSON) and consuming tool results (ToolResult).Maintenance & Community
No specific details on maintainers, community channels (like Discord/Slack), or roadmap were found in the provided text.
Licensing & Compatibility
The specific license is not stated in the provided text. As a Microsoft project, it is likely a permissive open-source license (e.g., MIT), but this should be verified. Compatibility for commercial use would depend on the final license.
Limitations & Caveats
Potential for TypeScript compilation errors in monorepos due to JSX conflicts, requiring manual tsconfig.json adjustments. Newlines within JSX text must be explicitly added using <br />. The priority and flex-based token management system introduces a learning curve for complex prompt designs. Asynchronous operations within prompts must be handled in the prepare method, as render is synchronous.
5 days ago
Inactive
microsoft