Skip to main content

A modular system prompt composition framework for AI assistants

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Prompt Composer

A modular system prompt composition framework that intelligently generates system prompts for AI assistants based on available tools, task complexity, and contextual information.

Language Support

  • Python: pip install system-prompt-composer
  • Node.js: npm install system-prompt-composer (native bindings - no Python required!)

Quick Start

Python

import system_prompt_composer
import json

request = {
    "user_prompt": "Help me analyze this code",
    "mcp_config": {"mcpServers": {...}},
    "session_state": {"tool_call_count": 0}
}

response = system_prompt_composer.compose_system_prompt(json.dumps(request))
result = json.loads(response)
print(result["system_prompt"])

Node.js (Native)

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

const request = {
  user_prompt: "Help me analyze this code",
  mcp_config: { mcpServers: {...} },
  session_state: { tool_call_count: 0 }
};

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

๐Ÿ“– For detailed Node.js documentation, see node/README.md

Project Structure

prompt-composer/
โ”œโ”€โ”€ core/              # Rust core implementation
โ”‚   โ”œโ”€โ”€ lib.rs         # Main library with NAPI bindings
โ”‚   โ”œโ”€โ”€ types.rs       # Type definitions
โ”‚   โ”œโ”€โ”€ composition.rs # Prompt composition logic
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ python/            # Python package (PyO3 bindings)
โ”œโ”€โ”€ node/              # Node.js package (native NAPI-RS bindings)
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ”œโ”€โ”€ index.js       # Native bindings wrapper
โ”‚   โ””โ”€โ”€ index.d.ts     # TypeScript definitions
โ”œโ”€โ”€ prompts/           # Modular prompt library
โ”‚   โ”œโ”€โ”€ domains/       # Domain-specific prompts
โ”‚   โ””โ”€โ”€ behaviors/     # Behavioral guidance prompts
โ””โ”€โ”€ README.md          # This file

Features

  • ๐Ÿง  Intelligent prompts that adapt to available MCP tools
  • ๐Ÿ“‹ Automatic task planning for complex requests
  • ๐ŸŽฏ Context-aware guidance for different domains (programming, analysis, filesystem, etc.)
  • ๐Ÿ“Š Progress monitoring for multi-step workflows
  • ๐Ÿ”„ Modular design with composable prompt components
  • โšก High performance with Rust core
  • ๐ŸŒ Multi-language support (Python, Node.js)

Installation

Python Package

pip install system-prompt-composer

Node.js Package (Native - No Python Required!)

npm install system-prompt-composer

The Node.js package now uses native Rust bindings via NAPI-RS, eliminating the Python dependency!

API Reference

Core Functions

composeSystemPrompt(request)

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

Parameters:

  • request.user_prompt (string): The user's request
  • request.mcp_config (object): MCP server configuration with mcpServers
  • request.session_state (object): Current session state including tool_call_count
  • request.domain_hints (array, optional): Domain hints like ["programming", "analysis"]
  • request.task_complexity (string, optional): "Simple", "Complex", or "Auto"

Returns:

{
  system_prompt: "Generated prompt text...",
  source: "native",
  version: "1.1.0",
  // ... additional metadata
}

getStatus()

Returns system status and configuration information including available domains and behaviors.

isAvailable()

Always returns true for native bindings.

Tools Directory Feature

The system-prompt-composer supports tool-specific instruction files to improve how LLMs use MCP tools.

How It Works

When you call composeSystemPrompt() with MCP server configurations, the system automatically looks for corresponding instruction files in prompts/tools/ and includes them in the generated system prompt.

prompts/
โ”œโ”€โ”€ behaviors/          # General AI behaviors 
โ”œโ”€โ”€ domains/           # Domain-specific knowledge
โ”œโ”€โ”€ tools/             # NEW: Tool-specific instructions
โ”‚   โ”œโ”€โ”€ desktop-commander.md
โ”‚   โ”œโ”€โ”€ weather-service.md
โ”‚   โ””โ”€โ”€ [your-mcp-server-name].md
โ””โ”€โ”€ server_patterns.toml

Creating Tool Instructions

Create a markdown file named after your MCP server:

# My Custom Tool Instructions

You have access to my-custom-tool with these capabilities:
- Function 1: description and best practices
- Function 2: common usage patterns

## Best Practices
- Specific guidance for effective tool usage
- Error handling approaches
- Performance considerations

Updated API Response

Tool instructions are automatically included and tracked:

{
  system_prompt: "...",
  applied_modules: [
    "planning",
    "tool:desktop-commander",  // Tool instructions included
    "tool:weather-service"
  ],
  recognized_tools: [...],
  complexity_assessment: "simple"
}

The getStatus() function now also returns available tools:

