* Rollback command action
( args: Record<string, any>, options: Record<string, any>, )
| 315 | * Rollback command action |
| 316 | */ |
| 317 | async function rollbackCommand( |
| 318 | args: Record<string, any>, |
| 319 | options: Record<string, any>, |
| 320 | ): Promise<void> { |
| 321 | try { |
| 322 | // Initialize agent |
| 323 | const agent = new SPARC2Agent(); |
| 324 | await agent.init(); |
| 325 | |
| 326 | // Determine rollback mode |
| 327 | const target = options.commit; |
| 328 | const mode = target.match(/^\d{4}-\d{2}-\d{2}/) ? "temporal" : "checkpoint"; |
| 329 | |
| 330 | // Rollback to checkpoint |
| 331 | await agent.rollback(target, mode); |
| 332 | |
| 333 | // Output results |
| 334 | console.log(`Rolled back to ${mode === "temporal" ? "date" : "checkpoint"}: ${target}`); |
| 335 | } catch (error: unknown) { |
| 336 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 337 | console.error(`Error: ${errorMessage}`); |
| 338 | Deno.exit(1); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Get configuration value |