Theme / v2.1.15

Chat On Steroids

把 ChatGPT 對話變成會寫程式、會派工的本地開發環境

實戰範例

Goal 與 Loop 的過夜長跑

把有明確驗收條件的清單交給 Loop 持續推進、把自認可完成的遷移交給 Goal;並理解 Compact & Resume 是 app/瀏覽器編排,以及 Astra finish boundary 如何接手排隊指示。

Goal 與 Loop 的過夜長跑

Goal 與 Loop 讓一個對話「繼續下去」:Goal 會自行判定任務完成,完成時可以不送任何訊息;Loop 會在你的 brief 範圍內持續工作,直到你停用它。兩者都支援 ChatGPT helper 或可選的 API backend。

這篇範例處理一個實際的週末情境:睡前丟出去、早上驗收。


情境

receipt-cli 累積了一批雜事:12 個 lint 警告、3 個沒人處理的 TODO:、一個沒人維護的 legacy/ 目錄、還有一個想做的遷移(把 src/tax.ts 換成新版的 Money 型別)。承接用 worker 團隊平行重構的紀律:長跑之前先 commit。

git add -A && git commit -m "checkpoint before overnight run"

目標

  • 用 Loop 推進「不確定幾輪才會結束」的清單。
  • 用 Goal 處理「做到什麼程度算完成,交給它判斷」的遷移。
  • 早上醒來,用命令自己重驗每一個條件,而不是相信摘要。

步驟一:把 brief 寫成可驗收條件

Loop 的 brief 就是你送出的那段文字。條件寫得越像驗收指令,早上越好驗:

Loop the following work until all three hold, then stop:
1. `npm run lint` reports zero warnings.
2. Every `TODO:` in src/ is either fixed or replaced by an issue reference
   in the comment.
3. `legacy/` may be deleted only after its behavior is covered by tests
   that pass in `npm test`.

Never change package.json versions. After each file change, run the
narrowest relevant test. If you are unsure whether a change is safe, write
the question into NOTES.md and stop that item instead of guessing.

步驟二:Goal 的遷移 brief

Goal: migrate src/tax.ts to the new Money type from packages/core, keeping
all existing tests green.

Definition of done: every call site in src/ uses Money, `npm test` passes,
and `npm run typecheck` passes. If the migration needs a data format
change, stop and report — that is out of scope.

兩個 brief 都刻意寫了「不確定就停」與「超出範圍就停」;無人看管的自動化,最貴的錯誤是它自信地做錯方向。

預期的工具呼叫序列

(App/瀏覽器編排層,不是模型工具)
- Loop:開始後每輪重新送出持續指示,直到你在 composer 停用它
- Goal:模型自行判定完成;判定完成時可以什麼都不送

(模型可呼叫的本地工具)
1. update_plan(plan: [...])                 # 整個長跑的進度看板
2. exec_command(cmd: "npm run lint")
3. read(paths: ["src/render.ts", "legacy/format.ts"])
4. apply_patch(patch: "<V4A 信封:先清一批警告>")
5. exec_command(cmds: ["npm test", "npm run typecheck"])
6. write_stdin(session_id: "...", chars: "")  # 長指令(e2e)輪詢

(交接時)
7. Compact & Resume:App/瀏覽器向 provider 要求 handoff,開一個全新的
   provider 對話,並把同一個 session 重新綁上去;任務與 worker 歷史跟著移動

認識三個續航機制

Goal 與 Loop

  • Goal 自行判定完成;Loop 在你的 brief 範圍內持續到停用。
  • 兩者都可以搭配 ChatGPT helper(就是同一個對話)或可選的 API backend。
  • 它們不會給你額外的額度或模型存取。用新對話、worker、Goal/Loop 或壓縮來規避 provider 限制,是明確被禁止的用法。

Compact & Resume

  • 它是 app/瀏覽器編排:向 provider 要求一份 handoff、開新對話、把同一個 session 重新綁上去。模型看不到 save_handoff 或 resume_session 這種工具——不要叫 ChatGPT「呼叫函式存檔」,它不存在。
  • 自動壓縮用本機設定的估算與符合條件的在途工作;Pro 模型永不自動壓縮。
  • Worker 永遠不跑 Compact & Resume:它們的對話就是它們的身分。
  • 看到 COMPACTION_IN_PROGRESS 時,讓來源對話把交接做完,工作會在替換的新對話裡繼續。

Astra finish boundary

  • Session finish 開啟時,Astra 的 finish boundary 可以在同一個工作回合內透過工具接收排隊的指示、計畫檢查點與自動跟進。
  • 你也可以直接從 composer 結束回合。
  • 它不會移除 provider 的使用量或內容視窗限制。

早上的驗收方式

  1. git log --oneline 與 git diff 逐段看:每一步是不是你真的想要的改動。
  2. 自己重跑一次三條 Loop 條件與 Goal 的完成定義;別只讀摘要。
  3. 檢查 NOTES.md:它應該留下「不確定所以停手」的問題,而不是硬改的痕跡;這些就是下一輪的輸入。

注意事項

  • 長跑前一定 commit;允許它碰的目錄、允許跑的指令、不確定時的停損規則,都要先寫進 brief。
  • 收到 provider 的使用限制或政策警告時:停掉該工作流與它的 Goal/Loop 自動化,照 provider 的流程處理,不要換帳號、換對話、換模型或換 tunnel。
  • 隨時可以從 composer 停用 Loop;對話不想再被本機工具碰,就 Block(撤銷該對話的本機工具,不代表取消 provider 端的生成)。

延伸閱讀:worker 團隊、Goal/Loop 與續航、worker 團隊與 Goal/Loop。