npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@promptsx/core

v0.0.7

Published

A flexible and extensible Prompt DSL for building AI prompts with templates, variables, chaining, and intelligent expansion.

Readme

PromptX

A flexible and extensible Prompt DSL for building AI prompts with templates, variables, chaining, and intelligent expansion.

Test Coverage License Package Manager TypeScript

📚 Documentation

📖 Full Documentation - Complete guides, API reference, and examples

🚀 Features

  • 🔧 Prompt Builder: Chain-based API for building complex prompts
  • 📝 Template System: Structured templates with semantic blocks
  • 🔄 Variable Substitution: Dynamic content with {{variable}} syntax
  • 🌳 Branching Logic: Conditional content with SWITCH statements
  • ⚡ Conditional Logic: IF/THEN/ELSE statements for dynamic prompts
  • 🛠️ Tool Integration: Built-in support for function calling and tool requirements
  • 📚 Content Organization: Hierarchical content with important, critical, and example sections
  • 🎯 Role Management: System, user, and assistant role definitions
  • 🔨 Direct Utility Functions: Use when(), block(), importants() etc. directly for custom prompts
  • 🔄 Flexible Architecture: Combine builder pattern with direct functions for maximum control
  • ⚙️ TypeScript Support: Full type safety and IntelliSense
  • 🧪 100% Test Coverage: Comprehensive testing suite
  • 🚀 Zero Dependencies: Pure TypeScript with no external runtime dependencies
  • 📦 Ultra Lightweight: Minimal bundle size for optimal performance

📦 Installation

# Using pnpm (recommended)
pnpm add @promptsx/core

# Using npm
npm install @promptsx/core

# Using yarn
yarn add @promptsx/core

💡 Zero Dependencies: PromptX has no external runtime dependencies, ensuring your bundle stays lean and your deployments remain fast.

🎯 Quick Start

import { P, PromptNode } from '@promptsx/core'

const builder = P()
const systemNode = new PromptNode('system')

systemNode
  .setRole('code-assistant', 'A helpful coding assistant')
  .content('You are an expert developer')
  .important('Always provide working code examples')

builder.nodes.push(systemNode)
const prompt = builder.build()

console.log(prompt)

📖 Learn More

🏗️ Project Structure

promptx/
├── src/                      # Source code (Zero Dependencies)
│   ├── builder.ts            # Main prompt builder
│   ├── node.ts               # Prompt node implementation
│   ├── branch.ts             # Branching logic
│   ├── common.ts             # Utility functions
│   ├── tool.ts               # Tool integration
│   ├── index.ts              # Main exports
│   └── *.test.ts             # Test files
├── docs/                     # Documentation (VitePress)
├── dist/                     # Built files
├── build.config.ts           # Build configuration
├── vitest.config.ts          # Test configuration
├── tsconfig.json             # TypeScript configuration
└── package.json              # No runtime dependencies

💡 Architecture: Pure TypeScript code with zero external runtime dependencies, ensuring maximum compatibility and minimal bundle size.

🔧 Development

Prerequisites

  • Node.js 18+
  • pnpm 8+

Setup

# Clone repository
git clone https://github.com/murongg/promptx.git
cd promptx

# Install dependencies
pnpm install

# Build packages
pnpm build

# Run tests
pnpm test

# Start documentation
pnpm docs:dev

Scripts

| Script | Description | |--------|-------------| | pnpm build | Build all packages | | pnpm dev | Development mode with watch | | pnpm test | Run tests | | pnpm lint | Run ESLint | | pnpm typecheck | TypeScript type checking | | pnpm docs:dev | Start documentation server | | pnpm docs:build | Build documentation |

🚀 Performance & Size

PromptX is designed for maximum efficiency and minimal footprint:

  • 🚀 Zero Dependencies: Pure TypeScript with no external runtime dependencies
  • 📦 Ultra Lightweight: Minimal bundle size (< 5KB gzipped)
  • ⚡ High Performance: Optimized string operations and memory management
  • 🔄 Scalable: Handles large amounts of content efficiently
  • 💾 Memory Efficient: No unnecessary object creation or memory leaks
  • 🌐 Tree-shakable: Only import what you need, reduce bundle size further

🔒 Type Safety

Full TypeScript support with comprehensive type definitions:

// All methods are fully typed
const prompt: PromptBuilder = P()
const node: PromptNode = prompt.system
const branch: BranchBuilder = node.branch('type')

// Type-safe variable access
node.var('name', 'value') // ✅
node.var(123, 'value') // ❌ Type error

📄 License

MIT License - see LICENSE for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Guidelines

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

📞 Support

🙏 Acknowledgments

  • Built with modern TypeScript and ES modules
  • Zero external runtime dependencies for maximum compatibility
  • Comprehensive testing with Vitest
  • ESLint configuration by Anthony Fu
  • Built with Unbuild for optimal bundling
  • Designed for minimal bundle size and maximum performance

Built with ❤️ by MuRong