Author SHA1 Message Date
rootandClaude Sonnet 5.5 34cf87a0fa fix: git 走 HTTPS 時改用 tea 預設 login 的 token 認證
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 01:36:17 +00:00
rootandClaude Sonnet 5.5 891db4e7f6 fix: tea 遇到 TLS 憑證錯誤時自動重試,避免輪詢腳本中斷
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 01:33:15 +00:00
rootandClaude Sonnet 5.5 58c76f517a chore: bump plugin manifests to 0.0.6
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 01:27:24 +00:00
rootandClaude Sonnet 5.5 7bd04b0bba fix: 所有 tea 操作改用預設使用者並同步 git 身分
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-08 01:26:57 +00:00
admin 15c87b3c08 Merge pull request '透過 revert 恢復 Claude agent 並升級至 0.0.5' (#9) from revert-copilot-0.0.5 into master
Reviewed-on: #9
Reviewed-by: 系統管理員 <1+admin@noreply.localhost>
2026-10-07 17:08:33 +00:00
root 1c7791c2ba chore: bump plugin manifests to 0.0.5 2026-10-07 17:04:51 +00:00
root e2725b91ee Revert "改用 Copilot 並將模型設為 auto"
This reverts commit c8b7dd9876.
2026-10-07 17:04:51 +00:00
10 changed files with 91 additions and 19 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "herdr-issue", "name": "herdr-issue",
"version": "0.0.4", "version": "0.0.6",
"description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。", "description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。",
"skills": "./skills", "skills": "./skills",
"author": { "author": {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "herdr-issue", "name": "herdr-issue",
"version": "0.0.4", "version": "0.0.6",
"description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。", "description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。",
"skills": "./skills" "skills": "./skills"
} }
+1 -1
View File
@@ -187,7 +187,7 @@ copilot plugin marketplace remove herdr-issue
### `herdr-issue` ### `herdr-issue`
透過 Herdr 讓 GitHub Copilot agent 逐一實作 Gitea 議題:每個議題一個 worktree 與 tab,監看到議題關閉後清理,並推薦下一批可執行的議題。僅在使用者執行 `/herdr-issue` 或明確要求以 Herdr 驅動 Gitea 議題/repo 連結時觸發。需在 Herdr 內(`HERDR_ENV=1`)執行。 透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題:每個議題一個 worktree 與 tab,監看到議題關閉後清理,並推薦下一批可執行的議題。僅在使用者執行 `/herdr-issue` 或明確要求以 Herdr 驅動 Gitea 議題/repo 連結時觸發。需在 Herdr 內(`HERDR_ENV=1`)執行。
- **Claude Code**:`/herdr-issue:herdr-issue <議題或 repo 連結>` - **Claude Code**:`/herdr-issue:herdr-issue <議題或 repo 連結>`
- **skills CLI**:`npx skills add https://gitea.jsc.idv.tw/plugins/herdr-issue.git --skill herdr-issue -g`,之後 `/herdr-issue <連結>` - **skills CLI**:`npx skills add https://gitea.jsc.idv.tw/plugins/herdr-issue.git --skill herdr-issue -g`,之後 `/herdr-issue <連結>`
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "herdr-issue", "name": "herdr-issue",
"version": "0.0.4", "version": "0.0.6",
"description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。", "description": "透過 Herdr 讓 Claude agent 逐一實作 Gitea 議題(每個議題一個 worktree 與 tab)。",
"skills": "./skills/" "skills": "./skills/"
} }
+9 -3
View File
@@ -1,11 +1,15 @@
--- ---
name: herdr-issue name: herdr-issue
description: "Run Gitea issues through Herdr: one GitHub Copilot agent per issue in its own worktree and tab, watch the issue to closure, then offer the next unblocked issues. Use only when the user runs /herdr-issue or explicitly asks to drive a Gitea issue or repo link with Herdr." description: "Run Gitea issues through Herdr: one Claude agent per issue in its own worktree and tab, watch the issue to closure, then offer the next unblocked issues. Use only when the user runs /herdr-issue or explicitly asks to drive a Gitea issue or repo link with Herdr."
--- ---
# herdr-issue # herdr-issue
把 Gitea 議題交給 Herdr 裡的 GitHub Copilot agent 實作。所有確定性的工作都在 `scripts/` 裡,你只在「要做決定」的時刻出手。腳本都要在該 repo 的 clone 裡執行;`S` 代表 `~/.claude/skills/herdr-issue/scripts`。 把 Gitea 議題交給 Herdr 裡的 Claude agent 實作。所有確定性的工作都在 `scripts/` 裡,你只在「要做決定」的時刻出手。腳本都要在該 repo 的 clone 裡執行;`S` 代表 `~/.claude/skills/herdr-issue/scripts`。
## 使用者身分
Gitea 一律以 tea 的預設 login(`tea login list` 中 default 為 true 的那個)操作:`lib.sh` 會取出它並讓所有 tea 呼叫加上 `--login`,避免在 clone 裡 tea 依 remote URL 挑到別的帳號。`start.sh` 也會把該使用者的名稱與 email 設成 worktree 的 git commit 身分。git 走 HTTPS 的帳密由 `scripts/git-credential.sh`(git credential helper)提供,用同一個 login 的 token:腳本內的 git 自動套用,`start.sh` 也會把它寫進 clone 的本地設定(只對該 Gitea 主機),所以 agent 在 worktree 裡 push/fetch 不會再出現 `could not read Username`。要換人先 `tea login default <name>`,或設 `HERDR_ISSUE_LOGIN`。
## 語言規則 ## 語言規則
@@ -55,4 +59,6 @@ description: "Run Gitea issues through Herdr: one GitHub Copilot agent per issue
| `tick.sh` | 子 agent | 勾議題內文第 k 個核取方塊 | | `tick.sh` | 子 agent | 勾議題內文第 k 個核取方塊 |
| `pr-wait.sh` | 子 agent(背景) | 等 PR 衝突、關閉或合併 | | `pr-wait.sh` | 子 agent(背景) | 等 PR 衝突、關閉或合併 |
環境變數:`HERDR_ISSUE_INTERVAL`(pr-wait 輪詢秒數,預設 300)、`HERDR_ISSUE_WATCH_INTERVAL`(watch-issue 輪詢秒數,預設 5)、`HERDR_ISSUE_BLOCKED_AFTER`(blocked 多久才通知,預設 60 秒)、`HERDR_ISSUE_MODEL`(預設 `auto`)。 TLS/憑證錯誤:`lib.sh` 的 tea 包裝會自動重試(預設 5 次、間隔 3 秒),輪詢中的 `watch-issue.sh`、`pr-wait.sh` 因此不會被一次性的連線問題打斷;不會關閉憑證驗證。若憑證長期有問題,請修正伺服器或系統 CA,而不是略過驗證。
環境變數:`HERDR_ISSUE_TLS_RETRIES`(TLS 重試次數,預設 5)、`HERDR_ISSUE_INTERVAL`(pr-wait 輪詢秒數,預設 300)、`HERDR_ISSUE_WATCH_INTERVAL`(watch-issue 輪詢秒數,預設 5)、`HERDR_ISSUE_BLOCKED_AFTER`(blocked 多久才通知,預設 60 秒)、`HERDR_ISSUE_MODEL`(預設 `claude-opus-5-5`)。
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# git credential helper:用 tea 預設 login 的帳號與 token 回應 HTTPS 認證,避免 git 要互動輸入帳密
# ("could not read Username ... No such device or address")。只處理 get,且只回應該 login 的主機。
[ "${1:-}" = get ] || exit 0
exec python3 -c '
import os, sys
req = dict(l.split("=", 1) for l in sys.stdin.read().splitlines() if "=" in l)
cfg = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "tea", "config.yml")
logins, cur = [], None
for line in open(cfg):
s = line.strip()
if s.startswith("- name:"):
cur = {"name": s.split(":", 1)[1].strip()}; logins.append(cur)
elif cur is not None and ":" in s:
k, v = s.split(":", 1)
if k in ("url", "token", "user", "default"): cur[k] = v.strip().strip("\"\x27")
want = os.environ.get("HERDR_ISSUE_LOGIN")
pick = next((l for l in logins if l["name"] == want), None) if want else None
pick = pick or next((l for l in logins if l.get("default") == "true"), None)
if not pick or not pick.get("token"): sys.exit(0)
host = pick["url"].split("://", 1)[-1].rstrip("/")
if req.get("host") != host: sys.exit(0)
print("username=" + pick["user"]); print("password=" + pick["token"])
'
+30 -1
View File
@@ -6,11 +6,40 @@ LABEL="in-progress"
LABEL_COLOR="0e8a16" LABEL_COLOR="0e8a16"
LABEL_DESC="Herdr 的 agent 正在實作" LABEL_DESC="Herdr 的 agent 正在實作"
INTERVAL="${HERDR_ISSUE_INTERVAL:-300}" INTERVAL="${HERDR_ISSUE_INTERVAL:-300}"
MODEL="${HERDR_ISSUE_MODEL:-auto}" MODEL="${HERDR_ISSUE_MODEL:-claude-opus-5-5}"
SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
die() { echo "herdr-issue: $*" >&2; exit 1; } die() { echo "herdr-issue: $*" >&2; exit 1; }
# tea 的預設使用者。在 clone 裡 tea 會依 remote URL 挑第一個符合的 login(可能不是預設的),
# 所以明確取 default 那個 login,所有 tea 呼叫都加 --login。可用 HERDR_ISSUE_LOGIN 覆寫。
if [ -z "${HERDR_ISSUE_LOGIN:-}" ]; then
HERDR_ISSUE_LOGIN="$(tea login list --output json | python3 -c "import sys,json
print(next((l['name'] for l in json.load(sys.stdin) if str(l.get('default')).lower()=='true'),''))")"
fi
[ -n "$HERDR_ISSUE_LOGIN" ] || { echo "herdr-issue: tea 沒有預設 login,請先 tea login default <name>" >&2; exit 1; }
export HERDR_ISSUE_LOGIN
# git 走 HTTPS 時沒有帳密又不能互動輸入會失敗,所以腳本內的 git 一律用 tea 預設 login 的 token(git-credential.sh)。
export GIT_TERMINAL_PROMPT=0
git() { command git -c credential.helper= -c "credential.helper=$SCRIPTS/git-credential.sh" "$@"; }
# TLS/憑證錯誤多半是暫時的(連線被重置、代理、時鐘),遇到就重試幾次,不要讓輪詢中的腳本因此中斷;
# 其他錯誤原樣回傳。不關閉憑證驗證。重試次數 HERDR_ISSUE_TLS_RETRIES(預設 5),間隔 3 秒。
tea() {
local out err rc=0 try max="${HERDR_ISSUE_TLS_RETRIES:-5}" ef; ef="$(mktemp)"
for ((try = 1; try <= max; try++)); do
out="$(command tea "$1" --login "$HERDR_ISSUE_LOGIN" "${@:2}" 2>"$ef")" && rc=0 || rc=$?
err="$(cat "$ef")"
if ! grep -qiE 'tls|x509|certificate|handshake' <<<"$out$err"; then break; fi
echo "herdr-issue: tea 遇到 TLS/憑證錯誤(第 $try/$max 次),3 秒後重試" >&2
rc=${rc/#0/1}; sleep 3
done
rm -f "$ef"
[ -z "$err" ] || printf '%s\n' "$err" >&2
printf '%s\n' "$out"
return "$rc"
}
# 從 stdin 讀 JSON,執行 python 片段,d 是解析後的物件。 # 從 stdin 讀 JSON,執行 python 片段,d 是解析後的物件。
jq_py() { python3 -c "import sys,json jq_py() { python3 -c "import sys,json
def find(o,k): def find(o,k):
+5 -4
View File
@@ -1,17 +1,18 @@
/implement {LINK} /mattpocock-skills:implement {LINK}
你在分支 issue-{N} 的 worktree 裡,從 origin/main 建立,請在這裡實作,不要另外建 worktree。 你在分支 issue-{N} 的 worktree 裡,從 origin/main 建立,請在這裡實作,不要另外建 worktree。
{RESUME} {RESUME}
規則: 規則:
0. 所有回覆、commit 訊息、PR 標題與描述、議題留言一律使用繁體中文(程式碼與指令除外)。 0. 一律以 tea 的預設使用者 {LOGIN} 操作 Gitea(tea 指令加 --login {LOGIN}),git commit 身分已設為同一人。
所有回覆、commit 訊息、PR 標題與描述、議題留言一律使用繁體中文(程式碼與指令除外)。
1. 議題的代辦項目是內文 Acceptance criteria 的核取方塊。每完成一項就執行 1. 議題的代辦項目是內文 Acceptance criteria 的核取方塊。每完成一項就執行
{S}/tick.sh {REPO} {N} <第幾項>(從第一個核取方塊數起,已勾的也算) {S}/tick.sh {REPO} {N} <第幾項>(從第一個核取方塊數起,已勾的也算)
它會重新讀取最新內文再改,不要自己用 tea issues edit 重寫整段。 它會重新讀取最新內文再改,不要自己用 tea issues edit 重寫整段。
2. 全部完成後推送分支並建立 PR 回 main: 2. 全部完成後推送分支並建立 PR 回 main:
tea pulls create --repo {REPO} --base main --head issue-{N} --title "<標題>" --description "<摘要> tea pulls create --login {LOGIN} --repo {REPO} --base main --head issue-{N} --title "<標題>" --description "<摘要>
Closes #{N}" Closes #{N}"
3. 然後在背景執行 {S}/pr-wait.sh {REPO} {N},它會在 PR 有衝突、被關閉或合併時結束並印出原因: 3. 然後在背景執行 {S}/pr-wait.sh {REPO} {N},它會在 PR 有衝突、被關閉或合併時結束並印出原因:
- conflict:git fetch origin && git merge origin/main,用 /mattpocock-skills:resolving-merge-conflicts 解決,跑測試,推送,再執行一次 pr-wait.sh。 - conflict:git fetch origin && git merge origin/main,用 /mattpocock-skills:resolving-merge-conflicts 解決,跑測試,推送,再執行一次 pr-wait.sh。
- closed:tea issues close --repo {REPO} {N},結束。 - closed:tea issues close --login {LOGIN} --repo {REPO} {N},結束。
- merged 或 issue-closed:結束。 - merged 或 issue-closed:結束。
+2 -2
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""列出可執行的議題。輸入:open.json agents.json tabs.json owner/repo """列出可執行的議題。輸入:open.json agents.json tabs.json owner/repo
阻擋關係只認 Gitea 原生 issue dependencies(tea api),不看議題內文。""" 阻擋關係只認 Gitea 原生 issue dependencies(tea api),不看議題內文。"""
import json, re, subprocess, sys import os, json, re, subprocess, sys
open_issues = json.load(open(sys.argv[1])) open_issues = json.load(open(sys.argv[1]))
agents = json.load(open(sys.argv[2])) agents = json.load(open(sys.argv[2]))
@@ -33,7 +33,7 @@ for t in find(tabs, "tabs") or []:
def open_blockers(n): def open_blockers(n):
"""擋住 #n 的 open 依賴。tea api 遇到 HTTP 錯誤仍 exit 0,所以回應不是陣列就當失敗,整個停下。""" """擋住 #n 的 open 依賴。tea api 遇到 HTTP 錯誤仍 exit 0,所以回應不是陣列就當失敗,整個停下。"""
raw = subprocess.run(["tea", "api", "--repo", repo, f"/repos/{{owner}}/{{repo}}/issues/{n}/dependencies"], raw = subprocess.run(["tea", "api", "--login", os.environ["HERDR_ISSUE_LOGIN"], "--repo", repo, f"/repos/{{owner}}/{{repo}}/issues/{n}/dependencies"],
capture_output=True, text=True).stdout capture_output=True, text=True).stdout
try: d = json.loads(raw) try: d = json.loads(raw)
except Exception: d = None except Exception: d = None
+16 -4
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# 用法:start.sh <owner/repo> <N> # 用法:start.sh <owner/repo> <N>
# 在目前 clone 旁建 worktree、開 Herdr tab、啟動 copilot、送提示詞並確認 agent 有反應、掛 in-progress 標籤。 # 在目前 clone 旁建 worktree、開 Herdr tab、啟動 claude、送提示詞並確認 agent 有反應、掛 in-progress 標籤。
# 送出提示詞後 15 秒內沒觀察到 working 或 blocked 就視為失敗並回滾(關 tab、移除 worktree、刪本次新建的分支)。 # 送出提示詞後 15 秒內沒觀察到 working 或 blocked 就視為失敗並回滾(關 tab、移除 worktree、刪本次新建的分支)。
# 最後一行印出 JSON:{"tab":..,"pane":..,"path":..,"resumed":..,"state":"working"|"blocked"} # 最後一行印出 JSON:{"tab":..,"pane":..,"path":..,"resumed":..,"state":"working"|"blocked"}
source "$(dirname "$0")/lib.sh" source "$(dirname "$0")/lib.sh"
@@ -39,13 +39,13 @@ rollback() {
$RESUMED || git -C "$CLONE" branch -D "$BRANCH" >/dev/null 2>&1 || true $RESUMED || git -C "$CLONE" branch -D "$BRANCH" >/dev/null 2>&1 || true
} }
TAB_JSON="$(herdr tab create --workspace "${HERDR_WORKSPACE_ID:?}" --cwd "$WT" --env COPILOT_ALLOW_ALL=true --label "#$N" --no-focus)" TAB_JSON="$(herdr tab create --workspace "${HERDR_WORKSPACE_ID:?}" --cwd "$WT" --label "#$N" --no-focus)"
TAB="$(jq_py 'print(find(d,"tab")["tab_id"])' <<<"$TAB_JSON")" TAB="$(jq_py 'print(find(d,"tab")["tab_id"])' <<<"$TAB_JSON")"
PANE="$(jq_py 'print(find(d,"root_pane")["pane_id"])' <<<"$TAB_JSON")" PANE="$(jq_py 'print(find(d,"root_pane")["pane_id"])' <<<"$TAB_JSON")"
START_ERR="$(mktemp)" START_ERR="$(mktemp)"
for _ in 1 2 3 4 5 6; do for _ in 1 2 3 4 5 6; do
if herdr agent start "issue-$N" --kind copilot --pane "$PANE" --timeout 90000 -- --model "$MODEL" --allow-all-tools --allow-all-paths >/dev/null 2>"$START_ERR"; then if herdr agent start "issue-$N" --kind claude --pane "$PANE" --timeout 90000 -- --model "$MODEL" >/dev/null 2>"$START_ERR"; then
rm -f "$START_ERR"; break rm -f "$START_ERR"; break
fi fi
sleep 2 sleep 2
@@ -56,8 +56,20 @@ if [ -f "$START_ERR" ]; then
die "agent 啟動失敗,已回滾" die "agent 啟動失敗,已回滾"
fi fi
# git 身分:與 tea 預設使用者一致(只設在這個 worktree,不動 clone 的設定)
GIT_USER="$(command tea login list --output json | jq_py "print(next((l['user'] for l in d if l['name']=='$HERDR_ISSUE_LOGIN'),''))")"
GIT_EMAIL="$(tea api "/user" | jq_py 'print(d.get("email") or "")' 2>/dev/null || true)"
git -C "$CLONE" config extensions.worktreeConfig true
# agent 在 worktree 裡自己跑的 git(push、fetch)也要有帳密:把 helper 設到 clone 的本地設定(worktree 共用),只對這個主機生效
GIT_HOST_URL="$(command tea login list --output json | jq_py "print(next((l['url'] for l in d if l['name']=='$HERDR_ISSUE_LOGIN'),''))")"
if [ -n "$GIT_HOST_URL" ]; then
git -C "$CLONE" config --local --replace-all "credential.$GIT_HOST_URL.helper" "$SCRIPTS/git-credential.sh"
fi
git -C "$WT" config --worktree user.name "$GIT_USER"
[ -z "$GIT_EMAIL" ] || git -C "$WT" config --worktree user.email "$GIT_EMAIL"
if $RESUMED; then RESUME_LINE="分支已有先前進度,先看 git log 和議題核取方塊再接續。"; else RESUME_LINE=""; fi if $RESUMED; then RESUME_LINE="分支已有先前進度,先看 git log 和議題核取方塊再接續。"; else RESUME_LINE=""; fi
PROMPT="$(sed -e "s|{LINK}|$LINK|g" -e "s|{REPO}|$REPO|g" -e "s|{N}|$N|g" -e "s|{S}|$SCRIPTS|g" -e "s|{RESUME}|$RESUME_LINE|" "$SCRIPTS/prompt.txt")" PROMPT="$(sed -e "s|{LINK}|$LINK|g" -e "s|{REPO}|$REPO|g" -e "s|{N}|$N|g" -e "s|{S}|$SCRIPTS|g" -e "s|{LOGIN}|$HERDR_ISSUE_LOGIN|g" -e "s|{RESUME}|$RESUME_LINE|" "$SCRIPTS/prompt.txt")"
# 送出後必須觀察到 agent 進入 working 或 blocked;否則 Herdr 回非 0(agent_prompt_stalled、timeout、agent_blocked 等)。 # 送出後必須觀察到 agent 進入 working 或 blocked;否則 Herdr 回非 0(agent_prompt_stalled、timeout、agent_blocked 等)。
PROMPT_ERR="$(mktemp)" PROMPT_ERR="$(mktemp)"