aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
83 lines • 3.41 kB
TypeScript
/**
* Citation Sidecar Edge Extraction
*
* Parses markdown citation sidecar files into typed graph edges.
* Each sidecar has YAML frontmatter with `ref: <id>` and two markdown tables:
*
* - **Outgoing**: papers this work cites (column: "Inducted REF") → `cites` edges
* - **Incoming**: corpus papers that cite this work (column: "REF") → `cited-by` edges
*
* Supported node-id forms (#105):
* - `REF-\d+` research-paper IDs (REF-001, REF-029, ...)
* - `PROF-[POFG]-[a-z0-9-]+` entity-profile IDs:
* - `PROF-P-*` people, `PROF-O-*` orgs, `PROF-F-*` funders, `PROF-G-*` groups
*
* Both forms can appear as the sidecar's source (`frontmatter.ref`) and as
* targets in the outgoing/incoming tables. The two ID spaces are
* unambiguous (always prefixed) and orthogonal.
*
* @implements #722
* @implements #105
* @source @src/artifacts/types.ts
* @tests @test/unit/artifacts/citation-parser.test.ts
*/
import type { TypedEdge } from './types.js';
/**
* Test whether a string is a valid sidecar node identifier.
*
* Accepts `REF-\d+` and `PROF-[POFG]-[a-z0-9-]+`. Returns false for any
* other input (including unrelated `PROF-` prefixed strings that don't
* match the four-letter type code form).
*/
export declare function isNodeId(value: unknown): value is string;
/**
* Result of parsing a single citation sidecar file
*/
export interface CitationParseResult {
/** Source node identifier (e.g., "REF-008" or "PROF-P-marks-samuel") */
ref: string;
/** Outgoing "cites" edges — node IDs this paper references */
cites: string[];
/** Incoming "cited-by" edges — node IDs of papers that cite this one */
citedBy: string[];
}
/**
* Extract node identifiers from a markdown table column.
*
* Scans table rows for a column matching `columnName` (case-insensitive)
* and extracts node IDs (REF-* or PROF-*), skipping empty/dash values.
*
* @param tableText - Markdown table text (header + separator + rows)
* @param columnName - Column header to extract from (e.g., "Inducted REF")
* @returns Array of node identifiers found
*/
export declare function extractRefsFromTable(tableText: string, columnName: string): string[];
/**
* Parse a citation sidecar markdown file into structured edges.
*
* @param content - Full markdown content of the sidecar file
* @returns Parse result with ref ID and edge arrays, or null if not a valid sidecar
*/
export declare function parseCitationSidecar(content: string): CitationParseResult | null;
/**
* Convert a CitationParseResult into TypedEdge arrays for the dependency graph.
*
* @param result - Parsed citation sidecar
* @param refToPath - Map from REF-XXX to file path in the index
* @returns Object with upstream (cites) and downstream (cited-by) typed edges
*/
export declare function citationResultToEdges(result: CitationParseResult, refToPath: Map<string, string>): {
upstream: TypedEdge[];
downstream: TypedEdge[];
};
/**
* Build a node-id → file path mapping from indexed entries.
*
* Scans entry frontmatter for `ref` fields matching the node-id pattern
* (REF-* or PROF-*).
*
* @param entries - Map of path → parsed frontmatter data
* @returns Map from node identifier to file path
*/
export declare function buildRefToPathMap(entries: Map<string, Record<string, unknown>>): Map<string, string>;
//# sourceMappingURL=citation-parser.d.ts.map