Skip to content

feat(cli): 支持远端文件列表 / add remote file listing - #484

Open
Jinghao-coding wants to merge 1 commit into
raids-lab:mainfrom
Jinghao-coding:codex/issue-479-file-list
Open

feat(cli): 支持远端文件列表 / add remote file listing#484
Jinghao-coding wants to merge 1 commit into
raids-lab:mainfrom
Jinghao-coding:codex/issue-479-file-list

Conversation

@Jinghao-coding

Copy link
Copy Markdown
Member

中文

说明

为普通用户新增 crater file ls [remote-path],用于浏览 userpublic 和当前 account 的远端文件空间。

实现内容

  • 新增顶层 file 名词命令及 file ls
  • 使用 typed API client 调用 GET /api/ss/files[/<path>]
  • 安全规范化逻辑路径,拒绝任何 ..、反斜杠和控制字符。
  • 按 URL segment 编码空格、中文、#% 等字符。
  • 目录优先、名称稳定排序;空响应 null 规范化为 []
  • 人类输出展示名称、类型、字节数和修改时间;JSON 仅返回稳定字段,不透传 sys
  • 补齐中英文 i18n、命令契约、File Skill、静态根路径补全、单元测试和双语快照。
  • 同步修正 feat(job): add server-side pagination for Volcano job lists #446 分页落地后遗留的两处 Job 快照 URL 基线。

验证

  • go test ./cmd ./internal/api -count=1
  • make snapshot-update,已人工检查新增/变化 golden
  • make pre-commit-check
  • make build
  • go vet ./cmd ./internal/api
  • 直接运行 ./crater file --help
  • 直接运行 ./crater file ls 'user/../public' --json --no-interactive,确认本地拒绝越界路径并返回退出码 2
  • httptest 精确验证根/嵌套路由、逐段 URL 编码、空列表和 API 错误保留

真实 storage service 未在本机 8088 入口提供,因此未把真实服务联调结果冒充为通过;HTTP 协议和命令行为由确定性的单元/快照测试覆盖。

测试截图

Issue 479 CLI test evidence

Closes #479


English

Summary

Adds crater file ls [remote-path] for ordinary users to browse remote files in user, public, and the current account storage spaces.

Changes

  • Adds the top-level file noun and file ls command.
  • Uses a typed API client for GET /api/ss/files[/<path>].
  • Safely normalizes logical paths and rejects every .. segment, backslash, and control character.
  • Escapes each URL segment so spaces, non-ASCII names, #, and % are preserved.
  • Sorts directories first and names deterministically; normalizes a null list to [].
  • Prints name, type, byte size, and modification time for humans; JSON exposes only stable fields and omits sys.
  • Adds bilingual i18n, command contract documentation, a File Skill, static root completion, unit tests, and bilingual snapshots.
  • Also refreshes the two stale Job snapshot URLs left by the feat(job): add server-side pagination for Volcano job lists #446 pagination change.

Validation

  • go test ./cmd ./internal/api -count=1
  • make snapshot-update, followed by manual golden review
  • make pre-commit-check
  • make build
  • go vet ./cmd ./internal/api
  • Direct ./crater file --help execution
  • Direct ./crater file ls 'user/../public' --json --no-interactive execution, confirming local traversal rejection and exit code 2
  • Deterministic httptest coverage for root/nested routes, segment encoding, empty lists, and API error preservation

The real storage service is not exposed through the local port 8088, so this PR does not claim a live storage integration result. HTTP contracts and command behavior are covered by deterministic unit and snapshot tests.

Test screenshot

Issue 479 CLI test evidence

Copilot AI review requested due to automatic review settings July 25, 2026 18:01

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Jinghao-coding
Jinghao-coding force-pushed the codex/issue-479-file-list branch from 6be9ef7 to 2d7d36a Compare July 28, 2026 14:34
@Jinghao-coding
Jinghao-coding force-pushed the codex/issue-479-file-list branch from 2d7d36a to 83120db Compare July 30, 2026 07:25
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.

feat(cli): 支持远端文件列表 / add remote file listing

2 participants