Files
system-dev-template/template/system-dev/workflows/tasks-project-sync.local.sh
T
Leo 6a49f25aef feat(W2 Phase 0-1): 雙 profile 地基+JDD 兩軸身分+兩支防炸閘
SDD: docs/3-specs/jdd-dual-profile(draft → active,leo 2026-08-05 回「開工」)
範圍:總管指定的「防炸兩件 → Phase 0 → Phase 1」,Phase 2 以後未開工。

■ 防炸(排在所有 task 之前,因為它們炸的是既有的東西)
- check-no-instance-names.sh + instance-names.txt:框架範本不得混入實例專名
  基線實測 22 行命中(非先前誤報的 20)→ 9 行無損泛化改寫、13 行檔級豁免記帳待 W3 搬走
  拒絕假性清理(把專名換成模糊詞=資訊消失、分層問題還在)
- check-legacy-paths.sh:已發佈腳本引用的 35 條遠端路徑只增不移
  舊實例跑的是舊腳本、路徑寫死;搬檔=整排 404 且不會有下一次更新來修它(1.16.0 前科)

■ Phase 0 地基
- template/manifest/{common,repo,orchestrator}.tsv:安裝清單單一真相源
  修好 install/update 兩份硬編清單的既有漂移——install 從不裝 wiki-first-search /
  subagent-wiki-guard / publish-lag-check / decisions-summary,但 update 會
  ⇒ 乾淨安裝反而拿不到 1.16/1.17/1.18 的招牌功能
- .claude/hooks/lib/role-lib.sh:scope×role 兩軸機械判定,零自陳
  身分矩陣六組實測全通過,含「成員 repo × orchestrator」不存在的格子擋下
- .sdt-framework-dev:框架開發標記(官方沒有 --framework-dev 這個參數,實查非記憶)

■ Phase 1 雙 profile
- profiles/{repo,orchestrator}/CLAUDE.md 兩部憲法
- install.sh:--profile + 自動偵測+寫檔前確認、manifest 驅動、
  CLAUDE.md 三段組裝(框架區/本地補充區界標+sha256)、.profile、.template-manifest、
  settings.json 寫入 env.AGENT_ROLE 預設
- update.sh:漂移偵測(不覆蓋手改檔、另存 .new、白話清單)+ 基準快照隨更新前進
- template/CLAUDE.md 原路徑凍結留底(相容)

■ 順手修掉兩個舊 bug(都在本次要動的函式裡)
- add_if_missing 少了 mkdir -p ⇒ 新目錄的檔 curl 失敗但 VERSION 照升(2026-07 記「待回報」至今未修)
- 下載健全性只用 [ -s ]=非空即接受 ⇒ 404 頁面會無聲覆寫好檔
  (SKILL.md 260→1 行的機制;同一支腳本的版本號那條路早就防了,檔案這條沒防)

■ 實測(非推論)
- G4 憲法分流:兩個乾淨環境各裝一次,orchestrator 版含 SDD 三件式關鍵字 0 次、
  repo 版含上游指針 8 次;界標 4/4;sha 宣告與實算相符
- G7 CI 擋實例名:注入違規行 → fail 並指出 sdd-check.md:77,exit 1;還原後 exit 0
- 漂移偵測:手改兩支 hook → 正確報 2 支、手改內容保住、產 .new;
  解掉後歸零;連跑三輪冪等

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 23:56:48 +08:00

