Skip to content

feat(prompts): add /m2_evolve and auto mode for pr/next/release - #20

Merged
oahsiao merged 1 commit into
mainfrom
feat/evolve-prompt-and-auto-mode
Jul 27, 2026
Merged

feat(prompts): add /m2_evolve and auto mode for pr/next/release#20
oahsiao merged 1 commit into
mainfrom
feat/evolve-prompt-and-auto-mode

Conversation

@oahsiao

@oahsiao oahsiao commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

新增 /m2_evolve 長時間自主迭代優化指令,並為 /m2_pr/m2_next/m2_release 加上後置 auto 全自動模式。auto 讓 agent 自行解決每個確認節點、一路跑到任務完成,最後才輸出單一的工作流程 + 結果報告;共用契約集中寫在 copilot-instructions §9,三支 prompt 只描述各自的差異。

Why

兩件事都在補「agent 能自己走完多久」這條線的兩端。

/m2_evolve 補的是長度:既有四支指令都是單次流程,沒有一支能「給一個目標,讓它反覆改到收斂」。實務上這種需求最容易失控——agent 會為了讓驗證變綠而改測試、放寬 lint、或宣稱沒實際跑過的驗證。因此這支 prompt 的重點不在「會迭代」,而在「作弊會被擋下來」。

auto 補的是中斷次數/m2_pr → 確認合併 → /m2_next → 確認刪分支,一輪要停三、四次。人在電腦前時這是對的,但在明確授權的情況下應該可以一路跑完。關鍵是「不需要人參與決策」不能等於「不需要安全檢查」,所以 ABORT 清單一條都沒放寬。

How

/m2_evolve

  • 啟動前用互動式按鈕訪談六件事(範圍、專案輪廓、期望成果、改進重點、自主程度、checkpoint 模式),產出凍結的 CHARTER;目標無法量測就追問到可驗收為止,沒有 smoke test 就先建一個。
  • 迭代循環固定七步(CHECK / SENSE / PLAN / ACT / VERIFY / JUDGE / COMMIT+LOG),判定只有 BETTER / NEUTRAL / WORSE 三種,沒有更好就退回。
  • 帳本寫在 .evolve/<run-id>/(CHARTER / BASELINE / STATE.json / LEDGER.md),支援 /m2_evolve resume 冷啟動接續。帳本以 .git/info/exclude 忽略而不改 .gitignore——它是本機過程檔,不該污染下游 repo 的版控設定,而且第 1.1 節才剛要求 working tree 乾淨。
  • 中斷機制分四層:三種 checkpoint 模式(ask / notify / silent)、檔案 kill switch(.evolve/STOP.evolve/PAUSE,一個迭代檢查三次)、不可停用的 tripwire、以及隨時可直接打開看的 LEDGER.md
  • 「絕不作弊」列為硬性規則:不得改測試遷就實作、不得 skip/刪測試、不得放寬 lint 或 smoke test、不得用「理論上更快」代替實際量測。回合報告固定列出「測試數」與「lint 問題數」前後對比,讓這些手法無所遁形。
  • Git 安全:commit 只 add 本迭代動到的檔(禁用 git add -A)、送出前 git diff --cached 自檢機密資料;退回時用 git restore 加上逐一刪除本迭代新建的檔,禁用 git clean -fd / git reset --hard(它們會動到使用者自己的未追蹤檔)。

auto 模式

  • 共用契約放 copilot-instructions §9,避免三支 prompt 各寫一套後漂移。
  • 決策規則:優先選 repo 歷史支持的選項;無依據且不可逆 → 中止。「agent 判斷」不等於「猜」。
  • ABORT 清單 auto 一條都不免:CI 紅/逾時/取消、diff 含機密資料、已追蹤檔未 commit、本機落後 origin、PR 身分無法查證、tag 或版號已被用掉、合併衝突、需繞過 branch protection。
  • 加了兩道本次實際踩到的防線:
    • 開工前強制新鮮度檢查git rev-list --left-right --count origin/main...HEAD 左邊必須是 0)。落後的 base 是最具破壞性的失敗模式——所有編輯都對到舊檔,開出來的 PR 會直接回退掉期間已合併的工作。
    • 合併/刪分支前強制用 gh api 查證 PR 身分head.ref / base.ref / title 全對)。gh pr create 印出的 URL 與 gh pr list 都曾指到不相干的 PR,沒人盯著時合錯 PR 幾乎無法還原。
  • 各流程的差異寫在自己的檔裡:m2_next auto 只有未追蹤檔就保留並繼續、有已追蹤檔的未 commit 變更就中止,且只刪本次 PR 的分支;m2_release auto 在版號與 tag 不一致、版號已在 CHANGELOG、合併後 HEAD 不是 bump commit、或 release PR 夾帶其他檔時一律停下且不打 tag。

其他

  • copilot-instructions §9 原本「不可跳過確認節點」修正為「唯一例外是使用者明打 auto」,並補上 /m2_evolve 的 routing 條目(scripts/validate.py 會檢查路由表涵蓋所有 prompt file)。
  • 明確禁止從「你直接做」「不用問我」這類語氣推論出 auto 模式——必須看到字面上的 auto

Impact

  • 影響範圍:新增一支 prompt file、三支既有 prompt 新增 auto 模式、copilot-instructions §9 新增一節。
  • 既有行為不變:沒打 auto 時三支流程的確認節點完全照舊。
  • 下游 repo:下次同步後收到新指令與新規範章節,屬 minor(v2.2.0),不需改任何檔案。
  • Breaking change:無。
  • 風險:auto 讓 agent 能在無人確認下合併 PR。已用 ABORT 清單、新鮮度檢查與 PR 身分查證三道防線收斂,但建議先在本 repo 實跑幾次再推廣。

Verification

  • python scripts/validate.py → 5 個 prompt file 全數通過、0 警告
  • 依 CI gate 於同一 PR 更新 CHANGELOG.md(v2.2.0)
  • 確認本機已同步 origin/main(本次即是先發現落後 6 個 commit、重做後才提交)
  • git diff --cached 自檢無機密資料
  • /m2_pr auto 端到端尚未跑過完整的「自行合併」路徑(本 PR 即為首次;auto 的合併節點會在這裡第一次實際執行)
  • /m2_next auto/m2_release auto 尚未實跑,屬規格
  • CI passed

Add /m2_evolve: a long-running self-iterating optimization flow that works a goal on a 12h budget via sense/plan/act/verify/judge iterations, keeps a resumable ledger under .evolve/, and reverts anything that does not measurably improve. It never opens or merges a PR itself.

Add an 'auto' trailing modifier to /m2_pr, /m2_next and /m2_release that resolves every confirmation node autonomously and reports once at the end. The shared contract lives in copilot-instructions section 9: decision rules, a non-waivable ABORT list, a mandatory origin-freshness check, and mandatory gh api verification of PR identity before any merge or branch deletion.

Kept as one commit because both changes share copilot-instructions section 9, README and CHANGELOG; any file-level split yields an intermediate commit that fails scripts/validate.py routing-coverage check. Merged with --squash per repo history, so branch granularity does not reach main.
@oahsiao oahsiao added the enhancement New feature or request label Jul 27, 2026
@oahsiao oahsiao self-assigned this Jul 27, 2026
@oahsiao
oahsiao merged commit e3fe422 into main Jul 27, 2026
1 check passed
@oahsiao
oahsiao deleted the feat/evolve-prompt-and-auto-mode branch July 27, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant