diff --git a/docs/src/pages/cli.astro b/docs/src/pages/cli.astro index 9667cd7..d2f8bcf 100644 --- a/docs/src/pages/cli.astro +++ b/docs/src/pages/cli.astro @@ -163,12 +163,14 @@ dex complete abc123 --result "Planning complete, no code changes" --no-commit`}
  • -d, --description — Updated description
  • --add-blocker <id> — Add blocking dependency
  • --remove-blocker <id> — Remove blocking dependency
  • +
  • --unstart — Clear started status (move back to ready)
  • diff --git a/src/cli/edit.test.ts b/src/cli/edit.test.ts index 794dbb8..b354f35 100644 --- a/src/cli/edit.test.ts +++ b/src/cli/edit.test.ts @@ -370,4 +370,39 @@ describe("edit command", () => { const out = output.stdout.join("\n"); expect(out).toContain("--commit"); }); + + it("moves an in-progress task back to ready with --unstart", async () => { + await runCli(["create", "-n", "In progress task", "--description", "ctx"], { + storage, + }); + const taskId = output.stdout.join("\n").match(TASK_ID_REGEX)?.[1]; + output.stdout.length = 0; + + // Start the task + await runCli(["start", taskId!], { storage }); + output.stdout.length = 0; + + // Verify it's in progress + const storeBeforeUnstart = await storage.readAsync(); + const taskBefore = storeBeforeUnstart.tasks.find((t) => t.id === taskId); + expect(taskBefore?.started_at).toBeTruthy(); + + // Unstart the task + await runCli(["edit", taskId!, "--unstart"], { storage }); + + const out = output.stdout.join("\n"); + expect(out).toContain("Updated"); + + // Verify started_at is cleared + const storeAfter = await storage.readAsync(); + const taskAfter = storeAfter.tasks.find((t) => t.id === taskId); + expect(taskAfter?.started_at).toBeNull(); + }); + + it("shows --unstart in help", async () => { + await runCli(["edit", "-h"], { storage }); + + const out = output.stdout.join("\n"); + expect(out).toContain("--unstart"); + }); }); diff --git a/src/cli/edit.ts b/src/cli/edit.ts index d25ac67..ea524b3 100644 --- a/src/cli/edit.ts +++ b/src/cli/edit.ts @@ -24,6 +24,7 @@ export async function editCommand( "add-blocker": { hasValue: true }, "remove-blocker": { hasValue: true }, commit: { short: "c", hasValue: true }, + unstart: { hasValue: false }, help: { short: "h", hasValue: false }, }, "edit", @@ -46,6 +47,7 @@ ${colors.bold}OPTIONS:${colors.reset} --add-blocker Comma-separated task IDs to add as blockers --remove-blocker Comma-separated task IDs to remove as blockers -c, --commit Link a git commit to the task + --unstart Clear started status (move back to ready) -h, --help Show this help message ${colors.bold}EXAMPLE:${colors.reset} @@ -55,6 +57,7 @@ ${colors.bold}EXAMPLE:${colors.reset} dex edit abc123 --add-blocker def456 dex edit abc123 --remove-blocker def456 dex edit abc123 --commit a1b2c3d + dex edit abc123 --unstart `); return; } @@ -118,6 +121,8 @@ ${colors.bold}EXAMPLE:${colors.reset} }; } + const unstart = getBooleanFlag(flags, "unstart"); + const task = await service.update({ id, name: getStringFlag(flags, "name"), @@ -127,6 +132,7 @@ ${colors.bold}EXAMPLE:${colors.reset} add_blocked_by: addBlockedBy, remove_blocked_by: removeBlockedBy, metadata, + ...(unstart ? { started_at: null } : {}), }); console.log( diff --git a/src/cli/help.ts b/src/cli/help.ts index 188e192..4f7d296 100644 --- a/src/cli/help.ts +++ b/src/cli/help.ts @@ -30,6 +30,7 @@ ${colors.bold}COMMANDS:${colors.reset} show --json Output as JSON (for scripts) edit [-n "..."] Edit task edit --commit Link commit to completed task + edit --unstart Move task from in progress back to ready update Alias for edit command start Mark task as in progress start --force Re-claim task already in progress