Python library making org-mode files first-class citizens for AI agent workflows
Project description
org-workspace
Python library that makes org-mode files first-class citizens for AI agent workflows.
Built on a vendored fork of orgparse with write support (PR #77), org-workspace adds multi-file workspace management, structured mutations, concurrency primitives, and query capabilities designed for autonomous AI agents.
Install
pip install org-workspace
Quick start
from pathlib import Path
from org_workspace import OrgWorkspace, Query
# Load workspace
ws = OrgWorkspace(roots=[Path("~/org")])
# Query tasks
q = Query(ws)
next_up = q.next_action()
ai_tasks = q.ai_tasks(states=["TODO"])
deadlines = q.deadlines(days=14)
# Create a task
task = ws.create_node(
file=Path("~/org/inbox.org"),
heading="Research org-mode parsing",
state="TODO",
tags=["AI", "research"],
body="Investigate approaches for org-mode mutation",
)
# Transition state
ws.transition(task, "DONE", agent="my-agent")
# Save changes (only modified files are written)
ws.save()
Features
Workspace management
- Multi-file loading with dirty-file tracking
- Content-addressed ID generation with dedup
- Round-trip safe serialization (zero byte-diff on unchanged files)
NodeView pattern
- Stateless, non-caching read-only views over org nodes
- Generation-counter staleness detection
- Safe for concurrent access patterns
Mutations (via OrgWorkspace)
create_node()— create headings with state, tags, properties, bodyrefile()— move nodes between files preserving subtreeremove_node()— delete nodes from filestransition()— state changes with LOGBOOK entriesset_property(),set_heading(),set_tags()
Query system
agenda(),deadlines(),overdue(),stale()by_state(),by_tag(),by_property()ai_tasks()— find:AI:tagged tasks for agent executionnext_action()— GTD next action selection
Dependency DAG (Plan)
- Parse
DEPENDS_ONproperties into dependency graphs - Topological sort for execution ordering
ready_tasks(),blocked_tasks(), cycle detection
Concurrency
FileLock— file-level lockingOptimisticLock— hash-based conflict detectionTaskClaim— agent-level task claiming with staleness timeoutmulti_lock()— deadlock-free multi-file locking (lexicographic order)
LOGBOOK and session logging
add_logbook_entry(),add_state_change_entry(),add_clock_entry()SessionLogfor buffered per-session logging
Archive
archive_node()— archive with hierarchy preservationarchive_done()— bulk archive completed tasksarchive_plan()— archive entire dependency plans
Context extraction (for AI agents)
build_execution_context()— structured context from task propertiesget_prompt()— PROMPT property with body fallbackget_role()— agent persona from ROLE property
GTD state configuration
from org_workspace import StateConfig
# Default GTD states
config = StateConfig.default()
# sequences: {"gtd": ["TODO", "NEXT", "WAITING", "DONE"]}
# With nightshift (autonomous execution) states
config = StateConfig.nightshift()
# adds: QUEUED, EXECUTING, REVIEW, FAILED
License
BSD 2-Clause. See LICENSE.
This library includes a vendored copy of orgparse (BSD 2-Clause, Copyright 2012 Takafumi Arakaki) with modifications from datacore-one/orgparse PR #77 adding write support.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file org_workspace-0.4.3.tar.gz.
File metadata
- Download URL: org_workspace-0.4.3.tar.gz
- Upload date:
- Size: 75.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e375299d99fa3dd5df37f02c4f6d2ac8aea272a252a5b08e52b394ae154676c1
|
|
| MD5 |
bad7500bd75c888ce8a9e1687f1be9ee
|
|
| BLAKE2b-256 |
109304e84ac7e41abe77b7ff746faace42cd3b30d0398af14d1ad4ec3094f4ba
|
File details
Details for the file org_workspace-0.4.3-py3-none-any.whl.
File metadata
- Download URL: org_workspace-0.4.3-py3-none-any.whl
- Upload date:
- Size: 63.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cf97c8377ebe9cef95787ff362a06b026ba3bc7dd4190b363d3d4efbe0ed2b8
|
|
| MD5 |
75b934e5e851d074d269377c697f5bbe
|
|
| BLAKE2b-256 |
7c7060a438da9cde414fca30c7ba5b296ca724a238e1062b732864fa6ef55001
|