Implementation:0xranx OpenContext Idea Utils
| Knowledge Sources | |
|---|---|
| Domains | Idea_Journaling, Markdown_Parsing |
| Last Updated | 2026-10-24 00:00 GMT |
Overview
Utility functions for the idea journaling module, providing entry marker parsing/serialization, thread document parsing, date formatting, file path generation, and date-grouped entry retrieval.
Description
The ideaUtils.js module in src/ui/src/utils/ implements the core data layer for idea threads. It parses hidden HTML comment markers ([//]: # (idea:id=... created_at=... is_ai=...)) to delimit entries within a single markdown thread document. Key functions: parseThreadDocument extracts all entries from markdown content, serializeThreadDocument converts entries back to markdown, generateThreadPath creates dated file paths, groupThreadsByDate and getDayEntries organize entries by date for timeline display, and getAllEntriesGroupedByDate produces the full timeline structure.
Usage
Import these functions in IdeaService, useIdeaLoader, and IdeaTimeline for parsing, formatting, and displaying idea entries.
Code Reference
Source Location
- Repository: 0xranx_OpenContext
- File: src/ui/src/utils/ideaUtils.js
- Lines: 1-307
Signature
export const IDEAS_ROOT = '.ideas'
export function generateEntryId() // → string (UUID v4)
export function createEntryMarker(id, createdAt, isAI) // → string
export function parseEntryMarker(line) // → {id, createdAt, isAI} | null
export function parseThreadDocument(content) // → Array<Entry>
export function serializeThreadDocument(entries) // → string
export function generateThreadPath(title, date) // → string path
export function extractDateFromPath(relPath) // → "YYYY-MM-DD" | null
export function groupThreadsByDate(threads) // → Map<dateKey, threads>
export function getDayEntries(threads, dateKey) // → Array<Entry>
export function getAllEntriesGroupedByDate(threads) // → Array<{dateKey, entries}>
Import
import { parseThreadDocument, serializeThreadDocument, IDEAS_ROOT } from './utils/ideaUtils';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| content | string | Yes (parse) | Markdown thread document content |
| entries | Array | Yes (serialize) | Array of entry objects |
| threads | Array | Yes (group) | Array of {rel_path, entries, title} |
| dateKey | string | Yes (getDay) | "YYYY-MM-DD" date key |
Outputs
| Name | Type | Description |
|---|---|---|
| Entry | object | { id, createdAt, text, isAI, threadId?, threadTitle?, type?, isFirstInThread?, isLastInThread? } |
| groupThreadsByDate | Map | dateKey → Array of threads, sorted desc |
Usage Examples
Parsing a Thread Document
import { parseThreadDocument, serializeThreadDocument } from './utils/ideaUtils';
const content = `[//]: # (idea:id=abc-123 created_at=2026-10-24T10:00:00Z)
My first idea
[//]: # (idea:id=def-456 created_at=2026-10-24T11:00:00Z is_ai=true)
AI reflection`;
const entries = parseThreadDocument(content);
// [{ id: 'abc-123', createdAt: '2026-10-24T10:00:00Z', text: 'My first idea', isAI: false }, ...]
const back = serializeThreadDocument(entries);
Building Timeline
import { getAllEntriesGroupedByDate } from './utils/ideaUtils';
const timeline = getAllEntriesGroupedByDate(threads);
// [{ dateKey: '2026-10-24', entries: [...] }, { dateKey: '2026-10-23', entries: [...] }]