Fix 'add' tool command
This commit is contained in:
@@ -0,0 +1,82 @@
|
|||||||
|
---
|
||||||
|
id: feature-planner-agent
|
||||||
|
name: Feature Planner Agent
|
||||||
|
description: Analyzes feature requests, breaks them down into structured tickets with acceptance criteria and implementation plans, and creates them in the worklane backlog after user confirmation
|
||||||
|
category: planning
|
||||||
|
type: standard
|
||||||
|
version: 1.0.0
|
||||||
|
author: opencode
|
||||||
|
mode: primary
|
||||||
|
temperature: 0.1
|
||||||
|
tools:
|
||||||
|
bash: true
|
||||||
|
read: true
|
||||||
|
glob: true
|
||||||
|
grep: true
|
||||||
|
permissions:
|
||||||
|
bash:
|
||||||
|
"sudo *": "deny"
|
||||||
|
skill:
|
||||||
|
"worklane_kanban": "allow"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Feature Planner Agent
|
||||||
|
|
||||||
|
You break down feature requests into manageable, well-structured tickets and create them in the worklane backlog.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Understand the request
|
||||||
|
|
||||||
|
Read the user's feature request carefully. If the user hasn't provided enough detail, ask clarifying questions before proceeding.
|
||||||
|
|
||||||
|
### 2. Explore the codebase
|
||||||
|
|
||||||
|
Familiarize yourself with the project structure. Understand the relevant files, existing patterns, and conventions. Look at:
|
||||||
|
- Project structure (top-level files and directories)
|
||||||
|
- Existing code patterns in relevant areas
|
||||||
|
- Configuration files (package.json, Cargo.toml, etc.)
|
||||||
|
- `AGENTS.md` if present for project-specific conventions
|
||||||
|
|
||||||
|
### 3. Break down the feature
|
||||||
|
|
||||||
|
Decompose the feature into logical, incremental tickets. Each ticket should:
|
||||||
|
|
||||||
|
- **Be self-contained**: implementable and testable on its own
|
||||||
|
- **Have clear acceptance criteria**: measurable conditions that define "done"
|
||||||
|
- **Have a practical implementation plan**: actionable steps
|
||||||
|
- **Depend logically on previous tickets**: order them so they build on each other
|
||||||
|
- **Be appropriately scoped**: not too large (hard to review) nor too small (too much overhead)
|
||||||
|
|
||||||
|
A good breakdown typically produces 3-8 tickets depending on complexity.
|
||||||
|
|
||||||
|
### 4. Present the plan to the user
|
||||||
|
|
||||||
|
Show the full plan with all tickets and their details. Use this format:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Feature: <feature name>
|
||||||
|
|
||||||
|
### Ticket 1: <title>
|
||||||
|
**Description**: <what this ticket covers>
|
||||||
|
**Acceptance Criteria**:
|
||||||
|
- <criterium 1>
|
||||||
|
- <criterium 2>
|
||||||
|
**Implementation Plan**:
|
||||||
|
1. <step 1>
|
||||||
|
2. <step 2>
|
||||||
|
**Tags**: <tag1, tag2>
|
||||||
|
|
||||||
|
### Ticket 2: <title>
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Then **ask the user explicitly** to confirm or request changes. Do NOT proceed without confirmation.
|
||||||
|
|
||||||
|
### 5. Create tickets on confirmation
|
||||||
|
|
||||||
|
Once the user confirms, create each ticket using `worklane_add` with:
|
||||||
|
- `owner` set to `"planning agent"`
|
||||||
|
- All fields populated from the plan above
|
||||||
|
|
||||||
|
Do NOT use bash to call `worklane add` — use the `worklane_add` tool directly.
|
||||||
+81
-33
@@ -10,10 +10,9 @@ export const init = tool({
|
|||||||
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
|
"Initialize worklane in the current project. Creates the .worklane/ directory with backlog, committed, reviewing, and done subdirectories.",
|
||||||
args: {},
|
args: {},
|
||||||
async execute(_args: Record<string, any>, context: ToolContext) {
|
async execute(_args: Record<string, any>, context: ToolContext) {
|
||||||
|
const workdir = resolveWorklaneDir(context);
|
||||||
try {
|
try {
|
||||||
const result = await Bun.$`worklane init`
|
const result = await Bun.$`worklane init`.cwd(workdir).text();
|
||||||
.cwd(resolveWorklaneDir(context))
|
|
||||||
.text();
|
|
||||||
return result.trim();
|
return result.trim();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return `Error initializing worklane: ${err.message}`;
|
return `Error initializing worklane: ${err.message}`;
|
||||||
@@ -23,21 +22,34 @@ export const init = tool({
|
|||||||
|
|
||||||
export const add = tool({
|
export const add = tool({
|
||||||
description:
|
description:
|
||||||
"Add a new ticket to the worklane backlog. Supports title, description, acceptance criteria, implementation plan, tags, due date, and owner.",
|
"Add a new ticket to the worklane backlog. Requires a title. Description, acceptance criteria, and plan each support multiple lines (one item per line). Tags are comma-separated.",
|
||||||
args: {
|
args: {
|
||||||
title: tool.schema.string().describe("Ticket title (required)"),
|
title: tool.schema
|
||||||
description: tool.schema.string().describe("Multiline ticket description"),
|
.string()
|
||||||
|
.describe("Ticket title (required)"),
|
||||||
|
description: tool.schema
|
||||||
|
.string()
|
||||||
|
.describe("Description text. Use newlines between paragraphs."),
|
||||||
acceptance: tool.schema
|
acceptance: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Acceptance criteria one per line"),
|
.describe("Acceptance criteria, one per line. Put each criterium on its own line."),
|
||||||
plan: tool.schema
|
plan: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Implementation plan with one step per line"),
|
.describe("Implementation plan steps, one per line. Put each step on its own line."),
|
||||||
tags: tool.schema.string().describe("Tags as comma-separated list"),
|
tags: tool.schema
|
||||||
due: tool.schema.string().describe("Due date in YYYY-MM-DD format"),
|
.string()
|
||||||
owner: tool.schema.string().describe("Owner name"),
|
.describe("Comma-separated tags, e.g. 'bug,frontend,urgent'"),
|
||||||
|
due: tool.schema
|
||||||
|
.string()
|
||||||
|
.describe("Due date in YYYY-MM-DD format"),
|
||||||
|
owner: tool.schema
|
||||||
|
.string()
|
||||||
|
.describe("Ticket owner name. If omitted, defaults to the git user."),
|
||||||
},
|
},
|
||||||
async execute(args: Record<string, any>, context: ToolContext) {
|
async execute(args: Record<string, any>, context: ToolContext) {
|
||||||
|
if (!args.title) {
|
||||||
|
return "Error adding ticket: title is required";
|
||||||
|
}
|
||||||
const cmd: (string | number)[] = ["add", "--title", args.title];
|
const cmd: (string | number)[] = ["add", "--title", args.title];
|
||||||
if (args.description) {
|
if (args.description) {
|
||||||
args.description
|
args.description
|
||||||
@@ -69,15 +81,24 @@ export const add = tool({
|
|||||||
|
|
||||||
const workdir = resolveWorklaneDir(context);
|
const workdir = resolveWorklaneDir(context);
|
||||||
try {
|
try {
|
||||||
const proc = Bun.spawn(["worklane", ...cmd], { cwd: workdir });
|
const proc = Bun.spawn(["worklane", ...cmd], {
|
||||||
const { exitCode, stdout, stderr } = await proc.exited;
|
cwd: workdir,
|
||||||
|
stdout: "pipe",
|
||||||
|
stderr: "pipe",
|
||||||
|
});
|
||||||
|
const [stdout, stderr, exitCode] = await Promise.all([
|
||||||
|
new Response(proc.stdout).text(),
|
||||||
|
new Response(proc.stderr).text(),
|
||||||
|
proc.exited,
|
||||||
|
]);
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
const stderrStr = new TextDecoder().decode(stderr);
|
throw new Error(
|
||||||
throw new Error(stderrStr.trim() || `Exit code ${exitCode}`);
|
stderr.trim() || `Exit code ${exitCode}, stderr: ${stderr}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return new TextDecoder().decode(stdout).trim();
|
return stdout;
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return `Error adding ticket: ${err.message}`;
|
return `Error adding ticket: ${err.message}, cmd: ${cmd}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -115,9 +136,12 @@ export const show = tool({
|
|||||||
args: {
|
args: {
|
||||||
id: tool.schema
|
id: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring"),
|
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||||
},
|
},
|
||||||
async execute(args: Record<string, any>, context: ToolContext) {
|
async execute(args: Record<string, any>, context: ToolContext) {
|
||||||
|
if (!args.id) {
|
||||||
|
return "Error showing ticket: id is required";
|
||||||
|
}
|
||||||
const workdir = resolveWorklaneDir(context);
|
const workdir = resolveWorklaneDir(context);
|
||||||
try {
|
try {
|
||||||
const result = await Bun.$`worklane show ${args.id}`.cwd(workdir).text();
|
const result = await Bun.$`worklane show ${args.id}`.cwd(workdir).text();
|
||||||
@@ -134,16 +158,22 @@ export const mv = tool({
|
|||||||
args: {
|
args: {
|
||||||
ticket: tool.schema
|
ticket: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring"),
|
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||||
status: tool.schema
|
status: tool.schema
|
||||||
.enum(["backlog", "committed", "reviewing", "done"])
|
.enum(["backlog", "committed", "reviewing", "done"])
|
||||||
.describe("Target status"),
|
.describe("Target status (required)"),
|
||||||
force: tool.schema
|
force: tool.schema
|
||||||
.boolean()
|
.boolean()
|
||||||
.describe("Force move (allows non-sequential moves like done -> backlog)")
|
.describe("Force move (allows non-sequential moves like done -> backlog). Use with caution.")
|
||||||
.optional(),
|
.optional(),
|
||||||
},
|
},
|
||||||
async execute(args: Record<string, any>, context: ToolContext) {
|
async execute(args: Record<string, any>, context: ToolContext) {
|
||||||
|
if (!args.ticket) {
|
||||||
|
return "Error moving ticket: ticket is required";
|
||||||
|
}
|
||||||
|
if (!args.status) {
|
||||||
|
return "Error moving ticket: status is required. Must be one of: backlog, committed, reviewing, done";
|
||||||
|
}
|
||||||
const cmd: (string | number)[] = [
|
const cmd: (string | number)[] = [
|
||||||
"mv",
|
"mv",
|
||||||
args.ticket,
|
args.ticket,
|
||||||
@@ -155,12 +185,15 @@ export const mv = tool({
|
|||||||
const workdir = resolveWorklaneDir(context);
|
const workdir = resolveWorklaneDir(context);
|
||||||
try {
|
try {
|
||||||
const proc = Bun.spawn(["worklane", ...cmd], { cwd: workdir });
|
const proc = Bun.spawn(["worklane", ...cmd], { cwd: workdir });
|
||||||
const { exitCode, stdout, stderr } = await proc.exited;
|
const [stdout, stderr, exitCode] = await Promise.all([
|
||||||
|
new Response(proc.stdout).text(),
|
||||||
|
new Response(proc.stderr).text(),
|
||||||
|
proc.exited,
|
||||||
|
]);
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
const stderrStr = new TextDecoder().decode(stderr);
|
throw new Error(stderr.trim() || `Exit code ${exitCode}`);
|
||||||
throw new Error(stderrStr.trim() || `Exit code ${exitCode}`);
|
|
||||||
}
|
}
|
||||||
return new TextDecoder().decode(stdout).trim();
|
return stdout.trim();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return `Error moving ticket: ${err.message}`;
|
return `Error moving ticket: ${err.message}`;
|
||||||
}
|
}
|
||||||
@@ -168,27 +201,42 @@ export const mv = tool({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const comment = tool({
|
export const comment = tool({
|
||||||
description: "Add a comment to an existing ticket.",
|
description: "Add a comment to an existing ticket. The comment body supports markdown and newlines. Use it to add review feedback, notes, or status updates.",
|
||||||
args: {
|
args: {
|
||||||
ticket: tool.schema
|
ticket: tool.schema
|
||||||
.string()
|
.string()
|
||||||
.describe("Ticket UUID (8+ chars) or title substring"),
|
.describe("Ticket UUID (8+ chars) or title substring (required)"),
|
||||||
body: tool.schema.string().describe("Comment body (required)"),
|
body: tool.schema
|
||||||
owner: tool.schema.string().describe("Comment author").optional(),
|
.string()
|
||||||
|
.describe("Comment body text (required). Supports markdown formatting and multiple paragraphs separated by newlines."),
|
||||||
|
owner: tool.schema
|
||||||
|
.string()
|
||||||
|
.describe("Comment author. If omitted, defaults to the git user.")
|
||||||
|
.optional(),
|
||||||
},
|
},
|
||||||
async execute(args: Record<string, any>, context: ToolContext) {
|
async execute(args: Record<string, any>, context: ToolContext) {
|
||||||
|
if (!args.ticket) {
|
||||||
|
return "Error adding comment: ticket is required";
|
||||||
|
}
|
||||||
|
if (!args.body) {
|
||||||
|
return "Error adding comment: body is required";
|
||||||
|
}
|
||||||
|
|
||||||
const cmd: (string | number)[] = ["comment", args.ticket, args.body];
|
const cmd: (string | number)[] = ["comment", args.ticket, args.body];
|
||||||
if (args.owner) cmd.push("--owner", args.owner);
|
if (args.owner) cmd.push("--owner", args.owner);
|
||||||
|
|
||||||
const workdir = resolveWorklaneDir(context);
|
const workdir = resolveWorklaneDir(context);
|
||||||
try {
|
try {
|
||||||
const proc = Bun.spawn(["worklane", ...cmd], { cwd: workdir });
|
const proc = Bun.spawn(["worklane", ...cmd], { cwd: workdir });
|
||||||
const { exitCode, stdout, stderr } = await proc.exited;
|
const [stdout, stderr, exitCode] = await Promise.all([
|
||||||
|
new Response(proc.stdout).text(),
|
||||||
|
new Response(proc.stderr).text(),
|
||||||
|
proc.exited,
|
||||||
|
]);
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
const stderrStr = new TextDecoder().decode(stderr);
|
throw new Error(stderr.trim() || `Exit code ${exitCode}`);
|
||||||
throw new Error(stderrStr.trim() || `Exit code ${exitCode}`);
|
|
||||||
}
|
}
|
||||||
return new TextDecoder().decode(stdout).trim();
|
return stdout.trim();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
return `Error adding comment: ${err.message}`;
|
return `Error adding comment: ${err.message}`;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -19,15 +19,15 @@ pub enum Command {
|
|||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
title: String,
|
title: String,
|
||||||
|
|
||||||
/// Ticket description
|
/// Ticket description. Use multiple flags to create multiline descriptions.
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
description: Vec<String>,
|
description: Vec<String>,
|
||||||
|
|
||||||
/// Acceptance criteria (comma-separated)
|
/// Acceptance criteria. Accepts multiple flags, each will be interpreted as a single criterium
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
acceptance: Vec<String>,
|
acceptance: Vec<String>,
|
||||||
|
|
||||||
/// Implementation plan (comma-separated steps)
|
/// Implementation plan. Accepts multiple flags, each will be interpreted as a single step
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
plan: Vec<String>,
|
plan: Vec<String>,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user