Files
memex/notes/org-skill-org-json-bridge.org

55 lines
1.9 KiB
Org Mode

#+TITLE: SKILL: Org-JSON Bridge (Universal Literate Note)
#+ID: skill-org-json-bridge
#+STARTUP: content
#+FILETAGS: :org-mode:json:manipulation:psf:
* Overview
The **Org-JSON Bridge** enables programmatic manipulation of Org-mode files by converting them into a structured JSON representation and vice-versa. This bypasses the fragility of direct string manipulation for complex structures like tables, properties, and source blocks.
* Phase A: Demand (PRD)
:PROPERTIES:
:STATUS: FROZEN
:END:
** 1. Purpose
Define the interfaces for bidirectional Org-to-JSON conversion.
** 2. User Needs
- **Robust Parsing:** Convert Org-mode files into structured JSON AST.
- **High-Fidelity Rendering:** Re-materialize JSON AST back into syntactically correct Org-mode text.
- **Complex Structure Support:** Handle tables, property drawers, and source blocks without data loss.
- **Programmatic API:** Provide a CLI and Lisp interface for other skills to use.
** 3. Success Criteria
*** TODO Parse Org-mode to JSON AST without loss of hierarchy
*** TODO Render JSON AST back to Org-mode text matching original format
*** TODO Table row injection via JSON manipulation verification
* Phase B: Blueprint (PROTOCOL)
:PROPERTIES:
:STATUS: SIGNED
:END:
** 1. Architectural Intent
The bridge acts as a translator between the human-readable Org AST and the machine-manipulable JSON format.
** 2. Semantic Interfaces
#+begin_src bash
(defun org-bridge-parse (file-path)
"Executes the Python parser to output JSON AST.")
(defun org-bridge-render (json-path output-path)
"Executes the Python renderer to re-create Org text.")
#+end_src
* Phase D: Build (Implementation)
Implementation logic is in `projects/org-json-bridge/org_bridge.py`.
** Python Parser Wrapper
#+begin_src python
;; Logic for calling the python bridge
#+end_src
* Phase E: Chaos (Verification)
Verification involves round-trip testing: Org -> JSON -> Org must result in a file identical to the source.