{
  available: true,
  domains: ["analysis", "filesystem", "programming"],
  behaviors: ["planning", "progress", "reasoning"], 
  tools: ["desktop-commander", "weather-service"],  // NEW
  version: "1.0.3"
}

Benefits

  • Better Tool Usage: LLMs get specific guidance for each tool
  • Developer Control: Customize instructions for your MCP tools
  • Automatic Integration: Just add markdown files - no code changes
  • Graceful Fallback: Missing tool files are safely ignored

Architecture

Native Node.js Architecture (NEW):

Node.js โ†’ NAPI-RS โ†’ Rust Core

Python Architecture:

Python โ†’ PyO3 โ†’ Rust Core  

Key Benefits of Native Bindings:

  • โœ… No Python dependency for Node.js users
  • โœ… Native performance - direct Rust execution
  • โœ… Simple deployment - just npm install
  • โœ… Better error handling
  • โœ… Cross-platform binary distribution
  • โœ… Smaller bundle size

Development

Building Native Node.js Package

cd node/
npm install
npm run build        # Build release binaries
npm run build:debug  # Build debug binaries
npm test            # Run tests

Python Development

cd python/
pip install -e .

Rust Core Development

cargo build --release
cargo test
cargo build --features nodejs  # For Node.js bindings
cargo build --features python  # For Python bindings

Publishing

Node.js (npm)

cd node/
npm run build       # Build native binaries
npm publish --access public

Python (PyPI)

cd python/
pip install build twine
python -m build
twine upload dist/*

Contributing

Contributions welcome! The project uses:

  • Rust for the core prompt composition engine
  • NAPI-RS for Node.js native bindings
  • PyO3 for Python bindings
  • Modular prompts in the prompts/ directory

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

system_prompt_composer-1.0.5.tar.gz (62.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_34_x86_64.whl (561.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl (18.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.5+ x86-64

system_prompt_composer-1.0.5-cp311-cp311-manylinux_2_34_x86_64.whl (562.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

system_prompt_composer-1.0.5-cp310-cp310-manylinux_2_34_x86_64.whl (562.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

system_prompt_composer-1.0.5-cp39-cp39-manylinux_2_34_x86_64.whl (562.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

system_prompt_composer-1.0.5-cp38-cp38-manylinux_2_34_x86_64.whl (562.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file system_prompt_composer-1.0.5.tar.gz.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5.tar.gz
Algorithm Hash digest
SHA256 a5b0bc2001c808421984057c0cbc3dfaff744cd1f915d57599ae1d0c5e25afce
MD5 51fa462e4b0c03480a2e77da424ccbe9
BLAKE2b-256 2795f0b7b990c86cde10d54bbb65dc89769d0ce6fcad55a6fe529c4a4c1836a8

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 692212d3fd7d8804698103d470d800eefa4b8e042514a892fd85b0d2ec2981f1
MD5 fee8855b3b9481f4fa3d69e32de26eb3
BLAKE2b-256 769f1ab6d0dfc83f67b40131199b2411f920118684ed74ae03f2b85119a614b2

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f6acad7ab539a53ad456f05820bb272ba721e66b11d2e1c7b0575242ee4fd686
MD5 666dadf2306db6a97d212f09b1b0d82f
BLAKE2b-256 9ccc136446e89974943c2c34c1a88e2c6a7576c2f8c5f779b240b66f9ec1bb6e

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4f2412349e6877195a0adf78536dedbb0fdb2bc4e8867c378c19343ef20032b3
MD5 54d7d40ea01ee35e71b1d2787a377129
BLAKE2b-256 7647ba51a52ea5b32c5e191d1dd66a77757ec1794564983ce2166194594b3f67

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6862f2c06b8e29a642c063d3d25217eb3c1f01bc140dfa5a45d7d2649a89da7d
MD5 75fbd4368916669225c84d1b07eb3a82
BLAKE2b-256 4683a9cfe4692fb7b9c87580a18cb485e699390e4b5b7d5864a7fe777fbe3640

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 6e9992ae2f44c4d6f7d74bc661cf3f227fd764d6f360765dbadfde39512ccfa2
MD5 0ca64d0578182cb0f0eb33a6b13cf63b
BLAKE2b-256 135fb59c7ebaf9085cd3c94d99b670c8b0c6f4f8279055f31d734129fa59b178

See more details on using hashes here.

File details

Details for the file system_prompt_composer-1.0.5-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for system_prompt_composer-1.0.5-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 148545d7b929ea9847ea5c3bb50a5422e7fe525aaca7d316d48e3c96e401b937
MD5 85f19aab684594bf0fabc21b6f37bb14
BLAKE2b-256 908b4e96c745e170012a7744f54dc66f5d7127b8d9d6f4ed064c933ad63b7e26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page