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

@promptc/parser

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/parser

Parsers (markdown / XML / plain) into promptc IR.

Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
30
-36.17%
Maintainers
1
Weekly downloads
 
Created
Source

@promptc/parser

The front end of the promptc compiler — turns markdown, XML, or plain-text prompts into a typed PromptIR (defined in @promptc/ir).

Every entry point is a pure function of the input string: same bytes in produces the same IR out. No I/O, no RNG. This is the basis for the compile path's overall determinism guarantee.

Install

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

Quick API

import { parse, parseAuto, parseMarkdown, parseXml, parsePlain } from "@promptc/parser";

// Format-routed:
const ir1 = parse(source, { format: "markdown" });
const ir2 = parse(source, { format: "auto" });

// Direct:
const ir3 = parseMarkdown(source);
const ir4 = parseXml(source);   // throws ParseError on malformed input
const ir5 = parsePlain(source);

parse(source, { format: "auto" }) runs the lightweight format detector (no LM, no heuristics that depend on locale or environment) and dispatches to the right per-format parser.

What's in here

  • parseMarkdown — heading-and-list driven layout, fenced code, simple example/output-schema markers.
  • parseXml<task>, <context>, <example>, etc. tag layout. Throws ParseError on malformed input.
  • parsePlain — minimal plain-text fallback (one big task section).
  • parseAuto — format detector + dispatch.
  • ErrorsParseError with byte/line/column location info.

Errors

Malformed XML or invalid plain-text shapes throw ParseError, which carries a location field ({ line, column, byteOffset }) suitable for piping into editor diagnostics.

License

Apache-2.0. See LICENSE.

FAQs

Package last updated on 12 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