feat:新增 organizations 指令(#45)

tea organizations 對等的日常操作:
- organizations list:GET /user/orgs,輸出 name/full_name/website/
  location/description/visibility(與 teai orgs 工作流命令同一
  端點,但輸出完整欄位)
- organizations create:POST /orgs,--name 必填,可選 --full-name/
  --description/--website/--location/--visibility;寫入需 --yes
- organizations delete:DELETE /orgs/{org},組織名為位置參數
  (tea 相容);寫入需 --yes

驗收測試涵蓋端點、payload、--yes 閘門(未確認不發請求)與
值域檢查;並以本機建置對 Gitea 實測 list 輸出欄位與 tea 一致。
This commit is contained in:
ceo
2026-09-13 19:32:34 +08:00
parent d45a8243c8
commit 8d446ed62b
4 changed files with 370 additions and 3 deletions
+7 -2
View File
@@ -88,7 +88,7 @@ teai whoami # 驗證:應輸出 {"username":"<你的帳號>"}
### 日常操作(tea 對等指令;#3 不避開 tea 已有功能;#8 已實作)
issues/pulls/labels/milestones/releases/repos/api 的日常操作,自行實作、輸出一致 JSON、共用同一套認證與全域選項。介面語義以 `tea`/Gitea API 為相容參考。已實作:
issues/pulls/labels/milestones/releases/repos/organizations/api 的日常操作,自行實作、輸出一致 JSON、共用同一套認證與全域選項。介面語義以 `tea`/Gitea API 為相容參考。已實作:
```sh
# issues
@@ -117,11 +117,15 @@ teai milestones list --repo <owner>/<repo> [--state open|closed|all]
teai milestones create --repo <owner>/<repo> --title … [--description …] [--due RFC3339] --yes
teai releases list --repo <owner>/<repo>
teai repos list [--org <org>]
# 組織管理(tea organizations 對等;#45)
teai organizations list # 列出自己可存取的組織(GET /user/orgs)
teai organizations create --name <org> [--full-name …] [--description …] [--website …] [--location …] [--visibility public|limited|private] --yes
teai organizations delete <org> --yes # 刪除組織(不可逆;DELETE /orgs/{org})
# 任意 API 呼叫(逃生口)
teai api <path> [--method GET|POST|PATCH|DELETE] [--data '<json>'] [--yes]
```
> `--yes` 閘門:所有寫入類命令(create/close/comment/merge/approve/labels create/milestones create/api 非 GET 動詞)未帶 `--yes` 時回 exit 2(用法錯誤),且不發出任何 HTTP 請求。
> `--yes` 閘門:所有寫入類命令(create/close/comment/merge/approve/labels create/milestones create/organizations create/delete/api 非 GET 動詞)未帶 `--yes` 時回 exit 2(用法錯誤),且不發出任何 HTTP 請求。
> `teai api` 的 path 內含查詢字串(如 `/repos/a/b/issues?state=closed`)時會正確傳遞。
> `teai pulls checkout` 是本機唯讀輔助:同倉庫 head 在 `--dir`(預設當前目錄)的既有工作樹 `git fetch origin <ref> && git checkout -B <ref> FETCH_HEAD`;跨倉庫 head 需 `--dir`(新目錄)執行 `git clone --branch <ref> <clone_url>`。teai 不代管 git 認證,私有倉庫請自備 credential helper。
@@ -146,6 +150,7 @@ teai [全域選項] <命令> [參數]
| `teai login list\|add\|default\|remove` | — | 管理 tea 相容登入組態(見下) |
| `teai whoami` | `get_current_username` | 目前帳號 |
| `teai orgs` | `for_all_organizations` | 我所屬的組織 |
| `teai organizations list\|create\|delete` | — | 組織管理(tea 對等日常操作;`orgs` 是工作流精簡版) |
| `teai members [--has-work]` | `members [--has-work]` | Agents 團隊成員;`--has-work` 只列有未完成工作者 |
| `teai mine` | `mine` | 分派給我、待跟進的 issues |
| `teai pulls [--mine\|--reviewer] [--repo <owner>/<repo>]` | `pulls` 系列 | 跨倉庫 PR 跟進清單 |