milestones:新增跨倉庫里程碑總覽命令(#31)

- teai milestones(不帶 --repo)輸出跨所屬組織各倉庫 open 里程碑概況,
  對應 gitea.py milestones(管理者巡邏,agents AGENTS.md 10.1):
  欄位 repo/id/title/url/open_issues/closed_issues/due_on/due_hours/
  overdue/unassigned/updated_at,排序期限近者在前、無期限最後。
- internal/workflow.MilestoneOverview:判定核心(Source 注入、離線可測);
  MilestoneEntry 自訂 MarshalJSON,鍵集鍵序與 gitea.py 全等
  (null 表示、due_hours 定點一位、unassigned PR 條目帶 author)。
- internal/workflow.APIClient 增 OpenMilestones/MilestoneOpenIssues
  (issues 端點刻意不帶 type=issues,PR 條目保留供覆蓋檢查,同 gitea.py)。
- milestones --repo a/b 維持現行單倉庫 list 語義不變。
- 空清單輸出 [](gitea.py 無輸出;#26 慣例差異,README 已文件化)。
- 交叉驗證:同帳號同時跑 gitea.py milestones 與 teai milestones,
  含逾期/未到期/無期限里程碑與未分派 issue/PR 條目,輸出位元組全等。
This commit is contained in:
2026-09-10 21:20:19 +08:00
parent fd3b8cbd6b
commit 744e7ad809
7 changed files with 916 additions and 8 deletions
+47 -3
View File
@@ -86,6 +86,8 @@ teai pulls comment --repo <owner>/<repo> --body … --yes <number>
# labels/milestones/releases/repos
teai labels list --repo <owner>/<repo>
teai labels create --repo <owner>/<repo> --name … [--color #RRGGBB] [--description …] --yes
teai milestones # 跨倉庫 open 里程碑總覽(gitea.py milestones 對應;期限近者在前)
teai milestones --repo <owner>/<repo> # 同 milestones list(單倉庫,維持既有語義)
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>
@@ -207,6 +209,47 @@ PR 改帶 `author` 與 `reviewers` 欄位。`reason` 取值:
- issue:`no-assignee`、`assignee-idle`、`no-commenter`、`waiting-outside`、`parent-tracking`
- PR:`no-reviewer`、`author-idle`、`reviewer-idle`、`no-commenter`
### `teai milestones` — 跨倉庫里程碑總覽
```sh
teai milestones # 各倉庫 open 里程碑概況(跨所屬組織;期限近者在前)
teai milestones --output table
```
管理者巡邏用(`gitea.py milestones` 對應,agents AGENTS.md 10.1)。帶 `--repo` 時
維持現行單倉庫 `list` 語義(`teai milestones --repo a/b` = `teai milestones list --repo a/b`)。
每筆欄位(鍵集鍵序與 `gitea.py` 全等,實測位元組一致):
```json
{
"repo": "alterminal/test",
"id": 6,
"title": "xcheck31-ms-overdue",
"url": "https://gitea.alterminal.com/alterminal/test/milestone/6",
"open_issues": 2,
"closed_issues": 0,
"due_on": "2026-09-08T08:00:00+08:00",
"due_hours": 61.3,
"overdue": true,
"unassigned": [
{
"type": "issue",
"number": 14,
"title": "…",
"url": "https://gitea.alterminal.com/alterminal/test/issues/14"
}
],
"updated_at": "2026-09-10T21:17:37+08:00"
}
```
- **排序**:`due_on` 近者在前;無期限者最後(`gitea.py` 的 `(due_on is None, due_on)` 鍵)。
- **`overdue`/`due_hours`**:期限已過為 `true`(`due_hours` 正數);無期限 → `null`。
- **`unassigned`**:該里程碑 open 條目(issue 與 PR)中無 assignee 者的摘要;PR 條目另帶 `author`。
- **`updated_at`**:里程碑本身與其 open 條目 `updated_at` 的最大值(判斷活躍度用)。
- 空輸出 → `[]`(`gitea.py` 無輸出;依 #26 慣例差異)。
### `teai members [--has-work]`
```sh
@@ -266,6 +309,7 @@ teai whoami # 目前帳號(讀 tea 組態)
| --- | --- | --- |
| `next` | `teai next` | 相同:author-PR → reviewer-PR → issue,最久未更新優先 |
| `stalled [--hours N]` | `teai stalled [--hours N]` | 相同,含 xref 父子追蹤與冷卻 |
| `milestones` | `teai milestones` | 相同:跨倉庫 open 里程碑總覽,期限近者在前(#31) |
| `members [--has-work]` | `teai members [--has-work]` | 相同 |
| `pulls`/`pulls --mine`/`pulls --reviewer` | `teai pulls [--mine\|--reviewer]` | 相同 |
| `mine` | `teai mine` | 相同 |
@@ -274,14 +318,14 @@ teai whoami # 目前帳號(讀 tea 組態)
已知輸出差異(刻意保留,機器可讀優先):
- **空清單**:`gitea.py` 的 `_dump` 對空清單**不輸出任何內容**;teai 的清單類命令
(`mine`/`pulls`)空清單輸出 `[]`。對 JSON 消費者來說 `[]` 比「無輸出」更明確,
(`mine`/`pulls`/`milestones` 總覽)空清單輸出 `[]`。對 JSON 消費者來說 `[]` 比「無輸出」更明確,
交叉驗證時以此差異為準。`next` 兩者語義相同(無工作 → `null`/「沒有未完成的工作」)。
- **清單欄位集(`mine`/`pulls`)**:`gitea.py` 直接傾倒完整 Gitea API 物件
(`_dump` 的副作用,欄位集隨 Gitea 版本浮動);teai 輸出策展摘要欄位
(`mine`:repo/number/title/url;`pulls`:number/title/state/author/
head/base/updated_at…依命令定義)。交叉驗證比對**項目集合**(列出哪些
issue/PR)與判定語義,不逐欄位比對;`next`/`stalled` 兩者為策展欄位且
鍵集鍵序全等,可逐欄位比對。判定 #26(維持摘要、文件化差異)。
issue/PR)與判定語義,不逐欄位比對;`next`/`stalled`/`milestones` 總覽
兩者為策展欄位且鍵集鍵序全等,可逐欄位比對(#31 實測位元組一致)。判定 #26(維持摘要、文件化差異)。
- **全域選項位置**:teai 的全域選項(`--output` 等)可出現在命令之前或之後,
且可與命令旗標交錯(`teai members --has-work --output table`);
gitea.py 的旗標剖析較寬鬆,兩者命令列介面以此行為對齊。