Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@promptc/ir

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@promptc/ir

Prompt IR types and utilities for promptc.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
27
-89.58%
Maintainers
1
Weekly downloads
 
Created
Source

@promptc/ir

The typed prompt intermediate representation (IR) and core utilities for promptc — a deterministic, LM-free compiler for prompts.

This package defines the IR that the rest of the @promptc/* toolchain operates on:

  • @promptc/parser produces a PromptIR from markdown / XML / plain input.
  • @promptc/passes runs optimization passes against a PromptIR.
  • @promptc/codegen emits a surface-format string from a PromptIR.
  • @promptc/cli wires them together as the promptc command.

If you want to write your own passes, custom parsers, or alternative codegen for the promptc pipeline, this is the package you import.

Install

bun add @promptc/ir
# or
npm install @promptc/ir

Quick API

import {
  buildPromptIR,
  addSection,
  addInstruction,
  validateIR,
  serializeIR,
  deserializeIR,
  type PromptIR,
} from "@promptc/ir";

// Build an IR from scratch.
let ir = buildPromptIR({ sourceFormat: "markdown" });
ir = addSection(ir, { kind: "task", title: "Task" });
ir = addInstruction(ir, { sectionId: /* ... */, kind: "directive", text: "Summarize." });

// Validate it.
const outcome = validateIR(ir);
if (!outcome.valid) throw new Error(outcome.errors[0]?.message);

// Snapshot / restore.
const json = serializeIR(ir);
const round = deserializeIR(json);

What's in here

  • TypesPromptIR, Section, Instruction, Example, Slot, OutputSchema, Pass, PassResult, etc. (canonical definitions for the whole compiler).
  • Builders — pure, deterministic constructors (buildPromptIR, addSection, addInstruction, ...) used by the parser and by tests.
  • Serialize — JSON snapshot + restore with IRValidationError.
  • ValidatevalidateIR(ir) runs invariant checks (no orphan nodes, no duplicate ids, etc.).

Determinism

Every entry point is a pure function of its inputs — no I/O, no clock, no RNG. Same inputs in produces same outputs out, bit-for-bit. This is the foundation of the promptc compile-path determinism guarantee.

License

Apache-2.0. See LICENSE.

FAQs

Package last updated on 25 May 2026

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