pub fn author_prompt(task: &str, notes: bool, skills: bool) -> String {
if !notes && !skills {
return task.to_string();
}
let mut said = format!("{task}\n\n----- about this worktree -----\n");
if skills {
said.push_str(
"\n`skills/` is not part of this repository. It is the workspace's own \
directory, linked in here, and it holds what this workspace expects of \
a run: procedures, conventions, the way things are done here.\n\n\
Read what applies before you start. It is written for you, and it is \
not something the code can tell you.\n",
);
}
if notes {
said.push_str(
"\n`notes/` is not part of this repository either. It is the workspace's \
own directory, linked in here, and it is shared with every other run.\n\n\
Read it before you start: what earlier runs worked out is in there, \
including what was tried and did not work.\n\n\
Write to it what the next run would want and cannot get from the diff \
— a decision and why, a dead end worth not repeating, a fact about \
this project that took effort to establish. What you write there is \
kept whether or not this change lands, and it stays out of the change \
itself.\n",
);
}
if skills {
said.push_str("\nLeave `skills/` as you found it.");
said.push_str(if notes {
" `notes/` is where a run writes.\n"
} else {
"\n"
});
}
said
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_worktree_with_neither_hands_the_task_over_untouched() {
let task = "add a --json flag to the runs command";
assert_eq!(author_prompt(task, false, false), task);
}
#[test]
fn an_author_is_told_what_the_notes_directory_is_and_what_it_is_not() {
let out = author_prompt("do the thing", true, false);
assert!(
out.starts_with("do the thing"),
"the task comes first: {out}"
);
assert!(out.contains("not part of this repository"), "{out}");
assert!(out.contains("shared with every other run"), "{out}");
assert!(out.contains("whether or not this change lands"), "{out}");
assert!(out.contains("stays out of the change itself"), "{out}");
}
#[test]
fn an_author_is_told_to_read_before_it_is_told_to_write() {
let out = author_prompt("do the thing", true, false);
let read_at = out.find("Read it").expect("asked to read");
let write_at = out.find("Write to it").expect("asked to write");
assert!(read_at < write_at, "writing was asked for first:\n{out}");
}
#[test]
fn the_author_is_told_nothing_about_being_reviewed() {
let out = author_prompt("do the thing", true, false);
for leak in ["review", "APPROVE", "reject", "verdict", "judge"] {
assert!(
!out.to_lowercase().contains(&leak.to_lowercase()),
"the author was told about {leak}:\n{out}"
);
}
}
#[test]
fn skills_are_described_as_what_the_workspace_asks_not_as_a_place_to_write() {
let out = author_prompt("do the thing", false, true);
assert!(out.starts_with("do the thing"), "{out}");
assert!(
out.contains("`skills/` is not part of this repository"),
"{out}"
);
assert!(
out.contains("what this workspace expects of a run"),
"{out}"
);
assert!(out.contains("Leave `skills/` as you found it"), "{out}");
assert!(!out.contains("Write to it"), "{out}");
}
#[test]
fn what_the_workspace_asks_comes_before_what_earlier_runs_left() {
let out = author_prompt("do the thing", true, true);
let skills_at = out.find("`skills/`").expect("skills described");
let notes_at = out.find("`notes/`").expect("notes described");
assert!(skills_at < notes_at, "notes came first:\n{out}");
}
#[test]
fn each_directory_is_named_only_where_it_was_linked() {
let only_notes = author_prompt("t", true, false);
assert!(
!only_notes.to_lowercase().contains("skills"),
"{only_notes}"
);
let only_skills = author_prompt("t", false, true);
assert!(
!only_skills.to_lowercase().contains("notes"),
"{only_skills}"
);
let both = author_prompt("t", true, true);
assert!(both.to_lowercase().contains("skills") && both.to_lowercase().contains("notes"));
}
}