@@ -16,6 +16,7 @@
- 你需要 agent 在同一個 approved plan 內,判斷是否還有 **下一個要派發的 task ** 。
- 你需要用 **dispatch receipt ** 證明「真的有派出下一步」,而不是只在回覆裡口頭說會繼續。
- 你已經在用 `hooks/force-recall/handler.ts` ,希望把 approved-plan continuity gate 注入 agent prompt。
- 你沒有 `force-recall` hook, 但有自己的 preflight / planner / orchestrator, 想直接呼叫通用 continuity adapter。
### 可先不裝的情況
@@ -23,7 +24,7 @@
- 你的 workspace 沒有 approved-plan / auto-chain / dispatch 這類流程。
- 你只需要一般單回合聊天,不需要 continuity hard gate。
- 你沒有 `force-recall` hook, 也暫時 不打算自己補 glue code。
- 你沒有 `force-recall` hook, 且 也不打算在 自己的 host / orchestrator 補 generic glue code。
---
@@ -31,11 +32,11 @@
安裝完成後,應達到這個最小結果:
- `hooks/force-recall/handler.ts` 能載入 `plugins/continuity/src/index.mjs`
- hook 在 preflight 時會呼叫 `runForceRecallContinuityAdapter(...)`
- 你的 host( 例如 `force-recall` hook 或自家 preflight) 能載入 `plugins/continuity/src/index.mjs`
- host 在 preflight 時會呼叫 `runForceRecallContinuityAdapter(...)` 、`runGenericPreflightContinuityAdapter(...)` 或 `runManualContinuityPreflight(...)` 其中之一
- agent prompt 內可看到 `[APPROVED_PLAN_CONTINUITY_GATE] ... [/APPROVED_PLAN_CONTINUITY_GATE]`
- 當 approved plan 任務完成,但沒有真實下一步 dispatch receipt 時, gate 會擋下錯誤結案
- plugin 自身測試與 hook smoke test 可通過
- plugin 自身測試與對應 host smoke test 可通過
---
@@ -49,7 +50,7 @@
<workspace>/plugins/continuity
```
以目前 MVP 的預期 layout :
建議 layout( 可依宿主調整) :
``` text
<workspace>/
@@ -86,7 +87,7 @@
- [ ] 你的 workspace 有 `hooks/force-recall/handler.ts`
- [ ] 你的 workspace 有 `scripts/test_force_recall_long_task_preflight.mjs`
- [ ] 你的 workspace 願意採用 approved-plan continuity hard gate
- [ ] 你接受 MVP 目前只優先支援 `force-recall` adapter
- [ ] 你接受目前 `force-recall` 是最成熟 adapter,但不是唯一宿主
- [ ] 你知道 receipt 只是「最小 contract」, 不是完整 workflow engine
可先用以下命令確認:
@@ -275,11 +276,11 @@ mkdir -p state/approved-plan-continuity
---
## 7. 如何接 `force-recall` hook
## 7. 如何接 host / hook( `force-recall` 只是其中一種)
## 7.1 你要確認的整合點
MVP 的主要 整合點是:
目前最成熟的 整合點仍 是:
``` text
hooks/force-recall/handler.ts
@@ -309,9 +310,9 @@ grep -n "APPROVED_PLAN_CONTINUITY_GATE" hooks/force-recall/handler.ts
grep -n "plugins\", \"continuity\", \"src\", \"index.mjs" hooks/force-recall/handler.ts
```
## 7.2 最小接法範例
## 7.2 最小接法範例( force-recall)
如果你要自己補接 ,最小概念如下:
如果你走既有 `force-recall` 路徑 ,最小概念如下:
``` js
import plugin from './plugins/continuity/src/index.mjs' ;
@@ -327,7 +328,44 @@ if (out?.block) {
}
```
## 7.3 實作者要檢查的實際條件
## 7.3 Generic/manual 最小接法範例
如果你沒有 `force-recall` ,也可直接把自己的 preflight 結果餵給 generic adapter:
``` js
import plugin from './plugins/continuity/src/index.mjs' ;
const out = plugin . runGenericPreflightContinuityAdapter ( {
config : plugin . defaultConfig ,
source : {
planId : 'approved-plan-1' ,
currentTask : 'task-3' ,
taskState : 'complete' ,
nextTaskKnown : true ,
sameApprovedPlan : true ,
taskBoundaryStop : true ,
nextTaskId : 'task-4' ,
nextDerivedAction : { type : 'message_subagent' , task : 'continue' } ,
replyClosureState : 'completed' ,
dispatchReceipt : null ,
} ,
} ) ;
```
若你只是手動做一次 continuity preflight, 也可直接呼叫:
``` js
const out = plugin . runManualContinuityPreflight ( {
config : plugin . defaultConfig ,
planId : 'approved-plan-1' ,
currentTask : 'task-3' ,
taskState : 'complete' ,
nextDerivedAction : { type : 'message_subagent' , task : 'continue' } ,
replyClosureState : 'waiting_user' ,
} ) ;
```
## 7.4 實作者要檢查的實際條件
- [ ] hook 能動態 import `plugins/continuity/src/index.mjs`
- [ ] `runForceRecallContinuityAdapter` 是 function
@@ -337,7 +375,7 @@ if (out?.block) {
- [ ] `out.block` 非空時有 prepend 到 `bodyForAgent`
- [ ] agent prompt 最終可見 continuity gate block
## 7.4 receipt 與 continuity input 的關係
## 7.5 receipt 與 continuity input 的關係
如果你的流程真的有派發下一步,請不要只在字串裡描述「已派發」,而要產出真實 `dispatchReceipt` 。
@@ -360,14 +398,14 @@ if (out?.block) {
### Checklist: 第一次把 plugin 接進現有 workspace
- [ ] 建立 / 複製 `plugins/continuity`
- [ ] 確認 `src/index.mjs` 可被 hook 載入
- [ ] 確認 `src/index.mjs` 可被 host 載入
- [ ] 確認 continuity example config 可讀
- [ ] 建立 `state/approved-plan-continuity/`
- [ ] 確認 `hooks/force-recall/handler.ts` 有 continuity adapter 接點
- [ ] 確認有 prepend continuity block 到 `bodyForAgent`
- [ ] 確認你的 host( 例如 `hooks/force-recall/handler.ts` 或自家 preflight) 有 continuity adapter 接點
- [ ] 確認有 prepend continuity block 到 `bodyForAgent` 或對應 prompt/body
- [ ] 若 dispatch 真的發生,補上 receipt 寫檔
- [ ] 跑 plugin test
- [ ] 跑 force-recall smoke test
- [ ] 跑對應 host 的 smoke test
- [ ] 檢查 injected prompt block 是否存在
### Checklist: 第一次加 receipt 落盤
@@ -553,11 +591,11 @@ find state/approved-plan-continuity -maxdepth 2 -type f | sort
## 13. 目前限制
這個 MVP 目前有以下限制,安裝前要先接受:
這個 plugin 目前有以下限制,安裝前要先接受:
- 它是 **approved-plan continuity hard gate ** 的抽離版,不是通用 workflow engine。
- 主要 adapter 目前只有 `force-recall` 。
- 文件描述的是「接在既有 force-recall preflight 鏈上」的路徑;若你的 workspace 沒這條鏈,仍要自己補 glue code 。
- `force-recall` 是目前最成熟的 adapter, 但不是唯一 adapter 。
- 若你的 workspace 沒有 `force-recall` ,仍需自己把 host 資料接到 generic/manual path 。
- config 目前是模組預設值 + 呼叫端傳入,不是完整 plugin installer / registry 流程。
- receipt store 目前只負責寫檔,不管 retention、cleanup、indexing。
- receipt validator 目前只驗證最小 contract, 不會深入驗證每種 `nextDerivedAction` 的完整語意。