File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,22 @@ program
4242 }
4343 } ) ;
4444
45+ program
46+ . command ( "cancel" )
47+ . description ( "Cancel the active intent" )
48+ . action ( async ( ) => {
49+ try {
50+ const projectId = await ensureProject ( ) ;
51+ const branchId = await ensureBranch ( projectId ) ;
52+
53+ const intent = await commands . cancel ( { branchId } ) ;
54+ console . log ( `Cancelled intent #${ intent . id } : ${ intent . message } ` ) ;
55+ } catch ( error ) {
56+ console . error ( "Failed to cancel intent:" , getErrorMessage ( error ) ) ;
57+ process . exit ( 1 ) ;
58+ }
59+ } ) ;
60+
4561program
4662 . command ( "finish" )
4763 . description ( "Finish the current active intent" )
Original file line number Diff line number Diff line change 1+ import { eq } from "drizzle-orm" ;
2+ import { db } from "../db" ;
3+ import { type Intent , intents } from "../db/schema" ;
4+ import { findActiveIntent } from "./findActiveIntent" ;
5+
6+ export async function cancel ( {
7+ branchId,
8+ } : {
9+ branchId : string ;
10+ } ) : Promise < Intent > {
11+ try {
12+ const activeIntent = await findActiveIntent ( { branchId } ) ;
13+
14+ if ( ! activeIntent ) {
15+ throw new Error ( "No active intent found for this branch" ) ;
16+ }
17+
18+ return db
19+ . update ( intents )
20+ . set ( {
21+ status : "cancelled" ,
22+ } )
23+ . where ( eq ( intents . id , activeIntent . id ) )
24+ . returning ( )
25+ . get ( ) ;
26+ } catch ( error ) {
27+ console . error ( "Failed to cancel intent: " , error ) ;
28+ throw new Error (
29+ `Failed to cancel intent: ${ error instanceof Error ? error . message : "Unknown error" } ` ,
30+ ) ;
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ export * from "./cancel" ;
12export * from "./findActiveIntent" ;
23export * from "./finish" ;
34export * from "./list" ;
You can’t perform that action at this time.
0 commit comments