9 Commits

Author SHA1 Message Date
Leo 969c3f2bcf revert: 還原被第一次同步蓋掉的三個檔(D95,inkstone/InkStoneCo#40)
2026-08-18 出貨線第一次真的把 arcrun-rag 的 collector/ 同步過來,
盲目鏡射蓋掉/刪掉了三個**本來就該只屬於這個 repo** 的檔:

  .gitignore           21 行的「不要再長回來」閘 → 被換成 arcrun-rag 那份的一行
                       🔴 最嚴重:那份清單正是擋 43 MB 建置產物的東西,
                          它被蓋掉之後,下一趟同步就會把產物搬進來
  README.md            介紹這個獨立 repo 的 → 被換成 arcrun-rag 子目錄的 README
  cmd/collector/main.go 正常源碼,被誤判成建置產物刪掉
                       (.gitignore 的 `collector` 一行是指根目錄那顆執行檔,
                         但無斜線樣式在任何層級都命中 ⇒ 連 cmd/collector/ 也中)

出貨線那側已修(installer/scripts/line-source-repo.mjs):
  · destOwned:目的 repo 的門面檔不覆蓋、不刪除,且同步前檢查它們還在不在
  · 已被目的 repo 追蹤的檔案不算「被忽略」(git 自己的語意)⇒ main.go 不再被誤刪

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 21:33:34 +08:00
Leo a35421e2e2 sync: collector/ 同步自 inkstone/arcrun-rag@99cc64f(桌面小幫手 0.18.33) 2026-08-18 21:23:45 +08:00
claude-code 0d3b853249 docs: 說清楚這個 repo 是什麼、成品在哪、跟 arcrun-rag 什麼關係(D95)
leo D95 的要求是「不要有很多扭曲,因為你根本不記得你做的這些扭曲,每次都要查」
⇒ 打開這個 repo 第一眼就要答得出三題:這是什麼產品/去哪拿/跟隔壁那個什麼關係。

過渡狀態(collector/ 還留在 arcrun-rag)也寫在裡面——
不寫的話,下一個人查到兩份源碼會以為自己找錯地方。

票:inkstone/InkStoneCo#40
2026-08-18 18:45:26 +08:00
雲端總管 ad34a87210 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
2026-07-20 11:15:21 +00:00
Leo 1c2fa6b294 ingest-hash-trigger SDD task 4:觸發鏈 Gitea webhook → collector sync 直打 named-webhook
- collector Go:trigger.go+sync 子命令(scan→R2 upload→POST collector-trigger.v1
  →2xx 才 MarkIngested 回寫;失敗不回寫=下輪自然重試;上傳失敗事件不送、同路徑
  renamed 連坐不回寫;防呆警告輪照送 warnings)。go test 19/19 綠(httptest mock)。
- workflow v3:rag-ingest-cards.local.yaml 改吃 collector payload(events[] 取代
  commits[];原稿從 R2 撈 CF REST API objects/{r2_key};新增 renamed 分支=只更新
  路徑映射 R5,跨界搬移轉 added/removed;removed 沿用 G9 雙判準;M3 recompute 尾鏈
  原樣保留,fetch_index 改 R2);rag-ingest.yaml v1 同步等價改。source_uri 遷移
  gitea://→kb://。schema_version!==1 整輪 no-op。
- push-demo-workflow.sh:補 __CF_ACCOUNT_ID__/__R2_BUCKET__/__CF_R2_TOKEN__ 佔位;
  GITEA_* 標 deprecated-for-ingest(rag-extract* 仍用)。
- Gitea 退場(本 repo 範圍):legacy JS collector 六檔刪除(git 記錄可查);
  install.sh 步驟 5 降級 deprecated;README 落「Gitea 退場切換 checklist」
  (推 v3→collector sync 實測→拆 Gitea webhook→觀察期+回滾法)。
- 驗證:yaml parse(raw+sed 模擬)/flow-config 對齊/JS 語法 node --check/
  demo cypher 唯讀 /cypher/search 編譯 missing=[]、出邊序如設計。
  未部署、未實跑 e2e(推 demo=leo 閘)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 21:58:39 +08:00
Leo fdb7a67484 feat(ingest-hash-trigger): collector R2 content-addressed 原稿上傳(SDD task 3)
- collector upload 子命令=scan+把 added/modified 原稿傳 R2(CF REST API
  Bearer token,key=raw/<sha256hex>,對齊 collector-trigger.v1 的 r2_key)
- 冪等:存在檢查命中=skipped_exists 不 PUT;CF API objects 端點不支援
  HEAD(live 實測 405)→ 改 GET+Range: bytes=0-0
- 完整性:上傳前重算 hash 核對 key,不符=failed 不上傳
- 失敗語意:failed → exit 1,ingested_hash 不動=下輪自動重試;
  回寫鉤子 Manifest.MarkIngested 留給 task 4
- 設定只走環境變數 CF_ACCOUNT_ID/CF_API_TOKEN/R2_BUCKET,不落 repo
- go test 14/14 綠(httptest mock 對齊真 API:HEAD 405);live e2e 全通
  (arcrun-rag-raw-demo:真上傳→重傳 no-op→下載 diff 一致+sha256==key)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 21:27:42 +08:00
Leo bb96bceb04 feat(ingest-hash-trigger): 凍結 collector/ingest schema+Go collector 骨架(issue #5, SDD task 1+2)
- schemas/collector-trigger.v1.schema.json:collector→named-webhook 觸發 payload(source_hash/r2_key/renamed/R6 warnings)
- schemas/kbdb-ingest-request.v1.schema.json:source_hash 必填缺=400;儲存映射走 metadata_json.$.source_hash(守 kbdb 表不變鐵律);同 hash 重送=200 already_ingested
- schemas/MIGRATION-webhook-payload.md:舊 Gitea push payload 逐欄對照(給 task 4 改寫 workflow)
- collector/:Go module(純 stdlib)——manifest 讀寫+mtime fast-path 掃描+renamed hash 配對+40% 大量刪除防呆;CLI collector scan
- go test ./... 全綠 7/7(added/modified/removed/renamed/防呆五情境+fast-path+manifest 往返)
- Node 版 collector 標 legacy 並存(SDD task 4 拆除)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 20:31:11 +08:00
Leo eff30bd741 T4: Markitdown adapter——docx/pptx/pdf 轉檔 + 原檔進 assets/originals(design §4)
transform.js:MARKITDOWN_EXT(docx/pptx/pdf)走 markitdown CLI 子行程轉出 md,輸出路徑
副檔名換 .md;回傳 originalCopy 供 index.js 把原檔複製進 assets/originals/<相對路徑>。
git-sync.js:ensureGitAttributes() 啟動時冪等寫入 LFS 宣告(三種格式 filter=lfs)。

已驗(雲端 sandbox,兩輪煙測):用 python-docx 生真實 docx(含標題+段落)丟進 watch 資料夾,
collector 呼叫 markitdown 轉出真實 md 內容(人工核對與原檔一致)、原檔複製進
assets/originals/、.gitattributes 正確含三種格式 LFS 宣告、commit+push 送達 bare remote。

誠實邊界:sandbox 無 git-lfs 二進位,驗不到真實 LFS smudge/clean filter 生效(只驗到
.gitattributes 內容正確);真實 Gitea remote push/憑證、真實客戶檔案樣本仍待本機/客戶環境。
其餘格式(xlsx/圖片)不在第一波承諾範圍,仍誠實丟 NotImplementedError。
2026-07-07 21:13:13 +00:00
Leo 4ca94c17ca T3: collector 骨架——watch→轉檔→git commit/push(design §4)
Node 單檔服務(非 arcrun workflow,跑客戶端機器):chokidar watch 事件驅動、debounce
合併批次 commit、.md passthrough(非 md 格式誠實丟 NotImplemented 待 T4 Markitdown)、
刪檔→target repo 移除對應檔(deprecated 標記留給 ingest workflow,collector 只管檔案鏡像)。

已驗(雲端 sandbox scratch 環境,非真實客戶環境):node --check 全過;起 scratch watch dir
+ scratch git repo + bare remote,實測 add/change/delete 三種事件皆正確偵測、debounce 正確
合併成一次 commit、git push 真的送達 remote(git log 驗證)、非 md 格式正確跳過並警告。

端到端待本機/客戶環境驗(README.md 已列):真實 NAS/VM watch、真實 Gitea remote+憑證、
Gitea push webhook 真觸發 ingest、systemd 常駐穩定性。
2026-07-07 21:08:21 +00:00