Leo
efdd75cbdc
feat(mira/feed): WikiStatusBadge — 顯示貼文 wiki 合成狀態 (leo 2026-05-17 反饋)
...
leo 反饋:「沒有符號顯示是否已建立 wiki,不知道是出錯了還是要等下一批」
新 component WikiStatusBadge 顯示在 PostCard header 來源/時間旁邊:
- ✅ wiki — tags 含 wiki-processed
- ⏳ 處理中 — 貼 < 6 分鐘前(cron 5 分鐘一輪,可能還沒撈到)
- ○ 排隊 — 6-30 分鐘(等下一個 tick)
- ⚠️ 漏了? — > 30 分鐘還沒處理(可能 wiki_synthesis 失敗)
Mira 自己貼文(type=wiki-page from showMira)不顯示 — 它本身就是 wiki。
資料來源純 client-side:mainBlocksList[0].tags_json + doc.created_at。
未來可加 click → 跳對應 wiki page,或 hover 顯示 entity 預覽。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-17 09:53:19 +08:00
Leo
1084e0102a
fix(mira): wikilink autocomplete 5s cache + 開下拉時 refetch
...
leo 反饋:30s TTL 太久,wiki_synthesis 後台跑出新 entity,autocomplete 撈不到。
- TTL 30s → 5s
- WikilinkAutocomplete 在 matchInfo 從 null → 有值時主動 invalidate refetch
- 順手把 yaml-parser 對 FOREACH iterator relation 命名變體(「對每個 X」/「FOREACH X」)放行,graph-builder 早就支援,validate 卻擋掉
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-16 13:37:03 +08:00
Leo
7da1eb6d65
feat(mira): [[entity]] wikilink — 顯式建檔 + autocomplete + render link
...
對應 tasks.md backlog #12 / design.md §3.6.2。leo 反饋:要像 Logseq 那樣
寫 [[X]] 立刻建檔,下次 [[X 自動補完,render 變連結。
helpers:
- parseWikilinks(text) → 抽 [[X]] entity list
- fetchAllEntityNames(apiKey) → 合 index-entry + wiki-page entity 名稱
- getEntityNamesCached → 30s session cache for autocomplete
- ensureEntitiesExist → 新 entity 立刻建 wiki-page placeholder
- tags 含 entity-type:book/url/concept(guessEntityType 推測:《》→ book / http → url)
- source: leo-explicit
- expandWikilinks(text) → render 時把 [[X]] 轉 markdown link to /mira/wiki/wiki-X
UI:
- <WikilinkAutocomplete>:textarea cursor 在 `[[query` 未閉合時,下拉顯示既存
entity(substring filter)+「⊕ 建立 [[query]]」option,↑↓選 / Enter 確認 /
Esc 取消。fixed-position below textarea bottom(cursor tracking 留下輪)
- PostComposer compact + popup 兩個 textarea 都掛 autocomplete
- EditingArea(PostEditor / BlockEditor / ReplyLine / PageReplyComposer 共用)
加 apiKey prop,內部 textarea + popup 都掛 autocomplete
submit hook:
- PostComposer.submit:postBlockId 建好後 ensureEntitiesExist(wikilinks)
- BlockEditor.submitReply / ReplyLine.submitReply 同樣建檔
- 在 wiki_synthesis trigger 前先建,避免 race
render:
- markdown.tsx expandWikilinks 取代 stripLogseqMeta 前處理(兩階段)
- 內部 wiki link(/mira/wiki/...)不開 _target=_blank(不離開頁面)
留下輪:metadata 補完 (作者/出版社) / cursor tracking / PostEditor.save 也建檔
2026-05-16 12:08:28 +08:00
Leo
d6bff9d551
fix(mira): reply @mira indicator + RAG match 寬鬆化
...
leo 試用反饋:
bug:reply 中 @mira 「看起來無效」
- 真正 root cause: trigger 確實 fire,但 thinking indicator 沒亮起 → leo 沒看到回應
以為失敗(其實 mira 後台跑 30s+ 才回)
- 修:MiraTriggerContext 把 thinking trigger 抽成 context callback
PostComposer / PostEditor / BlockEditor / ReplyLine 五個 @mira 觸發點
都呼叫 triggerThinking?.(docPageName) 啟動 5s polling
bug:RAG 抓不到 entity(leo 寫《李飛飛的視界之旅》沒被識別)
- 之前只看 type=index-entry,且嚴格 substring。新建 wiki 還沒 index-entry
時就漏;entity 名稱跟貼文文字稍微不同也漏
- 修 fetchRelevantWikiContext:
- 平行撈 index-entry + wiki-page 兩種,合併 entity set
- 雙向匹配:entity 完整 substring postContent(嚴格) OR
entity 內 3+ 字片段在 postContent 出現(寬鬆,中文友善)
- top 5(從 3 增加),給 mira 更多上下文
2026-05-16 11:43:28 +08:00
Leo
94368ec981
fix(mira): 4 bug — popup 在 edit / 思考 indicator 條件 / RAG / edit @mira
...
leo 試用 P0 後反饋的 4 個問題:
bug #1 : popup 編輯時沒有,更擠
- EditingArea 元件加 ⇱ 放大 button + popup overlay(共用 PostComposer 的 popup pattern)
- 影響:所有 edit / reply 模式現在都有放大編輯
bug #2 : Mira 思考中很久(即使沒 @mira)
- root cause: onAiTriggered(pageName) 在 PostComposer 永遠 fire,會在每篇貼文觸發
thinking indicator UI
- 修:移到 if (hasMiraMention) 分支內。沒 @mira → 不顯示 thinking
- wiki_synthesis 仍每篇都跑(背景靜默)但不顯示 thinking,避免 leo 誤會
bug #3 : Mira reply 不知道有 wiki,無狀態
- 加 fetchRelevantWikiContext: 撈所有 type=index-entry blocks,用 entity 名稱
keyword match against post content,取 top 3 整篇 markdown 餵進 prompt
- prompt 加規則「如果 leo 提到的 entity 你已有 wiki 知識,請主動引用」
- 對應 leo「應該以擁有知識庫的專人來回覆」
bug #4 : edit 時 @mira 沒反應
- PostEditor.save / BlockEditor.saveEdit / ReplyLine.save 三處都加 hasMiraMention 偵測
- 條件:新內容含 @mira 且舊版沒有 → 觸發(避免重複編輯重複 trigger)
placeholder 加 hint「@mira 呼叫 Mira 回覆」。
2026-05-16 11:07:34 +08:00
Leo
8d4c3a3464
feat(mira): P0 河道完善 3 task — Mira 頭像 / @mira 選擇性回覆 / 編輯器 popup
...
對應 tasks.md backlog #5a / #5b / #5c(leo 2026-05-16 P0),design.md §3.6.5。
#5a Mira 發文獨立頭像
- 新 MiraAvatar 元件(紫色漸層圓 + 🤖 emoji)
- isMiraSource() 判斷 post 來源是 leo(km-writer-direct/logseq/mobile/web/tg/rss)
還是 mira(ai-* / mira-* / 其他 test sources)
- PostCard header:showMira ? Mira 頭像 + 名「Mira」 : leo 頭像 + leo 名
#5b @mira 選擇性回覆(撤回每篇 auto-reply)
- 新 hasMiraMention() regex:偵測文字含 @mira(前後可有標點)
- PostComposer / BlockEditor / ReplyLine 三處 submit:只有 @mira 時 triggerAiReply
- triggerAiReply prompt 加 topic 抽取(@mira 後第一段到標點)+ scope hint
- wiki_synthesis trigger 跟 @mira 無關,每篇都跑(KB 副本同步)
- 不擋手動筆記(leo 隨手寫不需要 mira 每篇都回)
#5c 編輯器 popup 放大
- composer 加 ⇱ 放大按鈕 → 切到 fullscreen overlay popup
- popup 含大 textarea + 同 markdown toolbar + 同 submit 邏輯
- ⌘+Enter 發布、Esc 收起、外點 backdrop 收起
- 對應 leo「寫長文 textarea 太小」需求
CSS 加 .mira-avatar-mira / .mira-composer-popup-* 系列。
TS check pass。
2026-05-16 10:35:32 +08:00
Leo
3689f30409
fix(mira): [pageName] h1 顯示 entity 名 + listing dedupe by entity
...
兩個 leo 反饋的 UI bug:
1. wiki/[pageName] 對 index-entry 渲染時,h1 用 block.content(整篇 markdown)
會把整個內容塞進 h1。改:wiki-page 用 content 當 entity 名;其他類型
(index-entry/schema/log)用 page_name 剝 `wiki-` / `index-` prefix。
2. listing「Wiki Pages (21)」累積式設計造成同 entity 多版顯示為多張卡,雜亂。
改:用 useMemo dedupe by entity(content)— 每 entity 一張卡顯示最新版,
標題顯示「N 版累積」當 N>1。原始 21 筆 → 現在約 6-7 個 unique entity。
2026-05-16 09:03:45 +08:00
Leo
64193f2aa5
feat(mira): wiki listing 加 Index Entries section(CC navigation 入口)
...
leo 反饋:原本只看到 wiki-page 列表沒看到 per-entity index-entry,
不知道 CC 從哪入口。新增 section 列出所有 type=index-entry blocks,
標題用 entity 名稱(剝 `index-` prefix),點進去看完整 markdown 摘要。
對應 design.md §3.5.12.4.2 雙層 outliner(v1.6):
- 概覽層:index-entry markdown(含「段落 outline」/「涵蓋面向」等)
- 完整 outliner:wiki page 自身(7B.3g 已實現的樹狀渲染)
部署:arcrun-landing.pages.dev(手動 wrangler pages deploy)。
2026-05-14 18:01:55 +08:00
Leo
bc6360ccfc
feat(arcrun): http_request body_json + error heuristic; mira feed fire-and-forget
...
http_request 零件擴展(registry/components/http_request):
- 加 body_json 物件欄位(內部 JSON.stringify),yaml 端不用手組 JSON 字串
- 新增 JSON 回應的 error 欄位偵測 → 若 body 含 `{"error":"..."}` 則零件回 success=false
解 cascade bug:mira_feed_watcher 用 http_request trigger wiki_synthesis,
原本 4xx response 也被當 success,ON_SUCCESS 鏈會誤觸發
根因架構債:host fn 沒回 HTTP status code(arcrun.md 列為 P1 follow-up)
landing 河道 feed (landing/app/mira/feed/page.tsx):
- 加回 triggerWikiSynthesis fire-and-forget 對 cypher.arcrun.dev/webhooks/named/
wiki_synthesis/trigger 公開觸發 endpoint(arcrun-native,非 mira-specific route)
- 不走 watcher 是因為 cypher-executor 自己 fetch 自己 workers.dev URL = CF 1042
self-fetch 擋
watcher 仍存在當 cron backup,但目前因 self-fetch 1042 不會真正觸發下游
wiki_synthesis(arcrun.md 列為 P1 follow-up)。
2026-05-14 16:06:46 +08:00
Leo
9560485937
feat(cypher): add scheduled() handler — arcrun-native cron 排程基建
...
對應 arcrun.md 三-A P1 #3。
緣由:cron 零件存在但只做 expression validation,沒有真正的排程跑。leo 指出
「邊用 arcrun 邊修,不要 workaround」— 撤回前一輪的 /mira/wiki-from-raw
mira-specific route(違反 mira CLAUDE.md §1.5 一律 arcrun-native),改補
真正的 cron infra。
加入:
- src/lib/cron-match.ts — 5 欄位 cron matcher(* / N / */N / a-b / a,b 組合)
- src/scheduled.ts — handler:掃 KV cron-idx: prefix,比對 controller.scheduledTime
→ executeWebhookGraph 背景跑
- routes/webhooks-named.ts — acr push 時偵測首節點 cron → 存 cron_expr 到 record
+ 額外寫 cron-idx:{api_key}:{name} 輕量索引;DELETE 一併清理
- src/index.ts — export default 改 { fetch, scheduled }
- wrangler.toml — [triggers] crons = ["* * * * *"](每分鐘 tick)
- wrangler.toml — workers_dev = true 供 self-fetch self-trigger 用
- tests/arcrun-test/cron_heartbeat.yaml — 健康監控 workflow(每分鐘 fire + set 節點)
撤回:
- 刪 src/routes/mira.ts(mira-specific workaround)
- types.ts 拿掉 MIRA_CONFIG
- index.ts 拿掉 miraRouter wire
- landing/app/mira/feed/page.tsx 拿掉 triggerWikiSynthesis 呼叫
下一輪:mira_feed_watcher.yaml(mira side),可能要先補 kbdb_get filter +
CALLS_SUBFLOW wire(arcrun.md 列為跟進)。
2026-05-14 14:04:57 +08:00
Leo
660b32eafd
feat(mira): 河道 → wiki 自動化(fire-and-forget 觸發 wiki_synthesis)
...
對應 polaris/mira/.agents/specs/mira-app/tasks.md 7B.3h(簡化版)。
原計畫用 arcrun cron 零件 → cypher-executor scheduled() handler,但發現
cron 零件只是 validator,cypher-executor 還沒實作 scheduled()。為了不擋
「河道書寫 → 自動產 wiki」這條 UX,先做 fire-and-forget 版本:
- 新 cypher-executor route POST /mira/wiki-from-raw
- body: { raw_block_id }
- server 端從 MIRA_CONFIG secret 補 partner key / mira_token / 三個 block IDs
- waitUntil 背景跑 executeWebhookGraph,立刻回 202
- landing 河道 post composer 成功寫 raw 後 fire-and-forget triggerWikiSynthesis()
跟既有 triggerAiReply() 同範式
- types.ts 加 MIRA_CONFIG?: string
部署後需手動:
echo '{"service_api_key":"ak_...","data_api_key":"ak_...","schema_block_id":"...","skill_block_id":"...","entities_block_id":"...","mira_token":"..."}' \
| wrangler secret put MIRA_CONFIG
UX:河道貼一則 → AI reply 30s 內 → wiki 60-90s 內出現在 /mira/wiki。
arcrun.md 記 P1 #3:cypher-executor 加 scheduled() handler,那是真正的
cron 路線,封測前不擋。
2026-05-14 13:50:13 +08:00
Leo
933ae6cb13
feat(mira): 7B.3g wiki UI 樹狀渲染 + 跨 wiki 連結
...
對應 polaris/mira/.agents/specs/mira-app/design.md §5.2 + §3.5.12。
`/mira/wiki/[pageName]`:
- 抓 wiki-page 後平行撈所有 wiki-paragraph / triplet / wiki-page,client-side 用 parent_id filter
(KBDB 沒 parent_id server filter,且 tag filter 還有 KI-3 bug)
- 按 facet 分區渲染:facet 標題 + paragraph markdown + 該段的 triplets
- facet 預設展開(看一篇要看內容)/ triplets 預設折疊(leo Logseq outliner 習慣)
- **triplet A/B 拆字串 「A >> 關係 >> B」**,若 A 或 B 對得上既有 wiki entity → render 成 <Link>
跨 wiki 跳轉,是 Wikipedia-like 體驗的關鍵
- fallback:非 wiki-page block(schema/index/log 等)直接 render content
`/mira/wiki`:列表用 wiki-page 的 content (= entity 名稱) 當標題,不是 page_name slug。
mira.css 加 `.mira-wiki-detail` 不破版 + h2 底線,避免長 cypher 字串撐爆右邊界。
TS check pass。
2026-05-14 13:35:54 +08:00
Leo
519423cb0d
feat(arcrun): mira wiki page with tag filter + accumulated WIP
...
- landing/app/mira/wiki: tag=mira-wiki list now shows all wiki paragraphs
(depends on KBDB tag filter exposed in matrix/kbdb commit, separate repo)
- landing: app/mira hub + feed split + various WIP from prior sessions
- registry/components: claude_api / kbdb_create_block / kbdb_get / km_writer /
platform_crypto / auth_oauth2 contracts + main.go (accumulated)
- .component-builds: pkg-lock updates + index.ts adjustments (WIP)
- .agents/specs/arcrun/frontend-redesign: design notes
- docs/test_credentials, docs/user_requirements/arcrun-landing-page: WIP docs
- cypher-executor: auth-dispatcher / wasi-shim adjustments (WIP)
Includes accumulated work from prior sessions plus the wiki UI tag-filter
update that surfaces the AI-generated wiki paragraphs at /mira/wiki.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-07 16:52:01 +08:00
Leo
4516cdee4b
feat: add landing page + builtins Worker + BETA_TEST guide + README
...
- landing/: Next.js 15 app for arcrun.dev (dashboard, integrations,
API docs, login). Deploys via Cloudflare Pages — CI scan skips
this via pages_build_output_dir marker.
- builtins/: minimal Hono Worker at arcrun-builtins (/init for
one-shot component registry seeding). initComponents logic is
flagged stale in src/index.ts for future rewrite.
- BETA_TEST.md: pre-launch validation playbook.
- README.md: updated to match current arcrun.dev / acr CLI flow.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-04-20 17:52:41 +08:00