Skip to main content
Functions and classes exported by this package.

parseMarkdownSections(content)

Parse markdown content into classified sections. Splits on ## and ### headings, classifies each section by heuristic pattern matching, and returns structured section data with line numbers for source mapping. Signature
Parameters Returns — Array of parsed and classified sections

classifySection(section)

Classify a markdown section based on its heading and content. Uses heuristic matching against known patterns. Returns ‘unknown’ for sections that cannot be confidently classified. Signature
Parameters Returns — The classification type

extractProperties(lines)

Extract key-value properties from markdown bullet lists. Matches patterns like: - - **Key**: value - - **Key**: value - - Key: value Signature
Parameters Returns — Array of extracted properties

extractPermissions(lines)

Extract permission entries from markdown content. Handles two formats: 1. Structured: - Tasks: read, write 2. Prose: - Read and write tasks Signature
Parameters Returns — Array of extracted permissions

headingToIdentifier(heading)

Normalize a heading into a valid CANT identifier. Converts “Code Review Agent” to “code-review-agent”, strips common suffixes like ” Agent”, lowercases, and replaces non-alphanumeric chars with hyphens. Signature
Parameters Returns — A valid CANT identifier

headingToEventName(heading)

Map a hook heading to a CAAMP event name. Converts headings like “On Session Start” to “SessionStart”. Returns null if the heading does not match a known event. Signature
Parameters Returns — The CAAMP PascalCase event name, or null

getCaampEvents()

Get the full set of CAAMP event names. Signature
Returns — A read-only set of the 16 canonical CAAMP events

serializeCantDocument(doc)

Serialize a CANT document IR into .cant file text. Produces a complete .cant file including frontmatter and body. All string values are quoted, arrays use bracket notation, and indentation uses 2 spaces per level. Signature
Parameters Returns — The complete .cant file content as a string

formatValue(value)

Format a property value for .cant output. - Strings are double-quoted - Arrays use bracket notation with quoted elements - Numbers and booleans are bare Signature
Parameters Returns — Formatted string

propertiesToIR(properties)

Convert extracted properties to CANT property IR format. Maps known markdown property keys to their CANT equivalents: - “model” - model - “persistence” / “persist” - persist - “prompt” - prompt - “skills” - skills (as array) Signature
Parameters Returns — CANT property IR array

migrateMarkdown(content, inputFile, options)

Migrate a markdown file to CANT format. Parses the markdown into sections, classifies each section, converts recognized patterns to .cant files, and flags everything else as unconverted with TODO comments. Signature
Parameters Returns — Migration result with converted files and unconverted sections

showDiff(result, useColor)

Show a color-coded diff of the migration result. Displays: - A summary header with conversion stats - Each converted file with green-highlighted content - Each unconverted section with yellow-highlighted warnings Signature
Parameters Returns — The formatted diff string

showSummary(result)

Generate a simple text-only summary (no color). Suitable for logging or non-terminal output. Signature
Parameters Returns — Plain text summary

isNativeAvailable()

Check if the native addon is available Signature

cantParseNative()

Parse a CANT message using the native addon Signature

cantClassifyDirectiveNative()

Classify a directive using the native addon Signature

initCantParser()

Initialize the CANT parser With napi-rs native addons, this is a no-op (native modules load synchronously). Kept for backward compatibility with code that previously called this for WASM init. Signature
Example

parseCANTMessage(content)

Parse a CANT message If the native addon is available, uses the Rust cant-core parser via napi-rs. Falls back to a basic JavaScript implementation if the native addon is not loaded. Signature
Parameters Returns — ParsedCANTMessage with directive, addresses, task_refs, tags Example

initWasm()

Initialize the WASM module Must be called before using any WASM functions Signature

isWasmAvailable()

Check if WASM is available Signature

cantParseWASM()

Parse a CANT message using WASM Signature

cantClassifyDirectiveWASM()

Classify a directive using WASM Signature