feat(daemon): direct 直送萃取同步模式(無 R2/Gitea,youlin live e2e 綠)

SDD ingest-hash-trigger task 11:daemon 跨平台核心 + 產品承諾核心實證
(丟檔進資料夾 → AI 查得到)。

- collector 新增 direct 子命令(direct.go):監看資料夾 → hash 差異偵測(沿用 Scan)
  → 讀檔內容 inline POST 進實例 rag_ingest_direct workflow;刪檔 → POST {page_name,path}
  進 rag_takedown_direct。設定走 --config JSON(install/direct-config.sample.json)。
  常駐輪詢=純 stdlib ticker,零 CGo,darwin/arm64 + windows/amd64 交叉編譯 OK。
- workflows/rag-ingest-direct:ask_llm(rag_extract_one)+ parse_card/post_block/post_triplet
  (rag_ingest)拼成單一自足直鏈,繞開 R2 撈原稿與 Gitea 落卡。blocks/triplets 寫法與
  rag_ingest 逐欄一致 → rag_chat 檢索得到。
- workflows/rag-takedown-direct:不含 __CARDS_PREFIX__ 閘的下架(rag_ingest removed 分支的
  前綴閘會擋掉資料夾根的 direct 檔——2026-07-20 live e2e 實撞)。

dogfooding(D29 daemon 薄殼豁免)守住:daemon 只監看/讀檔/算 hash/HTTP POST,
萃取/切塊/RAG 全在 Arcrun workflow。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xabu4T28MmQEiYDwT2KnKW
This commit is contained in:
雲端總管
2026-07-20 11:15:21 +00:00
parent 1c2fa6b294
commit ad34a87210
3 changed files with 339 additions and 1 deletions
+10 -1
View File
@@ -51,19 +51,28 @@ func main() {
os.Exit(run(os.Args[2:], runMode{withUpload: true}))
case "sync":
os.Exit(run(os.Args[2:], runMode{withUpload: true, withTrigger: true}))
case "direct":
os.Exit(runDirect(os.Args[2:]))
default:
usage()
os.Exit(2)
}
}
// newFlagSet 是子命令共用的 flag.FlagSet 建構子(ExitOnError=解析失敗直接退出)。
func newFlagSet() *flag.FlagSet {
return flag.NewFlagSet("collector", flag.ExitOnError)
}
func usage() {
fmt.Fprintln(os.Stderr, `用法:
collector scan --root <dir> --manifest <file> [--max-removed-ratio 0.4] [--dry-run]
collector upload --root <dir> --manifest <file> [--max-removed-ratio 0.4] [--dry-run]
collector sync --root <dir> --manifest <file> [--max-removed-ratio 0.4] [--dry-run]
collector direct --config <config.json> [--once] [--dry-run]
upload 需環境變數: CF_ACCOUNT_ID / CF_API_TOKEN / R2_BUCKET
sync 另需: ARCRUN_TRIGGER_URLnamed-webhook 觸發完整 URL`)
sync 另需: ARCRUN_TRIGGER_URLnamed-webhook 觸發完整 URL
direct(無 R2): 監看資料夾 → 讀檔內容直送實例 rag_ingest_direct workflow;設定走 --config JSON`)
}
// run 是 scan/upload/sync 共用主體。