trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
56 lines • 2 kB
TypeScript
/**
* Wiki-Link Parser
*
* Parses [[...]] references from markdown files and doc-comments
* in source code. Supports namespaced and bare syntax with smart
* namespace inference.
*
* @see TRL-11
*/
import type { EntityRef, RefNamespace } from './types.js';
/**
* Parse all [[...]] references from a file's content.
* Detects context (markdown vs doc-comment) based on file extension.
*/
export declare function parseFileRefs(content: string, filePath: string): EntityRef[];
/**
* Parse all [[...]] references from markdown content.
*/
export declare function parseMarkdownRefs(content: string, filePath: string): EntityRef[];
/**
* Parse [[...]] references from doc-comments in source code.
* Extracts comment blocks first, then scans them for wiki-links.
*/
export declare function parseDocCommentRefs(content: string, filePath: string, ext?: string): EntityRef[];
interface ParsedRef {
namespace: RefNamespace;
target: string;
anchor?: string;
alias?: string;
}
/**
* Parse the inner content of a [[...]] wiki-link.
*
* Supported forms:
* - "namespace:target" → explicit namespace
* - "namespace:target|alias" → explicit namespace + alias
* - "namespace:target#anchor" → explicit namespace + anchor
* - "target" → infer namespace
* - "target|alias" → infer namespace + alias
* - "path#anchor" → symbol ref
* - "path#anchor|alias" → symbol ref + alias
*/
export declare function parseRefContent(raw: string): ParsedRef | null;
/**
* Infer the namespace from bare ref content.
*
* Rules (in order):
* 1. TRL-\d+ pattern → issue
* 2. DEC-\d+ pattern → decision
* 3. Has anchor (#) → symbol
* 4. Contains '/' or has known file extension → file
* 5. Otherwise → null (namespace required)
*/
export declare function inferNamespace(target: string, anchor?: string): RefNamespace | null;
export {};
//# sourceMappingURL=parser.d.ts.map