Skip to content

feat: add zeabur file list/read commands#231

Closed
leechenghsiu wants to merge 1 commit intomainfrom
feat/file-command
Closed

feat: add zeabur file list/read commands#231
leechenghsiu wants to merge 1 commit intomainfrom
feat/file-command

Conversation

@leechenghsiu
Copy link
Copy Markdown
Contributor

@leechenghsiu leechenghsiu commented Apr 30, 2026

Summary

  • Add zeabur file list <upload_id> [path] to list files in an upload
  • Add zeabur file read <upload_id> <path> to read file content
  • New FileAPI interface in pkg/api/ with GraphQL queries (files() / fileContent())

This enables the skilled agent to access user-uploaded project files via CLI (bash + skill), instead of requiring SDK tools.

Test plan

  • zeabur file list <upload_id> — lists root directory
  • zeabur file list <upload_id> src/ — lists subdirectory
  • zeabur file read <upload_id> package.json — reads file content
  • --json flag outputs JSON format
  • Tested with real upload IDs against production API

Closes DES-536

🤖 Generated with Claude Code

Summary by CodeRabbit

New Features

  • Added file command for managing uploaded files
  • Added file list subcommand to view files in an upload with optional path filtering
  • Added file read subcommand to read file contents from an upload
  • Both commands support JSON output format for programmatic use

Allow reading uploaded project files via CLI, enabling the skilled agent
to access user uploads through bash + skill instead of SDK tools.

- `zeabur file list <upload_id> [path]` — list files in an upload
- `zeabur file read <upload_id> <path>` — read file content

DES-536

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Walkthrough

The changes introduce a new file management feature through CLI subcommands and API client methods. A new file command with list and read subcommands is added to the root CLI, wired through command factories. Corresponding API client methods implement GraphQL queries to list and read uploaded files, with a new FileAPI interface defining the contract.

Changes

Cohort / File(s) Summary
File Management CLI Commands
internal/cmd/file/file.go, internal/cmd/file/list/list.go, internal/cmd/file/read/read.go, internal/cmd/root/root.go
Added new file command hierarchy with list (alias ls) and read subcommands for managing uploaded files. List subcommand accepts upload ID and optional path, outputs files in JSON or text format. Read subcommand fetches file content from a specified upload and path. Root command wired to include the new file command.
API Client Layer
pkg/api/file.go, pkg/api/interface.go
Added ListUploadFiles and ReadUploadFile client methods to execute GraphQL queries. Created new FileAPI interface defining these methods and embedded it in the Client interface for structured API organization.

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as File Command
    participant API as API Client
    participant GQL as GraphQL Backend

    rect rgba(100, 200, 150, 0.5)
    Note over User,GQL: List Files Flow
    User->>CLI: zeabur file list <upload-id> [path]
    CLI->>API: ListUploadFiles(uploadID, path)
    API->>GQL: Query: listUploadFiles(uploadID, path)
    GQL-->>API: [file paths] or error
    API-->>CLI: []string or error
    CLI->>User: JSON output or text list
    end

    rect rgba(150, 150, 200, 0.5)
    Note over User,GQL: Read File Flow
    User->>CLI: zeabur file read <upload-id> <path>
    CLI->>API: ReadUploadFile(uploadID, path)
    API->>GQL: Query: readUploadFile(uploadID, path)
    GQL-->>API: file content string or error
    API-->>CLI: content string or error
    CLI->>User: JSON output or raw content
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add zeabur file list/read commands' directly and clearly summarizes the main changes—adding two new CLI commands for file management, which is the primary focus of this changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/file-command

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/cmd/file/list/list.go`:
- Around line 25-29: The RunE handler currently only sets opts.path when a
second arg is provided, allowing a previous opts.path to leak into later
invocations; modify the RunE function in list.go so that after setting
opts.uploadID it explicitly clears or sets opts.path to an empty string when
len(args) <= 1 (i.e., reset opts.path on runs without a second arg) to avoid
stale state across command invocations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 597151d4-97ee-4c9e-a64e-fc5625eaa390

📥 Commits

Reviewing files that changed from the base of the PR and between bcb65be and f6f3f30.

📒 Files selected for processing (6)
  • internal/cmd/file/file.go
  • internal/cmd/file/list/list.go
  • internal/cmd/file/read/read.go
  • internal/cmd/root/root.go
  • pkg/api/file.go
  • pkg/api/interface.go

Comment on lines +25 to +29
RunE: func(cmd *cobra.Command, args []string) error {
opts.uploadID = args[0]
if len(args) > 1 {
opts.path = args[1]
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reset optional path on runs without a second arg to avoid stale state.

Line 27-29 only assigns opts.path when [path] is provided. Because opts is reused across invocations, a prior value can leak into a subsequent list <upload-id> call.

Proposed fix
 func NewCmdList(f *cmdutil.Factory) *cobra.Command {
-	opts := &Options{}
-
 	cmd := &cobra.Command{
 		Use:     "list <upload-id> [path]",
 		Short:   "List files in an upload",
 		Aliases: []string{"ls"},
 		Args:    cobra.RangeArgs(1, 2),
 		RunE: func(cmd *cobra.Command, args []string) error {
-			opts.uploadID = args[0]
+			opts := &Options{uploadID: args[0]}
 			if len(args) > 1 {
 				opts.path = args[1]
 			}
 			return runList(f, opts)
 		},
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/cmd/file/list/list.go` around lines 25 - 29, The RunE handler
currently only sets opts.path when a second arg is provided, allowing a previous
opts.path to leak into later invocations; modify the RunE function in list.go so
that after setting opts.uploadID it explicitly clears or sets opts.path to an
empty string when len(args) <= 1 (i.e., reset opts.path on runs without a second
arg) to avoid stale state across command invocations.

@leechenghsiu leechenghsiu deleted the feat/file-command branch April 30, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant