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

system-prompt-composer

v1.0.8

Published

Native Node.js bindings for prompt-composer - intelligent system prompt generation for AI assistants

Readme

system-prompt-composer

Native Node.js bindings for intelligent system prompt generation for AI assistants with MCP tool integration. No Python dependencies required!

Installation

npm install system-prompt-composer

🎉 That's it! No Python installation needed - this package uses native Rust bindings via NAPI-RS.

Quick Start

const { composeSystemPrompt } = require('system-prompt-composer');

const request = {
  user_prompt: "Help me analyze this code file",
  mcp_config: {
    mcpServers: {
      "desktop-commander": {
        name: "desktop-commander",
        command: "npx",
        args: ["@modelcontextprotocol/server-filesystem"]
      }
    }
  },
  session_state: {
    tool_call_count: 0
  }
};

const response = await composeSystemPrompt(request);
console.log(response.system_prompt);

Features

  • 🧠 Intelligent prompts that adapt to available MCP tools
  • 📋 Automatic task planning for complex requests
  • 🎯 Context-aware guidance for different domains (programming, analysis, filesystem, system)
  • 📊 Progress monitoring for multi-step workflows
  • Native performance - direct Rust execution via NAPI-RS
  • 🚫 No Python dependency - fully self-contained
  • 📦 TypeScript support with full type definitions
  • 🌍 Cross-platform - works on Linux, macOS, Windows

API Reference

Core Functions

const { 
  composeSystemPrompt,
  listAvailableDomains,
  listAvailableBehaviors,
  getStatus,
  isAvailable 
} = require('system-prompt-composer');

composeSystemPrompt(request)

Generate an intelligent system prompt based on available tools and context.

const request = {
  user_prompt: "Your user's request",
  mcp_config: {
    mcpServers: {
      "server-name": {
        name: "server-name", 
        command: "command",
        args: ["arg1", "arg2"]
      }
    }
  },
  session_state: {
    tool_call_count: 0,
    has_plan: false,
    task_complexity: "Auto" // "Auto" | "Simple" | "Complex"
  },
  domain_hints: ["programming", "analysis"], // Optional
  task_complexity: "Complex" // Optional override
};

const response = await composeSystemPrompt(request);

Response Format:

{
  system_prompt: "Generated system prompt...",
  source: "native",
  version: "1.1.0",
  available_domains: ["programming", "analysis", "filesystem", "system"],
  available_behaviors: ["planning", "progress", "reasoning", "tools"]
}

listAvailableDomains()

Returns array of available domain modules.

const domains = await listAvailableDomains();
// ["analysis", "filesystem", "programming", "system"]

listAvailableBehaviors()

Returns array of available behavior modules.

const behaviors = await listAvailableBehaviors();
// ["planning", "progress", "reasoning", "tools"]

getStatus()

Returns system status and configuration.

const status = await getStatus();
// {
//   available: true,
//   source: "native", 
//   version: "1.1.0",
//   domains: [...],
//   behaviors: [...]
// }

isAvailable()

Always returns true for native bindings.

const available = await isAvailable(); // true

Integration Examples

Express.js API

const express = require('express');
const { composeSystemPrompt } = require('system-prompt-composer');

app.post('/api/compose-prompt', async (req, res) => {
  try {
    const response = await composeSystemPrompt(req.body);
    res.json(response);
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

Electron Main Process

const { ipcMain } = require('electron');
const { composeSystemPrompt } = require('system-prompt-composer');

ipcMain.handle('prompt-composer:generate', async (event, request) => {
  try {
    return await composeSystemPrompt(request);
  } catch (error) {
    return { error: error.message, system_prompt: '' };
  }
});

Next.js API Route

// pages/api/compose.js
import { composeSystemPrompt } from 'system-prompt-composer';

export default async function handler(req, res) {
  if (req.method === 'POST') {
    try {
      const response = await composeSystemPrompt(req.body);
      res.status(200).json(response);
    } catch (error) {
      res.status(500).json({ error: error.message });
    }
  }
}

Domain and Behavior Modules

The prompt composer uses modular prompt components:

Available Domains

  • analysis - Data analysis and interpretation guidance
  • filesystem - File and directory operation guidance
  • programming - Code analysis and development guidance
  • system - System administration and configuration guidance

Available Behaviors

  • planning - Multi-step task planning and organization
  • progress - Progress tracking and status updates
  • reasoning - Analytical thinking and problem-solving
  • tools - Effective tool usage and integration

Error Handling

try {
  const response = await composeSystemPrompt(request);
  console.log(`Generated ${response.system_prompt.length} character prompt`);
} catch (error) {
  console.error('Prompt generation failed:', error.message);
  // Fallback to basic prompt
  const fallbackPrompt = "You are a helpful AI assistant.";
}

Requirements

  • Node.js: 14.0.0 or higher
  • No other dependencies - native bindings included

Architecture

This package uses native Rust bindings via NAPI-RS:

Node.js → NAPI-RS → Rust Core → Prompt Generation

Benefits over subprocess approach:

  • ✅ No Python dependency
  • ✅ Native performance
  • ✅ Simple installation (npm install)
  • ✅ Better error handling
  • ✅ Smaller bundle size
  • ✅ Cross-platform binary distribution

Development

# Install dependencies
npm install

# Build native bindings
npm run build         # Release build
npm run build:debug   # Debug build

# Run tests
npm test

# Package for distribution
npm pack

Building from Source

# Prerequisites: Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Clone and build
git clone <repository>
cd prompt-composer/node
npm install
npm run build

License

MIT License - see LICENSE file for details.

Related Projects

Support

For issues, feature requests, or questions: