Skip to content

Commit 89fddba

Browse files
committed
feat(edit): Add --unstart flag to clear started status
This is useful to move a in-progress task back to ready-to-work status. Alternative way do to is to edit JSONL files directly, but having an option on `dex edit` seems cleaner. I do have a agent loop that picks ready-to-work Dex tasks and work on them until completion, but I also do have a check to see if the agent stuck on a task for some period of time, and if so, I do `git reset` to reset everything and start the work from strach. `git reset` does the trick if you track `.dex/` in your Git repository, but if you use global directory or if you don't track `.dex/` in your repository, this command would be useful to reset Dex state. Pi session: https://pi.dev/session/#3bbd100f2ad00a5e98990e8e1b84841c
1 parent 3f55b2a commit 89fddba

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

docs/src/pages/cli.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ dex complete abc123 --result "Planning complete, no code changes" --no-commit`}
163163
<li><code>-d, --description</code> — Updated description</li>
164164
<li><code>--add-blocker &lt;id&gt;</code> — Add blocking dependency</li>
165165
<li><code>--remove-blocker &lt;id&gt;</code> — Remove blocking dependency</li>
166+
<li><code>--unstart</code> — Clear started status (move back to ready)</li>
166167
</ul>
167168
<Terminal title="Terminal">
168169
<Code
169170
code={`dex edit abc123 -n "Updated name"
170171
dex edit abc123 --add-blocker xyz789
171-
dex edit abc123 --remove-blocker xyz789`}
172+
dex edit abc123 --remove-blocker xyz789
173+
dex edit abc123 --unstart`}
172174
lang="bash"
173175
theme="vitesse-black"
174176
/>

src/cli/edit.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,39 @@ describe("edit command", () => {
370370
const out = output.stdout.join("\n");
371371
expect(out).toContain("--commit");
372372
});
373+
374+
it("moves an in-progress task back to ready with --unstart", async () => {
375+
await runCli(["create", "-n", "In progress task", "--description", "ctx"], {
376+
storage,
377+
});
378+
const taskId = output.stdout.join("\n").match(TASK_ID_REGEX)?.[1];
379+
output.stdout.length = 0;
380+
381+
// Start the task
382+
await runCli(["start", taskId!], { storage });
383+
output.stdout.length = 0;
384+
385+
// Verify it's in progress
386+
const storeBeforeUnstart = await storage.readAsync();
387+
const taskBefore = storeBeforeUnstart.tasks.find((t) => t.id === taskId);
388+
expect(taskBefore?.started_at).toBeTruthy();
389+
390+
// Unstart the task
391+
await runCli(["edit", taskId!, "--unstart"], { storage });
392+
393+
const out = output.stdout.join("\n");
394+
expect(out).toContain("Updated");
395+
396+
// Verify started_at is cleared
397+
const storeAfter = await storage.readAsync();
398+
const taskAfter = storeAfter.tasks.find((t) => t.id === taskId);
399+
expect(taskAfter?.started_at).toBeNull();
400+
});
401+
402+
it("shows --unstart in help", async () => {
403+
await runCli(["edit", "-h"], { storage });
404+
405+
const out = output.stdout.join("\n");
406+
expect(out).toContain("--unstart");
407+
});
373408
});

src/cli/edit.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export async function editCommand(
2424
"add-blocker": { hasValue: true },
2525
"remove-blocker": { hasValue: true },
2626
commit: { short: "c", hasValue: true },
27+
unstart: { hasValue: false },
2728
help: { short: "h", hasValue: false },
2829
},
2930
"edit",
@@ -46,6 +47,7 @@ ${colors.bold}OPTIONS:${colors.reset}
4647
--add-blocker <ids> Comma-separated task IDs to add as blockers
4748
--remove-blocker <ids> Comma-separated task IDs to remove as blockers
4849
-c, --commit <sha> Link a git commit to the task
50+
--unstart Clear started status (move back to ready)
4951
-h, --help Show this help message
5052
5153
${colors.bold}EXAMPLE:${colors.reset}
@@ -55,6 +57,7 @@ ${colors.bold}EXAMPLE:${colors.reset}
5557
dex edit abc123 --add-blocker def456
5658
dex edit abc123 --remove-blocker def456
5759
dex edit abc123 --commit a1b2c3d
60+
dex edit abc123 --unstart
5861
`);
5962
return;
6063
}
@@ -118,6 +121,8 @@ ${colors.bold}EXAMPLE:${colors.reset}
118121
};
119122
}
120123

124+
const unstart = getBooleanFlag(flags, "unstart");
125+
121126
const task = await service.update({
122127
id,
123128
name: getStringFlag(flags, "name"),
@@ -127,6 +132,7 @@ ${colors.bold}EXAMPLE:${colors.reset}
127132
add_blocked_by: addBlockedBy,
128133
remove_blocked_by: removeBlockedBy,
129134
metadata,
135+
...(unstart ? { started_at: null } : {}),
130136
});
131137

132138
console.log(

src/cli/help.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ${colors.bold}COMMANDS:${colors.reset}
3030
show <id> --json Output as JSON (for scripts)
3131
edit <id> [-n "..."] Edit task
3232
edit <id> --commit <sha> Link commit to completed task
33+
edit <id> --unstart Move task from in progress back to ready
3334
update Alias for edit command
3435
start <id> Mark task as in progress
3536
start <id> --force Re-claim task already in progress

0 commit comments

Comments
 (0)