feat: [PRODUCT-379] implement cli interface for Nodes API alpha#169
Conversation
Changed Files
|
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive CLI interface for the new Nodes API alpha, adding node management capabilities alongside the existing scale/procurement functionality. The implementation introduces a new sf nodes command with five subcommands: create, list, extend, release, and set.
The changes integrate the @sfcompute/nodes-sdk-alpha package to interact with the new API, which operates on individual compute nodes rather than the existing procurement-based model. The new interface supports both on-demand and reserved nodes, with features like auto-generated names, price quoting for reserved nodes, batch operations, and comprehensive status reporting.
Key architectural decisions include:
- Feature-flagged rollout using PostHog's 'vm-provider' flag to control access
- Reuse of existing procurement API for updating on-demand node pricing (via exported
updateProcurementfunction) - Separate client wrapper (
nodesClient.ts) for the new SDK alongside the existingapiClient.ts - Consistent CLI patterns matching existing commands (scale, buy, contracts) for user familiarity
- Price handling in cents on the backend with dollar conversion in the UI
- Support for both name and ID-based node identification
The implementation follows established codebase patterns for authentication, error handling, confirmation prompts, and UI rendering using Ink components. The extensive help text and examples indicate this is designed to be user-friendly for the new alpha feature.
Confidence score: 3/5
- Moderate risk due to several logic bugs and dependency management issues that could cause runtime failures
- Issues include array access without bounds checking, mismatched iteration logic in release command, and using 'latest' version for alpha SDK
- Files needing attention:
src/lib/nodes/release.ts,src/lib/nodes/list.tsx,package.json,src/lib/nodes/create.ts
13 files reviewed, 7 comments
| logAndQuit( | ||
| err instanceof Error ? err.message : "An unexpected error occurred.", | ||
| ); |
There was a problem hiding this comment.
logic: This function will always call logAndQuit twice for non-APIError cases, but logAndQuit calls process.exit(1) which prevents the second call from executing
| logAndQuit( | |
| err instanceof Error ? err.message : "An unexpected error occurred.", | |
| ); | |
| if (err instanceof SFCNodes.APIError) { | |
| logAndQuit(err.message); | |
| } else { | |
| logAndQuit( | |
| err instanceof Error ? err.message : "An unexpected error occurred.", | |
| ); | |
| } |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
CLI interface implementation for https://docs.sfcompute.com/api-reference#tag/nodes