@@ -12,6 +12,10 @@ import { textToString } from "../text.js";
1212 * @param doc - The document to search.
1313 * @param id - The node ID to find.
1414 * @returns The matching node, or null.
15+ * @example
16+ * ```ts
17+ * findNode(doc, "D1")
18+ * ```
1519 */
1620function findNode ( doc : SysProMDocument , id : string ) : Node | null {
1721 return doc . nodes . find ( ( n ) => n . id === id ) ?? null ;
@@ -22,6 +26,10 @@ function findNode(doc: SysProMDocument, id: string): Node | null {
2226 * @param doc - The document to search.
2327 * @param type - The node type to filter by.
2428 * @returns Matching nodes.
29+ * @example
30+ * ```ts
31+ * const decisions = findNodesByType(doc, "decision");
32+ * ```
2533 */
2634function findNodesByType ( doc : SysProMDocument , type : string ) : Node [ ] {
2735 return doc . nodes . filter ( ( n ) => n . type === type ) ;
@@ -33,6 +41,10 @@ function findNodesByType(doc: SysProMDocument, type: string): Node[] {
3341 * @param fromId - Source node ID.
3442 * @param relationType - Optional relationship type filter.
3543 * @returns Matching relationships.
44+ * @example
45+ * ```ts
46+ * const rels = findRelationshipsFrom(doc, "D1", "affects");
47+ * ```
3648 */
3749function findRelationshipsFrom (
3850 doc : SysProMDocument ,
@@ -52,6 +64,10 @@ function findRelationshipsFrom(
5264 * @param toId - Target node ID.
5365 * @param relationType - Optional relationship type filter.
5466 * @returns Matching relationships.
67+ * @example
68+ * ```ts
69+ * const rels = findRelationshipsTo(doc, "INV1", "must_preserve");
70+ * ```
5571 */
5672function findRelationshipsTo (
5773 doc : SysProMDocument ,
@@ -70,6 +86,10 @@ function findRelationshipsTo(
7086 * Looks for patterns like "P1", "P2", "Priority: P1", etc.
7187 * @param node - The node to extract priority from.
7288 * @returns Priority string (e.g. "P1").
89+ * @example
90+ * ```ts
91+ * const priority = extractPriority(node);
92+ * ```
7393 */
7494function extractPriority ( node : Node ) : string {
7595 const text = [
@@ -88,6 +108,10 @@ function extractPriority(node: Node): string {
88108 * Extract numeric suffix from an ID (e.g., "PREFIX-SPEC-001" -> "001").
89109 * @param id - The node ID.
90110 * @returns The numeric suffix.
111+ * @example
112+ * ```ts
113+ * getIdSuffix("FEAT-SPEC-001"); // => "001"
114+ * ```
91115 */
92116function getIdSuffix ( id : string ) : string {
93117 const parts = id . split ( "-" ) ;
@@ -98,6 +122,10 @@ function getIdSuffix(id: string): string {
98122 * Parse tasks from a change node's plan array.
99123 * @param node - The change node.
100124 * @returns Array of task descriptions and done flags.
125+ * @example
126+ * ```ts
127+ * const tasks = parseTasks(changeNode);
128+ * ```
101129 */
102130function parseTasks ( node : Node ) : { description : string ; done : boolean } [ ] {
103131 return ( node . plan ?? [ ] ) . map ( ( task ) => ( {
@@ -110,6 +138,10 @@ function parseTasks(node: Node): { description: string; done: boolean }[] {
110138 * Format the status for spec output: "proposed" -> "Draft", etc.
111139 * @param status - The node status string.
112140 * @returns Formatted status label.
141+ * @example
142+ * ```ts
143+ * formatStatus("proposed"); // => "Draft"
144+ * ```
113145 */
114146function formatStatus ( status ?: string ) : string {
115147 if ( ! status ) return "Draft" ;
@@ -130,6 +162,10 @@ function formatStatus(status?: string): string {
130162 * @param doc - The SysProM document.
131163 * @param prefix - ID prefix identifying nodes to include.
132164 * @returns The generated markdown.
165+ * @example
166+ * ```ts
167+ * const md = generateConstitution(doc, "FEAT");
168+ * ```
133169 */
134170export function generateConstitution (
135171 doc : SysProMDocument ,
@@ -224,6 +260,10 @@ export function generateConstitution(
224260 * @param doc - The SysProM document.
225261 * @param prefix - ID prefix identifying nodes to include.
226262 * @returns The generated markdown.
263+ * @example
264+ * ```ts
265+ * const md = generateSpec(doc, "FEAT");
266+ * ```
227267 */
228268export function generateSpec ( doc : SysProMDocument , prefix : string ) : string {
229269 const specId = `${ prefix } -SPEC` ;
@@ -369,6 +409,10 @@ export function generateSpec(doc: SysProMDocument, prefix: string): string {
369409 * @param doc - The SysProM document.
370410 * @param prefix - ID prefix identifying nodes to include.
371411 * @returns The generated markdown.
412+ * @example
413+ * ```ts
414+ * const md = generatePlan(doc, "FEAT");
415+ * ```
372416 */
373417export function generatePlan ( doc : SysProMDocument , prefix : string ) : string {
374418 const implProtocolId = `${ prefix } -PROT-IMPL` ;
@@ -432,6 +476,10 @@ export function generatePlan(doc: SysProMDocument, prefix: string): string {
432476 * @param doc - The SysProM document.
433477 * @param prefix - ID prefix identifying nodes to include.
434478 * @returns The generated markdown.
479+ * @example
480+ * ```ts
481+ * const md = generateTasks(doc, "FEAT");
482+ * ```
435483 */
436484export function generateTasks ( doc : SysProMDocument , prefix : string ) : string {
437485 const implProtocolId = `${ prefix } -PROT-IMPL` ;
@@ -627,6 +675,10 @@ export function generateTasks(doc: SysProMDocument, prefix: string): string {
627675 * @param doc - The SysProM document.
628676 * @param prefix - ID prefix identifying nodes to include.
629677 * @returns The generated markdown.
678+ * @example
679+ * ```ts
680+ * const md = generateChecklist(doc, "FEAT");
681+ * ```
630682 */
631683export function generateChecklist (
632684 doc : SysProMDocument ,
@@ -700,6 +752,10 @@ export function generateChecklist(
700752 * @param doc - The SysProM document.
701753 * @param outputDir - Output directory path.
702754 * @param prefix - ID prefix identifying nodes to include.
755+ * @example
756+ * ```ts
757+ * generateSpecKitProject(doc, "./output", "FEAT");
758+ * ```
703759 */
704760export function generateSpecKitProject (
705761 doc : SysProMDocument ,
0 commit comments