Skip to content

Inspecting and repairing nodes

Besides new, mv, and rm, okfctl has four node commands: two that show what a bundle holds and two that repair a node. node list prints every node in a bundle with its type, and node show prints one node’s type and body. node refresh sets a stale modified date to the day git last committed the file. node promote moves a note written as a folder’s index.md, where OKF tools can’t see it, to a file of its own. The first two only read. The last two rewrite files, and each has a --dry-run flag that lists the changes and writes nothing.

Run everything below in an empty directory. If bundles and nodes are new to you, read Concepts first.

Make a bundle with two notes and a README:

$ okfctl bundle init cellar
Initialized OKF bundle in cellar
$ okfctl node new wine/tannin --type Concept --title Tannin --bundle cellar
Created cellar/wine/tannin.md
$ okfctl node new grape/sangiovese --type "Grape Variety" --title Sangiovese --bundle cellar
Created cellar/grape/sangiovese.md
$ printf 'Notes for whoever edits this bundle.\n' > cellar/README.md
$ okfctl node list --bundle cellar
grape/sangiovese.md Grape Variety
wine/tannin.md Concept

You get one line per node, sorted by path, with the type in the second column. The README isn’t listed, and neither are the index.md and log.md files bundle init and node new wrote. The OKF spec decides that. Its “Concepts, assets, and other files” section says a Markdown file counts only when its header has a non-empty type. index.md and log.md are reserved names that never count, whatever they hold. Files and folders whose names start with a dot aren’t part of the bundle at all. node list prints the set the spec defines, the quickest way to see what another OKF tool will find in your bundle.

The type column is plain text. Filter it with grep:

$ okfctl node list --bundle cellar | grep 'Grape Variety'
grape/sangiovese.md Grape Variety

--bundle defaults to the current directory. An empty bundle prints nothing and exits 0.

Add a sentence to tannin, then print it:

$ printf '\nThe drying grip in red wine.\n' >> cellar/wine/tannin.md
$ okfctl node show wine/tannin --bundle cellar
path: wine/tannin.md
type: Concept
# Tannin
The drying grip in red wine.

show prints the path, the type, and the body. The rest of the header (title, timestamps, sources) stays out of the way. When you want it, cat the file. You can leave .md off the path.

The reserved files and the README aren’t nodes, and show won’t print them:

$ okfctl node show index --bundle cellar
okfctl: node not found: index.md
$ okfctl node show README --bundle cellar
okfctl: node not found: README.md

Fix stale modified dates with node refresh

Section titled “Fix stale modified dates with node refresh”

node new writes created and modified timestamps into every header. Both keys are okfctl’s. The OKF spec has no modified field (it uses generated.at for the last change of substance), and it lets any tool add keys of its own as long as other tools carry them through. okfctl uses modified for one check: do the header and git agree on when this file last changed? When they don’t, validate warns, and node refresh fixes the header.

Put the bundle in git with a commit made today. Then write a note by hand with a modified date of March 2, and commit it on April 10. cat shows the file as it stands, and validate names the note and both dates:

$ git -C cellar init -q
$ git -C cellar add -A
$ git -C cellar commit -q -m "Start the cellar"
$ printf -- '---\ntype: Concept\ntitle: Acidity\ncreated: 2026-03-02\nmodified: 2026-03-02\ntags: [taste] # how it feels on the tongue\n---\n\n# Acidity\n\nWhy a wine tastes fresh.\n' > cellar/wine/acidity.md
$ git -C cellar add -A
$ GIT_COMMITTER_DATE=2026-04-10T12:00:00Z git -C cellar commit -q --date=2026-04-10T12:00:00Z -m "Add acidity"
$ cat cellar/wine/acidity.md
---
type: Concept
title: Acidity
created: 2026-03-02
modified: 2026-03-02
tags: [taste] # how it feels on the tongue
---
# Acidity
Why a wine tastes fresh.
$ okfctl validate cellar
warning README.md: not a concept (no frontmatter); skipped, does not affect conformance (OKF spec, "Concepts, assets, and other files")
warning wine/acidity.md: modified 2026-03-02 disagrees with git last-commit 2026-04-10; run `okfctl node refresh` to fix it (or `okfctl node edit` per node)
1 drift warning(s)

