Skip to content

How Facet writes

Views and agents change files through the same set of edits. Each edit touches only the lines it must, keeps the file’s line breaks, and is refused with a reason when the result would not read back as intended. So a change made in a view looks like a change a careful person would make by hand, and the git diff stays small.

For example, setting owner to @jun on the task below adds one inline property and changes nothing else:

- [ ] Order docks [due:: 2027-03-01]
- [ ] Order docks [due:: 2027-03-01] [owner:: @jun]
  • Changing a property rewrites its value where it is. If the new value is too long to stay inline (see below), the property moves below the item.
  • A new property goes:
    1. below the item, if the item already has a property block;
    2. else inline at the end of the title line, while the line has fewer than 3 inline properties and the value is short (at most 30 characters, no square brackets);
    3. else on a new line right below the title, indented to the item’s text.
  • On a heading, a new block line goes right below the heading.
  • needs on a requirement is always written Needs:, below.
  • Setting a key that appears twice keeps the first and removes the others. Removing a key removes every occurrence.
  • Values are checked the way lint checks them: an invalid date, duration or other value is refused. A value must be one line without surrounding spaces.
  • A file without a # heading cannot hold properties, so setting one there is refused.
  • Setting a state rewrites the checkbox character. A plain item gets a checkbox and becomes a task.
  • Headings and requirements have no checkbox; setting their state is refused.

Ticking a repeating task keeps it [ ], writes last:: <today> and moves its due::, if it has one:

  • a when done rule: to today plus the interval;
  • a schedule-based rule: to its first occurrence after today or after the old due date, whichever is later.
- [ ] Pay the electricity bill [repeat:: every month on the 1st]
due:: 2027-04-01

Ticked on 2 April 2027, this becomes:

- [ ] Pay the electricity bill [repeat:: every month on the 1st]
due:: 2027-05-01
last:: 2027-04-02
  • A rule that has ended (UNTIL passed, or COUNT used up) is ticked [x] instead.
  • Ticking a COUNT rule that has no start:: also writes start:: (the old due date), so the count keeps its first occurrence.
  • Rules follow RFC 5545: a monthly rule on the 31st skips months without one. Write every month when done, or FREQ=MONTHLY;BYMONTHDAY=-1 for the last day of each month.

Renaming replaces the title only: the checkbox, the req~name: prefix and the properties stay. A file without a # heading gets one, after the frontmatter. A title that would read back differently (it starts with a checkbox, or ends with [key:: value]) is refused.

Writing a description replaces the node’s paragraphs, quotes, tables and code blocks, from the first to the last.

  • On a file with a # title, only the blocks below the title are replaced; blocks above it (a lint header, an introduction) stay.
  • A file without a # heading gets its description at the top, after the frontmatter.
  • A new description goes after the property block (or the title) after a blank line, with a blank line before what follows.
  • An item’s description is indented to the item’s text.
  • Removing a description deletes its blocks and the blank lines before them.

A description is refused when it contains a list item, a heading or a key:: value line (outside code blocks), and on a requirement when it contains a Needs: line. A description that starts on the item’s own line, or that has some of the node’s children between its blocks, is not rewritten.

  • A new item gets its properties inline when there are at most 3 short ones, otherwise all of them below the title.
  • A new heading’s properties always go below it.
  • Where a node goes, and the way it is indented, follow the rules for moves below.

A node moves with its properties, description and children; deleting a node removes everything below it too.

  • An item stays an item. Under another item it is indented to that item’s text; under a heading or a file it starts at column 0. It takes the marker of the list it joins.
  • A heading stays a heading. Under a file it becomes ##, under a heading one level deeper, and its sub-headings shift with it. A level past 6 is refused.
  • A setext heading (Title over ---) that moves is rewritten with #.
  • A heading cannot go under an item, and among a parent’s children items come before sub-headings.
  • Moving across files keeps links valid, since !id references work from any file.
  • Files and folders are never created, moved or deleted by edits.

Computed dates are never written back. Dragging a bar in the Gantt, in whole days, writes fixed dates in the form the node already uses:

  • Moving a bar shifts its written start:: and end::, or adds start:: when neither is written. An after:: stays, but no longer drives the start.
  • Dragging the end rewrites end::; else duration:: (N days, or N weeks when whole weeks); else adds end::.
  • Dragging the start keeps the end. When the start comes from end:: minus duration::, it rewrites duration::. Otherwise it rewrites or adds start::, then rewrites duration:: if there is no end::, or adds end:: when neither is written.
  • Roll-up bars, repeating tasks and milestones placed by due:: alone cannot be dragged. Other milestones can only be moved.

How each view turns a gesture into one of these edits (adding from the board, ticking in Today, dragging in the mindmap) is described with the views, for example the Board and Today. Agents use the same edits through facet edit.