Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a3802c4b7 | |||
| 09769a0dd1 | |||
| 3bc2147e36 | |||
| 6047dff71b | |||
| 147fdb1482 | |||
| ef11871ba4 | |||
| 7b5a6450df | |||
| 2bbcda2ac3 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "isep",
|
||||
"description": "InkStone Environment Plugin —— leo 的 Claude Code 環境唯一真相源:62 支機械閘(88 條註冊,白話盤點見 docs/hooks-inventory.md)、7 支 slash command、2 支 skill、8 位有名字的工人(agents/,見 docs/governance/worker-roster.md)、65 支腳本,外加治理規範與標籤真相源。本機與雲端裝同一份,沒有子集。",
|
||||
"version": "0.30.6",
|
||||
"version": "0.30.10",
|
||||
"keywords": [
|
||||
"inkstone",
|
||||
"guardrails",
|
||||
|
||||
+53
-2
@@ -429,11 +429,11 @@ bash hooks/tests/gitea-arm-check.test.sh .
|
||||
- ①③⑤⑥ 任一紅 ⇒ 收手收得太晚,暫存區已經開始長東西(磁碟風險回來了)
|
||||
- ② 紅 ⇒ 訊息沒給出走得通的那一行(本票整張票在講的就是這件事)
|
||||
- ⑧⑨⑩ 任一紅 ⇒ **誤攔/複製錯**:正常用法被弄壞,或複本裡混進了 `hooks/` 以外的東西
|
||||
### A31 — 雲端工人抓票的規則是機械可判的:80 條
|
||||
### A31 — 雲端工人抓票的規則是機械可判的:84 條
|
||||
```
|
||||
bash scripts/test-ticket-pick.sh
|
||||
```
|
||||
**該看到**:`通過 80 條,失敗 0 條`。**全程離線**:假池子(5 個 repo、3 個 open milestone、
|
||||
**該看到**:`通過 84 條,失敗 0 條`。**全程離線**:假池子(5 個 repo、3 個 open milestone、
|
||||
52 張票、1 條相依邊;`big` 那個 repo 的假伺服器每頁只給 30 張,驗分頁)餵給換掉的 `api()`,時鐘走 `ISEP_COUNTDOWN_NOW`,`TICKET_HOST` 指到連不上的位址
|
||||
——任何一條真的走到網路會當場炸,不會靜靜變成假綠。**不開票、不改票、不留任何東西在 Gitea 上。**
|
||||
|
||||
@@ -473,6 +473,8 @@ Gitea 主線里程碑抓票(`inkstone/InkStoneCo#118`),但那是一段給
|
||||
- ②「沒帶 --pool → 票池一通都沒讀」紅 ⇒ **誤攔**:本機總管跑過 `handback` 後每次收工都會被佇列閘點名去抓票池
|
||||
- ⑤「可抓 0 張時列理由表、不說正常」紅 ⇒ 「0 張」又被說成正常收工(c7797)
|
||||
- ⑤「分頁」紅 ⇒ 伺服器每頁上限比 50 小時,第二頁之後的票看不到
|
||||
- ⑤「票池抓盡、還有沒 s/* 的票 → 回待分診那張,下一步是 triage」紅 ⇒ 沒驗傷的票又沉默地消失在「可抓 0 張」後面(`inkstone/ISEP#159`;A43 測分診本身)
|
||||
- ⑤「pick --claim 遇到待分診 → 不認領」紅 ⇒ 會對一張還沒決定要不要做的票寫 s/doing
|
||||
|
||||
📌 **真實 Gitea 唯讀實跑**(2026-09-07,isep-hand,不改任何票):
|
||||
`ticket pick --mainline InkStoneCo/system-dev/mainline.json --all` 在主線
|
||||
@@ -483,6 +485,55 @@ Gitea 主線里程碑抓票(`inkstone/InkStoneCo#118`),但那是一段給
|
||||
assignee=`claude-code`、標籤 `s/todo → s/doing`、留言 6325 第一行【身份】——
|
||||
之後再 `pick` 就不再回 #131(票上驗收第 2 條的 log 在票的留言裡)。
|
||||
|
||||
### A43 — 雲端工人會分診、會組里程碑,而且碰不到 leo 的票:80 條
|
||||
```
|
||||
bash scripts/test-ticket-triage.sh
|
||||
bash hooks/tests/queue-drain-guard.test.sh # 28 條:待分診那一列,閘印 triage 不印 claim
|
||||
```
|
||||
**該看到**:`通過 80 條,失敗 0 條`、`通過 28 條,失敗 0 條`。**全程離線**(形狀同 A31:假池子 3 個 repo、
|
||||
3 個 open 里程碑、1 張載體帶 3 條相依;時鐘定在 2026-09-18;`TICKET_HOST` 連不上)。
|
||||
|
||||
**它在守什麼**(`inkstone/ISEP#159`):leo 09-18「我有快 500 個票⋯⋯它看到票時要能夠組成 milestone 提出版本,
|
||||
所以不只是看票,還要組票」。當天實量 open 302 張、沒 s/* 的 74 張、沒掛里程碑的 257 張;雲端只會撿(A31),不會組。
|
||||
哪張跟哪張重複、哪幾張該一起出版——是**讀票的人的判斷**;這一支守的是判斷寫回 Gitea 的那一步:
|
||||
|
||||
```
|
||||
triage 沒有 s/* 的票 → s/backlog|s/triage|s/pending + 票上一則說明(--why 必填),一個動作
|
||||
--dup-of <票> → 說明+close/duplicate+關+在留下的那張留一則指回來
|
||||
compose --title --goal --due --carrier inkstone/InkStoneCo#N <前置…>
|
||||
建在 InkStoneCo、掛在既有載體、前置掛成相依、s/backlog → s/todo,不開任何新票
|
||||
先全部讀過才寫第一筆;驗不過一次列出全部理由
|
||||
pick --pool 時:還沒到期的 InkStoneCo 里程碑的前置 → 排在散票之前(組了就照里程碑做)
|
||||
可做的都抓盡 → 回一張待分診的(row 帶 next=triage 那一行,佇列閘照它印)
|
||||
不碰 掛 Human/human/*、指派給別人(含 Leo)——判準是標籤與 assignee 登入名,不看文字
|
||||
```
|
||||
|
||||
**失敗**:
|
||||
- ①「掛 Human/指派 Leo → 不碰」任一紅,或 ②③ 裡「驗收 3」那幾條紅 ⇒ **會寫 leo 的票**(驗收 3 破了)
|
||||
- ②「重複的對象是 Leo 的票 → 不在它上面寫字」紅 ⇒ 關重複票時順手在 leo 的票上留言
|
||||
- ②「寫入恰好是 [留言, 改標籤]」紅 ⇒ 改了欄位卻沒留說明(驗收 1:每張被動過的票都說得出分到哪、為什麼)
|
||||
- ②「--to s/todo 擋」紅 ⇒ 沒排進里程碑的票被標成「已排進里程碑」
|
||||
- ③「好幾格不對時一次列齊」紅 ⇒ 改一格撞一次——閘在懲罰人
|
||||
- ③「名字是版本號/沒期限/9999/過去」任一紅 ⇒ 開工規約第 5、6 條破了
|
||||
- ③「載體不在 InkStoneCo」紅 ⇒ 開工規約第 7 條破了(在子 repo 建里程碑)
|
||||
- ③「前置已是別的里程碑載體的前置」/「載體是別一輪的前置」紅 ⇒ 一張票同時排進兩輪
|
||||
- ③「不開任何新票」紅 ⇒ 開工規約第 2 條破了
|
||||
- ④「里程碑那一組排在票池之前」紅 ⇒ 組了里程碑,工人還是照開票時間撿散票
|
||||
- ④「沒帶 --pool → 不看、不回待分診」紅 ⇒ **誤攔**:本機總管收工時被佇列閘叫去分診
|
||||
- ④「載體票本身不當成可做的票」紅 ⇒ 工人會去「做」一張容器票
|
||||
|
||||
📌 **真實 Gitea 實跑**(2026-09-18,isep-hand 用本分支代跑一趟,署名 `[isep-hand]`):
|
||||
- 分診前 `triage --list`:待分診 72 張 → 分診 4 張後 67 張(總數同時受別條線影響;我動的 4 張讀回皆對)
|
||||
- `Arcrun#188` → 與 `Arcrun#143` 重複:`close/duplicate`、已關,#143 上有指回來的留言
|
||||
- `Arcrun#131` → `s/triage`(與 #143 同一件事,兩張留哪張交總管)
|
||||
- `ISEP#47`、`arcrun-rag#199` → `s/backlog`,各有一則說明
|
||||
- 組里程碑:`ticket where` 撈不到能載這一輪的 InkStoneCo User Story ⇒ 補一張載體 `InkStoneCo#136`,
|
||||
`compose` 建出 InkStoneCo milestone 68「金鑰不再出現在任何畫面與 log 裡」(期限 09-25):
|
||||
載體掛上、`ISEP#47`/`arcrun-rag#199` 成為相依並 `s/backlog → s/todo`、三張各一則說明
|
||||
- `pick --pool --all`(主線 #65):第一組就是這個里程碑的兩張前置,之後票池 101 張、待分診 67 張
|
||||
- 真的擋:`compose --carrier InkStoneCo#134 ISEP#47 Arcrun#143` → 離開碼 2、一筆都沒寫,三個理由一次列出
|
||||
(#134 已是主線載體 #55 的前置/#47 已排進 milestone 68/#143 還沒分診)
|
||||
|
||||
### A19 — 下游做完時頂層跟著關:49 條
|
||||
```
|
||||
bash scripts/test-ticket-handoff-writeback.sh
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# 雲端環境(claude.ai Cloud environment)變數清單的版本紀錄——**只記名字,不記值**。
|
||||
# leo 2026-09-18:「你這裡記錄每版的 credential 的 key,但 value 自動產生,我就貼上去,你要有版本,因為這件事做了很多次,但你都沒記錄版本」
|
||||
# 產生器 scripts/make-cloud-env.sh 讀本檔最後一版的號碼印在產物檔頭,並列出與前一版的差異。
|
||||
# 欄位:版本<TAB>日期<TAB>key(逗號分隔,順序=NEEDED)<TAB>為什麼變
|
||||
v1 2026-08-20 GITEA_TOKEN_CLAUDE_CODE 首版:雲端 bootstrap 與 plugin 安裝(f855d82)
|
||||
v2 2026-09-01 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE 雲端拿得到 youlin 的 CF token(ISEP#115 c5526,ca9ea99)
|
||||
v3 2026-09-01 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE,CLOUDFLARE_ACCOUNT_ID_YOULIN,YOULIN_MCP_OWNER_SECRETS,STAGE_USERNAME_YOULIN,STAGE_PASSWORD_YOULIN,CLOUDFLARE_API_TOKEN_CC_SHIPPING_CORE,CLOUDFLARE_ACCOUNT_ID_GEEK6688 leo「youlin 和 geek6688 都全給」(ISEP#115 c5541/5542,7aef943)
|
||||
v4 2026-09-01 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE,CLOUDFLARE_ACCOUNT_ID_YOULIN,YOULIN_MCP_OWNER_SECRETS,STAGE_USERNAME_YOULIN,STAGE_PASSWORD_YOULIN,CLOUDFLARE_API_TOKEN_CC_SHIPPING_CORE,CLOUDFLARE_ACCOUNT_ID_GEEK6688,UNCLE6_CF_API_KEY 出貨三站實際部署到 uncle6(ISEP#115 c5577,cb310e9)
|
||||
v5 2026-09-01 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE,CLOUDFLARE_ACCOUNT_ID_YOULIN,YOULIN_MCP_OWNER_SECRETS,STAGE_USERNAME_YOULIN,STAGE_PASSWORD_YOULIN,CLOUDFLARE_API_TOKEN_CC_SHIPPING_CORE,CLOUDFLARE_ACCOUNT_ID_GEEK6688,UNCLE6_CF_API_KEY,ARCRUN_NS_YOULIN 出貨線實例座標(Arcrun#195,dd86fef/v0.21.0)
|
||||
v6 2026-09-18 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE,CLOUDFLARE_ACCOUNT_ID_YOULIN,YOULIN_MCP_OWNER_SECRETS,STAGE_USERNAME_YOULIN,STAGE_PASSWORD_YOULIN,CLOUDFLARE_API_TOKEN_CC_SHIPPING_CORE,CLOUDFLARE_ACCOUNT_ID_GEEK6688,UNCLE6_CF_API_KEY,ARCRUN_NS_YOULIN,ARCRUN_NS_UNCLE6,GITHUB_MIRROR_TOKEN,GITHUB_ACCOUNT_NAME 雲端要能出 stage/prod:uncle6 namespace+GitHub 鏡像兩把(InkStoneCo#98 c7739;ISEP#158)
|
||||
v7 2026-09-18 GITEA_TOKEN_CLAUDE_CODE,CLOUDFLARE_API_TOKEN_YOULIN_CC_USE,CLOUDFLARE_ACCOUNT_ID_YOULIN,YOULIN_MCP_OWNER_SECRETS,STAGE_USERNAME_YOULIN,STAGE_PASSWORD_YOULIN,CLOUDFLARE_API_TOKEN_CC_SHIPPING_CORE,CLOUDFLARE_ACCOUNT_ID_GEEK6688,UNCLE6_CF_API_KEY,ARCRUN_NS_YOULIN,ARCRUN_NS_UNCLE6,GITHUB_MIRROR_TOKEN,GITHUB_ACCOUNT_NAME,TELEGRAM_CHAT_ID,TELEGRAM_BOT_TOKEN,ISEP_DRAIN 收回雲端現行卻不在 v1–v6 的三個:TELEGRAM_CHAT_ID/TELEGRAM_BOT_TOKEN(通知出口,值在 polaris/mira/.env,點名放行)+ISEP_DRAIN=1 固定值(leo 09-18 貼出現行雲端環境才發現漏收)
|
||||
|
@@ -206,6 +206,29 @@ $ curl … https://git.uncle6.me/api/v1/version → 200
|
||||
其餘(讀票、認領、留言、handback、寫 code、跑測試、開 PR、對 leo21c 唯讀查詢、發 Telegram、**種 secret/直推成品/POST 到 stage 實例**——走 `scripts/stage` 與 Arcrun 的 `stage-deploy-artifacts.py`)雲端全做。
|
||||
📌 這份清單的家是 `inkstone/InkStoneCo` 的 `cloud-worker.md`(票上驗收第 4 條),ISEP 只放草稿;併進去由總管做。
|
||||
|
||||
## 雲端工人不只撿票,還要分診、組里程碑(inkstone/ISEP#159,給 `cloud-worker.md` 的草稿)
|
||||
|
||||
leo 09-18:「它看到票時要能夠組成 milestone 提出版本,所以不只是看票,還要組票。」
|
||||
ISEP 這一半是 `scripts/ticket` 的 `triage`/`compose` 兩個動詞,與 `pick --pool` 多的兩層(見 `docs/TESTING.md` A43)。
|
||||
`cloud-worker.md` 現在寫著「🚫 不開里程碑、不改里程碑⋯⋯」——那一條要換成下面這段(**併進 InkStoneCo 由總管做**):
|
||||
|
||||
```
|
||||
1. 分診:`ticket triage --list`(找重複用 `--all`)。每張沒 s/* 的票讀過之後擇一:
|
||||
ticket triage <票> --to s/backlog --why "…" 決定要做
|
||||
ticket triage <票> --to s/triage --why "…" 要總管/leo 判斷(方向、品味、要不要做)
|
||||
ticket triage <票> --to s/pending --why "…" 在等外部
|
||||
ticket triage <票> --dup-of <留下的那張> --why "…" 重複(關新的、留舊的)
|
||||
都帶 `--name <ISEP 工人名> --sign cloud-worker`。掛 Human/指派 Leo 的票工具會擋,不必自己判。
|
||||
2. 組里程碑:已分診、彼此相關、做完能出一個可測版本的幾張 ⇒
|
||||
ticket compose --title "<這一輪要讓什麼變成真的>" --goal "…" --due <1–60 天內>
|
||||
--carrier inkstone/InkStoneCo#N <前置票…> --name … --sign cloud-worker
|
||||
載體=既有的 InkStoneCo User Story;`ticket where` 撈不到能載這一輪的 ⇒ 先 `ticket new InkStoneCo` 補一張 US 當載體
|
||||
(開工規約第 2 條:撈不到才是真缺口)。一張票同時只排一輪,工具會擋。
|
||||
3. 取票:`ticket pick`(ISEP_DRAIN=1 ⇒ 自帶 --pool)。組好的里程碑的前置排在散票之前;
|
||||
可做的都抓盡時它回一張待分診的,下一步就是它印的那行 triage。
|
||||
收工條件不變:`ticket pick` 回離開碼 1。
|
||||
```
|
||||
|
||||
## 這張票沒動、也不會動的東西
|
||||
|
||||
- 沒有動 `youlinhsieh/inkstoneco`(GitHub 薄殼 repo)——這個新機制**完全不需要
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
其中 **3 支檔案存在但沒被掛上**(2 支是待人填的空範本、1 支是刻意留著沒開的止血帶,見下面「未生效」表)。
|
||||
下面按「你會在什麼時候撞到它」分組,一支一行。
|
||||
|
||||
> 📌 **`inkstone/ISEP#159`(2026-09-18,待總管定版)+0 支、+0 條、腳本 65→66**:沒加閘。`scripts/ticket` 多兩個動詞
|
||||
> `triage`(沒 s/* 的票給狀態+留說明,或當重複關掉並指回去)與 `compose`(把已分診的票組成 InkStoneCo 里程碑:載體+前置,
|
||||
> 先全部驗過才寫);`pick --pool` 多兩層(還沒到期的 InkStoneCo 里程碑的前置、最後是待分診的票),每一列帶 `next`。
|
||||
> `queue-drain-guard.sh` 改判準不加閘:照 pick 那一列的 `next` 印下一步(待分診的票下一步是 triage,不是 claim)。
|
||||
> `scripts/` +1:`test-ticket-triage.sh`。
|
||||
> **62 支、88 條、66 支腳本是在這棵樹上當場數出來的**(`ls hooks/*.sh | wc -l`=62、
|
||||
> `grep -c '"command":' hooks/hooks.json`=88、`ls -p scripts | grep -v / | wc -l`=66)。
|
||||
|
||||
> 📌 **`inkstone/ISEP#153`(2026-09-13,待總管定版)+0 支、+1 條**:`baton-handback-guard.sh` 多掛一條 `Stop`。
|
||||
> 背景派工時 `PostToolUse:Agent` 在工人**剛出發**就觸發,舊版當場念「收工了但棒子沒交回來」(09-13 對 ISEP#150、arcrun-rag#14 各一次,工人其實還要跑 17 分鐘)。
|
||||
> 現在送出那一刻看到 launch ack 就不查;工人交件(主對話收到 `<task-notification>` completed)時由 Stop 那半用 `tool-use-id` 對回原派工單再查,同一條線只點名一次。
|
||||
@@ -284,7 +292,7 @@
|
||||
| `delivery-police.sh` | AI 宣稱「這件事做完了」,卻看不到任何實測證據(畫面截圖、指令輸出、HTTP 狀態碼…)就擋下。 | 🛑 擋 |
|
||||
| `wiki-first-police.sh` | AI 做完事卻沒有把結論寫回 wiki 就想收工,就擋下——下次(或別的 AI)查 wiki 會查不到這次做過什麼。 | 🛑 擋 |
|
||||
| `unpushed-police.sh` | AI 改好的東西還留在本機、沒有真的推送出去給別人用,卻想收工,就擋下——「改對了但沒送到」跟沒改是一樣的。 | 🛑 擋 |
|
||||
| `queue-drain-guard.sh` | **在接票的 session(跑過 `ticket pick/claim/handback`,或環境設了 `ISEP_DRAIN=1`),池子裡還有現在就能抓的票,就不准收工**——它自己跑一次 `ticket pick`,有票就把票號和認領指令交回去。「池子」多大看環境:設了 `ISEP_DRAIN=1`(雲端工人)時 pick 會看到整個 open 票池的 `s/todo`/`s/backlog`;本機沒設時只看主線與逾期里程碑,所以總管跑過 `handback` 也不會被叫去抓票池(`inkstone/ISEP#130`)。這是 ISEP 唯一一支看「佇列」而不是看「這回合寫了什麼」的收工閘(`inkstone/ISEP#33`:雲端三趟 run 都是做完一件、還有票就停)。做不了的票要把理由寫回票、改欄位,pick 就不再回它。跟 leo 聊天的 session 不會被咬;同一張連續指名 3 次、讀不到佇列 3 次、或一個 session 擋滿 40 次就放行並留痕,不會鎖死。 | 🛑 擋(有上限) |
|
||||
| `queue-drain-guard.sh` | **在接票的 session(跑過 `ticket pick/claim/handback`,或環境設了 `ISEP_DRAIN=1`),池子裡還有現在就能抓的票,就不准收工**——它自己跑一次 `ticket pick`,有票就把票號和認領指令交回去。「池子」多大看環境:設了 `ISEP_DRAIN=1`(雲端工人)時 pick 會看到整個 open 票池的 `s/todo`/`s/backlog`;本機沒設時只看主線與逾期里程碑,所以總管跑過 `handback` 也不會被叫去抓票池(`inkstone/ISEP#130`)。雲端環境下可做的都抓盡、還有沒 s/* 的票時,pick 回一張待分診的,本閘照那一列印 `ticket triage …` 而不是 claim(`inkstone/ISEP#159`)。這是 ISEP 唯一一支看「佇列」而不是看「這回合寫了什麼」的收工閘(`inkstone/ISEP#33`:雲端三趟 run 都是做完一件、還有票就停)。做不了的票要把理由寫回票、改欄位,pick 就不再回它。跟 leo 聊天的 session 不會被咬;同一張連續指名 3 次、讀不到佇列 3 次、或一個 session 擋滿 40 次就放行並留痕,不會鎖死。 | 🛑 擋(有上限) |
|
||||
| `baton-handback-guard.sh` | **背景派出去的工人交件時**(主對話收到完工通知),檢查那張工單票有沒有把棒子交回來(指派/標籤/下一步三格),缺就擋一次要 AI 補。工人還在跑的時候一聲都不出(`inkstone/ISEP#153`)。同一條線只點名一次;補完三格就不再出現。前景派工的那一半在下面 H 組。 | 🛑 擋(每條線至多一次) |
|
||||
|
||||
> 🔴 **`claim-verify-police.sh` 已於 `inkstone/ISEP#60` 移除**(連同下面原本的 G 組 `subagent-claim-worksheet.sh`)。
|
||||
|
||||
@@ -141,6 +141,7 @@ miss = 0
|
||||
try:
|
||||
row = json.loads(out)
|
||||
ref, title = row.get("ref"), (row.get("title") or "")[:80]
|
||||
nxt = (row.get("next") or "").replace("\t", " ").replace("\n", " ")
|
||||
except Exception:
|
||||
save("ALLOW:unparsable")
|
||||
if not ref:
|
||||
@@ -152,19 +153,21 @@ if same > MAX_SAME:
|
||||
if blocks >= MAX_BLOCKS:
|
||||
save("ALLOW:max-blocks")
|
||||
blocks += 1
|
||||
save("BLOCK:%s\t%s\t%d" % (ref, title, same))
|
||||
save("BLOCK:%s\t%s\t%d\t%s" % (ref, title, same, nxt))
|
||||
' 2>/dev/null) || VERDICT="ALLOW:crash"
|
||||
|
||||
case "$VERDICT" in
|
||||
BLOCK:*)
|
||||
body="${VERDICT#BLOCK:}"
|
||||
REF=$(printf '%s' "$body" | cut -f1); TITLE=$(printf '%s' "$body" | cut -f2); N=$(printf '%s' "$body" | cut -f3)
|
||||
REF=$(printf '%s' "$body" | cut -f1); TITLE=$(printf '%s' "$body" | cut -f2); N=$(printf '%s' "$body" | cut -f3); NEXT=$(printf '%s' "$body" | cut -f4)
|
||||
# pick 的每一列自帶下一步(inkstone/ISEP#159):待分診的票下一步是 triage 不是 claim——照它印,不自己猜
|
||||
[ -z "$NEXT" ] && NEXT="python3 \"$PLUGIN_ROOT/scripts/ticket\" claim $REF --name <你的名字>"
|
||||
note "⛔ 擋下" "池子還有 $REF(第 $N 次指名)"
|
||||
cat >&2 <<MSG
|
||||
🔁 佇列警察:**這個 session 在接票,而池子裡還有一張現在就能抓的票——還不是收工的時候。**
|
||||
|
||||
下一張:$REF $TITLE
|
||||
認領:python3 "$PLUGIN_ROOT/scripts/ticket" claim $REF --name <你的名字>
|
||||
下一步:$NEXT
|
||||
|
||||
leo 2026-09-13:「任務完成自己去拿下一個任務,幫我消化任務」。
|
||||
回報寫在票上就好,**不必在這裡寫收工摘要**——摘要等 pick 抓盡再寫一次。
|
||||
|
||||
@@ -61,6 +61,11 @@ run "★ stop_hook_active=true 仍擋(別的閘擋過一次就讓路,正是
|
||||
ISEP_DRAIN=1 run "ISEP_DRAIN=1:還沒跑過任何 ticket 指令也擋" 2 s4 chat.jsonl
|
||||
check "log 寫在狀態目錄(不靠 CLAUDE_PROJECT_DIR)" "grep -q '擋下' '$TMP/state-s4/queue-drain-guard.log'"
|
||||
|
||||
stub 0 '{"ref":"inkstone/mira#21","title":"沒人看過的票","group":"待分診","next":"python3 /x/scripts/ticket triage inkstone/mira#21 --to <s/backlog|s/triage|s/pending> --why \"<一句理由>\""}'
|
||||
run "★ 可做的都抓盡、還有待分診的票 → 擋(ISEP#159:沒驗傷的票不會自己消失)" 2 s9 worker.jsonl
|
||||
check "訊息照 pick 那一列的 next 印 triage,不印 claim(待分診的票認領不了)" \
|
||||
"grep -q 'triage inkstone/mira#21' '$TMP/stderr' && ! grep -q 'claim inkstone/mira#21' '$TMP/stderr'"
|
||||
|
||||
echo
|
||||
echo "── ② 不該擋 ──"
|
||||
stub 0 "$TICKET"
|
||||
|
||||
+65
-16
@@ -5,7 +5,7 @@
|
||||
# 誤觸時怎麼關: 這支不擋任何東西。不想產生就別跑;產物在版控外,刪掉即可。
|
||||
#
|
||||
# 用法:bash scripts/make-cloud-env.sh
|
||||
# 產物:~/.claude/cloud-env/<日期>.txt(權限 600,**不在任何 repo 裡**)
|
||||
# 產物:~/Desktop/cloud-env-<版本>-<日期>.txt(權限 600,**不在任何 repo 裡**);版本紀錄 docs/cloud-env-versions.tsv
|
||||
# 本腳本只寫「變數名字」,值在執行當下才從既有 .env 讀出來寫進產物 —— 值不進版控、不進對話。
|
||||
set -euo pipefail
|
||||
|
||||
@@ -44,6 +44,28 @@ NEEDED=(
|
||||
# 只有 namespace 是機敏 ⇒ 走環境變數。原本只住在 ~/.arcrun/config.yaml 的 api_key,
|
||||
# 那個檔在家目錄、不隨 clone 走 ⇒ 雲端永遠拿不到。
|
||||
ARCRUN_NS_YOULIN # youlin 實例的 namespace(X-Arcrun-API-Key)
|
||||
ARCRUN_NS_UNCLE6 # uncle6 實例的 namespace:出貨第 1、19、20 站派給 uncle6 工作流(inkstone/InkStoneCo#98 → comment 7739)
|
||||
|
||||
# ── prod 出貨把產物推上 GitHub 鏡像(第 14、21、22 站)──
|
||||
# 🔴 名字進清單 ≠ 雲端可以自由寫 GitHub:`github-contact-guard.sh` 照樣擋,
|
||||
# 寫入仍要 D20 開閘(保險檔落在哪由 inkstone/ISEP#157 處理)。
|
||||
# 進清單是因為「拿不到這兩個名字」會讓 prod 那半在雲端**連開閘之後都走不下去**。
|
||||
GITHUB_MIRROR_TOKEN # GitHub 鏡像 repo 的寫入 token(走標頭,不進網址)
|
||||
GITHUB_ACCOUNT_NAME # 上面那把的帳號名(組鏡像 repo 路徑用,不是機密)
|
||||
|
||||
# ── 雲端工人的通知出口(v7,2026-09-18:leo 貼出現行雲端環境才發現 v1–v6 漏收)──
|
||||
# 雲端走 Bot API 直送(`scripts/isep-notify`;leo21c 的 notify_leo 已於 08-14 消失,InkStoneCo#110)
|
||||
TELEGRAM_CHAT_ID # 收訊的 chat id(不是機密)
|
||||
TELEGRAM_BOT_TOKEN # 通知 bot 的 token
|
||||
)
|
||||
|
||||
# 🔓 例外:值只住在 polaris/mira/.env、但**不是**打得到 leo21c 的憑證——點名放行,其他照擋(B8)
|
||||
# Telegram 兩把是通知 bot,不碰任何 CF 帳號;雲端 09-18 前就已手動設了同樣的值。
|
||||
MIRA_ALLOWED=(TELEGRAM_CHAT_ID TELEGRAM_BOT_TOKEN)
|
||||
|
||||
# ── 固定值(不是金鑰,產生器直接寫)──
|
||||
FIXED=(
|
||||
"ISEP_DRAIN=1" # 雲端工人=接票環境:ticket pick 自帶 --pool、佇列閘不准有票就收工(ISEP#130)
|
||||
)
|
||||
#
|
||||
# 🔴 這份清單的邊界——加一把之前先問「這把打得到哪個實例」,不是「這把方便嗎」
|
||||
@@ -91,23 +113,42 @@ lookup() { # $1=變數名 → 印出值(找不到就空)
|
||||
return 1
|
||||
}
|
||||
|
||||
# 預設丟 ~/.claude/cloud-env(權限 700)。要放別的地方= OUT_DIR=~/Desktop bash scripts/make-cloud-env.sh
|
||||
OUT_DIR="${OUT_DIR:-$HOME/.claude/cloud-env}"
|
||||
# ── 版本(leo 2026-09-18:「你要有版本,因為這件事做了很多次,但你都沒記錄版本」)──
|
||||
# 真相源=docs/cloud-env-versions.tsv(只記 key,不記值)。最後一列=現行版。
|
||||
# 🔴 NEEDED 跟最後一列的 key 不一致 ⇒ 拒絕產生:改了清單就必須在 tsv 加一版。
|
||||
VERSIONS="$(cd "$(dirname "$0")/.." && pwd)/docs/cloud-env-versions.tsv"
|
||||
[ -f "$VERSIONS" ] || { echo "🔴 找不到 $VERSIONS" >&2; exit 1; }
|
||||
CUR_LINE=$(grep -v '^#' "$VERSIONS" | grep -v '^[[:space:]]*$' | tail -1)
|
||||
PREV_LINE=$(grep -v '^#' "$VERSIONS" | grep -v '^[[:space:]]*$' | tail -2 | head -1)
|
||||
VER=$(printf '%s' "$CUR_LINE" | cut -f1); VER_DATE=$(printf '%s' "$CUR_LINE" | cut -f2)
|
||||
VER_KEYS=$(printf '%s' "$CUR_LINE" | cut -f3); VER_WHY=$(printf '%s' "$CUR_LINE" | cut -f4)
|
||||
PREV_VER=$(printf '%s' "$PREV_LINE" | cut -f1); PREV_KEYS=$(printf '%s' "$PREV_LINE" | cut -f3)
|
||||
FIXED_NAMES=(); for kv in "${FIXED[@]}"; do FIXED_NAMES+=("${kv%%=*}"); done
|
||||
NEEDED_JOINED=$(IFS=,; printf '%s' "${NEEDED[*]} ${FIXED_NAMES[*]}" | tr ' ' ',')
|
||||
if [ "$NEEDED_JOINED" != "$VER_KEYS" ]; then
|
||||
echo "🔴 NEEDED 與 $VERSIONS 最後一版($VER)的 key 不一致——改了清單就要在 tsv 加一列新版本再跑。" >&2
|
||||
echo " NEEDED:$NEEDED_JOINED" >&2
|
||||
echo " $VER :$VER_KEYS" >&2
|
||||
exit 2
|
||||
fi
|
||||
ADDED=$(comm -13 <(tr , '\n' <<<"$PREV_KEYS" | sort) <(tr , '\n' <<<"$VER_KEYS" | sort) | paste -sd, -)
|
||||
REMOVED=$(comm -23 <(tr , '\n' <<<"$PREV_KEYS" | sort) <(tr , '\n' <<<"$VER_KEYS" | sort) | paste -sd, -)
|
||||
|
||||
# 預設丟桌面(leo 2026-09-18 指定)。要放別的地方= OUT_DIR=<目錄> bash scripts/make-cloud-env.sh
|
||||
OUT_DIR="${OUT_DIR:-$HOME/Desktop}"
|
||||
mkdir -p "$OUT_DIR"
|
||||
# 只在「這個目錄是我們自己造的預設位置」時才收緊權限——
|
||||
# OUT_DIR 可被覆寫,不該對使用者指定的既有目錄(例如 ~/Desktop)動權限。
|
||||
[ "$OUT_DIR" = "$HOME/.claude/cloud-env" ] && chmod 700 "$OUT_DIR"
|
||||
OUT="$OUT_DIR/$(date +%Y%m%d-%H%M%S).txt"
|
||||
OUT="$OUT_DIR/cloud-env-${VER}-$(date +%Y%m%d-%H%M).txt"
|
||||
|
||||
SETUP="$(cd "$(dirname "$0")/.." && pwd)/docs/cloud-setup-script.sh"
|
||||
[ -f "$SETUP" ] || { echo "🔴 找不到 $SETUP" >&2; exit 1; }
|
||||
|
||||
MISSING=()
|
||||
# 🔴 兩個檔分開產(2026-09-18 實撞):原本兩段放同一檔、中間用「════」分隔,
|
||||
# leo 把分隔線一起貼進 Setup script 欄 ⇒ 雲端開機 exit 127「'════…': command not found」,
|
||||
# 每一趟 cloud-worker 在開機就死。⇒ 變數一個檔(只有 KEY=VALUE)、開機腳本一個檔(逐位元組=cloud-setup-script.sh),
|
||||
# **兩個檔都整份貼**,沒有任何要人自己裁切的地方。
|
||||
SETUP_OUT="${OUT%.txt}-setup-script.sh"
|
||||
{
|
||||
echo "claude.ai → Cloud environments → 你的環境。下面兩塊各自貼進對應欄位。"
|
||||
echo "產生時間:$(date '+%Y-%m-%d %H:%M')"
|
||||
echo
|
||||
echo "════════ ① Environment variables(一行一個,名字與值分開填)════════"
|
||||
for n in "${NEEDED[@]}"; do
|
||||
if v=$(lookup "$n"); then
|
||||
echo "$n=$v"
|
||||
@@ -116,12 +157,20 @@ MISSING=()
|
||||
MISSING+=("$n")
|
||||
fi
|
||||
done
|
||||
echo
|
||||
echo "════════ ② Setup script(整段貼,一字不改)════════"
|
||||
cat "$SETUP"
|
||||
for kv in "${FIXED[@]}"; do echo "$kv"; done
|
||||
} > "$OUT"
|
||||
chmod 600 "$OUT"
|
||||
cp "$SETUP" "$SETUP_OUT"
|
||||
chmod 600 "$OUT" "$SETUP_OUT"
|
||||
{
|
||||
echo "claude.ai → Cloud environments → 你的環境(${VER},${VER_DATE}:${VER_WHY})"
|
||||
echo "比 ${PREV_VER} 多:${ADDED:-(無)}|少:${REMOVED:-(無)}"
|
||||
echo "① Environment variables 欄:整份貼 $(basename "$OUT")"
|
||||
echo "② Setup script 欄:整份貼 $(basename "$SETUP_OUT")(一字不改,不要加任何東西)"
|
||||
echo "貼完刪掉這三個檔。"
|
||||
} > "${OUT%.txt}-README.txt"
|
||||
|
||||
echo "✅ 產生完成:$OUT"
|
||||
echo " 版本:${VER}(比 ${PREV_VER} 多:${ADDED:-無}|少:${REMOVED:-無})"
|
||||
echo " 變數 ${#NEEDED[@]} 個|找不到值的 ${#MISSING[@]} 個 ${MISSING[*]:-}"
|
||||
echo " 🔴 這個檔含金鑰真身:貼完就刪(rm '$OUT'),它刻意不在任何 repo 裡。"
|
||||
echo " 開機腳本:$SETUP_OUT"
|
||||
echo " 🔴 含金鑰真身:貼完就刪(rm '${OUT%.txt}'*),它刻意不在任何 repo 裡。"
|
||||
|
||||
@@ -35,6 +35,7 @@ NEEDED=()
|
||||
while IFS= read -r l; do NEEDED+=("$l"); done < <(
|
||||
sed -n '/^NEEDED=(/,/^)/p' "$S" | sed -E '1d;$d; s/[[:space:]]*#.*$//; s/[[:space:]]//g' | grep -v '^$')
|
||||
[ "${#NEEDED[@]}" -gt 0 ] || { echo "🔴 從 $S 讀不出 NEEDED,測試本身壞了"; exit 1; }
|
||||
MIRA_ALLOWED=($(sed -n 's/^MIRA_ALLOWED=(\(.*\))/\1/p' "$S"))
|
||||
echo "清單(只有名字):${NEEDED[*]}"
|
||||
echo
|
||||
|
||||
@@ -59,6 +60,19 @@ chk 0 "$miss" "A3 每個名字都帶著值出現在 ① 區塊"
|
||||
printf '%s\n' "$OUT_LINE" | grep -q "找不到值的 0 個" \
|
||||
&& ok "A4 收尾那行說「找不到值的 0 個」" || bad "A4 收尾計數不對:$OUT_LINE"
|
||||
|
||||
# 版本(leo 2026-09-18):產物檔頭帶現行版本號;清單改了沒升版要拒絕
|
||||
grep -q "(v[0-9]" "${F%.txt}-README.txt" && ok "V1 README 寫著版本號" || bad "V1 README 沒有版本號"
|
||||
# 2026-09-18 實撞:兩段同檔、分隔線被貼進 Setup script 欄 ⇒ 雲端開機 exit 127。分檔後兩件事要守住:
|
||||
bad_lines=$(grep -cvE '^[A-Z][A-Z0-9_]*=' "$F")
|
||||
chk 0 "$bad_lines" "V3 變數檔每一行都是 KEY=VALUE(沒有分隔線、說明文字)"
|
||||
cmp -s "${F%.txt}-setup-script.sh" "$(cd "$(dirname "$S")/.." && pwd)/docs/cloud-setup-script.sh" \
|
||||
&& ok "V4 開機腳本檔與 docs/cloud-setup-script.sh 逐位元組相同" || bad "V4 開機腳本檔被加料了"
|
||||
VT="$(cd "$(dirname "$S")/.." && pwd)/docs/cloud-env-versions.tsv"; VB="$VT.bak-test"
|
||||
cp "$VT" "$VB"; printf 'v999\t2099-01-01\tNOPE_ONLY\t測試用\n' >> "$VT"
|
||||
INKSTONE_ROOT="$FAKE" OUT_DIR="$OUTD" bash "$S" >/dev/null 2>&1; rc=$?
|
||||
mv "$VB" "$VT"
|
||||
chk 2 "$rc" "V2 清單與最後一版 key 不一致時拒絕產生(離開碼 2)"
|
||||
|
||||
# 缺值時不准假綠:拿掉第一個,它要變成 <🔴 …> 且計數變 1
|
||||
grep -v "^${NEEDED[0]}=" "$FAKE/.env" > "$FAKE/.env.tmp" && mv "$FAKE/.env.tmp" "$FAKE/.env"
|
||||
OUT2=$(INKSTONE_ROOT="$FAKE" OUT_DIR="$OUTD" bash "$S" 2>&1)
|
||||
@@ -104,7 +118,7 @@ else
|
||||
if r=$(real_src "$n"); then
|
||||
len="${r%% *}"; src="${r#* }"
|
||||
printf ' %-38s → 找得到(長度 %s)來自 %s\n' "$n" "$len" "${src#$BASE/}"
|
||||
case "$src" in */polaris/mira/.env) prod=$((prod+1)); echo " 🔴 ↑ 這是 leo21c 現役正式環境那份 .env";; esac
|
||||
case "$src" in */polaris/mira/.env) if printf '%s\n' "${MIRA_ALLOWED[@]}" | grep -qx "$n"; then echo " 🔓 ↑ 點名放行(MIRA_ALLOWED:通知 bot,不碰 CF)"; else prod=$((prod+1)); echo " 🔴 ↑ 這是 leo21c 現役正式環境那份 .env"; fi;; esac
|
||||
else
|
||||
printf ' %-38s → 🔴 這台拿不到\n' "$n"; gone=$((gone+1))
|
||||
fi
|
||||
|
||||
@@ -65,7 +65,8 @@ POOL = {
|
||||
I("mira", 23, ["s/backlog", "Human"], None), # Human:不抓
|
||||
I("mira", 24, ["s/review"], None), # 等總管:不抓
|
||||
I("mira", 25, ["s/backlog", "p/high"], None, created="2026-09-05T00:00:00Z"), # ★ 票池裡最優先
|
||||
I("mira", 26, ["s/todo", "hub"], None)], # hub:容器不是任務
|
||||
I("mira", 26, ["s/todo", "hub"], None), # hub:容器不是任務
|
||||
I("mira", 27, ["Human"], None)], # 沒 s/* 但掛 Human:不抓、也不分診(ISEP#159)
|
||||
# 分頁:伺服器每頁上限 30(比 pick 要的 50 小)——只看「不滿一頁」就停的寫法會漏掉第 31 張之後的
|
||||
"big": [I("big", n, [], None) for n in range(1, 31)] + [I("big", 31, ["s/backlog"], None)],
|
||||
}
|
||||
@@ -281,9 +282,19 @@ p "★ 環境 ISEP_DRAIN=1(雲端工人的環境)= 帶 --pool,指令不
|
||||
unset ISEP_DRAIN
|
||||
unset DROP
|
||||
export DROP='["Arcrun#6","ISEP#1","Arcrun#7","mira#25","Arcrun#8","ISEP#13","ISEP#5","ISEP#4","big#31"]'
|
||||
p "★ 票池也抓盡 → 離開碼 1" "1" "rc" "$POOLA"
|
||||
p "★ 可抓 0 張時列出池子大小與「不能抓的理由」各幾張(沒 s/* 的 31 張被點名),而且不說成「正常/不是故障」" "True" \
|
||||
"'open 票池' in out and '31 張' in out and '沒有 s/*' in out and '不是故障' not in out and '正常' not in out" "$POOLA"
|
||||
p "★ 票池抓盡、但還有沒 s/* 的票 → 回一張待分診的(同一天開的,票號序第一的 big#1),下一步是 triage 不是 claim(ISEP#159)" "True" \
|
||||
"rc is None and 'inkstone/big#1' in out and ' triage inkstone/big#1 ' in out and 'claim inkstone/big#1' not in out" "$POOLA"
|
||||
p "--json:待分診那一列帶 group=待分診 與貼了就能跑的 next(佇列閘照它印)" "True" \
|
||||
"(lambda r: r['group']=='待分診' and ' triage ' in r['next'])(json.loads(out))" \
|
||||
"[\"cmd_pick\",\"--mainline\",\"$MAIN\",\"--pool\",\"--json\"]"
|
||||
p "待分診那一層不回掛 Human 的 mira#27(沒 s/* 也不碰)" "False" "'mira#27' in out" "$POOLALL"
|
||||
p "pick --claim 遇到待分診的票 → 不認領(沒有任何寫入)" "True" \
|
||||
"not any(mm in ('PATCH','PUT','POST') for mm,_,_ in rec)" \
|
||||
"[\"cmd_pick\",\"--mainline\",\"$MAIN\",\"--pool\",\"--claim\"]"
|
||||
export DROP='["Arcrun#6","ISEP#1","Arcrun#7","mira#25","Arcrun#8","ISEP#13","ISEP#5","ISEP#4","big#31","mira#21"'"$(python3 -c 'print("".join(",\"big#%d\"" % n for n in range(1,31)))')"']'
|
||||
p "★ 票池與待分診都抓盡 → 離開碼 1" "1" "rc" "$POOLA"
|
||||
p "★ 可抓 0 張時列出池子大小與「不能抓的理由」各幾張(沒 s/* 又掛 Human 的被點名),而且不說成「正常/不是故障」" "True" \
|
||||
"'open 票池' in out and '沒有 s/*' in out and '不是故障' not in out and '正常' not in out" "$POOLA"
|
||||
p "--json 抓盡時同一張理由表寫到 stderr(stdout 仍是 null,佇列閘照舊解析得動)" "True" \
|
||||
"out.startswith('null') and '不能抓' not in out.split(chr(10))[0] and '沒有 s/*' in out" \
|
||||
"[\"cmd_pick\",\"--mainline\",\"$MAIN\",\"--pool\",\"--json\"]"
|
||||
|
||||
Executable
+300
@@ -0,0 +1,300 @@
|
||||
#!/bin/bash
|
||||
# 雲端工人「分診+組里程碑」的測試(inkstone/ISEP#159)
|
||||
#
|
||||
# 票上的驗收:
|
||||
# 1. 沒狀態的票數下降,每張被動過的票上都有一則說明(分到哪、為什麼;重複的指向哪張)
|
||||
# 2. 提出新里程碑:載體票在 InkStoneCo、執行票掛成前置、名字不是版本號、有期限、deliverable=版本
|
||||
# 3. 不碰 Human、不碰指派給 Leo 的票
|
||||
# 4. 組了之後照里程碑往下做(pick --pool 先回它的前置票)
|
||||
#
|
||||
# 全程離線:api() 換成錄音機餵假池子;TICKET_HOST 指到連不上的位址,漏接一條會當場炸,不會假綠。
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
T=scripts/ticket
|
||||
TMP=$(mktemp -d)
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
PASS=0; FAIL=0
|
||||
export TICKET_HOST=http://127.0.0.1:9 GITEA_TOKEN=x ISEP_MEMBER_BACKOFF=0
|
||||
export ISEP_COUNTDOWN_STATE_DIR="$TMP/state"; mkdir -p "$ISEP_COUNTDOWN_STATE_DIR"
|
||||
# 時鐘定在 2026-09-18 00:00 UTC
|
||||
export ISEP_COUNTDOWN_NOW=$(python3 -c 'import datetime as d;print(int(d.datetime(2026,9,18,0,0,tzinfo=d.timezone.utc).timestamp()))')
|
||||
unset ISEP_MAINLINE_FILE ISEP_IDENTITY CLAUDE_PROJECT_DIR ISEP_DRAIN
|
||||
export ISEP_WORKER_LOGIN=claude-code # 抓票者自己是誰(真跑時問 /user;離線測試不打網路)
|
||||
|
||||
MAIN="$TMP/mainline.json"
|
||||
cat > "$MAIN" <<'JSON'
|
||||
{"ref":"inkstone/InkStoneCo#65","owner":"inkstone","repo":"InkStoneCo","id":65,
|
||||
"title":"主線 M","due_on":"2026-09-25T23:59:59Z","members":[]}
|
||||
JSON
|
||||
|
||||
cat > "$TMP/pool.py" <<'PY'
|
||||
import json, os, re, urllib.parse
|
||||
MS = {"main": {"id": 65, "title": "主線 M", "due_on": "2026-09-25T23:59:59Z", "state": "open"},
|
||||
"mine": {"id": 70, "title": "組好的 M", "due_on": "2026-09-30T23:59:59Z", "state": "open"},
|
||||
"sub": {"id": 9, "title": "子 repo 的舊里程碑", "due_on": "2026-10-30T23:59:59Z", "state": "open"}}
|
||||
def I(repo, n, labels, ms=None, assignees=(), created="2026-09-01T00:00:00Z", pr=False, state="open", title=None):
|
||||
d = {"number": n, "title": title or f"票 {repo}#{n}", "state": state,
|
||||
"labels": [{"name": l} for l in labels],
|
||||
"assignees": [{"login": a} for a in assignees],
|
||||
"milestone": MS[ms] if ms else None, "created_at": created,
|
||||
"repository": {"full_name": f"inkstone/{repo}"}}
|
||||
if pr: d["pull_request"] = {"merged": False}
|
||||
return d
|
||||
POOL = {
|
||||
"InkStoneCo": [I("InkStoneCo", 55, [], None, title="身為一天只看兩眼的人…"), # ★ 載體候選:沒里程碑、沒人
|
||||
I("InkStoneCo", 132, ["Human", "s/pending"], "main", assignees=("Leo",)), # 主線載體(Leo 的)
|
||||
I("InkStoneCo", 80, ["s/backlog"], "mine"), # 組好的 M 的載體(有 s/* 也不是任務)
|
||||
I("InkStoneCo", 81, ["Human"], None), # 掛 Human 的載體候選
|
||||
I("InkStoneCo", 82, [], "main"),
|
||||
I("InkStoneCo", 83, [], None, assignees=("Leo",)), # 指派 Leo 的載體候選
|
||||
I("InkStoneCo", 84, ["s/backlog"], None)], # 已是「組好的 M」載體的前置——不能再當載體 # 已掛在主線里程碑的載體候選
|
||||
"ISEP": [I("ISEP", 1, [], None, created="2026-08-01T00:00:00Z"), # ★ 待分診(最舊)
|
||||
I("ISEP", 2, [], None), # 待分診
|
||||
I("ISEP", 3, ["Human"], None), # 沒 s/*、掛 Human:不碰
|
||||
I("ISEP", 4, [], None, assignees=("Leo",)), # 沒 s/*、指派 Leo:不碰
|
||||
I("ISEP", 5, ["s/backlog", "type/bug"], None), # ★ 已分診:可組進里程碑
|
||||
I("ISEP", 6, ["s/triage"], None), # 還沒決定:不可組
|
||||
I("ISEP", 7, ["s/backlog"], None), # 已是組好的 M 的前置
|
||||
I("ISEP", 8, ["s/backlog"], "sub"), # 掛著子 repo 里程碑
|
||||
I("ISEP", 9, [], None, pr=True), # PR
|
||||
I("ISEP", 10, [], None, assignees=("claude-code",))], # 只指派給自己:可分診
|
||||
"Arcrun": [I("Arcrun", 20, ["s/todo"], None), # ★ 已分診:可組進里程碑
|
||||
I("Arcrun", 21, ["s/todo"], None), # 組好的 M 的前置(pick 用)
|
||||
I("Arcrun", 22, ["s/backlog", "Human"], None), # Human 前置:不碰
|
||||
I("Arcrun", 23, ["s/backlog"], None, assignees=("Leo",))], # 指派 Leo 的前置:不碰 # Human 前置:不碰
|
||||
}
|
||||
MSN = {"InkStoneCo": ["main", "mine"], "ISEP": ["sub"]}
|
||||
DEPS = {"InkStoneCo#80": ["ISEP#7", "Arcrun#21", "InkStoneCo#84"]}
|
||||
def _by_ref(ref):
|
||||
repo, n = ref.split("#")
|
||||
return next(i for i in POOL[repo] if i["number"] == int(n))
|
||||
BLOCKS = {}
|
||||
for _p, _cs in DEPS.items():
|
||||
for _c in _cs:
|
||||
BLOCKS.setdefault(_c, []).append(_p)
|
||||
LABELS = ["s/triage", "s/backlog", "s/todo", "s/doing", "s/review", "s/pending", "close/duplicate",
|
||||
"Human", "type/bug", "p/high"]
|
||||
DROP = set(json.loads(os.environ.get("DROP", "[]")))
|
||||
rec = []
|
||||
def fake_api(path, payload=None, method=None):
|
||||
verb = method or ("POST" if payload is not None else "GET")
|
||||
rec.append((verb, path, payload))
|
||||
if path.startswith("/orgs/inkstone/repos"):
|
||||
return [{"name": r} for r in POOL]
|
||||
if path == "/user":
|
||||
return {"login": "claude-code"}
|
||||
if path.endswith("/labels?limit=100"):
|
||||
return [{"name": n, "id": k} for k, n in enumerate(LABELS, 1)]
|
||||
if "/milestones" in path:
|
||||
repo = path.split("/")[3]
|
||||
if verb == "POST":
|
||||
return {"id": 71, "title": payload["title"]}
|
||||
return [MS[k] for k in MSN.get(repo, [])]
|
||||
if "/issues?" in path:
|
||||
repo = path.split("/")[3]
|
||||
q = urllib.parse.parse_qs(path.split("?", 1)[1])
|
||||
rows = [i for i in POOL[repo] if f"{repo}#{i['number']}" not in DROP]
|
||||
if "milestones" in q:
|
||||
want = q["milestones"][0]
|
||||
return [i for i in rows if (i["milestone"] or {}).get("title") == want]
|
||||
rows = [i for i in rows if i["state"] == "open"]
|
||||
page = int(q.get("page", ["1"])[0]); per = int(q.get("limit", ["50"])[0])
|
||||
return rows[(page - 1) * per: page * per]
|
||||
m = re.match(r"/repos/inkstone/([\w-]+)/issues/(\d+)/(dependencies|blocks)(\?.*)?$", path)
|
||||
if m:
|
||||
if verb == "POST":
|
||||
return {}
|
||||
table = DEPS if m.group(3) == "dependencies" else BLOCKS
|
||||
return [_by_ref(r) for r in table.get(f"{m.group(1)}#{m.group(2)}", [])]
|
||||
m = re.match(r"/repos/inkstone/([\w-]+)/issues/(\d+)$", path)
|
||||
if m and verb == "GET":
|
||||
return _by_ref(f"{m.group(1)}#{m.group(2)}")
|
||||
return {}
|
||||
PY
|
||||
export POOL_PY="$TMP/pool.py"
|
||||
|
||||
probe() {
|
||||
python3 - "$1" "$2" <<'PY'
|
||||
import sys, os, json, io, contextlib, importlib.util as u
|
||||
from importlib.machinery import SourceFileLoader as L
|
||||
spec = u.spec_from_loader("t", L("t", "scripts/ticket"))
|
||||
m = u.module_from_spec(spec); spec.loader.exec_module(m)
|
||||
ns = {}
|
||||
exec(open(os.environ["POOL_PY"]).read(), ns)
|
||||
m.api = ns["fake_api"]; rec = ns["rec"]
|
||||
argv = json.loads(sys.argv[2]) if sys.argv[2] else None
|
||||
buf = io.StringIO(); rc = None
|
||||
if argv is not None:
|
||||
with contextlib.redirect_stdout(buf), contextlib.redirect_stderr(buf):
|
||||
try:
|
||||
getattr(m, argv[0])(argv[1:])
|
||||
except SystemExit as e:
|
||||
rc = e.code
|
||||
W = [(mm, p, pl) for mm, p, pl in rec if mm in ("POST", "PATCH", "PUT", "DELETE")]
|
||||
print(eval(sys.argv[1], {"m": m, "rec": rec, "W": W, "rc": rc, "out": buf.getvalue(), "I": ns["I"], "json": json}))
|
||||
PY
|
||||
}
|
||||
p() { # p <說明> <want> <python 片段> [argv json]
|
||||
got=$(probe "$3" "${4:-}" 2>&1)
|
||||
if [ "$got" = "$2" ]; then PASS=$((PASS+1)); printf ' ✅ '; else FAIL=$((FAIL+1)); printf ' ❌ '; fi
|
||||
printf 'want=%s got=%s %s\n' "$2" "$got" "$1"
|
||||
}
|
||||
j() { python3 -c 'import json,sys;print(json.dumps(sys.argv[1:],ensure_ascii=False))' "$@"; }
|
||||
|
||||
echo "── ① 規則本體(純函式)──"
|
||||
p "沒 s/*、沒人、沒 Human → 待分診" "True" "m.triageable(I('ISEP',1,[]),'claude-code')[0]"
|
||||
p "★ 掛 Human → 不碰(驗收 3)" "False" "m.triageable(I('ISEP',3,['Human']),'claude-code')[0]"
|
||||
p "human/exec 同組 → 不碰" "False" "m.triageable(I('ISEP',3,['human/exec']),'claude-code')[0]"
|
||||
p "★ 指派給 Leo → 不碰(驗收 3)" "False" "m.triageable(I('ISEP',4,[],assignees=('Leo',)),'claude-code')[0]"
|
||||
p "只指派給自己 → 可分診" "True" "m.triageable(I('ISEP',10,[],assignees=('claude-code',)),'claude-code')[0]"
|
||||
p "不知道自己是誰、票有指派 → 不碰(不猜)" "False" "m.triageable(I('ISEP',10,[],assignees=('claude-code',)),None)[0]"
|
||||
p "已經有 s/*(連 s/triage 也算)→ 不是待分診" "False" "m.triageable(I('ISEP',6,['s/triage']),'claude-code')[0]"
|
||||
p "PR → 不是票" "False" "m.triageable(I('ISEP',9,[],pr=True),'claude-code')[0]"
|
||||
p "已關 → 不碰" "False" "m.triageable(I('ISEP',1,[],state='closed'),'claude-code')[0]"
|
||||
p "InkStoneCo 裡掛在 open 里程碑的票(載體)→ 不是待分診(它是容器)" "False" "m.triageable(I('InkStoneCo',82,[],'main'),'claude-code')[0]"
|
||||
p "別的 repo 掛著里程碑、沒 s/* → 照樣待分診(載體只認 InkStoneCo)" "True" "m.triageable(I('ISEP',8,[],'sub'),'claude-code')[0]"
|
||||
p "名字以版本號開頭(1.4.52 雲端零件包)→ 算版本號名字" "True" "m._version_like('1.4.52 雲端零件包')"
|
||||
p "v 開頭也算" "True" "m._version_like('v0.30 什麼')"
|
||||
p "名字裡提到版本但不是開頭(封測不再斷,含 1.4 修正)→ 不算(誤攔比漏擋嚴重)" "False" "m._version_like('封測不再斷,含 1.4 修正')"
|
||||
|
||||
echo
|
||||
echo "── ② triage:一個動作=說明+欄位(驗收 1)──"
|
||||
TR=$(j cmd_triage inkstone/ISEP#1 --to s/backlog --why "還在用、要修" --name isep-hand)
|
||||
p "★ 先留說明、再改標籤:寫入恰好是 [留言, 改標籤]" "[('POST', '/repos/inkstone/ISEP/issues/1/comments'), ('PUT', '/repos/inkstone/ISEP/issues/1/labels')]" \
|
||||
"[(mm,p) for mm,p,_ in W]" "$TR"
|
||||
p "★ 說明第一行是【身份】,內文講得出分到哪、為什麼" "True" \
|
||||
"(lambda b: b.split(chr(10))[0]=='【身份】isep-hand/inkstone/ISEP/-' and 's/backlog' in b and '還在用、要修' in b)(W[0][2]['body'])" "$TR"
|
||||
p "標籤換成 s/backlog(id 2)" "[2]" "W[1][2]['labels']" "$TR"
|
||||
p "離開碼 0" "None" "rc" "$TR"
|
||||
TD=$(j cmd_triage inkstone/ISEP#2 --dup-of inkstone/ISEP#5 --why "同一件事" --name isep-hand)
|
||||
p "★ 重複:留說明→標 close/duplicate→關→在留下的那張留一則指回來" \
|
||||
"[('POST', '/repos/inkstone/ISEP/issues/2/comments'), ('PUT', '/repos/inkstone/ISEP/issues/2/labels'), ('PATCH', '/repos/inkstone/ISEP/issues/2'), ('POST', '/repos/inkstone/ISEP/issues/5/comments')]" \
|
||||
"[(mm,p) for mm,p,_ in W]" "$TD"
|
||||
p "★ 重複那則說明指向留下的那張(驗收 1:重複的指向哪張)" "True" "'inkstone/ISEP#5' in W[0][2]['body']" "$TD"
|
||||
p "關的是 state=closed、標的是 close/duplicate(id 7)" "True" "W[2][2]=={'state':'closed'} and W[1][2]['labels']==[7]" "$TD"
|
||||
TDL=$(j cmd_triage inkstone/ISEP#2 --dup-of inkstone/InkStoneCo#132 --why "同一件事")
|
||||
p "★ 重複的對象是 Leo 的票 → 這張照關,但**不在 Leo 的票上寫任何字**(驗收 3)" "True" \
|
||||
"rc is None and not any('/InkStoneCo/' in p for _,p,_ in W) and '沒在' in out" "$TDL"
|
||||
p "只指派給自己的 ISEP#10 → 分診得了" "None" "rc" "$(j cmd_triage inkstone/ISEP#10 --to s/triage --why 要總管看)"
|
||||
|
||||
echo
|
||||
echo " (該擋的:擋下時一筆都沒寫)"
|
||||
nb() { # nb <說明> <argv json> [要在訊息裡看到的字]
|
||||
p "$1 → 離開碼 2、零寫入${3:+、訊息有「$3」}" "True" "rc==2 and not W${3:+ and '$3' in out}" "$2"
|
||||
}
|
||||
nb "★ 掛 Human 的 ISEP#3(驗收 3)" "$(j cmd_triage inkstone/ISEP#3 --to s/backlog --why x)" "掛著 Human"
|
||||
nb "★ 指派給 Leo 的 ISEP#4(驗收 3)" "$(j cmd_triage inkstone/ISEP#4 --to s/backlog --why x)" "指派給 Leo"
|
||||
nb "已分診過的 ISEP#6" "$(j cmd_triage inkstone/ISEP#6 --to s/backlog --why x)" "已經分診過"
|
||||
nb "PR" "$(j cmd_triage inkstone/ISEP#9 --to s/backlog --why x)"
|
||||
p "triage --sign cloud-worker ⇒ 說明內文署 [cloud-worker]" "True" "'[cloud-worker]' in W[0][2]['body']" \
|
||||
"$(j cmd_triage inkstone/ISEP#1 --to s/backlog --why x --sign cloud-worker)"
|
||||
nb "沒寫 --why(說明是驗收 1 的本體)" "$(j cmd_triage inkstone/ISEP#1 --to s/backlog)" "--why"
|
||||
nb "--to s/todo(要經 compose 排進里程碑才給)" "$(j cmd_triage inkstone/ISEP#1 --to s/todo --why x)" "compose"
|
||||
nb "--to 與 --dup-of 都給" "$(j cmd_triage inkstone/ISEP#1 --to s/backlog --dup-of inkstone/ISEP#5 --why x)"
|
||||
nb "--dup-of 指到自己" "$(j cmd_triage inkstone/ISEP#1 --dup-of inkstone/ISEP#1 --why x)"
|
||||
p "參數錯(沒 --why)→ 一通 API 都沒打" "0" "len(rec)" "$(j cmd_triage inkstone/ISEP#1 --to s/backlog)"
|
||||
p "身份名不在名單上 → 一通 API 都沒打" "True" "rc==2 and len(rec)==0" "$(j cmd_triage inkstone/ISEP#1 --to s/backlog --why x --name 路人)"
|
||||
|
||||
echo
|
||||
echo " (--list:工人拿什麼來判斷)"
|
||||
p "★ --list 列出待分診的票(InkStoneCo 還沒分診的也算),不列 Human/Leo/已分診/PR" \
|
||||
"['inkstone/ISEP#1', 'inkstone/ISEP#10', 'inkstone/ISEP#2', 'inkstone/InkStoneCo#55']" \
|
||||
"[r['ref'] for r in json.loads(out)]" "$(j cmd_triage --list --json)"
|
||||
p "--list --all 連已分診的 open 票也列(找重複要看全部),並標出哪些可分診" "True" \
|
||||
"(lambda rows: len(rows)>10 and {r['ref'] for r in rows if r['triageable']}=={'inkstone/ISEP#1','inkstone/ISEP#2','inkstone/ISEP#10','inkstone/InkStoneCo#55'})(json.loads(out))" \
|
||||
"$(j cmd_triage --list --all --json)"
|
||||
p "--list 文字版講得出「不碰」的有幾張,並給出下一步那一行" "True" \
|
||||
"'不碰' in out and ' triage inkstone/ISEP#1 ' in out" "$(j cmd_triage --list)"
|
||||
p "--list 只讀不寫" "True" "not W" "$(j cmd_triage --list)"
|
||||
|
||||
echo
|
||||
echo "── ③ compose:組里程碑(驗收 2)──"
|
||||
CP=$(j cmd_compose --title "雲端自己把票池消化成版本" --goal "leo 不必一張張叫它做" --due 2026-10-01 \
|
||||
--carrier inkstone/InkStoneCo#55 inkstone/ISEP#5 inkstone/Arcrun#20 --name isep-hand)
|
||||
p "★ 里程碑建在 inkstone/InkStoneCo(開工規約第 7 條)" "True" \
|
||||
"[p for mm,p,_ in W if mm=='POST' and p.endswith('/milestones')]==['/repos/inkstone/InkStoneCo/milestones']" "$CP"
|
||||
p "★ 有期限(23:59:59Z),不是 9999" "2026-10-01T23:59:59Z" \
|
||||
"[pl['due_on'] for mm,p,pl in W if p.endswith('/milestones')][0]" "$CP"
|
||||
p "★ 描述寫明這一輪要讓什麼變成真的、deliverable=總管驗過的新版本、載體與前置" "True" \
|
||||
"(lambda d: '這一輪要讓什麼變成真的:leo 不必' in d and 'deliverable=' in d and '新版本' in d and 'inkstone/InkStoneCo#55' in d and 'inkstone/ISEP#5' in d)([pl['description'] for mm,p,pl in W if p.endswith('/milestones')][0])" "$CP"
|
||||
p "★ 載體票掛上新里程碑(id 71)" "True" \
|
||||
"('PATCH','/repos/inkstone/InkStoneCo/issues/55',{'milestone':71}) in W" "$CP"
|
||||
p "★ 兩張執行票都掛成載體票的前置(/dependencies)" "True" \
|
||||
"[pl for mm,p,pl in W if mm=='POST' and p=='/repos/inkstone/InkStoneCo/issues/55/dependencies']==[{'owner':'inkstone','repo':'ISEP','index':5},{'owner':'inkstone','repo':'Arcrun','index':20}]" "$CP"
|
||||
p "★ s/backlog → s/todo(已排進里程碑,等人領票),type/bug 留著" "[3, 9]" \
|
||||
"sorted([pl['labels'] for mm,p,pl in W if mm=='PUT' and p=='/repos/inkstone/ISEP/issues/5/labels'][0])" "$CP"
|
||||
p "本來就 s/todo 的 Arcrun#20 不重貼標籤" "False" "any(p.endswith('/Arcrun/issues/20/labels') for _,p,_ in W)" "$CP"
|
||||
p "每張前置與載體都留了一則說明(第一行【身份】)" "True" \
|
||||
"sorted(p for mm,p,pl in W if mm=='POST' and p.endswith('/comments') and pl['body'].startswith('【身份】'))==['/repos/inkstone/Arcrun/issues/20/comments','/repos/inkstone/ISEP/issues/5/comments','/repos/inkstone/InkStoneCo/issues/55/comments']" "$CP"
|
||||
p "★ 不開任何新票(開工規約第 2 條)" "False" \
|
||||
"any(mm=='POST' and p.endswith('/issues') for mm,p,_ in W)" "$CP"
|
||||
p "離開碼 0,印出里程碑網址" "True" "rc is None and '/inkstone/InkStoneCo/milestone/71' in out" "$CP"
|
||||
CPS=$(j cmd_compose --title "雲端自己把票池消化成版本" --goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#55 inkstone/ISEP#5 --sign cloud-worker)
|
||||
p "--sign cloud-worker ⇒ 每則留言內文都署 [cloud-worker];--sign 的值不會被當成前置票" "True" \
|
||||
"rc is None and all('[cloud-worker]' in pl['body'] for mm,p,pl in W if p.endswith('/comments')) and not any('cloud-worker' in str(pl) for mm,p,pl in W if p.endswith('/dependencies'))" "$CPS"
|
||||
p "沒給 --sign ⇒ 不署一個寫死的名字(誰跑的就署誰)" "False" \
|
||||
"any('[cloud-worker]' in pl['body'] for mm,p,pl in W if p.endswith('/comments'))" "$CP"
|
||||
|
||||
echo
|
||||
echo " (該擋的:先全部驗過才寫——擋下時一筆都沒寫,而且理由一次列齊)"
|
||||
cb() { # cb <說明> <要在訊息裡看到的字> <argv...>
|
||||
what=$1; want=$2; shift 2
|
||||
p "$what → 離開碼 2、零寫入、訊息有「$want」" "True" "rc==2 and not W and '$want' in out" "$(j cmd_compose "$@")"
|
||||
}
|
||||
OK=(--goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#55)
|
||||
cb "★ 名字是版本號(開工規約第 5 條)" "版本號" --title "1.4.52 雲端零件包" "${OK[@]}" inkstone/ISEP#5
|
||||
cb "沒名字" "--title" "${OK[@]}" inkstone/ISEP#5
|
||||
cb "★ 沒期限(開工規約第 6 條)" "--due" --title 好名字 --goal g --carrier inkstone/InkStoneCo#55 inkstone/ISEP#5
|
||||
cb "期限 9999" "天內" --title 好名字 --goal g --due 9999-01-01 --carrier inkstone/InkStoneCo#55 inkstone/ISEP#5
|
||||
cb "期限在過去" "天內" --title 好名字 --goal g --due 2026-09-01 --carrier inkstone/InkStoneCo#55 inkstone/ISEP#5
|
||||
cb "載體不在 InkStoneCo(不准在子 repo 建里程碑)" "InkStoneCo" --title 好名字 --goal g --due 2026-10-01 --carrier inkstone/ISEP#1 inkstone/ISEP#5
|
||||
cb "沒有前置" "前置" --title 好名字 "${OK[@]}"
|
||||
cb "★ 載體掛 Human(驗收 3)" "載體 inkstone/InkStoneCo#81:掛著 Human" --title 好名字 --goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#81 inkstone/ISEP#5
|
||||
cb "★ 載體指派給 Leo(驗收 3)" "載體 inkstone/InkStoneCo#83:指派給 Leo" --title 好名字 --goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#83 inkstone/ISEP#5
|
||||
cb "載體本身是別的 open 里程碑載體的前置(那一輪還在跑)" "那一輪還在跑" --title 好名字 --goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#84 inkstone/ISEP#5
|
||||
cb "載體已在別的 open 里程碑" "已經掛在里程碑" --title 好名字 --goal g --due 2026-10-01 --carrier inkstone/InkStoneCo#82 inkstone/ISEP#5
|
||||
cb "同名 open 里程碑已在" "同名" --title "組好的 M" "${OK[@]}" inkstone/ISEP#5
|
||||
cb "★ 前置掛 Human(驗收 3)" "前置 inkstone/Arcrun#22:掛著 Human" --title 好名字 "${OK[@]}" inkstone/Arcrun#22
|
||||
cb "★ 前置指派給 Leo(驗收 3)" "前置 inkstone/Arcrun#23:指派給 Leo" --title 好名字 "${OK[@]}" inkstone/Arcrun#23
|
||||
cb "前置還沒分診(沒 s/*)" "還沒分診" --title 好名字 "${OK[@]}" inkstone/ISEP#1
|
||||
cb "前置是 s/triage(要不要做還沒決定)" "還沒分診" --title 好名字 "${OK[@]}" inkstone/ISEP#6
|
||||
cb "前置已經是別的里程碑載體的前置(一張票同時只排一輪)" "只排一輪" --title 好名字 "${OK[@]}" inkstone/ISEP#7
|
||||
cb "前置掛著子 repo 的里程碑" "已經掛在里程碑" --title 好名字 "${OK[@]}" inkstone/ISEP#8
|
||||
p "★ 好幾格不對時一次列齊(Human 前置+沒分診前置,兩個理由都在)" "True" \
|
||||
"rc==2 and not W and 'Arcrun#22:掛著 Human' in out and 'ISEP#1 還沒分診' in out" \
|
||||
"$(j cmd_compose --title 好名字 "${OK[@]}" inkstone/Arcrun#22 inkstone/ISEP#1)"
|
||||
p "參數層的錯(版本號名字)在打任何 API 之前就擋" "0" "len(rec)" \
|
||||
"$(j cmd_compose --title 1.2.3 "${OK[@]}" inkstone/ISEP#5)"
|
||||
|
||||
echo
|
||||
echo "── ④ 組了之後照里程碑往下做(驗收:再照里程碑往下做)──"
|
||||
POOLA=$(j cmd_pick --mainline "$MAIN" --pool --all --json)
|
||||
p "★ --pool:還沒到期的 InkStoneCo 里程碑「組好的 M」一組,成員是載體的前置(ISEP#7 的 s/backlog 不抓,Arcrun#21 s/todo 可抓)" \
|
||||
"['inkstone/Arcrun#21']" "[r['ref'] for r in json.loads(out) if r['group']=='里程碑']" "$POOLA"
|
||||
p "★ 載體票本身(InkStoneCo#80,s/backlog)不當成可做的票——里程碑那組與票池那組都沒有它" "False" \
|
||||
"any(r['ref']=='inkstone/InkStoneCo#80' for r in json.loads(out))" "$POOLA"
|
||||
p "里程碑那一組排在票池之前(先照里程碑做,再撿散票)" "True" \
|
||||
"(lambda g: g.index('里程碑') < g.index('票池'))([r['group'] for r in json.loads(out)])" "$POOLA"
|
||||
p "★ 待分診那一組最舊的先(ISEP#1 08-01 開),不含 Human/Leo" \
|
||||
"['inkstone/ISEP#1', 'inkstone/ISEP#10', 'inkstone/ISEP#2', 'inkstone/InkStoneCo#55']" \
|
||||
"[r['ref'] for r in json.loads(out) if r['group']=='待分診']" "$POOLA"
|
||||
p "每一列都帶下一步(里程碑那一列是 claim、待分診那一列是 triage)" "True" \
|
||||
"all((' triage ' in r['next']) == (r['group']=='待分診') for r in json.loads(out))" "$POOLA"
|
||||
p "沒帶 --pool(本機總管)→ 不看還沒到期的里程碑、也不回待分診(誤攔比漏擋嚴重)" "True" \
|
||||
"rc==1 and '里程碑「組好的' not in out and '待分診' not in out" "$(j cmd_pick --mainline "$MAIN")"
|
||||
p "pick 只讀不寫" "True" "not W" "$POOLA"
|
||||
|
||||
echo
|
||||
echo "── ⑤ 動詞接得上 ──"
|
||||
out=$(python3 "$T" usage triage 2>&1); got=$?
|
||||
if [ "$got" = 0 ] && printf '%s' "$out" | grep -q -- '--dup-of'; then PASS=$((PASS+1)); printf ' ✅ '; else FAIL=$((FAIL+1)); printf ' ❌ '; fi
|
||||
printf 'ticket usage triage 印得出用法\n'
|
||||
out=$(python3 "$T" usage compose 2>&1); got=$?
|
||||
if [ "$got" = 0 ] && printf '%s' "$out" | grep -q -- '--carrier'; then PASS=$((PASS+1)); printf ' ✅ '; else FAIL=$((FAIL+1)); printf ' ❌ '; fi
|
||||
printf 'ticket usage compose 印得出用法\n'
|
||||
out=$(python3 "$T" triage inkstone/ISEP#1 --to s/backlog --why x 2>&1); got=$?
|
||||
if [ "$got" != 0 ] && ! printf '%s' "$out" | grep -q '✅'; then PASS=$((PASS+1)); printf ' ✅ '; else FAIL=$((FAIL+1)); printf ' ❌ '; fi
|
||||
printf 'triage 連不上 Gitea → 非零離開、不印成功(got=%s)\n' "$got"
|
||||
|
||||
echo
|
||||
echo "通過 $PASS 條,失敗 $FAIL 條"
|
||||
[ "$FAIL" = 0 ] || exit 1
|
||||
+489
-31
@@ -35,6 +35,14 @@ leo 2026-08-16 三句話,本工具就是它們的機械化:
|
||||
ticket claim <票> [--as <登入名>] [--name <身份>] 認領=指派+s/doing+【身份】留言,一個動作
|
||||
ticket pick --claim … 上面兩件連著做
|
||||
|
||||
雲端工人分診+組里程碑(inkstone/ISEP#159:不只撿票,還要組票):
|
||||
|
||||
ticket triage --list [--all] [--json] 還沒有 s/* 的票(--all 連已分診的一起列,找重複用)
|
||||
ticket triage <票> --to <s/backlog|s/triage|s/pending> --why <一句> 給狀態+票上一則說明,一個動作
|
||||
ticket triage <票> --dup-of <留下的票> --why <一句> 重複:說明+close/duplicate+關+指回去
|
||||
ticket compose --title … --goal … --due YYYY-MM-DD --carrier inkstone/InkStoneCo#N <前置…>
|
||||
組一個 InkStoneCo 里程碑(先全部驗過才寫,不開新票)
|
||||
|
||||
票的寫法:`owner/repo#N`,例:`inkstone/InkStoneCo#44`
|
||||
"""
|
||||
import json
|
||||
@@ -909,6 +917,22 @@ USAGE = {
|
||||
" 認領=指派給自己 + 換成 s/doing + 第一行【身份】的留言,**一個動作**。\n"
|
||||
" 抓票規則在這裡再驗一次:不是 s/todo、已有人、掛 Human、不在主線也不逾期 ⇒ 擋下(離開碼 2);\n"
|
||||
" 帶 --pool(或 ISEP_DRAIN=1)時 open 票池裡的 s/todo/s/backlog 也認領得了",
|
||||
"triage":
|
||||
"用法:{bin} triage --list [--json] [--all]\n"
|
||||
" {bin} triage <owner/repo#N> --to <s/backlog|s/triage|s/pending> --why \"<一句理由>\" [--name <身份>] [--sign <署名>]\n"
|
||||
" {bin} triage <owner/repo#N> --dup-of <owner/repo#M> --why \"<一句理由>\" [--name <身份>] [--sign <署名>]\n"
|
||||
" 分診**還沒有 s/* 的票**(inkstone/ISEP#159):給它一個狀態+在票上留一則說明,一個動作;\n"
|
||||
" 重複的關掉並指向留下的那張(close/duplicate,留下的那張也留一則指回來)。\n"
|
||||
" --list 列出現在待分診的票;--all 連已分診的 open 票一起列(找重複用)。\n"
|
||||
" 掛 Human/human/*、指派給別人(含 Leo)的票一律不碰;s/todo 要經 compose 排進里程碑才給。",
|
||||
"compose":
|
||||
"用法:{bin} compose --title \"<這一輪要讓什麼變成真的>\" --goal \"<一段話>\" --due YYYY-MM-DD\n"
|
||||
" --carrier inkstone/InkStoneCo#N <前置票 owner/repo#M ...> [--name <身份>] [--sign <署名,例 cloud-worker>]\n"
|
||||
" 把已分診的票組成一個里程碑(inkstone/ISEP#159,CLAUDE.md 開工規約 1–7 條):\n"
|
||||
" 里程碑建在 inkstone/InkStoneCo、掛在既有的載體票上;前置票掛成載體票的相依,s/backlog → s/todo;\n"
|
||||
" deliverable=一個總管在 stage 驗過的新版本(版本號由總管定)。**不開任何新票。**\n"
|
||||
" 先全部驗過才寫:名字像版本號、期限不在 1–60 天內、同名里程碑已在、載體或前置掛 Human/指派別人、\n"
|
||||
" 前置還沒分診或已在別的 open 里程碑裡 ⇒ 一次列出全部理由,一筆都不寫(離開碼 2)。",
|
||||
"subtask":
|
||||
"用法:{bin} subtask <母票 owner/repo#N> --title \"<User Story>\" -F <內文檔>\n"
|
||||
" [--repo <收件 repo,預設跟母票同一個>] [--label <s/xxx,預設 s/todo>]\n"
|
||||
@@ -1507,7 +1531,19 @@ def _open_issues(owner, repo):
|
||||
return out
|
||||
|
||||
|
||||
def pool_candidates(owner, me, seen=()):
|
||||
def pool_issues(owner):
|
||||
"""整個 org 的 open 票(不含 PR)——**全局票池的唯一讀法**,pick 的票池層與 triage 共用這一份。
|
||||
|
||||
🔌 接口留給 inkstone/ISEP#154:全局票池是 Arcrun 工作流 `global_index`(tickets 庫),
|
||||
寫卡驗完之前先用這裡直打 Gitea。要換成讀 #154 那份時**只換這一個函式**——
|
||||
呼叫端拿到的形狀不變(Gitea issue dict,帶 `repository.full_name`),不另寫第三套撈法。"""
|
||||
out = []
|
||||
for r in _repos(owner):
|
||||
out += [it for it in _open_issues(owner, r) if not it.get("pull_request")]
|
||||
return out
|
||||
|
||||
|
||||
def pool_candidates(owner, me, seen=(), issues=None):
|
||||
"""第三層:整個 org 的 open 票池(inkstone/ISEP#130 c7801)。回 (可抓的票…, 池子大小, {不能抓的理由: 張數})。
|
||||
|
||||
leo 09-18:「我看到 Gitea 有 446 張票,要它自己領工作就是持續消化工作,它說沒事做?」
|
||||
@@ -1518,19 +1554,23 @@ def pool_candidates(owner, me, seen=()):
|
||||
|
||||
`seen`=前兩層已經列過的票號,不重複。理由表一併回傳:**可抓 0 張時要說得出池子去哪了**。"""
|
||||
found, why_count, total = [], {}, 0
|
||||
for r in _repos(owner):
|
||||
for it in _open_issues(owner, r):
|
||||
if it.get("pull_request"):
|
||||
continue
|
||||
total += 1
|
||||
ref = _ref_of(it)
|
||||
if ref in seen:
|
||||
continue
|
||||
ok, why = pickable(it, None, me, POOL_STATUSES)
|
||||
if ok:
|
||||
found.append(it)
|
||||
else:
|
||||
why_count[why] = why_count.get(why, 0) + 1
|
||||
for it in (pool_issues(owner) if issues is None else issues):
|
||||
if it.get("pull_request"):
|
||||
continue
|
||||
total += 1
|
||||
ref = _ref_of(it)
|
||||
if ref in seen:
|
||||
continue
|
||||
if _is_carrier(it):
|
||||
# 開工規約第 7 條:InkStoneCo 里程碑裡的票是載體(容器),做的是它的前置(inkstone/ISEP#159)
|
||||
why = "是里程碑「%s」的載體票(容器,做的是它的前置)" % it["milestone"].get("title")
|
||||
why_count[why] = why_count.get(why, 0) + 1
|
||||
continue
|
||||
ok, why = pickable(it, None, me, POOL_STATUSES)
|
||||
if ok:
|
||||
found.append(it)
|
||||
else:
|
||||
why_count[why] = why_count.get(why, 0) + 1
|
||||
return sorted(found, key=pick_order), total, why_count
|
||||
|
||||
|
||||
@@ -1546,7 +1586,39 @@ def mainline_members(ms):
|
||||
return _mainline_lib().collect_members(api, ms)
|
||||
|
||||
|
||||
def pick_candidates(ms, now=None):
|
||||
# 里程碑一律住在這個 repo(CLAUDE.md 開工規約第 7 條,leo 2026-09-13):
|
||||
# 裡面只放載體票,別 repo 的執行票是載體票的**前置**(/dependencies)。
|
||||
CARRIER_REPO = "InkStoneCo"
|
||||
|
||||
|
||||
def carrier_members(owner, m):
|
||||
"""InkStoneCo 里程碑的**執行票**=載體票沿相依收下去的票,不含載體票本身(載體是容器不是任務)。
|
||||
判準同主線(`hooks/lib/mainline.py::collect_members`,inkstone/ISEP#133),不另寫一份。"""
|
||||
refs, info = _mainline_lib().collect_members(
|
||||
api, {"owner": owner, "repo": CARRIER_REPO, "id": m.get("id"), "title": m.get("title")})
|
||||
roots = set(info.get("milestone") or [])
|
||||
return [r for r in refs if r not in roots]
|
||||
|
||||
|
||||
def _milestone_group(owner, r, m, me):
|
||||
"""一個里程碑底下現在可抓的票。InkStoneCo 的里程碑看相依邊;別的 repo 照舊看票上的里程碑欄。"""
|
||||
found = []
|
||||
if r == CARRIER_REPO:
|
||||
for ref in carrier_members(owner, m):
|
||||
it = _fetch_issue(ref)
|
||||
if it and (it.get("state") or "open") == "open" and pickable(it, None, me)[0]:
|
||||
found.append(it)
|
||||
return sorted(found, key=pick_order)
|
||||
for it in _issues_in(owner, r, m.get("title")):
|
||||
if str((it.get("milestone") or {}).get("id")) != str(m.get("id")):
|
||||
continue
|
||||
ok, _ = pickable(it, m.get("title"), me)
|
||||
if ok:
|
||||
found.append(it)
|
||||
return sorted(found, key=pick_order)
|
||||
|
||||
|
||||
def pick_candidates(ms, now=None, pool=False):
|
||||
"""依序回 [(組名, 里程碑標題, [可抓的票…])]:第一組是主線,之後是逾期的 open 里程碑
|
||||
(最逾期的先)。**每一組裡都已經照 pick_order 排好。**
|
||||
|
||||
@@ -1572,23 +1644,26 @@ def pick_candidates(ms, now=None):
|
||||
groups = [("主線", ms["title"], sorted(found, key=pick_order))]
|
||||
|
||||
repos = _repos(owner)
|
||||
overdue = []
|
||||
overdue, upcoming = [], []
|
||||
for r, m in _open_milestones(owner, repos):
|
||||
if "%s/%s#%s" % (owner, r, m.get("id")) == anchor:
|
||||
continue
|
||||
due = ML.due_of(m)
|
||||
if due and due < now:
|
||||
overdue.append((due, r, m))
|
||||
elif r == CARRIER_REPO:
|
||||
upcoming.append((due, r, m))
|
||||
for due, r, m in sorted(overdue, key=lambda x: x[0]):
|
||||
found = []
|
||||
for it in _issues_in(owner, r, m.get("title")):
|
||||
if str((it.get("milestone") or {}).get("id")) != str(m.get("id")):
|
||||
continue
|
||||
ok, _ = pickable(it, m.get("title"), me)
|
||||
if ok:
|
||||
found.append(it)
|
||||
groups.append(("逾期里程碑", "%s(%s/%s#%s)" % (m.get("title"), owner, r, m.get("id")),
|
||||
sorted(found, key=pick_order)))
|
||||
_milestone_group(owner, r, m, me)))
|
||||
if pool:
|
||||
# 第三層(inkstone/ISEP#159):還沒到期的 InkStoneCo 里程碑——雲端工人自己組的里程碑就在這裡,
|
||||
# 「組了之後照里程碑往下做」靠這一層:它的前置票先於票池裡散的票。期限近的先。
|
||||
# 只在接票的環境(--pool/ISEP_DRAIN=1)看:本機總管收工時不會因此被點名。
|
||||
far = now.replace(year=now.year + 100)
|
||||
for due, r, m in sorted(upcoming, key=lambda x: x[0] or far):
|
||||
groups.append(("里程碑", "%s(%s/%s#%s)" % (m.get("title"), owner, r, m.get("id")),
|
||||
_milestone_group(owner, r, m, me)))
|
||||
return groups
|
||||
|
||||
|
||||
@@ -1602,19 +1677,26 @@ def cmd_pick(argv):
|
||||
pool = pool_mode(argv)
|
||||
pool_total, pool_why = None, {}
|
||||
try:
|
||||
groups = pick_candidates(ms)
|
||||
# 第三層只在前兩層抓盡(或要看全部)時才讀——它要翻整個 org,能省就省
|
||||
groups = pick_candidates(ms, pool=pool)
|
||||
# 票池那一層只在前面都抓盡(或要看全部)時才讀——它要翻整個 org,能省就省
|
||||
if pool and (show_all or not any(its for _, _, its in groups)):
|
||||
seen = {_ref_of(it) for _, _, its in groups for it in its}
|
||||
found, pool_total, pool_why = pool_candidates(ms.get("owner") or ORG, _me(), seen)
|
||||
me = _me()
|
||||
issues = pool_issues(ms.get("owner") or ORG)
|
||||
found, pool_total, pool_why = pool_candidates(ms.get("owner") or ORG, me, seen, issues)
|
||||
groups.append(("票池", "open 票池(%s,不限里程碑)" % "/".join(POOL_STATUSES), found))
|
||||
# 最後一層(inkstone/ISEP#159):沒有可做的票時,還沒驗傷的票就是下一件事——
|
||||
# 回一張待分診的票,下一步是 `triage` 不是 `claim`(佇列閘照 row 的 next 印)。
|
||||
if show_all or not found:
|
||||
groups.append(("待分診", "還沒有 s/* 的 open 票", triage_candidates(issues, me)))
|
||||
except (urllib.error.URLError, OSError) as e:
|
||||
die("🔴 拿不到 Gitea(%s)。讀不到 ≠ 沒有可抓的票——先修連線,不要空轉也不要抓別的。" % e)
|
||||
|
||||
flat = [(g, t, it) for g, t, its in groups for it in its]
|
||||
if as_json:
|
||||
rows = [{"ref": _ref_of(it), "title": it.get("title"), "group": g, "milestone": t,
|
||||
"labels": _label_names(it), "created_at": it.get("created_at")}
|
||||
"labels": _label_names(it), "created_at": it.get("created_at"),
|
||||
"next": _next_cmd(g, _ref_of(it))}
|
||||
for g, t, it in flat]
|
||||
print(json.dumps(rows if show_all else (rows[0] if rows else None), ensure_ascii=False, indent=2))
|
||||
if not rows:
|
||||
@@ -1623,8 +1705,8 @@ def cmd_pick(argv):
|
||||
|
||||
print("🎯 主線:「%s」(來源:%s)" % (ms["title"], src))
|
||||
for g, t, its in groups:
|
||||
if g in ("主線", "票池") or its or show_all:
|
||||
print(" %s「%s」:可抓 %d 張" % (g, t, len(its)))
|
||||
if g in ("主線", "票池", "待分診") or its or show_all:
|
||||
print(" %s「%s」:%s %d 張" % (g, t, "待分診" if g == "待分診" else "可抓", len(its)))
|
||||
print()
|
||||
if not flat:
|
||||
_explain_empty(pool, pool_total, pool_why, sys.stdout)
|
||||
@@ -1636,6 +1718,12 @@ def cmd_pick(argv):
|
||||
print(" %s" % (it.get("title") or "")[:80])
|
||||
print(" %s「%s」 開票 %s" % (g, t, (it.get("created_at") or "")[:10]))
|
||||
print()
|
||||
if flat[0][0] == "待分診":
|
||||
# 分診不是認領:沒有人要「做」這張票,要的是決定它去哪
|
||||
print("📌 可做的票都抓盡了,下一件事是分診(還沒驗傷的票不會自己消失):")
|
||||
print(" " + _next_cmd("待分診", _ref_of(flat[0][2])))
|
||||
print(" 找重複:%s triage --list --all 組里程碑:%s usage compose" % (self_path(), self_path()))
|
||||
return
|
||||
if "--claim" in argv:
|
||||
top = flat[0][2]
|
||||
cmd_claim([_ref_of(top)] + [a for a in argv if a != "--claim"])
|
||||
@@ -1647,6 +1735,14 @@ def cmd_pick(argv):
|
||||
% (self_path(), _ref_of(flat[0][2]), HANDBACK_TO))
|
||||
|
||||
|
||||
def _next_cmd(group, ref):
|
||||
"""這一列的下一步,**貼了就能跑的那一行**(佇列閘照這一格印,不自己猜)。"""
|
||||
if group == "待分診":
|
||||
return ("%s triage %s --to <s/backlog|s/triage|s/pending> --why \"<一句理由>\""
|
||||
" (重複的:--dup-of <owner/repo#M>)" % (self_path(), ref))
|
||||
return "%s claim %s --name <你的名字>" % (self_path(), ref)
|
||||
|
||||
|
||||
def _explain_empty(pool, total, why, out):
|
||||
"""可抓 0 張時講清楚池子去哪了。**不准說成「正常、不是故障」**(inkstone/ISEP#130 c7797:
|
||||
09-18 六趟 run 都把「可抓 0 張」寫成正常收工,而池子裡有幾百張 open 票)。"""
|
||||
@@ -1729,10 +1825,372 @@ def cmd_claim(argv):
|
||||
|
||||
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
# inkstone/ISEP#159 — 分診+組里程碑:雲端工人不只「撿」,還要「組」
|
||||
#
|
||||
# leo 2026-09-18:「它看到票時要能夠組成 milestone 提出版本,所以不只是看票,還要組票。」
|
||||
# 「我需要幫忙的 AI,而不是我要一直服務它的 AI。」
|
||||
# 09-18 實量 inkstone org:open 302 張,沒有 s/* 的 74 張、沒掛里程碑的 257 張。
|
||||
#
|
||||
# 哪張跟哪張重複、哪幾張該組成一輪——那是**判斷**,留給讀票的人(雲端工人);
|
||||
# 這裡只管判斷寫回 Gitea 的那一步,讓它**一個動作、有說明、碰不到不該碰的**:
|
||||
# · 判準全是欄位與唯一識別碼(s/* 標籤、assignee 登入名、票號、里程碑 id),沒有一格在猜文字
|
||||
# · 不該碰的=掛 Human/human/*、指派給別人(含 Leo)——讀可以,一個字都不寫
|
||||
# · compose 先全部驗過才寫第一筆;驗不過一次列出全部理由(改一格撞一次=閘在懲罰人)
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
TRIAGE_TO = ("s/backlog", "s/triage", "s/pending")
|
||||
COMPOSE_MEMBER_STATUSES = ("s/backlog", "s/todo", "s/doing", "s/review", "s/stage", "s/pending")
|
||||
COMPOSE_MAX_DAYS = 60
|
||||
|
||||
|
||||
def hands_off(issue, me):
|
||||
"""這張票能不能寫(留言/改標籤/關)。回 None=可以,否則回理由。**純函式。**"""
|
||||
if not isinstance(issue, dict) or not issue.get("number"):
|
||||
return "讀不到這張票"
|
||||
if issue.get("pull_request"):
|
||||
return "這是 PR,不是票"
|
||||
if (issue.get("state") or "open") != "open":
|
||||
return "已經關了"
|
||||
labels = _label_names(issue)
|
||||
if human_gated(labels):
|
||||
return "掛著 %s——要 leo 親手做的,不碰" % "、".join(
|
||||
n for n in labels if n == "Human" or n.startswith("human/"))
|
||||
who = [a.get("login") for a in (issue.get("assignees") or []) if isinstance(a, dict)]
|
||||
if not who and isinstance(issue.get("assignee"), dict):
|
||||
who = [issue["assignee"].get("login")]
|
||||
others = [w for w in who if w and w != me]
|
||||
if others or (who and not me):
|
||||
return "指派給 %s——棒子在別人手上,不碰" % "、".join(str(w) for w in who if w)
|
||||
return None
|
||||
|
||||
|
||||
def _status_of(issue):
|
||||
return sorted(n for n in _label_names(issue) if n.startswith("s/"))
|
||||
|
||||
|
||||
def triageable(issue, me):
|
||||
"""待分診=還沒有任何 s/*,而且碰得了。回 (ok, 理由)。**純函式。**"""
|
||||
why = hands_off(issue, me)
|
||||
if why:
|
||||
return False, why
|
||||
st = _status_of(issue)
|
||||
if st:
|
||||
return False, "已經分診過(%s)" % "、".join(st)
|
||||
if _is_carrier(issue):
|
||||
return False, "是里程碑「%s」的載體票(容器,狀態跟著它的前置走)" % issue["milestone"].get("title")
|
||||
return True, "ok"
|
||||
|
||||
|
||||
def _is_carrier(issue):
|
||||
"""InkStoneCo 裡掛在 open 里程碑上的票=載體(開工規約第 7 條)。只看欄位:repo 與里程碑狀態。"""
|
||||
full = ((issue.get("repository") or {}).get("full_name")) or ""
|
||||
ims = issue.get("milestone") or {}
|
||||
return full == "%s/%s" % (ORG, CARRIER_REPO) and bool(ims) and (ims.get("state") or "open") == "open"
|
||||
|
||||
|
||||
def triage_candidates(issues, me):
|
||||
"""票池裡現在待分診的票,舊的先(放最久的最該有人看一眼)。"""
|
||||
found = [it for it in issues if triageable(it, me)[0]]
|
||||
return sorted(found, key=lambda it: (it.get("created_at") or "", _ref_of(it)))
|
||||
|
||||
|
||||
def _opt(argv, name, default=None):
|
||||
return argv[argv.index(name) + 1] if name in argv and argv.index(name) + 1 < len(argv) else default
|
||||
|
||||
|
||||
def _positional(argv, flags_with_value):
|
||||
out, skip = [], False
|
||||
for a in argv:
|
||||
if skip:
|
||||
skip = False
|
||||
continue
|
||||
if a in flags_with_value:
|
||||
skip = True
|
||||
continue
|
||||
if a.startswith("--"):
|
||||
continue
|
||||
out.append(a)
|
||||
return out
|
||||
|
||||
|
||||
def _fetch(owner, repo, num):
|
||||
it = api("/repos/%s/%s/issues/%d" % (owner, repo, num))
|
||||
if isinstance(it, dict):
|
||||
it.setdefault("repository", {"full_name": "%s/%s" % (owner, repo)})
|
||||
return it
|
||||
|
||||
|
||||
def _sign(argv):
|
||||
"""`--sign cloud-worker` ⇒ 留言內文署名 `[cloud-worker]`。身份欄(--name)只收名單上的名字,
|
||||
雲端工人不在名單上(cloud-worker.md 步驟 1),署名就寫在內文——誰跑的就署誰,不寫死。"""
|
||||
v = (_opt(argv, "--sign") or "").strip()
|
||||
return "[%s]" % v if v else ""
|
||||
|
||||
|
||||
def _ident_line(name, owner, repo):
|
||||
return "【身份】%s/%s/%s/-" % (name, owner, repo)
|
||||
|
||||
|
||||
# ── triage ───────────────────────────────────────────────────────────────
|
||||
def cmd_triage(argv):
|
||||
"""分診一張還沒有 s/* 的票:給狀態+留說明(或當重複關掉並指向留下的那張),一個動作。"""
|
||||
if not argv or argv[0] in ("-h", "--help"):
|
||||
die(usage_text("triage"), 0 if argv else 2)
|
||||
if argv[0] == "--list":
|
||||
return _triage_list(argv[1:])
|
||||
|
||||
ref = argv[0]
|
||||
owner, repo, num = parse_ref(ref)
|
||||
to, dup, why = _opt(argv, "--to"), _opt(argv, "--dup-of"), (_opt(argv, "--why") or "").strip()
|
||||
name = _opt(argv, "--name") or "subagent"
|
||||
# ── 離線就能判的先判,一通 API 都不打 ──
|
||||
problems = []
|
||||
if bool(to) == bool(dup):
|
||||
problems.append("--to 與 --dup-of 恰好給一個(分到哪個狀態,或跟哪張重複)")
|
||||
if to and to not in TRIAGE_TO:
|
||||
extra = ("——s/todo 的意思是「已排進里程碑」,走 `ticket compose` 排進去才給" if to == "s/todo" else "")
|
||||
problems.append("--to 只收 %s,你給的是 %s%s" % ("/".join(TRIAGE_TO), to, extra))
|
||||
if not why:
|
||||
problems.append("--why 要寫一句理由——票上那則說明就是它(驗收:每張被動過的票上都說得出分到哪、為什麼)")
|
||||
dparts = None
|
||||
if dup:
|
||||
dparts = parse_ref(dup)
|
||||
if dparts == (owner, repo, num):
|
||||
problems.append("--dup-of 指到自己")
|
||||
if problems:
|
||||
die("🚫 triage %s 還沒送出,參數要補:\n%s\n\n%s" % (
|
||||
ref, "\n".join(" · " + p for p in problems), usage_text("triage")))
|
||||
ident = _ident_line(name, owner, repo)
|
||||
check_identity(ident, "分診留言")
|
||||
|
||||
me = _me()
|
||||
issue = _fetch(owner, repo, num)
|
||||
ok, reason = triageable(issue, me)
|
||||
if not ok:
|
||||
die("🚫 %s 不分診:%s\n 出路:`%s triage --list` 列得出現在待分診的票;"
|
||||
"已經有 s/* 的票要改狀態,走 `ticket handback`/`ticket decide`。" % (ref, reason, self_path()))
|
||||
before_labels = _label_names(issue)
|
||||
new_status = "close/duplicate" if dup else to
|
||||
ids = _labels_of(owner, repo)
|
||||
if new_status not in ids:
|
||||
die("🚫 %s/%s 沒有標籤 %s(標籤的唯一真相源是 ISEP labels.yaml,改那裡再跑 gitea-labels-sync)"
|
||||
% (owner, repo, new_status))
|
||||
|
||||
target, target_note = None, None
|
||||
if dup:
|
||||
target = _fetch(*dparts)
|
||||
if not isinstance(target, dict) or not target.get("number"):
|
||||
die("🚫 --dup-of %s 讀不到" % dup)
|
||||
if target.get("pull_request"):
|
||||
die("🚫 --dup-of %s 是 PR,不是票" % dup)
|
||||
if (target.get("state") or "open") != "open":
|
||||
die("🚫 --dup-of %s 已經關了——跟一張關掉的票「重複」不代表這件事做完了。\n"
|
||||
" 出路:這張給 --to s/triage 並在 --why 寫「疑似與 %s 重複、那張已關」,交總管看。" % (dup, dup))
|
||||
target_note = hands_off(target, me)
|
||||
|
||||
# ── 寫:說明先落地,再改欄位(改到一半炸掉時,票上至少說得出發生了什麼)──
|
||||
dref = "%s/%s#%d" % dparts if dparts else None
|
||||
lines = [ident, "",
|
||||
"🗂️ **分診**(inkstone/ISEP#159)%s" % _sign(argv), ""]
|
||||
if dup:
|
||||
lines += ["- 與 %s 重複 → 關掉這張,後續在那張" % dref,
|
||||
"- 為什麼:%s" % why]
|
||||
else:
|
||||
lines += ["- 狀態:(沒有 s/*)→ `%s`" % to,
|
||||
"- 為什麼:%s" % why]
|
||||
api("/repos/%s/%s/issues/%d/comments" % (owner, repo, num), {"body": "\n".join(lines)})
|
||||
keep = [n for n in before_labels if not n.startswith("s/")] + [new_status]
|
||||
api("/repos/%s/%s/issues/%d/labels" % (owner, repo, num), {"labels": [ids[n] for n in keep]}, method="PUT")
|
||||
if dup:
|
||||
api("/repos/%s/%s/issues/%d" % (owner, repo, num), {"state": "closed"}, method="PATCH")
|
||||
if target_note is None:
|
||||
to_ident = _ident_line(name, dparts[0], dparts[1])
|
||||
api("/repos/%s/%s/issues/%d/comments" % dparts,
|
||||
{"body": "\n".join([to_ident, "", "🗂️ %s 與這張重複,已關掉併到這裡(%s)%s" % (ref, why, _sign(argv))])})
|
||||
print("✅ 分診 %s → %s" % (ref, ("重複,併入 %s(已關)" % dref) if dup else to))
|
||||
print(" 票上留了說明:%s" % why)
|
||||
if dup and target_note:
|
||||
print(" ⚪ 沒在 %s 留指回來的留言:%s" % (dref, target_note))
|
||||
|
||||
|
||||
def _triage_list(argv):
|
||||
owner = ORG
|
||||
me = _me()
|
||||
issues = pool_issues(owner)
|
||||
pending = triage_candidates(issues, me)
|
||||
show = issues if "--all" in argv else pending
|
||||
if "--json" in argv:
|
||||
rows = [{"ref": _ref_of(it), "title": it.get("title"), "status": _status_of(it),
|
||||
"milestone": (it.get("milestone") or {}).get("title"),
|
||||
"triageable": triageable(it, me)[0], "created_at": it.get("created_at")}
|
||||
for it in sorted(show, key=lambda it: _ref_of(it))]
|
||||
print(json.dumps(rows, ensure_ascii=False, indent=2))
|
||||
return
|
||||
untouched = sum(1 for it in issues if not _status_of(it) and not triageable(it, me)[0])
|
||||
print("🗂️ open 票池 %d 張;待分診 %d 張(另有 %d 張沒 s/* 但掛 Human/指派給別人,不碰)"
|
||||
% (len(issues), len(pending), untouched))
|
||||
for it in sorted(show, key=lambda it: _ref_of(it)):
|
||||
st = "、".join(_status_of(it)) or "(沒有 s/*)"
|
||||
print(" %-28s %-12s %s" % (_ref_of(it), st, (it.get("title") or "")[:70]))
|
||||
if pending:
|
||||
print("\n📌 %s" % _next_cmd("待分診", _ref_of(pending[0])))
|
||||
|
||||
|
||||
# ── compose ──────────────────────────────────────────────────────────────
|
||||
def _version_like(title):
|
||||
"""名字就是版本號(`1.4.52 雲端零件包`)——開工規約第 5 條:版本號是 deliverable,不是名字。"""
|
||||
return bool(re.match(r"^\s*[vV]?\d+(\.\d+)+", title or ""))
|
||||
|
||||
|
||||
def cmd_compose(argv):
|
||||
"""把已分診的票組成一個 InkStoneCo 里程碑(載體票+前置),先全部驗過才寫。"""
|
||||
if not argv or argv[0] in ("-h", "--help"):
|
||||
die(usage_text("compose"), 0 if argv else 2)
|
||||
from datetime import datetime, timedelta, timezone
|
||||
title = (_opt(argv, "--title") or "").strip()
|
||||
goal = (_opt(argv, "--goal") or "").strip()
|
||||
due_s = (_opt(argv, "--due") or "").strip()
|
||||
carrier_s = _opt(argv, "--carrier")
|
||||
name = _opt(argv, "--name") or "subagent"
|
||||
members_s = _positional(argv, ("--title", "--goal", "--due", "--carrier", "--name", "--sign"))
|
||||
|
||||
problems = []
|
||||
if not title:
|
||||
problems.append("--title 要寫:名字回答「這一輪要讓什麼變成真的」(開工規約第 5 條)")
|
||||
elif _version_like(title):
|
||||
problems.append("--title「%s」以版本號開頭——版本號是 deliverable 不是名字(開工規約第 5 條,leo 2026-08-24)" % title)
|
||||
if not goal:
|
||||
problems.append("--goal 要寫一段話:這一輪做完,用戶那邊什麼會變成真的")
|
||||
due = None
|
||||
now = _now()
|
||||
try:
|
||||
due = datetime.strptime(due_s, "%Y-%m-%d").replace(hour=23, minute=59, second=59, tzinfo=timezone.utc)
|
||||
except ValueError:
|
||||
problems.append("--due 要是 YYYY-MM-DD(開工規約第 6 條:期限一律要填),你給的是「%s」" % due_s)
|
||||
if due and not (now < due <= now + timedelta(days=COMPOSE_MAX_DAYS + 1)):
|
||||
problems.append("--due %s 不在今天之後 %d 天內——過去的期限等於已逾期,太遠的期限是「沒有期限」穿了期限的衣服"
|
||||
% (due_s, COMPOSE_MAX_DAYS))
|
||||
carrier = None
|
||||
if not carrier_s:
|
||||
problems.append("--carrier 要給一張 inkstone/InkStoneCo 的既有票當載體(開工規約第 7 條;不開新票)")
|
||||
else:
|
||||
carrier = parse_ref(carrier_s)
|
||||
if carrier[:2] != (ORG, CARRIER_REPO):
|
||||
problems.append("--carrier %s 不在 %s/%s——里程碑一律建在 InkStoneCo,載體票也在那裡" % (carrier_s, ORG, CARRIER_REPO))
|
||||
members = []
|
||||
for m in members_s:
|
||||
r = parse_ref(m)
|
||||
if r == carrier:
|
||||
problems.append("%s 是載體票本身,不用再列成前置" % m)
|
||||
elif r not in members:
|
||||
members.append(r)
|
||||
if not members:
|
||||
problems.append("至少列一張前置票(別 repo 的執行票)——沒有前置的里程碑交不出版本")
|
||||
if problems:
|
||||
die("🚫 compose 還沒送出(一筆都沒寫):\n%s\n\n%s" % (
|
||||
"\n".join(" · " + p for p in problems), usage_text("compose")))
|
||||
ident = _ident_line(name, ORG, CARRIER_REPO)
|
||||
check_identity(ident, "組里程碑留言")
|
||||
|
||||
# ── 線上驗:全部讀過一次,理由收齊才決定寫不寫 ──
|
||||
me = _me()
|
||||
ML = _mainline_lib()
|
||||
cref = "%s/%s#%d" % carrier
|
||||
citem = _fetch(*carrier)
|
||||
why = hands_off(citem, me)
|
||||
if why:
|
||||
problems.append("載體 %s:%s" % (cref, why))
|
||||
elif citem.get("milestone") and (citem["milestone"].get("state") or "open") == "open":
|
||||
problems.append("載體 %s 已經掛在里程碑「%s」——一張載體只載一輪" % (cref, citem["milestone"].get("title")))
|
||||
else:
|
||||
for b in _blocks(*carrier):
|
||||
bm = (b or {}).get("milestone") or {}
|
||||
if (b or {}).get("state", "open") == "open" and bm and (bm.get("state") or "open") == "open":
|
||||
problems.append("載體 %s 已經是 %s(里程碑「%s」)的前置——它那一輪還在跑,不能再載另一輪"
|
||||
% (cref, ML.issue_ref(b) or "?", bm.get("title")))
|
||||
break
|
||||
existing = api("/repos/%s/%s/milestones?state=open&limit=100" % (ORG, CARRIER_REPO)) or []
|
||||
for m in existing:
|
||||
if isinstance(m, dict) and ML.norm(m.get("title")) == ML.norm(title):
|
||||
problems.append("InkStoneCo 已經有 open 里程碑「%s」(id %s)——同名不再建一個" % (m.get("title"), m.get("id")))
|
||||
rows = []
|
||||
for mo, mr, mn in members:
|
||||
mref = "%s/%s#%d" % (mo, mr, mn)
|
||||
it = _fetch(mo, mr, mn)
|
||||
why = hands_off(it, me)
|
||||
if why:
|
||||
problems.append("前置 %s:%s" % (mref, why))
|
||||
continue
|
||||
st = _status_of(it)
|
||||
if len(st) != 1 or st[0] not in COMPOSE_MEMBER_STATUSES:
|
||||
problems.append("前置 %s 還沒分診(現在 %s)——先 `ticket triage` 決定要不要做" % (mref, st or "沒有 s/*"))
|
||||
continue
|
||||
ims = it.get("milestone") or {}
|
||||
if ims and (ims.get("state") or "open") == "open":
|
||||
problems.append("前置 %s 已經掛在里程碑「%s」" % (mref, ims.get("title")))
|
||||
continue
|
||||
for b in _blocks(mo, mr, mn):
|
||||
bm = (b or {}).get("milestone") or {}
|
||||
if (b or {}).get("state", "open") == "open" and bm and (bm.get("state") or "open") == "open":
|
||||
problems.append("前置 %s 已經是 %s(里程碑「%s」)的前置——一張票同時只排一輪"
|
||||
% (mref, ML.issue_ref(b) or "?", bm.get("title")))
|
||||
break
|
||||
else:
|
||||
rows.append(((mo, mr, mn), mref, it, st[0]))
|
||||
if problems:
|
||||
die("🚫 compose 驗不過(一筆都沒寫):\n%s\n\n"
|
||||
"出路:把上面每一格換掉(換一張載體、拿掉那張前置、先 triage),再送一次。"
|
||||
"掛 Human/指派給 Leo 的票不會被組進來——那是 leo 的。" % "\n".join(" · " + p for p in problems))
|
||||
|
||||
# ── 寫 ──
|
||||
member_refs = [r for _, r, _, _ in rows]
|
||||
desc = "\n".join([
|
||||
"這一輪要讓什麼變成真的:%s" % goal,
|
||||
"deliverable=一個總管在 stage 驗過的新版本(版本號由總管定);前置全部關閉=100%=才出版本。",
|
||||
"載體票:%s;前置:%s" % (cref, "、".join(member_refs)),
|
||||
"組票:%s %s(inkstone/ISEP#159;CLAUDE.md 開工規約 1–7 條)" % (_sign(argv) or name, now.strftime("%Y-%m-%d")),
|
||||
])
|
||||
ms = api("/repos/%s/%s/milestones" % (ORG, CARRIER_REPO),
|
||||
{"title": title, "description": desc, "due_on": due.strftime("%Y-%m-%dT%H:%M:%SZ")})
|
||||
mid = (ms or {}).get("id")
|
||||
if not mid:
|
||||
die("🔴 建里程碑沒拿到 id(Gitea 回:%s)——後面一筆都沒寫" % str(ms)[:200])
|
||||
url = "%s/%s/%s/milestone/%s" % (HOST, ORG, CARRIER_REPO, mid)
|
||||
print("✅ 里程碑「%s」(%s/%s milestone %s,期限 %s)" % (title, ORG, CARRIER_REPO, mid, due_s))
|
||||
api("/repos/%s/%s/issues/%d" % carrier, {"milestone": mid}, method="PATCH")
|
||||
print(" 載體 %s 掛上里程碑" % cref)
|
||||
for (mo, mr, mn), mref, it, st in rows:
|
||||
add_dependency(carrier, (mo, mr, mn))
|
||||
moved = ""
|
||||
if st == "s/backlog":
|
||||
ids = _labels_of(mo, mr)
|
||||
keep = [n for n in _label_names(it) if not n.startswith("s/")] + ["s/todo"]
|
||||
if all(n in ids for n in keep):
|
||||
api("/repos/%s/%s/issues/%d/labels" % (mo, mr, mn), {"labels": [ids[n] for n in keep]}, method="PUT")
|
||||
moved = ";s/backlog → s/todo"
|
||||
api("/repos/%s/%s/issues/%d/comments" % (mo, mr, mn),
|
||||
{"body": "\n".join([_ident_line(name, mo, mr), "",
|
||||
"🧩 排進里程碑「%s」(載體 %s,期限 %s)%s %s" % (title, cref, due_s, moved, _sign(argv)),
|
||||
url])})
|
||||
print(" 前置 %s%s" % (mref, moved))
|
||||
api("/repos/%s/%s/issues/%d/comments" % carrier,
|
||||
{"body": "\n".join([ident, "", "🧩 **組里程碑**(inkstone/ISEP#159)%s" % _sign(argv), "",
|
||||
"- 里程碑:「%s」→ %s" % (title, url),
|
||||
"- 期限:%s" % due_s,
|
||||
"- 這一輪要讓什麼變成真的:%s" % goal,
|
||||
"- 前置(全部關閉=100%%=才出版本):%s" % "、".join(member_refs),
|
||||
"- deliverable:一個總管在 stage 驗過的新版本(版本號由總管定)"])})
|
||||
print(" %s" % url)
|
||||
print("\n📌 接下來照里程碑做:`%s pick --pool` 會先回這個里程碑的前置票(還沒到期的里程碑排在散票之前)" % self_path())
|
||||
|
||||
|
||||
|
||||
CMDS = {"where": cmd_where, "say": cmd_say, "new": cmd_new, "close": cmd_close,
|
||||
"decide": cmd_decide, "subtask": cmd_subtask, "handoff": cmd_subtask,
|
||||
"handback": cmd_handback, "mine": cmd_mine, "loose": cmd_loose,
|
||||
"usage": cmd_usage, "pick": cmd_pick, "claim": cmd_claim}
|
||||
"usage": cmd_usage, "pick": cmd_pick, "claim": cmd_claim,
|
||||
"triage": cmd_triage, "compose": cmd_compose}
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2 or sys.argv[1] not in CMDS:
|
||||
|
||||
Reference in New Issue
Block a user