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
| Name | Type | Description |
|---|---|---|
content | string | Raw markdown content |
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| Name | Type | Description |
|---|---|---|
section | MarkdownSection | The section to classify |
extractProperties(lines)
Extract key-value properties from markdown bullet lists. Matches patterns like: -- **Key**: value - - **Key**: value - - Key: value
Signature
| Name | Type | Description |
|---|---|---|
lines | string[] | Body lines of a section |
extractPermissions(lines)
Extract permission entries from markdown content. Handles two formats: 1. Structured:- Tasks: read, write 2. Prose: - Read and write tasks
Signature
| Name | Type | Description |
|---|---|---|
lines | string[] | Body lines of a permissions section |
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| Name | Type | Description |
|---|---|---|
heading | string | The raw heading text |
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| Name | Type | Description |
|---|---|---|
heading | string | The raw heading text |
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| Name | Type | Description |
|---|---|---|
doc | CantDocumentIR | The document IR to serialize |
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| Name | Type | Description |
|---|---|---|
value | string | string[] | number | boolean | The value to format |
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| Name | Type | Description |
|---|---|---|
properties | ExtractedProperty[] | Extracted markdown properties |
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| Name | Type | Description |
|---|---|---|
content | string | Raw markdown file content |
inputFile | string | Path to the input file (for diagnostics) |
options | MigrationOptions | Migration options (write, verbose, outputDir) |
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| Name | Type | Description |
|---|---|---|
result | MigrationResult | The migration result to display |
useColor | : boolean | Whether to use ANSI color codes (default: true) |
showSummary(result)
Generate a simple text-only summary (no color). Suitable for logging or non-terminal output. Signature| Name | Type | Description |
|---|---|---|
result | MigrationResult | The migration result to summarize |
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| Name | Type | Description |
|---|---|---|
content | string | The CANT message content to parse |