75 lines
4.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# tasks-project-sync.local.sh — 本地觸發端(投影的「本地一半」)
#
# 來源:issue #16;設計:system-dev/docs/3-specs/tasks-project-projection/design.md
#
# ⚠️ sdt-instance-name-ok-file — 檔級豁免(實例專名檢查)
# 理由:與 tasks-project-sync.yaml 同一組 **L2 政策包產物**(綁定某一家的工作流引擎)。
# 帳記在這:**W3(政策包 plugin 化)時與 yaml 一起移出 template/**,屆時本豁免刪除。
#
# ── 為什麼有這支(職責邊界)──────────────────────────────────────
# arcrun workflow 跑在遠端 CF Workers,沒有本地 fs / git / shell。
# 所以「讀 tasks.md / git diff / 回寫 <!-- gh:id -->」這三件本地事
# 不能放進 workflow(arcrun 也沒有對應零件,這是架構邊界、不是缺口)。
# 這支就是那「本地一半」:分類好增量 → 交給 acr run 打 GitHub。
#
# 這支(本地):讀 tasks.md → git diff → 分類四動作 → acr run 投影 → 回寫新 id
# │
# ▼
# tasks-project-sync.yaml(遠端):foreach → switch → github API
#
# ── 怎麼觸發(守 flag 紅線)─────────────────────────────────────
# push 後「本機觸發單次」,非 cron、非輪詢、非 GitHub Actions。
# 掛載點建議:本機 git post-push 類 hook,或叫 CC 在 push 後跑這支一次。
# ⚠️ 具體掛載點與「分類四動作」的精確 parse,待 leo21c 端到端驗證後定稿;
# 目前是 code-done 骨架,標出該做什麼、邊界在哪,不假裝已通。
#
# ── 用法 ───────────────────────────────────────────────────────
# tasks-project-sync.local.sh <owner> <repo> <project_id>
#
# 前置:acr 在 PATH、github_token 已 acr creds push、workflow 已 acr push。
set -euo pipefail
OWNER="${1:?需要 owner}"
REPO="${2:?需要 repo}"
PROJECT_ID="${3:?需要 GitHub Projects v2 node id}"
# 多組 SDD 全同步:glob 掃所有 tasks.md(新 folder 自動成組,免手動登記)。
GLOB="system-dev/docs/3-specs/*/tasks.md"
# ── 1. 分類增量(git diff 知道改了哪幾行 → 四動作)──────────────
# 這裡是「本地一半」的核心。實作策略(待端到端驗證後落地):
# - 拿 push 前後的 git diff,限定 $GLOB 範圍,只看動到的行。
# - 每行 task 解析:有無 `<!-- gh:N -->` id、checkbox 是否 [ ]→[x]、文字/負責人/日期變動。
# - 行不見(diff 的刪除行)且原本有 id → archive。
# - 子系統 = 該 tasks.md 的 folder 名(當 label 分組)。
# - 產出 tasks_json 陣列(格式見 yaml 註解)。
#
# ⚠️ 刻意不在這支用 TS/Python 刻複雜 parser(守薄殼)。複雜分類交給 CC 在 push 後
# 讀 diff 直接產 tasks_json;這支保持「薄殼 + 交棒 acr run」。若未來證明需要可重用的
# parser 零件,那屬於 arcrun 零件缺口 → 回報 issue #16 由 arcrun 端補,不在此自刻。
#
# 佔位:實際 tasks_json 由 CC 依上述策略產生後填入。
TASKS_JSON="${TASKS_JSON:-[]}"
if [ "$TASKS_JSON" = "[]" ]; then
echo "(無增量 → 本次 no-op,不呼叫 GitHub"
exit 0
fi
# ── 2. 交給遠端 workflow 投影 ───────────────────────────────────
acr run tasks_project_sync \
-i owner="$OWNER" \
-i repo="$REPO" \
-i project_id="$PROJECT_ID" \
-i tasks_json="$TASKS_JSON"
# ── 3. 回寫新 task 的 id(唯一對 md 的寫入,只在 create 時做一次)──
# create 動作的回傳 issue number → append `<!-- gh:N -->` 到該行末。
# ⚠️ 防迴圈:回寫造成 working tree 變動,這次回寫「不得」再觸發一輪投影
# (否則 push→觸發→回寫→又一個 diff→又觸發…)。實作時觸發端要排除
# 「只動到 <!-- gh:N --> 註解」的 diff,或回寫走 [skip-sync] 標記。
# 具體機制待端到端驗證定稿。
echo "(新 task 的 id 回寫:待端到端驗證後接上 acr run 的回傳 → append <!-- gh:N -->"