* Checkpoint command action
( args: Record<string, any>, options: Record<string, any>, )
| 289 | * Checkpoint command action |
| 290 | */ |
| 291 | async function checkpointCommand( |
| 292 | args: Record<string, any>, |
| 293 | options: Record<string, any>, |
| 294 | ): Promise<void> { |
| 295 | try { |
| 296 | // Initialize agent |
| 297 | const agent = new SPARC2Agent(); |
| 298 | await agent.init(); |
| 299 | |
| 300 | // Create checkpoint |
| 301 | // Sanitize the message to create a valid git tag (no spaces, special characters) |
| 302 | const sanitizedMessage = options.message.replace(/[^a-zA-Z0-9_-]/g, "_"); |
| 303 | const commitHash = await agent.createCheckpoint(sanitizedMessage); |
| 304 | |
| 305 | // Output results |
| 306 | console.log(`Checkpoint created: ${commitHash}`); |
| 307 | } catch (error: unknown) { |
| 308 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 309 | console.error(`Error: ${errorMessage}`); |
| 310 | Deno.exit(1); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Rollback command action |
nothing calls this directly
no test coverage detected