| Crates.io | tree-sitter-actions |
| lib.rs | tree-sitter-actions |
| version | 0.9.1 |
| created_at | 2025-03-04 06:04:37.341729+00 |
| updated_at | 2026-01-01 21:05:34.234363+00 |
| description | parser for the actions file as defined by the specification therein |
| homepage | |
| repository | https://github.com/clearheadtodo-devs/tree-sitter-actions |
| max_upload_size | |
| id | 1576800 |
| size | 318,620 |
===============================
A simple Tree Sitter parser for the custom .actions file format.
tree-sitter generate
tree-sitter parse examples/with_priority.actions
.actions files!npm run generate:schema # Regenerate schema from patterns
For detailed usage examples (Rust library, editors, JSON validation), see docs/usage.md.
This is a simple parser for the custom .actions File Format to be used in whatever form may be needed.
Actions can be thought of as planned, intended actions to be taken on by an agent.
This could be seen as a set of Intended Actions from a CIO ontology standpoint, but the usecases can vary these are just what we have in mind upon writing.
My purpose in creating this parser is to create the intention management file format that the world deserved. Slightly more complex than todo.txt, but not by much, while still being a plaintext format that can be used in whatever format may work for you.
In particular, the values are (you can also read this in the file specification linked above):
> with a recurrence for how many levels deep you arelabels vs syntax tree formats[ ] Take out trash @2025-01-21T19:00 R:FREQ=WEEKLY;BYDAY=TU #01950000-0000-7000-8000-000000000001
[x] Team meeting $ Discuss Q1 roadmap !1 *Projects +Work @2025-01-20T14:00 D60 %2025-01-20T15:05
[ ] Parent task >[ ] Child task >>[ ] Grandchild task
Key features:
[ ] not started, [x] completed, [-] in-progress, [=] blocked, [_] cancelled$ description, ! priority, * story/project, + contexts (tags)@ do-date/time, D duration (minutes), R: recurrence (RFC 5545 RRULE)% completed date, # UUID> child actions (up to 5 levels deep)See docs/action_specification.md for complete syntax reference.
This is to serve as a simple file format that can be used in several contexts:
.actions files! things like syntax highlighting, indentation, and folding should "just work" (knock on wood).actions format is a key usecase.actions data
tree-sitter-actions/schema) and Rust crate (ACTIONS_SCHEMA constant)tree-sitter-actions/schema/sql) and Rust crate (ACTIONS_SQL_SCHEMA constant)Once you've parsed .actions files, you'll need to query and filter the data. This project provides three complementary approaches depending on your needs:
Best for: Editor features, simple filtering, syntax-level tasks
Tree-sitter queries work directly on the AST without conversion. Great for:
# Find all priority 1 actions
tree-sitter query queries/actions/p1-actions.scm examples/with_priority.actions
# Find all completed actions
tree-sitter query queries/actions/completed-actions.scm examples/*.actions
Example queries provided:
completed-actions.scm, not-started.scm, in-progress.scm, blocked-actions.scmp1-actions.scmwith-children.scm, with_specific_story.scmSee queries/actions/ for all available queries and usage examples.
Best for: Ad-hoc queries, Unix pipelines, one-off scripts
After converting .actions to JSON (using the canonical JSON Schema), use jq for powerful filtering and transformations:
# Find P1 actions (assuming you have actions-to-json converter)
actions-to-json tasks.actions | jq -f examples/queries/jq/p1-actions.jq
# Get completion statistics by project
jq -f examples/queries/jq/completion-stats.jq tasks.json
# Filter by context
jq -f examples/queries/jq/by-context.jq --arg ctx "work" tasks.json
Example queries provided:
p1-actions.jq, completed-actions.jq, by-context.jq, by-story.jqcompletion-stats.jq, priority-summary.jqflatten-all.jq, with-children.jqSee examples/queries/jq/ for all examples and usage patterns.
Best for: Applications, persistent storage, complex queries at scale
The canonical SQL schema provides normalized relational storage for applications that need:
-- Find P1 actions in 'work' context due this week
SELECT a.* FROM actions a
JOIN action_contexts c ON a.id = c.action_id
WHERE a.priority = 1
AND c.context = 'work'
AND a.do_datetime >= date('now', 'weekday 0', '-7 days');
-- Completion rate by project
SELECT story,
COUNT(*) as total,
SUM(CASE WHEN state = 'completed' THEN 1 ELSE 0 END) as completed
FROM actions
WHERE story IS NOT NULL
GROUP BY story;
Schema includes:
actions, action_contexts, action_recurrenceSee schema/actions.sql for the complete schema and examples/queries/sql/ for 40+ example queries.
| Use Case | Recommended Approach | Why |
|---|---|---|
| Editor syntax highlighting | Tree-sitter queries | Native, fast, no conversion |
| Quick filter in terminal | Tree-sitter or jq | Minimal overhead |
| One-off data analysis | jq | Powerful, composable, no setup |
| Task management app | SQL | Persistent, indexed, concurrent |
| Complex reports | SQL | Aggregations, joins, performance |
| Pipeline processing | jq | Unix philosophy, composable |
You can use multiple approaches together:
# Parse → JSON → jq filter → SQL import → complex queries
actions-to-json tasks.actions | \
jq '.actions[] | select(.priority == 1)' | \
sqlite3 myapp.db < import-filtered.sql
For complete documentation on querying, see:
queries/actions/README.md - Tree-sitter query patternsexamples/queries/jq/README.md - jq query examplesexamples/queries/sql/README.md - SQL query examplesTests are organized into examples/, test/trees/, and test/corpus/ directories that work together to enable reuse by downstream projects.
Run tests:
npm run test:grammar
Regenerate tests after modifying the grammar or examples:
npm run regen:verify
When working on syntax highlighting and queries for Neovim, use the debugging scripts in scripts/nvim/:
# Check if Neovim can find the queries
nvim --headless examples/minimal.actions +"source scripts/nvim/check_queries.lua" +q
# Test if highlights are capturing correctly
nvim --headless examples/recurring_log_example.actions +"source scripts/nvim/test_highlights.lua" +q
# Check if conceal metadata is being applied
nvim --headless examples/minimal.actions +"source scripts/nvim/check_conceal_metadata.lua" +q
See scripts/nvim/README.md for detailed documentation on debugging Neovim integration issues.
For details on the test architecture, build system, and contributing workflow, see docs/contributing.md.