35 lines
3.9 KiB
Markdown
35 lines
3.9 KiB
Markdown
|
|
# b04g:facts.rs(279 行)+ find.rs(168 行)+ outputs.rs(113 行)+ doctor.rs(160 行)
|
|||
|
|
|
|||
|
|
## facts.rs(每台電腦的底細)
|
|||
|
|
常數:FRESH_SECS=30*60(快取新鮮度)、WAIT_MS=6_000(探測等待)、MAX_APPS=30(展示上限,超出加「…」)。
|
|||
|
|
- `PROBE`(25)=POSIX sh 一段,每行 `k key=value`:kernel(uname -s)、arch(uname -m)、os(/etc/os-release PRETTY_NAME,否則 sw_vers → 「macOS x.y」)、systemd(/run/systemd/system 有/无, 只在 Linux)、sudo(root/yes/password/none,sudo -n true 探)、net(curl -s -m 4 google generate_204 yes/no)、pkg(依序 apt-get dnf yum pacman apk zypper xbps-install brew winget,先中先報)、desktop($XDG_CURRENT_DESKTOP)、tz($TZ)、wm(pgrep -x:fluxbox xfwm4 gnome-shell plasmashell xfce4-session mate-session cinnamon sway Hyprland)、tools(python3 node npm git docker curl wget jq ffmpeg xdotool wmctrl osascript shortcuts brew 空格串)、apps(Linux: /usr/share/applications/*.desktop 的 Name= 去重 head-60;macOS: ls /Applications 去 .app head-80;都 `|` 分隔)。
|
|||
|
|
- `Facts{42}`(kernel,arch,os,systemd,sudo,net,pkg,desktop,tz,wm,tools,apps);`parse(out)`(60)=k= 行收;apps `|` 切、sort+dedup。
|
|||
|
|
- `describe(name, f, own_box, mac_sandbox)`(88)=一台電腦的人話描述(own_box/mac_sandbox 兩個旗標改變措辭)。
|
|||
|
|
- `for_turn(computers: &[Target], may_use_persons, via)`(202)=回合提示段;`readable(t, may_use_persons)`(163);`probe(t, via)`(174)=经 remote 通道跑 PROBE。
|
|||
|
|
- 快取=一台讀一次、30 分鐘(FRESH_SECS);Target/Place 型別與 remote.rs 互印(b05)。
|
|||
|
|
|
|||
|
|
## find.rs(聊天歷史全文搜尋)
|
|||
|
|
常數:LIMIT=40、BEFORE=12(命中前取 12 條)、SNIPPET=70(字)。
|
|||
|
|
- `Hit{16}`:bot,thread,index,at,mine,file,snippet。
|
|||
|
|
- `search(bots, query)`(64)回 (Vec<Hit>, truncated?)=**只搜 User/Assistant 訊息**(不搜工具結果、不搜摘要——實讀過濾)。
|
|||
|
|
- `stamp(bots)`(85)=(筆數, 最新訊息時間, 開著對話的標記)——搜尋快取:數字或 query 未變就不重搜(程式內註逐字)。
|
|||
|
|
- `Goto{98}`+GOTO_SCROLL_SECS=0.35、GOTO_LIGHT_SECS=1.8(UI 跳到那條的滾動/閃光秒數——b06 用)。
|
|||
|
|
- `snippet()`=按字計(char,非 byte)截,安全邊界。
|
|||
|
|
|
|||
|
|
## outputs.rs(工具結果大檔外置)
|
|||
|
|
常數:TOOL="read_result"、LIFE_DAYS=7、KEEP_MAX_BYTES=20MB、READ_MAX_CHARS=20_000。
|
|||
|
|
- `keep(text)`(28)=`httpd::sha256_hex(text)` 前 12 字 → id `r{id}`;檔 `data/outputs/{id}.txt`(httpd::write_private,私密目录权限);>20MB 截到字邊界(is_char_boundary 回退);已存在同 id 不重寫。
|
|||
|
|
- `note(left_out, id)`(43)=「…(中間省略 {left_out} 個字;完整內容用 read_result 讀:id={id})…」(送進模型的那句話逐字)。
|
|||
|
|
- `read(id, from, chars)`(48)=分段讀、字邊界安全;`prune()`(66)=7 天清。
|
|||
|
|
- `spec()`(75)+`run(args)`(86)=read_result 工具(恆准,b03a ALWAYS 互印)。
|
|||
|
|
|
|||
|
|
## doctor.rs(/doctor 體檢)
|
|||
|
|
- `command(text)`(12)=trim=="/doctor"。
|
|||
|
|
- `Line{18}`{ok,text};`ok()/bad()`(23/27);`report(lines)`(32)=標題+每行 ✓/✗+計數。
|
|||
|
|
- `tailscale_host(url)`(43,.ts.net 主機名)/`tailscale_path(ping)`(49,直連 vs relay 判定)/`ping_tailscale(host)`(59)。
|
|||
|
|
- `sandbox_line()`(71)=沙箱狀態行;`hooks_line()`(85);`free_mb(dir)`(96,磁碟可用);`last_crash(logs)`(103=(時間,行))。
|
|||
|
|
- 檢查清單(呼叫端 app.rs b06 互印):版本、資料夾、網路、同步、模型、連接器、磁碟、崩潰。
|
|||
|
|
|
|||
|
|
## 迁移
|
|||
|
|
facts.rs → **core::facts**(PROBE 字串逐字=探測行為);find.rs → **core::find**;outputs.rs → **core::outputs**;doctor.rs → **core::doctor**(tailscale/sandbox 行依賴 net/platform → 以參數注入,不 mod 直连)。
|