Skip to main content

org-workspace

CI PyPI

Python library that makes org-mode files first-class citizens for AI agent workflows.

If you need to read and write org-mode task lists from Python — create tasks, transition states, query deadlines, or coordinate multiple agents over a shared org file — org-workspace is the library for it.

Built on a vendored fork of orgparse with write support (PR #77), it adds:

  • Multi-file workspace management — load a directory, track dirty files, save only what changed
  • Safe serialization — round-trip invariant: unmodified nodes are byte-identical on save
  • GTD query layer — agenda(), deadlines(), overdue(), next_action(), ai_tasks()
  • Concurrency primitives — TaskClaim (atomic claiming), OptimisticLock, FileLock
  • Dependency DAG — parse DEPENDS_ON properties, topological sort, ready_tasks()

Install

pip install org-workspace

Quick start

from pathlib import Path
from org_workspace import OrgWorkspace, Query

# Load workspace
ws = OrgWorkspace(roots=[Path.home() / "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.home() / "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()

Documentation

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, body
  • refile() — move nodes between files preserving subtree
  • remove_node() — delete nodes from files
  • transition() — state changes with LOGBOOK entries
  • set_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 execution
  • next_action() — GTD next action selection

Dependency DAG (Plan)

  • Parse DEPENDS_ON properties into dependency graphs
  • Topological sort for execution ordering
  • ready_tasks(), blocked_tasks(), cycle detection

Concurrency

  • FileLock — file-level locking
  • OptimisticLock — hash-based conflict detection
  • TaskClaim — agent-level task claiming with staleness timeout
  • multi_lock() — deadlock-free multi-file locking (lexicographic order)

LOGBOOK and session logging

  • add_logbook_entry(), add_state_change_entry(), add_clock_entry()
  • SessionLog for buffered per-session logging

Archive

  • archive_node() — archive with hierarchy preservation
  • archive_done() — bulk archive completed tasks
  • archive_plan() — archive entire dependency plans

Context extraction (for AI agents)

  • build_execution_context() — structured context from task properties
  • get_prompt() — PROMPT property with body fallback
  • get_role() — agent persona from ROLE property

GTD state configuration

from org_workspace import StateConfig

# Default: the DIP-0009 v2.0 vocabulary
config = StateConfig.default()
# #+SEQ_TODO: TODO NEXT WAITING REVIEW | DONE DEFERRED CANCELLED
# terminal: DONE, CANCELLED. DEFERRED is done-class but not terminal (it can wake to TODO).

# StateConfig.nightshift() is a deprecated alias for default(). The v1.1
# execution overlay (QUEUED, WORKING, FAILED) is retired; a reader of a legacy
# file passes its own StateConfig, or relies on that file's #+SEQ_TODO header.

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.

Metadata

Release files for org-workspace 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for org-workspace 0.6.0
File Size Uploaded
org_workspace-0.6.0.tar.gz 86.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for org-workspace 0.6.0
File Interpreter ABI Platform
org_workspace-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 154.4 kB

Release files / org_workspace-0.6.0.tar.gz

Download URL org_workspace-0.6.0.tar.gz
Size 86.3 kB
Tags Source
SHA-256 checksum
How to use checksums
de5aa0d3baca9cb154831b851e7731e6367f8e0f6574c42b500c8ac052266ff0
BLAKE2b-256 checksum
How to use checksums
ecbc604d4542e92c070257c9982cae1132fa81034c4f85da89ca7de3a579cb54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / org_workspace-0.6.0-py3-none-any.whl

Download URL org_workspace-0.6.0-py3-none-any.whl
Size 68.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
446cc59fffeb2bb90844be3f2a82f2672b6fa94f654c268759db5f64f18f2f43
BLAKE2b-256 checksum
How to use checksums
4ac4481dcae834ffe8d5af13947b3174e22bffcc678ba6ad2274adc9cc4c2259
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page