feat: add zeabur file list/read commands#231
Conversation
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>
WalkthroughThe changes introduce a new file management feature through CLI subcommands and API client methods. A new Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (6)
internal/cmd/file/file.gointernal/cmd/file/list/list.gointernal/cmd/file/read/read.gointernal/cmd/root/root.gopkg/api/file.gopkg/api/interface.go
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| opts.uploadID = args[0] | ||
| if len(args) > 1 { | ||
| opts.path = args[1] | ||
| } |
There was a problem hiding this comment.
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.
Summary
zeabur file list <upload_id> [path]to list files in an uploadzeabur file read <upload_id> <path>to read file contentFileAPIinterface inpkg/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 directoryzeabur file list <upload_id> src/— lists subdirectoryzeabur file read <upload_id> package.json— reads file content--jsonflag outputs JSON formatCloses DES-536
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
filecommand for managing uploaded filesfile listsubcommand to view files in an upload with optional path filteringfile readsubcommand to read file contents from an upload