Commit Graph

8 Commits

Author SHA1 Message Date
Levi Neely 84101145d7 Add language plugin registry and Emacs-style #+RESULTS: formatting
Code execution now uses a LanguageRegistry with built-in defaults
(bash, python, ruby, perl, javascript) that can be overridden by TOML
config files in /etc/orkmode/languages or ~/.config/orkmode/languages.

Match Emacs org-babel result formatting: fixed-width (": " prefix) for
output under 10 lines, #+begin_example blocks for 10+ lines
(org-babel-min-lines-for-block-output).

Fix insert_results duplication: the source block span end already points
to the start of the line after #+END_SRC, so searching for the next
newline skipped the existing #+RESULTS: line and prepended duplicates on
re-execution. Also handle replacing existing #+begin_example result blocks.

Fix parser: #+begin_example, comment, and export blocks were misparsed as
SourceBlock with a bogus language, causing "unsupported language" errors
on re-execution. Map them to their correct AST element kinds.
2026-10-01 13:36:38 +02:00
Levi Neely 17f18b044c Add Landlock sandbox for code execution
- sandbox.rs: Landlock filesystem restrictions applied via pre_exec
- Library paths (/lib, /usr/lib) need execute permission for dynamic linker
- 30s timeout with SIGKILL on expiry
- Network access allowed (Landlock only restricts filesystem)
- Minimal env: PATH, HOME=/tmp, LANG, TERM
2026-10-01 11:38:43 +02:00
Levi Neely 33173bcc29 Remove dead orkmode-core (FFI) crate
Dropping the C FFI layer left orkmode-core unused: nothing in the
workspace depends on it, and the GUI will speak 9P instead. Delete the
crate, drop it from the workspace, and scrub FFI references from the
docs (README structure/usage, AGENTS structure/FFI/next-steps).
2026-09-30 22:27:50 +02:00
Levi Neely 32e4fd0007 Make ork a pure 9P client with friendly commands
ork now operates solely as a 9P client against ork-server; all org
intelligence lives in the server. Remove the local file-parsing command
layer (commands.rs) and its org-ast/org-parser/orkmode-core/serde deps.

Base verbs speak raw 9P: ls, read, write, rdwr. Address resolves from
--addr, then $ORK_ADDR, then tcp://localhost:5640.

Add friendly commands, all thin compositions of the base 9P operations:
docs, sections, todos, agenda, get, set, add (--parent), mkdoc, reload.

Fix the directory-listing parser in client.rs: the stat-entry name offset
double-counted the size field (pos + 2 + 41 instead of pos + 41), so ls
returned nothing. Handle a downstream reader closing early (e.g. | head)
by treating BrokenPipe as a clean exit instead of panicking.
2026-09-30 21:29:09 +02:00
Levi Neely 9e2fcb9010 Add 9P2000 server implementation
- p9.rs: Full 9P2000 protocol handler
  - Tversion/Tattach/Twalk/Topen/Tread/Twrite/Tclunk/Tstat
  - Directory listing with stat encoding
  - File read/write with buffering
  - Rdwr support for command files

- ork-server binary:
  - TCP or Unix socket listener
  - Threaded connection handling
  - Usage: ork-server -a unix:///tmp/ork.sock ~/org

Tested with plan9port 9p client - read/write/ls all working.
2026-09-30 15:09:59 +02:00
Levi Neely 6bb2994dff Add section creation with UUID IDs
- new file at root: create org file
- new file at doc level: create top-level section
- new file at section level: create child section
- All created sections get UUID in :ID: property
- body file added to doc (alias for raw)
- Test for section creation via 9P namespace
2026-09-30 10:41:19 +02:00
Levi Neely 246bd9bb5a Add ork-server crate with virtfs EDSL
- virtfs: Declarative filesystem EDSL (port of ollie's pattern)
  - dir(), file(), each(), dir_dynamic() constructors
  - read(), write(), rdwr(), rw() handlers
  - FsNode with walk(), list(), read(), write()

- state: OrkState manages parsed documents
  - Scans org directory, parses on load
  - Section ID from CUSTOM_ID > ID > slugified title
  - Read/write document content

- namespace: 9P namespace builder
  - ctl, idx, keywords at root
  - agenda/todos, agenda/today, agenda/week
  - {doc}/ with raw, meta, and sections
  - {section}/ with headline, title, keyword, priority, tags
  - Nested children for subsections
2026-09-30 10:31:11 +02:00
Levi Neely 14fc3233e9 Initial commit: org-mode parser and CLI
- org-ast: AST types for org documents
- org-parser: tree-sitter based parser
- orkmode-core: library + C FFI
- ork-cli: directory-aware CLI tool

CLI operates on directories by default, supports -R for recursive.
2026-09-30 09:43:21 +02:00