Internal
Internal Runtime Functions
Internal runtime helpers resolve document sources, parse recognized files, and build reader models.
These functions are implementation details of the bundled reader, not part of a stable public API.
function
readDocumentCollection
readDocumentCollection(): Promise<DocumentCollection>
Load all recognized Neenja documents and return the full reader collection.
- Behavior
no visible concepts.
- Resolves the documents directory.
- Reads recognized document files.
- Parses documentation, project plan, and task tree documents.
- Builds
documents,documentsBySlug, anddefaultDocument. - Uses the project plan as
defaultDocumentwhen documentation exists but has
function
readDocumentationDocument
readDocumentationDocument(): Promise<DocumentationDocument>
Load and parse the documentation document only.
- Behavior
- Supports single-document reader callers.
- Reads
NEENJA_DOCUMENTATION_PATHor the default documentation path. - Parses concepts, filters by visibility, and builds a type index.
function
parseConcept
parseConcept(block: string): Concept
Parse one ## Concept: block into the in-memory documentation concept model.
- Behavior
- Reads concept metadata such as
ID,Privacy,Type, andCategory. - Routes the body through the Markdown parser or structured entry parser based on
ConceptKind.
- Reads concept metadata such as
function
parsePlanSection
parsePlanSection(block: string): PlanSection
Parse one ## Plan: block into a technical project-plan section.
- Behavior
- Reads
ID,Area, and optionalSummary. - Keeps non-metadata section content as Markdown.
- Parses body content before the first
###heading as intro Markdown. - Parses each
###heading as aPlanDetailBlock.
- Reads
function
parsePlanDetailBlock
parsePlanDetailBlock(block: string, usedIds: Set<string>): PlanDetailBlock
Parse one ### technical detail block inside a project-plan section.
- Behavior
- Derives a unique block ID from the heading.
- Keeps the block body as Markdown content.
function
parsePlanMetadataFields
parsePlanMetadataFields(lines: string[]): { metadata: Record<string, string>; bodyStartIndex: number }
Parse the small metadata header at the start of a project-plan section.
- Behavior
- Accepts only
ID,Area, andSummaryas project-plan metadata. - Stops before the first non-metadata line so it can render as Markdown body content.
- Returns the index where body parsing should continue.
- Accepts only
function
parseYamlTaskNode
parseYamlTaskNode(rawTask: RawTaskNode, parentId: string | undefined, usedIds: Set<string>): { task: TaskNode; children: RawTaskNode[] }
Parse one YAML task object into a task node before derived graph relationships are applied.
- Behavior
children.- Reads
id,title,status,area,dependsOn,details, and nested - Normalizes status aliases such as
doingtoin-progressandcompletedtodone. - Parses
detailsas Markdown content.
- Reads
function
resolveDocumentDirectoryPath
resolveDocumentDirectoryPath(): Promise<string>
Resolve the directory that should be scanned for recognized Neenja documents.
- Behavior
- Uses
NEENJA_DOCUMENTS_DIRorNEENJA_DOCUMENTS_PATHwhen present. - Falls back to
${NEENJA_PROJECT_ROOT}/.neenjaor${process.cwd()}/.neenja.
- Uses
function
buildTypeIndex
buildTypeIndex(concepts: Concept[]): Record<string, TypeReferenceTarget>
Collect the first visible occurrence of each documented type name so inline type mentions can navigate to the matching type entry.