Skip to content

feat(bitable): add Bitable (Base) support#47

Merged
riba2534 merged 4 commits intoriba2534:mainfrom
flyinghanger:feat/bitable
Mar 25, 2026
Merged

feat(bitable): add Bitable (Base) support#47
riba2534 merged 4 commits intoriba2534:mainfrom
flyinghanger:feat/bitable

Conversation

@flyinghanger
Copy link
Copy Markdown
Contributor

@flyinghanger flyinghanger commented Mar 21, 2026

Summary

  • Add full CRUD support for Feishu Bitable (multi-dimensional tables) with 19 CLI subcommands
  • New API client (internal/client/bitable.go) with 24 public functions covering app/table/field/record/view operations
  • New Claude Code skill (skills/feishu-cli-bitable/) with practical pitfall guide from production usage

Commands added

Category Commands
App bitable create, bitable get
Table tables, create-table, delete-table, rename-table
Field fields, create-field, update-field, delete-field
Record records, get-record, add-record, add-records, update-record, delete-records
View views, create-view, delete-view

Alias: feishu-cli base = feishu-cli bitable

Pitfalls documented in skill

  1. PUT fields on SingleSelect clears options without full property
  2. New bases have ~10 empty default rows
  3. API-created bases are invisible until permissions added
  4. Primary index field rename requires type parameter
  5. Checkbox → use SingleSelect instead
  6. Link fields: one column = one linked table

Test plan

  • go build and go vet pass (verified locally)
  • feishu-cli bitable --help shows all subcommands
  • Create a bitable, add fields, insert records, query with filter
  • Batch create/delete records
  • View creation (grid, kanban)
  • Permission integration: feishu-cli perm add <token> --doc-type bitable

🤖 Generated with Claude Code

flyinghanger and others added 3 commits March 21, 2026 15:57
Add full CRUD support for Feishu Bitable (multi-dimensional tables),
including app management, table/field/record/view operations.

New files:
- internal/client/bitable.go: API client with 24 public functions
- cmd/bitable*.go: 19 subcommands (create, tables, fields, records, views, etc.)
- skills/feishu-cli-bitable/SKILL.md: Claude Code skill with pitfall guide

Key features:
- Create/get bitable apps
- Table CRUD (create, delete, rename)
- Field CRUD with type mapping (text, number, select, date, etc.)
- Record operations: single/batch create, update, delete, search with filter/sort
- View management (grid, kanban, gallery, gantt, form)
- Alias support: `feishu-cli base` = `feishu-cli bitable`

The skill includes practical pitfalls from production usage:
- PUT fields on SingleSelect clears options without full property
- New bases have ~10 empty default rows to clean up
- API-created bases are invisible until permissions are added
- Primary index field rename requires type parameter

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix BitableFieldDesc to handle both string and object formats from API
- Add owner_email and transfer_ownership config options
- Add `config get` command for reading config values (with secret masking)
- Update CLAUDE.md and bitable skill with ownership transfer workflow

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

@riba2534 riba2534 left a comment

Choose a reason for hiding this comment

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

Review: 功能完整且质量不错,修复几个问题后可合并

非常好的 PR!多维表格的 19 个子命令覆盖了核心 CRUD 场景,SKILL.md 的踩坑指南也很实用。以下几个问题修复后即可合并:

Warning(需修复)

  1. 分页未处理ListBitableTablesListBitableFieldsinternal/client/bitable.go:170)只请求一次 API,不处理 has_more/page_token。当多维表格有大量数据表或字段时结果会被截断。对比同文件 SearchBitableRecordsListBitableViews 都已正确处理分页。建议至少暴露 pageSize/pageToken 参数,或自动循环获取所有页。

  2. 必填参数未校验add-record--fieldscreate-field--field 未标记必填(cmd/bitable_record.go:155)。用户不提供时 json.Unmarshal("") 报错为 unexpected end of JSON input,不如直接提示缺少参数。建议添加 mustMarkFlagRequired 或在 RunE 开头检查空值。

  3. config get 报错owner_emailtransfer_ownership 没有调用 viper.SetDefault(),执行 config get owner_emailviper.IsSet() 返回 false,导致报"未知的配置项"。请在 config/config.goInit 函数中补充默认值。

  4. 死代码BatchUpdateBitableRecordsinternal/client/bitable.go:458)已实现但无对应 CLI 命令。建议二选一:

    • 补充 bitable update-records 命令(与 add-records/delete-records 对称)
    • 移除该函数,后续需要时再添加

Suggestion(可选优化)

  1. 所有 20+ 个函数中 tokenType/opts 初始化代码重复(约 5 行/函数),建议抽取辅助函数 resolveTokenOpts() 减少约 100 行重复。

  2. views 命令丢弃了分页 token(cmd/bitable_view.go:52),对比 records 命令已支持 --page-size/--page-token,建议保持一致。


整体质量很好,修复以上 4 个 warning 后即可合并。

@flyinghanger
Copy link
Copy Markdown
Contributor Author

已按 review 完成修复,最新提交:ceea98f (fix(bitable): address review feedback)。

本次处理内容:

  • ListBitableTables / ListBitableFields 补齐自动分页,避免结果截断
  • add-record / create-field 补必填参数校验,缺参时直接提示,不再落到 json.Unmarshal("")
  • config get owner_email / config get transfer_ownership 补默认值,已可正常读取
  • BatchUpdateBitableRecords 已接成 CLI 命令 bitable update-records
  • 抽取 resolveTokenOpts(),去掉 bitable client 中重复的 token 初始化逻辑
  • views 命令补 --page-size / --page-token,并返回分页 token

验证情况:

  • go test ./... 通过
  • go vet ./... 通过
  • 已在本地用真实 Feishu API 做了一轮联调,验证了:
    • config get 不再报未知配置项
    • add-record / create-field 缺参时报错友好
    • update-records 可真实更新记录
    • views --page-size 1 能返回 has_morepage_token
    • tables / fields 在创建超过单页数量的数据后,能返回完整结果

请继续审查。

riba2534 added a commit that referenced this pull request Mar 25, 2026
… bitable feature

Remove non-bitable changes from PR #47:
- Delete cmd/config_get.go (config get subcommand)
- Remove OwnerEmail and TransferOwnership fields from Config struct
- Remove related viper defaults, env bindings, and config template entries
- Remove TestInit_ConfigDefaultsExposedToViper test
- Revert CLAUDE.md permission section to main branch version
- Clean owner_email/transfer_ownership references from bitable SKILL.md
@riba2534 riba2534 merged commit 08c396c into riba2534:main Mar 25, 2026
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.

2 participants