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
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
Returns — The classification type
extractProperties(lines)
Extract key-value properties from markdown bullet lists. Matches patterns like: -- **Key**: value - - **Key**: value - - Key: value
Signature
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
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
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
Returns — The CAAMP PascalCase event name, or null
getCaampEvents()
Get the full set of CAAMP event names. SignatureserializeCantDocument(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
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
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
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
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
Returns — The formatted diff string
showSummary(result)
Generate a simple text-only summary (no color). Suitable for logging or non-terminal output. Signature
Returns — Plain text summary
isNativeAvailable()
Check if the native addon is available SignaturecantParseNative()
Parse a CANT message using the native addon SignaturecantClassifyDirectiveNative()
Classify a directive using the native addon SignatureinitCantParser()
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. SignatureparseCANTMessage(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
Returns — ParsedCANTMessage with directive, addresses, task_refs, tags
Example