(a0dc5e3) Display comments under worklane show

This commit is contained in:
2026-05-15 12:00:22 +02:00
parent bc3ee0c53b
commit cd19e4e6cf
3 changed files with 103 additions and 14 deletions
@@ -15,11 +15,12 @@ rendering:
# Worklane Kanban Skill # Worklane Kanban Skill
Use this skill when creating, listing, or managing Kanban-style tickets via the `worklane` CLI. Use this skill when creating, listing, or managing Kanban-style tickets via the `worklane` CLI.
When asked to "create a ticket", use the `worklane add` command.
When asked to "implement", "work on" or "read" a ticket, use the `worklane show` command.
When asked to "create a ticket", use the `worklane add` command.
When using backticks in the command arguments, escape them so the terminal doesn't execute them. When using backticks in the command arguments, escape them so the terminal doesn't execute them.
When asked to "implement", "work on" or "read" a ticket, use the `worklane show` command.
## Commands ## Commands
### `worklane add` ### `worklane add`
@@ -41,7 +42,8 @@ Add a new ticket to the backlog.
worklane add -t "Implement login" -d "Add user login page" -t login,auth -p "Design UI" "Build backend" "Write tests" --due 2026-06-01 --owner "ilya" worklane add -t "Implement login" -d "Add user login page" -t login,auth -p "Design UI" "Build backend" "Write tests" --due 2026-06-01 --owner "ilya"
``` ```
You can add multiple acceptance criteria or steps to a ticket: When there's multiple acceptance criteria, add each using a separate `--acceptance` or `-a` flag.
When there's mulitple steps to the implementation plan, add each using a separate `--plan` or `-p` flag.
```bash ```bash
worklane add -t "Implement logic" -a "Acceptance criterium 1" -a "Acceptance criterium 2" -p "Step 1" -p "Step 2" worklane add -t "Implement logic" -a "Acceptance criterium 1" -a "Acceptance criterium 2" -p "Step 1" -p "Step 2"
+3 -1
View File
@@ -39,6 +39,8 @@ Tests create temporary `.worklane` directories with all four status folders pre-
- When working on a ticket use `worklane show [ticketID]` to read the ticket. - When working on a ticket use `worklane show [ticketID]` to read the ticket.
- If the ticket status says backlog, move it to committed using `worklane mv --status committed [ticketID]`. - If the ticket status says backlog, move it to committed using `worklane mv --status committed [ticketID]`.
- When your changes meet the acceptance criteria and the code compiles, move the ticket to reviewing using `worklane mv --status reviewing [ticketID]`
- Use `worklane comment [ticketID] "[body]"` to leave notes on tickets (e.g. "LGTM", "needs fixes", "blocked on X") - Use `worklane comment [ticketID] "[body]"` to leave notes on tickets (e.g. "LGTM", "needs fixes", "blocked on X")
- Use git to commit your changes. The commit message should follow the format: `([ticketID]) [short description of changes]`
- If further changes are made later, use --fixup to commit them
- When your changes meet the acceptance criteria and the code compiles, move the ticket to reviewing using `worklane mv --status reviewing [ticketID]`
- When the ticket is approved, move it to done using `worklane mv --status done [ticketID]` - When the ticket is approved, move it to done using `worklane mv --status done [ticketID]`
+95 -10
View File
@@ -423,13 +423,95 @@ fn resolve_ticket(search: &str, worklane_dir: &Path) -> Result<(String, String,
Ok(matches.remove(0)) Ok(matches.remove(0))
} }
fn read_comments(comments_dir: &Path) -> Result<Vec<(String, String, String, String)>> {
if !comments_dir.exists() {
return Ok(vec![]);
}
let mut comments: Vec<(String, String, String, String)> = Vec::new();
for entry in fs::read_dir(comments_dir)? {
let entry = entry?;
let path = entry.path();
if path.extension().map_or(false, |e| e == "md") {
let content = fs::read_to_string(&path)?;
let filename = path
.file_stem()
.map(|s| s.to_string_lossy().to_string())
.unwrap_or_default();
let author = content
.lines()
.find(|l| l.starts_with("**Author**"))
.and_then(|l| l.splitn(2, "**Author**:").nth(1))
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
let time = content
.lines()
.find(|l| l.starts_with("**Time**"))
.and_then(|l| l.splitn(2, "**Time**:").nth(1))
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
let body = if let Some(after_comment) = content.strip_prefix("**Comment**\n") {
if let Some(end) = after_comment.find("\n\n**Author**") {
after_comment[..end].trim()
} else {
after_comment.trim()
}
} else {
""
};
comments.push((filename, author, time, body.to_string()));
}
}
comments.sort_by(|a, b| a.0.cmp(&b.0));
Ok(comments)
}
fn format_comments(comments: &[(String, String, String, String)]) -> String {
if comments.is_empty() {
return color_text("No comments yet.", "grey");
}
let mut result = String::new();
result.push_str("\n");
result.push_str(&color_text("COMMENTS", "orange"));
result.push_str(&format!("\n{}\n", "─".repeat(20)));
for (_filename, author, time, body) in comments {
result.push_str("\n");
result.push_str(&color_text(&format!("From {} ({})", author, time), "cyan"));
result.push_str("\n");
if !body.is_empty() {
result.push_str(&" ".to_string());
result.push_str(body);
}
result.push('\n');
}
result
}
fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> { fn cmd_show(search: &str, worklane_dir: &Path) -> Result<()> {
let (_status, title, content) = resolve_ticket(search, worklane_dir)?; let (_status, title, content) = resolve_ticket(search, worklane_dir)?;
let ticket_uuid = parse_ticket_field(&content, "ID");
println!("{}", title); println!("{}", title);
println!("{}", "─".repeat(title.len())); println!("{}", "─".repeat(title.len()));
println!("\n{}", content_trim_colored(&content)); println!("\n{}", content_trim_colored(&content));
if ticket_uuid != "_Not set_" {
let comments_dir = worklane_dir.join("comments").join(&ticket_uuid);
let comments = read_comments(&comments_dir)?;
let formatted = format_comments(&comments);
println!("{}", formatted);
}
Ok(()) Ok(())
} }
@@ -447,7 +529,7 @@ fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Re
let worklane_dir = find_worklane_dir(start)?; let worklane_dir = find_worklane_dir(start)?;
let (current_status, title, _) = resolve_ticket(ticket_id, &worklane_dir)?; let (current_status, title, _) = resolve_ticket(ticket_id, &worklane_dir)?;
let current_idx = forward_order let current_idx = forward_order
.iter() .iter()
.position(|&s| s == current_status) .position(|&s| s == current_status)
@@ -505,7 +587,7 @@ fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Re
// Read and update the ticket content // Read and update the ticket content
let mut content = fs::read_to_string(current_path.join(&found_filename))?; let mut content = fs::read_to_string(current_path.join(&found_filename))?;
// Update Status in Metadata section // Update Status in Metadata section
if let Some(start_pos) = content.find("- **Status**") { if let Some(start_pos) = content.find("- **Status**") {
// Skip "- " to find "**Status**" // Skip "- " to find "**Status**"
@@ -530,8 +612,11 @@ fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Re
// Write back updated content // Write back updated content
fs::write(target_path.join(&found_filename), content)?; fs::write(target_path.join(&found_filename), content)?;
println!("Moved ticket '{}' from {} to {}", title, current_status, target_status); println!(
"Moved ticket '{}' from {} to {}",
title, current_status, target_status
);
Ok(()) Ok(())
} }
@@ -769,11 +854,11 @@ fn main() -> Result<()> {
let worklane_dir = find_worklane_dir(&start)?; let worklane_dir = find_worklane_dir(&start)?;
cmd_show(&id, &worklane_dir) cmd_show(&id, &worklane_dir)
} }
Command::Mv { ticket, status, force } => { Command::Mv {
cmd_mv(&ticket, &status, force, &start) ticket,
} status,
Command::Comment { ticket, body } => { force,
cmd_comment(&ticket, &body, &start) } => cmd_mv(&ticket, &status, force, &start),
} Command::Comment { ticket, body } => cmd_comment(&ticket, &body, &start),
} }
} }