Scaffold the Rust crate and parity harness
Add a Cargo project with frork's tooling (flake dev shell, just
fmt/clippy/coverage/all, clippy config, bin/coverage), where `jeans`
with no arguments prints its command list. Check in the Ruby suite from
alpha-channel 150a86206e57 with JEANS read from the environment, and add
`just parity` to run it against the Rust binary; it fails until the port
lands.

Task: Scaffold the Rust crate and parity harness

  Done looks like: a Cargo project modeled on frork's tooling (flake.nix dev shell, justfile with fmt/clippy/coverage/all, .clippy.toml, bin/coverage, .gitignore) where `cargo build` produces a `jeans` binary that prints its command list with no arguments, and `just all` is green inside `nix develop`. Also a parity harness: the Ruby suite from alpha-channel 150a86206e57 (plugins/jeans/test/jeans_test.rb) checked in, changed only so the JEANS path comes from an env var, plus a just recipe that runs it against the Rust binary. It is expected to fail until the port lands.

Assisted-by: Claude Sonnet 5.5 <noreply@anthropic.com>
change zqnulyquvrwrsrsltsyszpmykkzsyqqt
commit 35a2525a954e124800c3db1bb8ecb2e67a1219a9
author Alpha Chen <alpha@kejadlen.dev>
date
diff --git a/.clippy.toml b/.clippy.toml
new file mode 100644
index 0000000..ff12a93
--- /dev/null
+++ b/.clippy.toml
@@ -0,0 +1,32 @@
+disallowed-methods = [
+    { path = "std::iter::Iterator::for_each", reason = "prefer `for` for side-effects" },
+    { path = "std::iter::Iterator::try_for_each", reason = "prefer `for` for side-effects" },
+    { path = "std::fs::read", reason = "use fs_err::read for better error messages" },
+    { path = "std::fs::read_to_string", reason = "use fs_err::read_to_string" },
+    { path = "std::fs::write", reason = "use fs_err::write" },
+    { path = "std::fs::copy", reason = "use fs_err::copy" },
+    { path = "std::fs::create_dir", reason = "use fs_err::create_dir" },
+    { path = "std::fs::create_dir_all", reason = "use fs_err::create_dir_all" },
+    { path = "std::fs::remove_file", reason = "use fs_err::remove_file" },
+    { path = "std::fs::remove_dir", reason = "use fs_err::remove_dir" },
+    { path = "std::fs::remove_dir_all", reason = "use fs_err::remove_dir_all" },
+    { path = "std::fs::rename", reason = "use fs_err::rename" },
+    { path = "std::fs::metadata", reason = "use fs_err::metadata" },
+    { path = "std::fs::symlink_metadata", reason = "use fs_err::symlink_metadata" },
+    { path = "std::fs::canonicalize", reason = "use fs_err::canonicalize" },
+    { path = "std::fs::hard_link", reason = "use fs_err::hard_link" },
+    { path = "std::fs::read_dir", reason = "use fs_err::read_dir" },
+    { path = "std::fs::read_link", reason = "use fs_err::read_link" },
+    { path = "std::fs::set_permissions", reason = "use fs_err::set_permissions" },
+    { path = "std::string::String::from_utf8_lossy", reason = "lossy at OS boundaries — consider OsStr/Path or stay in &[u8]; if input really is text, suppress with an #[allow] and a comment" },
+]
+
+disallowed-types = [
+    { path = "std::fs::File", reason = "use fs_err::File for better error messages" },
+    { path = "std::fs::OpenOptions", reason = "use fs_err::OpenOptions" },
+    { path = "chrono::DateTime", reason = "use jiff::Zoned or jiff::Timestamp" },
+    { path = "chrono::NaiveDateTime", reason = "use jiff::civil::DateTime" },
+    { path = "chrono::NaiveDate", reason = "use jiff::civil::Date" },
+    { path = "chrono::NaiveTime", reason = "use jiff::civil::Time" },
+    { path = "chrono::Duration", reason = "use jiff::Span or jiff::SignedDuration" },
+]
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1fa7462
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+target/
+/result
+/result-*
+/mutants.out*
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 0000000..5404ecb
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,7 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "jeans"
+version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..b27e7d6
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,18 @@
+[package]
+name = "jeans"
+version = "0.1.0"
+edition = "2024"
+
+[[bin]]
+name = "jeans"
+path = "src/bin/jeans/main.rs"
+
+[dependencies]
+
+[lints.clippy]
+self_named_module_files = "warn"
+unwrap_used = "warn"
+expect_used = "warn"
+panic = "warn"
+indexing_slicing = "warn"
+arithmetic_side_effects = "warn"
diff --git a/bin/coverage b/bin/coverage
new file mode 100755
index 0000000..c1fc918
--- /dev/null
+++ b/bin/coverage
@@ -0,0 +1,79 @@
+#!/usr/bin/env bash
+
+# Measures library line coverage with grcov and fails below the
+# threshold. Uses a separate CARGO_TARGET_DIR so instrumented and
+# normal build artifacts never mix — mixing causes phantom uncovered
+# lines. Override the gate with COVERAGE_THRESHOLD (defaults to 100).
+#
+# See the rust skill's coverage.md and scaffolding.md.
+
+set -euo pipefail
+if [[ "${TRACE-0}" == "1" ]]; then
+    set -o xtrace
+fi
+
+readonly THRESHOLD="${COVERAGE_THRESHOLD:-100}"
+readonly TARGET_DIR="$PWD/target/coverage"
+
+main() {
+    export RUSTFLAGS="-Cinstrument-coverage"
+    export CARGO_TARGET_DIR="$TARGET_DIR"
+    # Absolute: cargo runs test binaries with cwd set to the package root,
+    # so a relative path scatters profraw into each crate's own directory.
+    export LLVM_PROFILE_FILE="$TARGET_DIR/profraw/%p-%m.profraw"
+
+    rm -rf "$TARGET_DIR"
+    cargo test --quiet
+
+    local report
+    # Without --llvm-path, grcov only finds rustup's llvm-tools component.
+    report=$(grcov "$TARGET_DIR/profraw" \
+        ${GRCOV_LLVM_PATH:+--llvm-path "$GRCOV_LLVM_PATH"} \
+        --binary-path "$TARGET_DIR/debug/" \
+        --source-dir . \
+        --output-types covdir \
+        --ignore-not-existing \
+        --keep-only 'src/**' \
+        --ignore 'src/bin/**' \
+        --excl-line 'cov-excl-line|unreachable!|todo!' \
+        --excl-start 'cov-excl-start' \
+        --excl-stop 'cov-excl-stop')
+
+    # Per-file breakdown: walk the covdir tree, printing leaf files only.
+    jq --raw-output '
+        def files:
+            to_entries[] | .value |
+            if .children then .children | files
+            else "\(.name): \(.coveragePercent)% (\(.linesCovered)/\(.linesTotal))"
+            end;
+        .children | files
+    ' <<<"$report"
+
+    # A crate with no coverable library lines yet (fresh scaffold)
+    # reports 0.0% for an empty set; that's a vacuous pass, not a failure.
+    local lines_total
+    lines_total=$(jq '.linesTotal' <<<"$report")
+    # Guard the arithmetic below: [[ -eq ]] evaluates a non-numeric string
+    # as 0, so a missing field would silently skip the gate.
+    if ! [[ "$lines_total" =~ ^[0-9]+$ ]]; then
+        echo "ERROR: expected a numeric linesTotal in the grcov report, got '${lines_total}'" >&2
+        echo "The report may not be covdir format — check grcov's --output-types flag." >&2
+        exit 1
+    fi
+    if [[ "$lines_total" -eq 0 ]]; then
+        echo "ERROR: no coverable lines found; --keep-only likely does not match the source layout" >&2
+        exit 1
+    fi
+
+    local coverage
+    coverage=$(jq '.coveragePercent' <<<"$report")
+    echo ""
+    echo "Total: ${coverage}%"
+
+    if [[ "$(echo "$coverage < $THRESHOLD" | bc -l)" -eq 1 ]]; then
+        echo "ERROR: coverage ${coverage}% is below ${THRESHOLD}%" >&2
+        exit 1
+    fi
+}
+
+main "$@"
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..c1fcda1
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1795085501,
+        "narHash": "sha256-S5keGWzaKpuXo9MNoIC2FfTIuTyTnx8P4NhYJMEsTLI=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "0bb8272318b4ca41bf0edc6224df3e3e3046b70d",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..d67eb87
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,39 @@
+{
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+  outputs = { self, nixpkgs, ... }:
+    let
+      forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-darwin" "x86_64-linux" ];
+    in
+    {
+      devShells = forAllSystems (system:
+        let
+          pkgs = nixpkgs.legacyPackages.${system};
+        in
+        {
+          default = pkgs.mkShell {
+            packages = [
+              pkgs.cargo
+              pkgs.rustc
+              pkgs.clippy
+              pkgs.rustfmt
+              pkgs.rust-analyzer
+              # bin/coverage.
+              pkgs.grcov
+              pkgs.jq
+              pkgs.bc
+              pkgs.just
+              # The parity suite is Ruby (minitest ships with ruby 3.4's bundled gems).
+              pkgs.ruby
+              pkgs.jujutsu
+            ];
+
+            # There is no rustup llvm-tools component here, so bin/coverage
+            # points grcov at the LLVM that rustc was built with.
+            GRCOV_LLVM_PATH = "${pkgs.rustc.llvmPackages.llvm}/bin";
+
+            RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
+          };
+        });
+    };
+}
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..c17a453
--- /dev/null
+++ b/justfile
@@ -0,0 +1,18 @@
+default: all
+
+fmt:
+    cargo fmt --all
+
+clippy:
+    cargo clippy --all-targets -- -D warnings
+
+coverage:
+    ./bin/coverage
+
+# Runs the Ruby suite from the original plugin against the Rust binary.
+# Expected to fail until the port lands.
+parity:
+    cargo build --quiet
+    JEANS="$PWD/target/debug/jeans" ruby test/jeans_test.rb
+
+all: fmt clippy coverage
diff --git a/src/bin/jeans/main.rs b/src/bin/jeans/main.rs
new file mode 100644
index 0000000..f8c5f01
--- /dev/null
+++ b/src/bin/jeans/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+    print!("{}", jeans::USAGE);
+}
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..038a28a
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,57 @@
+#![cfg_attr(
+    test,
+    allow(
+        clippy::unwrap_used,
+        clippy::expect_used,
+        clippy::panic,
+        clippy::indexing_slicing,
+        clippy::arithmetic_side_effects
+    )
+)]
+
+/// The command list `jeans` prints when run with no arguments.
+pub const USAGE: &str = "\
+usage: jeans <command> [args] [--goal NAME] [--color WHEN]
+
+  init TITLE --goal NAME [-m BODY] [--team N] [--home DIR]
+  add TITLE [-m BODY] [--before TASK] [--after TASK]...
+  ready
+  log [VIEW]
+  status
+  tree [TASK] [--depth N]
+  board [TASK]
+  watch [tree|board] [TASK] [--depth N]
+  show TASK
+  describe TASK -m MESSAGE
+  claim TASK
+  done TASK -m MESSAGE
+  release TASK
+  team-size
+";
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn usage_lists_every_command() {
+        for command in [
+            "init",
+            "add",
+            "ready",
+            "log",
+            "status",
+            "tree",
+            "board",
+            "watch",
+            "show",
+            "describe",
+            "claim",
+            "done",
+            "release",
+            "team-size",
+        ] {
+            assert!(USAGE.contains(&format!("  {command}")), "missing {command}");
+        }
+    }
+}
diff --git a/test/jeans_test.rb b/test/jeans_test.rb
new file mode 100644
index 0000000..2911578
--- /dev/null
+++ b/test/jeans_test.rb
@@ -0,0 +1,400 @@
+require "minitest/autorun"
+require "open3"
+require "pathname"
+require "tmpdir"
+
+class JeansTest < Minitest::Test
+  JEANS = Pathname.new(ENV.fetch("JEANS")).expand_path
+  DONE = 'bookmarks(exact:"jeans/thing/done")'
+
+  def setup
+    @tmp = Pathname.new(Dir.mktmpdir)
+    @repo = @tmp / "repo"
+    @repo.mkpath
+    sh("jj", "git", "init", ".")
+    @goal = jeans("init", "ship the thing", "--goal", "thing", "--team", "2", "--home", @tmp / "jeans")
+  end
+
+  def teardown
+    FileUtils.rm_rf(@tmp)
+  end
+
+  def test_goal_alone_is_ready
+    assert_equal [@goal], jeans("ready").lines(chomp: true)
+    assert_equal "2", jeans("team-size")
+  end
+
+  def test_subtasks_block_their_parent
+    a = jeans("add", "A")
+    b = jeans("add", "B")
+
+    assert_equal [b, a].sort, jeans("ready").lines(chomp: true).sort
+    assert_equal [a, b].sort, parents(@goal).sort
+  end
+
+  def test_split_a_task_into_siblings_and_a_dependency
+    a = jeans("add", "A")
+    a1 = jeans("add", "A.1", "--before", a)
+    a2 = jeans("add", "A.2", "--before", a, "--after", a1)
+
+    assert_equal [a2], parents(a)
+    assert_equal [a1], parents(a2)
+    assert_equal [a1], jeans("ready").lines(chomp: true)
+  end
+
+  def test_only_the_claiming_developer_changes_a_claimed_task
+    a = jeans("add", "A")
+    ws = Pathname.new(jeans("claim", a))
+
+    assert_match(/is claimed/, jeans_fails("add", "A.1", "--before", a))
+    assert_match(/is claimed/, jeans_fails("describe", a, "-m", "A, rescoped"))
+
+    a1 = jeans("add", "A.1", "--before", a, chdir: ws)
+    jeans("add", "A.1.1", "--before", a1, chdir: ws)
+    jeans("describe", a, "-m", "A, rescoped", chdir: ws)
+
+    _, err, status = Open3.capture3(JEANS.to_s, "add", "found a bug", chdir: ws.to_s)
+    refute status.success?
+    assert_match(/outside your task/, err)
+    _, err, = Open3.capture3(JEANS.to_s, "describe", a1, "-m", "nope", chdir: ws.to_s)
+    assert_match(/outside your task/, err)
+  end
+
+  def test_done_keeps_the_spec_between_message_and_trailers
+    a = jeans("add", "A", "-m", "- one\n- two\n\nthen three")
+    jeans("claim", a)
+    jeans("done", a, "-m", "area: do A\n\nBecause.\n\nAssisted-by: Claude\nSigned-off-by: Someone")
+
+    assert_equal <<~MESSAGE, sh("jj", "log", "--no-graph", "-r", a, "-T", "description")
+      area: do A
+
+      Because.
+
+      Task: A
+
+        - one
+        - two
+
+        then three
+
+      Assisted-by: Claude
+      Signed-off-by: Someone
+    MESSAGE
+    trailer = 'trailers.filter(|t| t.key() == "Assisted-by").map(|t| t.value()).join(",")'
+    assert_equal "Claude", sh("jj", "log", "--no-graph", "-r", a, "-T", trailer)
+  end
+
+  def test_done_leaves_a_last_paragraph_that_isnt_trailers
+    a = jeans("add", "A")
+    jeans("claim", a)
+    jeans("done", a, "-m", "do A\n\n- a list\n  wrapped")
+
+    assert_equal "do A\n\n- a list\n  wrapped\n\nTask: A\n", sh("jj", "log", "--no-graph", "-r", a, "-T", "description")
+  end
+
+  def test_done_needs_a_message
+    a = jeans("add", "A")
+    ws = Pathname.new(jeans("claim", a))
+    (ws / "a.txt").write("hello\n")
+
+    assert_match(/done needs -m MESSAGE/, jeans_fails("done", a))
+    assert_match(/done needs -m MESSAGE/, jeans_fails("done", a, "-m", "  "))
+    assert_equal "claimed", jeans("show", a).lines.first.strip
+    assert_equal "A\n", sh("jj", "log", "--no-graph", "-r", a, "-T", "description")
+  end
+
+  def test_describe_rewrites_a_task
+    a = jeans("add", "A")
+    jeans("describe", a, "-m", "A, but answered")
+    assert_includes jeans("show", a), "A, but answered"
+  end
+
+  def test_claim_work_done
+    a = jeans("add", "A")
+    ws = Pathname.new(jeans("claim", a))
+    assert_includes jeans("show", a), "claimed"
+    refute_includes jeans("ready"), a
+    assert_equal "jeans: #{a} is claimed, not ready", jeans_fails("claim", a)
+
+    (ws / "a.txt").write("hello\n")
+    finish(a)
+
+    refute ws.exist?
+    assert_equal "done", jeans("show", a).lines.first.strip
+    assert_equal "A\n\nTask: A\n", sh("jj", "log", "--no-graph", "-r", a, "-T", "description")
+    assert_equal [a], parents(DONE)
+    assert_equal "hello\n", (@repo / "a.txt").read
+    assert_match(/is done/, jeans_fails("add", "late", "--before", a))
+    assert_equal "a.txt", sh("jj", "file", "list", "-r", a).strip
+    assert_equal [@goal], jeans("ready").lines(chomp: true)
+    assert_equal 1, sh("jj", "workspace", "list").lines.size
+    assert_equal "", sh("jj", "log", "--no-graph", "-r", "heads(all()) ~ (@ | #{@goal})", "-T", "change_id")
+  end
+
+  def test_done_goal_leaves_a_plain_commit
+    a = jeans("add", "A")
+    jeans("claim", a)
+    finish(a)
+    jeans("claim", @goal)
+    jeans("done", @goal, "-m", "thing: ship it\n\nBuilt A.")
+
+    assert_equal "", sh("jj", "bookmark", "list", "jeans/thing/goal", "jeans/thing/done")
+    assert_equal "thing: ship it\n\nBuilt A.\n\nTask: ship the thing\n", sh("jj", "log", "--no-graph", "-r", @goal, "-T", "description")
+    assert_equal [@goal], parents("@")
+    refute_equal @goal, jeans("init", "the next thing", "--goal", "thing", "--home", @tmp / "jeans")
+  end
+
+  def test_finished_work_goes_into_the_megamerge
+    @repo = @tmp / "megamerge"
+    @repo.mkpath
+    sh("jj", "git", "init", ".")
+    branches = %w[x y].map do |name|
+      sh("jj", "new", "root()", "-m", name)
+      (@repo / "#{name}.txt").write("#{name}\n")
+      change_id("@")
+    end
+    sh("jj", "new", *branches, "-m", "mm")
+    sh("jj", "bookmark", "create", "mm", "-r", "@")
+    sh("jj", "new")
+    goal = jeans("init", "ship the thing", "--goal", "thing", "--home", @tmp / "megamerge.jeans")
+    done = change_id(DONE)
+    assert_equal [*branches, done].sort, parents("mm").sort
+
+    a = jeans("add", "A")
+    (Pathname.new(jeans("claim", a)) / "a.txt").write("hello\n")
+    finish(a)
+
+    assert_equal [a], parents(DONE)
+    assert_equal [*branches, done].sort, parents("mm").sort
+    assert_equal [change_id("mm")], parents("@")
+    assert_equal "hello\n", (@repo / "a.txt").read
+
+    jeans("claim", goal)
+    finish(goal)
+    assert_equal [*branches, goal].sort, parents("mm").sort
+    assert_equal "", sh("jj", "bookmark", "list", "jeans/thing/goal", "jeans/thing/done")
+  end
+
+  def test_goals_keep_their_own_tasks
+    other_done = 'bookmarks(exact:"jeans/other/done")'
+    jeans("init", "another thing", "--goal", "other", "--home", @tmp / "jeans")
+    assert_match(/already has a goal named other/, jeans_fails("init", "again", "--goal", "other"))
+    assert_match(/init needs --goal NAME/, jeans_fails("init", "unnamed"))
+    assert_match(/has goals other, thing; pick one with --goal NAME/, jeans_fails("ready"))
+    assert_match(/no goal named nope; the goals are other, thing/, jeans_fails("ready", "--goal", "nope"))
+
+    a = jeans("add", "A", "--goal", "thing")
+    b = jeans("add", "B", "--goal", "other")
+    assert_equal [a], jeans("ready", "--goal", "thing").lines(chomp: true)
+    assert_equal [b], jeans("ready", "--goal", "other").lines(chomp: true)
+
+    ws = Pathname.new(jeans("claim", a))
+    a1 = jeans("add", "A.1", "--before", a, chdir: ws)
+    jeans("release", a, chdir: ws)
+    (Pathname.new(jeans("claim", a1)) / "a1.txt").write("hello\n")
+    finish(a1)
+
+    assert_equal "done", jeans("show", a1).lines.first.strip
+    assert_equal [a1], parents(DONE)
+    refute_includes parents(other_done), a1
+    assert_equal [change_id(DONE), change_id(other_done)].sort, parents("@").sort
+    assert_equal "hello\n", (@repo / "a1.txt").read
+  end
+
+  def test_release_keeps_work_without_finishing
+    a = jeans("add", "A")
+    ws = Pathname.new(jeans("claim", a))
+    (ws / "partial.txt").write("wip\n")
+    jeans("release", a)
+
+    assert_equal [a], jeans("ready").lines(chomp: true)
+    assert_equal "partial.txt", sh("jj", "file", "list", "-r", a).strip
+  end
+
+  def test_works_from_inside_a_workspace
+    a = jeans("add", "A")
+    ws = Pathname.new(jeans("claim", a))
+    a1 = jeans("add", "A.1", "--before", a, chdir: ws)
+    jeans("release", a, chdir: ws)
+
+    assert_equal [a1], jeans("ready").lines(chomp: true)
+  end
+
+  def test_integration_supersedes_an_untaken_resolution_task
+    [jeans("add", "A"), jeans("add", "B")].each do |task|
+      ws = Pathname.new(jeans("claim", task))
+      (ws / "same.txt").write("#{task}\n")
+      finish(task)
+    end
+    resolution = parents(DONE).first
+
+    ws = Pathname.new(jeans("claim", @goal))
+    (ws / "same.txt").write("both\n")
+    finish(@goal)
+
+    assert_equal [@goal], parents("@")
+    assert_equal "", sh("jj", "log", "--no-graph", "-r", "present(#{resolution})", "-T", "change_id")
+    assert_equal "both\n", (@repo / "same.txt").read
+  end
+
+  def test_conflicts_in_the_done_node_get_a_resolution_task
+    a = jeans("add", "A")
+    b = jeans("add", "B")
+    [a, b].each do |task|
+      ws = Pathname.new(jeans("claim", task))
+      (ws / "same.txt").write("#{task}\n")
+      finish(task)
+    end
+
+    assert_equal "true", sh("jj", "log", "--no-graph", "-r", "@", "-T", "conflict")
+    resolution, *others = parents(DONE)
+    assert_empty others
+    assert_match(/\AResolve conflicts between [AB], [AB]\n/, sh("jj", "log", "--no-graph", "-r", resolution, "-T", "description"))
+    assert_equal [@goal, resolution].sort, jeans("ready").lines(chomp: true).sort
+    assert_includes jeans("tree"), "#{resolution[0, 8]} Resolve conflicts"
+
+    [resolution, @goal].each do |task|
+      ws = Pathname.new(jeans("claim", task))
+      assert_match(/has conflicts/, jeans_fails("done", task, "-m", title(task)))
+      (ws / "same.txt").write("both\n")
+      finish(task)
+    end
+
+    assert_equal "false", sh("jj", "log", "--no-graph", "-r", "@", "-T", "conflict")
+    assert_equal "both\n", (@repo / "same.txt").read
+    assert_empty jeans("ready")
+  end
+
+  def test_views
+    a = jeans("add", "A")
+    a1 = jeans("add", "A.1", "--before", a)
+    b = jeans("add", "B")
+    jeans("claim", b)
+
+    assert_equal <<~TREE.strip, jeans("tree")
+      #{@goal[0, 8]} ship the thing [blocked]
+      ├── #{a[0, 8]} A [blocked]
+      │   └── #{a1[0, 8]} A.1 [ready]
+      └── #{b[0, 8]} B [claimed]
+    TREE
+    assert_equal "#{a[0, 8]} A [blocked] (+1 more)", jeans("tree", a, "--depth", "0")
+    scoped = jeans("board", a)
+    assert_includes scoped, a1[0, 8]
+    refute_includes scoped, b[0, 8]
+
+    assert_equal <<~BOARD.strip, jeans("board")
+      READY (1)
+        #{a1[0, 8]} A.1
+
+      CLAIMED (1)
+        #{b[0, 8]} B
+
+      BLOCKED (2)
+        #{@goal[0, 8]} ship the thing
+        #{a[0, 8]} A
+
+      DONE (0)
+    BOARD
+
+    assert_match(/#{a1[0, 12]} \[ready\] A\.1/, jeans("log", "ready"))
+    refute_match(/#{b[0, 12]}/, jeans("log", "ready"))
+    assert_equal [a, a1].map { it[0, 12] }, jeans("log", "under", a).scan(/[k-z]{12}/)
+    assert_equal [@goal, a, a1].map { it[0, 12] }, jeans("log", "path", a1).scan(/[k-z]{12}/)
+    assert_equal [b[0, 12]], jeans("log", 'description(exact:"B\n")').scan(/[k-z]{12}/)
+
+    [a1, a].each do |task|
+      jeans("claim", task)
+      finish(task)
+    end
+    assert_includes jeans("tree"), "#{a[0, 8]} A [done] (+1 done)"
+  end
+
+  def test_color_changes_only_escape_codes
+    a = jeans("add", "A")
+    jeans("add", "A.1", "--before", a)
+    jeans("claim", jeans("add", "B"))
+
+    [%w[tree], %w[board], %w[log], ["show", a]].each do |view|
+      colored = jeans(*view, "--color", "always")
+      assert_includes colored, "\e[", "#{view.first} has no color"
+      assert_equal jeans(*view), colored.gsub(/\e\[[\d;]*m/, ""), "#{view.first} differs beyond color"
+    end
+    assert_includes jeans("tree", "--color", "always"), "\e[32m[ready]\e[0m"
+    refute_includes jeans("tree"), "\e["
+  end
+
+  def test_watch_redraws_when_the_graph_changes
+    a = jeans("add", "A")
+    Open3.popen2(JEANS.to_s, "watch", chdir: @repo.to_s) do |_, out, thread|
+      read_until(out, "#{a[0, 8]} A [ready]")
+      op = sh("jj", "op", "log", "-n1", "--no-graph", "-T", "id")
+      sleep 2
+      assert_equal op, sh("jj", "op", "log", "-n1", "--no-graph", "-T", "id"), "watching added an operation"
+
+      b = jeans("add", "B")
+      read_until(out, "#{b[0, 8]} B [ready]")
+    ensure
+      Process.kill("INT", thread.pid)
+      thread.join
+    end
+    assert_match(/tree or board/, jeans_fails("watch", "log"))
+  end
+
+  def test_concurrent_done_leaves_no_divergence
+    tasks = 3.times.map { jeans("add", "T#{it}") }
+    tasks.each do |task|
+      ws = Pathname.new(jeans("claim", task))
+      (ws / "#{task}.txt").write("x\n")
+    end
+    tasks.map { |task| Thread.new { finish(task) } }.each(&:join)
+
+    assert_equal [@goal], jeans("ready").lines(chomp: true)
+    refute_includes sh("jj", "log", "-r", "all()"), "divergent"
+  end
+
+  private
+
+  # Reusing the task's title as the commit title keeps the views' labels stable.
+  def finish(task)
+    jeans("done", task, "-m", title(task))
+  end
+
+  def title(rev)
+    sh("jj", "log", "--no-graph", "-r", rev, "-T", "description.first_line()")
+  end
+
+  def change_id(rev)
+    sh("jj", "log", "--no-graph", "-r", rev, "-T", "change_id")
+  end
+
+  def parents(rev)
+    sh("jj", "log", "--no-graph", "-r", "parents(#{rev})", "-T", 'change_id ++ "\n"').lines(chomp: true)
+  end
+
+  def jeans(*args, chdir: @repo)
+    out, err, status = Open3.capture3(JEANS.to_s, *args.map(&:to_s), chdir: chdir.to_s)
+    assert status.success?, "jeans #{args.join(" ")} failed: #{err}"
+    out.strip
+  end
+
+  def read_until(io, text, timeout: 10)
+    seen = +""
+    deadline = Time.now + timeout
+    until seen.include?(text)
+      flunk "never printed #{text.inspect}; got:\n#{seen}" unless io.wait_readable([deadline - Time.now, 0].max)
+      seen << io.readpartial(4096)
+    end
+  end
+
+  def jeans_fails(*args)
+    _, err, status = Open3.capture3(JEANS.to_s, *args.map(&:to_s), chdir: @repo.to_s)
+    refute status.success?
+    err.strip
+  end
+
+  def sh(*args)
+    out, err, status = Open3.capture3(*args, chdir: @repo.to_s)
+    assert status.success?, "#{args.join(" ")} failed: #{err}"
+    out
+  end
+end
diff --git a/tests/cli.rs b/tests/cli.rs
new file mode 100644
index 0000000..961a3c0
--- /dev/null
+++ b/tests/cli.rs
@@ -0,0 +1,10 @@
+#![allow(clippy::unwrap_used)]
+
+use std::process::Command;
+
+#[test]
+fn no_arguments_prints_the_command_list() {
+    let out = Command::new(env!("CARGO_BIN_EXE_jeans")).output().unwrap();
+    assert!(out.status.success());
+    assert_eq!(String::from_utf8(out.stdout).unwrap(), jeans::USAGE);
+}