A third asset on the machinery 16c2bed settled, so the wiring is one entry in install::SKILLS. Four jobs, priorities, due dates, tags and campaigns, with propose-then-apply stated once at the top rather than per section. Every job writes to many tickets at once and no field can be cleared back to unset, so the document leans on the two traps that make a sweep destructive rather than merely wrong: set --tags replaces the whole field, and a due date is neither validated nor clearable. feature-planner-agent.md is deliberately not folded in. It decomposes a request into new tickets, which is intake; this orders the tickets that already exist, and one document holding both would fit neither. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
200 lines
8.4 KiB
Rust
200 lines
8.4 KiB
Rust
use assert_cmd::Command;
|
|
use assert_fs::TempDir;
|
|
|
|
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
|
|
|
/// The documents as this test's binary carries them, so the print path is pinned to the
|
|
/// files in the repo rather than to a description of them.
|
|
const SKILL: &str = include_str!("../assets/SKILL.md");
|
|
const REVIEW: &str = include_str!("../assets/REVIEW.md");
|
|
const PLAN: &str = include_str!("../assets/PLAN.md");
|
|
|
|
/// `HOME` is redirected, so the suite never writes into the home of whoever runs it.
|
|
/// A temp directory rather than the real one is also what makes the already-installed
|
|
/// and the modified cases reachable at all.
|
|
fn run(home: &TempDir, args: &[&str]) -> std::process::Output {
|
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
|
cmd.env("HOME", home.path()).args(args);
|
|
cmd.assert().get_output().clone()
|
|
}
|
|
|
|
fn installed(home: &TempDir) -> std::path::PathBuf {
|
|
home.path().join(".claude/skills/worklane/SKILL.md")
|
|
}
|
|
|
|
fn installed_review(home: &TempDir) -> std::path::PathBuf {
|
|
home.path().join(".claude/skills/worklane-review/SKILL.md")
|
|
}
|
|
|
|
fn installed_plan(home: &TempDir) -> std::path::PathBuf {
|
|
home.path().join(".claude/skills/worklane-plan/SKILL.md")
|
|
}
|
|
|
|
/// Nothing about the skills needs a board, and they are wanted before there is one.
|
|
///
|
|
/// One invocation writes every document. A person who learned the command before the
|
|
/// review skill existed gets it without learning anything new, which is the whole
|
|
/// reason there is no name to pass.
|
|
#[test]
|
|
fn every_skill_installs_outside_a_worklane_directory() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let out = run(&home, &["install-skill"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
|
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
|
|
assert!(stdout.contains(".claude/skills/worklane/SKILL.md"), "{stdout}");
|
|
assert!(stdout.contains("Installed the worklane-review skill"), "{stdout}");
|
|
assert!(stdout.contains(".claude/skills/worklane-review/SKILL.md"), "{stdout}");
|
|
assert!(stdout.contains("Installed the worklane-plan skill"), "{stdout}");
|
|
assert!(stdout.contains(".claude/skills/worklane-plan/SKILL.md"), "{stdout}");
|
|
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
|
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
|
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
|
|
|
// Once, not per document: it is the one thing to do next, not part of an outcome.
|
|
assert_eq!(
|
|
stdout.matches("pick it up on their next session").count(),
|
|
1,
|
|
"{stdout}"
|
|
);
|
|
}
|
|
|
|
/// Narrowing to one document is the exception, and it must leave the others alone.
|
|
#[test]
|
|
fn a_named_skill_installs_only_that_one() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let out = run(&home, &["install-skill", "worklane-review"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
|
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
|
assert!(!installed(&home).exists(), "a named install wrote the other document too");
|
|
assert!(!installed_plan(&home).exists(), "a named install wrote the other document too");
|
|
}
|
|
|
|
/// A name nothing ships is a stop, with the choices in the message: guessing at the
|
|
/// nearest match would install a document nobody asked for.
|
|
#[test]
|
|
fn an_unknown_skill_name_is_refused_and_lists_what_there_is() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let out = run(&home, &["install-skill", "reviewer"]);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
|
assert!(stderr.contains("no skill named"), "{stderr}");
|
|
assert!(stderr.contains("worklane-review"), "{stderr}");
|
|
assert!(!installed(&home).exists());
|
|
assert!(!installed_review(&home).exists());
|
|
assert!(!installed_plan(&home).exists());
|
|
}
|
|
|
|
#[test]
|
|
fn a_second_install_says_it_is_already_up_to_date() {
|
|
let home = TempDir::new().unwrap();
|
|
run(&home, &["install-skill"]);
|
|
|
|
let out = run(&home, &["install-skill"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
|
assert!(stdout.contains("Already up to date"), "{stdout}");
|
|
}
|
|
|
|
/// A copy someone edited is theirs. The command says what to do next rather than
|
|
/// discarding it, and only `--force` overwrites.
|
|
#[test]
|
|
fn a_modified_copy_is_reported_and_needs_force() {
|
|
let home = TempDir::new().unwrap();
|
|
run(&home, &["install-skill"]);
|
|
std::fs::write(installed(&home), "hand written\n").unwrap();
|
|
|
|
let out = run(&home, &["install-skill"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
|
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
|
|
assert!(stdout.contains("--force"), "{stdout}");
|
|
assert!(stdout.contains("--print"), "the message never says how to compare: {stdout}");
|
|
assert_eq!(
|
|
std::fs::read_to_string(installed(&home)).unwrap(),
|
|
"hand written\n",
|
|
"the modified copy was overwritten anyway"
|
|
);
|
|
|
|
let out = run(&home, &["install-skill", "--force"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
assert!(stdout.contains("Installed the worklane skill"), "{stdout}");
|
|
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), SKILL);
|
|
}
|
|
|
|
/// One refused document must not stop the ones behind it: the message is per document,
|
|
/// and the run still reports what it did with each.
|
|
#[test]
|
|
fn a_modified_copy_does_not_stop_the_other_documents() {
|
|
let home = TempDir::new().unwrap();
|
|
run(&home, &["install-skill"]);
|
|
std::fs::write(installed(&home), "hand written\n").unwrap();
|
|
std::fs::remove_file(installed_review(&home)).unwrap();
|
|
|
|
let out = run(&home, &["install-skill"]);
|
|
let stdout = String::from_utf8_lossy(&out.stdout);
|
|
|
|
assert_eq!(out.status.code(), Some(0), "{stdout}");
|
|
assert!(stdout.contains("Differs from the version in this binary"), "{stdout}");
|
|
assert!(stdout.contains("install-skill worklane --print"), "{stdout}");
|
|
assert_eq!(std::fs::read_to_string(installed(&home)).unwrap(), "hand written\n");
|
|
assert_eq!(std::fs::read_to_string(installed_review(&home)).unwrap(), REVIEW);
|
|
assert_eq!(std::fs::read_to_string(installed_plan(&home)).unwrap(), PLAN);
|
|
}
|
|
|
|
/// The print path is what makes a modified copy diffable, so it has to be the document
|
|
/// byte for byte and it must not install anything on the way past.
|
|
#[test]
|
|
fn print_writes_the_named_document_to_stdout_and_installs_nothing() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let out = run(&home, &["install-skill", "worklane", "--print"]);
|
|
assert_eq!(out.status.code(), Some(0));
|
|
assert_eq!(String::from_utf8_lossy(&out.stdout), SKILL);
|
|
|
|
let out = run(&home, &["install-skill", "worklane-review", "--print"]);
|
|
assert_eq!(out.status.code(), Some(0));
|
|
assert_eq!(String::from_utf8_lossy(&out.stdout), REVIEW);
|
|
|
|
let out = run(&home, &["install-skill", "worklane-plan", "--print"]);
|
|
assert_eq!(out.status.code(), Some(0));
|
|
assert_eq!(String::from_utf8_lossy(&out.stdout), PLAN);
|
|
|
|
assert!(!installed(&home).exists(), "--print installed the skill anyway");
|
|
assert!(!installed_review(&home).exists(), "--print installed the skill anyway");
|
|
assert!(!installed_plan(&home).exists(), "--print installed the skill anyway");
|
|
}
|
|
|
|
/// A diff is against one document. Printing them all run together would be neither of
|
|
/// them, so an unnamed `--print` says what to type instead of guessing.
|
|
#[test]
|
|
fn print_without_a_name_says_which_names_there_are() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let out = run(&home, &["install-skill", "--print"]);
|
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
|
|
|
assert_ne!(out.status.code(), Some(0), "{stderr}");
|
|
assert!(stderr.contains("name the skill to print"), "{stderr}");
|
|
assert!(stderr.contains("worklane-review"), "{stderr}");
|
|
assert!(String::from_utf8_lossy(&out.stdout).is_empty(), "a document was printed anyway");
|
|
}
|
|
|
|
/// The command has to be findable by someone who does not already know it exists.
|
|
#[test]
|
|
fn the_help_lists_the_install_skill_command() {
|
|
let home = TempDir::new().unwrap();
|
|
|
|
let stdout = String::from_utf8_lossy(&run(&home, &["--help"]).stdout).to_string();
|
|
assert!(stdout.contains("install-skill"), "{stdout}");
|
|
}
|