Skip to content
chaba-devPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

rfdtool

rfdtool checks, links, starts, and reports on a project's Requests for Discussion (RFDs) written in AsciiDoc. Run rfdtool check in CI to keep every RFD's layout, metadata, lifecycle, and links valid, and the other commands while writing.

rfdtool status            # each RFD's state and implementation progress
rfdtool check             # validate every RFD; exits 1 on problems
rfdtool link              # link every unlinked mention of another RFD
rfdtool new "Title"       # start the next RFD from the template

Installing

go install github.com/chaba-dev/rfdtool@latest

To pin the version a repository uses, add it as a Go tool and run it with go tool rfdtool:

go get -tool github.com/chaba-dev/rfdtool@latest

With Nix

Run it once with nix run github:chaba-dev/rfdtool -- check, or install it with nix profile install github:chaba-dev/rfdtool.

In an RFD repository with a flake, add rfdtool as an input and put the binary in the dev shell, so rfdtool is on the path there and in CI's nix develop --command. flake.lock pins the version; nix flake update rfdtool moves it to the latest commit.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    rfdtool = {
      url = "github:chaba-dev/rfdtool";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    { nixpkgs, flake-utils, rfdtool, ... }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        devShells.default = pkgs.mkShell {
          packages = [
            rfdtool.packages.${system}.default
            pkgs.git # for rfdtool check --base-ref, and authors in rfdtool new
          ];
        };
      }
    );
}

A flake that builds its own nixpkgs can add rfdtool.overlays.default to its overlays and use pkgs.rfdtool instead. Either way the package needs Go 1.26 (go_1_26) from that nixpkgs. It builds on Linux and Apple Silicon macOS; current nixpkgs no longer supports Intel Macs.

rfdtool --version prints the commit a Nix build came from, or the module version for go install.

To start a project, create the RFD directory and the first RFD:

mkdir rfd
rfdtool new --labels core "First RFD"

Configuring a project

rfdtool reads rfd.toml from the directory it runs in. Every setting is optional:

# Directory of the RFDs, one NNNN directory each. Default: "rfd".
dir = "rfd"

# Template directory with README.adoc and IMPLEMENTATION.adoc that
# rfdtool new starts an RFD from. Default: the built-in template.
template = "template"

# Labels rfdtool new gives an RFD, starting with its project. rfdtool new
# requires labels, from here or from --labels.
labels = "core"

# Projects whose RFDs are private by default and must never be public.
private_projects = ["internal"]

dir and template set in the file are relative to the file; given as flags or environment variables, they are relative to the working directory. Flags override environment variables, which override the file: --config or RFD_CONFIG, --dir or RFD_DIR, --private-projects or RFD_PRIVATE_PROJECTS, and new --template and new --labels. An unknown setting is an error.

The RFD format

Each RFD is a directory NNNN/ with a four-digit number:

  • README.adoc: the RFD. It starts with AsciiDoc attributes and then one title, = RFD N Title, whose number matches the directory. There is no front matter.

    :authors: Ada Lovelace <ada@example.com>
    :state: discussion
    :discussion: https://github.com/example/rfd/pull/12
    :labels: core, storage
    :visibility: public
    
    = RFD 12 Storage layout

    authors, state, discussion, and labels each appear exactly once; discussion may be empty until the state needs it. authors needs a name and an address in angle brackets. labels starts with the RFD's project. visibility is optional: public, or private for RFDs only signed-in readers should see. RFDs of a private project default to private and cannot be made public. Visibility is metadata that rfdtool check enforces and a site can read; rfdtool itself does not publish or hide anything.

    Section ids are Asciidoctor's defaults, so == Goal and scope is <<_goal_and_scope>>. Render RFDs without changing idprefix or idseparator, or links that rfdtool check accepts will break.

  • IMPLEMENTATION.adoc (or .md or .org): the implementation checklist. Its first line is = RFD NNNN implementation checklist (# in Markdown, #+TITLE: in Org), it links back to README.adoc, the README links to it, and its tasks are * [ ] and * [x] items. Checkboxes belong here, not in the README.

state follows the lifecycle

prediscussion ⇄ ideation → discussion → published → committed
                                                  ↘ abandoned

where an RFD may skip ahead but not move back, except between prediscussion and ideation, and any open state may be abandoned. discussion, published, and committed need a discussion URL, and committed needs a non-empty checklist with every task checked.

rfdtool check --base-ref REV (or RFD_BASE_REF) also compares the RFDs with a git revision, as CI should: states may only move forward, RFDs are never deleted, and committed or abandoned RFDs are final. Relabeling, publishing, linking mentions, rewrapping, and moving the checklist between formats are still allowed on a final RFD. --base-dir compares with another directory instead.

Links between RFDs

Every mention of another RFD links to it with an AsciiDoc cross reference. GitHub renders it as a link to the source, and Asciidoctor as a link to README.html, which a site can rewrite into its own pages:

See xref:../0005/README.adoc[RFD 5], and RFDs xref:../0013/README.adoc[13]
and xref:../0014/README.adoc[14]. xref:../0005/README.adoc#_goal[Its goal]
links to a section.

rfdtool check rejects unlinked mentions, links to RFDs or sections that do not exist, links from a public RFD to a private one, and link: macros to other RFDs, in README.adoc and IMPLEMENTATION.adoc. rfdtool link adds the missing links. Replacing link: macros with cross references is allowed on a final RFD. Links in Markdown and Org checklists are not checked.

Developing

The flake's dev shell has Go, gopls, gotools, golangci-lint, and delve. With direnv, run direnv allow once; otherwise enter it with nix develop. Then:

go test ./...
nix flake check   # builds the package and runs its tests, as CI does

When go.mod or go.sum change, update vendorHash in flake.nix: set it to pkgs.lib.fakeHash, run nix build, and copy the hash it reports.

Output

status and check color their output on a terminal. NO_COLOR turns color off and FORCE_COLOR turns it on.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages