(339c65a) Add comment command
This commit is contained in:
@@ -15,17 +15,13 @@ 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 using backticks in the command arguments, escape them so the terminal doesn't execute them.
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
### `worklane init`
|
|
||||||
|
|
||||||
Initialize worklane in the current project (creates the worklane data file if it doesn't exist).
|
|
||||||
|
|
||||||
```
|
|
||||||
worklane init
|
|
||||||
```
|
|
||||||
|
|
||||||
### `worklane add`
|
### `worklane add`
|
||||||
|
|
||||||
Add a new ticket to the backlog.
|
Add a new ticket to the backlog.
|
||||||
@@ -71,9 +67,52 @@ Show the full details of a single ticket by UUID or title.
|
|||||||
worklane show "ticket title or uuid"
|
worklane show "ticket title or uuid"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `worklane mv`
|
||||||
|
|
||||||
|
Move a ticket between statuses.
|
||||||
|
|
||||||
|
**Positional arguments:**
|
||||||
|
- `<id>`: Ticket UUID (8+ characters) or title
|
||||||
|
|
||||||
|
**Required options:**
|
||||||
|
- `--status <target>`: Target status (`backlog`, `committed`, `reviewing`, `done`)
|
||||||
|
|
||||||
|
**Options:**
|
||||||
|
- `-f`: Force move (allows skipping stages and backward moves)
|
||||||
|
|
||||||
|
**Default behavior:** Only allows forward moves, one stage at a time (`backlog` -> `committed` -> `reviewing` -> `done`).
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
worklane mv ticket-id --status committed # Move forward one stage
|
||||||
|
worklane mv ticket-title --status reviewing -f # Force skip stages
|
||||||
|
worklane mv a1b2c3d4 --status committed # Move by UUID prefix
|
||||||
|
worklane mv "My Ticket" --status done -f # Move by title with force
|
||||||
|
```
|
||||||
|
|
||||||
|
### `worklane comment`
|
||||||
|
|
||||||
|
Add a comment to a ticket.
|
||||||
|
|
||||||
|
**Positional arguments:**
|
||||||
|
- `<ticket>`: Ticket UUID (8+ characters) or title
|
||||||
|
- `<body>`: Comment text
|
||||||
|
|
||||||
|
Comments are stored as timestamped markdown files in `.worklane/comments/<ticket-uuid>/` and include the git author and timestamp.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
worklane comment ticket-id "Reviewed, looks good"
|
||||||
|
worklane comment "My Ticket" "Needs changes to the UI"
|
||||||
|
worklane comment a1b2c3d4 "LGTM, approved"
|
||||||
|
```
|
||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
1. Run `worklane init` before using other commands (if not already done)
|
1. Use `worklane add` to create tickets with all relevant details
|
||||||
2. Use `worklane add` to create tickets with all relevant details
|
2. Use `worklane ls [status]` to view tickets by status
|
||||||
3. Use `worklane ls [status]` to view tickets by status
|
3. Use `worklane show <id>` to view full ticket details
|
||||||
4. Use `worklane show <id>` to view full ticket details
|
4. Use `worklane mv <id> --status <target>` to move tickets through the workflow
|
||||||
|
5. Use `worklane comment <ticket> <body>` to add notes to tickets
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
| `worklane ls` | Lists tickets, optionally filtered by `--status` |
|
| `worklane ls` | Lists tickets, optionally filtered by `--status` |
|
||||||
| `worklane show <id>` | Shows ticket by UUID prefix or title |
|
| `worklane show <id>` | Shows ticket by UUID prefix or title |
|
||||||
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
| `worklane mv <id> --status <target> [-f]` | Moves ticket between statuses. Default: forward only, one stage at a time. `-f` bypasses both restrictions |
|
||||||
|
| `worklane comment <ticket> <body>` | Adds a comment to a ticket by UUID or title |
|
||||||
|
|
||||||
## Ticket File Format
|
## Ticket File Format
|
||||||
Filenames: `<uuid_v4>_<slug>.md`
|
Filenames: `<uuid_v4>_<slug>.md`
|
||||||
@@ -37,6 +38,7 @@ Tests create temporary `.worklane` directories with all four status folders pre-
|
|||||||
## Agent workflow
|
## Agent workflow
|
||||||
|
|
||||||
- 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 is in the 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]`
|
- When your changes meet the acceptance criteria and the code compiles, move the ticket to reviewing using `worklane mv --status reviewing [ticketID]`
|
||||||
- If you need more information on how to use `worklane`, use the worklane kanban skill
|
- Use `worklane comment [ticketID] "[body]"` to leave notes on tickets (e.g. "LGTM", "needs fixes", "blocked on X")
|
||||||
|
- When the ticket is approved, move it to done using `worklane mv --status done [ticketID]`
|
||||||
|
|||||||
@@ -69,4 +69,13 @@ pub enum Command {
|
|||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
force: bool,
|
force: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Add a comment to a ticket
|
||||||
|
Comment {
|
||||||
|
/// Ticket UUID or title
|
||||||
|
ticket: String,
|
||||||
|
|
||||||
|
/// Comment body (required)
|
||||||
|
body: String,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
+43
@@ -535,6 +535,46 @@ fn cmd_mv(ticket_id: &str, target_status: &str, force: bool, start: &Path) -> Re
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cmd_comment(ticket_id: &str, body: &str, start: &Path) -> Result<()> {
|
||||||
|
if body.is_empty() {
|
||||||
|
return Err(anyhow!("Comment body is required."));
|
||||||
|
}
|
||||||
|
|
||||||
|
let worklane_dir = find_worklane_dir(start)?;
|
||||||
|
let (_status, title, content) = resolve_ticket(ticket_id, &worklane_dir)?;
|
||||||
|
let ticket_uuid = parse_ticket_field(&content, "ID");
|
||||||
|
|
||||||
|
if ticket_uuid == "_Not set_" {
|
||||||
|
return Err(anyhow!("Could not determine ticket ID."));
|
||||||
|
}
|
||||||
|
|
||||||
|
let comments_dir = worklane_dir.join("comments").join(&ticket_uuid);
|
||||||
|
fs::create_dir_all(&comments_dir)?;
|
||||||
|
|
||||||
|
let timestamp = Local::now().format("%Y%m%d_%H%M%S");
|
||||||
|
let filename = format!("{}.md", timestamp);
|
||||||
|
let filepath = comments_dir.join(&filename);
|
||||||
|
|
||||||
|
let author = get_git_user().unwrap_or_else(|| "unknown".to_string());
|
||||||
|
|
||||||
|
let comment_content = format!(
|
||||||
|
"**Comment**\n\
|
||||||
|
{}\n\
|
||||||
|
\n\
|
||||||
|
**Author**: {}\n\
|
||||||
|
**Time**: {}\n\
|
||||||
|
",
|
||||||
|
body,
|
||||||
|
author,
|
||||||
|
Local::now().format("%Y-%m-%d %H:%M:%S")
|
||||||
|
);
|
||||||
|
|
||||||
|
fs::write(&filepath, comment_content)?;
|
||||||
|
|
||||||
|
println!("Comment added to '{}' ({})", title, filename);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn content_trim_colored(content: &str) -> String {
|
fn content_trim_colored(content: &str) -> String {
|
||||||
let lines: Vec<&str> = content.trim().lines().collect();
|
let lines: Vec<&str> = content.trim().lines().collect();
|
||||||
let mut result = String::new();
|
let mut result = String::new();
|
||||||
@@ -732,5 +772,8 @@ fn main() -> Result<()> {
|
|||||||
Command::Mv { ticket, status, force } => {
|
Command::Mv { ticket, status, force } => {
|
||||||
cmd_mv(&ticket, &status, force, &start)
|
cmd_mv(&ticket, &status, force, &start)
|
||||||
}
|
}
|
||||||
|
Command::Comment { ticket, body } => {
|
||||||
|
cmd_comment(&ticket, &body, &start)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
use assert_cmd::Command;
|
||||||
|
use assert_fs::fixture::{PathChild, PathCreateDir};
|
||||||
|
use assert_fs::TempDir;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
const BIN_NAME: &str = env!("CARGO_BIN_EXE_worklane");
|
||||||
|
|
||||||
|
fn setup_worklane(temp: &TempDir) -> PathBuf {
|
||||||
|
let worklane = temp.child(".worklane");
|
||||||
|
worklane.create_dir_all().unwrap();
|
||||||
|
|
||||||
|
for dir in ["backlog", "committed", "reviewing", "done"] {
|
||||||
|
worklane.child(dir).create_dir_all().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
worklane.path().to_path_buf()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_ticket(
|
||||||
|
worklane_dir: &PathBuf,
|
||||||
|
status: &str,
|
||||||
|
title: &str,
|
||||||
|
) -> String {
|
||||||
|
let uuid = uuid::Uuid::new_v4().to_string();
|
||||||
|
let slug = title
|
||||||
|
.to_lowercase()
|
||||||
|
.chars()
|
||||||
|
.filter(|c| c.is_alphanumeric() || *c == ' ' || *c == '-' || *c == '_')
|
||||||
|
.map(|c| if c == ' ' { '-' } else { c })
|
||||||
|
.collect::<String>();
|
||||||
|
let filename = format!("{}_{}.md", uuid, slug);
|
||||||
|
let content = format!(
|
||||||
|
"# {}\n\
|
||||||
|
\n\
|
||||||
|
## Metadata\n\
|
||||||
|
\n\
|
||||||
|
- **ID**: {}\n\
|
||||||
|
- **Status**: {}\n\
|
||||||
|
",
|
||||||
|
title, uuid, status
|
||||||
|
);
|
||||||
|
fs::create_dir_all(worklane_dir.join(status)).unwrap();
|
||||||
|
fs::write(worklane_dir.join(status).join(&filename), content).unwrap();
|
||||||
|
uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_creates_file_with_valid_ticket_uuid() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let uuid = create_ticket(&worklane, "backlog", "Test Ticket");
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.arg("comment")
|
||||||
|
.args([&uuid, "This is a test comment"])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let comments_dir = worklane.join("comments").join(&uuid);
|
||||||
|
assert!(comments_dir.exists());
|
||||||
|
let files: Vec<_> = fs::read_dir(&comments_dir)
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.collect();
|
||||||
|
assert_eq!(files.len(), 1);
|
||||||
|
let content = fs::read_to_string(files[0].path()).unwrap();
|
||||||
|
assert!(content.contains("This is a test comment"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_creates_file_with_valid_ticket_title() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
create_ticket(&worklane, "committed", "My Ticket");
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.arg("comment")
|
||||||
|
.args(["My Ticket", "Testing title lookup"])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_error_when_ticket_not_found() {
|
||||||
|
let _temp = TempDir::new().unwrap();
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.arg("comment")
|
||||||
|
.arg("Nonexistent")
|
||||||
|
.arg("Some comment")
|
||||||
|
.assert()
|
||||||
|
.code(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_includes_git_user_and_body() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let uuid = create_ticket(&worklane, "backlog", "Comment Test");
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.arg("comment")
|
||||||
|
.args([&uuid, "My comment body"])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let comments_dir = worklane.join("comments").join(&uuid);
|
||||||
|
let files: Vec<_> = fs::read_dir(&comments_dir)
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.collect();
|
||||||
|
let content = fs::read_to_string(files[0].path()).unwrap();
|
||||||
|
assert!(content.contains("My comment body"));
|
||||||
|
assert!(content.contains("**Author**"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_stored_in_timestamped_file() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let uuid = create_ticket(&worklane, "done", "Timestamp Test");
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.arg("comment")
|
||||||
|
.args([&uuid, "Timestamp test"])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
let comments_dir = worklane.join("comments").join(&uuid);
|
||||||
|
let files: Vec<_> = fs::read_dir(&comments_dir)
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.collect();
|
||||||
|
assert_eq!(files.len(), 1);
|
||||||
|
let filename = files[0].file_name().into_string().unwrap();
|
||||||
|
assert!(filename.ends_with(".md"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn comment_creates_comments_directory() {
|
||||||
|
let temp = TempDir::new().unwrap();
|
||||||
|
let worklane = setup_worklane(&temp);
|
||||||
|
|
||||||
|
let uuid = create_ticket(&worklane, "reviewing", "Dir Test");
|
||||||
|
|
||||||
|
let comments_dir = worklane.join("comments").join(&uuid);
|
||||||
|
assert!(!comments_dir.exists());
|
||||||
|
|
||||||
|
let mut cmd = Command::cargo_bin(BIN_NAME).unwrap();
|
||||||
|
cmd.current_dir(&temp.path())
|
||||||
|
.arg("comment")
|
||||||
|
.args([&uuid, "Create dir test"])
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
assert!(comments_dir.exists());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user