The other two notes, tannin and Sangiovese, don’t drift. Both got today’s modified from node new and went into today’s commit. --dry-run shows what refresh would write:

$ okfctl node refresh --dry-run cellar
would refresh wine/acidity.md: 2026-03-02 -> 2026-04-10
1 node(s) would be refreshed (dry run; nothing written)

Run it and look at the file after:

$ okfctl node refresh cellar
refreshed wine/acidity.md: 2026-03-02 -> 2026-04-10
1 node(s) refreshed
$ cat cellar/wine/acidity.md
---
type: Concept
title: Acidity
created: 2026-03-02
modified: 2026-04-10T00:00:00Z
tags: [taste] # how it feels on the tongue
---
# Acidity
Why a wine tastes fresh.
$ head -n 4 cellar/log.md
# Change Log
## <DATE>
* refreshed wine/acidity.md

One line changed. modified holds the commit day now, written as midnight UTC. created, the comment on tags, and the body match the old file byte for byte. refresh also added a line to log.md (dated the day you ran it) and rebuilt index.md at the end. Name a path after the bundle to fix just that note: okfctl node refresh cellar wine/acidity.

Outside a git repository there’s no history to compare with. Nothing drifts, and refresh prints No drift and exits 0.

Commit the refresh without starting the drift again

Section titled “Commit the refresh without starting the drift again”

You’ll commit the refresh like any other edit. Do that on a later day and the note’s last commit is now the refresh. Its header looks stale again:

$ git -C cellar add -A
$ GIT_COMMITTER_DATE=2026-05-01T12:00:00Z git -C cellar commit -q --date=2026-05-01T12:00:00Z -m "Refresh modified dates"
$ okfctl validate cellar
warning README.md: not a concept (no frontmatter); skipped, does not affect conformance (OKF spec, "Concepts, assets, and other files")
warning wine/acidity.md: modified 2026-04-10 disagrees with git last-commit 2026-05-01; run `okfctl node refresh` to fix it (or `okfctl node edit` per node)
1 drift warning(s)

Running refresh again would stamp May 1 on acidity. Its text didn’t change that day. List the refresh commit in .okf-drift-ignore-revs at the top of the bundle. The drift check skips any commit on that list and compares against the commit under it:

$ git -C cellar rev-parse HEAD >> cellar/.okf-drift-ignore-revs
$ okfctl validate cellar
warning README.md: not a concept (no frontmatter); skipped, does not affect conformance (OKF spec, "Concepts, assets, and other files")
OK: bundle conforms to the OKF spec floor

Big mechanical commits (reformats, migrations) belong in the same file. Leave one off and a single refresh would flatten every note it touched to one day. refresh won’t run when one commit accounts for half or more of 10 or more planned changes. It prints that commit’s SHA and the line to add, and --yes overrides the refusal. The index and freshness guide walks through that case.

Turn a folder’s index.md into a node with node promote

Section titled “Turn a folder’s index.md into a node with node promote”

A Hugo page bundle puts a page’s text in its folder’s index.md. Import notes from a Hugo site and they land in index.md files too. The spec forbids that twice. Subdirectory index.md files have no frontmatter, and a reader never counts any index.md as a concept, whatever header it carries. OKF tools skip the note (okfctl too), and validate fails the bundle. Swap the Sangiovese note for one written that way, and add a Chianti note that links to it with both spellings of a folder link:

$ okfctl node rm grape/sangiovese --bundle cellar
Removed grape/sangiovese.md
$ printf -- '---\ntype: Grape Variety\ntitle: Sangiovese\ndescription: The red grape of Tuscany.\n---\n\n# Sangiovese\n\nThin skins and high acid.\n' > cellar/grape/index.md
$ printf -- '---\ntype: Concept\ntitle: Chianti\n---\n\n# Chianti\n\nMostly [Sangiovese](../grape/), so read up on [its skins](../grape/index.md#skins).\n' > cellar/wine/chianti.md
$ okfctl node list --bundle cellar
wine/acidity.md Concept
wine/chianti.md Concept
wine/tannin.md Concept
$ okfctl validate cellar
FAIL grape/index.md: index files contain no frontmatter; only the bundle-root index may carry frontmatter (OKF spec, "Index files")
warning README.md: not a concept (no frontmatter); skipped, does not affect conformance (OKF spec, "Concepts, assets, and other files")
okfctl: 1 conformance finding(s)

node list skips Sangiovese because index.md is a reserved name, and no file called that counts as a node, header or not. The spec names the problem but offers no fix, and node promote is okfctl’s. It moves the note to a file named after its folder, grape/grape.md, and rewrites every link to the folder. ls shows the folder today, then --dry-run previews the change:

$ ls cellar/grape
index.md
$ okfctl node promote --dry-run cellar
would promote grape/index.md -> grape/grape.md
rewrite wine/chianti.md: ../grape/ -> ../grape/grape.md
rewrite wine/chianti.md: ../grape/index.md#skins -> ../grape/grape.md#skins
1 index(es) would be promoted (dry run; nothing written)

Apply it and look at the folder and the note after:

$ okfctl node promote cellar
promoted grape/index.md -> grape/grape.md (2 inbound link(s) rewritten)
1 index(es) promoted
$ ls cellar/grape
grape.md
index.md
$ cat cellar/grape/grape.md
---
type: Grape Variety
title: Sangiovese
description: The red grape of Tuscany.
---
# Sangiovese
Thin skins and high acid.
$ cat cellar/grape/index.md
# Grape
## Concepts
* [Sangiovese](grape.md) - The red grape of Tuscany.
$ tail -n 1 cellar/wine/chianti.md
Mostly [Sangiovese](../grape/grape.md), so read up on [its skins](../grape/grape.md#skins).
$ okfctl node list --bundle cellar
grape/grape.md Grape Variety
wine/acidity.md Concept
wine/chianti.md Concept
wine/tannin.md Concept
$ okfctl node promote cellar
No directory-as-concept indexes to promote.

The note moved whole, header and body, and both link spellings now point at the new file with the #skins anchor intact. What’s left in grape/index.md is the plain generated listing the spec expects, and log.md got a promoted line. Run promote again and it finds nothing to do. The bundle-root index.md never gets promoted. The spec lets that one file carry bundle metadata in its header.

To name every promoted file something other than its folder, pass --name. okfctl node promote --name overview cellar would have written grape/overview.md. The one name applies to every folder in the run.

promote stops with nothing written if a target name is taken. With a vine/vine.md in place, the vine/index.md note can’t move there:

$ mkdir cellar/vine
$ printf -- '---\ntype: Concept\ntitle: Vine\n---\n\n# Vine\n' > cellar/vine/index.md
$ printf -- '---\ntype: Concept\ntitle: Vine care\n---\n\n# Vine care\n' > cellar/vine/vine.md
$ okfctl node promote cellar
okfctl: cannot promote vine/index.md: destination vine/vine.md already exists as a node
$ ls cellar/vine
index.md
vine.md

Rename the existing file with node mv or rerun with --name, then promote. Leave it unpromoted and you get a warning about vine/index.md from index build and from every node command that rebuilds the index. okfctl never overwrites an index.md it didn’t write. index build --overwrite-hand-written does, and that deletes the Vine note.

refresh trusts the commit date git recorded. If the laptop that made the commit had its clock set a week off, modified lands a week off too, and okfctl has no way to notice.

show doesn’t print the header, and list doesn’t print titles. Neither one ever writes a file.

Made by Casey West.