🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

promptel

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promptel

A declarative language for crafting sophisticated prompts for Large Language Models

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
7
250%
Maintainers
1
Weekly downloads
 
Created
Source

Promptel

The first Node.js framework with native Harmony Protocol support for advanced prompt engineering. Supports both .prompt and .yml formats.

GitHub license npm version Node.js CI

Why Promptel?

Modern AI applications need sophisticated prompt engineering, but implementing advanced techniques like Chain-of-Thought or handling multi-channel responses is complex and error-prone. Promptel solves this with a declarative approach and native support for OpenAI's Harmony Protocol.

Key Problems Solved

  • Harmony Protocol Complexity: Only Node.js framework with native gpt-oss support
  • Advanced Reasoning Techniques: Built-in Chain-of-Thought, Tree-of-Thoughts, ReAct
  • Multi-Channel Responses: Automatic parsing of analysis, commentary, and final outputs
  • Provider Lock-in: Abstract across OpenAI, Anthropic, Groq with consistent APIs

Quick Start

Installation

npm install promptel

Basic Example (.prompt format)

import { parsePrompt, executePrompt } from 'promptel';

const prompt = parsePrompt(`
prompt MathSolver {
  params {
    problem: string
  }

  body {
    text\`Solve: \${params.problem}\`
  }

  technique {
    chainOfThought {
      step("Analysis") { text\`Break down the problem\` }
      step("Solution") { text\`Calculate step by step\` }
      step("Verification") { text\`Verify the answer\` }
    }
  }
}
`);

const result = await executePrompt(prompt, {
  problem: "What is 25% of 240?"
}, {
  provider: 'openai',
  apiKey: process.env.OPENAI_API_KEY
});

console.log(result);

Harmony Protocol Example (gpt-oss)

const harmonyPrompt = parsePrompt(`
prompt HarmonyReasoning {
  harmony {
    reasoning: "high"
    channels: ["final", "analysis", "commentary"]
  }

  params {
    question: string
  }

  body {
    text\`\${params.question}\`
  }
}
`);

const result = await executePrompt(harmonyPrompt, {
  question: "Optimize database query performance for large datasets"
});

// Multi-channel outputs automatically parsed
console.log(result.channels.final);      // Clean answer for users
console.log(result.channels.analysis);   // Detailed reasoning process
console.log(result.channels.commentary); // Verification and alternatives

YAML Format Example

The same prompts can be written in YAML format for those who prefer structured configuration:

name: MathSolver

params:
  problem:
    type: string
    required: true

body:
  text: "Solve: ${params.problem}"

technique:
  chainOfThought:
    steps:
      - name: "Analysis"
        text: "Break down the problem"
      - name: "Solution"
        text: "Calculate step by step"
      - name: "Verification"
        text: "Verify the answer"
// Works with both formats automatically
const yamlPrompt = fs.readFileSync('math_solver.yml', 'utf-8');
const result = await executePrompt(yamlPrompt, { problem: "What is 25% of 240?" });

Format Conversion

Convert between .prompt and .yml formats:

# Convert .prompt to YAML
promptel --convert yaml -f solver.prompt -o solver.yml

# Convert YAML to .prompt
promptel --convert prompt -f solver.yml -o solver.prompt
// Programmatic conversion
import { FormatConverter } from 'promptel';

const converter = new FormatConverter();
const yamlVersion = converter.promptToYaml(promptContent);
const promptVersion = converter.yamlToPrompt(yamlContent);

Architecture

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│  Parser Module  │    │ Executor Module │    │Provider Adapter │
│                 │    │                 │    │                 │
│ • Lexer/Parser  │◄──►│ • Harmony Integ │◄──►│ • OpenAI        │
│ • AST Builder   │    │ • Technique Eng │    │ • Anthropic     │
│ • Validation    │    │ • Output Format │    │ • Groq          │
└─────────────────┘    └─────────────────┘    └─────────────────┘

Flow: .prompt/.yml fileParserASTExecutorProviderLLMResponse ParserStructured Output

Advanced Features

Multi-Provider Support

// Same prompt, different optimizations per provider
const executor = new PromptelExecutor(process.env.LLM_PROVIDER);
const result = await executor.execute(prompt, params);

// Harmony channels for OpenAI gpt-oss
// Thinking tags for Anthropic Claude
// Custom reasoning for Groq models

Built-in Techniques

  • Chain of Thought: Step-by-step reasoning
  • Tree of Thoughts: Multiple solution paths
  • ReAct: Reasoning + Action planning
  • Self-Consistency: Multi-solution consensus

Type-Safe Parameters

params {
  temperature: number = 0.7
  max_tokens?: number
  difficulty: "easy" | "medium" | "hard"
}

CLI Usage

# Execute prompt file (.prompt format)
promptel -f solver.prompt -p openai -k $OPENAI_API_KEY --params '{"problem":"2+2"}'

# Execute YAML format
promptel -f solver.yml -p openai -k $OPENAI_API_KEY --params '{"problem":"2+2"}'

# With output file
promptel -f prompt.prompt -p anthropic -k $ANTHROPIC_KEY -o result.json

# Convert formats
promptel --convert yaml -f solver.prompt -o solver.yml
promptel --convert prompt -f solver.yml -o solver.prompt

Requirements

  • Node.js 18+ (LTS recommended)
  • Supported provider API key (OpenAI, Anthropic, or Groq)

Documentation

Contributing

We welcome contributions! Please see our development setup:

git clone https://github.com/terraprompt/promptel.git
cd promptel
npm install
npm test
npm run lint

Performance

OperationTime (ms)Memory (MB)
Parse prompt5-152-5
Execute simple200-8005-10
Execute complex1000-300010-20
Harmony parsing50-1508-15

License

MIT License - see LICENSE file for details.

Support

Promptel makes advanced prompt engineering accessible, maintainable, and scalable for production AI applications.

Keywords

LLM

FAQs

Package last updated on 25 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts