Skip to content

feat: [PRODUCT-379] implement cli interface for Nodes API alpha#169

Merged
sigmachirality merged 22 commits into
mainfrom
dt/nodes-alpha
Jul 25, 2025
Merged

feat: [PRODUCT-379] implement cli interface for Nodes API alpha#169
sigmachirality merged 22 commits into
mainfrom
dt/nodes-alpha

Conversation

@sigmachirality
Copy link
Copy Markdown
Member

@sigmachirality sigmachirality commented Jul 23, 2025

CLI interface implementation for https://docs.sfcompute.com/api-reference#tag/nodes

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented Jul 23, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  deno.json  100% smaller
  src/lib/scale/update.tsx  15% smaller
  src/lib/posthog.ts  7% smaller
  deno.lock Unsupported file format
  package.json  0% smaller
  src/index.ts  0% smaller
  src/lib/nodes/create.ts  0% smaller
  src/lib/nodes/extend.ts  0% smaller
  src/lib/nodes/index.ts  0% smaller
  src/lib/nodes/list.tsx  0% smaller
  src/lib/nodes/release.ts  0% smaller
  src/lib/nodes/set.ts  0% smaller
  src/lib/nodes/utils.ts  0% smaller
  src/nodesClient.ts  0% smaller

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 updateProcurement function)
  • Separate client wrapper (nodesClient.ts) for the new SDK alongside the existing apiClient.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

Edit Code Review Bot Settings | Greptile

Comment thread src/lib/nodes/release.ts Outdated
Comment thread src/lib/nodes/set.ts
Comment thread src/lib/nodes/extend.ts
Comment thread src/nodesClient.ts
Comment thread src/nodesClient.ts
Comment on lines +18 to +20
logAndQuit(
err instanceof Error ? err.message : "An unexpected error occurred.",
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Suggested change
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.",
);
}

Comment thread src/lib/nodes/utils.ts Outdated
Comment thread src/lib/nodes/index.ts Outdated
@sigmachirality sigmachirality self-assigned this Jul 23, 2025
@sigmachirality sigmachirality changed the title feat: implement cli interface for Nodes API alpha feat: [PRODUCT-379] implement cli interface for Nodes API alpha Jul 23, 2025
@sigmachirality sigmachirality added the enhancement New feature or request label Jul 23, 2025
Comment thread src/lib/nodes/create.ts Outdated
Comment thread src/lib/nodes/create.ts Outdated
Copy link
Copy Markdown
Contributor

@joshi4 joshi4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sigmachirality sigmachirality merged commit ead29b7 into main Jul 25, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants