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

vv-ai-promt-store

v2.0.2

Published

Helper for store promt in file

Readme

Русский

vv-ai-promt-store

A lightweight TypeScript library for storing and managing AI prompts in a simple text format.

Features

  • Simple text-based format for storing prompts
  • Support for system and user prompts
  • Custom parameters for each prompt
  • Multiple prompts in a single file
  • Parse and serialize prompts to/from text

Installation

npm install vv-ai-promt-store

Format

The library uses a simple text format with special markers:

$$begin
$$options
temperature=0.7
maxTokens=4096
$$system
System prompt text here
$$user
User prompt text here
$$jsonresponse
{"type": "object", "properties": {"name": {"type": "string"}}}
$$segment=segmentName
Segment content here
$$end

Format rules:

  • $$begin - Start of a prompt block
  • $$end - End of a prompt block
  • $$user - User prompt (required)
  • $$system - System prompt (optional)
  • $$options - LLM settings section (optional)
  • $$jsonresponse - JSON Schema for structured response output (optional)
  • $$segment=name - Named text segments (optional)
  • Text before the first $$begin and after the last $$end is ignored
  • Section order within a block doesn't matter
  • All sections except $$user are optional
  • Multiple segments with different names can be defined

Usage

Parsing prompts from text

import { PromtLoad } from 'vv-ai-promt-store'

const text = `
$$begin
$$options
temperature=0.7
maxTokens=4096
$$system
You are a helpful assistant
$$user
What is 2+2?
$$end
`

const prompts = PromtLoad(text)
console.log(prompts)
// [{
//   system: 'You are a helpful assistant',
//   user: 'What is 2+2?',
//   options: { temperature: 0.7, maxTokens: 4096 }
// }]

Serializing prompts to text

import { PromtStore, TPromt } from 'vv-ai-promt-store'

const prompts: TPromt[] = [{
  system: 'You are a helpful assistant',
  user: 'Hello, world!',
  options: {
    temperature: 0.7,
    maxTokens: 4096
  }
}]

const text = PromtStore(prompts)
console.log(text)
// $$begin
// $$options
// temperature=0.7
// maxTokens=4096
// $$system
// You are a helpful assistant
// $$user
// Hello, world!
// $$end

Multiple prompts

import { PromtLoad } from 'vv-ai-promt-store'

const text = `
$$begin
$$user
First prompt
$$end

$$begin
$$system
Different system prompt
$$user
Second prompt
$$end
`

const prompts = PromtLoad(text)
console.log(prompts.length) // 2

Working with JSON Schema responses

The $$jsonresponse section allows you to define a JSON Schema for structured response output. This is useful when you need the AI to return data in a specific format:

import { PromtLoad, PromtStore, TPromt } from 'vv-ai-promt-store'

const prompts: TPromt[] = [{
  user: 'Generate a user profile',
  jsonresponse: JSON.stringify({
    type: 'object',
    required: ['name', 'age'],
    properties: {
      name: { type: 'string' },
      age: { type: 'number' },
      email: { type: 'string', format: 'email' }
    }
  })
}]

const text = PromtStore(prompts)
console.log(text)
// $$begin
// $$user
// Generate a user profile
// $$jsonresponse
// {"type":"object","required":["name","age"],"properties":{"name":{"type":"string"},"age":{"type":"number"},"email":{"type":"string","format":"email"}}}
// $$end

const parsed = PromtLoad(text)
console.log(JSON.parse(parsed[0].jsonresponse)) // Access the JSON Schema

Working with segments

Segments allow you to store named blocks of text within a prompt:

import { PromtLoad, PromtStore, TPromt } from 'vv-ai-promt-store'

const prompts: TPromt[] = [{
  user: 'Analyze this code',
  segment: {
    code: 'function hello() { return "world"; }',
    tests: 'test("hello", () => { expect(hello()).toBe("world"); })'
  }
}]

const text = PromtStore(prompts)
console.log(text)
// $$begin
// $$user
// Analyze this code
// $$segment=code
// function hello() { return "world"; }
// $$segment=tests
// test("hello", () => { expect(hello()).toBe("world"); })
// $$end

const parsed = PromtLoad(text)
console.log(parsed[0].segment.code) // Access segment content

API

Types

type TPromtOptions = {
  temperature?: number
  topP?: number
  topK?: number
  minP?: number
  maxTokens?: number
  repeatPenalty?: number
  repeatPenaltyNum?: number
  presencePenalty?: number
  frequencyPenalty?: number
  mirostat?: number
  mirostatTau?: number
  mirostatEta?: number
  penalizeNewline?: boolean
  stopSequences?: string[]
  trimWhitespace?: boolean
}

type TPromt = {
  system?: string
  user: string
  options?: TPromtOptions
  segment?: Record<string, string>
  jsonresponse?: string
}

Options format

The $$options section supports various formats for values:

Numbers:

  • Decimal: 0.7, 2, 2.4
  • With comma separator: 0,7, 2,4
  • In quotes: "0.7", '0.9'

Booleans:

  • Standard: true, false
  • Numeric: 1, 0
  • Short: y, n (case insensitive)
  • In quotes: "true", 'false'

Arrays:

  • JSON format: stopSequences=["stop1", "stop2"]

Undefined:

  • Empty value: minP= (parameter will be undefined)

Functions

PromtLoad(raw: string, use?: 'core' | 'json'): TPromt[]

Parses text and returns an array of prompts.

Parameters:

  • raw - Text containing prompts in the specified format
  • use - Schema type for options validation (optional, default: 'core'):
    • 'core' - Standard AI model settings (higher temperature, creativity)
    • 'json' - Structured JSON output settings (lower temperature, deterministic)

Returns:

  • Array of TPromt objects

Example:

const prompts = PromtLoad(text, 'json') // Use JSON schema defaults

PromtOptionsParse(use: 'core' | 'json', raw?: object, useAllOptions?: boolean): TPromtOptions

Parses and validates prompt options from a raw object.

Parameters:

  • use - Schema type: 'core' for standard AI models, 'json' for structured JSON output
  • raw - Raw object containing option values to parse (optional)
  • useAllOptions - If true, returns all options with defaults; if false, returns only specified options (optional, default: true)

Returns:

  • Validated TPromtOptions object. Invalid values are replaced with defaults. Never throws errors.

Example:

// Get all options with defaults
const options = PromtOptionsParse('core', { temperature: 0.7 })
// Returns: { temperature: 0.7, topP: 0.9, topK: 40, ... all other defaults }

// Get only specified options
const options = PromtOptionsParse('core', { temperature: 0.7 }, false)
// Returns: { temperature: 0.7 }

PromtStore(promt: TPromt[]): string

Serializes an array of prompts to text format.

Parameters:

  • promt - Array of TPromt objects

Returns:

  • String in the specified format

License

MIT